@praxisjs/core 0.2.0 → 0.4.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 +28 -0
- package/dist/component/base.d.ts +8 -17
- package/dist/component/base.d.ts.map +1 -1
- package/dist/component/base.js +7 -23
- package/dist/component/base.js.map +1 -1
- package/dist/component/index.d.ts +3 -2
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/index.js +3 -2
- package/dist/component/index.js.map +1 -1
- package/dist/component/stateful.d.ts +9 -0
- package/dist/component/stateful.d.ts.map +1 -0
- package/dist/component/stateful.js +14 -0
- package/dist/component/stateful.js.map +1 -0
- package/dist/component/stateless.d.ts +5 -0
- package/dist/component/stateless.d.ts.map +1 -0
- package/dist/component/stateless.js +10 -0
- package/dist/component/stateless.js.map +1 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +1 -0
- package/dist/reactive/history.d.ts +2 -2
- package/dist/reactive/history.d.ts.map +1 -1
- package/dist/reactive/history.js +3 -4
- package/dist/reactive/history.js.map +1 -1
- package/dist/reactive/reactive.d.ts +3 -3
- package/dist/reactive/reactive.d.ts.map +1 -1
- package/dist/reactive/reactive.js +3 -5
- package/dist/reactive/reactive.js.map +1 -1
- package/dist/signal/computed.d.ts.map +1 -1
- package/dist/signal/computed.js +2 -2
- package/dist/signal/computed.js.map +1 -1
- package/dist/signal/peek.d.ts +1 -1
- package/dist/signal/peek.d.ts.map +1 -1
- package/dist/signal/peek.js.map +1 -1
- package/dist/signal/persisted.d.ts.map +1 -1
- package/dist/signal/persisted.js +1 -0
- package/dist/signal/persisted.js.map +1 -1
- package/dist/signal/signal.js +1 -0
- package/dist/signal/signal.js.map +1 -1
- package/package.json +6 -3
- package/src/component/base.ts +9 -36
- package/src/component/index.ts +3 -12
- package/src/component/stateful.ts +18 -0
- package/src/component/stateless.ts +12 -0
- package/src/index.ts +1 -28
- package/src/internal.ts +17 -0
- package/src/reactive/history.ts +5 -6
- package/src/reactive/reactive.ts +6 -11
- package/src/signal/computed.ts +2 -3
- package/src/signal/peek.ts +1 -1
- package/src/signal/persisted.ts +1 -0
- package/src/signal/signal.ts +1 -1
- package/dist/component/lifecycle.d.ts +0 -15
- package/dist/component/lifecycle.d.ts.map +0 -1
- package/dist/component/lifecycle.js +0 -58
- package/dist/component/lifecycle.js.map +0 -1
- package/src/component/lifecycle.ts +0 -82
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @praxisjs/core
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f52354d: Add `@Computed()` decorator to `@praxisjs/decorators` for declaring read-only reactive getters backed by a cached `computed()` signal. The getter recomputes automatically when any `@State` or `@Prop` dependency changes, and the result is cached until a dependency is invalidated — unlike a plain getter which recalculates on every read.
|
|
8
|
+
|
|
9
|
+
`@Debug()` in `@praxisjs/devtools` now supports `@Computed()` getters (`ClassGetterDecoratorContext`) in addition to fields and methods, allowing computed values to be tracked and historized in the devtools panel.
|
|
10
|
+
|
|
11
|
+
Also fixes a bug in the `computed()` primitive where an erroneous `track(recompute)` call caused premature dependency tracking on signal creation.
|
|
12
|
+
|
|
13
|
+
## 0.3.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- bb0d4f8: **Refactor decorator system and component architecture across PraxisJS packages**
|
|
18
|
+
|
|
19
|
+
- 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`.
|
|
20
|
+
- 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.
|
|
21
|
+
- Implemented core rendering functionality in `@praxisjs/runtime` (`mountChildren`, `mountComponent`, reactive scope management) and removed the deprecated `renderer.ts`.
|
|
22
|
+
- Refactored `@praxisjs/jsx` to delegate rendering to `@praxisjs/runtime` and improved type safety with `flattenChildren` and `isComponent` utilities.
|
|
23
|
+
- Updated internal module structure with new `internal` exports in `package.json` files for shared utilities and types.
|
|
24
|
+
- Removed `experimentalDecorators`/`emitDecoratorMetadata` from `tsconfig.json` in favor of native decorator support.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [bb0d4f8]
|
|
29
|
+
- @praxisjs/shared@0.2.0
|
|
30
|
+
|
|
3
31
|
## 0.2.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/dist/component/base.d.ts
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export declare abstract class BaseComponent {
|
|
1
|
+
export declare abstract class RootComponent<T extends object = Record<string, never>> {
|
|
3
2
|
/** Props passed by the parent — filled by the renderer when instantiating/updating. */
|
|
4
|
-
readonly _rawProps:
|
|
5
|
-
/**
|
|
6
|
-
readonly _defaults: Record<string, unknown>;
|
|
7
|
-
/** @internal — holds the previous props snapshot so `onAfterUpdate` can compare against them after the renderer commits to the DOM */
|
|
8
|
-
_pendingPreviusProps: Record<string, unknown> | null;
|
|
9
|
-
/** @internal — becomes `true` after `onMount` fires; the renderer uses this flag to skip the initial effect run */
|
|
3
|
+
readonly _rawProps: T;
|
|
4
|
+
/** @internal — becomes `true` after `onMount` fires */
|
|
10
5
|
_mounted: boolean;
|
|
11
|
-
/** @internal —
|
|
12
|
-
|
|
13
|
-
constructor(props?:
|
|
14
|
-
|
|
15
|
-
get props(): Record<string, unknown>;
|
|
16
|
-
abstract render(): VNode | null;
|
|
6
|
+
/** @internal — end comment anchor set by the runtime; used by decorators to locate the parent element */
|
|
7
|
+
_anchor?: Comment;
|
|
8
|
+
constructor(props?: T);
|
|
9
|
+
get props(): T;
|
|
17
10
|
onBeforeMount?(): void;
|
|
18
11
|
onMount?(): void;
|
|
19
12
|
onUnmount?(): void;
|
|
20
|
-
onBeforeUpdate?(prevProps: Record<string, unknown>): void;
|
|
21
|
-
onUpdate?(prevProps: Record<string, unknown>): void;
|
|
22
|
-
onAfterUpdate?(prevProps: Record<string, unknown>): void;
|
|
23
13
|
onError?(error: Error): void;
|
|
14
|
+
abstract render(): Node | Node[] | null;
|
|
24
15
|
}
|
|
25
16
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/component/base.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/component/base.ts"],"names":[],"mappings":"AAAA,8BAAsB,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAC1E,uFAAuF;IACvF,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAW;IAEhC,uDAAuD;IACvD,QAAQ,UAAS;IAEjB,yGAAyG;IACzG,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEN,KAAK,GAAE,CAAW;IAI9B,IAAI,KAAK,IAAI,CAAC,CAEb;IAED,aAAa,CAAC,IAAI,IAAI;IACtB,OAAO,CAAC,IAAI,IAAI;IAChB,SAAS,CAAC,IAAI,IAAI;IAClB,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAE5B,QAAQ,CAAC,MAAM,IAAI,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI;CACxC"}
|
package/dist/component/base.js
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class RootComponent {
|
|
2
|
+
/** Props passed by the parent — filled by the renderer when instantiating/updating. */
|
|
3
|
+
_rawProps = {};
|
|
4
|
+
/** @internal — becomes `true` after `onMount` fires */
|
|
5
|
+
_mounted = false;
|
|
6
|
+
/** @internal — end comment anchor set by the runtime; used by decorators to locate the parent element */
|
|
7
|
+
_anchor;
|
|
2
8
|
constructor(props = {}) {
|
|
3
|
-
/** Props passed by the parent — filled by the renderer when instantiating/updating. */
|
|
4
|
-
this._rawProps = {};
|
|
5
|
-
/** Default values declared in the class. */
|
|
6
|
-
this._defaults = {};
|
|
7
|
-
/** @internal — holds the previous props snapshot so `onAfterUpdate` can compare against them after the renderer commits to the DOM */
|
|
8
|
-
this._pendingPreviusProps = null;
|
|
9
|
-
/** @internal — becomes `true` after `onMount` fires; the renderer uses this flag to skip the initial effect run */
|
|
10
|
-
this._mounted = false;
|
|
11
|
-
/** @internal — set to true by @State on any write; cleared by renderer after each re-render */
|
|
12
|
-
this._stateDirty = false;
|
|
13
9
|
Object.assign(this._rawProps, props);
|
|
14
10
|
}
|
|
15
|
-
_setProps(props) {
|
|
16
|
-
const previous = { ...this._rawProps };
|
|
17
|
-
this.onBeforeUpdate?.(previous);
|
|
18
|
-
Object.keys(this._rawProps).forEach((k) => { Reflect.deleteProperty(this._rawProps, k); });
|
|
19
|
-
Object.assign(this._rawProps, props);
|
|
20
|
-
this._pendingPreviusProps = previous;
|
|
21
|
-
this.onUpdate?.(previous);
|
|
22
|
-
queueMicrotask(() => {
|
|
23
|
-
this.onAfterUpdate?.(previous);
|
|
24
|
-
this._pendingPreviusProps = null;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
11
|
get props() {
|
|
28
12
|
return this._rawProps;
|
|
29
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/component/base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/component/base.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,aAAa;IACjC,uFAAuF;IAC9E,SAAS,GAAM,EAAO,CAAC;IAEhC,uDAAuD;IACvD,QAAQ,GAAG,KAAK,CAAC;IAEjB,yGAAyG;IACzG,OAAO,CAAW;IAElB,YAAY,QAAW,EAAO;QAC5B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CAQF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { StatefulComponent } from "./stateful";
|
|
2
|
+
export { StatelessComponent } from "./stateless";
|
|
3
|
+
export { RootComponent } from "./base";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC"}
|
package/dist/component/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { StatefulComponent } from "./stateful";
|
|
2
|
+
export { StatelessComponent } from "./stateless";
|
|
3
|
+
export { RootComponent } from "./base";
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RootComponent } from "./base";
|
|
2
|
+
export declare abstract class StatefulComponent extends RootComponent<Record<string, unknown>> {
|
|
3
|
+
/** Default values declared in the class. */
|
|
4
|
+
readonly _defaults: Record<string, unknown>;
|
|
5
|
+
/** @internal — set to true by @State on any write; cleared by renderer after each re-render */
|
|
6
|
+
_stateDirty: boolean;
|
|
7
|
+
_setProps(props: Record<string, unknown>): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=stateful.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateful.d.ts","sourceRoot":"","sources":["../../src/component/stateful.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,8BAAsB,iBAAkB,SAAQ,aAAa,CAC3D,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACxB;IACC,4CAA4C;IAC5C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IAEjD,+FAA+F;IAC/F,WAAW,UAAS;IAEpB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAMzC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RootComponent } from "./base";
|
|
2
|
+
export class StatefulComponent extends RootComponent {
|
|
3
|
+
/** Default values declared in the class. */
|
|
4
|
+
_defaults = {};
|
|
5
|
+
/** @internal — set to true by @State on any write; cleared by renderer after each re-render */
|
|
6
|
+
_stateDirty = false;
|
|
7
|
+
_setProps(props) {
|
|
8
|
+
Object.keys(this._rawProps).forEach((k) => {
|
|
9
|
+
Reflect.deleteProperty(this._rawProps, k);
|
|
10
|
+
});
|
|
11
|
+
Object.assign(this._rawProps, props);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=stateful.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateful.js","sourceRoot":"","sources":["../../src/component/stateful.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,OAAgB,iBAAkB,SAAQ,aAE/C;IACC,4CAA4C;IACnC,SAAS,GAA4B,EAAE,CAAC;IAEjD,+FAA+F;IAC/F,WAAW,GAAG,KAAK,CAAC;IAEpB,SAAS,CAAC,KAA8B;QACtC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACxC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateless.d.ts","sourceRoot":"","sources":["../../src/component/stateless.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,8BAAsB,kBAAkB,CACtC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CACxC,SAAQ,aAAa,CAAC,CAAC,CAAC;IACxB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAMzC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RootComponent } from "./base";
|
|
2
|
+
export class StatelessComponent extends RootComponent {
|
|
3
|
+
_setProps(props) {
|
|
4
|
+
Object.keys(this._rawProps).forEach((k) => {
|
|
5
|
+
Reflect.deleteProperty(this._rawProps, k);
|
|
6
|
+
});
|
|
7
|
+
Object.assign(this._rawProps, props);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=stateless.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateless.js","sourceRoot":"","sources":["../../src/component/stateless.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,OAAgB,kBAEpB,SAAQ,aAAgB;IACxB,SAAS,CAAC,KAA8B;QACtC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACxC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
+
export { StatefulComponent, StatelessComponent } from "./component";
|
|
1
2
|
export { resource, createResource, type ResourceStatus, type Resource, type ResourceOptions, } from "./async/resource";
|
|
2
|
-
export { debounced, until, when, history, type HistoryElement, } from "./reactive";
|
|
3
|
-
export { signal, persistedSignal, peek, computed, batch, effect, type PersistedSignalOptions, } from "./signal";
|
|
4
|
-
export { BaseComponent, VALID_LIFECYCLE_HOOK_SIGNATURES, onBeforeMount, onError, onMount, onUnmount, createFunctionalContext, setFunctionalContext, type FunctionalContext, type LifeCycleHook, } from "./component";
|
|
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,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,QAAQ,EACR,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
+
export { StatefulComponent, StatelessComponent } from "./component";
|
|
1
2
|
export { resource, createResource, } from "./async/resource";
|
|
2
|
-
export { debounced, until, when, history, } from "./reactive";
|
|
3
|
-
export { signal, persistedSignal, peek, computed, batch, effect, } from "./signal";
|
|
4
|
-
export { BaseComponent, VALID_LIFECYCLE_HOOK_SIGNATURES, onBeforeMount, onError, onMount, onUnmount, createFunctionalContext, setFunctionalContext, } from "./component";
|
|
5
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,QAAQ,EACR,cAAc,GAIf,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { debounced, until, when, history, type HistoryElement, } from "./reactive";
|
|
2
|
+
export { signal, persistedSignal, peek, computed, batch, effect, type PersistedSignalOptions, } from "./signal";
|
|
3
|
+
export { RootComponent } from "./component";
|
|
4
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,IAAI,EACJ,OAAO,EACP,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,eAAe,EACf,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,sBAAsB,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,IAAI,EACJ,OAAO,GAER,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,eAAe,EACf,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,MAAM,GAEP,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Computed, Signal } from "@praxisjs/shared";
|
|
2
2
|
export interface HistoryElement<T> {
|
|
3
3
|
readonly values: Computed<T[]>;
|
|
4
4
|
readonly current: Computed<T>;
|
|
@@ -8,5 +8,5 @@ export interface HistoryElement<T> {
|
|
|
8
8
|
redo(): void;
|
|
9
9
|
clear(): void;
|
|
10
10
|
}
|
|
11
|
-
export declare function history<T>(source: Signal<T> | Computed<T
|
|
11
|
+
export declare function history<T>(source: Signal<T> | Computed<T>, limit?: number): HistoryElement<T>;
|
|
12
12
|
//# sourceMappingURL=history.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/reactive/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/reactive/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAMzD,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,IAAI,IAAI,CAAC;IACb,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,OAAO,CAAC,CAAC,EACvB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,EAC/B,KAAK,SAAK,GACT,cAAc,CAAC,CAAC,CAAC,CAmEnB"}
|
package/dist/reactive/history.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { isSignal } from "@praxisjs/shared";
|
|
1
|
+
import { isSignal } from "@praxisjs/shared/internal";
|
|
2
2
|
import { computed, signal, peek } from "../signal";
|
|
3
3
|
import { effect } from "../signal/effect";
|
|
4
4
|
export function history(source, limit = 50) {
|
|
5
|
-
const read = typeof source === "function" ? source : source;
|
|
6
5
|
const _past = signal([]);
|
|
7
6
|
const _future = signal([]);
|
|
8
|
-
const _current = signal(
|
|
7
|
+
const _current = signal(source());
|
|
9
8
|
let _ignoreNext = false;
|
|
10
9
|
let _initialized = false;
|
|
11
10
|
effect(() => {
|
|
12
|
-
const value =
|
|
11
|
+
const value = source();
|
|
13
12
|
if (!_initialized) {
|
|
14
13
|
_initialized = true;
|
|
15
14
|
_current.set(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/reactive/history.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/reactive/history.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAY1C,MAAM,UAAU,OAAO,CACrB,MAA+B,EAC/B,KAAK,GAAG,EAAE;IAEV,MAAM,KAAK,GAAG,MAAM,CAAM,EAAE,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAM,EAAE,CAAC,CAAC;IAChC,MAAM,QAAQ,GAAG,MAAM,CAAI,MAAM,EAAE,CAAC,CAAC;IAErC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,MAAM,CAAC,GAAG,EAAE;QACV,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;QAEvB,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,YAAY,GAAG,IAAI,CAAC;YACpB,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO;QACT,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YAChB,WAAW,GAAG,KAAK,CAAC;YACpB,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACvC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACxE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CAAC,CAAC,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;YACpC,WAAW,GAAG,IAAI,CAAC;YACnB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAEnB,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACpB,MAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,KAAK;YACH,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Computed, Signal } from "@praxisjs/shared";
|
|
2
|
-
export declare function when<T>(source: Signal<T> | Computed<T
|
|
3
|
-
export declare function until<T>(source: Signal<T> | Computed<T>
|
|
4
|
-
export declare function debounced<T>(source: Signal<T> | Computed<T
|
|
2
|
+
export declare function when<T>(source: Signal<T> | Computed<T>, fn: (value: NonNullable<T>) => void): () => void;
|
|
3
|
+
export declare function until<T>(source: Signal<T> | Computed<T>): Promise<NonNullable<T>>;
|
|
4
|
+
export declare function debounced<T>(source: Signal<T> | Computed<T>, ms: number): Signal<T>;
|
|
5
5
|
//# sourceMappingURL=reactive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../../src/reactive/reactive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAKzD,wBAAgB,IAAI,CAAC,CAAC,EACpB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../../src/reactive/reactive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAKzD,wBAAgB,IAAI,CAAC,CAAC,EACpB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,EAC/B,EAAE,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,cAcpC;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,2BAQvD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,aAcvE"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { signal } from "../signal";
|
|
2
2
|
import { effect } from "../signal/effect";
|
|
3
3
|
export function when(source, fn) {
|
|
4
|
-
const read = typeof source === "function" ? source : source;
|
|
5
4
|
let disposed = false;
|
|
6
5
|
const stop = effect(() => {
|
|
7
|
-
const value =
|
|
6
|
+
const value = source();
|
|
8
7
|
if (!value || disposed)
|
|
9
8
|
return;
|
|
10
9
|
disposed = true;
|
|
@@ -22,11 +21,10 @@ export function until(source) {
|
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
23
|
export function debounced(source, ms) {
|
|
25
|
-
const
|
|
26
|
-
const current = signal(read());
|
|
24
|
+
const current = signal(source());
|
|
27
25
|
let timeout;
|
|
28
26
|
effect(() => {
|
|
29
|
-
const value =
|
|
27
|
+
const value = source();
|
|
30
28
|
if (timeout)
|
|
31
29
|
clearTimeout(timeout);
|
|
32
30
|
timeout = setTimeout(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../src/reactive/reactive.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,UAAU,IAAI,CAClB,
|
|
1
|
+
{"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../src/reactive/reactive.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,UAAU,IAAI,CAClB,MAA+B,EAC/B,EAAmC;IAEnC,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,EAAE;QACvB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,IAAI,QAAQ;YAAE,OAAO;QAE/B,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,EAAE,CAAC;QACP,EAAE,CAAC,KAAK,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,KAAK,CAAI,MAA+B;IACtD,OAAO,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAClC,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,KAAK,IAAI,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,MAA+B,EAAE,EAAU;IACtE,MAAM,OAAO,GAAG,MAAM,CAAI,MAAM,EAAE,CAAC,CAAC;IACpC,IAAI,OAAkD,CAAC;IAEvD,MAAM,CAAC,GAAG,EAAE;QACV,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;QACvB,IAAI,OAAO;YAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,GAAG,SAAS,CAAC;QACtB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CA0C3D"}
|
package/dist/signal/computed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { activeEffect, runEffect } from "./effect";
|
|
2
2
|
export function computed(computeFn) {
|
|
3
3
|
let cachedValue;
|
|
4
4
|
let dirty = true;
|
|
@@ -30,9 +30,9 @@ export function computed(computeFn) {
|
|
|
30
30
|
wrappedEffect();
|
|
31
31
|
return () => subscribers.delete(wrappedEffect);
|
|
32
32
|
}
|
|
33
|
-
track(recompute);
|
|
34
33
|
const computedSignal = read;
|
|
35
34
|
computedSignal.subscribe = subscribe;
|
|
35
|
+
computedSignal.__isComputed = true;
|
|
36
36
|
return computedSignal;
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=computed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed.js","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"computed.js","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAe,MAAM,UAAU,CAAC;AAEhE,MAAM,UAAU,QAAQ,CAAI,SAAkB;IAC5C,IAAI,WAAc,CAAC;IACnB,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,KAAK,GAAG,IAAI,CAAC;QACb,CAAC,GAAG,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,GAAG,EAAE,CAAC;QACR,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,SAAS,IAAI;QACX,IAAI,YAAY,EAAE,CAAC;YACjB,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,UAAU,GAAG,YAAY,CAAC;YAChC,SAAS,CAAC,SAAS,CAAC,CAAC;YACrB,WAAW,GAAG,SAAS,EAAE,CAAC;YAC1B,KAAK,GAAG,KAAK,CAAC;YACd,SAAS,CAAC,UAAU,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,SAAS,SAAS,CAAC,EAAsB;QACvC,MAAM,aAAa,GAAG,GAAG,EAAE;YACzB,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACb,CAAC,CAAC;QACF,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC/B,aAAa,EAAE,CAAC;QAChB,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,cAAc,GAAG,IAAmB,CAAC;IAC3C,cAAc,CAAC,SAAS,GAAG,SAAS,CAAC;IACrC,cAAc,CAAC,YAAY,GAAG,IAAI,CAAC;IAEnC,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
package/dist/signal/peek.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peek.d.ts","sourceRoot":"","sources":["../../src/signal/peek.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAIzD,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"peek.d.ts","sourceRoot":"","sources":["../../src/signal/peek.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAIzD,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAQ1D"}
|
package/dist/signal/peek.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peek.js","sourceRoot":"","sources":["../../src/signal/peek.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEnD,MAAM,UAAU,IAAI,CAAI,
|
|
1
|
+
{"version":3,"file":"peek.js","sourceRoot":"","sources":["../../src/signal/peek.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEnD,MAAM,UAAU,IAAI,CAAI,MAA+B;IACrD,MAAM,IAAI,GAAG,YAAY,CAAC;IAC1B,SAAS,CAAC,IAAI,CAAC,CAAC;IAChB,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persisted.d.ts","sourceRoot":"","sources":["../../src/signal/persisted.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,EACf,OAAO,GAAE,sBAAsB,CAAC,CAAC,CAAM,
|
|
1
|
+
{"version":3,"file":"persisted.d.ts","sourceRoot":"","sources":["../../src/signal/persisted.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,EACf,OAAO,GAAE,sBAAsB,CAAC,CAAC,CAAM,aA0ExC"}
|
package/dist/signal/persisted.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persisted.js","sourceRoot":"","sources":["../../src/signal/persisted.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AAC;QACZ,CAAC,CAAC;QACF,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,EAAE,CAAC;QACV,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,MAAM,GAAG,IAAiB,CAAC;IACjC,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;IAEzB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@praxisjs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,14 +8,17 @@
|
|
|
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": {
|
|
14
18
|
"typescript": "^5.9.3"
|
|
15
19
|
},
|
|
16
20
|
"dependencies": {
|
|
17
|
-
"@praxisjs/
|
|
18
|
-
"@praxisjs/shared": "0.1.0"
|
|
21
|
+
"@praxisjs/shared": "0.2.0"
|
|
19
22
|
},
|
|
20
23
|
"scripts": {
|
|
21
24
|
"build": "tsc",
|
package/src/component/base.ts
CHANGED
|
@@ -1,52 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export abstract class BaseComponent {
|
|
1
|
+
export abstract class RootComponent<T extends object = Record<string, never>> {
|
|
4
2
|
/** Props passed by the parent — filled by the renderer when instantiating/updating. */
|
|
5
|
-
readonly _rawProps:
|
|
6
|
-
|
|
7
|
-
/** Default values declared in the class. */
|
|
8
|
-
readonly _defaults: Record<string, unknown> = {};
|
|
9
|
-
|
|
10
|
-
/** @internal — holds the previous props snapshot so `onAfterUpdate` can compare against them after the renderer commits to the DOM */
|
|
11
|
-
_pendingPreviusProps: Record<string, unknown> | null = null;
|
|
3
|
+
readonly _rawProps: T = {} as T;
|
|
12
4
|
|
|
13
|
-
/** @internal — becomes `true` after `onMount` fires
|
|
5
|
+
/** @internal — becomes `true` after `onMount` fires */
|
|
14
6
|
_mounted = false;
|
|
15
7
|
|
|
16
|
-
/** @internal —
|
|
17
|
-
|
|
8
|
+
/** @internal — end comment anchor set by the runtime; used by decorators to locate the parent element */
|
|
9
|
+
_anchor?: Comment;
|
|
18
10
|
|
|
19
|
-
constructor(props:
|
|
11
|
+
constructor(props: T = {} as T) {
|
|
20
12
|
Object.assign(this._rawProps, props);
|
|
21
13
|
}
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
const previous = { ...this._rawProps };
|
|
25
|
-
this.onBeforeUpdate?.(previous);
|
|
26
|
-
Object.keys(this._rawProps).forEach((k) => { Reflect.deleteProperty(this._rawProps, k); });
|
|
27
|
-
Object.assign(this._rawProps, props);
|
|
28
|
-
this._pendingPreviusProps = previous;
|
|
29
|
-
this.onUpdate?.(previous);
|
|
30
|
-
|
|
31
|
-
queueMicrotask(() => {
|
|
32
|
-
this.onAfterUpdate?.(previous);
|
|
33
|
-
this._pendingPreviusProps = null;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get props(): Record<string, unknown> {
|
|
15
|
+
get props(): T {
|
|
38
16
|
return this._rawProps;
|
|
39
17
|
}
|
|
40
18
|
|
|
41
|
-
abstract render(): VNode | null;
|
|
42
|
-
|
|
43
19
|
onBeforeMount?(): void;
|
|
44
20
|
onMount?(): void;
|
|
45
21
|
onUnmount?(): void;
|
|
46
|
-
|
|
47
|
-
onBeforeUpdate?(prevProps: Record<string, unknown>): void;
|
|
48
|
-
onUpdate?(prevProps: Record<string, unknown>): void;
|
|
49
|
-
onAfterUpdate?(prevProps: Record<string, unknown>): void;
|
|
50
|
-
|
|
51
22
|
onError?(error: Error): void;
|
|
23
|
+
|
|
24
|
+
abstract render(): Node | Node[] | null;
|
|
52
25
|
}
|
package/src/component/index.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
createFunctionalContext,
|
|
5
|
-
setFunctionalContext,
|
|
6
|
-
onBeforeMount,
|
|
7
|
-
onError,
|
|
8
|
-
onMount,
|
|
9
|
-
onUnmount,
|
|
10
|
-
type FunctionalContext,
|
|
11
|
-
type LifeCycleHook,
|
|
12
|
-
} from "./lifecycle";
|
|
1
|
+
export { StatefulComponent } from "./stateful";
|
|
2
|
+
export { StatelessComponent } from "./stateless";
|
|
3
|
+
export { RootComponent } from "./base";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RootComponent } from "./base";
|
|
2
|
+
|
|
3
|
+
export abstract class StatefulComponent extends RootComponent<
|
|
4
|
+
Record<string, unknown>
|
|
5
|
+
> {
|
|
6
|
+
/** Default values declared in the class. */
|
|
7
|
+
readonly _defaults: Record<string, unknown> = {};
|
|
8
|
+
|
|
9
|
+
/** @internal — set to true by @State on any write; cleared by renderer after each re-render */
|
|
10
|
+
_stateDirty = false;
|
|
11
|
+
|
|
12
|
+
_setProps(props: Record<string, unknown>) {
|
|
13
|
+
Object.keys(this._rawProps).forEach((k) => {
|
|
14
|
+
Reflect.deleteProperty(this._rawProps, k);
|
|
15
|
+
});
|
|
16
|
+
Object.assign(this._rawProps, props);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RootComponent } from "./base";
|
|
2
|
+
|
|
3
|
+
export abstract class StatelessComponent<
|
|
4
|
+
T extends object = Record<string, never>,
|
|
5
|
+
> extends RootComponent<T> {
|
|
6
|
+
_setProps(props: Record<string, unknown>) {
|
|
7
|
+
Object.keys(this._rawProps).forEach((k) => {
|
|
8
|
+
Reflect.deleteProperty(this._rawProps, k);
|
|
9
|
+
});
|
|
10
|
+
Object.assign(this._rawProps, props);
|
|
11
|
+
}
|
|
12
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { StatefulComponent, StatelessComponent } from "./component";
|
|
1
2
|
export {
|
|
2
3
|
resource,
|
|
3
4
|
createResource,
|
|
@@ -5,31 +6,3 @@ export {
|
|
|
5
6
|
type Resource,
|
|
6
7
|
type ResourceOptions,
|
|
7
8
|
} from "./async/resource";
|
|
8
|
-
export {
|
|
9
|
-
debounced,
|
|
10
|
-
until,
|
|
11
|
-
when,
|
|
12
|
-
history,
|
|
13
|
-
type HistoryElement,
|
|
14
|
-
} from "./reactive";
|
|
15
|
-
export {
|
|
16
|
-
signal,
|
|
17
|
-
persistedSignal,
|
|
18
|
-
peek,
|
|
19
|
-
computed,
|
|
20
|
-
batch,
|
|
21
|
-
effect,
|
|
22
|
-
type PersistedSignalOptions,
|
|
23
|
-
} from "./signal";
|
|
24
|
-
export {
|
|
25
|
-
BaseComponent,
|
|
26
|
-
VALID_LIFECYCLE_HOOK_SIGNATURES,
|
|
27
|
-
onBeforeMount,
|
|
28
|
-
onError,
|
|
29
|
-
onMount,
|
|
30
|
-
onUnmount,
|
|
31
|
-
createFunctionalContext,
|
|
32
|
-
setFunctionalContext,
|
|
33
|
-
type FunctionalContext,
|
|
34
|
-
type LifeCycleHook,
|
|
35
|
-
} from "./component";
|
package/src/internal.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export {
|
|
2
|
+
debounced,
|
|
3
|
+
until,
|
|
4
|
+
when,
|
|
5
|
+
history,
|
|
6
|
+
type HistoryElement,
|
|
7
|
+
} from "./reactive";
|
|
8
|
+
export {
|
|
9
|
+
signal,
|
|
10
|
+
persistedSignal,
|
|
11
|
+
peek,
|
|
12
|
+
computed,
|
|
13
|
+
batch,
|
|
14
|
+
effect,
|
|
15
|
+
type PersistedSignalOptions,
|
|
16
|
+
} from "./signal";
|
|
17
|
+
export { RootComponent } from "./component";
|
package/src/reactive/history.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Computed, Signal } from "@praxisjs/shared";
|
|
2
|
+
import { isSignal } from "@praxisjs/shared/internal";
|
|
2
3
|
|
|
3
4
|
import { computed, signal, peek } from "../signal";
|
|
4
5
|
import { effect } from "../signal/effect";
|
|
@@ -14,20 +15,18 @@ export interface HistoryElement<T> {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export function history<T>(
|
|
17
|
-
source: Signal<T> | Computed<T
|
|
18
|
+
source: Signal<T> | Computed<T>,
|
|
18
19
|
limit = 50,
|
|
19
20
|
): HistoryElement<T> {
|
|
20
|
-
const read = typeof source === "function" ? source : (source as () => T);
|
|
21
|
-
|
|
22
21
|
const _past = signal<T[]>([]);
|
|
23
22
|
const _future = signal<T[]>([]);
|
|
24
|
-
const _current = signal<T>(
|
|
23
|
+
const _current = signal<T>(source());
|
|
25
24
|
|
|
26
25
|
let _ignoreNext = false;
|
|
27
26
|
let _initialized = false;
|
|
28
27
|
|
|
29
28
|
effect(() => {
|
|
30
|
-
const value =
|
|
29
|
+
const value = source();
|
|
31
30
|
|
|
32
31
|
if (!_initialized) {
|
|
33
32
|
_initialized = true;
|
package/src/reactive/reactive.ts
CHANGED
|
@@ -4,14 +4,13 @@ import { signal } from "../signal";
|
|
|
4
4
|
import { effect } from "../signal/effect";
|
|
5
5
|
|
|
6
6
|
export function when<T>(
|
|
7
|
-
source: Signal<T> | Computed<T
|
|
7
|
+
source: Signal<T> | Computed<T>,
|
|
8
8
|
fn: (value: NonNullable<T>) => void,
|
|
9
9
|
) {
|
|
10
|
-
const read = typeof source === "function" ? source : (source as () => T);
|
|
11
10
|
let disposed = false;
|
|
12
11
|
|
|
13
12
|
const stop = effect(() => {
|
|
14
|
-
const value =
|
|
13
|
+
const value = source();
|
|
15
14
|
if (!value || disposed) return;
|
|
16
15
|
|
|
17
16
|
disposed = true;
|
|
@@ -22,7 +21,7 @@ export function when<T>(
|
|
|
22
21
|
return stop;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
export function until<T>(source: Signal<T> | Computed<T>
|
|
24
|
+
export function until<T>(source: Signal<T> | Computed<T>) {
|
|
26
25
|
return new Promise<NonNullable<T>>((resolve) => {
|
|
27
26
|
const stop = when(source, (value) => {
|
|
28
27
|
resolve(value);
|
|
@@ -32,16 +31,12 @@ export function until<T>(source: Signal<T> | Computed<T> | (() => T)) {
|
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
export function debounced<T>(
|
|
36
|
-
|
|
37
|
-
ms: number,
|
|
38
|
-
) {
|
|
39
|
-
const read = typeof source === "function" ? source : (source as () => T);
|
|
40
|
-
const current = signal<T>(read());
|
|
34
|
+
export function debounced<T>(source: Signal<T> | Computed<T>, ms: number) {
|
|
35
|
+
const current = signal<T>(source());
|
|
41
36
|
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
42
37
|
|
|
43
38
|
effect(() => {
|
|
44
|
-
const value =
|
|
39
|
+
const value = source();
|
|
45
40
|
if (timeout) clearTimeout(timeout);
|
|
46
41
|
timeout = setTimeout(() => {
|
|
47
42
|
current.set(value);
|
package/src/signal/computed.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Computed } from "@praxisjs/shared";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { activeEffect, runEffect, type Effect } from "./effect";
|
|
4
4
|
|
|
5
5
|
export function computed<T>(computeFn: () => T): Computed<T> {
|
|
6
6
|
let cachedValue: T;
|
|
@@ -39,10 +39,9 @@ export function computed<T>(computeFn: () => T): Computed<T> {
|
|
|
39
39
|
return () => subscribers.delete(wrappedEffect);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
track(recompute);
|
|
43
|
-
|
|
44
42
|
const computedSignal = read as Computed<T>;
|
|
45
43
|
computedSignal.subscribe = subscribe;
|
|
44
|
+
computedSignal.__isComputed = true;
|
|
46
45
|
|
|
47
46
|
return computedSignal;
|
|
48
47
|
}
|
package/src/signal/peek.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Computed, Signal } from "@praxisjs/shared";
|
|
|
2
2
|
|
|
3
3
|
import { activeEffect, runEffect } from "./effect";
|
|
4
4
|
|
|
5
|
-
export function peek<T>(source: Signal<T> | Computed<T>
|
|
5
|
+
export function peek<T>(source: Signal<T> | Computed<T>): T {
|
|
6
6
|
const prev = activeEffect;
|
|
7
7
|
runEffect(null);
|
|
8
8
|
try {
|
package/src/signal/persisted.ts
CHANGED
package/src/signal/signal.ts
CHANGED
|
@@ -15,7 +15,6 @@ export function signal<T>(initialValue: T): Signal<T> {
|
|
|
15
15
|
|
|
16
16
|
function set(newValue: T) {
|
|
17
17
|
if (Object.is(value, newValue)) return;
|
|
18
|
-
|
|
19
18
|
value = newValue;
|
|
20
19
|
[...subscribers].forEach((sub) => {
|
|
21
20
|
sub();
|
|
@@ -39,6 +38,7 @@ export function signal<T>(initialValue: T): Signal<T> {
|
|
|
39
38
|
signal.set = set;
|
|
40
39
|
signal.update = update;
|
|
41
40
|
signal.subscribe = subscribe;
|
|
41
|
+
signal.__isSignal = true;
|
|
42
42
|
|
|
43
43
|
return signal;
|
|
44
44
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type LifeCycleHook = "onBeforeMount" | "onMount" | "onBeforeUpdate" | "onUpdate" | "onAfterUpdate" | "onUnmount" | "onError";
|
|
2
|
-
export declare const VALID_LIFECYCLE_HOOK_SIGNATURES: Record<LifeCycleHook, string>;
|
|
3
|
-
export interface FunctionalContext {
|
|
4
|
-
onBeforeMount: Array<() => void>;
|
|
5
|
-
onMount: Array<() => void>;
|
|
6
|
-
onUnmount: Array<() => void>;
|
|
7
|
-
onError: Array<(error: Error) => void>;
|
|
8
|
-
}
|
|
9
|
-
export declare function setFunctionalContext(ctx: FunctionalContext | null): void;
|
|
10
|
-
export declare function createFunctionalContext(): FunctionalContext;
|
|
11
|
-
export declare function onBeforeMount(fn: () => void): void;
|
|
12
|
-
export declare function onMount(fn: () => void): void;
|
|
13
|
-
export declare function onUnmount(fn: () => void): void;
|
|
14
|
-
export declare function onError(fn: (error: Error) => void): void;
|
|
15
|
-
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/component/lifecycle.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,SAAS,GACT,gBAAgB,GAChB,UAAU,GACV,eAAe,GACf,WAAW,GACX,SAAS,CAAC;AAEd,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAUzE,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IACjC,OAAO,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IAC3B,SAAS,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IAC7B,OAAO,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC;CACxC;AAID,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAExE;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,CAO3D;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAQlD;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAQ5C;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAQ9C;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAQxD"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export const VALID_LIFECYCLE_HOOK_SIGNATURES = {
|
|
2
|
-
onBeforeMount: "(): void",
|
|
3
|
-
onMount: "(): void",
|
|
4
|
-
onUnmount: "(): void",
|
|
5
|
-
onBeforeUpdate: "(prevProps: Record<string, unknown>): void",
|
|
6
|
-
onUpdate: "(prevProps: Record<string, unknown>): void",
|
|
7
|
-
onAfterUpdate: "(prevProps: Record<string, unknown>): void",
|
|
8
|
-
onError: "(error: Error): void",
|
|
9
|
-
};
|
|
10
|
-
let _functionalContext = null;
|
|
11
|
-
export function setFunctionalContext(ctx) {
|
|
12
|
-
_functionalContext = ctx;
|
|
13
|
-
}
|
|
14
|
-
export function createFunctionalContext() {
|
|
15
|
-
return {
|
|
16
|
-
onBeforeMount: [],
|
|
17
|
-
onMount: [],
|
|
18
|
-
onUnmount: [],
|
|
19
|
-
onError: [],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export function onBeforeMount(fn) {
|
|
23
|
-
if (_functionalContext) {
|
|
24
|
-
_functionalContext.onBeforeMount.push(fn);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (process.env.NODE_ENV !== "production") {
|
|
28
|
-
console.warn("[onBeforeMount] Called outside of a functional component context.");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export function onMount(fn) {
|
|
32
|
-
if (_functionalContext) {
|
|
33
|
-
_functionalContext.onMount.push(fn);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (process.env.NODE_ENV !== "production") {
|
|
37
|
-
console.warn("[onMount] Called outside of a functional component context.");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export function onUnmount(fn) {
|
|
41
|
-
if (_functionalContext) {
|
|
42
|
-
_functionalContext.onUnmount.push(fn);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (process.env.NODE_ENV !== "production") {
|
|
46
|
-
console.warn("[onUnmount] Called outside of a functional component context.");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export function onError(fn) {
|
|
50
|
-
if (_functionalContext) {
|
|
51
|
-
_functionalContext.onError.push(fn);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (process.env.NODE_ENV !== "production") {
|
|
55
|
-
console.warn("[onError] Called outside of a functional component context.");
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/component/lifecycle.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,+BAA+B,GAAkC;IAC5E,aAAa,EAAE,UAAU;IACzB,OAAO,EAAE,UAAU;IACnB,SAAS,EAAE,UAAU;IAErB,cAAc,EAAE,4CAA4C;IAC5D,QAAQ,EAAE,4CAA4C;IACtD,aAAa,EAAE,4CAA4C;IAE3D,OAAO,EAAE,sBAAsB;CAChC,CAAC;AASF,IAAI,kBAAkB,GAA6B,IAAI,CAAC;AAExD,MAAM,UAAU,oBAAoB,CAAC,GAA6B;IAChE,kBAAkB,GAAG,GAAG,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,aAAa,EAAE,EAAE;QACjB,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAc;IAC1C,IAAI,kBAAkB,EAAE,CAAC;QACvB,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC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
-
export const VALID_LIFECYCLE_HOOK_SIGNATURES: Record<LifeCycleHook, string> = {
|
|
11
|
-
onBeforeMount: "(): void",
|
|
12
|
-
onMount: "(): void",
|
|
13
|
-
onUnmount: "(): void",
|
|
14
|
-
|
|
15
|
-
onBeforeUpdate: "(prevProps: Record<string, unknown>): void",
|
|
16
|
-
onUpdate: "(prevProps: Record<string, unknown>): void",
|
|
17
|
-
onAfterUpdate: "(prevProps: Record<string, unknown>): void",
|
|
18
|
-
|
|
19
|
-
onError: "(error: Error): void",
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export interface FunctionalContext {
|
|
23
|
-
onBeforeMount: Array<() => void>;
|
|
24
|
-
onMount: Array<() => void>;
|
|
25
|
-
onUnmount: Array<() => void>;
|
|
26
|
-
onError: Array<(error: Error) => void>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let _functionalContext: FunctionalContext | null = null;
|
|
30
|
-
|
|
31
|
-
export function setFunctionalContext(ctx: FunctionalContext | null): void {
|
|
32
|
-
_functionalContext = ctx;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function createFunctionalContext(): FunctionalContext {
|
|
36
|
-
return {
|
|
37
|
-
onBeforeMount: [],
|
|
38
|
-
onMount: [],
|
|
39
|
-
onUnmount: [],
|
|
40
|
-
onError: [],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function onBeforeMount(fn: () => void): void {
|
|
45
|
-
if (_functionalContext) {
|
|
46
|
-
_functionalContext.onBeforeMount.push(fn);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (process.env.NODE_ENV !== "production") {
|
|
50
|
-
console.warn("[onBeforeMount] Called outside of a functional component context.");
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function onMount(fn: () => void): void {
|
|
55
|
-
if (_functionalContext) {
|
|
56
|
-
_functionalContext.onMount.push(fn);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (process.env.NODE_ENV !== "production") {
|
|
60
|
-
console.warn("[onMount] Called outside of a functional component context.");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function onUnmount(fn: () => void): void {
|
|
65
|
-
if (_functionalContext) {
|
|
66
|
-
_functionalContext.onUnmount.push(fn);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (process.env.NODE_ENV !== "production") {
|
|
70
|
-
console.warn("[onUnmount] Called outside of a functional component context.");
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function onError(fn: (error: Error) => void): void {
|
|
75
|
-
if (_functionalContext) {
|
|
76
|
-
_functionalContext.onError.push(fn);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (process.env.NODE_ENV !== "production") {
|
|
80
|
-
console.warn("[onError] Called outside of a functional component context.");
|
|
81
|
-
}
|
|
82
|
-
}
|