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