@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,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/predicates.ts
5
5
  function isFunction(value) {
@@ -490,11 +490,40 @@ function withReactiveOrigin(owner, fn) {
490
490
  origin = previous;
491
491
  }
492
492
  }
493
+ var currentScope;
494
+ function openReactiveScope(info) {
495
+ const scope = {};
496
+ G.observer?.scope?.(scope, info, currentScope);
497
+ return scope;
498
+ }
499
+ function withReactiveScope(scope, fn) {
500
+ if (!G.observer) return fn();
501
+ const previous = currentScope;
502
+ currentScope = scope;
503
+ try {
504
+ return fn();
505
+ } finally {
506
+ currentScope = previous;
507
+ }
508
+ }
509
+ function closeReactiveScope(scope) {
510
+ G.observer?.scopeEnded?.(scope);
511
+ }
512
+ function adoptReactiveScope(scope, parent) {
513
+ G.observer?.scopeAdopted?.(scope, parent);
514
+ }
515
+ var SCOPE_OF = /* @__PURE__ */ Symbol.for("fluixi.reactiveScope");
516
+ function markReactiveScope(value, scope) {
517
+ Object.defineProperty(value, SCOPE_OF, { value: scope, configurable: true, enumerable: false });
518
+ }
519
+ function reactiveScopeOf(value) {
520
+ return value !== null && (typeof value === "object" || typeof value === "function") ? value[SCOPE_OF] ?? void 0 : void 0;
521
+ }
493
522
  function reportReactiveNode(report) {
494
523
  const observer = G.observer;
495
524
  if (observer) {
496
525
  observer.created(
497
- 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 }
498
527
  );
499
528
  }
500
529
  }
@@ -914,7 +943,7 @@ function batch(fn) {
914
943
  }
915
944
  }
916
945
  var EffectNode = class {
917
- constructor(fn, report = false) {
946
+ constructor(fn, report = false, name) {
918
947
  this.queued = false;
919
948
  this.disposed = false;
920
949
  this.owner = makeOwner(G.owner);
@@ -926,7 +955,7 @@ var EffectNode = class {
926
955
  if (typeof r === "function") (this.owner.cleanups ??= []).push(r);
927
956
  });
928
957
  });
929
- reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report });
958
+ reportReactiveNode({ kind: "effect", node: this.computed, handle: this, internal: !report, ...name ? { name } : {} });
930
959
  this.watcher = new Watcher(() => enqueue(this));
931
960
  this.run();
932
961
  this.watcher.watch(this.computed);
@@ -953,8 +982,8 @@ var EffectNode = class {
953
982
  disposeOwner(this.owner);
954
983
  }
955
984
  };
956
- function effect(fn, report = false) {
957
- const node = new EffectNode(fn, report);
985
+ function effect(fn, report = false, name) {
986
+ const node = new EffectNode(fn, report, name);
958
987
  return () => node.dispose();
959
988
  }
960
989
 
@@ -1022,12 +1051,12 @@ function createMemo(fn, value, options) {
1022
1051
  if (isObserved()) onCleanup(() => reportReactiveDispose(c));
1023
1052
  return read;
1024
1053
  }
1025
- function createEffect(fn, value) {
1054
+ function createEffect(fn, value, options) {
1026
1055
  let prev = value;
1027
1056
  return effect(() => {
1028
1057
  const r = fn(prev);
1029
1058
  prev = r;
1030
- }, true);
1059
+ }, true, options?.name);
1031
1060
  }
