solid-js 1.9.5 → 1.9.7
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 +21 -10
- package/dist/dev.js +327 -557
- package/dist/server.js +81 -178
- package/dist/solid.cjs +21 -10
- package/dist/solid.js +283 -486
- package/h/dist/h.js +9 -40
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +8 -11
- package/h/jsx-runtime/types/jsx.d.ts +2947 -1021
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.cjs +2 -2
- package/html/dist/html.js +96 -221
- package/html/types/lit.d.ts +33 -52
- package/package.json +3 -3
- package/store/dist/dev.js +43 -123
- package/store/dist/server.js +8 -20
- package/store/dist/store.js +40 -114
- package/store/types/index.d.ts +7 -21
- package/store/types/modifiers.d.ts +3 -6
- package/store/types/mutable.d.ts +2 -5
- package/store/types/server.d.ts +5 -25
- package/store/types/store.d.ts +61 -218
- package/types/index.d.ts +11 -78
- package/types/jsx.d.ts +2091 -278
- package/types/reactive/array.d.ts +4 -12
- package/types/reactive/observable.d.ts +16 -22
- package/types/reactive/scheduler.d.ts +6 -9
- package/types/reactive/signal.d.ts +145 -236
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +37 -73
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +15 -15
- package/types/server/index.d.ts +2 -57
- package/types/server/reactive.d.ts +45 -76
- package/types/server/rendering.d.ts +98 -169
- package/universal/dist/dev.cjs +3 -1
- package/universal/dist/dev.js +15 -29
- package/universal/dist/universal.cjs +3 -1
- package/universal/dist/universal.js +15 -29
- package/universal/types/index.d.ts +1 -3
- package/universal/types/universal.d.ts +1 -0
- package/web/dist/dev.cjs +8 -5
- package/web/dist/dev.js +96 -643
- package/web/dist/server.cjs +9 -6
- package/web/dist/server.js +116 -646
- package/web/dist/web.cjs +8 -5
- package/web/dist/web.js +94 -631
- package/web/storage/dist/storage.js +3 -3
- package/web/types/core.d.ts +2 -10
- package/web/types/index.d.ts +11 -31
- package/web/types/server-mock.d.ts +32 -47
package/dist/solid.js
CHANGED
|
@@ -52,11 +52,9 @@ function enqueue(taskQueue, task) {
|
|
|
52
52
|
let m = 0;
|
|
53
53
|
let n = taskQueue.length - 1;
|
|
54
54
|
while (m <= n) {
|
|
55
|
-
const k =
|
|
55
|
+
const k = n + m >> 1;
|
|
56
56
|
const cmp = task.expirationTime - taskQueue[k].expirationTime;
|
|
57
|
-
if (cmp > 0) m = k + 1;
|
|
58
|
-
else if (cmp < 0) n = k - 1;
|
|
59
|
-
else return k;
|
|
57
|
+
if (cmp > 0) m = k + 1;else if (cmp < 0) n = k - 1;else return k;
|
|
60
58
|
}
|
|
61
59
|
return m;
|
|
62
60
|
}
|
|
@@ -177,14 +175,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
177
175
|
owner = Owner,
|
|
178
176
|
unowned = fn.length === 0,
|
|
179
177
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
180
|
-
root = unowned
|
|
181
|
-
|
|
182
|
-
:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
owner: current
|
|
187
|
-
},
|
|
178
|
+
root = unowned ? UNOWNED : {
|
|
179
|
+
owned: null,
|
|
180
|
+
cleanups: null,
|
|
181
|
+
context: current ? current.context : null,
|
|
182
|
+
owner: current
|
|
183
|
+
},
|
|
188
184
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
189
185
|
Owner = root;
|
|
190
186
|
Listener = null;
|
|
@@ -205,8 +201,7 @@ function createSignal(value, options) {
|
|
|
205
201
|
};
|
|
206
202
|
const setter = value => {
|
|
207
203
|
if (typeof value === "function") {
|
|
208
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
209
|
-
else value = value(s.value);
|
|
204
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);else value = value(s.value);
|
|
210
205
|
}
|
|
211
206
|
return writeSignal(s, value);
|
|
212
207
|
};
|
|
@@ -214,13 +209,11 @@ function createSignal(value, options) {
|
|
|
214
209
|
}
|
|
215
210
|
function createComputed(fn, value, options) {
|
|
216
211
|
const c = createComputation(fn, value, true, STALE);
|
|
217
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
218
|
-
else updateComputation(c);
|
|
212
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
219
213
|
}
|
|
220
214
|
function createRenderEffect(fn, value, options) {
|
|
221
215
|
const c = createComputation(fn, value, false, STALE);
|
|
222
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
223
|
-
else updateComputation(c);
|
|
216
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
224
217
|
}
|
|
225
218
|
function createEffect(fn, value, options) {
|
|
226
219
|
runEffects = runUserEffects;
|
|
@@ -232,15 +225,10 @@ function createEffect(fn, value, options) {
|
|
|
232
225
|
}
|
|
233
226
|
function createReaction(onInvalidate, options) {
|
|
234
227
|
let fn;
|
|
235
|
-
const c = createComputation(
|
|
236
|
-
()
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
},
|
|
240
|
-
undefined,
|
|
241
|
-
false,
|
|
242
|
-
0
|
|
243
|
-
),
|
|
228
|
+
const c = createComputation(() => {
|
|
229
|
+
fn ? fn() : untrack(onInvalidate);
|
|
230
|
+
fn = undefined;
|
|
231
|
+
}, undefined, false, 0),
|
|
244
232
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
245
233
|
if (s) c.suspense = s;
|
|
246
234
|
c.user = true;
|
|
@@ -293,19 +281,15 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
293
281
|
[state, setState] = createSignal(resolved ? "ready" : "unresolved");
|
|
294
282
|
if (sharedConfig.context) {
|
|
295
283
|
id = sharedConfig.getNextContextId();
|
|
296
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
297
|
-
else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
|
|
284
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
|
|
298
285
|
}
|
|
299
286
|
function loadEnd(p, v, error, key) {
|
|
300
287
|
if (pr === p) {
|
|
301
288
|
pr = null;
|
|
302
289
|
key !== undefined && (resolved = true);
|
|
303
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
value: v
|
|
307
|
-
})
|
|
308
|
-
);
|
|
290
|
+
if ((p === initP || v === initP) && options.onHydrated) queueMicrotask(() => options.onHydrated(key, {
|
|
291
|
+
value: v
|
|
292
|
+
}));
|
|
309
293
|
initP = NO_INIT;
|
|
310
294
|
if (Transition && p && loadedUnderTransition) {
|
|
311
295
|
Transition.promises.delete(p);
|
|
@@ -336,8 +320,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
336
320
|
createComputed(() => {
|
|
337
321
|
track();
|
|
338
322
|
if (pr) {
|
|
339
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
340
|
-
else if (!contexts.has(c)) {
|
|
323
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);else if (!contexts.has(c)) {
|
|
341
324
|
c.increment();
|
|
342
325
|
contexts.add(c);
|
|
343
326
|
}
|
|
@@ -356,35 +339,36 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
356
339
|
return;
|
|
357
340
|
}
|
|
358
341
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
342
|
+
let error;
|
|
343
|
+
const p = initP !== NO_INIT ? initP : untrack(() => {
|
|
344
|
+
try {
|
|
345
|
+
return fetcher(lookup, {
|
|
346
|
+
value: value(),
|
|
347
|
+
refetching
|
|
348
|
+
});
|
|
349
|
+
} catch (fetcherError) {
|
|
350
|
+
error = fetcherError;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
if (error !== undefined) {
|
|
354
|
+
loadEnd(pr, undefined, castError(error), lookup);
|
|
355
|
+
return;
|
|
356
|
+
} else if (!isPromise(p)) {
|
|
369
357
|
loadEnd(pr, p, undefined, lookup);
|
|
370
358
|
return p;
|
|
371
359
|
}
|
|
372
360
|
pr = p;
|
|
373
|
-
if ("
|
|
374
|
-
if (p.
|
|
375
|
-
else loadEnd(pr, undefined, castError(p.value), lookup);
|
|
361
|
+
if ("v" in p) {
|
|
362
|
+
if (p.s === 1) loadEnd(pr, p.v, undefined, lookup);else loadEnd(pr, undefined, castError(p.v), lookup);
|
|
376
363
|
return p;
|
|
377
364
|
}
|
|
378
365
|
scheduled = true;
|
|
379
|
-
queueMicrotask(() =>
|
|
366
|
+
queueMicrotask(() => scheduled = false);
|
|
380
367
|
runUpdates(() => {
|
|
381
368
|
setState(resolved ? "refreshing" : "pending");
|
|
382
369
|
trigger();
|
|
383
370
|
}, false);
|
|
384
|
-
return p.then(
|
|
385
|
-
v => loadEnd(p, v, undefined, lookup),
|
|
386
|
-
e => loadEnd(p, undefined, castError(e), lookup)
|
|
387
|
-
);
|
|
371
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, undefined, castError(e), lookup));
|
|
388
372
|
}
|
|
389
373
|
Object.defineProperties(read, {
|
|
390
374
|
state: {
|
|
@@ -408,80 +392,51 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
408
392
|
}
|
|
409
393
|
}
|
|
410
394
|
});
|
|
411
|
-
|
|
412
|
-
else load(false);
|
|
413
|
-
return [
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
mutate: setValue
|
|
418
|
-
}
|
|
419
|
-
];
|
|
395
|
+
let owner = Owner;
|
|
396
|
+
if (dynamic) createComputed(() => (owner = Owner, load(false)));else load(false);
|
|
397
|
+
return [read, {
|
|
398
|
+
refetch: info => runWithOwner(owner, () => load(info)),
|
|
399
|
+
mutate: setValue
|
|
400
|
+
}];
|
|
420
401
|
}
|
|
421
402
|
function createDeferred(source, options) {
|
|
422
403
|
let t,
|
|
423
404
|
timeout = options ? options.timeoutMs : undefined;
|
|
424
|
-
const node = createComputation(
|
|
425
|
-
() => {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
timeout
|
|
432
|
-
}
|
|
433
|
-
: undefined
|
|
434
|
-
);
|
|
435
|
-
return source();
|
|
436
|
-
},
|
|
437
|
-
undefined,
|
|
438
|
-
true
|
|
439
|
-
);
|
|
440
|
-
const [deferred, setDeferred] = createSignal(
|
|
441
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
442
|
-
options
|
|
443
|
-
);
|
|
405
|
+
const node = createComputation(() => {
|
|
406
|
+
if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
|
|
407
|
+
timeout
|
|
408
|
+
} : undefined);
|
|
409
|
+
return source();
|
|
410
|
+
}, undefined, true);
|
|
411
|
+
const [deferred, setDeferred] = createSignal(Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, options);
|
|
444
412
|
updateComputation(node);
|
|
445
|
-
setDeferred(() =>
|
|
446
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
447
|
-
);
|
|
413
|
+
setDeferred(() => Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
448
414
|
return deferred;
|
|
449
415
|
}
|
|
450
416
|
function createSelector(source, fn = equalFn, options) {
|
|
451
417
|
const subs = new Map();
|
|
452
|
-
const node = createComputation(
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
for (const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
return v;
|
|
464
|
-
},
|
|
465
|
-
undefined,
|
|
466
|
-
true,
|
|
467
|
-
STALE
|
|
468
|
-
);
|
|
418
|
+
const node = createComputation(p => {
|
|
419
|
+
const v = source();
|
|
420
|
+
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
421
|
+
for (const c of val.values()) {
|
|
422
|
+
c.state = STALE;
|
|
423
|
+
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return v;
|
|
427
|
+
}, undefined, true, STALE);
|
|
469
428
|
updateComputation(node);
|
|
470
429
|
return key => {
|
|
471
430
|
const listener = Listener;
|
|
472
431
|
if (listener) {
|
|
473
432
|
let l;
|
|
474
|
-
if (
|
|
475
|
-
else subs.set(key, (l = new Set([listener])));
|
|
433
|
+
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
476
434
|
onCleanup(() => {
|
|
477
435
|
l.delete(listener);
|
|
478
436
|
!l.size && subs.delete(key);
|
|
479
437
|
});
|
|
480
438
|
}
|
|
481
|
-
return fn(
|
|
482
|
-
key,
|
|
483
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
484
|
-
);
|
|
439
|
+
return fn(key, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
485
440
|
};
|
|
486
441
|
}
|
|
487
442
|
function batch(fn) {
|
|
@@ -521,9 +476,7 @@ function onMount(fn) {
|
|
|
521
476
|
createEffect(() => untrack(fn));
|
|
522
477
|
}
|
|
523
478
|
function onCleanup(fn) {
|
|
524
|
-
if (Owner === null);
|
|
525
|
-
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
526
|
-
else Owner.cleanups.push(fn);
|
|
479
|
+
if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
527
480
|
return fn;
|
|
528
481
|
}
|
|
529
482
|
function catchError(fn, handler) {
|
|
@@ -577,17 +530,15 @@ function startTransition(fn) {
|
|
|
577
530
|
Owner = o;
|
|
578
531
|
let t;
|
|
579
532
|
if (Scheduler || SuspenseContext) {
|
|
580
|
-
t =
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
});
|
|
590
|
-
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
533
|
+
t = Transition || (Transition = {
|
|
534
|
+
sources: new Set(),
|
|
535
|
+
effects: [],
|
|
536
|
+
promises: new Set(),
|
|
537
|
+
disposed: new Set(),
|
|
538
|
+
queue: new Set(),
|
|
539
|
+
running: true
|
|
540
|
+
});
|
|
541
|
+
t.done || (t.done = new Promise(res => t.resolve = res));
|
|
591
542
|
t.running = true;
|
|
592
543
|
}
|
|
593
544
|
runUpdates(fn, false);
|
|
@@ -595,7 +546,7 @@ function startTransition(fn) {
|
|
|
595
546
|
return t ? t.done : undefined;
|
|
596
547
|
});
|
|
597
548
|
}
|
|
598
|
-
const [transPending, setTransPending] = /*@__PURE__*/
|
|
549
|
+
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
599
550
|
function useTransition() {
|
|
600
551
|
return [transPending, startTransition];
|
|
601
552
|
}
|
|
@@ -613,9 +564,7 @@ function createContext(defaultValue, options) {
|
|
|
613
564
|
}
|
|
614
565
|
function useContext(context) {
|
|
615
566
|
let value;
|
|
616
|
-
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
|
|
617
|
-
? value
|
|
618
|
-
: context.defaultValue;
|
|
567
|
+
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined ? value : context.defaultValue;
|
|
619
568
|
}
|
|
620
569
|
function children(fn) {
|
|
621
570
|
const children = createMemo(fn);
|
|
@@ -632,7 +581,10 @@ function getSuspenseContext() {
|
|
|
632
581
|
}
|
|
633
582
|
function enableExternalSource(factory, untrack = fn => fn()) {
|
|
634
583
|
if (ExternalSourceConfig) {
|
|
635
|
-
const {
|
|
584
|
+
const {
|
|
585
|
+
factory: oldFactory,
|
|
586
|
+
untrack: oldUntrack
|
|
587
|
+
} = ExternalSourceConfig;
|
|
636
588
|
ExternalSourceConfig = {
|
|
637
589
|
factory: (fn, trigger) => {
|
|
638
590
|
const oldSource = oldFactory(fn, trigger);
|
|
@@ -657,8 +609,7 @@ function enableExternalSource(factory, untrack = fn => fn()) {
|
|
|
657
609
|
function readSignal() {
|
|
658
610
|
const runningTransition = Transition && Transition.running;
|
|
659
611
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
660
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
661
|
-
else {
|
|
612
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
|
|
662
613
|
const updates = Updates;
|
|
663
614
|
Updates = null;
|
|
664
615
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -686,12 +637,11 @@ function readSignal() {
|
|
|
686
637
|
return this.value;
|
|
687
638
|
}
|
|
688
639
|
function writeSignal(node, value, isComp) {
|
|
689
|
-
let current =
|
|
690
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
640
|
+
let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
691
641
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
692
642
|
if (Transition) {
|
|
693
643
|
const TransitionRunning = Transition.running;
|
|
694
|
-
if (TransitionRunning ||
|
|
644
|
+
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
695
645
|
Transition.sources.add(node);
|
|
696
646
|
node.tValue = value;
|
|
697
647
|
}
|
|
@@ -704,16 +654,14 @@ function writeSignal(node, value, isComp) {
|
|
|
704
654
|
const TransitionRunning = Transition && Transition.running;
|
|
705
655
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
706
656
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
707
|
-
if (o.pure) Updates.push(o);
|
|
708
|
-
else Effects.push(o);
|
|
657
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
709
658
|
if (o.observers) markDownstream(o);
|
|
710
659
|
}
|
|
711
|
-
if (!TransitionRunning) o.state = STALE;
|
|
712
|
-
else o.tState = STALE;
|
|
660
|
+
if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
|
|
713
661
|
}
|
|
714
662
|
if (Updates.length > 10e5) {
|
|
715
663
|
Updates = [];
|
|
716
|
-
if (IS_DEV);
|
|
664
|
+
if (IS_DEV) ;
|
|
717
665
|
throw new Error();
|
|
718
666
|
}
|
|
719
667
|
}, false);
|
|
@@ -725,11 +673,7 @@ function updateComputation(node) {
|
|
|
725
673
|
if (!node.fn) return;
|
|
726
674
|
cleanNode(node);
|
|
727
675
|
const time = ExecCount;
|
|
728
|
-
runComputation(
|
|
729
|
-
node,
|
|
730
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
731
|
-
time
|
|
732
|
-
);
|
|
676
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
733
677
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
734
678
|
queueMicrotask(() => {
|
|
735
679
|
runUpdates(() => {
|
|
@@ -794,14 +738,11 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
794
738
|
c.state = 0;
|
|
795
739
|
c.tState = state;
|
|
796
740
|
}
|
|
797
|
-
if (Owner === null);
|
|
798
|
-
else if (Owner !== UNOWNED) {
|
|
741
|
+
if (Owner === null) ;else if (Owner !== UNOWNED) {
|
|
799
742
|
if (Transition && Transition.running && Owner.pure) {
|
|
800
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
801
|
-
else Owner.tOwned.push(c);
|
|
743
|
+
if (!Owner.tOwned) Owner.tOwned = [c];else Owner.tOwned.push(c);
|
|
802
744
|
} else {
|
|
803
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
804
|
-
else Owner.owned.push(c);
|
|
745
|
+
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
805
746
|
}
|
|
806
747
|
}
|
|
807
748
|
if (ExternalSourceConfig && c.fn) {
|
|
@@ -852,8 +793,7 @@ function runUpdates(fn, init) {
|
|
|
852
793
|
if (Updates) return fn();
|
|
853
794
|
let wait = false;
|
|
854
795
|
if (!init) Updates = [];
|
|
855
|
-
if (Effects) wait = true;
|
|
856
|
-
else Effects = [];
|
|
796
|
+
if (Effects) wait = true;else Effects = [];
|
|
857
797
|
ExecCount++;
|
|
858
798
|
try {
|
|
859
799
|
const res = fn();
|
|
@@ -867,8 +807,7 @@ function runUpdates(fn, init) {
|
|
|
867
807
|
}
|
|
868
808
|
function completeUpdates(wait) {
|
|
869
809
|
if (Updates) {
|
|
870
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
871
|
-
else runQueue(Updates);
|
|
810
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);else runQueue(Updates);
|
|
872
811
|
Updates = null;
|
|
873
812
|
}
|
|
874
813
|
if (wait) return;
|
|
@@ -936,8 +875,7 @@ function runUserEffects(queue) {
|
|
|
936
875
|
userLength = 0;
|
|
937
876
|
for (i = 0; i < queue.length; i++) {
|
|
938
877
|
const e = queue[i];
|
|
939
|
-
if (!e.user) runTop(e);
|
|
940
|
-
else queue[userLength++] = e;
|
|
878
|
+
if (!e.user) runTop(e);else queue[userLength++] = e;
|
|
941
879
|
}
|
|
942
880
|
if (sharedConfig.context) {
|
|
943
881
|
if (sharedConfig.count) {
|
|
@@ -956,15 +894,13 @@ function runUserEffects(queue) {
|
|
|
956
894
|
}
|
|
957
895
|
function lookUpstream(node, ignore) {
|
|
958
896
|
const runningTransition = Transition && Transition.running;
|
|
959
|
-
if (runningTransition) node.tState = 0;
|
|
960
|
-
else node.state = 0;
|
|
897
|
+
if (runningTransition) node.tState = 0;else node.state = 0;
|
|
961
898
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
962
899
|
const source = node.sources[i];
|
|
963
900
|
if (source.sources) {
|
|
964
901
|
const state = runningTransition ? source.tState : source.state;
|
|
965
902
|
if (state === STALE) {
|
|
966
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
967
|
-
runTop(source);
|
|
903
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
|
|
968
904
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
969
905
|
}
|
|
970
906
|
}
|
|
@@ -974,10 +910,8 @@ function markDownstream(node) {
|
|
|
974
910
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
975
911
|
const o = node.observers[i];
|
|
976
912
|
if (runningTransition ? !o.tState : !o.state) {
|
|
977
|
-
if (runningTransition) o.tState = PENDING;
|
|
978
|
-
|
|
979
|
-
if (o.pure) Updates.push(o);
|
|
980
|
-
else Effects.push(o);
|
|
913
|
+
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
914
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
981
915
|
o.observers && markDownstream(o);
|
|
982
916
|
}
|
|
983
917
|
}
|
|
@@ -1014,8 +948,7 @@ function cleanNode(node) {
|
|
|
1014
948
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
1015
949
|
node.cleanups = null;
|
|
1016
950
|
}
|
|
1017
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1018
|
-
else node.state = 0;
|
|
951
|
+
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
1019
952
|
}
|
|
1020
953
|
function reset(node, top) {
|
|
1021
954
|
if (!top) {
|
|
@@ -1036,21 +969,19 @@ function runErrors(err, fns, owner) {
|
|
|
1036
969
|
try {
|
|
1037
970
|
for (const f of fns) f(err);
|
|
1038
971
|
} catch (e) {
|
|
1039
|
-
handleError(e,
|
|
972
|
+
handleError(e, owner && owner.owner || null);
|
|
1040
973
|
}
|
|
1041
974
|
}
|
|
1042
975
|
function handleError(err, owner = Owner) {
|
|
1043
976
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
1044
977
|
const error = castError(err);
|
|
1045
978
|
if (!fns) throw error;
|
|
1046
|
-
if (Effects)
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
});
|
|
1053
|
-
else runErrors(error, fns, owner);
|
|
979
|
+
if (Effects) Effects.push({
|
|
980
|
+
fn() {
|
|
981
|
+
runErrors(error, fns, owner);
|
|
982
|
+
},
|
|
983
|
+
state: STALE
|
|
984
|
+
});else runErrors(error, fns, owner);
|
|
1054
985
|
}
|
|
1055
986
|
function resolveChildren(children) {
|
|
1056
987
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1067,24 +998,19 @@ function resolveChildren(children) {
|
|
|
1067
998
|
function createProvider(id, options) {
|
|
1068
999
|
return function provider(props) {
|
|
1069
1000
|
let res;
|
|
1070
|
-
createRenderEffect(
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
return children(() => props.children);
|
|
1078
|
-
})),
|
|
1079
|
-
undefined
|
|
1080
|
-
);
|
|
1001
|
+
createRenderEffect(() => res = untrack(() => {
|
|
1002
|
+
Owner.context = {
|
|
1003
|
+
...Owner.context,
|
|
1004
|
+
[id]: props.value
|
|
1005
|
+
};
|
|
1006
|
+
return children(() => props.children);
|
|
1007
|
+
}), undefined);
|
|
1081
1008
|
return res;
|
|
1082
1009
|
};
|
|
1083
1010
|
}
|
|
1084
1011
|
function onError(fn) {
|
|
1085
1012
|
ERROR || (ERROR = Symbol("error"));
|
|
1086
|
-
if (Owner === null);
|
|
1087
|
-
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1013
|
+
if (Owner === null) ;else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1088
1014
|
Owner.context = {
|
|
1089
1015
|
...Owner.context,
|
|
1090
1016
|
[ERROR]: [fn]
|
|
@@ -1113,8 +1039,7 @@ function observable(input) {
|
|
|
1113
1039
|
if (!(observer instanceof Object) || observer == null) {
|
|
1114
1040
|
throw new TypeError("Expected the observer to be an object.");
|
|
1115
1041
|
}
|
|
1116
|
-
const handler =
|
|
1117
|
-
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1042
|
+
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1118
1043
|
if (!handler) {
|
|
1119
1044
|
return {
|
|
1120
1045
|
unsubscribe() {}
|
|
@@ -1145,7 +1070,7 @@ function from(producer, initalValue = undefined) {
|
|
|
1145
1070
|
});
|
|
1146
1071
|
if ("subscribe" in producer) {
|
|
1147
1072
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1148
|
-
onCleanup(() =>
|
|
1073
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1149
1074
|
} else {
|
|
1150
1075
|
const clean = producer(set);
|
|
1151
1076
|
onCleanup(clean);
|
|
@@ -1189,7 +1114,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1189
1114
|
});
|
|
1190
1115
|
len = 1;
|
|
1191
1116
|
}
|
|
1192
|
-
}
|
|
1117
|
+
}
|
|
1118
|
+
else if (len === 0) {
|
|
1193
1119
|
mapped = new Array(newLen);
|
|
1194
1120
|
for (j = 0; j < newLen; j++) {
|
|
1195
1121
|
items[j] = newItems[j];
|
|
@@ -1200,16 +1126,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1200
1126
|
temp = new Array(newLen);
|
|
1201
1127
|
tempdisposers = new Array(newLen);
|
|
1202
1128
|
indexes && (tempIndexes = new Array(newLen));
|
|
1203
|
-
for (
|
|
1204
|
-
|
|
1205
|
-
start < end && items[start] === newItems[start];
|
|
1206
|
-
start++
|
|
1207
|
-
);
|
|
1208
|
-
for (
|
|
1209
|
-
end = len - 1, newEnd = newLen - 1;
|
|
1210
|
-
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1211
|
-
end--, newEnd--
|
|
1212
|
-
) {
|
|
1129
|
+
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
|
|
1130
|
+
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
|
|
1213
1131
|
temp[newEnd] = mapped[end];
|
|
1214
1132
|
tempdisposers[newEnd] = disposers[end];
|
|
1215
1133
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1243,7 +1161,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1243
1161
|
}
|
|
1244
1162
|
} else mapped[j] = createRoot(mapper);
|
|
1245
1163
|
}
|
|
1246
|
-
mapped = mapped.slice(0,
|
|
1164
|
+
mapped = mapped.slice(0, len = newLen);
|
|
1247
1165
|
items = newItems.slice(0);
|
|
1248
1166
|
}
|
|
1249
1167
|
return mapped;
|
|
@@ -1310,7 +1228,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1310
1228
|
}
|
|
1311
1229
|
len = signals.length = disposers.length = newLen;
|
|
1312
1230
|
items = newItems.slice(0);
|
|
1313
|
-
return
|
|
1231
|
+
return mapped = mapped.slice(0, len);
|
|
1314
1232
|
});
|
|
1315
1233
|
function mapper(disposer) {
|
|
1316
1234
|
disposers[i] = disposer;
|
|
@@ -1379,33 +1297,29 @@ function mergeProps(...sources) {
|
|
|
1379
1297
|
let proxy = false;
|
|
1380
1298
|
for (let i = 0; i < sources.length; i++) {
|
|
1381
1299
|
const s = sources[i];
|
|
1382
|
-
proxy = proxy ||
|
|
1383
|
-
sources[i] = typeof s === "function" ? (
|
|
1300
|
+
proxy = proxy || !!s && $PROXY in s;
|
|
1301
|
+
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1384
1302
|
}
|
|
1385
1303
|
if (SUPPORTS_PROXY && proxy) {
|
|
1386
|
-
return new Proxy(
|
|
1387
|
-
{
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
if (v !== undefined) return v;
|
|
1392
|
-
}
|
|
1393
|
-
},
|
|
1394
|
-
has(property) {
|
|
1395
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1396
|
-
if (property in resolveSource(sources[i])) return true;
|
|
1397
|
-
}
|
|
1398
|
-
return false;
|
|
1399
|
-
},
|
|
1400
|
-
keys() {
|
|
1401
|
-
const keys = [];
|
|
1402
|
-
for (let i = 0; i < sources.length; i++)
|
|
1403
|
-
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1404
|
-
return [...new Set(keys)];
|
|
1304
|
+
return new Proxy({
|
|
1305
|
+
get(property) {
|
|
1306
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1307
|
+
const v = resolveSource(sources[i])[property];
|
|
1308
|
+
if (v !== undefined) return v;
|
|
1405
1309
|
}
|
|
1406
1310
|
},
|
|
1407
|
-
|
|
1408
|
-
|
|
1311
|
+
has(property) {
|
|
1312
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1313
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1314
|
+
}
|
|
1315
|
+
return false;
|
|
1316
|
+
},
|
|
1317
|
+
keys() {
|
|
1318
|
+
const keys = [];
|
|
1319
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1320
|
+
return [...new Set(keys)];
|
|
1321
|
+
}
|
|
1322
|
+
}, propTraps);
|
|
1409
1323
|
}
|
|
1410
1324
|
const sourcesMap = {};
|
|
1411
1325
|
const defined = Object.create(null);
|
|
@@ -1418,20 +1332,15 @@ function mergeProps(...sources) {
|
|
|
1418
1332
|
if (key === "__proto__" || key === "constructor") continue;
|
|
1419
1333
|
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
1420
1334
|
if (!defined[key]) {
|
|
1421
|
-
defined[key] = desc.get
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
}
|
|
1427
|
-
: desc.value !== undefined
|
|
1428
|
-
? desc
|
|
1429
|
-
: undefined;
|
|
1335
|
+
defined[key] = desc.get ? {
|
|
1336
|
+
enumerable: true,
|
|
1337
|
+
configurable: true,
|
|
1338
|
+
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1339
|
+
} : desc.value !== undefined ? desc : undefined;
|
|
1430
1340
|
} else {
|
|
1431
1341
|
const sources = sourcesMap[key];
|
|
1432
1342
|
if (sources) {
|
|
1433
|
-
if (desc.get) sources.push(desc.get.bind(source));
|
|
1434
|
-
else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1343
|
+
if (desc.get) sources.push(desc.get.bind(source));else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1435
1344
|
}
|
|
1436
1345
|
}
|
|
1437
1346
|
}
|
|
@@ -1441,8 +1350,7 @@ function mergeProps(...sources) {
|
|
|
1441
1350
|
for (let i = definedKeys.length - 1; i >= 0; i--) {
|
|
1442
1351
|
const key = definedKeys[i],
|
|
1443
1352
|
desc = defined[key];
|
|
1444
|
-
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1445
|
-
else target[key] = desc ? desc.value : undefined;
|
|
1353
|
+
if (desc && desc.get) Object.defineProperty(target, key, desc);else target[key] = desc ? desc.value : undefined;
|
|
1446
1354
|
}
|
|
1447
1355
|
return target;
|
|
1448
1356
|
}
|
|
@@ -1450,60 +1358,47 @@ function splitProps(props, ...keys) {
|
|
|
1450
1358
|
if (SUPPORTS_PROXY && $PROXY in props) {
|
|
1451
1359
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1452
1360
|
const res = keys.map(k => {
|
|
1453
|
-
return new Proxy(
|
|
1454
|
-
{
|
|
1455
|
-
|
|
1456
|
-
return k.includes(property) ? props[property] : undefined;
|
|
1457
|
-
},
|
|
1458
|
-
has(property) {
|
|
1459
|
-
return k.includes(property) && property in props;
|
|
1460
|
-
},
|
|
1461
|
-
keys() {
|
|
1462
|
-
return k.filter(property => property in props);
|
|
1463
|
-
}
|
|
1361
|
+
return new Proxy({
|
|
1362
|
+
get(property) {
|
|
1363
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1464
1364
|
},
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
});
|
|
1468
|
-
res.push(
|
|
1469
|
-
new Proxy(
|
|
1470
|
-
{
|
|
1471
|
-
get(property) {
|
|
1472
|
-
return blocked.has(property) ? undefined : props[property];
|
|
1473
|
-
},
|
|
1474
|
-
has(property) {
|
|
1475
|
-
return blocked.has(property) ? false : property in props;
|
|
1476
|
-
},
|
|
1477
|
-
keys() {
|
|
1478
|
-
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1479
|
-
}
|
|
1365
|
+
has(property) {
|
|
1366
|
+
return k.includes(property) && property in props;
|
|
1480
1367
|
},
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1368
|
+
keys() {
|
|
1369
|
+
return k.filter(property => property in props);
|
|
1370
|
+
}
|
|
1371
|
+
}, propTraps);
|
|
1372
|
+
});
|
|
1373
|
+
res.push(new Proxy({
|
|
1374
|
+
get(property) {
|
|
1375
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1376
|
+
},
|
|
1377
|
+
has(property) {
|
|
1378
|
+
return blocked.has(property) ? false : property in props;
|
|
1379
|
+
},
|
|
1380
|
+
keys() {
|
|
1381
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1382
|
+
}
|
|
1383
|
+
}, propTraps));
|
|
1484
1384
|
return res;
|
|
1485
1385
|
}
|
|
1486
1386
|
const otherObject = {};
|
|
1487
1387
|
const objects = keys.map(() => ({}));
|
|
1488
1388
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1489
1389
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1490
|
-
const isDefaultDesc =
|
|
1491
|
-
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1390
|
+
const isDefaultDesc = !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1492
1391
|
let blocked = false;
|
|
1493
1392
|
let objectIndex = 0;
|
|
1494
1393
|
for (const k of keys) {
|
|
1495
1394
|
if (k.includes(propName)) {
|
|
1496
1395
|
blocked = true;
|
|
1497
|
-
isDefaultDesc
|
|
1498
|
-
? (objects[objectIndex][propName] = desc.value)
|
|
1499
|
-
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1396
|
+
isDefaultDesc ? objects[objectIndex][propName] = desc.value : Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1500
1397
|
}
|
|
1501
1398
|
++objectIndex;
|
|
1502
1399
|
}
|
|
1503
1400
|
if (!blocked) {
|
|
1504
|
-
isDefaultDesc
|
|
1505
|
-
? (otherObject[propName] = desc.value)
|
|
1506
|
-
: Object.defineProperty(otherObject, propName, desc);
|
|
1401
|
+
isDefaultDesc ? otherObject[propName] = desc.value : Object.defineProperty(otherObject, propName, desc);
|
|
1507
1402
|
}
|
|
1508
1403
|
}
|
|
1509
1404
|
return [...objects, otherObject];
|
|
@@ -1529,21 +1424,17 @@ function lazy(fn) {
|
|
|
1529
1424
|
comp = s;
|
|
1530
1425
|
}
|
|
1531
1426
|
let Comp;
|
|
1532
|
-
return createMemo(() =>
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
return r;
|
|
1542
|
-
})
|
|
1543
|
-
: ""
|
|
1544
|
-
);
|
|
1427
|
+
return createMemo(() => (Comp = comp()) ? untrack(() => {
|
|
1428
|
+
if (IS_DEV) ;
|
|
1429
|
+
if (!ctx || sharedConfig.done) return Comp(props);
|
|
1430
|
+
const c = sharedConfig.context;
|
|
1431
|
+
setHydrateContext(ctx);
|
|
1432
|
+
const r = Comp(props);
|
|
1433
|
+
setHydrateContext(c);
|
|
1434
|
+
return r;
|
|
1435
|
+
}) : "");
|
|
1545
1436
|
};
|
|
1546
|
-
wrap.preload = () => p || ((p = fn()).then(mod =>
|
|
1437
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1547
1438
|
return wrap;
|
|
1548
1439
|
}
|
|
1549
1440
|
let counter = 0;
|
|
@@ -1568,35 +1459,21 @@ function Index(props) {
|
|
|
1568
1459
|
function Show(props) {
|
|
1569
1460
|
const keyed = props.keyed;
|
|
1570
1461
|
const conditionValue = createMemo(() => props.when, undefined, undefined);
|
|
1571
|
-
const condition = keyed
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
const
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
? c
|
|
1587
|
-
: () => {
|
|
1588
|
-
if (!untrack(condition)) throw narrowedError("Show");
|
|
1589
|
-
return conditionValue();
|
|
1590
|
-
}
|
|
1591
|
-
)
|
|
1592
|
-
)
|
|
1593
|
-
: child;
|
|
1594
|
-
}
|
|
1595
|
-
return props.fallback;
|
|
1596
|
-
},
|
|
1597
|
-
undefined,
|
|
1598
|
-
undefined
|
|
1599
|
-
);
|
|
1462
|
+
const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1463
|
+
equals: (a, b) => !a === !b
|
|
1464
|
+
});
|
|
1465
|
+
return createMemo(() => {
|
|
1466
|
+
const c = condition();
|
|
1467
|
+
if (c) {
|
|
1468
|
+
const child = props.children;
|
|
1469
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1470
|
+
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1471
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1472
|
+
return conditionValue();
|
|
1473
|
+
})) : child;
|
|
1474
|
+
}
|
|
1475
|
+
return props.fallback;
|
|
1476
|
+
}, undefined, undefined);
|
|
1600
1477
|
}
|
|
1601
1478
|
function Switch(props) {
|
|
1602
1479
|
const chs = children(() => props.children);
|
|
@@ -1608,43 +1485,25 @@ function Switch(props) {
|
|
|
1608
1485
|
const index = i;
|
|
1609
1486
|
const mp = mps[i];
|
|
1610
1487
|
const prevFunc = func;
|
|
1611
|
-
const conditionValue = createMemo(
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
);
|
|
1616
|
-
const condition = mp.keyed
|
|
1617
|
-
? conditionValue
|
|
1618
|
-
: createMemo(conditionValue, undefined, {
|
|
1619
|
-
equals: (a, b) => !a === !b
|
|
1620
|
-
});
|
|
1488
|
+
const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, undefined);
|
|
1489
|
+
const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1490
|
+
equals: (a, b) => !a === !b
|
|
1491
|
+
});
|
|
1621
1492
|
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
1622
1493
|
}
|
|
1623
1494
|
return func;
|
|
1624
1495
|
});
|
|
1625
|
-
return createMemo(
|
|
1626
|
-
()
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
? conditionValue()
|
|
1637
|
-
: () => {
|
|
1638
|
-
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
1639
|
-
return conditionValue();
|
|
1640
|
-
}
|
|
1641
|
-
)
|
|
1642
|
-
)
|
|
1643
|
-
: child;
|
|
1644
|
-
},
|
|
1645
|
-
undefined,
|
|
1646
|
-
undefined
|
|
1647
|
-
);
|
|
1496
|
+
return createMemo(() => {
|
|
1497
|
+
const sel = switchFunc()();
|
|
1498
|
+
if (!sel) return props.fallback;
|
|
1499
|
+
const [index, conditionValue, mp] = sel;
|
|
1500
|
+
const child = mp.children;
|
|
1501
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1502
|
+
return fn ? untrack(() => child(mp.keyed ? conditionValue() : () => {
|
|
1503
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
1504
|
+
return conditionValue();
|
|
1505
|
+
})) : child;
|
|
1506
|
+
}, undefined, undefined);
|
|
1648
1507
|
}
|
|
1649
1508
|
function Match(props) {
|
|
1650
1509
|
return props;
|
|
@@ -1655,29 +1514,23 @@ function resetErrorBoundaries() {
|
|
|
1655
1514
|
}
|
|
1656
1515
|
function ErrorBoundary(props) {
|
|
1657
1516
|
let err;
|
|
1658
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1659
|
-
err = sharedConfig.load(sharedConfig.getContextId());
|
|
1517
|
+
if (sharedConfig.context && sharedConfig.load) err = sharedConfig.load(sharedConfig.getContextId());
|
|
1660
1518
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1661
1519
|
Errors || (Errors = new Set());
|
|
1662
1520
|
Errors.add(setErrored);
|
|
1663
1521
|
onCleanup(() => Errors.delete(setErrored));
|
|
1664
|
-
return createMemo(
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
},
|
|
1673
|
-
undefined,
|
|
1674
|
-
undefined
|
|
1675
|
-
);
|
|
1522
|
+
return createMemo(() => {
|
|
1523
|
+
let e;
|
|
1524
|
+
if (e = errored()) {
|
|
1525
|
+
const f = props.fallback;
|
|
1526
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1527
|
+
}
|
|
1528
|
+
return catchError(() => props.children, setErrored);
|
|
1529
|
+
}, undefined, undefined);
|
|
1676
1530
|
}
|
|
1677
1531
|
|
|
1678
|
-
const suspenseListEquals = (a, b) =>
|
|
1679
|
-
|
|
1680
|
-
const SuspenseListContext = /* #__PURE__ */ createContext();
|
|
1532
|
+
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1533
|
+
const SuspenseListContext = /* #__PURE__ */createContext();
|
|
1681
1534
|
function SuspenseList(props) {
|
|
1682
1535
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1683
1536
|
inFallback: false
|
|
@@ -1688,51 +1541,51 @@ function SuspenseList(props) {
|
|
|
1688
1541
|
if (listContext) {
|
|
1689
1542
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1690
1543
|
}
|
|
1691
|
-
const resolved = createMemo(
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1544
|
+
const resolved = createMemo(prev => {
|
|
1545
|
+
const reveal = props.revealOrder,
|
|
1546
|
+
tail = props.tail,
|
|
1547
|
+
{
|
|
1548
|
+
showContent = true,
|
|
1549
|
+
showFallback = true
|
|
1550
|
+
} = show ? show() : {},
|
|
1551
|
+
reg = registry(),
|
|
1552
|
+
reverse = reveal === "backwards";
|
|
1553
|
+
if (reveal === "together") {
|
|
1554
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1555
|
+
const res = reg.map(() => ({
|
|
1556
|
+
showContent: all && showContent,
|
|
1557
|
+
showFallback
|
|
1558
|
+
}));
|
|
1559
|
+
res.inFallback = !all;
|
|
1560
|
+
return res;
|
|
1561
|
+
}
|
|
1562
|
+
let stop = false;
|
|
1563
|
+
let inFallback = prev.inFallback;
|
|
1564
|
+
const res = [];
|
|
1565
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1566
|
+
const n = reverse ? len - i - 1 : i,
|
|
1567
|
+
s = reg[n]();
|
|
1568
|
+
if (!stop && !s) {
|
|
1569
|
+
res[n] = {
|
|
1570
|
+
showContent,
|
|
1702
1571
|
showFallback
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
s = reg[n]();
|
|
1713
|
-
if (!stop && !s) {
|
|
1714
|
-
res[n] = {
|
|
1715
|
-
showContent,
|
|
1716
|
-
showFallback
|
|
1717
|
-
};
|
|
1718
|
-
} else {
|
|
1719
|
-
const next = !stop;
|
|
1720
|
-
if (next) inFallback = true;
|
|
1721
|
-
res[n] = {
|
|
1722
|
-
showContent: next,
|
|
1723
|
-
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1724
|
-
};
|
|
1725
|
-
stop = true;
|
|
1726
|
-
}
|
|
1572
|
+
};
|
|
1573
|
+
} else {
|
|
1574
|
+
const next = !stop;
|
|
1575
|
+
if (next) inFallback = true;
|
|
1576
|
+
res[n] = {
|
|
1577
|
+
showContent: next,
|
|
1578
|
+
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1579
|
+
};
|
|
1580
|
+
stop = true;
|
|
1727
1581
|
}
|
|
1728
|
-
if (!stop) inFallback = false;
|
|
1729
|
-
res.inFallback = inFallback;
|
|
1730
|
-
return res;
|
|
1731
|
-
},
|
|
1732
|
-
{
|
|
1733
|
-
inFallback: false
|
|
1734
1582
|
}
|
|
1735
|
-
|
|
1583
|
+
if (!stop) inFallback = false;
|
|
1584
|
+
res.inFallback = inFallback;
|
|
1585
|
+
return res;
|
|
1586
|
+
}, {
|
|
1587
|
+
inFallback: false
|
|
1588
|
+
});
|
|
1736
1589
|
setWrapper(() => resolved);
|
|
1737
1590
|
return createComponent(SuspenseListContext.Provider, {
|
|
1738
1591
|
value: {
|
|
@@ -1777,27 +1630,23 @@ function Suspense(props) {
|
|
|
1777
1630
|
const key = sharedConfig.getContextId();
|
|
1778
1631
|
let ref = sharedConfig.load(key);
|
|
1779
1632
|
if (ref) {
|
|
1780
|
-
if (typeof ref !== "object" || ref.
|
|
1781
|
-
else sharedConfig.gather(key);
|
|
1633
|
+
if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(key);
|
|
1782
1634
|
}
|
|
1783
1635
|
if (p && p !== "$$f") {
|
|
1784
1636
|
const [s, set] = createSignal(undefined, {
|
|
1785
1637
|
equals: false
|
|
1786
1638
|
});
|
|
1787
1639
|
flicker = s;
|
|
1788
|
-
p.then(
|
|
1789
|
-
()
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
set();
|
|
1799
|
-
}
|
|
1800
|
-
);
|
|
1640
|
+
p.then(() => {
|
|
1641
|
+
if (sharedConfig.done) return set();
|
|
1642
|
+
sharedConfig.gather(key);
|
|
1643
|
+
setHydrateContext(ctx);
|
|
1644
|
+
set();
|
|
1645
|
+
setHydrateContext();
|
|
1646
|
+
}, err => {
|
|
1647
|
+
error = err;
|
|
1648
|
+
set();
|
|
1649
|
+
});
|
|
1801
1650
|
}
|
|
1802
1651
|
}
|
|
1803
1652
|
const listContext = useContext(SuspenseListContext);
|
|
@@ -1812,14 +1661,17 @@ function Suspense(props) {
|
|
|
1812
1661
|
ctx = sharedConfig.context;
|
|
1813
1662
|
if (flicker) {
|
|
1814
1663
|
flicker();
|
|
1815
|
-
return
|
|
1664
|
+
return flicker = undefined;
|
|
1816
1665
|
}
|
|
1817
1666
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1818
1667
|
const rendered = createMemo(() => props.children);
|
|
1819
1668
|
return createMemo(prev => {
|
|
1820
1669
|
const inFallback = store.inFallback(),
|
|
1821
|
-
{
|
|
1822
|
-
|
|
1670
|
+
{
|
|
1671
|
+
showContent = true,
|
|
1672
|
+
showFallback = true
|
|
1673
|
+
} = show ? show() : {};
|
|
1674
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1823
1675
|
store.resolved = true;
|
|
1824
1676
|
dispose && dispose();
|
|
1825
1677
|
dispose = ctx = p = undefined;
|
|
@@ -1847,59 +1699,4 @@ function Suspense(props) {
|
|
|
1847
1699
|
|
|
1848
1700
|
const DEV = undefined;
|
|
1849
1701
|
|
|
1850
|
-
export {
|
|
1851
|
-
$DEVCOMP,
|
|
1852
|
-
$PROXY,
|
|
1853
|
-
$TRACK,
|
|
1854
|
-
DEV,
|
|
1855
|
-
ErrorBoundary,
|
|
1856
|
-
For,
|
|
1857
|
-
Index,
|
|
1858
|
-
Match,
|
|
1859
|
-
Show,
|
|
1860
|
-
Suspense,
|
|
1861
|
-
SuspenseList,
|
|
1862
|
-
Switch,
|
|
1863
|
-
batch,
|
|
1864
|
-
cancelCallback,
|
|
1865
|
-
catchError,
|
|
1866
|
-
children,
|
|
1867
|
-
createComponent,
|
|
1868
|
-
createComputed,
|
|
1869
|
-
createContext,
|
|
1870
|
-
createDeferred,
|
|
1871
|
-
createEffect,
|
|
1872
|
-
createMemo,
|
|
1873
|
-
createReaction,
|
|
1874
|
-
createRenderEffect,
|
|
1875
|
-
createResource,
|
|
1876
|
-
createRoot,
|
|
1877
|
-
createSelector,
|
|
1878
|
-
createSignal,
|
|
1879
|
-
createUniqueId,
|
|
1880
|
-
enableExternalSource,
|
|
1881
|
-
enableHydration,
|
|
1882
|
-
enableScheduling,
|
|
1883
|
-
equalFn,
|
|
1884
|
-
from,
|
|
1885
|
-
getListener,
|
|
1886
|
-
getOwner,
|
|
1887
|
-
indexArray,
|
|
1888
|
-
lazy,
|
|
1889
|
-
mapArray,
|
|
1890
|
-
mergeProps,
|
|
1891
|
-
observable,
|
|
1892
|
-
on,
|
|
1893
|
-
onCleanup,
|
|
1894
|
-
onError,
|
|
1895
|
-
onMount,
|
|
1896
|
-
requestCallback,
|
|
1897
|
-
resetErrorBoundaries,
|
|
1898
|
-
runWithOwner,
|
|
1899
|
-
sharedConfig,
|
|
1900
|
-
splitProps,
|
|
1901
|
-
startTransition,
|
|
1902
|
-
untrack,
|
|
1903
|
-
useContext,
|
|
1904
|
-
useTransition
|
|
1905
|
-
};
|
|
1702
|
+
export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|