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