@solidjs/signals 2.0.0-rc.3 → 2.0.0-rc.5

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 (71) hide show
  1. package/dist/dev.js +2494 -271
  2. package/dist/node.cjs +3691 -1595
  3. package/dist/prod/affects.js +13 -12
  4. package/dist/prod/boundaries.js +43 -35
  5. package/dist/prod/core/action.js +3 -3
  6. package/dist/prod/core/async.js +137 -106
  7. package/dist/prod/core/constants.js +55 -1
  8. package/dist/prod/core/core.js +354 -247
  9. package/dist/prod/core/effect.js +47 -50
  10. package/dist/prod/core/error.js +13 -1
  11. package/dist/prod/core/external.js +4 -4
  12. package/dist/prod/core/graph.js +88 -52
  13. package/dist/prod/core/heap.js +38 -38
  14. package/dist/prod/core/lanes.js +34 -34
  15. package/dist/prod/core/optimistic.js +61 -58
  16. package/dist/prod/core/owner.js +38 -38
  17. package/dist/prod/core/scheduler.js +401 -174
  18. package/dist/prod/core/verdict.js +132 -65
  19. package/dist/prod/index.js +7 -3
  20. package/dist/prod/map.js +106 -106
  21. package/dist/prod/signals.js +253 -25
  22. package/dist/prod/store/index.js +2 -0
  23. package/dist/prod/store/next/optimistic.js +314 -121
  24. package/dist/prod/store/next/patch-hooks.js +13 -0
  25. package/dist/prod/store/next/patch.js +614 -0
  26. package/dist/prod/store/next/projection.js +23 -19
  27. package/dist/prod/store/next/reconcile.js +307 -120
  28. package/dist/prod/store/next/store.js +440 -117
  29. package/dist/prod/store/next/target.js +13 -4
  30. package/dist/prod/store/store.js +5 -5
  31. package/dist/types/core/async.d.ts +2 -0
  32. package/dist/types/core/attribution.d.ts +9 -4
  33. package/dist/types/core/constants.d.ts +54 -0
  34. package/dist/types/core/core.d.ts +34 -21
  35. package/dist/types/core/dev.d.ts +8 -0
  36. package/dist/types/core/error.d.ts +9 -0
  37. package/dist/types/core/graph.d.ts +22 -0
  38. package/dist/types/core/index.d.ts +2 -2
  39. package/dist/types/core/scheduler.d.ts +46 -0
  40. package/dist/types/core/types.d.ts +12 -0
  41. package/dist/types/index.d.ts +3 -3
  42. package/dist/types/signals.d.ts +108 -0
  43. package/dist/types/store/index.d.ts +2 -0
  44. package/dist/types/store/next/optimistic.d.ts +13 -10
  45. package/dist/types/store/next/patch-hooks.d.ts +41 -0
  46. package/dist/types/store/next/patch.d.ts +91 -0
  47. package/dist/types/store/next/projection.d.ts +1 -1
  48. package/dist/types/store/next/reconcile.d.ts +14 -0
  49. package/dist/types/store/next/store.d.ts +52 -2
  50. package/dist/types/store/next/target.d.ts +73 -8
  51. package/dist/types-cjs/core/async.d.cts +2 -0
  52. package/dist/types-cjs/core/attribution.d.cts +9 -4
  53. package/dist/types-cjs/core/constants.d.cts +54 -0
  54. package/dist/types-cjs/core/core.d.cts +34 -21
  55. package/dist/types-cjs/core/dev.d.cts +8 -0
  56. package/dist/types-cjs/core/error.d.cts +9 -0
  57. package/dist/types-cjs/core/graph.d.cts +22 -0
  58. package/dist/types-cjs/core/index.d.cts +2 -2
  59. package/dist/types-cjs/core/scheduler.d.cts +46 -0
  60. package/dist/types-cjs/core/types.d.cts +12 -0
  61. package/dist/types-cjs/index.d.cts +3 -3
  62. package/dist/types-cjs/signals.d.cts +108 -0
  63. package/dist/types-cjs/store/index.d.cts +2 -0
  64. package/dist/types-cjs/store/next/optimistic.d.cts +13 -10
  65. package/dist/types-cjs/store/next/patch-hooks.d.cts +41 -0
  66. package/dist/types-cjs/store/next/patch.d.cts +91 -0
  67. package/dist/types-cjs/store/next/projection.d.cts +1 -1
  68. package/dist/types-cjs/store/next/reconcile.d.cts +14 -0
  69. package/dist/types-cjs/store/next/store.d.cts +52 -2
  70. package/dist/types-cjs/store/next/target.d.cts +73 -8
  71. package/package.json +2 -2
