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