@solidjs/signals 2.0.0-rc.13 → 2.0.0-rc.15

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 (121) hide show
  1. package/dist/dev-shared.js +2059 -3768
  2. package/dist/dev.attribution.js +237 -101
  3. package/dist/dev.js +7466 -8497
  4. package/dist/observe/affects.js +128 -104
  5. package/dist/observe/boundaries.js +492 -665
  6. package/dist/observe/core/action.js +63 -66
  7. package/dist/observe/core/async.js +243 -379
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +394 -253
  10. package/dist/observe/core/constants.js +120 -187
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +874 -1440
  13. package/dist/observe/core/dev.js +3 -3
  14. package/dist/observe/core/effect.js +73 -84
  15. package/dist/observe/core/external.js +5 -5
  16. package/dist/observe/core/graph.js +62 -71
  17. package/dist/observe/core/heap.js +75 -98
  18. package/dist/observe/core/invariants.js +1 -34
  19. package/dist/observe/core/lanes.js +750 -181
  20. package/dist/observe/core/owner.js +80 -101
  21. package/dist/observe/core/scheduler.js +719 -1356
  22. package/dist/observe/core/verdict.js +314 -621
  23. package/dist/observe/flatten.js +79 -0
  24. package/dist/observe/index.js +15 -13
  25. package/dist/observe/map.js +232 -235
  26. package/dist/observe/reveal.js +212 -0
  27. package/dist/observe/signals.js +144 -216
  28. package/dist/observe/store/affects.js +142 -0
  29. package/dist/observe/store/hooks.js +13 -0
  30. package/dist/observe/store/index.js +27 -24
  31. package/dist/observe/store/optimistic.js +571 -0
  32. package/dist/observe/store/projection.js +308 -0
  33. package/dist/observe/store/reconcile.js +259 -0
  34. package/dist/observe/store/store.js +1988 -277
  35. package/dist/observe/store/storePath.js +1 -1
  36. package/dist/{prod/store/next → observe/store}/target.js +17 -18
  37. package/dist/observe/store/types.js +73 -0
  38. package/dist/observe/store/utils.js +1 -13
  39. package/dist/prod/affects.js +130 -106
  40. package/dist/prod/boundaries.js +476 -654
  41. package/dist/prod/core/action.js +71 -74
  42. package/dist/prod/core/async.js +306 -444
  43. package/dist/prod/core/constants.js +117 -186
  44. package/dist/prod/core/context.js +3 -3
  45. package/dist/prod/core/core.js +888 -1462
  46. package/dist/prod/core/effect.js +88 -99
  47. package/dist/prod/core/external.js +5 -5
  48. package/dist/prod/core/graph.js +62 -71
  49. package/dist/prod/core/heap.js +75 -98
  50. package/dist/prod/core/invariants.js +1 -32
  51. package/dist/prod/core/lanes.js +712 -181
  52. package/dist/prod/core/owner.js +75 -96
  53. package/dist/prod/core/scheduler.js +686 -1335
  54. package/dist/prod/core/verdict.js +309 -621
  55. package/dist/prod/flatten.js +77 -0
  56. package/dist/prod/index.js +15 -13
  57. package/dist/prod/map.js +142 -145
  58. package/dist/prod/reveal.js +212 -0
  59. package/dist/prod/signals.js +155 -227
  60. package/dist/prod/store/affects.js +142 -0
  61. package/dist/prod/store/hooks.js +13 -0
  62. package/dist/prod/store/index.js +26 -19
  63. package/dist/prod/store/optimistic.js +566 -0
  64. package/dist/prod/store/projection.js +301 -0
  65. package/dist/prod/store/reconcile.js +259 -0
  66. package/dist/prod/store/store.js +1883 -272
  67. package/dist/prod/store/storePath.js +1 -1
  68. package/dist/{observe/store/next → prod/store}/target.js +13 -17
  69. package/dist/prod/store/types.js +73 -0
  70. package/dist/prod/store/utils.js +1 -11
  71. package/dist/types/affects.d.ts +11 -30
  72. package/dist/types/boundaries.d.ts +66 -176
  73. package/dist/types/carved.d.ts +1 -0
  74. package/dist/types/core/action.d.ts +5 -6
  75. package/dist/types/core/async.d.ts +10 -5
  76. package/dist/types/core/attribution-hooks.d.ts +20 -1
  77. package/dist/types/core/attribution.d.ts +26 -11
  78. package/dist/types/core/constants.d.ts +130 -180
  79. package/dist/types/core/core.d.ts +134 -264
  80. package/dist/types/core/dev.d.ts +2 -2
  81. package/dist/types/core/effect.d.ts +0 -7
  82. package/dist/types/core/graph.d.ts +7 -1
  83. package/dist/types/core/heap.d.ts +5 -7
  84. package/dist/types/core/index.d.ts +5 -5
  85. package/dist/types/core/invariants.d.ts +0 -29
  86. package/dist/types/core/lanes.d.ts +74 -86
  87. package/dist/types/core/owner.d.ts +3 -3
  88. package/dist/types/core/scheduler.d.ts +255 -331
  89. package/dist/types/core/types.d.ts +45 -85
  90. package/dist/types/core/verdict.d.ts +3 -0
  91. package/dist/types/flatten.d.ts +8 -0
  92. package/dist/types/index.d.ts +6 -4
  93. package/dist/types/reveal.d.ts +19 -0
  94. package/dist/types/signals.d.ts +35 -91
  95. package/dist/types/store/affects.d.ts +12 -0
  96. package/dist/types/store/hooks.d.ts +48 -0
  97. package/dist/types/store/index.d.ts +34 -15
  98. package/dist/types/store/optimistic.d.ts +23 -0
  99. package/dist/types/store/projection.d.ts +18 -0
  100. package/dist/types/store/reconcile.d.ts +3 -0
  101. package/dist/types/store/store.d.ts +132 -145
  102. package/dist/types/store/storePath.d.ts +1 -1
  103. package/dist/types/store/target.d.ts +151 -0
  104. package/dist/types/store/types.d.ts +84 -0
  105. package/package.json +1 -1
  106. package/dist/observe/core/optimistic.js +0 -669
  107. package/dist/observe/store/next/optimistic.js +0 -717
  108. package/dist/observe/store/next/projection.js +0 -266
  109. package/dist/observe/store/next/reconcile.js +0 -375
  110. package/dist/observe/store/next/store.js +0 -2608
  111. package/dist/prod/core/optimistic.js +0 -658
  112. package/dist/prod/store/next/optimistic.js +0 -710
  113. package/dist/prod/store/next/projection.js +0 -257
  114. package/dist/prod/store/next/reconcile.js +0 -373
  115. package/dist/prod/store/next/store.js +0 -2484
  116. package/dist/types/core/optimistic.d.ts +0 -6
  117. package/dist/types/store/next/optimistic.d.ts +0 -25
  118. package/dist/types/store/next/projection.d.ts +0 -27
  119. package/dist/types/store/next/reconcile.d.ts +0 -10
  120. package/dist/types/store/next/store.d.ts +0 -145
  121. package/dist/types/store/next/target.d.ts +0 -196
