@solidjs/signals 2.0.0-rc.7 → 2.0.0-rc.9

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 (134) hide show
  1. package/dist/dev-shared.js +6357 -0
  2. package/dist/dev.attribution.js +2485 -0
  3. package/dist/dev.js +2851 -7027
  4. package/dist/observe/affects.js +129 -0
  5. package/dist/observe/attribution.js +7 -0
  6. package/dist/observe/boundaries.js +641 -0
  7. package/dist/observe/core/action.js +177 -0
  8. package/dist/observe/core/async.js +846 -0
  9. package/dist/observe/core/attribution-costs.js +66 -0
  10. package/dist/observe/core/attribution-feedback.js +282 -0
  11. package/dist/observe/core/attribution-hooks.js +82 -0
  12. package/dist/observe/core/attribution-queries.js +28 -0
  13. package/dist/observe/core/attribution.js +2095 -0
  14. package/dist/observe/core/constants.js +248 -0
  15. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  16. package/dist/observe/core/core.js +1789 -0
  17. package/dist/observe/core/dev.js +293 -0
  18. package/dist/observe/core/effect.js +195 -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 +585 -0
  27. package/dist/observe/core/owner.js +322 -0
  28. package/dist/observe/core/scheduler.js +1428 -0
  29. package/dist/observe/core/verdict.js +669 -0
  30. package/dist/observe/index.js +59 -0
  31. package/dist/observe/map.js +484 -0
  32. package/dist/{types-cjs/signals.d.cts → observe/signals.js} +311 -317
  33. package/dist/observe/store/index.js +40 -0
  34. package/dist/observe/store/next/optimistic.js +660 -0
  35. package/dist/observe/store/next/projection.js +255 -0
  36. package/dist/observe/store/next/reconcile.js +375 -0
  37. package/dist/observe/store/next/store.js +2327 -0
  38. package/dist/observe/store/next/target.js +51 -0
  39. package/dist/observe/store/store.js +325 -0
  40. package/dist/observe/store/storePath.js +103 -0
  41. package/dist/observe/store/utils.js +1023 -0
  42. package/dist/prod/attribution.js +41 -0
  43. package/dist/prod/boundaries.js +128 -76
  44. package/dist/prod/core/action.js +65 -37
  45. package/dist/prod/core/async.js +324 -172
  46. package/dist/prod/core/constants.js +57 -1
  47. package/dist/prod/core/context.js +3 -3
  48. package/dist/prod/core/core.js +1003 -364
  49. package/dist/prod/core/dev.js +17 -1
  50. package/dist/prod/core/effect.js +76 -42
  51. package/dist/prod/core/error-hooks.js +71 -0
  52. package/dist/prod/core/external.js +4 -4
  53. package/dist/prod/core/graph.js +37 -37
  54. package/dist/prod/core/heap.js +61 -56
  55. package/dist/prod/core/lanes.js +107 -63
  56. package/dist/prod/core/optimistic.js +374 -93
  57. package/dist/prod/core/owner.js +62 -46
  58. package/dist/prod/core/scheduler.js +653 -286
  59. package/dist/prod/core/verdict.js +245 -127
  60. package/dist/prod/index.js +15 -5
  61. package/dist/prod/map.js +292 -141
  62. package/dist/prod/signals.js +29 -16
  63. package/dist/prod/store/next/optimistic.js +77 -55
  64. package/dist/prod/store/next/projection.js +31 -20
  65. package/dist/prod/store/next/reconcile.js +87 -84
  66. package/dist/prod/store/next/store.js +718 -401
  67. package/dist/prod/store/next/target.js +32 -10
  68. package/dist/prod/store/store.js +12 -14
  69. package/dist/prod/store/utils.js +950 -130
  70. package/dist/types/attribution.d.ts +20 -0
  71. package/dist/types/attribution.prod.d.ts +22 -0
  72. package/dist/types/boundaries.d.ts +10 -1
  73. package/dist/types/core/action.d.ts +12 -5
  74. package/dist/types/core/async.d.ts +1 -1
  75. package/dist/types/core/attribution-costs.d.ts +35 -0
  76. package/dist/types/core/attribution-feedback.d.ts +133 -0
  77. package/dist/types/core/attribution-hooks.d.ts +147 -9
  78. package/dist/types/core/attribution-queries.d.ts +10 -0
  79. package/dist/types/core/attribution.d.ts +216 -182
  80. package/dist/types/core/constants.d.ts +56 -0
  81. package/dist/types/core/core.d.ts +190 -2
  82. package/dist/types/core/dev.d.ts +246 -28
  83. package/dist/types/core/effect.d.ts +8 -1
  84. package/dist/types/core/error-hooks.d.ts +71 -0
  85. package/dist/types/core/index.d.ts +4 -1
  86. package/dist/types/core/invariants.d.ts +4 -0
  87. package/dist/types/core/lanes.d.ts +39 -5
  88. package/dist/types/core/scheduler.d.ts +153 -0
  89. package/dist/types/core/types.d.ts +32 -9
  90. package/dist/types/index.d.ts +10 -3
  91. package/dist/types/map.d.ts +2 -0
  92. package/dist/types/signals.d.ts +8 -0
  93. package/dist/types/store/index.d.ts +2 -0
  94. package/dist/types/store/next/optimistic.d.ts +1 -1
  95. package/dist/types/store/next/store.d.ts +11 -5
  96. package/dist/types/store/next/target.d.ts +37 -10
  97. package/dist/types/store/utils.d.ts +178 -0
  98. package/package.json +21 -17
  99. package/dist/node.cjs +0 -10541
  100. package/dist/node.dev.cjs +0 -13724
  101. package/dist/types-cjs/affects.d.cts +0 -47
  102. package/dist/types-cjs/boundaries.d.cts +0 -175
  103. package/dist/types-cjs/core/action.d.cts +0 -64
  104. package/dist/types-cjs/core/async.d.cts +0 -23
  105. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -127
  106. package/dist/types-cjs/core/attribution.d.cts +0 -495
  107. package/dist/types-cjs/core/constants.d.cts +0 -159
  108. package/dist/types-cjs/core/core.d.cts +0 -185
  109. package/dist/types-cjs/core/dev.d.cts +0 -136
  110. package/dist/types-cjs/core/effect.d.cts +0 -30
  111. package/dist/types-cjs/core/error.d.cts +0 -56
  112. package/dist/types-cjs/core/external.d.cts +0 -15
  113. package/dist/types-cjs/core/graph.d.cts +0 -28
  114. package/dist/types-cjs/core/heap.d.cts +0 -24
  115. package/dist/types-cjs/core/index.d.cts +0 -13
  116. package/dist/types-cjs/core/invariants.d.cts +0 -59
  117. package/dist/types-cjs/core/lanes.d.cts +0 -54
  118. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  119. package/dist/types-cjs/core/owner.d.cts +0 -124
  120. package/dist/types-cjs/core/scheduler.d.cts +0 -236
  121. package/dist/types-cjs/core/types.d.cts +0 -204
  122. package/dist/types-cjs/core/verdict.d.cts +0 -2
  123. package/dist/types-cjs/index.d.cts +0 -10
  124. package/dist/types-cjs/map.d.cts +0 -69
  125. package/dist/types-cjs/package.json +0 -3
  126. package/dist/types-cjs/store/index.d.cts +0 -18
  127. package/dist/types-cjs/store/next/optimistic.d.cts +0 -25
  128. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  129. package/dist/types-cjs/store/next/reconcile.d.cts +0 -10
  130. package/dist/types-cjs/store/next/store.d.cts +0 -121
  131. package/dist/types-cjs/store/next/target.d.cts +0 -166
  132. package/dist/types-cjs/store/store.d.cts +0 -143
  133. package/dist/types-cjs/store/storePath.d.cts +0 -58
  134. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -1,11 +1,33 @@
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;
19
+
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
+ }
9
31
 
