@fluixi/reactive 1.0.0-alpha.82 → 1.0.0-alpha.84
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/README.md +4 -0
- package/dist/cdn/reactive.cjs +2673 -1
- package/dist/cdn/reactive.global.js +2 -1
- package/dist/cdn/reactive.mjs +2657 -1
- package/dist/cdn/signal.cjs +299 -1
- package/dist/cdn/signal.d.ts +1 -1
- package/dist/cdn/signal.global.js +2 -1
- package/dist/cdn/signal.js +1 -1
- package/dist/cdn/signal.mjs +276 -1
- package/dist/index.cjs +2673 -1
- package/dist/index.mjs +2657 -1
- package/dist/lib/index.cjs +2674 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.mjs +2659 -1
- package/dist/lib/observable/index.cjs +386 -1
- package/dist/lib/observable/index.mjs +364 -1
- package/dist/lib/observable/observable.cjs +384 -1
- package/dist/lib/observable/observable.d.ts +0 -137
- package/dist/lib/observable/observable.d.ts.map +1 -1
- package/dist/lib/observable/observable.js +0 -71
- package/dist/lib/observable/observable.mjs +361 -1
- package/dist/lib/observable/subscription.cjs +180 -1
- package/dist/lib/observable/subscription.d.ts +0 -12
- package/dist/lib/observable/subscription.d.ts.map +1 -1
- package/dist/lib/observable/subscription.js +0 -12
- package/dist/lib/observable/subscription.mjs +157 -1
- package/dist/lib/observable/types.cjs +18 -1
- package/dist/lib/observable/types.d.ts.map +1 -1
- package/dist/lib/predicates.cjs +44 -1
- package/dist/lib/predicates.d.ts +2 -2
- package/dist/lib/predicates.js +2 -2
- package/dist/lib/predicates.mjs +23 -1
- package/dist/lib/signal/api.cjs +571 -1
- package/dist/lib/signal/api.d.ts +211 -1
- package/dist/lib/signal/api.d.ts.map +1 -1
- package/dist/lib/signal/api.js +207 -12
- package/dist/lib/signal/api.mjs +548 -1
- package/dist/lib/signal/cached-resource.cjs +672 -1
- package/dist/lib/signal/cached-resource.d.ts +28 -16
- package/dist/lib/signal/cached-resource.d.ts.map +1 -1
- package/dist/lib/signal/cached-resource.js +35 -29
- package/dist/lib/signal/cached-resource.mjs +650 -1
- package/dist/lib/signal/graph/children.cjs +325 -1
- package/dist/lib/signal/graph/children.js +1 -1
- package/dist/lib/signal/graph/children.mjs +302 -1
- package/dist/lib/signal/graph/compat.cjs +578 -1
- package/dist/lib/signal/graph/compat.d.ts +13 -13
- package/dist/lib/signal/graph/compat.d.ts.map +1 -1
- package/dist/lib/signal/graph/compat.js +51 -32
- package/dist/lib/signal/graph/compat.mjs +556 -1
- package/dist/lib/signal/graph/core.cjs +295 -1
- package/dist/lib/signal/graph/core.d.ts +28 -24
- package/dist/lib/signal/graph/core.d.ts.map +1 -1
- package/dist/lib/signal/graph/core.js +45 -31
- package/dist/lib/signal/graph/core.mjs +273 -1
- package/dist/lib/signal/graph/debounced.cjs +668 -1
- package/dist/lib/signal/graph/debounced.d.ts +5 -5
- package/dist/lib/signal/graph/debounced.d.ts.map +1 -1
- package/dist/lib/signal/graph/debounced.js +5 -5
- package/dist/lib/signal/graph/debounced.mjs +645 -1
- package/dist/lib/signal/graph/derived.cjs +496 -1
- package/dist/lib/signal/graph/derived.d.ts +1 -1
- package/dist/lib/signal/graph/derived.js +1 -1
- package/dist/lib/signal/graph/derived.mjs +473 -1
- package/dist/lib/signal/graph/detect.cjs +66 -1
- package/dist/lib/signal/graph/detect.mjs +45 -1
- package/dist/lib/signal/graph/error-boundary.cjs +301 -1
- package/dist/lib/signal/graph/error-boundary.js +3 -3
- package/dist/lib/signal/graph/error-boundary.mjs +278 -1
- package/dist/lib/signal/graph/index.cjs +305 -1
- package/dist/lib/signal/graph/index.d.ts +7 -6
- package/dist/lib/signal/graph/index.d.ts.map +1 -1
- package/dist/lib/signal/graph/index.js +7 -6
- package/dist/lib/signal/graph/index.mjs +283 -1
- package/dist/lib/signal/graph/observe.cjs +163 -0
- package/dist/lib/signal/graph/observe.d.ts +141 -0
- package/dist/lib/signal/graph/observe.d.ts.map +1 -0
- package/dist/lib/signal/graph/observe.js +149 -0
- package/dist/lib/signal/graph/observe.mjs +140 -0
- package/dist/lib/signal/graph/resource.cjs +620 -1
- package/dist/lib/signal/graph/resource.d.ts +1 -1
- package/dist/lib/signal/graph/resource.js +7 -8
- package/dist/lib/signal/graph/resource.mjs +597 -1
- package/dist/lib/signal/graph/runtime.cjs +501 -1
- package/dist/lib/signal/graph/runtime.d.ts +9 -9
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
- package/dist/lib/signal/graph/runtime.js +56 -37
- package/dist/lib/signal/graph/runtime.mjs +478 -1
- package/dist/lib/signal/graph/signal-next.cjs +1208 -1
- package/dist/lib/signal/graph/signal-next.d.ts +5 -5
- package/dist/lib/signal/graph/signal-next.d.ts.map +1 -1
- package/dist/lib/signal/graph/signal-next.js +14 -12
- package/dist/lib/signal/graph/signal-next.mjs +1186 -1
- package/dist/lib/signal/graph/ssr-hooks.cjs +60 -1
- package/dist/lib/signal/graph/ssr-hooks.d.ts +6 -7
- package/dist/lib/signal/graph/ssr-hooks.d.ts.map +1 -1
- package/dist/lib/signal/graph/ssr-hooks.js +6 -7
- package/dist/lib/signal/graph/ssr-hooks.mjs +39 -1
- package/dist/lib/signal/graph/state.cjs +72 -1
- package/dist/lib/signal/graph/state.d.ts +43 -10
- package/dist/lib/signal/graph/state.d.ts.map +1 -1
- package/dist/lib/signal/graph/state.js +83 -21
- package/dist/lib/signal/graph/state.mjs +49 -1
- package/dist/lib/signal/graph/suspense.cjs +301 -1
- package/dist/lib/signal/graph/suspense.js +4 -4
- package/dist/lib/signal/graph/suspense.mjs +278 -1
- package/dist/lib/signal/index-legacy.cjs +2540 -1
- package/dist/lib/signal/index-legacy.d.ts +1 -1
- package/dist/lib/signal/index-legacy.js +1 -1
- package/dist/lib/signal/index-legacy.mjs +2518 -1
- package/dist/lib/signal/index.cjs +1275 -1
- package/dist/lib/signal/index.d.ts +5 -2
- package/dist/lib/signal/index.d.ts.map +1 -1
- package/dist/lib/signal/index.js +8 -3
- package/dist/lib/signal/index.mjs +1253 -1
- package/dist/lib/signal/list.cjs +549 -1
- package/dist/lib/signal/list.d.ts +5 -5
- package/dist/lib/signal/list.js +10 -10
- package/dist/lib/signal/list.mjs +526 -1
- package/dist/lib/signal/resource-api.cjs +626 -1
- package/dist/lib/signal/resource-api.d.ts +5 -5
- package/dist/lib/signal/resource-api.js +5 -5
- package/dist/lib/signal/resource-api.mjs +603 -1
- package/dist/lib/signal/signal.cjs +2023 -1
- package/dist/lib/signal/signal.d.ts +4 -4
- package/dist/lib/signal/signal.d.ts.map +1 -1
- package/dist/lib/signal/signal.js +22 -23
- package/dist/lib/signal/signal.mjs +2000 -1
- package/dist/lib/signal/types.cjs +38 -1
- package/dist/lib/signal/types.d.ts.map +1 -1
- package/dist/lib/signal/types.js +2 -2
- package/dist/lib/signal/types.mjs +17 -1
- package/dist/lib/signal/utilities.cjs +1012 -1
- package/dist/lib/signal/utilities.d.ts +0 -108
- package/dist/lib/signal/utilities.d.ts.map +1 -1
- package/dist/lib/signal/utilities.js +0 -158
- package/dist/lib/signal/utilities.mjs +990 -1
- package/dist/lib/store/api.cjs +612 -1
- package/dist/lib/store/api.d.ts +33 -0
- package/dist/lib/store/api.d.ts.map +1 -1
- package/dist/lib/store/api.js +41 -8
- package/dist/lib/store/api.mjs +596 -1
- package/dist/lib/store/index.cjs +691 -1
- package/dist/lib/store/index.js +1 -1
- package/dist/lib/store/index.mjs +676 -1
- package/dist/lib/store/setter.types.cjs +18 -1
- package/dist/lib/store/setter.types.d.ts +43 -3
- package/dist/lib/store/setter.types.d.ts.map +1 -1
- package/dist/lib/store/store.cjs +658 -1
- package/dist/lib/store/store.d.ts +72 -0
- package/dist/lib/store/store.d.ts.map +1 -1
- package/dist/lib/store/store.js +294 -11
- package/dist/lib/store/store.mjs +644 -1
- package/dist/lib/store/types.cjs +18 -1
- package/dist/lib/store/types.d.ts +1 -1
- package/dist/lib/store/types.d.ts.map +1 -1
- package/dist/lib/store/utils.cjs +43 -1
- package/dist/lib/store/utils.d.ts +1 -1
- package/dist/lib/store/utils.js +1 -1
- package/dist/lib/store/utils.mjs +22 -1
- package/dist/lib/subject.cjs +450 -1
- package/dist/lib/subject.js +3 -91
- package/dist/lib/subject.mjs +427 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +27 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +2 -2
- package/dist/version.generated.mjs +7 -1
- package/package.json +5 -4
|
@@ -1 +1,60 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/signal/graph/ssr-hooks.ts
|
|
21
|
+
var ssr_hooks_exports = {};
|
|
22
|
+
__export(ssr_hooks_exports, {
|
|
23
|
+
getServerData: () => getServerData,
|
|
24
|
+
nextResourceId: () => nextResourceId,
|
|
25
|
+
reportResourceData: () => reportResourceData,
|
|
26
|
+
setResourceDataSink: () => setResourceDataSink,
|
|
27
|
+
setResourceIdSource: () => setResourceIdSource,
|
|
28
|
+
setResourceTracker: () => setResourceTracker,
|
|
29
|
+
setServerDataGetter: () => setServerDataGetter,
|
|
30
|
+
trackResourcePromise: () => trackResourcePromise
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(ssr_hooks_exports);
|
|
33
|
+
var _resourceTracker = null;
|
|
34
|
+
function setResourceTracker(fn) {
|
|
35
|
+
_resourceTracker = fn;
|
|
36
|
+
}
|
|
37
|
+
function trackResourcePromise(p) {
|
|
38
|
+
if (_resourceTracker) _resourceTracker(p);
|
|
39
|
+
}
|
|
40
|
+
var _serverDataGetter = null;
|
|
41
|
+
function setServerDataGetter(fn) {
|
|
42
|
+
_serverDataGetter = fn;
|
|
43
|
+
}
|
|
44
|
+
function getServerData(id) {
|
|
45
|
+
return _serverDataGetter ? _serverDataGetter(id) : void 0;
|
|
46
|
+
}
|
|
47
|
+
var _resourceIdSource = null;
|
|
48
|
+
function setResourceIdSource(fn) {
|
|
49
|
+
_resourceIdSource = fn;
|
|
50
|
+
}
|
|
51
|
+
function nextResourceId() {
|
|
52
|
+
return _resourceIdSource ? _resourceIdSource() : void 0;
|
|
53
|
+
}
|
|
54
|
+
var _resourceDataSink = null;
|
|
55
|
+
function setResourceDataSink(fn) {
|
|
56
|
+
_resourceDataSink = fn;
|
|
57
|
+
}
|
|
58
|
+
function reportResourceData(id, value) {
|
|
59
|
+
if (_resourceDataSink) _resourceDataSink(id, value);
|
|
60
|
+
}
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SSR resource injectables
|
|
2
|
+
* SSR resource injectables: graph-agnostic module state. The server (@fluixi/server
|
|
3
3
|
* via @fluixi/dom) injects these so async SSR can await in-flight resource fetches and
|
|
4
|
-
* seed resources from server-serialized data on the client. All no-ops when unset
|
|
5
|
-
* zero client/runtime impact. Used by both the TC39 resource core and the legacy graph,
|
|
4
|
+
* seed resources from server-serialized data on the client. All no-ops when unset -> * zero client/runtime impact. Used by both the TC39 resource core and the legacy graph,
|
|
6
5
|
* so they live in a TC39-owned module (not signal.ts, which is being retired).
|
|
7
6
|
*/
|
|
8
7
|
/** Register a sink that receives every resource fetch promise (server: collect & await). */
|
|
9
8
|
export declare function setResourceTracker(fn: ((p: Promise<any>) => void) | null): void;
|
|
10
|
-
/** @internal
|
|
9
|
+
/** @internal: resources report their fetch promise here. */
|
|
11
10
|
export declare function trackResourcePromise(p: Promise<any>): void;
|
|
12
11
|
/** Inject server-serialized resource data (client hydration: seed without refetch). */
|
|
13
12
|
export declare function setServerDataGetter(fn: ((id: string) => {
|
|
14
13
|
value: any;
|
|
15
14
|
} | undefined) | null): void;
|
|
16
|
-
/** @internal
|
|
15
|
+
/** @internal: resources look up seeded data by their SSR id. */
|
|
17
16
|
export declare function getServerData(id: string): {
|
|
18
17
|
value: any;
|
|
19
18
|
} | undefined;
|
|
20
19
|
/** Inject a stable per-resource id source (server render order / hydration order). */
|
|
21
20
|
export declare function setResourceIdSource(fn: (() => string) | null): void;
|
|
22
|
-
/** @internal
|
|
21
|
+
/** @internal, a resource asks for its SSR id at creation; undefined on a plain client. */
|
|
23
22
|
export declare function nextResourceId(): string | undefined;
|
|
24
23
|
/** Inject a sink for resolved resource values (server: collect for serialization). */
|
|
25
24
|
export declare function setResourceDataSink(fn: ((id: string, value: any) => void) | null): void;
|
|
26
|
-
/** @internal
|
|
25
|
+
/** @internal, a resource reports its resolved value here. */
|
|
27
26
|
export declare function reportResourceData(id: string, value: any): void;
|
|
28
27
|
//# sourceMappingURL=ssr-hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-hooks.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/ssr-hooks.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ssr-hooks.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/ssr-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,4FAA4F;AAC5F,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAE/E;AACD,4DAA4D;AAC5D,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAE1D;AAGD,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,IAAI,CAEjG;AACD,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,GAAG,SAAS,CAEpE;AAGD,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI,GAAG,IAAI,CAEnE;AACD,0FAA0F;AAC1F,wBAAgB,cAAc,IAAI,MAAM,GAAG,SAAS,CAEnD;AAGD,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAEvF;AACD,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAE/D"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SSR resource injectables
|
|
2
|
+
* SSR resource injectables: graph-agnostic module state. The server (@fluixi/server
|
|
3
3
|
* via @fluixi/dom) injects these so async SSR can await in-flight resource fetches and
|
|
4
|
-
* seed resources from server-serialized data on the client. All no-ops when unset
|
|
5
|
-
* zero client/runtime impact. Used by both the TC39 resource core and the legacy graph,
|
|
4
|
+
* seed resources from server-serialized data on the client. All no-ops when unset -> * zero client/runtime impact. Used by both the TC39 resource core and the legacy graph,
|
|
6
5
|
* so they live in a TC39-owned module (not signal.ts, which is being retired).
|
|
7
6
|
*/
|
|
8
7
|
let _resourceTracker = null;
|
|
@@ -10,7 +9,7 @@ let _resourceTracker = null;
|
|
|
10
9
|
export function setResourceTracker(fn) {
|
|
11
10
|
_resourceTracker = fn;
|
|
12
11
|
}
|
|
13
|
-
/** @internal
|
|
12
|
+
/** @internal: resources report their fetch promise here. */
|
|
14
13
|
export function trackResourcePromise(p) {
|
|
15
14
|
if (_resourceTracker)
|
|
16
15
|
_resourceTracker(p);
|
|
@@ -20,7 +19,7 @@ let _serverDataGetter = null;
|
|
|
20
19
|
export function setServerDataGetter(fn) {
|
|
21
20
|
_serverDataGetter = fn;
|
|
22
21
|
}
|
|
23
|
-
/** @internal
|
|
22
|
+
/** @internal: resources look up seeded data by their SSR id. */
|
|
24
23
|
export function getServerData(id) {
|
|
25
24
|
return _serverDataGetter ? _serverDataGetter(id) : undefined;
|
|
26
25
|
}
|
|
@@ -29,7 +28,7 @@ let _resourceIdSource = null;
|
|
|
29
28
|
export function setResourceIdSource(fn) {
|
|
30
29
|
_resourceIdSource = fn;
|
|
31
30
|
}
|
|
32
|
-
/** @internal
|
|
31
|
+
/** @internal, a resource asks for its SSR id at creation; undefined on a plain client. */
|
|
33
32
|
export function nextResourceId() {
|
|
34
33
|
return _resourceIdSource ? _resourceIdSource() : undefined;
|
|
35
34
|
}
|
|
@@ -38,7 +37,7 @@ let _resourceDataSink = null;
|
|
|
38
37
|
export function setResourceDataSink(fn) {
|
|
39
38
|
_resourceDataSink = fn;
|
|
40
39
|
}
|
|
41
|
-
/** @internal
|
|
40
|
+
/** @internal, a resource reports its resolved value here. */
|
|
42
41
|
export function reportResourceData(id, value) {
|
|
43
42
|
if (_resourceDataSink)
|
|
44
43
|
_resourceDataSink(id, value);
|
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
// src/lib/signal/graph/ssr-hooks.ts
|
|
2
|
+
var _resourceTracker = null;
|
|
3
|
+
function setResourceTracker(fn) {
|
|
4
|
+
_resourceTracker = fn;
|
|
5
|
+
}
|
|
6
|
+
function trackResourcePromise(p) {
|
|
7
|
+
if (_resourceTracker) _resourceTracker(p);
|
|
8
|
+
}
|
|
9
|
+
var _serverDataGetter = null;
|
|
10
|
+
function setServerDataGetter(fn) {
|
|
11
|
+
_serverDataGetter = fn;
|
|
12
|
+
}
|
|
13
|
+
function getServerData(id) {
|
|
14
|
+
return _serverDataGetter ? _serverDataGetter(id) : void 0;
|
|
15
|
+
}
|
|
16
|
+
var _resourceIdSource = null;
|
|
17
|
+
function setResourceIdSource(fn) {
|
|
18
|
+
_resourceIdSource = fn;
|
|
19
|
+
}
|
|
20
|
+
function nextResourceId() {
|
|
21
|
+
return _resourceIdSource ? _resourceIdSource() : void 0;
|
|
22
|
+
}
|
|
23
|
+
var _resourceDataSink = null;
|
|
24
|
+
function setResourceDataSink(fn) {
|
|
25
|
+
_resourceDataSink = fn;
|
|
26
|
+
}
|
|
27
|
+
function reportResourceData(id, value) {
|
|
28
|
+
if (_resourceDataSink) _resourceDataSink(id, value);
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
getServerData,
|
|
32
|
+
nextResourceId,
|
|
33
|
+
reportResourceData,
|
|
34
|
+
setResourceDataSink,
|
|
35
|
+
setResourceIdSource,
|
|
36
|
+
setResourceTracker,
|
|
37
|
+
setServerDataGetter,
|
|
38
|
+
trackResourcePromise
|
|
39
|
+
};
|
|
@@ -1 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/signal/graph/state.ts
|
|
21
|
+
var state_exports = {};
|
|
22
|
+
__export(state_exports, {
|
|
23
|
+
G: () => G,
|
|
24
|
+
backfillState: () => backfillState,
|
|
25
|
+
joinedVersions: () => joinedVersions
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(state_exports);
|
|
28
|
+
|
|
29
|
+
// src/version.generated.ts
|
|
30
|
+
var VERSION = "1.0.0-alpha.84";
|
|
31
|
+
|
|
32
|
+
// src/lib/signal/graph/state.ts
|
|
33
|
+
var MAJOR = VERSION.split(".")[0];
|
|
34
|
+
var KEY = `__fluixi_signal_state_v${MAJOR}__`;
|
|
35
|
+
var VERSIONS_KEY = `__fluixi_signal_builds_v${MAJOR}__`;
|
|
36
|
+
var defaultSchedule = (run) => {
|
|
37
|
+
if (typeof queueMicrotask === "function") queueMicrotask(run);
|
|
38
|
+
else void Promise.resolve().then(run);
|
|
39
|
+
};
|
|
40
|
+
function defaults() {
|
|
41
|
+
return {
|
|
42
|
+
consumer: null,
|
|
43
|
+
untracked: false,
|
|
44
|
+
owner: null,
|
|
45
|
+
queue: [],
|
|
46
|
+
scheduled: false,
|
|
47
|
+
flushing: false,
|
|
48
|
+
batchDepth: 0,
|
|
49
|
+
hostSchedule: defaultSchedule,
|
|
50
|
+
onSuspend: null,
|
|
51
|
+
onError: null,
|
|
52
|
+
observer: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var realm = globalThis;
|
|
56
|
+
function backfillState(existing) {
|
|
57
|
+
const fresh = defaults();
|
|
58
|
+
const target = existing;
|
|
59
|
+
for (const field of Object.keys(fresh)) {
|
|
60
|
+
if (!(field in existing)) target[field] = fresh[field];
|
|
61
|
+
}
|
|
62
|
+
return existing;
|
|
63
|
+
}
|
|
64
|
+
function claim() {
|
|
65
|
+
const existing = realm[KEY];
|
|
66
|
+
return existing ? backfillState(existing) : realm[KEY] = defaults();
|
|
67
|
+
}
|
|
68
|
+
var G = claim();
|
|
69
|
+
(realm[VERSIONS_KEY] ??= []).push(VERSION);
|
|
70
|
+
function joinedVersions() {
|
|
71
|
+
return [...new Set(realm[VERSIONS_KEY] ?? [])];
|
|
72
|
+
}
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The reactive graph's mutable state, kept as a
|
|
2
|
+
* The reactive graph's mutable state, kept as a single object cached on globalThis.
|
|
3
3
|
*
|
|
4
|
-
* Why
|
|
4
|
+
* Why, tracking/scheduling reads module-global state ("who's the current consumer?",
|
|
5
5
|
* "what owner are we under?", "the effect queue"). If a production bundle emits more
|
|
6
|
-
* than one copy of this module (a common cross-package hazard
|
|
7
|
-
* integration bridge), plain `let`s would be
|
|
8
|
-
* consumer while a signal read checks copy B's
|
|
6
|
+
* than one copy of this module (a common cross-package hazard: see @fluixi/dom's
|
|
7
|
+
* integration bridge), plain `let`s would be duplicated: an effect would set copy A's
|
|
8
|
+
* consumer while a signal read checks copy B's -> no subscription -> reactivity silently
|
|
9
9
|
* lost (works in dev, breaks in prod). Caching the state on globalThis means every copy
|
|
10
|
-
* of this module reads/writes the
|
|
11
|
-
* many times the module is bundled
|
|
10
|
+
* of this module reads/writes the same object, so the graph stays unified no matter how
|
|
11
|
+
* many times the module is bundled, no integration bridge required.
|
|
12
12
|
*
|
|
13
13
|
* This is strictly more robust than SolidJS, which keeps this state in module `let`s and
|
|
14
14
|
* relies on dedup + a "multiple instances" warning. Node-ref fields are loosely typed
|
|
15
15
|
* (`any`) to avoid import cycles with core.ts/runtime.ts; the public API stays fully typed.
|
|
16
|
+
*
|
|
17
|
+
* Sharing is deliberate, and a standalone web component makes it load-bearing: several
|
|
18
|
+
* independent bundles can land on one page, each carrying its own copy of this module, and they
|
|
19
|
+
* have to end up on one graph or an effect in one will not see a signal from another.
|
|
20
|
+
*
|
|
21
|
+
* Two consequences that the original `??=` got wrong once more than one version is in play.
|
|
22
|
+
* The first copy to run used to define the whole object, so a field added in a later
|
|
23
|
+
* release stayed absent for every copy, including the one that expected it. Fields are
|
|
24
|
+
* backfilled now instead. And nothing recorded which builds had joined, so a genuine
|
|
25
|
+
* mismatch was invisible; `joinedVersions()` reports it, and @fluixi/dom's version-skew
|
|
26
|
+
* warning is where that surfaces.
|
|
16
27
|
*/
|
|
17
28
|
export interface GraphState {
|
|
18
|
-
/** The computation currently evaluating
|
|
29
|
+
/** The computation currently evaluating: reads inside it subscribe to it. */
|
|
19
30
|
consumer: any;
|
|
20
31
|
/** When true, reads don't subscribe (untrack / peek). */
|
|
21
32
|
untracked: boolean;
|
|
@@ -27,17 +38,39 @@ export interface GraphState {
|
|
|
27
38
|
disposed: boolean;
|
|
28
39
|
run(): void;
|
|
29
40
|
}>;
|
|
30
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Effects are queued and a flush is pending.
|
|
43
|
+
*
|
|
44
|
+
* Not a microtask on the shipped path: `compat.ts` installs a no-op host scheduler
|
|
45
|
+
* and flushes explicitly after a write, so this says a drain is owed rather than
|
|
46
|
+
* that one is booked.
|
|
47
|
+
*/
|
|
31
48
|
scheduled: boolean;
|
|
32
49
|
/** A flush is in progress (re-entrancy guard). */
|
|
33
50
|
flushing: boolean;
|
|
34
51
|
/** Depth of active batch() calls; >0 defers flushing. */
|
|
35
52
|
batchDepth: number;
|
|
36
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* How a pending drain gets run. `compat.ts` sets it to a no-op because it owns the
|
|
55
|
+
* flush points itself; `setScheduler(null)` restores the microtask default. SSR and
|
|
56
|
+
* tests override it too.
|
|
57
|
+
*/
|
|
37
58
|
hostSchedule: (run: () => void) => void;
|
|
38
59
|
/** Boundary hooks (injected by the Suspense / error-boundary layers). */
|
|
39
60
|
onSuspend: ((promise: Promise<unknown>, owner: any) => void) | null;
|
|
40
61
|
onError: ((error: unknown, owner: any) => boolean) | null;
|
|
62
|
+
/** A tool watching the graph (see observe.ts). Here for the same reason the rest is. */
|
|
63
|
+
observer: any;
|
|
41
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Add any field this release reads that an earlier copy never created.
|
|
67
|
+
*
|
|
68
|
+
* `in` rather than `??`, so a field whose default is null is not rewritten every time
|
|
69
|
+
* another copy loads. Mutates and returns the object it was given, because the whole
|
|
70
|
+
* point is that every copy keeps pointing at the same one.
|
|
71
|
+
*/
|
|
72
|
+
export declare function backfillState(existing: GraphState): GraphState;
|
|
42
73
|
export declare const G: GraphState;
|
|
74
|
+
/** Every `@fluixi/reactive` build that has joined the shared graph, deduplicated. */
|
|
75
|
+
export declare function joinedVersions(): string[];
|
|
43
76
|
//# sourceMappingURL=state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/state.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,MAAM,WAAW,UAAU;IACzB,6EAA6E;IAE7E,QAAQ,EAAE,GAAG,CAAC;IACd,yDAAyD;IACzD,SAAS,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAE5D,KAAK,EAAE,GAAG,CAAC;IACX,sCAAsC;IACtC,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAC;QAAC,GAAG,IAAI,IAAI,CAAA;KAAE,CAAC,CAAC;IAClE;;;;;;OAMG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,kDAAkD;IAClD,QAAQ,EAAE,OAAO,CAAC;IAClB,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IACxC,yEAAyE;IAEzE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAEpE,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,IAAI,CAAC;IAC1D,wFAAwF;IAExF,QAAQ,EAAE,GAAG,CAAC;CACf;AA6CD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAO9D;AAOD,eAAO,MAAM,CAAC,EAAE,UAAoB,CAAC;AAQrC,qFAAqF;AACrF,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAEzC"}
|
|
@@ -1,37 +1,99 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The reactive graph's mutable state, kept as a
|
|
2
|
+
* The reactive graph's mutable state, kept as a single object cached on globalThis.
|
|
3
3
|
*
|
|
4
|
-
* Why
|
|
4
|
+
* Why, tracking/scheduling reads module-global state ("who's the current consumer?",
|
|
5
5
|
* "what owner are we under?", "the effect queue"). If a production bundle emits more
|
|
6
|
-
* than one copy of this module (a common cross-package hazard
|
|
7
|
-
* integration bridge), plain `let`s would be
|
|
8
|
-
* consumer while a signal read checks copy B's
|
|
6
|
+
* than one copy of this module (a common cross-package hazard: see @fluixi/dom's
|
|
7
|
+
* integration bridge), plain `let`s would be duplicated: an effect would set copy A's
|
|
8
|
+
* consumer while a signal read checks copy B's -> no subscription -> reactivity silently
|
|
9
9
|
* lost (works in dev, breaks in prod). Caching the state on globalThis means every copy
|
|
10
|
-
* of this module reads/writes the
|
|
11
|
-
* many times the module is bundled
|
|
10
|
+
* of this module reads/writes the same object, so the graph stays unified no matter how
|
|
11
|
+
* many times the module is bundled, no integration bridge required.
|
|
12
12
|
*
|
|
13
13
|
* This is strictly more robust than SolidJS, which keeps this state in module `let`s and
|
|
14
14
|
* relies on dedup + a "multiple instances" warning. Node-ref fields are loosely typed
|
|
15
15
|
* (`any`) to avoid import cycles with core.ts/runtime.ts; the public API stays fully typed.
|
|
16
|
+
*
|
|
17
|
+
* Sharing is deliberate, and a standalone web component makes it load-bearing: several
|
|
18
|
+
* independent bundles can land on one page, each carrying its own copy of this module, and they
|
|
19
|
+
* have to end up on one graph or an effect in one will not see a signal from another.
|
|
20
|
+
*
|
|
21
|
+
* Two consequences that the original `??=` got wrong once more than one version is in play.
|
|
22
|
+
* The first copy to run used to define the whole object, so a field added in a later
|
|
23
|
+
* release stayed absent for every copy, including the one that expected it. Fields are
|
|
24
|
+
* backfilled now instead. And nothing recorded which builds had joined, so a genuine
|
|
25
|
+
* mismatch was invisible; `joinedVersions()` reports it, and @fluixi/dom's version-skew
|
|
26
|
+
* warning is where that surfaces.
|
|
27
|
+
*/
|
|
28
|
+
import { VERSION } from '../../../version.generated.js';
|
|
29
|
+
/**
|
|
30
|
+
* The graph is shared per major version.
|
|
31
|
+
*
|
|
32
|
+
* Copies of one major share it, which is the point: several bundles on a page each carry
|
|
33
|
+
* their own copy of this module, and an effect in one has to see a signal from another.
|
|
34
|
+
* Fields are backfilled below so a copy from a later release finds what it expects.
|
|
35
|
+
*
|
|
36
|
+
* A different major gets its own graph instead. Within a major the state shape only
|
|
37
|
+
* grows, so backfilling is enough; across one it can change meaning, and sharing then
|
|
38
|
+
* means the older copy's semantics silently win for everybody. Two isolated graphs on a
|
|
39
|
+
* page is a visible problem. One graph running two sets of rules is not.
|
|
40
|
+
*
|
|
41
|
+
* Derived from the package version rather than written by hand, so it cannot be
|
|
42
|
+
* forgotten at a major bump.
|
|
16
43
|
*/
|
|
17
|
-
const
|
|
44
|
+
const MAJOR = VERSION.split('.')[0];
|
|
45
|
+
const KEY = `__fluixi_signal_state_v${MAJOR}__`;
|
|
46
|
+
const VERSIONS_KEY = `__fluixi_signal_builds_v${MAJOR}__`;
|
|
18
47
|
const defaultSchedule = (run) => {
|
|
19
48
|
if (typeof queueMicrotask === 'function')
|
|
20
49
|
queueMicrotask(run);
|
|
21
50
|
else
|
|
22
51
|
void Promise.resolve().then(run);
|
|
23
52
|
};
|
|
24
|
-
|
|
53
|
+
function defaults() {
|
|
54
|
+
return {
|
|
55
|
+
consumer: null,
|
|
56
|
+
untracked: false,
|
|
57
|
+
owner: null,
|
|
58
|
+
queue: [],
|
|
59
|
+
scheduled: false,
|
|
60
|
+
flushing: false,
|
|
61
|
+
batchDepth: 0,
|
|
62
|
+
hostSchedule: defaultSchedule,
|
|
63
|
+
onSuspend: null,
|
|
64
|
+
onError: null,
|
|
65
|
+
observer: null,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
25
68
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
69
|
+
const realm = globalThis;
|
|
70
|
+
/**
|
|
71
|
+
* Add any field this release reads that an earlier copy never created.
|
|
72
|
+
*
|
|
73
|
+
* `in` rather than `??`, so a field whose default is null is not rewritten every time
|
|
74
|
+
* another copy loads. Mutates and returns the object it was given, because the whole
|
|
75
|
+
* point is that every copy keeps pointing at the same one.
|
|
76
|
+
*/
|
|
77
|
+
export function backfillState(existing) {
|
|
78
|
+
const fresh = defaults();
|
|
79
|
+
const target = existing;
|
|
80
|
+
for (const field of Object.keys(fresh)) {
|
|
81
|
+
if (!(field in existing))
|
|
82
|
+
target[field] = fresh[field];
|
|
83
|
+
}
|
|
84
|
+
return existing;
|
|
85
|
+
}
|
|
86
|
+
function claim() {
|
|
87
|
+
const existing = realm[KEY];
|
|
88
|
+
return existing ? backfillState(existing) : (realm[KEY] = defaults());
|
|
89
|
+
}
|
|
90
|
+
export const G = claim();
|
|
91
|
+
// Which builds of this module reached the shared graph, in the order they loaded.
|
|
92
|
+
// One entry is the normal case. More than one distinct version means two releases are
|
|
93
|
+
// driving the same graph, which is worth saying out loud but not worth refusing: the
|
|
94
|
+
// alternative is a page where half the components are inert.
|
|
95
|
+
(realm[VERSIONS_KEY] ??= []).push(VERSION);
|
|
96
|
+
/** Every `@fluixi/reactive` build that has joined the shared graph, deduplicated. */
|
|
97
|
+
export function joinedVersions() {
|
|
98
|
+
return [...new Set((realm[VERSIONS_KEY] ?? []))];
|
|
99
|
+
}
|
|
@@ -1 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
// src/version.generated.ts
|
|
2
|
+
var VERSION = "1.0.0-alpha.84";
|
|
3
|
+
|
|
4
|
+
// src/lib/signal/graph/state.ts
|
|
5
|
+
var MAJOR = VERSION.split(".")[0];
|
|
6
|
+
var KEY = `__fluixi_signal_state_v${MAJOR}__`;
|
|
7
|
+
var VERSIONS_KEY = `__fluixi_signal_builds_v${MAJOR}__`;
|
|
8
|
+
var defaultSchedule = (run) => {
|
|
9
|
+
if (typeof queueMicrotask === "function") queueMicrotask(run);
|
|
10
|
+
else void Promise.resolve().then(run);
|
|
11
|
+
};
|
|
12
|
+
function defaults() {
|
|
13
|
+
return {
|
|
14
|
+
consumer: null,
|
|
15
|
+
untracked: false,
|
|
16
|
+
owner: null,
|
|
17
|
+
queue: [],
|
|
18
|
+
scheduled: false,
|
|
19
|
+
flushing: false,
|
|
20
|
+
batchDepth: 0,
|
|
21
|
+
hostSchedule: defaultSchedule,
|
|
22
|
+
onSuspend: null,
|
|
23
|
+
onError: null,
|
|
24
|
+
observer: null
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var realm = globalThis;
|
|
28
|
+
function backfillState(existing) {
|
|
29
|
+
const fresh = defaults();
|
|
30
|
+
const target = existing;
|
|
31
|
+
for (const field of Object.keys(fresh)) {
|
|
32
|
+
if (!(field in existing)) target[field] = fresh[field];
|
|
33
|
+
}
|
|
34
|
+
return existing;
|
|
35
|
+
}
|
|
36
|
+
function claim() {
|
|
37
|
+
const existing = realm[KEY];
|
|
38
|
+
return existing ? backfillState(existing) : realm[KEY] = defaults();
|
|
39
|
+
}
|
|
40
|
+
var G = claim();
|
|
41
|
+
(realm[VERSIONS_KEY] ??= []).push(VERSION);
|
|
42
|
+
function joinedVersions() {
|
|
43
|
+
return [...new Set(realm[VERSIONS_KEY] ?? [])];
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
G,
|
|
47
|
+
backfillState,
|
|
48
|
+
joinedVersions
|
|
49
|
+
};
|