@@ -0,0 +1,142 @@
1
+ import { GlobalQueue } from "../core/scheduler.js";
2
+
3
+ import { optHooks, installAffectsHooks } from "./hooks.js";
4
+
5
+ import { lookupTarget, $OWNER } from "./target.js";
6
+
7
+ import { $TARGET } from "./types.js";
8
+
9
+ /**
10
+ * Store — the store half of `affects()` (plan sec. 29, plan sec. 37; A24 (4), #2882,
11
+ * #2893, #2904).
12
+ *
13
+ * A mark on a store is a mark on nodes (affects.ts: a count on the node, a
14
+ * dependency walk at probe time): `affects(record, key)` marks the slot's
15
+ * leaf; `affects(record)` marks a carrier (the record's `$AFFECTS` leaf)
16
+ * and every live node in the record's subtree — the edges existing readers
17
+ * subscribed through. Coverage is by RAW IDENTITY, not read path (#2882: a
18
+ * captured row proxy, a derived store sharing the source's raw, never read
19
+ * through the declaration's proxy): the identities reachable at the
20
+ * declaration are the mark's `scope`, so a node born inside the window on
21
+ * a covered record inherits the mark (released with the carrier's last),
22
+ * and an untracked probe through a record with no nodes is witnessed into
23
+ * the verdict. A mark declared on a draft (inside a setter) or over an
24
+ * optimistic family walks the view the writer sees.
25
+ *
26
+ * Imported by `affects()`, which installs it on its first store target
27
+ * (#3891, after #3912): a program with stores that never declares a mark
28
+ * carries none of it. It never imports store.ts — the engine's top level —
29
+ * so a program declaring marks without stores carries this module alone:
30
+ * the store's nodes and its wrappability test come through `GlobalQueue`
31
+ * (`_storeNode`, `_storeWrappable`), and node birth and the untracked traps
32
+ * reach back through `affectsHooks` (hooks.ts).
33
+ */
34
+ /** The keyless mark's carrier key: a leaf of the record no read serves. */ const $AFFECTS = Symbol(0);
35
+
36
+ const scopes = new Map;
37
+
38
+ function scopeOf(e, o) {
39
+ let n = scopes.get(e);
40
+ if (n === undefined) scopes.set(e, n = {
41
+ eo: new Set,
42
+ oo: [],
43
+ ot: o
44
+ });
45
+ return n;
46
+ }
47
+
48
+ /** The nodes an `affects(store[, key])` declaration marks (affects.ts
49
+ * registers each). */ function storeMarks(e, o) {
50
+ const n = GlobalQueue.no(e, o === undefined ? $AFFECTS : o);
51
+ const t = scopeOf(n, o);
52
+ if (o === undefined) {
53
+ const o = [ n ];
54
+ walk(e.px, t, o, e.fam, new Set);
55
+ return o;
56
+ }
57
+ t.eo.add(e.v);
58
+ if (e.pb !== null) t.eo.add(e.pb);
59
+ return [ n ];
60
+ }
61
+
62
+ /** The identities reachable from `value` into the scope (the draft's and
63
+ * the committed backing both, when a draft is open; an optimistic family's
64
+ * view), every live node under each record into `found`. Untracked by
65
+ * construction: raws, never traps. */ function walk(e, o, n, t, s) {
66
+ if (!GlobalQueue.so(e)) return;
67
+ const f = e[$TARGET] ?? lookupTarget(e, t);
68
+ let r = f !== undefined ? f.pb ?? f.v : e;
69
+ if (s.has(r)) return;
70
+ s.add(r);
71
+ o.eo.add(r);
72
+ if (f !== undefined) {
73
+ if (f.pb !== null) o.eo.add(f.v);
74
+ // The writer's view: the tick's own unflushed guesses are in motion too.
75
+ if (f.fam?.opt === true) r = optHooks.view(f, r, true);
76
+ const e = f.n;
77
+ if (e !== null) for (const o of Reflect.ownKeys(e))
78
+ // Another mark's carrier is its own channel: counting it here would
79
+ // extend that scope's lifetime to this declaration's.
80
+ if (o !== $AFFECTS) n.push(e[o]);
81
+ const s = f.h;
82
+ if (s !== null) for (const e of Reflect.ownKeys(s)) n.push(s[e]);
83
+ if (f.k !== null) n.push(f.k);
84
+ if (f.dk !== null) n.push(f.dk);
85
+ t = f.fam ?? t;
86
+ }
87
+ for (const e of Reflect.ownKeys(r)) if (e !== $OWNER) {
88
+ const f = Object.getOwnPropertyDescriptor(r, e);
89
+ if (f.get === undefined) walk(f.value, o, n, t, s);
90
+ }
91
+ }
92
+
93
+ /** A live scope covering `t`'s identity (keyed: for `key`). Chained
94
+ * backings (§7b): a view's backing is another store's proxy — marks cover
95
+ * the BASE raw, so every identity along the chain is checked. */ function covering(e, o, n) {
96
+ for (const [t, s] of scopes) {
97
+ if (t === n || s.ot !== undefined && s.ot !== o) continue;
98
+ for (let o = e.v; ;) {
99
+ if (s.eo.has(o)) return t;
100
+ const e = o?.[$TARGET];
101
+ if (e === undefined) break;
102
+ const n = e.pb ?? e.v;
103
+ if (n === o) break;
104
+ o = n;
105
+ }
106
+ }
107
+ return null;
108
+ }
109
+
110
+ /** The store's side: node birth and the untracked traps call it (store.ts,
111
+ * through `affectsHooks`) — with no live mark too: an empty scope map is
112
+ * no work. */ const hooks = {
113
+ // A node born on a record a live mark covers inherits it (released with
114
+ // the carrier's last registration).
115
+ fo(e, o, n) {
116
+ if (scopes.size === 0 || n === $AFFECTS) return;
117
+ const t = covering(e, n, o);
118
+ if (!t) return;
119
+ GlobalQueue.O(o);
120
+ scopes.get(t).oo.push(o);
121
+ },
122
+ // An untracked probe (`isPending(() => s.x)` with no observer) reading a
123
+ // record a live mark covers: no node carries the mark for it — the
124
+ // verdict is told directly.
125
+ ro(e, o) {
126
+ if (e.n?.[$AFFECTS]?.m?.T || covering(e, o)) GlobalQueue.ct();
127
+ }
128
+ };
129
+
130
+ /** `affects()` calls it before a store-targeted declaration (idempotent). */ function installStoreAffects() {
131
+ installAffectsHooks(hooks);
132
+ }
133
+
134
+ /** The carrier's last mark released (affects.ts): its scope dies, and the
135
+ * nodes that inherited the mark release theirs. */ function releaseMarkScope(e) {
136
+ const o = scopes.get(e);
137
+ if (o === undefined) return;
138
+ scopes.delete(e);
139
+ GlobalQueue.k(o.oo);
140
+ }
141
+
142
+ export { installStoreAffects, releaseMarkScope, storeMarks };
@@ -0,0 +1,13 @@
1
+ let optHooks = null;
2
+
3
+ function installOptHooks(o) {
4
+ optHooks = o;
5
+ }
6
+
7
+ let affectsHooks = null;
8
+
9
+ function installAffectsHooks(o) {
10
+ affectsHooks = o;
11
+ }
12
+
13
+ export { affectsHooks, installAffectsHooks, installOptHooks, optHooks };
@@ -1,38 +1,45 @@
1
- import "../core/core.js";
1
+ import { createStore as createStore$1, deep as deep$1, snapshot as snapshot$1 } from "./store.js";
2
2
 
