@praxisjs/shared 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/children.d.ts +1 -2
- package/dist/children.d.ts.map +1 -1
- package/dist/children.js.map +1 -1
- package/dist/component.d.ts +3 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/component.js +4 -0
- package/dist/component.js.map +1 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +7 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +1 -0
- package/dist/signal.d.ts +3 -3
- package/dist/signal.d.ts.map +1 -1
- package/dist/signal.js +5 -2
- package/dist/signal.js.map +1 -1
- package/dist/types/children.d.ts +12 -19
- package/dist/types/children.d.ts.map +1 -1
- package/dist/types/signal.d.ts +6 -4
- package/dist/types/signal.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/children.ts +1 -6
- package/src/component.ts +5 -0
- package/src/index.ts +1 -11
- package/src/internal.ts +10 -0
- package/src/signal.ts +7 -6
- package/src/types/children.ts +22 -31
- package/src/types/signal.ts +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @praxisjs/shared
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bb0d4f8: **Refactor decorator system and component architecture across PraxisJS packages**
|
|
8
|
+
|
|
9
|
+
- Replaced legacy decorator signatures (`constructor`, `target`, `propertyKey`, method descriptor) with the standard TC39 decorator context API (`ClassDecoratorContext`, `ClassFieldDecoratorContext`, `ClassMethodDecoratorContext`) across `@praxisjs/decorators`, `@praxisjs/store`, `@praxisjs/concurrent`, `@praxisjs/router`, `@praxisjs/motion`, `@praxisjs/di`, and `@praxisjs/fsm`.
|
|
10
|
+
- Introduced `StatefulComponent` and `StatelessComponent` as the new base classes, replacing the deprecated `BaseComponent`/`Function Component` pattern, across `@praxisjs/core`, `@praxisjs/runtime`, `@praxisjs/devtools`, and templates.
|
|
11
|
+
- Implemented core rendering functionality in `@praxisjs/runtime` (`mountChildren`, `mountComponent`, reactive scope management) and removed the deprecated `renderer.ts`.
|
|
12
|
+
- Refactored `@praxisjs/jsx` to delegate rendering to `@praxisjs/runtime` and improved type safety with `flattenChildren` and `isComponent` utilities.
|
|
13
|
+
- Updated internal module structure with new `internal` exports in `package.json` files for shared utilities and types.
|
|
14
|
+
- Removed `experimentalDecorators`/`emitDecoratorMetadata` from `tsconfig.json` in favor of native decorator support.
|
|
15
|
+
|
|
3
16
|
## 0.1.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/children.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const flattenChildren: (children: ChildrenInternal | ChildrenInternal[], out?: ChildrenInternal[]) => ChildrenInternal[];
|
|
1
|
+
export declare const flattenChildren: (children: unknown, out?: unknown[]) => unknown[];
|
|
3
2
|
//# sourceMappingURL=children.d.ts.map
|
package/dist/children.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../src/children.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../src/children.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,UAAU,OAAO,EAAE,MAAK,OAAO,EAAO,KAAG,OAAO,EAS/E,CAAC"}
|
package/dist/children.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"children.js","sourceRoot":"","sources":["../src/children.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"children.js","sourceRoot":"","sources":["../src/children.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAiB,EAAE,MAAiB,EAAE,EAAa,EAAE;IACnF,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,eAAO,MAAM,WAAW,GAAI,QAAQ,OAAO,KAAG,MAAM,IAAI,oBAEvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAe,EAAkC,EAAE;IAC7E,OAAO,OAAO,MAAM,KAAK,UAAU,IAAI,eAAe,IAAI,MAAM,CAAC;AACnE,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { Children, ComponentElement } from "./types/children";
|
|
2
2
|
export type { Computed, Signal } from "./types/signal";
|
|
3
|
-
export { flattenChildren } from "./children";
|
|
4
|
-
export type { VNode, Children, ChildrenInternal, FunctionComponent, ComponentConstructor, ComponentInstance, Component, } from "./types/children";
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { isSignal, isComputed, isReactive } from "./signal";
|
|
2
|
+
export { flattenChildren } from "./children";
|
|
3
|
+
export type { ComponentConstructor, ComponentInstance, Cleanup, } from "./types/children";
|
|
4
|
+
export type { BaseReactive } from "./types/signal";
|
|
5
|
+
export { isComponent } from "./component";
|
|
6
|
+
export type { ReactiveChildren } from "./types/children";
|
|
7
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,OAAO,GACR,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAO7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/signal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
1
|
+
export declare function isSignal(source: unknown): boolean;
|
|
2
|
+
export declare function isComputed(source: unknown): source is Function & Record<"__isComputed", unknown>;
|
|
3
|
+
export declare function isReactive(source: unknown): boolean;
|
|
4
4
|
//# sourceMappingURL=signal.d.ts.map
|
package/dist/signal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEjD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,wDAEzC;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,WAEzC"}
|
package/dist/signal.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export function isSignal(source) {
|
|
2
|
-
return typeof source
|
|
2
|
+
return typeof source === "function" && "__isSignal" in source;
|
|
3
3
|
}
|
|
4
4
|
export function isComputed(source) {
|
|
5
|
-
return typeof source === "function" && "
|
|
5
|
+
return typeof source === "function" && "__isComputed" in source;
|
|
6
|
+
}
|
|
7
|
+
export function isReactive(source) {
|
|
8
|
+
return isComputed(source) || isSignal(source);
|
|
6
9
|
}
|
|
7
10
|
//# sourceMappingURL=signal.js.map
|
package/dist/signal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,QAAQ,CAAC,MAAe;IACtC,OAAO,OAAO,MAAM,KAAK,UAAU,IAAI,YAAY,IAAI,MAAM,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAe;IACxC,OAAO,OAAO,MAAM,KAAK,UAAU,IAAI,cAAc,IAAI,MAAM,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAe;IACxC,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/types/children.d.ts
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
+
import type { Computed, Signal } from "./signal";
|
|
1
2
|
export type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
4
|
-
export type Children =
|
|
5
|
-
export type
|
|
6
|
-
export interface VNode {
|
|
7
|
-
type: string | Component;
|
|
8
|
-
props: Record<string, unknown>;
|
|
9
|
-
children: ChildrenInternal[];
|
|
10
|
-
key?: string | number;
|
|
11
|
-
}
|
|
12
|
-
export type FunctionComponent<P = Record<string, unknown>> = (props: P & {
|
|
13
|
-
children?: Children;
|
|
14
|
-
}) => VNode | null;
|
|
3
|
+
export type RenderedValue = Primitive | Signal<unknown> | Computed<unknown> | Node | Node[];
|
|
4
|
+
export type ReactiveChildren = () => RenderedValue | RenderedValue[] | ReactiveChildren[];
|
|
5
|
+
export type Children = Primitive | Node | ReactiveChildren | Children[];
|
|
6
|
+
export type Cleanup = () => void;
|
|
15
7
|
export interface ComponentConstructor<P = Record<string, unknown>> {
|
|
16
8
|
new (props: P): ComponentInstance;
|
|
17
|
-
|
|
9
|
+
__isComponent: true;
|
|
10
|
+
__isStateless: boolean;
|
|
11
|
+
name: string;
|
|
18
12
|
}
|
|
13
|
+
export type ComponentElement = new (...args: any[]) => ComponentInstance;
|
|
19
14
|
export interface ComponentInstance {
|
|
20
15
|
_mounted: boolean;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
_isMemorized?: boolean;
|
|
24
|
-
_arePropsEqual?: (prevProps: Record<string, unknown>, nextProps: Record<string, unknown>) => boolean;
|
|
16
|
+
_anchor?: Comment;
|
|
17
|
+
_stateDirty?: boolean;
|
|
25
18
|
_setProps(p: Record<string, unknown>): void;
|
|
26
|
-
render():
|
|
19
|
+
render(): Node | Node[] | null;
|
|
27
20
|
onBeforeMount?(): void;
|
|
28
21
|
onMount?(): void;
|
|
29
22
|
onUnmount?(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../../src/types/children.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,IAAI,GACJ,SAAS,CAAC;AAEd,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../../src/types/children.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,IAAI,GACJ,SAAS,CAAC;AAEd,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,MAAM,CAAC,OAAO,CAAC,GACf,QAAQ,CAAC,OAAO,CAAC,GACjB,IAAI,GACJ,IAAI,EAAE,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAC3B,aAAa,GACb,aAAa,EAAE,GACf,gBAAgB,EAAE,CAAC;AAEvB,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,GAAG,gBAAgB,GAAG,QAAQ,EAAE,CAAC;AAExE,MAAM,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC;AAEjC,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,KAAK,KAAK,EAAE,CAAC,GAAG,iBAAiB,CAAC;IAClC,aAAa,EAAE,IAAI,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAGD,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,iBAAiB,CAAC;AAEzE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5C,MAAM,IAAI,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IAC/B,aAAa,CAAC,IAAI,IAAI,CAAC;IACvB,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB,SAAS,CAAC,IAAI,IAAI,CAAC;IACnB,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;CAC1B"}
|
package/dist/types/signal.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface BaseReactive<T> {
|
|
2
2
|
(): T;
|
|
3
3
|
subscribe(effect: (value: T) => void): () => void;
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
6
|
-
|
|
5
|
+
export interface Computed<T> extends BaseReactive<T> {
|
|
6
|
+
__isComputed: true;
|
|
7
|
+
}
|
|
8
|
+
export interface Signal<T> extends BaseReactive<T> {
|
|
7
9
|
set(value: T): void;
|
|
8
10
|
update(updater: (prev: T) => T): void;
|
|
9
|
-
|
|
11
|
+
__isSignal: true;
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=signal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/types/signal.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/types/signal.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,IAAI,CAAC,CAAC;IACN,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;IAClD,YAAY,EAAE,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,MAAM,CAAC,CAAC,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;IAChD,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACtC,UAAU,EAAE,IAAI,CAAC;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@praxisjs/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./internal": {
|
|
13
|
+
"import": "./dist/internal.js",
|
|
14
|
+
"types": "./dist/internal.d.ts"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"devDependencies": {
|
package/src/children.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const flattenChildren = (
|
|
4
|
-
children: ChildrenInternal | ChildrenInternal[],
|
|
5
|
-
out: ChildrenInternal[] = [],
|
|
6
|
-
) => {
|
|
1
|
+
export const flattenChildren = (children: unknown, out: unknown[] = []): unknown[] => {
|
|
7
2
|
if (Array.isArray(children)) {
|
|
8
3
|
for (const child of children) {
|
|
9
4
|
flattenChildren(child, out);
|
package/src/component.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { Children, ComponentElement } from "./types/children";
|
|
2
2
|
export type { Computed, Signal } from "./types/signal";
|
|
3
|
-
export { flattenChildren } from "./children";
|
|
4
|
-
export type {
|
|
5
|
-
VNode,
|
|
6
|
-
Children,
|
|
7
|
-
ChildrenInternal,
|
|
8
|
-
FunctionComponent,
|
|
9
|
-
ComponentConstructor,
|
|
10
|
-
ComponentInstance,
|
|
11
|
-
Component,
|
|
12
|
-
} from "./types/children";
|
package/src/internal.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { isSignal, isComputed, isReactive } from "./signal";
|
|
2
|
+
export { flattenChildren } from "./children";
|
|
3
|
+
export type {
|
|
4
|
+
ComponentConstructor,
|
|
5
|
+
ComponentInstance,
|
|
6
|
+
Cleanup,
|
|
7
|
+
} from "./types/children";
|
|
8
|
+
export type { BaseReactive } from "./types/signal";
|
|
9
|
+
export { isComponent } from "./component";
|
|
10
|
+
export type { ReactiveChildren } from "./types/children";
|
package/src/signal.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { Computed, Signal } from "./types/signal";
|
|
2
1
|
|
|
3
|
-
export function isSignal
|
|
4
|
-
source
|
|
5
|
-
): boolean {
|
|
6
|
-
return typeof (source as Signal<T>).set === "function";
|
|
2
|
+
export function isSignal(source: unknown): boolean {
|
|
3
|
+
return typeof source === "function" && "__isSignal" in source;
|
|
7
4
|
}
|
|
8
5
|
|
|
9
6
|
export function isComputed(source: unknown) {
|
|
10
|
-
return typeof source === "function" && "
|
|
7
|
+
return typeof source === "function" && "__isComputed" in source;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function isReactive(source: unknown) {
|
|
11
|
+
return isComputed(source) || isSignal(source);
|
|
11
12
|
}
|
package/src/types/children.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Computed, Signal } from "./signal";
|
|
2
|
+
|
|
1
3
|
export type Primitive =
|
|
2
4
|
| string
|
|
3
5
|
| number
|
|
@@ -7,49 +9,38 @@ export type Primitive =
|
|
|
7
9
|
| null
|
|
8
10
|
| undefined;
|
|
9
11
|
|
|
10
|
-
export type
|
|
11
|
-
| Primitive
|
|
12
|
-
| VNode
|
|
13
|
-
| VNode[]
|
|
14
|
-
| ReactiveChildren[];
|
|
15
|
-
|
|
16
|
-
export type ChildrenInternal =
|
|
12
|
+
export type RenderedValue =
|
|
17
13
|
| Primitive
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
14
|
+
| Signal<unknown>
|
|
15
|
+
| Computed<unknown>
|
|
16
|
+
| Node
|
|
17
|
+
| Node[];
|
|
21
18
|
|
|
22
|
-
export type
|
|
19
|
+
export type ReactiveChildren = () =>
|
|
20
|
+
| RenderedValue
|
|
21
|
+
| RenderedValue[]
|
|
22
|
+
| ReactiveChildren[];
|
|
23
23
|
|
|
24
|
-
export type
|
|
24
|
+
export type Children = Primitive | Node | ReactiveChildren | Children[];
|
|
25
25
|
|
|
26
|
-
export
|
|
27
|
-
type: string | Component;
|
|
28
|
-
props: Record<string, unknown>;
|
|
29
|
-
children: ChildrenInternal[];
|
|
30
|
-
key?: string | number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type FunctionComponent<P = Record<string, unknown>> = (
|
|
34
|
-
props: P & { children?: Children },
|
|
35
|
-
) => VNode | null;
|
|
26
|
+
export type Cleanup = () => void;
|
|
36
27
|
|
|
37
28
|
export interface ComponentConstructor<P = Record<string, unknown>> {
|
|
38
29
|
new (props: P): ComponentInstance;
|
|
39
|
-
|
|
30
|
+
__isComponent: true;
|
|
31
|
+
__isStateless: boolean;
|
|
32
|
+
name: string;
|
|
40
33
|
}
|
|
41
34
|
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
export type ComponentElement = new (...args: any[]) => ComponentInstance;
|
|
37
|
+
|
|
42
38
|
export interface ComponentInstance {
|
|
43
39
|
_mounted: boolean;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
_isMemorized?: boolean;
|
|
47
|
-
_arePropsEqual?: (
|
|
48
|
-
prevProps: Record<string, unknown>,
|
|
49
|
-
nextProps: Record<string, unknown>,
|
|
50
|
-
) => boolean;
|
|
40
|
+
_anchor?: Comment;
|
|
41
|
+
_stateDirty?: boolean;
|
|
51
42
|
_setProps(p: Record<string, unknown>): void;
|
|
52
|
-
render():
|
|
43
|
+
render(): Node | Node[] | null;
|
|
53
44
|
onBeforeMount?(): void;
|
|
54
45
|
onMount?(): void;
|
|
55
46
|
onUnmount?(): void;
|
package/src/types/signal.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface BaseReactive<T> {
|
|
2
2
|
(): T;
|
|
3
3
|
subscribe(effect: (value: T) => void): () => void;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
export interface
|
|
7
|
-
|
|
6
|
+
export interface Computed<T> extends BaseReactive<T> {
|
|
7
|
+
__isComputed: true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Signal<T> extends BaseReactive<T> {
|
|
8
11
|
set(value: T): void;
|
|
9
12
|
update(updater: (prev: T) => T): void;
|
|
10
|
-
|
|
13
|
+
__isSignal: true;
|
|
11
14
|
}
|