@solidjs/signals 2.0.0-rc.2 → 2.0.0-rc.20
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.
- package/dist/dev-shared.js +6505 -0
- package/dist/dev.attribution.js +3484 -0
- package/dist/dev.js +10227 -9508
- package/dist/observe/affects-marks.js +86 -0
- package/dist/observe/affects.js +112 -0
- package/dist/observe/attribution.js +7 -0
- package/dist/observe/boundaries.js +696 -0
- package/dist/observe/core/action.js +182 -0
- package/dist/observe/core/async.js +824 -0
- package/dist/observe/core/attribution-costs.js +66 -0
- package/dist/observe/core/attribution-feedback.js +280 -0
- package/dist/observe/core/attribution-hooks.js +83 -0
- package/dist/observe/core/attribution-queries.js +43 -0
- package/dist/observe/core/attribution.js +3079 -0
- package/dist/observe/core/constants.js +269 -0
- package/dist/observe/core/context.js +63 -0
- package/dist/observe/core/copies.js +10 -0
- package/dist/observe/core/core.js +1707 -0
- package/dist/observe/core/dev.js +394 -0
- package/dist/observe/core/effect.js +193 -0
- package/dist/observe/core/error-hooks.js +71 -0
- package/dist/observe/core/error.js +82 -0
- package/dist/observe/core/external.js +97 -0
- package/dist/observe/core/graph.js +162 -0
- package/dist/observe/core/heap.js +124 -0
- package/dist/observe/core/identities.js +62 -0
- package/dist/observe/core/invariants.js +12 -0
- package/dist/observe/core/lanes.js +972 -0
- package/dist/observe/core/owner.js +371 -0
- package/dist/observe/core/scheduler.js +1157 -0
- package/dist/observe/core/truth.js +47 -0
- package/dist/observe/core/verdict.js +470 -0
- package/dist/observe/deferred.js +186 -0
- package/dist/observe/flatten.js +79 -0
- package/dist/observe/from.js +248 -0
- package/dist/observe/index.js +71 -0
- package/dist/observe/map.js +593 -0
- package/dist/observe/reveal.js +212 -0
- package/dist/observe/signals.js +717 -0
- package/dist/observe/store/affects.js +142 -0
- package/dist/observe/store/edges.js +39 -0
- package/dist/observe/store/hooks.js +16 -0
- package/dist/observe/store/index.js +47 -0
- package/dist/observe/store/optimistic.js +713 -0
- package/dist/observe/store/projection.js +345 -0
- package/dist/observe/store/reconcile.js +281 -0
- package/dist/observe/store/store.js +2127 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/target.js +46 -0
- package/dist/observe/store/types.js +83 -0
- package/dist/observe/store/utils.js +1063 -0
- package/dist/prod/affects-marks.js +86 -0
- package/dist/prod/affects.js +98 -112
- package/dist/prod/attribution.js +45 -0
- package/dist/prod/boundaries.js +578 -468
- package/dist/prod/core/action.js +92 -59
- package/dist/prod/core/async.js +522 -336
- package/dist/prod/core/attribution-hooks.js +3 -0
- package/dist/prod/core/constants.js +168 -44
- package/dist/prod/core/context.js +12 -16
- package/dist/prod/core/copies.js +10 -0
- package/dist/prod/core/core.js +1345 -627
- package/dist/prod/core/dev.js +123 -1
- package/dist/prod/core/effect.js +113 -80
- package/dist/prod/core/error-hooks.js +71 -0
- package/dist/prod/core/error.js +18 -4
- package/dist/prod/core/external.js +6 -7
- package/dist/prod/core/graph.js +119 -72
- package/dist/prod/core/heap.js +85 -109
- package/dist/prod/core/identities.js +62 -0
- package/dist/prod/core/invariants.js +1 -32
- package/dist/prod/core/lanes.js +931 -132
- package/dist/prod/core/owner.js +192 -129
- package/dist/prod/core/scheduler.js +948 -642
- package/dist/prod/core/truth.js +47 -0
- package/dist/prod/core/verdict.js +409 -420
- package/dist/prod/deferred.js +184 -0
- package/dist/prod/flatten.js +77 -0
- package/dist/prod/from.js +248 -0
- package/dist/prod/index.js +40 -16
- package/dist/prod/map.js +481 -211
- package/dist/prod/reveal.js +212 -0
- package/dist/prod/signals.js +401 -84
- package/dist/prod/store/affects.js +142 -0
- package/dist/prod/store/edges.js +39 -0
- package/dist/prod/store/hooks.js +16 -0
- package/dist/prod/store/index.js +27 -18
- package/dist/prod/store/optimistic.js +707 -0
- package/dist/prod/store/projection.js +331 -0
- package/dist/prod/store/reconcile.js +281 -0
- package/dist/prod/store/store.js +1952 -267
- package/dist/prod/store/storePath.js +1 -1
- package/dist/prod/store/target.js +43 -0
- package/dist/prod/store/types.js +83 -0
- package/dist/prod/store/utils.js +997 -138
- package/dist/types/affects-marks.d.ts +14 -0
- package/dist/types/affects.d.ts +12 -30
- package/dist/types/attribution.d.ts +19 -0
- package/dist/types/attribution.prod.d.ts +22 -0
- package/dist/types/boundaries.d.ts +99 -124
- package/dist/types/carved.d.ts +1 -0
- package/dist/types/core/action.d.ts +23 -9
- package/dist/types/core/async.d.ts +34 -6
- package/dist/types/core/attribution-costs.d.ts +35 -0
- package/dist/types/core/attribution-feedback.d.ts +133 -0
- package/dist/types/core/attribution-hooks.d.ts +307 -8
- package/dist/types/core/attribution-queries.d.ts +24 -0
- package/dist/types/core/attribution.d.ts +802 -72
- package/dist/types/core/constants.d.ts +195 -38
- package/dist/types/core/copies.d.ts +54 -0
- package/dist/types/core/core.d.ts +295 -65
- package/dist/types/core/dev.d.ts +509 -22
- package/dist/types/core/effect.d.ts +1 -1
- package/dist/types/core/error-hooks.d.ts +71 -0
- package/dist/types/core/error.d.ts +18 -1
- package/dist/types/core/graph.d.ts +40 -1
- package/dist/types/core/heap.d.ts +5 -5
- package/dist/types/core/identities.d.ts +17 -0
- package/dist/types/core/index.d.ts +11 -7
- package/dist/types/core/invariants.d.ts +1 -26
- package/dist/types/core/lanes.d.ts +74 -43
- package/dist/types/core/owner.d.ts +27 -9
- package/dist/types/core/scheduler.d.ts +353 -102
- package/dist/types/core/truth.d.ts +18 -0
- package/dist/types/core/types.d.ts +97 -71
- package/dist/types/core/verdict.d.ts +35 -0
- package/dist/types/deferred.d.ts +28 -0
- package/dist/types/flatten.d.ts +8 -0
- package/dist/types/from.d.ts +47 -0
- package/dist/types/index.d.ts +33 -7
- package/dist/types/map.d.ts +4 -2
- package/dist/types/reveal.d.ts +19 -0
- package/dist/types/signals.d.ts +196 -45
- package/dist/types/store/affects.d.ts +12 -0
- package/dist/types/store/edges.d.ts +9 -0
- package/dist/types/store/hooks.d.ts +62 -0
- package/dist/types/store/index.d.ts +42 -15
- package/dist/types/store/optimistic.d.ts +24 -45
- package/dist/types/store/projection.d.ts +17 -68
- package/dist/types/store/reconcile.d.ts +3 -46
- package/dist/types/store/store.d.ts +133 -136
- package/dist/types/store/storePath.d.ts +1 -1
- package/dist/types/store/target.d.ts +166 -0
- package/dist/types/store/types.d.ts +105 -0
- package/dist/types/store/utils.d.ts +188 -0
- package/package.json +31 -26
- package/dist/node.cjs +0 -8745
- package/dist/prod/core/optimistic.js +0 -265
- package/dist/prod/store/next/optimistic.js +0 -385
- package/dist/prod/store/next/projection.js +0 -172
- package/dist/prod/store/next/reconcile.js +0 -331
- package/dist/prod/store/next/store.js +0 -1499
- package/dist/prod/store/next/target.js +0 -20
- package/dist/types/core/optimistic.d.ts +0 -6
- package/dist/types/store/next/optimistic.d.ts +0 -20
- package/dist/types/store/next/projection.d.ts +0 -8
- package/dist/types/store/next/reconcile.d.ts +0 -3
- package/dist/types/store/next/store.d.ts +0 -77
- package/dist/types/store/next/target.d.ts +0 -117
- package/dist/types-cjs/affects.d.cts +0 -47
- package/dist/types-cjs/boundaries.d.cts +0 -175
- package/dist/types-cjs/core/action.d.cts +0 -64
- package/dist/types-cjs/core/async.d.cts +0 -21
- package/dist/types-cjs/core/attribution-hooks.d.cts +0 -52
- package/dist/types-cjs/core/attribution.d.cts +0 -186
- package/dist/types-cjs/core/constants.d.cts +0 -97
- package/dist/types-cjs/core/context.d.cts +0 -36
- package/dist/types-cjs/core/core.d.cts +0 -163
- package/dist/types-cjs/core/dev.d.cts +0 -81
- package/dist/types-cjs/core/effect.d.cts +0 -30
- package/dist/types-cjs/core/error.d.cts +0 -47
- package/dist/types-cjs/core/external.d.cts +0 -15
- package/dist/types-cjs/core/graph.d.cts +0 -6
- package/dist/types-cjs/core/heap.d.cts +0 -22
- package/dist/types-cjs/core/index.d.cts +0 -13
- package/dist/types-cjs/core/invariants.d.cts +0 -59
- package/dist/types-cjs/core/lanes.d.cts +0 -44
- package/dist/types-cjs/core/optimistic.d.cts +0 -6
- package/dist/types-cjs/core/owner.d.cts +0 -124
- package/dist/types-cjs/core/scheduler.d.cts +0 -180
- package/dist/types-cjs/core/types.d.cts +0 -192
- package/dist/types-cjs/core/verdict.d.cts +0 -2
- package/dist/types-cjs/index.d.cts +0 -10
- package/dist/types-cjs/map.d.cts +0 -69
- package/dist/types-cjs/package.json +0 -3
- package/dist/types-cjs/signals.d.cts +0 -624
- package/dist/types-cjs/store/index.d.cts +0 -19
- package/dist/types-cjs/store/next/optimistic.d.cts +0 -20
- package/dist/types-cjs/store/next/projection.d.cts +0 -8
- package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
- package/dist/types-cjs/store/next/store.d.cts +0 -77
- package/dist/types-cjs/store/next/target.d.cts +0 -117
- package/dist/types-cjs/store/optimistic.d.cts +0 -45
- package/dist/types-cjs/store/projection.d.cts +0 -70
- package/dist/types-cjs/store/reconcile.d.cts +0 -46
- package/dist/types-cjs/store/store.d.cts +0 -138
- package/dist/types-cjs/store/storePath.d.cts +0 -58
- package/dist/types-cjs/store/utils.d.cts +0 -74
|
@@ -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.Lt() : ready(t);
|
|
36
|
+
|
|
37
|
+
const slotMinReady = t => isController(t) ? t.Qt() : 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.$ = s;
|
|
45
|
+
t.ee = r;
|
|
46
|
+
t.Jt();
|
|
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.Xt && t._parent === e) t._parent = null;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (t.$ !== s || t.ee !== r) {
|
|
54
|
+
t.$ = s;
|
|
55
|
+
t.ee = r;
|
|
56
|
+
redraw(t);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class RevealController {
|
|
61
|
+
Yt;
|
|
62
|
+
Zt;
|
|
63
|
+
ts=[];
|
|
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
|
+
$=false;
|
|
68
|
+
ee=false;
|
|
69
|
+
Xt=true;
|
|
70
|
+
es=true;
|
|
71
|
+
ss=false;
|
|
72
|
+
constructor(t, e) {
|
|
73
|
+
this.Yt = t;
|
|
74
|
+
this.Zt = 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). */ rs(t) {
|
|
79
|
+
return (isController(t) ? t._parent : t.v) !== this;
|
|
80
|
+
}
|
|
81
|
+
/** The slots this controller still owns, in registration order — the
|
|
82
|
+
* ones the order's state is forced on. */ ns(t) {
|
|
83
|
+
for (let e = 0; e < this.ts.length; e++) {
|
|
84
|
+
const s = this.ts[e];
|
|
85
|
+
if (!this.rs(s) && t(s) === false) return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
/** Readiness is judged over every slot, done ones as ready. */ Lt() {
|
|
90
|
+
for (let t = 0; t < this.ts.length; t++) {
|
|
91
|
+
const e = this.ts[t];
|
|
92
|
+
if (!this.rs(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. */ Qt() {
|
|
99
|
+
const t = untrack(this.Yt);
|
|
100
|
+
const e = this.ts;
|
|
101
|
+
if (e.length === 0) return true;
|
|
102
|
+
if (t === "sequential") return this.rs(e[0]) || slotMinReady(e[0]);
|
|
103
|
+
for (let s = 0; s < e.length; s++) {
|
|
104
|
+
const r = this.rs(e[s]) || slotMinReady(e[s]);
|
|
105
|
+
if (t === "natural" ? r : !r) return t === "natural";
|
|
106
|
+
}
|
|
107
|
+
return t !== "natural";
|
|
108
|
+
}
|
|
109
|
+
te(t) {
|
|
110
|
+
if (this.ts.includes(t)) return;
|
|
111
|
+
this.ts.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.Yt) === "sequential" && !!untrack(this.Zt);
|
|
115
|
+
if (isController(t)) {
|
|
116
|
+
t._parent = this;
|
|
117
|
+
t.$ = true;
|
|
118
|
+
t.ee = e;
|
|
119
|
+
t.Jt();
|
|
120
|
+
} else {
|
|
121
|
+
t.v = this;
|
|
122
|
+
t.$ = true;
|
|
123
|
+
t.ee = e;
|
|
124
|
+
}
|
|
125
|
+
untrack(() => this.Jt());
|
|
126
|
+
}
|
|
127
|
+
oe(t) {
|
|
128
|
+
const e = this.ts.indexOf(t);
|
|
129
|
+
if (e >= 0) this.ts.splice(e, 1);
|
|
130
|
+
untrack(() => this.Jt());
|
|
131
|
+
}
|
|
132
|
+
/** Apply the order to the owned slots — or, gated by a parent, its state
|
|
133
|
+
* to all of them. */ Jt() {
|
|
134
|
+
if (this.ss) return;
|
|
135
|
+
this.ss = true;
|
|
136
|
+
const t = this.Xt;
|
|
137
|
+
const e = this.es;
|
|
138
|
+
try {
|
|
139
|
+
const t = untrack(this.Yt);
|
|
140
|
+
const e = t === "sequential" && !!untrack(this.Zt);
|
|
141
|
+
if (this.$) {
|
|
142
|
+
this.ns(t => setSlotState(t, this, true, this.ee));
|
|
143
|
+
} else if (t === "natural") {
|
|
144
|
+
this.ns(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.ns(slotMinReady);
|
|
149
|
+
this.ns(e => setSlotState(e, this, !t, false));
|
|
150
|
+
} else {
|
|
151
|
+
let t = false;
|
|
152
|
+
this.ns(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.Xt = this.Lt();
|
|
163
|
+
this.es = this.Qt();
|
|
164
|
+
this.ss = false;
|
|
165
|
+
}
|
|
166
|
+
if (this._parent !== null && (t !== this.Xt || e !== this.es)) this._parent.Jt();
|
|
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.A[REVEAL];
|
|
183
|
+
const i = new RevealController(e?.order || SEQUENTIAL_ACCESSOR, e?.collapsed || FALSE_ACCESSOR);
|
|
184
|
+
s.A = {
|
|
185
|
+
...s.A,
|
|
186
|
+
[REVEAL]: i
|
|
187
|
+
};
|
|
188
|
+
return runWithOwner(s, () => {
|
|
189
|
+
const e = t();
|
|
190
|
+
const s = computed(() => {
|
|
191
|
+
i.Yt();
|
|
192
|
+
i.Zt();
|
|
193
|
+
i.Jt();
|
|
194
|
+
});
|
|
195
|
+
if (true) s._name = "reveal order";
|
|
196
|
+
if (r) {
|
|
197
|
+
r.te(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
|
+
te: (t, e) => t.te(e),
|
|
208
|
+
oe: (t, e) => t.oe(e),
|
|
209
|
+
P: t => t.Jt()
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
export { createRevealOrder };
|