@solidjs/signals 0.2.4 → 0.3.0
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 +238 -191
- package/dist/node.cjs +465 -418
- package/dist/prod.js +460 -413
- package/dist/types/core/{suspense.d.ts → boundaries.d.ts} +3 -3
- package/dist/types/core/core.d.ts +1 -13
- package/dist/types/core/index.d.ts +4 -3
- package/dist/types/core/owner.d.ts +6 -1
- package/dist/types/core/scheduler.d.ts +1 -1
- package/dist/types/core/utils.d.ts +3 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +3 -11
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/store.d.ts +1 -0
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -74,8 +74,8 @@ var Queue = class {
|
|
|
74
74
|
for (let i = 0; i < this.F.length; i++) {
|
|
75
75
|
rerun = this.F[i].run(type) || rerun;
|
|
76
76
|
}
|
|
77
|
-
if (type === EFFECT_PURE
|
|
78
|
-
return
|
|
77
|
+
if (type === EFFECT_PURE)
|
|
78
|
+
return rerun || !!this.s[type].length;
|
|
79
79
|
}
|
|
80
80
|
flush() {
|
|
81
81
|
if (this.J)
|
|
@@ -109,14 +109,14 @@ function flushSync() {
|
|
|
109
109
|
}
|
|
110
110
|
function runTop(node) {
|
|
111
111
|
const ancestors = [];
|
|
112
|
-
for (let current = node; current !== null; current = current.
|
|
112
|
+
for (let current = node; current !== null; current = current.x) {
|
|
113
113
|
if (current.a !== STATE_CLEAN) {
|
|
114
114
|
ancestors.push(current);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
118
118
|
if (ancestors[i].a !== STATE_DISPOSED)
|
|
119
|
-
ancestors[i].
|
|
119
|
+
ancestors[i].y();
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
function runPureQueue(queue) {
|
|
@@ -127,13 +127,33 @@ function runPureQueue(queue) {
|
|
|
127
127
|
}
|
|
128
128
|
function runEffectQueue(queue) {
|
|
129
129
|
for (let i = 0; i < queue.length; i++)
|
|
130
|
-
queue[i].
|
|
130
|
+
queue[i].T();
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// src/core/utils.ts
|
|
134
134
|
function isUndefined(value) {
|
|
135
135
|
return typeof value === "undefined";
|
|
136
136
|
}
|
|
137
|
+
function tryCatch(fn) {
|
|
138
|
+
try {
|
|
139
|
+
const v = fn();
|
|
140
|
+
if (v instanceof Promise) {
|
|
141
|
+
return v.then(
|
|
142
|
+
(v2) => [void 0, v2],
|
|
143
|
+
(e) => {
|
|
144
|
+
if (e instanceof NotReadyError)
|
|
145
|
+
throw e;
|
|
146
|
+
return [e];
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return [void 0, v];
|
|
151
|
+
} catch (e) {
|
|
152
|
+
if (e instanceof NotReadyError)
|
|
153
|
+
throw e;
|
|
154
|
+
return [e];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
137
157
|
|
|
138
158
|
// src/core/owner.ts
|
|
139
159
|
var currentOwner = null;
|
|
@@ -146,34 +166,46 @@ function setOwner(owner) {
|
|
|
146
166
|
currentOwner = owner;
|
|
147
167
|
return out;
|
|
148
168
|
}
|
|
169
|
+
function formatId(prefix, id) {
|
|
170
|
+
const num = id.toString(36), len = num.length - 1;
|
|
171
|
+
return prefix + (len ? String.fromCharCode(64 + len) : "") + num;
|
|
172
|
+
}
|
|
149
173
|
var Owner = class {
|
|
150
174
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
151
175
|
// However, the children are actually added in reverse creation order
|
|
152
176
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
177
|
+
x = null;
|
|
178
|
+
l = null;
|
|
153
179
|
t = null;
|
|
154
|
-
n = null;
|
|
155
|
-
u = null;
|
|
156
180
|
a = STATE_CLEAN;
|
|
157
|
-
l = null;
|
|
158
|
-
p = defaultContext;
|
|
159
181
|
m = null;
|
|
182
|
+
o = defaultContext;
|
|
183
|
+
n = null;
|
|
160
184
|
h = globalQueue;
|
|
161
|
-
|
|
162
|
-
|
|
185
|
+
O = null;
|
|
186
|
+
X = 0;
|
|
187
|
+
id = null;
|
|
188
|
+
constructor(id = null, skipAppend = false) {
|
|
189
|
+
this.id = id;
|
|
190
|
+
if (currentOwner && !skipAppend)
|
|
163
191
|
currentOwner.append(this);
|
|
164
192
|
}
|
|
165
193
|
append(child) {
|
|
194
|
+
child.x = this;
|
|
166
195
|
child.t = this;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this.
|
|
172
|
-
|
|
173
|
-
|
|
196
|
+
if (this.id) {
|
|
197
|
+
child.O = this.l ? this.l.O + 1 : 0;
|
|
198
|
+
child.id = formatId(this.id, child.O);
|
|
199
|
+
}
|
|
200
|
+
if (this.l)
|
|
201
|
+
this.l.t = child;
|
|
202
|
+
child.l = this.l;
|
|
203
|
+
this.l = child;
|
|
204
|
+
if (child.o !== this.o) {
|
|
205
|
+
child.o = { ...this.o, ...child.o };
|
|
174
206
|
}
|
|
175
|
-
if (this.
|
|
176
|
-
child.
|
|
207
|
+
if (this.n) {
|
|
208
|
+
child.n = !child.n ? this.n : [...child.n, ...this.n];
|
|
177
209
|
}
|
|
178
210
|
if (this.h)
|
|
179
211
|
child.h = this.h;
|
|
@@ -181,51 +213,54 @@ var Owner = class {
|
|
|
181
213
|
dispose(self = true) {
|
|
182
214
|
if (this.a === STATE_DISPOSED)
|
|
183
215
|
return;
|
|
184
|
-
let head = self ? this.
|
|
185
|
-
while (current && current.
|
|
216
|
+
let head = self ? this.t || this.x : this, current = this.l, next = null;
|
|
217
|
+
while (current && current.x === this) {
|
|
186
218
|
current.dispose(true);
|
|
187
|
-
current.
|
|
188
|
-
next = current.
|
|
189
|
-
current.
|
|
219
|
+
current.z();
|
|
220
|
+
next = current.l;
|
|
221
|
+
current.l = null;
|
|
190
222
|
current = next;
|
|
191
223
|
}
|
|
192
224
|
if (self)
|
|
193
|
-
this.
|
|
225
|
+
this.z();
|
|
194
226
|
if (current)
|
|
195
|
-
current.
|
|
227
|
+
current.t = !self ? this : this.t;
|
|
196
228
|
if (head)
|
|
197
|
-
head.
|
|
229
|
+
head.l = current;
|
|
198
230
|
}
|
|
199
|
-
|
|
200
|
-
if (this.
|
|
201
|
-
this.
|
|
231
|
+
z() {
|
|
232
|
+
if (this.t)
|
|
233
|
+
this.t.l = null;
|
|
234
|
+
this.x = null;
|
|
202
235
|
this.t = null;
|
|
203
|
-
this.
|
|
204
|
-
this.
|
|
205
|
-
this.m = null;
|
|
236
|
+
this.o = defaultContext;
|
|
237
|
+
this.n = null;
|
|
206
238
|
this.a = STATE_DISPOSED;
|
|
207
239
|
this.emptyDisposal();
|
|
208
240
|
}
|
|
209
241
|
emptyDisposal() {
|
|
210
|
-
if (!this.
|
|
242
|
+
if (!this.m)
|
|
211
243
|
return;
|
|
212
|
-
if (Array.isArray(this.
|
|
213
|
-
for (let i = 0; i < this.
|
|
214
|
-
const callable = this.
|
|
244
|
+
if (Array.isArray(this.m)) {
|
|
245
|
+
for (let i = 0; i < this.m.length; i++) {
|
|
246
|
+
const callable = this.m[i];
|
|
215
247
|
callable.call(callable);
|
|
216
248
|
}
|
|
217
249
|
} else {
|
|
218
|
-
this.
|
|
250
|
+
this.m.call(this.m);
|
|
219
251
|
}
|
|
220
|
-
this.
|
|
252
|
+
this.m = null;
|
|
253
|
+
}
|
|
254
|
+
addErrorHandler(handler) {
|
|
255
|
+
this.n = this.n ? [handler, ...this.n] : [handler];
|
|
221
256
|
}
|
|
222
257
|
handleError(error) {
|
|
223
|
-
if (!this.
|
|
258
|
+
if (!this.n)
|
|
224
259
|
throw error;
|
|
225
|
-
let i = 0, len = this.
|
|
260
|
+
let i = 0, len = this.n.length;
|
|
226
261
|
for (i = 0; i < len; i++) {
|
|
227
262
|
try {
|
|
228
|
-
this.
|
|
263
|
+
this.n[i](error, this);
|
|
229
264
|
break;
|
|
230
265
|
} catch (e) {
|
|
231
266
|
error = e;
|
|
@@ -234,6 +269,11 @@ var Owner = class {
|
|
|
234
269
|
if (i === len)
|
|
235
270
|
throw error;
|
|
236
271
|
}
|
|
272
|
+
getNextChildId() {
|
|
273
|
+
if (this.id)
|
|
274
|
+
return formatId(this.id + "-", this.X++);
|
|
275
|
+
throw new Error("Cannot get child id from owner without an id");
|
|
276
|
+
}
|
|
237
277
|
};
|
|
238
278
|
function createContext(defaultValue, description) {
|
|
239
279
|
return { id: Symbol(description), defaultValue };
|
|
@@ -242,7 +282,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
242
282
|
if (!owner) {
|
|
243
283
|
throw new NoOwnerError();
|
|
244
284
|
}
|
|
245
|
-
const value = hasContext(context, owner) ? owner.
|
|
285
|
+
const value = hasContext(context, owner) ? owner.o[context.id] : context.defaultValue;
|
|
246
286
|
if (isUndefined(value)) {
|
|
247
287
|
throw new ContextNotFoundError();
|
|
248
288
|
}
|
|
@@ -252,24 +292,24 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
252
292
|
if (!owner) {
|
|
253
293
|
throw new NoOwnerError();
|
|
254
294
|
}
|
|
255
|
-
owner.
|
|
256
|
-
...owner.
|
|
295
|
+
owner.o = {
|
|
296
|
+
...owner.o,
|
|
257
297
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
258
298
|
};
|
|
259
299
|
}
|
|
260
300
|
function hasContext(context, owner = currentOwner) {
|
|
261
|
-
return !isUndefined(owner == null ? void 0 : owner.
|
|
301
|
+
return !isUndefined(owner == null ? void 0 : owner.o[context.id]);
|
|
262
302
|
}
|
|
263
303
|
function onCleanup(fn) {
|
|
264
304
|
if (!currentOwner)
|
|
265
305
|
return fn;
|
|
266
306
|
const node = currentOwner;
|
|
267
|
-
if (!node.
|
|
268
|
-
node.
|
|
269
|
-
} else if (Array.isArray(node.
|
|
270
|
-
node.
|
|
307
|
+
if (!node.m) {
|
|
308
|
+
node.m = fn;
|
|
309
|
+
} else if (Array.isArray(node.m)) {
|
|
310
|
+
node.m.push(fn);
|
|
271
311
|
} else {
|
|
272
|
-
node.
|
|
312
|
+
node.m = [node.m, fn];
|
|
273
313
|
}
|
|
274
314
|
return fn;
|
|
275
315
|
}
|
|
@@ -297,47 +337,44 @@ function getObserver() {
|
|
|
297
337
|
}
|
|
298
338
|
var UNCHANGED = Symbol(0);
|
|
299
339
|
var Computation = class extends Owner {
|
|
300
|
-
|
|
301
|
-
|
|
340
|
+
c = null;
|
|
341
|
+
f = null;
|
|
302
342
|
g;
|
|
303
343
|
G;
|
|
304
|
-
|
|
344
|
+
A;
|
|
305
345
|
// Used in __DEV__ mode, hopefully removed in production
|
|
306
346
|
$;
|
|
307
347
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
308
348
|
// which could enable more efficient DIRTY notification
|
|
309
|
-
|
|
310
|
-
|
|
349
|
+
P = isEqual;
|
|
350
|
+
U;
|
|
311
351
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
312
|
-
|
|
352
|
+
d = 0;
|
|
313
353
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
y = -1;
|
|
354
|
+
Q = DEFAULT_FLAGS;
|
|
355
|
+
B = -1;
|
|
317
356
|
K = false;
|
|
318
357
|
constructor(initialValue, compute2, options) {
|
|
319
|
-
super(compute2 === null);
|
|
320
|
-
this.
|
|
358
|
+
super(null, compute2 === null);
|
|
359
|
+
this.A = compute2;
|
|
321
360
|
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
322
|
-
this.
|
|
361
|
+
this.d = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
323
362
|
this.g = initialValue;
|
|
324
363
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
325
|
-
this.
|
|
364
|
+
this.P = options.equals;
|
|
326
365
|
if (options == null ? void 0 : options.unobserved)
|
|
327
|
-
this.
|
|
366
|
+
this.U = options == null ? void 0 : options.unobserved;
|
|
328
367
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (this.f & ERROR_BIT && this.y <= getClock())
|
|
368
|
+
V() {
|
|
369
|
+
if (this.A) {
|
|
370
|
+
if (this.d & ERROR_BIT && this.B <= getClock())
|
|
333
371
|
update(this);
|
|
334
372
|
else
|
|
335
|
-
this.
|
|
373
|
+
this.y();
|
|
336
374
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (this.f & ERROR_BIT) {
|
|
375
|
+
track(this);
|
|
376
|
+
newFlags |= this.d & ~currentMask;
|
|
377
|
+
if (this.d & ERROR_BIT) {
|
|
341
378
|
throw this.G;
|
|
342
379
|
} else {
|
|
343
380
|
return this.g;
|
|
@@ -348,7 +385,7 @@ var Computation = class extends Owner {
|
|
|
348
385
|
* Automatically re-executes the surrounding computation when the value changes
|
|
349
386
|
*/
|
|
350
387
|
read() {
|
|
351
|
-
return this.
|
|
388
|
+
return this.V();
|
|
352
389
|
}
|
|
353
390
|
/**
|
|
354
391
|
* Return the current value of this computation
|
|
@@ -358,46 +395,37 @@ var Computation = class extends Owner {
|
|
|
358
395
|
* before continuing
|
|
359
396
|
*/
|
|
360
397
|
wait() {
|
|
361
|
-
if (this.
|
|
398
|
+
if (this.A && this.d & ERROR_BIT && this.B <= getClock()) {
|
|
362
399
|
update(this);
|
|
400
|
+
} else {
|
|
401
|
+
this.y();
|
|
363
402
|
}
|
|
364
|
-
|
|
403
|
+
track(this);
|
|
404
|
+
if ((notStale || this.d & UNINITIALIZED_BIT) && this.d & LOADING_BIT) {
|
|
365
405
|
throw new NotReadyError();
|
|
366
406
|
}
|
|
367
|
-
if (staleCheck && this.
|
|
407
|
+
if (staleCheck && this.d & LOADING_BIT) {
|
|
368
408
|
staleCheck.g = true;
|
|
369
|
-
return this.W();
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Return true if the computation is the value is dependent on an unresolved promise
|
|
373
|
-
* Triggers re-execution of the computation when the loading state changes
|
|
374
|
-
*
|
|
375
|
-
* This is useful especially when effects want to re-execute when a computation's
|
|
376
|
-
* loading state changes
|
|
377
|
-
*/
|
|
378
|
-
loading() {
|
|
379
|
-
if (this.Q === null) {
|
|
380
|
-
this.Q = loadingState(this);
|
|
381
409
|
}
|
|
382
|
-
return this.
|
|
410
|
+
return this.V();
|
|
383
411
|
}
|
|
384
412
|
/** Update the computation with a new value. */
|
|
385
413
|
write(value, flags = 0, raw = false) {
|
|
386
414
|
const newValue = !raw && typeof value === "function" ? value(this.g) : value;
|
|
387
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
415
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.d & UNINITIALIZED_BIT) || this.d & LOADING_BIT & ~flags || this.P === false || !this.P(this.g, newValue));
|
|
388
416
|
if (valueChanged) {
|
|
389
417
|
this.g = newValue;
|
|
390
418
|
this.G = void 0;
|
|
391
419
|
}
|
|
392
|
-
const changedFlagsMask = this.
|
|
393
|
-
this.
|
|
394
|
-
this.
|
|
395
|
-
if (this.
|
|
396
|
-
for (let i = 0; i < this.
|
|
420
|
+
const changedFlagsMask = this.d ^ flags, changedFlags = changedFlagsMask & flags;
|
|
421
|
+
this.d = flags;
|
|
422
|
+
this.B = getClock() + 1;
|
|
423
|
+
if (this.f) {
|
|
424
|
+
for (let i = 0; i < this.f.length; i++) {
|
|
397
425
|
if (valueChanged) {
|
|
398
|
-
this.
|
|
426
|
+
this.f[i].r(STATE_DIRTY);
|
|
399
427
|
} else if (changedFlagsMask) {
|
|
400
|
-
this.
|
|
428
|
+
this.f[i].W(changedFlagsMask, changedFlags);
|
|
401
429
|
}
|
|
402
430
|
}
|
|
403
431
|
}
|
|
@@ -406,14 +434,14 @@ var Computation = class extends Owner {
|
|
|
406
434
|
/**
|
|
407
435
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
408
436
|
*/
|
|
409
|
-
|
|
437
|
+
r(state, skipQueue) {
|
|
410
438
|
if (this.a >= state && !this.K)
|
|
411
439
|
return;
|
|
412
440
|
this.K = !!skipQueue;
|
|
413
441
|
this.a = state;
|
|
414
|
-
if (this.
|
|
415
|
-
for (let i = 0; i < this.
|
|
416
|
-
this.
|
|
442
|
+
if (this.f) {
|
|
443
|
+
for (let i = 0; i < this.f.length; i++) {
|
|
444
|
+
this.f[i].r(STATE_CHECK, skipQueue);
|
|
417
445
|
}
|
|
418
446
|
}
|
|
419
447
|
}
|
|
@@ -423,31 +451,31 @@ var Computation = class extends Owner {
|
|
|
423
451
|
* @param mask A bitmask for which flag(s) were changed.
|
|
424
452
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
425
453
|
*/
|
|
426
|
-
|
|
454
|
+
W(mask, newFlags2) {
|
|
427
455
|
if (this.a >= STATE_DIRTY)
|
|
428
456
|
return;
|
|
429
|
-
if (mask & this.
|
|
430
|
-
this.
|
|
457
|
+
if (mask & this.Q) {
|
|
458
|
+
this.r(STATE_DIRTY);
|
|
431
459
|
return;
|
|
432
460
|
}
|
|
433
461
|
if (this.a >= STATE_CHECK)
|
|
434
462
|
return;
|
|
435
|
-
const prevFlags = this.
|
|
463
|
+
const prevFlags = this.d & mask;
|
|
436
464
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
437
465
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
438
|
-
this.
|
|
466
|
+
this.r(STATE_CHECK);
|
|
439
467
|
} else {
|
|
440
|
-
this.
|
|
441
|
-
if (this.
|
|
442
|
-
for (let i = 0; i < this.
|
|
443
|
-
this.
|
|
468
|
+
this.d ^= deltaFlags;
|
|
469
|
+
if (this.f) {
|
|
470
|
+
for (let i = 0; i < this.f.length; i++) {
|
|
471
|
+
this.f[i].W(mask, newFlags2);
|
|
444
472
|
}
|
|
445
473
|
}
|
|
446
474
|
}
|
|
447
475
|
}
|
|
448
476
|
H(error) {
|
|
449
477
|
this.G = error;
|
|
450
|
-
this.write(UNCHANGED, this.
|
|
478
|
+
this.write(UNCHANGED, this.d & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
451
479
|
}
|
|
452
480
|
/**
|
|
453
481
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -456,18 +484,21 @@ var Computation = class extends Owner {
|
|
|
456
484
|
*
|
|
457
485
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
458
486
|
*/
|
|
459
|
-
|
|
487
|
+
y() {
|
|
488
|
+
if (!this.A) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
460
491
|
if (this.a === STATE_DISPOSED) {
|
|
461
|
-
|
|
492
|
+
return;
|
|
462
493
|
}
|
|
463
494
|
if (this.a === STATE_CLEAN) {
|
|
464
495
|
return;
|
|
465
496
|
}
|
|
466
497
|
let observerFlags = 0;
|
|
467
498
|
if (this.a === STATE_CHECK) {
|
|
468
|
-
for (let i = 0; i < this.
|
|
469
|
-
this.
|
|
470
|
-
observerFlags |= this.
|
|
499
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
500
|
+
this.c[i].y();
|
|
501
|
+
observerFlags |= this.c[i].d;
|
|
471
502
|
if (this.a === STATE_DIRTY) {
|
|
472
503
|
break;
|
|
473
504
|
}
|
|
@@ -483,33 +514,17 @@ var Computation = class extends Owner {
|
|
|
483
514
|
/**
|
|
484
515
|
* Remove ourselves from the owner graph and the computation graph
|
|
485
516
|
*/
|
|
486
|
-
|
|
517
|
+
z() {
|
|
487
518
|
if (this.a === STATE_DISPOSED)
|
|
488
519
|
return;
|
|
489
|
-
if (this.
|
|
520
|
+
if (this.c)
|
|
490
521
|
removeSourceObservers(this, 0);
|
|
491
|
-
super.
|
|
522
|
+
super.z();
|
|
492
523
|
}
|
|
493
524
|
};
|
|
494
|
-
function loadingState(node) {
|
|
495
|
-
const prevOwner = setOwner(node.t);
|
|
496
|
-
const options = void 0;
|
|
497
|
-
const computation = new Computation(
|
|
498
|
-
void 0,
|
|
499
|
-
() => {
|
|
500
|
-
track(node);
|
|
501
|
-
node.z();
|
|
502
|
-
return !!(node.f & LOADING_BIT);
|
|
503
|
-
},
|
|
504
|
-
options
|
|
505
|
-
);
|
|
506
|
-
computation.P = ERROR_BIT | LOADING_BIT;
|
|
507
|
-
setOwner(prevOwner);
|
|
508
|
-
return computation;
|
|
509
|
-
}
|
|
510
525
|
function track(computation) {
|
|
511
526
|
if (currentObserver) {
|
|
512
|
-
if (!newSources && currentObserver.
|
|
527
|
+
if (!newSources && currentObserver.c && currentObserver.c[newSourcesIndex] === computation) {
|
|
513
528
|
newSourcesIndex++;
|
|
514
529
|
} else if (!newSources)
|
|
515
530
|
newSources = [computation];
|
|
@@ -517,7 +532,7 @@ function track(computation) {
|
|
|
517
532
|
newSources.push(computation);
|
|
518
533
|
}
|
|
519
534
|
if (updateCheck) {
|
|
520
|
-
updateCheck.g = computation.
|
|
535
|
+
updateCheck.g = computation.B > currentObserver.B;
|
|
521
536
|
}
|
|
522
537
|
}
|
|
523
538
|
}
|
|
@@ -529,42 +544,42 @@ function update(node) {
|
|
|
529
544
|
try {
|
|
530
545
|
node.dispose(false);
|
|
531
546
|
node.emptyDisposal();
|
|
532
|
-
const result = compute(node, node.
|
|
547
|
+
const result = compute(node, node.A, node);
|
|
533
548
|
node.write(result, newFlags, true);
|
|
534
549
|
} catch (error) {
|
|
535
550
|
if (error instanceof NotReadyError) {
|
|
536
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
551
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.d & UNINITIALIZED_BIT);
|
|
537
552
|
} else {
|
|
538
553
|
node.H(error);
|
|
539
554
|
}
|
|
540
555
|
} finally {
|
|
541
556
|
if (newSources) {
|
|
542
|
-
if (node.
|
|
557
|
+
if (node.c)
|
|
543
558
|
removeSourceObservers(node, newSourcesIndex);
|
|
544
|
-
if (node.
|
|
545
|
-
node.
|
|
559
|
+
if (node.c && newSourcesIndex > 0) {
|
|
560
|
+
node.c.length = newSourcesIndex + newSources.length;
|
|
546
561
|
for (let i = 0; i < newSources.length; i++) {
|
|
547
|
-
node.
|
|
562
|
+
node.c[newSourcesIndex + i] = newSources[i];
|
|
548
563
|
}
|
|
549
564
|
} else {
|
|
550
|
-
node.
|
|
565
|
+
node.c = newSources;
|
|
551
566
|
}
|
|
552
567
|
let source;
|
|
553
|
-
for (let i = newSourcesIndex; i < node.
|
|
554
|
-
source = node.
|
|
555
|
-
if (!source.
|
|
556
|
-
source.
|
|
568
|
+
for (let i = newSourcesIndex; i < node.c.length; i++) {
|
|
569
|
+
source = node.c[i];
|
|
570
|
+
if (!source.f)
|
|
571
|
+
source.f = [node];
|
|
557
572
|
else
|
|
558
|
-
source.
|
|
573
|
+
source.f.push(node);
|
|
559
574
|
}
|
|
560
|
-
} else if (node.
|
|
575
|
+
} else if (node.c && newSourcesIndex < node.c.length) {
|
|
561
576
|
removeSourceObservers(node, newSourcesIndex);
|
|
562
|
-
node.
|
|
577
|
+
node.c.length = newSourcesIndex;
|
|
563
578
|
}
|
|
564
579
|
newSources = prevSources;
|
|
565
580
|
newSourcesIndex = prevSourcesIndex;
|
|
566
581
|
newFlags = prevFlags;
|
|
567
|
-
node.
|
|
582
|
+
node.B = getClock() + 1;
|
|
568
583
|
node.a = STATE_CLEAN;
|
|
569
584
|
}
|
|
570
585
|
}
|
|
@@ -572,14 +587,14 @@ function removeSourceObservers(node, index) {
|
|
|
572
587
|
var _a;
|
|
573
588
|
let source;
|
|
574
589
|
let swap;
|
|
575
|
-
for (let i = index; i < node.
|
|
576
|
-
source = node.
|
|
577
|
-
if (source.
|
|
578
|
-
swap = source.
|
|
579
|
-
source.
|
|
580
|
-
source.
|
|
581
|
-
if (!source.
|
|
582
|
-
(_a = source.
|
|
590
|
+
for (let i = index; i < node.c.length; i++) {
|
|
591
|
+
source = node.c[i];
|
|
592
|
+
if (source.f) {
|
|
593
|
+
swap = source.f.indexOf(node);
|
|
594
|
+
source.f[swap] = source.f[source.f.length - 1];
|
|
595
|
+
source.f.pop();
|
|
596
|
+
if (!source.f.length)
|
|
597
|
+
(_a = source.U) == null ? void 0 : _a.call(source);
|
|
583
598
|
}
|
|
584
599
|
}
|
|
585
600
|
}
|
|
@@ -601,8 +616,7 @@ function hasUpdated(fn) {
|
|
|
601
616
|
updateCheck = current;
|
|
602
617
|
}
|
|
603
618
|
}
|
|
604
|
-
function
|
|
605
|
-
const argLength = arguments.length;
|
|
619
|
+
function pendingCheck(fn, loadingValue) {
|
|
606
620
|
const current = staleCheck;
|
|
607
621
|
staleCheck = { g: false };
|
|
608
622
|
try {
|
|
@@ -611,13 +625,20 @@ function isPending(fn, loadingValue) {
|
|
|
611
625
|
} catch (err) {
|
|
612
626
|
if (!(err instanceof NotReadyError))
|
|
613
627
|
return false;
|
|
614
|
-
if (
|
|
628
|
+
if (loadingValue !== void 0)
|
|
615
629
|
return loadingValue;
|
|
616
630
|
throw err;
|
|
617
631
|
} finally {
|
|
618
632
|
staleCheck = current;
|
|
619
633
|
}
|
|
620
634
|
}
|
|
635
|
+
function isPending(fn, loadingValue) {
|
|
636
|
+
if (!currentObserver)
|
|
637
|
+
return pendingCheck(fn, loadingValue);
|
|
638
|
+
const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
|
|
639
|
+
c.Q |= LOADING_BIT;
|
|
640
|
+
return c.read();
|
|
641
|
+
}
|
|
621
642
|
function latest(fn, fallback) {
|
|
622
643
|
const argLength = arguments.length;
|
|
623
644
|
const prevFlags = newFlags;
|
|
@@ -634,19 +655,10 @@ function latest(fn, fallback) {
|
|
|
634
655
|
notStale = prevNotStale;
|
|
635
656
|
}
|
|
636
657
|
}
|
|
637
|
-
function catchError(fn) {
|
|
638
|
-
try {
|
|
639
|
-
fn();
|
|
640
|
-
} catch (e) {
|
|
641
|
-
if (e instanceof NotReadyError)
|
|
642
|
-
throw e;
|
|
643
|
-
return e;
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
658
|
function runWithObserver(observer, run) {
|
|
647
659
|
const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
|
|
648
660
|
newSources = null;
|
|
649
|
-
newSourcesIndex = observer.
|
|
661
|
+
newSourcesIndex = observer.c ? observer.c.length : 0;
|
|
650
662
|
newFlags = 0;
|
|
651
663
|
try {
|
|
652
664
|
return compute(observer, run, observer);
|
|
@@ -654,7 +666,7 @@ function runWithObserver(observer, run) {
|
|
|
654
666
|
if (error instanceof NotReadyError) {
|
|
655
667
|
observer.write(
|
|
656
668
|
UNCHANGED,
|
|
657
|
-
newFlags | LOADING_BIT | observer.
|
|
669
|
+
newFlags | LOADING_BIT | observer.d & UNINITIALIZED_BIT
|
|
658
670
|
);
|
|
659
671
|
} else {
|
|
660
672
|
observer.H(error);
|
|
@@ -662,20 +674,20 @@ function runWithObserver(observer, run) {
|
|
|
662
674
|
} finally {
|
|
663
675
|
if (newSources) {
|
|
664
676
|
if (newSourcesIndex > 0) {
|
|
665
|
-
observer.
|
|
677
|
+
observer.c.length = newSourcesIndex + newSources.length;
|
|
666
678
|
for (let i = 0; i < newSources.length; i++) {
|
|
667
|
-
observer.
|
|
679
|
+
observer.c[newSourcesIndex + i] = newSources[i];
|
|
668
680
|
}
|
|
669
681
|
} else {
|
|
670
|
-
observer.
|
|
682
|
+
observer.c = newSources;
|
|
671
683
|
}
|
|
672
684
|
let source;
|
|
673
|
-
for (let i = newSourcesIndex; i < observer.
|
|
674
|
-
source = observer.
|
|
675
|
-
if (!source.
|
|
676
|
-
source.
|
|
685
|
+
for (let i = newSourcesIndex; i < observer.c.length; i++) {
|
|
686
|
+
source = observer.c[i];
|
|
687
|
+
if (!source.f)
|
|
688
|
+
source.f = [observer];
|
|
677
689
|
else
|
|
678
|
-
source.
|
|
690
|
+
source.f.push(observer);
|
|
679
691
|
}
|
|
680
692
|
}
|
|
681
693
|
newSources = prevSources;
|
|
@@ -686,7 +698,7 @@ function runWithObserver(observer, run) {
|
|
|
686
698
|
function compute(owner, fn, observer) {
|
|
687
699
|
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
688
700
|
currentObserver = observer;
|
|
689
|
-
currentMask = (observer == null ? void 0 : observer.
|
|
701
|
+
currentMask = (observer == null ? void 0 : observer.Q) ?? DEFAULT_FLAGS;
|
|
690
702
|
notStale = true;
|
|
691
703
|
try {
|
|
692
704
|
return fn(observer ? observer.g : void 0);
|
|
@@ -759,13 +771,6 @@ function flattenArray(children, results = [], options) {
|
|
|
759
771
|
throw notReady;
|
|
760
772
|
return needsUnwrap;
|
|
761
773
|
}
|
|
762
|
-
function createBoundary(fn, queue) {
|
|
763
|
-
const owner = new Owner();
|
|
764
|
-
const parentQueue = owner.h;
|
|
765
|
-
parentQueue.addChild(owner.h = queue);
|
|
766
|
-
onCleanup(() => parentQueue.removeChild(owner.h));
|
|
767
|
-
return compute(owner, fn, null);
|
|
768
|
-
}
|
|
769
774
|
|
|
770
775
|
// src/core/effect.ts
|
|
771
776
|
var Effect = class extends Computation {
|
|
@@ -774,25 +779,25 @@ var Effect = class extends Computation {
|
|
|
774
779
|
C;
|
|
775
780
|
R = false;
|
|
776
781
|
N;
|
|
777
|
-
|
|
782
|
+
u;
|
|
778
783
|
constructor(initialValue, compute2, effect, error, options) {
|
|
779
784
|
super(initialValue, compute2, options);
|
|
780
785
|
this.L = effect;
|
|
781
786
|
this.M = error;
|
|
782
787
|
this.N = initialValue;
|
|
783
|
-
this.
|
|
784
|
-
if (this.
|
|
785
|
-
this.
|
|
788
|
+
this.u = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
789
|
+
if (this.u === EFFECT_RENDER) {
|
|
790
|
+
this.A = (p) => getClock() > this.h.created && !(this.d & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
786
791
|
}
|
|
787
|
-
this.
|
|
788
|
-
!(options == null ? void 0 : options.defer) && (this.
|
|
792
|
+
this.y();
|
|
793
|
+
!(options == null ? void 0 : options.defer) && (this.u === EFFECT_USER ? this.h.enqueue(this.u, this) : this.T());
|
|
789
794
|
}
|
|
790
795
|
write(value, flags = 0) {
|
|
791
796
|
var _a, _b;
|
|
792
797
|
if (this.a == STATE_DIRTY) {
|
|
793
|
-
const currentFlags = this.
|
|
794
|
-
this.
|
|
795
|
-
if (this.
|
|
798
|
+
const currentFlags = this.d;
|
|
799
|
+
this.d = flags;
|
|
800
|
+
if (this.u === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
796
801
|
(_b = (_a = this.h).S) == null ? void 0 : _b.call(_a, this);
|
|
797
802
|
}
|
|
798
803
|
}
|
|
@@ -802,21 +807,21 @@ var Effect = class extends Computation {
|
|
|
802
807
|
this.R = true;
|
|
803
808
|
return value;
|
|
804
809
|
}
|
|
805
|
-
|
|
810
|
+
r(state, skipQueue) {
|
|
806
811
|
if (this.a >= state || skipQueue)
|
|
807
812
|
return;
|
|
808
813
|
if (this.a === STATE_CLEAN)
|
|
809
|
-
this.h.enqueue(this.
|
|
814
|
+
this.h.enqueue(this.u, this);
|
|
810
815
|
this.a = state;
|
|
811
816
|
}
|
|
812
817
|
H(error) {
|
|
813
818
|
var _a, _b, _c;
|
|
814
819
|
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
815
|
-
if (this.
|
|
820
|
+
if (this.d & LOADING_BIT) {
|
|
816
821
|
(_c = (_b = this.h).S) == null ? void 0 : _c.call(_b, this);
|
|
817
822
|
}
|
|
818
|
-
this.
|
|
819
|
-
if (this.
|
|
823
|
+
this.d = ERROR_BIT;
|
|
824
|
+
if (this.u === EFFECT_USER) {
|
|
820
825
|
try {
|
|
821
826
|
return this.M ? this.C = this.M(error) : console.error(new EffectError(this.L, error));
|
|
822
827
|
} catch (e) {
|
|
@@ -825,7 +830,7 @@ var Effect = class extends Computation {
|
|
|
825
830
|
}
|
|
826
831
|
this.handleError(error);
|
|
827
832
|
}
|
|
828
|
-
|
|
833
|
+
z() {
|
|
829
834
|
var _a;
|
|
830
835
|
if (this.a === STATE_DISPOSED)
|
|
831
836
|
return;
|
|
@@ -834,9 +839,9 @@ var Effect = class extends Computation {
|
|
|
834
839
|
this.M = void 0;
|
|
835
840
|
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
836
841
|
this.C = void 0;
|
|
837
|
-
super.
|
|
842
|
+
super.z();
|
|
838
843
|
}
|
|
839
|
-
|
|
844
|
+
T() {
|
|
840
845
|
var _a;
|
|
841
846
|
if (this.R && this.a !== STATE_DISPOSED) {
|
|
842
847
|
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
@@ -854,76 +859,128 @@ var Effect = class extends Computation {
|
|
|
854
859
|
var EagerComputation = class extends Computation {
|
|
855
860
|
constructor(initialValue, compute2, options) {
|
|
856
861
|
super(initialValue, compute2, options);
|
|
857
|
-
!(options == null ? void 0 : options.defer) && this.
|
|
862
|
+
!(options == null ? void 0 : options.defer) && this.y();
|
|
858
863
|
}
|
|
859
|
-
|
|
864
|
+
r(state, skipQueue) {
|
|
860
865
|
if (this.a >= state && !this.K)
|
|
861
866
|
return;
|
|
862
867
|
if (this.a === STATE_CLEAN && !skipQueue)
|
|
863
868
|
this.h.enqueue(EFFECT_PURE, this);
|
|
864
|
-
super.
|
|
869
|
+
super.r(state, skipQueue);
|
|
865
870
|
}
|
|
866
871
|
};
|
|
867
872
|
var ProjectionComputation = class extends Computation {
|
|
868
873
|
constructor(compute2) {
|
|
869
|
-
super(
|
|
874
|
+
super(void 0, compute2);
|
|
870
875
|
}
|
|
871
|
-
|
|
876
|
+
r(state, skipQueue) {
|
|
872
877
|
if (this.a >= state && !this.K)
|
|
873
878
|
return;
|
|
874
879
|
if (this.a === STATE_CLEAN && !skipQueue)
|
|
875
880
|
this.h.enqueue(EFFECT_PURE, this);
|
|
876
|
-
super.
|
|
881
|
+
super.r(state, true);
|
|
877
882
|
}
|
|
878
883
|
};
|
|
879
884
|
|
|
880
|
-
// src/core/
|
|
885
|
+
// src/core/boundaries.ts
|
|
886
|
+
function createBoundary(owner, fn, queue) {
|
|
887
|
+
if (queue) {
|
|
888
|
+
const parentQueue = owner.h;
|
|
889
|
+
parentQueue.addChild(owner.h = queue);
|
|
890
|
+
onCleanup(() => parentQueue.removeChild(owner.h));
|
|
891
|
+
}
|
|
892
|
+
return compute(
|
|
893
|
+
owner,
|
|
894
|
+
() => {
|
|
895
|
+
const c = new Computation(void 0, fn);
|
|
896
|
+
return new EagerComputation(void 0, () => flatten(c.wait()), { defer: true });
|
|
897
|
+
},
|
|
898
|
+
null
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
function createDecision(main, condition, fallback) {
|
|
902
|
+
const decision = new Computation(void 0, () => {
|
|
903
|
+
if (!condition.read()) {
|
|
904
|
+
const resolved = main.read();
|
|
905
|
+
if (!condition.read())
|
|
906
|
+
return resolved;
|
|
907
|
+
}
|
|
908
|
+
return fallback();
|
|
909
|
+
});
|
|
910
|
+
return decision.read.bind(decision);
|
|
911
|
+
}
|
|
881
912
|
var SuspenseQueue = class extends Queue {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
T = new Computation(false, null);
|
|
913
|
+
b = /* @__PURE__ */ new Set();
|
|
914
|
+
p = new Computation(false, null);
|
|
885
915
|
run(type) {
|
|
886
|
-
if (type && this.
|
|
916
|
+
if (type && this.p.read())
|
|
887
917
|
return;
|
|
888
918
|
return super.run(type);
|
|
889
919
|
}
|
|
890
920
|
S(node) {
|
|
891
|
-
if (node.
|
|
892
|
-
this.
|
|
893
|
-
if (
|
|
894
|
-
this.
|
|
895
|
-
this.T.write(true);
|
|
896
|
-
}
|
|
921
|
+
if (node.d & LOADING_BIT) {
|
|
922
|
+
this.b.add(node);
|
|
923
|
+
if (this.b.size === 1)
|
|
924
|
+
this.p.write(true);
|
|
897
925
|
} else {
|
|
898
|
-
this.
|
|
899
|
-
if (this.
|
|
900
|
-
this.
|
|
901
|
-
this.T.write(false);
|
|
902
|
-
}
|
|
926
|
+
this.b.delete(node);
|
|
927
|
+
if (this.b.size === 0)
|
|
928
|
+
this.p.write(false);
|
|
903
929
|
}
|
|
904
930
|
}
|
|
905
931
|
};
|
|
906
|
-
|
|
907
|
-
|
|
932
|
+
function createSuspense(fn, fallback) {
|
|
933
|
+
const owner = new Owner();
|
|
934
|
+
const queue = new SuspenseQueue();
|
|
935
|
+
const tree = createBoundary(owner, fn, queue);
|
|
936
|
+
const ogWrite = tree.write;
|
|
937
|
+
tree.write = function(value, flags = 0) {
|
|
908
938
|
var _a, _b;
|
|
909
|
-
const currentFlags = this.
|
|
939
|
+
const currentFlags = this.d;
|
|
910
940
|
const dirty = this.a === STATE_DIRTY;
|
|
911
|
-
|
|
941
|
+
ogWrite.call(this, value, flags);
|
|
912
942
|
if (dirty && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
913
943
|
(_b = (_a = this.h).S) == null ? void 0 : _b.call(_a, this);
|
|
914
944
|
}
|
|
915
945
|
return this.g;
|
|
946
|
+
};
|
|
947
|
+
return createDecision(tree, queue.p, fallback);
|
|
948
|
+
}
|
|
949
|
+
function createErrorBoundary(fn, fallback) {
|
|
950
|
+
const owner = new Owner();
|
|
951
|
+
const error = new Computation(void 0, null);
|
|
952
|
+
const nodes = /* @__PURE__ */ new Set();
|
|
953
|
+
function handler(err, node) {
|
|
954
|
+
if (nodes.has(node))
|
|
955
|
+
return;
|
|
956
|
+
compute(
|
|
957
|
+
node,
|
|
958
|
+
() => onCleanup(() => {
|
|
959
|
+
nodes.delete(node);
|
|
960
|
+
if (!nodes.size)
|
|
961
|
+
error.write(void 0);
|
|
962
|
+
}),
|
|
963
|
+
null
|
|
964
|
+
);
|
|
965
|
+
nodes.add(node);
|
|
966
|
+
if (nodes.size === 1)
|
|
967
|
+
error.write({ G: err });
|
|
916
968
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
969
|
+
owner.addErrorHandler(handler);
|
|
970
|
+
const tree = createBoundary(owner, fn);
|
|
971
|
+
tree.H = tree.handleError;
|
|
972
|
+
return createDecision(
|
|
973
|
+
tree,
|
|
974
|
+
error,
|
|
975
|
+
() => fallback(error.read().G, () => {
|
|
976
|
+
var _a;
|
|
977
|
+
incrementClock();
|
|
978
|
+
for (let node of nodes) {
|
|
979
|
+
node.a = STATE_DIRTY;
|
|
980
|
+
(_a = node.h) == null ? void 0 : _a.enqueue(node.u, node);
|
|
981
|
+
}
|
|
982
|
+
})
|
|
983
|
+
);
|
|
927
984
|
}
|
|
928
985
|
|
|
929
986
|
// src/signals.ts
|
|
@@ -950,79 +1007,66 @@ function createMemo(compute2, value, options) {
|
|
|
950
1007
|
);
|
|
951
1008
|
let resolvedValue;
|
|
952
1009
|
return () => {
|
|
953
|
-
var _a, _b
|
|
1010
|
+
var _a, _b;
|
|
954
1011
|
if (node) {
|
|
1012
|
+
if (node.a === STATE_DISPOSED) {
|
|
1013
|
+
node = void 0;
|
|
1014
|
+
return resolvedValue;
|
|
1015
|
+
}
|
|
955
1016
|
resolvedValue = node.wait();
|
|
956
|
-
if (!((_a = node.
|
|
1017
|
+
if (!((_a = node.c) == null ? void 0 : _a.length) && ((_b = node.l) == null ? void 0 : _b.x) !== node) {
|
|
957
1018
|
node.dispose();
|
|
958
1019
|
node = void 0;
|
|
959
|
-
} else if (!node.t && !((_c = node.e) == null ? void 0 : _c.length)) {
|
|
960
|
-
node.dispose();
|
|
961
|
-
node.a = STATE_DIRTY;
|
|
962
1020
|
}
|
|
963
1021
|
}
|
|
964
1022
|
return resolvedValue;
|
|
965
1023
|
};
|
|
966
1024
|
}
|
|
967
1025
|
function createAsync(compute2, value, options) {
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
{
|
|
971
|
-
g: value
|
|
972
|
-
},
|
|
1026
|
+
const node = new EagerComputation(
|
|
1027
|
+
value,
|
|
973
1028
|
(p) => {
|
|
974
|
-
const
|
|
975
|
-
const source = compute2(value2);
|
|
1029
|
+
const source = compute2(p);
|
|
976
1030
|
const isPromise = source instanceof Promise;
|
|
977
1031
|
const iterator = source[Symbol.asyncIterator];
|
|
978
1032
|
if (!isPromise && !iterator) {
|
|
979
|
-
return
|
|
980
|
-
wait() {
|
|
981
|
-
return source;
|
|
982
|
-
},
|
|
983
|
-
g: source
|
|
984
|
-
};
|
|
1033
|
+
return source;
|
|
985
1034
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
signal.wait = function() {
|
|
989
|
-
if (signal.f & ERROR_BIT && signal.y <= getClock()) {
|
|
990
|
-
lhs.q(STATE_DIRTY);
|
|
991
|
-
throw new NotReadyError();
|
|
992
|
-
}
|
|
993
|
-
return w.call(this);
|
|
994
|
-
};
|
|
995
|
-
signal.write(UNCHANGED, LOADING_BIT | (uninitialized ? UNINITIALIZED_BIT : 0));
|
|
1035
|
+
let abort = false;
|
|
1036
|
+
onCleanup(() => abort = true);
|
|
996
1037
|
if (isPromise) {
|
|
997
1038
|
source.then(
|
|
998
1039
|
(value3) => {
|
|
999
|
-
|
|
1000
|
-
|
|
1040
|
+
if (abort)
|
|
1041
|
+
return;
|
|
1042
|
+
node.write(value3, 0, true);
|
|
1001
1043
|
},
|
|
1002
1044
|
(error) => {
|
|
1003
|
-
|
|
1004
|
-
|
|
1045
|
+
if (abort)
|
|
1046
|
+
return;
|
|
1047
|
+
node.H(error);
|
|
1005
1048
|
}
|
|
1006
1049
|
);
|
|
1007
1050
|
} else {
|
|
1008
|
-
let abort = false;
|
|
1009
|
-
onCleanup(() => abort = true);
|
|
1010
1051
|
(async () => {
|
|
1011
1052
|
try {
|
|
1012
1053
|
for await (let value3 of source) {
|
|
1013
1054
|
if (abort)
|
|
1014
1055
|
return;
|
|
1015
|
-
|
|
1056
|
+
node.write(value3, 0, true);
|
|
1016
1057
|
}
|
|
1017
1058
|
} catch (error) {
|
|
1018
|
-
|
|
1059
|
+
if (abort)
|
|
1060
|
+
return;
|
|
1061
|
+
node.write(error, ERROR_BIT);
|
|
1019
1062
|
}
|
|
1020
1063
|
})();
|
|
1021
1064
|
}
|
|
1022
|
-
|
|
1023
|
-
}
|
|
1065
|
+
throw new NotReadyError();
|
|
1066
|
+
},
|
|
1067
|
+
options
|
|
1024
1068
|
);
|
|
1025
|
-
return
|
|
1069
|
+
return node.wait.bind(node);
|
|
1026
1070
|
}
|
|
1027
1071
|
function createEffect(compute2, effect, error, value, options) {
|
|
1028
1072
|
void new Effect(
|
|
@@ -1039,63 +1083,13 @@ function createRenderEffect(compute2, effect, value, options) {
|
|
|
1039
1083
|
...options
|
|
1040
1084
|
});
|
|
1041
1085
|
}
|
|
1042
|
-
function createRoot(init) {
|
|
1043
|
-
const owner = new Owner();
|
|
1086
|
+
function createRoot(init, options) {
|
|
1087
|
+
const owner = new Owner(options == null ? void 0 : options.id);
|
|
1044
1088
|
return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
|
|
1045
1089
|
}
|
|
1046
1090
|
function runWithOwner(owner, run) {
|
|
1047
1091
|
return compute(owner, run, null);
|
|
1048
1092
|
}
|
|
1049
|
-
function createErrorBoundary(fn, fallback) {
|
|
1050
|
-
const owner = new Owner();
|
|
1051
|
-
const error = new Computation(void 0, null);
|
|
1052
|
-
const nodes = /* @__PURE__ */ new Set();
|
|
1053
|
-
function handler(err, node) {
|
|
1054
|
-
if (nodes.has(node))
|
|
1055
|
-
return;
|
|
1056
|
-
compute(
|
|
1057
|
-
node,
|
|
1058
|
-
() => onCleanup(() => {
|
|
1059
|
-
nodes.delete(node);
|
|
1060
|
-
if (!nodes.size)
|
|
1061
|
-
error.write(void 0);
|
|
1062
|
-
}),
|
|
1063
|
-
null
|
|
1064
|
-
);
|
|
1065
|
-
nodes.add(node);
|
|
1066
|
-
if (nodes.size === 1)
|
|
1067
|
-
error.write({ G: err });
|
|
1068
|
-
}
|
|
1069
|
-
owner.m = owner.m ? [handler, ...owner.m] : [handler];
|
|
1070
|
-
const guarded = compute(
|
|
1071
|
-
owner,
|
|
1072
|
-
() => {
|
|
1073
|
-
const c = new Computation(void 0, fn);
|
|
1074
|
-
const f = new EagerComputation(void 0, () => flatten(c.read()), { defer: true });
|
|
1075
|
-
f.H = function(error2) {
|
|
1076
|
-
this.handleError(error2);
|
|
1077
|
-
};
|
|
1078
|
-
return f;
|
|
1079
|
-
},
|
|
1080
|
-
null
|
|
1081
|
-
);
|
|
1082
|
-
const decision = new Computation(null, () => {
|
|
1083
|
-
if (!error.read()) {
|
|
1084
|
-
const resolved = guarded.read();
|
|
1085
|
-
if (!error.read())
|
|
1086
|
-
return resolved;
|
|
1087
|
-
}
|
|
1088
|
-
return fallback(error.read().G, () => {
|
|
1089
|
-
var _a;
|
|
1090
|
-
incrementClock();
|
|
1091
|
-
for (let node of nodes) {
|
|
1092
|
-
node.a = STATE_DIRTY;
|
|
1093
|
-
(_a = node.h) == null ? void 0 : _a.enqueue(node.w, node);
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
});
|
|
1097
|
-
return decision.read.bind(decision);
|
|
1098
|
-
}
|
|
1099
1093
|
function resolve(fn) {
|
|
1100
1094
|
return new Promise((res, rej) => {
|
|
1101
1095
|
createRoot((dispose) => {
|
|
@@ -1148,8 +1142,10 @@ function wrap(source, node, wrapped) {
|
|
|
1148
1142
|
// src/store/store.ts
|
|
1149
1143
|
var $RAW = Symbol(0);
|
|
1150
1144
|
var $TRACK = Symbol(0);
|
|
1145
|
+
var $DEEP = Symbol(0);
|
|
1151
1146
|
var $TARGET = Symbol(0);
|
|
1152
1147
|
var $PROXY = Symbol(0);
|
|
1148
|
+
var PARENTS = /* @__PURE__ */ new WeakMap();
|
|
1153
1149
|
var STORE_VALUE = "v";
|
|
1154
1150
|
var STORE_NODE = "n";
|
|
1155
1151
|
var STORE_HAS = "h";
|
|
@@ -1172,11 +1168,11 @@ function wrap2(value) {
|
|
|
1172
1168
|
function isWrappable(obj) {
|
|
1173
1169
|
return obj != null && typeof obj === "object" && !Object.isFrozen(obj);
|
|
1174
1170
|
}
|
|
1175
|
-
function unwrap(item,
|
|
1171
|
+
function unwrap(item, deep2 = true, set) {
|
|
1176
1172
|
let result, unwrapped, v, prop;
|
|
1177
1173
|
if (result = item != null && item[$RAW])
|
|
1178
1174
|
return result;
|
|
1179
|
-
if (!
|
|
1175
|
+
if (!deep2)
|
|
1180
1176
|
return item;
|
|
1181
1177
|
if (!isWrappable(item) || (set == null ? void 0 : set.has(item)))
|
|
1182
1178
|
return item;
|
|
@@ -1186,11 +1182,11 @@ function unwrap(item, deep = true, set) {
|
|
|
1186
1182
|
if (Array.isArray(item)) {
|
|
1187
1183
|
for (let i = 0, l = item.length; i < l; i++) {
|
|
1188
1184
|
v = item[i];
|
|
1189
|
-
if ((unwrapped = unwrap(v,
|
|
1185
|
+
if ((unwrapped = unwrap(v, deep2, set)) !== v)
|
|
1190
1186
|
item[i] = unwrapped;
|
|
1191
1187
|
}
|
|
1192
1188
|
} else {
|
|
1193
|
-
if (!
|
|
1189
|
+
if (!deep2)
|
|
1194
1190
|
return item;
|
|
1195
1191
|
const keys = Object.keys(item);
|
|
1196
1192
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
@@ -1199,7 +1195,7 @@ function unwrap(item, deep = true, set) {
|
|
|
1199
1195
|
if (desc.get)
|
|
1200
1196
|
continue;
|
|
1201
1197
|
v = item[prop];
|
|
1202
|
-
if ((unwrapped = unwrap(v,
|
|
1198
|
+
if ((unwrapped = unwrap(v, deep2, set)) !== v)
|
|
1203
1199
|
item[prop] = unwrapped;
|
|
1204
1200
|
}
|
|
1205
1201
|
}
|
|
@@ -1232,8 +1228,8 @@ function proxyDescriptor(target, property) {
|
|
|
1232
1228
|
desc.get = () => target[STORE_VALUE][$PROXY][property];
|
|
1233
1229
|
return desc;
|
|
1234
1230
|
}
|
|
1235
|
-
function trackSelf(target) {
|
|
1236
|
-
getObserver() && getNode(getNodes(target, STORE_NODE),
|
|
1231
|
+
function trackSelf(target, symbol = $TRACK) {
|
|
1232
|
+
getObserver() && getNode(getNodes(target, STORE_NODE), symbol, void 0, false).read();
|
|
1237
1233
|
}
|
|
1238
1234
|
function ownKeys(target) {
|
|
1239
1235
|
trackSelf(target);
|
|
@@ -1248,8 +1244,8 @@ var proxyTraps = {
|
|
|
1248
1244
|
return target[STORE_VALUE];
|
|
1249
1245
|
if (property === $PROXY)
|
|
1250
1246
|
return receiver;
|
|
1251
|
-
if (property === $TRACK) {
|
|
1252
|
-
trackSelf(target);
|
|
1247
|
+
if (property === $TRACK || property === $DEEP) {
|
|
1248
|
+
trackSelf(target, property);
|
|
1253
1249
|
return receiver;
|
|
1254
1250
|
}
|
|
1255
1251
|
const nodes = getNodes(target, STORE_NODE);
|
|
@@ -1270,7 +1266,7 @@ var proxyTraps = {
|
|
|
1270
1266
|
let proto;
|
|
1271
1267
|
return !Array.isArray(storeValue) && (proto = Object.getPrototypeOf(storeValue)) && proto !== Object.prototype ? value.bind(storeValue) : value;
|
|
1272
1268
|
} else if (getObserver()) {
|
|
1273
|
-
|
|
1269
|
+
return getNode(nodes, property, isWrappable(value) ? wrap2(value) : value).read();
|
|
1274
1270
|
}
|
|
1275
1271
|
}
|
|
1276
1272
|
return isWrappable(value) ? wrap2(value) : value;
|
|
@@ -1297,7 +1293,7 @@ var proxyTraps = {
|
|
|
1297
1293
|
}
|
|
1298
1294
|
};
|
|
1299
1295
|
function setProperty(state, property, value, deleting = false) {
|
|
1300
|
-
var _a, _b, _c, _d, _e;
|
|
1296
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1301
1297
|
const prev = state[property];
|
|
1302
1298
|
if (!deleting && prev === value)
|
|
1303
1299
|
return;
|
|
@@ -1306,6 +1302,13 @@ function setProperty(state, property, value, deleting = false) {
|
|
|
1306
1302
|
delete state[property];
|
|
1307
1303
|
else
|
|
1308
1304
|
state[property] = value;
|
|
1305
|
+
const wrappable = isWrappable(value);
|
|
1306
|
+
if (isWrappable(prev)) {
|
|
1307
|
+
const parents = PARENTS.get(prev);
|
|
1308
|
+
parents && (parents instanceof Set ? parents.delete(state) : PARENTS.delete(prev));
|
|
1309
|
+
}
|
|
1310
|
+
if (recursivelyNotify(state) && wrappable)
|
|
1311
|
+
recursivelyAddParent(value[$RAW] || value, state);
|
|
1309
1312
|
const target = (_a = state[$PROXY]) == null ? void 0 : _a[$TARGET];
|
|
1310
1313
|
if (!target)
|
|
1311
1314
|
return;
|
|
@@ -1314,15 +1317,55 @@ function setProperty(state, property, value, deleting = false) {
|
|
|
1314
1317
|
else
|
|
1315
1318
|
(_e = (_d = target[STORE_HAS]) == null ? void 0 : _d[property]) == null ? void 0 : _e.write(true);
|
|
1316
1319
|
const nodes = getNodes(target, STORE_NODE);
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1320
|
+
(_f = nodes[property]) == null ? void 0 : _f.write(wrappable ? wrap2(value) : value);
|
|
1321
|
+
Array.isArray(state) && state.length !== len && ((_g = nodes.length) == null ? void 0 : _g.write(state.length));
|
|
1322
|
+
(_h = nodes[$TRACK]) == null ? void 0 : _h.write(void 0);
|
|
1323
|
+
}
|
|
1324
|
+
function recursivelyNotify(state) {
|
|
1325
|
+
var _a, _b;
|
|
1326
|
+
let target = (_a = state[$PROXY]) == null ? void 0 : _a[$TARGET];
|
|
1327
|
+
let notified = false;
|
|
1328
|
+
target && ((_b = getNodes(target, STORE_NODE)[$DEEP]) == null ? void 0 : _b.write(void 0), notified = true);
|
|
1329
|
+
const parents = PARENTS.get(state);
|
|
1330
|
+
if (!parents)
|
|
1331
|
+
return notified;
|
|
1332
|
+
if (parents instanceof Set) {
|
|
1333
|
+
for (let parent of parents)
|
|
1334
|
+
notified = recursivelyNotify(parent) || notified;
|
|
1335
|
+
} else
|
|
1336
|
+
notified = recursivelyNotify(parents) || notified;
|
|
1337
|
+
return notified;
|
|
1338
|
+
}
|
|
1339
|
+
function recursivelyAddParent(state, parent) {
|
|
1340
|
+
if (parent) {
|
|
1341
|
+
let parents = PARENTS.get(state);
|
|
1342
|
+
if (!parents)
|
|
1343
|
+
PARENTS.set(state, parent);
|
|
1344
|
+
else if (parents !== parent) {
|
|
1345
|
+
if (!(parents instanceof Set))
|
|
1346
|
+
PARENTS.set(state, parents = /* @__PURE__ */ new Set([parents]));
|
|
1347
|
+
else if (parents.has(parent))
|
|
1348
|
+
return;
|
|
1349
|
+
parents.add(parent);
|
|
1350
|
+
} else
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
if (Array.isArray(state)) {
|
|
1354
|
+
for (let i = 0; i < state.length; i++) {
|
|
1355
|
+
const item = state[i];
|
|
1356
|
+
isWrappable(item) && recursivelyAddParent(item[$RAW] || item, state);
|
|
1357
|
+
}
|
|
1358
|
+
} else {
|
|
1359
|
+
const keys = Object.keys(state);
|
|
1360
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1361
|
+
const item = state[keys[i]];
|
|
1362
|
+
isWrappable(item) && recursivelyAddParent(item[$RAW] || item, state);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1322
1365
|
}
|
|
1323
1366
|
function createStore(first, second) {
|
|
1324
1367
|
const derived = typeof first === "function", store = derived ? second : first;
|
|
1325
|
-
const unwrappedStore = unwrap(store
|
|
1368
|
+
const unwrappedStore = unwrap(store);
|
|
1326
1369
|
let wrappedStore = wrap2(unwrappedStore);
|
|
1327
1370
|
const setStore = (fn) => {
|
|
1328
1371
|
try {
|
|
@@ -1336,6 +1379,10 @@ function createStore(first, second) {
|
|
|
1336
1379
|
return wrapProjection(first, wrappedStore, setStore);
|
|
1337
1380
|
return [wrappedStore, setStore];
|
|
1338
1381
|
}
|
|
1382
|
+
function deep(store) {
|
|
1383
|
+
recursivelyAddParent(store[$RAW] || store);
|
|
1384
|
+
return store[$DEEP];
|
|
1385
|
+
}
|
|
1339
1386
|
|
|
1340
1387
|
// src/store/reconcile.ts
|
|
1341
1388
|
function applyState(next, state, keyFn) {
|
|
@@ -1605,14 +1652,14 @@ function mapArray(list, map, options) {
|
|
|
1605
1652
|
I: new Owner(),
|
|
1606
1653
|
i: 0,
|
|
1607
1654
|
Y: list,
|
|
1608
|
-
|
|
1655
|
+
w: [],
|
|
1609
1656
|
D: map,
|
|
1610
|
-
|
|
1611
|
-
|
|
1657
|
+
e: [],
|
|
1658
|
+
b: [],
|
|
1612
1659
|
E: keyFn,
|
|
1613
1660
|
j: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1614
1661
|
k: map.length > 1 ? [] : void 0,
|
|
1615
|
-
|
|
1662
|
+
p: options == null ? void 0 : options.fallback
|
|
1616
1663
|
});
|
|
1617
1664
|
}
|
|
1618
1665
|
function updateKeyedMap() {
|
|
@@ -1637,38 +1684,38 @@ function updateKeyedMap() {
|
|
|
1637
1684
|
if (newLen === 0) {
|
|
1638
1685
|
if (this.i !== 0) {
|
|
1639
1686
|
this.I.dispose(false);
|
|
1640
|
-
this.
|
|
1641
|
-
this.
|
|
1642
|
-
this.
|
|
1687
|
+
this.b = [];
|
|
1688
|
+
this.w = [];
|
|
1689
|
+
this.e = [];
|
|
1643
1690
|
this.i = 0;
|
|
1644
1691
|
this.j && (this.j = []);
|
|
1645
1692
|
this.k && (this.k = []);
|
|
1646
1693
|
}
|
|
1647
|
-
if (this.
|
|
1648
|
-
this.
|
|
1649
|
-
this.
|
|
1650
|
-
this.
|
|
1694
|
+
if (this.p && !this.e[0]) {
|
|
1695
|
+
this.e[0] = compute(
|
|
1696
|
+
this.b[0] = new Owner(),
|
|
1697
|
+
this.p,
|
|
1651
1698
|
null
|
|
1652
1699
|
);
|
|
1653
1700
|
}
|
|
1654
1701
|
} else if (this.i === 0) {
|
|
1655
|
-
if (this.
|
|
1656
|
-
this.
|
|
1657
|
-
this.
|
|
1702
|
+
if (this.b[0])
|
|
1703
|
+
this.b[0].dispose();
|
|
1704
|
+
this.e = new Array(newLen);
|
|
1658
1705
|
for (j = 0; j < newLen; j++) {
|
|
1659
|
-
this.
|
|
1660
|
-
this.
|
|
1706
|
+
this.w[j] = newItems[j];
|
|
1707
|
+
this.e[j] = compute(this.b[j] = new Owner(), mapper, null);
|
|
1661
1708
|
}
|
|
1662
1709
|
this.i = newLen;
|
|
1663
1710
|
} else {
|
|
1664
1711
|
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;
|
|
1665
|
-
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.
|
|
1712
|
+
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.w[start] === newItems[start] || this.j && compare(this.E, this.w[start], newItems[start])); start++) {
|
|
1666
1713
|
if (this.j)
|
|
1667
1714
|
this.j[start].write(newItems[start]);
|
|
1668
1715
|
}
|
|
1669
|
-
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
1670
|
-
temp[newEnd] = this.
|
|
1671
|
-
tempNodes[newEnd] = this.
|
|
1716
|
+
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.e[end];
|
|
1718
|
+
tempNodes[newEnd] = this.b[end];
|
|
1672
1719
|
tempRows && (tempRows[newEnd] = this.j[end]);
|
|
1673
1720
|
tempIndexes && (tempIndexes[newEnd] = this.k[end]);
|
|
1674
1721
|
}
|
|
@@ -1682,23 +1729,23 @@ function updateKeyedMap() {
|
|
|
1682
1729
|
newIndices.set(key, j);
|
|
1683
1730
|
}
|
|
1684
1731
|
for (i = start; i <= end; i++) {
|
|
1685
|
-
item = this.
|
|
1732
|
+
item = this.w[i];
|
|
1686
1733
|
key = this.E ? this.E(item) : item;
|
|
1687
1734
|
j = newIndices.get(key);
|
|
1688
1735
|
if (j !== void 0 && j !== -1) {
|
|
1689
|
-
temp[j] = this.
|
|
1690
|
-
tempNodes[j] = this.
|
|
1736
|
+
temp[j] = this.e[i];
|
|
1737
|
+
tempNodes[j] = this.b[i];
|
|
1691
1738
|
tempRows && (tempRows[j] = this.j[i]);
|
|
1692
1739
|
tempIndexes && (tempIndexes[j] = this.k[i]);
|
|
1693
1740
|
j = newIndicesNext[j];
|
|
1694
1741
|
newIndices.set(key, j);
|
|
1695
1742
|
} else
|
|
1696
|
-
this.
|
|
1743
|
+
this.b[i].dispose();
|
|
1697
1744
|
}
|
|
1698
1745
|
for (j = start; j < newLen; j++) {
|
|
1699
1746
|
if (j in temp) {
|
|
1700
|
-
this.
|
|
1701
|
-
this.
|
|
1747
|
+
this.e[j] = temp[j];
|
|
1748
|
+
this.b[j] = tempNodes[j];
|
|
1702
1749
|
if (tempRows) {
|
|
1703
1750
|
this.j[j] = tempRows[j];
|
|
1704
1751
|
this.j[j].write(newItems[j]);
|
|
@@ -1708,26 +1755,26 @@ function updateKeyedMap() {
|
|
|
1708
1755
|
this.k[j].write(j);
|
|
1709
1756
|
}
|
|
1710
1757
|
} else {
|
|
1711
|
-
this.
|
|
1758
|
+
this.e[j] = compute(this.b[j] = new Owner(), mapper, null);
|
|
1712
1759
|
}
|
|
1713
1760
|
}
|
|
1714
|
-
this.
|
|
1715
|
-
this.
|
|
1761
|
+
this.e = this.e.slice(0, this.i = newLen);
|
|
1762
|
+
this.w = newItems.slice(0);
|
|
1716
1763
|
}
|
|
1717
1764
|
});
|
|
1718
|
-
return this.
|
|
1765
|
+
return this.e;
|
|
1719
1766
|
}
|
|
1720
1767
|
function repeat(count, map, options) {
|
|
1721
1768
|
return updateRepeat.bind({
|
|
1722
1769
|
I: new Owner(),
|
|
1723
1770
|
i: 0,
|
|
1724
|
-
|
|
1771
|
+
q: 0,
|
|
1725
1772
|
Z: count,
|
|
1726
1773
|
D: map,
|
|
1727
|
-
|
|
1728
|
-
|
|
1774
|
+
b: [],
|
|
1775
|
+
e: [],
|
|
1729
1776
|
_: options == null ? void 0 : options.from,
|
|
1730
|
-
|
|
1777
|
+
p: options == null ? void 0 : options.fallback
|
|
1731
1778
|
});
|
|
1732
1779
|
}
|
|
1733
1780
|
function updateRepeat() {
|
|
@@ -1738,60 +1785,60 @@ function updateRepeat() {
|
|
|
1738
1785
|
if (newLen === 0) {
|
|
1739
1786
|
if (this.i !== 0) {
|
|
1740
1787
|
this.I.dispose(false);
|
|
1741
|
-
this.
|
|
1742
|
-
this.
|
|
1788
|
+
this.b = [];
|
|
1789
|
+
this.e = [];
|
|
1743
1790
|
this.i = 0;
|
|
1744
1791
|
}
|
|
1745
|
-
if (this.
|
|
1746
|
-
this.
|
|
1747
|
-
this.
|
|
1748
|
-
this.
|
|
1792
|
+
if (this.p && !this.e[0]) {
|
|
1793
|
+
this.e[0] = compute(
|
|
1794
|
+
this.b[0] = new Owner(),
|
|
1795
|
+
this.p,
|
|
1749
1796
|
null
|
|
1750
1797
|
);
|
|
1751
1798
|
}
|
|
1752
1799
|
return;
|
|
1753
1800
|
}
|
|
1754
1801
|
const to = from + newLen;
|
|
1755
|
-
const prevTo = this.
|
|
1756
|
-
if (this.i === 0 && this.
|
|
1757
|
-
this.
|
|
1802
|
+
const prevTo = this.q + this.i;
|
|
1803
|
+
if (this.i === 0 && this.b[0])
|
|
1804
|
+
this.b[0].dispose();
|
|
1758
1805
|
for (let i = to; i < prevTo; i++)
|
|
1759
|
-
this.
|
|
1760
|
-
if (this.
|
|
1761
|
-
let i = this.
|
|
1806
|
+
this.b[i - this.q].dispose();
|
|
1807
|
+
if (this.q < from) {
|
|
1808
|
+
let i = this.q;
|
|
1762
1809
|
while (i < from && i < this.i)
|
|
1763
|
-
this.
|
|
1764
|
-
this.
|
|
1765
|
-
this.
|
|
1766
|
-
} else if (this.
|
|
1767
|
-
let i = prevTo - this.
|
|
1768
|
-
let difference = this.
|
|
1769
|
-
this.
|
|
1810
|
+
this.b[i++].dispose();
|
|
1811
|
+
this.b.splice(0, from - this.q);
|
|
1812
|
+
this.e.splice(0, from - this.q);
|
|
1813
|
+
} else if (this.q > from) {
|
|
1814
|
+
let i = prevTo - this.q - 1;
|
|
1815
|
+
let difference = this.q - from;
|
|
1816
|
+
this.b.length = this.e.length = newLen;
|
|
1770
1817
|
while (i >= difference) {
|
|
1771
|
-
this.
|
|
1772
|
-
this.
|
|
1818
|
+
this.b[i] = this.b[i - difference];
|
|
1819
|
+
this.e[i] = this.e[i - difference];
|
|
1773
1820
|
i--;
|
|
1774
1821
|
}
|
|
1775
1822
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
1776
|
-
this.
|
|
1777
|
-
this.
|
|
1823
|
+
this.e[i2] = compute(
|
|
1824
|
+
this.b[i2] = new Owner(),
|
|
1778
1825
|
() => this.D(i2 + from),
|
|
1779
1826
|
null
|
|
1780
1827
|
);
|
|
1781
1828
|
}
|
|
1782
1829
|
}
|
|
1783
1830
|
for (let i = prevTo; i < to; i++) {
|
|
1784
|
-
this.
|
|
1785
|
-
this.
|
|
1831
|
+
this.e[i - from] = compute(
|
|
1832
|
+
this.b[i - from] = new Owner(),
|
|
1786
1833
|
() => this.D(i),
|
|
1787
1834
|
null
|
|
1788
1835
|
);
|
|
1789
1836
|
}
|
|
1790
|
-
this.
|
|
1791
|
-
this.
|
|
1837
|
+
this.e = this.e.slice(0, newLen);
|
|
1838
|
+
this.q = from;
|
|
1792
1839
|
this.i = newLen;
|
|
1793
1840
|
});
|
|
1794
|
-
return this.
|
|
1841
|
+
return this.e;
|
|
1795
1842
|
}
|
|
1796
1843
|
function compare(key, a, b) {
|
|
1797
1844
|
return key ? key(a) === key(b) : true;
|
|
@@ -1808,9 +1855,7 @@ exports.NotReadyError = NotReadyError;
|
|
|
1808
1855
|
exports.Owner = Owner;
|
|
1809
1856
|
exports.Queue = Queue;
|
|
1810
1857
|
exports.SUPPORTS_PROXY = SUPPORTS_PROXY;
|
|
1811
|
-
exports.catchError = catchError;
|
|
1812
1858
|
exports.createAsync = createAsync;
|
|
1813
|
-
exports.createBoundary = createBoundary;
|
|
1814
1859
|
exports.createContext = createContext;
|
|
1815
1860
|
exports.createEffect = createEffect;
|
|
1816
1861
|
exports.createErrorBoundary = createErrorBoundary;
|
|
@@ -1821,6 +1866,7 @@ exports.createRoot = createRoot;
|
|
|
1821
1866
|
exports.createSignal = createSignal;
|
|
1822
1867
|
exports.createStore = createStore;
|
|
1823
1868
|
exports.createSuspense = createSuspense;
|
|
1869
|
+
exports.deep = deep;
|
|
1824
1870
|
exports.flatten = flatten;
|
|
1825
1871
|
exports.flushSync = flushSync;
|
|
1826
1872
|
exports.getContext = getContext;
|
|
@@ -1842,5 +1888,6 @@ exports.resolve = resolve;
|
|
|
1842
1888
|
exports.runWithObserver = runWithObserver;
|
|
1843
1889
|
exports.runWithOwner = runWithOwner;
|
|
1844
1890
|
exports.setContext = setContext;
|
|
1891
|
+
exports.tryCatch = tryCatch;
|
|
1845
1892
|
exports.untrack = untrack;
|
|
1846
1893
|
exports.unwrap = unwrap;
|