@solidjs/signals 0.13.13 → 2.0.0-beta.7

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 (39) hide show
  1. package/README.md +8 -7
  2. package/dist/dev.js +90 -61
  3. package/dist/node.cjs +156 -137
  4. package/dist/prod.js +108 -81
  5. package/dist/types/core/graph.d.ts +1 -0
  6. package/dist/types/core/types.d.ts +2 -2
  7. package/dist/types/signals.d.ts +15 -21
  8. package/dist/types/store/optimistic.d.ts +2 -2
  9. package/dist/types/store/projection.d.ts +4 -4
  10. package/dist/types/store/store.d.ts +2 -2
  11. package/dist/types-cjs/boundaries.d.cts +52 -0
  12. package/dist/types-cjs/core/action.d.cts +1 -0
  13. package/dist/types-cjs/core/async.d.cts +6 -0
  14. package/dist/types-cjs/core/constants.d.cts +25 -0
  15. package/dist/types-cjs/core/context.d.cts +28 -0
  16. package/dist/types-cjs/core/core.d.cts +54 -0
  17. package/dist/types-cjs/core/dev.d.cts +49 -0
  18. package/dist/types-cjs/core/effect.d.cts +30 -0
  19. package/dist/types-cjs/core/error.d.cts +14 -0
  20. package/dist/types-cjs/core/external.d.cts +26 -0
  21. package/dist/types-cjs/core/graph.d.cts +4 -0
  22. package/dist/types-cjs/core/heap.d.cts +14 -0
  23. package/dist/types-cjs/core/index.d.cts +12 -0
  24. package/dist/types-cjs/core/lanes.d.cts +54 -0
  25. package/dist/types-cjs/core/owner.d.cts +26 -0
  26. package/dist/types-cjs/core/scheduler.d.cts +81 -0
  27. package/dist/types-cjs/core/types.d.cts +86 -0
  28. package/dist/types-cjs/index.d.cts +9 -0
  29. package/dist/types-cjs/map.d.cts +24 -0
  30. package/dist/types-cjs/package.json +3 -0
  31. package/dist/types-cjs/signals.d.cts +186 -0
  32. package/dist/types-cjs/store/index.d.cts +9 -0
  33. package/dist/types-cjs/store/optimistic.d.cts +19 -0
  34. package/dist/types-cjs/store/projection.d.cts +26 -0
  35. package/dist/types-cjs/store/reconcile.d.cts +1 -0
  36. package/dist/types-cjs/store/store.d.cts +68 -0
  37. package/dist/types-cjs/store/storePath.d.cts +30 -0
  38. package/dist/types-cjs/store/utils.d.cts +43 -0
  39. package/package.json +31 -24
package/dist/prod.js CHANGED
@@ -666,6 +666,7 @@ function unobserved(e) {
666
666
  t = unlinkSubs(t);
667
667
  }
668
668
  e.C = null;
669
+ e.ge = null;
669
670
  disposeChildren(e, true);
670
671
  }
671
672
  function link(e, t) {
@@ -746,12 +747,12 @@ function disposeChildren(e, t = false, n) {
746
747
  e.ve = null;
747
748
  } else {
748
749
  e.Ce = null;
749
- e.me = 0;
750
+ e.we = 0;
750
751
  }
751
752
  runDisposal(e, n);
752
753
  }
