@lab206/core 0.1.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/LICENSE +114 -0
- package/README.md +6 -0
- package/dist/effect.d.ts +31 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +85 -0
- package/dist/effect.js.map +1 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +76 -0
- package/dist/errors.js.map +1 -0
- package/dist/graph.d.ts +62 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +165 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/query.d.ts +35 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +35 -0
- package/dist/query.js.map +1 -0
- package/dist/resource.d.ts +55 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +128 -0
- package/dist/resource.js.map +1 -0
- package/dist/scheduler.d.ts +13 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +62 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/signal.d.ts +25 -0
- package/dist/signal.d.ts.map +1 -0
- package/dist/signal.js +94 -0
- package/dist/signal.js.map +1 -0
- package/dist/store.d.ts +52 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +70 -0
- package/dist/store.js.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +56 -0
- package/src/effect.ts +101 -0
- package/src/errors.ts +84 -0
- package/src/graph.ts +218 -0
- package/src/index.ts +45 -0
- package/src/query.ts +58 -0
- package/src/resource.ts +239 -0
- package/src/scheduler.ts +63 -0
- package/src/signal.ts +115 -0
- package/src/store.ts +118 -0
- package/src/types.ts +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor: Scott Powers
|
|
6
|
+
|
|
7
|
+
Licensed Work: Powers
|
|
8
|
+
The Licensed Work is (c) 2026 Scott Powers
|
|
9
|
+
|
|
10
|
+
Additional Use Grant: You may make production use of the Licensed Work,
|
|
11
|
+
provided You do not use the Licensed Work for a
|
|
12
|
+
Competing Offering.
|
|
13
|
+
|
|
14
|
+
A “Competing Offering” is a product, hosted service,
|
|
15
|
+
library, framework, design system, or documentation
|
|
16
|
+
site whose primary purpose is to provide a
|
|
17
|
+
general-purpose UI runtime, component library, or
|
|
18
|
+
design-system kit that substitutes for the Licensed
|
|
19
|
+
Work (including rebranded or forked distributions
|
|
20
|
+
marketed as a competing UI kit or “Powers
|
|
21
|
+
alternative”).
|
|
22
|
+
|
|
23
|
+
Building end-user applications, internal tools, or
|
|
24
|
+
client project work *with* the Licensed Work is
|
|
25
|
+
allowed and is not a Competing Offering.
|
|
26
|
+
|
|
27
|
+
Change Date: Four years from the first public release of each
|
|
28
|
+
version of the Licensed Work, or 2030-08-15,
|
|
29
|
+
whichever is earlier for that version
|
|
30
|
+
|
|
31
|
+
Change License: Apache License, Version 2.0
|
|
32
|
+
|
|
33
|
+
For information about alternative licensing arrangements for the Software,
|
|
34
|
+
see LICENSE-COMMERCIAL.md or contact the Licensor.
|
|
35
|
+
|
|
36
|
+
Notice
|
|
37
|
+
|
|
38
|
+
The Business Source License (this document, or the “License”) is not an Open
|
|
39
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
40
|
+
under an Open Source License, as stated in this License.
|
|
41
|
+
|
|
42
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
43
|
+
“Business Source License” is a trademark of MariaDB Corporation Ab.
|
|
44
|
+
|
|
45
|
+
-----------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
Business Source License 1.1
|
|
48
|
+
|
|
49
|
+
Terms
|
|
50
|
+
|
|
51
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
52
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
53
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
54
|
+
production use.
|
|
55
|
+
|
|
56
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
57
|
+
available distribution of a specific version of the Licensed Work under this
|
|
58
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
59
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
60
|
+
above terminate.
|
|
61
|
+
|
|
62
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
63
|
+
currently in effect as described in this License, you must purchase a
|
|
64
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
65
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
66
|
+
|
|
67
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
68
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
69
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
70
|
+
for each version of the Licensed Work released by Licensor.
|
|
71
|
+
|
|
72
|
+
You must conspicuously display this License on each original or modified copy
|
|
73
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
74
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
75
|
+
License apply to your use of that work.
|
|
76
|
+
|
|
77
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
78
|
+
terminate your rights under this License for the current and all other
|
|
79
|
+
versions of the Licensed Work.
|
|
80
|
+
|
|
81
|
+
This License does not grant you any right in any trademark or logo of
|
|
82
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
83
|
+
Licensor as expressly required by this License).
|
|
84
|
+
|
|
85
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
86
|
+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
87
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
88
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
89
|
+
TITLE.
|
|
90
|
+
|
|
91
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
|
92
|
+
your works, and to refer to it using the trademark “Business Source License”,
|
|
93
|
+
as long as you comply with the Covenants of Licensor below.
|
|
94
|
+
|
|
95
|
+
Covenants of Licensor
|
|
96
|
+
|
|
97
|
+
In consideration of the right to use this License’s text and the “Business
|
|
98
|
+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
99
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
100
|
+
|
|
101
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
102
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
103
|
+
where “compatible” means that software provided under the Change License can
|
|
104
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
105
|
+
later version. Licensor may specify additional Change Licenses without
|
|
106
|
+
limitation.
|
|
107
|
+
|
|
108
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
109
|
+
impose any additional restriction on the right granted in this License, as
|
|
110
|
+
the Additional Use Grant; or (b) insert the text “None”.
|
|
111
|
+
|
|
112
|
+
3. To specify a Change Date.
|
|
113
|
+
|
|
114
|
+
4. Not to modify this License in any other way.
|
package/README.md
ADDED
package/dist/effect.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ReactiveNode } from "./graph.js";
|
|
2
|
+
import type { Dispose, EffectFn } from "./types.js";
|
|
3
|
+
export interface EffectOptions {
|
|
4
|
+
name?: string;
|
|
5
|
+
/** Local error handler (runs before owner `onError` handlers). */
|
|
6
|
+
onError?: (error: unknown) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Run `fn` immediately, track reactive reads, and re-run when they change.
|
|
10
|
+
* Returns a dispose function. `fn` may return a cleanup called before the
|
|
11
|
+
* next run and on dispose.
|
|
12
|
+
*
|
|
13
|
+
* Errors are caught so one bad effect cannot tear down the whole graph.
|
|
14
|
+
* Handle them with `options.onError` or owner-level `onError()`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const stop = effect(() => {
|
|
19
|
+
* console.log(count());
|
|
20
|
+
* return () => console.log("cleanup");
|
|
21
|
+
* });
|
|
22
|
+
* stop();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function effect(fn: EffectFn, options?: EffectOptions): Dispose;
|
|
26
|
+
/**
|
|
27
|
+
* Schedule an effect run without running it now.
|
|
28
|
+
* Primarily for internal/testing use.
|
|
29
|
+
*/
|
|
30
|
+
export declare function scheduleEffect(node: ReactiveNode): void;
|
|
31
|
+
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAyDrE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAEvD"}
|
package/dist/effect.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { clearSources, createNode, disposeNode, getActiveOwner, setActiveNode, } from "./graph.js";
|
|
2
|
+
import { reportError } from "./errors.js";
|
|
3
|
+
import { enqueue } from "./scheduler.js";
|
|
4
|
+
/**
|
|
5
|
+
* Run `fn` immediately, track reactive reads, and re-run when they change.
|
|
6
|
+
* Returns a dispose function. `fn` may return a cleanup called before the
|
|
7
|
+
* next run and on dispose.
|
|
8
|
+
*
|
|
9
|
+
* Errors are caught so one bad effect cannot tear down the whole graph.
|
|
10
|
+
* Handle them with `options.onError` or owner-level `onError()`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const stop = effect(() => {
|
|
15
|
+
* console.log(count());
|
|
16
|
+
* return () => console.log("cleanup");
|
|
17
|
+
* });
|
|
18
|
+
* stop();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function effect(fn, options) {
|
|
22
|
+
const node = createNode("effect", options?.name);
|
|
23
|
+
const owner = getActiveOwner();
|
|
24
|
+
const localOnError = options?.onError;
|
|
25
|
+
const run = () => {
|
|
26
|
+
if (node.disposed)
|
|
27
|
+
return;
|
|
28
|
+
if (node.cleanup) {
|
|
29
|
+
const c = node.cleanup;
|
|
30
|
+
node.cleanup = undefined;
|
|
31
|
+
try {
|
|
32
|
+
c();
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
handle(err);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
clearSources(node);
|
|
39
|
+
const prev = setActiveNode(node);
|
|
40
|
+
try {
|
|
41
|
+
const cleanup = fn();
|
|
42
|
+
if (typeof cleanup === "function") {
|
|
43
|
+
node.cleanup = cleanup;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
handle(err);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
setActiveNode(prev);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
function handle(err) {
|
|
54
|
+
if (localOnError) {
|
|
55
|
+
try {
|
|
56
|
+
localOnError(err);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
catch (handlerError) {
|
|
60
|
+
// Fall through to owner handlers with the handler error.
|
|
61
|
+
if (reportError(handlerError, owner))
|
|
62
|
+
return;
|
|
63
|
+
console.error("[powers] effect onError handler threw:", handlerError);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (reportError(err, owner))
|
|
68
|
+
return;
|
|
69
|
+
console.error("[powers] Unhandled effect error:", err);
|
|
70
|
+
}
|
|
71
|
+
node.run = run;
|
|
72
|
+
// Initial run is synchronous so first paint / first log is immediate.
|
|
73
|
+
run();
|
|
74
|
+
return () => {
|
|
75
|
+
disposeNode(node);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Schedule an effect run without running it now.
|
|
80
|
+
* Primarily for internal/testing use.
|
|
81
|
+
*/
|
|
82
|
+
export function scheduleEffect(node) {
|
|
83
|
+
enqueue(node);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,GAEd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AASzC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CAAC,EAAY,EAAE,OAAuB;IAC1D,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IAC/B,MAAM,YAAY,GAAG,OAAO,EAAE,OAAO,CAAC;IAEtC,MAAM,GAAG,GAAG,GAAG,EAAE;QACf,IAAI,IAA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G,CAAC;IAEf,sEAAsE;IACtE,GAAG,EAAE,CAAC;IAEN,OAAO,GAAG,EAAE;QACV,WAAW,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAkB;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Owner } from "./graph.js";
|
|
2
|
+
import type { Dispose } from "./types.js";
|
|
3
|
+
type ErrorHandler = (error: unknown) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Register an error handler for the **current owner** (from `createRoot`).
|
|
6
|
+
* Effect errors bubble to these handlers instead of crashing the graph.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* createRoot(() => {
|
|
11
|
+
* onError((err) => console.error("caught", err));
|
|
12
|
+
* effect(() => { throw new Error("boom"); });
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function onError(fn: ErrorHandler): Dispose;
|
|
17
|
+
/**
|
|
18
|
+
* Report an error to the nearest owner handlers, then parent owners,
|
|
19
|
+
* then the global handler. Returns true if anyone handled it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function reportError(error: unknown, owner: Owner | null): boolean;
|
|
22
|
+
/** @internal */
|
|
23
|
+
export declare function clearGlobalErrorHandler(): void;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,KAAK,YAAY,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAQ7C;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAqBjD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,OAAO,CA4BxE;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getActiveOwner } from "./graph.js";
|
|
2
|
+
/** Owner → handlers registered while that owner is active. */
|
|
3
|
+
const ownerHandlers = new WeakMap();
|
|
4
|
+
/** Fallback when no owner handler claims the error. */
|
|
5
|
+
let globalHandler = null;
|
|
6
|
+
/**
|
|
7
|
+
* Register an error handler for the **current owner** (from `createRoot`).
|
|
8
|
+
* Effect errors bubble to these handlers instead of crashing the graph.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* createRoot(() => {
|
|
13
|
+
* onError((err) => console.error("caught", err));
|
|
14
|
+
* effect(() => { throw new Error("boom"); });
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function onError(fn) {
|
|
19
|
+
const owner = getActiveOwner();
|
|
20
|
+
if (!owner) {
|
|
21
|
+
// No owner — install as process-local global for this call site's lifetime.
|
|
22
|
+
const prev = globalHandler;
|
|
23
|
+
globalHandler = fn;
|
|
24
|
+
return () => {
|
|
25
|
+
if (globalHandler === fn)
|
|
26
|
+
globalHandler = prev;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
let set = ownerHandlers.get(owner);
|
|
30
|
+
if (!set) {
|
|
31
|
+
set = new Set();
|
|
32
|
+
ownerHandlers.set(owner, set);
|
|
33
|
+
}
|
|
34
|
+
set.add(fn);
|
|
35
|
+
return () => {
|
|
36
|
+
set.delete(fn);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Report an error to the nearest owner handlers, then parent owners,
|
|
41
|
+
* then the global handler. Returns true if anyone handled it.
|
|
42
|
+
*/
|
|
43
|
+
export function reportError(error, owner) {
|
|
44
|
+
let current = owner;
|
|
45
|
+
while (current) {
|
|
46
|
+
const set = ownerHandlers.get(current);
|
|
47
|
+
if (set && set.size > 0) {
|
|
48
|
+
for (const handler of set) {
|
|
49
|
+
try {
|
|
50
|
+
handler(error);
|
|
51
|
+
}
|
|
52
|
+
catch (handlerError) {
|
|
53
|
+
// Handler bugs should not recurse forever.
|
|
54
|
+
console.error("[powers] onError handler threw:", handlerError);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
current = current.parent;
|
|
60
|
+
}
|
|
61
|
+
if (globalHandler) {
|
|
62
|
+
try {
|
|
63
|
+
globalHandler(error);
|
|
64
|
+
}
|
|
65
|
+
catch (handlerError) {
|
|
66
|
+
console.error("[powers] onError handler threw:", handlerError);
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
/** @internal */
|
|
73
|
+
export function clearGlobalErrorHandler() {
|
|
74
|
+
globalHandler = null;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAc,MAAM,YAAY,CAAC;AAKxD,8DAA8D;AAC9D,MAAM,aAAa,GAAG,IAAI,OAAO,EAA4B,CAAC;AAE9D,uDAAuD;AACvD,IAAI,aAAa,GAAwB,IAAI,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,OAAO,CAAC,EAAgB;IACtC,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IAC/B,IAAI,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;YACH,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAAC,OAAO,YAAY,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,YAAY,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,uBAAuB;IACrC,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC"}
|
package/dist/graph.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Dispose, NodeKind } from "./types.js";
|
|
2
|
+
/** A node in the reactive dependency graph. */
|
|
3
|
+
export interface ReactiveNode {
|
|
4
|
+
kind: NodeKind;
|
|
5
|
+
name?: string;
|
|
6
|
+
disposed: boolean;
|
|
7
|
+
pending: boolean;
|
|
8
|
+
/** Sources this node currently depends on. */
|
|
9
|
+
sources: Set<ReactiveNode>;
|
|
10
|
+
/** Nodes that depend on this node. */
|
|
11
|
+
observers: Set<ReactiveNode>;
|
|
12
|
+
/** For computed: dirty when a source may have changed. */
|
|
13
|
+
dirty: boolean;
|
|
14
|
+
/** Recompute value (computed) or re-run body (effect). */
|
|
15
|
+
run?: () => void;
|
|
16
|
+
/** Cleanup registered by the last effect run. */
|
|
17
|
+
cleanup?: (() => void) | undefined;
|
|
18
|
+
/** Owner that created this node (for disposal trees). */
|
|
19
|
+
owner: Owner | null;
|
|
20
|
+
/** Child nodes owned by this owner-like node (effects/roots). */
|
|
21
|
+
children?: Set<ReactiveNode>;
|
|
22
|
+
}
|
|
23
|
+
/** Ownership scope — disposing a root disposes all owned nodes. */
|
|
24
|
+
export interface Owner {
|
|
25
|
+
parent: Owner | null;
|
|
26
|
+
nodes: Set<ReactiveNode>;
|
|
27
|
+
disposed: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function getActiveNode(): ReactiveNode | null;
|
|
30
|
+
export declare function setActiveNode(node: ReactiveNode | null): ReactiveNode | null;
|
|
31
|
+
export declare function getActiveOwner(): Owner | null;
|
|
32
|
+
export declare function setActiveOwner(owner: Owner | null): Owner | null;
|
|
33
|
+
export declare function isTracking(): boolean;
|
|
34
|
+
/** Run `fn` without collecting dependencies. */
|
|
35
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
36
|
+
export declare function createOwner(parent?: Owner | null): Owner;
|
|
37
|
+
export declare function createNode(kind: NodeKind, name?: string, owner?: Owner | null): ReactiveNode;
|
|
38
|
+
/** Register `source` as a dependency of the active consumer. */
|
|
39
|
+
export declare function track(source: ReactiveNode): void;
|
|
40
|
+
/** Drop all current source links for a node (before re-running). */
|
|
41
|
+
export declare function clearSources(node: ReactiveNode): void;
|
|
42
|
+
/** Notify observers that `source` changed. */
|
|
43
|
+
export declare function notify(source: ReactiveNode): void;
|
|
44
|
+
/** Dispose a single node and unlink it from the graph. */
|
|
45
|
+
export declare function disposeNode(node: ReactiveNode): void;
|
|
46
|
+
/** Dispose an owner and every node it owns (depth-first). */
|
|
47
|
+
export declare function disposeOwner(owner: Owner): void;
|
|
48
|
+
/**
|
|
49
|
+
* Create a reactive root. All signals/effects created inside are owned by
|
|
50
|
+
* this root and disposed when the returned dispose function is called.
|
|
51
|
+
*
|
|
52
|
+
* Clears the active *tracking* node while `fn` runs so parent effects (e.g.
|
|
53
|
+
* a router outlet) do not accidentally subscribe to signals read during
|
|
54
|
+
* component setup — that would remount the whole page on first keystroke.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createRoot<T>(fn: (dispose: Dispose) => T): T;
|
|
57
|
+
/**
|
|
58
|
+
* Run `fn` under a fresh owner nested under the current owner.
|
|
59
|
+
* Useful for scoped components later.
|
|
60
|
+
*/
|
|
61
|
+
export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
|
|
62
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],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AAE,MAAM,CAAC,GAAG,CAAC,CAQzC;AAED,wBAAgB,WAAW,CAAC,MAAM,GAAE,KAAK,GAAG,IAAkB,GAAG,KAAK,CAMrE;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,EACd,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,GAAE,KAAK,GAAG,IAAkB,GAChC,YAAY,CAmBd;AAED,gEAAgE;AAChE,wBAAgB,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAMhD;AAED,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAKrD;AAED,8CAA8C;AAC9C,wBAAgB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAcjD;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CA2BpD;AAED,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAU/C;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAe5D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAOnE"}
|
package/dist/graph.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { enqueue } from "./scheduler.js";
|
|
2
|
+
let activeNode = null;
|
|
3
|
+
let activeOwner = null;
|
|
4
|
+
let tracking = true;
|
|
5
|
+
export function getActiveNode() {
|
|
6
|
+
return activeNode;
|
|
7
|
+
}
|
|
8
|
+
export function setActiveNode(node) {
|
|
9
|
+
const prev = activeNode;
|
|
10
|
+
activeNode = node;
|
|
11
|
+
return prev;
|
|
12
|
+
}
|
|
13
|
+
export function getActiveOwner() {
|
|
14
|
+
return activeOwner;
|
|
15
|
+
}
|
|
16
|
+
export function setActiveOwner(owner) {
|
|
17
|
+
const prev = activeOwner;
|
|
18
|
+
activeOwner = owner;
|
|
19
|
+
return prev;
|
|
20
|
+
}
|
|
21
|
+
export function isTracking() {
|
|
22
|
+
return tracking;
|
|
23
|
+
}
|
|
24
|
+
/** Run `fn` without collecting dependencies. */
|
|
25
|
+
export function untrack(fn) {
|
|
26
|
+
const prev = tracking;
|
|
27
|
+
tracking = false;
|
|
28
|
+
try {
|
|
29
|
+
return fn();
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
tracking = prev;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function createOwner(parent = activeOwner) {
|
|
36
|
+
return {
|
|
37
|
+
parent,
|
|
38
|
+
nodes: new Set(),
|
|
39
|
+
disposed: false,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function createNode(kind, name, owner = activeOwner) {
|
|
43
|
+
const node = {
|
|
44
|
+
kind,
|
|
45
|
+
disposed: false,
|
|
46
|
+
pending: false,
|
|
47
|
+
sources: new Set(),
|
|
48
|
+
observers: new Set(),
|
|
49
|
+
dirty: true,
|
|
50
|
+
owner,
|
|
51
|
+
};
|
|
52
|
+
if (name !== undefined) {
|
|
53
|
+
node.name = name;
|
|
54
|
+
}
|
|
55
|
+
if (owner && !owner.disposed) {
|
|
56
|
+
owner.nodes.add(node);
|
|
57
|
+
}
|
|
58
|
+
return node;
|
|
59
|
+
}
|
|
60
|
+
/** Register `source` as a dependency of the active consumer. */
|
|
61
|
+
export function track(source) {
|
|
62
|
+
if (!tracking || !activeNode || activeNode === source || source.disposed) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
source.observers.add(activeNode);
|
|
66
|
+
activeNode.sources.add(source);
|
|
67
|
+
}
|
|
68
|
+
/** Drop all current source links for a node (before re-running). */
|
|
69
|
+
export function clearSources(node) {
|
|
70
|
+
for (const source of node.sources) {
|
|
71
|
+
source.observers.delete(node);
|
|
72
|
+
}
|
|
73
|
+
node.sources.clear();
|
|
74
|
+
}
|
|
75
|
+
/** Notify observers that `source` changed. */
|
|
76
|
+
export function notify(source) {
|
|
77
|
+
for (const observer of source.observers) {
|
|
78
|
+
if (observer.disposed)
|
|
79
|
+
continue;
|
|
80
|
+
if (observer.kind === "computed") {
|
|
81
|
+
if (!observer.dirty) {
|
|
82
|
+
observer.dirty = true;
|
|
83
|
+
// Propagate dirty flags through computed chains.
|
|
84
|
+
notify(observer);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else if (observer.kind === "effect") {
|
|
88
|
+
enqueue(observer);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Dispose a single node and unlink it from the graph. */
|
|
93
|
+
export function disposeNode(node) {
|
|
94
|
+
if (node.disposed)
|
|
95
|
+
return;
|
|
96
|
+
node.disposed = true;
|
|
97
|
+
if (node.cleanup) {
|
|
98
|
+
const c = node.cleanup;
|
|
99
|
+
node.cleanup = undefined;
|
|
100
|
+
c();
|
|
101
|
+
}
|
|
102
|
+
clearSources(node);
|
|
103
|
+
for (const observer of node.observers) {
|
|
104
|
+
observer.sources.delete(node);
|
|
105
|
+
}
|
|
106
|
+
node.observers.clear();
|
|
107
|
+
if (node.children) {
|
|
108
|
+
for (const child of node.children) {
|
|
109
|
+
disposeNode(child);
|
|
110
|
+
}
|
|
111
|
+
node.children.clear();
|
|
112
|
+
}
|
|
113
|
+
if (node.owner) {
|
|
114
|
+
node.owner.nodes.delete(node);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Dispose an owner and every node it owns (depth-first). */
|
|
118
|
+
export function disposeOwner(owner) {
|
|
119
|
+
if (owner.disposed)
|
|
120
|
+
return;
|
|
121
|
+
owner.disposed = true;
|
|
122
|
+
// Snapshot — disposal mutates the set.
|
|
123
|
+
const nodes = [...owner.nodes];
|
|
124
|
+
for (const node of nodes) {
|
|
125
|
+
disposeNode(node);
|
|
126
|
+
}
|
|
127
|
+
owner.nodes.clear();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Create a reactive root. All signals/effects created inside are owned by
|
|
131
|
+
* this root and disposed when the returned dispose function is called.
|
|
132
|
+
*
|
|
133
|
+
* Clears the active *tracking* node while `fn` runs so parent effects (e.g.
|
|
134
|
+
* a router outlet) do not accidentally subscribe to signals read during
|
|
135
|
+
* component setup — that would remount the whole page on first keystroke.
|
|
136
|
+
*/
|
|
137
|
+
export function createRoot(fn) {
|
|
138
|
+
const owner = createOwner(activeOwner);
|
|
139
|
+
const prevOwner = setActiveOwner(owner);
|
|
140
|
+
const prevNode = setActiveNode(null);
|
|
141
|
+
const dispose = () => {
|
|
142
|
+
disposeOwner(owner);
|
|
143
|
+
};
|
|
144
|
+
try {
|
|
145
|
+
return fn(dispose);
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
setActiveOwner(prevOwner);
|
|
149
|
+
setActiveNode(prevNode);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Run `fn` under a fresh owner nested under the current owner.
|
|
154
|
+
* Useful for scoped components later.
|
|
155
|
+
*/
|
|
156
|
+
export function runWithOwner(owner, fn) {
|
|
157
|
+
const prev = setActiveOwner(owner);
|
|
158
|
+
try {
|
|
159
|
+
return fn();
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
setActiveOwner(prev);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA+BzC,IAAI,UAAU,GAAwB,IAAI,CAAC;AAC3C,IAAI,WAAW,GAAiB,IAAI,CAAC;AACrC,IAAI,QAAQ,GAAG,IAAI,CAAC;AAEpB,MA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GAOG;AACH,MAAM,UAAU,UAAU,CAAI,EAA2B;IACvD,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAErC,MAAM,OAAO,GAAY,GAAG,EAAE;QAC5B,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;YAAS,CAAC;QACT,cAAc,CAAC,SAAS,CAAC,CAAC;QAC1B,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,KAAmB,EAAE,EAAW;IAC9D,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;YAAS,CAAC;QACT,cAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lab206/core
|
|
3
|
+
*
|
|
4
|
+
* Fine-grained reactivity primitives.
|
|
5
|
+
* No DOM. No framework. Just a correct reactive graph.
|
|
6
|
+
*
|
|
7
|
+
* Learning order (intentionally short):
|
|
8
|
+
* 1. signal 2. computed 3. effect 4. store 5. resource / createQuery
|
|
9
|
+
*/
|
|
10
|
+
export { signal, computed } from "./signal.js";
|
|
11
|
+
export { effect } from "./effect.js";
|
|
12
|
+
export type { EffectOptions } from "./effect.js";
|
|
13
|
+
export { batch, flush, isBatching } from "./scheduler.js";
|
|
14
|
+
export { createRoot, untrack, getActiveOwner, runWithOwner, createOwner, disposeOwner, } from "./graph.js";
|
|
15
|
+
export { store, cell } from "./store.js";
|
|
16
|
+
export type { Store, StoreFields, StoreOptions } from "./store.js";
|
|
17
|
+
export { resource } from "./resource.js";
|
|
18
|
+
export type { Resource, ResourceState, ResourceOptions, ResourceFetcher, ResourceFetcherInfo, } from "./resource.js";
|
|
19
|
+
export { createQuery } from "./query.js";
|
|
20
|
+
export type { CreateQueryOptions, QueryKey } from "./query.js";
|
|
21
|
+
export { onError } from "./errors.js";
|
|
22
|
+
export type { Signal, ReadonlySignal, SignalOptions, EffectFn, Dispose, } from "./types.js";
|
|
23
|
+
export type { Owner } from "./graph.js";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,UAAU,EACV,OAAO,EACP,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EACV,QAAQ,EACR,aAAa,EACb,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,YAAY,EACV,MAAM,EACN,cAAc,EACd,aAAa,EACb,QAAQ,EACR,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lab206/core
|
|
3
|
+
*
|
|
4
|
+
* Fine-grained reactivity primitives.
|
|
5
|
+
* No DOM. No framework. Just a correct reactive graph.
|
|
6
|
+
*
|
|
7
|
+
* Learning order (intentionally short):
|
|
8
|
+
* 1. signal 2. computed 3. effect 4. store 5. resource / createQuery
|
|
9
|
+
*/
|
|
10
|
+
export { signal, computed } from "./signal.js";
|
|
11
|
+
export { effect } from "./effect.js";
|
|
12
|
+
export { batch, flush, isBatching } from "./scheduler.js";
|
|
13
|
+
export { createRoot, untrack, getActiveOwner, runWithOwner, createOwner, disposeOwner, } from "./graph.js";
|
|
14
|
+
export { store, cell } from "./store.js";
|
|
15
|
+
export { resource } from "./resource.js";
|
|
16
|
+
export { createQuery } from "./query.js";
|
|
17
|
+
export { onError } from "./errors.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,UAAU,EACV,OAAO,EACP,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQzC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|