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