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