@solidjs/signals 0.3.0 → 0.3.1
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 +126 -111
- package/dist/node.cjs +297 -283
- package/dist/prod.js +296 -281
- package/dist/types/core/boundaries.d.ts +11 -5
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/owner.d.ts +0 -5
- package/dist/types/core/scheduler.d.ts +4 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -45,11 +45,12 @@ function schedule() {
|
|
|
45
45
|
if (scheduled)
|
|
46
46
|
return;
|
|
47
47
|
scheduled = true;
|
|
48
|
-
if (!globalQueue.
|
|
48
|
+
if (!globalQueue.K)
|
|
49
49
|
queueMicrotask(flushSync);
|
|
50
50
|
}
|
|
51
51
|
var Queue = class {
|
|
52
|
-
|
|
52
|
+
n = null;
|
|
53
|
+
K = false;
|
|
53
54
|
s = [[], [], []];
|
|
54
55
|
F = [];
|
|
55
56
|
created = clock;
|
|
@@ -78,9 +79,9 @@ var Queue = class {
|
|
|
78
79
|
return rerun || !!this.s[type].length;
|
|
79
80
|
}
|
|
80
81
|
flush() {
|
|
81
|
-
if (this.
|
|
82
|
+
if (this.K)
|
|
82
83
|
return;
|
|
83
|
-
this.
|
|
84
|
+
this.K = true;
|
|
84
85
|
try {
|
|
85
86
|
while (this.run(EFFECT_PURE)) {
|
|
86
87
|
}
|
|
@@ -89,17 +90,23 @@ var Queue = class {
|
|
|
89
90
|
this.run(EFFECT_RENDER);
|
|
90
91
|
this.run(EFFECT_USER);
|
|
91
92
|
} finally {
|
|
92
|
-
this.
|
|
93
|
+
this.K = false;
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
addChild(child) {
|
|
96
97
|
this.F.push(child);
|
|
98
|
+
child.n = this;
|
|
97
99
|
}
|
|
98
100
|
removeChild(child) {
|
|
99
101
|
const index = this.F.indexOf(child);
|
|
100
102
|
if (index >= 0)
|
|
101
103
|
this.F.splice(index, 1);
|
|
102
104
|
}
|
|
105
|
+
notify(...args) {
|
|
106
|
+
if (this.n)
|
|
107
|
+
return this.n.notify(...args);
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
103
110
|
};
|
|
104
111
|
var globalQueue = new Queue();
|
|
105
112
|
function flushSync() {
|
|
@@ -109,14 +116,14 @@ function flushSync() {
|
|
|
109
116
|
}
|
|
110
117
|
function runTop(node) {
|
|
111
118
|
const ancestors = [];
|
|
112
|
-
for (let current = node; current !== null; current = current.
|
|
119
|
+
for (let current = node; current !== null; current = current.n) {
|
|
113
120
|
if (current.a !== STATE_CLEAN) {
|
|
114
121
|
ancestors.push(current);
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
124
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
118
125
|
if (ancestors[i].a !== STATE_DISPOSED)
|
|
119
|
-
ancestors[i].
|
|
126
|
+
ancestors[i].x();
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
129
|
function runPureQueue(queue) {
|
|
@@ -127,7 +134,7 @@ function runPureQueue(queue) {
|
|
|
127
134
|
}
|
|
128
135
|
function runEffectQueue(queue) {
|
|
129
136
|
for (let i = 0; i < queue.length; i++)
|
|
130
|
-
queue[i].
|
|
137
|
+
queue[i].V();
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
// src/core/utils.ts
|
|
@@ -174,104 +181,80 @@ var Owner = class {
|
|
|
174
181
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
175
182
|
// However, the children are actually added in reverse creation order
|
|
176
183
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
177
|
-
|
|
178
|
-
|
|
184
|
+
n = null;
|
|
185
|
+
m = null;
|
|
179
186
|
t = null;
|
|
180
187
|
a = STATE_CLEAN;
|
|
181
|
-
|
|
188
|
+
l = null;
|
|
182
189
|
o = defaultContext;
|
|
183
|
-
n = null;
|
|
184
190
|
h = globalQueue;
|
|
185
|
-
|
|
186
|
-
X = 0;
|
|
191
|
+
W = 0;
|
|
187
192
|
id = null;
|
|
188
193
|
constructor(id = null, skipAppend = false) {
|
|
189
194
|
this.id = id;
|
|
190
|
-
if (currentOwner
|
|
191
|
-
currentOwner.
|
|
195
|
+
if (currentOwner) {
|
|
196
|
+
if (!id && currentOwner.id)
|
|
197
|
+
this.id = currentOwner.getNextChildId();
|
|
198
|
+
!skipAppend && currentOwner.append(this);
|
|
199
|
+
}
|
|
192
200
|
}
|
|
193
201
|
append(child) {
|
|
194
|
-
child.
|
|
202
|
+
child.n = this;
|
|
195
203
|
child.t = this;
|
|
196
|
-
if (this.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (this.l)
|
|
201
|
-
this.l.t = child;
|
|
202
|
-
child.l = this.l;
|
|
203
|
-
this.l = child;
|
|
204
|
+
if (this.m)
|
|
205
|
+
this.m.t = child;
|
|
206
|
+
child.m = this.m;
|
|
207
|
+
this.m = child;
|
|
204
208
|
if (child.o !== this.o) {
|
|
205
209
|
child.o = { ...this.o, ...child.o };
|
|
206
210
|
}
|
|
207
|
-
if (this.n) {
|
|
208
|
-
child.n = !child.n ? this.n : [...child.n, ...this.n];
|
|
209
|
-
}
|
|
210
211
|
if (this.h)
|
|
211
212
|
child.h = this.h;
|
|
212
213
|
}
|
|
213
214
|
dispose(self = true) {
|
|
214
215
|
if (this.a === STATE_DISPOSED)
|
|
215
216
|
return;
|
|
216
|
-
let head = self ? this.t || this.
|
|
217
|
-
while (current && current.
|
|
217
|
+
let head = self ? this.t || this.n : this, current = this.m, next = null;
|
|
218
|
+
while (current && current.n === this) {
|
|
218
219
|
current.dispose(true);
|
|
219
|
-
current.
|
|
220
|
-
next = current.
|
|
221
|
-
current.
|
|
220
|
+
current.y();
|
|
221
|
+
next = current.m;
|
|
222
|
+
current.m = null;
|
|
222
223
|
current = next;
|
|
223
224
|
}
|
|
225
|
+
this.W = 0;
|
|
224
226
|
if (self)
|
|
225
|
-
this.
|
|
227
|
+
this.y();
|
|
226
228
|
if (current)
|
|
227
229
|
current.t = !self ? this : this.t;
|
|
228
230
|
if (head)
|
|
229
|
-
head.
|
|
231
|
+
head.m = current;
|
|
230
232
|
}
|
|
231
|
-
|
|
233
|
+
y() {
|
|
232
234
|
if (this.t)
|
|
233
|
-
this.t.
|
|
234
|
-
this.
|
|
235
|
+
this.t.m = null;
|
|
236
|
+
this.n = null;
|
|
235
237
|
this.t = null;
|
|
236
238
|
this.o = defaultContext;
|
|
237
|
-
this.n = null;
|
|
238
239
|
this.a = STATE_DISPOSED;
|
|
239
240
|
this.emptyDisposal();
|
|
240
241
|
}
|
|
241
242
|
emptyDisposal() {
|
|
242
|
-
if (!this.
|
|
243
|
+
if (!this.l)
|
|
243
244
|
return;
|
|
244
|
-
if (Array.isArray(this.
|
|
245
|
-
for (let i = 0; i < this.
|
|
246
|
-
const callable = this.
|
|
245
|
+
if (Array.isArray(this.l)) {
|
|
246
|
+
for (let i = 0; i < this.l.length; i++) {
|
|
247
|
+
const callable = this.l[i];
|
|
247
248
|
callable.call(callable);
|
|
248
249
|
}
|
|
249
250
|
} else {
|
|
250
|
-
this.
|
|
251
|
+
this.l.call(this.l);
|
|
251
252
|
}
|
|
252
|
-
this.
|
|
253
|
-
}
|
|
254
|
-
addErrorHandler(handler) {
|
|
255
|
-
this.n = this.n ? [handler, ...this.n] : [handler];
|
|
256
|
-
}
|
|
257
|
-
handleError(error) {
|
|
258
|
-
if (!this.n)
|
|
259
|
-
throw error;
|
|
260
|
-
let i = 0, len = this.n.length;
|
|
261
|
-
for (i = 0; i < len; i++) {
|
|
262
|
-
try {
|
|
263
|
-
this.n[i](error, this);
|
|
264
|
-
break;
|
|
265
|
-
} catch (e) {
|
|
266
|
-
error = e;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
if (i === len)
|
|
270
|
-
throw error;
|
|
253
|
+
this.l = null;
|
|
271
254
|
}
|
|
272
255
|
getNextChildId() {
|
|
273
256
|
if (this.id)
|
|
274
|
-
return formatId(this.id
|
|
257
|
+
return formatId(this.id, this.W++);
|
|
275
258
|
throw new Error("Cannot get child id from owner without an id");
|
|
276
259
|
}
|
|
277
260
|
};
|
|
@@ -304,12 +287,12 @@ function onCleanup(fn) {
|
|
|
304
287
|
if (!currentOwner)
|
|
305
288
|
return fn;
|
|
306
289
|
const node = currentOwner;
|
|
307
|
-
if (!node.
|
|
308
|
-
node.
|
|
309
|
-
} else if (Array.isArray(node.
|
|
310
|
-
node.
|
|
290
|
+
if (!node.l) {
|
|
291
|
+
node.l = fn;
|
|
292
|
+
} else if (Array.isArray(node.l)) {
|
|
293
|
+
node.l.push(fn);
|
|
311
294
|
} else {
|
|
312
|
-
node.
|
|
295
|
+
node.l = [node.l, fn];
|
|
313
296
|
}
|
|
314
297
|
return fn;
|
|
315
298
|
}
|
|
@@ -338,43 +321,43 @@ function getObserver() {
|
|
|
338
321
|
var UNCHANGED = Symbol(0);
|
|
339
322
|
var Computation = class extends Owner {
|
|
340
323
|
c = null;
|
|
341
|
-
|
|
324
|
+
e = null;
|
|
342
325
|
g;
|
|
343
326
|
G;
|
|
344
|
-
|
|
327
|
+
z;
|
|
345
328
|
// Used in __DEV__ mode, hopefully removed in production
|
|
346
|
-
|
|
329
|
+
ba;
|
|
347
330
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
348
331
|
// which could enable more efficient DIRTY notification
|
|
349
|
-
|
|
350
|
-
|
|
332
|
+
S = isEqual;
|
|
333
|
+
X;
|
|
351
334
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
352
|
-
|
|
335
|
+
f = 0;
|
|
353
336
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
337
|
+
T = DEFAULT_FLAGS;
|
|
338
|
+
A = -1;
|
|
339
|
+
B = false;
|
|
357
340
|
constructor(initialValue, compute2, options) {
|
|
358
341
|
super(null, compute2 === null);
|
|
359
|
-
this.
|
|
342
|
+
this.z = compute2;
|
|
360
343
|
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
361
|
-
this.
|
|
344
|
+
this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
362
345
|
this.g = initialValue;
|
|
363
346
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
364
|
-
this.
|
|
347
|
+
this.S = options.equals;
|
|
365
348
|
if (options == null ? void 0 : options.unobserved)
|
|
366
|
-
this.
|
|
349
|
+
this.X = options == null ? void 0 : options.unobserved;
|
|
367
350
|
}
|
|
368
|
-
|
|
369
|
-
if (this.
|
|
370
|
-
if (this.
|
|
351
|
+
Y() {
|
|
352
|
+
if (this.z) {
|
|
353
|
+
if (this.f & ERROR_BIT && this.A <= getClock())
|
|
371
354
|
update(this);
|
|
372
355
|
else
|
|
373
|
-
this.
|
|
356
|
+
this.x();
|
|
374
357
|
}
|
|
375
358
|
track(this);
|
|
376
|
-
newFlags |= this.
|
|
377
|
-
if (this.
|
|
359
|
+
newFlags |= this.f & ~currentMask;
|
|
360
|
+
if (this.f & ERROR_BIT) {
|
|
378
361
|
throw this.G;
|
|
379
362
|
} else {
|
|
380
363
|
return this.g;
|
|
@@ -385,7 +368,7 @@ var Computation = class extends Owner {
|
|
|
385
368
|
* Automatically re-executes the surrounding computation when the value changes
|
|
386
369
|
*/
|
|
387
370
|
read() {
|
|
388
|
-
return this.
|
|
371
|
+
return this.Y();
|
|
389
372
|
}
|
|
390
373
|
/**
|
|
391
374
|
* Return the current value of this computation
|
|
@@ -395,37 +378,37 @@ var Computation = class extends Owner {
|
|
|
395
378
|
* before continuing
|
|
396
379
|
*/
|
|
397
380
|
wait() {
|
|
398
|
-
if (this.
|
|
381
|
+
if (this.z && this.f & ERROR_BIT && this.A <= getClock()) {
|
|
399
382
|
update(this);
|
|
400
383
|
} else {
|
|
401
|
-
this.
|
|
384
|
+
this.x();
|
|
402
385
|
}
|
|
403
386
|
track(this);
|
|
404
|
-
if ((notStale || this.
|
|
387
|
+
if ((notStale || this.f & UNINITIALIZED_BIT) && this.f & LOADING_BIT) {
|
|
405
388
|
throw new NotReadyError();
|
|
406
389
|
}
|
|
407
|
-
if (staleCheck && this.
|
|
390
|
+
if (staleCheck && this.f & LOADING_BIT) {
|
|
408
391
|
staleCheck.g = true;
|
|
409
392
|
}
|
|
410
|
-
return this.
|
|
393
|
+
return this.Y();
|
|
411
394
|
}
|
|
412
395
|
/** Update the computation with a new value. */
|
|
413
396
|
write(value, flags = 0, raw = false) {
|
|
414
397
|
const newValue = !raw && typeof value === "function" ? value(this.g) : value;
|
|
415
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
398
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || this.f & LOADING_BIT & ~flags || this.S === false || !this.S(this.g, newValue));
|
|
416
399
|
if (valueChanged) {
|
|
417
400
|
this.g = newValue;
|
|
418
401
|
this.G = void 0;
|
|
419
402
|
}
|
|
420
|
-
const changedFlagsMask = this.
|
|
421
|
-
this.
|
|
422
|
-
this.
|
|
423
|
-
if (this.
|
|
424
|
-
for (let i = 0; i < this.
|
|
403
|
+
const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
|
|
404
|
+
this.f = flags;
|
|
405
|
+
this.A = getClock() + 1;
|
|
406
|
+
if (this.e) {
|
|
407
|
+
for (let i = 0; i < this.e.length; i++) {
|
|
425
408
|
if (valueChanged) {
|
|
426
|
-
this.
|
|
409
|
+
this.e[i].r(STATE_DIRTY);
|
|
427
410
|
} else if (changedFlagsMask) {
|
|
428
|
-
this.
|
|
411
|
+
this.e[i].Z(changedFlagsMask, changedFlags);
|
|
429
412
|
}
|
|
430
413
|
}
|
|
431
414
|
}
|
|
@@ -435,13 +418,13 @@ var Computation = class extends Owner {
|
|
|
435
418
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
436
419
|
*/
|
|
437
420
|
r(state, skipQueue) {
|
|
438
|
-
if (this.a >= state && !this.
|
|
421
|
+
if (this.a >= state && !this.B)
|
|
439
422
|
return;
|
|
440
|
-
this.
|
|
423
|
+
this.B = !!skipQueue;
|
|
441
424
|
this.a = state;
|
|
442
|
-
if (this.
|
|
443
|
-
for (let i = 0; i < this.
|
|
444
|
-
this.
|
|
425
|
+
if (this.e) {
|
|
426
|
+
for (let i = 0; i < this.e.length; i++) {
|
|
427
|
+
this.e[i].r(STATE_CHECK, skipQueue);
|
|
445
428
|
}
|
|
446
429
|
}
|
|
447
430
|
}
|
|
@@ -451,31 +434,31 @@ var Computation = class extends Owner {
|
|
|
451
434
|
* @param mask A bitmask for which flag(s) were changed.
|
|
452
435
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
453
436
|
*/
|
|
454
|
-
|
|
437
|
+
Z(mask, newFlags2) {
|
|
455
438
|
if (this.a >= STATE_DIRTY)
|
|
456
439
|
return;
|
|
457
|
-
if (mask & this.
|
|
440
|
+
if (mask & this.T) {
|
|
458
441
|
this.r(STATE_DIRTY);
|
|
459
442
|
return;
|
|
460
443
|
}
|
|
461
444
|
if (this.a >= STATE_CHECK)
|
|
462
445
|
return;
|
|
463
|
-
const prevFlags = this.
|
|
446
|
+
const prevFlags = this.f & mask;
|
|
464
447
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
465
448
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
466
449
|
this.r(STATE_CHECK);
|
|
467
450
|
} else {
|
|
468
|
-
this.
|
|
469
|
-
if (this.
|
|
470
|
-
for (let i = 0; i < this.
|
|
471
|
-
this.
|
|
451
|
+
this.f ^= deltaFlags;
|
|
452
|
+
if (this.e) {
|
|
453
|
+
for (let i = 0; i < this.e.length; i++) {
|
|
454
|
+
this.e[i].Z(mask, newFlags2);
|
|
472
455
|
}
|
|
473
456
|
}
|
|
474
457
|
}
|
|
475
458
|
}
|
|
476
|
-
|
|
459
|
+
L(error) {
|
|
477
460
|
this.G = error;
|
|
478
|
-
this.write(UNCHANGED, this.
|
|
461
|
+
this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
479
462
|
}
|
|
480
463
|
/**
|
|
481
464
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -484,8 +467,8 @@ var Computation = class extends Owner {
|
|
|
484
467
|
*
|
|
485
468
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
486
469
|
*/
|
|
487
|
-
|
|
488
|
-
if (!this.
|
|
470
|
+
x() {
|
|
471
|
+
if (!this.z) {
|
|
489
472
|
return;
|
|
490
473
|
}
|
|
491
474
|
if (this.a === STATE_DISPOSED) {
|
|
@@ -497,8 +480,8 @@ var Computation = class extends Owner {
|
|
|
497
480
|
let observerFlags = 0;
|
|
498
481
|
if (this.a === STATE_CHECK) {
|
|
499
482
|
for (let i = 0; i < this.c.length; i++) {
|
|
500
|
-
this.c[i].
|
|
501
|
-
observerFlags |= this.c[i].
|
|
483
|
+
this.c[i].x();
|
|
484
|
+
observerFlags |= this.c[i].f;
|
|
502
485
|
if (this.a === STATE_DIRTY) {
|
|
503
486
|
break;
|
|
504
487
|
}
|
|
@@ -514,12 +497,12 @@ var Computation = class extends Owner {
|
|
|
514
497
|
/**
|
|
515
498
|
* Remove ourselves from the owner graph and the computation graph
|
|
516
499
|
*/
|
|
517
|
-
|
|
500
|
+
y() {
|
|
518
501
|
if (this.a === STATE_DISPOSED)
|
|
519
502
|
return;
|
|
520
503
|
if (this.c)
|
|
521
504
|
removeSourceObservers(this, 0);
|
|
522
|
-
super.
|
|
505
|
+
super.y();
|
|
523
506
|
}
|
|
524
507
|
};
|
|
525
508
|
function track(computation) {
|
|
@@ -532,7 +515,7 @@ function track(computation) {
|
|
|
532
515
|
newSources.push(computation);
|
|
533
516
|
}
|
|
534
517
|
if (updateCheck) {
|
|
535
|
-
updateCheck.g = computation.
|
|
518
|
+
updateCheck.g = computation.A > currentObserver.A;
|
|
536
519
|
}
|
|
537
520
|
}
|
|
538
521
|
}
|
|
@@ -544,13 +527,13 @@ function update(node) {
|
|
|
544
527
|
try {
|
|
545
528
|
node.dispose(false);
|
|
546
529
|
node.emptyDisposal();
|
|
547
|
-
const result = compute(node, node.
|
|
530
|
+
const result = compute(node, node.z, node);
|
|
548
531
|
node.write(result, newFlags, true);
|
|
549
532
|
} catch (error) {
|
|
550
533
|
if (error instanceof NotReadyError) {
|
|
551
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
534
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
|
|
552
535
|
} else {
|
|
553
|
-
node.
|
|
536
|
+
node.L(error);
|
|
554
537
|
}
|
|
555
538
|
} finally {
|
|
556
539
|
if (newSources) {
|
|
@@ -567,10 +550,10 @@ function update(node) {
|
|
|
567
550
|
let source;
|
|
568
551
|
for (let i = newSourcesIndex; i < node.c.length; i++) {
|
|
569
552
|
source = node.c[i];
|
|
570
|
-
if (!source.
|
|
571
|
-
source.
|
|
553
|
+
if (!source.e)
|
|
554
|
+
source.e = [node];
|
|
572
555
|
else
|
|
573
|
-
source.
|
|
556
|
+
source.e.push(node);
|
|
574
557
|
}
|
|
575
558
|
} else if (node.c && newSourcesIndex < node.c.length) {
|
|
576
559
|
removeSourceObservers(node, newSourcesIndex);
|
|
@@ -579,7 +562,7 @@ function update(node) {
|
|
|
579
562
|
newSources = prevSources;
|
|
580
563
|
newSourcesIndex = prevSourcesIndex;
|
|
581
564
|
newFlags = prevFlags;
|
|
582
|
-
node.
|
|
565
|
+
node.A = getClock() + 1;
|
|
583
566
|
node.a = STATE_CLEAN;
|
|
584
567
|
}
|
|
585
568
|
}
|
|
@@ -589,12 +572,12 @@ function removeSourceObservers(node, index) {
|
|
|
589
572
|
let swap;
|
|
590
573
|
for (let i = index; i < node.c.length; i++) {
|
|
591
574
|
source = node.c[i];
|
|
592
|
-
if (source.
|
|
593
|
-
swap = source.
|
|
594
|
-
source.
|
|
595
|
-
source.
|
|
596
|
-
if (!source.
|
|
597
|
-
(_a = source.
|
|
575
|
+
if (source.e) {
|
|
576
|
+
swap = source.e.indexOf(node);
|
|
577
|
+
source.e[swap] = source.e[source.e.length - 1];
|
|
578
|
+
source.e.pop();
|
|
579
|
+
if (!source.e.length)
|
|
580
|
+
(_a = source.X) == null ? void 0 : _a.call(source);
|
|
598
581
|
}
|
|
599
582
|
}
|
|
600
583
|
}
|
|
@@ -636,7 +619,7 @@ function isPending(fn, loadingValue) {
|
|
|
636
619
|
if (!currentObserver)
|
|
637
620
|
return pendingCheck(fn, loadingValue);
|
|
638
621
|
const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
|
|
639
|
-
c.
|
|
622
|
+
c.T |= LOADING_BIT;
|
|
640
623
|
return c.read();
|
|
641
624
|
}
|
|
642
625
|
function latest(fn, fallback) {
|
|
@@ -666,10 +649,10 @@ function runWithObserver(observer, run) {
|
|
|
666
649
|
if (error instanceof NotReadyError) {
|
|
667
650
|
observer.write(
|
|
668
651
|
UNCHANGED,
|
|
669
|
-
newFlags | LOADING_BIT | observer.
|
|
652
|
+
newFlags | LOADING_BIT | observer.f & UNINITIALIZED_BIT
|
|
670
653
|
);
|
|
671
654
|
} else {
|
|
672
|
-
observer.
|
|
655
|
+
observer.L(error);
|
|
673
656
|
}
|
|
674
657
|
} finally {
|
|
675
658
|
if (newSources) {
|
|
@@ -684,10 +667,10 @@ function runWithObserver(observer, run) {
|
|
|
684
667
|
let source;
|
|
685
668
|
for (let i = newSourcesIndex; i < observer.c.length; i++) {
|
|
686
669
|
source = observer.c[i];
|
|
687
|
-
if (!source.
|
|
688
|
-
source.
|
|
670
|
+
if (!source.e)
|
|
671
|
+
source.e = [observer];
|
|
689
672
|
else
|
|
690
|
-
source.
|
|
673
|
+
source.e.push(observer);
|
|
691
674
|
}
|
|
692
675
|
}
|
|
693
676
|
newSources = prevSources;
|
|
@@ -698,7 +681,7 @@ function runWithObserver(observer, run) {
|
|
|
698
681
|
function compute(owner, fn, observer) {
|
|
699
682
|
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
700
683
|
currentObserver = observer;
|
|
701
|
-
currentMask = (observer == null ? void 0 : observer.
|
|
684
|
+
currentMask = (observer == null ? void 0 : observer.T) ?? DEFAULT_FLAGS;
|
|
702
685
|
notStale = true;
|
|
703
686
|
try {
|
|
704
687
|
return fn(observer ? observer.g : void 0);
|
|
@@ -774,37 +757,36 @@ function flattenArray(children, results = [], options) {
|
|
|
774
757
|
|
|
775
758
|
// src/core/effect.ts
|
|
776
759
|
var Effect = class extends Computation {
|
|
777
|
-
L;
|
|
778
760
|
M;
|
|
779
|
-
C;
|
|
780
|
-
R = false;
|
|
781
761
|
N;
|
|
762
|
+
C;
|
|
763
|
+
U = false;
|
|
764
|
+
O;
|
|
782
765
|
u;
|
|
783
766
|
constructor(initialValue, compute2, effect, error, options) {
|
|
784
767
|
super(initialValue, compute2, options);
|
|
785
|
-
this.
|
|
786
|
-
this.
|
|
787
|
-
this.
|
|
768
|
+
this.M = effect;
|
|
769
|
+
this.N = error;
|
|
770
|
+
this.O = initialValue;
|
|
788
771
|
this.u = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
789
772
|
if (this.u === EFFECT_RENDER) {
|
|
790
|
-
this.
|
|
773
|
+
this.z = (p) => getClock() > this.h.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
791
774
|
}
|
|
792
|
-
this.
|
|
793
|
-
!(options == null ? void 0 : options.defer) && (this.u === EFFECT_USER ? this.h.enqueue(this.u, this) : this.
|
|
775
|
+
this.x();
|
|
776
|
+
!(options == null ? void 0 : options.defer) && (this.u === EFFECT_USER ? this.h.enqueue(this.u, this) : this.V());
|
|
794
777
|
}
|
|
795
778
|
write(value, flags = 0) {
|
|
796
|
-
var _a, _b;
|
|
797
779
|
if (this.a == STATE_DIRTY) {
|
|
798
|
-
|
|
799
|
-
this.
|
|
800
|
-
if (this.u === EFFECT_RENDER
|
|
801
|
-
|
|
780
|
+
this.f;
|
|
781
|
+
this.f = flags;
|
|
782
|
+
if (this.u === EFFECT_RENDER) {
|
|
783
|
+
this.h.notify(this, LOADING_BIT | ERROR_BIT, flags);
|
|
802
784
|
}
|
|
803
785
|
}
|
|
804
786
|
if (value === UNCHANGED)
|
|
805
787
|
return this.g;
|
|
806
788
|
this.g = value;
|
|
807
|
-
this.
|
|
789
|
+
this.U = true;
|
|
808
790
|
return value;
|
|
809
791
|
}
|
|
810
792
|
r(state, skipQueue) {
|
|
@@ -814,44 +796,45 @@ var Effect = class extends Computation {
|
|
|
814
796
|
this.h.enqueue(this.u, this);
|
|
815
797
|
this.a = state;
|
|
816
798
|
}
|
|
817
|
-
|
|
818
|
-
var _a
|
|
799
|
+
L(error) {
|
|
800
|
+
var _a;
|
|
801
|
+
this.G = error;
|
|
819
802
|
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
this.d = ERROR_BIT;
|
|
803
|
+
this.h.notify(this, LOADING_BIT, 0);
|
|
804
|
+
this.f = ERROR_BIT;
|
|
824
805
|
if (this.u === EFFECT_USER) {
|
|
825
806
|
try {
|
|
826
|
-
return this.
|
|
807
|
+
return this.N ? this.C = this.N(error) : console.error(new EffectError(this.M, error));
|
|
827
808
|
} catch (e) {
|
|
828
809
|
error = e;
|
|
829
810
|
}
|
|
830
811
|
}
|
|
831
|
-
this.
|
|
812
|
+
if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
|
|
813
|
+
throw error;
|
|
832
814
|
}
|
|
833
|
-
|
|
815
|
+
y() {
|
|
834
816
|
var _a;
|
|
835
817
|
if (this.a === STATE_DISPOSED)
|
|
836
818
|
return;
|
|
837
|
-
this.L = void 0;
|
|
838
|
-
this.N = void 0;
|
|
839
819
|
this.M = void 0;
|
|
820
|
+
this.O = void 0;
|
|
821
|
+
this.N = void 0;
|
|
840
822
|
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
841
823
|
this.C = void 0;
|
|
842
|
-
super.
|
|
824
|
+
super.y();
|
|
843
825
|
}
|
|
844
|
-
|
|
826
|
+
V() {
|
|
845
827
|
var _a;
|
|
846
|
-
if (this.
|
|
828
|
+
if (this.U && this.a !== STATE_DISPOSED) {
|
|
847
829
|
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
848
830
|
try {
|
|
849
|
-
this.C = this.
|
|
831
|
+
this.C = this.M(this.g, this.O);
|
|
850
832
|
} catch (e) {
|
|
851
|
-
this.
|
|
833
|
+
if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
|
|
834
|
+
throw e;
|
|
852
835
|
} finally {
|
|
853
|
-
this.
|
|
854
|
-
this.
|
|
836
|
+
this.O = this.g;
|
|
837
|
+
this.U = false;
|
|
855
838
|
}
|
|
856
839
|
}
|
|
857
840
|
}
|
|
@@ -859,10 +842,10 @@ var Effect = class extends Computation {
|
|
|
859
842
|
var EagerComputation = class extends Computation {
|
|
860
843
|
constructor(initialValue, compute2, options) {
|
|
861
844
|
super(initialValue, compute2, options);
|
|
862
|
-
!(options == null ? void 0 : options.defer) && this.
|
|
845
|
+
!(options == null ? void 0 : options.defer) && this.x();
|
|
863
846
|
}
|
|
864
847
|
r(state, skipQueue) {
|
|
865
|
-
if (this.a >= state && !this.
|
|
848
|
+
if (this.a >= state && !this.B)
|
|
866
849
|
return;
|
|
867
850
|
if (this.a === STATE_CLEAN && !skipQueue)
|
|
868
851
|
this.h.enqueue(EFFECT_PURE, this);
|
|
@@ -874,51 +857,82 @@ var ProjectionComputation = class extends Computation {
|
|
|
874
857
|
super(void 0, compute2);
|
|
875
858
|
}
|
|
876
859
|
r(state, skipQueue) {
|
|
877
|
-
if (this.a >= state && !this.
|
|
860
|
+
if (this.a >= state && !this.B)
|
|
878
861
|
return;
|
|
879
|
-
if (this.a === STATE_CLEAN &&
|
|
862
|
+
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.B))
|
|
880
863
|
this.h.enqueue(EFFECT_PURE, this);
|
|
881
864
|
super.r(state, true);
|
|
865
|
+
this.B = !!skipQueue;
|
|
882
866
|
}
|
|
883
867
|
};
|
|
884
868
|
|
|
885
869
|
// src/core/boundaries.ts
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
870
|
+
var BoundaryComputation = class extends EagerComputation {
|
|
871
|
+
H;
|
|
872
|
+
constructor(compute2, propagationMask) {
|
|
873
|
+
super(void 0, compute2, { defer: true });
|
|
874
|
+
this.H = propagationMask;
|
|
875
|
+
}
|
|
876
|
+
write(value, flags) {
|
|
877
|
+
super.write(value, flags & ~this.H);
|
|
878
|
+
if (this.H & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
|
|
879
|
+
flags &= ~LOADING_BIT;
|
|
880
|
+
}
|
|
881
|
+
this.h.notify(this, this.H, flags);
|
|
882
|
+
return this.g;
|
|
891
883
|
}
|
|
884
|
+
};
|
|
885
|
+
function createBoundChildren(owner, fn, queue, mask) {
|
|
886
|
+
const parentQueue = owner.h;
|
|
887
|
+
parentQueue.addChild(owner.h = queue);
|
|
888
|
+
onCleanup(() => parentQueue.removeChild(owner.h));
|
|
892
889
|
return compute(
|
|
893
890
|
owner,
|
|
894
891
|
() => {
|
|
895
892
|
const c = new Computation(void 0, fn);
|
|
896
|
-
return new
|
|
893
|
+
return new BoundaryComputation(() => flatten(c.wait()), mask);
|
|
897
894
|
},
|
|
898
895
|
null
|
|
899
896
|
);
|
|
900
897
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
});
|
|
910
|
-
return decision.read.bind(decision);
|
|
911
|
-
}
|
|
912
|
-
var SuspenseQueue = class extends Queue {
|
|
913
|
-
b = /* @__PURE__ */ new Set();
|
|
914
|
-
p = new Computation(false, null);
|
|
898
|
+
var ConditionalQueue = class extends Queue {
|
|
899
|
+
p;
|
|
900
|
+
P = /* @__PURE__ */ new Set();
|
|
901
|
+
Q = /* @__PURE__ */ new Set();
|
|
902
|
+
constructor(disabled) {
|
|
903
|
+
super();
|
|
904
|
+
this.p = disabled;
|
|
905
|
+
}
|
|
915
906
|
run(type) {
|
|
916
907
|
if (type && this.p.read())
|
|
917
908
|
return;
|
|
918
909
|
return super.run(type);
|
|
919
910
|
}
|
|
920
|
-
|
|
921
|
-
if (
|
|
911
|
+
notify(node, type, flags) {
|
|
912
|
+
if (this.p.read()) {
|
|
913
|
+
if (type === LOADING_BIT) {
|
|
914
|
+
flags & LOADING_BIT ? this.Q.add(node) : this.Q.delete(node);
|
|
915
|
+
}
|
|
916
|
+
if (type === ERROR_BIT) {
|
|
917
|
+
flags & ERROR_BIT ? this.P.add(node) : this.P.delete(node);
|
|
918
|
+
}
|
|
919
|
+
return true;
|
|
920
|
+
}
|
|
921
|
+
return super.notify(node, type, flags);
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
var CollectionQueue = class extends Queue {
|
|
925
|
+
R;
|
|
926
|
+
b = /* @__PURE__ */ new Set();
|
|
927
|
+
p = new Computation(false, null);
|
|
928
|
+
constructor(type) {
|
|
929
|
+
super();
|
|
930
|
+
this.R = type;
|
|
931
|
+
}
|
|
932
|
+
notify(node, type, flags) {
|
|
933
|
+
if (!(type & this.R))
|
|
934
|
+
return super.notify(node, type, flags);
|
|
935
|
+
if (flags & this.R) {
|
|
922
936
|
this.b.add(node);
|
|
923
937
|
if (this.b.size === 1)
|
|
924
938
|
this.p.write(true);
|
|
@@ -927,55 +941,51 @@ var SuspenseQueue = class extends Queue {
|
|
|
927
941
|
if (this.b.size === 0)
|
|
928
942
|
this.p.write(false);
|
|
929
943
|
}
|
|
944
|
+
type &= ~this.R;
|
|
945
|
+
return type ? super.notify(node, type, flags) : true;
|
|
930
946
|
}
|
|
931
947
|
};
|
|
932
|
-
function
|
|
948
|
+
function createBoundary(fn, condition) {
|
|
933
949
|
const owner = new Owner();
|
|
934
|
-
const queue = new
|
|
935
|
-
const tree =
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
950
|
+
const queue = new ConditionalQueue(new Computation(void 0, () => condition() === "hidden" /* HIDDEN */));
|
|
951
|
+
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
952
|
+
new EagerComputation(void 0, () => {
|
|
953
|
+
const disabled = queue.p.read();
|
|
954
|
+
tree.H = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
955
|
+
if (!disabled) {
|
|
956
|
+
queue.Q.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
957
|
+
queue.P.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
958
|
+
queue.Q.clear();
|
|
959
|
+
queue.P.clear();
|
|
944
960
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
return createDecision(tree, queue.p, fallback);
|
|
961
|
+
});
|
|
962
|
+
return () => queue.p.read() ? void 0 : tree.read();
|
|
948
963
|
}
|
|
949
|
-
function
|
|
964
|
+
function createCollectionBoundary(type, fn, fallback) {
|
|
950
965
|
const owner = new Owner();
|
|
951
|
-
const
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
if (
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
tree.H = tree.handleError;
|
|
972
|
-
return createDecision(
|
|
973
|
-
tree,
|
|
974
|
-
error,
|
|
975
|
-
() => fallback(error.read().G, () => {
|
|
966
|
+
const queue = new CollectionQueue(type);
|
|
967
|
+
const tree = createBoundChildren(owner, fn, queue, type);
|
|
968
|
+
const decision = new Computation(void 0, () => {
|
|
969
|
+
if (!queue.p.read()) {
|
|
970
|
+
const resolved = tree.read();
|
|
971
|
+
if (!queue.p.read())
|
|
972
|
+
return resolved;
|
|
973
|
+
}
|
|
974
|
+
return fallback(queue);
|
|
975
|
+
});
|
|
976
|
+
return decision.read.bind(decision);
|
|
977
|
+
}
|
|
978
|
+
function createSuspense(fn, fallback) {
|
|
979
|
+
return createCollectionBoundary(LOADING_BIT, fn, () => fallback());
|
|
980
|
+
}
|
|
981
|
+
function createErrorBoundary(fn, fallback) {
|
|
982
|
+
return createCollectionBoundary(
|
|
983
|
+
ERROR_BIT,
|
|
984
|
+
fn,
|
|
985
|
+
(queue) => fallback(queue.b.values().next().value.G, () => {
|
|
976
986
|
var _a;
|
|
977
987
|
incrementClock();
|
|
978
|
-
for (let node of
|
|
988
|
+
for (let node of queue.b) {
|
|
979
989
|
node.a = STATE_DIRTY;
|
|
980
990
|
(_a = node.h) == null ? void 0 : _a.enqueue(node.u, node);
|
|
981
991
|
}
|
|
@@ -1014,7 +1024,7 @@ function createMemo(compute2, value, options) {
|
|
|
1014
1024
|
return resolvedValue;
|
|
1015
1025
|
}
|
|
1016
1026
|
resolvedValue = node.wait();
|
|
1017
|
-
if (!((_a = node.c) == null ? void 0 : _a.length) && ((_b = node.
|
|
1027
|
+
if (!((_a = node.c) == null ? void 0 : _a.length) && ((_b = node.m) == null ? void 0 : _b.n) !== node) {
|
|
1018
1028
|
node.dispose();
|
|
1019
1029
|
node = void 0;
|
|
1020
1030
|
}
|
|
@@ -1044,7 +1054,7 @@ function createAsync(compute2, value, options) {
|
|
|
1044
1054
|
(error) => {
|
|
1045
1055
|
if (abort)
|
|
1046
1056
|
return;
|
|
1047
|
-
node.
|
|
1057
|
+
node.L(error);
|
|
1048
1058
|
}
|
|
1049
1059
|
);
|
|
1050
1060
|
} else {
|
|
@@ -1235,7 +1245,7 @@ function ownKeys(target) {
|
|
|
1235
1245
|
trackSelf(target);
|
|
1236
1246
|
return Reflect.ownKeys(target[STORE_VALUE]);
|
|
1237
1247
|
}
|
|
1238
|
-
var Writing =
|
|
1248
|
+
var Writing = null;
|
|
1239
1249
|
var proxyTraps = {
|
|
1240
1250
|
get(target, property, receiver) {
|
|
1241
1251
|
if (property === $TARGET)
|
|
@@ -1256,7 +1266,7 @@ var proxyTraps = {
|
|
|
1256
1266
|
if (desc && desc.get)
|
|
1257
1267
|
return desc.get.call(receiver);
|
|
1258
1268
|
}
|
|
1259
|
-
if (Writing.has(storeValue)) {
|
|
1269
|
+
if (Writing == null ? void 0 : Writing.has(storeValue)) {
|
|
1260
1270
|
const value2 = tracked ? tracked.g : storeValue[property];
|
|
1261
1271
|
return isWrappable(value2) ? (Writing.add(value2[$RAW] || value2), wrap2(value2)) : value2;
|
|
1262
1272
|
}
|
|
@@ -1279,11 +1289,11 @@ var proxyTraps = {
|
|
|
1279
1289
|
return has;
|
|
1280
1290
|
},
|
|
1281
1291
|
set(target, property, value) {
|
|
1282
|
-
Writing.has(target[STORE_VALUE]) && setProperty(target[STORE_VALUE], property, unwrap(value, false));
|
|
1292
|
+
(Writing == null ? void 0 : Writing.has(target[STORE_VALUE])) && setProperty(target[STORE_VALUE], property, unwrap(value, false));
|
|
1283
1293
|
return true;
|
|
1284
1294
|
},
|
|
1285
1295
|
deleteProperty(target, property) {
|
|
1286
|
-
Writing.has(target[STORE_VALUE]) && setProperty(target[STORE_VALUE], property, void 0, true);
|
|
1296
|
+
(Writing == null ? void 0 : Writing.has(target[STORE_VALUE])) && setProperty(target[STORE_VALUE], property, void 0, true);
|
|
1287
1297
|
return true;
|
|
1288
1298
|
},
|
|
1289
1299
|
ownKeys,
|
|
@@ -1368,11 +1378,14 @@ function createStore(first, second) {
|
|
|
1368
1378
|
const unwrappedStore = unwrap(store);
|
|
1369
1379
|
let wrappedStore = wrap2(unwrappedStore);
|
|
1370
1380
|
const setStore = (fn) => {
|
|
1381
|
+
const prevWriting = Writing;
|
|
1382
|
+
Writing = /* @__PURE__ */ new Set();
|
|
1383
|
+
Writing.add(unwrappedStore);
|
|
1371
1384
|
try {
|
|
1372
|
-
Writing.add(unwrappedStore);
|
|
1373
1385
|
fn(wrappedStore);
|
|
1374
1386
|
} finally {
|
|
1375
1387
|
Writing.clear();
|
|
1388
|
+
Writing = prevWriting;
|
|
1376
1389
|
}
|
|
1377
1390
|
};
|
|
1378
1391
|
if (derived)
|
|
@@ -1651,19 +1664,19 @@ function mapArray(list, map, options) {
|
|
|
1651
1664
|
return updateKeyedMap.bind({
|
|
1652
1665
|
I: new Owner(),
|
|
1653
1666
|
i: 0,
|
|
1654
|
-
|
|
1667
|
+
_: list,
|
|
1655
1668
|
w: [],
|
|
1656
1669
|
D: map,
|
|
1657
|
-
|
|
1670
|
+
d: [],
|
|
1658
1671
|
b: [],
|
|
1659
1672
|
E: keyFn,
|
|
1660
1673
|
j: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1661
1674
|
k: map.length > 1 ? [] : void 0,
|
|
1662
|
-
|
|
1675
|
+
J: options == null ? void 0 : options.fallback
|
|
1663
1676
|
});
|
|
1664
1677
|
}
|
|
1665
1678
|
function updateKeyedMap() {
|
|
1666
|
-
const newItems = this.
|
|
1679
|
+
const newItems = this._() || [], newLen = newItems.length;
|
|
1667
1680
|
newItems[$TRACK];
|
|
1668
1681
|
runWithOwner(this.I, () => {
|
|
1669
1682
|
let i, j, mapper = this.j ? () => {
|
|
@@ -1686,25 +1699,25 @@ function updateKeyedMap() {
|
|
|
1686
1699
|
this.I.dispose(false);
|
|
1687
1700
|
this.b = [];
|
|
1688
1701
|
this.w = [];
|
|
1689
|
-
this.
|
|
1702
|
+
this.d = [];
|
|
1690
1703
|
this.i = 0;
|
|
1691
1704
|
this.j && (this.j = []);
|
|
1692
1705
|
this.k && (this.k = []);
|
|
1693
1706
|
}
|
|
1694
|
-
if (this.
|
|
1695
|
-
this.
|
|
1707
|
+
if (this.J && !this.d[0]) {
|
|
1708
|
+
this.d[0] = compute(
|
|
1696
1709
|
this.b[0] = new Owner(),
|
|
1697
|
-
this.
|
|
1710
|
+
this.J,
|
|
1698
1711
|
null
|
|
1699
1712
|
);
|
|
1700
1713
|
}
|
|
1701
1714
|
} else if (this.i === 0) {
|
|
1702
1715
|
if (this.b[0])
|
|
1703
1716
|
this.b[0].dispose();
|
|
1704
|
-
this.
|
|
1717
|
+
this.d = new Array(newLen);
|
|
1705
1718
|
for (j = 0; j < newLen; j++) {
|
|
1706
1719
|
this.w[j] = newItems[j];
|
|
1707
|
-
this.
|
|
1720
|
+
this.d[j] = compute(this.b[j] = new Owner(), mapper, null);
|
|
1708
1721
|
}
|
|
1709
1722
|
this.i = newLen;
|
|
1710
1723
|
} else {
|
|
@@ -1714,7 +1727,7 @@ function updateKeyedMap() {
|
|
|
1714
1727
|
this.j[start].write(newItems[start]);
|
|
1715
1728
|
}
|
|
1716
1729
|
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.w[end] === newItems[newEnd] || this.j && compare(this.E, this.w[end], newItems[newEnd])); end--, newEnd--) {
|
|
1717
|
-
temp[newEnd] = this.
|
|
1730
|
+
temp[newEnd] = this.d[end];
|
|
1718
1731
|
tempNodes[newEnd] = this.b[end];
|
|
1719
1732
|
tempRows && (tempRows[newEnd] = this.j[end]);
|
|
1720
1733
|
tempIndexes && (tempIndexes[newEnd] = this.k[end]);
|
|
@@ -1733,7 +1746,7 @@ function updateKeyedMap() {
|
|
|
1733
1746
|
key = this.E ? this.E(item) : item;
|
|
1734
1747
|
j = newIndices.get(key);
|
|
1735
1748
|
if (j !== void 0 && j !== -1) {
|
|
1736
|
-
temp[j] = this.
|
|
1749
|
+
temp[j] = this.d[i];
|
|
1737
1750
|
tempNodes[j] = this.b[i];
|
|
1738
1751
|
tempRows && (tempRows[j] = this.j[i]);
|
|
1739
1752
|
tempIndexes && (tempIndexes[j] = this.k[i]);
|
|
@@ -1744,7 +1757,7 @@ function updateKeyedMap() {
|
|
|
1744
1757
|
}
|
|
1745
1758
|
for (j = start; j < newLen; j++) {
|
|
1746
1759
|
if (j in temp) {
|
|
1747
|
-
this.
|
|
1760
|
+
this.d[j] = temp[j];
|
|
1748
1761
|
this.b[j] = tempNodes[j];
|
|
1749
1762
|
if (tempRows) {
|
|
1750
1763
|
this.j[j] = tempRows[j];
|
|
@@ -1755,44 +1768,44 @@ function updateKeyedMap() {
|
|
|
1755
1768
|
this.k[j].write(j);
|
|
1756
1769
|
}
|
|
1757
1770
|
} else {
|
|
1758
|
-
this.
|
|
1771
|
+
this.d[j] = compute(this.b[j] = new Owner(), mapper, null);
|
|
1759
1772
|
}
|
|
1760
1773
|
}
|
|
1761
|
-
this.
|
|
1774
|
+
this.d = this.d.slice(0, this.i = newLen);
|
|
1762
1775
|
this.w = newItems.slice(0);
|
|
1763
1776
|
}
|
|
1764
1777
|
});
|
|
1765
|
-
return this.
|
|
1778
|
+
return this.d;
|
|
1766
1779
|
}
|
|
1767
1780
|
function repeat(count, map, options) {
|
|
1768
1781
|
return updateRepeat.bind({
|
|
1769
1782
|
I: new Owner(),
|
|
1770
1783
|
i: 0,
|
|
1771
1784
|
q: 0,
|
|
1772
|
-
|
|
1785
|
+
$: count,
|
|
1773
1786
|
D: map,
|
|
1774
1787
|
b: [],
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1788
|
+
d: [],
|
|
1789
|
+
aa: options == null ? void 0 : options.from,
|
|
1790
|
+
J: options == null ? void 0 : options.fallback
|
|
1778
1791
|
});
|
|
1779
1792
|
}
|
|
1780
1793
|
function updateRepeat() {
|
|
1781
1794
|
var _a;
|
|
1782
|
-
const newLen = this
|
|
1783
|
-
const from = ((_a = this.
|
|
1795
|
+
const newLen = this.$();
|
|
1796
|
+
const from = ((_a = this.aa) == null ? void 0 : _a.call(this)) || 0;
|
|
1784
1797
|
runWithOwner(this.I, () => {
|
|
1785
1798
|
if (newLen === 0) {
|
|
1786
1799
|
if (this.i !== 0) {
|
|
1787
1800
|
this.I.dispose(false);
|
|
1788
1801
|
this.b = [];
|
|
1789
|
-
this.
|
|
1802
|
+
this.d = [];
|
|
1790
1803
|
this.i = 0;
|
|
1791
1804
|
}
|
|
1792
|
-
if (this.
|
|
1793
|
-
this.
|
|
1805
|
+
if (this.J && !this.d[0]) {
|
|
1806
|
+
this.d[0] = compute(
|
|
1794
1807
|
this.b[0] = new Owner(),
|
|
1795
|
-
this.
|
|
1808
|
+
this.J,
|
|
1796
1809
|
null
|
|
1797
1810
|
);
|
|
1798
1811
|
}
|
|
@@ -1809,18 +1822,18 @@ function updateRepeat() {
|
|
|
1809
1822
|
while (i < from && i < this.i)
|
|
1810
1823
|
this.b[i++].dispose();
|
|
1811
1824
|
this.b.splice(0, from - this.q);
|
|
1812
|
-
this.
|
|
1825
|
+
this.d.splice(0, from - this.q);
|
|
1813
1826
|
} else if (this.q > from) {
|
|
1814
1827
|
let i = prevTo - this.q - 1;
|
|
1815
1828
|
let difference = this.q - from;
|
|
1816
|
-
this.b.length = this.
|
|
1829
|
+
this.b.length = this.d.length = newLen;
|
|
1817
1830
|
while (i >= difference) {
|
|
1818
1831
|
this.b[i] = this.b[i - difference];
|
|
1819
|
-
this.
|
|
1832
|
+
this.d[i] = this.d[i - difference];
|
|
1820
1833
|
i--;
|
|
1821
1834
|
}
|
|
1822
1835
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
1823
|
-
this.
|
|
1836
|
+
this.d[i2] = compute(
|
|
1824
1837
|
this.b[i2] = new Owner(),
|
|
1825
1838
|
() => this.D(i2 + from),
|
|
1826
1839
|
null
|
|
@@ -1828,17 +1841,17 @@ function updateRepeat() {
|
|
|
1828
1841
|
}
|
|
1829
1842
|
}
|
|
1830
1843
|
for (let i = prevTo; i < to; i++) {
|
|
1831
|
-
this.
|
|
1844
|
+
this.d[i - from] = compute(
|
|
1832
1845
|
this.b[i - from] = new Owner(),
|
|
1833
1846
|
() => this.D(i),
|
|
1834
1847
|
null
|
|
1835
1848
|
);
|
|
1836
1849
|
}
|
|
1837
|
-
this.
|
|
1850
|
+
this.d = this.d.slice(0, newLen);
|
|
1838
1851
|
this.q = from;
|
|
1839
1852
|
this.i = newLen;
|
|
1840
1853
|
});
|
|
1841
|
-
return this.
|
|
1854
|
+
return this.d;
|
|
1842
1855
|
}
|
|
1843
1856
|
function compare(key, a, b) {
|
|
1844
1857
|
return key ? key(a) === key(b) : true;
|
|
@@ -1856,6 +1869,7 @@ exports.Owner = Owner;
|
|
|
1856
1869
|
exports.Queue = Queue;
|
|
1857
1870
|
exports.SUPPORTS_PROXY = SUPPORTS_PROXY;
|
|
1858
1871
|
exports.createAsync = createAsync;
|
|
1872
|
+
exports.createBoundary = createBoundary;
|
|
1859
1873
|
exports.createContext = createContext;
|
|
1860
1874
|
exports.createEffect = createEffect;
|
|
1861
1875
|
exports.createErrorBoundary = createErrorBoundary;
|