1032
1061
  function createComputed(fn, value) {
1033
1062
  let prev = value;
@@ -1273,6 +1302,32 @@ function setResourceDataSink(fn) {
1273
1302
  function reportResourceData(id, value) {
1274
1303
  if (_resourceDataSink) _resourceDataSink(id, value);
1275
1304
  }
1305
+ function createResourceCache() {
1306
+ const entries = /* @__PURE__ */ new Map();
1307
+ const inflight = /* @__PURE__ */ new Map();
1308
+ return {
1309
+ get: (key) => entries.get(key),
1310
+ set: (key, entry) => void entries.set(key, entry),
1311
+ delete: (key) => void entries.delete(key),
1312
+ keys: () => entries.keys(),
1313
+ clear: () => {
1314
+ entries.clear();
1315
+ inflight.clear();
1316
+ },
1317
+ inflight
1318
+ };
1319
+ }
1320
+ var _cacheScope = null;
1321
+ function setResourceCacheScope(fn) {
1322
+ _cacheScope = fn;
1323
+ }
1324
+ var _pageCache;
1325
+ function currentResourceCache() {
1326
+ const scoped = _cacheScope?.();
1327
+ if (scoped) return scoped;
1328
+ if (typeof window === "undefined") return createResourceCache();
1329
+ return _pageCache ??= createResourceCache();
1330
+ }
1276
1331
 
1277
1332
  // src/lib/signal/graph/derived.ts
1278
1333
  function createSelector(source, fn = (k, v) => k === v) {
@@ -1592,8 +1647,8 @@ function signal(value, options) {
1592
1647
  function memo(fn, value, options) {
1593
1648
  return createMemo(fn, value, options);
1594
1649
  }
1595
- function effect2(fn, value) {
1596
- return createEffect(fn, value);
1650
+ function effect2(fn, value, options) {
1651
+ return createEffect(fn, value, options);
1597
1652
  }
1598
1653
  function root(fn) {
1599
1654
  return createRoot(fn);
@@ -2383,12 +2438,10 @@ function readSignal(signal2) {
2383
2438
  }
2384
2439
 
2385
2440
  // src/lib/signal/cached-resource.ts
2386
- var ttlCache = /* @__PURE__ */ new Map();
2387
- var inflight = /* @__PURE__ */ new Map();
2388
2441
  var _autoId = 0;
2389
2442
  var $SIGNAL4 = /* @__PURE__ */ Symbol.for("signal");
2390
2443
  var $RESOURCE2 = /* @__PURE__ */ Symbol.for("resource");
2391
- function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
2444
+ function cachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
2392
2445
  let sourceFn;
2393
2446
  let fetchFn;
2394
2447
  let options;
@@ -2407,7 +2460,13 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
2407
2460
  staleWhileRevalidate = true
2408
2461
  } = options;
2409
2462
  const ns = name;
2410
- const buildKey = (key) => `${ns}:${JSON.stringify(key)}`;
2463
+ const cache = options.cache ?? currentResourceCache();
2464
+ const inflight = cache.inflight;
2465
+ const ssrId = options.transport === false ? void 0 : nextResourceId();
2466
+ const seed = ssrId !== void 0 ? getServerData(ssrId) : void 0;
2467
+ const deps = options.deps ?? [];
2468
+ const depValues = () => deps.map((dep) => dep());
2469
+ const buildKey = (key, values = untrack2(depValues)) => `${ns}:${JSON.stringify(key)}` + (deps.length ? `:${JSON.stringify(values)}` : "");
2411
2470
  const isFresh = (entry) => ttl === Infinity || Date.now() - entry.timestamp <= ttl;
2412
2471
  const [value, setValue] = createSignal(void 0, { equals: false });
2413
2472
  const [resourceState, setResourceState] = createSignal("unresolved", { equals: false });
@@ -2420,8 +2479,9 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
2420
2479
  let flagRefetch = false;
2421
2480
  let flagInvalidate = false;
2422
2481
  function doFetch(key, ck, background, isCancelled) {
2423
- if (inflight.has(ck)) {
2424
- inflight.get(ck).then(
2482
+ const running2 = inflight.get(ck);
2483
+ if (running2) {
2484
+ running2.then(
2425
2485
  (v) => {
2426
2486
  if (!isCancelled()) settle(v, background);
2427
2487
  },
@@ -2429,12 +2489,15 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
2429
2489
  if (!isCancelled() && !background) fail(e);
2430
2490
  }
2431
2491
  );
2432
- if (!background) setPendingP(inflight.get(ck));
2492
+ if (!background) {
2493
+ trackResourcePromise(running2);
2494
+ setPendingP(running2);
2495
+ }
2433
2496
  return;
2434
2497
  }
2435
2498
  const promise = Promise.resolve(fetchFn(key)).then(
2436
2499
  (v) => {
2437
- ttlCache.set(ck, { value: v, timestamp: Date.now() });
2500
+ cache.set(ck, { value: v, timestamp: Date.now() });
2438
2501
  inflight.delete(ck);
2439
2502
  return v;
2440
2503
  },
@@ -2457,7 +2520,8 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
2457
2520
  }
2458
2521
  );
2459
2522
  }
2460
- function settle(v, background) {
2523
+ function settle(v, _background) {
2524
+ if (ssrId !== void 0) reportResourceData(ssrId, v);
2461
2525
  batch2(() => {
2462
2526
  setValue(() => v);
2463
2527
  setResourceState("ready");
@@ -2475,6 +2539,7 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
2475
2539
  }
2476
2540
  createEffect(() => {
2477
2541
  const key = sourceFn();
2542
+ const values = depValues();
2478
2543
  tick();
2479
2544
  if (key === false || key === null || key === void 0) {
2480
2545
  prevKey = UNSET2;
@@ -2489,16 +2554,18 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
2489
2554
  const doInvalidate = flagInvalidate;
2490
2555
  flagRefetch = false;
2491
2556
  flagInvalidate = false;
2492
- const ck = buildKey(key);
2493
- if (doInvalidate) ttlCache.delete(ck);
2557
+ const ck = buildKey(key, values);
2558
+ if (seed && prevKey === UNSET2 && !cache.get(ck)) cache.set(ck, { value: seed.value, timestamp: Date.now() });
2559
+ if (doInvalidate) cache.delete(ck);
2494
2560
  const keyChanged = prevKey === UNSET2 || key !== prevKey;
2495
2561
  prevKey = key;
2496
2562
  let cancelled = false;
2497
2563
  onCleanup(() => {
2498
2564
  cancelled = true;
2499
2565
  });
2500
- const cached = ttlCache.get(ck);
2566
+ const cached = cache.get(ck);
2501
2567
  if (cached && isFresh(cached) && !doRefetch && !doInvalidate) {
2568
+ if (ssrId !== void 0) reportResourceData(ssrId, cached.value);
2502
2569
  const cur2 = untrack2(resourceState);
2503
2570
  if (cur2 !== "ready" || untrack2(value) !== cached.value) {
2504
2571
  batch2(() => {
@@ -2559,22 +2626,17 @@ function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
2559
2626
  const invalidate = () => {
2560
2627
  const key = untrack2(sourceFn);
2561
2628
  if (key !== null && key !== void 0 && key !== false) {
2562
- ttlCache.delete(buildKey(key));
2629
+ cache.delete(buildKey(key));
2563
2630
  }
2564
2631
  flagInvalidate = true;
2565
2632
  setTick((v) => v + 1);
2566
2633
  };
2567
- return [resource2, { mutate: setValue, refetch, invalidate }];
2634
+ return Object.assign(resource2, { mutate: setValue, refetch, invalidate });
2568
2635
  }
2569
- function clearCachedResourceNamespace(name) {
2636
+ function clearCachedResources(name, cache = currentResourceCache()) {
2637
+ if (name === void 0) return cache.clear();
2570
2638
  const prefix = `${name}:`;
2571
- for (const key of ttlCache.keys()) {
2572
- if (key.startsWith(prefix)) ttlCache.delete(key);
2573
- }
2574
- }
2575
- function clearAllCachedResources() {
2576
- ttlCache.clear();
2577
- inflight.clear();
2639
+ for (const key of [...cache.keys()]) if (key.startsWith(prefix)) cache.delete(key);
2578
2640
  }
2579
2641
  export {
2580
2642
  $NAME,
@@ -2596,15 +2658,16 @@ export {
2596
2658
  SuspenseContext,
2597
2659
  VERSION,
2598
2660
  __DEV__,
2661
+ adoptReactiveScope,
2599
2662
  batch2 as batch,
2663
+ cachedResource,
2600
2664
  childOwner,
2601
- clearAllCachedResources,
2602
- clearCachedResourceNamespace,
2665
+ clearCachedResources,
2666
+ closeReactiveScope,
2603
2667
  combineSignal,
2604
2668
  combineSignals,
2605
2669
  computed,
2606
2670
  context,
2607
- createCachedResource,
2608
2671
  createChildOwner,
2609
2672
  createComputed,
2610
2673
  createComputedStore,
@@ -2619,6 +2682,7 @@ export {
2619
2682
  createMutableStore,
2620
2683
  createRenderEffect,
2621
2684
  createResource,
2685
+ createResourceCache,
2622
2686
  createRoot,
2623
2687
  createSelector,
2624
2688
  createSignal,
@@ -2626,6 +2690,7 @@ export {
2626
2690
  createStoreEffect,
2627
2691
  createStoreMemo,
2628
2692
  createSuspenseBoundary,
2693
+ currentResourceCache,
2629
2694
  debounceSignal,
2630
2695
  disposeScope,
2631
2696
  distinctSignal,
@@ -2654,6 +2719,7 @@ export {
2654
2719
  makeArrayFlat,
2655
2720
  mapArray,
2656
2721
  mapSignal,
2722
+ markReactiveScope,
2657
2723
  memo,
2658
2724
  mergeSignal,
2659
2725
  modifiable,
@@ -2662,12 +2728,14 @@ export {
2662
2728
  omitSignal,
2663
2729
  on,
2664
2730
  onCleanup,
2731
+ openReactiveScope,
2665
2732
  operate,
2666
2733
  pickSignal,
2667
2734
  produce as produceUtil,
2668
2735
  provide,
2669
2736
  provideErrorBoundary,
2670
2737
  provideSuspense,
2738
+ reactiveScopeOf,
2671
2739
  readChildren,
2672
2740
  readSignal,
2673
2741
  reconcile as reconcileUtil,
@@ -2684,6 +2752,7 @@ export {
2684
2752
  runWithOwner,
2685
2753
  selectSignal,
2686
2754
  setOwner,
2755
+ setResourceCacheScope,
2687
2756
  setResourceDataSink,
2688
2757
  setResourceIdSource,
2689
2758
  setResourceTracker,
@@ -2701,6 +2770,7 @@ export {
2701
2770
  useContext,
2702
2771
  useTransition,
2703
2772
  whenSignal,
2773
+ withReactiveScope,
2704
2774
  wrap,
2705
2775
  zipSignal
2706
2776
  };
@@ -27,7 +27,7 @@ __export(signal_exports, {
27
27
  module.exports = __toCommonJS(signal_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];
@@ -1,2 +1,2 @@
1
- /*! @fluixi/reactive v1.0.0-alpha.92 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
- "use strict";var Signal=(()=>{var b=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var z=(e,t)=>{for(var n in t)b(e,n,{get:t[n],enumerable:!0})},H=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of K(t))!j.call(e,s)&&s!==n&&b(e,s,{get:()=>t[s],enumerable:!(o=G(t,s))||o.enumerable});return e};var V=e=>H(b({},"__esModule",{value:!0}),e);var U={};z(U,{Computed:()=>h,State:()=>v,subtle:()=>Y});var a="1.0.0-alpha.92";var m=a.split(".")[0],_=`__fluixi_signal_state_v${m}__`,A=`__fluixi_signal_builds_v${m}__`,F=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function R(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:F,onSuspend:null,onError:null,observer:null}}var w=globalThis;function L(e){let t=R(),n=e;for(let o of Object.keys(t))o in e||(n[o]=t[o]);return e}function M(){let e=w[_];return e?L(e):w[_]=R()}var r=M();(w[A]??=[]).push(a);function P(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var y=[];function S(e){return r.observer?(y.push(e),!0):!1}function x(){y.pop()}function T(e){r.observer?.ran?.(e)}function O(e,t){r.observer?.wrote?.(e,t)}var W="__FLUIXI_DEVTOOLS_HOOK__",g=globalThis[W];if(typeof g?.inject=="function")try{g.inject({observeReactiveNodes:P,version:a})}catch{}var N=0,C=1,u=2,d=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},v=class extends d{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,O(this,r.consumer),this.observers)for(let n of[...this.observers])n.markDirty(u);k(this)}}peek(){return this._value}},h=class extends d{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=u;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===C&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===u)break}(this.state===u||!this._initialized)&&this.recompute(),this.state=N}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked,s=S(this);r.consumer=this,r.untracked=!1;let c,l=!1,p;try{c=this._fn()}catch(i){l=!0,p=i,c=this._value}finally{r.consumer=n,r.untracked=o,s&&x()}let I=!this._initialized||this._threw!==l||(l?p!==this._error:!this._equals(this._value,c));if(this._initialized=!0,this._threw=l,this._error=p,this._value=c,T(this),I){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(u);k(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===N;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(C);k(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function k(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var f=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function q(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function E(){return r.consumer}function D(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}var Y={Watcher:f,untrack:q,currentComputed:E,hasSinks:D};return V(U);})();
1
+ /*! @fluixi/reactive v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ "use strict";var Signal=(()=>{var b=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var z=(e,t)=>{for(var n in t)b(e,n,{get:t[n],enumerable:!0})},A=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of G(t))!K.call(e,s)&&s!==n&&b(e,s,{get:()=>t[s],enumerable:!(r=D(t,s))||r.enumerable});return e};var H=e=>A(b({},"__esModule",{value:!0}),e);var U={};z(U,{Computed:()=>p,State:()=>l,subtle:()=>Y});var a="1.0.0-alpha.94";var R=a.split(".")[0],_=`__fluixi_signal_state_v${R}__`,P=`__fluixi_signal_builds_v${R}__`,V=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)};function m(){return{consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:V,onSuspend:null,onError:null,observer:null}}var w=globalThis;function F(e){let t=m(),n=e;for(let r of Object.keys(t))r in e||(n[r]=t[r]);return e}function L(){let e=w[_];return e?F(e):w[_]=m()}var o=L();(w[P]??=[]).push(a);function M(e){return o.observer=e,()=>{o.observer===e&&(o.observer=null)}}var S=[];function g(e){return o.observer?(S.push(e),!0):!1}function x(){S.pop()}function T(e){o.observer?.ran?.(e)}function O(e,t){o.observer?.wrote?.(e,t)}var W="__FLUIXI_DEVTOOLS_HOOK__",y=globalThis[W];if(typeof y?.inject=="function")try{y.inject({observeReactiveNodes:M,version:a})}catch{}var j=0,N=1,c=2,v=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let t=o.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},l=class extends v{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,O(this,o.consumer),this.observers)for(let n of[...this.observers])n.markDirty(c);k(this)}}peek(){return this._value}},p=class extends v{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=c;this.sources=null;this._fn=n,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(o.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===N&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===c)break}(this.state===c||!this._initialized)&&this.recompute(),this.state=j}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let n=o.consumer,r=o.untracked,s=g(this);o.consumer=this,o.untracked=!1;let u,d=!1,h;try{u=this._fn()}catch(i){d=!0,h=i,u=this._value}finally{o.consumer=n,o.untracked=r,s&&x()}let I=!this._initialized||this._threw!==d||(d?h!==this._error:!this._equals(this._value,u));if(this._initialized=!0,this._threw=d,this._error=h,this._value=u,T(this),I){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(c);k(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===j;if(this.state=n,r){if(this.observers)for(let s of[...this.observers])s.markDirty(N);k(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function k(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var f=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function C(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function E(){return o.consumer}function q(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}var Y={Watcher:f,untrack:C,currentComputed:E,hasSinks:q};return H(U);})();
@@ -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];