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

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 (118) hide show
  1. package/dist/dev-shared.js +2000 -3768
  2. package/dist/dev.attribution.js +132 -79
  3. package/dist/dev.js +7226 -8488
  4. package/dist/observe/affects.js +125 -104
  5. package/dist/observe/boundaries.js +458 -665
  6. package/dist/observe/core/action.js +63 -66
  7. package/dist/observe/core/async.js +240 -383
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +240 -183
  10. package/dist/observe/core/constants.js +115 -187
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +840 -1438
  13. package/dist/observe/core/dev.js +3 -3
  14. package/dist/observe/core/effect.js +75 -86
  15. package/dist/observe/core/external.js +5 -5
  16. package/dist/observe/core/graph.js +61 -70
  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 +704 -181
  20. package/dist/observe/core/owner.js +80 -101
  21. package/dist/observe/core/scheduler.js +708 -1351
  22. package/dist/observe/core/verdict.js +302 -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 +133 -215
  28. package/dist/observe/store/affects.js +135 -0
  29. package/dist/observe/store/index.js +29 -24
  30. package/dist/observe/store/optimistic.js +538 -0
  31. package/dist/observe/store/projection.js +302 -0
  32. package/dist/observe/store/reconcile.js +257 -0
  33. package/dist/observe/store/store.js +1945 -277
  34. package/dist/observe/store/storePath.js +1 -1
  35. package/dist/{prod/store/next → observe/store}/target.js +17 -18
  36. package/dist/observe/store/types.js +73 -0
  37. package/dist/observe/store/utils.js +1 -13
  38. package/dist/prod/affects.js +127 -106
  39. package/dist/prod/boundaries.js +442 -654
  40. package/dist/prod/core/action.js +71 -74
  41. package/dist/prod/core/async.js +307 -442
  42. package/dist/prod/core/constants.js +112 -186
  43. package/dist/prod/core/context.js +3 -3
  44. package/dist/prod/core/core.js +852 -1458
  45. package/dist/prod/core/effect.js +88 -99
  46. package/dist/prod/core/external.js +5 -5
  47. package/dist/prod/core/graph.js +61 -70
  48. package/dist/prod/core/heap.js +75 -98
  49. package/dist/prod/core/invariants.js +1 -32
  50. package/dist/prod/core/lanes.js +666 -181
  51. package/dist/prod/core/owner.js +75 -96
  52. package/dist/prod/core/scheduler.js +677 -1332
  53. package/dist/prod/core/verdict.js +297 -621
  54. package/dist/prod/flatten.js +77 -0
  55. package/dist/prod/index.js +15 -13
  56. package/dist/prod/map.js +143 -146
  57. package/dist/prod/reveal.js +212 -0
  58. package/dist/prod/signals.js +144 -226
  59. package/dist/prod/store/affects.js +135 -0
  60. package/dist/prod/store/index.js +28 -19
  61. package/dist/prod/store/optimistic.js +533 -0
  62. package/dist/prod/store/projection.js +295 -0
  63. package/dist/prod/store/reconcile.js +257 -0
  64. package/dist/prod/store/store.js +1840 -272
  65. package/dist/prod/store/storePath.js +1 -1
  66. package/dist/{observe/store/next → prod/store}/target.js +13 -17
  67. package/dist/prod/store/types.js +73 -0
  68. package/dist/prod/store/utils.js +1 -11
  69. package/dist/types/affects.d.ts +11 -30
  70. package/dist/types/boundaries.d.ts +62 -176
  71. package/dist/types/carved.d.ts +1 -0
  72. package/dist/types/core/action.d.ts +5 -6
  73. package/dist/types/core/async.d.ts +10 -5
  74. package/dist/types/core/attribution-hooks.d.ts +20 -1
  75. package/dist/types/core/attribution.d.ts +20 -9
  76. package/dist/types/core/constants.d.ts +125 -180
  77. package/dist/types/core/core.d.ts +104 -264
  78. package/dist/types/core/dev.d.ts +2 -2
  79. package/dist/types/core/effect.d.ts +0 -7
  80. package/dist/types/core/graph.d.ts +7 -1
  81. package/dist/types/core/heap.d.ts +5 -7
  82. package/dist/types/core/index.d.ts +5 -5
  83. package/dist/types/core/invariants.d.ts +0 -29
  84. package/dist/types/core/lanes.d.ts +65 -87
  85. package/dist/types/core/owner.d.ts +3 -3
  86. package/dist/types/core/scheduler.d.ts +249 -331
  87. package/dist/types/core/types.d.ts +51 -85
  88. package/dist/types/core/verdict.d.ts +3 -0
  89. package/dist/types/flatten.d.ts +8 -0
  90. package/dist/types/index.d.ts +6 -4
  91. package/dist/types/reveal.d.ts +19 -0
  92. package/dist/types/signals.d.ts +35 -91
  93. package/dist/types/store/affects.d.ts +1 -0
  94. package/dist/types/store/index.d.ts +35 -15
  95. package/dist/types/store/optimistic.d.ts +23 -0
  96. package/dist/types/store/projection.d.ts +18 -0
  97. package/dist/types/store/reconcile.d.ts +3 -0
  98. package/dist/types/store/store.d.ts +165 -143
  99. package/dist/types/store/storePath.d.ts +1 -1
  100. package/dist/types/store/target.d.ts +151 -0
  101. package/dist/types/store/types.d.ts +84 -0
  102. package/package.json +1 -1
  103. package/dist/observe/core/optimistic.js +0 -669
  104. package/dist/observe/store/next/optimistic.js +0 -717
  105. package/dist/observe/store/next/projection.js +0 -266
  106. package/dist/observe/store/next/reconcile.js +0 -375
  107. package/dist/observe/store/next/store.js +0 -2608
  108. package/dist/prod/core/optimistic.js +0 -658
  109. package/dist/prod/store/next/optimistic.js +0 -710
  110. package/dist/prod/store/next/projection.js +0 -257
  111. package/dist/prod/store/next/reconcile.js +0 -373
  112. package/dist/prod/store/next/store.js +0 -2484
  113. package/dist/types/core/optimistic.d.ts +0 -6
  114. package/dist/types/store/next/optimistic.d.ts +0 -25
  115. package/dist/types/store/next/projection.d.ts +0 -27
  116. package/dist/types/store/next/reconcile.d.ts +0 -10
  117. package/dist/types/store/next/store.d.ts +0 -145
  118. 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.te = s;