@@ -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.cjs";
15
+ import type { Computed, Owner, Signal } from "../../core/types.cjs";
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. */
@@ -27,11 +27,56 @@ export interface StoreNextFamily {
27
27
  /** Targets currently carrying active node overrides (landing-consumption
28
28
  * walk, RUL-2: visible landed truth replaces optimism). */
29
29
  overlaid?: Set<any>;
30
+ /** Retaining transactions (#3164 fold ruling): every transaction that made
31
+ * an optimistic setter call on this family and may still be open. While
32
+ * any member is live, truth landings FOLD — they stage into the retaining
33
+ * transaction and reveal atomically at its settle, exactly like a signal
34
+ * landing under an active override. Dead members prune lazily at each
35
+ * landing (retainingTransition). */
36
+ rt?: Set<any>;
37
+ /** Normalized row-key fn (same resolution as the projection channels:
38
+ * `options.key`, "id" default, null = unkeyed). The staged-landing walk
39
+ * reads it: key-matched rows keep their proxy identity across a fold. */
40
+ key?: ((item: any) => any) | null;
30
41
  map: WeakMap<object, StoreNextTarget>;
31
42
  /** The projection computed — assigned after creation (accessor pattern). */
32
43
  node: Computed<any> | null;
33
44
  shallow?: boolean;
34
45
  }
