solid-js 1.8.2 → 1.8.4
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.cjs +1 -1
- package/dist/dev.js +534 -299
- package/dist/server.js +170 -75
- package/dist/solid.cjs +1 -1
- package/dist/solid.js +461 -257
- package/h/dist/h.js +34 -8
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -31
- package/package.json +7 -3
- package/store/dist/dev.js +114 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +105 -39
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +72 -9
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +228 -140
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +62 -31
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +166 -95
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.cjs +3 -0
- package/web/dist/dev.js +620 -81
- package/web/dist/server.cjs +17 -5
- package/web/dist/server.js +188 -95
- package/web/dist/storage.cjs +12 -0
- package/web/dist/storage.js +10 -0
- package/web/dist/web.cjs +3 -0
- package/web/dist/web.js +614 -80
- package/web/types/client.d.ts +8 -3
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
- package/web/types/server.d.ts +10 -1
- package/web/types/storage.d.ts +2 -0
package/dist/dev.js
CHANGED
|
@@ -52,9 +52,11 @@ function enqueue(taskQueue, task) {
|
|
|
52
52
|
let m = 0;
|
|
53
53
|
let n = taskQueue.length - 1;
|
|
54
54
|
while (m <= n) {
|
|
55
|
-
const k = n + m >> 1;
|
|
55
|
+
const k = (n + m) >> 1;
|
|
56
56
|
const cmp = task.expirationTime - taskQueue[k].expirationTime;
|
|
57
|
-
if (cmp > 0) m = k + 1;
|
|
57
|
+
if (cmp > 0) m = k + 1;
|
|
58
|
+
else if (cmp < 0) n = k - 1;
|
|
59
|
+
else return k;
|
|
58
60
|
}
|
|
59
61
|
return m;
|
|
60
62
|
}
|
|
@@ -159,26 +161,31 @@ const DevHooks = {
|
|
|
159
161
|
afterUpdate: null,
|
|
160
162
|
afterCreateOwner: null
|
|
161
163
|
};
|
|
162
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
164
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
163
165
|
function createRoot(fn, detachedOwner) {
|
|
164
166
|
const listener = Listener,
|
|
165
167
|
owner = Owner,
|
|
166
168
|
unowned = fn.length === 0,
|
|
167
169
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
168
|
-
root = unowned
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
170
|
+
root = unowned
|
|
171
|
+
? {
|
|
172
|
+
owned: null,
|
|
173
|
+
cleanups: null,
|
|
174
|
+
context: null,
|
|
175
|
+
owner: null
|
|
176
|
+
}
|
|
177
|
+
: {
|
|
178
|
+
owned: null,
|
|
179
|
+
cleanups: null,
|
|
180
|
+
context: current ? current.context : null,
|
|
181
|
+
owner: current
|
|
182
|
+
},
|
|
183
|
+
updateFn = unowned
|
|
184
|
+
? () =>
|
|
185
|
+
fn(() => {
|
|
186
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
187
|
+
})
|
|
188
|
+
: () => fn(() => untrack(() => cleanNode(root)));
|
|
182
189
|
DevHooks.afterCreateOwner && DevHooks.afterCreateOwner(root);
|
|
183
190
|
Owner = root;
|
|
184
191
|
Listener = null;
|
|
@@ -203,23 +210,26 @@ function createSignal(value, options) {
|
|
|
203
210
|
}
|
|
204
211
|
const setter = value => {
|
|
205
212
|
if (typeof value === "function") {
|
|
206
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
213
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
214
|
+
else value = value(s.value);
|
|
207
215
|
}
|
|
208
216
|
return writeSignal(s, value);
|
|
209
217
|
};
|
|
210
218
|
return [readSignal.bind(s), setter];
|
|
211
219
|
}
|
|
212
220
|
function createComputed(fn, value, options) {
|
|
213
|
-
const c = createComputation(fn, value, true, STALE, options
|
|
214
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
221
|
+
const c = createComputation(fn, value, true, STALE, options);
|
|
222
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
223
|
+
else updateComputation(c);
|
|
215
224
|
}
|
|
216
225
|
function createRenderEffect(fn, value, options) {
|
|
217
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
218
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
226
|
+
const c = createComputation(fn, value, false, STALE, options);
|
|
227
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
228
|
+
else updateComputation(c);
|
|
219
229
|
}
|
|
220
230
|
function createEffect(fn, value, options) {
|
|
221
231
|
runEffects = runUserEffects;
|
|
222
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
232
|
+
const c = createComputation(fn, value, false, STALE, options),
|
|
223
233
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
224
234
|
if (s) c.suspense = s;
|
|
225
235
|
if (!options || !options.render) c.user = true;
|
|
@@ -227,10 +237,16 @@ function createEffect(fn, value, options) {
|
|
|
227
237
|
}
|
|
228
238
|
function createReaction(onInvalidate, options) {
|
|
229
239
|
let fn;
|
|
230
|
-
const c = createComputation(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
240
|
+
const c = createComputation(
|
|
241
|
+
() => {
|
|
242
|
+
fn ? fn() : untrack(onInvalidate);
|
|
243
|
+
fn = undefined;
|
|
244
|
+
},
|
|
245
|
+
undefined,
|
|
246
|
+
false,
|
|
247
|
+
0,
|
|
248
|
+
options
|
|
249
|
+
),
|
|
234
250
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
235
251
|
if (s) c.suspense = s;
|
|
236
252
|
c.user = true;
|
|
@@ -241,7 +257,7 @@ function createReaction(onInvalidate, options) {
|
|
|
241
257
|
}
|
|
242
258
|
function createMemo(fn, value, options) {
|
|
243
259
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
244
|
-
const c = createComputation(fn, value, true, 0, options
|
|
260
|
+
const c = createComputation(fn, value, true, 0, options);
|
|
245
261
|
c.observers = null;
|
|
246
262
|
c.observerSlots = null;
|
|
247
263
|
c.comparator = options.equals || undefined;
|
|
@@ -258,7 +274,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
258
274
|
let source;
|
|
259
275
|
let fetcher;
|
|
260
276
|
let options;
|
|
261
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
277
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
262
278
|
source = true;
|
|
263
279
|
fetcher = pSource;
|
|
264
280
|
options = pFetcher || {};
|
|
@@ -272,7 +288,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
272
288
|
id = null,
|
|
273
289
|
loadedUnderTransition = false,
|
|
274
290
|
scheduled = false,
|
|
275
|
-
resolved =
|
|
291
|
+
resolved = "initialValue" in options,
|
|
276
292
|
dynamic = typeof source === "function" && createMemo(source);
|
|
277
293
|
const contexts = new Set(),
|
|
278
294
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -284,15 +300,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
284
300
|
if (sharedConfig.context) {
|
|
285
301
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
286
302
|
let v;
|
|
287
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
303
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
304
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
|
|
288
305
|
}
|
|
289
306
|
function loadEnd(p, v, error, key) {
|
|
290
307
|
if (pr === p) {
|
|
291
308
|
pr = null;
|
|
292
309
|
key !== undefined && (resolved = true);
|
|
293
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
294
|
-
|
|
295
|
-
|
|
310
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
311
|
+
queueMicrotask(() =>
|
|
312
|
+
options.onHydrated(key, {
|
|
313
|
+
value: v
|
|
314
|
+
})
|
|
315
|
+
);
|
|
296
316
|
initP = NO_INIT;
|
|
297
317
|
if (Transition && p && loadedUnderTransition) {
|
|
298
318
|
Transition.promises.delete(p);
|
|
@@ -323,7 +343,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
323
343
|
createComputed(() => {
|
|
324
344
|
track();
|
|
325
345
|
if (pr) {
|
|
326
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
346
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
347
|
+
else if (!contexts.has(c)) {
|
|
327
348
|
c.increment();
|
|
328
349
|
contexts.add(c);
|
|
329
350
|
}
|
|
@@ -342,26 +363,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
342
363
|
return;
|
|
343
364
|
}
|
|
344
365
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
345
|
-
const p =
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
366
|
+
const p =
|
|
367
|
+
initP !== NO_INIT
|
|
368
|
+
? initP
|
|
369
|
+
: untrack(() =>
|
|
370
|
+
fetcher(lookup, {
|
|
371
|
+
value: value(),
|
|
372
|
+
refetching
|
|
373
|
+
})
|
|
374
|
+
);
|
|
349
375
|
if (!isPromise(p)) {
|
|
350
376
|
loadEnd(pr, p, undefined, lookup);
|
|
351
377
|
return p;
|
|
352
378
|
}
|
|
353
379
|
if ("value" in p) {
|
|
354
|
-
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
380
|
+
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
381
|
+
else loadEnd(pr, undefined, undefined, lookup);
|
|
355
382
|
return p;
|
|
356
383
|
}
|
|
357
384
|
pr = p;
|
|
358
385
|
scheduled = true;
|
|
359
|
-
queueMicrotask(() => scheduled = false);
|
|
386
|
+
queueMicrotask(() => (scheduled = false));
|
|
360
387
|
runUpdates(() => {
|
|
361
388
|
setState(resolved ? "refreshing" : "pending");
|
|
362
389
|
trigger();
|
|
363
390
|
}, false);
|
|
364
|
-
return p.then(
|
|
391
|
+
return p.then(
|
|
392
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
393
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
394
|
+
);
|
|
365
395
|
}
|
|
366
396
|
Object.defineProperties(read, {
|
|
367
397
|
state: {
|
|
@@ -385,50 +415,81 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
385
415
|
}
|
|
386
416
|
}
|
|
387
417
|
});
|
|
388
|
-
if (dynamic) createComputed(() => load(false));
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
418
|
+
if (dynamic) createComputed(() => load(false));
|
|
419
|
+
else load(false);
|
|
420
|
+
return [
|
|
421
|
+
read,
|
|
422
|
+
{
|
|
423
|
+
refetch: load,
|
|
424
|
+
mutate: setValue
|
|
425
|
+
}
|
|
426
|
+
];
|
|
393
427
|
}
|
|
394
428
|
function createDeferred(source, options) {
|
|
395
429
|
let t,
|
|
396
430
|
timeout = options ? options.timeoutMs : undefined;
|
|
397
|
-
const node = createComputation(
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
431
|
+
const node = createComputation(
|
|
432
|
+
() => {
|
|
433
|
+
if (!t || !t.fn)
|
|
434
|
+
t = requestCallback(
|
|
435
|
+
() => setDeferred(() => node.value),
|
|
436
|
+
timeout !== undefined
|
|
437
|
+
? {
|
|
438
|
+
timeout
|
|
439
|
+
}
|
|
440
|
+
: undefined
|
|
441
|
+
);
|
|
442
|
+
return source();
|
|
443
|
+
},
|
|
444
|
+
undefined,
|
|
445
|
+
true
|
|
446
|
+
);
|
|
447
|
+
const [deferred, setDeferred] = createSignal(
|
|
448
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
449
|
+
options
|
|
450
|
+
);
|
|
404
451
|
updateComputation(node);
|
|
405
|
-
setDeferred(() =>
|
|
452
|
+
setDeferred(() =>
|
|
453
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
454
|
+
);
|
|
406
455
|
return deferred;
|
|
407
456
|
}
|
|
408
457
|
function createSelector(source, fn = equalFn, options) {
|
|
409
458
|
const subs = new Map();
|
|
410
|
-
const node = createComputation(
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
for (const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
459
|
+
const node = createComputation(
|
|
460
|
+
p => {
|
|
461
|
+
const v = source();
|
|
462
|
+
for (const [key, val] of subs.entries())
|
|
463
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
464
|
+
for (const c of val.values()) {
|
|
465
|
+
c.state = STALE;
|
|
466
|
+
if (c.pure) Updates.push(c);
|
|
467
|
+
else Effects.push(c);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return v;
|
|
471
|
+
},
|
|
472
|
+
undefined,
|
|
473
|
+
true,
|
|
474
|
+
STALE,
|
|
475
|
+
options
|
|
476
|
+
);
|
|
420
477
|
updateComputation(node);
|
|
421
478
|
return key => {
|
|
422
479
|
const listener = Listener;
|
|
423
480
|
if (listener) {
|
|
424
481
|
let l;
|
|
425
|
-
if (l = subs.get(key)) l.add(listener);
|
|
482
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
483
|
+
else subs.set(key, (l = new Set([listener])));
|
|
426
484
|
onCleanup(() => {
|
|
427
485
|
l.delete(listener);
|
|
428
486
|
!l.size && subs.delete(key);
|
|
429
487
|
});
|
|
430
488
|
}
|
|
431
|
-
return fn(
|
|
489
|
+
return fn(
|
|
490
|
+
key,
|
|
491
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
492
|
+
);
|
|
432
493
|
};
|
|
433
494
|
}
|
|
434
495
|
function batch(fn) {
|
|
@@ -467,7 +528,10 @@ function onMount(fn) {
|
|
|
467
528
|
createEffect(() => untrack(fn));
|
|
468
529
|
}
|
|
469
530
|
function onCleanup(fn) {
|
|
470
|
-
if (Owner === null)
|
|
531
|
+
if (Owner === null)
|
|
532
|
+
console.warn("cleanups created outside a `createRoot` or `render` will never be run");
|
|
533
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
534
|
+
else Owner.cleanups.push(fn);
|
|
471
535
|
return fn;
|
|
472
536
|
}
|
|
473
537
|
function catchError(fn, handler) {
|
|
@@ -521,15 +585,17 @@ function startTransition(fn) {
|
|
|
521
585
|
Owner = o;
|
|
522
586
|
let t;
|
|
523
587
|
if (Scheduler || SuspenseContext) {
|
|
524
|
-
t =
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
588
|
+
t =
|
|
589
|
+
Transition ||
|
|
590
|
+
(Transition = {
|
|
591
|
+
sources: new Set(),
|
|
592
|
+
effects: [],
|
|
593
|
+
promises: new Set(),
|
|
594
|
+
disposed: new Set(),
|
|
595
|
+
queue: new Set(),
|
|
596
|
+
running: true
|
|
597
|
+
});
|
|
598
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
533
599
|
t.running = true;
|
|
534
600
|
}
|
|
535
601
|
runUpdates(fn, false);
|
|
@@ -545,12 +611,18 @@ function resumeEffects(e) {
|
|
|
545
611
|
e.length = 0;
|
|
546
612
|
}
|
|
547
613
|
function devComponent(Comp, props) {
|
|
548
|
-
const c = createComputation(
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
614
|
+
const c = createComputation(
|
|
615
|
+
() =>
|
|
616
|
+
untrack(() => {
|
|
617
|
+
Object.assign(Comp, {
|
|
618
|
+
[$DEVCOMP]: true
|
|
619
|
+
});
|
|
620
|
+
return Comp(props);
|
|
621
|
+
}),
|
|
622
|
+
undefined,
|
|
623
|
+
true,
|
|
624
|
+
0
|
|
625
|
+
);
|
|
554
626
|
c.props = props;
|
|
555
627
|
c.observers = null;
|
|
556
628
|
c.observerSlots = null;
|
|
@@ -561,7 +633,8 @@ function devComponent(Comp, props) {
|
|
|
561
633
|
}
|
|
562
634
|
function registerGraph(value) {
|
|
563
635
|
if (!Owner) return;
|
|
564
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
636
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
637
|
+
else Owner.sourceMap = [value];
|
|
565
638
|
value.graph = Owner;
|
|
566
639
|
}
|
|
567
640
|
function createContext(defaultValue, options) {
|
|
@@ -573,13 +646,15 @@ function createContext(defaultValue, options) {
|
|
|
573
646
|
};
|
|
574
647
|
}
|
|
575
648
|
function useContext(context) {
|
|
576
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
649
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
650
|
+
? Owner.context[context.id]
|
|
651
|
+
: context.defaultValue;
|
|
577
652
|
}
|
|
578
653
|
function children(fn) {
|
|
579
654
|
const children = createMemo(fn);
|
|
580
655
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
581
656
|
name: "children"
|
|
582
|
-
})
|
|
657
|
+
});
|
|
583
658
|
memo.toArray = () => {
|
|
584
659
|
const c = memo();
|
|
585
660
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -611,7 +686,8 @@ function enableExternalSource(factory) {
|
|
|
611
686
|
function readSignal() {
|
|
612
687
|
const runningTransition = Transition && Transition.running;
|
|
613
688
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
614
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
689
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
690
|
+
else {
|
|
615
691
|
const updates = Updates;
|
|
616
692
|
Updates = null;
|
|
617
693
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -639,11 +715,12 @@ function readSignal() {
|
|
|
639
715
|
return this.value;
|
|
640
716
|
}
|
|
641
717
|
function writeSignal(node, value, isComp) {
|
|
642
|
-
let current =
|
|
718
|
+
let current =
|
|
719
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
643
720
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
644
721
|
if (Transition) {
|
|
645
722
|
const TransitionRunning = Transition.running;
|
|
646
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
723
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
647
724
|
Transition.sources.add(node);
|
|
648
725
|
node.tValue = value;
|
|
649
726
|
}
|
|
@@ -656,10 +733,12 @@ function writeSignal(node, value, isComp) {
|
|
|
656
733
|
const TransitionRunning = Transition && Transition.running;
|
|
657
734
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
658
735
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
659
|
-
if (o.pure) Updates.push(o);
|
|
736
|
+
if (o.pure) Updates.push(o);
|
|
737
|
+
else Effects.push(o);
|
|
660
738
|
if (o.observers) markDownstream(o);
|
|
661
739
|
}
|
|
662
|
-
if (!TransitionRunning) o.state = STALE;
|
|
740
|
+
if (!TransitionRunning) o.state = STALE;
|
|
741
|
+
else o.tState = STALE;
|
|
663
742
|
}
|
|
664
743
|
if (Updates.length > 10e5) {
|
|
665
744
|
Updates = [];
|
|
@@ -678,7 +757,11 @@ function updateComputation(node) {
|
|
|
678
757
|
listener = Listener,
|
|
679
758
|
time = ExecCount;
|
|
680
759
|
Listener = Owner = node;
|
|
681
|
-
runComputation(
|
|
760
|
+
runComputation(
|
|
761
|
+
node,
|
|
762
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
763
|
+
time
|
|
764
|
+
);
|
|
682
765
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
683
766
|
queueMicrotask(() => {
|
|
684
767
|
runUpdates(() => {
|
|
@@ -739,11 +822,15 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
739
822
|
c.state = 0;
|
|
740
823
|
c.tState = state;
|
|
741
824
|
}
|
|
742
|
-
if (Owner === null)
|
|
825
|
+
if (Owner === null)
|
|
826
|
+
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
827
|
+
else if (Owner !== UNOWNED) {
|
|
743
828
|
if (Transition && Transition.running && Owner.pure) {
|
|
744
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
829
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
830
|
+
else Owner.tOwned.push(c);
|
|
745
831
|
} else {
|
|
746
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
832
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
833
|
+
else Owner.owned.push(c);
|
|
747
834
|
}
|
|
748
835
|
}
|
|
749
836
|
if (options && options.name) c.name = options.name;
|
|
@@ -796,7 +883,8 @@ function runUpdates(fn, init) {
|
|
|
796
883
|
if (Updates) return fn();
|
|
797
884
|
let wait = false;
|
|
798
885
|
if (!init) Updates = [];
|
|
799
|
-
if (Effects) wait = true;
|
|
886
|
+
if (Effects) wait = true;
|
|
887
|
+
else Effects = [];
|
|
800
888
|
ExecCount++;
|
|
801
889
|
try {
|
|
802
890
|
const res = fn();
|
|
@@ -810,7 +898,8 @@ function runUpdates(fn, init) {
|
|
|
810
898
|
}
|
|
811
899
|
function completeUpdates(wait) {
|
|
812
900
|
if (Updates) {
|
|
813
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
901
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
902
|
+
else runQueue(Updates);
|
|
814
903
|
Updates = null;
|
|
815
904
|
}
|
|
816
905
|
if (wait) return;
|
|
@@ -850,7 +939,8 @@ function completeUpdates(wait) {
|
|
|
850
939
|
}
|
|
851
940
|
const e = Effects;
|
|
852
941
|
Effects = null;
|
|
853
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
942
|
+
if (e.length) runUpdates(() => runEffects(e), false);
|
|
943
|
+
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
854
944
|
if (res) res();
|
|
855
945
|
}
|
|
856
946
|
function runQueue(queue) {
|
|
@@ -878,7 +968,8 @@ function runUserEffects(queue) {
|
|
|
878
968
|
userLength = 0;
|
|
879
969
|
for (i = 0; i < queue.length; i++) {
|
|
880
970
|
const e = queue[i];
|
|
881
|
-
if (!e.user) runTop(e);
|
|
971
|
+
if (!e.user) runTop(e);
|
|
972
|
+
else queue[userLength++] = e;
|
|
882
973
|
}
|
|
883
974
|
if (sharedConfig.context) {
|
|
884
975
|
if (sharedConfig.count) {
|
|
@@ -896,13 +987,15 @@ function runUserEffects(queue) {
|
|
|
896
987
|
}
|
|
897
988
|
function lookUpstream(node, ignore) {
|
|
898
989
|
const runningTransition = Transition && Transition.running;
|
|
899
|
-
if (runningTransition) node.tState = 0;
|
|
990
|
+
if (runningTransition) node.tState = 0;
|
|
991
|
+
else node.state = 0;
|
|
900
992
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
901
993
|
const source = node.sources[i];
|
|
902
994
|
if (source.sources) {
|
|
903
995
|
const state = runningTransition ? source.tState : source.state;
|
|
904
996
|
if (state === STALE) {
|
|
905
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
997
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
998
|
+
runTop(source);
|
|
906
999
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
907
1000
|
}
|
|
908
1001
|
}
|
|
@@ -912,8 +1005,10 @@ function markDownstream(node) {
|
|
|
912
1005
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
913
1006
|
const o = node.observers[i];
|
|
914
1007
|
if (runningTransition ? !o.tState : !o.state) {
|
|
915
|
-
if (runningTransition) o.tState = PENDING;
|
|
916
|
-
|
|
1008
|
+
if (runningTransition) o.tState = PENDING;
|
|
1009
|
+
else o.state = PENDING;
|
|
1010
|
+
if (o.pure) Updates.push(o);
|
|
1011
|
+
else Effects.push(o);
|
|
917
1012
|
o.observers && markDownstream(o);
|
|
918
1013
|
}
|
|
919
1014
|
}
|
|
@@ -950,7 +1045,8 @@ function cleanNode(node) {
|
|
|
950
1045
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
951
1046
|
node.cleanups = null;
|
|
952
1047
|
}
|
|
953
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1048
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1049
|
+
else node.state = 0;
|
|
954
1050
|
delete node.sourceMap;
|
|
955
1051
|
}
|
|
956
1052
|
function reset(node, top) {
|
|
@@ -972,19 +1068,21 @@ function runErrors(err, fns, owner) {
|
|
|
972
1068
|
try {
|
|
973
1069
|
for (const f of fns) f(err);
|
|
974
1070
|
} catch (e) {
|
|
975
|
-
handleError(e, owner && owner.owner || null);
|
|
1071
|
+
handleError(e, (owner && owner.owner) || null);
|
|
976
1072
|
}
|
|
977
1073
|
}
|
|
978
1074
|
function handleError(err, owner = Owner) {
|
|
979
1075
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
980
1076
|
const error = castError(err);
|
|
981
1077
|
if (!fns) throw error;
|
|
982
|
-
if (Effects)
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1078
|
+
if (Effects)
|
|
1079
|
+
Effects.push({
|
|
1080
|
+
fn() {
|
|
1081
|
+
runErrors(error, fns, owner);
|
|
1082
|
+
},
|
|
1083
|
+
state: STALE
|
|
1084
|
+
});
|
|
1085
|
+
else runErrors(error, fns, owner);
|
|
988
1086
|
}
|
|
989
1087
|
function resolveChildren(children) {
|
|
990
1088
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1001,19 +1099,26 @@ function resolveChildren(children) {
|
|
|
1001
1099
|
function createProvider(id, options) {
|
|
1002
1100
|
return function provider(props) {
|
|
1003
1101
|
let res;
|
|
1004
|
-
createRenderEffect(
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1102
|
+
createRenderEffect(
|
|
1103
|
+
() =>
|
|
1104
|
+
(res = untrack(() => {
|
|
1105
|
+
Owner.context = {
|
|
1106
|
+
...Owner.context,
|
|
1107
|
+
[id]: props.value
|
|
1108
|
+
};
|
|
1109
|
+
return children(() => props.children);
|
|
1110
|
+
})),
|
|
1111
|
+
undefined,
|
|
1112
|
+
options
|
|
1113
|
+
);
|
|
1011
1114
|
return res;
|
|
1012
1115
|
};
|
|
1013
1116
|
}
|
|
1014
1117
|
function onError(fn) {
|
|
1015
1118
|
ERROR || (ERROR = Symbol("error"));
|
|
1016
|
-
if (Owner === null)
|
|
1119
|
+
if (Owner === null)
|
|
1120
|
+
console.warn("error handlers created outside a `createRoot` or `render` will never be run");
|
|
1121
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1017
1122
|
Owner.context = {
|
|
1018
1123
|
...Owner.context,
|
|
1019
1124
|
[ERROR]: [fn]
|
|
@@ -1042,7 +1147,8 @@ function observable(input) {
|
|
|
1042
1147
|
if (!(observer instanceof Object) || observer == null) {
|
|
1043
1148
|
throw new TypeError("Expected the observer to be an object.");
|
|
1044
1149
|
}
|
|
1045
|
-
const handler =
|
|
1150
|
+
const handler =
|
|
1151
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1046
1152
|
if (!handler) {
|
|
1047
1153
|
return {
|
|
1048
1154
|
unsubscribe() {}
|
|
@@ -1073,7 +1179,7 @@ function from(producer) {
|
|
|
1073
1179
|
});
|
|
1074
1180
|
if ("subscribe" in producer) {
|
|
1075
1181
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1076
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1182
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1077
1183
|
} else {
|
|
1078
1184
|
const clean = producer(set);
|
|
1079
1185
|
onCleanup(clean);
|
|
@@ -1125,8 +1231,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1125
1231
|
});
|
|
1126
1232
|
len = 1;
|
|
1127
1233
|
}
|
|
1128
|
-
}
|
|
1129
|
-
else if (len === 0) {
|
|
1234
|
+
} else if (len === 0) {
|
|
1130
1235
|
mapped = new Array(newLen);
|
|
1131
1236
|
for (j = 0; j < newLen; j++) {
|
|
1132
1237
|
items[j] = newItems[j];
|
|
@@ -1137,8 +1242,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1137
1242
|
temp = new Array(newLen);
|
|
1138
1243
|
tempdisposers = new Array(newLen);
|
|
1139
1244
|
indexes && (tempIndexes = new Array(newLen));
|
|
1140
|
-
for (
|
|
1141
|
-
|
|
1245
|
+
for (
|
|
1246
|
+
start = 0, end = Math.min(len, newLen);
|
|
1247
|
+
start < end && items[start] === newItems[start];
|
|
1248
|
+
start++
|
|
1249
|
+
);
|
|
1250
|
+
for (
|
|
1251
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1252
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1253
|
+
end--, newEnd--
|
|
1254
|
+
) {
|
|
1142
1255
|
temp[newEnd] = mapped[end];
|
|
1143
1256
|
tempdisposers[newEnd] = disposers[end];
|
|
1144
1257
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1172,7 +1285,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1172
1285
|
}
|
|
1173
1286
|
} else mapped[j] = createRoot(mapper);
|
|
1174
1287
|
}
|
|
1175
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1288
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1176
1289
|
items = newItems.slice(0);
|
|
1177
1290
|
}
|
|
1178
1291
|
return mapped;
|
|
@@ -1182,7 +1295,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1182
1295
|
if (indexes) {
|
|
1183
1296
|
const [s, set] = createSignal(j, {
|
|
1184
1297
|
name: "index"
|
|
1185
|
-
})
|
|
1298
|
+
});
|
|
1186
1299
|
indexes[j] = set;
|
|
1187
1300
|
return mapFn(newItems[j], s);
|
|
1188
1301
|
}
|
|
@@ -1240,13 +1353,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1240
1353
|
}
|
|
1241
1354
|
len = signals.length = disposers.length = newItems.length;
|
|
1242
1355
|
items = newItems.slice(0);
|
|
1243
|
-
return mapped = mapped.slice(0, len);
|
|
1356
|
+
return (mapped = mapped.slice(0, len));
|
|
1244
1357
|
});
|
|
1245
1358
|
function mapper(disposer) {
|
|
1246
1359
|
disposers[i] = disposer;
|
|
1247
1360
|
const [s, set] = createSignal(newItems[i], {
|
|
1248
1361
|
name: "value"
|
|
1249
|
-
})
|
|
1362
|
+
});
|
|
1250
1363
|
signals[i] = set;
|
|
1251
1364
|
return mapFn(s, i);
|
|
1252
1365
|
}
|
|
@@ -1262,7 +1375,7 @@ function createComponent(Comp, props) {
|
|
|
1262
1375
|
if (sharedConfig.context) {
|
|
1263
1376
|
const c = sharedConfig.context;
|
|
1264
1377
|
setHydrateContext(nextHydrateContext());
|
|
1265
|
-
const r = devComponent(Comp, props || {})
|
|
1378
|
+
const r = devComponent(Comp, props || {});
|
|
1266
1379
|
setHydrateContext(c);
|
|
1267
1380
|
return r;
|
|
1268
1381
|
}
|
|
@@ -1311,29 +1424,33 @@ function mergeProps(...sources) {
|
|
|
1311
1424
|
let proxy = false;
|
|
1312
1425
|
for (let i = 0; i < sources.length; i++) {
|
|
1313
1426
|
const s = sources[i];
|
|
1314
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1315
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1427
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1428
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1316
1429
|
}
|
|
1317
1430
|
if (proxy) {
|
|
1318
|
-
return new Proxy(
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1431
|
+
return new Proxy(
|
|
1432
|
+
{
|
|
1433
|
+
get(property) {
|
|
1434
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1435
|
+
const v = resolveSource(sources[i])[property];
|
|
1436
|
+
if (v !== undefined) return v;
|
|
1437
|
+
}
|
|
1438
|
+
},
|
|
1439
|
+
has(property) {
|
|
1440
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1441
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1442
|
+
}
|
|
1443
|
+
return false;
|
|
1444
|
+
},
|
|
1445
|
+
keys() {
|
|
1446
|
+
const keys = [];
|
|
1447
|
+
for (let i = 0; i < sources.length; i++)
|
|
1448
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1449
|
+
return [...new Set(keys)];
|
|
1328
1450
|
}
|
|
1329
|
-
return false;
|
|
1330
1451
|
},
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1334
|
-
return [...new Set(keys)];
|
|
1335
|
-
}
|
|
1336
|
-
}, propTraps);
|
|
1452
|
+
propTraps
|
|
1453
|
+
);
|
|
1337
1454
|
}
|
|
1338
1455
|
const target = {};
|
|
1339
1456
|
const sourcesMap = {};
|
|
@@ -1352,7 +1469,7 @@ function mergeProps(...sources) {
|
|
|
1352
1469
|
Object.defineProperty(target, key, {
|
|
1353
1470
|
enumerable: true,
|
|
1354
1471
|
configurable: true,
|
|
1355
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1472
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1356
1473
|
});
|
|
1357
1474
|
} else {
|
|
1358
1475
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1376,47 +1493,60 @@ function splitProps(props, ...keys) {
|
|
|
1376
1493
|
if ($PROXY in props) {
|
|
1377
1494
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1378
1495
|
const res = keys.map(k => {
|
|
1379
|
-
return new Proxy(
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1496
|
+
return new Proxy(
|
|
1497
|
+
{
|
|
1498
|
+
get(property) {
|
|
1499
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1500
|
+
},
|
|
1501
|
+
has(property) {
|
|
1502
|
+
return k.includes(property) && property in props;
|
|
1503
|
+
},
|
|
1504
|
+
keys() {
|
|
1505
|
+
return k.filter(property => property in props);
|
|
1506
|
+
}
|
|
1385
1507
|
},
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
}
|
|
1389
|
-
}, propTraps);
|
|
1508
|
+
propTraps
|
|
1509
|
+
);
|
|
1390
1510
|
});
|
|
1391
|
-
res.push(
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1511
|
+
res.push(
|
|
1512
|
+
new Proxy(
|
|
1513
|
+
{
|
|
1514
|
+
get(property) {
|
|
1515
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1516
|
+
},
|
|
1517
|
+
has(property) {
|
|
1518
|
+
return blocked.has(property) ? false : property in props;
|
|
1519
|
+
},
|
|
1520
|
+
keys() {
|
|
1521
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
propTraps
|
|
1525
|
+
)
|
|
1526
|
+
);
|
|
1402
1527
|
return res;
|
|
1403
1528
|
}
|
|
1404
1529
|
const otherObject = {};
|
|
1405
1530
|
const objects = keys.map(() => ({}));
|
|
1406
1531
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1407
1532
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1408
|
-
const isDefaultDesc =
|
|
1533
|
+
const isDefaultDesc =
|
|
1534
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1409
1535
|
let blocked = false;
|
|
1410
1536
|
let objectIndex = 0;
|
|
1411
1537
|
for (const k of keys) {
|
|
1412
1538
|
if (k.includes(propName)) {
|
|
1413
1539
|
blocked = true;
|
|
1414
|
-
isDefaultDesc
|
|
1540
|
+
isDefaultDesc
|
|
1541
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1542
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1415
1543
|
}
|
|
1416
1544
|
++objectIndex;
|
|
1417
1545
|
}
|
|
1418
1546
|
if (!blocked) {
|
|
1419
|
-
isDefaultDesc
|
|
1547
|
+
isDefaultDesc
|
|
1548
|
+
? (otherObject[propName] = desc.value)
|
|
1549
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1420
1550
|
}
|
|
1421
1551
|
}
|
|
1422
1552
|
return [...objects, otherObject];
|
|
@@ -1442,19 +1572,24 @@ function lazy(fn) {
|
|
|
1442
1572
|
comp = s;
|
|
1443
1573
|
}
|
|
1444
1574
|
let Comp;
|
|
1445
|
-
return createMemo(
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1575
|
+
return createMemo(
|
|
1576
|
+
() =>
|
|
1577
|
+
(Comp = comp()) &&
|
|
1578
|
+
untrack(() => {
|
|
1579
|
+
if (true)
|
|
1580
|
+
Object.assign(Comp, {
|
|
1581
|
+
[$DEVCOMP]: true
|
|
1582
|
+
});
|
|
1583
|
+
if (!ctx) return Comp(props);
|
|
1584
|
+
const c = sharedConfig.context;
|
|
1585
|
+
setHydrateContext(ctx);
|
|
1586
|
+
const r = Comp(props);
|
|
1587
|
+
setHydrateContext(c);
|
|
1588
|
+
return r;
|
|
1589
|
+
})
|
|
1590
|
+
);
|
|
1456
1591
|
};
|
|
1457
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1592
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1458
1593
|
return wrap;
|
|
1459
1594
|
}
|
|
1460
1595
|
let counter = 0;
|
|
@@ -1463,75 +1598,113 @@ function createUniqueId() {
|
|
|
1463
1598
|
return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
|
|
1464
1599
|
}
|
|
1465
1600
|
|
|
1466
|
-
const narrowedError = name =>
|
|
1601
|
+
const narrowedError = name =>
|
|
1602
|
+
`Attempting to access a stale value from <${name}> that could possibly be undefined. This may occur because you are reading the accessor returned from the component at a time where it has already been unmounted. We recommend cleaning up any stale timers or async, or reading from the initial condition.`;
|
|
1467
1603
|
function For(props) {
|
|
1468
1604
|
const fallback = "fallback" in props && {
|
|
1469
1605
|
fallback: () => props.fallback
|
|
1470
1606
|
};
|
|
1471
|
-
return createMemo(
|
|
1472
|
-
|
|
1473
|
-
|
|
1607
|
+
return createMemo(
|
|
1608
|
+
mapArray(() => props.each, props.children, fallback || undefined),
|
|
1609
|
+
undefined,
|
|
1610
|
+
{
|
|
1611
|
+
name: "value"
|
|
1612
|
+
}
|
|
1613
|
+
);
|
|
1474
1614
|
}
|
|
1475
1615
|
function Index(props) {
|
|
1476
1616
|
const fallback = "fallback" in props && {
|
|
1477
1617
|
fallback: () => props.fallback
|
|
1478
1618
|
};
|
|
1479
|
-
return createMemo(
|
|
1480
|
-
|
|
1481
|
-
|
|
1619
|
+
return createMemo(
|
|
1620
|
+
indexArray(() => props.each, props.children, fallback || undefined),
|
|
1621
|
+
undefined,
|
|
1622
|
+
{
|
|
1623
|
+
name: "value"
|
|
1624
|
+
}
|
|
1625
|
+
);
|
|
1482
1626
|
}
|
|
1483
1627
|
function Show(props) {
|
|
1484
1628
|
const keyed = props.keyed;
|
|
1485
1629
|
const condition = createMemo(() => props.when, undefined, {
|
|
1486
|
-
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1630
|
+
equals: (a, b) => (keyed ? a === b : !a === !b),
|
|
1487
1631
|
name: "condition"
|
|
1488
|
-
}
|
|
1489
|
-
return createMemo(
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1632
|
+
});
|
|
1633
|
+
return createMemo(
|
|
1634
|
+
() => {
|
|
1635
|
+
const c = condition();
|
|
1636
|
+
if (c) {
|
|
1637
|
+
const child = props.children;
|
|
1638
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1639
|
+
return fn
|
|
1640
|
+
? untrack(() =>
|
|
1641
|
+
child(
|
|
1642
|
+
keyed
|
|
1643
|
+
? c
|
|
1644
|
+
: () => {
|
|
1645
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1646
|
+
return props.when;
|
|
1647
|
+
}
|
|
1648
|
+
)
|
|
1649
|
+
)
|
|
1650
|
+
: child;
|
|
1651
|
+
}
|
|
1652
|
+
return props.fallback;
|
|
1653
|
+
},
|
|
1654
|
+
undefined,
|
|
1655
|
+
{
|
|
1656
|
+
name: "value"
|
|
1498
1657
|
}
|
|
1499
|
-
|
|
1500
|
-
}, undefined, {
|
|
1501
|
-
name: "value"
|
|
1502
|
-
} );
|
|
1658
|
+
);
|
|
1503
1659
|
}
|
|
1504
1660
|
function Switch(props) {
|
|
1505
1661
|
let keyed = false;
|
|
1506
|
-
const equals = (a, b) =>
|
|
1662
|
+
const equals = (a, b) =>
|
|
1663
|
+
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1507
1664
|
const conditions = children(() => props.children),
|
|
1508
|
-
evalConditions = createMemo(
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1665
|
+
evalConditions = createMemo(
|
|
1666
|
+
() => {
|
|
1667
|
+
let conds = conditions();
|
|
1668
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1669
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1670
|
+
const c = conds[i].when;
|
|
1671
|
+
if (c) {
|
|
1672
|
+
keyed = !!conds[i].keyed;
|
|
1673
|
+
return [i, c, conds[i]];
|
|
1674
|
+
}
|
|
1516
1675
|
}
|
|
1676
|
+
return [-1];
|
|
1677
|
+
},
|
|
1678
|
+
undefined,
|
|
1679
|
+
{
|
|
1680
|
+
equals,
|
|
1681
|
+
name: "eval conditions"
|
|
1517
1682
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1683
|
+
);
|
|
1684
|
+
return createMemo(
|
|
1685
|
+
() => {
|
|
1686
|
+
const [index, when, cond] = evalConditions();
|
|
1687
|
+
if (index < 0) return props.fallback;
|
|
1688
|
+
const c = cond.children;
|
|
1689
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1690
|
+
return fn
|
|
1691
|
+
? untrack(() =>
|
|
1692
|
+
c(
|
|
1693
|
+
keyed
|
|
1694
|
+
? when
|
|
1695
|
+
: () => {
|
|
1696
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1697
|
+
return cond.when;
|
|
1698
|
+
}
|
|
1699
|
+
)
|
|
1700
|
+
)
|
|
1701
|
+
: c;
|
|
1702
|
+
},
|
|
1703
|
+
undefined,
|
|
1704
|
+
{
|
|
1705
|
+
name: "value"
|
|
1706
|
+
}
|
|
1707
|
+
);
|
|
1535
1708
|
}
|
|
1536
1709
|
function Match(props) {
|
|
1537
1710
|
return props;
|
|
@@ -1542,27 +1715,33 @@ function resetErrorBoundaries() {
|
|
|
1542
1715
|
}
|
|
1543
1716
|
function ErrorBoundary(props) {
|
|
1544
1717
|
let err;
|
|
1545
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1718
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1719
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1546
1720
|
const [errored, setErrored] = createSignal(err, {
|
|
1547
1721
|
name: "errored"
|
|
1548
|
-
}
|
|
1722
|
+
});
|
|
1549
1723
|
Errors || (Errors = new Set());
|
|
1550
1724
|
Errors.add(setErrored);
|
|
1551
1725
|
onCleanup(() => Errors.delete(setErrored));
|
|
1552
|
-
return createMemo(
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1726
|
+
return createMemo(
|
|
1727
|
+
() => {
|
|
1728
|
+
let e;
|
|
1729
|
+
if ((e = errored())) {
|
|
1730
|
+
const f = props.fallback;
|
|
1731
|
+
if (typeof f !== "function" || f.length == 0) console.error(e);
|
|
1732
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1733
|
+
}
|
|
1734
|
+
return catchError(() => props.children, setErrored);
|
|
1735
|
+
},
|
|
1736
|
+
undefined,
|
|
1737
|
+
{
|
|
1738
|
+
name: "value"
|
|
1558
1739
|
}
|
|
1559
|
-
|
|
1560
|
-
}, undefined, {
|
|
1561
|
-
name: "value"
|
|
1562
|
-
} );
|
|
1740
|
+
);
|
|
1563
1741
|
}
|
|
1564
1742
|
|
|
1565
|
-
const suspenseListEquals = (a, b) =>
|
|
1743
|
+
const suspenseListEquals = (a, b) =>
|
|
1744
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1566
1745
|
const SuspenseListContext = createContext();
|
|
1567
1746
|
function SuspenseList(props) {
|
|
1568
1747
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1574,51 +1753,51 @@ function SuspenseList(props) {
|
|
|
1574
1753
|
if (listContext) {
|
|
1575
1754
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1576
1755
|
}
|
|
1577
|
-
const resolved = createMemo(
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
showContent = true,
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
const res = reg.map(() => ({
|
|
1589
|
-
showContent: all && showContent,
|
|
1590
|
-
showFallback
|
|
1591
|
-
}));
|
|
1592
|
-
res.inFallback = !all;
|
|
1593
|
-
return res;
|
|
1594
|
-
}
|
|
1595
|
-
let stop = false;
|
|
1596
|
-
let inFallback = prev.inFallback;
|
|
1597
|
-
const res = [];
|
|
1598
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1599
|
-
const n = reverse ? len - i - 1 : i,
|
|
1600
|
-
s = reg[n]();
|
|
1601
|
-
if (!stop && !s) {
|
|
1602
|
-
res[n] = {
|
|
1603
|
-
showContent,
|
|
1756
|
+
const resolved = createMemo(
|
|
1757
|
+
prev => {
|
|
1758
|
+
const reveal = props.revealOrder,
|
|
1759
|
+
tail = props.tail,
|
|
1760
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1761
|
+
reg = registry(),
|
|
1762
|
+
reverse = reveal === "backwards";
|
|
1763
|
+
if (reveal === "together") {
|
|
1764
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1765
|
+
const res = reg.map(() => ({
|
|
1766
|
+
showContent: all && showContent,
|
|
1604
1767
|
showFallback
|
|
1605
|
-
};
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
if (next) inFallback = true;
|
|
1609
|
-
res[n] = {
|
|
1610
|
-
showContent: next,
|
|
1611
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1612
|
-
};
|
|
1613
|
-
stop = true;
|
|
1768
|
+
}));
|
|
1769
|
+
res.inFallback = !all;
|
|
1770
|
+
return res;
|
|
1614
1771
|
}
|
|
1772
|
+
let stop = false;
|
|
1773
|
+
let inFallback = prev.inFallback;
|
|
1774
|
+
const res = [];
|
|
1775
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1776
|
+
const n = reverse ? len - i - 1 : i,
|
|
1777
|
+
s = reg[n]();
|
|
1778
|
+
if (!stop && !s) {
|
|
1779
|
+
res[n] = {
|
|
1780
|
+
showContent,
|
|
1781
|
+
showFallback
|
|
1782
|
+
};
|
|
1783
|
+
} else {
|
|
1784
|
+
const next = !stop;
|
|
1785
|
+
if (next) inFallback = true;
|
|
1786
|
+
res[n] = {
|
|
1787
|
+
showContent: next,
|
|
1788
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1789
|
+
};
|
|
1790
|
+
stop = true;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
if (!stop) inFallback = false;
|
|
1794
|
+
res.inFallback = inFallback;
|
|
1795
|
+
return res;
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
inFallback: false
|
|
1615
1799
|
}
|
|
1616
|
-
|
|
1617
|
-
res.inFallback = inFallback;
|
|
1618
|
-
return res;
|
|
1619
|
-
}, {
|
|
1620
|
-
inFallback: false
|
|
1621
|
-
});
|
|
1800
|
+
);
|
|
1622
1801
|
setWrapper(() => resolved);
|
|
1623
1802
|
return createComponent(SuspenseListContext.Provider, {
|
|
1624
1803
|
value: {
|
|
@@ -1662,7 +1841,7 @@ function Suspense(props) {
|
|
|
1662
1841
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1663
1842
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1664
1843
|
let ref = sharedConfig.load(key);
|
|
1665
|
-
if (ref && (typeof ref !== "object" ||
|
|
1844
|
+
if (ref && (typeof ref !== "object" || ref.status !== "success")) p = ref;
|
|
1666
1845
|
if (p && p !== "$$f") {
|
|
1667
1846
|
const [s, set] = createSignal(undefined, {
|
|
1668
1847
|
equals: false
|
|
@@ -1693,17 +1872,14 @@ function Suspense(props) {
|
|
|
1693
1872
|
ctx = sharedConfig.context;
|
|
1694
1873
|
if (flicker) {
|
|
1695
1874
|
flicker();
|
|
1696
|
-
return flicker = undefined;
|
|
1875
|
+
return (flicker = undefined);
|
|
1697
1876
|
}
|
|
1698
1877
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1699
1878
|
const rendered = createMemo(() => props.children);
|
|
1700
1879
|
return createMemo(prev => {
|
|
1701
1880
|
const inFallback = store.inFallback(),
|
|
1702
|
-
{
|
|
1703
|
-
|
|
1704
|
-
showFallback = true
|
|
1705
|
-
} = show ? show() : {};
|
|
1706
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1881
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1882
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1707
1883
|
store.resolved = true;
|
|
1708
1884
|
dispose && dispose();
|
|
1709
1885
|
dispose = ctx = p = undefined;
|
|
@@ -1733,9 +1909,68 @@ const DEV = {
|
|
|
1733
1909
|
hooks: DevHooks,
|
|
1734
1910
|
writeSignal,
|
|
1735
1911
|
registerGraph
|
|
1736
|
-
}
|
|
1912
|
+
};
|
|
1737
1913
|
if (globalThis) {
|
|
1738
|
-
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1914
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1915
|
+
else
|
|
1916
|
+
console.warn(
|
|
1917
|
+
"You appear to have multiple instances of Solid. This can lead to unexpected behavior."
|
|
1918
|
+
);
|
|
1739
1919
|
}
|
|
1740
1920
|
|
|
1741
|
-
export {
|
|
1921
|
+
export {
|
|
1922
|
+
$DEVCOMP,
|
|
1923
|
+
$PROXY,
|
|
1924
|
+
$TRACK,
|
|
1925
|
+
DEV,
|
|
1926
|
+
ErrorBoundary,
|
|
1927
|
+
For,
|
|
1928
|
+
Index,
|
|
1929
|
+
Match,
|
|
1930
|
+
Show,
|
|
1931
|
+
Suspense,
|
|
1932
|
+
SuspenseList,
|
|
1933
|
+
Switch,
|
|
1934
|
+
batch,
|
|
1935
|
+
cancelCallback,
|
|
1936
|
+
catchError,
|
|
1937
|
+
children,
|
|
1938
|
+
createComponent,
|
|
1939
|
+
createComputed,
|
|
1940
|
+
createContext,
|
|
1941
|
+
createDeferred,
|
|
1942
|
+
createEffect,
|
|
1943
|
+
createMemo,
|
|
1944
|
+
createReaction,
|
|
1945
|
+
createRenderEffect,
|
|
1946
|
+
createResource,
|
|
1947
|
+
createRoot,
|
|
1948
|
+
createSelector,
|
|
1949
|
+
createSignal,
|
|
1950
|
+
createUniqueId,
|
|
1951
|
+
enableExternalSource,
|
|
1952
|
+
enableHydration,
|
|
1953
|
+
enableScheduling,
|
|
1954
|
+
equalFn,
|
|
1955
|
+
from,
|
|
1956
|
+
getListener,
|
|
1957
|
+
getOwner,
|
|
1958
|
+
indexArray,
|
|
1959
|
+
lazy,
|
|
1960
|
+
mapArray,
|
|
1961
|
+
mergeProps,
|
|
1962
|
+
observable,
|
|
1963
|
+
on,
|
|
1964
|
+
onCleanup,
|
|
1965
|
+
onError,
|
|
1966
|
+
onMount,
|
|
1967
|
+
requestCallback,
|
|
1968
|
+
resetErrorBoundaries,
|
|
1969
|
+
runWithOwner,
|
|
1970
|
+
sharedConfig,
|
|
1971
|
+
splitProps,
|
|
1972
|
+
startTransition,
|
|
1973
|
+
untrack,
|
|
1974
|
+
useContext,
|
|
1975
|
+
useTransition
|
|
1976
|
+
};
|