@solidjs/signals 2.0.0-beta.14 → 2.0.0-beta.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/README.md +2 -3
- package/dist/dev.js +966 -550
- package/dist/node.cjs +2153 -1821
- package/dist/prod.js +1848 -1530
- package/dist/types/boundaries.d.ts +3 -3
- package/dist/types/core/async.d.ts +1 -0
- package/dist/types/core/core.d.ts +27 -15
- package/dist/types/core/dev.d.ts +10 -2
- package/dist/types/core/effect.d.ts +1 -3
- package/dist/types/core/graph.d.ts +1 -1
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/invariants.d.ts +49 -0
- package/dist/types/core/scheduler.d.ts +8 -0
- package/dist/types/core/types.d.ts +19 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +39 -2
- package/dist/types/store/projection.d.ts +4 -4
- package/dist/types/store/store.d.ts +29 -1
- package/dist/types-cjs/boundaries.d.cts +3 -3
- package/dist/types-cjs/core/async.d.cts +1 -0
- package/dist/types-cjs/core/core.d.cts +27 -15
- package/dist/types-cjs/core/dev.d.cts +10 -2
- package/dist/types-cjs/core/effect.d.cts +1 -3
- package/dist/types-cjs/core/graph.d.cts +1 -1
- package/dist/types-cjs/core/index.d.cts +2 -2
- package/dist/types-cjs/core/invariants.d.cts +49 -0
- package/dist/types-cjs/core/scheduler.d.cts +8 -0
- package/dist/types-cjs/core/types.d.cts +19 -0
- package/dist/types-cjs/index.d.cts +1 -1
- package/dist/types-cjs/signals.d.cts +39 -2
- package/dist/types-cjs/store/projection.d.cts +4 -4
- package/dist/types-cjs/store/store.d.cts +29 -1
- package/package.json +1 -1
- package/dist/types/src/boundaries.d.ts +0 -173
- package/dist/types/src/core/action.d.ts +0 -35
- package/dist/types/src/core/async.d.ts +0 -6
- package/dist/types/src/core/constants.d.ts +0 -51
- package/dist/types/src/core/context.d.ts +0 -36
- package/dist/types/src/core/core.d.ts +0 -174
- package/dist/types/src/core/dev.d.ts +0 -49
- package/dist/types/src/core/effect.d.ts +0 -32
- package/dist/types/src/core/error.d.ts +0 -38
- package/dist/types/src/core/external.d.ts +0 -45
- package/dist/types/src/core/graph.d.ts +0 -5
- package/dist/types/src/core/heap.d.ts +0 -14
- package/dist/types/src/core/index.d.ts +0 -12
- package/dist/types/src/core/lanes.d.ts +0 -54
- package/dist/types/src/core/owner.d.ts +0 -116
- package/dist/types/src/core/scheduler.d.ts +0 -122
- package/dist/types/src/core/types.d.ts +0 -85
- package/dist/types/src/index.d.ts +0 -9
- package/dist/types/src/map.d.ts +0 -53
- package/dist/types/src/signals.d.ts +0 -512
- package/dist/types/src/store/index.d.ts +0 -9
- package/dist/types/src/store/optimistic.d.ts +0 -45
- package/dist/types/src/store/projection.d.ts +0 -66
- package/dist/types/src/store/reconcile.d.ts +0 -23
- package/dist/types/src/store/store.d.ts +0 -125
- package/dist/types/src/store/storePath.d.ts +0 -58
- package/dist/types/src/store/utils.d.ts +0 -114
- package/dist/types-cjs/src/boundaries.d.cts +0 -173
- package/dist/types-cjs/src/core/action.d.cts +0 -35
- package/dist/types-cjs/src/core/async.d.cts +0 -6
- package/dist/types-cjs/src/core/constants.d.cts +0 -51
- package/dist/types-cjs/src/core/context.d.cts +0 -36
- package/dist/types-cjs/src/core/core.d.cts +0 -174
- package/dist/types-cjs/src/core/dev.d.cts +0 -49
- package/dist/types-cjs/src/core/effect.d.cts +0 -32
- package/dist/types-cjs/src/core/error.d.cts +0 -38
- package/dist/types-cjs/src/core/external.d.cts +0 -45
- package/dist/types-cjs/src/core/graph.d.cts +0 -5
- package/dist/types-cjs/src/core/heap.d.cts +0 -14
- package/dist/types-cjs/src/core/index.d.cts +0 -12
- package/dist/types-cjs/src/core/lanes.d.cts +0 -54
- package/dist/types-cjs/src/core/owner.d.cts +0 -116
- package/dist/types-cjs/src/core/scheduler.d.cts +0 -122
- package/dist/types-cjs/src/core/types.d.cts +0 -85
- package/dist/types-cjs/src/index.d.cts +0 -9
- package/dist/types-cjs/src/map.d.cts +0 -53
- package/dist/types-cjs/src/signals.d.cts +0 -512
- package/dist/types-cjs/src/store/index.d.cts +0 -9
- package/dist/types-cjs/src/store/optimistic.d.cts +0 -45
- package/dist/types-cjs/src/store/projection.d.cts +0 -66
- package/dist/types-cjs/src/store/reconcile.d.cts +0 -23
- package/dist/types-cjs/src/store/store.d.cts +0 -125
- package/dist/types-cjs/src/store/storePath.d.cts +0 -58
- package/dist/types-cjs/src/store/utils.d.cts +0 -114
package/dist/prod.js
CHANGED
|
@@ -53,115 +53,19 @@ const STORE_SNAPSHOT_PROPS = "sp";
|
|
|
53
53
|
const SUPPORTS_PROXY = typeof Proxy === "function";
|
|
54
54
|
const defaultContext = {};
|
|
55
55
|
const $REFRESH = Symbol("refresh");
|
|
56
|
-
const diagnosticListeners = new Set();
|
|
57
|
-
const diagnosticCaptures = new Set();
|
|
58
|
-
let diagnosticSequence = 0;
|
|
59
56
|
const DEV$1 = undefined;
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
for (const e of diagnosticListeners) e(t);
|
|
63
|
-
for (const e of diagnosticCaptures) e.push(t);
|
|
64
|
-
return t;
|
|
65
|
-
}
|
|
66
|
-
function actualInsertIntoHeap(e, t) {
|
|
67
|
-
const n = (e.i?.t ? e.i.u?.o : e.i?.o) ?? -1;
|
|
68
|
-
if (n >= e.o) e.o = n + 1;
|
|
69
|
-
const i = e.o;
|
|
70
|
-
const r = t.l[i];
|
|
71
|
-
if (r === undefined) t.l[i] = e;
|
|
72
|
-
else {
|
|
73
|
-
const t = r.S;
|
|
74
|
-
t.T = e;
|
|
75
|
-
e.S = t;
|
|
76
|
-
r.S = e;
|
|
77
|
-
}
|
|
78
|
-
if (i > t._) t._ = i;
|
|
79
|
-
}
|
|
80
|
-
function insertIntoHeap(e, t) {
|
|
81
|
-
let n = e.O;
|
|
82
|
-
if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_MANUAL_WRITE)) return;
|
|
83
|
-
if (n & REACTIVE_CHECK) {
|
|
84
|
-
e.O = (n & -4) | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
|
|
85
|
-
} else e.O = n | REACTIVE_IN_HEAP;
|
|
86
|
-
if (!(n & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, t);
|
|
57
|
+
function devCheckActiveOverrides(e) {
|
|
58
|
+
return;
|
|
87
59
|
}
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
n &
|
|
92
|
-
(REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_MANUAL_WRITE)
|
|
93
|
-
)
|
|
94
|
-
return;
|
|
95
|
-
e.O = n | REACTIVE_IN_HEAP_HEIGHT;
|
|
96
|
-
actualInsertIntoHeap(e, t);
|
|
60
|
+
function devCheckFlushStart() {
|
|
61
|
+
return;
|
|
97
62
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
e.O = n & -25;
|
|
102
|
-
const i = e.o;
|
|
103
|
-
if (e.S === e) t.l[i] = undefined;
|
|
104
|
-
else {
|
|
105
|
-
const n = e.T;
|
|
106
|
-
const r = t.l[i];
|
|
107
|
-
const o = n ?? r;
|
|
108
|
-
if (e === r) t.l[i] = n;
|
|
109
|
-
else e.S.T = n;
|
|
110
|
-
o.S = e.S;
|
|
111
|
-
}
|
|
112
|
-
e.S = e;
|
|
113
|
-
e.T = undefined;
|
|
63
|
+
typeof globalThis !== "undefined" && !!globalThis.process?.env?.COMPANION_CENSUS;
|
|
64
|
+
function devCensusCompanions(e) {
|
|
65
|
+
return;
|
|
114
66
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
e.R = true;
|
|
118
|
-
for (let t = 0; t <= e._; t++) {
|
|
119
|
-
for (let n = e.l[t]; n !== undefined; n = n.T) {
|
|
120
|
-
if (n.O & REACTIVE_IN_HEAP) markNode(n);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function markNode(e, t = REACTIVE_DIRTY) {
|
|
125
|
-
const n = e.O;
|
|
126
|
-
if ((n & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return;
|
|
127
|
-
e.O = (n & -4) | t;
|
|
128
|
-
for (let t = e.I; t !== null; t = t.p) {
|
|
129
|
-
markNode(t.h, REACTIVE_CHECK);
|
|
130
|
-
}
|
|
131
|
-
if (e.N !== null) {
|
|
132
|
-
for (let t = e.N; t !== null; t = t.A) {
|
|
133
|
-
for (let e = t.I; e !== null; e = e.p) {
|
|
134
|
-
markNode(e.h, REACTIVE_CHECK);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function runHeap(e, t) {
|
|
140
|
-
e.R = false;
|
|
141
|
-
for (e.C = 0; e.C <= e._; e.C++) {
|
|
142
|
-
let n = e.l[e.C];
|
|
143
|
-
while (n !== undefined) {
|
|
144
|
-
if (n.O & REACTIVE_IN_HEAP) t(n);
|
|
145
|
-
else adjustHeight(n, e);
|
|
146
|
-
n = e.l[e.C];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
e._ = 0;
|
|
150
|
-
}
|
|
151
|
-
function adjustHeight(e, t) {
|
|
152
|
-
deleteFromHeap(e, t);
|
|
153
|
-
let n = e.o;
|
|
154
|
-
for (let t = e.P; t; t = t.D) {
|
|
155
|
-
const e = t.m;
|
|
156
|
-
const i = e.V || e;
|
|
157
|
-
if (i.L && i.o >= n) n = i.o + 1;
|
|
158
|
-
}
|
|
159
|
-
if (e.o !== n) {
|
|
160
|
-
e.o = n;
|
|
161
|
-
for (let n = e.I; n !== null; n = n.p) {
|
|
162
|
-
insertIntoHeapHeight(n.h, t);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
67
|
+
function devCheckQuiescent(e) {
|
|
68
|
+
return;
|
|
165
69
|
}
|
|
166
70
|
const signalLanes = new WeakMap();
|
|
167
71
|
const activeLanes = new Set();
|
|
@@ -170,69 +74,73 @@ function getOrCreateLane(e) {
|
|
|
170
74
|
if (t) {
|
|
171
75
|
return findLane(t);
|
|
172
76
|
}
|
|
173
|
-
const n = e.
|
|
174
|
-
const i = n?.
|
|
175
|
-
t = {
|
|
77
|
+
const n = e.t;
|
|
78
|
+
const i = n?.i ? findLane(n.i) : null;
|
|
79
|
+
t = { o: e, u: new Set(), l: [[], []], S: null, T: activeTransition, _: i };
|
|
176
80
|
signalLanes.set(e, t);
|
|
177
81
|
activeLanes.add(t);
|
|
178
|
-
e.$ = false;
|
|
179
82
|
return t;
|
|
180
83
|
}
|
|
181
84
|
function findLane(e) {
|
|
182
|
-
while (e.
|
|
85
|
+
while (e.S) e = e.S;
|
|
183
86
|
return e;
|
|
184
87
|
}
|
|
185
88
|
function mergeLanes(e, t) {
|
|
186
89
|
e = findLane(e);
|
|
187
90
|
t = findLane(t);
|
|
188
91
|
if (e === t) return e;
|
|
189
|
-
t.
|
|
190
|
-
for (const n of t.
|
|
191
|
-
|
|
192
|
-
e.
|
|
92
|
+
t.S = e;
|
|
93
|
+
for (const n of t.u) e.u.add(n);
|
|
94
|
+
t.u.clear();
|
|
95
|
+
e.l[0].push(...t.l[0]);
|
|
96
|
+
e.l[1].push(...t.l[1]);
|
|
97
|
+
t.l[0].length = 0;
|
|
98
|
+
t.l[1].length = 0;
|
|
193
99
|
return e;
|
|
194
100
|
}
|
|
195
101
|
function resolveLane(e) {
|
|
196
|
-
const t = e.
|
|
102
|
+
const t = e.i;
|
|
197
103
|
if (!t) return undefined;
|
|
198
104
|
const n = findLane(t);
|
|
199
105
|
if (activeLanes.has(n)) return n;
|
|
200
|
-
e.
|
|
106
|
+
e.i = undefined;
|
|
201
107
|
return undefined;
|
|
202
108
|
}
|
|
203
109
|
function resolveTransition(e) {
|
|
204
|
-
return resolveLane(e)?.
|
|
110
|
+
return resolveLane(e)?.T ?? e.T;
|
|
205
111
|
}
|
|
206
112
|
function hasActiveOverride(e) {
|
|
207
|
-
return !!(e.
|
|
113
|
+
return !!(e.O !== undefined && e.O !== NOT_PENDING);
|
|
208
114
|
}
|
|
209
115
|
function assignOrMergeLane(e, t) {
|
|
210
116
|
const n = findLane(t);
|
|
211
|
-
const i = e.
|
|
117
|
+
const i = e.i;
|
|
212
118
|
if (i) {
|
|
213
|
-
if (i.
|
|
214
|
-
e.
|
|
119
|
+
if (i.S) {
|
|
120
|
+
e.i = t;
|
|
215
121
|
return;
|
|
216
122
|
}
|
|
217
123
|
const r = findLane(i);
|
|
218
124
|
if (activeLanes.has(r)) {
|
|
219
125
|
if (r !== n && !hasActiveOverride(e)) {
|
|
220
|
-
if (n.
|
|
221
|
-
e.
|
|
222
|
-
} else if (r.
|
|
126
|
+
if (n._ && findLane(n._) === r) {
|
|
127
|
+
e.i = t;
|
|
128
|
+
} else if (r._ && findLane(r._) === n);
|
|
223
129
|
else mergeLanes(n, r);
|
|
224
130
|
}
|
|
225
131
|
return;
|
|
226
132
|
}
|
|
227
133
|
}
|
|
228
|
-
e.
|
|
134
|
+
e.i = t;
|
|
229
135
|
}
|
|
230
136
|
const transitions = new Set();
|
|
231
|
-
const dirtyQueue = {
|
|
232
|
-
const zombieQueue = {
|
|
137
|
+
const dirtyQueue = { p: new Array(2e3).fill(undefined), R: false, I: 0, h: 0 };
|
|
138
|
+
const zombieQueue = { p: new Array(2e3).fill(undefined), R: false, I: 0, h: 0 };
|
|
233
139
|
let clock = 0;
|
|
234
140
|
let activeTransition = null;
|
|
235
141
|
let scheduled = false;
|
|
142
|
+
let halted = false;
|
|
143
|
+
let haltNotified = false;
|
|
236
144
|
let syncDepth = 0;
|
|
237
145
|
let projectionWriteActive = false;
|
|
238
146
|
let stashedOptimisticReads = null;
|
|
@@ -244,23 +152,23 @@ function canUseSimpleSyncFlush(e) {
|
|
|
244
152
|
return (
|
|
245
153
|
transitions.size === 0 &&
|
|
246
154
|
activeLanes.size === 0 &&
|
|
247
|
-
e.
|
|
248
|
-
e.
|
|
249
|
-
e.
|
|
155
|
+
e.A.length === 0 &&
|
|
156
|
+
e.N.length === 0 &&
|
|
157
|
+
e.C.size === 0 &&
|
|
250
158
|
transientStoreNodes.size === 0
|
|
251
159
|
);
|
|
252
160
|
}
|
|
253
161
|
function sweepTransientStoreNodes() {
|
|
254
162
|
if (transientStoreNodes.size === 0) return;
|
|
255
163
|
for (const e of transientStoreNodes) {
|
|
256
|
-
if (e.
|
|
164
|
+
if (e.P !== null) {
|
|
257
165
|
transientStoreNodes.delete(e);
|
|
258
166
|
continue;
|
|
259
167
|
}
|
|
260
|
-
if (e.
|
|
261
|
-
if (e.
|
|
168
|
+
if (e.D !== NOT_PENDING) continue;
|
|
169
|
+
if (e.O !== undefined && e.O !== NOT_PENDING) continue;
|
|
262
170
|
transientStoreNodes.delete(e);
|
|
263
|
-
e.
|
|
171
|
+
e.m?.();
|
|
264
172
|
}
|
|
265
173
|
}
|
|
266
174
|
function enforceLoadingBoundary(e) {}
|
|
@@ -269,27 +177,27 @@ function shouldReadStashedOptimisticValue(e) {
|
|
|
269
177
|
}
|
|
270
178
|
function runLaneEffects(e) {
|
|
271
179
|
for (const t of activeLanes) {
|
|
272
|
-
if (t.
|
|
273
|
-
const n = t.
|
|
180
|
+
if (t.S || t.u.size > 0) continue;
|
|
181
|
+
const n = t.l[e - 1];
|
|
274
182
|
if (n.length) {
|
|
275
|
-
t.
|
|
183
|
+
t.l[e - 1] = [];
|
|
276
184
|
runQueue(n, e);
|
|
277
185
|
}
|
|
278
186
|
}
|
|
279
187
|
}
|
|
280
188
|
function queueStashedOptimisticEffects(e) {
|
|
281
|
-
for (let t = e.
|
|
282
|
-
const e = t.
|
|
283
|
-
if (!e.
|
|
284
|
-
if (e.
|
|
285
|
-
if (!e.
|
|
286
|
-
e.
|
|
287
|
-
e.
|
|
189
|
+
for (let t = e.P; t !== null; t = t.L) {
|
|
190
|
+
const e = t.U;
|
|
191
|
+
if (!e.V) continue;
|
|
192
|
+
if (e.V === EFFECT_TRACKED) {
|
|
193
|
+
if (!e.G) {
|
|
194
|
+
e.G = true;
|
|
195
|
+
e.F.enqueue(EFFECT_USER, e.k);
|
|
288
196
|
}
|
|
289
197
|
continue;
|
|
290
198
|
}
|
|
291
|
-
const n = e.
|
|
292
|
-
if (n.
|
|
199
|
+
const n = e.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
200
|
+
if (n.I > e.H) n.I = e.H;
|
|
293
201
|
insertIntoHeap(e, n);
|
|
294
202
|
}
|
|
295
203
|
}
|
|
@@ -297,153 +205,177 @@ function setProjectionWriteActive(e) {
|
|
|
297
205
|
projectionWriteActive = e;
|
|
298
206
|
}
|
|
299
207
|
function mergeTransitionState(e, t) {
|
|
300
|
-
t.
|
|
301
|
-
e.
|
|
302
|
-
for (const n of activeLanes) if (n.
|
|
303
|
-
e.
|
|
304
|
-
for (const n of t.
|
|
305
|
-
for (const [n, i] of t
|
|
306
|
-
let t = e
|
|
307
|
-
if (!t) e
|
|
208
|
+
t.M = e;
|
|
209
|
+
e.j.push(...t.j);
|
|
210
|
+
for (const n of activeLanes) if (n.T === t) n.T = e;
|
|
211
|
+
e.N.push(...t.N);
|
|
212
|
+
for (const n of t.C) e.C.add(n);
|
|
213
|
+
for (const [n, i] of t.$) {
|
|
214
|
+
let t = e.$.get(n);
|
|
215
|
+
if (!t) e.$.set(n, (t = new Set()));
|
|
308
216
|
for (const e of i) t.add(e);
|
|
309
217
|
}
|
|
310
|
-
for (const n of t.
|
|
218
|
+
for (const n of t.K) e.K.add(n);
|
|
311
219
|
}
|
|
312
220
|
function resolveOptimisticNodes(e) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
221
|
+
const t = e.length;
|
|
222
|
+
for (let n = 0; n < t; n++) {
|
|
223
|
+
const t = e[n];
|
|
224
|
+
t.i = undefined;
|
|
225
|
+
if (!(t.Y & STATUS_PENDING)) t.Y &= ~STATUS_UNINITIALIZED;
|
|
226
|
+
const i = t.O;
|
|
227
|
+
t.O = NOT_PENDING;
|
|
228
|
+
if (i !== NOT_PENDING && t.Z !== i) insertSubs(t, true);
|
|
229
|
+
t.T = null;
|
|
230
|
+
}
|
|
231
|
+
for (let n = 0; n < t; n++) {
|
|
232
|
+
const t = e[n];
|
|
233
|
+
if (t.B || t.q) snapCompanionsToState(t);
|
|
234
|
+
const i = t.t;
|
|
235
|
+
if (i && (i.B === t || i.q === t)) snapCompanionsToState(i);
|
|
236
|
+
}
|
|
237
|
+
e.splice(0, t);
|
|
326
238
|
}
|
|
327
239
|
function cleanupCompletedLanes(e) {
|
|
328
240
|
for (const t of activeLanes) {
|
|
329
|
-
const n = e ? t.
|
|
241
|
+
const n = e ? t.T === e : !t.T;
|
|
330
242
|
if (!n) continue;
|
|
331
|
-
if (!t.
|
|
332
|
-
if (t.
|
|
333
|
-
if (t.
|
|
334
|
-
}
|
|
335
|
-
if (t.
|
|
336
|
-
t.
|
|
337
|
-
t.
|
|
338
|
-
t.
|
|
243
|
+
if (!t.S) {
|
|
244
|
+
if (t.l[0].length) runQueue(t.l[0], EFFECT_RENDER);
|
|
245
|
+
if (t.l[1].length) runQueue(t.l[1], EFFECT_USER);
|
|
246
|
+
}
|
|
247
|
+
if (t.o.i === t) t.o.i = undefined;
|
|
248
|
+
t.u.clear();
|
|
249
|
+
t.l[0].length = 0;
|
|
250
|
+
t.l[1].length = 0;
|
|
339
251
|
activeLanes.delete(t);
|
|
340
|
-
signalLanes.delete(t.
|
|
252
|
+
signalLanes.delete(t.o);
|
|
341
253
|
}
|
|
342
254
|
}
|
|
343
255
|
function schedule() {
|
|
256
|
+
if (halted) {
|
|
257
|
+
notifyHalted();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
344
260
|
if (scheduled) return;
|
|
345
261
|
scheduled = true;
|
|
346
|
-
if (!syncDepth && !globalQueue.
|
|
262
|
+
if (!syncDepth && !globalQueue.X && !projectionWriteActive) queueMicrotask(flush);
|
|
263
|
+
}
|
|
264
|
+
function haltReactivity() {
|
|
265
|
+
if (halted) return;
|
|
266
|
+
halted = true;
|
|
267
|
+
let e = "[REACTIVITY_HALTED] An uncaught error halted the reactive system.";
|
|
268
|
+
console.error(e);
|
|
269
|
+
}
|
|
270
|
+
function notifyHalted() {
|
|
271
|
+
if (haltNotified) return;
|
|
272
|
+
haltNotified = true;
|
|
273
|
+
console.error("[REACTIVITY_HALTED] Update ignored.");
|
|
274
|
+
}
|
|
275
|
+
function resetErrorHalt() {
|
|
276
|
+
halted = false;
|
|
277
|
+
haltNotified = false;
|
|
347
278
|
}
|
|
348
279
|
class Queue {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
280
|
+
J = null;
|
|
281
|
+
ee = [[], []];
|
|
282
|
+
A = [];
|
|
352
283
|
created = clock;
|
|
353
284
|
addChild(e) {
|
|
354
|
-
this.
|
|
355
|
-
e.
|
|
285
|
+
this.A.push(e);
|
|
286
|
+
e.J = this;
|
|
356
287
|
}
|
|
357
288
|
removeChild(e) {
|
|
358
|
-
const t = this.
|
|
289
|
+
const t = this.A.indexOf(e);
|
|
359
290
|
if (t >= 0) {
|
|
360
|
-
this.
|
|
361
|
-
e.
|
|
291
|
+
this.A.splice(t, 1);
|
|
292
|
+
e.J = null;
|
|
362
293
|
}
|
|
363
294
|
}
|
|
364
295
|
notify(e, t, n, i) {
|
|
365
|
-
if (this.
|
|
296
|
+
if (this.J) return this.J.notify(e, t, n, i);
|
|
366
297
|
return false;
|
|
367
298
|
}
|
|
368
299
|
run(e) {
|
|
369
|
-
if (this.
|
|
370
|
-
const t = this.
|
|
371
|
-
this.
|
|
300
|
+
if (this.ee[e - 1].length) {
|
|
301
|
+
const t = this.ee[e - 1];
|
|
302
|
+
this.ee[e - 1] = [];
|
|
372
303
|
runQueue(t, e);
|
|
373
304
|
}
|
|
374
|
-
for (let t = 0; t < this.
|
|
305
|
+
for (let t = 0; t < this.A.length; t++) this.A[t].run?.(e);
|
|
375
306
|
}
|
|
376
307
|
enqueue(e, t) {
|
|
377
308
|
if (e) {
|
|
378
309
|
if (currentOptimisticLane) {
|
|
379
310
|
const n = findLane(currentOptimisticLane);
|
|
380
|
-
n.
|
|
311
|
+
n.l[e - 1].push(t);
|
|
381
312
|
} else {
|
|
382
|
-
this.
|
|
313
|
+
this.ee[e - 1].push(t);
|
|
383
314
|
}
|
|
384
315
|
}
|
|
385
316
|
schedule();
|
|
386
317
|
}
|
|
387
318
|
stashQueues(e) {
|
|
388
|
-
e.
|
|
389
|
-
e.
|
|
390
|
-
this.
|
|
391
|
-
for (let t = 0; t < this.
|
|
392
|
-
let n = this.
|
|
393
|
-
let i = e.
|
|
319
|
+
e.ee[0].push(...this.ee[0]);
|
|
320
|
+
e.ee[1].push(...this.ee[1]);
|
|
321
|
+
this.ee = [[], []];
|
|
322
|
+
for (let t = 0; t < this.A.length; t++) {
|
|
323
|
+
let n = this.A[t];
|
|
324
|
+
let i = e.A[t];
|
|
394
325
|
if (!i) {
|
|
395
|
-
i = {
|
|
396
|
-
e.
|
|
326
|
+
i = { ee: [[], []], A: [] };
|
|
327
|
+
e.A[t] = i;
|
|
397
328
|
}
|
|
398
329
|
n.stashQueues(i);
|
|
399
330
|
}
|
|
400
331
|
}
|
|
401
332
|
restoreQueues(e) {
|
|
402
|
-
this.
|
|
403
|
-
this.
|
|
404
|
-
for (let t = 0; t < e.
|
|
405
|
-
const n = e.
|
|
406
|
-
let i = this.
|
|
333
|
+
this.ee[0].push(...e.ee[0]);
|
|
334
|
+
this.ee[1].push(...e.ee[1]);
|
|
335
|
+
for (let t = 0; t < e.A.length; t++) {
|
|
336
|
+
const n = e.A[t];
|
|
337
|
+
let i = this.A[t];
|
|
407
338
|
if (i) i.restoreQueues(n);
|
|
408
339
|
}
|
|
409
340
|
}
|
|
410
341
|
}
|
|
411
342
|
class GlobalQueue extends Queue {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
static
|
|
418
|
-
static
|
|
419
|
-
static
|
|
420
|
-
static
|
|
343
|
+
X = false;
|
|
344
|
+
te = null;
|
|
345
|
+
ne = [];
|
|
346
|
+
N = [];
|
|
347
|
+
C = new Set();
|
|
348
|
+
static ie;
|
|
349
|
+
static re;
|
|
350
|
+
static oe;
|
|
351
|
+
static se = null;
|
|
421
352
|
flush() {
|
|
422
|
-
if (this.
|
|
423
|
-
this.
|
|
353
|
+
if (this.X) return;
|
|
354
|
+
this.X = true;
|
|
424
355
|
try {
|
|
425
|
-
|
|
356
|
+
if (false);
|
|
357
|
+
runHeap(dirtyQueue, GlobalQueue.ie);
|
|
426
358
|
if (activeTransition) {
|
|
427
359
|
const e = transitionComplete(activeTransition);
|
|
428
360
|
if (!e) {
|
|
429
361
|
const e = activeTransition;
|
|
430
|
-
runHeap(zombieQueue, GlobalQueue.
|
|
431
|
-
this.
|
|
432
|
-
this.
|
|
433
|
-
this.
|
|
434
|
-
this.
|
|
362
|
+
runHeap(zombieQueue, GlobalQueue.ie);
|
|
363
|
+
this.te = null;
|
|
364
|
+
this.ne = [];
|
|
365
|
+
this.N = [];
|
|
366
|
+
this.C = new Set();
|
|
435
367
|
runLaneEffects(EFFECT_RENDER);
|
|
436
368
|
runLaneEffects(EFFECT_USER);
|
|
437
|
-
this.stashQueues(e.
|
|
369
|
+
this.stashQueues(e.ue);
|
|
438
370
|
clock++;
|
|
439
|
-
scheduled = dirtyQueue.
|
|
440
|
-
reassignPendingTransition(e.
|
|
371
|
+
scheduled = dirtyQueue.h >= dirtyQueue.I;
|
|
372
|
+
reassignPendingTransition(e.ne);
|
|
441
373
|
activeTransition = null;
|
|
442
|
-
if (!e.
|
|
374
|
+
if (!e.j.length && !e.$.size && e.N.length) {
|
|
443
375
|
stashedOptimisticReads = new Set();
|
|
444
|
-
for (let t = 0; t < e.
|
|
445
|
-
const n = e.
|
|
446
|
-
if (n.
|
|
376
|
+
for (let t = 0; t < e.N.length; t++) {
|
|
377
|
+
const n = e.N[t];
|
|
378
|
+
if (n.ce || n.le & CONFIG_OWNED_WRITE) continue;
|
|
447
379
|
stashedOptimisticReads.add(n);
|
|
448
380
|
queueStashedOptimisticEffects(n);
|
|
449
381
|
}
|
|
@@ -455,44 +387,52 @@ class GlobalQueue extends Queue {
|
|
|
455
387
|
}
|
|
456
388
|
return;
|
|
457
389
|
}
|
|
458
|
-
this.
|
|
459
|
-
this.restoreQueues(activeTransition.
|
|
390
|
+
this.ne !== activeTransition.ne && this.ne.push(...activeTransition.ne);
|
|
391
|
+
this.restoreQueues(activeTransition.ue);
|
|
460
392
|
transitions.delete(activeTransition);
|
|
461
393
|
const t = activeTransition;
|
|
462
394
|
activeTransition = null;
|
|
463
|
-
reassignPendingTransition(this.
|
|
395
|
+
reassignPendingTransition(this.ne);
|
|
464
396
|
finalizePureQueue(t);
|
|
465
397
|
} else {
|
|
466
398
|
if (canUseSimpleSyncFlush(this)) {
|
|
467
399
|
commitPendingNodes();
|
|
468
|
-
if (dirtyQueue.
|
|
469
|
-
runHeap(dirtyQueue, GlobalQueue.
|
|
400
|
+
if (dirtyQueue.h >= dirtyQueue.I) {
|
|
401
|
+
runHeap(dirtyQueue, GlobalQueue.ie);
|
|
470
402
|
commitPendingNodes();
|
|
471
403
|
}
|
|
472
404
|
} else {
|
|
473
|
-
if (transitions.size) runHeap(zombieQueue, GlobalQueue.
|
|
405
|
+
if (transitions.size) runHeap(zombieQueue, GlobalQueue.ie);
|
|
474
406
|
finalizePureQueue();
|
|
475
407
|
}
|
|
476
408
|
}
|
|
477
409
|
clock++;
|
|
478
|
-
scheduled = dirtyQueue.
|
|
410
|
+
scheduled = dirtyQueue.h >= dirtyQueue.I;
|
|
479
411
|
activeLanes.size && runLaneEffects(EFFECT_RENDER);
|
|
480
412
|
this.run(EFFECT_RENDER);
|
|
481
413
|
activeLanes.size && runLaneEffects(EFFECT_USER);
|
|
482
414
|
this.run(EFFECT_USER);
|
|
483
415
|
if (false);
|
|
416
|
+
if (
|
|
417
|
+
false &&
|
|
418
|
+
!scheduled &&
|
|
419
|
+
!activeTransition &&
|
|
420
|
+
transitions.size === 0 &&
|
|
421
|
+
activeLanes.size === 0
|
|
422
|
+
);
|
|
423
|
+
if (false);
|
|
484
424
|
} finally {
|
|
485
|
-
this.
|
|
425
|
+
this.X = false;
|
|
486
426
|
}
|
|
487
427
|
}
|
|
488
428
|
notify(e, t, n, i) {
|
|
489
429
|
if (t & STATUS_PENDING) {
|
|
490
430
|
if (n & STATUS_PENDING) {
|
|
491
|
-
const t = i !== undefined ? i : e.
|
|
431
|
+
const t = i !== undefined ? i : e.ae;
|
|
492
432
|
if (activeTransition && t) {
|
|
493
433
|
const n = t.source;
|
|
494
|
-
let i = activeTransition
|
|
495
|
-
if (!i) activeTransition
|
|
434
|
+
let i = activeTransition.$.get(n);
|
|
435
|
+
if (!i) activeTransition.$.set(n, (i = new Set()));
|
|
496
436
|
const r = i.size;
|
|
497
437
|
i.add(e);
|
|
498
438
|
if (i.size !== r) schedule();
|
|
@@ -505,18 +445,18 @@ class GlobalQueue extends Queue {
|
|
|
505
445
|
initTransition(e) {
|
|
506
446
|
if (e) e = currentTransition(e);
|
|
507
447
|
if (e && e === activeTransition) return;
|
|
508
|
-
if (!e && activeTransition && activeTransition.
|
|
448
|
+
if (!e && activeTransition && activeTransition.fe === clock) return;
|
|
509
449
|
if (!activeTransition) {
|
|
510
450
|
activeTransition = e ?? {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
451
|
+
fe: clock,
|
|
452
|
+
ne: [],
|
|
453
|
+
$: new Map(),
|
|
454
|
+
N: [],
|
|
455
|
+
C: new Set(),
|
|
456
|
+
j: [],
|
|
457
|
+
ue: { ee: [[], []], A: [] },
|
|
458
|
+
M: false,
|
|
459
|
+
K: new Set()
|
|
520
460
|
};
|
|
521
461
|
} else if (e) {
|
|
522
462
|
const t = activeTransition;
|
|
@@ -525,104 +465,106 @@ class GlobalQueue extends Queue {
|
|
|
525
465
|
activeTransition = e;
|
|
526
466
|
}
|
|
527
467
|
transitions.add(activeTransition);
|
|
528
|
-
activeTransition.
|
|
529
|
-
if (this.
|
|
530
|
-
this.
|
|
531
|
-
activeTransition.
|
|
532
|
-
this.
|
|
533
|
-
}
|
|
534
|
-
if (this.
|
|
535
|
-
for (let e = 0; e < this.
|
|
536
|
-
const t = this.
|
|
537
|
-
t.
|
|
538
|
-
activeTransition.
|
|
468
|
+
activeTransition.fe = clock;
|
|
469
|
+
if (this.te !== null) {
|
|
470
|
+
this.te.T = activeTransition;
|
|
471
|
+
activeTransition.ne.push(this.te);
|
|
472
|
+
this.te = null;
|
|
473
|
+
}
|
|
474
|
+
if (this.ne !== activeTransition.ne) {
|
|
475
|
+
for (let e = 0; e < this.ne.length; e++) {
|
|
476
|
+
const t = this.ne[e];
|
|
477
|
+
t.T = activeTransition;
|
|
478
|
+
activeTransition.ne.push(t);
|
|
539
479
|
}
|
|
540
|
-
this.
|
|
480
|
+
this.ne = activeTransition.ne;
|
|
541
481
|
}
|
|
542
|
-
if (this.
|
|
543
|
-
for (let e = 0; e < this.
|
|
544
|
-
const t = this.
|
|
545
|
-
t.
|
|
546
|
-
activeTransition.
|
|
482
|
+
if (this.N !== activeTransition.N) {
|
|
483
|
+
for (let e = 0; e < this.N.length; e++) {
|
|
484
|
+
const t = this.N[e];
|
|
485
|
+
t.T = activeTransition;
|
|
486
|
+
activeTransition.N.push(t);
|
|
547
487
|
}
|
|
548
|
-
this.
|
|
488
|
+
this.N = activeTransition.N;
|
|
549
489
|
}
|
|
550
490
|
for (const e of activeLanes) {
|
|
551
|
-
if (!e.
|
|
491
|
+
if (!e.T) e.T = activeTransition;
|
|
552
492
|
}
|
|
553
|
-
if (this.
|
|
554
|
-
for (const e of this.
|
|
555
|
-
this.
|
|
493
|
+
if (this.C !== activeTransition.C) {
|
|
494
|
+
for (const e of this.C) activeTransition.C.add(e);
|
|
495
|
+
this.C = activeTransition.C;
|
|
556
496
|
}
|
|
557
497
|
}
|
|
558
498
|
}
|
|
559
499
|
function queuePendingNode(e) {
|
|
560
500
|
if (activeTransition) {
|
|
561
|
-
globalQueue.
|
|
501
|
+
globalQueue.ne.push(e);
|
|
562
502
|
return;
|
|
563
503
|
}
|
|
564
|
-
if (globalQueue.
|
|
565
|
-
globalQueue.
|
|
504
|
+
if (globalQueue.te === null && globalQueue.ne.length === 0) {
|
|
505
|
+
globalQueue.te = e;
|
|
566
506
|
return;
|
|
567
507
|
}
|
|
568
|
-
if (globalQueue.
|
|
569
|
-
globalQueue.
|
|
570
|
-
globalQueue.
|
|
508
|
+
if (globalQueue.te !== null) {
|
|
509
|
+
globalQueue.ne.push(globalQueue.te);
|
|
510
|
+
globalQueue.te = null;
|
|
571
511
|
}
|
|
572
|
-
globalQueue.
|
|
512
|
+
globalQueue.ne.push(e);
|
|
573
513
|
}
|
|
574
514
|
function insertSubs(e, t = false) {
|
|
575
|
-
const n = e.
|
|
576
|
-
const i = e.
|
|
577
|
-
for (let r = e.
|
|
578
|
-
if (i && r.
|
|
579
|
-
r.
|
|
515
|
+
const n = e.i || currentOptimisticLane;
|
|
516
|
+
const i = e.Ee !== undefined;
|
|
517
|
+
for (let r = e.P; r !== null; r = r.L) {
|
|
518
|
+
if (i && r.U.le & CONFIG_IN_SNAPSHOT_SCOPE) {
|
|
519
|
+
r.U.W |= REACTIVE_SNAPSHOT_STALE;
|
|
580
520
|
continue;
|
|
581
521
|
}
|
|
582
522
|
if (t && n) {
|
|
583
|
-
r.
|
|
584
|
-
assignOrMergeLane(r.
|
|
523
|
+
r.U.W |= REACTIVE_OPTIMISTIC_DIRTY;
|
|
524
|
+
assignOrMergeLane(r.U, n);
|
|
585
525
|
} else if (t) {
|
|
586
|
-
r.
|
|
587
|
-
r.
|
|
588
|
-
}
|
|
589
|
-
const e = r.
|
|
590
|
-
if (e.
|
|
591
|
-
if (!e.
|
|
592
|
-
e.
|
|
593
|
-
e.
|
|
526
|
+
r.U.W |= REACTIVE_OPTIMISTIC_DIRTY;
|
|
527
|
+
r.U.i = undefined;
|
|
528
|
+
}
|
|
529
|
+
const e = r.U;
|
|
530
|
+
if (e.V === EFFECT_TRACKED) {
|
|
531
|
+
if (!e.G) {
|
|
532
|
+
e.G = true;
|
|
533
|
+
e.F.enqueue(EFFECT_USER, e.k);
|
|
594
534
|
}
|
|
595
535
|
continue;
|
|
596
536
|
}
|
|
597
|
-
const o = r.
|
|
598
|
-
if (o.
|
|
599
|
-
insertIntoHeap(r.
|
|
537
|
+
const o = r.U.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
538
|
+
if (o.I > r.U.H) o.I = r.U.H;
|
|
539
|
+
insertIntoHeap(r.U, o);
|
|
600
540
|
}
|
|
601
541
|
}
|
|
602
542
|
function commitPendingNode(e) {
|
|
603
543
|
const t = e;
|
|
604
|
-
if (!t.
|
|
605
|
-
if (e.
|
|
606
|
-
e.
|
|
607
|
-
e.
|
|
544
|
+
if (!t.ce) {
|
|
545
|
+
if (e.D !== NOT_PENDING) {
|
|
546
|
+
e.Z = e.D;
|
|
547
|
+
e.D = NOT_PENDING;
|
|
608
548
|
}
|
|
549
|
+
if (e.B || e.q) snapCompanionsToState(e);
|
|
609
550
|
return;
|
|
610
551
|
}
|
|
611
|
-
if (e.
|
|
612
|
-
e.
|
|
613
|
-
e.
|
|
614
|
-
if (e.
|
|
552
|
+
if (e.D !== NOT_PENDING) {
|
|
553
|
+
e.Z = e.D;
|
|
554
|
+
e.D = NOT_PENDING;
|
|
555
|
+
if (e.V && e.V !== EFFECT_TRACKED) e.G = true;
|
|
615
556
|
}
|
|
616
|
-
t.
|
|
617
|
-
if (!(t.
|
|
618
|
-
if (t.
|
|
557
|
+
t.W &= ~REACTIVE_MANUAL_WRITE;
|
|
558
|
+
if (!(t.Y & STATUS_PENDING)) t.Y &= ~STATUS_UNINITIALIZED;
|
|
559
|
+
if (t.de !== null || t.Se !== null) GlobalQueue.re(t, false, true);
|
|
560
|
+
if (e.B || e.q) snapCompanionsToState(e);
|
|
619
561
|
}
|
|
620
562
|
function commitPendingNodes() {
|
|
621
|
-
if (globalQueue.
|
|
622
|
-
commitPendingNode(globalQueue.
|
|
623
|
-
globalQueue.
|
|
563
|
+
if (globalQueue.te !== null) {
|
|
564
|
+
commitPendingNode(globalQueue.te);
|
|
565
|
+
globalQueue.te = null;
|
|
624
566
|
}
|
|
625
|
-
const e = globalQueue.
|
|
567
|
+
const e = globalQueue.ne;
|
|
626
568
|
for (let t = 0; t < e.length; t++) {
|
|
627
569
|
commitPendingNode(e[t]);
|
|
628
570
|
}
|
|
@@ -631,32 +573,32 @@ function commitPendingNodes() {
|
|
|
631
573
|
function finalizePureQueue(e = null, t = false) {
|
|
632
574
|
const n = !t;
|
|
633
575
|
if (n) commitPendingNodes();
|
|
634
|
-
if (!t && globalQueue.
|
|
635
|
-
const i = dirtyQueue.
|
|
636
|
-
if (i) runHeap(dirtyQueue, GlobalQueue.
|
|
576
|
+
if (!t && globalQueue.A.length) checkBoundaryChildren(globalQueue);
|
|
577
|
+
const i = dirtyQueue.h >= dirtyQueue.I;
|
|
578
|
+
if (i) runHeap(dirtyQueue, GlobalQueue.ie);
|
|
637
579
|
if (n) {
|
|
638
580
|
if (i) commitPendingNodes();
|
|
639
|
-
resolveOptimisticNodes(e ? e.
|
|
640
|
-
if (e && e.
|
|
641
|
-
for (const t of e.
|
|
642
|
-
if (t.
|
|
643
|
-
if (t.
|
|
644
|
-
if (!t.
|
|
645
|
-
t.
|
|
646
|
-
t.
|
|
581
|
+
resolveOptimisticNodes(e ? e.N : globalQueue.N);
|
|
582
|
+
if (e && e.K.size) {
|
|
583
|
+
for (const t of e.K) {
|
|
584
|
+
if (t.W & REACTIVE_DISPOSED) continue;
|
|
585
|
+
if (t.V === EFFECT_TRACKED) {
|
|
586
|
+
if (!t.G) {
|
|
587
|
+
t.G = true;
|
|
588
|
+
t.F.enqueue(EFFECT_USER, t.k);
|
|
647
589
|
}
|
|
648
590
|
continue;
|
|
649
591
|
}
|
|
650
|
-
const e = t.
|
|
651
|
-
if (e.
|
|
592
|
+
const e = t.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
593
|
+
if (e.I > t.H) e.I = t.H;
|
|
652
594
|
insertIntoHeap(t, e);
|
|
653
595
|
}
|
|
654
|
-
e.
|
|
596
|
+
e.K.clear();
|
|
655
597
|
}
|
|
656
|
-
const t = e ? e.
|
|
657
|
-
if (GlobalQueue.
|
|
598
|
+
const t = e ? e.C : globalQueue.C;
|
|
599
|
+
if (GlobalQueue.se && t.size) {
|
|
658
600
|
for (const e of t) {
|
|
659
|
-
GlobalQueue.
|
|
601
|
+
GlobalQueue.se(e);
|
|
660
602
|
}
|
|
661
603
|
t.clear();
|
|
662
604
|
schedule();
|
|
@@ -666,18 +608,18 @@ function finalizePureQueue(e = null, t = false) {
|
|
|
666
608
|
}
|
|
667
609
|
}
|
|
668
610
|
function checkBoundaryChildren(e) {
|
|
669
|
-
for (const t of e.
|
|
611
|
+
for (const t of e.A) {
|
|
670
612
|
t.checkSources?.();
|
|
671
613
|
checkBoundaryChildren(t);
|
|
672
614
|
}
|
|
673
615
|
}
|
|
674
616
|
function trackOptimisticStore(e) {
|
|
675
|
-
globalQueue.
|
|
617
|
+
globalQueue.C.add(e);
|
|
676
618
|
schedule();
|
|
677
619
|
}
|
|
678
620
|
function reassignPendingTransition(e) {
|
|
679
621
|
for (let t = 0; t < e.length; t++) {
|
|
680
|
-
e[t].
|
|
622
|
+
e[t].T = activeTransition;
|
|
681
623
|
}
|
|
682
624
|
}
|
|
683
625
|
const globalQueue = new GlobalQueue();
|
|
@@ -687,13 +629,17 @@ function flush(e) {
|
|
|
687
629
|
try {
|
|
688
630
|
return e();
|
|
689
631
|
} finally {
|
|
690
|
-
|
|
691
|
-
|
|
632
|
+
try {
|
|
633
|
+
flush();
|
|
634
|
+
} finally {
|
|
635
|
+
syncDepth--;
|
|
636
|
+
}
|
|
692
637
|
}
|
|
693
638
|
}
|
|
694
|
-
if (globalQueue.
|
|
639
|
+
if (globalQueue.X) {
|
|
695
640
|
return;
|
|
696
641
|
}
|
|
642
|
+
if (halted) return;
|
|
697
643
|
while (scheduled || activeTransition) {
|
|
698
644
|
globalQueue.flush();
|
|
699
645
|
}
|
|
@@ -702,22 +648,22 @@ function runQueue(e, t) {
|
|
|
702
648
|
for (let n = 0; n < e.length; n++) e[n](t);
|
|
703
649
|
}
|
|
704
650
|
function reporterBlocksSource(e, t) {
|
|
705
|
-
if (e.
|
|
706
|
-
if (e.
|
|
707
|
-
for (let n = e.
|
|
708
|
-
let e = n.
|
|
651
|
+
if (e.W & (REACTIVE_ZOMBIE | REACTIVE_DISPOSED)) return false;
|
|
652
|
+
if (e.Te === t || e._e?.has(t)) return true;
|
|
653
|
+
for (let n = e.Oe; n; n = n.pe) {
|
|
654
|
+
let e = n.Re;
|
|
709
655
|
while (e) {
|
|
710
|
-
if (e === t || e.
|
|
711
|
-
e = e.
|
|
656
|
+
if (e === t || e.Ie === t) return true;
|
|
657
|
+
e = e.t;
|
|
712
658
|
}
|
|
713
659
|
}
|
|
714
|
-
return !!(e.
|
|
660
|
+
return !!(e.Y & STATUS_PENDING && e.ae instanceof NotReadyError && e.ae.source === t);
|
|
715
661
|
}
|
|
716
662
|
function transitionComplete(e) {
|
|
717
|
-
if (e.
|
|
718
|
-
if (e.
|
|
663
|
+
if (e.M) return true;
|
|
664
|
+
if (e.j.length) return false;
|
|
719
665
|
let t = true;
|
|
720
|
-
for (const [n, i] of e
|
|
666
|
+
for (const [n, i] of e.$) {
|
|
721
667
|
let r = false;
|
|
722
668
|
for (const e of i) {
|
|
723
669
|
if (reporterBlocksSource(e, n)) {
|
|
@@ -726,32 +672,31 @@ function transitionComplete(e) {
|
|
|
726
672
|
}
|
|
727
673
|
i.delete(e);
|
|
728
674
|
}
|
|
729
|
-
if (!r) e
|
|
730
|
-
else if (n.
|
|
675
|
+
if (!r) e.$.delete(n);
|
|
676
|
+
else if (n.Y & STATUS_PENDING && n.ae?.source === n) {
|
|
731
677
|
t = false;
|
|
732
678
|
break;
|
|
733
679
|
}
|
|
734
680
|
}
|
|
735
681
|
if (t) {
|
|
736
|
-
for (let n = 0; n < e.
|
|
737
|
-
const i = e.
|
|
682
|
+
for (let n = 0; n < e.N.length; n++) {
|
|
683
|
+
const i = e.N[n];
|
|
738
684
|
if (
|
|
739
685
|
hasActiveOverride(i) &&
|
|
740
|
-
"
|
|
741
|
-
i.
|
|
742
|
-
i.
|
|
743
|
-
i.Re.source !== i
|
|
686
|
+
"Y" in i &&
|
|
687
|
+
i.Y & STATUS_PENDING &&
|
|
688
|
+
i.ae instanceof NotReadyError
|
|
744
689
|
) {
|
|
745
690
|
t = false;
|
|
746
691
|
break;
|
|
747
692
|
}
|
|
748
693
|
}
|
|
749
694
|
}
|
|
750
|
-
t && (e.
|
|
695
|
+
t && (e.M = true);
|
|
751
696
|
return t;
|
|
752
697
|
}
|
|
753
698
|
function currentTransition(e) {
|
|
754
|
-
while (e.
|
|
699
|
+
while (e.M && typeof e.M === "object") e = e.M;
|
|
755
700
|
return e;
|
|
756
701
|
}
|
|
757
702
|
function setActiveTransition(e) {
|
|
@@ -766,67 +711,178 @@ function runInTransition(e, t) {
|
|
|
766
711
|
activeTransition = n;
|
|
767
712
|
}
|
|
768
713
|
}
|
|
714
|
+
function actualInsertIntoHeap(e, t) {
|
|
715
|
+
const n = (e.J?.he ? e.J.Ae?.H : e.J?.H) ?? -1;
|
|
716
|
+
if (n >= e.H) e.H = n + 1;
|
|
717
|
+
const i = e.H;
|
|
718
|
+
const r = t.p[i];
|
|
719
|
+
if (r === undefined) t.p[i] = e;
|
|
720
|
+
else {
|
|
721
|
+
const t = r.Ne;
|
|
722
|
+
t.Ce = e;
|
|
723
|
+
e.Ne = t;
|
|
724
|
+
r.Ne = e;
|
|
725
|
+
}
|
|
726
|
+
if (i > t.h) t.h = i;
|
|
727
|
+
}
|
|
728
|
+
function insertIntoHeap(e, t) {
|
|
729
|
+
let n = e.W;
|
|
730
|
+
if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_MANUAL_WRITE)) return;
|
|
731
|
+
if (n & REACTIVE_CHECK) {
|
|
732
|
+
e.W = (n & -4) | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
|
|
733
|
+
} else e.W = n | REACTIVE_IN_HEAP;
|
|
734
|
+
if (!(n & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, t);
|
|
735
|
+
}
|
|
736
|
+
function insertIntoHeapHeight(e, t) {
|
|
737
|
+
let n = e.W;
|
|
738
|
+
if (
|
|
739
|
+
n &
|
|
740
|
+
(REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_MANUAL_WRITE)
|
|
741
|
+
)
|
|
742
|
+
return;
|
|
743
|
+
e.W = n | REACTIVE_IN_HEAP_HEIGHT;
|
|
744
|
+
actualInsertIntoHeap(e, t);
|
|
745
|
+
}
|
|
746
|
+
function deleteFromHeap(e, t) {
|
|
747
|
+
const n = e.W;
|
|
748
|
+
if (!(n & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
749
|
+
e.W = n & -25;
|
|
750
|
+
const i = e.H;
|
|
751
|
+
if (e.Ne === e) t.p[i] = undefined;
|
|
752
|
+
else {
|
|
753
|
+
const n = e.Ce;
|
|
754
|
+
const r = t.p[i];
|
|
755
|
+
const o = n ?? r;
|
|
756
|
+
if (e === r) t.p[i] = n;
|
|
757
|
+
else e.Ne.Ce = n;
|
|
758
|
+
o.Ne = e.Ne;
|
|
759
|
+
}
|
|
760
|
+
e.Ne = e;
|
|
761
|
+
e.Ce = undefined;
|
|
762
|
+
}
|
|
763
|
+
function markHeap(e) {
|
|
764
|
+
if (e.R) return;
|
|
765
|
+
e.R = true;
|
|
766
|
+
for (let t = 0; t <= e.h; t++) {
|
|
767
|
+
for (let n = e.p[t]; n !== undefined; n = n.Ce) {
|
|
768
|
+
if (n.W & REACTIVE_IN_HEAP) markNode(n);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function markNode(e, t = REACTIVE_DIRTY) {
|
|
773
|
+
const n = e.W;
|
|
774
|
+
if ((n & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return;
|
|
775
|
+
e.W = (n & -4) | t;
|
|
776
|
+
for (let t = e.P; t !== null; t = t.L) {
|
|
777
|
+
markNode(t.U, REACTIVE_CHECK);
|
|
778
|
+
}
|
|
779
|
+
if (e.ye !== null) {
|
|
780
|
+
for (let t = e.ye; t !== null; t = t.Pe) {
|
|
781
|
+
for (let e = t.P; e !== null; e = e.L) {
|
|
782
|
+
markNode(e.U, REACTIVE_CHECK);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
function runHeap(e, t) {
|
|
788
|
+
e.R = false;
|
|
789
|
+
for (e.I = 0; e.I <= e.h; e.I++) {
|
|
790
|
+
let n = e.p[e.I];
|
|
791
|
+
while (n !== undefined) {
|
|
792
|
+
if (n.W & REACTIVE_IN_HEAP) t(n);
|
|
793
|
+
else adjustHeight(n, e);
|
|
794
|
+
n = e.p[e.I];
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
e.h = 0;
|
|
798
|
+
}
|
|
799
|
+
function adjustHeight(e, t) {
|
|
800
|
+
deleteFromHeap(e, t);
|
|
801
|
+
let n = e.H;
|
|
802
|
+
for (let t = e.Oe; t; t = t.pe) {
|
|
803
|
+
const e = t.Re;
|
|
804
|
+
const i = e.Ie || e;
|
|
805
|
+
if (i.ce && i.H >= n) n = i.H + 1;
|
|
806
|
+
}
|
|
807
|
+
if (e.H !== n) {
|
|
808
|
+
e.H = n;
|
|
809
|
+
for (let t = e.P; t !== null; t = t.L) {
|
|
810
|
+
insertIntoHeapHeight(t.U, t.U.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
769
814
|
const PENDING_OWNER = {};
|
|
770
815
|
function markDisposal(e) {
|
|
771
816
|
let t = e.ge;
|
|
772
817
|
while (t) {
|
|
773
|
-
t.
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
818
|
+
const e = t.W;
|
|
819
|
+
t.W = e | REACTIVE_ZOMBIE;
|
|
820
|
+
if (e & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT)) {
|
|
821
|
+
deleteFromHeap(t, e & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
822
|
+
if (e & REACTIVE_IN_HEAP) insertIntoHeap(t, zombieQueue);
|
|
823
|
+
else insertIntoHeapHeight(t, zombieQueue);
|
|
777
824
|
}
|
|
778
825
|
markDisposal(t);
|
|
779
826
|
t = t.De;
|
|
780
827
|
}
|
|
781
828
|
}
|
|
782
829
|
function dispose(e) {
|
|
783
|
-
let t = e.
|
|
784
|
-
|
|
830
|
+
let t = e.Oe;
|
|
831
|
+
while (t !== null) {
|
|
785
832
|
t = unlinkSubs(t);
|
|
786
|
-
}
|
|
787
|
-
e.
|
|
788
|
-
e.
|
|
833
|
+
}
|
|
834
|
+
e.Oe = null;
|
|
835
|
+
e.me = null;
|
|
789
836
|
disposeChildren(e, true);
|
|
790
837
|
}
|
|
791
838
|
function disposeChildren(e, t = false, n) {
|
|
792
|
-
const i = e.
|
|
839
|
+
const i = e.W;
|
|
793
840
|
if (i & REACTIVE_DISPOSED) return;
|
|
794
|
-
if (t)
|
|
795
|
-
|
|
796
|
-
|
|
841
|
+
if (t) {
|
|
842
|
+
e.W = i | REACTIVE_DISPOSED;
|
|
843
|
+
const t = e;
|
|
844
|
+
if (t.B || t.q) snapCompanionsToState(t);
|
|
845
|
+
}
|
|
846
|
+
if (t && e.ce) e.be = null;
|
|
847
|
+
let r = n ? e.de : e.ge;
|
|
797
848
|
while (r) {
|
|
798
849
|
const e = r.De;
|
|
799
|
-
if (r.
|
|
850
|
+
if (r.Oe) {
|
|
800
851
|
const e = r;
|
|
801
|
-
deleteFromHeap(e, e.
|
|
802
|
-
let t = e.
|
|
852
|
+
deleteFromHeap(e, e.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
853
|
+
let t = e.Oe;
|
|
803
854
|
do {
|
|
804
855
|
t = unlinkSubs(t);
|
|
805
856
|
} while (t !== null);
|
|
806
|
-
e.
|
|
807
|
-
e.
|
|
857
|
+
e.Oe = null;
|
|
858
|
+
e.me = null;
|
|
808
859
|
}
|
|
809
860
|
disposeChildren(r, true);
|
|
810
861
|
r = e;
|
|
811
862
|
}
|
|
812
863
|
if (n) {
|
|
813
|
-
e.
|
|
864
|
+
e.de = null;
|
|
814
865
|
} else {
|
|
815
866
|
e.ge = null;
|
|
816
|
-
e.
|
|
867
|
+
e.ve = 0;
|
|
817
868
|
}
|
|
818
|
-
if (t && !n && !(i & REACTIVE_ZOMBIE) && e.
|
|
869
|
+
if (t && !n && !(i & REACTIVE_ZOMBIE) && e.J !== null && !(e.J.W & REACTIVE_DISPOSED)) {
|
|
819
870
|
const t = e.we;
|
|
820
871
|
const n = e.De;
|
|
821
872
|
if (t !== null) t.De = n;
|
|
822
|
-
else e.
|
|
873
|
+
else e.J.ge = n;
|
|
823
874
|
if (n !== null) n.we = t;
|
|
824
875
|
e.we = null;
|
|
825
876
|
}
|
|
826
877
|
runDisposal(e, n);
|
|
878
|
+
if (t && e.Le) {
|
|
879
|
+
const t = e.Le;
|
|
880
|
+
e.Le = undefined;
|
|
881
|
+
t();
|
|
882
|
+
}
|
|
827
883
|
}
|
|
828
884
|
function runDisposal(e, t) {
|
|
829
|
-
let n = t ? e.
|
|
885
|
+
let n = t ? e.Se : e.Ue;
|
|
830
886
|
if (!n) return;
|
|
831
887
|
if (Array.isArray(n)) {
|
|
832
888
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -836,12 +892,12 @@ function runDisposal(e, t) {
|
|
|
836
892
|
} else {
|
|
837
893
|
n.call(n);
|
|
838
894
|
}
|
|
839
|
-
t ? (e.
|
|
895
|
+
t ? (e.Se = null) : (e.Ue = null);
|
|
840
896
|
}
|
|
841
897
|
function childId(e, t) {
|
|
842
898
|
let n = e;
|
|
843
|
-
while (n.
|
|
844
|
-
if (n.id != null) return formatId(n.id, t ? n.
|
|
899
|
+
while (n.le & CONFIG_TRANSPARENT && n.J) n = n.J;
|
|
900
|
+
if (n.id != null) return formatId(n.id, t ? n.ve++ : n.ve);
|
|
845
901
|
throw new Error("Cannot get child id from owner without an id");
|
|
846
902
|
}
|
|
847
903
|
function getNextChildId(e) {
|
|
@@ -864,13 +920,13 @@ function getOwner() {
|
|
|
864
920
|
}
|
|
865
921
|
function cleanup(e) {
|
|
866
922
|
if (!context) return e;
|
|
867
|
-
if (!context.
|
|
868
|
-
else if (Array.isArray(context.
|
|
869
|
-
else context.
|
|
923
|
+
if (!context.Ue) context.Ue = e;
|
|
924
|
+
else if (Array.isArray(context.Ue)) context.Ue.push(e);
|
|
925
|
+
else context.Ue = [context.Ue, e];
|
|
870
926
|
return e;
|
|
871
927
|
}
|
|
872
928
|
function isDisposed(e) {
|
|
873
|
-
return !!(e.
|
|
929
|
+
return !!(e.W & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE));
|
|
874
930
|
}
|
|
875
931
|
function disposeRootSelf(e = true) {
|
|
876
932
|
disposeChildren(this, e);
|
|
@@ -880,19 +936,19 @@ function createOwner(e) {
|
|
|
880
936
|
const n = e?.transparent ?? false;
|
|
881
937
|
const i = {
|
|
882
938
|
id: e?.id ?? (n ? t?.id : t?.id != null ? getNextChildId(t) : undefined),
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
939
|
+
le: n ? CONFIG_TRANSPARENT : 0,
|
|
940
|
+
he: true,
|
|
941
|
+
Ae: t?.he ? t.Ae : t,
|
|
886
942
|
ge: null,
|
|
887
943
|
De: null,
|
|
888
944
|
we: null,
|
|
889
|
-
|
|
890
|
-
|
|
945
|
+
Ue: null,
|
|
946
|
+
F: t?.F ?? globalQueue,
|
|
891
947
|
Ve: t?.Ve || defaultContext,
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
948
|
+
ve: 0,
|
|
949
|
+
Se: null,
|
|
950
|
+
de: null,
|
|
951
|
+
J: t,
|
|
896
952
|
dispose: disposeRootSelf
|
|
897
953
|
};
|
|
898
954
|
if (t) {
|
|
@@ -912,128 +968,137 @@ function createRoot(e, t) {
|
|
|
912
968
|
return runWithOwner(n, () => e(() => n.dispose()));
|
|
913
969
|
}
|
|
914
970
|
function unlinkSubs(e) {
|
|
915
|
-
const t = e.
|
|
916
|
-
const n = e.
|
|
917
|
-
const i = e.
|
|
918
|
-
const r = e.
|
|
919
|
-
if (i !== null) i.
|
|
920
|
-
else t.
|
|
921
|
-
if (r !== null) r.
|
|
971
|
+
const t = e.Re;
|
|
972
|
+
const n = e.pe;
|
|
973
|
+
const i = e.L;
|
|
974
|
+
const r = e.Ge;
|
|
975
|
+
if (i !== null) i.Ge = r;
|
|
976
|
+
else t.Fe = r;
|
|
977
|
+
if (r !== null) r.L = i;
|
|
922
978
|
else {
|
|
923
|
-
t.
|
|
979
|
+
t.P = i;
|
|
924
980
|
if (i === null) {
|
|
925
|
-
t.
|
|
981
|
+
t.m?.();
|
|
926
982
|
const e = t;
|
|
927
|
-
e.
|
|
983
|
+
e.ce && e.le & CONFIG_AUTO_DISPOSE && !(e.W & REACTIVE_ZOMBIE) && unobserved(e);
|
|
928
984
|
}
|
|
929
985
|
}
|
|
930
986
|
return n;
|
|
931
987
|
}
|
|
932
988
|
function trimStaleDeps(e) {
|
|
933
|
-
const t = e.
|
|
934
|
-
let n = t !== null ? t.
|
|
989
|
+
const t = e.me;
|
|
990
|
+
let n = t !== null ? t.pe : e.Oe;
|
|
935
991
|
if (n !== null) {
|
|
936
992
|
do {
|
|
937
993
|
n = unlinkSubs(n);
|
|
938
994
|
} while (n !== null);
|
|
939
|
-
if (t !== null) t.
|
|
940
|
-
else e.
|
|
995
|
+
if (t !== null) t.pe = null;
|
|
996
|
+
else e.Oe = null;
|
|
941
997
|
}
|
|
942
998
|
}
|
|
943
999
|
function unobserved(e) {
|
|
944
|
-
deleteFromHeap(e, e.
|
|
945
|
-
let t = e.
|
|
1000
|
+
deleteFromHeap(e, e.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1001
|
+
let t = e.Oe;
|
|
946
1002
|
while (t !== null) {
|
|
947
1003
|
t = unlinkSubs(t);
|
|
948
1004
|
}
|
|
949
|
-
e.
|
|
950
|
-
e.
|
|
1005
|
+
e.Oe = null;
|
|
1006
|
+
e.me = null;
|
|
951
1007
|
disposeChildren(e, true);
|
|
952
1008
|
}
|
|
953
|
-
function link(e, t) {
|
|
954
|
-
const
|
|
955
|
-
if (
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1009
|
+
function link(e, t, n = false) {
|
|
1010
|
+
const i = t.me;
|
|
1011
|
+
if (i !== null && i.Re === e) {
|
|
1012
|
+
i.ke = n;
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
let r = null;
|
|
1016
|
+
const o = t.W & REACTIVE_RECOMPUTING_DEPS;
|
|
1017
|
+
if (o) {
|
|
1018
|
+
r = i !== null ? i.pe : t.Oe;
|
|
1019
|
+
if (r !== null && r.Re === e) {
|
|
1020
|
+
r.We = t.He;
|
|
1021
|
+
t.me = r;
|
|
1022
|
+
r.ke = n;
|
|
962
1023
|
return;
|
|
963
1024
|
}
|
|
964
1025
|
}
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
else t.P = s;
|
|
970
|
-
if (o !== null) o.p = s;
|
|
971
|
-
else e.I = s;
|
|
972
|
-
}
|
|
973
|
-
function isValidLink(e, t) {
|
|
974
|
-
const n = t.ye;
|
|
975
|
-
if (n !== null) {
|
|
976
|
-
let i = t.P;
|
|
977
|
-
do {
|
|
978
|
-
if (i === e) return true;
|
|
979
|
-
if (i === n) break;
|
|
980
|
-
i = i.D;
|
|
981
|
-
} while (i !== null);
|
|
1026
|
+
const s = e.Fe;
|
|
1027
|
+
if (s !== null && s.U === t && (!o || s.We === t.He)) {
|
|
1028
|
+
s.ke = n;
|
|
1029
|
+
return;
|
|
982
1030
|
}
|
|
983
|
-
|
|
1031
|
+
const u = (t.me = e.Fe = { Re: e, U: t, pe: r, Ge: s, L: null, We: t.He, ke: n });
|
|
1032
|
+
if (i !== null) i.pe = u;
|
|
1033
|
+
else t.Oe = u;
|
|
1034
|
+
if (s !== null) s.L = u;
|
|
1035
|
+
else e.P = u;
|
|
984
1036
|
}
|
|
985
1037
|
function addPendingSource(e, t) {
|
|
986
|
-
if (e.
|
|
987
|
-
if (!e.
|
|
988
|
-
e.
|
|
1038
|
+
if (e.Te === t || e._e?.has(t)) return false;
|
|
1039
|
+
if (!e.Te) {
|
|
1040
|
+
e.Te = t;
|
|
989
1041
|
return true;
|
|
990
1042
|
}
|
|
991
|
-
if (!e.
|
|
992
|
-
e.
|
|
1043
|
+
if (!e._e) {
|
|
1044
|
+
e._e = new Set([e.Te, t]);
|
|
993
1045
|
} else {
|
|
994
|
-
e.
|
|
1046
|
+
e._e.add(t);
|
|
995
1047
|
}
|
|
996
|
-
e.
|
|
1048
|
+
e.Te = undefined;
|
|
997
1049
|
return true;
|
|
998
1050
|
}
|
|
999
1051
|
function removePendingSource(e, t) {
|
|
1000
|
-
if (e.
|
|
1001
|
-
if (e.
|
|
1002
|
-
e.
|
|
1052
|
+
if (e.Te) {
|
|
1053
|
+
if (e.Te !== t) return false;
|
|
1054
|
+
e.Te = undefined;
|
|
1003
1055
|
return true;
|
|
1004
1056
|
}
|
|
1005
|
-
if (!e.
|
|
1006
|
-
if (e.
|
|
1007
|
-
e.
|
|
1008
|
-
e.
|
|
1009
|
-
} else if (e.
|
|
1010
|
-
e.
|
|
1057
|
+
if (!e._e?.delete(t)) return false;
|
|
1058
|
+
if (e._e.size === 1) {
|
|
1059
|
+
e.Te = e._e.values().next().value;
|
|
1060
|
+
e._e = undefined;
|
|
1061
|
+
} else if (e._e.size === 0) {
|
|
1062
|
+
e._e = undefined;
|
|
1011
1063
|
}
|
|
1012
1064
|
return true;
|
|
1013
1065
|
}
|
|
1014
1066
|
function clearPendingSources(e) {
|
|
1015
|
-
e.
|
|
1016
|
-
e.
|
|
1017
|
-
e.
|
|
1067
|
+
e.Te = undefined;
|
|
1068
|
+
e._e?.clear();
|
|
1069
|
+
e._e = undefined;
|
|
1018
1070
|
}
|
|
1019
1071
|
function setPendingError(e, t, n) {
|
|
1020
1072
|
if (!t) {
|
|
1021
|
-
e.
|
|
1073
|
+
e.ae = null;
|
|
1022
1074
|
return;
|
|
1023
1075
|
}
|
|
1024
1076
|
if (n instanceof NotReadyError && n.source === t) {
|
|
1025
|
-
e.
|
|
1077
|
+
e.ae = n;
|
|
1026
1078
|
return;
|
|
1027
1079
|
}
|
|
1028
|
-
const i = e.
|
|
1080
|
+
const i = e.ae;
|
|
1029
1081
|
if (!(i instanceof NotReadyError) || i.source !== t) {
|
|
1030
|
-
e.
|
|
1082
|
+
e.ae = new NotReadyError(t);
|
|
1031
1083
|
}
|
|
1032
1084
|
}
|
|
1033
1085
|
function forEachDependent(e, t) {
|
|
1034
|
-
for (let n = e.
|
|
1035
|
-
for (let n = e.
|
|
1036
|
-
for (let e = n.
|
|
1086
|
+
for (let n = e.P; n !== null; n = n.L) t(n.U, n);
|
|
1087
|
+
for (let n = e.ye; n !== null; n = n.Pe) {
|
|
1088
|
+
for (let e = n.P; e !== null; e = e.L) t(e.U, e);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
function enqueueForRerun(e) {
|
|
1092
|
+
if (e.V === EFFECT_TRACKED) {
|
|
1093
|
+
const t = e;
|
|
1094
|
+
if (!t.G) {
|
|
1095
|
+
t.G = true;
|
|
1096
|
+
t.F.enqueue(EFFECT_USER, t.k);
|
|
1097
|
+
}
|
|
1098
|
+
} else {
|
|
1099
|
+
const t = e.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
1100
|
+
if (t.I > e.H) t.I = e.H;
|
|
1101
|
+
insertIntoHeap(e, t);
|
|
1037
1102
|
}
|
|
1038
1103
|
}
|
|
1039
1104
|
function settlePendingSource(e) {
|
|
@@ -1042,88 +1107,88 @@ function settlePendingSource(e) {
|
|
|
1042
1107
|
const settle = i => {
|
|
1043
1108
|
if (n.has(i) || !removePendingSource(i, e)) return;
|
|
1044
1109
|
n.add(i);
|
|
1045
|
-
i.
|
|
1046
|
-
const r = i.
|
|
1110
|
+
i.fe = clock;
|
|
1111
|
+
const r = i.Te ?? i._e?.values().next().value;
|
|
1047
1112
|
if (r) {
|
|
1048
1113
|
setPendingError(i, r);
|
|
1049
1114
|
updatePendingSignal(i);
|
|
1050
1115
|
} else {
|
|
1051
|
-
i.
|
|
1116
|
+
i.Y &= ~STATUS_PENDING;
|
|
1052
1117
|
setPendingError(i);
|
|
1053
1118
|
updatePendingSignal(i);
|
|
1054
|
-
if (i.
|
|
1055
|
-
|
|
1056
|
-
const e = i;
|
|
1057
|
-
if (!e.ee) {
|
|
1058
|
-
e.ee = true;
|
|
1059
|
-
e.te.enqueue(EFFECT_USER, e.ne);
|
|
1060
|
-
}
|
|
1061
|
-
} else {
|
|
1062
|
-
const e = i.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
1063
|
-
if (e.C > i.o) e.C = i.o;
|
|
1064
|
-
insertIntoHeap(i, e);
|
|
1065
|
-
}
|
|
1119
|
+
if (i.Me) {
|
|
1120
|
+
enqueueForRerun(i);
|
|
1066
1121
|
t = true;
|
|
1067
1122
|
}
|
|
1068
|
-
i.
|
|
1123
|
+
i.Me = false;
|
|
1069
1124
|
}
|
|
1070
1125
|
forEachDependent(i, settle);
|
|
1071
1126
|
};
|
|
1072
1127
|
forEachDependent(e, settle);
|
|
1073
1128
|
if (t) schedule();
|
|
1074
1129
|
}
|
|
1130
|
+
function isThenable(e) {
|
|
1131
|
+
return e != null && typeof e === "object" && typeof e.then === "function";
|
|
1132
|
+
}
|
|
1075
1133
|
function handleAsync(e, t, n) {
|
|
1076
1134
|
let i = false;
|
|
1077
1135
|
let r = false;
|
|
1078
1136
|
if (typeof t === "object" && t !== null) {
|
|
1079
1137
|
untrack(() => {
|
|
1080
1138
|
i = t[Symbol.asyncIterator];
|
|
1081
|
-
r = !i &&
|
|
1139
|
+
r = !i && isThenable(t);
|
|
1082
1140
|
});
|
|
1083
1141
|
}
|
|
1084
1142
|
if (!r && !i) {
|
|
1085
|
-
e.
|
|
1143
|
+
e.be = null;
|
|
1086
1144
|
return t;
|
|
1087
1145
|
}
|
|
1088
|
-
e.
|
|
1146
|
+
e.be = t;
|
|
1089
1147
|
let o;
|
|
1090
1148
|
const handleError = n => {
|
|
1091
|
-
if (e.
|
|
1149
|
+
if (e.be !== t) return;
|
|
1092
1150
|
globalQueue.initTransition(resolveTransition(e));
|
|
1093
1151
|
notifyStatus(e, n instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, n);
|
|
1094
|
-
e.
|
|
1152
|
+
e.fe = clock;
|
|
1095
1153
|
};
|
|
1096
1154
|
const asyncWrite = (i, r) => {
|
|
1097
|
-
if (e.
|
|
1098
|
-
if (e.
|
|
1155
|
+
if (e.be !== t) return;
|
|
1156
|
+
if (e.W & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
|
|
1099
1157
|
globalQueue.initTransition(resolveTransition(e));
|
|
1100
|
-
const o = !!(e.
|
|
1158
|
+
const o = !!(e.Y & STATUS_UNINITIALIZED);
|
|
1101
1159
|
trimStaleDeps(e);
|
|
1102
1160
|
clearStatus(e);
|
|
1103
1161
|
const s = resolveLane(e);
|
|
1104
|
-
if (s) s.
|
|
1105
|
-
if (n)
|
|
1106
|
-
|
|
1107
|
-
if (
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
e
|
|
1162
|
+
if (s) s.u.delete(e);
|
|
1163
|
+
if (n) {
|
|
1164
|
+
n(i);
|
|
1165
|
+
if (o) clearStatus(e, true);
|
|
1166
|
+
} else if (e.O !== undefined) {
|
|
1167
|
+
if (e.D === NOT_PENDING) queuePendingNode(e);
|
|
1168
|
+
e.D = i;
|
|
1169
|
+
syncCompanions(e, i);
|
|
1170
|
+
if (!hasActiveOverride(e)) insertSubs(e);
|
|
1171
|
+
e.fe = clock;
|
|
1113
1172
|
} else if (s) {
|
|
1114
|
-
const t = e.
|
|
1115
|
-
const n = e.
|
|
1116
|
-
const r = e.
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1173
|
+
const t = e.V;
|
|
1174
|
+
const n = e.Z;
|
|
1175
|
+
const r = e.xe;
|
|
1176
|
+
try {
|
|
1177
|
+
if ((!t && o) || !r || !r(i, n)) {
|
|
1178
|
+
e.Z = i;
|
|
1179
|
+
e.fe = clock;
|
|
1180
|
+
syncCompanions(e, i);
|
|
1181
|
+
insertSubs(e, true);
|
|
1122
1182
|
}
|
|
1123
|
-
|
|
1183
|
+
} catch (t) {
|
|
1184
|
+
notifyStatus(e, STATUS_ERROR, t);
|
|
1124
1185
|
}
|
|
1125
1186
|
} else {
|
|
1126
|
-
|
|
1187
|
+
try {
|
|
1188
|
+
setSignal(e, () => i);
|
|
1189
|
+
} catch (t) {
|
|
1190
|
+
notifyStatus(e, STATUS_ERROR, t);
|
|
1191
|
+
}
|
|
1127
1192
|
}
|
|
1128
1193
|
settlePendingSource(e);
|
|
1129
1194
|
schedule();
|
|
@@ -1132,20 +1197,28 @@ function handleAsync(e, t, n) {
|
|
|
1132
1197
|
};
|
|
1133
1198
|
if (r) {
|
|
1134
1199
|
let n = false,
|
|
1135
|
-
i =
|
|
1200
|
+
i = false,
|
|
1201
|
+
r,
|
|
1202
|
+
s = true;
|
|
1136
1203
|
t.then(
|
|
1137
1204
|
e => {
|
|
1138
|
-
if (
|
|
1205
|
+
if (s) {
|
|
1139
1206
|
o = e;
|
|
1140
1207
|
n = true;
|
|
1141
1208
|
} else asyncWrite(e);
|
|
1142
1209
|
},
|
|
1143
1210
|
e => {
|
|
1144
|
-
if (
|
|
1211
|
+
if (s) {
|
|
1212
|
+
r = e;
|
|
1213
|
+
i = true;
|
|
1214
|
+
} else handleError(e);
|
|
1145
1215
|
}
|
|
1146
1216
|
);
|
|
1147
|
-
|
|
1148
|
-
if (
|
|
1217
|
+
s = false;
|
|
1218
|
+
if (i) {
|
|
1219
|
+
handleError(r);
|
|
1220
|
+
throw r;
|
|
1221
|
+
} else if (!n) {
|
|
1149
1222
|
globalQueue.initTransition(resolveTransition(e));
|
|
1150
1223
|
throw new NotReadyError(context);
|
|
1151
1224
|
}
|
|
@@ -1159,9 +1232,7 @@ function handleAsync(e, t, n) {
|
|
|
1159
1232
|
r = true;
|
|
1160
1233
|
try {
|
|
1161
1234
|
const e = n.return?.();
|
|
1162
|
-
if (e
|
|
1163
|
-
e.then(undefined, () => {});
|
|
1164
|
-
}
|
|
1235
|
+
if (isThenable(e)) e.then(undefined, () => {});
|
|
1165
1236
|
} catch {}
|
|
1166
1237
|
});
|
|
1167
1238
|
const iterate = () => {
|
|
@@ -1174,7 +1245,7 @@ function handleAsync(e, t, n) {
|
|
|
1174
1245
|
s = n;
|
|
1175
1246
|
u = true;
|
|
1176
1247
|
if (n.done) r = true;
|
|
1177
|
-
} else if (e.
|
|
1248
|
+
} else if (e.be !== t) {
|
|
1178
1249
|
return;
|
|
1179
1250
|
} else if (!n.done) asyncWrite(n.value, iterate);
|
|
1180
1251
|
else {
|
|
@@ -1184,7 +1255,7 @@ function handleAsync(e, t, n) {
|
|
|
1184
1255
|
}
|
|
1185
1256
|
},
|
|
1186
1257
|
n => {
|
|
1187
|
-
if (!c && e.
|
|
1258
|
+
if (!c && e.be === t) {
|
|
1188
1259
|
r = true;
|
|
1189
1260
|
handleError(n);
|
|
1190
1261
|
}
|
|
@@ -1207,55 +1278,62 @@ function handleAsync(e, t, n) {
|
|
|
1207
1278
|
return o;
|
|
1208
1279
|
}
|
|
1209
1280
|
function clearStatus(e, t = false) {
|
|
1210
|
-
if (e.
|
|
1211
|
-
if (e.
|
|
1212
|
-
e.
|
|
1213
|
-
if (e.
|
|
1214
|
-
if (e.
|
|
1215
|
-
if (e.
|
|
1281
|
+
if (e.Te || e._e) clearPendingSources(e);
|
|
1282
|
+
if (e.Me) e.Me = false;
|
|
1283
|
+
e.Y = t ? 0 : e.Y & STATUS_UNINITIALIZED;
|
|
1284
|
+
if (e.ae) setPendingError(e);
|
|
1285
|
+
if (e.B || e.q) updatePendingSignal(e);
|
|
1286
|
+
if (e.ye) updateChildCompanions(e);
|
|
1287
|
+
if (e.Qe) e.Qe();
|
|
1216
1288
|
}
|
|
1217
1289
|
function notifyStatus(e, t, n, i, r) {
|
|
1218
1290
|
if (t === STATUS_ERROR && !(n instanceof StatusError) && !(n instanceof NotReadyError))
|
|
1219
1291
|
n = new StatusError(e, n);
|
|
1220
1292
|
const o = t === STATUS_PENDING && n instanceof NotReadyError ? n.source : undefined;
|
|
1221
1293
|
const s = o === e;
|
|
1222
|
-
const u = t === STATUS_PENDING && e.
|
|
1294
|
+
const u = t === STATUS_PENDING && e.O !== undefined && !s;
|
|
1223
1295
|
const c = u && hasActiveOverride(e);
|
|
1224
1296
|
if (!i) {
|
|
1225
1297
|
if (t === STATUS_PENDING && o) {
|
|
1226
1298
|
addPendingSource(e, o);
|
|
1227
|
-
e.
|
|
1299
|
+
e.Y = STATUS_PENDING | (e.Y & STATUS_UNINITIALIZED);
|
|
1228
1300
|
setPendingError(e, o, n);
|
|
1229
1301
|
} else {
|
|
1230
1302
|
clearPendingSources(e);
|
|
1231
|
-
e.
|
|
1232
|
-
e.
|
|
1303
|
+
e.Y = t | (t !== STATUS_ERROR ? e.Y & STATUS_UNINITIALIZED : 0);
|
|
1304
|
+
e.ae = n;
|
|
1233
1305
|
}
|
|
1234
1306
|
updatePendingSignal(e);
|
|
1307
|
+
if (e.ye) updateChildCompanions(e);
|
|
1235
1308
|
}
|
|
1236
1309
|
if (r && !i) {
|
|
1237
1310
|
assignOrMergeLane(e, r);
|
|
1238
1311
|
}
|
|
1239
1312
|
const l = i || c;
|
|
1240
1313
|
const a = i || u ? undefined : r;
|
|
1241
|
-
if (e.
|
|
1314
|
+
if (e.Qe) {
|
|
1242
1315
|
if (i && t === STATUS_PENDING) {
|
|
1243
1316
|
return;
|
|
1244
1317
|
}
|
|
1245
1318
|
if (l) {
|
|
1246
|
-
e.
|
|
1319
|
+
e.Qe(t, n);
|
|
1247
1320
|
} else {
|
|
1248
|
-
e.
|
|
1321
|
+
e.Qe();
|
|
1249
1322
|
}
|
|
1250
1323
|
return;
|
|
1251
1324
|
}
|
|
1252
|
-
forEachDependent(e, e => {
|
|
1253
|
-
e.
|
|
1325
|
+
forEachDependent(e, (e, i) => {
|
|
1326
|
+
e.fe = clock;
|
|
1254
1327
|
if (
|
|
1255
|
-
(t === STATUS_PENDING && o && e.
|
|
1256
|
-
(t !== STATUS_PENDING && (e.
|
|
1328
|
+
(t === STATUS_PENDING && o && e.Te !== o && !e._e?.has(o)) ||
|
|
1329
|
+
(t !== STATUS_PENDING && (e.ae !== n || e.Te || e._e))
|
|
1257
1330
|
) {
|
|
1258
|
-
if (
|
|
1331
|
+
if (i.ke && t !== STATUS_PENDING && !(n instanceof NotReadyError)) {
|
|
1332
|
+
enqueueForRerun(e);
|
|
1333
|
+
schedule();
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
if (!l && !e.T) queuePendingNode(e);
|
|
1259
1337
|
notifyStatus(e, t, n, l, a);
|
|
1260
1338
|
}
|
|
1261
1339
|
});
|
|
@@ -1283,23 +1361,21 @@ function enableExternalSource(e) {
|
|
|
1283
1361
|
externalSourceConfig = { factory: t, untrack: n };
|
|
1284
1362
|
}
|
|
1285
1363
|
}
|
|
1286
|
-
GlobalQueue.
|
|
1287
|
-
GlobalQueue.
|
|
1364
|
+
GlobalQueue.ie = recompute;
|
|
1365
|
+
GlobalQueue.re = disposeChildren;
|
|
1288
1366
|
let tracking = false;
|
|
1289
1367
|
let stale = false;
|
|
1290
|
-
let refreshing = false;
|
|
1291
1368
|
let pendingCheckActive = false;
|
|
1292
|
-
let foundPending = false;
|
|
1293
1369
|
let latestReadActive = false;
|
|
1294
1370
|
let context = null;
|
|
1295
1371
|
let currentOptimisticLane = null;
|
|
1296
|
-
let
|
|
1372
|
+
let pendingProbe = null;
|
|
1297
1373
|
let snapshotCaptureActive = false;
|
|
1298
1374
|
let snapshotSources = null;
|
|
1299
1375
|
function ownerInSnapshotScope(e) {
|
|
1300
1376
|
while (e) {
|
|
1301
|
-
if (e.
|
|
1302
|
-
e = e.
|
|
1377
|
+
if (e.je) return true;
|
|
1378
|
+
e = e.J;
|
|
1303
1379
|
}
|
|
1304
1380
|
return false;
|
|
1305
1381
|
}
|
|
@@ -1308,27 +1384,27 @@ function setSnapshotCapture(e) {
|
|
|
1308
1384
|
if (e && !snapshotSources) snapshotSources = new Set();
|
|
1309
1385
|
}
|
|
1310
1386
|
function markSnapshotScope(e) {
|
|
1311
|
-
e.
|
|
1387
|
+
e.je = true;
|
|
1312
1388
|
}
|
|
1313
1389
|
function releaseSnapshotScope(e) {
|
|
1314
|
-
e.
|
|
1390
|
+
e.je = false;
|
|
1315
1391
|
releaseSubtree(e);
|
|
1316
1392
|
schedule();
|
|
1317
1393
|
}
|
|
1318
1394
|
function releaseSubtree(e) {
|
|
1319
1395
|
let t = e.ge;
|
|
1320
1396
|
while (t) {
|
|
1321
|
-
if (t.
|
|
1397
|
+
if (t.je) {
|
|
1322
1398
|
t = t.De;
|
|
1323
1399
|
continue;
|
|
1324
1400
|
}
|
|
1325
|
-
if (t.
|
|
1401
|
+
if (t.ce) {
|
|
1326
1402
|
const e = t;
|
|
1327
|
-
e.
|
|
1328
|
-
if (e.
|
|
1329
|
-
e.
|
|
1330
|
-
e.
|
|
1331
|
-
if (dirtyQueue.
|
|
1403
|
+
e.le &= ~CONFIG_IN_SNAPSHOT_SCOPE;
|
|
1404
|
+
if (e.W & REACTIVE_SNAPSHOT_STALE) {
|
|
1405
|
+
e.W &= ~REACTIVE_SNAPSHOT_STALE;
|
|
1406
|
+
e.W |= REACTIVE_DIRTY;
|
|
1407
|
+
if (dirtyQueue.I > e.H) dirtyQueue.I = e.H;
|
|
1332
1408
|
insertIntoHeap(e, dirtyQueue);
|
|
1333
1409
|
}
|
|
1334
1410
|
}
|
|
@@ -1339,7 +1415,7 @@ function releaseSubtree(e) {
|
|
|
1339
1415
|
function clearSnapshots() {
|
|
1340
1416
|
if (snapshotSources) {
|
|
1341
1417
|
for (const e of snapshotSources) {
|
|
1342
|
-
delete e.
|
|
1418
|
+
delete e.Ee;
|
|
1343
1419
|
delete e[STORE_SNAPSHOT_PROPS];
|
|
1344
1420
|
}
|
|
1345
1421
|
snapshotSources = null;
|
|
@@ -1347,192 +1423,204 @@ function clearSnapshots() {
|
|
|
1347
1423
|
snapshotCaptureActive = false;
|
|
1348
1424
|
}
|
|
1349
1425
|
function recompute(e, t = false) {
|
|
1350
|
-
const n = e.
|
|
1426
|
+
const n = e.V;
|
|
1351
1427
|
if (!t) {
|
|
1352
|
-
if (e.
|
|
1353
|
-
globalQueue.initTransition(e.
|
|
1354
|
-
deleteFromHeap(e, e.
|
|
1355
|
-
e.
|
|
1356
|
-
if (e.
|
|
1357
|
-
else if (e.ge !== null || e.
|
|
1428
|
+
if (e.T && (!n || activeTransition) && activeTransition !== e.T)
|
|
1429
|
+
globalQueue.initTransition(e.T);
|
|
1430
|
+
deleteFromHeap(e, e.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1431
|
+
e.be = null;
|
|
1432
|
+
if (e.T || n === EFFECT_TRACKED) disposeChildren(e);
|
|
1433
|
+
else if (e.ge !== null || e.Ue !== null) {
|
|
1358
1434
|
markDisposal(e);
|
|
1359
|
-
e.
|
|
1360
|
-
e.
|
|
1361
|
-
e.
|
|
1435
|
+
e.Se = e.Ue;
|
|
1436
|
+
e.de = e.ge;
|
|
1437
|
+
e.Ue = null;
|
|
1362
1438
|
e.ge = null;
|
|
1363
|
-
e.
|
|
1439
|
+
e.ve = 0;
|
|
1364
1440
|
} else;
|
|
1365
1441
|
}
|
|
1366
|
-
let i = !!(e.
|
|
1367
|
-
const r = e.
|
|
1368
|
-
|
|
1369
|
-
const
|
|
1370
|
-
const
|
|
1442
|
+
let i = !!(e.W & REACTIVE_OPTIMISTIC_DIRTY);
|
|
1443
|
+
const r = e.O !== undefined && e.O !== NOT_PENDING;
|
|
1444
|
+
!!(e.Y & STATUS_PENDING);
|
|
1445
|
+
const o = !!(e.Y & STATUS_UNINITIALIZED);
|
|
1446
|
+
const s = context;
|
|
1371
1447
|
context = e;
|
|
1372
|
-
e.
|
|
1373
|
-
e.
|
|
1374
|
-
e.
|
|
1375
|
-
|
|
1376
|
-
let
|
|
1377
|
-
let
|
|
1378
|
-
let
|
|
1448
|
+
e.me = null;
|
|
1449
|
+
e.He++;
|
|
1450
|
+
e.W = REACTIVE_RECOMPUTING_DEPS;
|
|
1451
|
+
e.fe = clock;
|
|
1452
|
+
let u = e.D === NOT_PENDING ? e.Z : e.D;
|
|
1453
|
+
let c = e.H;
|
|
1454
|
+
let l = tracking;
|
|
1455
|
+
let a = currentOptimisticLane;
|
|
1379
1456
|
tracking = true;
|
|
1380
1457
|
if (i) {
|
|
1381
1458
|
const t = resolveLane(e);
|
|
1382
1459
|
if (t) currentOptimisticLane = t;
|
|
1383
|
-
} else if (activeTransition && !t && activeTransition.
|
|
1384
|
-
for (let t = e.
|
|
1385
|
-
const n = t.
|
|
1386
|
-
if (n.
|
|
1460
|
+
} else if (activeTransition && !t && activeTransition.N.length) {
|
|
1461
|
+
for (let t = e.Oe; t; t = t.pe) {
|
|
1462
|
+
const n = t.Re;
|
|
1463
|
+
if (n.W & REACTIVE_OPTIMISTIC_DIRTY) {
|
|
1387
1464
|
const t = resolveLane(n);
|
|
1388
1465
|
if (t) {
|
|
1389
1466
|
i = true;
|
|
1390
1467
|
currentOptimisticLane = t;
|
|
1391
|
-
e.
|
|
1468
|
+
e.W |= REACTIVE_OPTIMISTIC_DIRTY;
|
|
1392
1469
|
assignOrMergeLane(e, t);
|
|
1393
1470
|
break;
|
|
1394
1471
|
}
|
|
1395
1472
|
}
|
|
1396
1473
|
}
|
|
1397
1474
|
}
|
|
1398
|
-
const
|
|
1399
|
-
const
|
|
1400
|
-
if (
|
|
1475
|
+
const f = n && n !== EFFECT_USER;
|
|
1476
|
+
const E = stale;
|
|
1477
|
+
if (f) stale = true;
|
|
1401
1478
|
try {
|
|
1402
|
-
if (!false && e.
|
|
1403
|
-
|
|
1404
|
-
e.
|
|
1479
|
+
if (!false && e.le & CONFIG_SYNC) {
|
|
1480
|
+
u = e.ce(u);
|
|
1481
|
+
e.be = null;
|
|
1405
1482
|
} else {
|
|
1406
|
-
const t = e.
|
|
1407
|
-
const n = e.
|
|
1483
|
+
const t = e.be;
|
|
1484
|
+
const n = e.ce(u);
|
|
1408
1485
|
const i = typeof n === "object" && n !== null;
|
|
1409
|
-
const r = e.
|
|
1410
|
-
|
|
1411
|
-
if (!r && !i) e.
|
|
1486
|
+
const r = e.be !== t;
|
|
1487
|
+
u = r || !i ? n : handleAsync(e, n);
|
|
1488
|
+
if (!r && !i) e.be = null;
|
|
1412
1489
|
}
|
|
1413
1490
|
clearStatus(e, t);
|
|
1414
|
-
if (e.
|
|
1491
|
+
if (e.i) {
|
|
1415
1492
|
const t = resolveLane(e);
|
|
1416
1493
|
if (t) {
|
|
1417
|
-
t.
|
|
1418
|
-
updatePendingSignal(t.
|
|
1494
|
+
t.u.delete(e);
|
|
1495
|
+
updatePendingSignal(t.o);
|
|
1419
1496
|
}
|
|
1420
1497
|
}
|
|
1421
1498
|
} catch (t) {
|
|
1422
1499
|
if (t instanceof NotReadyError && currentOptimisticLane) {
|
|
1423
1500
|
const t = findLane(currentOptimisticLane);
|
|
1424
|
-
if (t.
|
|
1425
|
-
t.
|
|
1426
|
-
e.
|
|
1427
|
-
updatePendingSignal(t.
|
|
1501
|
+
if (t.o !== e) {
|
|
1502
|
+
t.u.add(e);
|
|
1503
|
+
e.i = t;
|
|
1504
|
+
updatePendingSignal(t.o);
|
|
1428
1505
|
}
|
|
1429
1506
|
}
|
|
1430
|
-
if (t instanceof NotReadyError) e.
|
|
1507
|
+
if (t instanceof NotReadyError) e.Me = true;
|
|
1431
1508
|
notifyStatus(
|
|
1432
1509
|
e,
|
|
1433
1510
|
t instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
|
|
1434
1511
|
t,
|
|
1435
1512
|
undefined,
|
|
1436
|
-
t instanceof NotReadyError ? e.
|
|
1513
|
+
t instanceof NotReadyError ? e.i : undefined
|
|
1437
1514
|
);
|
|
1438
1515
|
} finally {
|
|
1439
|
-
tracking =
|
|
1440
|
-
if (
|
|
1441
|
-
e.
|
|
1442
|
-
context =
|
|
1516
|
+
tracking = l;
|
|
1517
|
+
if (f) stale = E;
|
|
1518
|
+
e.W = REACTIVE_NONE | (t ? e.W & REACTIVE_SNAPSHOT_STALE : 0);
|
|
1519
|
+
context = s;
|
|
1443
1520
|
}
|
|
1444
|
-
if (!e.
|
|
1521
|
+
if (!e.ae) {
|
|
1445
1522
|
trimStaleDeps(e);
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
e.
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1523
|
+
const s = r ? e.O : e.D === NOT_PENDING ? e.Z : e.D;
|
|
1524
|
+
let l = false;
|
|
1525
|
+
try {
|
|
1526
|
+
l = (!n && o) || !e.xe || !e.xe(s, u);
|
|
1527
|
+
} catch (t) {
|
|
1528
|
+
notifyStatus(e, STATUS_ERROR, t);
|
|
1529
|
+
}
|
|
1530
|
+
if (n && l) {
|
|
1531
|
+
e.G = !e.ae;
|
|
1532
|
+
if (!t) e.F.enqueue(n, (e.$e ??= GlobalQueue.oe.bind(null, e)));
|
|
1533
|
+
}
|
|
1534
|
+
if (e.ae);
|
|
1535
|
+
else if (l) {
|
|
1536
|
+
const o = r ? e.O : undefined;
|
|
1537
|
+
if (t || (n && activeTransition !== e.T) || i) {
|
|
1538
|
+
e.Z = u;
|
|
1456
1539
|
if (r && i) {
|
|
1457
|
-
e.
|
|
1458
|
-
e.
|
|
1540
|
+
e.O = u;
|
|
1541
|
+
e.D = NOT_PENDING;
|
|
1459
1542
|
}
|
|
1460
|
-
} else
|
|
1461
|
-
|
|
1462
|
-
|
|
1543
|
+
} else {
|
|
1544
|
+
e.D = u;
|
|
1545
|
+
if (activeTransition || e.T) syncCompanions(e, u);
|
|
1546
|
+
}
|
|
1547
|
+
if (!r || i || e.O !== o) insertSubs(e, i || r);
|
|
1463
1548
|
} else if (r) {
|
|
1464
|
-
e.
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1549
|
+
if (e.D === NOT_PENDING) queuePendingNode(e);
|
|
1550
|
+
e.D = u;
|
|
1551
|
+
} else if (e.H != c) {
|
|
1552
|
+
for (let t = e.P; t !== null; t = t.L) {
|
|
1553
|
+
insertIntoHeapHeight(t.U, t.U.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1468
1554
|
}
|
|
1469
1555
|
}
|
|
1470
1556
|
}
|
|
1471
|
-
currentOptimisticLane =
|
|
1472
|
-
const
|
|
1473
|
-
e.
|
|
1474
|
-
e.
|
|
1475
|
-
e.
|
|
1476
|
-
!!(e.
|
|
1477
|
-
|
|
1478
|
-
e.
|
|
1557
|
+
currentOptimisticLane = a;
|
|
1558
|
+
const d =
|
|
1559
|
+
e.D !== NOT_PENDING ||
|
|
1560
|
+
e.de !== null ||
|
|
1561
|
+
e.Se !== null ||
|
|
1562
|
+
!!(e.Y & (STATUS_PENDING | STATUS_UNINITIALIZED));
|
|
1563
|
+
d && (!t || e.Y & STATUS_PENDING) && (!e.T || r) && queuePendingNode(e);
|
|
1564
|
+
e.T && n && activeTransition !== e.T && runInTransition(e.T, () => recompute(e));
|
|
1479
1565
|
}
|
|
1480
1566
|
function updateIfNecessary(e) {
|
|
1481
|
-
if (e.
|
|
1482
|
-
for (let t = e.
|
|
1483
|
-
const n = t.
|
|
1484
|
-
const i = n.
|
|
1485
|
-
if (i.
|
|
1567
|
+
if (e.W & REACTIVE_CHECK) {
|
|
1568
|
+
for (let t = e.Oe; t; t = t.pe) {
|
|
1569
|
+
const n = t.Re;
|
|
1570
|
+
const i = n.Ie || n;
|
|
1571
|
+
if (i.ce) {
|
|
1486
1572
|
updateIfNecessary(i);
|
|
1487
1573
|
}
|
|
1488
|
-
if (e.
|
|
1574
|
+
if (e.W & REACTIVE_DIRTY) {
|
|
1489
1575
|
break;
|
|
1490
1576
|
}
|
|
1491
1577
|
}
|
|
1492
1578
|
}
|
|
1493
|
-
if (e.
|
|
1579
|
+
if (e.W & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.ae && e.fe < clock && !e.be)) {
|
|
1494
1580
|
recompute(e);
|
|
1495
1581
|
}
|
|
1496
|
-
e.
|
|
1582
|
+
e.W = e.W & (REACTIVE_SNAPSHOT_STALE | REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT);
|
|
1497
1583
|
}
|
|
1498
1584
|
function computed(e, t) {
|
|
1499
1585
|
const n = t?.transparent ?? false;
|
|
1500
1586
|
const i = {
|
|
1501
1587
|
id: t?.id ?? (n ? context?.id : context?.id != null ? getNextChildId(context) : undefined),
|
|
1502
|
-
|
|
1588
|
+
le:
|
|
1503
1589
|
(n ? CONFIG_TRANSPARENT : 0) |
|
|
1504
1590
|
(t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) |
|
|
1505
1591
|
(!context || t?.lazy ? CONFIG_AUTO_DISPOSE : 0) |
|
|
1506
1592
|
(t?.sync ? CONFIG_SYNC : 0) |
|
|
1593
|
+
(t?.Ke ? CONFIG_NO_SNAPSHOT : 0) |
|
|
1507
1594
|
(snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1595
|
+
xe: t?.equals != null ? t.equals : isEqual,
|
|
1596
|
+
m: t?.unobserved,
|
|
1597
|
+
Ue: null,
|
|
1598
|
+
F: context?.F ?? globalQueue,
|
|
1512
1599
|
Ve: context?.Ve ?? defaultContext,
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
N: null,
|
|
1518
|
-
T: undefined,
|
|
1519
|
-
S: null,
|
|
1520
|
-
P: null,
|
|
1600
|
+
ve: 0,
|
|
1601
|
+
ce: e,
|
|
1602
|
+
Z: undefined,
|
|
1603
|
+
H: 0,
|
|
1521
1604
|
ye: null,
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1605
|
+
Ce: undefined,
|
|
1606
|
+
Ne: null,
|
|
1607
|
+
Oe: null,
|
|
1608
|
+
me: null,
|
|
1609
|
+
He: 0,
|
|
1610
|
+
P: null,
|
|
1611
|
+
Fe: null,
|
|
1612
|
+
J: context,
|
|
1525
1613
|
De: null,
|
|
1526
1614
|
we: null,
|
|
1527
1615
|
ge: null,
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1616
|
+
W: t?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
|
|
1617
|
+
Y: STATUS_UNINITIALIZED,
|
|
1618
|
+
fe: clock,
|
|
1619
|
+
D: NOT_PENDING,
|
|
1620
|
+
Se: null,
|
|
1621
|
+
de: null,
|
|
1622
|
+
be: null,
|
|
1623
|
+
T: null
|
|
1536
1624
|
};
|
|
1537
1625
|
setupComputedNode(i, t);
|
|
1538
1626
|
return i;
|
|
@@ -1541,55 +1629,55 @@ function createEffectNode(e, t, n, i, r, o) {
|
|
|
1541
1629
|
const s = o?.transparent ?? false;
|
|
1542
1630
|
const u = {
|
|
1543
1631
|
id: o?.id ?? (s ? context?.id : context?.id != null ? getNextChildId(context) : undefined),
|
|
1544
|
-
|
|
1632
|
+
le:
|
|
1545
1633
|
(s ? CONFIG_TRANSPARENT : 0) |
|
|
1546
1634
|
(o?.ownedWrite ? CONFIG_OWNED_WRITE : 0) |
|
|
1547
1635
|
(o?.sync ? CONFIG_SYNC : 0) |
|
|
1548
1636
|
(snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1637
|
+
xe: false,
|
|
1638
|
+
m: o?.unobserved,
|
|
1639
|
+
Ue: null,
|
|
1640
|
+
F: context?.F ?? globalQueue,
|
|
1553
1641
|
Ve: context?.Ve ?? defaultContext,
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
N: null,
|
|
1559
|
-
T: undefined,
|
|
1560
|
-
S: null,
|
|
1561
|
-
P: null,
|
|
1642
|
+
ve: 0,
|
|
1643
|
+
ce: e,
|
|
1644
|
+
Z: undefined,
|
|
1645
|
+
H: 0,
|
|
1562
1646
|
ye: null,
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1647
|
+
Ce: undefined,
|
|
1648
|
+
Ne: null,
|
|
1649
|
+
Oe: null,
|
|
1650
|
+
me: null,
|
|
1651
|
+
He: 0,
|
|
1652
|
+
P: null,
|
|
1653
|
+
Fe: null,
|
|
1654
|
+
J: context,
|
|
1566
1655
|
De: null,
|
|
1567
1656
|
we: null,
|
|
1568
1657
|
ge: null,
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
xe: r
|
|
1658
|
+
W: REACTIVE_LAZY,
|
|
1659
|
+
Y: STATUS_UNINITIALIZED,
|
|
1660
|
+
fe: clock,
|
|
1661
|
+
D: NOT_PENDING,
|
|
1662
|
+
Se: null,
|
|
1663
|
+
de: null,
|
|
1664
|
+
be: null,
|
|
1665
|
+
T: null,
|
|
1666
|
+
G: false,
|
|
1667
|
+
Ye: undefined,
|
|
1668
|
+
Ze: t,
|
|
1669
|
+
Be: n,
|
|
1670
|
+
Le: undefined,
|
|
1671
|
+
V: i,
|
|
1672
|
+
Qe: r
|
|
1585
1673
|
};
|
|
1586
1674
|
setupComputedNode(u, lazyOptions);
|
|
1587
1675
|
return u;
|
|
1588
1676
|
}
|
|
1589
1677
|
const lazyOptions = { lazy: true };
|
|
1590
1678
|
function setupComputedNode(e, t) {
|
|
1591
|
-
e.
|
|
1592
|
-
const n = context?.
|
|
1679
|
+
e.Ne = e;
|
|
1680
|
+
const n = context?.he ? context.Ae : context;
|
|
1593
1681
|
if (context) {
|
|
1594
1682
|
const t = context.ge;
|
|
1595
1683
|
if (t === null) {
|
|
@@ -1600,54 +1688,54 @@ function setupComputedNode(e, t) {
|
|
|
1600
1688
|
context.ge = e;
|
|
1601
1689
|
}
|
|
1602
1690
|
}
|
|
1603
|
-
if (n) e.
|
|
1691
|
+
if (n) e.H = n.H + 1;
|
|
1604
1692
|
if (externalSourceConfig) {
|
|
1605
1693
|
const t = signal(undefined, { equals: false, ownedWrite: true });
|
|
1606
|
-
const n = externalSourceConfig.factory(e.
|
|
1694
|
+
const n = externalSourceConfig.factory(e.ce, () => {
|
|
1607
1695
|
setSignal(t, undefined);
|
|
1608
1696
|
});
|
|
1609
1697
|
cleanup(() => n.dispose());
|
|
1610
|
-
e.
|
|
1698
|
+
e.ce = e => {
|
|
1611
1699
|
read(t);
|
|
1612
1700
|
return n.track(e);
|
|
1613
1701
|
};
|
|
1614
1702
|
}
|
|
1615
1703
|
!t?.lazy && recompute(e, true);
|
|
1616
1704
|
if (snapshotCaptureActive && !t?.lazy) {
|
|
1617
|
-
if (!(e.
|
|
1618
|
-
e.
|
|
1705
|
+
if (!(e.Y & STATUS_PENDING) && !(e.le & CONFIG_NO_SNAPSHOT)) {
|
|
1706
|
+
e.Ee = e.Z === undefined ? NO_SNAPSHOT : e.Z;
|
|
1619
1707
|
snapshotSources.add(e);
|
|
1620
1708
|
}
|
|
1621
1709
|
}
|
|
1622
1710
|
}
|
|
1623
1711
|
function signal(e, t, n = null) {
|
|
1624
1712
|
const i = {
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1713
|
+
xe: t?.equals != null ? t.equals : isEqual,
|
|
1714
|
+
le: (t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (t?.Ke ? CONFIG_NO_SNAPSHOT : 0),
|
|
1715
|
+
m: t?.unobserved,
|
|
1716
|
+
Z: e,
|
|
1717
|
+
P: null,
|
|
1718
|
+
Fe: null,
|
|
1719
|
+
fe: clock,
|
|
1720
|
+
Ie: n,
|
|
1721
|
+
Pe: n?.ye || null,
|
|
1722
|
+
D: NOT_PENDING
|
|
1635
1723
|
};
|
|
1636
|
-
n && (n.
|
|
1637
|
-
if (snapshotCaptureActive && !(i.
|
|
1638
|
-
i.
|
|
1724
|
+
n && (n.ye = i);
|
|
1725
|
+
if (snapshotCaptureActive && !(i.le & CONFIG_NO_SNAPSHOT) && !((n?.Y ?? 0) & STATUS_PENDING)) {
|
|
1726
|
+
i.Ee = e === undefined ? NO_SNAPSHOT : e;
|
|
1639
1727
|
snapshotSources.add(i);
|
|
1640
1728
|
}
|
|
1641
1729
|
return i;
|
|
1642
1730
|
}
|
|
1643
1731
|
function optimisticSignal(e, t) {
|
|
1644
1732
|
const n = signal(e, t);
|
|
1645
|
-
n.
|
|
1733
|
+
n.O = NOT_PENDING;
|
|
1646
1734
|
return n;
|
|
1647
1735
|
}
|
|
1648
1736
|
function optimisticComputed(e, t) {
|
|
1649
1737
|
const n = computed(e, t);
|
|
1650
|
-
n.
|
|
1738
|
+
n.O = NOT_PENDING;
|
|
1651
1739
|
return n;
|
|
1652
1740
|
}
|
|
1653
1741
|
function isEqual(e, t) {
|
|
@@ -1664,222 +1752,199 @@ function untrack(e, t) {
|
|
|
1664
1752
|
tracking = n;
|
|
1665
1753
|
}
|
|
1666
1754
|
}
|
|
1755
|
+
function prepareComputed(e, t) {
|
|
1756
|
+
if (e.W & REACTIVE_LAZY) {
|
|
1757
|
+
e.W &= ~REACTIVE_LAZY;
|
|
1758
|
+
recompute(e, true);
|
|
1759
|
+
} else if (e.W & REACTIVE_DISPOSED) {
|
|
1760
|
+
recompute(e, true);
|
|
1761
|
+
} else if (t) {
|
|
1762
|
+
updateIfNecessary(e);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1667
1765
|
function read(e) {
|
|
1668
1766
|
if (latestReadActive) {
|
|
1669
1767
|
const t = getLatestValueComputed(e);
|
|
1670
1768
|
const n = latestReadActive;
|
|
1671
1769
|
latestReadActive = false;
|
|
1672
|
-
const i = e.
|
|
1770
|
+
const i = e.O !== undefined && e.O !== NOT_PENDING ? e.O : e.Z;
|
|
1673
1771
|
let r;
|
|
1674
1772
|
try {
|
|
1675
1773
|
r = read(t);
|
|
1676
|
-
} catch (
|
|
1677
|
-
if (!context
|
|
1678
|
-
throw
|
|
1774
|
+
} catch (t) {
|
|
1775
|
+
if (t instanceof NotReadyError && (!context || !(e.Y & STATUS_UNINITIALIZED))) return i;
|
|
1776
|
+
throw t;
|
|
1679
1777
|
} finally {
|
|
1680
1778
|
latestReadActive = n;
|
|
1681
1779
|
}
|
|
1682
|
-
if (t.
|
|
1683
|
-
if (stale && currentOptimisticLane && t.
|
|
1684
|
-
const e = findLane(t.
|
|
1780
|
+
if (t.Y & STATUS_PENDING) return i;
|
|
1781
|
+
if (stale && currentOptimisticLane && t.i) {
|
|
1782
|
+
const e = findLane(t.i);
|
|
1685
1783
|
const n = findLane(currentOptimisticLane);
|
|
1686
|
-
if (e !== n && e.
|
|
1784
|
+
if (e !== n && e.u.size > 0) {
|
|
1687
1785
|
return i;
|
|
1688
1786
|
}
|
|
1689
1787
|
}
|
|
1690
1788
|
return r;
|
|
1691
1789
|
}
|
|
1692
|
-
if (pendingCheckActive) {
|
|
1693
|
-
const t = e.V;
|
|
1694
|
-
const n = pendingCheckActive;
|
|
1695
|
-
pendingCheckActive = false;
|
|
1696
|
-
let i = context;
|
|
1697
|
-
if (i?.t) i = i.u;
|
|
1698
|
-
const r = t || e;
|
|
1699
|
-
const o = e;
|
|
1700
|
-
if (typeof o.L === "function") {
|
|
1701
|
-
const t = e;
|
|
1702
|
-
if (t.O & REACTIVE_LAZY) {
|
|
1703
|
-
t.O &= ~REACTIVE_LAZY;
|
|
1704
|
-
recompute(t, true);
|
|
1705
|
-
} else if (t.O & REACTIVE_DISPOSED) {
|
|
1706
|
-
recompute(t, true);
|
|
1707
|
-
} else {
|
|
1708
|
-
updateIfNecessary(t);
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
if (i && r.he & STATUS_PENDING && r.he & STATUS_UNINITIALIZED) {
|
|
1712
|
-
if (tracking && e !== i) link(e, i);
|
|
1713
|
-
pendingCheckActive = n;
|
|
1714
|
-
throw r.Re;
|
|
1715
|
-
}
|
|
1716
|
-
if (t && e.K !== undefined) {
|
|
1717
|
-
if (e.K !== NOT_PENDING && (t.ve || !!(t.he & STATUS_PENDING))) {
|
|
1718
|
-
foundPending = true;
|
|
1719
|
-
}
|
|
1720
|
-
collectPendingSources(e);
|
|
1721
|
-
collectPendingSources(t);
|
|
1722
|
-
if (i && tracking) link(e, i);
|
|
1723
|
-
} else {
|
|
1724
|
-
collectPendingSources(e);
|
|
1725
|
-
if (t) collectPendingSources(t);
|
|
1726
|
-
}
|
|
1727
|
-
pendingCheckActive = n;
|
|
1728
|
-
}
|
|
1729
1790
|
let t = context;
|
|
1730
|
-
if (t?.
|
|
1791
|
+
if (t?.he) t = t.Ae;
|
|
1731
1792
|
const n = e;
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1793
|
+
const i = e.Ie;
|
|
1794
|
+
const r = i || e;
|
|
1795
|
+
if (pendingCheckActive) {
|
|
1796
|
+
pendingCheckActive = false;
|
|
1797
|
+
if (typeof n.ce === "function") prepareComputed(e, true);
|
|
1798
|
+
if (t && r.Y & STATUS_PENDING && r.Y & STATUS_UNINITIALIZED) {
|
|
1799
|
+
if (tracking && e !== t) link(e, t);
|
|
1800
|
+
pendingCheckActive = true;
|
|
1801
|
+
throw r.ae;
|
|
1739
1802
|
}
|
|
1803
|
+
collectPendingSources(e);
|
|
1804
|
+
if (i) collectPendingSources(i);
|
|
1805
|
+
pendingCheckActive = true;
|
|
1806
|
+
} else if (typeof n.ce === "function") {
|
|
1807
|
+
prepareComputed(e, false);
|
|
1740
1808
|
}
|
|
1741
|
-
const i = e.V || e;
|
|
1742
1809
|
if (
|
|
1743
|
-
!n.
|
|
1744
|
-
|
|
1745
|
-
e.
|
|
1746
|
-
e.
|
|
1810
|
+
!n.ce &&
|
|
1811
|
+
r === e &&
|
|
1812
|
+
e.O === undefined &&
|
|
1813
|
+
e.Ee === undefined &&
|
|
1747
1814
|
activeTransition === null &&
|
|
1748
1815
|
currentOptimisticLane === null &&
|
|
1749
1816
|
!snapshotCaptureActive &&
|
|
1750
1817
|
true
|
|
1751
1818
|
) {
|
|
1752
1819
|
if (t && tracking) link(e, t);
|
|
1753
|
-
return !t || e.
|
|
1820
|
+
return !t || e.D === NOT_PENDING ? e.Z : e.D;
|
|
1754
1821
|
}
|
|
1755
1822
|
if (t && tracking) {
|
|
1756
|
-
link(e, t);
|
|
1757
|
-
if (
|
|
1758
|
-
const n = e.
|
|
1759
|
-
if (
|
|
1823
|
+
link(e, t, pendingCheckActive);
|
|
1824
|
+
if (r.ce) {
|
|
1825
|
+
const n = e.W & REACTIVE_ZOMBIE;
|
|
1826
|
+
if (r.H >= (n ? zombieQueue.I : dirtyQueue.I)) {
|
|
1760
1827
|
markNode(t);
|
|
1761
1828
|
markHeap(n ? zombieQueue : dirtyQueue);
|
|
1762
|
-
updateIfNecessary(
|
|
1829
|
+
updateIfNecessary(r);
|
|
1763
1830
|
}
|
|
1764
|
-
const
|
|
1765
|
-
if (
|
|
1766
|
-
t.
|
|
1831
|
+
const i = r.H;
|
|
1832
|
+
if (i >= t.H && e.J !== t) {
|
|
1833
|
+
t.H = i + 1;
|
|
1767
1834
|
}
|
|
1768
1835
|
}
|
|
1769
1836
|
}
|
|
1770
|
-
if (
|
|
1771
|
-
if (t && !(stale &&
|
|
1837
|
+
if (r.Y & STATUS_PENDING) {
|
|
1838
|
+
if (t && !(stale && r.T && activeTransition !== r.T)) {
|
|
1772
1839
|
if (currentOptimisticLane) {
|
|
1773
|
-
const n = i
|
|
1774
|
-
const
|
|
1775
|
-
if (n && findLane(n) ===
|
|
1840
|
+
const n = r.i;
|
|
1841
|
+
const i = findLane(currentOptimisticLane);
|
|
1842
|
+
if (n && findLane(n) === i && !hasActiveOverride(r)) {
|
|
1776
1843
|
if (!tracking && e !== t) link(e, t);
|
|
1777
|
-
throw
|
|
1844
|
+
throw r.ae;
|
|
1778
1845
|
}
|
|
1779
1846
|
} else {
|
|
1780
1847
|
if (!tracking && e !== t) link(e, t);
|
|
1781
|
-
throw
|
|
1848
|
+
throw r.ae;
|
|
1782
1849
|
}
|
|
1783
|
-
} else if (t &&
|
|
1850
|
+
} else if (t && r !== e && r.Y & STATUS_UNINITIALIZED) {
|
|
1784
1851
|
if (!tracking && e !== t) link(e, t);
|
|
1785
|
-
throw
|
|
1786
|
-
} else if (!t &&
|
|
1787
|
-
throw
|
|
1852
|
+
throw r.ae;
|
|
1853
|
+
} else if (!t && r.Y & STATUS_UNINITIALIZED) {
|
|
1854
|
+
throw r.ae;
|
|
1788
1855
|
}
|
|
1789
1856
|
}
|
|
1790
|
-
if (e.
|
|
1791
|
-
if (e.
|
|
1857
|
+
if (e.ce && e.Y & STATUS_ERROR) {
|
|
1858
|
+
if (tracking && !pendingCheckActive && e.fe < clock) {
|
|
1792
1859
|
recompute(e);
|
|
1793
1860
|
return read(e);
|
|
1794
|
-
} else throw e.
|
|
1861
|
+
} else throw e.ae;
|
|
1795
1862
|
}
|
|
1796
|
-
if (snapshotCaptureActive && t && t.
|
|
1797
|
-
const n = e.
|
|
1863
|
+
if (snapshotCaptureActive && t && t.le & CONFIG_IN_SNAPSHOT_SCOPE) {
|
|
1864
|
+
const n = e.Ee;
|
|
1798
1865
|
if (n !== undefined) {
|
|
1799
1866
|
const i = n === NO_SNAPSHOT ? undefined : n;
|
|
1800
|
-
const r = e.
|
|
1801
|
-
if (r !== i) t.
|
|
1867
|
+
const r = e.D !== NOT_PENDING ? e.D : e.Z;
|
|
1868
|
+
if (r !== i) t.W |= REACTIVE_SNAPSHOT_STALE;
|
|
1802
1869
|
return i;
|
|
1803
1870
|
}
|
|
1804
1871
|
}
|
|
1805
|
-
if (e.
|
|
1806
|
-
if (t && stale && shouldReadStashedOptimisticValue(e)) return e.
|
|
1807
|
-
return e.
|
|
1872
|
+
if (e.O !== undefined && e.O !== NOT_PENDING) {
|
|
1873
|
+
if (t && stale && shouldReadStashedOptimisticValue(e)) return e.Z;
|
|
1874
|
+
return e.O;
|
|
1808
1875
|
}
|
|
1809
1876
|
if (
|
|
1810
1877
|
activeTransition !== null &&
|
|
1811
1878
|
currentOptimisticLane !== null &&
|
|
1812
1879
|
!latestReadActive &&
|
|
1813
|
-
e.
|
|
1814
|
-
|
|
1815
|
-
!e.
|
|
1880
|
+
e.D !== NOT_PENDING &&
|
|
1881
|
+
(r === e || !!(r.W & REACTIVE_MANUAL_WRITE)) &&
|
|
1882
|
+
!e.ce &&
|
|
1816
1883
|
t
|
|
1817
1884
|
) {
|
|
1818
|
-
activeTransition.
|
|
1819
|
-
return e.
|
|
1885
|
+
activeTransition.K.add(t);
|
|
1886
|
+
return e.Z;
|
|
1820
1887
|
}
|
|
1821
|
-
const
|
|
1888
|
+
const o =
|
|
1822
1889
|
!t ||
|
|
1823
1890
|
(currentOptimisticLane !== null &&
|
|
1824
|
-
(e.
|
|
1825
|
-
e.
|
|
1826
|
-
(stale && e.
|
|
1827
|
-
? e.
|
|
1828
|
-
: e.
|
|
1891
|
+
(e.O !== undefined || e.i || (r === e && stale && t.t !== e) || !!(r.Y & STATUS_PENDING))) ||
|
|
1892
|
+
e.D === NOT_PENDING ||
|
|
1893
|
+
(stale && e.T && activeTransition !== e.T)
|
|
1894
|
+
? e.Z
|
|
1895
|
+
: e.D;
|
|
1896
|
+
if (pendingCheckActive && pendingProbe !== null && e.D !== NOT_PENDING && o === e.D)
|
|
1897
|
+
pendingProbe.freshReads.add(e);
|
|
1829
1898
|
if (
|
|
1830
1899
|
!t &&
|
|
1831
|
-
|
|
1832
|
-
typeof n.
|
|
1833
|
-
e.
|
|
1834
|
-
!(
|
|
1835
|
-
!e.
|
|
1900
|
+
r === e &&
|
|
1901
|
+
typeof n.ce === "function" &&
|
|
1902
|
+
e.le & CONFIG_AUTO_DISPOSE &&
|
|
1903
|
+
!(r.Y & STATUS_PENDING) &&
|
|
1904
|
+
!e.P
|
|
1836
1905
|
) {
|
|
1837
1906
|
unobserved(e);
|
|
1838
1907
|
}
|
|
1839
|
-
return
|
|
1908
|
+
return o;
|
|
1840
1909
|
}
|
|
1841
1910
|
function setSignal(e, t) {
|
|
1842
|
-
if (e.
|
|
1843
|
-
const n = e.
|
|
1844
|
-
const i = e.
|
|
1845
|
-
const r = n ? (i ? e.
|
|
1911
|
+
if (e.T && activeTransition !== e.T) globalQueue.initTransition(e.T);
|
|
1912
|
+
const n = e.O !== undefined && !projectionWriteActive;
|
|
1913
|
+
const i = e.O !== undefined && e.O !== NOT_PENDING;
|
|
1914
|
+
const r = n ? (i ? e.O : e.Z) : e.D === NOT_PENDING ? e.Z : e.D;
|
|
1846
1915
|
if (typeof t === "function") t = t(r);
|
|
1847
|
-
const o = !e.
|
|
1916
|
+
const o = !!(e.Y & STATUS_UNINITIALIZED) || !e.xe || !e.xe(r, t);
|
|
1848
1917
|
if (!o) {
|
|
1849
|
-
if (n && i
|
|
1850
|
-
|
|
1851
|
-
|
|
1918
|
+
if (n && i) {
|
|
1919
|
+
const t = resolveTransition(e);
|
|
1920
|
+
if (t && activeTransition !== t) globalQueue.initTransition(t);
|
|
1852
1921
|
}
|
|
1853
1922
|
return t;
|
|
1854
1923
|
}
|
|
1855
1924
|
if (n) {
|
|
1856
|
-
const n = e.
|
|
1925
|
+
const n = e.O === NOT_PENDING;
|
|
1857
1926
|
if (!n) globalQueue.initTransition(resolveTransition(e));
|
|
1858
|
-
if (n)
|
|
1859
|
-
e.B = e.ue;
|
|
1860
|
-
globalQueue.Z.push(e);
|
|
1861
|
-
}
|
|
1862
|
-
e.$ = true;
|
|
1927
|
+
if (n) globalQueue.N.push(e);
|
|
1863
1928
|
const i = getOrCreateLane(e);
|
|
1864
|
-
e.
|
|
1865
|
-
e.
|
|
1929
|
+
e.i = i;
|
|
1930
|
+
e.O = t;
|
|
1866
1931
|
} else {
|
|
1867
|
-
if (e.
|
|
1868
|
-
e.
|
|
1932
|
+
if (e.D === NOT_PENDING) queuePendingNode(e);
|
|
1933
|
+
e.D = t;
|
|
1869
1934
|
}
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
setSignal(e.Fe, t);
|
|
1873
|
-
}
|
|
1874
|
-
e.Ie = clock;
|
|
1935
|
+
syncCompanions(e, t);
|
|
1936
|
+
e.fe = clock;
|
|
1875
1937
|
insertSubs(e, n);
|
|
1876
1938
|
schedule();
|
|
1877
1939
|
return t;
|
|
1878
1940
|
}
|
|
1879
1941
|
function suppressComputedRecompute(e) {
|
|
1880
|
-
deleteFromHeap(e, e.
|
|
1881
|
-
if (!(e.
|
|
1882
|
-
|
|
1942
|
+
deleteFromHeap(e, e.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1943
|
+
if (!(e.W & REACTIVE_MANUAL_WRITE) && e.D === NOT_PENDING) {
|
|
1944
|
+
queuePendingNode(e);
|
|
1945
|
+
schedule();
|
|
1946
|
+
}
|
|
1947
|
+
e.W = (e.W & -4) | REACTIVE_MANUAL_WRITE;
|
|
1883
1948
|
}
|
|
1884
1949
|
function setMemo(e, t) {
|
|
1885
1950
|
const n = setSignal(e, t);
|
|
@@ -1899,78 +1964,96 @@ function runWithOwner(e, t) {
|
|
|
1899
1964
|
}
|
|
1900
1965
|
}
|
|
1901
1966
|
function getPendingSignal(e) {
|
|
1902
|
-
if (!e.
|
|
1903
|
-
e.
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
}
|
|
1907
|
-
if (computePendingState(e)) setSignal(e.We, true);
|
|
1967
|
+
if (!e.B) {
|
|
1968
|
+
e.B = optimisticSignal(false, { ownedWrite: true });
|
|
1969
|
+
e.B.t = e;
|
|
1970
|
+
if (computePendingState(e)) setSignal(e.B, true);
|
|
1908
1971
|
}
|
|
1909
|
-
return e.
|
|
1972
|
+
return e.B;
|
|
1910
1973
|
}
|
|
1911
1974
|
function collectPendingSources(e) {
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1975
|
+
if (!pendingProbe) return;
|
|
1976
|
+
pendingProbe.sources.add(e);
|
|
1977
|
+
const t = e.Ie || e;
|
|
1978
|
+
if (t !== e) pendingProbe.sources.add(t);
|
|
1915
1979
|
}
|
|
1916
1980
|
function computePendingState(e) {
|
|
1917
1981
|
const t = e;
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1982
|
+
if (t.W & REACTIVE_DISPOSED) return false;
|
|
1983
|
+
const n = e.Ie;
|
|
1984
|
+
if ((n || t).qe) return false;
|
|
1985
|
+
if (e.t) {
|
|
1986
|
+
const t = e.t;
|
|
1987
|
+
if (hasActiveOverride(t)) return false;
|
|
1988
|
+
const n = t.Ie || t;
|
|
1989
|
+
if (n.qe) return false;
|
|
1990
|
+
return !!(n.Y & STATUS_PENDING && !(n.Y & STATUS_UNINITIALIZED));
|
|
1991
|
+
}
|
|
1992
|
+
if (hasActiveOverride(e)) return false;
|
|
1993
|
+
if (n && e.D !== NOT_PENDING) {
|
|
1994
|
+
return !!(n.W & REACTIVE_MANUAL_WRITE) || (!n.be && !(n.Y & STATUS_PENDING));
|
|
1995
|
+
}
|
|
1996
|
+
if (e.D !== NOT_PENDING && !(t.Y & STATUS_UNINITIALIZED)) return true;
|
|
1997
|
+
return !!(t.Y & STATUS_PENDING && !(t.Y & STATUS_UNINITIALIZED));
|
|
1998
|
+
}
|
|
1999
|
+
function syncCompanions(e, t) {
|
|
2000
|
+
if (e.B) updatePendingSignal(e);
|
|
2001
|
+
if (e.q) setSignal(e.q, t);
|
|
2002
|
+
}
|
|
2003
|
+
function updatePendingSignal(e) {
|
|
2004
|
+
if (e.B) {
|
|
2005
|
+
setSignal(e.B, computePendingState(e));
|
|
1923
2006
|
}
|
|
1924
|
-
if (
|
|
1925
|
-
|
|
2007
|
+
if (e.q) updatePendingSignal(e.q);
|
|
2008
|
+
}
|
|
2009
|
+
function updateChildCompanions(e) {
|
|
2010
|
+
for (let t = e.ye; t !== null; t = t.Pe) {
|
|
2011
|
+
if (t.B || t.q) updatePendingSignal(t);
|
|
1926
2012
|
}
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2013
|
+
}
|
|
2014
|
+
function snapCompanionsToState(e) {
|
|
2015
|
+
const t = e.B;
|
|
2016
|
+
if (t && (t.O === undefined || t.O === NOT_PENDING)) {
|
|
2017
|
+
const n = computePendingState(e);
|
|
2018
|
+
if (t.Z !== n || t.D !== NOT_PENDING) {
|
|
2019
|
+
t.Z = n;
|
|
2020
|
+
t.D = NOT_PENDING;
|
|
2021
|
+
t.fe = clock;
|
|
2022
|
+
insertSubs(t);
|
|
2023
|
+
schedule();
|
|
1932
2024
|
}
|
|
1933
|
-
return true;
|
|
1934
2025
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
const t = resolveLane(e);
|
|
1948
|
-
if (t && t.F.size > 0) {
|
|
1949
|
-
const e = findLane(n.G);
|
|
1950
|
-
if (e !== t) {
|
|
1951
|
-
mergeLanes(t, e);
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
signalLanes.delete(n);
|
|
1955
|
-
n.G = undefined;
|
|
2026
|
+
const n = e.q;
|
|
2027
|
+
if (n && !(n.W & REACTIVE_DISPOSED)) {
|
|
2028
|
+
if (
|
|
2029
|
+
(n.O === undefined || n.O === NOT_PENDING) &&
|
|
2030
|
+
n.D === NOT_PENDING &&
|
|
2031
|
+
!Object.is(n.Z, e.Z) &&
|
|
2032
|
+
!(n.W & (REACTIVE_DIRTY | REACTIVE_CHECK))
|
|
2033
|
+
) {
|
|
2034
|
+
n.W |= REACTIVE_DIRTY;
|
|
2035
|
+
insertIntoHeap(n, n.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
2036
|
+
insertSubs(n);
|
|
2037
|
+
schedule();
|
|
1956
2038
|
}
|
|
2039
|
+
snapCompanionsToState(n);
|
|
1957
2040
|
}
|
|
1958
2041
|
}
|
|
1959
2042
|
function getLatestValueComputed(e) {
|
|
1960
|
-
if (!e.
|
|
2043
|
+
if (!e.q) {
|
|
1961
2044
|
const t = latestReadActive;
|
|
1962
2045
|
latestReadActive = false;
|
|
1963
2046
|
const n = pendingCheckActive;
|
|
1964
2047
|
pendingCheckActive = false;
|
|
1965
2048
|
const i = context;
|
|
1966
2049
|
context = null;
|
|
1967
|
-
e.
|
|
1968
|
-
e.
|
|
2050
|
+
e.q = optimisticComputed(() => read(e));
|
|
2051
|
+
e.q.t = e;
|
|
1969
2052
|
context = i;
|
|
1970
2053
|
pendingCheckActive = n;
|
|
1971
2054
|
latestReadActive = t;
|
|
1972
2055
|
}
|
|
1973
|
-
return e.
|
|
2056
|
+
return e.q;
|
|
1974
2057
|
}
|
|
1975
2058
|
function staleValues(e, t = true) {
|
|
1976
2059
|
const n = stale;
|
|
@@ -1992,16 +2075,14 @@ function latest(e) {
|
|
|
1992
2075
|
}
|
|
1993
2076
|
function isPending(e) {
|
|
1994
2077
|
const t = pendingCheckActive;
|
|
1995
|
-
const n =
|
|
1996
|
-
const i = pendingCheckSources;
|
|
2078
|
+
const n = pendingProbe;
|
|
1997
2079
|
pendingCheckActive = true;
|
|
1998
|
-
|
|
1999
|
-
pendingCheckSources = new Set();
|
|
2080
|
+
const i = (pendingProbe = { found: false, sources: new Set(), freshReads: new Set() });
|
|
2000
2081
|
const collectPending = () => {
|
|
2001
2082
|
pendingCheckActive = false;
|
|
2002
2083
|
try {
|
|
2003
|
-
|
|
2004
|
-
if (read(getPendingSignal(e)))
|
|
2084
|
+
i.sources.forEach(e => {
|
|
2085
|
+
if (read(getPendingSignal(e)) && !i.freshReads.has(e)) i.found = true;
|
|
2005
2086
|
});
|
|
2006
2087
|
} finally {
|
|
2007
2088
|
pendingCheckActive = true;
|
|
@@ -2010,38 +2091,29 @@ function isPending(e) {
|
|
|
2010
2091
|
try {
|
|
2011
2092
|
e();
|
|
2012
2093
|
collectPending();
|
|
2013
|
-
return
|
|
2094
|
+
return i.found;
|
|
2014
2095
|
} catch (e) {
|
|
2015
2096
|
collectPending();
|
|
2016
2097
|
if (e instanceof NotReadyError) {
|
|
2017
|
-
if (
|
|
2098
|
+
if (i.found && !(e.source?.Y & STATUS_UNINITIALIZED)) return true;
|
|
2018
2099
|
if (context) throw e;
|
|
2019
2100
|
}
|
|
2020
|
-
return
|
|
2101
|
+
return i.found;
|
|
2021
2102
|
} finally {
|
|
2022
2103
|
pendingCheckActive = t;
|
|
2023
|
-
|
|
2024
|
-
pendingCheckSources = i;
|
|
2104
|
+
pendingProbe = n;
|
|
2025
2105
|
}
|
|
2026
2106
|
}
|
|
2027
2107
|
function refresh(e) {
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
} finally {
|
|
2037
|
-
refreshing = t;
|
|
2038
|
-
if (!t) {
|
|
2039
|
-
schedule();
|
|
2040
|
-
}
|
|
2108
|
+
const t = e?.[$REFRESH];
|
|
2109
|
+
if (!t) {
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
if (typeof t.ce === "function" && !(t.W & (REACTIVE_DISPOSED | REACTIVE_MANUAL_WRITE))) {
|
|
2113
|
+
t.W = (t.W & ~REACTIVE_CHECK) | REACTIVE_DIRTY;
|
|
2114
|
+
insertIntoHeap(t, t.W & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
2115
|
+
schedule();
|
|
2041
2116
|
}
|
|
2042
|
-
}
|
|
2043
|
-
function isRefreshing() {
|
|
2044
|
-
return refreshing;
|
|
2045
2117
|
}
|
|
2046
2118
|
function createContext(e, t) {
|
|
2047
2119
|
return { id: Symbol(t), defaultValue: e };
|
|
@@ -2073,88 +2145,106 @@ function effect(e, t, n, i) {
|
|
|
2073
2145
|
const o = createEffectNode(e, t, n, r ? EFFECT_USER : EFFECT_RENDER, notifyEffectStatus, i);
|
|
2074
2146
|
recompute(o, true);
|
|
2075
2147
|
!i?.defer &&
|
|
2076
|
-
(o.
|
|
2077
|
-
? o.te.enqueue(o.J, runEffect.bind(null, o))
|
|
2078
|
-
: runEffect(o));
|
|
2148
|
+
(o.V === EFFECT_USER || i?.schedule ? o.F.enqueue(o.V, runEffect.bind(null, o)) : runEffect(o));
|
|
2079
2149
|
}
|
|
2080
2150
|
function notifyEffectStatus(e, t) {
|
|
2081
|
-
const n = e !== undefined ? e : this.
|
|
2082
|
-
const i = t !== undefined ? t : this.
|
|
2151
|
+
const n = e !== undefined ? e : this.Y;
|
|
2152
|
+
const i = t !== undefined ? t : this.ae;
|
|
2083
2153
|
if (n & STATUS_ERROR) {
|
|
2084
|
-
|
|
2085
|
-
this.
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
? this.je(e, () => {
|
|
2090
|
-
this.$e?.();
|
|
2091
|
-
this.$e = undefined;
|
|
2092
|
-
})
|
|
2093
|
-
: console.error(e);
|
|
2094
|
-
} catch (t) {
|
|
2095
|
-
e = t;
|
|
2154
|
+
this.F.notify(this, STATUS_PENDING, 0);
|
|
2155
|
+
if (this.V === EFFECT_USER) {
|
|
2156
|
+
if (this.Y & STATUS_ERROR) {
|
|
2157
|
+
this.G = true;
|
|
2158
|
+
this.F.enqueue(this.V, (this.$e ??= runEffect.bind(null, this)));
|
|
2096
2159
|
}
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
if (!this.F.notify(this, STATUS_ERROR, STATUS_ERROR)) {
|
|
2163
|
+
haltReactivity();
|
|
2164
|
+
throw i;
|
|
2097
2165
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
this.te.notify(this, STATUS_PENDING | STATUS_ERROR, n, i);
|
|
2166
|
+
} else if (this.V === EFFECT_RENDER) {
|
|
2167
|
+
this.F.notify(this, STATUS_PENDING | STATUS_ERROR, n, i);
|
|
2101
2168
|
}
|
|
2102
2169
|
}
|
|
2103
2170
|
function runEffect(e) {
|
|
2104
|
-
if (!e.
|
|
2105
|
-
e
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2171
|
+
if (!e.G || e.W & REACTIVE_DISPOSED) return;
|
|
2172
|
+
if (e.Y & STATUS_ERROR && e.V === EFFECT_USER) {
|
|
2173
|
+
const t = e.ae instanceof StatusError ? (e.ae.cause ?? e.ae) : e.ae;
|
|
2174
|
+
e.Ye = e.Z;
|
|
2175
|
+
e.G = false;
|
|
2176
|
+
try {
|
|
2177
|
+
e.Be
|
|
2178
|
+
? e.Be(t, () => {
|
|
2179
|
+
const t = e.Le;
|
|
2180
|
+
e.Le = undefined;
|
|
2181
|
+
t?.();
|
|
2182
|
+
})
|
|
2183
|
+
: console.error(t);
|
|
2184
|
+
} catch (t) {
|
|
2185
|
+
if (!e.F.notify(e, STATUS_ERROR, STATUS_ERROR)) {
|
|
2186
|
+
haltReactivity();
|
|
2187
|
+
throw t;
|
|
2188
|
+
}
|
|
2114
2189
|
}
|
|
2190
|
+
return;
|
|
2191
|
+
}
|
|
2192
|
+
const t = e.Le;
|
|
2193
|
+
e.Le = undefined;
|
|
2194
|
+
try {
|
|
2195
|
+
t?.();
|
|
2196
|
+
const n = e.Ze(e.Z, e.Ye);
|
|
2197
|
+
if (false && n !== undefined && typeof n !== "function");
|
|
2198
|
+
e.Le = n;
|
|
2115
2199
|
} catch (t) {
|
|
2116
|
-
e.
|
|
2117
|
-
e.
|
|
2118
|
-
if (!e.
|
|
2200
|
+
e.ae = new StatusError(e, t);
|
|
2201
|
+
e.Y |= STATUS_ERROR;
|
|
2202
|
+
if (!e.F.notify(e, STATUS_ERROR, STATUS_ERROR)) {
|
|
2203
|
+
haltReactivity();
|
|
2204
|
+
throw t;
|
|
2205
|
+
}
|
|
2119
2206
|
} finally {
|
|
2120
|
-
e.
|
|
2121
|
-
e.
|
|
2207
|
+
e.Ye = e.Z;
|
|
2208
|
+
e.G = false;
|
|
2122
2209
|
}
|
|
2123
2210
|
}
|
|
2124
|
-
GlobalQueue.
|
|
2211
|
+
GlobalQueue.oe = runEffect;
|
|
2125
2212
|
function trackedEffect(e, t) {
|
|
2126
2213
|
const run = () => {
|
|
2127
|
-
if (!n.
|
|
2214
|
+
if (!n.G || n.W & REACTIVE_DISPOSED) return;
|
|
2128
2215
|
try {
|
|
2129
|
-
n.
|
|
2216
|
+
n.G = false;
|
|
2130
2217
|
recompute(n);
|
|
2131
2218
|
} finally {
|
|
2132
2219
|
}
|
|
2133
2220
|
};
|
|
2134
2221
|
const n = computed(
|
|
2135
2222
|
() => {
|
|
2136
|
-
n
|
|
2137
|
-
n
|
|
2138
|
-
|
|
2139
|
-
|
|
2223
|
+
const t = n.Le;
|
|
2224
|
+
n.Le = undefined;
|
|
2225
|
+
t?.();
|
|
2226
|
+
const i = staleValues(e);
|
|
2227
|
+
n.Le = i;
|
|
2140
2228
|
},
|
|
2141
2229
|
{ ...t, lazy: true }
|
|
2142
2230
|
);
|
|
2143
|
-
n
|
|
2144
|
-
n.
|
|
2145
|
-
n.
|
|
2146
|
-
n.
|
|
2147
|
-
n.
|
|
2148
|
-
const i = e !== undefined ? e : n.
|
|
2231
|
+
n.Le = undefined;
|
|
2232
|
+
n.le = (n.le & ~CONFIG_AUTO_DISPOSE) | CONFIG_CHILDREN_FORBIDDEN;
|
|
2233
|
+
n.G = true;
|
|
2234
|
+
n.V = EFFECT_TRACKED;
|
|
2235
|
+
n.Qe = (e, t) => {
|
|
2236
|
+
const i = e !== undefined ? e : n.Y;
|
|
2149
2237
|
if (i & STATUS_ERROR) {
|
|
2150
|
-
n.
|
|
2151
|
-
const e = t !== undefined ? t : n.
|
|
2152
|
-
if (!n.
|
|
2238
|
+
n.F.notify(n, STATUS_PENDING, 0);
|
|
2239
|
+
const e = t !== undefined ? t : n.ae;
|
|
2240
|
+
if (!n.F.notify(n, STATUS_ERROR, STATUS_ERROR)) {
|
|
2241
|
+
haltReactivity();
|
|
2242
|
+
throw e;
|
|
2243
|
+
}
|
|
2153
2244
|
}
|
|
2154
2245
|
};
|
|
2155
|
-
n.
|
|
2156
|
-
n.
|
|
2157
|
-
cleanup(() => n.$e?.());
|
|
2246
|
+
n.k = run;
|
|
2247
|
+
n.F.enqueue(EFFECT_USER, run);
|
|
2158
2248
|
}
|
|
2159
2249
|
function restoreTransition(e, t) {
|
|
2160
2250
|
globalQueue.initTransition(e);
|
|
@@ -2168,11 +2258,11 @@ function action(e) {
|
|
|
2168
2258
|
const r = e(...t);
|
|
2169
2259
|
globalQueue.initTransition();
|
|
2170
2260
|
let o = activeTransition;
|
|
2171
|
-
o.
|
|
2261
|
+
o.j.push(r);
|
|
2172
2262
|
const done = (e, t) => {
|
|
2173
2263
|
o = currentTransition(o);
|
|
2174
|
-
const s = o.
|
|
2175
|
-
if (s >= 0) o.
|
|
2264
|
+
const s = o.j.indexOf(r);
|
|
2265
|
+
if (s >= 0) o.j.splice(s, 1);
|
|
2176
2266
|
setActiveTransition(o);
|
|
2177
2267
|
schedule();
|
|
2178
2268
|
t ? i(t) : n(e);
|
|
@@ -2184,13 +2274,12 @@ function action(e) {
|
|
|
2184
2274
|
} catch (e) {
|
|
2185
2275
|
return done(undefined, e);
|
|
2186
2276
|
}
|
|
2187
|
-
if (n
|
|
2188
|
-
return void n.then(run, e => restoreTransition(o, () => step(e, true)));
|
|
2277
|
+
if (isThenable(n)) return void n.then(run, e => done(undefined, e));
|
|
2189
2278
|
run(n);
|
|
2190
2279
|
};
|
|
2191
2280
|
const run = e => {
|
|
2192
2281
|
if (e.done) return done(e.value);
|
|
2193
|
-
if (e.value
|
|
2282
|
+
if (isThenable(e.value))
|
|
2194
2283
|
return void e.value.then(
|
|
2195
2284
|
e => restoreTransition(o, () => step(e)),
|
|
2196
2285
|
e => restoreTransition(o, () => step(e, true))
|
|
@@ -2211,7 +2300,7 @@ function accessor(e) {
|
|
|
2211
2300
|
function createSignal(e, t) {
|
|
2212
2301
|
if (typeof e === "function") {
|
|
2213
2302
|
const n = computed(e, t);
|
|
2214
|
-
n.
|
|
2303
|
+
n.le &= ~CONFIG_AUTO_DISPOSE;
|
|
2215
2304
|
return [accessor(n), setMemo.bind(null, n)];
|
|
2216
2305
|
}
|
|
2217
2306
|
const n = signal(e, t);
|
|
@@ -2253,22 +2342,25 @@ function createReaction(e, t) {
|
|
|
2253
2342
|
function resolve(e) {
|
|
2254
2343
|
return new Promise((t, n) => {
|
|
2255
2344
|
createRoot(i => {
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2345
|
+
effect(
|
|
2346
|
+
e,
|
|
2347
|
+
e => {
|
|
2348
|
+
t(e);
|
|
2349
|
+
i();
|
|
2350
|
+
},
|
|
2351
|
+
e => {
|
|
2261
2352
|
n(e);
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2353
|
+
i();
|
|
2354
|
+
},
|
|
2355
|
+
{ user: true }
|
|
2356
|
+
);
|
|
2265
2357
|
});
|
|
2266
2358
|
});
|
|
2267
2359
|
}
|
|
2268
2360
|
function createOptimistic(e, t) {
|
|
2269
2361
|
if (typeof e === "function") {
|
|
2270
2362
|
const n = optimisticComputed(e, t);
|
|
2271
|
-
n.
|
|
2363
|
+
n.le &= ~CONFIG_AUTO_DISPOSE;
|
|
2272
2364
|
return [accessor(n), setSignal.bind(null, n)];
|
|
2273
2365
|
}
|
|
2274
2366
|
const n = optimisticSignal(e, t);
|
|
@@ -2276,26 +2368,103 @@ function createOptimistic(e, t) {
|
|
|
2276
2368
|
}
|
|
2277
2369
|
function onSettled(e) {
|
|
2278
2370
|
const t = getOwner();
|
|
2279
|
-
t && !(t.
|
|
2371
|
+
t && !(t.le & CONFIG_CHILDREN_FORBIDDEN)
|
|
2280
2372
|
? createTrackedEffect(() => untrack(e), undefined)
|
|
2281
2373
|
: globalQueue.enqueue(EFFECT_USER, () => {
|
|
2282
|
-
|
|
2283
|
-
t?.();
|
|
2374
|
+
e();
|
|
2284
2375
|
});
|
|
2285
2376
|
}
|
|
2377
|
+
function nodeKeys(e) {
|
|
2378
|
+
const t = Object.keys(e);
|
|
2379
|
+
if (symbolKeyedRecords.has(e)) {
|
|
2380
|
+
const n = Object.getOwnPropertySymbols(e);
|
|
2381
|
+
for (let e = 0, i = n.length; e < i; e++) {
|
|
2382
|
+
if (n[e] !== $TRACK) t.push(n[e]);
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
return t;
|
|
2386
|
+
}
|
|
2286
2387
|
function unwrap(e) {
|
|
2287
|
-
|
|
2388
|
+
if (e === null || typeof e !== "object") return e;
|
|
2389
|
+
return e[$TARGET]?.[STORE_VALUE] ?? e;
|
|
2288
2390
|
}
|
|
2289
2391
|
function getOverrideValue(e, t, n, i) {
|
|
2290
2392
|
if (i && n in i) return i[n];
|
|
2291
2393
|
return t && n in t ? t[n] : e[n];
|
|
2292
2394
|
}
|
|
2395
|
+
function addEnumSymbols(e, t, n) {
|
|
2396
|
+
for (let i = 0, r = t.length; i < r; i++) {
|
|
2397
|
+
if (Object.prototype.propertyIsEnumerable.call(e, t[i])) n.add(t[i]);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2293
2400
|
function getAllKeys(e, t, n) {
|
|
2294
2401
|
const i = getKeys(e, t);
|
|
2295
2402
|
const r = Object.keys(n);
|
|
2296
|
-
|
|
2403
|
+
const o = e[$TARGET]
|
|
2404
|
+
? untrack(() => Object.getOwnPropertySymbols(e))
|
|
2405
|
+
: Object.getOwnPropertySymbols(e);
|
|
2406
|
+
const s = Object.getOwnPropertySymbols(n);
|
|
2407
|
+
if (o.length === 0 && s.length === 0) {
|
|
2408
|
+
if (i.length === r.length) {
|
|
2409
|
+
let e = true;
|
|
2410
|
+
for (let t = 0; t < i.length; t++) {
|
|
2411
|
+
if (i[t] !== r[t]) {
|
|
2412
|
+
e = false;
|
|
2413
|
+
break;
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
if (e) return i;
|
|
2417
|
+
}
|
|
2418
|
+
const e = new Set(i);
|
|
2419
|
+
for (let t = 0; t < r.length; t++) e.add(r[t]);
|
|
2420
|
+
return Array.from(e);
|
|
2421
|
+
}
|
|
2422
|
+
const u = new Set(i);
|
|
2423
|
+
addEnumSymbols(e, o, u);
|
|
2424
|
+
if (t) {
|
|
2425
|
+
for (const e of Reflect.ownKeys(t)) {
|
|
2426
|
+
t[e] === $DELETED ? u.delete(e) : u.add(e);
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
for (let e = 0; e < r.length; e++) u.add(r[e]);
|
|
2430
|
+
addEnumSymbols(n, s, u);
|
|
2431
|
+
return Array.from(u);
|
|
2432
|
+
}
|
|
2433
|
+
function wrapValue(e, t) {
|
|
2434
|
+
return isWrappable(e) ? wrap(e, t) : e;
|
|
2435
|
+
}
|
|
2436
|
+
function itemKey(e, t) {
|
|
2437
|
+
return isWrappable(e) ? t(e) : e;
|
|
2438
|
+
}
|
|
2439
|
+
function keyedMatch(e, t, n) {
|
|
2440
|
+
return e === t || (isWrappable(e) && isWrappable(t) && n(e) === n(t));
|
|
2441
|
+
}
|
|
2442
|
+
function syncArrayNodeMembership(e, t) {
|
|
2443
|
+
let n = e[STORE_NODE];
|
|
2444
|
+
if (n) {
|
|
2445
|
+
const e = nodeKeys(n);
|
|
2446
|
+
for (let i = 0, r = e.length; i < r; i++) {
|
|
2447
|
+
const r = e[i];
|
|
2448
|
+
r in t || setSignal(n[r], undefined);
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
if ((n = e[STORE_HAS])) {
|
|
2452
|
+
const e = nodeKeys(n);
|
|
2453
|
+
for (let i = 0, r = e.length; i < r; i++) {
|
|
2454
|
+
const r = e[i];
|
|
2455
|
+
setSignal(n[r], r in t);
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
function applyArrayItem(e, t, n, i, r) {
|
|
2460
|
+
if (isWrappable(e) && isWrappable(t)) {
|
|
2461
|
+
const o = wrap(t, n);
|
|
2462
|
+
i && setSignal(i, o);
|
|
2463
|
+
applyState(e, o, r);
|
|
2464
|
+
} else i && setSignal(i, wrapValue(e, n));
|
|
2297
2465
|
}
|
|
2298
2466
|
function applyState(e, t, n) {
|
|
2467
|
+
e = unwrap(e);
|
|
2299
2468
|
const i = t?.[$TARGET];
|
|
2300
2469
|
if (!i) return;
|
|
2301
2470
|
if (i[STORE_OVERRIDE] || i[STORE_OPTIMISTIC_OVERRIDE]) {
|
|
@@ -2307,106 +2476,109 @@ function applyState(e, t, n) {
|
|
|
2307
2476
|
function applyStateFast(e, t, n) {
|
|
2308
2477
|
const i = t[STORE_VALUE];
|
|
2309
2478
|
if (e === i) return;
|
|
2479
|
+
const r = t[STORE_NODE];
|
|
2310
2480
|
(t[STORE_LOOKUP] || storeLookup).set(e, t[$PROXY]);
|
|
2311
2481
|
t[STORE_VALUE] = e;
|
|
2312
2482
|
if (Array.isArray(i)) {
|
|
2313
|
-
let
|
|
2314
|
-
const
|
|
2315
|
-
if (e.length &&
|
|
2316
|
-
let
|
|
2317
|
-
for (
|
|
2318
|
-
|
|
2319
|
-
c < l && ((f = i[c]) === e[c] || (f && e[c] && n(f) === n(e[c])));
|
|
2320
|
-
c++
|
|
2321
|
-
) {
|
|
2322
|
-
applyState(e[c], wrap(f, t), n);
|
|
2483
|
+
let o = false;
|
|
2484
|
+
const s = i.length;
|
|
2485
|
+
if (e.length && s && isWrappable(e[0]) && n(e[0]) != null) {
|
|
2486
|
+
let u, c, l, a, f, E, d, S;
|
|
2487
|
+
for (l = 0, a = Math.min(s, e.length); l < a && keyedMatch((E = i[l]), e[l], n); l++) {
|
|
2488
|
+
isWrappable(E) && isWrappable(e[l]) && applyState(e[l], wrap(E, t), n);
|
|
2323
2489
|
}
|
|
2324
2490
|
const T = new Array(e.length),
|
|
2325
|
-
|
|
2491
|
+
_ = new Map();
|
|
2326
2492
|
for (
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2493
|
+
a = s - 1, f = e.length - 1;
|
|
2494
|
+
a >= l && f >= l && keyedMatch((E = i[a]), e[f], n);
|
|
2495
|
+
a--, f--
|
|
2330
2496
|
) {
|
|
2331
|
-
T[
|
|
2497
|
+
T[f] = E;
|
|
2332
2498
|
}
|
|
2333
|
-
if (
|
|
2334
|
-
for (
|
|
2335
|
-
|
|
2336
|
-
|
|
2499
|
+
if (l > f || l > a) {
|
|
2500
|
+
for (c = l; c <= f; c++) {
|
|
2501
|
+
o = true;
|
|
2502
|
+
r?.[c] && setSignal(r[c], wrapValue(e[c], t));
|
|
2337
2503
|
}
|
|
2338
|
-
for (;
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
t[STORE_NODE][u] && setSignal(t[STORE_NODE][u], i);
|
|
2342
|
-
applyState(e[u], i, n);
|
|
2504
|
+
for (; c < e.length; c++) {
|
|
2505
|
+
o = true;
|
|
2506
|
+
applyArrayItem(e[c], T[c], t, r?.[c], n);
|
|
2343
2507
|
}
|
|
2344
|
-
|
|
2345
|
-
o !== e.length &&
|
|
2508
|
+
syncArrayNodeMembership(t, e);
|
|
2509
|
+
(o || s !== e.length) && notifySelf(t);
|
|
2510
|
+
s !== e.length && r?.length && setSignal(r.length, e.length);
|
|
2346
2511
|
return;
|
|
2347
2512
|
}
|
|
2348
|
-
|
|
2349
|
-
for (
|
|
2350
|
-
|
|
2351
|
-
S =
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
}
|
|
2356
|
-
for (
|
|
2357
|
-
|
|
2358
|
-
S =
|
|
2359
|
-
|
|
2360
|
-
if (
|
|
2361
|
-
T[
|
|
2362
|
-
|
|
2363
|
-
|
|
2513
|
+
d = new Array(f + 1);
|
|
2514
|
+
for (c = f; c >= l; c--) {
|
|
2515
|
+
E = e[c];
|
|
2516
|
+
S = itemKey(E, n);
|
|
2517
|
+
u = _.get(S);
|
|
2518
|
+
d[c] = u === undefined ? -1 : u;
|
|
2519
|
+
_.set(S, c);
|
|
2520
|
+
}
|
|
2521
|
+
for (u = l; u <= a; u++) {
|
|
2522
|
+
E = i[u];
|
|
2523
|
+
S = itemKey(E, n);
|
|
2524
|
+
c = _.get(S);
|
|
2525
|
+
if (c !== undefined && c !== -1) {
|
|
2526
|
+
T[c] = E;
|
|
2527
|
+
c = d[c];
|
|
2528
|
+
_.set(S, c);
|
|
2364
2529
|
}
|
|
2365
2530
|
}
|
|
2366
|
-
for (
|
|
2367
|
-
if (
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
applyState(e[u], i, n);
|
|
2371
|
-
} else t[STORE_NODE][u] && setSignal(t[STORE_NODE][u], wrap(e[u], t));
|
|
2531
|
+
for (c = l; c < e.length; c++) {
|
|
2532
|
+
if (c in T) {
|
|
2533
|
+
applyArrayItem(e[c], T[c], t, r?.[c], n);
|
|
2534
|
+
} else r?.[c] && setSignal(r[c], wrapValue(e[c], t));
|
|
2372
2535
|
}
|
|
2373
|
-
if (
|
|
2536
|
+
if (l < e.length) o = true;
|
|
2374
2537
|
} else if (e.length) {
|
|
2375
|
-
for (let
|
|
2376
|
-
const
|
|
2377
|
-
isWrappable(
|
|
2378
|
-
|
|
2379
|
-
|
|
2538
|
+
for (let s = 0, u = e.length; s < u; s++) {
|
|
2539
|
+
const u = i[s];
|
|
2540
|
+
if (isWrappable(u) && isWrappable(e[s])) applyState(e[s], wrap(u, t), n);
|
|
2541
|
+
else {
|
|
2542
|
+
if (u !== e[s]) o = true;
|
|
2543
|
+
r?.[s] && setSignal(r[s], wrapValue(e[s], t));
|
|
2544
|
+
}
|
|
2380
2545
|
}
|
|
2381
2546
|
}
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2547
|
+
syncArrayNodeMembership(t, e);
|
|
2548
|
+
if (s !== e.length) {
|
|
2549
|
+
o = true;
|
|
2550
|
+
r?.length && setSignal(r.length, e.length);
|
|
2385
2551
|
}
|
|
2386
|
-
|
|
2552
|
+
o && notifySelf(t);
|
|
2387
2553
|
return;
|
|
2388
2554
|
}
|
|
2389
|
-
let
|
|
2390
|
-
if (
|
|
2391
|
-
const
|
|
2392
|
-
const s =
|
|
2555
|
+
let o = t[STORE_NODE];
|
|
2556
|
+
if (o) {
|
|
2557
|
+
const r = o[$TRACK];
|
|
2558
|
+
const s = r ? getAllKeys(i, undefined, e) : nodeKeys(o);
|
|
2393
2559
|
for (let u = 0, c = s.length; u < c; u++) {
|
|
2394
2560
|
const c = s[u];
|
|
2395
|
-
const l =
|
|
2561
|
+
const l = o[c];
|
|
2396
2562
|
const a = unwrap(i[c]);
|
|
2397
2563
|
let f = unwrap(e[c]);
|
|
2398
2564
|
if (a === f) continue;
|
|
2399
|
-
if (
|
|
2400
|
-
|
|
2565
|
+
if (
|
|
2566
|
+
!a ||
|
|
2567
|
+
!isWrappable(a) ||
|
|
2568
|
+
!isWrappable(f) ||
|
|
2569
|
+
Array.isArray(a) !== Array.isArray(f) ||
|
|
2570
|
+
(n(a) != null && n(a) !== n(f))
|
|
2571
|
+
) {
|
|
2572
|
+
r && setSignal(r, void 0);
|
|
2401
2573
|
l && setSignal(l, isWrappable(f) ? wrap(f, t) : f);
|
|
2402
2574
|
} else applyState(f, wrap(a, t), n);
|
|
2403
2575
|
}
|
|
2404
2576
|
}
|
|
2405
|
-
if ((
|
|
2406
|
-
const t =
|
|
2577
|
+
if ((o = t[STORE_HAS])) {
|
|
2578
|
+
const t = nodeKeys(o);
|
|
2407
2579
|
for (let n = 0, i = t.length; n < i; n++) {
|
|
2408
2580
|
const i = t[n];
|
|
2409
|
-
setSignal(
|
|
2581
|
+
setSignal(o[i], i in e);
|
|
2410
2582
|
}
|
|
2411
2583
|
}
|
|
2412
2584
|
}
|
|
@@ -2419,101 +2591,107 @@ function applyStateSlow(e, t, n) {
|
|
|
2419
2591
|
t[STORE_VALUE] = e;
|
|
2420
2592
|
t[STORE_OVERRIDE] = undefined;
|
|
2421
2593
|
if (Array.isArray(i)) {
|
|
2422
|
-
let
|
|
2423
|
-
const
|
|
2424
|
-
if (e.length &&
|
|
2425
|
-
let
|
|
2594
|
+
let u = false;
|
|
2595
|
+
const c = getOverrideValue(i, r, "length", o);
|
|
2596
|
+
if (e.length && c && isWrappable(e[0]) && n(e[0]) != null) {
|
|
2597
|
+
let l, a, f, E, d, S, T, _;
|
|
2426
2598
|
for (
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2599
|
+
f = 0, E = Math.min(c, e.length);
|
|
2600
|
+
f < E && keyedMatch((S = getOverrideValue(i, r, f, o)), e[f], n);
|
|
2601
|
+
f++
|
|
2430
2602
|
) {
|
|
2431
|
-
applyState(e[
|
|
2603
|
+
isWrappable(S) && isWrappable(e[f]) && applyState(e[f], wrap(S, t), n);
|
|
2432
2604
|
}
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2605
|
+
const O = new Array(e.length),
|
|
2606
|
+
p = new Map();
|
|
2435
2607
|
for (
|
|
2436
|
-
|
|
2437
|
-
f >=
|
|
2438
|
-
E
|
|
2439
|
-
((S = getOverrideValue(i, r, f, o)) === e[E] || (S && e[E] && n(S) === n(e[E])));
|
|
2440
|
-
f--, E--
|
|
2608
|
+
E = c - 1, d = e.length - 1;
|
|
2609
|
+
E >= f && d >= f && keyedMatch((S = getOverrideValue(i, r, E, o)), e[d], n);
|
|
2610
|
+
E--, d--
|
|
2441
2611
|
) {
|
|
2442
|
-
|
|
2612
|
+
O[d] = S;
|
|
2443
2613
|
}
|
|
2444
|
-
if (
|
|
2445
|
-
for (
|
|
2446
|
-
|
|
2447
|
-
|
|
2614
|
+
if (f > d || f > E) {
|
|
2615
|
+
for (a = f; a <= d; a++) {
|
|
2616
|
+
u = true;
|
|
2617
|
+
s?.[a] && setSignal(s[a], wrapValue(e[a], t));
|
|
2448
2618
|
}
|
|
2449
|
-
for (;
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
t[STORE_NODE][l] && setSignal(t[STORE_NODE][l], i);
|
|
2453
|
-
applyState(e[l], i, n);
|
|
2619
|
+
for (; a < e.length; a++) {
|
|
2620
|
+
u = true;
|
|
2621
|
+
applyArrayItem(e[a], O[a], t, s?.[a], n);
|
|
2454
2622
|
}
|
|
2455
|
-
|
|
2456
|
-
|
|
2623
|
+
const i = e.length;
|
|
2624
|
+
syncArrayNodeMembership(t, e);
|
|
2625
|
+
(u || c !== i) && notifySelf(t);
|
|
2626
|
+
c !== i && s?.length && setSignal(s.length, i);
|
|
2457
2627
|
return;
|
|
2458
2628
|
}
|
|
2459
|
-
T = new Array(
|
|
2460
|
-
for (
|
|
2461
|
-
S = e[
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
T[
|
|
2465
|
-
|
|
2466
|
-
}
|
|
2467
|
-
for (
|
|
2468
|
-
S = getOverrideValue(i, r,
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
if (
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2629
|
+
T = new Array(d + 1);
|
|
2630
|
+
for (a = d; a >= f; a--) {
|
|
2631
|
+
S = e[a];
|
|
2632
|
+
_ = itemKey(S, n);
|
|
2633
|
+
l = p.get(_);
|
|
2634
|
+
T[a] = l === undefined ? -1 : l;
|
|
2635
|
+
p.set(_, a);
|
|
2636
|
+
}
|
|
2637
|
+
for (l = f; l <= E; l++) {
|
|
2638
|
+
S = getOverrideValue(i, r, l, o);
|
|
2639
|
+
_ = itemKey(S, n);
|
|
2640
|
+
a = p.get(_);
|
|
2641
|
+
if (a !== undefined && a !== -1) {
|
|
2642
|
+
O[a] = S;
|
|
2643
|
+
a = T[a];
|
|
2644
|
+
p.set(_, a);
|
|
2475
2645
|
}
|
|
2476
2646
|
}
|
|
2477
|
-
for (
|
|
2478
|
-
if (
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
applyState(e[l], i, n);
|
|
2482
|
-
} else t[STORE_NODE][l] && setSignal(t[STORE_NODE][l], wrap(e[l], t));
|
|
2647
|
+
for (a = f; a < e.length; a++) {
|
|
2648
|
+
if (a in O) {
|
|
2649
|
+
applyArrayItem(e[a], O[a], t, s?.[a], n);
|
|
2650
|
+
} else s?.[a] && setSignal(s[a], wrapValue(e[a], t));
|
|
2483
2651
|
}
|
|
2484
|
-
if (
|
|
2652
|
+
if (f < e.length) u = true;
|
|
2485
2653
|
} else if (e.length) {
|
|
2486
|
-
for (let
|
|
2487
|
-
const
|
|
2488
|
-
isWrappable(
|
|
2489
|
-
|
|
2490
|
-
|
|
2654
|
+
for (let c = 0, l = e.length; c < l; c++) {
|
|
2655
|
+
const l = getOverrideValue(i, r, c, o);
|
|
2656
|
+
if (isWrappable(l) && isWrappable(e[c])) applyState(e[c], wrap(l, t), n);
|
|
2657
|
+
else {
|
|
2658
|
+
if (l !== e[c]) u = true;
|
|
2659
|
+
s?.[c] && setSignal(s[c], wrapValue(e[c], t));
|
|
2660
|
+
}
|
|
2491
2661
|
}
|
|
2492
2662
|
}
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2663
|
+
const l = e.length;
|
|
2664
|
+
syncArrayNodeMembership(t, e);
|
|
2665
|
+
if (c !== l) {
|
|
2666
|
+
u = true;
|
|
2667
|
+
s?.length && setSignal(s.length, l);
|
|
2496
2668
|
}
|
|
2497
|
-
|
|
2669
|
+
u && notifySelf(t);
|
|
2498
2670
|
return;
|
|
2499
2671
|
}
|
|
2500
2672
|
if (s) {
|
|
2501
2673
|
const u = s[$TRACK];
|
|
2502
|
-
const c = u ? getAllKeys(i, r, e) :
|
|
2674
|
+
const c = u ? getAllKeys(i, r, e) : nodeKeys(s);
|
|
2503
2675
|
for (let l = 0, a = c.length; l < a; l++) {
|
|
2504
2676
|
const a = c[l];
|
|
2505
2677
|
const f = s[a];
|
|
2506
2678
|
const E = unwrap(getOverrideValue(i, r, a, o));
|
|
2507
|
-
let
|
|
2508
|
-
if (E ===
|
|
2509
|
-
if (
|
|
2679
|
+
let d = unwrap(e[a]);
|
|
2680
|
+
if (E === d) continue;
|
|
2681
|
+
if (
|
|
2682
|
+
!E ||
|
|
2683
|
+
!isWrappable(E) ||
|
|
2684
|
+
!isWrappable(d) ||
|
|
2685
|
+
Array.isArray(E) !== Array.isArray(d) ||
|
|
2686
|
+
(n(E) != null && n(E) !== n(d))
|
|
2687
|
+
) {
|
|
2510
2688
|
u && setSignal(u, void 0);
|
|
2511
|
-
f && setSignal(f, isWrappable(
|
|
2512
|
-
} else applyState(
|
|
2689
|
+
f && setSignal(f, isWrappable(d) ? wrap(d, t) : d);
|
|
2690
|
+
} else applyState(d, wrap(E, t), n);
|
|
2513
2691
|
}
|
|
2514
2692
|
}
|
|
2515
2693
|
if ((s = t[STORE_HAS])) {
|
|
2516
|
-
const t =
|
|
2694
|
+
const t = nodeKeys(s);
|
|
2517
2695
|
for (let n = 0, i = t.length; n < i; n++) {
|
|
2518
2696
|
const i = t[n];
|
|
2519
2697
|
setSignal(s[i], i in e);
|
|
@@ -2525,7 +2703,7 @@ function reconcile(e, t) {
|
|
|
2525
2703
|
if (n == null) throw new Error("Cannot reconcile null or undefined state");
|
|
2526
2704
|
const i = typeof t === "string" ? e => e[t] : t;
|
|
2527
2705
|
const r = i(n);
|
|
2528
|
-
if (r !== undefined && i(e) !==
|
|
2706
|
+
if (r !== undefined && i(e) !== r)
|
|
2529
2707
|
throw new Error("Cannot reconcile states with different identity");
|
|
2530
2708
|
applyState(e, n, i);
|
|
2531
2709
|
};
|
|
@@ -2555,45 +2733,46 @@ function createProjectionInternal(e, t, n) {
|
|
|
2555
2733
|
if (!i) i = getOwner();
|
|
2556
2734
|
runProjectionComputed(o, e, n?.key || "id");
|
|
2557
2735
|
}, undefined);
|
|
2558
|
-
i.
|
|
2736
|
+
i.le &= ~CONFIG_AUTO_DISPOSE;
|
|
2559
2737
|
return { store: o, node: i };
|
|
2560
2738
|
}
|
|
2561
2739
|
function createProjection(e, t, n) {
|
|
2562
2740
|
return createProjectionInternal(e, t, n).store;
|
|
2563
2741
|
}
|
|
2564
|
-
function runProjectionComputed(e, t, n, i) {
|
|
2565
|
-
const
|
|
2566
|
-
let
|
|
2567
|
-
let
|
|
2568
|
-
const
|
|
2742
|
+
function runProjectionComputed(e, t, n, i, r) {
|
|
2743
|
+
const o = getOwner();
|
|
2744
|
+
let s = false;
|
|
2745
|
+
let u;
|
|
2746
|
+
const c = new Proxy(
|
|
2569
2747
|
e,
|
|
2570
|
-
createWriteTraps(() => !
|
|
2748
|
+
createWriteTraps(() => !s || o.be === u, r)
|
|
2571
2749
|
);
|
|
2572
|
-
storeSetter(
|
|
2573
|
-
|
|
2574
|
-
|
|
2750
|
+
storeSetter(c, r => {
|
|
2751
|
+
u = t(r);
|
|
2752
|
+
s = true;
|
|
2575
2753
|
const commit = t => {
|
|
2576
|
-
if (t ===
|
|
2754
|
+
if (t === r || t === undefined) return;
|
|
2577
2755
|
const write = () => storeSetter(e, reconcile(t, n));
|
|
2578
2756
|
i ? i(write) : write();
|
|
2579
2757
|
};
|
|
2580
|
-
commit(handleAsync(
|
|
2758
|
+
commit(handleAsync(o, u, commit));
|
|
2581
2759
|
});
|
|
2582
|
-
return
|
|
2760
|
+
return o;
|
|
2583
2761
|
}
|
|
2584
|
-
function createWriteTraps(e) {
|
|
2585
|
-
const
|
|
2586
|
-
get(e,
|
|
2762
|
+
function createWriteTraps(e, t) {
|
|
2763
|
+
const n = {
|
|
2764
|
+
get(e, t) {
|
|
2587
2765
|
let i;
|
|
2588
2766
|
setWriteOverride(true);
|
|
2589
2767
|
setProjectionWriteActive(true);
|
|
2590
2768
|
try {
|
|
2591
|
-
i = e[
|
|
2769
|
+
i = e[t];
|
|
2592
2770
|
} finally {
|
|
2593
2771
|
setWriteOverride(false);
|
|
2594
2772
|
setProjectionWriteActive(false);
|
|
2595
2773
|
}
|
|
2596
|
-
|
|
2774
|
+
if (t === $TARGET) return i;
|
|
2775
|
+
return typeof i === "object" && i !== null ? new Proxy(i, n) : i;
|
|
2597
2776
|
},
|
|
2598
2777
|
has(e, t) {
|
|
2599
2778
|
let n;
|
|
@@ -2607,24 +2786,26 @@ function createWriteTraps(e) {
|
|
|
2607
2786
|
}
|
|
2608
2787
|
return n;
|
|
2609
2788
|
},
|
|
2610
|
-
set(
|
|
2789
|
+
set(n, i, r) {
|
|
2611
2790
|
if (e && !e()) return true;
|
|
2612
2791
|
setWriteOverride(true);
|
|
2613
2792
|
setProjectionWriteActive(true);
|
|
2614
2793
|
try {
|
|
2615
|
-
|
|
2794
|
+
n[i] = r;
|
|
2795
|
+
t?.();
|
|
2616
2796
|
} finally {
|
|
2617
2797
|
setWriteOverride(false);
|
|
2618
2798
|
setProjectionWriteActive(false);
|
|
2619
2799
|
}
|
|
2620
2800
|
return true;
|
|
2621
2801
|
},
|
|
2622
|
-
deleteProperty(
|
|
2802
|
+
deleteProperty(n, i) {
|
|
2623
2803
|
if (e && !e()) return true;
|
|
2624
2804
|
setWriteOverride(true);
|
|
2625
2805
|
setProjectionWriteActive(true);
|
|
2626
2806
|
try {
|
|
2627
|
-
delete
|
|
2807
|
+
delete n[i];
|
|
2808
|
+
t?.();
|
|
2628
2809
|
} finally {
|
|
2629
2810
|
setWriteOverride(false);
|
|
2630
2811
|
setProjectionWriteActive(false);
|
|
@@ -2632,7 +2813,7 @@ function createWriteTraps(e) {
|
|
|
2632
2813
|
return true;
|
|
2633
2814
|
}
|
|
2634
2815
|
};
|
|
2635
|
-
return
|
|
2816
|
+
return n;
|
|
2636
2817
|
}
|
|
2637
2818
|
const $TRACK = Symbol(0),
|
|
2638
2819
|
$TARGET = Symbol(0),
|
|
@@ -2647,7 +2828,9 @@ const STORE_VALUE = "v",
|
|
|
2647
2828
|
STORE_WRAP = "w",
|
|
2648
2829
|
STORE_LOOKUP = "l",
|
|
2649
2830
|
STORE_FIREWALL = "f",
|
|
2650
|
-
STORE_OPTIMISTIC = "p"
|
|
2831
|
+
STORE_OPTIMISTIC = "p",
|
|
2832
|
+
STORE_MASKED = "m";
|
|
2833
|
+
const STORE_SELF_PENDING = Symbol(0);
|
|
2651
2834
|
function createStoreProxy(e, t = storeTraps, n) {
|
|
2652
2835
|
let i;
|
|
2653
2836
|
if (Array.isArray(e)) {
|
|
@@ -2665,6 +2848,7 @@ function createStoreProxy(e, t = storeTraps, n) {
|
|
|
2665
2848
|
return (i[$PROXY] = new Proxy(i, t));
|
|
2666
2849
|
}
|
|
2667
2850
|
const storeLookup = new WeakMap();
|
|
2851
|
+
const symbolKeyedRecords = new WeakSet();
|
|
2668
2852
|
function wrap(e, t) {
|
|
2669
2853
|
if (t?.[STORE_WRAP]) return t[STORE_WRAP](e, t);
|
|
2670
2854
|
let n = e[$PROXY] || storeLookup.get(e);
|
|
@@ -2682,17 +2866,45 @@ function setWriteOverride(e) {
|
|
|
2682
2866
|
function writeOnly(e) {
|
|
2683
2867
|
return writeOverride || !!Writing?.has(e);
|
|
2684
2868
|
}
|
|
2685
|
-
function unwrapStoreValue(e) {
|
|
2686
|
-
|
|
2869
|
+
function unwrapStoreValue(e, t, n) {
|
|
2870
|
+
const i = e?.[$TARGET] || n?.get(e)?.[$TARGET];
|
|
2871
|
+
if (!i) return e;
|
|
2872
|
+
const r = i[STORE_OVERRIDE];
|
|
2873
|
+
if (!r) return i[STORE_VALUE];
|
|
2874
|
+
if (!t) t = new Map();
|
|
2875
|
+
if (t.has(e)) return t.get(e);
|
|
2876
|
+
const o = i[STORE_VALUE];
|
|
2877
|
+
const s = Array.isArray(o);
|
|
2878
|
+
const u = s ? [] : Object.create(Object.getPrototypeOf(o));
|
|
2879
|
+
t.set(e, u);
|
|
2880
|
+
n = i[STORE_LOOKUP] ?? storeLookup;
|
|
2881
|
+
for (const e of getKeys(o, r)) {
|
|
2882
|
+
if (s && e === "length") continue;
|
|
2883
|
+
const i = e in r ? r[e] : o[e];
|
|
2884
|
+
if (i !== $DELETED) u[e] = unwrapStoreValue(i, t, n);
|
|
2885
|
+
}
|
|
2886
|
+
if (s) u.length = r.length ?? o.length;
|
|
2887
|
+
return u;
|
|
2687
2888
|
}
|
|
2688
2889
|
function isPrototypePollutionKey$1(e) {
|
|
2689
2890
|
return e === "__proto__" || e === "constructor" || e === "prototype";
|
|
2690
2891
|
}
|
|
2691
|
-
function
|
|
2892
|
+
function ownEnumerableKeys(e) {
|
|
2893
|
+
return Reflect.ownKeys(e).filter(t => Object.prototype.propertyIsEnumerable.call(e, t));
|
|
2894
|
+
}
|
|
2895
|
+
function getOverlayLayer(e, t) {
|
|
2692
2896
|
const n = e[STORE_OPTIMISTIC_OVERRIDE];
|
|
2693
|
-
if (n &&
|
|
2897
|
+
if (n && t in n) return n;
|
|
2694
2898
|
const i = e[STORE_OVERRIDE];
|
|
2695
|
-
if (i &&
|
|
2899
|
+
if (i && t in i) return i;
|
|
2900
|
+
return undefined;
|
|
2901
|
+
}
|
|
2902
|
+
function visibleNodeValue(e) {
|
|
2903
|
+
return e.O !== undefined && e.O !== NOT_PENDING ? e.O : e.D !== NOT_PENDING ? e.D : e.Z;
|
|
2904
|
+
}
|
|
2905
|
+
function hasOwnStoreProperty(e, t) {
|
|
2906
|
+
const n = getOverlayLayer(e, t);
|
|
2907
|
+
if (n) return n[t] !== $DELETED;
|
|
2696
2908
|
return Object.prototype.hasOwnProperty.call(unwrapStoreValue(e[STORE_VALUE]), t);
|
|
2697
2909
|
}
|
|
2698
2910
|
function hasInheritedAccessor(e, t) {
|
|
@@ -2716,19 +2928,33 @@ function getNode(e, t, n, i, r = isEqual, o, s) {
|
|
|
2716
2928
|
{
|
|
2717
2929
|
equals: r,
|
|
2718
2930
|
unobserved() {
|
|
2719
|
-
if (e[t] === u)
|
|
2931
|
+
if (e[t] === u) {
|
|
2932
|
+
delete e[t];
|
|
2933
|
+
if (typeof t === "symbol" && t !== $TRACK && symbolKeyedRecords.has(e)) {
|
|
2934
|
+
const t = Object.getOwnPropertySymbols(e);
|
|
2935
|
+
let n = false;
|
|
2936
|
+
for (let e = 0, i = t.length; e < i; e++) {
|
|
2937
|
+
if (t[e] !== $TRACK) {
|
|
2938
|
+
n = true;
|
|
2939
|
+
break;
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
if (!n) symbolKeyedRecords.delete(e);
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2720
2945
|
}
|
|
2721
2946
|
},
|
|
2722
2947
|
i
|
|
2723
2948
|
);
|
|
2724
2949
|
if (o) {
|
|
2725
|
-
u.
|
|
2950
|
+
u.O = NOT_PENDING;
|
|
2726
2951
|
}
|
|
2727
2952
|
if (s && t in s) {
|
|
2728
2953
|
const e = s[t];
|
|
2729
|
-
u.
|
|
2954
|
+
u.Ee = e === undefined ? NO_SNAPSHOT : e;
|
|
2730
2955
|
snapshotSources?.add(u);
|
|
2731
2956
|
}
|
|
2957
|
+
if (typeof t === "symbol" && t !== $TRACK) symbolKeyedRecords.add(e);
|
|
2732
2958
|
return (e[t] = u);
|
|
2733
2959
|
}
|
|
2734
2960
|
function trackSelf(e, t = $TRACK) {
|
|
@@ -2737,8 +2963,16 @@ function trackSelf(e, t = $TRACK) {
|
|
|
2737
2963
|
getNode(getNodes(e, STORE_NODE), t, undefined, e[STORE_FIREWALL], false, e[STORE_OPTIMISTIC])
|
|
2738
2964
|
);
|
|
2739
2965
|
}
|
|
2966
|
+
function notifySelf(e) {
|
|
2967
|
+
const t = e[STORE_NODE]?.[$TRACK];
|
|
2968
|
+
t && setSignal(t, e[STORE_OPTIMISTIC] && !projectionWriteActive ? STORE_SELF_PENDING : undefined);
|
|
2969
|
+
}
|
|
2740
2970
|
function getKeys(e, t, n = true) {
|
|
2741
|
-
const i =
|
|
2971
|
+
const i = e[$TARGET]
|
|
2972
|
+
? untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e)))
|
|
2973
|
+
: n
|
|
2974
|
+
? Object.keys(e)
|
|
2975
|
+
: Reflect.ownKeys(e);
|
|
2742
2976
|
if (!t) return i;
|
|
2743
2977
|
const r = new Set(i);
|
|
2744
2978
|
const o = Reflect.ownKeys(t);
|
|
@@ -2752,15 +2986,31 @@ function getPropertyDescriptor(e, t, n) {
|
|
|
2752
2986
|
if (t && n in t) {
|
|
2753
2987
|
if (t[n] === $DELETED) return void 0;
|
|
2754
2988
|
const i = Reflect.getOwnPropertyDescriptor(t, n);
|
|
2755
|
-
if (i?.get || i?.set
|
|
2989
|
+
if (i?.get || i?.set) return i;
|
|
2990
|
+
const r = Reflect.getOwnPropertyDescriptor(e, n);
|
|
2991
|
+
if (!r) return i;
|
|
2992
|
+
if (r.get || r.set) return r;
|
|
2993
|
+
r.value = t[n];
|
|
2994
|
+
return r;
|
|
2756
2995
|
}
|
|
2757
2996
|
return Reflect.getOwnPropertyDescriptor(e, n);
|
|
2758
2997
|
}
|
|
2998
|
+
function maskStoreTarget(e, t) {
|
|
2999
|
+
const n = e[STORE_FIREWALL];
|
|
3000
|
+
if (!n) return;
|
|
3001
|
+
if (!!e[STORE_MASKED] === t) return;
|
|
3002
|
+
e[STORE_MASKED] = t;
|
|
3003
|
+
const i = (n.qe = (n.qe || 0) + (t ? 1 : -1));
|
|
3004
|
+
if ((t && i === 1) || (!t && i === 0)) {
|
|
3005
|
+
updatePendingSignal(n);
|
|
3006
|
+
updateChildCompanions(n);
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
2759
3009
|
function prepareStoreWrite(e, t, n) {
|
|
2760
3010
|
if (e[STORE_OPTIMISTIC]) {
|
|
2761
3011
|
const t = e[STORE_FIREWALL];
|
|
2762
|
-
if (t?.
|
|
2763
|
-
globalQueue.initTransition(t.
|
|
3012
|
+
if (t?.T) {
|
|
3013
|
+
globalQueue.initTransition(t.T);
|
|
2764
3014
|
}
|
|
2765
3015
|
}
|
|
2766
3016
|
const i = e[STORE_VALUE];
|
|
@@ -2768,7 +3018,7 @@ function prepareStoreWrite(e, t, n) {
|
|
|
2768
3018
|
if (
|
|
2769
3019
|
snapshotCaptureActive &&
|
|
2770
3020
|
typeof n !== "symbol" &&
|
|
2771
|
-
!((e[STORE_FIREWALL]?.
|
|
3021
|
+
!((e[STORE_FIREWALL]?.Y ?? 0) & STATUS_PENDING)
|
|
2772
3022
|
) {
|
|
2773
3023
|
if (!e[STORE_SNAPSHOT_PROPS]) {
|
|
2774
3024
|
e[STORE_SNAPSHOT_PROPS] = Object.create(null);
|
|
@@ -2780,9 +3030,14 @@ function prepareStoreWrite(e, t, n) {
|
|
|
2780
3030
|
}
|
|
2781
3031
|
const o = e[STORE_OPTIMISTIC] && !projectionWriteActive;
|
|
2782
3032
|
const s = o ? STORE_OPTIMISTIC_OVERRIDE : STORE_OVERRIDE;
|
|
2783
|
-
if (o) trackOptimisticStore(t);
|
|
2784
3033
|
return { base: r, overrideKey: s, state: i };
|
|
2785
3034
|
}
|
|
3035
|
+
function armOptimisticStoreWrite(e, t) {
|
|
3036
|
+
if (e[STORE_OPTIMISTIC] && !projectionWriteActive) {
|
|
3037
|
+
trackOptimisticStore(t);
|
|
3038
|
+
maskStoreTarget(e, true);
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
2786
3041
|
function upsertStoreNode(e, t, n, i, r) {
|
|
2787
3042
|
if (t[n]) return t[n];
|
|
2788
3043
|
const o = isWrappable(i) ? wrap(i, e) : i;
|
|
@@ -2821,7 +3076,7 @@ function notifyStoreProperty(e, t, n, i, r, o) {
|
|
|
2821
3076
|
setSignal(n, undefined);
|
|
2822
3077
|
}
|
|
2823
3078
|
}
|
|
2824
|
-
|
|
3079
|
+
notifySelf(e);
|
|
2825
3080
|
}
|
|
2826
3081
|
let Writing = null;
|
|
2827
3082
|
const storeTraps = {
|
|
@@ -2833,73 +3088,64 @@ const storeTraps = {
|
|
|
2833
3088
|
trackSelf(e);
|
|
2834
3089
|
return n;
|
|
2835
3090
|
}
|
|
2836
|
-
const i =
|
|
2837
|
-
const r =
|
|
2838
|
-
const o =
|
|
3091
|
+
const i = getObserver() === e[STORE_FIREWALL];
|
|
3092
|
+
const r = getNodes(e, STORE_NODE);
|
|
3093
|
+
const o = i ? undefined : r[t];
|
|
3094
|
+
const s = e[STORE_VALUE];
|
|
2839
3095
|
if (
|
|
2840
|
-
!
|
|
3096
|
+
!o &&
|
|
2841
3097
|
!e[STORE_OVERRIDE] &&
|
|
2842
3098
|
!e[STORE_OPTIMISTIC_OVERRIDE] &&
|
|
2843
3099
|
!e[STORE_CUSTOM_PROTO] &&
|
|
2844
3100
|
!e[STORE_OPTIMISTIC] &&
|
|
2845
3101
|
!e[STORE_SNAPSHOT_PROPS] &&
|
|
2846
|
-
!
|
|
2847
|
-
!(t in
|
|
3102
|
+
!s[$TARGET] &&
|
|
3103
|
+
!(t in s) &&
|
|
2848
3104
|
getObserver() &&
|
|
3105
|
+
!i &&
|
|
2849
3106
|
!writeOnly(n)
|
|
2850
3107
|
) {
|
|
2851
|
-
return read(getNode(
|
|
2852
|
-
}
|
|
2853
|
-
const
|
|
2854
|
-
const
|
|
2855
|
-
const
|
|
2856
|
-
const
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
? e[STORE_OVERRIDE]
|
|
2860
|
-
: e[STORE_VALUE];
|
|
2861
|
-
if (!r) {
|
|
2862
|
-
const i = Object.getOwnPropertyDescriptor(l, t);
|
|
3108
|
+
return read(getNode(r, t, undefined, e[STORE_FIREWALL]));
|
|
3109
|
+
}
|
|
3110
|
+
const u = getOverlayLayer(e, t);
|
|
3111
|
+
const c = !!u;
|
|
3112
|
+
const l = !!e[STORE_VALUE][$TARGET];
|
|
3113
|
+
const a = u ?? e[STORE_VALUE];
|
|
3114
|
+
if (!o) {
|
|
3115
|
+
const i = Object.getOwnPropertyDescriptor(a, t);
|
|
2863
3116
|
if (i && i.get) return i.get.call(n);
|
|
2864
|
-
if (!i && !
|
|
2865
|
-
const e = unwrapStoreValue(
|
|
3117
|
+
if (!i && !c && e[STORE_CUSTOM_PROTO]) {
|
|
3118
|
+
const e = unwrapStoreValue(a);
|
|
2866
3119
|
if (hasInheritedAccessor(e, t)) {
|
|
2867
|
-
return Reflect.get(
|
|
3120
|
+
return Reflect.get(a, t, n);
|
|
2868
3121
|
}
|
|
2869
3122
|
}
|
|
2870
3123
|
}
|
|
2871
3124
|
if (writeOnly(n)) {
|
|
2872
3125
|
if (isPrototypePollutionKey$1(t) && !hasOwnStoreProperty(e, t)) return undefined;
|
|
2873
|
-
let n =
|
|
2874
|
-
r && (u || !c)
|
|
2875
|
-
? r.K !== undefined && r.K !== NOT_PENDING
|
|
2876
|
-
? r.K
|
|
2877
|
-
: r.B !== NOT_PENDING
|
|
2878
|
-
? r.B
|
|
2879
|
-
: r.ue
|
|
2880
|
-
: l[t];
|
|
3126
|
+
let n = o && (c || !l) ? visibleNodeValue(o) : a[t];
|
|
2881
3127
|
n === $DELETED && (n = undefined);
|
|
2882
3128
|
if (!isWrappable(n)) return n;
|
|
2883
3129
|
const i = wrap(n, e);
|
|
2884
3130
|
Writing?.add(i);
|
|
2885
3131
|
return i;
|
|
2886
3132
|
}
|
|
2887
|
-
let
|
|
2888
|
-
|
|
2889
|
-
if (!
|
|
2890
|
-
if (!
|
|
3133
|
+
let f = o ? (c || !l ? read(r[t]) : (read(r[t]), a[t])) : a[t];
|
|
3134
|
+
f === $DELETED && (f = undefined);
|
|
3135
|
+
if (!o) {
|
|
3136
|
+
if (!c && typeof f === "function" && !Object.prototype.hasOwnProperty.call(a, t)) {
|
|
2891
3137
|
let t;
|
|
2892
3138
|
return !Array.isArray(e[STORE_VALUE]) &&
|
|
2893
3139
|
(t = Object.getPrototypeOf(e[STORE_VALUE])) &&
|
|
2894
3140
|
t !== Object.prototype
|
|
2895
|
-
?
|
|
2896
|
-
:
|
|
2897
|
-
} else if (getObserver()) {
|
|
3141
|
+
? f.bind(a)
|
|
3142
|
+
: f;
|
|
3143
|
+
} else if (getObserver() && !i) {
|
|
2898
3144
|
return read(
|
|
2899
3145
|
getNode(
|
|
2900
|
-
|
|
3146
|
+
r,
|
|
2901
3147
|
t,
|
|
2902
|
-
isWrappable(
|
|
3148
|
+
isWrappable(f) ? wrap(f, e) : f,
|
|
2903
3149
|
e[STORE_FIREWALL],
|
|
2904
3150
|
isEqual,
|
|
2905
3151
|
e[STORE_OPTIMISTIC],
|
|
@@ -2908,23 +3154,19 @@ const storeTraps = {
|
|
|
2908
3154
|
);
|
|
2909
3155
|
}
|
|
2910
3156
|
}
|
|
2911
|
-
return isWrappable(
|
|
3157
|
+
return isWrappable(f) ? wrap(f, e) : f;
|
|
2912
3158
|
},
|
|
2913
3159
|
has(e, t) {
|
|
2914
3160
|
if (t === $PROXY || t === $TRACK || t === "__proto__") return true;
|
|
2915
|
-
const n =
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
: t in e[STORE_VALUE];
|
|
2921
|
-
if (writeOnly(e[$PROXY])) return n;
|
|
2922
|
-
const i = getNodes(e, STORE_HAS);
|
|
2923
|
-
if (i[t]) return read(i[t]);
|
|
3161
|
+
const n = getOverlayLayer(e, t);
|
|
3162
|
+
const i = n ? n[t] !== $DELETED : t in e[STORE_VALUE];
|
|
3163
|
+
if (writeOnly(e[$PROXY]) || getObserver() === e[STORE_FIREWALL]) return i;
|
|
3164
|
+
const r = getNodes(e, STORE_HAS);
|
|
3165
|
+
if (r[t]) return read(r[t]);
|
|
2924
3166
|
if (getObserver()) {
|
|
2925
|
-
return read(getNode(
|
|
3167
|
+
return read(getNode(r, t, i, e[STORE_FIREWALL], isEqual, e[STORE_OPTIMISTIC]));
|
|
2926
3168
|
}
|
|
2927
|
-
return
|
|
3169
|
+
return i;
|
|
2928
3170
|
},
|
|
2929
3171
|
set(e, t, n) {
|
|
2930
3172
|
if (t === "__proto__") return true;
|
|
@@ -2932,43 +3174,45 @@ const storeTraps = {
|
|
|
2932
3174
|
if (writeOnly(i)) {
|
|
2933
3175
|
untrack(() => {
|
|
2934
3176
|
const { base: r, overrideKey: o, state: s } = prepareStoreWrite(e, i, t);
|
|
2935
|
-
const u =
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
const
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
: t in e[STORE_VALUE];
|
|
2947
|
-
const l = unwrapStoreValue(n);
|
|
2948
|
-
const a = Array.isArray(s) && t !== "length";
|
|
2949
|
-
const f = a ? parseInt(t) + 1 : 0;
|
|
2950
|
-
const E =
|
|
2951
|
-
a &&
|
|
2952
|
-
(e[STORE_OPTIMISTIC_OVERRIDE] && "length" in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
2953
|
-
? e[STORE_OPTIMISTIC_OVERRIDE].length
|
|
2954
|
-
: e[STORE_OVERRIDE] && "length" in e[STORE_OVERRIDE]
|
|
2955
|
-
? e[STORE_OVERRIDE].length
|
|
2956
|
-
: s.length);
|
|
2957
|
-
const S = a && f > E ? f : undefined;
|
|
2958
|
-
if (u === l && S === undefined) return true;
|
|
2959
|
-
if (l !== undefined && l === r && S === undefined) delete e[o]?.[t];
|
|
3177
|
+
const u = getOverlayLayer(e, t);
|
|
3178
|
+
const c = u ? u[t] : r;
|
|
3179
|
+
const l = u ? u[t] !== $DELETED : t in e[STORE_VALUE];
|
|
3180
|
+
const a = unwrapStoreValue(n);
|
|
3181
|
+
const f = Array.isArray(s) && t !== "length" && typeof t !== "symbol";
|
|
3182
|
+
const E = f ? parseInt(t) + 1 : 0;
|
|
3183
|
+
const d = f && (getOverlayLayer(e, "length") ?? s).length;
|
|
3184
|
+
const S = f && E > d ? E : undefined;
|
|
3185
|
+
if (c === a && S === undefined) return true;
|
|
3186
|
+
armOptimisticStoreWrite(e, i);
|
|
3187
|
+
if (a !== undefined && a === r && S === undefined) delete e[o]?.[t];
|
|
2960
3188
|
else {
|
|
2961
3189
|
const n = e[o] || (e[o] = Object.create(null));
|
|
2962
|
-
n[t] =
|
|
3190
|
+
n[t] = a;
|
|
2963
3191
|
if (S !== undefined) n.length = S;
|
|
2964
3192
|
}
|
|
2965
|
-
notifyStoreProperty(e, t, "set",
|
|
3193
|
+
notifyStoreProperty(e, t, "set", a, c, l);
|
|
3194
|
+
if (
|
|
3195
|
+
Array.isArray(s) &&
|
|
3196
|
+
t === "length" &&
|
|
3197
|
+
typeof a === "number" &&
|
|
3198
|
+
typeof c === "number" &&
|
|
3199
|
+
a < c
|
|
3200
|
+
) {
|
|
3201
|
+
const t = e[o] || (e[o] = Object.create(null));
|
|
3202
|
+
for (let n = a; n < c; n++) {
|
|
3203
|
+
if (t[n] === $DELETED) continue;
|
|
3204
|
+
const i = n in t ? t[n] : s[n];
|
|
3205
|
+
if (!(n in t) && !(n in s)) continue;
|
|
3206
|
+
t[n] = $DELETED;
|
|
3207
|
+
notifyStoreProperty(e, n, "delete", undefined, i, true);
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
2966
3210
|
if (Array.isArray(s) && t !== "length" && S !== undefined) {
|
|
2967
3211
|
const t = getNodes(e, STORE_NODE);
|
|
2968
3212
|
if (t.length) {
|
|
2969
3213
|
setSignal(t.length, S);
|
|
2970
3214
|
} else if (!projectionWriteActive && !e[STORE_OPTIMISTIC]) {
|
|
2971
|
-
const n = upsertStoreNode(e, t, "length",
|
|
3215
|
+
const n = upsertStoreNode(e, t, "length", d, e[STORE_SNAPSHOT_PROPS]);
|
|
2972
3216
|
setSignal(n, S);
|
|
2973
3217
|
}
|
|
2974
3218
|
}
|
|
@@ -2983,6 +3227,7 @@ const storeTraps = {
|
|
|
2983
3227
|
if (writeOnly(i)) {
|
|
2984
3228
|
untrack(() => {
|
|
2985
3229
|
const { base: r, overrideKey: o } = prepareStoreWrite(e, i, t);
|
|
3230
|
+
armOptimisticStoreWrite(e, i);
|
|
2986
3231
|
const s = "value" in n ? { ...n, value: unwrapStoreValue(n.value) } : n;
|
|
2987
3232
|
Object.defineProperty(e[o] || (e[o] = Object.create(null)), t, s);
|
|
2988
3233
|
notifyStoreProperty(e, t, "invalidate");
|
|
@@ -2999,25 +3244,22 @@ const storeTraps = {
|
|
|
2999
3244
|
untrack(() => {
|
|
3000
3245
|
const n = e[STORE_OPTIMISTIC] && !projectionWriteActive;
|
|
3001
3246
|
const i = n ? STORE_OPTIMISTIC_OVERRIDE : STORE_OVERRIDE;
|
|
3002
|
-
|
|
3003
|
-
const r
|
|
3004
|
-
e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
3005
|
-
? e[STORE_OPTIMISTIC_OVERRIDE][t]
|
|
3006
|
-
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
3007
|
-
? e[STORE_OVERRIDE][t]
|
|
3008
|
-
: e[STORE_VALUE][t];
|
|
3247
|
+
const r = getOverlayLayer(e, t);
|
|
3248
|
+
const o = r ? r[t] : e[STORE_VALUE][t];
|
|
3009
3249
|
if (t in e[STORE_VALUE] || (e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE])) {
|
|
3250
|
+
armOptimisticStoreWrite(e, e[$PROXY]);
|
|
3010
3251
|
(e[i] || (e[i] = Object.create(null)))[t] = $DELETED;
|
|
3011
3252
|
} else if (e[i] && t in e[i]) {
|
|
3253
|
+
armOptimisticStoreWrite(e, e[$PROXY]);
|
|
3012
3254
|
delete e[i][t];
|
|
3013
3255
|
} else return true;
|
|
3014
|
-
notifyStoreProperty(e, t, "delete", undefined,
|
|
3256
|
+
notifyStoreProperty(e, t, "delete", undefined, o, true);
|
|
3015
3257
|
});
|
|
3016
3258
|
}
|
|
3017
3259
|
return true;
|
|
3018
3260
|
},
|
|
3019
3261
|
ownKeys(e) {
|
|
3020
|
-
trackSelf(e);
|
|
3262
|
+
if (getObserver() !== e[STORE_FIREWALL]) trackSelf(e);
|
|
3021
3263
|
let t = getKeys(e[STORE_VALUE], e[STORE_OVERRIDE], false);
|
|
3022
3264
|
if (e[STORE_OPTIMISTIC_OVERRIDE]) {
|
|
3023
3265
|
const n = new Set(t);
|
|
@@ -3037,7 +3279,9 @@ const storeTraps = {
|
|
|
3037
3279
|
if (n?.get || n?.set || !(t in e[STORE_VALUE])) return n;
|
|
3038
3280
|
const i = getPropertyDescriptor(e[STORE_VALUE], e[STORE_OVERRIDE], t);
|
|
3039
3281
|
if (i) {
|
|
3040
|
-
|
|
3282
|
+
const n = Reflect.getOwnPropertyDescriptor(e, t);
|
|
3283
|
+
const r = !n || n.configurable ? true : i.configurable;
|
|
3284
|
+
return { ...i, configurable: r, value: e[STORE_OPTIMISTIC_OVERRIDE][t] };
|
|
3041
3285
|
}
|
|
3042
3286
|
return {
|
|
3043
3287
|
value: e[STORE_OPTIMISTIC_OVERRIDE][t],
|
|
@@ -3046,7 +3290,12 @@ const storeTraps = {
|
|
|
3046
3290
|
configurable: true
|
|
3047
3291
|
};
|
|
3048
3292
|
}
|
|
3049
|
-
|
|
3293
|
+
const n = getPropertyDescriptor(e[STORE_VALUE], e[STORE_OVERRIDE], t);
|
|
3294
|
+
if (n && !n.configurable) {
|
|
3295
|
+
const i = Reflect.getOwnPropertyDescriptor(e, t);
|
|
3296
|
+
if (!i || i.configurable) return { ...n, configurable: true };
|
|
3297
|
+
}
|
|
3298
|
+
return n;
|
|
3050
3299
|
},
|
|
3051
3300
|
getPrototypeOf(e) {
|
|
3052
3301
|
return Object.getPrototypeOf(e[STORE_VALUE]);
|
|
@@ -3063,7 +3312,7 @@ function storeSetter(e, t) {
|
|
|
3063
3312
|
for (let t = 0, i = n.length; t < i; t++) e[t] = n[t];
|
|
3064
3313
|
e.length = n.length;
|
|
3065
3314
|
} else {
|
|
3066
|
-
const t = new Set([...
|
|
3315
|
+
const t = new Set([...ownEnumerableKeys(e), ...ownEnumerableKeys(n)]);
|
|
3067
3316
|
t.forEach(t => {
|
|
3068
3317
|
if (t in n) e[t] = n[t];
|
|
3069
3318
|
else delete e[t];
|
|
@@ -3080,11 +3329,16 @@ function createStore(e, t, n) {
|
|
|
3080
3329
|
r = i ? createProjectionInternal(e, t, n).store : wrap(e);
|
|
3081
3330
|
return [
|
|
3082
3331
|
r,
|
|
3083
|
-
i
|
|
3332
|
+
i
|
|
3333
|
+
? e => {
|
|
3334
|
+
suppressComputedRecompute(r[$REFRESH]);
|
|
3335
|
+
storeSetter(r, e);
|
|
3336
|
+
}
|
|
3337
|
+
: e => storeSetter(r, e)
|
|
3084
3338
|
];
|
|
3085
3339
|
}
|
|
3086
3340
|
function createOptimisticStore(e, t, n) {
|
|
3087
|
-
GlobalQueue.
|
|
3341
|
+
GlobalQueue.se ||= clearOptimisticStore;
|
|
3088
3342
|
const i = typeof e === "function";
|
|
3089
3343
|
const r = i ? t : e;
|
|
3090
3344
|
const o = i ? e : undefined;
|
|
@@ -3093,30 +3347,47 @@ function createOptimisticStore(e, t, n) {
|
|
|
3093
3347
|
}
|
|
3094
3348
|
function clearOptimisticStore(e) {
|
|
3095
3349
|
const t = e[$TARGET];
|
|
3096
|
-
if (!t
|
|
3097
|
-
|
|
3098
|
-
|
|
3350
|
+
if (!t) return;
|
|
3351
|
+
maskStoreTarget(t, false);
|
|
3352
|
+
if (!t[STORE_OPTIMISTIC_OVERRIDE]) return;
|
|
3353
|
+
clearOptimisticOverride(t);
|
|
3354
|
+
}
|
|
3355
|
+
function clearOptimisticOverride(e) {
|
|
3356
|
+
const t = e[STORE_OPTIMISTIC_OVERRIDE];
|
|
3357
|
+
if (!t) return;
|
|
3358
|
+
maskStoreTarget(e, false);
|
|
3359
|
+
const n = e[STORE_NODE];
|
|
3360
|
+
delete e[STORE_OPTIMISTIC_OVERRIDE];
|
|
3361
|
+
const i = projectionWriteActive;
|
|
3099
3362
|
setProjectionWriteActive(true);
|
|
3100
3363
|
try {
|
|
3101
|
-
if (
|
|
3102
|
-
for (const
|
|
3103
|
-
if (i
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
const
|
|
3108
|
-
|
|
3364
|
+
if (n) {
|
|
3365
|
+
for (const i of Reflect.ownKeys(t)) {
|
|
3366
|
+
if (n[i]) {
|
|
3367
|
+
const t = n[i];
|
|
3368
|
+
t.i = undefined;
|
|
3369
|
+
const r = getOverlayLayer(e, i);
|
|
3370
|
+
const o = r ? r[i] : e[STORE_VALUE][i];
|
|
3371
|
+
const s = o === $DELETED ? undefined : o;
|
|
3372
|
+
const u = isWrappable(s) ? wrap(s, e) : s;
|
|
3373
|
+
const c = visibleNodeValue(t);
|
|
3374
|
+
t.O = NOT_PENDING;
|
|
3375
|
+
t.D = NOT_PENDING;
|
|
3376
|
+
t.Z = u;
|
|
3377
|
+
if (!t.xe || !t.xe(c, u)) {
|
|
3378
|
+
insertSubs(t, true);
|
|
3379
|
+
schedule();
|
|
3380
|
+
}
|
|
3109
3381
|
}
|
|
3110
3382
|
}
|
|
3111
|
-
if (
|
|
3112
|
-
|
|
3113
|
-
|
|
3383
|
+
if (n[$TRACK]) {
|
|
3384
|
+
n[$TRACK].i = undefined;
|
|
3385
|
+
notifySelf(e);
|
|
3114
3386
|
}
|
|
3115
3387
|
}
|
|
3116
3388
|
} finally {
|
|
3117
|
-
setProjectionWriteActive(
|
|
3389
|
+
setProjectionWriteActive(i);
|
|
3118
3390
|
}
|
|
3119
|
-
delete t[STORE_OPTIMISTIC_OVERRIDE];
|
|
3120
3391
|
}
|
|
3121
3392
|
function createOptimisticProjectionInternal(e, t, n) {
|
|
3122
3393
|
let i;
|
|
@@ -3141,23 +3412,29 @@ function createOptimisticProjectionInternal(e, t, n) {
|
|
|
3141
3412
|
};
|
|
3142
3413
|
const o = wrapProjection(t);
|
|
3143
3414
|
if (e) {
|
|
3415
|
+
const clearProjectionOverride = () => {
|
|
3416
|
+
const e = o[$TARGET];
|
|
3417
|
+
if (e?.[STORE_OPTIMISTIC_OVERRIDE]) clearOptimisticOverride(e);
|
|
3418
|
+
};
|
|
3144
3419
|
const wrapCommit = e => {
|
|
3420
|
+
const t = projectionWriteActive;
|
|
3145
3421
|
setProjectionWriteActive(true);
|
|
3146
3422
|
try {
|
|
3147
3423
|
e();
|
|
3424
|
+
clearProjectionOverride();
|
|
3148
3425
|
} finally {
|
|
3149
|
-
setProjectionWriteActive(
|
|
3426
|
+
setProjectionWriteActive(t);
|
|
3150
3427
|
}
|
|
3151
3428
|
};
|
|
3152
3429
|
i = computed(() => {
|
|
3153
3430
|
setProjectionWriteActive(true);
|
|
3154
3431
|
try {
|
|
3155
|
-
runProjectionComputed(o, e, n?.key || "id", wrapCommit);
|
|
3432
|
+
runProjectionComputed(o, e, n?.key || "id", wrapCommit, clearProjectionOverride);
|
|
3156
3433
|
} finally {
|
|
3157
3434
|
setProjectionWriteActive(false);
|
|
3158
3435
|
}
|
|
3159
3436
|
}, undefined);
|
|
3160
|
-
i.
|
|
3437
|
+
i.le &= ~CONFIG_AUTO_DISPOSE;
|
|
3161
3438
|
}
|
|
3162
3439
|
return { store: o, node: i };
|
|
3163
3440
|
}
|
|
@@ -3213,10 +3490,10 @@ function updatePath(e, t, n = 0) {
|
|
|
3213
3490
|
delete e[i];
|
|
3214
3491
|
} else if (i === undefined || (isWrappable(r) && isWrappable(o) && !Array.isArray(o))) {
|
|
3215
3492
|
const t = i !== undefined ? e[i] : e;
|
|
3216
|
-
const n =
|
|
3493
|
+
const n = ownEnumerableKeys(o);
|
|
3217
3494
|
for (let e = 0; e < n.length; e++) {
|
|
3218
3495
|
const i = n[e];
|
|
3219
|
-
if (isPrototypePollutionKey(i)) continue;
|
|
3496
|
+
if (typeof i === "string" && isPrototypePollutionKey(i)) continue;
|
|
3220
3497
|
const r = Object.getOwnPropertyDescriptor(o, i);
|
|
3221
3498
|
if (r.get || r.set) Object.defineProperty(t, i, r);
|
|
3222
3499
|
else t[i] = r.value;
|
|
@@ -3233,6 +3510,11 @@ const storePath = Object.assign(
|
|
|
3233
3510
|
},
|
|
3234
3511
|
{ DELETE: DELETE }
|
|
3235
3512
|
);
|
|
3513
|
+
function mergedOverlay(e) {
|
|
3514
|
+
const t = e[STORE_OVERRIDE];
|
|
3515
|
+
const n = e[STORE_OPTIMISTIC_OVERRIDE];
|
|
3516
|
+
return t && n ? { ...t, ...n } : (n ?? t);
|
|
3517
|
+
}
|
|
3236
3518
|
function snapshotImpl(e, t, n, i) {
|
|
3237
3519
|
let r, o, s, u, c, l;
|
|
3238
3520
|
if (!isWrappable(e)) return e;
|
|
@@ -3240,20 +3522,20 @@ function snapshotImpl(e, t, n, i) {
|
|
|
3240
3522
|
if (!n) n = new Map();
|
|
3241
3523
|
if ((r = e[$TARGET] || i?.get(e)?.[$TARGET])) {
|
|
3242
3524
|
if (t) trackSelf(r, $TRACK);
|
|
3243
|
-
s = r
|
|
3525
|
+
s = mergedOverlay(r);
|
|
3244
3526
|
o = Array.isArray(r[STORE_VALUE]);
|
|
3245
3527
|
n.set(
|
|
3246
3528
|
e,
|
|
3247
3529
|
s ? (u = o ? [] : Object.create(Object.getPrototypeOf(r[STORE_VALUE]))) : r[STORE_VALUE]
|
|
3248
3530
|
);
|
|
3249
3531
|
e = r[STORE_VALUE];
|
|
3250
|
-
i = storeLookup;
|
|
3532
|
+
i = r[STORE_LOOKUP] ?? storeLookup;
|
|
3251
3533
|
} else {
|
|
3252
3534
|
o = Array.isArray(e);
|
|
3253
3535
|
n.set(e, e);
|
|
3254
3536
|
}
|
|
3255
3537
|
if (o) {
|
|
3256
|
-
const o = s?.length
|
|
3538
|
+
const o = s?.length ?? e.length;
|
|
3257
3539
|
for (let a = 0; a < o; a++) {
|
|
3258
3540
|
l = s && a in s ? s[a] : e[a];
|
|
3259
3541
|
if (l === $DELETED) continue;
|
|
@@ -3263,13 +3545,30 @@ function snapshotImpl(e, t, n, i) {
|
|
|
3263
3545
|
u[a] = c;
|
|
3264
3546
|
}
|
|
3265
3547
|
}
|
|
3548
|
+
if (u) u.length = o;
|
|
3549
|
+
} else if (!s) {
|
|
3550
|
+
const o = getKeys(e, undefined);
|
|
3551
|
+
for (let s = 0, a = o.length; s < a; s++) {
|
|
3552
|
+
const a = o[s];
|
|
3553
|
+
const f = Object.getOwnPropertyDescriptor(e, a);
|
|
3554
|
+
if (f.get) continue;
|
|
3555
|
+
l = f.value;
|
|
3556
|
+
if (t && isWrappable(l)) wrap(l, r);
|
|
3557
|
+
if ((c = snapshotImpl(l, t, n, i)) !== l || u) {
|
|
3558
|
+
if (!u) {
|
|
3559
|
+
u = Object.create(Object.getPrototypeOf(e));
|
|
3560
|
+
Object.assign(u, e);
|
|
3561
|
+
}
|
|
3562
|
+
u[a] = c;
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3266
3565
|
} else {
|
|
3267
3566
|
const o = getKeys(e, s);
|
|
3268
3567
|
for (let a = 0, f = o.length; a < f; a++) {
|
|
3269
3568
|
let f = o[a];
|
|
3270
3569
|
const E = getPropertyDescriptor(e, s, f);
|
|
3271
3570
|
if (E.get) continue;
|
|
3272
|
-
l =
|
|
3571
|
+
l = f in s ? s[f] : e[f];
|
|
3273
3572
|
if (t && isWrappable(l)) wrap(l, r);
|
|
3274
3573
|
if ((c = snapshotImpl(l, t, n, i)) !== e[f] || u) {
|
|
3275
3574
|
if (!u) {
|
|
@@ -3352,7 +3651,7 @@ function merge(...e) {
|
|
|
3352
3651
|
keys() {
|
|
3353
3652
|
const e = new Set();
|
|
3354
3653
|
for (let t = 0; t < n.length; t++) {
|
|
3355
|
-
const i =
|
|
3654
|
+
const i = ownEnumerableKeys(resolveSource(n[t]));
|
|
3356
3655
|
for (let t = 0; t < i.length; t++) e.add(i[t]);
|
|
3357
3656
|
}
|
|
3358
3657
|
return [...e];
|
|
@@ -3404,7 +3703,7 @@ function omit(e, ...t) {
|
|
|
3404
3703
|
return !t.includes(n) && n in e;
|
|
3405
3704
|
},
|
|
3406
3705
|
keys() {
|
|
3407
|
-
return
|
|
3706
|
+
return ownEnumerableKeys(e).filter(e => !t.includes(e));
|
|
3408
3707
|
}
|
|
3409
3708
|
},
|
|
3410
3709
|
propTraps
|
|
@@ -3428,74 +3727,74 @@ function mapArray(e, t, n) {
|
|
|
3428
3727
|
const r = t.length > 1;
|
|
3429
3728
|
const o = t;
|
|
3430
3729
|
const s = {
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
ze: [],
|
|
3435
|
-
Xe: o,
|
|
3436
|
-
Je: [],
|
|
3730
|
+
ze: createOwner(),
|
|
3731
|
+
Xe: 0,
|
|
3732
|
+
Je: e,
|
|
3437
3733
|
et: [],
|
|
3438
|
-
tt:
|
|
3439
|
-
nt:
|
|
3440
|
-
it:
|
|
3441
|
-
rt:
|
|
3442
|
-
ot: n?.
|
|
3734
|
+
tt: o,
|
|
3735
|
+
nt: [],
|
|
3736
|
+
it: [],
|
|
3737
|
+
rt: i,
|
|
3738
|
+
ot: i || n?.keyed === false ? [] : undefined,
|
|
3739
|
+
st: r && n?.keyed !== false ? [] : undefined,
|
|
3740
|
+
ut: n?.keyed === false,
|
|
3741
|
+
ct: n?.fallback
|
|
3443
3742
|
};
|
|
3444
3743
|
const u = computed(updateKeyedMap.bind(s));
|
|
3445
|
-
s.
|
|
3446
|
-
u.
|
|
3744
|
+
s.ze.Ae = u;
|
|
3745
|
+
u.le &= ~CONFIG_AUTO_DISPOSE;
|
|
3447
3746
|
return accessor(u);
|
|
3448
3747
|
}
|
|
3449
3748
|
const pureOptions = { ownedWrite: true };
|
|
3450
3749
|
function updateKeyedMap() {
|
|
3451
|
-
const e = this.
|
|
3750
|
+
const e = this.Je() || [],
|
|
3452
3751
|
t = e.length;
|
|
3453
3752
|
e[$TRACK];
|
|
3454
|
-
runWithOwner(this.
|
|
3753
|
+
runWithOwner(this.ze, () => {
|
|
3455
3754
|
let n,
|
|
3456
3755
|
i,
|
|
3457
|
-
r = this.
|
|
3458
|
-
? this.
|
|
3756
|
+
r = this.ot
|
|
3757
|
+
? this.ut
|
|
3459
3758
|
? () => {
|
|
3460
|
-
this.
|
|
3461
|
-
return this.
|
|
3759
|
+
this.ot[i] = signal(e[i], pureOptions);
|
|
3760
|
+
return this.tt(accessor(this.ot[i]), i);
|
|
3462
3761
|
}
|
|
3463
3762
|
: () => {
|
|
3464
|
-
this.
|
|
3465
|
-
this.
|
|
3466
|
-
return this.
|
|
3763
|
+
this.ot[i] = signal(e[i], pureOptions);
|
|
3764
|
+
this.st && (this.st[i] = signal(i, pureOptions));
|
|
3765
|
+
return this.tt(accessor(this.ot[i]), this.st ? accessor(this.st[i]) : undefined);
|
|
3467
3766
|
}
|
|
3468
|
-
: this.
|
|
3767
|
+
: this.st
|
|
3469
3768
|
? () => {
|
|
3470
3769
|
const t = e[i];
|
|
3471
|
-
this.
|
|
3472
|
-
return this.
|
|
3770
|
+
this.st[i] = signal(i, pureOptions);
|
|
3771
|
+
return this.tt(t, accessor(this.st[i]));
|
|
3473
3772
|
}
|
|
3474
3773
|
: () => {
|
|
3475
3774
|
const t = e[i];
|
|
3476
|
-
return this.
|
|
3775
|
+
return this.tt(t);
|
|
3477
3776
|
};
|
|
3478
3777
|
if (t === 0) {
|
|
3479
|
-
if (this.
|
|
3480
|
-
this.
|
|
3778
|
+
if (this.Xe !== 0) {
|
|
3779
|
+
this.ze.dispose(false);
|
|
3780
|
+
this.it = [];
|
|
3481
3781
|
this.et = [];
|
|
3482
|
-
this.
|
|
3483
|
-
this.
|
|
3484
|
-
this.
|
|
3485
|
-
this.
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
this.Je = new Array(t);
|
|
3782
|
+
this.nt = [];
|
|
3783
|
+
this.Xe = 0;
|
|
3784
|
+
this.ot && (this.ot = []);
|
|
3785
|
+
this.st && (this.st = []);
|
|
3786
|
+
}
|
|
3787
|
+
if (this.ct && !this.nt[0]) {
|
|
3788
|
+
this.nt[0] = runWithOwner((this.it[0] = createOwner()), this.ct);
|
|
3789
|
+
}
|
|
3790
|
+
} else if (this.Xe === 0) {
|
|
3791
|
+
if (this.it[0]) this.it[0].dispose();
|
|
3792
|
+
this.nt = new Array(t);
|
|
3494
3793
|
for (i = 0; i < t; i++) {
|
|
3495
|
-
this.
|
|
3496
|
-
this.
|
|
3794
|
+
this.et[i] = e[i];
|
|
3795
|
+
this.nt[i] = runWithOwner((this.it[i] = createOwner()), r);
|
|
3497
3796
|
}
|
|
3498
|
-
this.
|
|
3797
|
+
this.Xe = t;
|
|
3499
3798
|
} else {
|
|
3500
3799
|
let o,
|
|
3501
3800
|
s,
|
|
@@ -3505,157 +3804,173 @@ function updateKeyedMap() {
|
|
|
3505
3804
|
a,
|
|
3506
3805
|
f,
|
|
3507
3806
|
E = new Array(t),
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3807
|
+
d = new Array(t),
|
|
3808
|
+
S = this.ot ? new Array(t) : undefined,
|
|
3809
|
+
T = this.st ? new Array(t) : undefined;
|
|
3511
3810
|
for (
|
|
3512
|
-
o = 0, s = Math.min(this.
|
|
3513
|
-
o < s && (this.
|
|
3811
|
+
o = 0, s = Math.min(this.Xe, t);
|
|
3812
|
+
o < s && (this.et[o] === e[o] || (this.ot && compare(this.rt, this.et[o], e[o])));
|
|
3514
3813
|
o++
|
|
3515
3814
|
) {
|
|
3516
|
-
if (this.
|
|
3815
|
+
if (this.ot) setSignal(this.ot[o], e[o]);
|
|
3517
3816
|
}
|
|
3518
3817
|
for (
|
|
3519
|
-
s = this.
|
|
3818
|
+
s = this.Xe - 1, u = t - 1;
|
|
3520
3819
|
s >= o &&
|
|
3521
3820
|
u >= o &&
|
|
3522
|
-
(this.
|
|
3821
|
+
(this.et[s] === e[u] || (this.ot && compare(this.rt, this.et[s], e[u])));
|
|
3523
3822
|
s--, u--
|
|
3524
3823
|
) {
|
|
3525
|
-
E[u] = this.
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3824
|
+
E[u] = this.nt[s];
|
|
3825
|
+
d[u] = this.it[s];
|
|
3826
|
+
S && (S[u] = this.ot[s]);
|
|
3827
|
+
T && (T[u] = this.st[s]);
|
|
3529
3828
|
}
|
|
3530
3829
|
a = new Map();
|
|
3531
3830
|
f = new Array(u + 1);
|
|
3532
3831
|
for (i = u; i >= o; i--) {
|
|
3533
3832
|
c = e[i];
|
|
3534
|
-
l = this.
|
|
3833
|
+
l = this.rt ? this.rt(c) : c;
|
|
3535
3834
|
n = a.get(l);
|
|
3536
3835
|
f[i] = n === undefined ? -1 : n;
|
|
3537
3836
|
a.set(l, i);
|
|
3538
3837
|
}
|
|
3539
3838
|
for (n = o; n <= s; n++) {
|
|
3540
|
-
c = this.
|
|
3541
|
-
l = this.
|
|
3839
|
+
c = this.et[n];
|
|
3840
|
+
l = this.rt ? this.rt(c) : c;
|
|
3542
3841
|
i = a.get(l);
|
|
3543
3842
|
if (i !== undefined && i !== -1) {
|
|
3544
|
-
E[i] = this.
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3843
|
+
E[i] = this.nt[n];
|
|
3844
|
+
d[i] = this.it[n];
|
|
3845
|
+
S && (S[i] = this.ot[n]);
|
|
3846
|
+
T && (T[i] = this.st[n]);
|
|
3548
3847
|
i = f[i];
|
|
3549
3848
|
a.set(l, i);
|
|
3550
|
-
} else this.
|
|
3849
|
+
} else this.it[n].dispose();
|
|
3551
3850
|
}
|
|
3552
3851
|
for (i = o; i < t; i++) {
|
|
3553
3852
|
if (i in E) {
|
|
3554
|
-
this.
|
|
3555
|
-
this.
|
|
3556
|
-
if (
|
|
3557
|
-
this.
|
|
3558
|
-
setSignal(this.
|
|
3853
|
+
this.nt[i] = E[i];
|
|
3854
|
+
this.it[i] = d[i];
|
|
3855
|
+
if (S) {
|
|
3856
|
+
this.ot[i] = S[i];
|
|
3857
|
+
setSignal(this.ot[i], e[i]);
|
|
3559
3858
|
}
|
|
3560
|
-
if (
|
|
3561
|
-
this.
|
|
3562
|
-
setSignal(this.
|
|
3859
|
+
if (T) {
|
|
3860
|
+
this.st[i] = T[i];
|
|
3861
|
+
setSignal(this.st[i], i);
|
|
3563
3862
|
}
|
|
3564
3863
|
} else {
|
|
3565
|
-
this.
|
|
3864
|
+
this.nt[i] = runWithOwner((this.it[i] = createOwner()), r);
|
|
3566
3865
|
}
|
|
3567
3866
|
}
|
|
3568
|
-
this.
|
|
3569
|
-
this.
|
|
3867
|
+
this.nt = this.nt.slice(0, (this.Xe = t));
|
|
3868
|
+
this.et = e.slice(0);
|
|
3570
3869
|
}
|
|
3571
3870
|
});
|
|
3572
|
-
return this.
|
|
3871
|
+
return this.nt;
|
|
3573
3872
|
}
|
|
3574
3873
|
function repeat(e, t, n) {
|
|
3575
3874
|
const i = t;
|
|
3576
3875
|
const r = computed(
|
|
3577
3876
|
updateRepeat.bind({
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3877
|
+
ze: createOwner(),
|
|
3878
|
+
Xe: 0,
|
|
3879
|
+
lt: 0,
|
|
3880
|
+
ft: e,
|
|
3881
|
+
tt: i,
|
|
3882
|
+
it: [],
|
|
3883
|
+
nt: [],
|
|
3884
|
+
Et: n?.from,
|
|
3885
|
+
ct: n?.fallback
|
|
3587
3886
|
})
|
|
3588
3887
|
);
|
|
3589
|
-
r.
|
|
3888
|
+
r.le &= ~CONFIG_AUTO_DISPOSE;
|
|
3590
3889
|
return accessor(r);
|
|
3591
3890
|
}
|
|
3592
3891
|
function updateRepeat() {
|
|
3593
|
-
const e = this.
|
|
3594
|
-
const t = this.
|
|
3595
|
-
runWithOwner(this.
|
|
3892
|
+
const e = this.ft();
|
|
3893
|
+
const t = this.Et?.() || 0;
|
|
3894
|
+
runWithOwner(this.ze, () => {
|
|
3596
3895
|
if (e === 0) {
|
|
3597
|
-
if (this.
|
|
3598
|
-
this.
|
|
3599
|
-
this.
|
|
3600
|
-
this.
|
|
3601
|
-
this.
|
|
3896
|
+
if (this.Xe !== 0) {
|
|
3897
|
+
this.ze.dispose(false);
|
|
3898
|
+
this.it = [];
|
|
3899
|
+
this.nt = [];
|
|
3900
|
+
this.Xe = 0;
|
|
3901
|
+
this.lt = 0;
|
|
3602
3902
|
}
|
|
3603
|
-
if (this.
|
|
3604
|
-
this.
|
|
3903
|
+
if (this.ct && !this.nt[0]) {
|
|
3904
|
+
this.nt[0] = runWithOwner((this.it[0] = createOwner()), this.ct);
|
|
3605
3905
|
}
|
|
3606
3906
|
return;
|
|
3607
3907
|
}
|
|
3608
3908
|
const n = t + e;
|
|
3609
|
-
const i = this.
|
|
3610
|
-
if (this.
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3909
|
+
const i = this.lt + this.Xe;
|
|
3910
|
+
if (this.Xe === 0 && this.it[0]) this.it[0].dispose();
|
|
3911
|
+
if (t >= i || n <= this.lt) {
|
|
3912
|
+
for (let e = 0; e < this.Xe; e++) this.it[e].dispose();
|
|
3913
|
+
this.it = new Array(e);
|
|
3914
|
+
this.nt = new Array(e);
|
|
3915
|
+
for (let n = 0; n < e; n++)
|
|
3916
|
+
this.nt[n] = runWithOwner((this.it[n] = createOwner()), () => this.tt(t + n));
|
|
3917
|
+
this.lt = t;
|
|
3918
|
+
this.Xe = e;
|
|
3919
|
+
return;
|
|
3920
|
+
}
|
|
3921
|
+
for (let e = n; e < i; e++) this.it[e - this.lt].dispose();
|
|
3922
|
+
if (this.lt < t) {
|
|
3923
|
+
const e = t - this.lt;
|
|
3924
|
+
for (let t = 0; t < e && t < this.Xe; t++) this.it[t].dispose();
|
|
3925
|
+
this.it.splice(0, e);
|
|
3926
|
+
this.nt.splice(0, e);
|
|
3927
|
+
} else if (this.lt > t) {
|
|
3928
|
+
let n = i - this.lt - 1;
|
|
3929
|
+
let r = this.lt - t;
|
|
3930
|
+
this.it.length = this.nt.length = e;
|
|
3621
3931
|
while (n >= r) {
|
|
3622
|
-
this.
|
|
3623
|
-
this.
|
|
3932
|
+
this.it[n] = this.it[n - r];
|
|
3933
|
+
this.nt[n] = this.nt[n - r];
|
|
3624
3934
|
n--;
|
|
3625
3935
|
}
|
|
3626
3936
|
for (let e = 0; e < r; e++) {
|
|
3627
|
-
this.
|
|
3937
|
+
this.nt[e] = runWithOwner((this.it[e] = createOwner()), () => this.tt(e + t));
|
|
3628
3938
|
}
|
|
3629
3939
|
}
|
|
3630
3940
|
for (let e = i; e < n; e++) {
|
|
3631
|
-
this.
|
|
3941
|
+
this.nt[e - t] = runWithOwner((this.it[e - t] = createOwner()), () => this.tt(e));
|
|
3632
3942
|
}
|
|
3633
|
-
this.
|
|
3634
|
-
this.
|
|
3635
|
-
this.
|
|
3943
|
+
this.nt = this.nt.slice(0, e);
|
|
3944
|
+
this.lt = t;
|
|
3945
|
+
this.Xe = e;
|
|
3636
3946
|
});
|
|
3637
|
-
return this.
|
|
3947
|
+
return this.nt;
|
|
3638
3948
|
}
|
|
3639
3949
|
function compare(e, t, n) {
|
|
3640
3950
|
return e ? e(t) === e(n) : true;
|
|
3641
3951
|
}
|
|
3642
3952
|
function boundaryComputed(e, t) {
|
|
3643
3953
|
const n = computed(e, { lazy: true });
|
|
3644
|
-
n.
|
|
3645
|
-
const i = e !== undefined ? e : n.
|
|
3646
|
-
const r = t !== undefined ? t : n.
|
|
3647
|
-
n.
|
|
3648
|
-
n.
|
|
3954
|
+
n.Qe = (e, t) => {
|
|
3955
|
+
const i = e !== undefined ? e : n.Y;
|
|
3956
|
+
const r = t !== undefined ? t : n.ae;
|
|
3957
|
+
n.Y &= ~n.dt;
|
|
3958
|
+
n.F.notify(n, STATUS_PENDING | STATUS_ERROR, i, r);
|
|
3959
|
+
const o = i & ~n.dt & (STATUS_PENDING | STATUS_ERROR);
|
|
3960
|
+
if (o) {
|
|
3961
|
+
n.Y &= ~o;
|
|
3962
|
+
if (n.ae === r && !(n.Y & (STATUS_PENDING | STATUS_ERROR))) n.ae = undefined;
|
|
3963
|
+
}
|
|
3649
3964
|
};
|
|
3650
|
-
n.
|
|
3651
|
-
n.
|
|
3965
|
+
n.dt = t;
|
|
3966
|
+
n.le &= ~CONFIG_AUTO_DISPOSE;
|
|
3652
3967
|
recompute(n, true);
|
|
3653
3968
|
return n;
|
|
3654
3969
|
}
|
|
3655
3970
|
function createBoundChildren(e, t, n, i) {
|
|
3656
|
-
const r = e.
|
|
3657
|
-
r.addChild((e.
|
|
3658
|
-
cleanup(() => r.removeChild(e.
|
|
3971
|
+
const r = e.F;
|
|
3972
|
+
r.addChild((e.F = n));
|
|
3973
|
+
cleanup(() => r.removeChild(e.F));
|
|
3659
3974
|
return runWithOwner(e, () => {
|
|
3660
3975
|
const e = computed(t);
|
|
3661
3976
|
return boundaryComputed(() => flatten(read(e)), i);
|
|
@@ -3670,52 +3985,52 @@ function isRevealController(e) {
|
|
|
3670
3985
|
return e instanceof RevealController;
|
|
3671
3986
|
}
|
|
3672
3987
|
function isSlotReady(e) {
|
|
3673
|
-
return isRevealController(e) ? e.isReady() : e.
|
|
3988
|
+
return isRevealController(e) ? e.isReady() : e.St.size === 0 && !e.Tt;
|
|
3674
3989
|
}
|
|
3675
3990
|
function isSlotMinimallyReady(e) {
|
|
3676
3991
|
return isRevealController(e) ? e.isMinimallyReady() : isSlotReady(e);
|
|
3677
3992
|
}
|
|
3678
3993
|
function setSlotState(e, t, n, i) {
|
|
3679
|
-
setSignal(e.
|
|
3680
|
-
setSignal(e.
|
|
3994
|
+
setSignal(e._t, n);
|
|
3995
|
+
setSignal(e.Ot, i);
|
|
3681
3996
|
if (isRevealController(e)) {
|
|
3682
|
-
if (!n && e.
|
|
3997
|
+
if (!n && e.Rt === t) e.Rt = undefined;
|
|
3683
3998
|
return e.evaluate(n, i);
|
|
3684
3999
|
}
|
|
3685
|
-
if (!n && e.
|
|
4000
|
+
if (!n && e.It === t && e.ht) e.It = undefined;
|
|
3686
4001
|
}
|
|
3687
4002
|
class RevealController {
|
|
4003
|
+
At;
|
|
4004
|
+
Nt;
|
|
4005
|
+
Ct = [];
|
|
3688
4006
|
Rt;
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
Nt = true;
|
|
3695
|
-
At = true;
|
|
3696
|
-
Ct = false;
|
|
4007
|
+
_t = signal(false, { ownedWrite: true, Ke: true });
|
|
4008
|
+
Ot = signal(false, { ownedWrite: true, Ke: true });
|
|
4009
|
+
yt = true;
|
|
4010
|
+
Pt = true;
|
|
4011
|
+
gt = false;
|
|
3697
4012
|
constructor(e, t) {
|
|
3698
|
-
this.
|
|
3699
|
-
this.
|
|
4013
|
+
this.At = e;
|
|
4014
|
+
this.Nt = t;
|
|
3700
4015
|
}
|
|
3701
|
-
|
|
3702
|
-
for (let t = 0; t < this.
|
|
3703
|
-
const n = this.
|
|
3704
|
-
if ((isRevealController(n) ? n.
|
|
4016
|
+
Dt(e) {
|
|
4017
|
+
for (let t = 0; t < this.Ct.length; t++) {
|
|
4018
|
+
const n = this.Ct[t];
|
|
4019
|
+
if ((isRevealController(n) ? n.Rt : n.It) !== this) continue;
|
|
3705
4020
|
if (e(n) === false) return false;
|
|
3706
4021
|
}
|
|
3707
4022
|
return true;
|
|
3708
4023
|
}
|
|
3709
4024
|
isReady() {
|
|
3710
|
-
return this.
|
|
4025
|
+
return this.Dt(isSlotReady);
|
|
3711
4026
|
}
|
|
3712
4027
|
isMinimallyReady() {
|
|
3713
|
-
const e = untrack(this.
|
|
4028
|
+
const e = untrack(this.At);
|
|
3714
4029
|
if (e === "together") return this.isReady();
|
|
3715
4030
|
if (e === "natural") {
|
|
3716
4031
|
let e = false;
|
|
3717
4032
|
let t = false;
|
|
3718
|
-
this.
|
|
4033
|
+
this.Dt(n => {
|
|
3719
4034
|
e = true;
|
|
3720
4035
|
if (isSlotMinimallyReady(n)) {
|
|
3721
4036
|
t = true;
|
|
@@ -3725,58 +4040,58 @@ class RevealController {
|
|
|
3725
4040
|
return !e || t;
|
|
3726
4041
|
}
|
|
3727
4042
|
let t = true;
|
|
3728
|
-
this.
|
|
4043
|
+
this.Dt(e => {
|
|
3729
4044
|
t = isSlotMinimallyReady(e);
|
|
3730
4045
|
return false;
|
|
3731
4046
|
});
|
|
3732
4047
|
return t;
|
|
3733
4048
|
}
|
|
3734
4049
|
register(e) {
|
|
3735
|
-
if (this.
|
|
3736
|
-
this.
|
|
3737
|
-
const t = untrack(this.
|
|
3738
|
-
(setSignal(e.
|
|
4050
|
+
if (this.Ct.includes(e)) return;
|
|
4051
|
+
this.Ct.push(e);
|
|
4052
|
+
const t = untrack(this.At);
|
|
4053
|
+
(setSignal(e._t, true), setSignal(e.Ot, t === "sequential" ? !!untrack(this.Nt) : false));
|
|
3739
4054
|
untrack(() => this.evaluate());
|
|
3740
4055
|
}
|
|
3741
4056
|
unregister(e) {
|
|
3742
|
-
const t = this.
|
|
3743
|
-
if (t >= 0) this.
|
|
4057
|
+
const t = this.Ct.indexOf(e);
|
|
4058
|
+
if (t >= 0) this.Ct.splice(t, 1);
|
|
3744
4059
|
untrack(() => this.evaluate());
|
|
3745
4060
|
}
|
|
3746
4061
|
evaluate(e, t) {
|
|
3747
|
-
if (this.
|
|
3748
|
-
this.
|
|
3749
|
-
const n = this.
|
|
3750
|
-
const i = this.
|
|
4062
|
+
if (this.gt) return;
|
|
4063
|
+
this.gt = true;
|
|
4064
|
+
const n = this.yt;
|
|
4065
|
+
const i = this.Pt;
|
|
3751
4066
|
try {
|
|
3752
|
-
const n = e ?? read(this.
|
|
3753
|
-
i = untrack(this.
|
|
3754
|
-
r = i === "sequential" && !!untrack(this.
|
|
4067
|
+
const n = e ?? read(this._t),
|
|
4068
|
+
i = untrack(this.At),
|
|
4069
|
+
r = i === "sequential" && !!untrack(this.Nt),
|
|
3755
4070
|
o = t ?? r;
|
|
3756
4071
|
if (n) {
|
|
3757
|
-
this.
|
|
4072
|
+
this.Dt(e => setSlotState(e, this, true, o));
|
|
3758
4073
|
} else if (i === "natural") {
|
|
3759
|
-
this.
|
|
4074
|
+
this.Dt(e => {
|
|
3760
4075
|
if (isRevealController(e)) {
|
|
3761
|
-
setSignal(e.
|
|
3762
|
-
setSignal(e.
|
|
4076
|
+
setSignal(e.Ot, false);
|
|
4077
|
+
setSignal(e._t, false);
|
|
3763
4078
|
e.evaluate(false, false);
|
|
3764
4079
|
} else {
|
|
3765
4080
|
setSlotState(e, this, !isSlotReady(e), false);
|
|
3766
4081
|
}
|
|
3767
4082
|
});
|
|
3768
4083
|
} else if (i === "together") {
|
|
3769
|
-
const e = this.
|
|
3770
|
-
this.
|
|
4084
|
+
const e = this.Dt(isSlotMinimallyReady);
|
|
4085
|
+
this.Dt(t => setSlotState(t, this, !e, false));
|
|
3771
4086
|
} else {
|
|
3772
4087
|
let e = false;
|
|
3773
|
-
this.
|
|
4088
|
+
this.Dt(t => {
|
|
3774
4089
|
if (e) return setSlotState(t, this, true, r);
|
|
3775
4090
|
if (isSlotReady(t)) return setSlotState(t, this, false, false);
|
|
3776
4091
|
e = true;
|
|
3777
4092
|
if (isRevealController(t)) {
|
|
3778
|
-
setSignal(t.
|
|
3779
|
-
setSignal(t.
|
|
4093
|
+
setSignal(t.Ot, false);
|
|
4094
|
+
setSignal(t._t, false);
|
|
3780
4095
|
t.evaluate(false, false);
|
|
3781
4096
|
} else {
|
|
3782
4097
|
setSlotState(t, this, true, false);
|
|
@@ -3784,101 +4099,101 @@ class RevealController {
|
|
|
3784
4099
|
});
|
|
3785
4100
|
}
|
|
3786
4101
|
} finally {
|
|
3787
|
-
this.
|
|
3788
|
-
this.
|
|
3789
|
-
this.
|
|
4102
|
+
this.yt = this.isReady();
|
|
4103
|
+
this.Pt = this.isMinimallyReady();
|
|
4104
|
+
this.gt = false;
|
|
3790
4105
|
}
|
|
3791
|
-
if (this.
|
|
4106
|
+
if (this.Rt && (n !== this.yt || i !== this.Pt)) this.Rt.evaluate();
|
|
3792
4107
|
}
|
|
3793
4108
|
}
|
|
3794
4109
|
class CollectionQueue extends Queue {
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
4110
|
+
bt;
|
|
4111
|
+
St = new Set();
|
|
4112
|
+
vt;
|
|
4113
|
+
Tt = true;
|
|
4114
|
+
_t = signal(false, { ownedWrite: true, Ke: true });
|
|
4115
|
+
ae;
|
|
4116
|
+
Ot = signal(false, { ownedWrite: true, Ke: true });
|
|
4117
|
+
It;
|
|
4118
|
+
ht = false;
|
|
4119
|
+
wt;
|
|
4120
|
+
Lt = ON_INIT;
|
|
3806
4121
|
constructor(e) {
|
|
3807
4122
|
super();
|
|
3808
|
-
this.
|
|
4123
|
+
this.bt = e;
|
|
3809
4124
|
}
|
|
3810
4125
|
run(e) {
|
|
3811
|
-
if (!e || (read(this.
|
|
4126
|
+
if (!e || (read(this._t) && (!_revealUsed || read(this.Ot)))) return;
|
|
3812
4127
|
return super.run(e);
|
|
3813
4128
|
}
|
|
3814
4129
|
notify(e, t, n, i) {
|
|
3815
|
-
if (!(t & this.
|
|
3816
|
-
if (this.
|
|
4130
|
+
if (!(t & this.bt)) return super.notify(e, t, n, i);
|
|
4131
|
+
if (this.ht && this.wt) {
|
|
3817
4132
|
const e = untrack(() => {
|
|
3818
4133
|
try {
|
|
3819
|
-
return this.
|
|
4134
|
+
return this.wt();
|
|
3820
4135
|
} catch {
|
|
3821
4136
|
return ON_INIT;
|
|
3822
4137
|
}
|
|
3823
4138
|
});
|
|
3824
|
-
if (e !== this.
|
|
3825
|
-
this.
|
|
3826
|
-
this.
|
|
3827
|
-
this.
|
|
4139
|
+
if (e !== this.Lt) {
|
|
4140
|
+
this.Lt = e;
|
|
4141
|
+
this.ht = false;
|
|
4142
|
+
this.St.clear();
|
|
3828
4143
|
}
|
|
3829
4144
|
}
|
|
3830
|
-
if (this.
|
|
3831
|
-
if (this.gt & STATUS_PENDING && n & STATUS_ERROR) {
|
|
4145
|
+
if (this.bt & STATUS_PENDING && n & STATUS_ERROR) {
|
|
3832
4146
|
return super.notify(e, STATUS_ERROR, n, i);
|
|
3833
4147
|
}
|
|
3834
|
-
if (
|
|
3835
|
-
|
|
3836
|
-
|
|
4148
|
+
if (this.bt & STATUS_PENDING && this.ht) return super.notify(e, t, n, i);
|
|
4149
|
+
if (n & this.bt) {
|
|
4150
|
+
this.Tt = true;
|
|
4151
|
+
const t = i?.source || e.ae?.source;
|
|
3837
4152
|
if (t) {
|
|
3838
|
-
const e = this.
|
|
3839
|
-
this.
|
|
3840
|
-
if (e) setSignal(this.
|
|
3841
|
-
if (this.
|
|
3842
|
-
setSignal(this.
|
|
4153
|
+
const e = this.St.size === 0;
|
|
4154
|
+
this.St.add(t);
|
|
4155
|
+
if (e) setSignal(this._t, true);
|
|
4156
|
+
if (this.bt & STATUS_ERROR) {
|
|
4157
|
+
setSignal(this.ae, t.ae?.cause ?? t.ae);
|
|
3843
4158
|
}
|
|
3844
4159
|
}
|
|
3845
4160
|
}
|
|
3846
|
-
t &= ~this.
|
|
4161
|
+
t &= ~this.bt;
|
|
3847
4162
|
return t ? super.notify(e, t, n, i) : true;
|
|
3848
4163
|
}
|
|
3849
4164
|
checkSources() {
|
|
3850
|
-
for (const e of this.
|
|
4165
|
+
for (const e of this.St) {
|
|
3851
4166
|
if (
|
|
3852
|
-
e.
|
|
3853
|
-
(!(e.
|
|
4167
|
+
e.W & REACTIVE_DISPOSED ||
|
|
4168
|
+
(!(e.Y & this.bt) && !(this.bt & STATUS_ERROR && e.Y & STATUS_PENDING))
|
|
3854
4169
|
)
|
|
3855
|
-
this.
|
|
4170
|
+
this.St.delete(e);
|
|
3856
4171
|
}
|
|
3857
|
-
if (!this.
|
|
3858
|
-
if (this.
|
|
3859
|
-
this.
|
|
4172
|
+
if (!this.St.size) {
|
|
4173
|
+
if (this.bt & STATUS_PENDING && this.Tt && !this.ht && this.vt) {
|
|
4174
|
+
this.Tt = !!(this.vt.Y & this.bt);
|
|
3860
4175
|
} else {
|
|
3861
|
-
this.
|
|
4176
|
+
this.Tt = false;
|
|
3862
4177
|
}
|
|
3863
|
-
if (!this.
|
|
3864
|
-
setSignal(this.
|
|
3865
|
-
if (this.
|
|
4178
|
+
if (!this.Tt) {
|
|
4179
|
+
setSignal(this._t, false);
|
|
4180
|
+
if (this.wt) {
|
|
3866
4181
|
try {
|
|
3867
|
-
this.
|
|
4182
|
+
this.Lt = untrack(() => this.wt());
|
|
3868
4183
|
} catch {}
|
|
3869
4184
|
}
|
|
3870
4185
|
}
|
|
3871
4186
|
}
|
|
3872
|
-
if (_revealUsed) this.
|
|
4187
|
+
if (_revealUsed) this.It?.evaluate();
|
|
3873
4188
|
}
|
|
3874
4189
|
}
|
|
3875
4190
|
function createCollectionBoundary(e, t, n, i) {
|
|
3876
4191
|
const r = createOwner();
|
|
3877
4192
|
if (_revealUsed) setContext(RevealControllerContext, null, r);
|
|
3878
4193
|
const o = new CollectionQueue(e);
|
|
3879
|
-
if (e === STATUS_ERROR) o.
|
|
3880
|
-
if (i) o.
|
|
3881
|
-
const s = (o.
|
|
4194
|
+
if (e === STATUS_ERROR) o.ae = signal(undefined, { ownedWrite: true, Ke: true });
|
|
4195
|
+
if (i) o.wt = i;
|
|
4196
|
+
const s = (o.vt = createBoundChildren(r, t, o, e));
|
|
3882
4197
|
untrack(() => {
|
|
3883
4198
|
let t = false;
|
|
3884
4199
|
try {
|
|
@@ -3887,23 +4202,26 @@ function createCollectionBoundary(e, t, n, i) {
|
|
|
3887
4202
|
if (e instanceof NotReadyError) t = true;
|
|
3888
4203
|
else throw e;
|
|
3889
4204
|
}
|
|
3890
|
-
o.
|
|
4205
|
+
o.Tt = t || !!(s.Y & e) || s.ae instanceof NotReadyError;
|
|
3891
4206
|
});
|
|
3892
4207
|
const u = _revealUsed && e === STATUS_PENDING ? getContext(RevealControllerContext) : null;
|
|
3893
4208
|
if (u) {
|
|
3894
|
-
o.
|
|
4209
|
+
o.It = u;
|
|
3895
4210
|
u.register(o);
|
|
3896
4211
|
cleanup(() => u.unregister(o));
|
|
3897
4212
|
}
|
|
3898
4213
|
return accessor(
|
|
3899
|
-
computed(
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
4214
|
+
computed(
|
|
4215
|
+
() => {
|
|
4216
|
+
if (!read(o._t)) {
|
|
4217
|
+
const e = read(s);
|
|
4218
|
+
if (!untrack(() => read(o._t))) return ((o.ht = true), e);
|
|
4219
|
+
}
|
|
4220
|
+
if (_revealUsed && read(o.Ot)) return undefined;
|
|
4221
|
+
return n(o);
|
|
4222
|
+
},
|
|
4223
|
+
{ Ke: true }
|
|
4224
|
+
)
|
|
3907
4225
|
);
|
|
3908
4226
|
}
|
|
3909
4227
|
function createLoadingBoundary(e, t, n) {
|
|
@@ -3911,8 +4229,8 @@ function createLoadingBoundary(e, t, n) {
|
|
|
3911
4229
|
}
|
|
3912
4230
|
function createErrorBoundary(e, t) {
|
|
3913
4231
|
return createCollectionBoundary(STATUS_ERROR, e, e =>
|
|
3914
|
-
t(accessor(e.
|
|
3915
|
-
for (const t of e.
|
|
4232
|
+
t(accessor(e.ae), () => {
|
|
4233
|
+
for (const t of e.St) recompute(t);
|
|
3916
4234
|
schedule();
|
|
3917
4235
|
})
|
|
3918
4236
|
);
|
|
@@ -3933,7 +4251,7 @@ function createRevealOrder(e, t) {
|
|
|
3933
4251
|
s.evaluate();
|
|
3934
4252
|
});
|
|
3935
4253
|
if (i) {
|
|
3936
|
-
s.
|
|
4254
|
+
s.Rt = i;
|
|
3937
4255
|
i.register(s);
|
|
3938
4256
|
cleanup(() => i.unregister(s));
|
|
3939
4257
|
}
|
|
@@ -4030,7 +4348,6 @@ export {
|
|
|
4030
4348
|
isDisposed,
|
|
4031
4349
|
isEqual,
|
|
4032
4350
|
isPending,
|
|
4033
|
-
isRefreshing,
|
|
4034
4351
|
isWrappable,
|
|
4035
4352
|
latest,
|
|
4036
4353
|
mapArray,
|
|
@@ -4044,6 +4361,7 @@ export {
|
|
|
4044
4361
|
refresh,
|
|
4045
4362
|
releaseSnapshotScope,
|
|
4046
4363
|
repeat,
|
|
4364
|
+
resetErrorHalt,
|
|
4047
4365
|
resolve,
|
|
4048
4366
|
runWithOwner,
|
|
4049
4367
|
setContext,
|