46
+ /** Write-side patch-channel state (stage 2), grouped off the target's named
47
+ * fields — see the shape rule on `StoreNextTarget.pc`. One literal shape,
48
+ * allocated by `pcOf` on first use. */
49
+ export interface PatchChannel {
50
+ /** Slot-patch hooks for shallow arrays — the reconcile walk emits
51
+ * (i, next, prev) for key-aligned value-replaced slots through the patch
52
+ * apply queue (records are raw, no per-record targets exist).
53
+ * MULTI-CONSUMER (external audit): one array can drive several lists. */
54
+ sp: {
55
+ fn: (index: number, next: any, prev: any) => void;
56
+ owner: Owner | null;
57
+ }[] | null;
58
+ /** Patch-channel consumers (next/patch.ts): per-record compiled patch
59
+ * entries, multi-consumer. null when unpatched (the common case). */
60
+ p: object[] | null;
61
+ /** Same-batch coalescing stamp (re-audit 2/3): the container array this
62
+ * channel last pushed a non-forced SELF entry into, plus that entry. A
63
+ * later same-batch emission UPDATES the queued entry's `next` in place
64
+ * (latest state wins — adoption REPLACES the captured object, so dropping
65
+ * the later emission would apply stale state) while `prev` stays the
66
+ * batch's earliest. The drain clears both stamps so a quiet record
67
+ * retains nothing from its last batch. */
68
+ qa: unknown;
69
+ qe: unknown;
70
+ /** Row-ops consumers (next/patch.ts, PR-B): structural list ops —
71
+ * (nextRows, { prefix, sources, removed }) at apply timing. */
72
+ ro: object[] | null;
73
+ /** Keys written through the traps since the last fold commit. Bounds the
74
+ * setter notify/hold-check to O(written) instead of O(subscribed nodes) —
75
+ * a record with thousands of per-key subscriptions (selection maps) would
76
+ * otherwise pay a full node scan on every write. null = no trap writes
77
+ * this batch (bulk paths fall back to the full scan). */
78
+ wk: Set<PropertyKey> | null;
79
+ }
35
80
  export interface StoreNextTarget {
36
81
  /** Committed backing: source object (shared) or owned clone. */
37
82
  v: Record<PropertyKey, any>;
@@ -47,6 +92,15 @@ export interface StoreNextTarget {
47
92
  h: Record<PropertyKey, Signal<boolean>> | null;
48
93
  /** Lazy key-set node: membership/iteration/$TRACK subscriptions (§6). */
49
94
  k: Signal<number> | null;
95
+ /** Patch-channel extension (lazily allocated on first use): groups the
96
+ * write-side stage-2 fields so they never widen the TARGET's own named
97
+ * field count. LOAD-BEARING SHAPE RULE: array proxy targets carry their
98
+ * fields as named properties on a real array, and V8 normalizes an array
99
+ * to dictionary properties as the named count grows (empirically at
100
+ * counts ≡ 0 mod 3 from 18 up on V8 13.x) — every trap field read then
101
+ * becomes a hash lookup (~15% uibench, tree suites worst). New
102
+ * patch-channel state MUST go inside this object, not on the target. */
103
+ pc: PatchChannel | null;
50
104
  /** Lazy deep-witness node: `deep()` subscribes ONE node per record instead
51
105
  * of one per path; write paths bump it only when it exists. Separate from
52
106
  * `k` so $TRACK/mapArray never rerun on leaf value changes (R9). */
@@ -79,17 +133,21 @@ export interface StoreNextTarget {
79
133
  /** Keys deleted in the overlay window (a prototype overlay cannot shadow
80
134
  * a delete); null when none. */
81
135
  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
136
  /** Projection family, null for plain stores (§7b). */
90
137
  fam: StoreNextFamily | null;
91
138
  /** Shallow store root (values served raw). */
92
139
  s: boolean;
140
+ /** Held committed view (#3074/#3075): the pre-hold committed backing,
141
+ * served to committed-visibility readers while `ht` is live. Adoption is
142
+ * eager by contract, but a projection recompute deriving from uncommitted
143
+ * inputs (a transition-held source, or a latest()-pull ahead of the flush)
144
+ * swaps the backing SPECULATIVELY — the old view must stay servable until
145
+ * the hold resolves. */
146
+ hv: Record<PropertyKey, any> | null;
147
+ /** The holder for `hv`: a live transition (cleared lazily when it is done)
148
+ * or the PLAIN_HOLD sentinel (a latest()-pull staging — cleared by the
149
+ * fold commit). null = no hold. */
150
+ ht: any;
93
151
  }
94
152
  /**
95
153
  * Ownership (first cut, decision 2026-08-16d): one WeakSet of store-owned
@@ -112,6 +170,13 @@ export interface OptStoreHooks {
112
170
  notifyOptimisticWrites(t: any, pb: Record<PropertyKey, any>): void;
113
171
  optimisticView(t: any, src: Record<PropertyKey, any>): Record<PropertyKey, any>;
114
172
  applyTentative(t: any, incoming: any, keyFn: ((item: any) => any) | null): void;
173
+ /** #3164 fold: does this live transaction still retain optimism (armed
174
+ * nodes or tracked stores)? Backs the held-truth masks in next/store.ts so
175
+ * plain-store bundles don't carry the transition-optimism probe. */
176
+ retainsOptimism(t: any): boolean;
115
177
  }
116
178
  export declare let optHooks: OptStoreHooks | null;
117
179
  export declare function setOptHooks(h: OptStoreHooks): void;
180
+ /** Sticky descendants flag walk (§6d): reconcile's keyed pruning descends
181
+ * only where subscriptions exist at/below. Nodes AND patches count. */
182
+ export declare function markDescendants(target: StoreNextTarget): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.0.0-rc.5",
4
4
  "description": "Solid's reactive primitives: signals, memos, effects, stores, and async-aware computations.",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
@@ -66,4 +66,4 @@
66
66
  "vite": "^7.0.0",
67
67
  "vitest": "^4.1.6"
68
68
  }
69
- }
69
+ }