@solidjs/signals 2.0.0-rc.6 → 2.0.0-rc.8

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 (131) hide show
  1. package/dist/dev-shared.js +5243 -0
  2. package/dist/dev.attribution.js +2333 -0
  3. package/dist/dev.js +1758 -6621
  4. package/dist/observe/affects.js +127 -0
  5. package/dist/observe/attribution.js +1 -0
  6. package/dist/observe/boundaries.js +586 -0
  7. package/dist/observe/core/action.js +167 -0
  8. package/dist/observe/core/async.js +736 -0
  9. package/dist/observe/core/attribution-hooks.js +60 -0
  10. package/dist/observe/core/attribution.js +2318 -0
  11. package/dist/{types-cjs/core/constants.d.cts → observe/core/constants.js} +135 -71
  12. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  13. package/dist/observe/core/core.js +1289 -0
  14. package/dist/observe/core/dev.js +232 -0
  15. package/dist/observe/core/effect.js +179 -0
  16. package/dist/observe/core/error.js +80 -0
  17. package/dist/observe/core/external.js +98 -0
  18. package/dist/observe/core/graph.js +155 -0
  19. package/dist/observe/core/heap.js +147 -0
  20. package/dist/observe/core/invariants.js +43 -0
  21. package/dist/observe/core/lanes.js +168 -0
  22. package/dist/observe/core/optimistic.js +438 -0
  23. package/dist/observe/core/owner.js +308 -0
  24. package/dist/observe/core/scheduler.js +1190 -0
  25. package/dist/observe/core/verdict.js +551 -0
  26. package/dist/observe/index.js +55 -0
  27. package/dist/observe/map.js +482 -0
  28. package/dist/{types-cjs/signals.d.cts → observe/signals.js} +305 -317
  29. package/dist/observe/store/index.js +38 -0
  30. package/dist/observe/store/next/optimistic.js +651 -0
  31. package/dist/observe/store/next/projection.js +242 -0
  32. package/dist/observe/store/next/reconcile.js +373 -0
  33. package/dist/observe/store/next/store.js +2213 -0
  34. package/dist/observe/store/next/target.js +51 -0
  35. package/dist/observe/store/store.js +323 -0
  36. package/dist/observe/store/storePath.js +103 -0
  37. package/dist/observe/store/utils.js +210 -0
  38. package/dist/prod/attribution.js +32 -0
  39. package/dist/prod/boundaries.js +3 -1
  40. package/dist/prod/core/action.js +52 -32
  41. package/dist/prod/core/async.js +177 -128
  42. package/dist/prod/core/attribution-hooks.js +3 -0
  43. package/dist/prod/core/constants.js +32 -1
  44. package/dist/prod/core/context.js +10 -16
  45. package/dist/prod/core/core.js +505 -286
  46. package/dist/prod/core/dev.js +2 -0
  47. package/dist/prod/core/effect.js +72 -43
  48. package/dist/prod/core/external.js +2 -2
  49. package/dist/prod/core/graph.js +40 -36
  50. package/dist/prod/core/heap.js +50 -51
  51. package/dist/prod/core/lanes.js +43 -22
  52. package/dist/prod/core/optimistic.js +224 -80
  53. package/dist/prod/core/owner.js +43 -39
  54. package/dist/prod/core/scheduler.js +347 -232
  55. package/dist/prod/core/verdict.js +71 -74
  56. package/dist/prod/index.js +9 -5
  57. package/dist/prod/map.js +311 -150
  58. package/dist/prod/signals.js +52 -38
  59. package/dist/prod/store/next/optimistic.js +127 -131
  60. package/dist/prod/store/next/projection.js +3 -3
  61. package/dist/prod/store/next/reconcile.js +149 -294
  62. package/dist/prod/store/next/store.js +694 -380
  63. package/dist/prod/store/next/target.js +32 -10
  64. package/dist/prod/store/store.js +12 -14
  65. package/dist/prod/store/utils.js +36 -27
  66. package/dist/types/attribution.d.ts +15 -0
  67. package/dist/types/attribution.prod.d.ts +13 -0
  68. package/dist/types/core/async.d.ts +1 -1
  69. package/dist/types/core/attribution-hooks.d.ts +183 -6
  70. package/dist/types/core/attribution.d.ts +435 -24
  71. package/dist/types/core/constants.d.ts +31 -0
  72. package/dist/types/core/core.d.ts +19 -3
  73. package/dist/types/core/dev.d.ts +165 -26
  74. package/dist/types/core/effect.d.ts +8 -1
  75. package/dist/types/core/heap.d.ts +5 -3
  76. package/dist/types/core/index.d.ts +2 -1
  77. package/dist/types/core/invariants.d.ts +1 -1
  78. package/dist/types/core/lanes.d.ts +17 -0
  79. package/dist/types/core/scheduler.d.ts +69 -4
  80. package/dist/types/core/types.d.ts +29 -9
  81. package/dist/types/index.d.ts +9 -2
  82. package/dist/types/map.d.ts +2 -0
  83. package/dist/types/signals.d.ts +10 -0
  84. package/dist/types/store/index.d.ts +4 -6
  85. package/dist/types/store/next/optimistic.d.ts +4 -2
  86. package/dist/types/store/next/reconcile.d.ts +5 -12
  87. package/dist/types/store/next/store.d.ts +8 -9
  88. package/dist/types/store/next/target.d.ts +56 -55
  89. package/dist/types/store/store.d.ts +14 -9
  90. package/dist/types/store/utils.d.ts +7 -0
  91. package/package.json +21 -16
  92. package/dist/node.cjs +0 -11121
  93. package/dist/prod/store/next/patch-hooks.js +0 -13
  94. package/dist/prod/store/next/patch.js +0 -614
  95. package/dist/types/store/next/patch-hooks.d.ts +0 -41
  96. package/dist/types/store/next/patch.d.ts +0 -91
  97. package/dist/types-cjs/affects.d.cts +0 -47
  98. package/dist/types-cjs/boundaries.d.cts +0 -175
  99. package/dist/types-cjs/core/action.d.cts +0 -64
  100. package/dist/types-cjs/core/async.d.cts +0 -23
  101. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -63
  102. package/dist/types-cjs/core/attribution.d.cts +0 -239
  103. package/dist/types-cjs/core/core.d.cts +0 -176
  104. package/dist/types-cjs/core/dev.d.cts +0 -95
  105. package/dist/types-cjs/core/effect.d.cts +0 -30
  106. package/dist/types-cjs/core/error.d.cts +0 -56
  107. package/dist/types-cjs/core/external.d.cts +0 -15
  108. package/dist/types-cjs/core/graph.d.cts +0 -28
  109. package/dist/types-cjs/core/heap.d.cts +0 -22
  110. package/dist/types-cjs/core/index.d.cts +0 -13
  111. package/dist/types-cjs/core/invariants.d.cts +0 -59
  112. package/dist/types-cjs/core/lanes.d.cts +0 -44
  113. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  114. package/dist/types-cjs/core/owner.d.cts +0 -124
  115. package/dist/types-cjs/core/scheduler.d.cts +0 -231
  116. package/dist/types-cjs/core/types.d.cts +0 -204
  117. package/dist/types-cjs/core/verdict.d.cts +0 -2
  118. package/dist/types-cjs/index.d.cts +0 -10
  119. package/dist/types-cjs/map.d.cts +0 -69
  120. package/dist/types-cjs/package.json +0 -3
  121. package/dist/types-cjs/store/index.d.cts +0 -21
  122. package/dist/types-cjs/store/next/optimistic.d.cts +0 -23
  123. package/dist/types-cjs/store/next/patch-hooks.d.cts +0 -41
  124. package/dist/types-cjs/store/next/patch.d.cts +0 -91
  125. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  126. package/dist/types-cjs/store/next/reconcile.d.cts +0 -17
  127. package/dist/types-cjs/store/next/store.d.cts +0 -127
  128. package/dist/types-cjs/store/next/target.d.cts +0 -192
  129. package/dist/types-cjs/store/store.d.cts +0 -138
  130. package/dist/types-cjs/store/storePath.d.cts +0 -58
  131. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -1,204 +0,0 @@
