solid-js 1.9.2 → 1.9.3
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 +559 -318
- package/dist/server.js +168 -74
- package/dist/solid.js +486 -276
- package/h/dist/h.js +40 -9
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +93 -91
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +219 -94
- package/html/types/lit.d.ts +52 -33
- package/package.json +1 -1
- package/store/dist/dev.js +123 -43
- package/store/dist/server.js +20 -8
- package/store/dist/store.js +114 -40
- 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 +25 -5
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +143 -157
- 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 +233 -142
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +71 -35
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +15 -15
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +169 -98
- 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.js +639 -89
- package/web/dist/server.cjs +13 -10
- package/web/dist/server.js +653 -118
- package/web/dist/web.js +627 -87
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +1 -1
- 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 +1 -1
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
|
}
|
|
@@ -179,20 +181,25 @@ function createRoot(fn, detachedOwner) {
|
|
|
179
181
|
owner = Owner,
|
|
180
182
|
unowned = fn.length === 0,
|
|
181
183
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
182
|
-
root = unowned
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
184
|
+
root = unowned
|
|
185
|
+
? {
|
|
186
|
+
owned: null,
|
|
187
|
+
cleanups: null,
|
|
188
|
+
context: null,
|
|
189
|
+
owner: null
|
|
190
|
+
}
|
|
191
|
+
: {
|
|
192
|
+
owned: null,
|
|
193
|
+
cleanups: null,
|
|
194
|
+
context: current ? current.context : null,
|
|
195
|
+
owner: current
|
|
196
|
+
},
|
|
197
|
+
updateFn = unowned
|
|
198
|
+
? () =>
|
|
199
|
+
fn(() => {
|
|
200
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
201
|
+
})
|
|
202
|
+
: () => fn(() => untrack(() => cleanNode(root)));
|
|
196
203
|
DevHooks.afterCreateOwner && DevHooks.afterCreateOwner(root);
|
|
197
204
|
Owner = root;
|
|
198
205
|
Listener = null;
|
|
@@ -218,23 +225,26 @@ function createSignal(value, options) {
|
|
|
218
225
|
}
|
|
219
226
|
const setter = value => {
|
|
220
227
|
if (typeof value === "function") {
|
|
221
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
228
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
229
|
+
else value = value(s.value);
|
|
222
230
|
}
|
|
223
231
|
return writeSignal(s, value);
|
|
224
232
|
};
|
|
225
233
|
return [readSignal.bind(s), setter];
|
|
226
234
|
}
|
|
227
235
|
function createComputed(fn, value, options) {
|
|
228
|
-
const c = createComputation(fn, value, true, STALE, options
|
|
229
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
236
|
+
const c = createComputation(fn, value, true, STALE, options);
|
|
237
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
238
|
+
else updateComputation(c);
|
|
230
239
|
}
|
|
231
240
|
function createRenderEffect(fn, value, options) {
|
|
232
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
233
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
241
|
+
const c = createComputation(fn, value, false, STALE, options);
|
|
242
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
243
|
+
else updateComputation(c);
|
|
234
244
|
}
|
|
235
245
|
function createEffect(fn, value, options) {
|
|
236
246
|
runEffects = runUserEffects;
|
|
237
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
247
|
+
const c = createComputation(fn, value, false, STALE, options),
|
|
238
248
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
239
249
|
if (s) c.suspense = s;
|
|
240
250
|
if (!options || !options.render) c.user = true;
|
|
@@ -242,10 +252,16 @@ function createEffect(fn, value, options) {
|
|
|
242
252
|
}
|
|
243
253
|
function createReaction(onInvalidate, options) {
|
|
244
254
|
let fn;
|
|
245
|
-
const c = createComputation(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
255
|
+
const c = createComputation(
|
|
256
|
+
() => {
|
|
257
|
+
fn ? fn() : untrack(onInvalidate);
|
|
258
|
+
fn = undefined;
|
|
259
|
+
},
|
|
260
|
+
undefined,
|
|
261
|
+
false,
|
|
262
|
+
0,
|
|
263
|
+
options
|
|
264
|
+
),
|
|
249
265
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
250
266
|
if (s) c.suspense = s;
|
|
251
267
|
c.user = true;
|
|
@@ -256,7 +272,7 @@ function createReaction(onInvalidate, options) {
|
|
|
256
272
|
}
|
|
257
273
|
function createMemo(fn, value, options) {
|
|
258
274
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
259
|
-
const c = createComputation(fn, value, true, 0, options
|
|
275
|
+
const c = createComputation(fn, value, true, 0, options);
|
|
260
276
|
c.observers = null;
|
|
261
277
|
c.observerSlots = null;
|
|
262
278
|
c.comparator = options.equals || undefined;
|
|
@@ -273,7 +289,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
273
289
|
let source;
|
|
274
290
|
let fetcher;
|
|
275
291
|
let options;
|
|
276
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
292
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
277
293
|
source = true;
|
|
278
294
|
fetcher = pSource;
|
|
279
295
|
options = pFetcher || {};
|
|
@@ -298,15 +314,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
298
314
|
[state, setState] = createSignal(resolved ? "ready" : "unresolved");
|
|
299
315
|
if (sharedConfig.context) {
|
|
300
316
|
id = sharedConfig.getNextContextId();
|
|
301
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
317
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
318
|
+
else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
|
|
302
319
|
}
|
|
303
320
|
function loadEnd(p, v, error, key) {
|
|
304
321
|
if (pr === p) {
|
|
305
322
|
pr = null;
|
|
306
323
|
key !== undefined && (resolved = true);
|
|
307
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
308
|
-
|
|
309
|
-
|
|
324
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
325
|
+
queueMicrotask(() =>
|
|
326
|
+
options.onHydrated(key, {
|
|
327
|
+
value: v
|
|
328
|
+
})
|
|
329
|
+
);
|
|
310
330
|
initP = NO_INIT;
|
|
311
331
|
if (Transition && p && loadedUnderTransition) {
|
|
312
332
|
Transition.promises.delete(p);
|
|
@@ -337,7 +357,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
337
357
|
createComputed(() => {
|
|
338
358
|
track();
|
|
339
359
|
if (pr) {
|
|
340
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
360
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
361
|
+
else if (!contexts.has(c)) {
|
|
341
362
|
c.increment();
|
|
342
363
|
contexts.add(c);
|
|
343
364
|
}
|
|
@@ -356,26 +377,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
356
377
|
return;
|
|
357
378
|
}
|
|
358
379
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
359
|
-
const p =
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
380
|
+
const p =
|
|
381
|
+
initP !== NO_INIT
|
|
382
|
+
? initP
|
|
383
|
+
: untrack(() =>
|
|
384
|
+
fetcher(lookup, {
|
|
385
|
+
value: value(),
|
|
386
|
+
refetching
|
|
387
|
+
})
|
|
388
|
+
);
|
|
363
389
|
if (!isPromise(p)) {
|
|
364
390
|
loadEnd(pr, p, undefined, lookup);
|
|
365
391
|
return p;
|
|
366
392
|
}
|
|
367
393
|
pr = p;
|
|
368
394
|
if ("value" in p) {
|
|
369
|
-
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
395
|
+
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
396
|
+
else loadEnd(pr, undefined, castError(p.value), lookup);
|
|
370
397
|
return p;
|
|
371
398
|
}
|
|
372
399
|
scheduled = true;
|
|
373
|
-
queueMicrotask(() => scheduled = false);
|
|
400
|
+
queueMicrotask(() => (scheduled = false));
|
|
374
401
|
runUpdates(() => {
|
|
375
402
|
setState(resolved ? "refreshing" : "pending");
|
|
376
403
|
trigger();
|
|
377
404
|
}, false);
|
|
378
|
-
return p.then(
|
|
405
|
+
return p.then(
|
|
406
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
407
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
408
|
+
);
|
|
379
409
|
}
|
|
380
410
|
Object.defineProperties(read, {
|
|
381
411
|
state: {
|
|
@@ -399,50 +429,81 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
399
429
|
}
|
|
400
430
|
}
|
|
401
431
|
});
|
|
402
|
-
if (dynamic) createComputed(() => load(false));
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
432
|
+
if (dynamic) createComputed(() => load(false));
|
|
433
|
+
else load(false);
|
|
434
|
+
return [
|
|
435
|
+
read,
|
|
436
|
+
{
|
|
437
|
+
refetch: load,
|
|
438
|
+
mutate: setValue
|
|
439
|
+
}
|
|
440
|
+
];
|
|
407
441
|
}
|
|
408
442
|
function createDeferred(source, options) {
|
|
409
443
|
let t,
|
|
410
444
|
timeout = options ? options.timeoutMs : undefined;
|
|
411
|
-
const node = createComputation(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
445
|
+
const node = createComputation(
|
|
446
|
+
() => {
|
|
447
|
+
if (!t || !t.fn)
|
|
448
|
+
t = requestCallback(
|
|
449
|
+
() => setDeferred(() => node.value),
|
|
450
|
+
timeout !== undefined
|
|
451
|
+
? {
|
|
452
|
+
timeout
|
|
453
|
+
}
|
|
454
|
+
: undefined
|
|
455
|
+
);
|
|
456
|
+
return source();
|
|
457
|
+
},
|
|
458
|
+
undefined,
|
|
459
|
+
true
|
|
460
|
+
);
|
|
461
|
+
const [deferred, setDeferred] = createSignal(
|
|
462
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
463
|
+
options
|
|
464
|
+
);
|
|
418
465
|
updateComputation(node);
|
|
419
|
-
setDeferred(() =>
|
|
466
|
+
setDeferred(() =>
|
|
467
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
468
|
+
);
|
|
420
469
|
return deferred;
|
|
421
470
|
}
|
|
422
471
|
function createSelector(source, fn = equalFn, options) {
|
|
423
472
|
const subs = new Map();
|
|
424
|
-
const node = createComputation(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
for (const
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
473
|
+
const node = createComputation(
|
|
474
|
+
p => {
|
|
475
|
+
const v = source();
|
|
476
|
+
for (const [key, val] of subs.entries())
|
|
477
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
478
|
+
for (const c of val.values()) {
|
|
479
|
+
c.state = STALE;
|
|
480
|
+
if (c.pure) Updates.push(c);
|
|
481
|
+
else Effects.push(c);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return v;
|
|
485
|
+
},
|
|
486
|
+
undefined,
|
|
487
|
+
true,
|
|
488
|
+
STALE,
|
|
489
|
+
options
|
|
490
|
+
);
|
|
434
491
|
updateComputation(node);
|
|
435
492
|
return key => {
|
|
436
493
|
const listener = Listener;
|
|
437
494
|
if (listener) {
|
|
438
495
|
let l;
|
|
439
|
-
if (l = subs.get(key)) l.add(listener);
|
|
496
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
497
|
+
else subs.set(key, (l = new Set([listener])));
|
|
440
498
|
onCleanup(() => {
|
|
441
499
|
l.delete(listener);
|
|
442
500
|
!l.size && subs.delete(key);
|
|
443
501
|
});
|
|
444
502
|
}
|
|
445
|
-
return fn(
|
|
503
|
+
return fn(
|
|
504
|
+
key,
|
|
505
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
506
|
+
);
|
|
446
507
|
};
|
|
447
508
|
}
|
|
448
509
|
function batch(fn) {
|
|
@@ -482,7 +543,10 @@ function onMount(fn) {
|
|
|
482
543
|
createEffect(() => untrack(fn));
|
|
483
544
|
}
|
|
484
545
|
function onCleanup(fn) {
|
|
485
|
-
if (Owner === null)
|
|
546
|
+
if (Owner === null)
|
|
547
|
+
console.warn("cleanups created outside a `createRoot` or `render` will never be run");
|
|
548
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
549
|
+
else Owner.cleanups.push(fn);
|
|
486
550
|
return fn;
|
|
487
551
|
}
|
|
488
552
|
function catchError(fn, handler) {
|
|
@@ -536,15 +600,17 @@ function startTransition(fn) {
|
|
|
536
600
|
Owner = o;
|
|
537
601
|
let t;
|
|
538
602
|
if (Scheduler || SuspenseContext) {
|
|
539
|
-
t =
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
603
|
+
t =
|
|
604
|
+
Transition ||
|
|
605
|
+
(Transition = {
|
|
606
|
+
sources: new Set(),
|
|
607
|
+
effects: [],
|
|
608
|
+
promises: new Set(),
|
|
609
|
+
disposed: new Set(),
|
|
610
|
+
queue: new Set(),
|
|
611
|
+
running: true
|
|
612
|
+
});
|
|
613
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
548
614
|
t.running = true;
|
|
549
615
|
}
|
|
550
616
|
runUpdates(fn, false);
|
|
@@ -552,7 +618,7 @@ function startTransition(fn) {
|
|
|
552
618
|
return t ? t.done : undefined;
|
|
553
619
|
});
|
|
554
620
|
}
|
|
555
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
621
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
556
622
|
function useTransition() {
|
|
557
623
|
return [transPending, startTransition];
|
|
558
624
|
}
|
|
@@ -561,12 +627,18 @@ function resumeEffects(e) {
|
|
|
561
627
|
e.length = 0;
|
|
562
628
|
}
|
|
563
629
|
function devComponent(Comp, props) {
|
|
564
|
-
const c = createComputation(
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
630
|
+
const c = createComputation(
|
|
631
|
+
() =>
|
|
632
|
+
untrack(() => {
|
|
633
|
+
Object.assign(Comp, {
|
|
634
|
+
[$DEVCOMP]: true
|
|
635
|
+
});
|
|
636
|
+
return Comp(props);
|
|
637
|
+
}),
|
|
638
|
+
undefined,
|
|
639
|
+
true,
|
|
640
|
+
0
|
|
641
|
+
);
|
|
570
642
|
c.props = props;
|
|
571
643
|
c.observers = null;
|
|
572
644
|
c.observerSlots = null;
|
|
@@ -577,7 +649,8 @@ function devComponent(Comp, props) {
|
|
|
577
649
|
}
|
|
578
650
|
function registerGraph(value) {
|
|
579
651
|
if (!Owner) return;
|
|
580
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
652
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
653
|
+
else Owner.sourceMap = [value];
|
|
581
654
|
value.graph = Owner;
|
|
582
655
|
}
|
|
583
656
|
function createContext(defaultValue, options) {
|
|
@@ -590,13 +663,15 @@ function createContext(defaultValue, options) {
|
|
|
590
663
|
}
|
|
591
664
|
function useContext(context) {
|
|
592
665
|
let value;
|
|
593
|
-
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
|
|
666
|
+
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
|
|
667
|
+
? value
|
|
668
|
+
: context.defaultValue;
|
|
594
669
|
}
|
|
595
670
|
function children(fn) {
|
|
596
671
|
const children = createMemo(fn);
|
|
597
672
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
598
673
|
name: "children"
|
|
599
|
-
})
|
|
674
|
+
});
|
|
600
675
|
memo.toArray = () => {
|
|
601
676
|
const c = memo();
|
|
602
677
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -609,10 +684,7 @@ function getSuspenseContext() {
|
|
|
609
684
|
}
|
|
610
685
|
function enableExternalSource(factory, untrack = fn => fn()) {
|
|
611
686
|
if (ExternalSourceConfig) {
|
|
612
|
-
const {
|
|
613
|
-
factory: oldFactory,
|
|
614
|
-
untrack: oldUntrack
|
|
615
|
-
} = ExternalSourceConfig;
|
|
687
|
+
const { factory: oldFactory, untrack: oldUntrack } = ExternalSourceConfig;
|
|
616
688
|
ExternalSourceConfig = {
|
|
617
689
|
factory: (fn, trigger) => {
|
|
618
690
|
const oldSource = oldFactory(fn, trigger);
|
|
@@ -637,7 +709,8 @@ function enableExternalSource(factory, untrack = fn => fn()) {
|
|
|
637
709
|
function readSignal() {
|
|
638
710
|
const runningTransition = Transition && Transition.running;
|
|
639
711
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
640
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
712
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
713
|
+
else {
|
|
641
714
|
const updates = Updates;
|
|
642
715
|
Updates = null;
|
|
643
716
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -665,11 +738,12 @@ function readSignal() {
|
|
|
665
738
|
return this.value;
|
|
666
739
|
}
|
|
667
740
|
function writeSignal(node, value, isComp) {
|
|
668
|
-
let current =
|
|
741
|
+
let current =
|
|
742
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
669
743
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
670
744
|
if (Transition) {
|
|
671
745
|
const TransitionRunning = Transition.running;
|
|
672
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
746
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
673
747
|
Transition.sources.add(node);
|
|
674
748
|
node.tValue = value;
|
|
675
749
|
}
|
|
@@ -682,10 +756,12 @@ function writeSignal(node, value, isComp) {
|
|
|
682
756
|
const TransitionRunning = Transition && Transition.running;
|
|
683
757
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
684
758
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
685
|
-
if (o.pure) Updates.push(o);
|
|
759
|
+
if (o.pure) Updates.push(o);
|
|
760
|
+
else Effects.push(o);
|
|
686
761
|
if (o.observers) markDownstream(o);
|
|
687
762
|
}
|
|
688
|
-
if (!TransitionRunning) o.state = STALE;
|
|
763
|
+
if (!TransitionRunning) o.state = STALE;
|
|
764
|
+
else o.tState = STALE;
|
|
689
765
|
}
|
|
690
766
|
if (Updates.length > 10e5) {
|
|
691
767
|
Updates = [];
|
|
@@ -701,7 +777,11 @@ function updateComputation(node) {
|
|
|
701
777
|
if (!node.fn) return;
|
|
702
778
|
cleanNode(node);
|
|
703
779
|
const time = ExecCount;
|
|
704
|
-
runComputation(
|
|
780
|
+
runComputation(
|
|
781
|
+
node,
|
|
782
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
783
|
+
time
|
|
784
|
+
);
|
|
705
785
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
706
786
|
queueMicrotask(() => {
|
|
707
787
|
runUpdates(() => {
|
|
@@ -766,11 +846,15 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
766
846
|
c.state = 0;
|
|
767
847
|
c.tState = state;
|
|
768
848
|
}
|
|
769
|
-
if (Owner === null)
|
|
849
|
+
if (Owner === null)
|
|
850
|
+
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
851
|
+
else if (Owner !== UNOWNED) {
|
|
770
852
|
if (Transition && Transition.running && Owner.pure) {
|
|
771
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
853
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
854
|
+
else Owner.tOwned.push(c);
|
|
772
855
|
} else {
|
|
773
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
856
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
857
|
+
else Owner.owned.push(c);
|
|
774
858
|
}
|
|
775
859
|
}
|
|
776
860
|
if (options && options.name) c.name = options.name;
|
|
@@ -823,7 +907,8 @@ function runUpdates(fn, init) {
|
|
|
823
907
|
if (Updates) return fn();
|
|
824
908
|
let wait = false;
|
|
825
909
|
if (!init) Updates = [];
|
|
826
|
-
if (Effects) wait = true;
|
|
910
|
+
if (Effects) wait = true;
|
|
911
|
+
else Effects = [];
|
|
827
912
|
ExecCount++;
|
|
828
913
|
try {
|
|
829
914
|
const res = fn();
|
|
@@ -837,7 +922,8 @@ function runUpdates(fn, init) {
|
|
|
837
922
|
}
|
|
838
923
|
function completeUpdates(wait) {
|
|
839
924
|
if (Updates) {
|
|
840
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
925
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
926
|
+
else runQueue(Updates);
|
|
841
927
|
Updates = null;
|
|
842
928
|
}
|
|
843
929
|
if (wait) return;
|
|
@@ -877,7 +963,8 @@ function completeUpdates(wait) {
|
|
|
877
963
|
}
|
|
878
964
|
const e = Effects;
|
|
879
965
|
Effects = null;
|
|
880
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
966
|
+
if (e.length) runUpdates(() => runEffects(e), false);
|
|
967
|
+
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
881
968
|
if (res) res();
|
|
882
969
|
}
|
|
883
970
|
function runQueue(queue) {
|
|
@@ -905,7 +992,8 @@ function runUserEffects(queue) {
|
|
|
905
992
|
userLength = 0;
|
|
906
993
|
for (i = 0; i < queue.length; i++) {
|
|
907
994
|
const e = queue[i];
|
|
908
|
-
if (!e.user) runTop(e);
|
|
995
|
+
if (!e.user) runTop(e);
|
|
996
|
+
else queue[userLength++] = e;
|
|
909
997
|
}
|
|
910
998
|
if (sharedConfig.context) {
|
|
911
999
|
if (sharedConfig.count) {
|
|
@@ -924,13 +1012,15 @@ function runUserEffects(queue) {
|
|
|
924
1012
|
}
|
|
925
1013
|
function lookUpstream(node, ignore) {
|
|
926
1014
|
const runningTransition = Transition && Transition.running;
|
|
927
|
-
if (runningTransition) node.tState = 0;
|
|
1015
|
+
if (runningTransition) node.tState = 0;
|
|
1016
|
+
else node.state = 0;
|
|
928
1017
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
929
1018
|
const source = node.sources[i];
|
|
930
1019
|
if (source.sources) {
|
|
931
1020
|
const state = runningTransition ? source.tState : source.state;
|
|
932
1021
|
if (state === STALE) {
|
|
933
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
1022
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
1023
|
+
runTop(source);
|
|
934
1024
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
935
1025
|
}
|
|
936
1026
|
}
|
|
@@ -940,8 +1030,10 @@ function markDownstream(node) {
|
|
|
940
1030
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
941
1031
|
const o = node.observers[i];
|
|
942
1032
|
if (runningTransition ? !o.tState : !o.state) {
|
|
943
|
-
if (runningTransition) o.tState = PENDING;
|
|
944
|
-
|
|
1033
|
+
if (runningTransition) o.tState = PENDING;
|
|
1034
|
+
else o.state = PENDING;
|
|
1035
|
+
if (o.pure) Updates.push(o);
|
|
1036
|
+
else Effects.push(o);
|
|
945
1037
|
o.observers && markDownstream(o);
|
|
946
1038
|
}
|
|
947
1039
|
}
|
|
@@ -978,7 +1070,8 @@ function cleanNode(node) {
|
|
|
978
1070
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
979
1071
|
node.cleanups = null;
|
|
980
1072
|
}
|
|
981
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1073
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1074
|
+
else node.state = 0;
|
|
982
1075
|
delete node.sourceMap;
|
|
983
1076
|
}
|
|
984
1077
|
function reset(node, top) {
|
|
@@ -1000,19 +1093,21 @@ function runErrors(err, fns, owner) {
|
|
|
1000
1093
|
try {
|
|
1001
1094
|
for (const f of fns) f(err);
|
|
1002
1095
|
} catch (e) {
|
|
1003
|
-
handleError(e, owner && owner.owner || null);
|
|
1096
|
+
handleError(e, (owner && owner.owner) || null);
|
|
1004
1097
|
}
|
|
1005
1098
|
}
|
|
1006
1099
|
function handleError(err, owner = Owner) {
|
|
1007
1100
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
1008
1101
|
const error = castError(err);
|
|
1009
1102
|
if (!fns) throw error;
|
|
1010
|
-
if (Effects)
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1103
|
+
if (Effects)
|
|
1104
|
+
Effects.push({
|
|
1105
|
+
fn() {
|
|
1106
|
+
runErrors(error, fns, owner);
|
|
1107
|
+
},
|
|
1108
|
+
state: STALE
|
|
1109
|
+
});
|
|
1110
|
+
else runErrors(error, fns, owner);
|
|
1016
1111
|
}
|
|
1017
1112
|
function resolveChildren(children) {
|
|
1018
1113
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1029,19 +1124,26 @@ function resolveChildren(children) {
|
|
|
1029
1124
|
function createProvider(id, options) {
|
|
1030
1125
|
return function provider(props) {
|
|
1031
1126
|
let res;
|
|
1032
|
-
createRenderEffect(
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1127
|
+
createRenderEffect(
|
|
1128
|
+
() =>
|
|
1129
|
+
(res = untrack(() => {
|
|
1130
|
+
Owner.context = {
|
|
1131
|
+
...Owner.context,
|
|
1132
|
+
[id]: props.value
|
|
1133
|
+
};
|
|
1134
|
+
return children(() => props.children);
|
|
1135
|
+
})),
|
|
1136
|
+
undefined,
|
|
1137
|
+
options
|
|
1138
|
+
);
|
|
1039
1139
|
return res;
|
|
1040
1140
|
};
|
|
1041
1141
|
}
|
|
1042
1142
|
function onError(fn) {
|
|
1043
1143
|
ERROR || (ERROR = Symbol("error"));
|
|
1044
|
-
if (Owner === null)
|
|
1144
|
+
if (Owner === null)
|
|
1145
|
+
console.warn("error handlers created outside a `createRoot` or `render` will never be run");
|
|
1146
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1045
1147
|
Owner.context = {
|
|
1046
1148
|
...Owner.context,
|
|
1047
1149
|
[ERROR]: [fn]
|
|
@@ -1070,7 +1172,8 @@ function observable(input) {
|
|
|
1070
1172
|
if (!(observer instanceof Object) || observer == null) {
|
|
1071
1173
|
throw new TypeError("Expected the observer to be an object.");
|
|
1072
1174
|
}
|
|
1073
|
-
const handler =
|
|
1175
|
+
const handler =
|
|
1176
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1074
1177
|
if (!handler) {
|
|
1075
1178
|
return {
|
|
1076
1179
|
unsubscribe() {}
|
|
@@ -1101,7 +1204,7 @@ function from(producer) {
|
|
|
1101
1204
|
});
|
|
1102
1205
|
if ("subscribe" in producer) {
|
|
1103
1206
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1104
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1207
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1105
1208
|
} else {
|
|
1106
1209
|
const clean = producer(set);
|
|
1107
1210
|
onCleanup(clean);
|
|
@@ -1145,8 +1248,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1145
1248
|
});
|
|
1146
1249
|
len = 1;
|
|
1147
1250
|
}
|
|
1148
|
-
}
|
|
1149
|
-
else if (len === 0) {
|
|
1251
|
+
} else if (len === 0) {
|
|
1150
1252
|
mapped = new Array(newLen);
|
|
1151
1253
|
for (j = 0; j < newLen; j++) {
|
|
1152
1254
|
items[j] = newItems[j];
|
|
@@ -1157,8 +1259,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1157
1259
|
temp = new Array(newLen);
|
|
1158
1260
|
tempdisposers = new Array(newLen);
|
|
1159
1261
|
indexes && (tempIndexes = new Array(newLen));
|
|
1160
|
-
for (
|
|
1161
|
-
|
|
1262
|
+
for (
|
|
1263
|
+
start = 0, end = Math.min(len, newLen);
|
|
1264
|
+
start < end && items[start] === newItems[start];
|
|
1265
|
+
start++
|
|
1266
|
+
);
|
|
1267
|
+
for (
|
|
1268
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1269
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1270
|
+
end--, newEnd--
|
|
1271
|
+
) {
|
|
1162
1272
|
temp[newEnd] = mapped[end];
|
|
1163
1273
|
tempdisposers[newEnd] = disposers[end];
|
|
1164
1274
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1192,7 +1302,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1192
1302
|
}
|
|
1193
1303
|
} else mapped[j] = createRoot(mapper);
|
|
1194
1304
|
}
|
|
1195
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1305
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1196
1306
|
items = newItems.slice(0);
|
|
1197
1307
|
}
|
|
1198
1308
|
return mapped;
|
|
@@ -1202,7 +1312,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1202
1312
|
if (indexes) {
|
|
1203
1313
|
const [s, set] = createSignal(j, {
|
|
1204
1314
|
name: "index"
|
|
1205
|
-
})
|
|
1315
|
+
});
|
|
1206
1316
|
indexes[j] = set;
|
|
1207
1317
|
return mapFn(newItems[j], s);
|
|
1208
1318
|
}
|
|
@@ -1261,13 +1371,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1261
1371
|
}
|
|
1262
1372
|
len = signals.length = disposers.length = newLen;
|
|
1263
1373
|
items = newItems.slice(0);
|
|
1264
|
-
return mapped = mapped.slice(0, len);
|
|
1374
|
+
return (mapped = mapped.slice(0, len));
|
|
1265
1375
|
});
|
|
1266
1376
|
function mapper(disposer) {
|
|
1267
1377
|
disposers[i] = disposer;
|
|
1268
1378
|
const [s, set] = createSignal(newItems[i], {
|
|
1269
1379
|
name: "value"
|
|
1270
|
-
})
|
|
1380
|
+
});
|
|
1271
1381
|
signals[i] = set;
|
|
1272
1382
|
return mapFn(s, i);
|
|
1273
1383
|
}
|
|
@@ -1283,7 +1393,7 @@ function createComponent(Comp, props) {
|
|
|
1283
1393
|
if (sharedConfig.context) {
|
|
1284
1394
|
const c = sharedConfig.context;
|
|
1285
1395
|
setHydrateContext(nextHydrateContext());
|
|
1286
|
-
const r = devComponent(Comp, props || {})
|
|
1396
|
+
const r = devComponent(Comp, props || {});
|
|
1287
1397
|
setHydrateContext(c);
|
|
1288
1398
|
return r;
|
|
1289
1399
|
}
|
|
@@ -1332,29 +1442,33 @@ function mergeProps(...sources) {
|
|
|
1332
1442
|
let proxy = false;
|
|
1333
1443
|
for (let i = 0; i < sources.length; i++) {
|
|
1334
1444
|
const s = sources[i];
|
|
1335
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1336
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1445
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1446
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1337
1447
|
}
|
|
1338
1448
|
if (SUPPORTS_PROXY && proxy) {
|
|
1339
|
-
return new Proxy(
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1449
|
+
return new Proxy(
|
|
1450
|
+
{
|
|
1451
|
+
get(property) {
|
|
1452
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1453
|
+
const v = resolveSource(sources[i])[property];
|
|
1454
|
+
if (v !== undefined) return v;
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
has(property) {
|
|
1458
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1459
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1460
|
+
}
|
|
1461
|
+
return false;
|
|
1462
|
+
},
|
|
1463
|
+
keys() {
|
|
1464
|
+
const keys = [];
|
|
1465
|
+
for (let i = 0; i < sources.length; i++)
|
|
1466
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1467
|
+
return [...new Set(keys)];
|
|
1349
1468
|
}
|
|
1350
|
-
return false;
|
|
1351
1469
|
},
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1355
|
-
return [...new Set(keys)];
|
|
1356
|
-
}
|
|
1357
|
-
}, propTraps);
|
|
1470
|
+
propTraps
|
|
1471
|
+
);
|
|
1358
1472
|
}
|
|
1359
1473
|
const sourcesMap = {};
|
|
1360
1474
|
const defined = Object.create(null);
|
|
@@ -1367,15 +1481,20 @@ function mergeProps(...sources) {
|
|
|
1367
1481
|
if (key === "__proto__" || key === "constructor") continue;
|
|
1368
1482
|
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
1369
1483
|
if (!defined[key]) {
|
|
1370
|
-
defined[key] = desc.get
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1484
|
+
defined[key] = desc.get
|
|
1485
|
+
? {
|
|
1486
|
+
enumerable: true,
|
|
1487
|
+
configurable: true,
|
|
1488
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1489
|
+
}
|
|
1490
|
+
: desc.value !== undefined
|
|
1491
|
+
? desc
|
|
1492
|
+
: undefined;
|
|
1375
1493
|
} else {
|
|
1376
1494
|
const sources = sourcesMap[key];
|
|
1377
1495
|
if (sources) {
|
|
1378
|
-
if (desc.get) sources.push(desc.get.bind(source));
|
|
1496
|
+
if (desc.get) sources.push(desc.get.bind(source));
|
|
1497
|
+
else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1379
1498
|
}
|
|
1380
1499
|
}
|
|
1381
1500
|
}
|
|
@@ -1385,7 +1504,8 @@ function mergeProps(...sources) {
|
|
|
1385
1504
|
for (let i = definedKeys.length - 1; i >= 0; i--) {
|
|
1386
1505
|
const key = definedKeys[i],
|
|
1387
1506
|
desc = defined[key];
|
|
1388
|
-
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1507
|
+
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1508
|
+
else target[key] = desc ? desc.value : undefined;
|
|
1389
1509
|
}
|
|
1390
1510
|
return target;
|
|
1391
1511
|
}
|
|
@@ -1393,47 +1513,60 @@ function splitProps(props, ...keys) {
|
|
|
1393
1513
|
if (SUPPORTS_PROXY && $PROXY in props) {
|
|
1394
1514
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1395
1515
|
const res = keys.map(k => {
|
|
1396
|
-
return new Proxy(
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1516
|
+
return new Proxy(
|
|
1517
|
+
{
|
|
1518
|
+
get(property) {
|
|
1519
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1520
|
+
},
|
|
1521
|
+
has(property) {
|
|
1522
|
+
return k.includes(property) && property in props;
|
|
1523
|
+
},
|
|
1524
|
+
keys() {
|
|
1525
|
+
return k.filter(property => property in props);
|
|
1526
|
+
}
|
|
1402
1527
|
},
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
}
|
|
1406
|
-
}, propTraps);
|
|
1528
|
+
propTraps
|
|
1529
|
+
);
|
|
1407
1530
|
});
|
|
1408
|
-
res.push(
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1531
|
+
res.push(
|
|
1532
|
+
new Proxy(
|
|
1533
|
+
{
|
|
1534
|
+
get(property) {
|
|
1535
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1536
|
+
},
|
|
1537
|
+
has(property) {
|
|
1538
|
+
return blocked.has(property) ? false : property in props;
|
|
1539
|
+
},
|
|
1540
|
+
keys() {
|
|
1541
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1542
|
+
}
|
|
1543
|
+
},
|
|
1544
|
+
propTraps
|
|
1545
|
+
)
|
|
1546
|
+
);
|
|
1419
1547
|
return res;
|
|
1420
1548
|
}
|
|
1421
1549
|
const otherObject = {};
|
|
1422
1550
|
const objects = keys.map(() => ({}));
|
|
1423
1551
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1424
1552
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1425
|
-
const isDefaultDesc =
|
|
1553
|
+
const isDefaultDesc =
|
|
1554
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1426
1555
|
let blocked = false;
|
|
1427
1556
|
let objectIndex = 0;
|
|
1428
1557
|
for (const k of keys) {
|
|
1429
1558
|
if (k.includes(propName)) {
|
|
1430
1559
|
blocked = true;
|
|
1431
|
-
isDefaultDesc
|
|
1560
|
+
isDefaultDesc
|
|
1561
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1562
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1432
1563
|
}
|
|
1433
1564
|
++objectIndex;
|
|
1434
1565
|
}
|
|
1435
1566
|
if (!blocked) {
|
|
1436
|
-
isDefaultDesc
|
|
1567
|
+
isDefaultDesc
|
|
1568
|
+
? (otherObject[propName] = desc.value)
|
|
1569
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1437
1570
|
}
|
|
1438
1571
|
}
|
|
1439
1572
|
return [...objects, otherObject];
|
|
@@ -1459,19 +1592,24 @@ function lazy(fn) {
|
|
|
1459
1592
|
comp = s;
|
|
1460
1593
|
}
|
|
1461
1594
|
let Comp;
|
|
1462
|
-
return createMemo(() =>
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1595
|
+
return createMemo(() =>
|
|
1596
|
+
(Comp = comp())
|
|
1597
|
+
? untrack(() => {
|
|
1598
|
+
if (true)
|
|
1599
|
+
Object.assign(Comp, {
|
|
1600
|
+
[$DEVCOMP]: true
|
|
1601
|
+
});
|
|
1602
|
+
if (!ctx || sharedConfig.done) return Comp(props);
|
|
1603
|
+
const c = sharedConfig.context;
|
|
1604
|
+
setHydrateContext(ctx);
|
|
1605
|
+
const r = Comp(props);
|
|
1606
|
+
setHydrateContext(c);
|
|
1607
|
+
return r;
|
|
1608
|
+
})
|
|
1609
|
+
: ""
|
|
1610
|
+
);
|
|
1473
1611
|
};
|
|
1474
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1612
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1475
1613
|
return wrap;
|
|
1476
1614
|
}
|
|
1477
1615
|
let counter = 0;
|
|
@@ -1480,75 +1618,112 @@ function createUniqueId() {
|
|
|
1480
1618
|
return ctx ? sharedConfig.getNextContextId() : `cl-${counter++}`;
|
|
1481
1619
|
}
|
|
1482
1620
|
|
|
1483
|
-
const narrowedError = name =>
|
|
1621
|
+
const narrowedError = name =>
|
|
1622
|
+
`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.`;
|
|
1484
1623
|
function For(props) {
|
|
1485
1624
|
const fallback = "fallback" in props && {
|
|
1486
1625
|
fallback: () => props.fallback
|
|
1487
1626
|
};
|
|
1488
|
-
return createMemo(
|
|
1489
|
-
|
|
1490
|
-
|
|
1627
|
+
return createMemo(
|
|
1628
|
+
mapArray(() => props.each, props.children, fallback || undefined),
|
|
1629
|
+
undefined,
|
|
1630
|
+
{
|
|
1631
|
+
name: "value"
|
|
1632
|
+
}
|
|
1633
|
+
);
|
|
1491
1634
|
}
|
|
1492
1635
|
function Index(props) {
|
|
1493
1636
|
const fallback = "fallback" in props && {
|
|
1494
1637
|
fallback: () => props.fallback
|
|
1495
1638
|
};
|
|
1496
|
-
return createMemo(
|
|
1497
|
-
|
|
1498
|
-
|
|
1639
|
+
return createMemo(
|
|
1640
|
+
indexArray(() => props.each, props.children, fallback || undefined),
|
|
1641
|
+
undefined,
|
|
1642
|
+
{
|
|
1643
|
+
name: "value"
|
|
1644
|
+
}
|
|
1645
|
+
);
|
|
1499
1646
|
}
|
|
1500
1647
|
function Show(props) {
|
|
1501
1648
|
const keyed = props.keyed;
|
|
1502
1649
|
const condition = createMemo(() => props.when, undefined, {
|
|
1503
|
-
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1650
|
+
equals: (a, b) => (keyed ? a === b : !a === !b),
|
|
1504
1651
|
name: "condition"
|
|
1505
|
-
}
|
|
1506
|
-
return createMemo(
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1652
|
+
});
|
|
1653
|
+
return createMemo(
|
|
1654
|
+
() => {
|
|
1655
|
+
const c = condition();
|
|
1656
|
+
if (c) {
|
|
1657
|
+
const child = props.children;
|
|
1658
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1659
|
+
return fn
|
|
1660
|
+
? untrack(() =>
|
|
1661
|
+
child(
|
|
1662
|
+
keyed
|
|
1663
|
+
? c
|
|
1664
|
+
: () => {
|
|
1665
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1666
|
+
return props.when;
|
|
1667
|
+
}
|
|
1668
|
+
)
|
|
1669
|
+
)
|
|
1670
|
+
: child;
|
|
1671
|
+
}
|
|
1672
|
+
return props.fallback;
|
|
1673
|
+
},
|
|
1674
|
+
undefined,
|
|
1675
|
+
{
|
|
1676
|
+
name: "value"
|
|
1515
1677
|
}
|
|
1516
|
-
|
|
1517
|
-
}, undefined, {
|
|
1518
|
-
name: "value"
|
|
1519
|
-
} );
|
|
1678
|
+
);
|
|
1520
1679
|
}
|
|
1521
1680
|
function Switch(props) {
|
|
1522
1681
|
let keyed = false;
|
|
1523
1682
|
const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1524
1683
|
const conditions = children(() => props.children),
|
|
1525
|
-
evalConditions = createMemo(
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1684
|
+
evalConditions = createMemo(
|
|
1685
|
+
() => {
|
|
1686
|
+
let conds = conditions();
|
|
1687
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1688
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1689
|
+
const c = conds[i].when;
|
|
1690
|
+
if (c) {
|
|
1691
|
+
keyed = !!conds[i].keyed;
|
|
1692
|
+
return [i, c, conds[i]];
|
|
1693
|
+
}
|
|
1533
1694
|
}
|
|
1695
|
+
return [-1];
|
|
1696
|
+
},
|
|
1697
|
+
undefined,
|
|
1698
|
+
{
|
|
1699
|
+
equals,
|
|
1700
|
+
name: "eval conditions"
|
|
1534
1701
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1702
|
+
);
|
|
1703
|
+
return createMemo(
|
|
1704
|
+
() => {
|
|
1705
|
+
const [index, when, cond] = evalConditions();
|
|
1706
|
+
if (index < 0) return props.fallback;
|
|
1707
|
+
const c = cond.children;
|
|
1708
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1709
|
+
return fn
|
|
1710
|
+
? untrack(() =>
|
|
1711
|
+
c(
|
|
1712
|
+
keyed
|
|
1713
|
+
? when
|
|
1714
|
+
: () => {
|
|
1715
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1716
|
+
return cond.when;
|
|
1717
|
+
}
|
|
1718
|
+
)
|
|
1719
|
+
)
|
|
1720
|
+
: c;
|
|
1721
|
+
},
|
|
1722
|
+
undefined,
|
|
1723
|
+
{
|
|
1724
|
+
name: "value"
|
|
1725
|
+
}
|
|
1726
|
+
);
|
|
1552
1727
|
}
|
|
1553
1728
|
function Match(props) {
|
|
1554
1729
|
return props;
|
|
@@ -1559,28 +1734,34 @@ function resetErrorBoundaries() {
|
|
|
1559
1734
|
}
|
|
1560
1735
|
function ErrorBoundary(props) {
|
|
1561
1736
|
let err;
|
|
1562
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1737
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1738
|
+
err = sharedConfig.load(sharedConfig.getContextId());
|
|
1563
1739
|
const [errored, setErrored] = createSignal(err, {
|
|
1564
1740
|
name: "errored"
|
|
1565
|
-
}
|
|
1741
|
+
});
|
|
1566
1742
|
Errors || (Errors = new Set());
|
|
1567
1743
|
Errors.add(setErrored);
|
|
1568
1744
|
onCleanup(() => Errors.delete(setErrored));
|
|
1569
|
-
return createMemo(
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1745
|
+
return createMemo(
|
|
1746
|
+
() => {
|
|
1747
|
+
let e;
|
|
1748
|
+
if ((e = errored())) {
|
|
1749
|
+
const f = props.fallback;
|
|
1750
|
+
if (typeof f !== "function" || f.length == 0) console.error(e);
|
|
1751
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1752
|
+
}
|
|
1753
|
+
return catchError(() => props.children, setErrored);
|
|
1754
|
+
},
|
|
1755
|
+
undefined,
|
|
1756
|
+
{
|
|
1757
|
+
name: "value"
|
|
1575
1758
|
}
|
|
1576
|
-
|
|
1577
|
-
}, undefined, {
|
|
1578
|
-
name: "value"
|
|
1579
|
-
} );
|
|
1759
|
+
);
|
|
1580
1760
|
}
|
|
1581
1761
|
|
|
1582
|
-
const suspenseListEquals = (a, b) =>
|
|
1583
|
-
|
|
1762
|
+
const suspenseListEquals = (a, b) =>
|
|
1763
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1764
|
+
const SuspenseListContext = /* #__PURE__ */ createContext();
|
|
1584
1765
|
function SuspenseList(props) {
|
|
1585
1766
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1586
1767
|
inFallback: false
|
|
@@ -1591,51 +1772,51 @@ function SuspenseList(props) {
|
|
|
1591
1772
|
if (listContext) {
|
|
1592
1773
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1593
1774
|
}
|
|
1594
|
-
const resolved = createMemo(
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
showContent = true,
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
const res = reg.map(() => ({
|
|
1606
|
-
showContent: all && showContent,
|
|
1607
|
-
showFallback
|
|
1608
|
-
}));
|
|
1609
|
-
res.inFallback = !all;
|
|
1610
|
-
return res;
|
|
1611
|
-
}
|
|
1612
|
-
let stop = false;
|
|
1613
|
-
let inFallback = prev.inFallback;
|
|
1614
|
-
const res = [];
|
|
1615
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1616
|
-
const n = reverse ? len - i - 1 : i,
|
|
1617
|
-
s = reg[n]();
|
|
1618
|
-
if (!stop && !s) {
|
|
1619
|
-
res[n] = {
|
|
1620
|
-
showContent,
|
|
1775
|
+
const resolved = createMemo(
|
|
1776
|
+
prev => {
|
|
1777
|
+
const reveal = props.revealOrder,
|
|
1778
|
+
tail = props.tail,
|
|
1779
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1780
|
+
reg = registry(),
|
|
1781
|
+
reverse = reveal === "backwards";
|
|
1782
|
+
if (reveal === "together") {
|
|
1783
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1784
|
+
const res = reg.map(() => ({
|
|
1785
|
+
showContent: all && showContent,
|
|
1621
1786
|
showFallback
|
|
1622
|
-
};
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
if (next) inFallback = true;
|
|
1626
|
-
res[n] = {
|
|
1627
|
-
showContent: next,
|
|
1628
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1629
|
-
};
|
|
1630
|
-
stop = true;
|
|
1787
|
+
}));
|
|
1788
|
+
res.inFallback = !all;
|
|
1789
|
+
return res;
|
|
1631
1790
|
}
|
|
1791
|
+
let stop = false;
|
|
1792
|
+
let inFallback = prev.inFallback;
|
|
1793
|
+
const res = [];
|
|
1794
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1795
|
+
const n = reverse ? len - i - 1 : i,
|
|
1796
|
+
s = reg[n]();
|
|
1797
|
+
if (!stop && !s) {
|
|
1798
|
+
res[n] = {
|
|
1799
|
+
showContent,
|
|
1800
|
+
showFallback
|
|
1801
|
+
};
|
|
1802
|
+
} else {
|
|
1803
|
+
const next = !stop;
|
|
1804
|
+
if (next) inFallback = true;
|
|
1805
|
+
res[n] = {
|
|
1806
|
+
showContent: next,
|
|
1807
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1808
|
+
};
|
|
1809
|
+
stop = true;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
if (!stop) inFallback = false;
|
|
1813
|
+
res.inFallback = inFallback;
|
|
1814
|
+
return res;
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
inFallback: false
|
|
1632
1818
|
}
|
|
1633
|
-
|
|
1634
|
-
res.inFallback = inFallback;
|
|
1635
|
-
return res;
|
|
1636
|
-
}, {
|
|
1637
|
-
inFallback: false
|
|
1638
|
-
});
|
|
1819
|
+
);
|
|
1639
1820
|
setWrapper(() => resolved);
|
|
1640
1821
|
return createComponent(SuspenseListContext.Provider, {
|
|
1641
1822
|
value: {
|
|
@@ -1680,23 +1861,27 @@ function Suspense(props) {
|
|
|
1680
1861
|
const key = sharedConfig.getContextId();
|
|
1681
1862
|
let ref = sharedConfig.load(key);
|
|
1682
1863
|
if (ref) {
|
|
1683
|
-
if (typeof ref !== "object" || ref.status !== "success") p = ref;
|
|
1864
|
+
if (typeof ref !== "object" || ref.status !== "success") p = ref;
|
|
1865
|
+
else sharedConfig.gather(key);
|
|
1684
1866
|
}
|
|
1685
1867
|
if (p && p !== "$$f") {
|
|
1686
1868
|
const [s, set] = createSignal(undefined, {
|
|
1687
1869
|
equals: false
|
|
1688
1870
|
});
|
|
1689
1871
|
flicker = s;
|
|
1690
|
-
p.then(
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1872
|
+
p.then(
|
|
1873
|
+
() => {
|
|
1874
|
+
if (sharedConfig.done) return set();
|
|
1875
|
+
sharedConfig.gather(key);
|
|
1876
|
+
setHydrateContext(ctx);
|
|
1877
|
+
set();
|
|
1878
|
+
setHydrateContext();
|
|
1879
|
+
},
|
|
1880
|
+
err => {
|
|
1881
|
+
error = err;
|
|
1882
|
+
set();
|
|
1883
|
+
}
|
|
1884
|
+
);
|
|
1700
1885
|
}
|
|
1701
1886
|
}
|
|
1702
1887
|
const listContext = useContext(SuspenseListContext);
|
|
@@ -1711,17 +1896,14 @@ function Suspense(props) {
|
|
|
1711
1896
|
ctx = sharedConfig.context;
|
|
1712
1897
|
if (flicker) {
|
|
1713
1898
|
flicker();
|
|
1714
|
-
return flicker = undefined;
|
|
1899
|
+
return (flicker = undefined);
|
|
1715
1900
|
}
|
|
1716
1901
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1717
1902
|
const rendered = createMemo(() => props.children);
|
|
1718
1903
|
return createMemo(prev => {
|
|
1719
1904
|
const inFallback = store.inFallback(),
|
|
1720
|
-
{
|
|
1721
|
-
|
|
1722
|
-
showFallback = true
|
|
1723
|
-
} = show ? show() : {};
|
|
1724
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1905
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1906
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1725
1907
|
store.resolved = true;
|
|
1726
1908
|
dispose && dispose();
|
|
1727
1909
|
dispose = ctx = p = undefined;
|
|
@@ -1751,9 +1933,68 @@ const DEV = {
|
|
|
1751
1933
|
hooks: DevHooks,
|
|
1752
1934
|
writeSignal,
|
|
1753
1935
|
registerGraph
|
|
1754
|
-
}
|
|
1936
|
+
};
|
|
1755
1937
|
if (globalThis) {
|
|
1756
|
-
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1938
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1939
|
+
else
|
|
1940
|
+
console.warn(
|
|
1941
|
+
"You appear to have multiple instances of Solid. This can lead to unexpected behavior."
|
|
1942
|
+
);
|
|
1757
1943
|
}
|
|
1758
1944
|
|
|
1759
|
-
export {
|
|
1945
|
+
export {
|
|
1946
|
+
$DEVCOMP,
|
|
1947
|
+
$PROXY,
|
|
1948
|
+
$TRACK,
|
|
1949
|
+
DEV,
|
|
1950
|
+
ErrorBoundary,
|
|
1951
|
+
For,
|
|
1952
|
+
Index,
|
|
1953
|
+
Match,
|
|
1954
|
+
Show,
|
|
1955
|
+
Suspense,
|
|
1956
|
+
SuspenseList,
|
|
1957
|
+
Switch,
|
|
1958
|
+
batch,
|
|
1959
|
+
cancelCallback,
|
|
1960
|
+
catchError,
|
|
1961
|
+
children,
|
|
1962
|
+
createComponent,
|
|
1963
|
+
createComputed,
|
|
1964
|
+
createContext,
|
|
1965
|
+
createDeferred,
|
|
1966
|
+
createEffect,
|
|
1967
|
+
createMemo,
|
|
1968
|
+
createReaction,
|
|
1969
|
+
createRenderEffect,
|
|
1970
|
+
createResource,
|
|
1971
|
+
createRoot,
|
|
1972
|
+
createSelector,
|
|
1973
|
+
createSignal,
|
|
1974
|
+
createUniqueId,
|
|
1975
|
+
enableExternalSource,
|
|
1976
|
+
enableHydration,
|
|
1977
|
+
enableScheduling,
|
|
1978
|
+
equalFn,
|
|
1979
|
+
from,
|
|
1980
|
+
getListener,
|
|
1981
|
+
getOwner,
|
|
1982
|
+
indexArray,
|
|
1983
|
+
lazy,
|
|
1984
|
+
mapArray,
|
|
1985
|
+
mergeProps,
|
|
1986
|
+
observable,
|
|
1987
|
+
on,
|
|
1988
|
+
onCleanup,
|
|
1989
|
+
onError,
|
|
1990
|
+
onMount,
|
|
1991
|
+
requestCallback,
|
|
1992
|
+
resetErrorBoundaries,
|
|
1993
|
+
runWithOwner,
|
|
1994
|
+
sharedConfig,
|
|
1995
|
+
splitProps,
|
|
1996
|
+
startTransition,
|
|
1997
|
+
untrack,
|
|
1998
|
+
useContext,
|
|
1999
|
+
useTransition
|
|
2000
|
+
};
|