@solidjs/signals 2.0.0-rc.2 → 2.0.0-rc.4

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 (57) hide show
  1. package/dist/dev.js +1454 -118
  2. package/dist/node.cjs +2709 -1396
  3. package/dist/prod/affects.js +13 -12
  4. package/dist/prod/boundaries.js +39 -34
  5. package/dist/prod/core/action.js +3 -3
  6. package/dist/prod/core/async.js +48 -46
  7. package/dist/prod/core/core.js +99 -67
  8. package/dist/prod/core/effect.js +25 -28
  9. package/dist/prod/core/external.js +2 -2
  10. package/dist/prod/core/graph.js +85 -49
  11. package/dist/prod/core/heap.js +10 -10
  12. package/dist/prod/core/lanes.js +19 -19
  13. package/dist/prod/core/optimistic.js +66 -41
  14. package/dist/prod/core/owner.js +13 -13
  15. package/dist/prod/core/scheduler.js +131 -85
  16. package/dist/prod/core/verdict.js +36 -15
  17. package/dist/prod/index.js +4 -0
  18. package/dist/prod/map.js +101 -101
  19. package/dist/prod/signals.js +1 -1
  20. package/dist/prod/store/index.js +2 -0
  21. package/dist/prod/store/next/optimistic.js +65 -11
  22. package/dist/prod/store/next/patch-hooks.js +13 -0
  23. package/dist/prod/store/next/patch.js +614 -0
  24. package/dist/prod/store/next/projection.js +107 -45
  25. package/dist/prod/store/next/reconcile.js +307 -120
  26. package/dist/prod/store/next/store.js +321 -92
  27. package/dist/prod/store/next/target.js +13 -4
  28. package/dist/prod/store/store.js +5 -5
  29. package/dist/types/core/core.d.ts +15 -1
  30. package/dist/types/core/dev.d.ts +8 -0
  31. package/dist/types/core/graph.d.ts +22 -0
  32. package/dist/types/core/invariants.d.ts +1 -1
  33. package/dist/types/core/scheduler.d.ts +12 -0
  34. package/dist/types/store/index.d.ts +2 -0
  35. package/dist/types/store/next/patch-hooks.d.ts +41 -0
  36. package/dist/types/store/next/patch.d.ts +91 -0
  37. package/dist/types/store/next/reconcile.d.ts +14 -0
  38. package/dist/types/store/next/store.d.ts +30 -2
  39. package/dist/types/store/next/target.d.ts +58 -8
  40. package/dist/types-cjs/core/core.d.cts +15 -1
  41. package/dist/types-cjs/core/dev.d.cts +8 -0
  42. package/dist/types-cjs/core/graph.d.cts +22 -0
  43. package/dist/types-cjs/core/invariants.d.cts +1 -1
  44. package/dist/types-cjs/core/scheduler.d.cts +12 -0
  45. package/dist/types-cjs/store/index.d.cts +2 -0
  46. package/dist/types-cjs/store/next/patch-hooks.d.cts +41 -0
  47. package/dist/types-cjs/store/next/patch.d.cts +91 -0
  48. package/dist/types-cjs/store/next/reconcile.d.cts +14 -0
  49. package/dist/types-cjs/store/next/store.d.cts +30 -2
  50. package/dist/types-cjs/store/next/target.d.cts +58 -8
  51. package/package.json +14 -14
  52. package/dist/types/store/optimistic.d.ts +0 -45
  53. package/dist/types/store/projection.d.ts +0 -70
  54. package/dist/types/store/reconcile.d.ts +0 -46
  55. package/dist/types-cjs/store/optimistic.d.cts +0 -45
  56. package/dist/types-cjs/store/projection.d.cts +0 -70
  57. package/dist/types-cjs/store/reconcile.d.cts +0 -46
@@ -7,14 +7,23 @@ const ownedRaw = new WeakSet;
7
7
 
8
8
  /** raw → target. The only raw-keyed lookup; boundary mechanism (O8). */ const storeNextLookup = new WeakMap;
9
9
 