753
754
  function runDisposal(e, t) {
754
- let n = t ? e.we : e.Ve;
755
+ let n = t ? e.me : e.Ve;
755
756
  if (!n) return;
756
757
  if (Array.isArray(n)) {
757
758
  for (let e = 0; e < n.length; e++) {
@@ -761,12 +762,12 @@ function runDisposal(e, t) {
761
762
  } else {
762
763
  n.call(n);
763
764
  }
764
- t ? (e.we = null) : (e.Ve = null);
765
+ t ? (e.me = null) : (e.Ve = null);
765
766
  }
766
767
  function childId(e, t) {
767
768
  let n = e;
768
769
  while (n.be && n.i) n = n.i;
769
- if (n.id != null) return formatId(n.id, t ? n.me++ : n.me);
770
+ if (n.id != null) return formatId(n.id, t ? n.we++ : n.we);
770
771
  throw new Error("Cannot get child id from owner without an id");
771
772
  }
772
773
  function getNextChildId(e) {
@@ -810,8 +811,8 @@ function createOwner(e) {
810
811
  Ve: null,
811
812
  F: t?.F ?? globalQueue,
812
813
  Le: t?.Le || defaultContext,
813
- me: 0,
814
- we: null,
814
+ we: 0,
815
+ me: null,
815
816
  ve: null,
816
817
  i: t,
817
818
  dispose(e = true) {
@@ -1200,11 +1201,11 @@ function recompute(e, t = false) {
1200
1201
  if (e.K || n === EFFECT_TRACKED) disposeChildren(e);
1201
1202
  else {
1202
1203
  markDisposal(e);
1203
- e.we = e.Ve;
1204
+ e.me = e.Ve;
1204
1205
  e.ve = e.Ce;
1205
1206
  e.Ve = null;
1206
1207
  e.Ce = null;
1207
- e.me = 0;
1208
+ e.we = 0;
1208
1209
  }
1209
1210
  }
1210
1211
  const i = !!(e.O & REACTIVE_OPTIMISTIC_DIRTY);
@@ -1314,12 +1315,12 @@ function computed(e, t, n) {
1314
1315
  id: n?.id ?? (i ? context?.id : context?.id != null ? getNextChildId(context) : undefined),
1315
1316
  be: i || undefined,
1316
1317
  ke: n?.equals != null ? n.equals : isEqual,
1317
- le: !!n?.pureWrite,
1318
+ le: !!n?.ownedWrite,
1318
1319
  Ne: n?.unobserved,
1319
1320
  Ve: null,
1320
1321
  F: context?.F ?? globalQueue,
1321
1322
  Le: context?.Le ?? defaultContext,
1322
- me: 0,
1323
+ we: 0,
1323
1324
  L: e,
1324
1325
  J: t,
1325
1326
  o: 0,
@@ -1337,7 +1338,7 @@ function computed(e, t, n) {
1337
1338
  Se: STATUS_UNINITIALIZED,
1338
1339
  Ee: clock,
1339
1340
  X: NOT_PENDING,
1340
- we: null,
1341
+ me: null,
1341
1342
  ve: null,
1342
1343
  ye: null,
1343
1344
  K: null
@@ -1356,7 +1357,7 @@ function computed(e, t, n) {
1356
1357
  if (s) r.o = s.o + 1;
1357
1358
  if (snapshotCaptureActive && ownerInSnapshotScope(context)) r.Te = true;
1358
1359
  if (externalSourceConfig) {
1359
- const e = signal(undefined, { equals: false, pureWrite: true });
1360
+ const e = signal(undefined, { equals: false, ownedWrite: true });
1360
1361
  const t = externalSourceConfig.factory(r.L, () => {
1361
1362
  setSignal(e, undefined);
1362
1363
  });
@@ -1378,7 +1379,7 @@ function computed(e, t, n) {
1378
1379
  function signal(e, t, n = null) {
1379
1380
  const i = {
1380
1381
  ke: t?.equals != null ? t.equals : isEqual,
1381
- le: !!t?.pureWrite,
1382
+ le: !!t?.ownedWrite,
1382
1383
  He: !!t?.He,
1383
1384
  Ne: t?.unobserved,
1384
1385
  J: e,
@@ -1467,46 +1468,51 @@ function read(e) {
1467
1468
  }
1468
1469
  let t = context;
1469
1470
  if (t?.t) t = t.u;
1470
- if (refreshing && e.L) recompute(e);
1471
- if (e.O & REACTIVE_LAZY) {
1472
- e.O &= ~REACTIVE_LAZY;
1473
- recompute(e, true);
1474
- }
1475
- const n = e.V || e;
1471
+ const n = e;
1472
+ if (typeof n.L === "function") {
1473
+ const t = e;
1474
+ if (refreshing && !(t.O & REACTIVE_DISPOSED)) recompute(t);
1475
+ if (t.O & REACTIVE_LAZY) {
1476
+ t.O &= ~REACTIVE_LAZY;
1477
+ recompute(t, true);
1478
+ } else if (t.O & REACTIVE_DISPOSED) {
1479
+ recompute(t, true);
1480
+ }
1481
+ }
1482
+ const i = e.V || e;
1476
1483
  if (t && tracking) {
1477
- if (e.L && e.O & REACTIVE_DISPOSED) recompute(e);
1478
1484
  link(e, t);
1479
- if (n.L) {
1480
- const i = e.O & REACTIVE_ZOMBIE;
1481
- if (n.o >= (i ? zombieQueue.P : dirtyQueue.P)) {
1485
+ if (i.L) {
1486
+ const n = e.O & REACTIVE_ZOMBIE;
1487
+ if (i.o >= (n ? zombieQueue.P : dirtyQueue.P)) {
1482
1488
  markNode(t);
1483
- markHeap(i ? zombieQueue : dirtyQueue);
1484
- updateIfNecessary(n);
1489
+ markHeap(n ? zombieQueue : dirtyQueue);
1490
+ updateIfNecessary(i);
1485
1491
  }
1486
- const r = n.o;
1492
+ const r = i.o;
1487
1493
  if (r >= t.o && e.i !== t) {
1488
1494
  t.o = r + 1;
1489
1495
  }
1490
1496
  }
1491
1497
  }
1492
- if (n.Se & STATUS_PENDING) {
1493
- if (t && !(stale && n.K && activeTransition !== n.K)) {
1498
+ if (i.Se & STATUS_PENDING) {
1499
+ if (t && !(stale && i.K && activeTransition !== i.K)) {
1494
1500
  if (currentOptimisticLane) {
1495
- const i = n.q;
1501
+ const n = i.q;
1496
1502
  const r = findLane(currentOptimisticLane);
1497
- if (i && findLane(i) === r && !hasActiveOverride(n)) {
1503
+ if (n && findLane(n) === r && !hasActiveOverride(i)) {
1498
1504
  if (!tracking && e !== t) link(e, t);
1499
- throw n.fe;
1505
+ throw i.fe;
1500
1506
  }
1501
1507
  } else {
1502
1508
  if (!tracking && e !== t) link(e, t);
1503
- throw n.fe;
1509
+ throw i.fe;
1504
1510
  }
1505
- } else if (t && n !== e && n.Se & STATUS_UNINITIALIZED) {
1511
+ } else if (t && i !== e && i.Se & STATUS_UNINITIALIZED) {
1506
1512
  if (!tracking && e !== t) link(e, t);
1507
- throw n.fe;
1508
- } else if (!t && n.Se & STATUS_UNINITIALIZED) {
1509
- throw n.fe;
1513
+ throw i.fe;
1514
+ } else if (!t && i.Se & STATUS_UNINITIALIZED) {
1515
+ throw i.fe;
1510
1516
  }
1511
1517
  }
1512
1518
  if (e.L && e.Se & STATUS_ERROR) {
@@ -1528,13 +1534,26 @@ function read(e) {
1528
1534
  if (t && stale && shouldReadStashedOptimisticValue(e)) return e.J;
1529
1535
  return e.ee;
1530
1536
  }
1531
- return !t ||
1537
+ const r =
1538
+ !t ||
1532
1539
  (currentOptimisticLane !== null &&
1533
- (e.ee !== undefined || e.q || (n === e && stale) || !!(n.Se & STATUS_PENDING))) ||
1540
+ (e.ee !== undefined || e.q || (i === e && stale) || !!(i.Se & STATUS_PENDING))) ||
1534
1541
  e.X === NOT_PENDING ||
1535
1542
  (stale && e.K && activeTransition !== e.K)
1536
- ? e.J
1537
- : e.X;
1543
+ ? e.J
1544
+ : e.X;
1545
+ if (
1546
+ !t &&
1547
+ i === e &&
1548
+ typeof n.L === "function" &&
1549
+ !n.Pe &&
1550
+ !(i.Se & STATUS_PENDING) &&
1551
+ !n.i &&
1552
+ !e.I
1553
+ ) {
1554
+ unobserved(e);
1555
+ }
1556
+ return r;
1538
1557
  }
1539
1558
  function setSignal(e, t) {
1540
1559
  if (e.K && activeTransition !== e.K) globalQueue.initTransition(e.K);
@@ -1588,7 +1607,7 @@ function runWithOwner(e, t) {
1588
1607
  }
1589
1608
  function getPendingSignal(e) {
1590
1609
  if (!e.Fe) {
1591
- e.Fe = optimisticSignal(false, { pureWrite: true });
1610
+ e.Fe = optimisticSignal(false, { ownedWrite: true });
1592
1611
  if (e._e) {
1593
1612
  e.Fe._e = e;
1594
1613
  }
@@ -1875,23 +1894,24 @@ function accessor(e) {
1875
1894
  t.$r = true;
1876
1895
  return t;
1877
1896
  }
1878
- function createSignal(e, t, n) {
1897
+ function createSignal(e, t) {
1879
1898
  if (typeof e === "function") {
1880
- const i = computed(e, t, n);
1881
- return [accessor(i), setSignal.bind(null, i)];
1899
+ const n = computed(e, undefined, t);
1900
+ n.Pe = true;
1901
+ return [accessor(n), setSignal.bind(null, n)];
1882
1902
  }
1883
- const i = signal(e, t);
1884
- return [accessor(i), setSignal.bind(null, i)];
1903
+ const n = signal(e, t);
1904
+ return [accessor(n), setSignal.bind(null, n)];
1885
1905
  }
1886
- function createMemo(e, t, n) {
1887
- let i = computed(e, t, n);
1888
- return accessor(i);
1906
+ function createMemo(e, t) {
1907
+ let n = computed(e, undefined, t);
1908
+ return accessor(n);
1889
1909
  }
1890
- function createEffect(e, t, n, i) {
1891
- effect(e, t.effect || t, t.error, n, i);
1910
+ function createEffect(e, t, n) {
1911
+ effect(e, t.effect || t, t.error, undefined, n);
1892
1912
  }
1893
- function createRenderEffect(e, t, n, i) {
1894
- effect(e, t, undefined, n, { render: true, ...i });
1913
+ function createRenderEffect(e, t, n) {
1914
+ effect(e, t, undefined, undefined, { render: true, ...n });
1895
1915
  }
1896
1916
  function createTrackedEffect(e, t) {
1897
1917
  trackedEffect(e, t);
@@ -1933,13 +1953,14 @@ function resolve(e) {
1933
1953
  });
1934
1954
  });
1935
1955
  }
1936
- function createOptimistic(e, t, n) {
1956
+ function createOptimistic(e, t) {
1937
1957
  if (typeof e === "function") {
1938
- const i = optimisticComputed(e, t, n);
1939
- return [accessor(i), setSignal.bind(null, i)];
1958
+ const n = optimisticComputed(e, undefined, t);
1959
+ n.Pe = true;
1960
+ return [accessor(n), setSignal.bind(null, n)];
1940
1961
  }
1941
- const i = optimisticSignal(e, t);
1942
- return [accessor(i), setSignal.bind(null, i)];
1962
+ const n = optimisticSignal(e, t);
1963
+ return [accessor(n), setSignal.bind(null, n)];
1943
1964
  }
1944
1965
  function onSettled(e) {
1945
1966
  const t = getOwner();
@@ -2086,7 +2107,7 @@ function reconcile(e, t) {
2086
2107
  applyState(e, n, i);
2087
2108
  };
2088
2109
  }
2089
- function createProjectionInternal(e, t = {}, n) {
2110
+ function createProjectionInternal(e, t, n) {
2090
2111
  let i;
2091
2112
  const r = new WeakMap();
2092
2113
  const wrapper = e => {
@@ -2127,7 +2148,7 @@ function createProjectionInternal(e, t = {}, n) {
2127
2148
  i.Pe = true;
2128
2149
  return { store: s, node: i };
2129
2150
  }
2130
- function createProjection(e, t = {}, n) {
2151
+ function createProjection(e, t, n) {
2131
2152
  return createProjectionInternal(e, t, n).store;
2132
2153
  }
2133
2154
  function createWriteTraps(e) {
@@ -2546,7 +2567,7 @@ function createStore(e, t, n) {
2546
2567
  function createOptimisticStore(e, t, n) {
2547
2568
  GlobalQueue.ce ||= clearOptimisticStore;
2548
2569
  const i = typeof e === "function";
2549
- const r = (i ? t : e) ?? {};
2570
+ const r = i ? t : e;
2550
2571
  const s = i ? e : undefined;
2551
2572
  const { store: o } = createOptimisticProjectionInternal(s, r, n);
2552
2573
  return [o, e => storeSetter(o, e)];
@@ -2578,7 +2599,7 @@ function clearOptimisticStore(e) {
2578
2599
  }
2579
2600
  delete t[STORE_OPTIMISTIC_OVERRIDE];
2580
2601
  }
2581
- function createOptimisticProjectionInternal(e, t = {}, n) {
2602
+ function createOptimisticProjectionInternal(e, t, n) {
2582
2603
  let i;
2583
2604
  const r = new WeakMap();
2584
2605
  const wrapper = e => {
@@ -2888,7 +2909,7 @@ function mapArray(e, t, n) {
2888
2909
  const i = typeof n?.keyed === "function" ? n.keyed : undefined;
2889
2910
  const r = t.length > 1;
2890
2911
  const s = t;
2891
- return createMemo(
2912
+ const o = computed(
2892
2913
  updateKeyedMap.bind({
2893
2914
  Ye: createOwner(),
2894
2915
  Ze: 0,
@@ -2903,8 +2924,10 @@ function mapArray(e, t, n) {
2903
2924
  it: n?.fallback
2904
2925
  })
2905
2926
  );
2927
+ o.Pe = true;
2928
+ return accessor(o);
2906
2929
  }
2907
- const pureOptions = { pureWrite: true };
2930
+ const pureOptions = { ownedWrite: true };
2908
2931
  function updateKeyedMap() {
2909
2932
  const e = this.Be() || [],
2910
2933
  t = e.length;
@@ -3026,17 +3049,21 @@ function updateKeyedMap() {
3026
3049
  }
3027
3050
  function repeat(e, t, n) {
3028
3051
  const i = t;
3029
- return updateRepeat.bind({
3030
- Ye: createOwner(),
3031
- Ze: 0,
3032
- rt: 0,
3033
- st: e,
3034
- Xe: i,
3035
- Je: [],
3036
- ze: [],
3037
- ot: n?.from,
3038
- it: n?.fallback
3039
- });
3052
+ const r = computed(
3053
+ updateRepeat.bind({
3054
+ Ye: createOwner(),
3055
+ Ze: 0,
3056
+ rt: 0,
3057
+ st: e,
3058
+ Xe: i,
3059
+ Je: [],
3060
+ ze: [],
3061
+ ot: n?.from,
3062
+ it: n?.fallback
3063
+ })
3064
+ );
3065
+ r.Pe = true;
3066
+ return accessor(r);
3040
3067
  }
3041
3068
  function updateRepeat() {
3042
3069
  const e = this.st();
@@ -3134,8 +3161,8 @@ class RevealController {
3134
3161
  Ot;
3135
3162
  _t = [];
3136
3163
  dt;
3137
- ft = signal(false, { pureWrite: true, He: true });
3138
- Et = signal(false, { pureWrite: true, He: true });
3164
+ ft = signal(false, { ownedWrite: true, He: true });
3165
+ Et = signal(false, { ownedWrite: true, He: true });
3139
3166
  It = true;
3140
3167
  ht = false;
3141
3168
  constructor(e, t) {
@@ -3157,7 +3184,7 @@ class RevealController {
3157
3184
  if (this._t.includes(e)) return;
3158
3185
  this._t.push(e);
3159
3186
  const t = !!untrack(this.Rt);
3160
- setSignal(e.ft, true), setSignal(e.Et, t ? false : !!untrack(this.Ot));
3187
+ (setSignal(e.ft, true), setSignal(e.Et, t ? false : !!untrack(this.Ot)));
3161
3188
  untrack(() => this.evaluate());
3162
3189
  }
3163
3190
  unregister(e) {
@@ -3198,8 +3225,8 @@ class CollectionQueue extends Queue {
3198
3225
  ct = new Set();
3199
3226
  Pt;
3200
3227
  lt = true;
3201
- ft = signal(false, { pureWrite: true, He: true });
3202
- Et = signal(false, { pureWrite: true, He: true });
3228
+ ft = signal(false, { ownedWrite: true, He: true });
3229
+ Et = signal(false, { ownedWrite: true, He: true });
3203
3230
  Tt;
3204
3231
  St = false;
3205
3232
  gt;
@@ -3295,7 +3322,7 @@ function createCollectionBoundary(e, t, n, i) {
3295
3322
  const c = computed(() => {
3296
3323
  if (!read(s.ft)) {
3297
3324
  const e = read(o);
3298
- if (!untrack(() => read(s.ft))) return (s.St = true), e;
3325
+ if (!untrack(() => read(s.ft))) return ((s.St = true), e);
3299
3326
  }
3300
3327
  if (_revealUsed && read(s.Et)) return undefined;
3301
3328
  return n(s);
@@ -1,3 +1,4 @@
1
1
  import type { Computed, Link, Signal } from "./types.js";
2
2
  export declare function unlinkSubs(link: Link): Link | null;
3
+ export declare function unobserved(el: Computed<unknown>): void;
3
4
  export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>): void;
@@ -16,7 +16,7 @@ export interface NodeOptions<T> {
16
16
  name?: string;
17
17
  transparent?: boolean;
18
18
  equals?: ((prev: T, next: T) => boolean) | false;
19
- pureWrite?: boolean;
19
+ ownedWrite?: boolean;
20
20
  /** Exclude this signal from snapshot capture (internal — not part of public API) */
21
21
  _noSnapshot?: boolean;
22
22
  unobserved?: () => void;
@@ -29,7 +29,7 @@ export interface RawSignal<T> {
29
29
  _snapshotValue?: any;
30
30
  _name?: string;
31
31
  _equals: false | ((a: T, b: T) => boolean);
32
- _pureWrite?: boolean;
32
+ _ownedWrite?: boolean;
33
33
  _noSnapshot?: boolean;
34
34
  _unobserved?: () => void;
35
35
  _time: number;
@@ -29,7 +29,7 @@ export interface SignalOptions<T> {
29
29
  /** Custom equality function, or `false` to always notify subscribers */
30
30
  equals?: false | ((prev: T, next: T) => boolean);
31
31
  /** Suppress dev-mode warnings when writing inside an owned scope */
32
- pureWrite?: boolean;
32
+ ownedWrite?: boolean;
33
33
  /** Callback invoked when the signal loses all subscribers */
34
34
  unobserved?: () => void;
35
35
  }
@@ -56,7 +56,7 @@ export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
56
56
  /**
57
57
  * Creates a simple reactive state with a getter and setter.
58
58
  *
59
- * When called with a plain value, creates a signal with `SignalOptions` (name, equals, pureWrite, unobserved).
59
+ * When called with a plain value, creates a signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
60
60
  * When called with a function, creates a writable memo with `SignalOptions & MemoOptions` (adds id, lazy).
61
61
  *
62
62
  * ```typescript
@@ -74,52 +74,46 @@ export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
74
74
  */
75
75
  export declare function createSignal<T>(): Signal<T | undefined>;
76
76
  export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
77
- export declare function createSignal<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
77
+ export declare function createSignal<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
78
78
  /**
79
79
  * Creates a readonly derived reactive memoized signal.
80
80
  *
81
81
  * ```typescript
82
- * const value = createMemo<T>(compute, initialValue?, options?: MemoOptions<T>);
82
+ * const value = createMemo<T>(compute, options?: MemoOptions<T>);
83
83
  * ```
84
- * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
85
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
84
+ * @param compute a function that receives its previous value and returns a new value used to react on a computation
86
85
  * @param options `MemoOptions` -- id, name, equals, unobserved, lazy
87
86
  *
88
87
  * @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
89
88
  */
90
- export declare function createMemo<Next extends Prev, Prev = Next>(compute: ComputeFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
91
- export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(compute: ComputeFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
89
+ export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: MemoOptions<T>): Accessor<T>;
92
90
  /**
93
91
  * Creates a reactive effect that runs after the render phase.
94
92
  *
95
93
  * ```typescript
96
- * createEffect<T>(compute, effectFn | { effect, error }, initialValue?, options?: EffectOptions);
94
+ * createEffect<T>(compute, effectFn | { effect, error }, options?: EffectOptions);
97
95
  * ```
98
- * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
96
+ * @param compute a function that receives its previous value and returns a new value used to react on a computation
99
97
  * @param effectFn a function that receives the new value and is used to perform side effects (return a cleanup function), or an `EffectBundle` with `effect` and `error` handlers
100
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
101
98
  * @param options `EffectOptions` -- name, defer
102
99
  *
103
100
  * @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
104
101
  */
105
- export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next> | EffectBundle<NoInfer<Next>, Next>): void;
106
- export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next> | EffectBundle<Next, Next>, value: Init, options?: EffectOptions): void;
102
+ export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
107
103
  /**
108
104
  * Creates a reactive computation that runs during the render phase as DOM elements
109
105
  * are created and updated but not necessarily connected.
110
106
  *
111
107
  * ```typescript
112
- * createRenderEffect<T>(compute, effectFn, initialValue?, options?: EffectOptions);
108
+ * createRenderEffect<T>(compute, effectFn, options?: EffectOptions);
113
109
  * ```
114
- * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
110
+ * @param compute a function that receives its previous value and returns a new value used to react on a computation
115
111
  * @param effectFn a function that receives the new value and is used to perform side effects
116
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
117
112
  * @param options `EffectOptions` -- name, defer
118
113
  *
119
114
  * @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
120
115
  */
121
- export declare function createRenderEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next>): void;
122
- export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effectFn: EffectFunction<Next, Next>, value: Init, options?: EffectOptions): void;
116
+ export declare function createRenderEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
123
117
  /**
124
118
  * Creates a tracked reactive effect where dependency tracking and side effects happen
125
119
  * in the same scope.
@@ -159,14 +153,14 @@ export declare function resolve<T>(fn: () => T): Promise<T>;
159
153
  * Creates an optimistic signal that can be used to optimistically update a value
160
154
  * and then revert it back to the previous value at end of transition.
161
155
  *
162
- * When called with a plain value, creates an optimistic signal with `SignalOptions` (name, equals, pureWrite, unobserved).
156
+ * When called with a plain value, creates an optimistic signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
163
157
  * When called with a function, creates a writable optimistic memo with `SignalOptions & MemoOptions` (adds id, lazy).
164
158
  *
165
159
  * ```typescript
166
160
  * // Plain optimistic signal
167
161
  * const [state, setState] = createOptimistic<T>(value, options?: SignalOptions<T>);
168
162
  * // Writable optimistic memo (function overload)
169
- * const [state, setState] = createOptimistic<T>(fn, initialValue?, options?: SignalOptions<T> & MemoOptions<T>);
163
+ * const [state, setState] = createOptimistic<T>(fn, options?: SignalOptions<T> & MemoOptions<T>);
170
164
  * ```
171
165
  * @param value initial value of the signal; if empty, the signal's type will automatically extended with undefined
172
166
  * @param options optional object with a name for debugging purposes and equals, a comparator function for the previous and next value to allow fine-grained control over the reactivity
@@ -177,7 +171,7 @@ export declare function resolve<T>(fn: () => T): Promise<T>;
177
171
  */
178
172
  export declare function createOptimistic<T>(): Signal<T | undefined>;
179
173
  export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
180
- export declare function createOptimistic<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
174
+ export declare function createOptimistic<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
181
175
  /**
182
176
  * Runs a callback after the current flush cycle completes.
183
177
  *
@@ -8,12 +8,12 @@ import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from
8
8
  * When called with a function, creates a derived optimistic store with `ProjectionOptions` (name, key, all).
9
9
  *
10
10
  * @param fn a function that receives the current store and can be used to mutate it directly inside a transition
11
- * @param initial The initial value of the store.
11
+ * @param store The plain store value, or the backing seed when using the derived-store form.
12
12
  * @param options Optional projection options for reconciliation.
13
13
  *
14
14
  * @returns A tuple containing a store accessor and a setter function to apply changes.
15
15
  */
16
16
  export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
17
- export declare function createOptimisticStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store?: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T> & {
17
+ export declare function createOptimisticStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T> & {
18
18
  [$REFRESH]: any;
19
19
  }, set: StoreSetter<T>];
@@ -1,6 +1,6 @@
1
1
  import { $REFRESH, type Computed } from "../core/index.js";
2
2
  import { type ProjectionOptions, type Store } from "./store.js";
3
- export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: ProjectionOptions): {
3
+ export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T>, options?: ProjectionOptions): {
4
4
  store: Store<T> & {
5
5
  [$REFRESH]: any;
6
6
  };
@@ -11,15 +11,15 @@ export declare function createProjectionInternal<T extends object = {}>(fn: (dra
11
11
  * draft and can mutate it directly or return a new value for reconciliation.
12
12
  *
13
13
  * ```typescript
14
- * const store = createProjection<T>(fn, initialValue?, options?: ProjectionOptions);
14
+ * const store = createProjection<T>(fn, seed, options?: ProjectionOptions);
15
15
  * ```
16
16
  * @param fn a function that receives the current draft and mutates it or returns new data
17
- * @param initialValue the initial store value (defaults to `{}`)
17
+ * @param seed the backing store host value to wrap and reconcile into
18
18
  * @param options `ProjectionOptions` -- name, key, all
19
19
  *
20
20
  * @see {@link https://github.com/solidjs/x-reactivity#createprojection}
21
21
  */
22
- export declare function createProjection<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: ProjectionOptions): Store<T> & {
22
+ export declare function createProjection<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T>, options?: ProjectionOptions): Store<T> & {
23
23
  [$REFRESH]: any;
24
24
  };
25
25
  export declare function createWriteTraps(isActive?: () => boolean): ProxyHandler<any>;
@@ -54,7 +54,7 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
54
54
  * // Plain store
55
55
  * const [store, setStore] = createStore<T>(initialValue);
56
56
  * // Derived store (projection)
57
- * const [store, setStore] = createStore<T>(fn, initialValue?, options?: ProjectionOptions);
57
+ * const [store, setStore] = createStore<T>(fn, seed, options?: ProjectionOptions);
58
58
  * ```
59
59
  * @param store initial value to wrap in a reactive proxy, or a derive function
60
60
  * @param options `ProjectionOptions` -- name, key, all (only for derived stores)
@@ -62,7 +62,7 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
62
62
  * @returns `[store: Store<T>, setStore: StoreSetter<T>]`
63
63
  */
64
64
  export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
65
- export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store?: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T> & {
65
+ export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T> & {
66
66
  [$REFRESH]: any;
67
67
  }, set: StoreSetter<T>];
68
68
  export {};
@@ -0,0 +1,52 @@
1
+ import { Queue, type Computed, type Effect } from "./core/index.cjs";
2
+ import type { Signal } from "./core/index.cjs";
3
+ export interface BoundaryComputed<T> extends Computed<T> {
4
+ _propagationMask: number;
5
+ }
6
+ type RevealSlot = CollectionQueue | RevealController;
7
+ type BoolAccessor = () => boolean;
8
+ export declare class RevealController {
9
+ _togetherAccessor: BoolAccessor;
10
+ _collapsedAccessor: BoolAccessor;
11
+ _slots: RevealSlot[];
12
+ _parentController?: RevealController;
13
+ _disabled: Signal<boolean>;
14
+ _collapsed: Signal<boolean>;
15
+ _ready: boolean;
16
+ _evaluating: boolean;
17
+ constructor(together: BoolAccessor, collapsed: BoolAccessor);
18
+ _forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
19
+ isReady(): boolean;
20
+ register(slot: RevealSlot): void;
21
+ unregister(slot: RevealSlot): void;
22
+ evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
23
+ }
24
+ export declare class CollectionQueue extends Queue {
25
+ _collectionType: number;
26
+ _sources: Set<Computed<any>>;
27
+ _tree?: BoundaryComputed<any>;
28
+ _pending: boolean;
29
+ _disabled: Signal<boolean>;
30
+ _collapsed: Signal<boolean>;
31
+ _revealController?: RevealController;
32
+ _initialized: boolean;
33
+ _onFn: (() => any) | undefined;
34
+ _prevOn: any;
35
+ constructor(type: number);
36
+ run(type: number): void;
37
+ notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
38
+ checkSources(): void;
39
+ }
40
+ export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
41
+ on?: () => any;
42
+ }): import("./signals.cjs").Accessor<unknown>;
43
+ export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): import("./signals.cjs").Accessor<unknown>;
44
+ export declare function createRevealOrder<T>(fn: () => T, options?: {
45
+ together?: BoolAccessor;
46
+ collapsed?: BoolAccessor;
47
+ }): T;
48
+ export declare function flatten(children: any, options?: {
49
+ skipNonRendered?: boolean;
50
+ doNotUnwrap?: boolean;
51
+ }): any;
52
+ export {};
@@ -0,0 +1 @@
1
+ export declare function action<Args extends any[], Y, R>(genFn: (...args: Args) => Generator<Y, R, any> | AsyncGenerator<Y, R, any>): (...args: Args) => Promise<R>;
@@ -0,0 +1,6 @@
1
+ import { type OptimisticLane } from "./lanes.cjs";
2
+ import type { Computed } from "./types.cjs";
3
+ export declare function settlePendingSource(el: Computed<any>): void;
4
+ export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
5
+ export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
6
+ export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;