@fluixi/reactive 1.0.0-alpha.92 → 1.0.0-alpha.94

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.
Files changed (92) hide show
  1. package/dist/cdn/reactive.cjs +105 -35
  2. package/dist/cdn/reactive.global.js +2 -2
  3. package/dist/cdn/reactive.mjs +105 -35
  4. package/dist/cdn/signal.cjs +1 -1
  5. package/dist/cdn/signal.global.js +2 -2
  6. package/dist/cdn/signal.mjs +1 -1
  7. package/dist/index.cjs +105 -35
  8. package/dist/index.mjs +105 -35
  9. package/dist/lib/index.cjs +106 -36
  10. package/dist/lib/index.mjs +106 -36
  11. package/dist/lib/observable/index.cjs +1 -1
  12. package/dist/lib/observable/index.mjs +1 -1
  13. package/dist/lib/signal/api.cjs +11 -10
  14. package/dist/lib/signal/api.d.ts +5 -1
  15. package/dist/lib/signal/api.d.ts.map +1 -1
  16. package/dist/lib/signal/api.js +4 -2
  17. package/dist/lib/signal/api.mjs +11 -10
  18. package/dist/lib/signal/cached-resource.cjs +77 -34
  19. package/dist/lib/signal/cached-resource.d.ts +48 -68
  20. package/dist/lib/signal/cached-resource.d.ts.map +1 -1
  21. package/dist/lib/signal/cached-resource.js +59 -72
  22. package/dist/lib/signal/cached-resource.mjs +77 -34
  23. package/dist/lib/signal/graph/children.cjs +3 -2
  24. package/dist/lib/signal/graph/children.mjs +3 -2
  25. package/dist/lib/signal/graph/compat.cjs +10 -9
  26. package/dist/lib/signal/graph/compat.d.ts +3 -1
  27. package/dist/lib/signal/graph/compat.d.ts.map +1 -1
  28. package/dist/lib/signal/graph/compat.js +2 -2
  29. package/dist/lib/signal/graph/compat.mjs +10 -9
  30. package/dist/lib/signal/graph/core.cjs +2 -2
  31. package/dist/lib/signal/graph/core.mjs +2 -2
  32. package/dist/lib/signal/graph/debounced.cjs +9 -8
  33. package/dist/lib/signal/graph/debounced.mjs +9 -8
  34. package/dist/lib/signal/graph/derived.cjs +9 -8
  35. package/dist/lib/signal/graph/derived.mjs +9 -8
  36. package/dist/lib/signal/graph/error-boundary.cjs +3 -2
  37. package/dist/lib/signal/graph/error-boundary.mjs +3 -2
  38. package/dist/lib/signal/graph/index.cjs +2 -2
  39. package/dist/lib/signal/graph/index.mjs +2 -2
  40. package/dist/lib/signal/graph/observe.cjs +38 -3
  41. package/dist/lib/signal/graph/observe.d.ts +44 -0
  42. package/dist/lib/signal/graph/observe.d.ts.map +1 -1
  43. package/dist/lib/signal/graph/observe.js +50 -1
  44. package/dist/lib/signal/graph/observe.mjs +38 -3
  45. package/dist/lib/signal/graph/resource.cjs +9 -8
  46. package/dist/lib/signal/graph/resource.mjs +9 -8
  47. package/dist/lib/signal/graph/runtime.cjs +7 -6
  48. package/dist/lib/signal/graph/runtime.d.ts +1 -1
  49. package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
  50. package/dist/lib/signal/graph/runtime.js +4 -4
  51. package/dist/lib/signal/graph/runtime.mjs +7 -6
  52. package/dist/lib/signal/graph/signal-next.cjs +39 -9
  53. package/dist/lib/signal/graph/signal-next.d.ts +1 -1
  54. package/dist/lib/signal/graph/signal-next.d.ts.map +1 -1
  55. package/dist/lib/signal/graph/signal-next.js +1 -1
  56. package/dist/lib/signal/graph/signal-next.mjs +39 -9
  57. package/dist/lib/signal/graph/ssr-hooks.cjs +29 -0
  58. package/dist/lib/signal/graph/ssr-hooks.d.ts +24 -0
  59. package/dist/lib/signal/graph/ssr-hooks.d.ts.map +1 -1
  60. package/dist/lib/signal/graph/ssr-hooks.js +36 -0
  61. package/dist/lib/signal/graph/ssr-hooks.mjs +29 -0
  62. package/dist/lib/signal/graph/state.cjs +1 -1
  63. package/dist/lib/signal/graph/state.mjs +1 -1
  64. package/dist/lib/signal/graph/suspense.cjs +3 -2
  65. package/dist/lib/signal/graph/suspense.mjs +3 -2
  66. package/dist/lib/signal/index-legacy.cjs +65 -34
  67. package/dist/lib/signal/index-legacy.mjs +65 -34
  68. package/dist/lib/signal/index.cjs +76 -12
  69. package/dist/lib/signal/index.d.ts +2 -1
  70. package/dist/lib/signal/index.d.ts.map +1 -1
  71. package/dist/lib/signal/index.js +1 -1
  72. package/dist/lib/signal/index.mjs +76 -12
  73. package/dist/lib/signal/list.cjs +3 -2
  74. package/dist/lib/signal/list.mjs +3 -2
  75. package/dist/lib/signal/resource-api.cjs +9 -8
  76. package/dist/lib/signal/resource-api.mjs +9 -8
  77. package/dist/lib/signal/signal.cjs +9 -8
  78. package/dist/lib/signal/signal.mjs +9 -8
  79. package/dist/lib/signal/utilities.cjs +10 -9
  80. package/dist/lib/signal/utilities.mjs +10 -9
  81. package/dist/lib/store/api.cjs +3 -2
  82. package/dist/lib/store/api.mjs +3 -2
  83. package/dist/lib/store/index.cjs +4 -3
  84. package/dist/lib/store/index.mjs +4 -3
  85. package/dist/lib/store/store.cjs +3 -2
  86. package/dist/lib/store/store.mjs +3 -2
  87. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  88. package/dist/version.generated.cjs +2 -2
  89. package/dist/version.generated.d.ts +1 -1
  90. package/dist/version.generated.js +1 -1
  91. package/dist/version.generated.mjs +2 -2
  92. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- /*! @fluixi/reactive v1.0.0-alpha.92 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/reactive v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,8 +26,10 @@ __export(index_exports, {
26
26
  Signal: () => Signal,
27
27
  SuspenseContext: () => SuspenseContext,
28
28
  __DEV__: () => __DEV__,
29
+ adoptReactiveScope: () => adoptReactiveScope,
29
30
  batch: () => batch2,
30
31
  childOwner: () => childOwner,
32
+ closeReactiveScope: () => closeReactiveScope,
31
33
  computed: () => computed,
32
34
  context: () => context,
33
35
  createChildOwner: () => createChildOwner,
@@ -42,10 +44,12 @@ __export(index_exports, {
42
44
  createMemo: () => createMemo,
43
45
  createRenderEffect: () => createRenderEffect,
44
46
  createResource: () => createResource,
47
+ createResourceCache: () => createResourceCache,
45
48
  createRoot: () => createRoot,
46
49
  createSelector: () => createSelector,
47
50
  createSignal: () => createSignal,
48
51
  createSuspenseBoundary: () => createSuspenseBoundary,
52
+ currentResourceCache: () => currentResourceCache,
49
53
  disposeScope: () => disposeScope,
50
54
  effect: () => effect2,
51
55
  flush: () => flush,
@@ -63,14 +67,17 @@ __export(index_exports, {
63
67
  keyArray: () => keyArray,
64
68
  makeArrayFlat: () => makeArrayFlat,
65
69
  mapArray: () => mapArray,
70
+ markReactiveScope: () => markReactiveScope,
66
71
  memo: () => memo,
67
72
  nextResourceId: () => nextResourceId,
68
73
  observeReactiveNodes: () => observeReactiveNodes,
69
74
  on: () => on,
70
75
  onCleanup: () => onCleanup,
76
+ openReactiveScope: () => openReactiveScope,
71
77
  provide: () => provide,
72
78
  provideErrorBoundary: () => provideErrorBoundary,
73
79
  provideSuspense: () => provideSuspense,
80
+ reactiveScopeOf: () => reactiveScopeOf,
74
81
  readChildren: () => readChildren,
75
82
  renderEffect: () => renderEffect,
76
83
  reportReactiveBinding: () => reportReactiveBinding,
@@ -83,6 +90,7 @@ __export(index_exports, {
83
90
  root: () => root,
84
91
  runWithOwner: () => runWithOwner,
85
92
  setOwner: () => setOwner,
93
+ setResourceCacheScope: () => setResourceCacheScope,
86
94
  setResourceDataSink: () => setResourceDataSink,
87
95
  setResourceIdSource: () => setResourceIdSource,
88
96
  setResourceTracker: () => setResourceTracker,
@@ -92,12 +100,13 @@ __export(index_exports, {
92
100
  trackResourcePromise: () => trackResourcePromise,
93
101
  untrack: () => untrack2,
94
102
  useContext: () => useContext,
95
- useTransition: () => useTransition
103
+ useTransition: () => useTransition,
104
+ withReactiveScope: () => withReactiveScope
96
105
  });
97
106
  module.exports = __toCommonJS(index_exports);
98
107
 
99
108
  // src/version.generated.ts
100
- var VERSION = "1.0.0-alpha.92";
109
+ var VERSION = "1.0.0-alpha.94";
101
110
 
102
111
  // src/lib/signal/graph/state.ts
103
112
  var MAJOR = VERSION.split(".")[0];
@@ -150,11 +159,40 @@ function observeReactiveNodes(next) {
150
159
  }
151
160
  var running = [];
152
161
  var origin;
162
+ var currentScope;
163
+ function openReactiveScope(info) {
164
+ const scope = {};
165
+ G.observer?.scope?.(scope, info, currentScope);
166
+ return scope;
167
+ }
168
+ function withReactiveScope(scope, fn) {
169
+ if (!G.observer) return fn();
170
+ const previous = currentScope;
171
+ currentScope = scope;
172
+ try {
173
+ return fn();
174
+ } finally {
175
+ currentScope = previous;
176
+ }
177
+ }
178
+ function closeReactiveScope(scope) {
179
+ G.observer?.scopeEnded?.(scope);
180
+ }
181
+ function adoptReactiveScope(scope, parent) {
182
+ G.observer?.scopeAdopted?.(scope, parent);
183
+ }
184
+ var SCOPE_OF = /* @__PURE__ */ Symbol.for("fluixi.reactiveScope");
185
+ function markReactiveScope(value, scope) {
186
+ Object.defineProperty(value, SCOPE_OF, { value: scope, configurable: true, enumerable: false });
187
+ }
188
+ function reactiveScopeOf(value) {
189
+ return value !== null && (typeof value === "object" || typeof value === "function") ? value[SCOPE_OF] ?? void 0 : void 0;
190
+ }
153
191
  function reportReactiveNode(report) {
154
192
  const observer = G.observer;
155
193
  if (observer) {
156
194
  observer.created(
157
- report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
195
+ report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
158
196
  );
159
197
  }
160
198
  }
