@fluixi/reactive 1.0.0-alpha.91 → 1.0.0-alpha.93
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/dist/cdn/reactive.cjs +105 -35
- package/dist/cdn/reactive.global.js +2 -2
- package/dist/cdn/reactive.mjs +105 -35
- package/dist/cdn/signal.cjs +1 -1
- package/dist/cdn/signal.global.js +2 -2
- package/dist/cdn/signal.mjs +1 -1
- package/dist/index.cjs +105 -35
- package/dist/index.mjs +105 -35
- package/dist/lib/index.cjs +106 -36
- package/dist/lib/index.mjs +106 -36
- package/dist/lib/observable/index.cjs +1 -1
- package/dist/lib/observable/index.mjs +1 -1
- package/dist/lib/signal/api.cjs +11 -10
- package/dist/lib/signal/api.d.ts +5 -1
- package/dist/lib/signal/api.d.ts.map +1 -1
- package/dist/lib/signal/api.js +4 -2
- package/dist/lib/signal/api.mjs +11 -10
- package/dist/lib/signal/cached-resource.cjs +77 -34
- package/dist/lib/signal/cached-resource.d.ts +48 -68
- package/dist/lib/signal/cached-resource.d.ts.map +1 -1
- package/dist/lib/signal/cached-resource.js +59 -72
- package/dist/lib/signal/cached-resource.mjs +77 -34
- package/dist/lib/signal/graph/children.cjs +3 -2
- package/dist/lib/signal/graph/children.mjs +3 -2
- package/dist/lib/signal/graph/compat.cjs +10 -9
- package/dist/lib/signal/graph/compat.d.ts +3 -1
- package/dist/lib/signal/graph/compat.d.ts.map +1 -1
- package/dist/lib/signal/graph/compat.js +2 -2
- package/dist/lib/signal/graph/compat.mjs +10 -9
- package/dist/lib/signal/graph/core.cjs +2 -2
- package/dist/lib/signal/graph/core.mjs +2 -2
- package/dist/lib/signal/graph/debounced.cjs +9 -8
- package/dist/lib/signal/graph/debounced.mjs +9 -8
- package/dist/lib/signal/graph/derived.cjs +9 -8
- package/dist/lib/signal/graph/derived.mjs +9 -8
- package/dist/lib/signal/graph/error-boundary.cjs +3 -2
- package/dist/lib/signal/graph/error-boundary.mjs +3 -2
- package/dist/lib/signal/graph/index.cjs +2 -2
- package/dist/lib/signal/graph/index.mjs +2 -2
- package/dist/lib/signal/graph/observe.cjs +38 -3
- package/dist/lib/signal/graph/observe.d.ts +44 -0
- package/dist/lib/signal/graph/observe.d.ts.map +1 -1
- package/dist/lib/signal/graph/observe.js +50 -1
- package/dist/lib/signal/graph/observe.mjs +38 -3
- package/dist/lib/signal/graph/resource.cjs +9 -8
- package/dist/lib/signal/graph/resource.mjs +9 -8
- package/dist/lib/signal/graph/runtime.cjs +7 -6
- package/dist/lib/signal/graph/runtime.d.ts +1 -1
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
- package/dist/lib/signal/graph/runtime.js +4 -4
- package/dist/lib/signal/graph/runtime.mjs +7 -6
- package/dist/lib/signal/graph/signal-next.cjs +39 -9
- package/dist/lib/signal/graph/signal-next.d.ts +1 -1
- package/dist/lib/signal/graph/signal-next.d.ts.map +1 -1
- package/dist/lib/signal/graph/signal-next.js +1 -1
- package/dist/lib/signal/graph/signal-next.mjs +39 -9
- package/dist/lib/signal/graph/ssr-hooks.cjs +29 -0
- package/dist/lib/signal/graph/ssr-hooks.d.ts +24 -0
- package/dist/lib/signal/graph/ssr-hooks.d.ts.map +1 -1
- package/dist/lib/signal/graph/ssr-hooks.js +36 -0
- package/dist/lib/signal/graph/ssr-hooks.mjs +29 -0
- package/dist/lib/signal/graph/state.cjs +1 -1
- package/dist/lib/signal/graph/state.mjs +1 -1
- package/dist/lib/signal/graph/suspense.cjs +3 -2
- package/dist/lib/signal/graph/suspense.mjs +3 -2
- package/dist/lib/signal/index-legacy.cjs +65 -34
- package/dist/lib/signal/index-legacy.mjs +65 -34
- package/dist/lib/signal/index.cjs +76 -12
- package/dist/lib/signal/index.d.ts +2 -1
- package/dist/lib/signal/index.d.ts.map +1 -1
- package/dist/lib/signal/index.js +1 -1
- package/dist/lib/signal/index.mjs +76 -12
- package/dist/lib/signal/list.cjs +3 -2
- package/dist/lib/signal/list.mjs +3 -2
- package/dist/lib/signal/resource-api.cjs +9 -8
- package/dist/lib/signal/resource-api.mjs +9 -8
- package/dist/lib/signal/signal.cjs +9 -8
- package/dist/lib/signal/signal.mjs +9 -8
- package/dist/lib/signal/utilities.cjs +10 -9
- package/dist/lib/signal/utilities.mjs +10 -9
- package/dist/lib/store/api.cjs +3 -2
- package/dist/lib/store/api.mjs +3 -2
- package/dist/lib/store/index.cjs +4 -3
- package/dist/lib/store/index.mjs +4 -3
- package/dist/lib/store/store.cjs +3 -2
- package/dist/lib/store/store.mjs +3 -2
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +2 -2
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/version.generated.mjs +2 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.generated.ts
|
|
2
|
-
var VERSION = "1.0.0-alpha.
|
|
2
|
+
var VERSION = "1.0.0-alpha.93";
|
|
3
3
|
|
|
4
4
|
// src/lib/signal/graph/state.ts
|
|
5
5
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -59,11 +59,40 @@ function withReactiveOrigin(owner, fn) {
|
|
|
59
59
|
origin = previous;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
var currentScope;
|
|
63
|
+
function openReactiveScope(info) {
|
|
64
|
+
const scope = {};
|
|
65
|
+
G.observer?.scope?.(scope, info, currentScope);
|
|
66
|
+
return scope;
|
|
67
|
+
}
|
|
68
|
+
function withReactiveScope(scope, fn) {
|
|
69
|
+
if (!G.observer) return fn();
|
|
70
|
+
const previous = currentScope;
|
|
71
|
+
currentScope = scope;
|
|
72
|
+
try {
|
|
73
|
+
return fn();
|
|
74
|
+
} finally {
|
|
75
|
+
currentScope = previous;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function closeReactiveScope(scope) {
|
|
79
|
+
G.observer?.scopeEnded?.(scope);
|
|
80
|
+
}
|
|
81
|
+
function adoptReactiveScope(scope, parent) {
|
|
82
|
+
G.observer?.scopeAdopted?.(scope, parent);
|
|
83
|
+
}
|
|
84
|
+
var SCOPE_OF = /* @__PURE__ */ Symbol.for("fluixi.reactiveScope");
|
|
85
|
+
function markReactiveScope(value, scope) {
|
|
86
|
+
Object.defineProperty(value, SCOPE_OF, { value: scope, configurable: true, enumerable: false });
|
|
87
|
+
}
|
|
88
|
+
function reactiveScopeOf(value) {
|
|
89
|
+
return value !== null && (typeof value === "object" || typeof value === "function") ? value[SCOPE_OF] ?? void 0 : void 0;
|
|
90
|
+
}
|
|
62
91
|
function reportReactiveNode(report) {
|
|
63
92
|
const observer = G.observer;
|
|
64
93
|
if (observer) {
|
|
65
94
|
observer.created(
|
|
66
|
-
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
95
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
|
|
67
96
|
);
|
|
68
97
|
}
|
|
69
98
|
}
|
|
@@ -122,10 +151,15 @@ function isObserved() {
|
|
|
122
151
|
return G.observer != null;
|
|
123
152
|
}
|
|
124
153
|
export {
|
|
154
|
+
adoptReactiveScope,
|
|
155
|
+
closeReactiveScope,
|
|
125
156
|
enterReactiveRun,
|
|
126
157
|
exitReactiveRun,
|
|
127
158
|
isObserved,
|
|
159
|
+
markReactiveScope,
|
|
128
160
|
observeReactiveNodes,
|
|
161
|
+
openReactiveScope,
|
|
162
|
+
reactiveScopeOf,
|
|
129
163
|
reportReactiveBinding,
|
|
130
164
|
reportReactiveContext,
|
|
131
165
|
reportReactiveContextCreated,
|
|
@@ -136,5 +170,6 @@ export {
|
|
|
136
170
|
reportReactiveProps,
|
|
137
171
|
reportReactiveRun,
|
|
138
172
|
reportReactiveWrite,
|
|
139
|
-
withReactiveOrigin
|
|
173
|
+
withReactiveOrigin,
|
|
174
|
+
withReactiveScope
|
|
140
175
|
};
|
|
@@ -25,7 +25,7 @@ __export(resource_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(resource_exports);
|
|
26
26
|
|
|
27
27
|
// src/version.generated.ts
|
|
28
|
-
var VERSION = "1.0.0-alpha.
|
|
28
|
+
var VERSION = "1.0.0-alpha.93";
|
|
29
29
|
|
|
30
30
|
// src/lib/signal/graph/state.ts
|
|
31
31
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -75,11 +75,12 @@ function observeReactiveNodes(next) {
|
|
|
75
75
|
}
|
|
76
76
|
var running = [];
|
|
77
77
|
var origin;
|
|
78
|
+
var currentScope;
|
|
78
79
|
function reportReactiveNode(report) {
|
|
79
80
|
const observer = G.observer;
|
|
80
81
|
if (observer) {
|
|
81
82
|
observer.created(
|
|
82
|
-
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
83
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
|
|
83
84
|
);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -373,7 +374,7 @@ function batch(fn) {
|
|
|
373
374
|
}
|
|
374
375
|
}
|
|
375
376
|
var EffectNode = class {
|
|
376
|
-
constructor(fn, report = false) {
|
|
377
|
+
constructor(fn, report = false, name) {
|
|
377
378
|
this.queued = false;
|
|
378
379
|
this.disposed = false;
|
|
379
380
|
this.owner = makeOwner(G.owner);
|
|
@@ -385,7 +386,7 @@ var EffectNode = class {
|
|
|
385
386
|
if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
|
|
386
387
|
});
|
|
387
388
|
});
|
|
388
|
-
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
|
|
389
|
+
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
|
|
389
390
|
this.watcher = new Watcher(() => enqueue(this));
|
|
390
391
|
this.run();
|
|
391
392
|
this.watcher.watch(this.computed);
|
|
@@ -412,8 +413,8 @@ var EffectNode = class {
|
|
|
412
413
|
disposeOwner(this.owner);
|
|
413
414
|
}
|
|
414
415
|
};
|
|
415
|
-
function effect(fn, report = false) {
|
|
416
|
-
const node = new EffectNode(fn, report);
|
|
416
|
+
function effect(fn, report = false, name) {
|
|
417
|
+
const node = new EffectNode(fn, report, name);
|
|
417
418
|
return () => node.dispose();
|
|
418
419
|
}
|
|
419
420
|
|
|
@@ -453,12 +454,12 @@ function createSignal(value, options) {
|
|
|
453
454
|
if (isObserved()) onCleanup(() => reportReactiveDispose(state));
|
|
454
455
|
return [read, write];
|
|
455
456
|
}
|
|
456
|
-
function createEffect(fn, value) {
|
|
457
|
+
function createEffect(fn, value, options) {
|
|
457
458
|
let prev = value;
|
|
458
459
|
return effect(() => {
|
|
459
460
|
const r = fn(prev);
|
|
460
461
|
prev = r;
|
|
461
|
-
}, true);
|
|
462
|
+
}, true, options?.name);
|
|
462
463
|
}
|
|
463
464
|
function batch2(fn) {
|
|
464
465
|
return batch(fn);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.generated.ts
|
|
2
|
-
var VERSION = "1.0.0-alpha.
|
|
2
|
+
var VERSION = "1.0.0-alpha.93";
|
|
3
3
|
|
|
4
4
|
// src/lib/signal/graph/state.ts
|
|
5
5
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -49,11 +49,12 @@ function observeReactiveNodes(next) {
|
|
|
49
49
|
}
|
|
50
50
|
var running = [];
|
|
51
51
|
var origin;
|
|
52
|
+
var currentScope;
|
|
52
53
|
function reportReactiveNode(report) {
|
|
53
54
|
const observer = G.observer;
|
|
54
55
|
if (observer) {
|
|
55
56
|
observer.created(
|
|
56
|
-
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
57
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
|
|
57
58
|
);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -347,7 +348,7 @@ function batch(fn) {
|
|
|
347
348
|
}
|
|
348
349
|
}
|
|
349
350
|
var EffectNode = class {
|
|
350
|
-
constructor(fn, report = false) {
|
|
351
|
+
constructor(fn, report = false, name) {
|
|
351
352
|
this.queued = false;
|
|
352
353
|
this.disposed = false;
|
|
353
354
|
this.owner = makeOwner(G.owner);
|
|
@@ -359,7 +360,7 @@ var EffectNode = class {
|
|
|
359
360
|
if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
|
|
360
361
|
});
|
|
361
362
|
});
|
|
362
|
-
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
|
|
363
|
+
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
|
|
363
364
|
this.watcher = new Watcher(() => enqueue(this));
|
|
364
365
|
this.run();
|
|
365
366
|
this.watcher.watch(this.computed);
|
|
@@ -386,8 +387,8 @@ var EffectNode = class {
|
|
|
386
387
|
disposeOwner(this.owner);
|
|
387
388
|
}
|
|
388
389
|
};
|
|
389
|
-
function effect(fn, report = false) {
|
|
390
|
-
const node = new EffectNode(fn, report);
|
|
390
|
+
function effect(fn, report = false, name) {
|
|
391
|
+
const node = new EffectNode(fn, report, name);
|
|
391
392
|
return () => node.dispose();
|
|
392
393
|
}
|
|
393
394
|
|
|
@@ -427,12 +428,12 @@ function createSignal(value, options) {
|
|
|
427
428
|
if (isObserved()) onCleanup(() => reportReactiveDispose(state));
|
|
428
429
|
return [read, write];
|
|
429
430
|
}
|
|
430
|
-
function createEffect(fn, value) {
|
|
431
|
+
function createEffect(fn, value, options) {
|
|
431
432
|
let prev = value;
|
|
432
433
|
return effect(() => {
|
|
433
434
|
const r = fn(prev);
|
|
434
435
|
prev = r;
|
|
435
|
-
}, true);
|
|
436
|
+
}, true, options?.name);
|
|
436
437
|
}
|
|
437
438
|
function batch2(fn) {
|
|
438
439
|
return batch(fn);
|
|
@@ -44,7 +44,7 @@ __export(runtime_exports, {
|
|
|
44
44
|
module.exports = __toCommonJS(runtime_exports);
|
|
45
45
|
|
|
46
46
|
// src/version.generated.ts
|
|
47
|
-
var VERSION = "1.0.0-alpha.
|
|
47
|
+
var VERSION = "1.0.0-alpha.93";
|
|
48
48
|
|
|
49
49
|
// src/lib/signal/graph/state.ts
|
|
50
50
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -94,11 +94,12 @@ function observeReactiveNodes(next) {
|
|
|
94
94
|
}
|
|
95
95
|
var running = [];
|
|
96
96
|
var origin;
|
|
97
|
+
var currentScope;
|
|
97
98
|
function reportReactiveNode(report) {
|
|
98
99
|
const observer = G.observer;
|
|
99
100
|
if (observer) {
|
|
100
101
|
observer.created(
|
|
101
|
-
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
102
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
|
|
102
103
|
);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
@@ -456,7 +457,7 @@ function batch(fn) {
|
|
|
456
457
|
}
|
|
457
458
|
}
|
|
458
459
|
var EffectNode = class {
|
|
459
|
-
constructor(fn, report = false) {
|
|
460
|
+
constructor(fn, report = false, name) {
|
|
460
461
|
this.queued = false;
|
|
461
462
|
this.disposed = false;
|
|
462
463
|
this.owner = makeOwner(G.owner);
|
|
@@ -468,7 +469,7 @@ var EffectNode = class {
|
|
|
468
469
|
if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
|
|
469
470
|
});
|
|
470
471
|
});
|
|
471
|
-
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
|
|
472
|
+
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
|
|
472
473
|
this.watcher = new Watcher(() => enqueue(this));
|
|
473
474
|
this.run();
|
|
474
475
|
this.watcher.watch(this.computed);
|
|
@@ -495,7 +496,7 @@ var EffectNode = class {
|
|
|
495
496
|
disposeOwner(this.owner);
|
|
496
497
|
}
|
|
497
498
|
};
|
|
498
|
-
function effect(fn, report = false) {
|
|
499
|
-
const node = new EffectNode(fn, report);
|
|
499
|
+
function effect(fn, report = false, name) {
|
|
500
|
+
const node = new EffectNode(fn, report, name);
|
|
500
501
|
return () => node.dispose();
|
|
501
502
|
}
|
|
@@ -73,5 +73,5 @@ export declare function afterWrite(): void;
|
|
|
73
73
|
/** Group writes so dependent effects flush once, at the end. */
|
|
74
74
|
export declare function batch<T>(fn: () => T): T;
|
|
75
75
|
/** A re-running side effect. Runs once now, then again (G.scheduled) when deps change. */
|
|
76
|
-
export declare function effect(fn: () => void | (() => void), report?: boolean): () => void;
|
|
76
|
+
export declare function effect(fn: () => void | (() => void), report?: boolean, name?: string): () => void;
|
|
77
77
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/runtime.ts"],"names":[],"mappings":"AA8BA,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IACnC,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,mFAAmF;IACnF,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACtC;+EAC2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAI5D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,UAAO,GAAG,IAAI,CAE7D;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,OAAO,CAE5D;AAUD,MAAM,W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AE,MAAM,IAAI,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAEzE;AAYD,qDAAqD;AACrD,wBAAgB,SAAS,IAAI,IAAI,CAqBhC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAED,gEAAgE;AAChE,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAOvC;AAoED,0FAA0F;AAC1F,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,MAAM,UAAQ,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,IAAI,CAK/F"}
|
|
@@ -272,7 +272,7 @@ class EffectNode {
|
|
|
272
272
|
owner;
|
|
273
273
|
queued = false;
|
|
274
274
|
disposed = false;
|
|
275
|
-
constructor(fn, report = false) {
|
|
275
|
+
constructor(fn, report = false, name) {
|
|
276
276
|
this.owner = makeOwner(G.owner);
|
|
277
277
|
// Tie disposal to the creating scope, when the parent owner tears down it must
|
|
278
278
|
// fully dispose this effect (unwatch + body cleanups), not just run the body
|
|
@@ -294,7 +294,7 @@ class EffectNode {
|
|
|
294
294
|
// Before the first run, so a watcher counts that run like every later one. A render
|
|
295
295
|
// effect is reported too, marked as plumbing: it is not worth drawing, but a node made
|
|
296
296
|
// inside one has to be able to find its way back to the component that caused it.
|
|
297
|
-
reportReactiveNode({ kind: 'effect', node: this.computed, handle: this, internal: !report });
|
|
297
|
+
reportReactiveNode({ kind: 'effect', node: this.computed, handle: this, internal: !report, ...(name ? { name } : {}) });
|
|
298
298
|
// The watcher only schedules; the recompute happens on flush.
|
|
299
299
|
this.watcher = new Watcher(() => enqueue(this));
|
|
300
300
|
this.run(); // initial synchronous run (Solid semantics)
|
|
@@ -331,9 +331,9 @@ class EffectNode {
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
/** A re-running side effect. Runs once now, then again (G.scheduled) when deps change. */
|
|
334
|
-
export function effect(fn, report = false) {
|
|
334
|
+
export function effect(fn, report = false, name) {
|
|
335
335
|
// Reported only when the caller says so. Every DOM binding is a render effect through this
|
|
336
336
|
// same factory, and a graph holding one node per text node is not a graph anyone reads.
|
|
337
|
-
const node = new EffectNode(fn, report);
|
|
337
|
+
const node = new EffectNode(fn, report, name);
|
|
338
338
|
return () => node.dispose();
|
|
339
339
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.generated.ts
|
|
2
|
-
var VERSION = "1.0.0-alpha.
|
|
2
|
+
var VERSION = "1.0.0-alpha.93";
|
|
3
3
|
|
|
4
4
|
// src/lib/signal/graph/state.ts
|
|
5
5
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -49,11 +49,12 @@ function observeReactiveNodes(next) {
|
|
|
49
49
|
}
|
|
50
50
|
var running = [];
|
|
51
51
|
var origin;
|
|
52
|
+
var currentScope;
|
|
52
53
|
function reportReactiveNode(report) {
|
|
53
54
|
const observer = G.observer;
|
|
54
55
|
if (observer) {
|
|
55
56
|
observer.created(
|
|
56
|
-
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
57
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
|
|
57
58
|
);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -411,7 +412,7 @@ function batch(fn) {
|
|
|
411
412
|
}
|
|
412
413
|
}
|
|
413
414
|
var EffectNode = class {
|
|
414
|
-
constructor(fn, report = false) {
|
|
415
|
+
constructor(fn, report = false, name) {
|
|
415
416
|
this.queued = false;
|
|
416
417
|
this.disposed = false;
|
|
417
418
|
this.owner = makeOwner(G.owner);
|
|
@@ -423,7 +424,7 @@ var EffectNode = class {
|
|
|
423
424
|
if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
|
|
424
425
|
});
|
|
425
426
|
});
|
|
426
|
-
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
|
|
427
|
+
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
|
|
427
428
|
this.watcher = new Watcher(() => enqueue(this));
|
|
428
429
|
this.run();
|
|
429
430
|
this.watcher.watch(this.computed);
|
|
@@ -450,8 +451,8 @@ var EffectNode = class {
|
|
|
450
451
|
disposeOwner(this.owner);
|
|
451
452
|
}
|
|
452
453
|
};
|
|
453
|
-
function effect(fn, report = false) {
|
|
454
|
-
const node = new EffectNode(fn, report);
|
|
454
|
+
function effect(fn, report = false, name) {
|
|
455
|
+
const node = new EffectNode(fn, report, name);
|
|
455
456
|
return () => node.dispose();
|
|
456
457
|
}
|
|
457
458
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.93 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -39,10 +39,12 @@ __export(signal_next_exports, {
|
|
|
39
39
|
createMemo: () => createMemo,
|
|
40
40
|
createRenderEffect: () => createRenderEffect,
|
|
41
41
|
createResource: () => createResource,
|
|
42
|
+
createResourceCache: () => createResourceCache,
|
|
42
43
|
createRoot: () => createRoot,
|
|
43
44
|
createSelector: () => createSelector,
|
|
44
45
|
createSignal: () => createSignal,
|
|
45
46
|
createSuspenseBoundary: () => createSuspenseBoundary,
|
|
47
|
+
currentResourceCache: () => currentResourceCache,
|
|
46
48
|
disposeScope: () => disposeScope,
|
|
47
49
|
flush: () => flush,
|
|
48
50
|
getOwner: () => getOwner,
|
|
@@ -68,6 +70,7 @@ __export(signal_next_exports, {
|
|
|
68
70
|
reportResourceData: () => reportResourceData,
|
|
69
71
|
runWithOwner: () => runWithOwner,
|
|
70
72
|
setOwner: () => setOwner,
|
|
73
|
+
setResourceCacheScope: () => setResourceCacheScope,
|
|
71
74
|
setResourceDataSink: () => setResourceDataSink,
|
|
72
75
|
setResourceIdSource: () => setResourceIdSource,
|
|
73
76
|
setResourceTracker: () => setResourceTracker,
|
|
@@ -81,7 +84,7 @@ __export(signal_next_exports, {
|
|
|
81
84
|
module.exports = __toCommonJS(signal_next_exports);
|
|
82
85
|
|
|
83
86
|
// src/version.generated.ts
|
|
84
|
-
var VERSION = "1.0.0-alpha.
|
|
87
|
+
var VERSION = "1.0.0-alpha.93";
|
|
85
88
|
|
|
86
89
|
// src/lib/signal/graph/state.ts
|
|
87
90
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -131,11 +134,12 @@ function observeReactiveNodes(next) {
|
|
|
131
134
|
}
|
|
132
135
|
var running = [];
|
|
133
136
|
var origin;
|
|
137
|
+
var currentScope;
|
|
134
138
|
function reportReactiveNode(report) {
|
|
135
139
|
const observer = G.observer;
|
|
136
140
|
if (observer) {
|
|
137
141
|
observer.created(
|
|
138
|
-
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
142
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
|
|
139
143
|
);
|
|
140
144
|
}
|
|
141
145
|
}
|
|
@@ -537,7 +541,7 @@ function batch(fn) {
|
|
|
537
541
|
}
|
|
538
542
|
}
|
|
539
543
|
var EffectNode = class {
|
|
540
|
-
constructor(fn, report = false) {
|
|
544
|
+
constructor(fn, report = false, name) {
|
|
541
545
|
this.queued = false;
|
|
542
546
|
this.disposed = false;
|
|
543
547
|
this.owner = makeOwner(G.owner);
|
|
@@ -549,7 +553,7 @@ var EffectNode = class {
|
|
|
549
553
|
if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
|
|
550
554
|
});
|
|
551
555
|
});
|
|
552
|
-
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
|
|
556
|
+
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
|
|
553
557
|
this.watcher = new Watcher(() => enqueue(this));
|
|
554
558
|
this.run();
|
|
555
559
|
this.watcher.watch(this.computed);
|
|
@@ -576,8 +580,8 @@ var EffectNode = class {
|
|
|
576
580
|
disposeOwner(this.owner);
|
|
577
581
|
}
|
|
578
582
|
};
|
|
579
|
-
function effect(fn, report = false) {
|
|
580
|
-
const node = new EffectNode(fn, report);
|
|
583
|
+
function effect(fn, report = false, name) {
|
|
584
|
+
const node = new EffectNode(fn, report, name);
|
|
581
585
|
return () => node.dispose();
|
|
582
586
|
}
|
|
583
587
|
|
|
@@ -645,12 +649,12 @@ function createMemo(fn, value, options) {
|
|
|
645
649
|
if (isObserved()) onCleanup(() => reportReactiveDispose(c));
|
|
646
650
|
return read;
|
|
647
651
|
}
|
|
648
|
-
function createEffect(fn, value) {
|
|
652
|
+
function createEffect(fn, value, options) {
|
|
649
653
|
let prev = value;
|
|
650
654
|
return effect(() => {
|
|
651
655
|
const r = fn(prev);
|
|
652
656
|
prev = r;
|
|
653
|
-
}, true);
|
|
657
|
+
}, true, options?.name);
|
|
654
658
|
}
|
|
655
659
|
function createComputed(fn, value) {
|
|
656
660
|
let prev = value;
|
|
@@ -896,6 +900,32 @@ function setResourceDataSink(fn) {
|
|
|
896
900
|
function reportResourceData(id, value) {
|
|
897
901
|
if (_resourceDataSink) _resourceDataSink(id, value);
|
|
898
902
|
}
|
|
903
|
+
function createResourceCache() {
|
|
904
|
+
const entries = /* @__PURE__ */ new Map();
|
|
905
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
906
|
+
return {
|
|
907
|
+
get: (key) => entries.get(key),
|
|
908
|
+
set: (key, entry) => void entries.set(key, entry),
|
|
909
|
+
delete: (key) => void entries.delete(key),
|
|
910
|
+
keys: () => entries.keys(),
|
|
911
|
+
clear: () => {
|
|
912
|
+
entries.clear();
|
|
913
|
+
inflight.clear();
|
|
914
|
+
},
|
|
915
|
+
inflight
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
var _cacheScope = null;
|
|
919
|
+
function setResourceCacheScope(fn) {
|
|
920
|
+
_cacheScope = fn;
|
|
921
|
+
}
|
|
922
|
+
var _pageCache;
|
|
923
|
+
function currentResourceCache() {
|
|
924
|
+
const scoped = _cacheScope?.();
|
|
925
|
+
if (scoped) return scoped;
|
|
926
|
+
if (typeof window === "undefined") return createResourceCache();
|
|
927
|
+
return _pageCache ??= createResourceCache();
|
|
928
|
+
}
|
|
899
929
|
|
|
900
930
|
// src/lib/signal/graph/derived.ts
|
|
901
931
|
function createSelector(source, fn = (k, v) => k === v) {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
export type { Accessor, Setter, SignalOptions, SignalTuple, MemoOptions, EqualityFn, EffectFn, EffectOptions, ComputationFn, Computation, Cleanup, DerivedFn, AsyncFn, Resource, ResourceFetcher, ResourceSource, ResourceOptions, ResourceState, RootOwner, ReactiveNode, Trigger, EnhancedTrigger, EnhancedSignal, AsyncSignal, LazySignal, SignalWithHistory, SuspenseContextType, SuspenseListContextType, SuspenseListRegisteredState, } from '../signal.js';
|
|
24
24
|
export * from '../list.js';
|
|
25
25
|
export { __DEV__, isSignal, isMemo, isResource, isComponent, isSuspense, isProvider, makeArrayFlat, } from './detect.js';
|
|
26
|
-
export { setResourceTracker, trackResourcePromise, setServerDataGetter, getServerData, setResourceIdSource, nextResourceId, setResourceDataSink, reportResourceData, } from './ssr-hooks.js';
|
|
26
|
+
export { setResourceTracker, trackResourcePromise, setServerDataGetter, getServerData, setResourceIdSource, nextResourceId, setResourceDataSink, reportResourceData, setResourceCacheScope, currentResourceCache, createResourceCache, type ResourceCache, type ResourceCacheEntry, } from './ssr-hooks.js';
|
|
27
27
|
export { createSelector, createDeferred, createDebounce } from './derived.js';
|
|
28
28
|
export { createDebouncedSignal, createDebouncedResource, type DebounceControls, type DebouncedResourceOptions, type DebouncedResourceControls, } from './debounced.js';
|
|
29
29
|
export { readChildren } from './children.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal-next.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/signal-next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,YAAY,EACV,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EACrE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAChF,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EACzE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAC9E,UAAU,EAAE,iBAAiB,EAC7B,mBAAmB,EAAE,uBAAuB,EAAE,2BAA2B,GAC1E,MAAM,cAAc,CAAC;AAOtB,cAAc,YAAY,CAAC;AAI3B,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"signal-next.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/signal-next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,YAAY,EACV,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EACrE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAChF,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EACzE,SAAS,E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Ae,CAAC;AAG1F,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAOpC,eAAO,MAAM,OAAO,eAAuB,CAAC;AAC5C,eAAO,MAAM,MAAM,eAA6B,CAAC"}
|
|
@@ -9,7 +9,7 @@ export * from '../list.js';
|
|
|
9
9
|
// so they survive once signal.ts is retired. Explicit re-export wins over the star.
|
|
10
10
|
export { __DEV__, isSignal, isMemo, isResource, isComponent, isSuspense, isProvider, makeArrayFlat, } from './detect.js';
|
|
11
11
|
// SSR resource injectables: sourced from the TC39-owned module, not signal.js.
|
|
12
|
-
export { setResourceTracker, trackResourcePromise, setServerDataGetter, getServerData, setResourceIdSource, nextResourceId, setResourceDataSink, reportResourceData, } from './ssr-hooks.js';
|
|
12
|
+
export { setResourceTracker, trackResourcePromise, setServerDataGetter, getServerData, setResourceIdSource, nextResourceId, setResourceDataSink, reportResourceData, setResourceCacheScope, currentResourceCache, createResourceCache, } from './ssr-hooks.js';
|
|
13
13
|
// Derived utilities on the TC39 graph.
|
|
14
14
|
export { createSelector, createDeferred, createDebounce } from './derived.js';
|
|
15
15
|
export { createDebouncedSignal, createDebouncedResource, } from './debounced.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @fluixi/reactive v1.0.0-alpha.
|
|
1
|
+
/*! @fluixi/reactive v1.0.0-alpha.93 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
|
|
3
3
|
// src/version.generated.ts
|
|
4
|
-
var VERSION = "1.0.0-alpha.
|
|
4
|
+
var VERSION = "1.0.0-alpha.93";
|
|
5
5
|
|
|
6
6
|
// src/lib/signal/graph/state.ts
|
|
7
7
|
var MAJOR = VERSION.split(".")[0];
|
|
@@ -51,11 +51,12 @@ function observeReactiveNodes(next) {
|
|
|
51
51
|
}
|
|
52
52
|
var running = [];
|
|
53
53
|
var origin;
|
|
54
|
+
var currentScope;
|
|
54
55
|
function reportReactiveNode(report) {
|
|
55
56
|
const observer = G.observer;
|
|
56
57
|
if (observer) {
|
|
57
58
|
observer.created(
|
|
58
|
-
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
|
|
59
|
+
report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
|
|
59
60
|
);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
@@ -457,7 +458,7 @@ function batch(fn) {
|
|
|
457
458
|
}
|
|
458
459
|
}
|
|
459
460
|
var EffectNode = class {
|
|
460
|
-
constructor(fn, report = false) {
|
|
461
|
+
constructor(fn, report = false, name) {
|
|
461
462
|
this.queued = false;
|
|
462
463
|
this.disposed = false;
|
|
463
464
|
this.owner = makeOwner(G.owner);
|
|
@@ -469,7 +470,7 @@ var EffectNode = class {
|
|
|
469
470
|
if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
|
|
470
471
|
});
|
|
471
472
|
});
|
|
472
|
-
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
|
|
473
|
+
reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
|
|
473
474
|
this.watcher = new Watcher(() => enqueue(this));
|
|
474
475
|
this.run();
|
|
475
476
|
this.watcher.watch(this.computed);
|
|
@@ -496,8 +497,8 @@ var EffectNode = class {
|
|
|
496
497
|
disposeOwner(this.owner);
|
|
497
498
|
}
|
|
498
499
|
};
|
|
499
|
-
function effect(fn, report = false) {
|
|
500
|
-
const node = new EffectNode(fn, report);
|
|
500
|
+
function effect(fn, report = false, name) {
|
|
501
|
+
const node = new EffectNode(fn, report, name);
|
|
501
502
|
return () => node.dispose();
|
|
502
503
|
}
|
|
503
504
|
|
|
@@ -565,12 +566,12 @@ function createMemo(fn, value, options) {
|
|
|
565
566
|
if (isObserved()) onCleanup(() => reportReactiveDispose(c));
|
|
566
567
|
return read;
|
|
567
568
|
}
|
|
568
|
-
function createEffect(fn, value) {
|
|
569
|
+
function createEffect(fn, value, options) {
|
|
569
570
|
let prev = value;
|
|
570
571
|
return effect(() => {
|
|
571
572
|
const r = fn(prev);
|
|
572
573
|
prev = r;
|
|
573
|
-
}, true);
|
|
574
|
+
}, true, options?.name);
|
|
574
575
|
}
|
|
575
576
|
function createComputed(fn, value) {
|
|
576
577
|
let prev = value;
|
|
@@ -816,6 +817,32 @@ function setResourceDataSink(fn) {
|
|
|
816
817
|
function reportResourceData(id, value) {
|
|
817
818
|
if (_resourceDataSink) _resourceDataSink(id, value);
|
|
818
819
|
}
|
|
820
|
+
function createResourceCache() {
|
|
821
|
+
const entries = /* @__PURE__ */ new Map();
|
|
822
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
823
|
+
return {
|
|
824
|
+
get: (key) => entries.get(key),
|
|
825
|
+
set: (key, entry) => void entries.set(key, entry),
|
|
826
|
+
delete: (key) => void entries.delete(key),
|
|
827
|
+
keys: () => entries.keys(),
|
|
828
|
+
clear: () => {
|
|
829
|
+
entries.clear();
|
|
830
|
+
inflight.clear();
|
|
831
|
+
},
|
|
832
|
+
inflight
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
var _cacheScope = null;
|
|
836
|
+
function setResourceCacheScope(fn) {
|
|
837
|
+
_cacheScope = fn;
|
|
838
|
+
}
|
|
839
|
+
var _pageCache;
|
|
840
|
+
function currentResourceCache() {
|
|
841
|
+
const scoped = _cacheScope?.();
|
|
842
|
+
if (scoped) return scoped;
|
|
843
|
+
if (typeof window === "undefined") return createResourceCache();
|
|
844
|
+
return _pageCache ??= createResourceCache();
|
|
845
|
+
}
|
|
819
846
|
|
|
820
847
|
// src/lib/signal/graph/derived.ts
|
|
821
848
|
function createSelector(source, fn = (k, v) => k === v) {
|
|
@@ -1145,10 +1172,12 @@ export {
|
|
|
1145
1172
|
createMemo,
|
|
1146
1173
|
createRenderEffect,
|
|
1147
1174
|
createResource,
|
|
1175
|
+
createResourceCache,
|
|
1148
1176
|
createRoot,
|
|
1149
1177
|
createSelector,
|
|
1150
1178
|
createSignal,
|
|
1151
1179
|
createSuspenseBoundary,
|
|
1180
|
+
currentResourceCache,
|
|
1152
1181
|
disposeScope,
|
|
1153
1182
|
flush,
|
|
1154
1183
|
getOwner,
|
|
@@ -1174,6 +1203,7 @@ export {
|
|
|
1174
1203
|
reportResourceData,
|
|
1175
1204
|
runWithOwner,
|
|
1176
1205
|
setOwner,
|
|
1206
|
+
setResourceCacheScope,
|
|
1177
1207
|
setResourceDataSink,
|
|
1178
1208
|
setResourceIdSource,
|
|
1179
1209
|
setResourceTracker,
|
|
@@ -20,9 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/lib/signal/graph/ssr-hooks.ts
|
|
21
21
|
var ssr_hooks_exports = {};
|
|
22
22
|
__export(ssr_hooks_exports, {
|
|
23
|
+
createResourceCache: () => createResourceCache,
|
|
24
|
+
currentResourceCache: () => currentResourceCache,
|
|
23
25
|
getServerData: () => getServerData,
|
|
24
26
|
nextResourceId: () => nextResourceId,
|
|
25
27
|
reportResourceData: () => reportResourceData,
|
|
28
|
+
setResourceCacheScope: () => setResourceCacheScope,
|
|
26
29
|
setResourceDataSink: () => setResourceDataSink,
|
|
27
30
|
setResourceIdSource: () => setResourceIdSource,
|
|
28
31
|
setResourceTracker: () => setResourceTracker,
|
|
@@ -58,3 +61,29 @@ function setResourceDataSink(fn) {
|
|
|
58
61
|
function reportResourceData(id, value) {
|
|
59
62
|
if (_resourceDataSink) _resourceDataSink(id, value);
|
|
60
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
|
+
}
|