solid-js 1.8.2 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.cjs +1 -1
- package/dist/dev.js +534 -299
- package/dist/server.js +170 -75
- package/dist/solid.cjs +1 -1
- package/dist/solid.js +461 -257
- package/h/dist/h.js +34 -8
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +45 -31
- package/package.json +1 -1
- package/store/dist/dev.js +114 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +105 -39
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +72 -9
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +228 -140
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +62 -31
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +166 -95
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.js +617 -81
- package/web/dist/server.js +175 -92
- package/web/dist/web.js +611 -80
- 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
|
}
|
|
@@ -155,18 +157,20 @@ let Listener = null;
|
|
|
155
157
|
let Updates = null;
|
|
156
158
|
let Effects = null;
|
|
157
159
|
let ExecCount = 0;
|
|
158
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
160
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
159
161
|
function createRoot(fn, detachedOwner) {
|
|
160
162
|
const listener = Listener,
|
|
161
163
|
owner = Owner,
|
|
162
164
|
unowned = fn.length === 0,
|
|
163
165
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
164
|
-
root = unowned
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
root = unowned
|
|
167
|
+
? UNOWNED
|
|
168
|
+
: {
|
|
169
|
+
owned: null,
|
|
170
|
+
cleanups: null,
|
|
171
|
+
context: current ? current.context : null,
|
|
172
|
+
owner: current
|
|
173
|
+
},
|
|
170
174
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
171
175
|
Owner = root;
|
|
172
176
|
Listener = null;
|
|
@@ -187,7 +191,8 @@ function createSignal(value, options) {
|
|
|
187
191
|
};
|
|
188
192
|
const setter = value => {
|
|
189
193
|
if (typeof value === "function") {
|
|
190
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
194
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
195
|
+
else value = value(s.value);
|
|
191
196
|
}
|
|
192
197
|
return writeSignal(s, value);
|
|
193
198
|
};
|
|
@@ -195,11 +200,13 @@ function createSignal(value, options) {
|
|
|
195
200
|
}
|
|
196
201
|
function createComputed(fn, value, options) {
|
|
197
202
|
const c = createComputation(fn, value, true, STALE);
|
|
198
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
203
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
204
|
+
else updateComputation(c);
|
|
199
205
|
}
|
|
200
206
|
function createRenderEffect(fn, value, options) {
|
|
201
207
|
const c = createComputation(fn, value, false, STALE);
|
|
202
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
208
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
209
|
+
else updateComputation(c);
|
|
203
210
|
}
|
|
204
211
|
function createEffect(fn, value, options) {
|
|
205
212
|
runEffects = runUserEffects;
|
|
@@ -211,10 +218,15 @@ function createEffect(fn, value, options) {
|
|
|
211
218
|
}
|
|
212
219
|
function createReaction(onInvalidate, options) {
|
|
213
220
|
let fn;
|
|
214
|
-
const c = createComputation(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
const c = createComputation(
|
|
222
|
+
() => {
|
|
223
|
+
fn ? fn() : untrack(onInvalidate);
|
|
224
|
+
fn = undefined;
|
|
225
|
+
},
|
|
226
|
+
undefined,
|
|
227
|
+
false,
|
|
228
|
+
0
|
|
229
|
+
),
|
|
218
230
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
219
231
|
if (s) c.suspense = s;
|
|
220
232
|
c.user = true;
|
|
@@ -242,7 +254,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
242
254
|
let source;
|
|
243
255
|
let fetcher;
|
|
244
256
|
let options;
|
|
245
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
257
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
246
258
|
source = true;
|
|
247
259
|
fetcher = pSource;
|
|
248
260
|
options = pFetcher || {};
|
|
@@ -256,7 +268,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
256
268
|
id = null,
|
|
257
269
|
loadedUnderTransition = false,
|
|
258
270
|
scheduled = false,
|
|
259
|
-
resolved =
|
|
271
|
+
resolved = "initialValue" in options,
|
|
260
272
|
dynamic = typeof source === "function" && createMemo(source);
|
|
261
273
|
const contexts = new Set(),
|
|
262
274
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -268,15 +280,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
268
280
|
if (sharedConfig.context) {
|
|
269
281
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
270
282
|
let v;
|
|
271
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
283
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
284
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
|
|
272
285
|
}
|
|
273
286
|
function loadEnd(p, v, error, key) {
|
|
274
287
|
if (pr === p) {
|
|
275
288
|
pr = null;
|
|
276
289
|
key !== undefined && (resolved = true);
|
|
277
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
278
|
-
|
|
279
|
-
|
|
290
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
291
|
+
queueMicrotask(() =>
|
|
292
|
+
options.onHydrated(key, {
|
|
293
|
+
value: v
|
|
294
|
+
})
|
|
295
|
+
);
|
|
280
296
|
initP = NO_INIT;
|
|
281
297
|
if (Transition && p && loadedUnderTransition) {
|
|
282
298
|
Transition.promises.delete(p);
|
|
@@ -307,7 +323,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
307
323
|
createComputed(() => {
|
|
308
324
|
track();
|
|
309
325
|
if (pr) {
|
|
310
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
326
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
327
|
+
else if (!contexts.has(c)) {
|
|
311
328
|
c.increment();
|
|
312
329
|
contexts.add(c);
|
|
313
330
|
}
|
|
@@ -326,26 +343,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
326
343
|
return;
|
|
327
344
|
}
|
|
328
345
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
329
|
-
const p =
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
346
|
+
const p =
|
|
347
|
+
initP !== NO_INIT
|
|
348
|
+
? initP
|
|
349
|
+
: untrack(() =>
|
|
350
|
+
fetcher(lookup, {
|
|
351
|
+
value: value(),
|
|
352
|
+
refetching
|
|
353
|
+
})
|
|
354
|
+
);
|
|
333
355
|
if (!isPromise(p)) {
|
|
334
356
|
loadEnd(pr, p, undefined, lookup);
|
|
335
357
|
return p;
|
|
336
358
|
}
|
|
337
359
|
if ("value" in p) {
|
|
338
|
-
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
360
|
+
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
361
|
+
else loadEnd(pr, undefined, undefined, lookup);
|
|
339
362
|
return p;
|
|
340
363
|
}
|
|
341
364
|
pr = p;
|
|
342
365
|
scheduled = true;
|
|
343
|
-
queueMicrotask(() => scheduled = false);
|
|
366
|
+
queueMicrotask(() => (scheduled = false));
|
|
344
367
|
runUpdates(() => {
|
|
345
368
|
setState(resolved ? "refreshing" : "pending");
|
|
346
369
|
trigger();
|
|
347
370
|
}, false);
|
|
348
|
-
return p.then(
|
|
371
|
+
return p.then(
|
|
372
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
373
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
374
|
+
);
|
|
349
375
|
}
|
|
350
376
|
Object.defineProperties(read, {
|
|
351
377
|
state: {
|
|
@@ -369,50 +395,80 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
369
395
|
}
|
|
370
396
|
}
|
|
371
397
|
});
|
|
372
|
-
if (dynamic) createComputed(() => load(false));
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
398
|
+
if (dynamic) createComputed(() => load(false));
|
|
399
|
+
else load(false);
|
|
400
|
+
return [
|
|
401
|
+
read,
|
|
402
|
+
{
|
|
403
|
+
refetch: load,
|
|
404
|
+
mutate: setValue
|
|
405
|
+
}
|
|
406
|
+
];
|
|
377
407
|
}
|
|
378
408
|
function createDeferred(source, options) {
|
|
379
409
|
let t,
|
|
380
410
|
timeout = options ? options.timeoutMs : undefined;
|
|
381
|
-
const node = createComputation(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
411
|
+
const node = createComputation(
|
|
412
|
+
() => {
|
|
413
|
+
if (!t || !t.fn)
|
|
414
|
+
t = requestCallback(
|
|
415
|
+
() => setDeferred(() => node.value),
|
|
416
|
+
timeout !== undefined
|
|
417
|
+
? {
|
|
418
|
+
timeout
|
|
419
|
+
}
|
|
420
|
+
: undefined
|
|
421
|
+
);
|
|
422
|
+
return source();
|
|
423
|
+
},
|
|
424
|
+
undefined,
|
|
425
|
+
true
|
|
426
|
+
);
|
|
427
|
+
const [deferred, setDeferred] = createSignal(
|
|
428
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
429
|
+
options
|
|
430
|
+
);
|
|
388
431
|
updateComputation(node);
|
|
389
|
-
setDeferred(() =>
|
|
432
|
+
setDeferred(() =>
|
|
433
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
434
|
+
);
|
|
390
435
|
return deferred;
|
|
391
436
|
}
|
|
392
437
|
function createSelector(source, fn = equalFn, options) {
|
|
393
438
|
const subs = new Map();
|
|
394
|
-
const node = createComputation(
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
for (const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
439
|
+
const node = createComputation(
|
|
440
|
+
p => {
|
|
441
|
+
const v = source();
|
|
442
|
+
for (const [key, val] of subs.entries())
|
|
443
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
444
|
+
for (const c of val.values()) {
|
|
445
|
+
c.state = STALE;
|
|
446
|
+
if (c.pure) Updates.push(c);
|
|
447
|
+
else Effects.push(c);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return v;
|
|
451
|
+
},
|
|
452
|
+
undefined,
|
|
453
|
+
true,
|
|
454
|
+
STALE
|
|
455
|
+
);
|
|
404
456
|
updateComputation(node);
|
|
405
457
|
return key => {
|
|
406
458
|
const listener = Listener;
|
|
407
459
|
if (listener) {
|
|
408
460
|
let l;
|
|
409
|
-
if (l = subs.get(key)) l.add(listener);
|
|
461
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
462
|
+
else subs.set(key, (l = new Set([listener])));
|
|
410
463
|
onCleanup(() => {
|
|
411
464
|
l.delete(listener);
|
|
412
465
|
!l.size && subs.delete(key);
|
|
413
466
|
});
|
|
414
467
|
}
|
|
415
|
-
return fn(
|
|
468
|
+
return fn(
|
|
469
|
+
key,
|
|
470
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
471
|
+
);
|
|
416
472
|
};
|
|
417
473
|
}
|
|
418
474
|
function batch(fn) {
|
|
@@ -451,7 +507,9 @@ function onMount(fn) {
|
|
|
451
507
|
createEffect(() => untrack(fn));
|
|
452
508
|
}
|
|
453
509
|
function onCleanup(fn) {
|
|
454
|
-
if (Owner === null)
|
|
510
|
+
if (Owner === null);
|
|
511
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
512
|
+
else Owner.cleanups.push(fn);
|
|
455
513
|
return fn;
|
|
456
514
|
}
|
|
457
515
|
function catchError(fn, handler) {
|
|
@@ -505,15 +563,17 @@ function startTransition(fn) {
|
|
|
505
563
|
Owner = o;
|
|
506
564
|
let t;
|
|
507
565
|
if (Scheduler || SuspenseContext) {
|
|
508
|
-
t =
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
566
|
+
t =
|
|
567
|
+
Transition ||
|
|
568
|
+
(Transition = {
|
|
569
|
+
sources: new Set(),
|
|
570
|
+
effects: [],
|
|
571
|
+
promises: new Set(),
|
|
572
|
+
disposed: new Set(),
|
|
573
|
+
queue: new Set(),
|
|
574
|
+
running: true
|
|
575
|
+
});
|
|
576
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
517
577
|
t.running = true;
|
|
518
578
|
}
|
|
519
579
|
runUpdates(fn, false);
|
|
@@ -537,7 +597,9 @@ function createContext(defaultValue, options) {
|
|
|
537
597
|
};
|
|
538
598
|
}
|
|
539
599
|
function useContext(context) {
|
|
540
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
600
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
601
|
+
? Owner.context[context.id]
|
|
602
|
+
: context.defaultValue;
|
|
541
603
|
}
|
|
542
604
|
function children(fn) {
|
|
543
605
|
const children = createMemo(fn);
|
|
@@ -573,7 +635,8 @@ function enableExternalSource(factory) {
|
|
|
573
635
|
function readSignal() {
|
|
574
636
|
const runningTransition = Transition && Transition.running;
|
|
575
637
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
576
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
638
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
639
|
+
else {
|
|
577
640
|
const updates = Updates;
|
|
578
641
|
Updates = null;
|
|
579
642
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -601,11 +664,12 @@ function readSignal() {
|
|
|
601
664
|
return this.value;
|
|
602
665
|
}
|
|
603
666
|
function writeSignal(node, value, isComp) {
|
|
604
|
-
let current =
|
|
667
|
+
let current =
|
|
668
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
605
669
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
606
670
|
if (Transition) {
|
|
607
671
|
const TransitionRunning = Transition.running;
|
|
608
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
672
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
609
673
|
Transition.sources.add(node);
|
|
610
674
|
node.tValue = value;
|
|
611
675
|
}
|
|
@@ -618,14 +682,16 @@ function writeSignal(node, value, isComp) {
|
|
|
618
682
|
const TransitionRunning = Transition && Transition.running;
|
|
619
683
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
620
684
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
621
|
-
if (o.pure) Updates.push(o);
|
|
685
|
+
if (o.pure) Updates.push(o);
|
|
686
|
+
else Effects.push(o);
|
|
622
687
|
if (o.observers) markDownstream(o);
|
|
623
688
|
}
|
|
624
|
-
if (!TransitionRunning) o.state = STALE;
|
|
689
|
+
if (!TransitionRunning) o.state = STALE;
|
|
690
|
+
else o.tState = STALE;
|
|
625
691
|
}
|
|
626
692
|
if (Updates.length > 10e5) {
|
|
627
693
|
Updates = [];
|
|
628
|
-
if (false)
|
|
694
|
+
if (false);
|
|
629
695
|
throw new Error();
|
|
630
696
|
}
|
|
631
697
|
}, false);
|
|
@@ -640,7 +706,11 @@ function updateComputation(node) {
|
|
|
640
706
|
listener = Listener,
|
|
641
707
|
time = ExecCount;
|
|
642
708
|
Listener = Owner = node;
|
|
643
|
-
runComputation(
|
|
709
|
+
runComputation(
|
|
710
|
+
node,
|
|
711
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
712
|
+
time
|
|
713
|
+
);
|
|
644
714
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
645
715
|
queueMicrotask(() => {
|
|
646
716
|
runUpdates(() => {
|
|
@@ -701,11 +771,14 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
701
771
|
c.state = 0;
|
|
702
772
|
c.tState = state;
|
|
703
773
|
}
|
|
704
|
-
if (Owner === null)
|
|
774
|
+
if (Owner === null);
|
|
775
|
+
else if (Owner !== UNOWNED) {
|
|
705
776
|
if (Transition && Transition.running && Owner.pure) {
|
|
706
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
777
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
778
|
+
else Owner.tOwned.push(c);
|
|
707
779
|
} else {
|
|
708
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
780
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
781
|
+
else Owner.owned.push(c);
|
|
709
782
|
}
|
|
710
783
|
}
|
|
711
784
|
if (ExternalSourceFactory) {
|
|
@@ -756,7 +829,8 @@ function runUpdates(fn, init) {
|
|
|
756
829
|
if (Updates) return fn();
|
|
757
830
|
let wait = false;
|
|
758
831
|
if (!init) Updates = [];
|
|
759
|
-
if (Effects) wait = true;
|
|
832
|
+
if (Effects) wait = true;
|
|
833
|
+
else Effects = [];
|
|
760
834
|
ExecCount++;
|
|
761
835
|
try {
|
|
762
836
|
const res = fn();
|
|
@@ -770,7 +844,8 @@ function runUpdates(fn, init) {
|
|
|
770
844
|
}
|
|
771
845
|
function completeUpdates(wait) {
|
|
772
846
|
if (Updates) {
|
|
773
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
847
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
848
|
+
else runQueue(Updates);
|
|
774
849
|
Updates = null;
|
|
775
850
|
}
|
|
776
851
|
if (wait) return;
|
|
@@ -838,7 +913,8 @@ function runUserEffects(queue) {
|
|
|
838
913
|
userLength = 0;
|
|
839
914
|
for (i = 0; i < queue.length; i++) {
|
|
840
915
|
const e = queue[i];
|
|
841
|
-
if (!e.user) runTop(e);
|
|
916
|
+
if (!e.user) runTop(e);
|
|
917
|
+
else queue[userLength++] = e;
|
|
842
918
|
}
|
|
843
919
|
if (sharedConfig.context) {
|
|
844
920
|
if (sharedConfig.count) {
|
|
@@ -856,13 +932,15 @@ function runUserEffects(queue) {
|
|
|
856
932
|
}
|
|
857
933
|
function lookUpstream(node, ignore) {
|
|
858
934
|
const runningTransition = Transition && Transition.running;
|
|
859
|
-
if (runningTransition) node.tState = 0;
|
|
935
|
+
if (runningTransition) node.tState = 0;
|
|
936
|
+
else node.state = 0;
|
|
860
937
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
861
938
|
const source = node.sources[i];
|
|
862
939
|
if (source.sources) {
|
|
863
940
|
const state = runningTransition ? source.tState : source.state;
|
|
864
941
|
if (state === STALE) {
|
|
865
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
942
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
943
|
+
runTop(source);
|
|
866
944
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
867
945
|
}
|
|
868
946
|
}
|
|
@@ -872,8 +950,10 @@ function markDownstream(node) {
|
|
|
872
950
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
873
951
|
const o = node.observers[i];
|
|
874
952
|
if (runningTransition ? !o.tState : !o.state) {
|
|
875
|
-
if (runningTransition) o.tState = PENDING;
|
|
876
|
-
|
|
953
|
+
if (runningTransition) o.tState = PENDING;
|
|
954
|
+
else o.state = PENDING;
|
|
955
|
+
if (o.pure) Updates.push(o);
|
|
956
|
+
else Effects.push(o);
|
|
877
957
|
o.observers && markDownstream(o);
|
|
878
958
|
}
|
|
879
959
|
}
|
|
@@ -910,7 +990,8 @@ function cleanNode(node) {
|
|
|
910
990
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
911
991
|
node.cleanups = null;
|
|
912
992
|
}
|
|
913
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
993
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
994
|
+
else node.state = 0;
|
|
914
995
|
}
|
|
915
996
|
function reset(node, top) {
|
|
916
997
|
if (!top) {
|
|
@@ -931,19 +1012,21 @@ function runErrors(err, fns, owner) {
|
|
|
931
1012
|
try {
|
|
932
1013
|
for (const f of fns) f(err);
|
|
933
1014
|
} catch (e) {
|
|
934
|
-
handleError(e, owner && owner.owner || null);
|
|
1015
|
+
handleError(e, (owner && owner.owner) || null);
|
|
935
1016
|
}
|
|
936
1017
|
}
|
|
937
1018
|
function handleError(err, owner = Owner) {
|
|
938
1019
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
939
1020
|
const error = castError(err);
|
|
940
1021
|
if (!fns) throw error;
|
|
941
|
-
if (Effects)
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1022
|
+
if (Effects)
|
|
1023
|
+
Effects.push({
|
|
1024
|
+
fn() {
|
|
1025
|
+
runErrors(error, fns, owner);
|
|
1026
|
+
},
|
|
1027
|
+
state: STALE
|
|
1028
|
+
});
|
|
1029
|
+
else runErrors(error, fns, owner);
|
|
947
1030
|
}
|
|
948
1031
|
function resolveChildren(children) {
|
|
949
1032
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -960,19 +1043,24 @@ function resolveChildren(children) {
|
|
|
960
1043
|
function createProvider(id, options) {
|
|
961
1044
|
return function provider(props) {
|
|
962
1045
|
let res;
|
|
963
|
-
createRenderEffect(
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1046
|
+
createRenderEffect(
|
|
1047
|
+
() =>
|
|
1048
|
+
(res = untrack(() => {
|
|
1049
|
+
Owner.context = {
|
|
1050
|
+
...Owner.context,
|
|
1051
|
+
[id]: props.value
|
|
1052
|
+
};
|
|
1053
|
+
return children(() => props.children);
|
|
1054
|
+
})),
|
|
1055
|
+
undefined
|
|
1056
|
+
);
|
|
970
1057
|
return res;
|
|
971
1058
|
};
|
|
972
1059
|
}
|
|
973
1060
|
function onError(fn) {
|
|
974
1061
|
ERROR || (ERROR = Symbol("error"));
|
|
975
|
-
if (Owner === null)
|
|
1062
|
+
if (Owner === null);
|
|
1063
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
976
1064
|
Owner.context = {
|
|
977
1065
|
...Owner.context,
|
|
978
1066
|
[ERROR]: [fn]
|
|
@@ -1001,7 +1089,8 @@ function observable(input) {
|
|
|
1001
1089
|
if (!(observer instanceof Object) || observer == null) {
|
|
1002
1090
|
throw new TypeError("Expected the observer to be an object.");
|
|
1003
1091
|
}
|
|
1004
|
-
const handler =
|
|
1092
|
+
const handler =
|
|
1093
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1005
1094
|
if (!handler) {
|
|
1006
1095
|
return {
|
|
1007
1096
|
unsubscribe() {}
|
|
@@ -1032,7 +1121,7 @@ function from(producer) {
|
|
|
1032
1121
|
});
|
|
1033
1122
|
if ("subscribe" in producer) {
|
|
1034
1123
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1035
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1124
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1036
1125
|
} else {
|
|
1037
1126
|
const clean = producer(set);
|
|
1038
1127
|
onCleanup(clean);
|
|
@@ -1084,8 +1173,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1084
1173
|
});
|
|
1085
1174
|
len = 1;
|
|
1086
1175
|
}
|
|
1087
|
-
}
|
|
1088
|
-
else if (len === 0) {
|
|
1176
|
+
} else if (len === 0) {
|
|
1089
1177
|
mapped = new Array(newLen);
|
|
1090
1178
|
for (j = 0; j < newLen; j++) {
|
|
1091
1179
|
items[j] = newItems[j];
|
|
@@ -1096,8 +1184,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1096
1184
|
temp = new Array(newLen);
|
|
1097
1185
|
tempdisposers = new Array(newLen);
|
|
1098
1186
|
indexes && (tempIndexes = new Array(newLen));
|
|
1099
|
-
for (
|
|
1100
|
-
|
|
1187
|
+
for (
|
|
1188
|
+
start = 0, end = Math.min(len, newLen);
|
|
1189
|
+
start < end && items[start] === newItems[start];
|
|
1190
|
+
start++
|
|
1191
|
+
);
|
|
1192
|
+
for (
|
|
1193
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1194
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1195
|
+
end--, newEnd--
|
|
1196
|
+
) {
|
|
1101
1197
|
temp[newEnd] = mapped[end];
|
|
1102
1198
|
tempdisposers[newEnd] = disposers[end];
|
|
1103
1199
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1131,7 +1227,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1131
1227
|
}
|
|
1132
1228
|
} else mapped[j] = createRoot(mapper);
|
|
1133
1229
|
}
|
|
1134
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1230
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1135
1231
|
items = newItems.slice(0);
|
|
1136
1232
|
}
|
|
1137
1233
|
return mapped;
|
|
@@ -1197,7 +1293,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1197
1293
|
}
|
|
1198
1294
|
len = signals.length = disposers.length = newItems.length;
|
|
1199
1295
|
items = newItems.slice(0);
|
|
1200
|
-
return mapped = mapped.slice(0, len);
|
|
1296
|
+
return (mapped = mapped.slice(0, len));
|
|
1201
1297
|
});
|
|
1202
1298
|
function mapper(disposer) {
|
|
1203
1299
|
disposers[i] = disposer;
|
|
@@ -1266,29 +1362,33 @@ function mergeProps(...sources) {
|
|
|
1266
1362
|
let proxy = false;
|
|
1267
1363
|
for (let i = 0; i < sources.length; i++) {
|
|
1268
1364
|
const s = sources[i];
|
|
1269
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1270
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1365
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1366
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1271
1367
|
}
|
|
1272
1368
|
if (proxy) {
|
|
1273
|
-
return new Proxy(
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1369
|
+
return new Proxy(
|
|
1370
|
+
{
|
|
1371
|
+
get(property) {
|
|
1372
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1373
|
+
const v = resolveSource(sources[i])[property];
|
|
1374
|
+
if (v !== undefined) return v;
|
|
1375
|
+
}
|
|
1376
|
+
},
|
|
1377
|
+
has(property) {
|
|
1378
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1379
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1380
|
+
}
|
|
1381
|
+
return false;
|
|
1382
|
+
},
|
|
1383
|
+
keys() {
|
|
1384
|
+
const keys = [];
|
|
1385
|
+
for (let i = 0; i < sources.length; i++)
|
|
1386
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1387
|
+
return [...new Set(keys)];
|
|
1283
1388
|
}
|
|
1284
|
-
return false;
|
|
1285
1389
|
},
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1289
|
-
return [...new Set(keys)];
|
|
1290
|
-
}
|
|
1291
|
-
}, propTraps);
|
|
1390
|
+
propTraps
|
|
1391
|
+
);
|
|
1292
1392
|
}
|
|
1293
1393
|
const target = {};
|
|
1294
1394
|
const sourcesMap = {};
|
|
@@ -1307,7 +1407,7 @@ function mergeProps(...sources) {
|
|
|
1307
1407
|
Object.defineProperty(target, key, {
|
|
1308
1408
|
enumerable: true,
|
|
1309
1409
|
configurable: true,
|
|
1310
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1410
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1311
1411
|
});
|
|
1312
1412
|
} else {
|
|
1313
1413
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1331,47 +1431,60 @@ function splitProps(props, ...keys) {
|
|
|
1331
1431
|
if ($PROXY in props) {
|
|
1332
1432
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1333
1433
|
const res = keys.map(k => {
|
|
1334
|
-
return new Proxy(
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1434
|
+
return new Proxy(
|
|
1435
|
+
{
|
|
1436
|
+
get(property) {
|
|
1437
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1438
|
+
},
|
|
1439
|
+
has(property) {
|
|
1440
|
+
return k.includes(property) && property in props;
|
|
1441
|
+
},
|
|
1442
|
+
keys() {
|
|
1443
|
+
return k.filter(property => property in props);
|
|
1444
|
+
}
|
|
1340
1445
|
},
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1344
|
-
}, propTraps);
|
|
1446
|
+
propTraps
|
|
1447
|
+
);
|
|
1345
1448
|
});
|
|
1346
|
-
res.push(
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1449
|
+
res.push(
|
|
1450
|
+
new Proxy(
|
|
1451
|
+
{
|
|
1452
|
+
get(property) {
|
|
1453
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1454
|
+
},
|
|
1455
|
+
has(property) {
|
|
1456
|
+
return blocked.has(property) ? false : property in props;
|
|
1457
|
+
},
|
|
1458
|
+
keys() {
|
|
1459
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1460
|
+
}
|
|
1461
|
+
},
|
|
1462
|
+
propTraps
|
|
1463
|
+
)
|
|
1464
|
+
);
|
|
1357
1465
|
return res;
|
|
1358
1466
|
}
|
|
1359
1467
|
const otherObject = {};
|
|
1360
1468
|
const objects = keys.map(() => ({}));
|
|
1361
1469
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1362
1470
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1363
|
-
const isDefaultDesc =
|
|
1471
|
+
const isDefaultDesc =
|
|
1472
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1364
1473
|
let blocked = false;
|
|
1365
1474
|
let objectIndex = 0;
|
|
1366
1475
|
for (const k of keys) {
|
|
1367
1476
|
if (k.includes(propName)) {
|
|
1368
1477
|
blocked = true;
|
|
1369
|
-
isDefaultDesc
|
|
1478
|
+
isDefaultDesc
|
|
1479
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1480
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1370
1481
|
}
|
|
1371
1482
|
++objectIndex;
|
|
1372
1483
|
}
|
|
1373
1484
|
if (!blocked) {
|
|
1374
|
-
isDefaultDesc
|
|
1485
|
+
isDefaultDesc
|
|
1486
|
+
? (otherObject[propName] = desc.value)
|
|
1487
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1375
1488
|
}
|
|
1376
1489
|
}
|
|
1377
1490
|
return [...objects, otherObject];
|
|
@@ -1397,17 +1510,21 @@ function lazy(fn) {
|
|
|
1397
1510
|
comp = s;
|
|
1398
1511
|
}
|
|
1399
1512
|
let Comp;
|
|
1400
|
-
return createMemo(
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1513
|
+
return createMemo(
|
|
1514
|
+
() =>
|
|
1515
|
+
(Comp = comp()) &&
|
|
1516
|
+
untrack(() => {
|
|
1517
|
+
if (false);
|
|
1518
|
+
if (!ctx) return Comp(props);
|
|
1519
|
+
const c = sharedConfig.context;
|
|
1520
|
+
setHydrateContext(ctx);
|
|
1521
|
+
const r = Comp(props);
|
|
1522
|
+
setHydrateContext(c);
|
|
1523
|
+
return r;
|
|
1524
|
+
})
|
|
1525
|
+
);
|
|
1409
1526
|
};
|
|
1410
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1527
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1411
1528
|
return wrap;
|
|
1412
1529
|
}
|
|
1413
1530
|
let counter = 0;
|
|
@@ -1432,49 +1549,78 @@ function Index(props) {
|
|
|
1432
1549
|
function Show(props) {
|
|
1433
1550
|
const keyed = props.keyed;
|
|
1434
1551
|
const condition = createMemo(() => props.when, undefined, {
|
|
1435
|
-
equals: (a, b) => keyed ? a === b : !a === !b
|
|
1552
|
+
equals: (a, b) => (keyed ? a === b : !a === !b)
|
|
1436
1553
|
});
|
|
1437
|
-
return createMemo(
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1554
|
+
return createMemo(
|
|
1555
|
+
() => {
|
|
1556
|
+
const c = condition();
|
|
1557
|
+
if (c) {
|
|
1558
|
+
const child = props.children;
|
|
1559
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1560
|
+
return fn
|
|
1561
|
+
? untrack(() =>
|
|
1562
|
+
child(
|
|
1563
|
+
keyed
|
|
1564
|
+
? c
|
|
1565
|
+
: () => {
|
|
1566
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1567
|
+
return props.when;
|
|
1568
|
+
}
|
|
1569
|
+
)
|
|
1570
|
+
)
|
|
1571
|
+
: child;
|
|
1572
|
+
}
|
|
1573
|
+
return props.fallback;
|
|
1574
|
+
},
|
|
1575
|
+
undefined,
|
|
1576
|
+
undefined
|
|
1577
|
+
);
|
|
1449
1578
|
}
|
|
1450
1579
|
function Switch(props) {
|
|
1451
1580
|
let keyed = false;
|
|
1452
|
-
const equals = (a, b) =>
|
|
1581
|
+
const equals = (a, b) =>
|
|
1582
|
+
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1453
1583
|
const conditions = children(() => props.children),
|
|
1454
|
-
evalConditions = createMemo(
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1584
|
+
evalConditions = createMemo(
|
|
1585
|
+
() => {
|
|
1586
|
+
let conds = conditions();
|
|
1587
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1588
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1589
|
+
const c = conds[i].when;
|
|
1590
|
+
if (c) {
|
|
1591
|
+
keyed = !!conds[i].keyed;
|
|
1592
|
+
return [i, c, conds[i]];
|
|
1593
|
+
}
|
|
1462
1594
|
}
|
|
1595
|
+
return [-1];
|
|
1596
|
+
},
|
|
1597
|
+
undefined,
|
|
1598
|
+
{
|
|
1599
|
+
equals
|
|
1463
1600
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1601
|
+
);
|
|
1602
|
+
return createMemo(
|
|
1603
|
+
() => {
|
|
1604
|
+
const [index, when, cond] = evalConditions();
|
|
1605
|
+
if (index < 0) return props.fallback;
|
|
1606
|
+
const c = cond.children;
|
|
1607
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1608
|
+
return fn
|
|
1609
|
+
? untrack(() =>
|
|
1610
|
+
c(
|
|
1611
|
+
keyed
|
|
1612
|
+
? when
|
|
1613
|
+
: () => {
|
|
1614
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1615
|
+
return cond.when;
|
|
1616
|
+
}
|
|
1617
|
+
)
|
|
1618
|
+
)
|
|
1619
|
+
: c;
|
|
1620
|
+
},
|
|
1621
|
+
undefined,
|
|
1622
|
+
undefined
|
|
1623
|
+
);
|
|
1478
1624
|
}
|
|
1479
1625
|
function Match(props) {
|
|
1480
1626
|
return props;
|
|
@@ -1485,22 +1631,28 @@ function resetErrorBoundaries() {
|
|
|
1485
1631
|
}
|
|
1486
1632
|
function ErrorBoundary(props) {
|
|
1487
1633
|
let err;
|
|
1488
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1634
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1635
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1489
1636
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1490
1637
|
Errors || (Errors = new Set());
|
|
1491
1638
|
Errors.add(setErrored);
|
|
1492
1639
|
onCleanup(() => Errors.delete(setErrored));
|
|
1493
|
-
return createMemo(
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1640
|
+
return createMemo(
|
|
1641
|
+
() => {
|
|
1642
|
+
let e;
|
|
1643
|
+
if ((e = errored())) {
|
|
1644
|
+
const f = props.fallback;
|
|
1645
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1646
|
+
}
|
|
1647
|
+
return catchError(() => props.children, setErrored);
|
|
1648
|
+
},
|
|
1649
|
+
undefined,
|
|
1650
|
+
undefined
|
|
1651
|
+
);
|
|
1501
1652
|
}
|
|
1502
1653
|
|
|
1503
|
-
const suspenseListEquals = (a, b) =>
|
|
1654
|
+
const suspenseListEquals = (a, b) =>
|
|
1655
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1504
1656
|
const SuspenseListContext = createContext();
|
|
1505
1657
|
function SuspenseList(props) {
|
|
1506
1658
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1512,51 +1664,51 @@ function SuspenseList(props) {
|
|
|
1512
1664
|
if (listContext) {
|
|
1513
1665
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1514
1666
|
}
|
|
1515
|
-
const resolved = createMemo(
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
showContent = true,
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
const res = reg.map(() => ({
|
|
1527
|
-
showContent: all && showContent,
|
|
1528
|
-
showFallback
|
|
1529
|
-
}));
|
|
1530
|
-
res.inFallback = !all;
|
|
1531
|
-
return res;
|
|
1532
|
-
}
|
|
1533
|
-
let stop = false;
|
|
1534
|
-
let inFallback = prev.inFallback;
|
|
1535
|
-
const res = [];
|
|
1536
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1537
|
-
const n = reverse ? len - i - 1 : i,
|
|
1538
|
-
s = reg[n]();
|
|
1539
|
-
if (!stop && !s) {
|
|
1540
|
-
res[n] = {
|
|
1541
|
-
showContent,
|
|
1667
|
+
const resolved = createMemo(
|
|
1668
|
+
prev => {
|
|
1669
|
+
const reveal = props.revealOrder,
|
|
1670
|
+
tail = props.tail,
|
|
1671
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1672
|
+
reg = registry(),
|
|
1673
|
+
reverse = reveal === "backwards";
|
|
1674
|
+
if (reveal === "together") {
|
|
1675
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1676
|
+
const res = reg.map(() => ({
|
|
1677
|
+
showContent: all && showContent,
|
|
1542
1678
|
showFallback
|
|
1543
|
-
};
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
if (next) inFallback = true;
|
|
1547
|
-
res[n] = {
|
|
1548
|
-
showContent: next,
|
|
1549
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1550
|
-
};
|
|
1551
|
-
stop = true;
|
|
1679
|
+
}));
|
|
1680
|
+
res.inFallback = !all;
|
|
1681
|
+
return res;
|
|
1552
1682
|
}
|
|
1683
|
+
let stop = false;
|
|
1684
|
+
let inFallback = prev.inFallback;
|
|
1685
|
+
const res = [];
|
|
1686
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1687
|
+
const n = reverse ? len - i - 1 : i,
|
|
1688
|
+
s = reg[n]();
|
|
1689
|
+
if (!stop && !s) {
|
|
1690
|
+
res[n] = {
|
|
1691
|
+
showContent,
|
|
1692
|
+
showFallback
|
|
1693
|
+
};
|
|
1694
|
+
} else {
|
|
1695
|
+
const next = !stop;
|
|
1696
|
+
if (next) inFallback = true;
|
|
1697
|
+
res[n] = {
|
|
1698
|
+
showContent: next,
|
|
1699
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1700
|
+
};
|
|
1701
|
+
stop = true;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
if (!stop) inFallback = false;
|
|
1705
|
+
res.inFallback = inFallback;
|
|
1706
|
+
return res;
|
|
1707
|
+
},
|
|
1708
|
+
{
|
|
1709
|
+
inFallback: false
|
|
1553
1710
|
}
|
|
1554
|
-
|
|
1555
|
-
res.inFallback = inFallback;
|
|
1556
|
-
return res;
|
|
1557
|
-
}, {
|
|
1558
|
-
inFallback: false
|
|
1559
|
-
});
|
|
1711
|
+
);
|
|
1560
1712
|
setWrapper(() => resolved);
|
|
1561
1713
|
return createComponent(SuspenseListContext.Provider, {
|
|
1562
1714
|
value: {
|
|
@@ -1600,7 +1752,7 @@ function Suspense(props) {
|
|
|
1600
1752
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1601
1753
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1602
1754
|
let ref = sharedConfig.load(key);
|
|
1603
|
-
if (ref && (typeof ref !== "object" ||
|
|
1755
|
+
if (ref && (typeof ref !== "object" || ref.status !== "success")) p = ref;
|
|
1604
1756
|
if (p && p !== "$$f") {
|
|
1605
1757
|
const [s, set] = createSignal(undefined, {
|
|
1606
1758
|
equals: false
|
|
@@ -1631,17 +1783,14 @@ function Suspense(props) {
|
|
|
1631
1783
|
ctx = sharedConfig.context;
|
|
1632
1784
|
if (flicker) {
|
|
1633
1785
|
flicker();
|
|
1634
|
-
return flicker = undefined;
|
|
1786
|
+
return (flicker = undefined);
|
|
1635
1787
|
}
|
|
1636
1788
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1637
1789
|
const rendered = createMemo(() => props.children);
|
|
1638
1790
|
return createMemo(prev => {
|
|
1639
1791
|
const inFallback = store.inFallback(),
|
|
1640
|
-
{
|
|
1641
|
-
|
|
1642
|
-
showFallback = true
|
|
1643
|
-
} = show ? show() : {};
|
|
1644
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1792
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1793
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1645
1794
|
store.resolved = true;
|
|
1646
1795
|
dispose && dispose();
|
|
1647
1796
|
dispose = ctx = p = undefined;
|
|
@@ -1669,4 +1818,59 @@ function Suspense(props) {
|
|
|
1669
1818
|
|
|
1670
1819
|
const DEV = undefined;
|
|
1671
1820
|
|
|
1672
|
-
export {
|
|
1821
|
+
export {
|
|
1822
|
+
$DEVCOMP,
|
|
1823
|
+
$PROXY,
|
|
1824
|
+
$TRACK,
|
|
1825
|
+
DEV,
|
|
1826
|
+
ErrorBoundary,
|
|
1827
|
+
For,
|
|
1828
|
+
Index,
|
|
1829
|
+
Match,
|
|
1830
|
+
Show,
|
|
1831
|
+
Suspense,
|
|
1832
|
+
SuspenseList,
|
|
1833
|
+
Switch,
|
|
1834
|
+
batch,
|
|
1835
|
+
cancelCallback,
|
|
1836
|
+
catchError,
|
|
1837
|
+
children,
|
|
1838
|
+
createComponent,
|
|
1839
|
+
createComputed,
|
|
1840
|
+
createContext,
|
|
1841
|
+
createDeferred,
|
|
1842
|
+
createEffect,
|
|
1843
|
+
createMemo,
|
|
1844
|
+
createReaction,
|
|
1845
|
+
createRenderEffect,
|
|
1846
|
+
createResource,
|
|
1847
|
+
createRoot,
|
|
1848
|
+
createSelector,
|
|
1849
|
+
createSignal,
|
|
1850
|
+
createUniqueId,
|
|
1851
|
+
enableExternalSource,
|
|
1852
|
+
enableHydration,
|
|
1853
|
+
enableScheduling,
|
|
1854
|
+
equalFn,
|
|
1855
|
+
from,
|
|
1856
|
+
getListener,
|
|
1857
|
+
getOwner,
|
|
1858
|
+
indexArray,
|
|
1859
|
+
lazy,
|
|
1860
|
+
mapArray,
|
|
1861
|
+
mergeProps,
|
|
1862
|
+
observable,
|
|
1863
|
+
on,
|
|
1864
|
+
onCleanup,
|
|
1865
|
+
onError,
|
|
1866
|
+
onMount,
|
|
1867
|
+
requestCallback,
|
|
1868
|
+
resetErrorBoundaries,
|
|
1869
|
+
runWithOwner,
|
|
1870
|
+
sharedConfig,
|
|
1871
|
+
splitProps,
|
|
1872
|
+
startTransition,
|
|
1873
|
+
untrack,
|
|
1874
|
+
useContext,
|
|
1875
|
+
useTransition
|
|
1876
|
+
};
|