45
+ t.le = 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.te !== s || t.le !== r) {
54
+ t.te = s;
55
+ t.le = 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
+ te=false;
68
+ le=false;
69
+ Lt=true;
70
+ Qt=true;
71
+ Ut=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). */ bt(t) {
79
+ return (isController(t) ? t._parent : t.B) !== this;
80
+ }
81
+ /** The slots this controller still owns, in registration order — the
82
+ * ones the order's state is forced on. */ xt(t) {
83
+ for (let e = 0; e < this.Ft.length; e++) {
84
+ const s = this.Ft[e];
85
+ if (!this.bt(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.bt(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.bt(e[0]) || slotMinReady(e[0]);
103
+ for (let s = 0; s < e.length; s++) {
104
+ const r = this.bt(e[s]) || slotMinReady(e[s]);
105
+ if (t === "natural" ? r : !r) return t === "natural";
106
+ }
107
+ return t !== "natural";
108
+ }
109
+ ae(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.te = true;
118
+ t.le = e;
119
+ t.vt();
120
+ } else {
121
+ t.B = this;
122
+ t.te = true;
123
+ t.le = e;
124
+ }
125
+ untrack(() => this.vt());
126
+ }
127
+ ue(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.Ut) return;
135
+ this.Ut = 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.te) {
142
+ this.xt(t => setSlotState(t, this, true, this.le));
143
+ } else if (t === "natural") {
144
+ this.xt(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.xt(slotMinReady);
149
+ this.xt(e => setSlotState(e, this, !t, false));
150
+ } else {
151
+ let t = false;
152
+ this.xt(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.Ut = 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.U[REVEAL];
183
+ const i = new RevealController(e?.order || SEQUENTIAL_ACCESSOR, e?.collapsed || FALSE_ACCESSOR);
184
+ s.U = {
185
+ ...s.U,
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.ae(i);
198
+ cleanup(() => r.ue(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
+ ae: (t, e) => t.ae(e),
208
+ ue: (t, e) => t.ue(e),
209
+ j: t => t.vt()
210
+ });
211
+
212
+ export { createRevealOrder };