@@ -571,7 +609,7 @@ function batch(fn) {
571
609
  }
572
610
  }
573
611
  var EffectNode = class {
574
- constructor(fn, report = false) {
612
+ constructor(fn, report = false, name) {
575
613
  this.queued = false;
576
614
  this.disposed = false;
577
615
  this.owner = makeOwner(G.owner);
@@ -583,7 +621,7 @@ var EffectNode = class {
583
621
  if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
584
622
  });
585
623
  });
586
- reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
624
+ reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
587
625
  this.watcher = new Watcher(() => enqueue(this));
588
626
  this.run();
589
627
  this.watcher.watch(this.computed);
@@ -610,8 +648,8 @@ var EffectNode = class {
610
648
  disposeOwner(this.owner);
611
649
  }
612
650
  };
613
- function effect(fn, report = false) {
614
- const node = new EffectNode(fn, report);
651
+ function effect(fn, report = false, name) {
652
+ const node = new EffectNode(fn, report, name);
615
653
  return () => node.dispose();
616
654
  }
617
655
 
@@ -679,12 +717,12 @@ function createMemo(fn, value, options) {
679
717
  if (isObserved()) onCleanup(() => reportReactiveDispose(c));
680
718
  return read;
681
719
  }
682
- function createEffect(fn, value) {
720
+ function createEffect(fn, value, options) {
683
721
  let prev = value;
684
722
  return effect(() => {
685
723
  const r = fn(prev);
686
724
  prev = r;
687
- }, true);
725
+ }, true, options?.name);
688
726
  }
