Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./angular": {
"types": "./dist/index.angular.d.ts",
"default": "./dist/index.angular.js"
},
Comment thread
sonukapoor marked this conversation as resolved.
"./preact": {
"types": "./dist/index.preact.d.ts",
"default": "./dist/index.preact.js"
Expand Down Expand Up @@ -68,6 +72,7 @@
"build": "tsdown"
},
"devDependencies": {
"@angular/core": "^21.0.0",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"@formisch/eslint-config": "workspace:*",
"@preact/signals": "^2.2.1",
"@qwik.dev/core": "2.0.0-beta.5",
Expand All @@ -86,6 +91,7 @@
"vue": "^3.5.17"
},
"peerDependencies": {
"@angular/core": ">=17.0.0",
"@qwik.dev/core": "^2.0.0",
"solid-js": "^1.6.0",
"svelte": "^5.29.0",
Expand All @@ -94,6 +100,9 @@
"vue": "^3.3.0"
Comment thread
sonukapoor marked this conversation as resolved.
},
"peerDependenciesMeta": {
"@angular/core": {
"optional": true
},
"@preact/signals": {
"optional": true
},
Expand Down
52 changes: 52 additions & 0 deletions packages/core/src/framework/index.angular.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { signal } from '@angular/core';
import type { Signal } from '../types/signal/index.ts';
import type { Framework } from './index.ts';

export { untracked as untrack } from '@angular/core';

/**
* The current framework being used.
*/
export const framework: Framework = 'angular';

/**
* Creates a unique identifier string.
*
* @returns The unique identifier.
*/
// @__NO_SIDE_EFFECTS__
export function createId(): string {
return Math.random().toString(36).slice(2);
}

/**
* Creates a reactive signal with an initial value.
*
* @param initialValue The initial value.
*
* @returns The created signal.
*/
// @__NO_SIDE_EFFECTS__
export function createSignal<T>(initialValue: T): Signal<T> {
const writableSignal = signal(initialValue);
return {
get value() {
return writableSignal();
},
set value(nextValue: T) {
writableSignal.set(nextValue);
},
};
}

/**
* Batches multiple signal updates into a single update cycle. This is a
* no-op in Angular as batching is handled automatically.
*
* @param fn The function to execute.
*
* @returns The return value of the function.
*/
export function batch<T>(fn: () => T): T {
return fn();
}
1 change: 1 addition & 0 deletions packages/core/src/framework/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Signal } from '../types/index.ts';
* Framework type.
*/
export type Framework =
| 'angular'
| 'preact'
| 'qwik'
| 'react'
Expand Down
4 changes: 3 additions & 1 deletion packages/core/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { join } from 'node:path';
import type { RolldownPluginOption } from 'rolldown';
import { defineConfig, type UserConfig, type UserConfigFn } from 'tsdown';

type Framework = 'preact' | 'qwik' | 'react' | 'solid' | 'svelte' | 'vue';
type Framework = 'angular' | 'preact' | 'qwik' | 'react' | 'solid' | 'svelte' | 'vue';

/**
* Rolldown plugin to rewrite framework-specific imports.
Expand Down Expand Up @@ -85,6 +85,7 @@ function defineFrameworkConfig(
return defineConfig({
entry: ['./src/index.ts'],
external: [
'@angular/core',
'@preact/signals',
'@qwik.dev/core',
'solid-js',
Expand Down Expand Up @@ -115,6 +116,7 @@ function defineFrameworkConfig(

const config: (UserConfig | UserConfigFn)[] = [
defineFrameworkConfig(null),
defineFrameworkConfig('angular'),
defineFrameworkConfig('preact'),
defineFrameworkConfig('qwik'),
defineFrameworkConfig('react'),
Expand Down
21 changes: 21 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading