@solidjs/signals 2.0.0-rc.1 → 2.0.0-rc.10

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 (150) hide show
  1. package/dist/dev-shared.js +7138 -0
  2. package/dist/dev.attribution.js +3307 -0
  3. package/dist/dev.js +5691 -4491
  4. package/dist/observe/affects.js +129 -0
  5. package/dist/observe/attribution.js +7 -0
  6. package/dist/observe/boundaries.js +793 -0
  7. package/dist/observe/core/action.js +177 -0
  8. package/dist/observe/core/async.js +849 -0
  9. package/dist/observe/core/attribution-costs.js +66 -0
  10. package/dist/observe/core/attribution-feedback.js +280 -0
  11. package/dist/observe/core/attribution-hooks.js +83 -0
  12. package/dist/observe/core/attribution-queries.js +43 -0
  13. package/dist/observe/core/attribution.js +2904 -0
  14. package/dist/observe/core/constants.js +283 -0
  15. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  16. package/dist/observe/core/core.js +1999 -0
  17. package/dist/observe/core/dev.js +343 -0
  18. package/dist/observe/core/effect.js +200 -0
  19. package/dist/observe/core/error-hooks.js +71 -0
  20. package/dist/observe/core/error.js +80 -0
  21. package/dist/observe/core/external.js +98 -0
  22. package/dist/observe/core/graph.js +155 -0
  23. package/dist/observe/core/heap.js +147 -0
  24. package/dist/observe/core/invariants.js +45 -0
  25. package/dist/observe/core/lanes.js +205 -0
  26. package/dist/observe/core/optimistic.js +627 -0
  27. package/dist/observe/core/owner.js +353 -0
  28. package/dist/observe/core/scheduler.js +1547 -0
  29. package/dist/observe/core/verdict.js +674 -0
  30. package/dist/observe/index.js +59 -0
  31. package/dist/observe/map.js +484 -0
  32. package/dist/observe/signals.js +731 -0
  33. package/dist/observe/store/index.js +44 -0
  34. package/dist/observe/store/next/optimistic.js +717 -0
  35. package/dist/observe/store/next/projection.js +266 -0
  36. package/dist/observe/store/next/reconcile.js +375 -0
  37. package/dist/observe/store/next/store.js +2480 -0
  38. package/dist/observe/store/next/target.js +51 -0
  39. package/dist/observe/store/store.js +331 -0
  40. package/dist/observe/store/storePath.js +103 -0
  41. package/dist/observe/store/utils.js +1070 -0
  42. package/dist/prod/affects.js +10 -9
  43. package/dist/prod/attribution.js +45 -0
  44. package/dist/prod/boundaries.js +388 -178
  45. package/dist/prod/core/action.js +65 -37
  46. package/dist/prod/core/async.js +378 -163
  47. package/dist/prod/core/attribution-hooks.js +3 -0
  48. package/dist/prod/core/constants.js +186 -1
  49. package/dist/prod/core/context.js +10 -16
  50. package/dist/prod/core/core.js +1546 -416
  51. package/dist/prod/core/dev.js +18 -1
  52. package/dist/prod/core/effect.js +119 -79
  53. package/dist/prod/core/error-hooks.js +71 -0
  54. package/dist/prod/core/error.js +13 -1
  55. package/dist/prod/core/external.js +4 -4
  56. package/dist/prod/core/graph.js +105 -54
  57. package/dist/prod/core/heap.js +72 -65
  58. package/dist/prod/core/invariants.js +3 -2
  59. package/dist/prod/core/lanes.js +117 -52
  60. package/dist/prod/core/optimistic.js +458 -104
  61. package/dist/prod/core/owner.js +131 -84
  62. package/dist/prod/core/scheduler.js +998 -241
  63. package/dist/prod/core/verdict.js +417 -112
  64. package/dist/prod/index.js +20 -8
  65. package/dist/prod/map.js +312 -151
  66. package/dist/prod/signals.js +363 -32
  67. package/dist/prod/store/index.js +2 -0
  68. package/dist/prod/store/next/optimistic.js +530 -197
  69. package/dist/prod/store/next/projection.js +142 -57
  70. package/dist/prod/store/next/reconcile.js +149 -103
  71. package/dist/prod/store/next/store.js +1470 -346
  72. package/dist/prod/store/next/target.js +40 -9
  73. package/dist/prod/store/store.js +23 -19
  74. package/dist/prod/store/utils.js +997 -130
  75. package/dist/types/attribution.d.ts +19 -0
  76. package/dist/types/attribution.prod.d.ts +22 -0
  77. package/dist/types/boundaries.d.ts +78 -5
  78. package/dist/types/core/action.d.ts +12 -5
  79. package/dist/types/core/async.d.ts +3 -1
  80. package/dist/types/core/attribution-costs.d.ts +35 -0
  81. package/dist/types/core/attribution-feedback.d.ts +133 -0
  82. package/dist/types/core/attribution-hooks.d.ts +304 -0
  83. package/dist/types/core/attribution-queries.d.ts +24 -0
  84. package/dist/types/core/attribution.d.ts +892 -0
  85. package/dist/types/core/constants.d.ts +179 -0
  86. package/dist/types/core/core.d.ts +299 -25
  87. package/dist/types/core/dev.d.ts +421 -8
  88. package/dist/types/core/effect.d.ts +8 -1
  89. package/dist/types/core/error-hooks.d.ts +71 -0
  90. package/dist/types/core/error.d.ts +9 -0
  91. package/dist/types/core/graph.d.ts +23 -0
  92. package/dist/types/core/heap.d.ts +5 -3
  93. package/dist/types/core/index.d.ts +6 -3
  94. package/dist/types/core/invariants.d.ts +5 -1
  95. package/dist/types/core/lanes.d.ts +51 -19
  96. package/dist/types/core/owner.d.ts +15 -3
  97. package/dist/types/core/scheduler.d.ts +248 -1
  98. package/dist/types/core/types.d.ts +124 -41
  99. package/dist/types/index.d.ts +18 -5
  100. package/dist/types/map.d.ts +2 -0
  101. package/dist/types/signals.d.ts +145 -13
  102. package/dist/types/store/index.d.ts +7 -6
  103. package/dist/types/store/next/optimistic.d.ts +18 -13
  104. package/dist/types/store/next/projection.d.ts +5 -2
  105. package/dist/types/store/next/reconcile.d.ts +7 -0
  106. package/dist/types/store/next/store.d.ts +83 -11
  107. package/dist/types/store/next/target.d.ts +108 -11
  108. package/dist/types/store/store.d.ts +20 -11
  109. package/dist/types/store/utils.d.ts +188 -0
  110. package/package.json +31 -26
  111. package/dist/node.cjs +0 -8137
  112. package/dist/types/store/optimistic.d.ts +0 -45
  113. package/dist/types/store/projection.d.ts +0 -70
  114. package/dist/types/store/reconcile.d.ts +0 -46
  115. package/dist/types-cjs/affects.d.cts +0 -47
  116. package/dist/types-cjs/boundaries.d.cts +0 -175
  117. package/dist/types-cjs/core/action.d.cts +0 -64
  118. package/dist/types-cjs/core/async.d.cts +0 -21
  119. package/dist/types-cjs/core/constants.d.cts +0 -71
  120. package/dist/types-cjs/core/core.d.cts +0 -156
  121. package/dist/types-cjs/core/dev.d.cts +0 -64
  122. package/dist/types-cjs/core/effect.d.cts +0 -30
  123. package/dist/types-cjs/core/error.d.cts +0 -47
  124. package/dist/types-cjs/core/external.d.cts +0 -15
  125. package/dist/types-cjs/core/graph.d.cts +0 -5
  126. package/dist/types-cjs/core/heap.d.cts +0 -22
  127. package/dist/types-cjs/core/index.d.cts +0 -13
  128. package/dist/types-cjs/core/invariants.d.cts +0 -59
  129. package/dist/types-cjs/core/lanes.d.cts +0 -56
  130. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  131. package/dist/types-cjs/core/owner.d.cts +0 -124
  132. package/dist/types-cjs/core/scheduler.d.cts +0 -172
  133. package/dist/types-cjs/core/types.d.cts +0 -148
  134. package/dist/types-cjs/core/verdict.d.cts +0 -2
  135. package/dist/types-cjs/index.d.cts +0 -10
  136. package/dist/types-cjs/map.d.cts +0 -69
  137. package/dist/types-cjs/package.json +0 -3
  138. package/dist/types-cjs/signals.d.cts +0 -624
  139. package/dist/types-cjs/store/index.d.cts +0 -19
  140. package/dist/types-cjs/store/next/optimistic.d.cts +0 -20
  141. package/dist/types-cjs/store/next/projection.d.cts +0 -24
  142. package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
  143. package/dist/types-cjs/store/next/store.d.cts +0 -71
  144. package/dist/types-cjs/store/next/target.d.cts +0 -99
  145. package/dist/types-cjs/store/optimistic.d.cts +0 -45
  146. package/dist/types-cjs/store/projection.d.cts +0 -70
  147. package/dist/types-cjs/store/reconcile.d.cts +0 -46
  148. package/dist/types-cjs/store/store.d.cts +0 -138
  149. package/dist/types-cjs/store/storePath.d.cts +0 -58
  150. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -1,20 +1,51 @@
1
1
  /**
2
- * Ownership (first cut, decision 2026-08-16d): one WeakSet of store-owned
3
- * backings serving both the production identity-skip guard and the false
4
- * no-mutation oracle.
2
+ * Ownership stamp (#3360): every backing the store ALLOCATES (CoW clones,
3
+ * privatized committed backings) carries its owning target under this
4
+ * enumerable symbol. One property write replaces the two weak-collection
5
+ * registrations (ownership set + raw→target map) a fresh object used to pay
6
+ * per draft — V8's identity-hash + ephemeron cost dominated the one-key
7
+ * write floor. Enumerable so a spread copy (the plain-data clone path) stays
8
+ * on the fast path and carries the stamp along.
9
+ *
10
+ * Owned backings are never user-reachable (`snapshot` copies them, the traps
11
+ * hide the key), so every raw key walk in the store must skip `$OWNER`, and
12
+ * ownership is answered by `isOwned` — a user object never carries it.
13
+ * Overlay drafts (`Object.create(v)` over an owned `v`) inherit the stamp.
5
14
  */
6
- const ownedRaw = new WeakSet;
15
+ const $OWNER = Symbol(0);
7
16
 
8
- /** raw → target. The only raw-keyed lookup; boundary mechanism (O8). */ const storeNextLookup = new WeakMap;
17
+ /** raw → target for UNOWNED backings (user-ingested, adopted); owned
18
+ * backings resolve through their `$OWNER` stamp. Boundary mechanism (O8). */ const storeNextLookup = new WeakMap;
9
19
 