10
32
  function devAssertNeverUserMutation(e) {
11
33
  return;
@@ -19,11 +41,11 @@ function setOptHooks(e) {
19
41
 
20
42
  /** Sticky descendants flag walk (§6d): reconcile's keyed pruning descends
21
43
  * 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;
44
+ let o = e;
45
+ while (o && !o.d) {
46
+ o.d = true;
47
+ o = o.u;
26
48
  }
27
49
  }
28
50
 
29
- export { devAssertNeverUserMutation, markDescendants, optHooks, ownedRaw, setOptHooks, storeNextLookup };
51
+ export { $OWNER, devAssertNeverUserMutation, isOwned, lookupTarget, markDescendants, optHooks, setOptHooks, storeNextLookup };
@@ -8,7 +8,7 @@ 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.
@@ -24,13 +24,9 @@ $AFFECTS = Symbol(0);
24
24
  const STORE_VALUE = "v", STORE_NODE = "n", STORE_HAS = "h";
25
25
 
26
26
  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);
27
+ // Family registrations (projections/optimistic) first, then the global
28
+ // next lookup. Proxies resolve through $TARGET directly.
29
+ return (t ? lookupTarget$1(e, t) : undefined) ?? lookupTarget$1(e, null);
34
30
  }
35
31
 
36
32
  // Values marked raw never acquire a proxy identity: wrap() serves them as-is
@@ -202,9 +198,9 @@ s) {
202
198
  // scope must mark them like any property node.
203
199
  if (f.k) o.push(f.k);
204
200
  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;
201
+ // Carry the effective family into untouched descendants (projections/
202
+ // optimistic stores register children under their family).
203
+ r = f.fam ?? r;
208
204
  }
209
205
  // Overlays are gone (next has no layer): raw enumeration; the optimistic
210
206
  // view composition above already folded armed-node membership/values in.
@@ -214,6 +210,7 @@ s) {
214
210
  }
215
211
  const e = Object.getOwnPropertySymbols(n);
216
212
  for (let f = 0, c = e.length; f < c; f++) {
213
+ if (e[f] === $OWNER) continue;
217
214
  const c = Object.getOwnPropertyDescriptor(n, e[f]);
218
215
  if (!c || c.get) continue;
219
216
  walkAffectsScope(c.value, t, o, r, s);
@@ -221,6 +218,7 @@ s) {
221
218
  } else {
222
219
  const e = Reflect.ownKeys(n);
223
220
  for (let f = 0, c = e.length; f < c; f++) {
221
+ if (e[f] === $OWNER) continue;
224
222
  const c = Object.getOwnPropertyDescriptor(n, e[f]);
225
223
  if (!c || c.get) continue;
226
224
  walkAffectsScope(c.value, t, o, r, s);
@@ -252,7 +250,7 @@ s) {
252
250
  // Callers guard on `pendingCheckActive`, which only flips inside
253
251
  // isPending() — the verdict layer is loaded and its hook installed.
254
252
  const o = e[STORE_NODE]?.[$AFFECTS];
255
- if (o?.o?.t) GlobalQueue.zt(o);
253
+ if (o?.o?.t) GlobalQueue.pn(o);
256
254
  if (affectsScopes.size) {
257
255
  // Chained backings (§7b): a wrapper's STORE_VALUE can be another store's
258
256
  // proxy — marks cover by identity of the BASE raw, so resolve the chain
@@ -263,7 +261,7 @@ s) {
263
261
  let t = r;
264
262
  for (;;) {
265
263
  if (s.scope.has(t)) {
266
- GlobalQueue.zt(e);
264
+ GlobalQueue.pn(e);
267
265
  break;
268
266
  }
269
267
  const o = t?.[$TARGET];
@@ -302,7 +300,7 @@ s) {
302
300
  inherited: []
303
301
  });
304
302
  const r = [ t ];
305
- walkAffectsScope(e[$PROXY], o, r, e.fam?.map, new Set);
303
+ walkAffectsScope(e[$PROXY], o, r, e.fam, new Set);
306
304
  return r;
307
305
  }
308
306
  const o = e.n?.[t] ?? nextAffectsNodeResolver(e, t);