@fluixi/reactive 1.0.0-alpha.100
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 +21 -0
- package/README.md +280 -0
- package/dist/cdn/reactive.cjs +2803 -0
- package/dist/cdn/reactive.d.ts +11 -0
- package/dist/cdn/reactive.d.ts.map +1 -0
- package/dist/cdn/reactive.global.js +2 -0
- package/dist/cdn/reactive.js +10 -0
- package/dist/cdn/reactive.mjs +2787 -0
- package/dist/cdn/signal.cjs +299 -0
- package/dist/cdn/signal.d.ts +19 -0
- package/dist/cdn/signal.d.ts.map +1 -0
- package/dist/cdn/signal.global.js +2 -0
- package/dist/cdn/signal.js +18 -0
- package/dist/cdn/signal.mjs +276 -0
- package/dist/index.cjs +2803 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +2787 -0
- package/dist/lib/index.cjs +2804 -0
- package/dist/lib/index.d.ts +8 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +11 -0
- package/dist/lib/index.mjs +2789 -0
- package/dist/lib/observable/index.cjs +386 -0
- package/dist/lib/observable/index.d.ts +4 -0
- package/dist/lib/observable/index.d.ts.map +1 -0
- package/dist/lib/observable/index.js +3 -0
- package/dist/lib/observable/index.mjs +364 -0
- package/dist/lib/observable/observable.cjs +384 -0
- package/dist/lib/observable/observable.d.ts +246 -0
- package/dist/lib/observable/observable.d.ts.map +1 -0
- package/dist/lib/observable/observable.js +268 -0
- package/dist/lib/observable/observable.mjs +361 -0
- package/dist/lib/observable/subscription.cjs +180 -0
- package/dist/lib/observable/subscription.d.ts +58 -0
- package/dist/lib/observable/subscription.d.ts.map +1 -0
- package/dist/lib/observable/subscription.js +177 -0
- package/dist/lib/observable/subscription.mjs +157 -0
- package/dist/lib/observable/types.cjs +18 -0
- package/dist/lib/observable/types.d.ts +44 -0
- package/dist/lib/observable/types.d.ts.map +1 -0
- package/dist/lib/observable/types.js +1 -0
- package/dist/lib/observable/types.mjs +0 -0
- package/dist/lib/predicates.cjs +44 -0
- package/dist/lib/predicates.d.ts +37 -0
- package/dist/lib/predicates.d.ts.map +1 -0
- package/dist/lib/predicates.js +62 -0
- package/dist/lib/predicates.mjs +23 -0
- package/dist/lib/signal/api.cjs +592 -0
- package/dist/lib/signal/api.d.ts +227 -0
- package/dist/lib/signal/api.d.ts.map +1 -0
- package/dist/lib/signal/api.js +228 -0
- package/dist/lib/signal/api.mjs +569 -0
- package/dist/lib/signal/cached-resource.cjs +726 -0
- package/dist/lib/signal/cached-resource.d.ts +86 -0
- package/dist/lib/signal/cached-resource.d.ts.map +1 -0
- package/dist/lib/signal/cached-resource.js +250 -0
- package/dist/lib/signal/cached-resource.mjs +704 -0
- package/dist/lib/signal/graph/children.cjs +326 -0
- package/dist/lib/signal/graph/children.d.ts +2 -0
- package/dist/lib/signal/graph/children.d.ts.map +1 -0
- package/dist/lib/signal/graph/children.js +30 -0
- package/dist/lib/signal/graph/children.mjs +303 -0
- package/dist/lib/signal/graph/compat.cjs +590 -0
- package/dist/lib/signal/graph/compat.d.ts +66 -0
- package/dist/lib/signal/graph/compat.d.ts.map +1 -0
- package/dist/lib/signal/graph/compat.js +197 -0
- package/dist/lib/signal/graph/compat.mjs +568 -0
- package/dist/lib/signal/graph/core.cjs +295 -0
- package/dist/lib/signal/graph/core.d.ts +99 -0
- package/dist/lib/signal/graph/core.d.ts.map +1 -0
- package/dist/lib/signal/graph/core.js +268 -0
- package/dist/lib/signal/graph/core.mjs +273 -0
- package/dist/lib/signal/graph/debounced.cjs +680 -0
- package/dist/lib/signal/graph/debounced.d.ts +67 -0
- package/dist/lib/signal/graph/debounced.d.ts.map +1 -0
- package/dist/lib/signal/graph/debounced.js +92 -0
- package/dist/lib/signal/graph/debounced.mjs +657 -0
- package/dist/lib/signal/graph/derived.cjs +508 -0
- package/dist/lib/signal/graph/derived.d.ts +14 -0
- package/dist/lib/signal/graph/derived.d.ts.map +1 -0
- package/dist/lib/signal/graph/derived.js +65 -0
- package/dist/lib/signal/graph/derived.mjs +485 -0
- package/dist/lib/signal/graph/detect.cjs +66 -0
- package/dist/lib/signal/graph/detect.d.ts +17 -0
- package/dist/lib/signal/graph/detect.d.ts.map +1 -0
- package/dist/lib/signal/graph/detect.js +39 -0
- package/dist/lib/signal/graph/detect.mjs +45 -0
- package/dist/lib/signal/graph/error-boundary.cjs +313 -0
- package/dist/lib/signal/graph/error-boundary.d.ts +16 -0
- package/dist/lib/signal/graph/error-boundary.d.ts.map +1 -0
- package/dist/lib/signal/graph/error-boundary.js +34 -0
- package/dist/lib/signal/graph/error-boundary.mjs +290 -0
- package/dist/lib/signal/graph/index.cjs +305 -0
- package/dist/lib/signal/graph/index.d.ts +22 -0
- package/dist/lib/signal/graph/index.d.ts.map +1 -0
- package/dist/lib/signal/graph/index.js +21 -0
- package/dist/lib/signal/graph/index.mjs +283 -0
- package/dist/lib/signal/graph/observe.cjs +198 -0
- package/dist/lib/signal/graph/observe.d.ts +185 -0
- package/dist/lib/signal/graph/observe.d.ts.map +1 -0
- package/dist/lib/signal/graph/observe.js +198 -0
- package/dist/lib/signal/graph/observe.mjs +175 -0
- package/dist/lib/signal/graph/resource.cjs +632 -0
- package/dist/lib/signal/graph/resource.d.ts +39 -0
- package/dist/lib/signal/graph/resource.d.ts.map +1 -0
- package/dist/lib/signal/graph/resource.js +165 -0
- package/dist/lib/signal/graph/resource.mjs +609 -0
- package/dist/lib/signal/graph/runtime.cjs +522 -0
- package/dist/lib/signal/graph/runtime.d.ts +80 -0
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -0
- package/dist/lib/signal/graph/runtime.js +358 -0
- package/dist/lib/signal/graph/runtime.mjs +499 -0
- package/dist/lib/signal/graph/signal-next.cjs +1249 -0
- package/dist/lib/signal/graph/signal-next.d.ts +38 -0
- package/dist/lib/signal/graph/signal-next.d.ts.map +1 -0
- package/dist/lib/signal/graph/signal-next.js +44 -0
- package/dist/lib/signal/graph/signal-next.mjs +1227 -0
- package/dist/lib/signal/graph/ssr-hooks.cjs +89 -0
- package/dist/lib/signal/graph/ssr-hooks.d.ts +51 -0
- package/dist/lib/signal/graph/ssr-hooks.d.ts.map +1 -0
- package/dist/lib/signal/graph/ssr-hooks.js +80 -0
- package/dist/lib/signal/graph/ssr-hooks.mjs +68 -0
- package/dist/lib/signal/graph/state.cjs +72 -0
- package/dist/lib/signal/graph/state.d.ts +76 -0
- package/dist/lib/signal/graph/state.d.ts.map +1 -0
- package/dist/lib/signal/graph/state.js +99 -0
- package/dist/lib/signal/graph/state.mjs +49 -0
- package/dist/lib/signal/graph/suspense.cjs +313 -0
- package/dist/lib/signal/graph/suspense.d.ts +13 -0
- package/dist/lib/signal/graph/suspense.d.ts.map +1 -0
- package/dist/lib/signal/graph/suspense.js +36 -0
- package/dist/lib/signal/graph/suspense.mjs +290 -0
- package/dist/lib/signal/index-legacy.cjs +2582 -0
- package/dist/lib/signal/index-legacy.d.ts +12 -0
- package/dist/lib/signal/index-legacy.d.ts.map +1 -0
- package/dist/lib/signal/index-legacy.js +11 -0
- package/dist/lib/signal/index-legacy.mjs +2560 -0
- package/dist/lib/signal/index.cjs +1350 -0
- package/dist/lib/signal/index.d.ts +19 -0
- package/dist/lib/signal/index.d.ts.map +1 -0
- package/dist/lib/signal/index.js +19 -0
- package/dist/lib/signal/index.mjs +1328 -0
- package/dist/lib/signal/list.cjs +561 -0
- package/dist/lib/signal/list.d.ts +39 -0
- package/dist/lib/signal/list.d.ts.map +1 -0
- package/dist/lib/signal/list.js +172 -0
- package/dist/lib/signal/list.mjs +538 -0
- package/dist/lib/signal/resource-api.cjs +638 -0
- package/dist/lib/signal/resource-api.d.ts +19 -0
- package/dist/lib/signal/resource-api.d.ts.map +1 -0
- package/dist/lib/signal/resource-api.js +27 -0
- package/dist/lib/signal/resource-api.mjs +615 -0
- package/dist/lib/signal/signal.cjs +2035 -0
- package/dist/lib/signal/signal.d.ts +303 -0
- package/dist/lib/signal/signal.d.ts.map +1 -0
- package/dist/lib/signal/signal.js +1233 -0
- package/dist/lib/signal/signal.mjs +2012 -0
- package/dist/lib/signal/types.cjs +38 -0
- package/dist/lib/signal/types.d.ts +133 -0
- package/dist/lib/signal/types.d.ts.map +1 -0
- package/dist/lib/signal/types.js +38 -0
- package/dist/lib/signal/types.mjs +17 -0
- package/dist/lib/signal/utilities.cjs +1024 -0
- package/dist/lib/signal/utilities.d.ts +247 -0
- package/dist/lib/signal/utilities.d.ts.map +1 -0
- package/dist/lib/signal/utilities.js +346 -0
- package/dist/lib/signal/utilities.mjs +1002 -0
- package/dist/lib/store/api.cjs +662 -0
- package/dist/lib/store/api.d.ts +40 -0
- package/dist/lib/store/api.d.ts.map +1 -0
- package/dist/lib/store/api.js +63 -0
- package/dist/lib/store/api.mjs +646 -0
- package/dist/lib/store/index.cjs +741 -0
- package/dist/lib/store/index.d.ts +16 -0
- package/dist/lib/store/index.d.ts.map +1 -0
- package/dist/lib/store/index.js +13 -0
- package/dist/lib/store/index.mjs +726 -0
- package/dist/lib/store/setter.types.cjs +18 -0
- package/dist/lib/store/setter.types.d.ts +131 -0
- package/dist/lib/store/setter.types.d.ts.map +1 -0
- package/dist/lib/store/setter.types.js +65 -0
- package/dist/lib/store/setter.types.mjs +0 -0
- package/dist/lib/store/store.cjs +708 -0
- package/dist/lib/store/store.d.ts +142 -0
- package/dist/lib/store/store.d.ts.map +1 -0
- package/dist/lib/store/store.js +812 -0
- package/dist/lib/store/store.mjs +694 -0
- package/dist/lib/store/types.cjs +18 -0
- package/dist/lib/store/types.d.ts +57 -0
- package/dist/lib/store/types.d.ts.map +1 -0
- package/dist/lib/store/types.js +1 -0
- package/dist/lib/store/types.mjs +0 -0
- package/dist/lib/store/utils.cjs +43 -0
- package/dist/lib/store/utils.d.ts +13 -0
- package/dist/lib/store/utils.d.ts.map +1 -0
- package/dist/lib/store/utils.js +29 -0
- package/dist/lib/store/utils.mjs +22 -0
- package/dist/lib/subject.cjs +450 -0
- package/dist/lib/subject.d.ts +14 -0
- package/dist/lib/subject.d.ts.map +1 -0
- package/dist/lib/subject.js +81 -0
- package/dist/lib/subject.mjs +427 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/dist/version.generated.cjs +27 -0
- package/dist/version.generated.d.ts +3 -0
- package/dist/version.generated.d.ts.map +1 -0
- package/dist/version.generated.js +3 -0
- package/dist/version.generated.mjs +7 -0
- package/package.json +115 -0
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
createResourceCache: () => createResourceCache,
|
|
24
|
+
currentResourceCache: () => currentResourceCache,
|
|
25
|
+
getServerData: () => getServerData,
|
|
26
|
+
nextResourceId: () => nextResourceId,
|
|
27
|
+
reportResourceData: () => reportResourceData,
|
|
28
|
+
setResourceCacheScope: () => setResourceCacheScope,
|
|
29
|
+
setResourceDataSink: () => setResourceDataSink,
|
|
30
|
+
setResourceIdSource: () => setResourceIdSource,
|
|
31
|
+
setResourceTracker: () => setResourceTracker,
|
|
32
|
+
setServerDataGetter: () => setServerDataGetter,
|
|
33
|
+
trackResourcePromise: () => trackResourcePromise
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(ssr_hooks_exports);
|
|
36
|
+
var _resourceTracker = null;
|
|
37
|
+
function setResourceTracker(fn) {
|
|
38
|
+
_resourceTracker = fn;
|
|
39
|
+
}
|
|
40
|
+
function trackResourcePromise(p) {
|
|
41
|
+
if (_resourceTracker) _resourceTracker(p);
|
|
42
|
+
}
|
|
43
|
+
var _serverDataGetter = null;
|
|
44
|
+
function setServerDataGetter(fn) {
|
|
45
|
+
_serverDataGetter = fn;
|
|
46
|
+
}
|
|
47
|
+
function getServerData(id) {
|
|
48
|
+
return _serverDataGetter ? _serverDataGetter(id) : void 0;
|
|
49
|
+
}
|
|
50
|
+
var _resourceIdSource = null;
|
|
51
|
+
function setResourceIdSource(fn) {
|
|
52
|
+
_resourceIdSource = fn;
|
|
53
|
+
}
|
|
54
|
+
function nextResourceId() {
|
|
55
|
+
return _resourceIdSource ? _resourceIdSource() : void 0;
|
|
56
|
+
}
|
|
57
|
+
var _resourceDataSink = null;
|
|
58
|
+
function setResourceDataSink(fn) {
|
|
59
|
+
_resourceDataSink = fn;
|
|
60
|
+
}
|
|
61
|
+
function reportResourceData(id, value) {
|
|
62
|
+
if (_resourceDataSink) _resourceDataSink(id, value);
|
|
63
|
+
}
|
|
64
|
+
function createResourceCache() {
|
|
65
|
+
const entries = /* @__PURE__ */ new Map();
|
|
66
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
67
|
+
return {
|
|
68
|
+
get: (key) => entries.get(key),
|
|
69
|
+
set: (key, entry) => void entries.set(key, entry),
|
|
70
|
+
delete: (key) => void entries.delete(key),
|
|
71
|
+
keys: () => entries.keys(),
|
|
72
|
+
clear: () => {
|
|
73
|
+
entries.clear();
|
|
74
|
+
inflight.clear();
|
|
75
|
+
},
|
|
76
|
+
inflight
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
var _cacheScope = null;
|
|
80
|
+
function setResourceCacheScope(fn) {
|
|
81
|
+
_cacheScope = fn;
|
|
82
|
+
}
|
|
83
|
+
var _pageCache;
|
|
84
|
+
function currentResourceCache() {
|
|
85
|
+
const scoped = _cacheScope?.();
|
|
86
|
+
if (scoped) return scoped;
|
|
87
|
+
if (typeof window === "undefined") return createResourceCache();
|
|
88
|
+
return _pageCache ??= createResourceCache();
|
|
89
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSR resource injectables: graph-agnostic module state. The server (@fluixi/server
|
|
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 -> * zero client/runtime impact. Used by both the TC39 resource core and the legacy graph,
|
|
5
|
+
* so they live in a TC39-owned module (not signal.ts, which is being retired).
|
|
6
|
+
*/
|
|
7
|
+
/** Register a sink that receives every resource fetch promise (server: collect & await). */
|
|
8
|
+
export declare function setResourceTracker(fn: ((p: Promise<any>) => void) | null): void;
|
|
9
|
+
/** @internal: resources report their fetch promise here. */
|
|
10
|
+
export declare function trackResourcePromise(p: Promise<any>): void;
|
|
11
|
+
/** Inject server-serialized resource data (client hydration: seed without refetch). */
|
|
12
|
+
export declare function setServerDataGetter(fn: ((id: string) => {
|
|
13
|
+
value: any;
|
|
14
|
+
} | undefined) | null): void;
|
|
15
|
+
/** @internal: resources look up seeded data by their SSR id. */
|
|
16
|
+
export declare function getServerData(id: string): {
|
|
17
|
+
value: any;
|
|
18
|
+
} | undefined;
|
|
19
|
+
/** Inject a stable per-resource id source (server render order / hydration order). */
|
|
20
|
+
export declare function setResourceIdSource(fn: (() => string) | null): void;
|
|
21
|
+
/** @internal, a resource asks for its SSR id at creation; undefined on a plain client. */
|
|
22
|
+
export declare function nextResourceId(): string | undefined;
|
|
23
|
+
/** Inject a sink for resolved resource values (server: collect for serialization). */
|
|
24
|
+
export declare function setResourceDataSink(fn: ((id: string, value: any) => void) | null): void;
|
|
25
|
+
/** @internal, a resource reports its resolved value here. */
|
|
26
|
+
export declare function reportResourceData(id: string, value: any): void;
|
|
27
|
+
/** Where cached resources keep their entries and in-flight fetches. */
|
|
28
|
+
export interface ResourceCacheEntry {
|
|
29
|
+
value: unknown;
|
|
30
|
+
/** Date.now() when it was fetched. */
|
|
31
|
+
timestamp: number;
|
|
32
|
+
}
|
|
33
|
+
export interface ResourceCache {
|
|
34
|
+
get(key: string): ResourceCacheEntry | undefined;
|
|
35
|
+
set(key: string, entry: ResourceCacheEntry): void;
|
|
36
|
+
delete(key: string): void;
|
|
37
|
+
keys(): Iterable<string>;
|
|
38
|
+
clear(): void;
|
|
39
|
+
/** Fetches running now, by key, so two readers share one request. Same scope as the entries. */
|
|
40
|
+
readonly inflight: Map<string, Promise<unknown>>;
|
|
41
|
+
}
|
|
42
|
+
/** A cache held in memory, values kept as they are (Dates, class instances). */
|
|
43
|
+
export declare function createResourceCache(): ResourceCache;
|
|
44
|
+
/**
|
|
45
|
+
* Inject the cache for the current scope. The server sets one per request, so two visitors
|
|
46
|
+
* never share an entry or an in-flight fetch.
|
|
47
|
+
*/
|
|
48
|
+
export declare function setResourceCacheScope(fn: (() => ResourceCache | undefined) | null): void;
|
|
49
|
+
/** The cache for where this runs: the injected scope, else the page in a browser, else a private one. */
|
|
50
|
+
export declare function currentResourceCache(): ResourceCache;
|
|
51
|
+
//# sourceMappingURL=ssr-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAED,uEAAuE;AACvE,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAAC;IACjD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAClD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,KAAK,IAAI,IAAI,CAAC;IACd,gGAAgG;IAChG,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CAClD;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,IAAI,aAAa,CAcnD;AAGD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,IAAI,CAExF;AAKD,yGAAyG;AACzG,wBAAgB,oBAAoB,IAAI,aAAa,CAMpD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSR resource injectables: graph-agnostic module state. The server (@fluixi/server
|
|
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 -> * zero client/runtime impact. Used by both the TC39 resource core and the legacy graph,
|
|
5
|
+
* so they live in a TC39-owned module (not signal.ts, which is being retired).
|
|
6
|
+
*/
|
|
7
|
+
let _resourceTracker = null;
|
|
8
|
+
/** Register a sink that receives every resource fetch promise (server: collect & await). */
|
|
9
|
+
export function setResourceTracker(fn) {
|
|
10
|
+
_resourceTracker = fn;
|
|
11
|
+
}
|
|
12
|
+
/** @internal: resources report their fetch promise here. */
|
|
13
|
+
export function trackResourcePromise(p) {
|
|
14
|
+
if (_resourceTracker)
|
|
15
|
+
_resourceTracker(p);
|
|
16
|
+
}
|
|
17
|
+
let _serverDataGetter = null;
|
|
18
|
+
/** Inject server-serialized resource data (client hydration: seed without refetch). */
|
|
19
|
+
export function setServerDataGetter(fn) {
|
|
20
|
+
_serverDataGetter = fn;
|
|
21
|
+
}
|
|
22
|
+
/** @internal: resources look up seeded data by their SSR id. */
|
|
23
|
+
export function getServerData(id) {
|
|
24
|
+
return _serverDataGetter ? _serverDataGetter(id) : undefined;
|
|
25
|
+
}
|
|
26
|
+
let _resourceIdSource = null;
|
|
27
|
+
/** Inject a stable per-resource id source (server render order / hydration order). */
|
|
28
|
+
export function setResourceIdSource(fn) {
|
|
29
|
+
_resourceIdSource = fn;
|
|
30
|
+
}
|
|
31
|
+
/** @internal, a resource asks for its SSR id at creation; undefined on a plain client. */
|
|
32
|
+
export function nextResourceId() {
|
|
33
|
+
return _resourceIdSource ? _resourceIdSource() : undefined;
|
|
34
|
+
}
|
|
35
|
+
let _resourceDataSink = null;
|
|
36
|
+
/** Inject a sink for resolved resource values (server: collect for serialization). */
|
|
37
|
+
export function setResourceDataSink(fn) {
|
|
38
|
+
_resourceDataSink = fn;
|
|
39
|
+
}
|
|
40
|
+
/** @internal, a resource reports its resolved value here. */
|
|
41
|
+
export function reportResourceData(id, value) {
|
|
42
|
+
if (_resourceDataSink)
|
|
43
|
+
_resourceDataSink(id, value);
|
|
44
|
+
}
|
|
45
|
+
/** A cache held in memory, values kept as they are (Dates, class instances). */
|
|
46
|
+
export function createResourceCache() {
|
|
47
|
+
const entries = new Map();
|
|
48
|
+
const inflight = new Map();
|
|
49
|
+
return {
|
|
50
|
+
get: (key) => entries.get(key),
|
|
51
|
+
set: (key, entry) => void entries.set(key, entry),
|
|
52
|
+
delete: (key) => void entries.delete(key),
|
|
53
|
+
keys: () => entries.keys(),
|
|
54
|
+
clear: () => {
|
|
55
|
+
entries.clear();
|
|
56
|
+
inflight.clear();
|
|
57
|
+
},
|
|
58
|
+
inflight,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
let _cacheScope = null;
|
|
62
|
+
/**
|
|
63
|
+
* Inject the cache for the current scope. The server sets one per request, so two visitors
|
|
64
|
+
* never share an entry or an in-flight fetch.
|
|
65
|
+
*/
|
|
66
|
+
export function setResourceCacheScope(fn) {
|
|
67
|
+
_cacheScope = fn;
|
|
68
|
+
}
|
|
69
|
+
// The browser serves one user, so the page is the scope there.
|
|
70
|
+
let _pageCache;
|
|
71
|
+
/** The cache for where this runs: the injected scope, else the page in a browser, else a private one. */
|
|
72
|
+
export function currentResourceCache() {
|
|
73
|
+
const scoped = _cacheScope?.();
|
|
74
|
+
if (scoped)
|
|
75
|
+
return scoped;
|
|
76
|
+
// A server with no scope injected: nothing safe to share, so nothing is shared.
|
|
77
|
+
if (typeof window === 'undefined')
|
|
78
|
+
return createResourceCache();
|
|
79
|
+
return (_pageCache ??= createResourceCache());
|
|
80
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
function createResourceCache() {
|
|
31
|
+
const entries = /* @__PURE__ */ new Map();
|
|
32
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
33
|
+
return {
|
|
34
|
+
get: (key) => entries.get(key),
|
|
35
|
+
set: (key, entry) => void entries.set(key, entry),
|
|
36
|
+
delete: (key) => void entries.delete(key),
|
|
37
|
+
keys: () => entries.keys(),
|
|
38
|
+
clear: () => {
|
|
39
|
+
entries.clear();
|
|
40
|
+
inflight.clear();
|
|
41
|
+
},
|
|
42
|
+
inflight
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var _cacheScope = null;
|
|
46
|
+
function setResourceCacheScope(fn) {
|
|
47
|
+
_cacheScope = fn;
|
|
48
|
+
}
|
|
49
|
+
var _pageCache;
|
|
50
|
+
function currentResourceCache() {
|
|
51
|
+
const scoped = _cacheScope?.();
|
|
52
|
+
if (scoped) return scoped;
|
|
53
|
+
if (typeof window === "undefined") return createResourceCache();
|
|
54
|
+
return _pageCache ??= createResourceCache();
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
createResourceCache,
|
|
58
|
+
currentResourceCache,
|
|
59
|
+
getServerData,
|
|
60
|
+
nextResourceId,
|
|
61
|
+
reportResourceData,
|
|
62
|
+
setResourceCacheScope,
|
|
63
|
+
setResourceDataSink,
|
|
64
|
+
setResourceIdSource,
|
|
65
|
+
setResourceTracker,
|
|
66
|
+
setServerDataGetter,
|
|
67
|
+
trackResourcePromise
|
|
68
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
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.100";
|
|
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
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reactive graph's mutable state, kept as a single object cached on globalThis.
|
|
3
|
+
*
|
|
4
|
+
* Why, tracking/scheduling reads module-global state ("who's the current consumer?",
|
|
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: 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
|
+
* lost (works in dev, breaks in prod). Caching the state on globalThis means every copy
|
|
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
|
+
*
|
|
13
|
+
* This is strictly more robust than SolidJS, which keeps this state in module `let`s and
|
|
14
|
+
* relies on dedup + a "multiple instances" warning. Node-ref fields are loosely typed
|
|
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
|
+
export interface GraphState {
|
|
29
|
+
/** The computation currently evaluating: reads inside it subscribe to it. */
|
|
30
|
+
consumer: any;
|
|
31
|
+
/** When true, reads don't subscribe (untrack / peek). */
|
|
32
|
+
untracked: boolean;
|
|
33
|
+
/** The current owner scope (ownership/disposal/context). */
|
|
34
|
+
owner: any;
|
|
35
|
+
/** Pending effects awaiting flush. */
|
|
36
|
+
queue: Array<{
|
|
37
|
+
queued: boolean;
|
|
38
|
+
disposed: boolean;
|
|
39
|
+
run(): void;
|
|
40
|
+
}>;
|
|
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
|
+
*/
|
|
48
|
+
scheduled: boolean;
|
|
49
|
+
/** A flush is in progress (re-entrancy guard). */
|
|
50
|
+
flushing: boolean;
|
|
51
|
+
/** Depth of active batch() calls; >0 defers flushing. */
|
|
52
|
+
batchDepth: number;
|
|
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
|
+
*/
|
|
58
|
+
hostSchedule: (run: () => void) => void;
|
|
59
|
+
/** Boundary hooks (injected by the Suspense / error-boundary layers). */
|
|
60
|
+
onSuspend: ((promise: Promise<unknown>, owner: any) => void) | null;
|
|
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;
|
|
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;
|
|
73
|
+
export declare const G: GraphState;
|
|
74
|
+
/** Every `@fluixi/reactive` build that has joined the shared graph, deduplicated. */
|
|
75
|
+
export declare function joinedVersions(): string[];
|
|
76
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reactive graph's mutable state, kept as a single object cached on globalThis.
|
|
3
|
+
*
|
|
4
|
+
* Why, tracking/scheduling reads module-global state ("who's the current consumer?",
|
|
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: 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
|
+
* lost (works in dev, breaks in prod). Caching the state on globalThis means every copy
|
|
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
|
+
*
|
|
13
|
+
* This is strictly more robust than SolidJS, which keeps this state in module `let`s and
|
|
14
|
+
* relies on dedup + a "multiple instances" warning. Node-ref fields are loosely typed
|
|
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.
|
|
43
|
+
*/
|
|
44
|
+
const MAJOR = VERSION.split('.')[0];
|
|
45
|
+
const KEY = `__fluixi_signal_state_v${MAJOR}__`;
|
|
46
|
+
const VERSIONS_KEY = `__fluixi_signal_builds_v${MAJOR}__`;
|
|
47
|
+
const defaultSchedule = (run) => {
|
|
48
|
+
if (typeof queueMicrotask === 'function')
|
|
49
|
+
queueMicrotask(run);
|
|
50
|
+
else
|
|
51
|
+
void Promise.resolve().then(run);
|
|
52
|
+
};
|
|
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
|
+
}
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/version.generated.ts
|
|
2
|
+
var VERSION = "1.0.0-alpha.100";
|
|
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
|
+
};
|