solid-js 1.8.19 → 1.8.21
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 +6 -6
- package/dist/dev.js +562 -321
- package/dist/server.js +168 -74
- package/dist/solid.cjs +6 -6
- package/dist/solid.js +489 -279
- package/h/dist/h.js +38 -9
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -33
- package/package.json +1 -1
- package/store/dist/dev.js +122 -43
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +113 -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 +12 -4
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +913 -862
- 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 +64 -33
- 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.cjs +34 -18
- package/web/dist/dev.js +655 -97
- package/web/dist/server.cjs +1 -1
- package/web/dist/server.js +210 -96
- package/web/dist/web.cjs +32 -16
- package/web/dist/web.js +646 -95
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +2 -2
- 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/dist/solid.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
|
}
|
|
@@ -117,6 +119,7 @@ function workLoop(hasTimeRemaining, initialTime) {
|
|
|
117
119
|
const sharedConfig = {
|
|
118
120
|
context: undefined,
|
|
119
121
|
registry: undefined,
|
|
122
|
+
done: false,
|
|
120
123
|
getContextId() {
|
|
121
124
|
return getContextId(this.context.count);
|
|
122
125
|
},
|
|
@@ -171,12 +174,14 @@ function createRoot(fn, detachedOwner) {
|
|
|
171
174
|
owner = Owner,
|
|
172
175
|
unowned = fn.length === 0,
|
|
173
176
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
174
|
-
root = unowned
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
root = unowned
|
|
178
|
+
? UNOWNED
|
|
179
|
+
: {
|
|
180
|
+
owned: null,
|
|
181
|
+
cleanups: null,
|
|
182
|
+
context: current ? current.context : null,
|
|
183
|
+
owner: current
|
|
184
|
+
},
|
|
180
185
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
181
186
|
Owner = root;
|
|
182
187
|
Listener = null;
|
|
@@ -197,7 +202,8 @@ function createSignal(value, options) {
|
|
|
197
202
|
};
|
|
198
203
|
const setter = value => {
|
|
199
204
|
if (typeof value === "function") {
|
|
200
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
205
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
206
|
+
else value = value(s.value);
|
|
201
207
|
}
|
|
202
208
|
return writeSignal(s, value);
|
|
203
209
|
};
|
|
@@ -205,11 +211,13 @@ function createSignal(value, options) {
|
|
|
205
211
|
}
|
|
206
212
|
function createComputed(fn, value, options) {
|
|
207
213
|
const c = createComputation(fn, value, true, STALE);
|
|
208
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
214
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
215
|
+
else updateComputation(c);
|
|
209
216
|
}
|
|
210
217
|
function createRenderEffect(fn, value, options) {
|
|
211
218
|
const c = createComputation(fn, value, false, STALE);
|
|
212
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
219
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
220
|
+
else updateComputation(c);
|
|
213
221
|
}
|
|
214
222
|
function createEffect(fn, value, options) {
|
|
215
223
|
runEffects = runUserEffects;
|
|
@@ -221,10 +229,15 @@ function createEffect(fn, value, options) {
|
|
|
221
229
|
}
|
|
222
230
|
function createReaction(onInvalidate, options) {
|
|
223
231
|
let fn;
|
|
224
|
-
const c = createComputation(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
232
|
+
const c = createComputation(
|
|
233
|
+
() => {
|
|
234
|
+
fn ? fn() : untrack(onInvalidate);
|
|
235
|
+
fn = undefined;
|
|
236
|
+
},
|
|
237
|
+
undefined,
|
|
238
|
+
false,
|
|
239
|
+
0
|
|
240
|
+
),
|
|
228
241
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
229
242
|
if (s) c.suspense = s;
|
|
230
243
|
c.user = true;
|
|
@@ -252,7 +265,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
252
265
|
let source;
|
|
253
266
|
let fetcher;
|
|
254
267
|
let options;
|
|
255
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
268
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
256
269
|
source = true;
|
|
257
270
|
fetcher = pSource;
|
|
258
271
|
options = pFetcher || {};
|
|
@@ -266,7 +279,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
266
279
|
id = null,
|
|
267
280
|
loadedUnderTransition = false,
|
|
268
281
|
scheduled = false,
|
|
269
|
-
resolved =
|
|
282
|
+
resolved = "initialValue" in options,
|
|
270
283
|
dynamic = typeof source === "function" && createMemo(source);
|
|
271
284
|
const contexts = new Set(),
|
|
272
285
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -277,16 +290,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
277
290
|
[state, setState] = createSignal(resolved ? "ready" : "unresolved");
|
|
278
291
|
if (sharedConfig.context) {
|
|
279
292
|
id = sharedConfig.getNextContextId();
|
|
280
|
-
|
|
281
|
-
|
|
293
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
294
|
+
else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
|
|
282
295
|
}
|
|
283
296
|
function loadEnd(p, v, error, key) {
|
|
284
297
|
if (pr === p) {
|
|
285
298
|
pr = null;
|
|
286
299
|
key !== undefined && (resolved = true);
|
|
287
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
288
|
-
|
|
289
|
-
|
|
300
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
301
|
+
queueMicrotask(() =>
|
|
302
|
+
options.onHydrated(key, {
|
|
303
|
+
value: v
|
|
304
|
+
})
|
|
305
|
+
);
|
|
290
306
|
initP = NO_INIT;
|
|
291
307
|
if (Transition && p && loadedUnderTransition) {
|
|
292
308
|
Transition.promises.delete(p);
|
|
@@ -317,7 +333,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
317
333
|
createComputed(() => {
|
|
318
334
|
track();
|
|
319
335
|
if (pr) {
|
|
320
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
336
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
337
|
+
else if (!contexts.has(c)) {
|
|
321
338
|
c.increment();
|
|
322
339
|
contexts.add(c);
|
|
323
340
|
}
|
|
@@ -336,26 +353,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
336
353
|
return;
|
|
337
354
|
}
|
|
338
355
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
339
|
-
const p =
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
356
|
+
const p =
|
|
357
|
+
initP !== NO_INIT
|
|
358
|
+
? initP
|
|
359
|
+
: untrack(() =>
|
|
360
|
+
fetcher(lookup, {
|
|
361
|
+
value: value(),
|
|
362
|
+
refetching
|
|
363
|
+
})
|
|
364
|
+
);
|
|
343
365
|
if (!isPromise(p)) {
|
|
344
366
|
loadEnd(pr, p, undefined, lookup);
|
|
345
367
|
return p;
|
|
346
368
|
}
|
|
347
369
|
pr = p;
|
|
348
370
|
if ("value" in p) {
|
|
349
|
-
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
371
|
+
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
372
|
+
else loadEnd(pr, undefined, castError(p.value), lookup);
|
|
350
373
|
return p;
|
|
351
374
|
}
|
|
352
375
|
scheduled = true;
|
|
353
|
-
queueMicrotask(() => scheduled = false);
|
|
376
|
+
queueMicrotask(() => (scheduled = false));
|
|
354
377
|
runUpdates(() => {
|
|
355
378
|
setState(resolved ? "refreshing" : "pending");
|
|
356
379
|
trigger();
|
|
357
380
|
}, false);
|
|
358
|
-
return p.then(
|
|
381
|
+
return p.then(
|
|
382
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
383
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
384
|
+
);
|
|
359
385
|
}
|
|
360
386
|
Object.defineProperties(read, {
|
|
361
387
|
state: {
|
|
@@ -379,50 +405,80 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
379
405
|
}
|
|
380
406
|
}
|
|
381
407
|
});
|
|
382
|
-
if (dynamic) createComputed(() => load(false));
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
408
|
+
if (dynamic) createComputed(() => load(false));
|
|
409
|
+
else load(false);
|
|
410
|
+
return [
|
|
411
|
+
read,
|
|
412
|
+
{
|
|
413
|
+
refetch: load,
|
|
414
|
+
mutate: setValue
|
|
415
|
+
}
|
|
416
|
+
];
|
|
387
417
|
}
|
|
388
418
|
function createDeferred(source, options) {
|
|
389
419
|
let t,
|
|
390
420
|
timeout = options ? options.timeoutMs : undefined;
|
|
391
|
-
const node = createComputation(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
421
|
+
const node = createComputation(
|
|
422
|
+
() => {
|
|
423
|
+
if (!t || !t.fn)
|
|
424
|
+
t = requestCallback(
|
|
425
|
+
() => setDeferred(() => node.value),
|
|
426
|
+
timeout !== undefined
|
|
427
|
+
? {
|
|
428
|
+
timeout
|
|
429
|
+
}
|
|
430
|
+
: undefined
|
|
431
|
+
);
|
|
432
|
+
return source();
|
|
433
|
+
},
|
|
434
|
+
undefined,
|
|
435
|
+
true
|
|
436
|
+
);
|
|
437
|
+
const [deferred, setDeferred] = createSignal(
|
|
438
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
439
|
+
options
|
|
440
|
+
);
|
|
398
441
|
updateComputation(node);
|
|
399
|
-
setDeferred(() =>
|
|
442
|
+
setDeferred(() =>
|
|
443
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
444
|
+
);
|
|
400
445
|
return deferred;
|
|
401
446
|
}
|
|
402
447
|
function createSelector(source, fn = equalFn, options) {
|
|
403
448
|
const subs = new Map();
|
|
404
|
-
const node = createComputation(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
for (const
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
449
|
+
const node = createComputation(
|
|
450
|
+
p => {
|
|
451
|
+
const v = source();
|
|
452
|
+
for (const [key, val] of subs.entries())
|
|
453
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
454
|
+
for (const c of val.values()) {
|
|
455
|
+
c.state = STALE;
|
|
456
|
+
if (c.pure) Updates.push(c);
|
|
457
|
+
else Effects.push(c);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return v;
|
|
461
|
+
},
|
|
462
|
+
undefined,
|
|
463
|
+
true,
|
|
464
|
+
STALE
|
|
465
|
+
);
|
|
414
466
|
updateComputation(node);
|
|
415
467
|
return key => {
|
|
416
468
|
const listener = Listener;
|
|
417
469
|
if (listener) {
|
|
418
470
|
let l;
|
|
419
|
-
if (l = subs.get(key)) l.add(listener);
|
|
471
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
472
|
+
else subs.set(key, (l = new Set([listener])));
|
|
420
473
|
onCleanup(() => {
|
|
421
474
|
l.delete(listener);
|
|
422
475
|
!l.size && subs.delete(key);
|
|
423
476
|
});
|
|
424
477
|
}
|
|
425
|
-
return fn(
|
|
478
|
+
return fn(
|
|
479
|
+
key,
|
|
480
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
481
|
+
);
|
|
426
482
|
};
|
|
427
483
|
}
|
|
428
484
|
function batch(fn) {
|
|
@@ -462,7 +518,9 @@ function onMount(fn) {
|
|
|
462
518
|
createEffect(() => untrack(fn));
|
|
463
519
|
}
|
|
464
520
|
function onCleanup(fn) {
|
|
465
|
-
if (Owner === null)
|
|
521
|
+
if (Owner === null);
|
|
522
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
523
|
+
else Owner.cleanups.push(fn);
|
|
466
524
|
return fn;
|
|
467
525
|
}
|
|
468
526
|
function catchError(fn, handler) {
|
|
@@ -516,15 +574,17 @@ function startTransition(fn) {
|
|
|
516
574
|
Owner = o;
|
|
517
575
|
let t;
|
|
518
576
|
if (Scheduler || SuspenseContext) {
|
|
519
|
-
t =
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
577
|
+
t =
|
|
578
|
+
Transition ||
|
|
579
|
+
(Transition = {
|
|
580
|
+
sources: new Set(),
|
|
581
|
+
effects: [],
|
|
582
|
+
promises: new Set(),
|
|
583
|
+
disposed: new Set(),
|
|
584
|
+
queue: new Set(),
|
|
585
|
+
running: true
|
|
586
|
+
});
|
|
587
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
528
588
|
t.running = true;
|
|
529
589
|
}
|
|
530
590
|
runUpdates(fn, false);
|
|
@@ -532,7 +592,7 @@ function startTransition(fn) {
|
|
|
532
592
|
return t ? t.done : undefined;
|
|
533
593
|
});
|
|
534
594
|
}
|
|
535
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
595
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
536
596
|
function useTransition() {
|
|
537
597
|
return [transPending, startTransition];
|
|
538
598
|
}
|
|
@@ -550,7 +610,9 @@ function createContext(defaultValue, options) {
|
|
|
550
610
|
}
|
|
551
611
|
function useContext(context) {
|
|
552
612
|
let value;
|
|
553
|
-
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
|
|
613
|
+
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
|
|
614
|
+
? value
|
|
615
|
+
: context.defaultValue;
|
|
554
616
|
}
|
|
555
617
|
function children(fn) {
|
|
556
618
|
const children = createMemo(fn);
|
|
@@ -567,10 +629,7 @@ function getSuspenseContext() {
|
|
|
567
629
|
}
|
|
568
630
|
function enableExternalSource(factory, untrack = fn => fn()) {
|
|
569
631
|
if (ExternalSourceConfig) {
|
|
570
|
-
const {
|
|
571
|
-
factory: oldFactory,
|
|
572
|
-
untrack: oldUntrack
|
|
573
|
-
} = ExternalSourceConfig;
|
|
632
|
+
const { factory: oldFactory, untrack: oldUntrack } = ExternalSourceConfig;
|
|
574
633
|
ExternalSourceConfig = {
|
|
575
634
|
factory: (fn, trigger) => {
|
|
576
635
|
const oldSource = oldFactory(fn, trigger);
|
|
@@ -595,7 +654,8 @@ function enableExternalSource(factory, untrack = fn => fn()) {
|
|
|
595
654
|
function readSignal() {
|
|
596
655
|
const runningTransition = Transition && Transition.running;
|
|
597
656
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
598
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
657
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
658
|
+
else {
|
|
599
659
|
const updates = Updates;
|
|
600
660
|
Updates = null;
|
|
601
661
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -623,11 +683,12 @@ function readSignal() {
|
|
|
623
683
|
return this.value;
|
|
624
684
|
}
|
|
625
685
|
function writeSignal(node, value, isComp) {
|
|
626
|
-
let current =
|
|
686
|
+
let current =
|
|
687
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
627
688
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
628
689
|
if (Transition) {
|
|
629
690
|
const TransitionRunning = Transition.running;
|
|
630
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
691
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
631
692
|
Transition.sources.add(node);
|
|
632
693
|
node.tValue = value;
|
|
633
694
|
}
|
|
@@ -640,14 +701,16 @@ function writeSignal(node, value, isComp) {
|
|
|
640
701
|
const TransitionRunning = Transition && Transition.running;
|
|
641
702
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
642
703
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
643
|
-
if (o.pure) Updates.push(o);
|
|
704
|
+
if (o.pure) Updates.push(o);
|
|
705
|
+
else Effects.push(o);
|
|
644
706
|
if (o.observers) markDownstream(o);
|
|
645
707
|
}
|
|
646
|
-
if (!TransitionRunning) o.state = STALE;
|
|
708
|
+
if (!TransitionRunning) o.state = STALE;
|
|
709
|
+
else o.tState = STALE;
|
|
647
710
|
}
|
|
648
711
|
if (Updates.length > 10e5) {
|
|
649
712
|
Updates = [];
|
|
650
|
-
if (false)
|
|
713
|
+
if (false);
|
|
651
714
|
throw new Error();
|
|
652
715
|
}
|
|
653
716
|
}, false);
|
|
@@ -659,7 +722,11 @@ function updateComputation(node) {
|
|
|
659
722
|
if (!node.fn) return;
|
|
660
723
|
cleanNode(node);
|
|
661
724
|
const time = ExecCount;
|
|
662
|
-
runComputation(
|
|
725
|
+
runComputation(
|
|
726
|
+
node,
|
|
727
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
728
|
+
time
|
|
729
|
+
);
|
|
663
730
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
664
731
|
queueMicrotask(() => {
|
|
665
732
|
runUpdates(() => {
|
|
@@ -724,11 +791,14 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
724
791
|
c.state = 0;
|
|
725
792
|
c.tState = state;
|
|
726
793
|
}
|
|
727
|
-
if (Owner === null)
|
|
794
|
+
if (Owner === null);
|
|
795
|
+
else if (Owner !== UNOWNED) {
|
|
728
796
|
if (Transition && Transition.running && Owner.pure) {
|
|
729
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
797
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
798
|
+
else Owner.tOwned.push(c);
|
|
730
799
|
} else {
|
|
731
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
800
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
801
|
+
else Owner.owned.push(c);
|
|
732
802
|
}
|
|
733
803
|
}
|
|
734
804
|
if (ExternalSourceConfig && c.fn) {
|
|
@@ -779,7 +849,8 @@ function runUpdates(fn, init) {
|
|
|
779
849
|
if (Updates) return fn();
|
|
780
850
|
let wait = false;
|
|
781
851
|
if (!init) Updates = [];
|
|
782
|
-
if (Effects) wait = true;
|
|
852
|
+
if (Effects) wait = true;
|
|
853
|
+
else Effects = [];
|
|
783
854
|
ExecCount++;
|
|
784
855
|
try {
|
|
785
856
|
const res = fn();
|
|
@@ -793,7 +864,8 @@ function runUpdates(fn, init) {
|
|
|
793
864
|
}
|
|
794
865
|
function completeUpdates(wait) {
|
|
795
866
|
if (Updates) {
|
|
796
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
867
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
868
|
+
else runQueue(Updates);
|
|
797
869
|
Updates = null;
|
|
798
870
|
}
|
|
799
871
|
if (wait) return;
|
|
@@ -861,7 +933,8 @@ function runUserEffects(queue) {
|
|
|
861
933
|
userLength = 0;
|
|
862
934
|
for (i = 0; i < queue.length; i++) {
|
|
863
935
|
const e = queue[i];
|
|
864
|
-
if (!e.user) runTop(e);
|
|
936
|
+
if (!e.user) runTop(e);
|
|
937
|
+
else queue[userLength++] = e;
|
|
865
938
|
}
|
|
866
939
|
if (sharedConfig.context) {
|
|
867
940
|
if (sharedConfig.count) {
|
|
@@ -879,13 +952,15 @@ function runUserEffects(queue) {
|
|
|
879
952
|
}
|
|
880
953
|
function lookUpstream(node, ignore) {
|
|
881
954
|
const runningTransition = Transition && Transition.running;
|
|
882
|
-
if (runningTransition) node.tState = 0;
|
|
955
|
+
if (runningTransition) node.tState = 0;
|
|
956
|
+
else node.state = 0;
|
|
883
957
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
884
958
|
const source = node.sources[i];
|
|
885
959
|
if (source.sources) {
|
|
886
960
|
const state = runningTransition ? source.tState : source.state;
|
|
887
961
|
if (state === STALE) {
|
|
888
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
962
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
963
|
+
runTop(source);
|
|
889
964
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
890
965
|
}
|
|
891
966
|
}
|
|
@@ -895,8 +970,10 @@ function markDownstream(node) {
|
|
|
895
970
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
896
971
|
const o = node.observers[i];
|
|
897
972
|
if (runningTransition ? !o.tState : !o.state) {
|
|
898
|
-
if (runningTransition) o.tState = PENDING;
|
|
899
|
-
|
|
973
|
+
if (runningTransition) o.tState = PENDING;
|
|
974
|
+
else o.state = PENDING;
|
|
975
|
+
if (o.pure) Updates.push(o);
|
|
976
|
+
else Effects.push(o);
|
|
900
977
|
o.observers && markDownstream(o);
|
|
901
978
|
}
|
|
902
979
|
}
|
|
@@ -933,7 +1010,8 @@ function cleanNode(node) {
|
|
|
933
1010
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
934
1011
|
node.cleanups = null;
|
|
935
1012
|
}
|
|
936
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1013
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1014
|
+
else node.state = 0;
|
|
937
1015
|
}
|
|
938
1016
|
function reset(node, top) {
|
|
939
1017
|
if (!top) {
|
|
@@ -954,19 +1032,21 @@ function runErrors(err, fns, owner) {
|
|
|
954
1032
|
try {
|
|
955
1033
|
for (const f of fns) f(err);
|
|
956
1034
|
} catch (e) {
|
|
957
|
-
handleError(e, owner && owner.owner || null);
|
|
1035
|
+
handleError(e, (owner && owner.owner) || null);
|
|
958
1036
|
}
|
|
959
1037
|
}
|
|
960
1038
|
function handleError(err, owner = Owner) {
|
|
961
1039
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
962
1040
|
const error = castError(err);
|
|
963
1041
|
if (!fns) throw error;
|
|
964
|
-
if (Effects)
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1042
|
+
if (Effects)
|
|
1043
|
+
Effects.push({
|
|
1044
|
+
fn() {
|
|
1045
|
+
runErrors(error, fns, owner);
|
|
1046
|
+
},
|
|
1047
|
+
state: STALE
|
|
1048
|
+
});
|
|
1049
|
+
else runErrors(error, fns, owner);
|
|
970
1050
|
}
|
|
971
1051
|
function resolveChildren(children) {
|
|
972
1052
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -983,19 +1063,24 @@ function resolveChildren(children) {
|
|
|
983
1063
|
function createProvider(id, options) {
|
|
984
1064
|
return function provider(props) {
|
|
985
1065
|
let res;
|
|
986
|
-
createRenderEffect(
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1066
|
+
createRenderEffect(
|
|
1067
|
+
() =>
|
|
1068
|
+
(res = untrack(() => {
|
|
1069
|
+
Owner.context = {
|
|
1070
|
+
...Owner.context,
|
|
1071
|
+
[id]: props.value
|
|
1072
|
+
};
|
|
1073
|
+
return children(() => props.children);
|
|
1074
|
+
})),
|
|
1075
|
+
undefined
|
|
1076
|
+
);
|
|
993
1077
|
return res;
|
|
994
1078
|
};
|
|
995
1079
|
}
|
|
996
1080
|
function onError(fn) {
|
|
997
1081
|
ERROR || (ERROR = Symbol("error"));
|
|
998
|
-
if (Owner === null)
|
|
1082
|
+
if (Owner === null);
|
|
1083
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
999
1084
|
Owner.context = {
|
|
1000
1085
|
...Owner.context,
|
|
1001
1086
|
[ERROR]: [fn]
|
|
@@ -1024,7 +1109,8 @@ function observable(input) {
|
|
|
1024
1109
|
if (!(observer instanceof Object) || observer == null) {
|
|
1025
1110
|
throw new TypeError("Expected the observer to be an object.");
|
|
1026
1111
|
}
|
|
1027
|
-
const handler =
|
|
1112
|
+
const handler =
|
|
1113
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1028
1114
|
if (!handler) {
|
|
1029
1115
|
return {
|
|
1030
1116
|
unsubscribe() {}
|
|
@@ -1055,7 +1141,7 @@ function from(producer) {
|
|
|
1055
1141
|
});
|
|
1056
1142
|
if ("subscribe" in producer) {
|
|
1057
1143
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1058
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1144
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1059
1145
|
} else {
|
|
1060
1146
|
const clean = producer(set);
|
|
1061
1147
|
onCleanup(clean);
|
|
@@ -1099,8 +1185,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1099
1185
|
});
|
|
1100
1186
|
len = 1;
|
|
1101
1187
|
}
|
|
1102
|
-
}
|
|
1103
|
-
else if (len === 0) {
|
|
1188
|
+
} else if (len === 0) {
|
|
1104
1189
|
mapped = new Array(newLen);
|
|
1105
1190
|
for (j = 0; j < newLen; j++) {
|
|
1106
1191
|
items[j] = newItems[j];
|
|
@@ -1111,8 +1196,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1111
1196
|
temp = new Array(newLen);
|
|
1112
1197
|
tempdisposers = new Array(newLen);
|
|
1113
1198
|
indexes && (tempIndexes = new Array(newLen));
|
|
1114
|
-
for (
|
|
1115
|
-
|
|
1199
|
+
for (
|
|
1200
|
+
start = 0, end = Math.min(len, newLen);
|
|
1201
|
+
start < end && items[start] === newItems[start];
|
|
1202
|
+
start++
|
|
1203
|
+
);
|
|
1204
|
+
for (
|
|
1205
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1206
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1207
|
+
end--, newEnd--
|
|
1208
|
+
) {
|
|
1116
1209
|
temp[newEnd] = mapped[end];
|
|
1117
1210
|
tempdisposers[newEnd] = disposers[end];
|
|
1118
1211
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1146,7 +1239,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1146
1239
|
}
|
|
1147
1240
|
} else mapped[j] = createRoot(mapper);
|
|
1148
1241
|
}
|
|
1149
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1242
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1150
1243
|
items = newItems.slice(0);
|
|
1151
1244
|
}
|
|
1152
1245
|
return mapped;
|
|
@@ -1213,7 +1306,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1213
1306
|
}
|
|
1214
1307
|
len = signals.length = disposers.length = newLen;
|
|
1215
1308
|
items = newItems.slice(0);
|
|
1216
|
-
return mapped = mapped.slice(0, len);
|
|
1309
|
+
return (mapped = mapped.slice(0, len));
|
|
1217
1310
|
});
|
|
1218
1311
|
function mapper(disposer) {
|
|
1219
1312
|
disposers[i] = disposer;
|
|
@@ -1282,29 +1375,33 @@ function mergeProps(...sources) {
|
|
|
1282
1375
|
let proxy = false;
|
|
1283
1376
|
for (let i = 0; i < sources.length; i++) {
|
|
1284
1377
|
const s = sources[i];
|
|
1285
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1286
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1378
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1379
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1287
1380
|
}
|
|
1288
1381
|
if (proxy) {
|
|
1289
|
-
return new Proxy(
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1382
|
+
return new Proxy(
|
|
1383
|
+
{
|
|
1384
|
+
get(property) {
|
|
1385
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1386
|
+
const v = resolveSource(sources[i])[property];
|
|
1387
|
+
if (v !== undefined) return v;
|
|
1388
|
+
}
|
|
1389
|
+
},
|
|
1390
|
+
has(property) {
|
|
1391
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1392
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1393
|
+
}
|
|
1394
|
+
return false;
|
|
1395
|
+
},
|
|
1396
|
+
keys() {
|
|
1397
|
+
const keys = [];
|
|
1398
|
+
for (let i = 0; i < sources.length; i++)
|
|
1399
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1400
|
+
return [...new Set(keys)];
|
|
1299
1401
|
}
|
|
1300
|
-
return false;
|
|
1301
1402
|
},
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1305
|
-
return [...new Set(keys)];
|
|
1306
|
-
}
|
|
1307
|
-
}, propTraps);
|
|
1403
|
+
propTraps
|
|
1404
|
+
);
|
|
1308
1405
|
}
|
|
1309
1406
|
const sourcesMap = {};
|
|
1310
1407
|
const defined = Object.create(null);
|
|
@@ -1317,15 +1414,20 @@ function mergeProps(...sources) {
|
|
|
1317
1414
|
if (key === "__proto__" || key === "constructor") continue;
|
|
1318
1415
|
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
1319
1416
|
if (!defined[key]) {
|
|
1320
|
-
defined[key] = desc.get
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1417
|
+
defined[key] = desc.get
|
|
1418
|
+
? {
|
|
1419
|
+
enumerable: true,
|
|
1420
|
+
configurable: true,
|
|
1421
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1422
|
+
}
|
|
1423
|
+
: desc.value !== undefined
|
|
1424
|
+
? desc
|
|
1425
|
+
: undefined;
|
|
1325
1426
|
} else {
|
|
1326
1427
|
const sources = sourcesMap[key];
|
|
1327
1428
|
if (sources) {
|
|
1328
|
-
if (desc.get) sources.push(desc.get.bind(source));
|
|
1429
|
+
if (desc.get) sources.push(desc.get.bind(source));
|
|
1430
|
+
else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1329
1431
|
}
|
|
1330
1432
|
}
|
|
1331
1433
|
}
|
|
@@ -1335,7 +1437,8 @@ function mergeProps(...sources) {
|
|
|
1335
1437
|
for (let i = definedKeys.length - 1; i >= 0; i--) {
|
|
1336
1438
|
const key = definedKeys[i],
|
|
1337
1439
|
desc = defined[key];
|
|
1338
|
-
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1440
|
+
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1441
|
+
else target[key] = desc ? desc.value : undefined;
|
|
1339
1442
|
}
|
|
1340
1443
|
return target;
|
|
1341
1444
|
}
|
|
@@ -1343,47 +1446,60 @@ function splitProps(props, ...keys) {
|
|
|
1343
1446
|
if ($PROXY in props) {
|
|
1344
1447
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1345
1448
|
const res = keys.map(k => {
|
|
1346
|
-
return new Proxy(
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1449
|
+
return new Proxy(
|
|
1450
|
+
{
|
|
1451
|
+
get(property) {
|
|
1452
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1453
|
+
},
|
|
1454
|
+
has(property) {
|
|
1455
|
+
return k.includes(property) && property in props;
|
|
1456
|
+
},
|
|
1457
|
+
keys() {
|
|
1458
|
+
return k.filter(property => property in props);
|
|
1459
|
+
}
|
|
1352
1460
|
},
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
}
|
|
1356
|
-
}, propTraps);
|
|
1461
|
+
propTraps
|
|
1462
|
+
);
|
|
1357
1463
|
});
|
|
1358
|
-
res.push(
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1464
|
+
res.push(
|
|
1465
|
+
new Proxy(
|
|
1466
|
+
{
|
|
1467
|
+
get(property) {
|
|
1468
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1469
|
+
},
|
|
1470
|
+
has(property) {
|
|
1471
|
+
return blocked.has(property) ? false : property in props;
|
|
1472
|
+
},
|
|
1473
|
+
keys() {
|
|
1474
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1475
|
+
}
|
|
1476
|
+
},
|
|
1477
|
+
propTraps
|
|
1478
|
+
)
|
|
1479
|
+
);
|
|
1369
1480
|
return res;
|
|
1370
1481
|
}
|
|
1371
1482
|
const otherObject = {};
|
|
1372
1483
|
const objects = keys.map(() => ({}));
|
|
1373
1484
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1374
1485
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1375
|
-
const isDefaultDesc =
|
|
1486
|
+
const isDefaultDesc =
|
|
1487
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1376
1488
|
let blocked = false;
|
|
1377
1489
|
let objectIndex = 0;
|
|
1378
1490
|
for (const k of keys) {
|
|
1379
1491
|
if (k.includes(propName)) {
|
|
1380
1492
|
blocked = true;
|
|
1381
|
-
isDefaultDesc
|
|
1493
|
+
isDefaultDesc
|
|
1494
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1495
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1382
1496
|
}
|
|
1383
1497
|
++objectIndex;
|
|
1384
1498
|
}
|
|
1385
1499
|
if (!blocked) {
|
|
1386
|
-
isDefaultDesc
|
|
1500
|
+
isDefaultDesc
|
|
1501
|
+
? (otherObject[propName] = desc.value)
|
|
1502
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1387
1503
|
}
|
|
1388
1504
|
}
|
|
1389
1505
|
return [...objects, otherObject];
|
|
@@ -1398,7 +1514,7 @@ function lazy(fn) {
|
|
|
1398
1514
|
sharedConfig.count || (sharedConfig.count = 0);
|
|
1399
1515
|
sharedConfig.count++;
|
|
1400
1516
|
(p || (p = fn())).then(mod => {
|
|
1401
|
-
setHydrateContext(ctx);
|
|
1517
|
+
!sharedConfig.done && setHydrateContext(ctx);
|
|
1402
1518
|
sharedConfig.count--;
|
|
1403
1519
|
set(() => mod.default);
|
|
1404
1520
|
setHydrateContext();
|
|
@@ -1409,17 +1525,21 @@ function lazy(fn) {
|
|
|
1409
1525
|
comp = s;
|
|
1410
1526
|
}
|
|
1411
1527
|
let Comp;
|
|
1412
|
-
return createMemo(() =>
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1528
|
+
return createMemo(() =>
|
|
1529
|
+
(Comp = comp())
|
|
1530
|
+
? untrack(() => {
|
|
1531
|
+
if (false);
|
|
1532
|
+
if (!ctx || sharedConfig.done) return Comp(props);
|
|
1533
|
+
const c = sharedConfig.context;
|
|
1534
|
+
setHydrateContext(ctx);
|
|
1535
|
+
const r = Comp(props);
|
|
1536
|
+
setHydrateContext(c);
|
|
1537
|
+
return r;
|
|
1538
|
+
})
|
|
1539
|
+
: ""
|
|
1540
|
+
);
|
|
1421
1541
|
};
|
|
1422
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1542
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1423
1543
|
return wrap;
|
|
1424
1544
|
}
|
|
1425
1545
|
let counter = 0;
|
|
@@ -1444,49 +1564,77 @@ function Index(props) {
|
|
|
1444
1564
|
function Show(props) {
|
|
1445
1565
|
const keyed = props.keyed;
|
|
1446
1566
|
const condition = createMemo(() => props.when, undefined, {
|
|
1447
|
-
equals: (a, b) => keyed ? a === b : !a === !b
|
|
1567
|
+
equals: (a, b) => (keyed ? a === b : !a === !b)
|
|
1448
1568
|
});
|
|
1449
|
-
return createMemo(
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1569
|
+
return createMemo(
|
|
1570
|
+
() => {
|
|
1571
|
+
const c = condition();
|
|
1572
|
+
if (c) {
|
|
1573
|
+
const child = props.children;
|
|
1574
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1575
|
+
return fn
|
|
1576
|
+
? untrack(() =>
|
|
1577
|
+
child(
|
|
1578
|
+
keyed
|
|
1579
|
+
? c
|
|
1580
|
+
: () => {
|
|
1581
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1582
|
+
return props.when;
|
|
1583
|
+
}
|
|
1584
|
+
)
|
|
1585
|
+
)
|
|
1586
|
+
: child;
|
|
1587
|
+
}
|
|
1588
|
+
return props.fallback;
|
|
1589
|
+
},
|
|
1590
|
+
undefined,
|
|
1591
|
+
undefined
|
|
1592
|
+
);
|
|
1461
1593
|
}
|
|
1462
1594
|
function Switch(props) {
|
|
1463
1595
|
let keyed = false;
|
|
1464
1596
|
const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1465
1597
|
const conditions = children(() => props.children),
|
|
1466
|
-
evalConditions = createMemo(
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1598
|
+
evalConditions = createMemo(
|
|
1599
|
+
() => {
|
|
1600
|
+
let conds = conditions();
|
|
1601
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1602
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1603
|
+
const c = conds[i].when;
|
|
1604
|
+
if (c) {
|
|
1605
|
+
keyed = !!conds[i].keyed;
|
|
1606
|
+
return [i, c, conds[i]];
|
|
1607
|
+
}
|
|
1474
1608
|
}
|
|
1609
|
+
return [-1];
|
|
1610
|
+
},
|
|
1611
|
+
undefined,
|
|
1612
|
+
{
|
|
1613
|
+
equals
|
|
1475
1614
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1615
|
+
);
|
|
1616
|
+
return createMemo(
|
|
1617
|
+
() => {
|
|
1618
|
+
const [index, when, cond] = evalConditions();
|
|
1619
|
+
if (index < 0) return props.fallback;
|
|
1620
|
+
const c = cond.children;
|
|
1621
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1622
|
+
return fn
|
|
1623
|
+
? untrack(() =>
|
|
1624
|
+
c(
|
|
1625
|
+
keyed
|
|
1626
|
+
? when
|
|
1627
|
+
: () => {
|
|
1628
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1629
|
+
return cond.when;
|
|
1630
|
+
}
|
|
1631
|
+
)
|
|
1632
|
+
)
|
|
1633
|
+
: c;
|
|
1634
|
+
},
|
|
1635
|
+
undefined,
|
|
1636
|
+
undefined
|
|
1637
|
+
);
|
|
1490
1638
|
}
|
|
1491
1639
|
function Match(props) {
|
|
1492
1640
|
return props;
|
|
@@ -1497,23 +1645,29 @@ function resetErrorBoundaries() {
|
|
|
1497
1645
|
}
|
|
1498
1646
|
function ErrorBoundary(props) {
|
|
1499
1647
|
let err;
|
|
1500
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1648
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1649
|
+
err = sharedConfig.load(sharedConfig.getContextId());
|
|
1501
1650
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1502
1651
|
Errors || (Errors = new Set());
|
|
1503
1652
|
Errors.add(setErrored);
|
|
1504
1653
|
onCleanup(() => Errors.delete(setErrored));
|
|
1505
|
-
return createMemo(
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1654
|
+
return createMemo(
|
|
1655
|
+
() => {
|
|
1656
|
+
let e;
|
|
1657
|
+
if ((e = errored())) {
|
|
1658
|
+
const f = props.fallback;
|
|
1659
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1660
|
+
}
|
|
1661
|
+
return catchError(() => props.children, setErrored);
|
|
1662
|
+
},
|
|
1663
|
+
undefined,
|
|
1664
|
+
undefined
|
|
1665
|
+
);
|
|
1513
1666
|
}
|
|
1514
1667
|
|
|
1515
|
-
const suspenseListEquals = (a, b) =>
|
|
1516
|
-
|
|
1668
|
+
const suspenseListEquals = (a, b) =>
|
|
1669
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1670
|
+
const SuspenseListContext = /* #__PURE__ */ createContext();
|
|
1517
1671
|
function SuspenseList(props) {
|
|
1518
1672
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1519
1673
|
inFallback: false
|
|
@@ -1524,51 +1678,51 @@ function SuspenseList(props) {
|
|
|
1524
1678
|
if (listContext) {
|
|
1525
1679
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1526
1680
|
}
|
|
1527
|
-
const resolved = createMemo(
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
showContent = true,
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
const res = reg.map(() => ({
|
|
1539
|
-
showContent: all && showContent,
|
|
1540
|
-
showFallback
|
|
1541
|
-
}));
|
|
1542
|
-
res.inFallback = !all;
|
|
1543
|
-
return res;
|
|
1544
|
-
}
|
|
1545
|
-
let stop = false;
|
|
1546
|
-
let inFallback = prev.inFallback;
|
|
1547
|
-
const res = [];
|
|
1548
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1549
|
-
const n = reverse ? len - i - 1 : i,
|
|
1550
|
-
s = reg[n]();
|
|
1551
|
-
if (!stop && !s) {
|
|
1552
|
-
res[n] = {
|
|
1553
|
-
showContent,
|
|
1681
|
+
const resolved = createMemo(
|
|
1682
|
+
prev => {
|
|
1683
|
+
const reveal = props.revealOrder,
|
|
1684
|
+
tail = props.tail,
|
|
1685
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1686
|
+
reg = registry(),
|
|
1687
|
+
reverse = reveal === "backwards";
|
|
1688
|
+
if (reveal === "together") {
|
|
1689
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1690
|
+
const res = reg.map(() => ({
|
|
1691
|
+
showContent: all && showContent,
|
|
1554
1692
|
showFallback
|
|
1555
|
-
};
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1693
|
+
}));
|
|
1694
|
+
res.inFallback = !all;
|
|
1695
|
+
return res;
|
|
1696
|
+
}
|
|
1697
|
+
let stop = false;
|
|
1698
|
+
let inFallback = prev.inFallback;
|
|
1699
|
+
const res = [];
|
|
1700
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1701
|
+
const n = reverse ? len - i - 1 : i,
|
|
1702
|
+
s = reg[n]();
|
|
1703
|
+
if (!stop && !s) {
|
|
1704
|
+
res[n] = {
|
|
1705
|
+
showContent,
|
|
1706
|
+
showFallback
|
|
1707
|
+
};
|
|
1708
|
+
} else {
|
|
1709
|
+
const next = !stop;
|
|
1710
|
+
if (next) inFallback = true;
|
|
1711
|
+
res[n] = {
|
|
1712
|
+
showContent: next,
|
|
1713
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1714
|
+
};
|
|
1715
|
+
stop = true;
|
|
1716
|
+
}
|
|
1564
1717
|
}
|
|
1718
|
+
if (!stop) inFallback = false;
|
|
1719
|
+
res.inFallback = inFallback;
|
|
1720
|
+
return res;
|
|
1721
|
+
},
|
|
1722
|
+
{
|
|
1723
|
+
inFallback: false
|
|
1565
1724
|
}
|
|
1566
|
-
|
|
1567
|
-
res.inFallback = inFallback;
|
|
1568
|
-
return res;
|
|
1569
|
-
}, {
|
|
1570
|
-
inFallback: false
|
|
1571
|
-
});
|
|
1725
|
+
);
|
|
1572
1726
|
setWrapper(() => resolved);
|
|
1573
1727
|
return createComponent(SuspenseListContext.Provider, {
|
|
1574
1728
|
value: {
|
|
@@ -1613,23 +1767,27 @@ function Suspense(props) {
|
|
|
1613
1767
|
const key = sharedConfig.getContextId();
|
|
1614
1768
|
let ref = sharedConfig.load(key);
|
|
1615
1769
|
if (ref) {
|
|
1616
|
-
if (typeof ref !== "object" || ref.status !== "success") p = ref;
|
|
1770
|
+
if (typeof ref !== "object" || ref.status !== "success") p = ref;
|
|
1771
|
+
else sharedConfig.gather(key);
|
|
1617
1772
|
}
|
|
1618
1773
|
if (p && p !== "$$f") {
|
|
1619
1774
|
const [s, set] = createSignal(undefined, {
|
|
1620
1775
|
equals: false
|
|
1621
1776
|
});
|
|
1622
1777
|
flicker = s;
|
|
1623
|
-
p.then(
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1778
|
+
p.then(
|
|
1779
|
+
() => {
|
|
1780
|
+
if (sharedConfig.done) return set();
|
|
1781
|
+
sharedConfig.gather(key);
|
|
1782
|
+
setHydrateContext(ctx);
|
|
1783
|
+
set();
|
|
1784
|
+
setHydrateContext();
|
|
1785
|
+
},
|
|
1786
|
+
err => {
|
|
1787
|
+
error = err;
|
|
1788
|
+
set();
|
|
1789
|
+
}
|
|
1790
|
+
);
|
|
1633
1791
|
}
|
|
1634
1792
|
}
|
|
1635
1793
|
const listContext = useContext(SuspenseListContext);
|
|
@@ -1644,17 +1802,14 @@ function Suspense(props) {
|
|
|
1644
1802
|
ctx = sharedConfig.context;
|
|
1645
1803
|
if (flicker) {
|
|
1646
1804
|
flicker();
|
|
1647
|
-
return flicker = undefined;
|
|
1805
|
+
return (flicker = undefined);
|
|
1648
1806
|
}
|
|
1649
1807
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1650
1808
|
const rendered = createMemo(() => props.children);
|
|
1651
1809
|
return createMemo(prev => {
|
|
1652
1810
|
const inFallback = store.inFallback(),
|
|
1653
|
-
{
|
|
1654
|
-
|
|
1655
|
-
showFallback = true
|
|
1656
|
-
} = show ? show() : {};
|
|
1657
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1811
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1812
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1658
1813
|
store.resolved = true;
|
|
1659
1814
|
dispose && dispose();
|
|
1660
1815
|
dispose = ctx = p = undefined;
|
|
@@ -1682,4 +1837,59 @@ function Suspense(props) {
|
|
|
1682
1837
|
|
|
1683
1838
|
const DEV = undefined;
|
|
1684
1839
|
|
|
1685
|
-
export {
|
|
1840
|
+
export {
|
|
1841
|
+
$DEVCOMP,
|
|
1842
|
+
$PROXY,
|
|
1843
|
+
$TRACK,
|
|
1844
|
+
DEV,
|
|
1845
|
+
ErrorBoundary,
|
|
1846
|
+
For,
|
|
1847
|
+
Index,
|
|
1848
|
+
Match,
|
|
1849
|
+
Show,
|
|
1850
|
+
Suspense,
|
|
1851
|
+
SuspenseList,
|
|
1852
|
+
Switch,
|
|
1853
|
+
batch,
|
|
1854
|
+
cancelCallback,
|
|
1855
|
+
catchError,
|
|
1856
|
+
children,
|
|
1857
|
+
createComponent,
|
|
1858
|
+
createComputed,
|
|
1859
|
+
createContext,
|
|
1860
|
+
createDeferred,
|
|
1861
|
+
createEffect,
|
|
1862
|
+
createMemo,
|
|
1863
|
+
createReaction,
|
|
1864
|
+
createRenderEffect,
|
|
1865
|
+
createResource,
|
|
1866
|
+
createRoot,
|
|
1867
|
+
createSelector,
|
|
1868
|
+
createSignal,
|
|
1869
|
+
createUniqueId,
|
|
1870
|
+
enableExternalSource,
|
|
1871
|
+
enableHydration,
|
|
1872
|
+
enableScheduling,
|
|
1873
|
+
equalFn,
|
|
1874
|
+
from,
|
|
1875
|
+
getListener,
|
|
1876
|
+
getOwner,
|
|
1877
|
+
indexArray,
|
|
1878
|
+
lazy,
|
|
1879
|
+
mapArray,
|
|
1880
|
+
mergeProps,
|
|
1881
|
+
observable,
|
|
1882
|
+
on,
|
|
1883
|
+
onCleanup,
|
|
1884
|
+
onError,
|
|
1885
|
+
onMount,
|
|
1886
|
+
requestCallback,
|
|
1887
|
+
resetErrorBoundaries,
|
|
1888
|
+
runWithOwner,
|
|
1889
|
+
sharedConfig,
|
|
1890
|
+
splitProps,
|
|
1891
|
+
startTransition,
|
|
1892
|
+
untrack,
|
|
1893
|
+
useContext,
|
|
1894
|
+
useTransition
|
|
1895
|
+
};
|