689
727
  function createComputed(fn, value) {
690
728
  let prev = value;
@@ -930,6 +968,32 @@ function setResourceDataSink(fn) {
930
968
  function reportResourceData(id, value) {
931
969
  if (_resourceDataSink) _resourceDataSink(id, value);
932
970
  }
971
+ function createResourceCache() {
972
+ const entries = /* @__PURE__ */ new Map();
973
+ const inflight = /* @__PURE__ */ new Map();
974
+ return {
975
+ get: (key) => entries.get(key),
976
+ set: (key, entry) => void entries.set(key, entry),
977
+ delete: (key) => void entries.delete(key),
978
+ keys: () => entries.keys(),
979
+ clear: () => {
980
+ entries.clear();
981
+ inflight.clear();
982
+ },
983
+ inflight
984
+ };
985
+ }
986
+ var _cacheScope = null;
987
+ function setResourceCacheScope(fn) {
988
+ _cacheScope = fn;
989
+ }
990
+ var _pageCache;
991
+ function currentResourceCache() {
992
+ const scoped = _cacheScope?.();
993
+ if (scoped) return scoped;
994
+ if (typeof window === "undefined") return createResourceCache();
995
+ return _pageCache ??= createResourceCache();
996
+ }
933
997
 
934
998
  // src/lib/signal/graph/derived.ts
935
999
  function createSelector(source, fn = (k, v) => k === v) {
@@ -1249,8 +1313,8 @@ function signal(value, options) {
1249
1313
  function memo(fn, value, options) {
1250
1314
  return createMemo(fn, value, options);
1251
1315
  }
1252
- function effect2(fn, value) {
1253
- return createEffect(fn, value);
1316
+ function effect2(fn, value, options) {
1317
+ return createEffect(fn, value, options);
1254
1318
  }
1255
1319
  function root(fn) {
1256
1320
  return createRoot(fn);
@@ -9,7 +9,8 @@
9
9
  * `@fluixi/reactive/signal-legacy` entry (./index-legacy.ts).
10
10
  */
11
11
  export * from './graph/signal-next.js';
12
- export { observeReactiveNodes, reportReactiveBinding, reportReactiveProps, reportReactiveDirective, reportReactiveContext, reportReactiveContextCreated } from './graph/observe.js';
12
+ export { observeReactiveNodes, reportReactiveBinding, reportReactiveProps, reportReactiveDirective, reportReactiveContext, reportReactiveContextCreated, openReactiveScope, withReactiveScope, closeReactiveScope, adoptReactiveScope, markReactiveScope, reactiveScopeOf } from './graph/observe.js';
13
+ export type { ReactiveScopeInfo, ReactiveScopeKind } from './graph/observe.js';
13
14
  export { joinedVersions } from './graph/state.js';
14
15
  export type { ReactiveNodeKind, ReactiveNodeReport, ReactiveObserver } from './graph/observe.js';
15
16
  export * from './api.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/signal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,wBAAwB,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAGpL,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGjG,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/signal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,wBAAwB,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACtS,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG/E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGjG,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
@@ -10,7 +10,7 @@
10
10
  */
11
11
  export * from './graph/signal-next.js';
12
12
  // Watching nodes as they are made: what @fluixi/devtools attaches to.
13
- export { observeReactiveNodes, reportReactiveBinding, reportReactiveProps, reportReactiveDirective, reportReactiveContext, reportReactiveContextCreated } from './graph/observe.js';
13
+ export { observeReactiveNodes, reportReactiveBinding, reportReactiveProps, reportReactiveDirective, reportReactiveContext, reportReactiveContextCreated, openReactiveScope, withReactiveScope, closeReactiveScope, adoptReactiveScope, markReactiveScope, reactiveScopeOf } from './graph/observe.js';
14
14
  // Which builds reached the shared graph. @fluixi/dom reports on it; a standalone web
15
15
  // component is the case where two of them can genuinely meet.
16
16
  export { joinedVersions } from './graph/state.js';
@@ -1,7 +1,7 @@
1
- /*! @fluixi/reactive v1.0.0-alpha.92 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/reactive v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
 
3
3
  // src/version.generated.ts
4
- var VERSION = "1.0.0-alpha.92";
4
+ var VERSION = "1.0.0-alpha.94";
5
5
 
6
6
  // src/lib/signal/graph/state.ts
7
7
  var MAJOR = VERSION.split(".")[0];
@@ -54,11 +54,40 @@ function observeReactiveNodes(next) {
54
54
  }
55
55
  var running = [];
56
56
  var origin;
57
+ var currentScope;
58
+ function openReactiveScope(info) {
59
+ const scope = {};
60
+ G.observer?.scope?.(scope, info, currentScope);
61
+ return scope;
62
+ }
63
+ function withReactiveScope(scope, fn) {
64
+ if (!G.observer) return fn();
65
+ const previous = currentScope;
66
+ currentScope = scope;
67
+ try {
68
+ return fn();
69
+ } finally {
70
+ currentScope = previous;
71
+ }
72
+ }
73
+ function closeReactiveScope(scope) {
74
+ G.observer?.scopeEnded?.(scope);
75
+ }
76
+ function adoptReactiveScope(scope, parent) {
77
+ G.observer?.scopeAdopted?.(scope, parent);
78
+ }
79
+ var SCOPE_OF = /* @__PURE__ */ Symbol.for("fluixi.reactiveScope");
80
+ function markReactiveScope(value, scope) {
81
+ Object.defineProperty(value, SCOPE_OF, { value: scope, configurable: true, enumerable: false });
82
+ }
83
+ function reactiveScopeOf(value) {
84
+ return value !== null && (typeof value === "object" || typeof value === "function") ? value[SCOPE_OF] ?? void 0 : void 0;
85
+ }
57
86
  function reportReactiveNode(report) {
58
87
  const observer = G.observer;
59
88
  if (observer) {
60
89
  observer.created(
61
- report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
90
+ report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
62
91
  );
63
92
  }
64
93
  }
@@ -475,7 +504,7 @@ function batch(fn) {
475
504
  }
476
505
  }
477
506
  var EffectNode = class {
478
- constructor(fn, report = false) {
507
+ constructor(fn, report = false, name) {
479
508
  this.queued = false;
480
509
  this.disposed = false;
481
510
  this.owner = makeOwner(G.owner);
@@ -487,7 +516,7 @@ var EffectNode = class {
487
516
  if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
488
517
  });
489
518
  });
490
- reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
519
+ reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
491
520
  this.watcher = new Watcher(() => enqueue(this));
492
521
  this.run();
493
522
  this.watcher.watch(this.computed);
@@ -514,8 +543,8 @@ var EffectNode = class {
514
543
  disposeOwner(this.owner);
515
544
  }
516
545
  };
517
- function effect(fn, report = false) {
518
- const node = new EffectNode(fn, report);
546
+ function effect(fn, report = false, name) {
547
+ const node = new EffectNode(fn, report, name);
519
548
  return () => node.dispose();
520
549
  }
521
550
 
@@ -583,12 +612,12 @@ function createMemo(fn, value, options) {
583
612
  if (isObserved()) onCleanup(() => reportReactiveDispose(c));
584
613
  return read;
585
614
  }
586
- function createEffect(fn, value) {
615
+ function createEffect(fn, value, options) {
587
616
  let prev = value;
588
617
  return effect(() => {
589
618
  const r = fn(prev);
590
619
  prev = r;
591
- }, true);
620
+ }, true, options?.name);
592
621
  }
593
622
  function createComputed(fn, value) {
594
623
  let prev = value;
@@ -834,6 +863,32 @@ function setResourceDataSink(fn) {
834
863
  function reportResourceData(id, value) {
835
864
  if (_resourceDataSink) _resourceDataSink(id, value);
836
865
  }
866
+ function createResourceCache() {
867
+ const entries = /* @__PURE__ */ new Map();
868
+ const inflight = /* @__PURE__ */ new Map();
869
+ return {
870
+ get: (key) => entries.get(key),
871
+ set: (key, entry) => void entries.set(key, entry),
872
+ delete: (key) => void entries.delete(key),
873
+ keys: () => entries.keys(),
874
+ clear: () => {
875
+ entries.clear();
876
+ inflight.clear();
877
+ },
878
+ inflight
879
+ };
880
+ }
881
+ var _cacheScope = null;
882
+ function setResourceCacheScope(fn) {
883
+ _cacheScope = fn;
884
+ }
885
+ var _pageCache;
886
+ function currentResourceCache() {
887
+ const scoped = _cacheScope?.();
888
+ if (scoped) return scoped;
889
+ if (typeof window === "undefined") return createResourceCache();
890
+ return _pageCache ??= createResourceCache();
891
+ }
837
892
 
838
893
  // src/lib/signal/graph/derived.ts
839
894
  function createSelector(source, fn = (k, v) => k === v) {
@@ -1153,8 +1208,8 @@ function signal(value, options) {
1153
1208
  function memo(fn, value, options) {
1154
1209
  return createMemo(fn, value, options);
1155
1210
  }
1156
- function effect2(fn, value) {
1157
- return createEffect(fn, value);
1211
+ function effect2(fn, value, options) {
1212
+ return createEffect(fn, value, options);
1158
1213
  }
1159
1214
  function root(fn) {
1160
1215
  return createRoot(fn);
@@ -1183,8 +1238,10 @@ export {
1183
1238
  Signal,
1184
1239
  SuspenseContext,
1185
1240
  __DEV__,
1241
+ adoptReactiveScope,
1186
1242
  batch2 as batch,
1187
1243
  childOwner,
1244
+ closeReactiveScope,
1188
1245
  computed,
1189
1246
  context,
1190
1247
  createChildOwner,
@@ -1199,10 +1256,12 @@ export {
1199
1256
  createMemo,
1200
1257
  createRenderEffect,
1201
1258
  createResource,
1259
+ createResourceCache,
1202
1260
  createRoot,
1203
1261
  createSelector,
1204
1262
  createSignal,
1205
1263
  createSuspenseBoundary,
1264
+ currentResourceCache,
1206
1265
  disposeScope,
1207
1266
  effect2 as effect,
1208
1267
  flush,
@@ -1220,14 +1279,17 @@ export {
1220
1279
  keyArray,
1221
1280
  makeArrayFlat,
1222
1281
  mapArray,
1282
+ markReactiveScope,
1223
1283
  memo,
1224
1284
  nextResourceId,
1225
1285
  observeReactiveNodes,
1226
1286
  on,
1227
1287
  onCleanup,
1288
+ openReactiveScope,
1228
1289
  provide,
1229
1290
  provideErrorBoundary,
1230
1291
  provideSuspense,
1292
+ reactiveScopeOf,
1231
1293
  readChildren,
1232
1294
  renderEffect,
1233
1295
  reportReactiveBinding,
@@ -1240,6 +1302,7 @@ export {
1240
1302
  root,
1241
1303
  runWithOwner,
1242
1304
  setOwner,
1305
+ setResourceCacheScope,
1243
1306
  setResourceDataSink,
1244
1307
  setResourceIdSource,
1245
1308
  setResourceTracker,
@@ -1249,5 +1312,6 @@ export {
1249
1312
  trackResourcePromise,
1250
1313
  untrack2 as untrack,
1251
1314
  useContext,
1252
- useTransition
1315
+ useTransition,
1316
+ withReactiveScope
1253
1317
  };
@@ -27,7 +27,7 @@ __export(list_exports, {
27
27
  module.exports = __toCommonJS(list_exports);
28
28
 
29
29
  // src/version.generated.ts
30
- var VERSION = "1.0.0-alpha.92";
30
+ var VERSION = "1.0.0-alpha.94";
31
31
 
32
32
  // src/lib/signal/graph/state.ts
33
33
  var MAJOR = VERSION.split(".")[0];
@@ -77,11 +77,12 @@ function observeReactiveNodes(next) {
77
77
  }
78
78
  var running = [];
79
79
  var origin;
80
+ var currentScope;
80
81
  function reportReactiveNode(report) {
81
82
  const observer = G.observer;
82
83
  if (observer) {
83
84
  observer.created(
84
- report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
85
+ report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
85
86
  );
86
87
  }
87
88
  }
@@ -1,5 +1,5 @@
1
1
  // src/version.generated.ts
2
- var VERSION = "1.0.0-alpha.92";
2
+ var VERSION = "1.0.0-alpha.94";
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
  }
@@ -25,7 +25,7 @@ __export(resource_api_exports, {
25
25
  module.exports = __toCommonJS(resource_api_exports);
26
26
 
27
27
  // src/version.generated.ts
28
- var VERSION = "1.0.0-alpha.92";
28
+ var VERSION = "1.0.0-alpha.94";
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.92";
2
+ var VERSION = "1.0.0-alpha.94";
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);
@@ -468,7 +468,7 @@ function makeArrayFlat(values) {
468
468
  }
469
469
 
470
470
  // src/version.generated.ts
471
- var VERSION = "1.0.0-alpha.92";
471
+ var VERSION = "1.0.0-alpha.94";
472
472
 
473
473
  // src/lib/signal/graph/state.ts
474
474
  var MAJOR = VERSION.split(".")[0];
@@ -518,11 +518,12 @@ function observeReactiveNodes(next) {
518
518
  }
519
519
  var running = [];
520
520
  var origin;
521
+ var currentScope;
521
522
  function reportReactiveNode(report) {
522
523
  const observer = G.observer;
523
524
  if (observer) {
524
525
  observer.created(
525
- report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin } : report
526
+ report.parents === void 0 ? { ...report, parents: running, origin: report.origin ?? origin, scope: report.scope ?? currentScope } : { ...report, scope: report.scope ?? currentScope }
526
527
  );
527
528
  }
528
529
  }
@@ -809,7 +810,7 @@ function afterWrite() {
809
810
  if (G.batchDepth === 0) flushSync();
810
811
  }
811
812
  var EffectNode = class {
812
- constructor(fn, report = false) {
813
+ constructor(fn, report = false, name) {
813
814
  this.queued = false;
814
815
  this.disposed = false;
815
816
  this.owner = makeOwner(G.owner);
@@ -821,7 +822,7 @@ var EffectNode = class {
821
822
  if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
822
823
  });
823
824
  });
824
- reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
825
+ reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
825
826
  this.watcher = new Watcher(() => enqueue(this));
826
827
  this.run();
827
828
  this.watcher.watch(this.computed);
@@ -848,8 +849,8 @@ var EffectNode = class {
848
849
  disposeOwner(this.owner);
849
850
  }
850
851
  };
851
- function effect(fn, report = false) {
852
- const node = new EffectNode(fn, report);
852
+ function effect(fn, report = false, name) {
853
+ const node = new EffectNode(fn, report, name);
853
854
  return () => node.dispose();
854
855
  }
855
856
 
@@ -917,12 +918,12 @@ function createMemo(fn, value, options) {
917
918
  if (isObserved()) onCleanup(() => reportReactiveDispose(c));
918
919
  return read;
919
920
  }
920
- function createEffect(fn, value) {
921
+ function createEffect(fn, value, options) {
921
922
  let prev = value;
922
923
  return effect(() => {
923
924
  const r = fn(prev);
924
925
  prev = r;
925
- }, true);
926
+ }, true, options?.name);
926
927
  }
927
928
 
928
929
  // src/lib/signal/graph/derived.ts