1
- import type { NOT_PENDING } from "./constants.cjs";
2
- import type { OptimisticLane } from "./lanes.cjs";
3
- import type { IQueue, Transition } from "./scheduler.cjs";
4
- export interface Disposable {
5
- (): void;
6
- }
7
- export interface Link {
8
- _dep: Signal<unknown> | Computed<unknown>;
9
- _sub: Computed<unknown>;
10
- _nextDep: Link | null;
11
- _prevSub: Link | null;
12
- _nextSub: Link | null;
13
- /**
14
- * `_sub._depGen` at the time this link was created or last revalidated
15
- * in-order. A link stamped with the subscriber's current pass generation is
16
- * inside the validated `[deps.._depsTail]` prefix — an O(1) replacement for
17
- * scanning the dep list to answer membership (see `link()`).
18
- */
19
- _gen: number;
20
- _pendingObserver?: boolean;
21
- }
22
- export interface NodeOptions<T> {
23
- id?: string;
24
- name?: string;
25
- transparent?: boolean;
26
- equals?: ((prev: T, next: T) => boolean) | false;
27
- ownedWrite?: boolean;
28
- /** Exclude this signal from snapshot capture (internal — not part of public API) */
29
- _noSnapshot?: boolean;
30
- /** Extra CONFIG_* bits OR'd into the node's config at creation (internal —
31
- * not part of public API). Used by resolve()/until() for
32
- * CONFIG_DIRECT_COMMIT / CONFIG_AUTHORITATIVE_READ, keeping the per-flag
33
- * option arms out of the core creation path. */
34
- _extraConfig?: number;
35
- unobserved?: () => void;
36
- lazy?: boolean;
37
- sync?: boolean;
38
- /**
39
- * Commit #0. When present (checked with `in`, so an explicit `undefined`
40
- * counts), the node is born committed with this value instead of
41
- * STATUS_UNINITIALIZED: reads serve it everywhere, nothing suspends to
42
- * Loading boundaries, transitions are never held, and the window is
43
- * verdict-quiet (`isPending` stays false — commit #0 answers the question
44
- * by declaration; first-load affordances live in the value itself). After
45
- * the first real answer lands, normal refetch/pending semantics apply.
46
- */
47
- loadingValue?: T;
48
- }
49
- /**
50
- * Cold node extension (stage-3 §12): optional machinery that most nodes
51
- * never touch lives one hop away so the CORE node literal stays under V8's
52
- * in-object property boundary (~39 fields measured: past it, every literal
53
- * allocation spills to an out-of-object backing store and creation cost
54
- * roughly quadruples — the create0to1 cliff). Allocated lazily by `ext()`
55
- * on first installer write; ONE shape shared by signals and computeds so
56
- * `_x` access stays monomorphic. Presence bits on `_config`
57
- * (CONFIG_OPTIMISTIC / HAS_COMPANIONS / HAS_LANE / HAS_SNAPSHOT) remain the
58
- * hot-path gates — a bit says "consult _x", never the reverse.
59
- */
60
- export interface NodeExtension {
61
- _overrideValue: unknown | typeof NOT_PENDING;
62
- /**
63
- * The transaction that owns the active override (stamped at optimistic
64
- * write, cleared at settle). Ownership must live on the node: a lane's
65
- * _transition is a scheduling affinity that a shared subscriber can merge
66
- * across transactions (#2912) — following it would let one action's settle
67
- * revert another action's live override. Node-level sibling of the store
68
- * layer's STORE_OPTIMISTIC_OWNERS stamps (#2899). `null` = ambient write.
69
- */
70
- _overrideOwner: Transition | null | undefined;
71
- _optimisticLane: OptimisticLane | undefined;
72
- _pendingSignal: Signal<boolean> | undefined;
73
- _latestValueComputed: Computed<any> | undefined;
74
- _parentSource: Signal<any> | Computed<any> | undefined;
75
- /**
76
- * Live `affects()` marks on this node (refcount). Non-zero is declared
77
- * motion — see affects(); the count is the mark's only graph state.
78
- */
79
- _affectsCount: number;
80
- _inFlight: PromiseLike<any> | AsyncIterable<any> | null;
81
- /** Cancellation for the CURRENT iterator flight (#3122): closes the
82
- * iterator (`it.return()`), idempotent. Fired at the sites that release
83
- * `_inFlight` so a superseded stream stops at supersede time — its owner
84
- * cleanup registration may ride the zombie-disposal channel, which a held
85
- * transition defers until the SUPERSEDING flight settles. Null for plain
86
- * promise flights (no cancellation hook exists). */
87
- _flightTeardown: (() => void) | null;
88
- _error: unknown;
89
- _blocked: boolean | undefined;
90
- _pendingSources: Set<Computed<any>> | undefined;
91
- _notifyStatus: ((status?: number, error?: any) => void) | undefined;
92
- /** Question-scoped re-ask classification of the current pending window
93
- * (see the former Computed._x?._reask doc): set by recompute from
94
- * REACTIVE_REASK, cleared on landing; meaningless while not pending. */
95
- _reask: boolean;
96
- _child: FirewallSignal<any> | null;
97
- _unobserved: (() => void) | undefined;
98
- _snapshotValue: any;
99
- /** Zombie staging (staged disposal): a recompute of an owner that HAS
100
- * children/disposal parks them here until the flush commits (or a
101
- * transition reverts). Childless nodes — the common case — never write
102
- * these. */
103
- _pendingDisposal: Disposable | Disposable[] | null;
104
- _pendingFirstChild: Owner | null;
105
- /** #3038: the firewall children that actually carry isPending()/latest()
106
- * companions. The post-recompute companion snap iterates THIS set —
107
- * O(companions asked for) — never the full `_child` chain (one entry per
108
- * materialized leaf). Populated at companion creation; entries live as
109
- * long as their companions (which are permanent once created). */
110
- _companionChildren: Set<FirewallSignal<any>> | undefined;
111
- }
112
- export interface RawSignal<T> {
113
- _subs: Link | null;
114
- _subsTail: Link | null;
115
- /**
116
- * DEV-only live subscriber count. Maintained by `link`/`unlinkSubs` for
117
- * graph-size diagnostics; undefined in production.
118
- */
119
- _subCount?: number;
120
- _value: T;
121
- _name?: string;
122
- _equals: false | ((a: T, b: T) => boolean);
123
- _config: number;
124
- _time: number;
125
- /** IN CORE, not the extension (stage-3 §12c): consulted on EVERY write
126
- * (setSignal's transition-init check) and on recompute scheduling — the
127
- * per-write extension chase measurably taxed propagation chains. */
128
- _transition: Transition | null;
129
- /** Notify-epoch stamp of the last subscriber walk (§12d). A re-write to an
130
- * already-staged node whose stamp still equals the global epoch skips the
131
- * whole walk — marking is idempotent, and the epoch bumps on every
132
- * recompute and new subscriber edge (either can invalidate the skip). */
133
- _notifiedAt: number;
134
- _pendingValue: T | typeof NOT_PENDING;
135
- /** Cold extension — see NodeExtension. */
136
- _x: NodeExtension | null;
137
- }
138
- export interface FirewallSignal<T> extends RawSignal<T> {
139
- _firewall: Computed<any>;
140
- _nextChild: FirewallSignal<unknown> | null;
141
- }
142
- export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
143
- export interface Owner {
144
- id?: string;
145
- _config: number;
146
- _snapshotScope?: boolean;
147
- /** Effect-returned cleanup; managed across reruns, invoked at true disposal */
148
- _cleanup?: () => void;
149
- _disposal: Disposable | Disposable[] | null;
150
- _parent: Owner | null;
151
- _context: Record<symbol | string, unknown>;
152
- _childCount: number;
153
- _queue: IQueue;
154
- _firstChild: Owner | null;
155
- _nextSibling: Owner | null;
156
- _prevSibling: Owner | null;
157
- /** Cold extension — see NodeExtension (owners use the zombie-pair slots). */
158
- _x: NodeExtension | null;
159
- }
160
- export interface Computed<T> extends RawSignal<T>, Owner {
161
- _deps: Link | null;
162
- _depsTail: Link | null;
163
- /**
164
- * DEV-only live source count. Maintained by `link`/`unlinkSubs` for
165
- * graph-size diagnostics; undefined in production.
166
- */
167
- _depCount?: number;
168
- /** Recompute-pass counter; bumped when dep revalidation starts. */
169
- _depGen: number;
170
- _flags: number;
171
- _statusFlags: number;
172
- _height: number;
173
- _nextHeap: Computed<any> | undefined;
174
- _prevHeap: Computed<any>;
175
- _fn: (prev?: T) => T;
176
- /**
177
- * Clock tick at which REACTIVE_MANUAL_WRITE was last applied
178
- * (`suppressComputedRecompute`). Lets `refresh()` distinguish a same-tick
179
- * manual write (which wins over the refresh, #2692) from a mask carried
180
- * across ticks by a transaction (which an explicit refresh lifts, #3026).
181
- * Only meaningful while REACTIVE_MANUAL_WRITE is set.
182
- */
183
- _manualWriteTime?: number;
184
- /**
185
- * True while a `loadingValue` node's first real answer hasn't landed: the
186
- * node was born committed (commit #0 = the loading value) and `handleAsync`
187
- * serves that committed value instead of throwing NotReadyError, so first
188
- * flights never suspend readers, trip boundaries, or hold transitions.
189
- * The window is verdict-quiet: `isPending` stays false, because commit #0
190
- * answers the question by declaration (first-load affordances belong to
191
- * the value channel). Cleared by the first value landing on any path (sync
192
- * return, sync-resolved promise, first iterator yield, async settle); a
193
- * real error leaves it set — errors answer reads but don't enter the value
194
- * lineage, so a retry serves the loading value again. Once cleared, normal
195
- * pending/refetch semantics apply forever. (Stays in CORE: written
196
- * unconditionally by recompute and every commit.)
197
- */
198
- _loading: boolean;
199
- }
200
- export interface Root extends Owner {
201
- _root: true;
202
- _parentComputed: Computed<any> | null;
203
- dispose(self?: boolean): void;
204
- }
@@ -1,2 +0,0 @@
1
- export declare function latest<T>(fn: () => T): T;
2
- export declare function isPending(fn: () => any): boolean;
@@ -1,10 +0,0 @@
1
- export { $REFRESH, ContextNotFoundError, NoOwnerError, NotReadyError, TimeoutError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, peekNextChildId, getContext, setContext, getOwner, isDisposed, getObserver, isEqual, untrack, isPending, latest, SUPPORTS_PROXY, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots, enforceLoadingBoundary, enableExternalSource, resetErrorHalt } from "./core/index.cjs";
2
- import { type Dev } from "./core/index.cjs";
3
- export declare const DEV: Dev | undefined;
4
- export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig, Refreshable, Dev, DevHooks, DiagnosticCapture, DiagnosticCode, DiagnosticEvent, DiagnosticKind, Diagnostics, DiagnosticSeverity } from "./core/index.cjs";
5
- export { createSignal, createMemo, createEffect, createRenderEffect, createTrackedEffect, createReaction, createOptimistic, refresh, resolve, until, onSettled, onCleanup } from "./signals.cjs";
6
- export type { Truthy, UntilOptions, Accessor, SourceAccessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.cjs";
7
- export { affects } from "./affects.cjs";
8
- export { mapArray, repeat, type Maybe } from "./map.cjs";
9
- export * from "./store/index.cjs";
10
- export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten, type RevealOrder } from "./boundaries.cjs";
@@ -1,69 +0,0 @@
1
- import { type Accessor } from "./signals.cjs";
2
- export type Maybe<T> = T | void | null | undefined | false;
3
- /**
4
- * Reactively maps an array, reusing the previously-mapped value for unchanged
5
- * items.
6
- *
7
- * The callback shape follows the keying mode:
8
- * - default / `keyed: true` receives `(item, index)` where `item` is the raw
9
- * row value and `index` is an accessor.
10
- * - `keyed: false` receives `(item, index)` where `item` is an accessor and
11
- * `index` is a stable number.
12
- * - `keyed: item => key` receives accessors for both arguments.
13
- *
14
- * This is the underlying helper that powers `<For>`. App code should use
15
- * `<For>` directly; reach for `mapArray` when implementing custom list
16
- * components.
17
- *
18
- * - `options.keyed` — `true` (default for primitives) compares by identity;
19
- * `false` falls back to index-only mapping; pass a function `(item) => key`
20
- * for stable identity by extracted key.
21
- * - `options.fallback` — accessor returning a value to show when the input is
22
- * empty.
23
- *
24
- * @example
25
- * ```ts
26
- * const view = mapArray(
27
- * items,
28
- * (item, index) => `${index()}: ${item.label}`,
29
- * { fallback: () => "no items" }
30
- * );
31
- * ```
32
- *
33
- * @description https://docs.solidjs.com/reference/reactive-utilities/map-array
34
- */
35
- export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Item, index: Accessor<number>) => MappedItem, options?: {
36
- keyed?: true;
37
- fallback?: Accessor<any>;
38
- name?: string;
39
- }): Accessor<MappedItem[]>;
40
- export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: number) => MappedItem, options: {
41
- keyed: false;
42
- fallback?: Accessor<any>;
43
- name?: string;
44
- }): Accessor<MappedItem[]>;
45
- export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: Accessor<number>) => MappedItem, options: {
46
- keyed: (item: Item) => any;
47
- fallback?: Accessor<any>;
48
- name?: string;
49
- }): Accessor<MappedItem[]>;
50
- /**
51
- * Reactively renders a callback `count` times, reusing previously-rendered
52
- * entries when only the count changes. Underlying helper for `<Repeat>`.
53
- *
54
- * - `options.from` — start index (default `0`); useful for offset/windowed
55
- * rendering.
56
- * - `options.fallback` — accessor returning a value to show when count is `0`.
57
- *
58
- * @example
59
- * ```ts
60
- * const view = repeat(count, i => `Item ${i}`, { fallback: () => "empty" });
61
- * ```
62
- *
63
- * @description https://docs.solidjs.com/reference/reactive-utilities/repeat
64
- */
65
- export declare function repeat(count: Accessor<number>, map: (index: number) => any, options?: {
66
- from?: Accessor<number | undefined>;
67
- fallback?: Accessor<any>;
68
- name?: string;
69
- }): Accessor<any[]>;
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,21 +0,0 @@
1
- export type { Store, StoreReturn, ProjectionStoreReturn, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.cjs";
2
- export type { Merge, Omit } from "./utils.cjs";
3
- export { isWrappable, $TRACK, $PROXY, $TARGET } from "./store.cjs";
4
- import type { NoFn, ProjectionOptions, Store, StoreOptions, StoreSetter } from "./store.cjs";
5
- import type { Refreshable } from "../core/index.cjs";
6
- export { createProjectionNext as createProjection } from "./next/projection.cjs";
7
- export { registerPatch, registerRowOps, registerSlotPatchNext as registerSlotPatch, patchableRaw } from "./next/patch.cjs";
8
- export { storeIsShallow, storeHasFamily, storeHasOptimisticFamily } from "./next/store.cjs";
9
- export { createOptimisticStoreNext as createOptimisticStore } from "./next/optimistic.cjs";
10
- /** Public createStore: plain form `(init, options?)` and derived writable
11
- * form `(fn, seed, options?)`. */
12
- export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: StoreOptions & {
13
- shallow?: boolean;
14
- }): [get: Store<T>, set: StoreSetter<T>];
15
- 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: Refreshable<Store<T>>, set: StoreSetter<T>];
16
- export declare function reconcile<T extends U, U>(value: T, key?: string | ((item: NonNullable<any>) => any) | null): (state: U) => T;
17
- export declare function snapshot<T>(value: T): T;
18
- export declare function deep<T>(value: T): T;
19
- export { storePath } from "./storePath.cjs";
20
- export type { PathSetter, Part, StorePathRange, ArrayFilterFn, CustomPartial } from "./storePath.cjs";
21
- export { merge, omit } from "./utils.cjs";
@@ -1,23 +0,0 @@
1
- import { type Transition } from "../../core/scheduler.cjs";
2
- import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from "../store.cjs";
3
- import type { StoreNextTarget } from "./target.cjs";
4
- /** #3164 fold: a stamped truth is HELD (masked from ordinary readers until
5
- * the reveal) only while its transition is live AND retaining optimism —
6
- * overrides are what make partial-coverage composition a tear. A plain
7
- * async transition carries no overrides, so downstream computes must see
8
- * staged values to converge (normal speculation). Resolves merges first:
9
- * merge unions optimistic nodes/stores into the target. */
10
- export declare function transitionHoldsOptimism(transition: Transition): boolean;
11
- export declare function createOptimisticStoreNext<T extends object = {}>(first: T | ((store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>), second?: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
12
- /** Diff the draft against the current OPTIMISTIC VIEW (committed + active
13
- * overrides — the same view the draft was seeded from) and emit engine writes
14
- * for exactly the changed keys. Visible-view diffing keeps no-op writes from
15
- * entangling lanes (RUL-10 / opt R38). */
16
- export declare function notifyOptimisticWrites(t: StoreNextTarget, pb: Record<PropertyKey, any>): void;
17
- /** Optimistic-view composition for snapshot/deep (O1: snapshot is the CURRENT
18
- * view, lane values included; a fresh copy per call during pending windows —
19
- * RUL-12). Returns `src` untouched when no override is active on `t`.
20
- * Authoritative-view reads (until()'s predicate) skip composition entirely:
21
- * the predicate observes authoritative truth, never the caller's tentative
22
- * overlay. (Write-side emission callers never run under such a compute.) */
23
- export declare function optimisticView(t: StoreNextTarget, src: Record<PropertyKey, any>): Record<PropertyKey, any>;
@@ -1,41 +0,0 @@
1
- import type { StoreNextTarget } from "./target.cjs";
2
- import type { RowOps } from "./patch.cjs";
3
- /**
4
- * Patch-channel emission seams (pay-for-use). The store/reconcile/optimistic
5
- * write paths emit through these installed hook objects instead of importing
6
- * `patch.js` statically, so the channel tree-shakes out of apps that never
7
- * register a patch consumer.
8
- *
9
- * TWO TIERS, armed at registration (patch.js installs them; it is retained
10
- * only through its registration exports, which only compiled patch-mode
11
- * output — via the web runtime's driver module — imports):
12
- * - VALUE hooks (`patchHooks`): record patches. Armed by `registerPatch` —
13
- * present in any bundle with one eligible template under patch mode.
14
- * - ROW hooks (`rowHooks`): list structure (row ops, slot ticks, the
15
- * identity/keyed diff builders in reconcile.js they drag in). Armed by
16
- * `registerRowOps`/`registerSlotPatchNext` — the LIST driver's
17
- * registrations, so value-only bundles never retain the row machinery.
18
- *
19
- * Soundness: every emission site is guarded by the matching `pc` channel
20
- * (`pc.p` for value, `pc.ro`/`pc.sp` for rows), and a target can only
21
- * acquire that channel through the corresponding registration — so each
22
- * hook object is installed by the time any guard passes. Type-only imports
23
- * from `patch.js` are erased.
24
- */
25
- export interface PatchValueHooks {
26
- emitPatch(t: StoreNextTarget, next: any, prev: any): void;
27
- emitPatchLocal(t: StoreNextTarget, next: any, prev: any): void;
28
- emitPatchOptimistic(t: StoreNextTarget, next: any, prev: any): void;
29
- hasPatches(): boolean;
30
- demoteToEffects(t: StoreNextTarget): void;
31
- }
32
- export interface PatchRowHooks {
33
- emitRowOps(t: StoreNextTarget, next: any[], ops: RowOps): void;
34
- emitSlotPatch(t: StoreNextTarget, index: number, next: any, prev: any): void;
35
- emitSetterRowOps(t: StoreNextTarget, prevRows: any[], nextRows: any[]): void;
36
- emitRowOpsOptimistic(t: StoreNextTarget, next: any[] | null, ops: RowOps | null): void;
37
- }
38
- export declare let patchHooks: PatchValueHooks | null;
39
- export declare let rowHooks: PatchRowHooks | null;
40
- export declare function installPatchHooks(hooks: PatchValueHooks): void;
41
- export declare function installRowHooks(hooks: PatchRowHooks): void;
@@ -1,91 +0,0 @@
1
- import type { Owner } from "../../core/types.cjs";
2
- import { type StoreNextTarget } from "./target.cjs";
3
- export type PatchFn = (next: any, prev: any, force?: boolean) => void;
4
- interface PatchEntry {
5
- fn: PatchFn;
6
- owner: Owner | null;
7
- }
8
- /**
9
- * Emit a record's visibility transition. Callers gate on `hasPatches()` and
10
- * `t.d` cheaply; this function re-checks and walks ancestors (§4b).
11
- */
12
- export declare function emitPatch(t: StoreNextTarget, next: any, prev: any): void;
13
- /** Emission for sites that already stand at the record with both sides in
14
- * hand and have already handled ancestors (the adoption walk descends —
15
- * parents were visited first), so no bubbling walk. */
16
- export declare function emitPatchLocal(t: StoreNextTarget, next: any, prev: any): void;
17
- export declare function emitPatchOptimistic(t: StoreNextTarget, next: any, prev: any): void;
18
- /** Row-ops emission at OPTIMISTIC (lane) timing: user drafts on an
19
- * optimistic family must show structure IN FLIGHT — bypassing the
20
- * transition stash exactly like emitPatchOptimistic. Two forms:
21
- * - `ops` given (write site): `nextRows` is the draft's intended visible
22
- * list, ops the identity diff against the pre-write optimistic view.
23
- * - `ops === null` (revert site): RESYNC — the consumer rebuilds retention
24
- * by row identity against the live post-revert view, resolved from the
25
- * target at drain time (overrides are gone by then, so `pb ?? v` IS the
26
- * committed truth). */
27
- export declare function emitRowOpsOptimistic(t: StoreNextTarget, nextRows: any[] | null, ops: RowOps | null): void;
28
- /** Test-only accounting probe: the live registration count must return to
29
- * baseline across register/unbind/demote cycles. @internal */
30
- export declare function patchCountForTests(): number;
31
- export declare function hasPatches(): boolean;
32
- export declare function registerPatch(record: any, fn: PatchFn): () => void;
33
- /** Dual-driver bind probe (compiler runtime contract): when `record` is a
34
- * patchable store record, returns its CURRENT raw backing (the driver's
35
- * initial force-apply reads it directly — no proxy traffic, no tracking);
36
- * returns undefined otherwise (driver falls back to the effect path).
37
- * Not patchable: non-records, non-proxies, accessor-bearing records
38
- * (patches read raw — getters need tracked evaluation), broken chains. */
39
- export declare function patchableRaw(record: any): Record<PropertyKey, any> | undefined;
40
- /** Accessor demotion (design §5): a record that acquires an accessor after
41
- * registration stops being patchable — reads must go through tracked
42
- * evaluation. Clears patches and repairs the global count; callers re-drive
43
- * the pulled bodies (demoteToEffects). */
44
- export declare function demotePatches(t: StoreNextTarget): PatchEntry[] | null;
45
- /** The demotion re-drive (re-audit blocker 3): each pulled body becomes the
46
- * SAME dual-driver effect fallback the web runtime would have chosen had the
47
- * record carried the accessor at bind — a tracked compute pass (next === prev
48
- * short-circuits every compare into a pure read THROUGH THE PROXY, so getter
49
- * dependencies track) plus an untracked force-apply at effect timing.
50
- *
51
- * Creation is DEFERRED to the effect phase: the trap that discovers the
52
- * accessor runs mid-draft, and an effect's initial pass must not read
53
- * through the proxy inside the write window. The record's own transition
54
- * for that draft is covered by the new effect's initial force-apply.
55
- *
56
- * Known edge (documented): a demoted LIST-ROW body re-drives under its
57
- * registering owner (the list owner), so per-row severing on removal is
58
- * lost for demoted rows — the effect lives until the LIST disposes. Rows
59
- * only demote when user code defines an accessor on a row record at
60
- * runtime. */
61
- export declare function demoteToEffects(t: StoreNextTarget): void;
62
- /** Structural ops for one keyed-array transition. `prefix` rows key-matched
63
- * in place; for each later index i (absolute), `sources[i - prefix]` is the
64
- * OLD index its row retained from, or -1 for a new row. `removed` holds the
65
- * dropped old row values (unbind/teardown handles). Aligned value ticks emit
66
- * NOTHING — ops exist only when structure changed. */
67
- export interface RowOps {
68
- prefix: number;
69
- sources: number[];
70
- removed: any[];
71
- }
72
- /** `ops === null` is the RESYNC form (optimistic revert): the consumer
73
- * rebuilds retention by row identity against `next` (the live view). */
74
- export type RowOpsFn = (next: any[], ops: RowOps | null) => void;
75
- /** Register a structural-ops consumer on a keyed store array (the list
76
- * container's channel — what `For` consumes through the seam). */
77
- export declare function registerRowOps(array: any, fn: RowOpsFn): () => void;
78
- /** Slot patches (shallow arrays) ride the same apply queue: the walk emits
79
- * per aligned value-replaced slot; application happens at effect phase under
80
- * the registration owner's lifetime. */
81
- export declare function emitSlotPatch(t: StoreNextTarget, index: number, next: any, prev: any): void;
82
- /** Slot patch for shallow arrays: the reconcile walk emits (index, next,
83
- * prev) for KEY-ALIGNED value-replaced slots (structure rides row ops), and
84
- * the emission queues through the patch apply queue — effect-phase timing,
85
- * transition stamping, disposed-owner drop — like every other channel. */
86
- export declare function registerSlotPatchNext(arr: any, fn: (index: number, next: any, prev: any) => void): () => void;
87
- /** Row-ops ride the SAME apply queue/timing as record patches: transition-
88
- * stamped, applied at effect phase, in emission order (structure before the
89
- * new rows' own patches can exist; retained rows' value patches commute). */
90
- export declare function emitRowOps(t: StoreNextTarget, next: any[], ops: RowOps): void;
91
- export {};
@@ -1,8 +0,0 @@
1
- import { type Computed, type Refreshable } from "../../core/index.cjs";
2
- import { type NoFn, type ProjectionOptions, type Store } from "../store.cjs";
3
- export declare function createProjectionNext<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): Refreshable<Store<T>>;
4
- /** Derived writable store (legacy parity): a projection whose public setter
5
- * masks the recompute for the tick (core R31 — the manual write wins over a
6
- * same-flush dependency change). */
7
- export declare function createStoreDerivedNext<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [Refreshable<Store<T>>, (f: (draft: T) => T | void) => void];
8
- export declare function runProjectionComputedNext<T extends object>(wrappedStore: Store<T>, fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, key: string | ((item: NonNullable<any>) => any) | null, wrapCommit?: (write: () => void, value: T) => void, aroundDraftWrite?: (op: () => void) => void): Computed<void | T>;
@@ -1,17 +0,0 @@
1
- import type { RowOps } from "./patch.cjs";
2
- import { type StoreNextTarget } from "./target.cjs";
3
- type KeyFn = (item: any) => any;
4
- export declare function reconcileNextState(value: any, state: any, key: string | KeyFn | null | undefined, replace?: boolean): void;
5
- /** Key equality for EVERY key comparison in this module (re-audit 2, P1-5):
6
- * SameValueZero, matching the Map-based matchers (buildRowOps, the adoption
7
- * window) — NaN keys are equal to themselves, so aligned NaN rows stay
8
- * aligned in the prefix walk instead of forever misaligning. Adoption and
9
- * row ops MUST agree on key equality or retained DOM rows go stale. */
10
- export declare function sameKey(a: any, b: any): boolean;
11
- export declare function emitSetterRowOps(t: StoreNextTarget, prevRows: any[], nextRows: any[]): void;
12
- /** Identity-keyed structural diff, returned rather than emitted: shared by
13
- * the setter channel (regular queue) and the OPTIMISTIC write channel (lane
14
- * queue) — same retention semantics, different dispatch timing. Returns
15
- * null when the lists are identity-aligned (no structure changed). */
16
- export declare function buildIdentityRowOps(prevRows: any[], nextRows: any[]): RowOps | null;
17
- export {};
@@ -1,127 +0,0 @@
1
- import type { Signal } from "../../core/types.cjs";
2
- import { type StoreNextFamily, type StoreNextTarget, type PatchChannel } from "./target.cjs";
3
- /** Lazily allocate the patch-channel extension (one literal shape). */
4
- export declare function pcOf(t: StoreNextTarget): PatchChannel;
5
- export declare function wrapNext<T extends Record<PropertyKey, any>>(value: T, parent?: StoreNextTarget | null, parentKey?: PropertyKey | null, fam?: StoreNextFamily | null): T;
6
- /** Unwrap our own proxies to their current backing; leave everything else. */
7
- export declare function unwrapValue(v: any): any;
8
- export declare function getNode(target: StoreNextTarget, key: PropertyKey, current: any): Signal<any>;
9
- export declare function getHasNode(target: StoreNextTarget, key: PropertyKey, present: boolean): Signal<boolean>;
10
- export declare function getKeySetNode(target: StoreNextTarget): Signal<number>;
11
- /** Deep-witness bump: any value/shape change on a record with a live deep()
12
- * subscriber notifies it. One null check when unused. */
13
- export declare function bumpDeep(t: StoreNextTarget): void;
14
- /** Scanned plainness for patch admission (patchableRaw): runs the one-time
15
- * accessor scan if it hasn't happened yet — the sticky `a` flag alone is not
16
- * trustworthy before a scan (it starts false and is discovered lazily). */
17
- export declare function targetIsPlain(target: StoreNextTarget): boolean;
18
- /** Downgrade a prototype-overlay pending backing to the clone path: builds
19
- * the real container (committed + overlay writes − deletes) that fold will
20
- * SWAP in as the committed backing, exactly as if the draft had started on
21
- * the clone path. Consumers that need a complete container (reconcile's
22
- * diff walks, drafts escaping into other storage) call this. */
23
- export declare function materializePB(target: StoreNextTarget): void;
24
- /**
25
- * Adoption (2026-08-16c): the incoming object becomes the committed backing
26
- * IMMEDIATELY — reconcile is eagerly visible to every reader (shipped
27
- * contract; only its notifications batch), unlike setter writes which stay
28
- * pending until flush. Ownership resets (incoming is unowned/user data). Any
29
- * staged draft clone folds into the diff and is discarded — next is the
30
- * authoritative base (R21/R32).
31
- */
32
- export declare function adoptPB(target: StoreNextTarget, incoming: Record<PropertyKey, any>, eager?: boolean): void;
33
- /** Parked truth-staged pending backings (#3164 fold): a tentative draft that
34
- * opens while a folded landing's backing is live moves the staged container
35
- * here (see ensurePB); the tentative discard in notifyOptimisticWrites
36
- * restores it in place of the usual null. */
37
- export declare const stagedTruthPB: WeakMap<StoreNextTarget, Record<PropertyKey, any>>;
38
- /** Same logical slot: both values resolve to one (re-pointed) child target —
39
- * adoption preserved identity, so the slot did not change (R9). */
40
- export declare function targetsEqual(ov: any, nv: any): boolean;
41
- export declare function arrayStructureChanged(old: any[], neu: any[]): boolean;
42
- export declare function membershipChanged(old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): boolean;
43
- /**
44
- * The fold diff walks SUBSCRIPTION KEYS ONLY (legacy parity: `for key in
45
- * nodes`): nodes exist exactly where something tracked, so unobserved data
46
- * costs nothing here regardless of object size. Accessor safety rides the
47
- * sticky `t.a` flag — a node's key was necessarily read, so the get trap has
48
- * already seen whether it is an accessor.
49
- */
50
- /** One node's fold notification (shared by notifyFold's walk and the fused
51
- * adoption walk): accessor-aware compare + equality/identity-gated setSignal. */
52
- export declare function notifyKeyDiff(node: Signal<any>, key: PropertyKey, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>, probe?: boolean): void;
53
- /** Accessor-flag probe for the fused walk's early-continue (accessor keys
54
- * can never identity-skip: their VALUE is the descriptor's product). */
55
- export declare function hasAccessorFlag(node: Signal<any>): boolean;
56
- /** Fused-walk per-key notification with values already in hand: the caller
57
- * fetched both sides and handled the identity skip; this applies the
58
- * accessor branch (cached flag only — reconcile channel) or the plain
59
- * equality/identity-gated write. */
60
- export declare function notifyKeyValue(node: Signal<any>, key: PropertyKey, ov: any, nv: any, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
61
- /** Presence + membership halves of a fold notification (shared tail). */
62
- export declare function notifyFoldTail(t: StoreNextTarget, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
63
- export declare function notifyFold(t: StoreNextTarget, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
64
- /** Authoritative-write wrapper exported for the optimistic module: sets the
65
- * scheduler's projectionWriteActive through THIS module's binding (proven to
66
- * share the instance core reads — cross-module live-binding writes from other
67
- * store modules were observed not to propagate under the test transform). */
68
- export declare function runAuthoritative<T>(fn: () => T): T;
69
- /** Active optimistic override on an armed node (armed slot idles at
70
- * NOT_PENDING; undefined = unarmed plain node). */
71
- export declare function hasActiveOverride(node: Signal<any>): boolean;
72
- /** The reading computation is until()'s authoritative-view predicate — same
73
- * source of truth as core read()'s A17 carve-out (`context`, which persists
74
- * under untrack). optimisticView()'s composition gate consults exactly this:
75
- * write-side machinery (patch emission, tentative re-application) must keep
76
- * composing even when it runs inside an authoritative-write bracket. */
77
- export declare function authoritativeRead(): boolean;
78
- /** Serve-side authoritative gate: until()'s predicate PLUS truth authors —
79
- * the projection derive's draft (wrapDraft trap brackets, runAuthoritative;
80
- * the same posture pair ensurePB classifies drafts by). A source computing
81
- * the next truth must never read its callers' tentative overlays: a derive
82
- * continuation's `store.push` computing its index from an action's
83
- * optimistic row landed truth in the wrong slot and corrupted committed
84
- * state (#3108). Trap-level overlay serves gate on this so values, length,
85
- * membership, and keys leave the authoritative view together. */
86
- export declare function authoritativeServe(): boolean;
87
- export type SetStoreNextFunction<T> = (fn: (draft: T) => T | void) => void;
88
- /** Low-level setter primitive: opens write mode on a next proxy, runs `fn`,
89
- * emits write-time notifications at outermost exit, applies returned
90
- * replacements as adoptions. `guard=false` skips the owned-scope dev guard —
91
- * projection recomputes legitimately write from inside their computed. */
92
- export declare function storeSetterNext<T>(proxy: T, fn: (draft: T) => T | void, guard?: boolean): void;
93
- export declare function createStoreNext<T extends Record<PropertyKey, any>>(init: T, shallow?: boolean): [T, SetStoreNextFunction<T>];
94
- /** True when `proxy` is a SHALLOW store (children served verbatim, slots
95
- * replaced by reference — #2932). The list driver uses this to choose the
96
- * slot-patch channel (collected row bodies) over per-record registration. */
97
- export declare function storeIsShallow(proxy: any): boolean;
98
- /** True when `proxy` belongs to a projection/optimistic FAMILY. The list
99
- * driver must DECLINE family arrays (external audit finding): family
100
- * structural changes never emit row/slot ops (the setter channel is
101
- * fam-gated; optimistic writes ride node overrides), and the proxy identity
102
- * is stable so the each-watch cannot catch the change either — an engaged
103
- * list would freeze on optimistic/projection structural updates. Record-
104
- * level family patches are unaffected (they have their own emission). */
105
- export declare function storeHasFamily(proxy: any): boolean;
106
- /** True when `proxy` belongs to an OPTIMISTIC family specifically. The list
107
- * driver declines these (audit finding, narrowed): optimistic user writes
108
- * ride node-level overrides — they never enter the reconcile walk, so no
109
- * row/slot ops are emitted and an engaged list would freeze on optimistic
110
- * structural changes. PROJECTION (non-optimistic) families are drivable:
111
- * their recomputes go through the reconcile walk, whose emissions are
112
- * transition-stamped in the apply queue like any other (equivalence-matrix
113
- * gated). Re-admitting optimistic families requires a lane-timed structural
114
- * emission mirroring emitPatchOptimistic, plus revert resync. */
115
- export declare function storeHasOptimisticFamily(proxy: any): boolean;
116
- /** Tracking deep snapshot (`deep()` for next targets): subscribes to the
117
- * key-set and deep-witness node at every reachable level, then returns the
118
- * plain view. Shared references and cycles handled via the visited set. */
119
- export declare function deepNext<T>(value: T): T;
120
- /**
121
- * Snapshot with per-object registration resolution (RUL-12 DAG ruling): every
122
- * reachable wrappable resolves through its target's CURRENT backing, so
123
- * privatized subtrees are seen through any parent path. Identity-preserving:
124
- * a subtree with no substitutions below returns its own object (zero copy for
125
- * settled, never-diverged graphs).
126
- */
127
- export declare function snapshotNext<T>(value: T): T;