10
- function devAssertNeverUserMutation(o) {
10
+ function devAssertNeverUserMutation(e) {
11
11
  return;
12
12
  }
13
13
 
14
14
  let optHooks = null;
15
15
 
16
- function setOptHooks(o) {
17
- optHooks = o;
16
+ function setOptHooks(e) {
17
+ optHooks = e;
18
18
  }
19
19
 
20
- export { devAssertNeverUserMutation, optHooks, ownedRaw, setOptHooks, storeNextLookup };
20
+ /** Sticky descendants flag walk (§6d): reconcile's keyed pruning descends
21
+ * only where subscriptions exist at/below. Nodes AND patches count. */ function markDescendants(e) {
22
+ let t = e;
23
+ while (t && !t.d) {
24
+ t.d = true;
25
+ t = t.u;
26
+ }
27
+ }
28
+
29
+ export { devAssertNeverUserMutation, markDescendants, optHooks, ownedRaw, setOptHooks, storeNextLookup };
@@ -139,7 +139,7 @@ function ownEnumerableKeys(e) {
139
139
  // A live scope exists, so affects.ts already installed the mark engine.
140
140
  for (const [r, s] of affectsScopes) {
141
141
  if (r.o?.t && s.scope.has(t) && (s.key === undefined || s.key === o)) {
142
- GlobalQueue.h(e);
142
+ GlobalQueue.M(e);
143
143
  s.inherited.push(e);
144
144
  }
145
145
  }
@@ -252,7 +252,7 @@ s) {
252
252
  // Callers guard on `pendingCheckActive`, which only flips inside
253
253
  // isPending() — the verdict layer is loaded and its hook installed.
254
254
  const o = e[STORE_NODE]?.[$AFFECTS];
255
- if (o?.o?.t) GlobalQueue.Bt(o);
255
+ if (o?.o?.t) GlobalQueue.wt(o);
256
256
  if (affectsScopes.size) {
257
257
  // Chained backings (§7b): a wrapper's STORE_VALUE can be another store's
258
258
  // proxy — marks cover by identity of the BASE raw, so resolve the chain
@@ -263,7 +263,7 @@ s) {
263
263
  let t = r;
264
264
  for (;;) {
265
265
  if (s.scope.has(t)) {
266
- GlobalQueue.Bt(e);
266
+ GlobalQueue.wt(e);
267
267
  break;
268
268
  }
269
269
  const o = t?.[$TARGET];
@@ -288,11 +288,11 @@ s) {
288
288
  *
289
289
  * @internal
290
290
  */ function getStoreAffectsNodes(e, t) {
291
- GlobalQueue.G ||= e => {
291
+ GlobalQueue.p ||= e => {
292
292
  const t = affectsScopes.get(e);
293
293
  if (!t) return;
294
294
  affectsScopes.delete(e);
295
- for (let e = 0; e < t.inherited.length; e++) GlobalQueue.j(t.inherited[e]);
295
+ for (let e = 0; e < t.inherited.length; e++) GlobalQueue.N(t.inherited[e]);
296
296
  };
297
297
  if (t === undefined) {
298
298
  const t = nextAffectsNodeResolver(e, $AFFECTS);
@@ -38,7 +38,21 @@ export declare function ext(el: {
38
38
  * mode (recompute is called explicitly by `effect()`), so we hardcode the lazy bits and skip
39
39
  * the auto-dispose CONFIG bit (effect() previously cleared it post-construction).
40
40
  */
41
- export declare function createEffectNode<T>(fn: (prev?: T) => T, effectFn: (val: T, prev: T | undefined) => void | (() => void), errorFn: ((err: unknown, cleanup: () => void) => void | (() => void)) | undefined, type: number, notifyStatus: ((status?: number, error?: any) => void) | undefined, options: NodeOptions<T> | undefined): any;
41
+ export declare function createEffectNode<T>(fn: (prev?: T) => T, effectFn: (val: T, prev: T | undefined) => void | (() => void), errorFn: ((err: unknown, cleanup: () => void) => void | (() => void)) | undefined, type: number, options: NodeOptions<T> | undefined): any;
42
+ /**
43
+ * The shared status notifier for effect nodes, installed once by effect.ts
44
+ * at module evaluation (`this`-dispatched — one function serves every
45
+ * effect, so nodes never store it). Boundary computeds keep their own
46
+ * per-node channel on `_x._notifyStatus`, which takes precedence.
47
+ */
48
+ export declare let effectStatusNotify: ((this: any, status?: number, error?: any) => void) | null;
49
+ export declare function setEffectStatusNotify(fn: NonNullable<typeof effectStatusNotify>): void;
50
+ /** Resolve a node's status notifier: an own `_x` channel (boundaries) wins;
51
+ * effect nodes (`_type` — EFFECT_PURE is 0, and only effect literals carry
52
+ * the field) fall back to the shared notifier. Presence doubles as the
53
+ * "display consumer" membership test in the status walks, exactly as the
54
+ * per-node field did when every effect carried one. */
55
+ export declare function statusNotifierOf(el: any): ((this: any, status?: number, error?: any) => void) | undefined;
42
56
  export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
43
57
  export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
44
58
  export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
@@ -33,6 +33,14 @@ export interface DiagnosticCapture {
33
33
  export interface Diagnostics {
34
34
  subscribe(listener: DiagnosticListener): () => void;
35
35
  capture(): DiagnosticCapture;
36
+ /**
37
+ * Registers a console footer printed after the first console report of
38
+ * each diagnostic code — a discovery pointer to deeper guidance (e.g.
39
+ * solid-js registers its shipped repair skill). Returning undefined for
40
+ * an event suppresses the footer. Passing undefined unregisters and
41
+ * resets the once-per-code memory.
42
+ */
43
+ setConsoleFooter(footer: ((event: DiagnosticEvent) => string | undefined) | undefined): void;
36
44
  }
37
45
  export interface Dev {
38
46
  hooks: DevHooks;
@@ -3,4 +3,26 @@ export declare function unlinkSubs(link: Link): Link | null;
3
3
  export declare function trimStaleDeps(el: Computed<any>): void;
4
4
  export declare function clearDeps(el: Computed<unknown>): void;
5
5
  export declare function unobserved(el: Computed<unknown>): void;
6
+ /**
7
+ * Deferred dormancy for never-observed auto-dispose computeds (#3078).
8
+ *
9
+ * An untracked top-level read of a subscriber-less observation-lifecycle memo
10
+ * used to call unobserved() inline at the end of read(). That kept the leak
11
+ * closed (the compute links the memo into its deps' sub lists — without a
12
+ * teardown point a never-observed memo is retained by its sources forever;
13
+ * upstream alien-signals has exactly this retention), but it made reads
14
+ * destructive: each read disposed the node, the next read revived it with a
15
+ * full recompute in whatever ambient transition/lane context happened to be
16
+ * current, so consecutive reads could return different answers with no write
17
+ * in between.
18
+ *
19
+ * Instead, reads queue the node here and the scheduler sweeps at the top of
20
+ * the next flush (before runHeap, so a same-tick dirtying is reclaimed
21
+ * instead of recomputed). Reads become idempotent within a tick (the node
22
+ * stays alive and serves its cache, uniform with observed memos) while
23
+ * reclamation still happens within one microtask — the enqueue site arms
24
+ * schedule(), so a flush is guaranteed even when no other work is queued.
25
+ */
26
+ export declare const dormantNodes: Set<Computed<unknown>>;
27
+ export declare function sweepDormant(): void;
6
28
  export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>, pendingObserver?: boolean): void;
@@ -2,7 +2,7 @@ import type { OptimisticLane } from "./lanes.js";
2
2
  import type { Computed, Signal } from "./types.js";
3
3
  /**
4
4
  * Test-mode invariant checks for the async/transition/lane machinery.
5
- * Catalog and rationale: packages/solid-signals/INTERNALS-ASYNC-STATE.md.
5
+ * Catalog and rationale: packages/signals/INTERNALS-ASYNC-STATE.md.
6
6
  *
7
7
  * These are implementation self-consistency checks, not semantic rules: a
8
8
  * violation means the reactive system contradicted itself.
@@ -103,6 +103,10 @@ export declare class GlobalQueue extends Queue {
103
103
  static _transitionBlocked: ((transition: Transition) => boolean) | null;
104
104
  static _cleanupLanes: ((completingTransition: Transition | null) => void) | null;
105
105
  static _runLaneEffects: ((type: number) => void) | null;
106
+ /** Patch-channel optimistic drain (next/patch.ts): optimistic emissions
107
+ * apply at lane-effect timing — visible in flight, unlike the regular
108
+ * effect queues an action stashes. Injected; null when unused. */
109
+ static _drainPatchOptimistic: (() => void) | null;
106
110
  static _gatedRead: ((el: Signal<any>, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
107
111
  static _laneSuspends: ((owner: OptimisticNode) => boolean) | null;
108
112
  static _laneReadsCommitted: ((el: OptimisticNode, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
@@ -126,6 +130,14 @@ export declare function armReaskClear(): void;
126
130
  export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
127
131
  export declare let storeCommitHook: (() => void) | null;
128
132
  export declare function setStoreCommitHook(fn: () => void): void;
133
+ /** Patch-channel release hook (next/patch.ts): transition-stamped patch
134
+ * emissions are released when THEIR batch commits. Transitions never
135
+ * abort: failed actions still commit (only optimistic overrides revert),
136
+ * and merged-away transitions hand their stash to the survivor
137
+ * (mergeTransitionState) — every stash drains exactly once. Injected like
138
+ * storeCommitHook to stay tree-shakeable. */
139
+ export declare let patchCommitHook: ((batch: Transition) => void) | null;
140
+ export declare function setPatchCommitHook(fn: (batch: Transition) => void): void;
129
141
  export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
130
142
  /**
131
143
  * Count of live `affects()` registrations across the system (including
@@ -4,6 +4,8 @@ export { isWrappable, $TRACK, $PROXY, $TARGET } from "./store.js";
4
4
  import type { NoFn, ProjectionOptions, Store, StoreOptions, StoreSetter } from "./store.js";
5
5
  import type { Refreshable } from "../core/index.js";
6
6
  export { createProjectionNext as createProjection } from "./next/projection.js";
7
+ export { registerPatch, registerRowOps, registerSlotPatchNext as registerSlotPatch, patchableRaw } from "./next/patch.js";
8
+ export { storeIsShallow, storeHasFamily, storeHasOptimisticFamily } from "./next/store.js";
7
9
  export { createOptimisticStoreNext as createOptimisticStore } from "./next/optimistic.js";
8
10
  /** Public createStore: plain form `(init, options?)` and derived writable
9
11
  * form `(fn, seed, options?)`. */
@@ -0,0 +1,41 @@
1
+ import type { StoreNextTarget } from "./target.js";
2
+ import type { RowOps } from "./patch.js";
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;
@@ -0,0 +1,91 @@
1
+ import type { Owner } from "../../core/types.js";
2
+ import { type StoreNextTarget } from "./target.js";
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,3 +1,17 @@
1
+ import type { RowOps } from "./patch.js";
2
+ import { type StoreNextTarget } from "./target.js";
1
3
  type KeyFn = (item: any) => any;
2
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;
3
17
  export {};
@@ -1,5 +1,7 @@
1
1
  import type { Signal } from "../../core/types.js";
2
- import { type StoreNextFamily, type StoreNextTarget } from "./target.js";
2
+ import { type StoreNextFamily, type StoreNextTarget, type PatchChannel } from "./target.js";
3
+ /** Lazily allocate the patch-channel extension (one literal shape). */
4
+ export declare function pcOf(t: StoreNextTarget): PatchChannel;
3
5
  export declare function wrapNext<T extends Record<PropertyKey, any>>(value: T, parent?: StoreNextTarget | null, parentKey?: PropertyKey | null, fam?: StoreNextFamily | null): T;
4
6
  /** Unwrap our own proxies to their current backing; leave everything else. */
5
7
  export declare function unwrapValue(v: any): any;
@@ -9,6 +11,10 @@ export declare function getKeySetNode(target: StoreNextTarget): Signal<number>;
9
11
  /** Deep-witness bump: any value/shape change on a record with a live deep()
10
12
  * subscriber notifies it. One null check when unused. */
11
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;
12
18
  /** Downgrade a prototype-overlay pending backing to the clone path: builds
13
19
  * the real container (committed + overlay writes − deletes) that fold will
14
20
  * SWAP in as the committed backing, exactly as if the draft had started on
@@ -63,8 +69,30 @@ export type SetStoreNextFunction<T> = (fn: (draft: T) => T | void) => void;
63
69
  * projection recomputes legitimately write from inside their computed. */
64
70
  export declare function storeSetterNext<T>(proxy: T, fn: (draft: T) => T | void, guard?: boolean): void;
65
71
  export declare function createStoreNext<T extends Record<PropertyKey, any>>(init: T, shallow?: boolean): [T, SetStoreNextFunction<T>];
72
+ /** True when `proxy` is a SHALLOW store (children served verbatim, slots
73
+ * replaced by reference — #2932). The list driver uses this to choose the
74
+ * slot-patch channel (collected row bodies) over per-record registration. */
75
+ export declare function storeIsShallow(proxy: any): boolean;
76
+ /** True when `proxy` belongs to a projection/optimistic FAMILY. The list
77
+ * driver must DECLINE family arrays (external audit finding): family
78
+ * structural changes never emit row/slot ops (the setter channel is
79
+ * fam-gated; optimistic writes ride node overrides), and the proxy identity
80
+ * is stable so the each-watch cannot catch the change either — an engaged
81
+ * list would freeze on optimistic/projection structural updates. Record-
82
+ * level family patches are unaffected (they have their own emission). */
83
+ export declare function storeHasFamily(proxy: any): boolean;
84
+ /** True when `proxy` belongs to an OPTIMISTIC family specifically. The list
85
+ * driver declines these (audit finding, narrowed): optimistic user writes
86
+ * ride node-level overrides — they never enter the reconcile walk, so no
87
+ * row/slot ops are emitted and an engaged list would freeze on optimistic
88
+ * structural changes. PROJECTION (non-optimistic) families are drivable:
89
+ * their recomputes go through the reconcile walk, whose emissions are
90
+ * transition-stamped in the apply queue like any other (equivalence-matrix
91
+ * gated). Re-admitting optimistic families requires a lane-timed structural
92
+ * emission mirroring emitPatchOptimistic, plus revert resync. */
93
+ export declare function storeHasOptimisticFamily(proxy: any): boolean;
66
94
  /** Tracking deep snapshot (`deep()` for next targets): subscribes to the
67
- * key-set and every property node at every reachable level, then returns the
95
+ * key-set and deep-witness node at every reachable level, then returns the
68
96
  * plain view. Shared references and cycles handled via the visited set. */
69
97
  export declare function deepNext<T>(value: T): T;
70
98
  /**
@@ -12,7 +12,7 @@
12
12
  * entry per read-through object; zero layer slots; nodes, has-nodes, and the
13
13
  * key-set node are lazy, materialized only by subscription.
14
14
  */
15
- import type { Computed, Signal } from "../../core/types.js";
15
+ import type { Computed, Owner, Signal } from "../../core/types.js";
16
16
  /** Projection family (§7b): children wrap into the family's own map (writes
17
17
  * land in the projection, never the source family), and every node created
18
18
  * under the family carries the projection computed as its firewall. */
@@ -32,6 +32,40 @@ export interface StoreNextFamily {
32
32
  node: Computed<any> | null;
33
33
  shallow?: boolean;
34
34
  }
35
+ /** Write-side patch-channel state (stage 2), grouped off the target's named
36
+ * fields — see the shape rule on `StoreNextTarget.pc`. One literal shape,
37
+ * allocated by `pcOf` on first use. */
38
+ export interface PatchChannel {
39
+ /** Slot-patch hooks for shallow arrays — the reconcile walk emits
40
+ * (i, next, prev) for key-aligned value-replaced slots through the patch
41
+ * apply queue (records are raw, no per-record targets exist).
42
+ * MULTI-CONSUMER (external audit): one array can drive several lists. */
43
+ sp: {
44
+ fn: (index: number, next: any, prev: any) => void;
45
+ owner: Owner | null;
46
+ }[] | null;
47
+ /** Patch-channel consumers (next/patch.ts): per-record compiled patch
48
+ * entries, multi-consumer. null when unpatched (the common case). */
49
+ p: object[] | null;
50
+ /** Same-batch coalescing stamp (re-audit 2/3): the container array this
51
+ * channel last pushed a non-forced SELF entry into, plus that entry. A
52
+ * later same-batch emission UPDATES the queued entry's `next` in place
53
+ * (latest state wins — adoption REPLACES the captured object, so dropping
54
+ * the later emission would apply stale state) while `prev` stays the
55
+ * batch's earliest. The drain clears both stamps so a quiet record
56
+ * retains nothing from its last batch. */
57
+ qa: unknown;
58
+ qe: unknown;
59
+ /** Row-ops consumers (next/patch.ts, PR-B): structural list ops —
60
+ * (nextRows, { prefix, sources, removed }) at apply timing. */
61
+ ro: object[] | null;
62
+ /** Keys written through the traps since the last fold commit. Bounds the
63
+ * setter notify/hold-check to O(written) instead of O(subscribed nodes) —
64
+ * a record with thousands of per-key subscriptions (selection maps) would
65
+ * otherwise pay a full node scan on every write. null = no trap writes
66
+ * this batch (bulk paths fall back to the full scan). */
67
+ wk: Set<PropertyKey> | null;
68
+ }
35
69
  export interface StoreNextTarget {
36
70
  /** Committed backing: source object (shared) or owned clone. */
37
71
  v: Record<PropertyKey, any>;
@@ -47,6 +81,15 @@ export interface StoreNextTarget {
47
81
  h: Record<PropertyKey, Signal<boolean>> | null;
48
82
  /** Lazy key-set node: membership/iteration/$TRACK subscriptions (§6). */
49
83
  k: Signal<number> | null;
84
+ /** Patch-channel extension (lazily allocated on first use): groups the
85
+ * write-side stage-2 fields so they never widen the TARGET's own named
86
+ * field count. LOAD-BEARING SHAPE RULE: array proxy targets carry their
87
+ * fields as named properties on a real array, and V8 normalizes an array
88
+ * to dictionary properties as the named count grows (empirically at
89
+ * counts ≡ 0 mod 3 from 18 up on V8 13.x) — every trap field read then
90
+ * becomes a hash lookup (~15% uibench, tree suites worst). New
91
+ * patch-channel state MUST go inside this object, not on the target. */
92
+ pc: PatchChannel | null;
50
93
  /** Lazy deep-witness node: `deep()` subscribes ONE node per record instead
51
94
  * of one per path; write paths bump it only when it exists. Separate from
52
95
  * `k` so $TRACK/mapArray never rerun on leaf value changes (R9). */
@@ -79,17 +122,21 @@ export interface StoreNextTarget {
79
122
  /** Keys deleted in the overlay window (a prototype overlay cannot shadow
80
123
  * a delete); null when none. */
81
124
  del: Set<PropertyKey> | null;
82
- /** Keys written through the traps since the last fold commit. Bounds the
83
- * setter notify/hold-check to O(written) instead of O(subscribed nodes) —
84
- * a record with thousands of per-key subscriptions (selection maps) would
85
- * otherwise pay a full node scan on every write. null = no trap writes
86
- * this batch (bulk paths fall back to the full scan); WK_ALL sentinel =
87
- * bound unusable this batch (array length write implies index deletes). */
88
- wk: Set<PropertyKey> | null;
89
125
  /** Projection family, null for plain stores (§7b). */
90
126
  fam: StoreNextFamily | null;
91
127
  /** Shallow store root (values served raw). */
92
128
  s: boolean;
129
+ /** Held committed view (#3074/#3075): the pre-hold committed backing,
130
+ * served to committed-visibility readers while `ht` is live. Adoption is
131
+ * eager by contract, but a projection recompute deriving from uncommitted
132
+ * inputs (a transition-held source, or a latest()-pull ahead of the flush)
133
+ * swaps the backing SPECULATIVELY — the old view must stay servable until
134
+ * the hold resolves. */
135
+ hv: Record<PropertyKey, any> | null;
136
+ /** The holder for `hv`: a live transition (cleared lazily when it is done)
137
+ * or the PLAIN_HOLD sentinel (a latest()-pull staging — cleared by the
138
+ * fold commit). null = no hold. */
139
+ ht: any;
93
140
  }
94
141
  /**
95
142
  * Ownership (first cut, decision 2026-08-16d): one WeakSet of store-owned
@@ -115,3 +162,6 @@ export interface OptStoreHooks {
115
162
  }
116
163
  export declare let optHooks: OptStoreHooks | null;
117
164
  export declare function setOptHooks(h: OptStoreHooks): void;
165
+ /** Sticky descendants flag walk (§6d): reconcile's keyed pruning descends
166
+ * only where subscriptions exist at/below. Nodes AND patches count. */
167
+ export declare function markDescendants(target: StoreNextTarget): void;
@@ -38,7 +38,21 @@ export declare function ext(el: {
38
38
  * mode (recompute is called explicitly by `effect()`), so we hardcode the lazy bits and skip
39
39
  * the auto-dispose CONFIG bit (effect() previously cleared it post-construction).
40
40
  */
41
- export declare function createEffectNode<T>(fn: (prev?: T) => T, effectFn: (val: T, prev: T | undefined) => void | (() => void), errorFn: ((err: unknown, cleanup: () => void) => void | (() => void)) | undefined, type: number, notifyStatus: ((status?: number, error?: any) => void) | undefined, options: NodeOptions<T> | undefined): any;
41
+ export declare function createEffectNode<T>(fn: (prev?: T) => T, effectFn: (val: T, prev: T | undefined) => void | (() => void), errorFn: ((err: unknown, cleanup: () => void) => void | (() => void)) | undefined, type: number, options: NodeOptions<T> | undefined): any;
42
+ /**
43
+ * The shared status notifier for effect nodes, installed once by effect.ts
44
+ * at module evaluation (`this`-dispatched — one function serves every
45
+ * effect, so nodes never store it). Boundary computeds keep their own
46
+ * per-node channel on `_x._notifyStatus`, which takes precedence.
47
+ */
48
+ export declare let effectStatusNotify: ((this: any, status?: number, error?: any) => void) | null;
49
+ export declare function setEffectStatusNotify(fn: NonNullable<typeof effectStatusNotify>): void;
50
+ /** Resolve a node's status notifier: an own `_x` channel (boundaries) wins;
51
+ * effect nodes (`_type` — EFFECT_PURE is 0, and only effect literals carry
52
+ * the field) fall back to the shared notifier. Presence doubles as the
53
+ * "display consumer" membership test in the status walks, exactly as the
54
+ * per-node field did when every effect carried one. */
55
+ export declare function statusNotifierOf(el: any): ((this: any, status?: number, error?: any) => void) | undefined;
42
56
  export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
43
57
  export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
44
58
  export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
@@ -33,6 +33,14 @@ export interface DiagnosticCapture {
33
33
  export interface Diagnostics {
34
34
  subscribe(listener: DiagnosticListener): () => void;
35
35
  capture(): DiagnosticCapture;
36
+ /**
37
+ * Registers a console footer printed after the first console report of
38
+ * each diagnostic code — a discovery pointer to deeper guidance (e.g.
39
+ * solid-js registers its shipped repair skill). Returning undefined for
40
+ * an event suppresses the footer. Passing undefined unregisters and
41
+ * resets the once-per-code memory.
42
+ */
43
+ setConsoleFooter(footer: ((event: DiagnosticEvent) => string | undefined) | undefined): void;
36
44
  }
37
45
  export interface Dev {
38
46
  hooks: DevHooks;
@@ -3,4 +3,26 @@ export declare function unlinkSubs(link: Link): Link | null;
3
3
  export declare function trimStaleDeps(el: Computed<any>): void;
4
4
  export declare function clearDeps(el: Computed<unknown>): void;
5
5
  export declare function unobserved(el: Computed<unknown>): void;
6
+ /**
7
+ * Deferred dormancy for never-observed auto-dispose computeds (#3078).
8
+ *
9
+ * An untracked top-level read of a subscriber-less observation-lifecycle memo
10
+ * used to call unobserved() inline at the end of read(). That kept the leak
11
+ * closed (the compute links the memo into its deps' sub lists — without a
12
+ * teardown point a never-observed memo is retained by its sources forever;
13
+ * upstream alien-signals has exactly this retention), but it made reads
14
+ * destructive: each read disposed the node, the next read revived it with a
15
+ * full recompute in whatever ambient transition/lane context happened to be
16
+ * current, so consecutive reads could return different answers with no write
17
+ * in between.
18
+ *
19
+ * Instead, reads queue the node here and the scheduler sweeps at the top of
20
+ * the next flush (before runHeap, so a same-tick dirtying is reclaimed
21
+ * instead of recomputed). Reads become idempotent within a tick (the node
22
+ * stays alive and serves its cache, uniform with observed memos) while
23
+ * reclamation still happens within one microtask — the enqueue site arms
24
+ * schedule(), so a flush is guaranteed even when no other work is queued.
25
+ */
26
+ export declare const dormantNodes: Set<Computed<unknown>>;
27
+ export declare function sweepDormant(): void;
6
28
  export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>, pendingObserver?: boolean): void;
@@ -2,7 +2,7 @@ import type { OptimisticLane } from "./lanes.cjs";
2
2
  import type { Computed, Signal } from "./types.cjs";
3
3
  /**
4
4
  * Test-mode invariant checks for the async/transition/lane machinery.
5
- * Catalog and rationale: packages/solid-signals/INTERNALS-ASYNC-STATE.md.
5
+ * Catalog and rationale: packages/signals/INTERNALS-ASYNC-STATE.md.
6
6
  *
7
7
  * These are implementation self-consistency checks, not semantic rules: a
8
8
  * violation means the reactive system contradicted itself.
@@ -103,6 +103,10 @@ export declare class GlobalQueue extends Queue {
103
103
  static _transitionBlocked: ((transition: Transition) => boolean) | null;
104
104
  static _cleanupLanes: ((completingTransition: Transition | null) => void) | null;
105
105
  static _runLaneEffects: ((type: number) => void) | null;
106
+ /** Patch-channel optimistic drain (next/patch.ts): optimistic emissions
107
+ * apply at lane-effect timing — visible in flight, unlike the regular
108
+ * effect queues an action stashes. Injected; null when unused. */
109
+ static _drainPatchOptimistic: (() => void) | null;
106
110
  static _gatedRead: ((el: Signal<any>, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
107
111
  static _laneSuspends: ((owner: OptimisticNode) => boolean) | null;
108
112
  static _laneReadsCommitted: ((el: OptimisticNode, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
@@ -126,6 +130,14 @@ export declare function armReaskClear(): void;
126
130
  export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
127
131
  export declare let storeCommitHook: (() => void) | null;
128
132
  export declare function setStoreCommitHook(fn: () => void): void;
133
+ /** Patch-channel release hook (next/patch.ts): transition-stamped patch
134
+ * emissions are released when THEIR batch commits. Transitions never
135
+ * abort: failed actions still commit (only optimistic overrides revert),
136
+ * and merged-away transitions hand their stash to the survivor
137
+ * (mergeTransitionState) — every stash drains exactly once. Injected like
138
+ * storeCommitHook to stay tree-shakeable. */
139
+ export declare let patchCommitHook: ((batch: Transition) => void) | null;
140
+ export declare function setPatchCommitHook(fn: (batch: Transition) => void): void;
129
141
  export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
130
142
  /**
131
143
  * Count of live `affects()` registrations across the system (including
@@ -4,6 +4,8 @@ export { isWrappable, $TRACK, $PROXY, $TARGET } from "./store.cjs";
4
4
  import type { NoFn, ProjectionOptions, Store, StoreOptions, StoreSetter } from "./store.cjs";
5
5
  import type { Refreshable } from "../core/index.cjs";
6
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";
7
9
  export { createOptimisticStoreNext as createOptimisticStore } from "./next/optimistic.cjs";
8
10
  /** Public createStore: plain form `(init, options?)` and derived writable
9
11
  * form `(fn, seed, options?)`. */