@solidjs/signals 2.0.0-rc.14 → 2.0.0-rc.16
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 +882 -405
- package/dist/dev.attribution.js +172 -66
- package/dist/dev.js +1529 -745
- package/dist/observe/affects-marks.js +86 -0
- package/dist/observe/affects.js +32 -80
- package/dist/observe/boundaries.js +202 -166
- package/dist/observe/core/async.js +192 -141
- package/dist/observe/core/attribution-queries.js +1 -1
- package/dist/observe/core/attribution.js +315 -214
- package/dist/observe/core/constants.js +23 -4
- package/dist/observe/core/context.js +3 -3
- package/dist/observe/core/core.js +532 -360
- package/dist/observe/core/dev.js +63 -35
- package/dist/observe/core/effect.js +47 -47
- package/dist/observe/core/error.js +5 -3
- package/dist/observe/core/external.js +5 -6
- package/dist/observe/core/graph.js +56 -42
- package/dist/observe/core/heap.js +33 -33
- package/dist/observe/core/identities.js +62 -0
- package/dist/observe/core/lanes.js +242 -229
- package/dist/observe/core/owner.js +62 -50
- package/dist/observe/core/scheduler.js +322 -168
- package/dist/observe/core/truth.js +45 -0
- package/dist/observe/core/verdict.js +114 -64
- package/dist/observe/deferred.js +184 -0
- package/dist/observe/index.js +7 -1
- package/dist/observe/map.js +339 -254
- package/dist/observe/reveal.js +77 -77
- package/dist/observe/signals.js +54 -33
- package/dist/observe/store/affects.js +76 -69
- package/dist/observe/store/edges.js +39 -0
- package/dist/observe/store/hooks.js +13 -0
- package/dist/observe/store/index.js +0 -2
- package/dist/observe/store/optimistic.js +82 -44
- package/dist/observe/store/projection.js +83 -64
- package/dist/observe/store/reconcile.js +32 -30
- package/dist/observe/store/store.js +219 -123
- package/dist/prod/affects-marks.js +86 -0
- package/dist/prod/affects.js +33 -79
- package/dist/prod/boundaries.js +185 -149
- package/dist/prod/core/async.js +176 -135
- package/dist/prod/core/constants.js +23 -4
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +521 -353
- package/dist/prod/core/effect.js +66 -66
- package/dist/prod/core/error.js +5 -3
- package/dist/prod/core/external.js +5 -6
- package/dist/prod/core/graph.js +56 -42
- package/dist/prod/core/heap.js +38 -38
- package/dist/prod/core/identities.js +62 -0
- package/dist/prod/core/lanes.js +237 -224
- package/dist/prod/core/owner.js +62 -51
- package/dist/prod/core/scheduler.js +312 -158
- package/dist/prod/core/truth.js +45 -0
- package/dist/prod/core/verdict.js +113 -63
- package/dist/prod/deferred.js +182 -0
- package/dist/prod/index.js +7 -1
- package/dist/prod/map.js +366 -281
- package/dist/prod/reveal.js +77 -77
- package/dist/prod/signals.js +59 -38
- package/dist/prod/store/affects.js +76 -69
- package/dist/prod/store/edges.js +39 -0
- package/dist/prod/store/hooks.js +13 -0
- package/dist/prod/store/index.js +0 -2
- package/dist/prod/store/optimistic.js +121 -84
- package/dist/prod/store/projection.js +46 -34
- package/dist/prod/store/reconcile.js +32 -30
- package/dist/prod/store/store.js +205 -116
- package/dist/types/affects-marks.d.ts +14 -0
- package/dist/types/boundaries.d.ts +5 -1
- package/dist/types/core/async.d.ts +10 -0
- package/dist/types/core/attribution.d.ts +6 -2
- package/dist/types/core/constants.d.ts +18 -1
- package/dist/types/core/core.d.ts +77 -5
- package/dist/types/core/dev.d.ts +43 -13
- package/dist/types/core/graph.d.ts +11 -0
- package/dist/types/core/identities.d.ts +17 -0
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/core/lanes.d.ts +2 -4
- package/dist/types/core/owner.d.ts +5 -3
- package/dist/types/core/scheduler.d.ts +59 -34
- package/dist/types/core/truth.d.ts +16 -0
- package/dist/types/core/types.d.ts +21 -6
- package/dist/types/core/verdict.d.ts +32 -0
- package/dist/types/deferred.d.ts +28 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/map.d.ts +2 -2
- package/dist/types/signals.d.ts +28 -7
- package/dist/types/store/affects.d.ts +11 -0
- package/dist/types/store/edges.d.ts +9 -0
- package/dist/types/store/hooks.d.ts +48 -0
- package/dist/types/store/index.d.ts +10 -4
- package/dist/types/store/optimistic.d.ts +3 -2
- package/dist/types/store/projection.d.ts +4 -3
- package/dist/types/store/store.d.ts +4 -39
- package/dist/types/store/target.d.ts +16 -8
- package/dist/types/store/types.d.ts +14 -0
- package/package.json +1 -1
package/dist/prod/reveal.js
CHANGED
|
@@ -32,124 +32,124 @@ const SEQUENTIAL_ACCESSOR = () => "sequential";
|
|
|
32
32
|
|
|
33
33
|
const isController = t => t instanceof RevealController;
|
|
34
34
|
|
|
35
|
-
const slotReady = t => isController(t) ? t.
|
|
35
|
+
const slotReady = t => isController(t) ? t.St() : ready(t);
|
|
36
36
|
|
|
37
|
-
const slotMinReady = t => isController(t) ? t.
|
|
37
|
+
const slotMinReady = t => isController(t) ? t.Rt() : ready(t);
|
|
38
38
|
|
|
39
39
|
/** Force a slot's state. A boundary re-derives its output when it changes;
|
|
40
40
|
* a nested controller passes the state on to its own slots. Released
|
|
41
41
|
* (`!gated`), a nested controller leaves its parent's ownership and runs its
|
|
42
42
|
* own order; a boundary leaves when it has shown content (boundaries.ts). */ function setSlotState(t, e, s, r) {
|
|
43
43
|
if (isController(t)) {
|
|
44
|
-
t
|
|
45
|
-
t.
|
|
46
|
-
t.
|
|
44
|
+
t.$ = s;
|
|
45
|
+
t.ee = r;
|
|
46
|
+
t._t();
|
|
47
47
|
// Released and ready — every slot of its own has shown — it graduates,
|
|
48
48
|
// as a boundary does when it shows content. Released at the frontier
|
|
49
49
|
// but not ready, it stays the parent's frontier.
|
|
50
|
-
if (!s && t.
|
|
50
|
+
if (!s && t.Ct && t._parent === e) t._parent = null;
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
if (t
|
|
54
|
-
t
|
|
55
|
-
t.
|
|
53
|
+
if (t.$ !== s || t.ee !== r) {
|
|
54
|
+
t.$ = s;
|
|
55
|
+
t.ee = r;
|
|
56
56
|
redraw(t);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
class RevealController {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
yt;
|
|
62
|
+
Et;
|
|
63
|
+
At=[];
|
|
64
64
|
/** The controller gating this one, until it releases this one. */
|
|
65
65
|
_parent=null;
|
|
66
66
|
/** The state a parent forces on this whole group. */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
$=false;
|
|
68
|
+
ee=false;
|
|
69
|
+
Ct=true;
|
|
70
|
+
kt=true;
|
|
71
|
+
vt=false;
|
|
72
72
|
constructor(t, e) {
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
73
|
+
this.yt = t;
|
|
74
|
+
this.Et = e;
|
|
75
75
|
}
|
|
76
76
|
/** A slot that has left this controller's ownership: a boundary that has
|
|
77
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). */
|
|
79
|
-
return (isController(t) ? t._parent : t.
|
|
78
|
+
* as ready whatever happens to it later (a re-arm gates nobody else). */ gt(t) {
|
|
79
|
+
return (isController(t) ? t._parent : t.V) !== this;
|
|
80
80
|
}
|
|
81
81
|
/** The slots this controller still owns, in registration order — the
|
|
82
|
-
* ones the order's state is forced on. */
|
|
83
|
-
for (let e = 0; e < this.
|
|
84
|
-
const s = this.
|
|
85
|
-
if (!this.
|
|
82
|
+
* ones the order's state is forced on. */ Lt(t) {
|
|
83
|
+
for (let e = 0; e < this.At.length; e++) {
|
|
84
|
+
const s = this.At[e];
|
|
85
|
+
if (!this.gt(s) && t(s) === false) return false;
|
|
86
86
|
}
|
|
87
87
|
return true;
|
|
88
88
|
}
|
|
89
|
-
/** Readiness is judged over every slot, done ones as ready. */
|
|
90
|
-
for (let t = 0; t < this.
|
|
91
|
-
const e = this.
|
|
92
|
-
if (!this.
|
|
89
|
+
/** Readiness is judged over every slot, done ones as ready. */ St() {
|
|
90
|
+
for (let t = 0; t < this.At.length; t++) {
|
|
91
|
+
const e = this.At[t];
|
|
92
|
+
if (!this.gt(e) && !slotReady(e)) return false;
|
|
93
93
|
}
|
|
94
94
|
return true;
|
|
95
95
|
}
|
|
96
96
|
/** Something visible to show under its own order — what an enclosing
|
|
97
97
|
* `together` waits for: `together` — every slot minimally ready;
|
|
98
|
-
* `sequential` — the first slot; `natural` — any. */
|
|
99
|
-
const t = untrack(this.
|
|
100
|
-
const e = this.
|
|
98
|
+
* `sequential` — the first slot; `natural` — any. */ Rt() {
|
|
99
|
+
const t = untrack(this.yt);
|
|
100
|
+
const e = this.At;
|
|
101
101
|
if (e.length === 0) return true;
|
|
102
|
-
if (t === "sequential") return this.
|
|
102
|
+
if (t === "sequential") return this.gt(e[0]) || slotMinReady(e[0]);
|
|
103
103
|
for (let s = 0; s < e.length; s++) {
|
|
104
|
-
const r = this.
|
|
104
|
+
const r = this.gt(e[s]) || slotMinReady(e[s]);
|
|
105
105
|
if (t === "natural" ? r : !r) return t === "natural";
|
|
106
106
|
}
|
|
107
107
|
return t !== "natural";
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
if (this.
|
|
111
|
-
this.
|
|
109
|
+
oe(t) {
|
|
110
|
+
if (this.At.includes(t)) return;
|
|
111
|
+
this.At.push(t);
|
|
112
112
|
// Gated from the start (collapsed in a collapsed sequential tail); the
|
|
113
113
|
// evaluation releases what the order allows.
|
|
114
|
-
const e = untrack(this.
|
|
114
|
+
const e = untrack(this.yt) === "sequential" && !!untrack(this.Et);
|
|
115
115
|
if (isController(t)) {
|
|
116
116
|
t._parent = this;
|
|
117
|
-
t
|
|
118
|
-
t.
|
|
119
|
-
t.
|
|
117
|
+
t.$ = true;
|
|
118
|
+
t.ee = e;
|
|
119
|
+
t._t();
|
|
120
120
|
} else {
|
|
121
|
-
t.
|
|
122
|
-
t
|
|
123
|
-
t.
|
|
121
|
+
t.V = this;
|
|
122
|
+
t.$ = true;
|
|
123
|
+
t.ee = e;
|
|
124
124
|
}
|
|
125
|
-
untrack(() => this.
|
|
125
|
+
untrack(() => this._t());
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
const e = this.
|
|
129
|
-
if (e >= 0) this.
|
|
130
|
-
untrack(() => this.
|
|
127
|
+
te(t) {
|
|
128
|
+
const e = this.At.indexOf(t);
|
|
129
|
+
if (e >= 0) this.At.splice(e, 1);
|
|
130
|
+
untrack(() => this._t());
|
|
131
131
|
}
|
|
132
132
|
/** Apply the order to the owned slots — or, gated by a parent, its state
|
|
133
|
-
* to all of them. */
|
|
134
|
-
if (this.
|
|
135
|
-
this.
|
|
136
|
-
const t = this.
|
|
137
|
-
const e = this.
|
|
133
|
+
* to all of them. */ _t() {
|
|
134
|
+
if (this.vt) return;
|
|
135
|
+
this.vt = true;
|
|
136
|
+
const t = this.Ct;
|
|
137
|
+
const e = this.kt;
|
|
138
138
|
try {
|
|
139
|
-
const t = untrack(this.
|
|
140
|
-
const e = t === "sequential" && !!untrack(this.
|
|
141
|
-
if (this
|
|
142
|
-
this.
|
|
139
|
+
const t = untrack(this.yt);
|
|
140
|
+
const e = t === "sequential" && !!untrack(this.Et);
|
|
141
|
+
if (this.$) {
|
|
142
|
+
this.Lt(t => setSlotState(t, this, true, this.ee));
|
|
143
143
|
} else if (t === "natural") {
|
|
144
|
-
this.
|
|
144
|
+
this.Lt(t => {
|
|
145
145
|
if (isController(t)) setSlotState(t, this, false, false); else setSlotState(t, this, !ready(t), false);
|
|
146
146
|
});
|
|
147
147
|
} else if (t === "together") {
|
|
148
|
-
const t = this.
|
|
149
|
-
this.
|
|
148
|
+
const t = this.Lt(slotMinReady);
|
|
149
|
+
this.Lt(e => setSlotState(e, this, !t, false));
|
|
150
150
|
} else {
|
|
151
151
|
let t = false;
|
|
152
|
-
this.
|
|
152
|
+
this.Lt(s => {
|
|
153
153
|
if (t) return setSlotState(s, this, true, e);
|
|
154
154
|
if (slotReady(s)) return setSlotState(s, this, false, false);
|
|
155
155
|
t = true;
|
|
@@ -159,11 +159,11 @@ class RevealController {
|
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
} finally {
|
|
162
|
-
this.
|
|
163
|
-
this.
|
|
164
|
-
this.
|
|
162
|
+
this.Ct = this.St();
|
|
163
|
+
this.kt = this.Rt();
|
|
164
|
+
this.vt = false;
|
|
165
165
|
}
|
|
166
|
-
if (this._parent !== null && (t !== this.
|
|
166
|
+
if (this._parent !== null && (t !== this.Ct || e !== this.kt)) this._parent._t();
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -179,23 +179,23 @@ class RevealController {
|
|
|
179
179
|
* slots behind the frontier render nothing instead of their fallbacks
|
|
180
180
|
*/ function createRevealOrder(t, e) {
|
|
181
181
|
const s = createOwner();
|
|
182
|
-
const r = s.
|
|
182
|
+
const r = s.A[REVEAL];
|
|
183
183
|
const i = new RevealController(e?.order || SEQUENTIAL_ACCESSOR, e?.collapsed || FALSE_ACCESSOR);
|
|
184
|
-
s.
|
|
185
|
-
...s.
|
|
184
|
+
s.A = {
|
|
185
|
+
...s.A,
|
|
186
186
|
[REVEAL]: i
|
|
187
187
|
};
|
|
188
188
|
return runWithOwner(s, () => {
|
|
189
189
|
const e = t();
|
|
190
190
|
const s = computed(() => {
|
|
191
|
-
i.
|
|
192
|
-
i.
|
|
193
|
-
i.
|
|
191
|
+
i.yt();
|
|
192
|
+
i.Et();
|
|
193
|
+
i._t();
|
|
194
194
|
});
|
|
195
195
|
if (false) ;
|
|
196
196
|
if (r) {
|
|
197
|
-
r.
|
|
198
|
-
cleanup(() => r.
|
|
197
|
+
r.oe(i);
|
|
198
|
+
cleanup(() => r.te(i));
|
|
199
199
|
}
|
|
200
200
|
return e;
|
|
201
201
|
});
|
|
@@ -204,9 +204,9 @@ class RevealController {
|
|
|
204
204
|
// Installed at module evaluation — present exactly when something imports
|
|
205
205
|
// `createRevealOrder`; a Loading boundary without one pays a null check.
|
|
206
206
|
setRevealHooks({
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
oe: (t, e) => t.oe(e),
|
|
208
|
+
te: (t, e) => t.te(e),
|
|
209
|
+
P: t => t._t()
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
export { createRevealOrder };
|
package/dist/prod/signals.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { NotReadyError, unwrapStatusError
|
|
1
|
+
import { TimeoutError, NotReadyError, unwrapStatusError } from "./core/error.js";
|
|
2
2
|
|
|
3
3
|
import "./core/verdict.js";
|
|
4
4
|
|
|
5
|
-
import { CONFIG_CHILDREN_FORBIDDEN, EFFECT_USER, $REFRESH, CONFIG_REDERIVE, REACTIVE_JOINED,
|
|
5
|
+
import { CONFIG_CHILDREN_FORBIDDEN, EFFECT_USER, $REFRESH, CONFIG_AUTO_DISPOSE, CONFIG_AUTHORITATIVE, CONFIG_REDERIVE, REACTIVE_JOINED, CONFIG_FRESH_READ, CONFIG_GUESS, STATUS_PENDING, STATUS_ERROR } from "./core/constants.js";
|
|
6
6
|
|
|
7
7
|
import { computed, signal, runWithOwner, setMemo, setSignal, markRefresh, read, untrack } from "./core/core.js";
|
|
8
8
|
|
|
9
|
-
import { globalQueue, flushTransaction, resolveTx, passTx, staleReader,
|
|
9
|
+
import { globalQueue, flushTransaction, dirtyQueue, GlobalQueue, resolveTx, passTx, staleReader, joinFuture } from "./core/scheduler.js";
|
|
10
10
|
|
|
11
11
|
import { cleanup, createRoot, getOwner, dispose } from "./core/owner.js";
|
|
12
12
|
|
|
13
|
+
import { signalHook } from "./core/identities.js";
|
|
14
|
+
|
|
13
15
|
import { effect, trackedEffect } from "./core/effect.js";
|
|
14
16
|
|
|
15
17
|
import { optimisticWrite } from "./core/lanes.js";
|
|
16
18
|
|
|
19
|
+
import { truthRead, truthConfirmed } from "./core/truth.js";
|
|
20
|
+
|
|
17
21
|
/**
|
|
18
22
|
* Low-level reactive-cleanup primitive. Registers a callback that runs when
|
|
19
23
|
* the surrounding owner is disposed.
|
|
@@ -71,17 +75,18 @@ function accessor(e) {
|
|
|
71
75
|
function createSignal(e, t) {
|
|
72
76
|
if (typeof e === "function") {
|
|
73
77
|
const r = computed(e, t);
|
|
74
|
-
r.
|
|
78
|
+
r.l &= ~CONFIG_AUTO_DISPOSE;
|
|
75
79
|
return [ accessor(r), setMemo.bind(null, r) ];
|
|
76
80
|
}
|
|
77
81
|
const r = signal(e, t);
|
|
82
|
+
if (signalHook !== null) signalHook(r);
|
|
78
83
|
return [ accessor(r), setSignal.bind(null, r) ];
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
function createOptimistic(e, t) {
|
|
82
87
|
if (typeof e === "function") {
|
|
83
88
|
const r = computed(e, t);
|
|
84
|
-
r.
|
|
89
|
+
r.l &= ~CONFIG_AUTO_DISPOSE;
|
|
85
90
|
return [ accessor(r), optimisticWrite.bind(null, r) ];
|
|
86
91
|
}
|
|
87
92
|
const r = signal(e, t);
|
|
@@ -158,7 +163,7 @@ function createMemo(e, t) {
|
|
|
158
163
|
* );
|
|
159
164
|
* ```
|
|
160
165
|
*
|
|
161
|
-
* @description https://
|
|
166
|
+
* @description https://v2.solidjs.com/reference/solid-js/reactivity/create-effect
|
|
162
167
|
*/ function createEffect(e, t, r) {
|
|
163
168
|
effect(e, t.effect || t, t.error, {
|
|
164
169
|
user: true,
|
|
@@ -193,7 +198,7 @@ function createMemo(e, t) {
|
|
|
193
198
|
* }
|
|
194
199
|
* ```
|
|
195
200
|
*
|
|
196
|
-
* @description https://
|
|
201
|
+
* @description https://v2.solidjs.com/reference/solid-js/advanced/specialized-reactivity/create-render-effect
|
|
197
202
|
*/ function createRenderEffect(e, t, r) {
|
|
198
203
|
effect(e, t, undefined, r);
|
|
199
204
|
}
|
|
@@ -241,7 +246,7 @@ function createMemo(e, t) {
|
|
|
241
246
|
* });
|
|
242
247
|
* ```
|
|
243
248
|
*
|
|
244
|
-
* @description https://
|
|
249
|
+
* @description https://v2.solidjs.com/reference/solid-js/advanced/specialized-reactivity/create-tracked-effect
|
|
245
250
|
*/ function createTrackedEffect(e, t) {
|
|
246
251
|
trackedEffect(e, t);
|
|
247
252
|
}
|
|
@@ -270,7 +275,7 @@ function createMemo(e, t) {
|
|
|
270
275
|
* setCount(1); // logs once, reaction re-armed for next change
|
|
271
276
|
* ```
|
|
272
277
|
*
|
|
273
|
-
* @description https://
|
|
278
|
+
* @description https://v2.solidjs.com/reference/solid-js/advanced/specialized-reactivity/create-reaction
|
|
274
279
|
*/ function createReaction(e, t) {
|
|
275
280
|
let r = undefined;
|
|
276
281
|
cleanup(() => r?.());
|
|
@@ -320,31 +325,41 @@ function createMemo(e, t) {
|
|
|
320
325
|
* - a mainline reader whose pass read a frame another transaction holds
|
|
321
326
|
* joined it (L2, born held — A29) and delivers at that commit: the
|
|
322
327
|
* committed view, never a foreign hold's unrevealed frame. */ function watch(e, t, r, n = 0, o, c = flushTransaction) {
|
|
328
|
+
if (n & CONFIG_AUTHORITATIVE) {
|
|
329
|
+
GlobalQueue.rn = truthRead;
|
|
330
|
+
GlobalQueue.sn = truthConfirmed;
|
|
331
|
+
}
|
|
323
332
|
// `config` is on the node for its first pass too (the pass runs inside
|
|
324
333
|
// `computed()`): `until`'s predicate is authoritative from its first read,
|
|
325
334
|
// or an already-displayed guess would satisfy it in a later slice. (REDERIVE
|
|
326
335
|
// after: the first pass's own error is the promise's rejection.)
|
|
327
|
-
|
|
328
|
-
let
|
|
336
|
+
computed(() => {
|
|
337
|
+
let i, u = false;
|
|
329
338
|
try {
|
|
330
|
-
|
|
339
|
+
i = e();
|
|
331
340
|
} catch (e) {
|
|
332
341
|
if (e instanceof NotReadyError) throw e;
|
|
333
|
-
|
|
334
|
-
|
|
342
|
+
// An error is an answer (D-41): delivered by the same frame rule.
|
|
343
|
+
i = unwrapStatusError(e);
|
|
344
|
+
u = true;
|
|
335
345
|
}
|
|
336
|
-
const
|
|
346
|
+
const s = getOwner();
|
|
347
|
+
// A truth reader waits out a `createDeferred` flight its value derives
|
|
348
|
+
// from, which serves everyone else the stale answer (D-40).
|
|
349
|
+
const f = n & CONFIG_AUTHORITATIVE && GlobalQueue.er?.(s);
|
|
350
|
+
if (f) throw new NotReadyError(f);
|
|
337
351
|
// (Outside a flush a mainline pass joins through `passTx`.)
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
340
|
-
staleReader(
|
|
352
|
+
const a = flushTransaction ?? passTx;
|
|
353
|
+
if (s.R & REACTIVE_JOINED && a !== null && (c === null || resolveTx(c) !== resolveTx(a))) {
|
|
354
|
+
staleReader(s, resolveTx(a));
|
|
341
355
|
return;
|
|
342
356
|
}
|
|
343
|
-
|
|
344
|
-
|
|
357
|
+
if (u) return void queueMicrotask(() => r(i));
|
|
358
|
+
o?.(i);
|
|
359
|
+
queueMicrotask(() => t(i));
|
|
345
360
|
}, {
|
|
346
|
-
|
|
347
|
-
}).
|
|
361
|
+
Le: n
|
|
362
|
+
}).l |= CONFIG_REDERIVE;
|
|
348
363
|
}
|
|
349
364
|
|
|
350
365
|
/**
|
|
@@ -430,23 +445,29 @@ function createMemo(e, t) {
|
|
|
430
445
|
const r = flushTransaction;
|
|
431
446
|
const n = new Promise((n, o) => {
|
|
432
447
|
queueMicrotask(() => {
|
|
433
|
-
//
|
|
434
|
-
//
|
|
435
|
-
//
|
|
436
|
-
// capture runs inside the watcher's
|
|
437
|
-
// IS the watcher — exactly what
|
|
448
|
+
// The root is load-bearing: an ownerless computed is auto-disposing,
|
|
449
|
+
// and the settle walk releases an unobserved one instead of re-running
|
|
450
|
+
// it, so the waiter would never see the refetch land (#3888). Settle
|
|
451
|
+
// disposes the waiter directly; the capture runs inside the watcher's
|
|
452
|
+
// own pass, where the ambient owner IS the watcher — exactly what
|
|
453
|
+
// dispose() takes.
|
|
438
454
|
let c = null;
|
|
439
455
|
const make = () => watch(() => {
|
|
440
456
|
if (c === null) c = getOwner();
|
|
441
|
-
|
|
457
|
+
// Authoritative: the truth beneath a guess (`until`'s view). A
|
|
458
|
+
// guessed node's own re-ask is not answered by it (#3895): park
|
|
459
|
+
// on that flight, or reject with its error.
|
|
460
|
+
const e = read(t);
|
|
461
|
+
if (t.l & CONFIG_GUESS && t.m & (STATUS_PENDING | STATUS_ERROR)) throw t.T?.F;
|
|
462
|
+
return e;
|
|
442
463
|
}, t => {
|
|
443
464
|
n(typeof e === "function" ? t : e);
|
|
444
465
|
dispose(c);
|
|
445
466
|
}, e => {
|
|
446
467
|
o(e);
|
|
447
468
|
dispose(c);
|
|
448
|
-
}, CONFIG_FRESH_READ, undefined, r);
|
|
449
|
-
make
|
|
469
|
+
}, CONFIG_FRESH_READ | CONFIG_AUTHORITATIVE, undefined, r);
|
|
470
|
+
createRoot(make);
|
|
450
471
|
});
|
|
451
472
|
});
|
|
452
473
|
// Fire-and-forget refresh must not turn a failed refetch into an unhandled
|
|
@@ -495,14 +516,14 @@ function createMemo(e, t) {
|
|
|
495
516
|
// (`saving=true` beside the confirmed `version=1` is a tear no timeline
|
|
496
517
|
// contains). Updates that do not flip the predicate reveal freely.
|
|
497
518
|
const c = flushTransaction;
|
|
498
|
-
createRoot(
|
|
499
|
-
let
|
|
519
|
+
createRoot(i => {
|
|
520
|
+
let u;
|
|
500
521
|
let s;
|
|
501
522
|
const settle = e => {
|
|
502
|
-
if (
|
|
523
|
+
if (u !== undefined) clearTimeout(u);
|
|
503
524
|
if (s !== undefined) o.removeEventListener("abort", s);
|
|
504
525
|
e();
|
|
505
|
-
|
|
526
|
+
i();
|
|
506
527
|
};
|
|
507
528
|
// Authoritative: the predicate sees the truth, never the action's own
|
|
508
529
|
// optimistic guess — a guess cannot satisfy the wait for its own
|
|
@@ -515,9 +536,9 @@ function createMemo(e, t) {
|
|
|
515
536
|
// The flip, inside the pass of the flush carrying it: the flush
|
|
516
537
|
// joins the action's transaction, and what it staged is held and
|
|
517
538
|
// revealed with the action.
|
|
518
|
-
if (e && c !== null && globalQueue.
|
|
539
|
+
if (e && c !== null && globalQueue.q && resolveTx(c).tt !== 0) joinFuture(c);
|
|
519
540
|
});
|
|
520
|
-
if (t?.timeout !== undefined)
|
|
541
|
+
if (t?.timeout !== undefined) u = setTimeout(() => settle(() => n(new TimeoutError)), t.timeout);
|
|
521
542
|
if (o !== undefined) {
|
|
522
543
|
s = () => settle(() => n(o.reason));
|
|
523
544
|
o.addEventListener("abort", s, {
|
|
@@ -623,7 +644,7 @@ function createMemo(e, t) {
|
|
|
623
644
|
* on owner disposal
|
|
624
645
|
*/ function onSettled(e) {
|
|
625
646
|
const t = getOwner();
|
|
626
|
-
t && !(t.
|
|
647
|
+
t && !(t.l & CONFIG_CHILDREN_FORBIDDEN) ? trackedEffect(() => untrack(e), undefined) : globalQueue.enqueue(EFFECT_USER, function fire() {
|
|
627
648
|
// Settled means derived. A settle that reverts optimism (or replays
|
|
628
649
|
// gated reads) only enqueues the affected subscribers; the pass after
|
|
629
650
|
// the commit re-derives them. Fired in the commit pass, the callback
|
|
@@ -631,7 +652,7 @@ function createMemo(e, t) {
|
|
|
631
652
|
// still holding the optimistic value — reads do not pull (#3411). Fall
|
|
632
653
|
// to the next pass while the heap has work; `run` swapped the queue,
|
|
633
654
|
// so this lands there, and `enqueue` keeps the drain alive.
|
|
634
|
-
if (dirtyQueue.
|
|
655
|
+
if (dirtyQueue.et >= dirtyQueue.Ge) return globalQueue.enqueue(EFFECT_USER, fire);
|
|
635
656
|
// Unowned, out-of-band fire (no owner, or a children-forbidden one this
|
|
636
657
|
// one-shot must not bind to): a returned cleanup has no lifecycle to
|
|
637
658
|
// attach to. Reject it in dev; in production the return is simply
|