@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,212 @@
1
+ import { runWithOwner, untrack, computed } from "./core/core.js";
2
+
3
+ import { createOwner, cleanup } from "./core/owner.js";
4
+
5
+ import { REVEAL, ready, redraw, setRevealHooks } from "./boundaries.js";
6
+
7
+ /**
8
+ * Reveal order — `createRevealOrder` (`<Reveal>`): the order in which a group
9
+ * of Loading boundaries (its direct slots) may show their content.
10
+ *
11
+ * A controller owns each slot until the slot has shown content, and forces
12
+ * on the slots it owns the state the order dictates: gated (the fallback,
13
+ * whatever the content's state) and, in a collapsed sequential tail, nothing
14
+ * at all. A nested reveal order is a composite slot of its parent — gated,
15
+ * it gates all of its own; released, it runs its own order.
16
+ *
17
+ * - `sequential`: slots reveal front to back. The first unready slot is the
18
+ * frontier — its fallback shows; the slots behind it are gated (collapsed
19
+ * when `collapsed`); the ones before it have revealed.
20
+ * - `together`: every owned slot is gated until all are minimally ready;
21
+ * then all are released at once.
22
+ * - `natural`: each slot reveals on its own as it becomes ready.
23
+ *
24
+ * A slot graduates when it shows content: a later re-arm of it gates nobody
25
+ * else, and slots appended after graduation form a fresh frontier. The
26
+ * boundary tells the controller when its readiness changed (boundaries.ts:
27
+ * caught, settled, shown, disposed); `order`/`collapsed` are tracked by a
28
+ * computed of the group's own.
29
+ */ const FALSE_ACCESSOR = () => false;
30
+
31
+ const SEQUENTIAL_ACCESSOR = () => "sequential";
32
+
33
+ const isController = t => t instanceof RevealController;
34
+
35
+ const slotReady = t => isController(t) ? t.Rt() : ready(t);
36
+
37
+ const slotMinReady = t => isController(t) ? t.Ct() : ready(t);
38
+
39
+ /** Force a slot's state. A boundary re-derives its output when it changes;
40
+ * a nested controller passes the state on to its own slots. Released
41
+ * (`!gated`), a nested controller leaves its parent's ownership and runs its
42
+ * own order; a boundary leaves when it has shown content (boundaries.ts). */ function setSlotState(t, e, s, r) {
43
+ if (isController(t)) {
44
+ t.ne = s;
45
+ t.re = r;
46
+ t.vt();
47
+ // Released and ready — every slot of its own has shown — it graduates,
48
+ // as a boundary does when it shows content. Released at the frontier
49
+ // but not ready, it stays the parent's frontier.
50
+ if (!s && t.Lt && t._parent === e) t._parent = null;
51
+ return;
52
+ }
53
+ if (t.ne !== s || t.re !== r) {
54
+ t.ne = s;
55
+ t.re = r;
56
+ redraw(t);
57
+ }
58
+ }
59
+
60
+ class RevealController {
61
+ qt;
62
+ Vt;
63
+ Ft=[];
64
+ /** The controller gating this one, until it releases this one. */
65
+ _parent=null;
66
+ /** The state a parent forces on this whole group. */
67
+ ne=false;
68
+ re=false;
69
+ Lt=true;
70
+ Qt=true;
71
+ Tt=false;
72
+ constructor(t, e) {
73
+ this.qt = t;
74
+ this.Vt = e;
75
+ }
76
+ /** A slot that has left this controller's ownership: a boundary that has
77
+ * shown content, a nested group that is ready. Shown is shown — it counts
78
+ * as ready whatever happens to it later (a re-arm gates nobody else). */ Ut(t) {
79
+ return (isController(t) ? t._parent : t.H) !== this;
80
+ }
81
+ /** The slots this controller still owns, in registration order — the
82
+ * ones the order's state is forced on. */ Wt(t) {
83
+ for (let e = 0; e < this.Ft.length; e++) {
84
+ const s = this.Ft[e];
85
+ if (!this.Ut(s) && t(s) === false) return false;
86
+ }
87
+ return true;
88
+ }
89
+ /** Readiness is judged over every slot, done ones as ready. */ Rt() {
90
+ for (let t = 0; t < this.Ft.length; t++) {
91
+ const e = this.Ft[t];
92
+ if (!this.Ut(e) && !slotReady(e)) return false;
93
+ }
94
+ return true;
95
+ }
96
+ /** Something visible to show under its own order — what an enclosing
97
+ * `together` waits for: `together` — every slot minimally ready;
98
+ * `sequential` — the first slot; `natural` — any. */ Ct() {
99
+ const t = untrack(this.qt);
100
+ const e = this.Ft;
101
+ if (e.length === 0) return true;
102
+ if (t === "sequential") return this.Ut(e[0]) || slotMinReady(e[0]);
103
+ for (let s = 0; s < e.length; s++) {
104
+ const r = this.Ut(e[s]) || slotMinReady(e[s]);
105
+ if (t === "natural" ? r : !r) return t === "natural";
106
+ }
107
+ return t !== "natural";
108
+ }
109
+ ue(t) {
110
+ if (this.Ft.includes(t)) return;
111
+ this.Ft.push(t);
112
+ // Gated from the start (collapsed in a collapsed sequential tail); the
113
+ // evaluation releases what the order allows.
114
+ const e = untrack(this.qt) === "sequential" && !!untrack(this.Vt);
115
+ if (isController(t)) {
116
+ t._parent = this;
117
+ t.ne = true;
118
+ t.re = e;
119
+ t.vt();
120
+ } else {
121
+ t.H = this;
122
+ t.ne = true;
123
+ t.re = e;
124
+ }
125
+ untrack(() => this.vt());
126
+ }
127
+ oe(t) {
128
+ const e = this.Ft.indexOf(t);
129
+ if (e >= 0) this.Ft.splice(e, 1);
130
+ untrack(() => this.vt());
131
+ }
132
+ /** Apply the order to the owned slots — or, gated by a parent, its state
133
+ * to all of them. */ vt() {
134
+ if (this.Tt) return;
135
+ this.Tt = true;
136
+ const t = this.Lt;
137
+ const e = this.Qt;
138
+ try {
139
+ const t = untrack(this.qt);
140
+ const e = t === "sequential" && !!untrack(this.Vt);
141
+ if (this.ne) {
142
+ this.Wt(t => setSlotState(t, this, true, this.re));
143
+ } else if (t === "natural") {
144
+ this.Wt(t => {
145
+ if (isController(t)) setSlotState(t, this, false, false); else setSlotState(t, this, !ready(t), false);
146
+ });
147
+ } else if (t === "together") {
148
+ const t = this.Wt(slotMinReady);
149
+ this.Wt(e => setSlotState(e, this, !t, false));
150
+ } else {
151
+ let t = false;
152
+ this.Wt(s => {
153
+ if (t) return setSlotState(s, this, true, e);
154
+ if (slotReady(s)) return setSlotState(s, this, false, false);
155
+ t = true;
156
+ // The frontier: its fallback shows; a nested controller at the
157
+ // frontier runs its own order.
158
+ setSlotState(s, this, isController(s) ? false : true, false);
159
+ });
160
+ }
161
+ } finally {
162
+ this.Lt = this.Rt();
163
+ this.Qt = this.Ct();
164
+ this.Tt = false;
165
+ }
166
+ if (this._parent !== null && (t !== this.Lt || e !== this.Qt)) this._parent.vt();
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Lower-level primitive behind `<Reveal>`: coordinates the order in which the
172
+ * Loading boundaries created directly inside `fn` reveal their content.
173
+ *
174
+ * @param fn the subtree; the Loading boundaries it creates directly are the
175
+ * group's slots, a nested `createRevealOrder` a composite slot
176
+ * @param options `order` — `"sequential"` (default: front to back, the
177
+ * first unready slot showing its fallback), `"together"` (all at once),
178
+ * `"natural"` (each on its own); `collapsed` — in a sequential group, the
179
+ * slots behind the frontier render nothing instead of their fallbacks
180
+ */ function createRevealOrder(t, e) {
181
+ const s = createOwner();
182
+ const r = s.D[REVEAL];
183
+ const i = new RevealController(e?.order || SEQUENTIAL_ACCESSOR, e?.collapsed || FALSE_ACCESSOR);
184
+ s.D = {
185
+ ...s.D,
186
+ [REVEAL]: i
187
+ };
188
+ return runWithOwner(s, () => {
189
+ const e = t();
190
+ const s = computed(() => {
191
+ i.qt();
192
+ i.Vt();
193
+ i.vt();
194
+ });
195
+ if (false) ;
196
+ if (r) {
197
+ r.ue(i);
198
+ cleanup(() => r.oe(i));
199
+ }
200
+ return e;
201
+ });
202
+ }
203
+
204
+ // Installed at module evaluation — present exactly when something imports
205
+ // `createRevealOrder`; a Loading boundary without one pays a null check.
206
+ setRevealHooks({
207
+ ue: (t, e) => t.ue(e),
208
+ oe: (t, e) => t.oe(e),
209
+ P: t => t.vt()
210
+ });
211
+
212
+ export { createRevealOrder };