@solidjs/signals 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +68 -33
- package/dist/node.cjs +463 -428
- package/dist/prod.js +463 -428
- package/dist/types/core/scheduler.d.ts +8 -3
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -45,30 +45,30 @@ function schedule() {
|
|
|
45
45
|
if (scheduled)
|
|
46
46
|
return;
|
|
47
47
|
scheduled = true;
|
|
48
|
-
if (!globalQueue.
|
|
48
|
+
if (!globalQueue.A)
|
|
49
49
|
queueMicrotask(flush);
|
|
50
50
|
}
|
|
51
51
|
function notifyUnobserved() {
|
|
52
52
|
for (let i = 0; i < Unobserved.length; i++) {
|
|
53
53
|
const source = Unobserved[i];
|
|
54
54
|
if (!source.b || !source.b.length)
|
|
55
|
-
Unobserved[i].
|
|
55
|
+
Unobserved[i].ea?.();
|
|
56
56
|
}
|
|
57
57
|
Unobserved = [];
|
|
58
58
|
}
|
|
59
59
|
var pureQueue = [];
|
|
60
60
|
var Queue = class {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
k = null;
|
|
62
|
+
A = false;
|
|
63
|
+
g = [[], []];
|
|
64
|
+
f = [];
|
|
65
65
|
created = clock;
|
|
66
66
|
enqueue(type, fn) {
|
|
67
|
-
if (ActiveTransition && ActiveTransition.
|
|
68
|
-
return ActiveTransition.
|
|
67
|
+
if (ActiveTransition && ActiveTransition.p.has(this))
|
|
68
|
+
return ActiveTransition.p.get(this).enqueue(type, fn);
|
|
69
69
|
pureQueue.push(fn);
|
|
70
70
|
if (type)
|
|
71
|
-
this.
|
|
71
|
+
this.g[type - 1].push(fn);
|
|
72
72
|
schedule();
|
|
73
73
|
}
|
|
74
74
|
run(type) {
|
|
@@ -76,19 +76,19 @@ var Queue = class {
|
|
|
76
76
|
pureQueue.length && runQueue(pureQueue, type);
|
|
77
77
|
pureQueue = [];
|
|
78
78
|
return;
|
|
79
|
-
} else if (this.
|
|
80
|
-
const effects = this.
|
|
81
|
-
this.
|
|
79
|
+
} else if (this.g[type - 1].length) {
|
|
80
|
+
const effects = this.g[type - 1];
|
|
81
|
+
this.g[type - 1] = [];
|
|
82
82
|
runQueue(effects, type);
|
|
83
83
|
}
|
|
84
|
-
for (let i = 0; i < this.
|
|
85
|
-
this.
|
|
84
|
+
for (let i = 0; i < this.f.length; i++) {
|
|
85
|
+
this.f[i].run(type);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
flush() {
|
|
89
|
-
if (this.
|
|
89
|
+
if (this.A)
|
|
90
90
|
return;
|
|
91
|
-
this.
|
|
91
|
+
this.A = true;
|
|
92
92
|
try {
|
|
93
93
|
this.run(EFFECT_PURE);
|
|
94
94
|
incrementClock();
|
|
@@ -96,35 +96,41 @@ var Queue = class {
|
|
|
96
96
|
this.run(EFFECT_RENDER);
|
|
97
97
|
this.run(EFFECT_USER);
|
|
98
98
|
} finally {
|
|
99
|
-
this.
|
|
99
|
+
this.A = false;
|
|
100
100
|
Unobserved.length && notifyUnobserved();
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
addChild(child) {
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
if (ActiveTransition && ActiveTransition.p.has(this))
|
|
105
|
+
return ActiveTransition.p.get(this).addChild(child);
|
|
106
|
+
this.f.push(child);
|
|
107
|
+
child.k = this;
|
|
106
108
|
}
|
|
107
109
|
removeChild(child) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
if (ActiveTransition && ActiveTransition.p.has(this))
|
|
111
|
+
return ActiveTransition.p.get(this).removeChild(child);
|
|
112
|
+
const index = this.f.indexOf(child);
|
|
113
|
+
if (index >= 0) {
|
|
114
|
+
this.f.splice(index, 1);
|
|
115
|
+
child.k = null;
|
|
116
|
+
}
|
|
111
117
|
}
|
|
112
118
|
notify(...args) {
|
|
113
|
-
if (ActiveTransition && ActiveTransition.
|
|
114
|
-
return ActiveTransition.
|
|
115
|
-
if (this.
|
|
116
|
-
return this.
|
|
119
|
+
if (ActiveTransition && ActiveTransition.p.has(this))
|
|
120
|
+
return ActiveTransition.p.get(this).notify(...args);
|
|
121
|
+
if (this.k)
|
|
122
|
+
return this.k.notify(...args);
|
|
117
123
|
return false;
|
|
118
124
|
}
|
|
119
125
|
merge(queue) {
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
122
|
-
for (let i = 0; i < queue.
|
|
123
|
-
const og = this.
|
|
126
|
+
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
127
|
+
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
128
|
+
for (let i = 0; i < queue.f.length; i++) {
|
|
129
|
+
const og = this.f.find((c) => c.e === queue.f[i].e);
|
|
124
130
|
if (og)
|
|
125
|
-
og.merge(queue.
|
|
131
|
+
og.merge(queue.f[i]);
|
|
126
132
|
else
|
|
127
|
-
this.addChild(queue.
|
|
133
|
+
this.addChild(queue.f[i]);
|
|
128
134
|
}
|
|
129
135
|
}
|
|
130
136
|
};
|
|
@@ -134,34 +140,50 @@ function flush() {
|
|
|
134
140
|
globalQueue.flush();
|
|
135
141
|
}
|
|
136
142
|
}
|
|
143
|
+
function removeSourceObservers(node, index) {
|
|
144
|
+
let source;
|
|
145
|
+
let swap;
|
|
146
|
+
for (let i = index; i < node.a.length; i++) {
|
|
147
|
+
source = getTransitionSource(node.a[i]);
|
|
148
|
+
if (source.b) {
|
|
149
|
+
if ((swap = source.b.indexOf(node)) !== -1) {
|
|
150
|
+
source.b[swap] = source.b[source.b.length - 1];
|
|
151
|
+
source.b.pop();
|
|
152
|
+
}
|
|
153
|
+
if (!source.b.length)
|
|
154
|
+
Unobserved.push(source);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
137
158
|
function runQueue(queue, type) {
|
|
138
159
|
for (let i = 0; i < queue.length; i++)
|
|
139
160
|
queue[i](type);
|
|
140
161
|
}
|
|
141
162
|
var Transition = class _Transition {
|
|
142
163
|
a = /* @__PURE__ */ new Map();
|
|
143
|
-
|
|
144
|
-
|
|
164
|
+
t = /* @__PURE__ */ new Set();
|
|
165
|
+
Q = /* @__PURE__ */ new Set();
|
|
145
166
|
W = /* @__PURE__ */ new Set();
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
167
|
+
I = false;
|
|
168
|
+
g = [[], []];
|
|
169
|
+
p = /* @__PURE__ */ new Map();
|
|
149
170
|
E = [];
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
171
|
+
f = [];
|
|
172
|
+
k = null;
|
|
173
|
+
A = false;
|
|
153
174
|
X = false;
|
|
175
|
+
e = globalQueue;
|
|
154
176
|
created = clock;
|
|
155
177
|
constructor() {
|
|
156
|
-
this.
|
|
157
|
-
for (const child of globalQueue.
|
|
158
|
-
cloneQueue(child, this, this.
|
|
178
|
+
this.p.set(globalQueue, this);
|
|
179
|
+
for (const child of globalQueue.f) {
|
|
180
|
+
cloneQueue(child, this, this.p);
|
|
159
181
|
}
|
|
160
182
|
}
|
|
161
183
|
enqueue(type, fn) {
|
|
162
184
|
this.E.push(fn);
|
|
163
185
|
if (type)
|
|
164
|
-
this.
|
|
186
|
+
this.g[type - 1].push(fn);
|
|
165
187
|
this.schedule();
|
|
166
188
|
}
|
|
167
189
|
run(type) {
|
|
@@ -169,19 +191,19 @@ var Transition = class _Transition {
|
|
|
169
191
|
this.E.length && runQueue(this.E, type);
|
|
170
192
|
this.E = [];
|
|
171
193
|
return;
|
|
172
|
-
} else if (this.
|
|
173
|
-
const effects = this.
|
|
174
|
-
this.
|
|
194
|
+
} else if (this.g[type - 1].length) {
|
|
195
|
+
const effects = this.g[type - 1];
|
|
196
|
+
this.g[type - 1] = [];
|
|
175
197
|
runQueue(effects, type);
|
|
176
198
|
}
|
|
177
|
-
for (let i = 0; i < this.
|
|
178
|
-
this.
|
|
199
|
+
for (let i = 0; i < this.f.length; i++) {
|
|
200
|
+
this.f[i].run(type);
|
|
179
201
|
}
|
|
180
202
|
}
|
|
181
203
|
flush() {
|
|
182
|
-
if (this.
|
|
204
|
+
if (this.A)
|
|
183
205
|
return;
|
|
184
|
-
this.
|
|
206
|
+
this.A = true;
|
|
185
207
|
let currentTransition = ActiveTransition;
|
|
186
208
|
ActiveTransition = this;
|
|
187
209
|
try {
|
|
@@ -191,52 +213,52 @@ var Transition = class _Transition {
|
|
|
191
213
|
ActiveTransition = currentTransition;
|
|
192
214
|
finishTransition(this);
|
|
193
215
|
} finally {
|
|
194
|
-
this.
|
|
216
|
+
this.A = false;
|
|
195
217
|
ActiveTransition = currentTransition;
|
|
196
218
|
}
|
|
197
219
|
}
|
|
198
220
|
addChild(child) {
|
|
199
|
-
this.
|
|
200
|
-
child.
|
|
221
|
+
this.f.push(child);
|
|
222
|
+
child.k = this;
|
|
201
223
|
}
|
|
202
224
|
removeChild(child) {
|
|
203
|
-
const index = this.
|
|
225
|
+
const index = this.f.indexOf(child);
|
|
204
226
|
if (index >= 0)
|
|
205
|
-
this.
|
|
227
|
+
this.f.splice(index, 1);
|
|
206
228
|
}
|
|
207
229
|
notify(node, type, flags) {
|
|
208
230
|
if (!(type & LOADING_BIT))
|
|
209
231
|
return false;
|
|
210
232
|
if (flags & LOADING_BIT) {
|
|
211
|
-
this.
|
|
233
|
+
this.t.add(node);
|
|
212
234
|
} else {
|
|
213
|
-
this.
|
|
235
|
+
this.t.delete(node);
|
|
214
236
|
}
|
|
215
237
|
return true;
|
|
216
238
|
}
|
|
217
239
|
merge(queue) {
|
|
218
|
-
this.
|
|
219
|
-
this.
|
|
240
|
+
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
241
|
+
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
220
242
|
this.E.push.apply(this.E, queue.E);
|
|
221
|
-
for (let i = 0; i < queue.
|
|
222
|
-
const og = this.
|
|
243
|
+
for (let i = 0; i < queue.f.length; i++) {
|
|
244
|
+
const og = this.f.find((c) => c.e === queue.f[i].e);
|
|
223
245
|
if (og)
|
|
224
|
-
og.merge(queue.
|
|
246
|
+
og.merge(queue.f[i]);
|
|
225
247
|
else
|
|
226
|
-
this.addChild(queue.
|
|
248
|
+
this.addChild(queue.f[i]);
|
|
227
249
|
}
|
|
228
250
|
}
|
|
229
251
|
schedule() {
|
|
230
252
|
if (this.X)
|
|
231
253
|
return;
|
|
232
254
|
this.X = true;
|
|
233
|
-
if (!this.
|
|
255
|
+
if (!this.A)
|
|
234
256
|
queueMicrotask(() => this.flush());
|
|
235
257
|
}
|
|
236
258
|
runTransition(fn, force = false) {
|
|
237
|
-
if (this.
|
|
238
|
-
if (this.
|
|
239
|
-
return this.
|
|
259
|
+
if (this.I) {
|
|
260
|
+
if (this.I instanceof _Transition)
|
|
261
|
+
return this.I.runTransition(fn, force);
|
|
240
262
|
if (!force)
|
|
241
263
|
throw new Error("Transition already completed");
|
|
242
264
|
fn();
|
|
@@ -247,9 +269,9 @@ var Transition = class _Transition {
|
|
|
247
269
|
const result = fn();
|
|
248
270
|
const transition2 = ActiveTransition;
|
|
249
271
|
if (result instanceof Promise) {
|
|
250
|
-
transition2.
|
|
272
|
+
transition2.Q.add(result);
|
|
251
273
|
result.finally(() => {
|
|
252
|
-
transition2.
|
|
274
|
+
transition2.Q.delete(result);
|
|
253
275
|
finishTransition(transition2);
|
|
254
276
|
});
|
|
255
277
|
}
|
|
@@ -283,14 +305,12 @@ function cloneGraph(node) {
|
|
|
283
305
|
}
|
|
284
306
|
const clone = Object.create(Object.getPrototypeOf(node));
|
|
285
307
|
Object.assign(clone, node, {
|
|
308
|
+
o: null,
|
|
286
309
|
n: null,
|
|
287
|
-
r: null,
|
|
288
310
|
b: null,
|
|
289
311
|
a: node.a ? [...node.a] : null,
|
|
290
|
-
|
|
312
|
+
e: node
|
|
291
313
|
});
|
|
292
|
-
if (clone.F)
|
|
293
|
-
clone.g |= UNINITIALIZED_BIT;
|
|
294
314
|
ActiveTransition.a.set(node, clone);
|
|
295
315
|
node.j = ActiveTransition;
|
|
296
316
|
if (node.a) {
|
|
@@ -300,7 +320,7 @@ function cloneGraph(node) {
|
|
|
300
320
|
if (node.b) {
|
|
301
321
|
clone.b = [];
|
|
302
322
|
for (let i = 0, length = node.b.length; i < length; i++) {
|
|
303
|
-
!node.b[i].
|
|
323
|
+
!node.b[i].e && clone.b.push(cloneGraph(node.b[i]));
|
|
304
324
|
}
|
|
305
325
|
}
|
|
306
326
|
return clone;
|
|
@@ -313,7 +333,7 @@ function replaceSourceObservers(node, transition2) {
|
|
|
313
333
|
transitionSource = transition2.a.get(node.a[i]);
|
|
314
334
|
source = transitionSource || node.a[i];
|
|
315
335
|
if (source.b && (swap = source.b.indexOf(node)) !== -1) {
|
|
316
|
-
source.b[swap] = transitionSource ? node.
|
|
336
|
+
source.b[swap] = transitionSource ? node.e : source.b[source.b.length - 1];
|
|
317
337
|
!transitionSource && source.b.pop();
|
|
318
338
|
}
|
|
319
339
|
}
|
|
@@ -321,15 +341,15 @@ function replaceSourceObservers(node, transition2) {
|
|
|
321
341
|
function cloneQueue(queue, parent, clonedQueues) {
|
|
322
342
|
const clone = Object.create(Object.getPrototypeOf(queue));
|
|
323
343
|
Object.assign(clone, queue, {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
344
|
+
e: queue,
|
|
345
|
+
k: parent,
|
|
346
|
+
f: [],
|
|
327
347
|
enqueue(type, fn) {
|
|
328
348
|
ActiveTransition?.enqueue(type, fn);
|
|
329
349
|
},
|
|
330
350
|
notify(node, type, flags) {
|
|
331
|
-
node = node.
|
|
332
|
-
if (!clone.
|
|
351
|
+
node = node.e || node;
|
|
352
|
+
if (!clone.F || type & LOADING_BIT) {
|
|
333
353
|
type &= ~LOADING_BIT;
|
|
334
354
|
ActiveTransition?.notify(node, LOADING_BIT, flags);
|
|
335
355
|
if (!type)
|
|
@@ -338,26 +358,26 @@ function cloneQueue(queue, parent, clonedQueues) {
|
|
|
338
358
|
return queue.notify.call(this, node, type, flags);
|
|
339
359
|
}
|
|
340
360
|
});
|
|
341
|
-
parent.
|
|
361
|
+
parent.f.push(clone);
|
|
342
362
|
clonedQueues.set(queue, clone);
|
|
343
|
-
for (const child of queue.
|
|
363
|
+
for (const child of queue.f) {
|
|
344
364
|
cloneQueue(child, clone, clonedQueues);
|
|
345
365
|
}
|
|
346
366
|
}
|
|
347
367
|
function resolveQueues(children) {
|
|
348
368
|
for (const child of children) {
|
|
349
|
-
const og = child.
|
|
369
|
+
const og = child.e;
|
|
350
370
|
if (og) {
|
|
351
|
-
const clonedChildren = child.
|
|
371
|
+
const clonedChildren = child.f;
|
|
352
372
|
delete child.enqueue;
|
|
353
373
|
delete child.notify;
|
|
354
|
-
delete child.
|
|
355
|
-
delete child.
|
|
374
|
+
delete child.k;
|
|
375
|
+
delete child.f;
|
|
356
376
|
Object.assign(og, child);
|
|
357
|
-
delete og.
|
|
377
|
+
delete og.e;
|
|
358
378
|
resolveQueues(clonedChildren);
|
|
359
|
-
} else if (child.
|
|
360
|
-
child.
|
|
379
|
+
} else if (child.k.e) {
|
|
380
|
+
child.k.e.addChild(child);
|
|
361
381
|
}
|
|
362
382
|
}
|
|
363
383
|
}
|
|
@@ -370,31 +390,57 @@ function mergeTransitions(t1, t2) {
|
|
|
370
390
|
c.j = t1;
|
|
371
391
|
t1.W.add(c);
|
|
372
392
|
});
|
|
373
|
-
t2.
|
|
374
|
-
t2.
|
|
393
|
+
t2.Q.forEach((p) => t1.Q.add(p));
|
|
394
|
+
t2.t.forEach((n) => t1.t.add(n));
|
|
375
395
|
t1.merge(t2);
|
|
376
|
-
t2.
|
|
396
|
+
t2.I = t1;
|
|
397
|
+
}
|
|
398
|
+
function getTransitionSource(input) {
|
|
399
|
+
return ActiveTransition && ActiveTransition.a.get(input) || input;
|
|
400
|
+
}
|
|
401
|
+
function initialDispose(node) {
|
|
402
|
+
let current = node.n;
|
|
403
|
+
while (current !== null && current.k === node) {
|
|
404
|
+
initialDispose(current);
|
|
405
|
+
const clone = ActiveTransition.a.get(current);
|
|
406
|
+
if (clone && !clone.Y)
|
|
407
|
+
clone.dispose(true);
|
|
408
|
+
current = current.n;
|
|
409
|
+
}
|
|
377
410
|
}
|
|
378
411
|
function finishTransition(transition2) {
|
|
379
|
-
if (transition2.
|
|
412
|
+
if (transition2.I || transition2.X || transition2.Q.size || transition2.t.size)
|
|
380
413
|
return;
|
|
414
|
+
globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
|
|
415
|
+
globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
|
|
416
|
+
resolveQueues(transition2.f);
|
|
381
417
|
for (const [source, clone] of transition2.a) {
|
|
382
|
-
if (source === clone || source.j !== transition2)
|
|
418
|
+
if (source === clone || source.j !== transition2) {
|
|
419
|
+
delete source.j;
|
|
383
420
|
continue;
|
|
421
|
+
}
|
|
384
422
|
if (clone.a)
|
|
385
423
|
replaceSourceObservers(clone, transition2);
|
|
386
|
-
if (
|
|
387
|
-
source.dispose(
|
|
424
|
+
if (clone.Y || clone.c === STATE_DISPOSED) {
|
|
425
|
+
source.dispose(clone.c === STATE_DISPOSED);
|
|
388
426
|
source.emptyDisposal();
|
|
389
|
-
|
|
390
|
-
|
|
427
|
+
delete clone.Y;
|
|
428
|
+
} else {
|
|
429
|
+
delete clone.n;
|
|
430
|
+
delete clone.o;
|
|
431
|
+
}
|
|
432
|
+
Object.assign(source, clone);
|
|
433
|
+
delete source.e;
|
|
434
|
+
let current = clone.n;
|
|
435
|
+
if (current?.w === clone)
|
|
436
|
+
current.w = source;
|
|
437
|
+
while (current?.k === clone) {
|
|
438
|
+
current.k = source;
|
|
439
|
+
current = current.n;
|
|
391
440
|
}
|
|
392
441
|
delete source.j;
|
|
393
442
|
}
|
|
394
|
-
|
|
395
|
-
globalQueue.f[1].push.apply(globalQueue.f[1], transition2.f[1]);
|
|
396
|
-
resolveQueues(transition2.e);
|
|
397
|
-
transition2.J = true;
|
|
443
|
+
transition2.I = true;
|
|
398
444
|
for (const reset of transition2.W) {
|
|
399
445
|
delete reset.j;
|
|
400
446
|
reset();
|
|
@@ -417,14 +463,14 @@ var Owner = class {
|
|
|
417
463
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
418
464
|
// However, the children are actually added in reverse creation order
|
|
419
465
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
420
|
-
|
|
421
|
-
r = null;
|
|
422
|
-
B = null;
|
|
423
|
-
c = STATE_CLEAN;
|
|
466
|
+
k = null;
|
|
424
467
|
n = null;
|
|
425
|
-
w =
|
|
426
|
-
|
|
427
|
-
|
|
468
|
+
w = null;
|
|
469
|
+
c = STATE_CLEAN;
|
|
470
|
+
o = null;
|
|
471
|
+
x = defaultContext;
|
|
472
|
+
m = globalQueue;
|
|
473
|
+
fa = 0;
|
|
428
474
|
id = null;
|
|
429
475
|
constructor(id = null, skipAppend = false) {
|
|
430
476
|
this.id = id;
|
|
@@ -433,64 +479,63 @@ var Owner = class {
|
|
|
433
479
|
}
|
|
434
480
|
}
|
|
435
481
|
append(child) {
|
|
436
|
-
child.
|
|
437
|
-
child.
|
|
438
|
-
if (this.
|
|
439
|
-
this.
|
|
440
|
-
child.
|
|
441
|
-
this.
|
|
482
|
+
child.k = this;
|
|
483
|
+
child.w = this;
|
|
484
|
+
if (this.n)
|
|
485
|
+
this.n.w = child;
|
|
486
|
+
child.n = this.n;
|
|
487
|
+
this.n = child;
|
|
442
488
|
if (this.id != null && child.id == null)
|
|
443
489
|
child.id = this.getNextChildId();
|
|
444
|
-
if (child.
|
|
445
|
-
child.
|
|
490
|
+
if (child.x !== this.x) {
|
|
491
|
+
child.x = { ...this.x, ...child.x };
|
|
446
492
|
}
|
|
447
|
-
if (this.
|
|
448
|
-
child.
|
|
493
|
+
if (this.m)
|
|
494
|
+
child.m = this.m;
|
|
449
495
|
}
|
|
450
496
|
dispose(self = true) {
|
|
451
497
|
if (this.c === STATE_DISPOSED)
|
|
452
498
|
return;
|
|
453
|
-
let head = self ? this.
|
|
454
|
-
while (current && current.
|
|
499
|
+
let head = self ? this.w || this.k : this, current = this.n, next = null;
|
|
500
|
+
while (current && current.k === this) {
|
|
455
501
|
current.dispose(true);
|
|
456
|
-
current.
|
|
457
|
-
|
|
458
|
-
current.r = null;
|
|
502
|
+
next = current.n;
|
|
503
|
+
current.n = null;
|
|
459
504
|
current = next;
|
|
460
505
|
}
|
|
461
|
-
this.
|
|
506
|
+
this.fa = 0;
|
|
462
507
|
if (self)
|
|
463
|
-
this.
|
|
508
|
+
this.R();
|
|
464
509
|
if (current)
|
|
465
|
-
current.
|
|
510
|
+
current.w = !self ? this : this.w;
|
|
466
511
|
if (head)
|
|
467
|
-
head.
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
if (this.
|
|
471
|
-
this.
|
|
472
|
-
this.
|
|
473
|
-
this.
|
|
474
|
-
this.
|
|
512
|
+
head.n = current;
|
|
513
|
+
}
|
|
514
|
+
R() {
|
|
515
|
+
if (this.w)
|
|
516
|
+
this.w.n = null;
|
|
517
|
+
this.k = null;
|
|
518
|
+
this.w = null;
|
|
519
|
+
this.x = defaultContext;
|
|
475
520
|
this.c = STATE_DISPOSED;
|
|
476
521
|
this.emptyDisposal();
|
|
477
522
|
}
|
|
478
523
|
emptyDisposal() {
|
|
479
|
-
if (!this.
|
|
524
|
+
if (!this.o)
|
|
480
525
|
return;
|
|
481
|
-
if (Array.isArray(this.
|
|
482
|
-
for (let i = 0; i < this.
|
|
483
|
-
const callable = this.
|
|
526
|
+
if (Array.isArray(this.o)) {
|
|
527
|
+
for (let i = 0; i < this.o.length; i++) {
|
|
528
|
+
const callable = this.o[i];
|
|
484
529
|
callable.call(callable);
|
|
485
530
|
}
|
|
486
531
|
} else {
|
|
487
|
-
this.
|
|
532
|
+
this.o.call(this.o);
|
|
488
533
|
}
|
|
489
|
-
this.
|
|
534
|
+
this.o = null;
|
|
490
535
|
}
|
|
491
536
|
getNextChildId() {
|
|
492
537
|
if (this.id != null)
|
|
493
|
-
return formatId(this.id, this.
|
|
538
|
+
return formatId(this.id, this.fa++);
|
|
494
539
|
throw new Error("Cannot get child id from owner without an id");
|
|
495
540
|
}
|
|
496
541
|
};
|
|
@@ -501,7 +546,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
501
546
|
if (!owner) {
|
|
502
547
|
throw new NoOwnerError();
|
|
503
548
|
}
|
|
504
|
-
const value = hasContext(context, owner) ? owner.
|
|
549
|
+
const value = hasContext(context, owner) ? owner.x[context.id] : context.defaultValue;
|
|
505
550
|
if (isUndefined(value)) {
|
|
506
551
|
throw new ContextNotFoundError();
|
|
507
552
|
}
|
|
@@ -511,24 +556,24 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
511
556
|
if (!owner) {
|
|
512
557
|
throw new NoOwnerError();
|
|
513
558
|
}
|
|
514
|
-
owner.
|
|
515
|
-
...owner.
|
|
559
|
+
owner.x = {
|
|
560
|
+
...owner.x,
|
|
516
561
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
517
562
|
};
|
|
518
563
|
}
|
|
519
564
|
function hasContext(context, owner = currentOwner) {
|
|
520
|
-
return !isUndefined(owner?.
|
|
565
|
+
return !isUndefined(owner?.x[context.id]);
|
|
521
566
|
}
|
|
522
567
|
function onCleanup(fn) {
|
|
523
568
|
if (!currentOwner)
|
|
524
569
|
return fn;
|
|
525
570
|
const node = currentOwner;
|
|
526
|
-
if (!node.
|
|
527
|
-
node.
|
|
528
|
-
} else if (Array.isArray(node.
|
|
529
|
-
node.
|
|
571
|
+
if (!node.o) {
|
|
572
|
+
node.o = fn;
|
|
573
|
+
} else if (Array.isArray(node.o)) {
|
|
574
|
+
node.o.push(fn);
|
|
530
575
|
} else {
|
|
531
|
-
node.
|
|
576
|
+
node.o = [node.o, fn];
|
|
532
577
|
}
|
|
533
578
|
return fn;
|
|
534
579
|
}
|
|
@@ -556,48 +601,48 @@ var UNCHANGED = Symbol(0);
|
|
|
556
601
|
var Computation = class extends Owner {
|
|
557
602
|
a = null;
|
|
558
603
|
b = null;
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
604
|
+
l;
|
|
605
|
+
J;
|
|
606
|
+
K;
|
|
562
607
|
// Used in __DEV__ mode, hopefully removed in production
|
|
563
|
-
|
|
608
|
+
la;
|
|
564
609
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
565
610
|
// which could enable more efficient DIRTY notification
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
611
|
+
aa = isEqual;
|
|
612
|
+
ea;
|
|
613
|
+
ha = false;
|
|
569
614
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
570
|
-
|
|
615
|
+
h = 0;
|
|
571
616
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
617
|
+
ba = DEFAULT_FLAGS;
|
|
618
|
+
L = -1;
|
|
619
|
+
G = false;
|
|
575
620
|
j;
|
|
576
|
-
|
|
621
|
+
e;
|
|
577
622
|
constructor(initialValue, compute2, options) {
|
|
578
623
|
super(options?.id, compute2 === null);
|
|
579
|
-
this.
|
|
624
|
+
this.K = compute2;
|
|
580
625
|
this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
581
|
-
this.
|
|
582
|
-
this.
|
|
626
|
+
this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
627
|
+
this.l = initialValue;
|
|
583
628
|
if (options?.equals !== void 0)
|
|
584
|
-
this
|
|
629
|
+
this.aa = options.equals;
|
|
585
630
|
if (options?.pureWrite)
|
|
586
|
-
this.
|
|
631
|
+
this.ha = true;
|
|
587
632
|
if (options?.unobserved)
|
|
588
|
-
this.
|
|
633
|
+
this.ea = options?.unobserved;
|
|
589
634
|
if (ActiveTransition) {
|
|
590
635
|
this.j = ActiveTransition;
|
|
591
636
|
ActiveTransition.a.set(this, this);
|
|
592
637
|
}
|
|
593
638
|
}
|
|
594
|
-
|
|
639
|
+
ga() {
|
|
595
640
|
track(this);
|
|
596
|
-
newFlags |= this.
|
|
597
|
-
if (this.
|
|
598
|
-
throw this.
|
|
641
|
+
newFlags |= this.h & ~currentMask;
|
|
642
|
+
if (this.h & ERROR_BIT) {
|
|
643
|
+
throw this.J;
|
|
599
644
|
} else {
|
|
600
|
-
return this.
|
|
645
|
+
return this.l;
|
|
601
646
|
}
|
|
602
647
|
}
|
|
603
648
|
/**
|
|
@@ -605,18 +650,18 @@ var Computation = class extends Owner {
|
|
|
605
650
|
* Automatically re-executes the surrounding computation when the value changes
|
|
606
651
|
*/
|
|
607
652
|
read() {
|
|
608
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
653
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.e && this.h & UNINITIALIZED_BIT | ERROR_BIT)) {
|
|
609
654
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
610
655
|
if (clone !== this)
|
|
611
656
|
return clone.read();
|
|
612
657
|
}
|
|
613
|
-
if (this.
|
|
614
|
-
if (this.
|
|
658
|
+
if (this.K) {
|
|
659
|
+
if (this.h & ERROR_BIT && this.L <= clock)
|
|
615
660
|
update(this);
|
|
616
661
|
else
|
|
617
|
-
this.
|
|
662
|
+
this.H();
|
|
618
663
|
}
|
|
619
|
-
return this.
|
|
664
|
+
return this.ga();
|
|
620
665
|
}
|
|
621
666
|
/**
|
|
622
667
|
* Return the current value of this computation
|
|
@@ -626,65 +671,65 @@ var Computation = class extends Owner {
|
|
|
626
671
|
* before continuing
|
|
627
672
|
*/
|
|
628
673
|
wait() {
|
|
629
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
674
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.e && this.h & UNINITIALIZED_BIT)) {
|
|
630
675
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
631
676
|
if (clone !== this)
|
|
632
677
|
return clone.wait();
|
|
633
678
|
}
|
|
634
|
-
if (this.
|
|
635
|
-
if (this.
|
|
679
|
+
if (this.K) {
|
|
680
|
+
if (this.h & ERROR_BIT && this.L <= clock)
|
|
636
681
|
update(this);
|
|
637
682
|
else
|
|
638
|
-
this.
|
|
683
|
+
this.H();
|
|
639
684
|
}
|
|
640
|
-
if ((notStale || this.
|
|
685
|
+
if ((notStale || this.h & UNINITIALIZED_BIT) && this.h & LOADING_BIT) {
|
|
641
686
|
track(this);
|
|
642
687
|
throw new NotReadyError();
|
|
643
688
|
}
|
|
644
|
-
if (staleCheck && this.
|
|
645
|
-
staleCheck.
|
|
689
|
+
if (staleCheck && this.h & LOADING_BIT) {
|
|
690
|
+
staleCheck.l = true;
|
|
646
691
|
}
|
|
647
|
-
return this.
|
|
692
|
+
return this.ga();
|
|
648
693
|
}
|
|
649
694
|
/** Update the computation with a new value. */
|
|
650
695
|
write(value, flags = 0, raw = false) {
|
|
651
|
-
if (ActiveTransition && !this.
|
|
696
|
+
if (ActiveTransition && !this.e) {
|
|
652
697
|
const clone = cloneGraph(this);
|
|
653
698
|
if (clone !== this)
|
|
654
699
|
return clone.write(value, flags, raw);
|
|
655
700
|
}
|
|
656
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
657
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
658
|
-
this
|
|
701
|
+
const newValue = !raw && typeof value === "function" ? value(this.l) : value;
|
|
702
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.h & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
703
|
+
this.aa === false || !this.aa(this.l, newValue));
|
|
659
704
|
if (valueChanged) {
|
|
660
|
-
this.
|
|
661
|
-
this.
|
|
705
|
+
this.l = newValue;
|
|
706
|
+
this.J = void 0;
|
|
662
707
|
}
|
|
663
|
-
const changedFlagsMask = this.
|
|
664
|
-
this.
|
|
665
|
-
this.
|
|
708
|
+
const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
|
|
709
|
+
this.h = flags;
|
|
710
|
+
this.L = clock + 1;
|
|
666
711
|
if (this.b) {
|
|
667
712
|
for (let i = 0; i < this.b.length; i++) {
|
|
668
713
|
if (valueChanged) {
|
|
669
|
-
this.b[i].
|
|
714
|
+
this.b[i].y(STATE_DIRTY);
|
|
670
715
|
} else if (changedFlagsMask) {
|
|
671
|
-
this.b[i].
|
|
716
|
+
this.b[i].Z(changedFlagsMask, changedFlags);
|
|
672
717
|
}
|
|
673
718
|
}
|
|
674
719
|
}
|
|
675
|
-
return this.
|
|
720
|
+
return this.l;
|
|
676
721
|
}
|
|
677
722
|
/**
|
|
678
723
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
679
724
|
*/
|
|
680
|
-
|
|
681
|
-
if (this.c >= state && !this.
|
|
725
|
+
y(state, skipQueue) {
|
|
726
|
+
if (this.c >= state && !this.G)
|
|
682
727
|
return;
|
|
683
|
-
this.
|
|
728
|
+
this.G = !!skipQueue;
|
|
684
729
|
this.c = state;
|
|
685
730
|
if (this.b) {
|
|
686
731
|
for (let i = 0; i < this.b.length; i++) {
|
|
687
|
-
this.b[i].
|
|
732
|
+
this.b[i].y(STATE_CHECK, skipQueue);
|
|
688
733
|
}
|
|
689
734
|
}
|
|
690
735
|
}
|
|
@@ -694,36 +739,36 @@ var Computation = class extends Owner {
|
|
|
694
739
|
* @param mask A bitmask for which flag(s) were changed.
|
|
695
740
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
696
741
|
*/
|
|
697
|
-
|
|
742
|
+
Z(mask, newFlags2) {
|
|
698
743
|
if (this.c >= STATE_DIRTY)
|
|
699
744
|
return;
|
|
700
|
-
if (mask & this.
|
|
701
|
-
this.
|
|
745
|
+
if (mask & this.ba) {
|
|
746
|
+
this.y(STATE_DIRTY);
|
|
702
747
|
return;
|
|
703
748
|
}
|
|
704
749
|
if (this.c >= STATE_CHECK)
|
|
705
750
|
return;
|
|
706
|
-
const prevFlags = this.
|
|
751
|
+
const prevFlags = this.h & mask;
|
|
707
752
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
708
753
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
709
|
-
this.
|
|
754
|
+
this.y(STATE_CHECK);
|
|
710
755
|
} else {
|
|
711
|
-
this.
|
|
756
|
+
this.h ^= deltaFlags;
|
|
712
757
|
if (this.b) {
|
|
713
758
|
for (let i = 0; i < this.b.length; i++) {
|
|
714
|
-
this.b[i].
|
|
759
|
+
this.b[i].Z(mask, newFlags2);
|
|
715
760
|
}
|
|
716
761
|
}
|
|
717
762
|
}
|
|
718
763
|
}
|
|
719
|
-
|
|
720
|
-
if (ActiveTransition && !this.
|
|
764
|
+
M(error) {
|
|
765
|
+
if (ActiveTransition && !this.e) {
|
|
721
766
|
const clone = cloneGraph(this);
|
|
722
767
|
if (clone !== this)
|
|
723
|
-
return clone.
|
|
768
|
+
return clone.M(error);
|
|
724
769
|
}
|
|
725
|
-
this.
|
|
726
|
-
this.write(UNCHANGED, this.
|
|
770
|
+
this.J = error;
|
|
771
|
+
this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
727
772
|
}
|
|
728
773
|
/**
|
|
729
774
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -732,8 +777,8 @@ var Computation = class extends Owner {
|
|
|
732
777
|
*
|
|
733
778
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
734
779
|
*/
|
|
735
|
-
|
|
736
|
-
if (!this.
|
|
780
|
+
H() {
|
|
781
|
+
if (!this.K) {
|
|
737
782
|
return;
|
|
738
783
|
}
|
|
739
784
|
if (this.c === STATE_DISPOSED) {
|
|
@@ -745,9 +790,9 @@ var Computation = class extends Owner {
|
|
|
745
790
|
let observerFlags = 0;
|
|
746
791
|
if (this.c === STATE_CHECK) {
|
|
747
792
|
for (let i = 0; i < this.a.length; i++) {
|
|
748
|
-
const source =
|
|
749
|
-
source.
|
|
750
|
-
observerFlags |= source.
|
|
793
|
+
const source = getTransitionSource(this.a[i]);
|
|
794
|
+
source.H();
|
|
795
|
+
observerFlags |= source.h & ~UNINITIALIZED_BIT;
|
|
751
796
|
if (this.c === STATE_DIRTY) {
|
|
752
797
|
break;
|
|
753
798
|
}
|
|
@@ -763,17 +808,17 @@ var Computation = class extends Owner {
|
|
|
763
808
|
/**
|
|
764
809
|
* Remove ourselves from the owner graph and the computation graph
|
|
765
810
|
*/
|
|
766
|
-
|
|
811
|
+
R() {
|
|
767
812
|
if (this.c === STATE_DISPOSED)
|
|
768
813
|
return;
|
|
769
814
|
if (this.a)
|
|
770
815
|
removeSourceObservers(this, 0);
|
|
771
|
-
super.
|
|
816
|
+
super.R();
|
|
772
817
|
}
|
|
773
818
|
};
|
|
774
819
|
function track(computation) {
|
|
775
|
-
if (ActiveTransition && computation.
|
|
776
|
-
computation = computation.
|
|
820
|
+
if (ActiveTransition && computation.e)
|
|
821
|
+
computation = computation.e;
|
|
777
822
|
if (currentObserver) {
|
|
778
823
|
if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
|
|
779
824
|
newSourcesIndex++;
|
|
@@ -783,7 +828,7 @@ function track(computation) {
|
|
|
783
828
|
newSources.push(computation);
|
|
784
829
|
}
|
|
785
830
|
if (updateCheck) {
|
|
786
|
-
updateCheck.
|
|
831
|
+
updateCheck.l = computation.L > currentObserver.L;
|
|
787
832
|
}
|
|
788
833
|
}
|
|
789
834
|
}
|
|
@@ -793,15 +838,19 @@ function update(node) {
|
|
|
793
838
|
newSourcesIndex = 0;
|
|
794
839
|
newFlags = 0;
|
|
795
840
|
try {
|
|
841
|
+
if (ActiveTransition && node.e && !node.Y) {
|
|
842
|
+
initialDispose(node.e);
|
|
843
|
+
node.Y = true;
|
|
844
|
+
}
|
|
796
845
|
node.dispose(false);
|
|
797
846
|
node.emptyDisposal();
|
|
798
|
-
const result = compute(node, node.
|
|
847
|
+
const result = compute(node, node.K, node);
|
|
799
848
|
node.write(result, newFlags, true);
|
|
800
849
|
} catch (error) {
|
|
801
850
|
if (error instanceof NotReadyError) {
|
|
802
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
851
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
|
|
803
852
|
} else {
|
|
804
|
-
node.
|
|
853
|
+
node.M(error);
|
|
805
854
|
}
|
|
806
855
|
} finally {
|
|
807
856
|
if (newSources) {
|
|
@@ -817,7 +866,7 @@ function update(node) {
|
|
|
817
866
|
}
|
|
818
867
|
let source;
|
|
819
868
|
for (let i = newSourcesIndex; i < node.a.length; i++) {
|
|
820
|
-
source =
|
|
869
|
+
source = getTransitionSource(node.a[i]);
|
|
821
870
|
if (!source.b)
|
|
822
871
|
source.b = [node];
|
|
823
872
|
else
|
|
@@ -830,25 +879,10 @@ function update(node) {
|
|
|
830
879
|
newSources = prevSources;
|
|
831
880
|
newSourcesIndex = prevSourcesIndex;
|
|
832
881
|
newFlags = prevFlags;
|
|
833
|
-
node.
|
|
882
|
+
node.L = clock + 1;
|
|
834
883
|
node.c = STATE_CLEAN;
|
|
835
884
|
}
|
|
836
885
|
}
|
|
837
|
-
function removeSourceObservers(node, index) {
|
|
838
|
-
let source;
|
|
839
|
-
let swap;
|
|
840
|
-
for (let i = index; i < node.a.length; i++) {
|
|
841
|
-
source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
|
|
842
|
-
if (source.b) {
|
|
843
|
-
if ((swap = source.b.indexOf(node)) !== -1) {
|
|
844
|
-
source.b[swap] = source.b[source.b.length - 1];
|
|
845
|
-
source.b.pop();
|
|
846
|
-
}
|
|
847
|
-
if (!source.b.length)
|
|
848
|
-
Unobserved.push(source);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
886
|
function isEqual(a, b) {
|
|
853
887
|
return a === b;
|
|
854
888
|
}
|
|
@@ -859,20 +893,20 @@ function untrack(fn) {
|
|
|
859
893
|
}
|
|
860
894
|
function hasUpdated(fn) {
|
|
861
895
|
const current = updateCheck;
|
|
862
|
-
updateCheck = {
|
|
896
|
+
updateCheck = { l: false };
|
|
863
897
|
try {
|
|
864
898
|
fn();
|
|
865
|
-
return updateCheck.
|
|
899
|
+
return updateCheck.l;
|
|
866
900
|
} finally {
|
|
867
901
|
updateCheck = current;
|
|
868
902
|
}
|
|
869
903
|
}
|
|
870
904
|
function pendingCheck(fn, loadingValue) {
|
|
871
905
|
const current = staleCheck;
|
|
872
|
-
staleCheck = {
|
|
906
|
+
staleCheck = { l: false };
|
|
873
907
|
try {
|
|
874
908
|
latest(fn);
|
|
875
|
-
return staleCheck.
|
|
909
|
+
return staleCheck.l;
|
|
876
910
|
} catch (err) {
|
|
877
911
|
if (!(err instanceof NotReadyError))
|
|
878
912
|
return false;
|
|
@@ -887,7 +921,7 @@ function isPending(fn, loadingValue) {
|
|
|
887
921
|
if (!currentObserver)
|
|
888
922
|
return pendingCheck(fn, loadingValue);
|
|
889
923
|
const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
|
|
890
|
-
c.
|
|
924
|
+
c.ba |= LOADING_BIT;
|
|
891
925
|
return c.read();
|
|
892
926
|
}
|
|
893
927
|
function latest(fn, fallback) {
|
|
@@ -917,10 +951,10 @@ function runWithObserver(observer, run) {
|
|
|
917
951
|
if (error instanceof NotReadyError) {
|
|
918
952
|
observer.write(
|
|
919
953
|
UNCHANGED,
|
|
920
|
-
newFlags | LOADING_BIT | observer.
|
|
954
|
+
newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
|
|
921
955
|
);
|
|
922
956
|
} else {
|
|
923
|
-
observer.
|
|
957
|
+
observer.M(error);
|
|
924
958
|
}
|
|
925
959
|
} finally {
|
|
926
960
|
if (newSources) {
|
|
@@ -949,10 +983,10 @@ function runWithObserver(observer, run) {
|
|
|
949
983
|
function compute(owner, fn, observer) {
|
|
950
984
|
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
951
985
|
currentObserver = observer;
|
|
952
|
-
currentMask = observer?.
|
|
986
|
+
currentMask = observer?.ba ?? DEFAULT_FLAGS;
|
|
953
987
|
notStale = true;
|
|
954
988
|
try {
|
|
955
|
-
return fn.call(observer, observer ? observer.
|
|
989
|
+
return fn.call(observer, observer ? observer.l : void 0);
|
|
956
990
|
} finally {
|
|
957
991
|
setOwner(prevOwner);
|
|
958
992
|
currentObserver = prevObserver;
|
|
@@ -963,99 +997,99 @@ function compute(owner, fn, observer) {
|
|
|
963
997
|
|
|
964
998
|
// src/core/effect.ts
|
|
965
999
|
var Effect = class extends Computation {
|
|
966
|
-
|
|
967
|
-
Z;
|
|
968
|
-
O;
|
|
969
|
-
ca = false;
|
|
1000
|
+
ca;
|
|
970
1001
|
_;
|
|
971
|
-
|
|
1002
|
+
N;
|
|
1003
|
+
da = false;
|
|
1004
|
+
$;
|
|
1005
|
+
B;
|
|
972
1006
|
constructor(initialValue, compute2, effect, error, options) {
|
|
973
1007
|
super(initialValue, compute2, options);
|
|
974
|
-
this.
|
|
975
|
-
this.
|
|
976
|
-
this
|
|
977
|
-
this.
|
|
978
|
-
if (this.
|
|
979
|
-
this.
|
|
980
|
-
return !this.
|
|
1008
|
+
this.ca = effect;
|
|
1009
|
+
this._ = error;
|
|
1010
|
+
this.$ = initialValue;
|
|
1011
|
+
this.B = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
1012
|
+
if (this.B === EFFECT_RENDER) {
|
|
1013
|
+
this.K = function(p) {
|
|
1014
|
+
return !this.e && clock > this.m.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
981
1015
|
};
|
|
982
1016
|
}
|
|
983
|
-
this.
|
|
984
|
-
!options?.defer && (this.
|
|
1017
|
+
this.H();
|
|
1018
|
+
!options?.defer && (this.B === EFFECT_USER ? this.m.enqueue(this.B, this.C.bind(this)) : this.C(this.B));
|
|
985
1019
|
}
|
|
986
1020
|
write(value, flags = 0) {
|
|
987
1021
|
if (this.c == STATE_DIRTY) {
|
|
988
|
-
this.
|
|
989
|
-
if (this.
|
|
990
|
-
this.
|
|
1022
|
+
this.h = flags;
|
|
1023
|
+
if (this.B === EFFECT_RENDER) {
|
|
1024
|
+
this.m.notify(this, LOADING_BIT | ERROR_BIT, this.h);
|
|
991
1025
|
}
|
|
992
1026
|
}
|
|
993
1027
|
if (value === UNCHANGED)
|
|
994
|
-
return this.
|
|
995
|
-
this.
|
|
996
|
-
this.
|
|
997
|
-
this.
|
|
1028
|
+
return this.l;
|
|
1029
|
+
this.l = value;
|
|
1030
|
+
this.da = true;
|
|
1031
|
+
this.J = void 0;
|
|
998
1032
|
return value;
|
|
999
1033
|
}
|
|
1000
|
-
|
|
1034
|
+
y(state, skipQueue) {
|
|
1001
1035
|
if (this.c >= state || skipQueue)
|
|
1002
1036
|
return;
|
|
1003
1037
|
if (this.c === STATE_CLEAN)
|
|
1004
|
-
this.
|
|
1038
|
+
this.m.enqueue(this.B, this.C.bind(this));
|
|
1005
1039
|
this.c = state;
|
|
1006
1040
|
}
|
|
1007
|
-
|
|
1008
|
-
if (this.
|
|
1041
|
+
Z(mask, newFlags2) {
|
|
1042
|
+
if (this.e) {
|
|
1009
1043
|
if (this.c >= STATE_DIRTY)
|
|
1010
1044
|
return;
|
|
1011
1045
|
if (mask & 3) {
|
|
1012
|
-
this.
|
|
1046
|
+
this.y(STATE_DIRTY);
|
|
1013
1047
|
return;
|
|
1014
1048
|
}
|
|
1015
1049
|
}
|
|
1016
|
-
super.
|
|
1050
|
+
super.Z(mask, newFlags2);
|
|
1017
1051
|
}
|
|
1018
|
-
|
|
1019
|
-
this.
|
|
1020
|
-
this.
|
|
1021
|
-
this.
|
|
1022
|
-
if (this.
|
|
1052
|
+
M(error) {
|
|
1053
|
+
this.J = error;
|
|
1054
|
+
this.m.notify(this, LOADING_BIT, 0);
|
|
1055
|
+
this.h = ERROR_BIT;
|
|
1056
|
+
if (this.B === EFFECT_USER) {
|
|
1023
1057
|
try {
|
|
1024
|
-
return this.
|
|
1025
|
-
this.
|
|
1026
|
-
this.
|
|
1058
|
+
return this._ ? this._(error, () => {
|
|
1059
|
+
this.N?.();
|
|
1060
|
+
this.N = void 0;
|
|
1027
1061
|
}) : console.error(error);
|
|
1028
1062
|
} catch (e) {
|
|
1029
1063
|
error = e;
|
|
1030
1064
|
}
|
|
1031
1065
|
}
|
|
1032
|
-
if (!this.
|
|
1066
|
+
if (!this.m.notify(this, ERROR_BIT, ERROR_BIT))
|
|
1033
1067
|
throw error;
|
|
1034
1068
|
}
|
|
1035
|
-
|
|
1069
|
+
R() {
|
|
1036
1070
|
if (this.c === STATE_DISPOSED)
|
|
1037
1071
|
return;
|
|
1038
|
-
this.
|
|
1072
|
+
this.ca = void 0;
|
|
1073
|
+
this.$ = void 0;
|
|
1039
1074
|
this._ = void 0;
|
|
1040
|
-
this.
|
|
1041
|
-
this.
|
|
1042
|
-
this.
|
|
1043
|
-
|
|
1044
|
-
super.K();
|
|
1075
|
+
this.N?.();
|
|
1076
|
+
this.N = void 0;
|
|
1077
|
+
this.m.notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1078
|
+
super.R();
|
|
1045
1079
|
}
|
|
1046
1080
|
C(type) {
|
|
1047
1081
|
if (type) {
|
|
1048
|
-
const effect = this.
|
|
1049
|
-
if (effect.
|
|
1050
|
-
effect.
|
|
1082
|
+
const effect = this.e || this;
|
|
1083
|
+
if (effect.da && effect.c !== STATE_DISPOSED) {
|
|
1084
|
+
effect.N?.();
|
|
1051
1085
|
try {
|
|
1052
|
-
effect.
|
|
1086
|
+
effect.N = effect.ca(effect.l, effect.$);
|
|
1053
1087
|
} catch (e) {
|
|
1054
|
-
if (!effect.
|
|
1088
|
+
if (!effect.m.notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1055
1089
|
throw e;
|
|
1056
1090
|
} finally {
|
|
1057
|
-
effect
|
|
1058
|
-
effect.
|
|
1091
|
+
effect.$ = effect.l;
|
|
1092
|
+
effect.da = false;
|
|
1059
1093
|
}
|
|
1060
1094
|
}
|
|
1061
1095
|
} else
|
|
@@ -1065,14 +1099,14 @@ var Effect = class extends Computation {
|
|
|
1065
1099
|
var EagerComputation = class extends Computation {
|
|
1066
1100
|
constructor(initialValue, compute2, options) {
|
|
1067
1101
|
super(initialValue, compute2, options);
|
|
1068
|
-
!options?.defer && this.
|
|
1102
|
+
!options?.defer && this.H();
|
|
1069
1103
|
}
|
|
1070
|
-
|
|
1071
|
-
if (this.c >= state && !this.
|
|
1104
|
+
y(state, skipQueue) {
|
|
1105
|
+
if (this.c >= state && !this.G)
|
|
1072
1106
|
return;
|
|
1073
|
-
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.
|
|
1074
|
-
this.
|
|
1075
|
-
super.
|
|
1107
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
|
|
1108
|
+
this.m.enqueue(EFFECT_PURE, this.C.bind(this));
|
|
1109
|
+
super.y(state, skipQueue);
|
|
1076
1110
|
}
|
|
1077
1111
|
C() {
|
|
1078
1112
|
this.c !== STATE_CLEAN && runTop(this);
|
|
@@ -1083,13 +1117,13 @@ var FirewallComputation = class extends Computation {
|
|
|
1083
1117
|
constructor(compute2) {
|
|
1084
1118
|
super(void 0, compute2);
|
|
1085
1119
|
}
|
|
1086
|
-
|
|
1087
|
-
if (this.c >= state && !this.
|
|
1120
|
+
y(state, skipQueue) {
|
|
1121
|
+
if (this.c >= state && !this.G)
|
|
1088
1122
|
return;
|
|
1089
|
-
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.
|
|
1090
|
-
this.
|
|
1091
|
-
super.
|
|
1092
|
-
this.
|
|
1123
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
|
|
1124
|
+
this.m.enqueue(EFFECT_PURE, this.C.bind(this));
|
|
1125
|
+
super.y(state, true);
|
|
1126
|
+
this.G = !!skipQueue;
|
|
1093
1127
|
}
|
|
1094
1128
|
C() {
|
|
1095
1129
|
this.c !== STATE_CLEAN && runTop(this);
|
|
@@ -1097,14 +1131,16 @@ var FirewallComputation = class extends Computation {
|
|
|
1097
1131
|
};
|
|
1098
1132
|
function runTop(node) {
|
|
1099
1133
|
const ancestors = [];
|
|
1100
|
-
for (let current = node; current !== null; current = current.
|
|
1134
|
+
for (let current = node; current !== null; current = current.k) {
|
|
1135
|
+
if (ActiveTransition && current.j)
|
|
1136
|
+
current = ActiveTransition.a.get(current);
|
|
1101
1137
|
if (current.c !== STATE_CLEAN) {
|
|
1102
1138
|
ancestors.push(current);
|
|
1103
1139
|
}
|
|
1104
1140
|
}
|
|
1105
1141
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1106
1142
|
if (ancestors[i].c !== STATE_DISPOSED)
|
|
1107
|
-
ancestors[i].
|
|
1143
|
+
ancestors[i].H();
|
|
1108
1144
|
}
|
|
1109
1145
|
}
|
|
1110
1146
|
|
|
@@ -1238,7 +1274,7 @@ var storeTraps = {
|
|
|
1238
1274
|
return desc.get.call(receiver);
|
|
1239
1275
|
}
|
|
1240
1276
|
if (Writing?.has(receiver)) {
|
|
1241
|
-
let value2 = tracked && (overridden || !proxySource) ? tracked.
|
|
1277
|
+
let value2 = tracked && (overridden || !proxySource) ? tracked.l : storeValue[property];
|
|
1242
1278
|
value2 === $DELETED && (value2 = void 0);
|
|
1243
1279
|
if (!isWrappable(value2))
|
|
1244
1280
|
return value2;
|
|
@@ -1775,7 +1811,7 @@ function createMemo(compute2, value, options) {
|
|
|
1775
1811
|
return resolvedValue;
|
|
1776
1812
|
}
|
|
1777
1813
|
resolvedValue = node.wait();
|
|
1778
|
-
if (!node.a?.length && node.
|
|
1814
|
+
if (!node.a?.length && node.n?.k !== node && !(node.h & UNINITIALIZED_BIT)) {
|
|
1779
1815
|
node.dispose();
|
|
1780
1816
|
node = void 0;
|
|
1781
1817
|
}
|
|
@@ -1811,8 +1847,8 @@ function createAsync(compute2, value, options) {
|
|
|
1811
1847
|
if (abort)
|
|
1812
1848
|
return;
|
|
1813
1849
|
if (transition2)
|
|
1814
|
-
return transition2.runTransition(() => node.
|
|
1815
|
-
node.
|
|
1850
|
+
return transition2.runTransition(() => node.M(error), true);
|
|
1851
|
+
node.M(error);
|
|
1816
1852
|
}
|
|
1817
1853
|
);
|
|
1818
1854
|
} else {
|
|
@@ -1837,12 +1873,12 @@ function createAsync(compute2, value, options) {
|
|
|
1837
1873
|
const read = node.wait.bind(node);
|
|
1838
1874
|
read.refresh = () => {
|
|
1839
1875
|
let n = node;
|
|
1840
|
-
if (ActiveTransition && !node.
|
|
1876
|
+
if (ActiveTransition && !node.e) {
|
|
1841
1877
|
n = cloneGraph(node);
|
|
1842
1878
|
}
|
|
1843
1879
|
n.c = STATE_DIRTY;
|
|
1844
1880
|
refreshing = true;
|
|
1845
|
-
n.
|
|
1881
|
+
n.H();
|
|
1846
1882
|
};
|
|
1847
1883
|
return read;
|
|
1848
1884
|
}
|
|
@@ -1955,47 +1991,47 @@ function mapArray(list, map, options) {
|
|
|
1955
1991
|
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
1956
1992
|
return updateKeyedMap.bind({
|
|
1957
1993
|
S: new Owner(),
|
|
1958
|
-
|
|
1959
|
-
|
|
1994
|
+
q: 0,
|
|
1995
|
+
ia: list,
|
|
1960
1996
|
D: [],
|
|
1961
|
-
|
|
1997
|
+
O: map,
|
|
1962
1998
|
i: [],
|
|
1963
1999
|
d: [],
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
2000
|
+
P: keyFn,
|
|
2001
|
+
r: keyFn || options?.keyed === false ? [] : void 0,
|
|
2002
|
+
s: map.length > 1 ? [] : void 0,
|
|
1967
2003
|
T: options?.fallback
|
|
1968
2004
|
});
|
|
1969
2005
|
}
|
|
1970
2006
|
var pureOptions = { pureWrite: true };
|
|
1971
2007
|
function updateKeyedMap() {
|
|
1972
|
-
const newItems = this.
|
|
2008
|
+
const newItems = this.ia() || [], newLen = newItems.length;
|
|
1973
2009
|
newItems[$TRACK];
|
|
1974
2010
|
runWithOwner(this.S, () => {
|
|
1975
|
-
let i, j, mapper = this.
|
|
1976
|
-
this.
|
|
1977
|
-
this.
|
|
1978
|
-
return this.
|
|
1979
|
-
Computation.prototype.read.bind(this.
|
|
1980
|
-
this.
|
|
2011
|
+
let i, j, mapper = this.r ? () => {
|
|
2012
|
+
this.r[j] = new Computation(newItems[j], null, pureOptions);
|
|
2013
|
+
this.s && (this.s[j] = new Computation(j, null, pureOptions));
|
|
2014
|
+
return this.O(
|
|
2015
|
+
Computation.prototype.read.bind(this.r[j]),
|
|
2016
|
+
this.s ? Computation.prototype.read.bind(this.s[j]) : void 0
|
|
1981
2017
|
);
|
|
1982
|
-
} : this.
|
|
2018
|
+
} : this.s ? () => {
|
|
1983
2019
|
const item = newItems[j];
|
|
1984
|
-
this.
|
|
1985
|
-
return this.
|
|
2020
|
+
this.s[j] = new Computation(j, null, pureOptions);
|
|
2021
|
+
return this.O(() => item, Computation.prototype.read.bind(this.s[j]));
|
|
1986
2022
|
} : () => {
|
|
1987
2023
|
const item = newItems[j];
|
|
1988
|
-
return this.
|
|
2024
|
+
return this.O(() => item);
|
|
1989
2025
|
};
|
|
1990
2026
|
if (newLen === 0) {
|
|
1991
|
-
if (this.
|
|
2027
|
+
if (this.q !== 0) {
|
|
1992
2028
|
this.S.dispose(false);
|
|
1993
2029
|
this.d = [];
|
|
1994
2030
|
this.D = [];
|
|
1995
2031
|
this.i = [];
|
|
1996
|
-
this.
|
|
1997
|
-
this.
|
|
1998
|
-
this.
|
|
2032
|
+
this.q = 0;
|
|
2033
|
+
this.r && (this.r = []);
|
|
2034
|
+
this.s && (this.s = []);
|
|
1999
2035
|
}
|
|
2000
2036
|
if (this.T && !this.i[0]) {
|
|
2001
2037
|
this.i[0] = compute(
|
|
@@ -2004,7 +2040,7 @@ function updateKeyedMap() {
|
|
|
2004
2040
|
null
|
|
2005
2041
|
);
|
|
2006
2042
|
}
|
|
2007
|
-
} else if (this.
|
|
2043
|
+
} else if (this.q === 0) {
|
|
2008
2044
|
if (this.d[0])
|
|
2009
2045
|
this.d[0].dispose();
|
|
2010
2046
|
this.i = new Array(newLen);
|
|
@@ -2012,37 +2048,37 @@ function updateKeyedMap() {
|
|
|
2012
2048
|
this.D[j] = newItems[j];
|
|
2013
2049
|
this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
|
|
2014
2050
|
}
|
|
2015
|
-
this.
|
|
2051
|
+
this.q = newLen;
|
|
2016
2052
|
} else {
|
|
2017
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
2018
|
-
for (start = 0, end = Math.min(this.
|
|
2019
|
-
if (this.
|
|
2020
|
-
this.
|
|
2053
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.r ? new Array(newLen) : void 0, tempIndexes = this.s ? new Array(newLen) : void 0;
|
|
2054
|
+
for (start = 0, end = Math.min(this.q, newLen); start < end && (this.D[start] === newItems[start] || this.r && compare(this.P, this.D[start], newItems[start])); start++) {
|
|
2055
|
+
if (this.r)
|
|
2056
|
+
this.r[start].write(newItems[start]);
|
|
2021
2057
|
}
|
|
2022
|
-
for (end = this.
|
|
2058
|
+
for (end = this.q - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.D[end] === newItems[newEnd] || this.r && compare(this.P, this.D[end], newItems[newEnd])); end--, newEnd--) {
|
|
2023
2059
|
temp[newEnd] = this.i[end];
|
|
2024
2060
|
tempNodes[newEnd] = this.d[end];
|
|
2025
|
-
tempRows && (tempRows[newEnd] = this.
|
|
2026
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
2061
|
+
tempRows && (tempRows[newEnd] = this.r[end]);
|
|
2062
|
+
tempIndexes && (tempIndexes[newEnd] = this.s[end]);
|
|
2027
2063
|
}
|
|
2028
2064
|
newIndices = /* @__PURE__ */ new Map();
|
|
2029
2065
|
newIndicesNext = new Array(newEnd + 1);
|
|
2030
2066
|
for (j = newEnd; j >= start; j--) {
|
|
2031
2067
|
item = newItems[j];
|
|
2032
|
-
key = this.
|
|
2068
|
+
key = this.P ? this.P(item) : item;
|
|
2033
2069
|
i = newIndices.get(key);
|
|
2034
2070
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
2035
2071
|
newIndices.set(key, j);
|
|
2036
2072
|
}
|
|
2037
2073
|
for (i = start; i <= end; i++) {
|
|
2038
2074
|
item = this.D[i];
|
|
2039
|
-
key = this.
|
|
2075
|
+
key = this.P ? this.P(item) : item;
|
|
2040
2076
|
j = newIndices.get(key);
|
|
2041
2077
|
if (j !== void 0 && j !== -1) {
|
|
2042
2078
|
temp[j] = this.i[i];
|
|
2043
2079
|
tempNodes[j] = this.d[i];
|
|
2044
|
-
tempRows && (tempRows[j] = this.
|
|
2045
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
2080
|
+
tempRows && (tempRows[j] = this.r[i]);
|
|
2081
|
+
tempIndexes && (tempIndexes[j] = this.s[i]);
|
|
2046
2082
|
j = newIndicesNext[j];
|
|
2047
2083
|
newIndices.set(key, j);
|
|
2048
2084
|
} else
|
|
@@ -2053,18 +2089,18 @@ function updateKeyedMap() {
|
|
|
2053
2089
|
this.i[j] = temp[j];
|
|
2054
2090
|
this.d[j] = tempNodes[j];
|
|
2055
2091
|
if (tempRows) {
|
|
2056
|
-
this.
|
|
2057
|
-
this.
|
|
2092
|
+
this.r[j] = tempRows[j];
|
|
2093
|
+
this.r[j].write(newItems[j]);
|
|
2058
2094
|
}
|
|
2059
2095
|
if (tempIndexes) {
|
|
2060
|
-
this.
|
|
2061
|
-
this.
|
|
2096
|
+
this.s[j] = tempIndexes[j];
|
|
2097
|
+
this.s[j].write(j);
|
|
2062
2098
|
}
|
|
2063
2099
|
} else {
|
|
2064
2100
|
this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
|
|
2065
2101
|
}
|
|
2066
2102
|
}
|
|
2067
|
-
this.i = this.i.slice(0, this.
|
|
2103
|
+
this.i = this.i.slice(0, this.q = newLen);
|
|
2068
2104
|
this.D = newItems.slice(0);
|
|
2069
2105
|
}
|
|
2070
2106
|
});
|
|
@@ -2073,26 +2109,26 @@ function updateKeyedMap() {
|
|
|
2073
2109
|
function repeat(count, map, options) {
|
|
2074
2110
|
return updateRepeat.bind({
|
|
2075
2111
|
S: new Owner(),
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2112
|
+
q: 0,
|
|
2113
|
+
z: 0,
|
|
2114
|
+
ja: count,
|
|
2115
|
+
O: map,
|
|
2080
2116
|
d: [],
|
|
2081
2117
|
i: [],
|
|
2082
|
-
|
|
2118
|
+
ka: options?.from,
|
|
2083
2119
|
T: options?.fallback
|
|
2084
2120
|
});
|
|
2085
2121
|
}
|
|
2086
2122
|
function updateRepeat() {
|
|
2087
|
-
const newLen = this.
|
|
2088
|
-
const from = this.
|
|
2123
|
+
const newLen = this.ja();
|
|
2124
|
+
const from = this.ka?.() || 0;
|
|
2089
2125
|
runWithOwner(this.S, () => {
|
|
2090
2126
|
if (newLen === 0) {
|
|
2091
|
-
if (this.
|
|
2127
|
+
if (this.q !== 0) {
|
|
2092
2128
|
this.S.dispose(false);
|
|
2093
2129
|
this.d = [];
|
|
2094
2130
|
this.i = [];
|
|
2095
|
-
this.
|
|
2131
|
+
this.q = 0;
|
|
2096
2132
|
}
|
|
2097
2133
|
if (this.T && !this.i[0]) {
|
|
2098
2134
|
this.i[0] = compute(
|
|
@@ -2104,20 +2140,20 @@ function updateRepeat() {
|
|
|
2104
2140
|
return;
|
|
2105
2141
|
}
|
|
2106
2142
|
const to = from + newLen;
|
|
2107
|
-
const prevTo = this.
|
|
2108
|
-
if (this.
|
|
2143
|
+
const prevTo = this.z + this.q;
|
|
2144
|
+
if (this.q === 0 && this.d[0])
|
|
2109
2145
|
this.d[0].dispose();
|
|
2110
2146
|
for (let i = to; i < prevTo; i++)
|
|
2111
|
-
this.d[i - this.
|
|
2112
|
-
if (this.
|
|
2113
|
-
let i = this.
|
|
2114
|
-
while (i < from && i < this.
|
|
2147
|
+
this.d[i - this.z].dispose();
|
|
2148
|
+
if (this.z < from) {
|
|
2149
|
+
let i = this.z;
|
|
2150
|
+
while (i < from && i < this.q)
|
|
2115
2151
|
this.d[i++].dispose();
|
|
2116
|
-
this.d.splice(0, from - this.
|
|
2117
|
-
this.i.splice(0, from - this.
|
|
2118
|
-
} else if (this.
|
|
2119
|
-
let i = prevTo - this.
|
|
2120
|
-
let difference = this.
|
|
2152
|
+
this.d.splice(0, from - this.z);
|
|
2153
|
+
this.i.splice(0, from - this.z);
|
|
2154
|
+
} else if (this.z > from) {
|
|
2155
|
+
let i = prevTo - this.z - 1;
|
|
2156
|
+
let difference = this.z - from;
|
|
2121
2157
|
this.d.length = this.i.length = newLen;
|
|
2122
2158
|
while (i >= difference) {
|
|
2123
2159
|
this.d[i] = this.d[i - difference];
|
|
@@ -2127,7 +2163,7 @@ function updateRepeat() {
|
|
|
2127
2163
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2128
2164
|
this.i[i2] = compute(
|
|
2129
2165
|
this.d[i2] = new Owner(),
|
|
2130
|
-
() => this.
|
|
2166
|
+
() => this.O(i2 + from),
|
|
2131
2167
|
null
|
|
2132
2168
|
);
|
|
2133
2169
|
}
|
|
@@ -2135,13 +2171,13 @@ function updateRepeat() {
|
|
|
2135
2171
|
for (let i = prevTo; i < to; i++) {
|
|
2136
2172
|
this.i[i - from] = compute(
|
|
2137
2173
|
this.d[i - from] = new Owner(),
|
|
2138
|
-
() => this.
|
|
2174
|
+
() => this.O(i),
|
|
2139
2175
|
null
|
|
2140
2176
|
);
|
|
2141
2177
|
}
|
|
2142
2178
|
this.i = this.i.slice(0, newLen);
|
|
2143
|
-
this.
|
|
2144
|
-
this.
|
|
2179
|
+
this.z = from;
|
|
2180
|
+
this.q = newLen;
|
|
2145
2181
|
});
|
|
2146
2182
|
return this.i;
|
|
2147
2183
|
}
|
|
@@ -2158,17 +2194,17 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2158
2194
|
}
|
|
2159
2195
|
write(value, flags) {
|
|
2160
2196
|
super.write(value, flags & ~this.U);
|
|
2161
|
-
if (this.U & LOADING_BIT && !(this.
|
|
2197
|
+
if (this.U & LOADING_BIT && !(this.h & UNINITIALIZED_BIT)) {
|
|
2162
2198
|
flags &= ~LOADING_BIT;
|
|
2163
2199
|
}
|
|
2164
|
-
this.
|
|
2165
|
-
return this.
|
|
2200
|
+
this.m.notify(this, this.U, flags);
|
|
2201
|
+
return this.l;
|
|
2166
2202
|
}
|
|
2167
2203
|
};
|
|
2168
2204
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2169
|
-
const parentQueue = owner.
|
|
2170
|
-
parentQueue.addChild(owner.
|
|
2171
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2205
|
+
const parentQueue = owner.m;
|
|
2206
|
+
parentQueue.addChild(owner.m = queue);
|
|
2207
|
+
onCleanup(() => parentQueue.removeChild(owner.m));
|
|
2172
2208
|
return compute(
|
|
2173
2209
|
owner,
|
|
2174
2210
|
() => {
|
|
@@ -2179,27 +2215,27 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2179
2215
|
);
|
|
2180
2216
|
}
|
|
2181
2217
|
var ConditionalQueue = class extends Queue {
|
|
2182
|
-
|
|
2218
|
+
u;
|
|
2183
2219
|
V = /* @__PURE__ */ new Set();
|
|
2184
|
-
|
|
2220
|
+
t = /* @__PURE__ */ new Set();
|
|
2185
2221
|
constructor(disabled) {
|
|
2186
2222
|
super();
|
|
2187
|
-
this.
|
|
2223
|
+
this.u = disabled;
|
|
2188
2224
|
}
|
|
2189
2225
|
run(type) {
|
|
2190
|
-
if (!type || this.
|
|
2226
|
+
if (!type || this.u.read())
|
|
2191
2227
|
return;
|
|
2192
2228
|
return super.run(type);
|
|
2193
2229
|
}
|
|
2194
2230
|
notify(node, type, flags) {
|
|
2195
|
-
if (ActiveTransition && ActiveTransition.
|
|
2196
|
-
return ActiveTransition.
|
|
2197
|
-
if (this.
|
|
2231
|
+
if (ActiveTransition && ActiveTransition.p.has(this))
|
|
2232
|
+
return ActiveTransition.p.get(this).notify(node, type, flags);
|
|
2233
|
+
if (this.u.read()) {
|
|
2198
2234
|
if (type & LOADING_BIT) {
|
|
2199
2235
|
if (flags & LOADING_BIT) {
|
|
2200
|
-
this.
|
|
2236
|
+
this.t.add(node);
|
|
2201
2237
|
type &= ~LOADING_BIT;
|
|
2202
|
-
} else if (this.
|
|
2238
|
+
} else if (this.t.delete(node))
|
|
2203
2239
|
type &= ~LOADING_BIT;
|
|
2204
2240
|
}
|
|
2205
2241
|
if (type & ERROR_BIT) {
|
|
@@ -2213,43 +2249,43 @@ var ConditionalQueue = class extends Queue {
|
|
|
2213
2249
|
return type ? super.notify(node, type, flags) : true;
|
|
2214
2250
|
}
|
|
2215
2251
|
merge(queue) {
|
|
2216
|
-
queue.
|
|
2252
|
+
queue.t.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
|
|
2217
2253
|
queue.V.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
|
|
2218
2254
|
super.merge(queue);
|
|
2219
2255
|
}
|
|
2220
2256
|
};
|
|
2221
2257
|
var CollectionQueue = class extends Queue {
|
|
2222
|
-
|
|
2258
|
+
F;
|
|
2223
2259
|
d = /* @__PURE__ */ new Set();
|
|
2224
|
-
|
|
2260
|
+
u = new Computation(false, null, { pureWrite: true });
|
|
2225
2261
|
constructor(type) {
|
|
2226
2262
|
super();
|
|
2227
|
-
this.
|
|
2263
|
+
this.F = type;
|
|
2228
2264
|
}
|
|
2229
2265
|
run(type) {
|
|
2230
|
-
if (!type || this.
|
|
2266
|
+
if (!type || this.u.read())
|
|
2231
2267
|
return;
|
|
2232
2268
|
return super.run(type);
|
|
2233
2269
|
}
|
|
2234
2270
|
notify(node, type, flags) {
|
|
2235
|
-
if (ActiveTransition && ActiveTransition.
|
|
2236
|
-
return ActiveTransition.
|
|
2237
|
-
if (!(type & this.
|
|
2271
|
+
if (ActiveTransition && ActiveTransition.p.has(this))
|
|
2272
|
+
return ActiveTransition.p.get(this).notify(node, type, flags);
|
|
2273
|
+
if (!(type & this.F))
|
|
2238
2274
|
return super.notify(node, type, flags);
|
|
2239
|
-
if (flags & this.
|
|
2275
|
+
if (flags & this.F) {
|
|
2240
2276
|
this.d.add(node);
|
|
2241
2277
|
if (this.d.size === 1)
|
|
2242
|
-
this.
|
|
2243
|
-
} else {
|
|
2278
|
+
this.u.write(true);
|
|
2279
|
+
} else if (this.d.size > 0) {
|
|
2244
2280
|
this.d.delete(node);
|
|
2245
2281
|
if (this.d.size === 0)
|
|
2246
|
-
this.
|
|
2282
|
+
this.u.write(false);
|
|
2247
2283
|
}
|
|
2248
|
-
type &= ~this.
|
|
2284
|
+
type &= ~this.F;
|
|
2249
2285
|
return type ? super.notify(node, type, flags) : true;
|
|
2250
2286
|
}
|
|
2251
2287
|
merge(queue) {
|
|
2252
|
-
queue.d.forEach((n) => this.notify(n, this.
|
|
2288
|
+
queue.d.forEach((n) => this.notify(n, this.F, this.F));
|
|
2253
2289
|
super.merge(queue);
|
|
2254
2290
|
}
|
|
2255
2291
|
};
|
|
@@ -2260,25 +2296,25 @@ function createBoundary(fn, condition) {
|
|
|
2260
2296
|
);
|
|
2261
2297
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2262
2298
|
new EagerComputation(void 0, () => {
|
|
2263
|
-
const disabled = queue.
|
|
2299
|
+
const disabled = queue.u.read();
|
|
2264
2300
|
tree.U = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
2265
2301
|
if (!disabled) {
|
|
2266
|
-
queue.
|
|
2302
|
+
queue.t.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
2267
2303
|
queue.V.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
2268
|
-
queue.
|
|
2304
|
+
queue.t.clear();
|
|
2269
2305
|
queue.V.clear();
|
|
2270
2306
|
}
|
|
2271
2307
|
});
|
|
2272
|
-
return () => queue.
|
|
2308
|
+
return () => queue.u.read() ? void 0 : tree.read();
|
|
2273
2309
|
}
|
|
2274
2310
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2275
2311
|
const owner = new Owner();
|
|
2276
2312
|
const queue = new CollectionQueue(type);
|
|
2277
2313
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2278
2314
|
const decision = new Computation(void 0, () => {
|
|
2279
|
-
if (!queue.
|
|
2315
|
+
if (!queue.u.read()) {
|
|
2280
2316
|
const resolved = tree.read();
|
|
2281
|
-
if (!queue.
|
|
2317
|
+
if (!queue.u.read())
|
|
2282
2318
|
return resolved;
|
|
2283
2319
|
}
|
|
2284
2320
|
return fallback(queue);
|
|
@@ -2290,15 +2326,14 @@ function createSuspense(fn, fallback) {
|
|
|
2290
2326
|
}
|
|
2291
2327
|
function createErrorBoundary(fn, fallback) {
|
|
2292
2328
|
return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
|
|
2293
|
-
let node = queue.d.values().next().value;
|
|
2294
|
-
|
|
2295
|
-
return fallback(node.L, () => {
|
|
2329
|
+
let node = getTransitionSource(queue.d.values().next().value);
|
|
2330
|
+
return fallback(node.J, () => {
|
|
2296
2331
|
incrementClock();
|
|
2297
2332
|
for (let node2 of queue.d) {
|
|
2298
|
-
if (ActiveTransition && !node2.
|
|
2333
|
+
if (ActiveTransition && !node2.e)
|
|
2299
2334
|
node2 = cloneGraph(node2);
|
|
2300
2335
|
node2.c = STATE_DIRTY;
|
|
2301
|
-
node2.
|
|
2336
|
+
node2.m?.enqueue(node2.B, node2.C.bind(node2));
|
|
2302
2337
|
}
|
|
2303
2338
|
});
|
|
2304
2339
|
});
|