10
- function devAssertNeverUserMutation(o) {
20
+ /** A backing the store allocated and may mutate in place. */ function isOwned(e) {
21
+ return e[$OWNER] !== undefined;
22
+ }
23
+
24
+ /** raw → target within a family (`null` = plain stores / the global map).
25
+ * The stamp answers for backings owned by a target OF THAT FAMILY; anything
26
+ * else (user objects, adoptees, another family's backings the family
27
+ * re-registered for its own wrapper) resolves through the family's map. */ function lookupTarget(e, o) {
28
+ const t = e[$OWNER];
29
+ return t !== undefined && t.fam === o ? t : (o?.map ?? storeNextLookup).get(e);
30
+ }
31
+
32
+ function devAssertNeverUserMutation(e) {
11
33
  return;
12
34
  }
13
35
 
14
36
  let optHooks = null;
15
37
 
16
- function setOptHooks(o) {
17
- optHooks = o;
38
+ function setOptHooks(e) {
39
+ optHooks = e;
40
+ }
41
+
42
+ /** Sticky descendants flag walk (§6d): reconcile's keyed pruning descends
43
+ * only where subscriptions exist at/below. Nodes AND patches count. */ function markDescendants(e) {
44
+ let o = e;
45
+ while (o && !o.d) {
46
+ o.d = true;
47
+ o = o.u;
48
+ }
18
49
  }
19
50
 
20
- export { devAssertNeverUserMutation, optHooks, ownedRaw, setOptHooks, storeNextLookup };
51
+ export { $OWNER, devAssertNeverUserMutation, isOwned, lookupTarget, markDescendants, optHooks, setOptHooks, storeNextLookup };
@@ -8,14 +8,20 @@ import "../core/verdict.js";
8
8
 
9
9
  import "../core/effect.js";
10
10
 
11
- import { storeNextLookup } from "./next/target.js";
11
+ import { $OWNER, lookupTarget as lookupTarget$1 } from "./next/target.js";
12
12
 
13
13
  /**
14
14
  * Brand symbols used internally by the store proxy / projection plumbing.
15
15
  * Cross-package wiring; not part of the user-facing API.
16
16
  *
17
17
  * @internal
18
- */ const $TRACK = Symbol(0), $TARGET = Symbol(0), $PROXY = Symbol(0), // Node-map slot carrying a record-level `affects()` mark: any read through
18
+ */ const $TRACK = Symbol(0), $TARGET = Symbol(0), $PROXY = Symbol(0),
19
+ // The view record behind a merge()/omit() proxy (a `MergeView` or an
20
+ // `OmitView`, utils.ts); a store answers `undefined` on its symbol fast
21
+ // path. One read classifies any `$PROXY`-marked object — store, view, or
22
+ // foreign — where asking `$TARGET` first and then each view kind was two
23
+ // to four trap hops (see `viewOf`).
24
+ $RECORD = Symbol(0), // Node-map slot carrying a record-level `affects()` mark: any read through
19
25
  // the record witnesses it into the active isPending() probe.
20
26
  $AFFECTS = Symbol(0);
21
27
 
@@ -24,13 +30,9 @@ $AFFECTS = Symbol(0);
24
30
  const STORE_VALUE = "v", STORE_NODE = "n", STORE_HAS = "h";
25
31
 
26
32
  function lookupTarget(e, t) {
27
- // Family maps (projections/optimistic) map raw -> target; the global next
28
- // lookup maps raw -> target too. Proxies resolve through $TARGET directly.
29
- if (t !== undefined) {
30
- const o = t.get(e);
31
- if (o !== undefined) return o[$TARGET] ?? o;
32
- }
33
- return storeNextLookup.get(e);
33
+ // Family registrations (projections/optimistic) first, then the global
34
+ // next lookup. Proxies resolve through $TARGET directly.
35
+ return (t ? lookupTarget$1(e, t) : undefined) ?? lookupTarget$1(e, null);
34
36
  }
35
37
 
36
38
  // Values marked raw never acquire a proxy identity: wrap() serves them as-is
@@ -138,7 +140,7 @@ function ownEnumerableKeys(e) {
138
140
  */ function inheritAffectsMarks(e, t, o) {
139
141
  // A live scope exists, so affects.ts already installed the mark engine.
140
142
  for (const [r, s] of affectsScopes) {
141
- if (r.t && s.scope.has(t) && (s.key === undefined || s.key === o)) {
143
+ if (r.o?.t && s.scope.has(t) && (s.key === undefined || s.key === o)) {
142
144
  GlobalQueue.M(e);
143
145
  s.inherited.push(e);
144
146
  }
@@ -202,9 +204,9 @@ s) {
202
204
  // scope must mark them like any property node.
203
205
  if (f.k) o.push(f.k);
204
206
  if (f.dk) o.push(f.dk);
205
- // Carry the effective lookup into untouched descendants (family maps for
206
- // projections/optimistic stores; the global next lookup otherwise).
207
- r = f.fam?.map ?? r ?? storeNextLookup;
207
+ // Carry the effective family into untouched descendants (projections/
208
+ // optimistic stores register children under their family).
209
+ r = f.fam ?? r;
208
210
  }
209
211
  // Overlays are gone (next has no layer): raw enumeration; the optimistic
210
212
  // view composition above already folded armed-node membership/values in.
@@ -214,6 +216,7 @@ s) {
214
216
  }
215
217
  const e = Object.getOwnPropertySymbols(n);
216
218
  for (let f = 0, c = e.length; f < c; f++) {
219
+ if (e[f] === $OWNER) continue;
217
220
  const c = Object.getOwnPropertyDescriptor(n, e[f]);
218
221
  if (!c || c.get) continue;
219
222
  walkAffectsScope(c.value, t, o, r, s);
@@ -221,6 +224,7 @@ s) {
221
224
  } else {
222
225
  const e = Reflect.ownKeys(n);
223
226
  for (let f = 0, c = e.length; f < c; f++) {
227
+ if (e[f] === $OWNER) continue;
224
228
  const c = Object.getOwnPropertyDescriptor(n, e[f]);
225
229
  if (!c || c.get) continue;
226
230
  walkAffectsScope(c.value, t, o, r, s);
@@ -252,18 +256,18 @@ s) {
252
256
  // Callers guard on `pendingCheckActive`, which only flips inside
253
257
  // isPending() — the verdict layer is loaded and its hook installed.
254
258
  const o = e[STORE_NODE]?.[$AFFECTS];
255
- if (o?.t) GlobalQueue.Lt(o);
259
+ if (o?.o?.t) GlobalQueue.Et(o);
256
260
  if (affectsScopes.size) {
257
261
  // Chained backings (§7b): a wrapper's STORE_VALUE can be another store's
258
262
  // proxy — marks cover by identity of the BASE raw, so resolve the chain
259
263
  // and check every identity along it.
260
264
  let r = e[STORE_VALUE];
261
265
  for (const [e, s] of affectsScopes) {
262
- if (e !== o && e.t && (s.key === undefined || s.key === t)) {
266
+ if (e !== o && e.o?.t && (s.key === undefined || s.key === t)) {
263
267
  let t = r;
264
268
  for (;;) {
265
269
  if (s.scope.has(t)) {
266
- GlobalQueue.Lt(e);
270
+ GlobalQueue.Et(e);
267
271
  break;
268
272
  }
269
273
  const o = t?.[$TARGET];
@@ -292,7 +296,7 @@ s) {
292
296
  const t = affectsScopes.get(e);
293
297
  if (!t) return;
294
298
  affectsScopes.delete(e);
295
- for (let e = 0; e < t.inherited.length; e++) GlobalQueue.h(t.inherited[e]);
299
+ for (let e = 0; e < t.inherited.length; e++) GlobalQueue.N(t.inherited[e]);
296
300
  };
297
301
  if (t === undefined) {
298
302
  const t = nextAffectsNodeResolver(e, $AFFECTS);
@@ -302,7 +306,7 @@ s) {
302
306
  inherited: []
303
307
  });
304
308
  const r = [ t ];
305
- walkAffectsScope(e[$PROXY], o, r, e.fam?.map, new Set);
309
+ walkAffectsScope(e[$PROXY], o, r, e.fam, new Set);
306
310
  return r;
307
311
  }
308
312
  const o = e.n?.[t] ?? nextAffectsNodeResolver(e, t);
@@ -322,4 +326,4 @@ s) {
322
326
  return [ o ];
323
327
  }
324
328
 
325
- export { $AFFECTS, $PROXY, $TARGET, $TRACK, STORE_HAS, STORE_NODE, STORE_VALUE, affectsScopesLive, getStoreAffectsNodes, getWriteOverride, inheritAffectsMarks, isRawValue, isWrappable, markRawIngest, markRawOne, nextAffectsNodeResolver, nextOptimisticViewResolver, ownEnumerableKeys, rawValuesUsed, setNextAffectsNodeResolver, setNextOptimisticViewResolver, setWriteOverride, witnessAffectsMark };
329
+ export { $AFFECTS, $PROXY, $RECORD, $TARGET, $TRACK, STORE_HAS, STORE_NODE, STORE_VALUE, affectsScopesLive, getStoreAffectsNodes, getWriteOverride, inheritAffectsMarks, isRawValue, isWrappable, markRawIngest, markRawOne, nextAffectsNodeResolver, nextOptimisticViewResolver, ownEnumerableKeys, rawValuesUsed, setNextAffectsNodeResolver, setNextOptimisticViewResolver, setWriteOverride, witnessAffectsMark };