3
- import "../core/scheduler.js";
3
+ export { storeHasFamily, storeHasOptimisticFamily, storeIsShallow } from "./store.js";
4
4
 
5
- import "../core/invariants.js";
5
+ export { createOptimisticStore } from "./optimistic.js";
6
6
 
7
- import "../core/verdict.js";
7
+ import { createStoreDerived } from "./projection.js";
8
8
 
9
- import "../core/effect.js";
9
+ export { createProjection } from "./projection.js";
10
10
 
11
- import { createStoreNext, deepNext, snapshotNext } from "./next/store.js";
11
+ import { reconcileState } from "./reconcile.js";
12
12
 
13
- export { storeHasFamily, storeHasOptimisticFamily, storeIsShallow } from "./next/store.js";
13
+ import "../core/verdict.js";
14
14
 
15
- import { reconcileNextState } from "./next/reconcile.js";
15
+ import "../core/core.js";
16
+
17
+ import "../core/scheduler.js";
16
18
 
17
- import { createStoreDerivedNext } from "./next/projection.js";
19
+ import "../core/effect.js";
18
20
 
19
- export { createProjectionNext as createProjection } from "./next/projection.js";
21
+ import "../core/lanes.js";
20
22
 
21
- function createStore(e, t, r) {
22
- if (typeof e === "function") return createStoreDerivedNext(e, t, r);
23
- return createStoreNext(e, !!t?.shallow);
23
+ function createStore(e, r, t) {
24
+ if (typeof e === "function") return createStoreDerived(e, r, t);
25
+ return createStore$1(e, r);
24
26
  }
25
27
 
26
- function reconcile(e, t = "id") {
27
- return r => reconcileNextState(e, r, t);
28
+ /**
29
+ * A setter transform that reconciles `value` into the store by key
30
+ * (`"id"` by default; `null` positional), preserving store identity for
31
+ * surviving rows.
32
+ */ function reconcile(e, r = "id") {
33
+ return t => reconcileState(e, t, r);
28
34
  }
29
35
 
30
- function snapshot(e) {
31
- return snapshotNext(e);
36
+ /** Non-tracking snapshot of a store's current value (source identity for
37
+ * unmodified subtrees). */ function snapshot(e) {
38
+ return snapshot$1(e);
32
39
  }
33
40
 
34
- function deep(e) {
35
- return deepNext(e);
41
+ /** Tracking snapshot: subscribes to every reachable record. */ function deep(e) {
42
+ return deep$1(e);
36
43
  }
37
44
 
38
45
  export { createStore, deep, reconcile, snapshot };