solid-js 1.7.7 → 1.7.9
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 +24 -13
- package/dist/dev.js +555 -306
- package/dist/server.cjs +3 -3
- package/dist/server.js +177 -79
- package/dist/solid.cjs +24 -13
- package/dist/solid.js +482 -264
- package/h/dist/h.cjs +2 -2
- package/h/dist/h.js +36 -10
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +130 -100
- package/h/types/hyperscript.d.ts +11 -11
- package/h/types/index.d.ts +3 -2
- package/html/dist/html.cjs +2 -2
- package/html/dist/html.js +218 -96
- package/html/types/index.d.ts +3 -2
- package/html/types/lit.d.ts +45 -31
- package/package.json +1 -1
- package/store/dist/dev.cjs +34 -32
- package/store/dist/dev.js +141 -67
- package/store/dist/server.js +19 -8
- package/store/dist/store.cjs +34 -32
- package/store/dist/store.js +132 -64
- 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 +217 -63
- package/types/index.d.ts +69 -9
- package/types/jsx.d.ts +10 -6
- 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 +227 -136
- 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 -10
- package/types/server/index.d.ts +55 -2
- package/types/server/reactive.d.ts +67 -40
- package/types/server/rendering.d.ts +171 -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 +610 -79
- package/web/dist/server.cjs +4 -4
- package/web/dist/server.js +180 -81
- package/web/dist/web.js +610 -79
- 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,17 +157,19 @@ 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
|
-
root = unowned
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
root = unowned
|
|
166
|
+
? UNOWNED
|
|
167
|
+
: {
|
|
168
|
+
owned: null,
|
|
169
|
+
cleanups: null,
|
|
170
|
+
context: null,
|
|
171
|
+
owner: detachedOwner === undefined ? owner : detachedOwner
|
|
172
|
+
},
|
|
169
173
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
170
174
|
Owner = root;
|
|
171
175
|
Listener = null;
|
|
@@ -186,7 +190,8 @@ function createSignal(value, options) {
|
|
|
186
190
|
};
|
|
187
191
|
const setter = value => {
|
|
188
192
|
if (typeof value === "function") {
|
|
189
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
193
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
194
|
+
else value = value(s.value);
|
|
190
195
|
}
|
|
191
196
|
return writeSignal(s, value);
|
|
192
197
|
};
|
|
@@ -194,11 +199,13 @@ function createSignal(value, options) {
|
|
|
194
199
|
}
|
|
195
200
|
function createComputed(fn, value, options) {
|
|
196
201
|
const c = createComputation(fn, value, true, STALE);
|
|
197
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
202
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
203
|
+
else updateComputation(c);
|
|
198
204
|
}
|
|
199
205
|
function createRenderEffect(fn, value, options) {
|
|
200
206
|
const c = createComputation(fn, value, false, STALE);
|
|
201
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
207
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
208
|
+
else updateComputation(c);
|
|
202
209
|
}
|
|
203
210
|
function createEffect(fn, value, options) {
|
|
204
211
|
runEffects = runUserEffects;
|
|
@@ -210,10 +217,15 @@ function createEffect(fn, value, options) {
|
|
|
210
217
|
}
|
|
211
218
|
function createReaction(onInvalidate, options) {
|
|
212
219
|
let fn;
|
|
213
|
-
const c = createComputation(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
const c = createComputation(
|
|
221
|
+
() => {
|
|
222
|
+
fn ? fn() : untrack(onInvalidate);
|
|
223
|
+
fn = undefined;
|
|
224
|
+
},
|
|
225
|
+
undefined,
|
|
226
|
+
false,
|
|
227
|
+
0
|
|
228
|
+
),
|
|
217
229
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
218
230
|
if (s) c.suspense = s;
|
|
219
231
|
c.user = true;
|
|
@@ -238,7 +250,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
238
250
|
let source;
|
|
239
251
|
let fetcher;
|
|
240
252
|
let options;
|
|
241
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
253
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
242
254
|
source = true;
|
|
243
255
|
fetcher = pSource;
|
|
244
256
|
options = pFetcher || {};
|
|
@@ -252,7 +264,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
252
264
|
id = null,
|
|
253
265
|
loadedUnderTransition = false,
|
|
254
266
|
scheduled = false,
|
|
255
|
-
resolved =
|
|
267
|
+
resolved = "initialValue" in options,
|
|
256
268
|
dynamic = typeof source === "function" && createMemo(source);
|
|
257
269
|
const contexts = new Set(),
|
|
258
270
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -264,15 +276,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
264
276
|
if (sharedConfig.context) {
|
|
265
277
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
266
278
|
let v;
|
|
267
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
279
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
280
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
268
281
|
}
|
|
269
282
|
function loadEnd(p, v, error, key) {
|
|
270
283
|
if (pr === p) {
|
|
271
284
|
pr = null;
|
|
272
285
|
key !== undefined && (resolved = true);
|
|
273
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
274
|
-
|
|
275
|
-
|
|
286
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
287
|
+
queueMicrotask(() =>
|
|
288
|
+
options.onHydrated(key, {
|
|
289
|
+
value: v
|
|
290
|
+
})
|
|
291
|
+
);
|
|
276
292
|
initP = NO_INIT;
|
|
277
293
|
if (Transition && p && loadedUnderTransition) {
|
|
278
294
|
Transition.promises.delete(p);
|
|
@@ -303,7 +319,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
303
319
|
createComputed(() => {
|
|
304
320
|
track();
|
|
305
321
|
if (pr) {
|
|
306
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
322
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
323
|
+
else if (!contexts.has(c)) {
|
|
307
324
|
c.increment();
|
|
308
325
|
contexts.add(c);
|
|
309
326
|
}
|
|
@@ -322,22 +339,30 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
322
339
|
return;
|
|
323
340
|
}
|
|
324
341
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
325
|
-
const p =
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
342
|
+
const p =
|
|
343
|
+
initP !== NO_INIT
|
|
344
|
+
? initP
|
|
345
|
+
: untrack(() =>
|
|
346
|
+
fetcher(lookup, {
|
|
347
|
+
value: value(),
|
|
348
|
+
refetching
|
|
349
|
+
})
|
|
350
|
+
);
|
|
329
351
|
if (typeof p !== "object" || !(p && "then" in p)) {
|
|
330
352
|
loadEnd(pr, p, undefined, lookup);
|
|
331
353
|
return p;
|
|
332
354
|
}
|
|
333
355
|
pr = p;
|
|
334
356
|
scheduled = true;
|
|
335
|
-
queueMicrotask(() => scheduled = false);
|
|
357
|
+
queueMicrotask(() => (scheduled = false));
|
|
336
358
|
runUpdates(() => {
|
|
337
359
|
setState(resolved ? "refreshing" : "pending");
|
|
338
360
|
trigger();
|
|
339
361
|
}, false);
|
|
340
|
-
return p.then(
|
|
362
|
+
return p.then(
|
|
363
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
364
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
365
|
+
);
|
|
341
366
|
}
|
|
342
367
|
Object.defineProperties(read, {
|
|
343
368
|
state: {
|
|
@@ -361,21 +386,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
361
386
|
}
|
|
362
387
|
}
|
|
363
388
|
});
|
|
364
|
-
if (dynamic) createComputed(() => load(false));
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
389
|
+
if (dynamic) createComputed(() => load(false));
|
|
390
|
+
else load(false);
|
|
391
|
+
return [
|
|
392
|
+
read,
|
|
393
|
+
{
|
|
394
|
+
refetch: load,
|
|
395
|
+
mutate: setValue
|
|
396
|
+
}
|
|
397
|
+
];
|
|
369
398
|
}
|
|
370
399
|
function createDeferred(source, options) {
|
|
371
400
|
let t,
|
|
372
401
|
timeout = options ? options.timeoutMs : undefined;
|
|
373
|
-
const node = createComputation(
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
402
|
+
const node = createComputation(
|
|
403
|
+
() => {
|
|
404
|
+
if (!t || !t.fn)
|
|
405
|
+
t = requestCallback(
|
|
406
|
+
() => setDeferred(() => node.value),
|
|
407
|
+
timeout !== undefined
|
|
408
|
+
? {
|
|
409
|
+
timeout
|
|
410
|
+
}
|
|
411
|
+
: undefined
|
|
412
|
+
);
|
|
413
|
+
return source();
|
|
414
|
+
},
|
|
415
|
+
undefined,
|
|
416
|
+
true
|
|
417
|
+
);
|
|
379
418
|
const [deferred, setDeferred] = createSignal(node.value, options);
|
|
380
419
|
updateComputation(node);
|
|
381
420
|
setDeferred(() => node.value);
|
|
@@ -383,28 +422,39 @@ function createDeferred(source, options) {
|
|
|
383
422
|
}
|
|
384
423
|
function createSelector(source, fn = equalFn, options) {
|
|
385
424
|
const subs = new Map();
|
|
386
|
-
const node = createComputation(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
for (const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
425
|
+
const node = createComputation(
|
|
426
|
+
p => {
|
|
427
|
+
const v = source();
|
|
428
|
+
for (const [key, val] of subs.entries())
|
|
429
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
430
|
+
for (const c of val.values()) {
|
|
431
|
+
c.state = STALE;
|
|
432
|
+
if (c.pure) Updates.push(c);
|
|
433
|
+
else Effects.push(c);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return v;
|
|
437
|
+
},
|
|
438
|
+
undefined,
|
|
439
|
+
true,
|
|
440
|
+
STALE
|
|
441
|
+
);
|
|
396
442
|
updateComputation(node);
|
|
397
443
|
return key => {
|
|
398
444
|
const listener = Listener;
|
|
399
445
|
if (listener) {
|
|
400
446
|
let l;
|
|
401
|
-
if (l = subs.get(key)) l.add(listener);
|
|
447
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
448
|
+
else subs.set(key, (l = new Set([listener])));
|
|
402
449
|
onCleanup(() => {
|
|
403
450
|
l.delete(listener);
|
|
404
451
|
!l.size && subs.delete(key);
|
|
405
452
|
});
|
|
406
453
|
}
|
|
407
|
-
return fn(
|
|
454
|
+
return fn(
|
|
455
|
+
key,
|
|
456
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
457
|
+
);
|
|
408
458
|
};
|
|
409
459
|
}
|
|
410
460
|
function batch(fn) {
|
|
@@ -443,7 +493,9 @@ function onMount(fn) {
|
|
|
443
493
|
createEffect(() => untrack(fn));
|
|
444
494
|
}
|
|
445
495
|
function onCleanup(fn) {
|
|
446
|
-
if (Owner === null)
|
|
496
|
+
if (Owner === null);
|
|
497
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
498
|
+
else Owner.cleanups.push(fn);
|
|
447
499
|
return fn;
|
|
448
500
|
}
|
|
449
501
|
function catchError(fn, handler) {
|
|
@@ -463,9 +515,13 @@ function catchError(fn, handler) {
|
|
|
463
515
|
}
|
|
464
516
|
function onError(fn) {
|
|
465
517
|
ERROR || (ERROR = Symbol("error"));
|
|
466
|
-
if (Owner === null)
|
|
467
|
-
|
|
468
|
-
|
|
518
|
+
if (Owner === null);
|
|
519
|
+
else if (Owner.context === null)
|
|
520
|
+
Owner.context = {
|
|
521
|
+
[ERROR]: [fn]
|
|
522
|
+
};
|
|
523
|
+
else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];
|
|
524
|
+
else Owner.context[ERROR].push(fn);
|
|
469
525
|
}
|
|
470
526
|
function getListener() {
|
|
471
527
|
return Listener;
|
|
@@ -502,15 +558,17 @@ function startTransition(fn) {
|
|
|
502
558
|
Owner = o;
|
|
503
559
|
let t;
|
|
504
560
|
if (Scheduler || SuspenseContext) {
|
|
505
|
-
t =
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
561
|
+
t =
|
|
562
|
+
Transition ||
|
|
563
|
+
(Transition = {
|
|
564
|
+
sources: new Set(),
|
|
565
|
+
effects: [],
|
|
566
|
+
promises: new Set(),
|
|
567
|
+
disposed: new Set(),
|
|
568
|
+
queue: new Set(),
|
|
569
|
+
running: true
|
|
570
|
+
});
|
|
571
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
514
572
|
t.running = true;
|
|
515
573
|
}
|
|
516
574
|
runUpdates(fn, false);
|
|
@@ -571,7 +629,8 @@ function enableExternalSource(factory) {
|
|
|
571
629
|
function readSignal() {
|
|
572
630
|
const runningTransition = Transition && Transition.running;
|
|
573
631
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
574
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
632
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
633
|
+
else {
|
|
575
634
|
const updates = Updates;
|
|
576
635
|
Updates = null;
|
|
577
636
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -599,11 +658,12 @@ function readSignal() {
|
|
|
599
658
|
return this.value;
|
|
600
659
|
}
|
|
601
660
|
function writeSignal(node, value, isComp) {
|
|
602
|
-
let current =
|
|
661
|
+
let current =
|
|
662
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
603
663
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
604
664
|
if (Transition) {
|
|
605
665
|
const TransitionRunning = Transition.running;
|
|
606
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
666
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
607
667
|
Transition.sources.add(node);
|
|
608
668
|
node.tValue = value;
|
|
609
669
|
}
|
|
@@ -616,14 +676,16 @@ function writeSignal(node, value, isComp) {
|
|
|
616
676
|
const TransitionRunning = Transition && Transition.running;
|
|
617
677
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
618
678
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
619
|
-
if (o.pure) Updates.push(o);
|
|
679
|
+
if (o.pure) Updates.push(o);
|
|
680
|
+
else Effects.push(o);
|
|
620
681
|
if (o.observers) markDownstream(o);
|
|
621
682
|
}
|
|
622
|
-
if (!TransitionRunning) o.state = STALE;
|
|
683
|
+
if (!TransitionRunning) o.state = STALE;
|
|
684
|
+
else o.tState = STALE;
|
|
623
685
|
}
|
|
624
686
|
if (Updates.length > 10e5) {
|
|
625
687
|
Updates = [];
|
|
626
|
-
if (false)
|
|
688
|
+
if (false);
|
|
627
689
|
throw new Error();
|
|
628
690
|
}
|
|
629
691
|
}, false);
|
|
@@ -638,7 +700,11 @@ function updateComputation(node) {
|
|
|
638
700
|
listener = Listener,
|
|
639
701
|
time = ExecCount;
|
|
640
702
|
Listener = Owner = node;
|
|
641
|
-
runComputation(
|
|
703
|
+
runComputation(
|
|
704
|
+
node,
|
|
705
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
706
|
+
time
|
|
707
|
+
);
|
|
642
708
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
643
709
|
queueMicrotask(() => {
|
|
644
710
|
runUpdates(() => {
|
|
@@ -699,11 +765,14 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
699
765
|
c.state = 0;
|
|
700
766
|
c.tState = state;
|
|
701
767
|
}
|
|
702
|
-
if (Owner === null)
|
|
768
|
+
if (Owner === null);
|
|
769
|
+
else if (Owner !== UNOWNED) {
|
|
703
770
|
if (Transition && Transition.running && Owner.pure) {
|
|
704
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
771
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
772
|
+
else Owner.tOwned.push(c);
|
|
705
773
|
} else {
|
|
706
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
774
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
775
|
+
else Owner.owned.push(c);
|
|
707
776
|
}
|
|
708
777
|
}
|
|
709
778
|
if (ExternalSourceFactory) {
|
|
@@ -754,7 +823,8 @@ function runUpdates(fn, init) {
|
|
|
754
823
|
if (Updates) return fn();
|
|
755
824
|
let wait = false;
|
|
756
825
|
if (!init) Updates = [];
|
|
757
|
-
if (Effects) wait = true;
|
|
826
|
+
if (Effects) wait = true;
|
|
827
|
+
else Effects = [];
|
|
758
828
|
ExecCount++;
|
|
759
829
|
try {
|
|
760
830
|
const res = fn();
|
|
@@ -768,7 +838,8 @@ function runUpdates(fn, init) {
|
|
|
768
838
|
}
|
|
769
839
|
function completeUpdates(wait) {
|
|
770
840
|
if (Updates) {
|
|
771
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
841
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
842
|
+
else runQueue(Updates);
|
|
772
843
|
Updates = null;
|
|
773
844
|
}
|
|
774
845
|
if (wait) return;
|
|
@@ -836,20 +907,34 @@ function runUserEffects(queue) {
|
|
|
836
907
|
userLength = 0;
|
|
837
908
|
for (i = 0; i < queue.length; i++) {
|
|
838
909
|
const e = queue[i];
|
|
839
|
-
if (!e.user) runTop(e);
|
|
910
|
+
if (!e.user) runTop(e);
|
|
911
|
+
else queue[userLength++] = e;
|
|
912
|
+
}
|
|
913
|
+
if (sharedConfig.context) {
|
|
914
|
+
if (sharedConfig.count) {
|
|
915
|
+
sharedConfig.effects || (sharedConfig.effects = []);
|
|
916
|
+
sharedConfig.effects.push(...queue.slice(0, userLength));
|
|
917
|
+
return;
|
|
918
|
+
} else if (sharedConfig.effects) {
|
|
919
|
+
queue = [...sharedConfig.effects, ...queue];
|
|
920
|
+
userLength += sharedConfig.effects.length;
|
|
921
|
+
delete sharedConfig.effects;
|
|
922
|
+
}
|
|
923
|
+
setHydrateContext();
|
|
840
924
|
}
|
|
841
|
-
if (sharedConfig.context) setHydrateContext();
|
|
842
925
|
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
843
926
|
}
|
|
844
927
|
function lookUpstream(node, ignore) {
|
|
845
928
|
const runningTransition = Transition && Transition.running;
|
|
846
|
-
if (runningTransition) node.tState = 0;
|
|
929
|
+
if (runningTransition) node.tState = 0;
|
|
930
|
+
else node.state = 0;
|
|
847
931
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
848
932
|
const source = node.sources[i];
|
|
849
933
|
if (source.sources) {
|
|
850
934
|
const state = runningTransition ? source.tState : source.state;
|
|
851
935
|
if (state === STALE) {
|
|
852
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
936
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
937
|
+
runTop(source);
|
|
853
938
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
854
939
|
}
|
|
855
940
|
}
|
|
@@ -859,8 +944,10 @@ function markDownstream(node) {
|
|
|
859
944
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
860
945
|
const o = node.observers[i];
|
|
861
946
|
if (runningTransition ? !o.tState : !o.state) {
|
|
862
|
-
if (runningTransition) o.tState = PENDING;
|
|
863
|
-
|
|
947
|
+
if (runningTransition) o.tState = PENDING;
|
|
948
|
+
else o.state = PENDING;
|
|
949
|
+
if (o.pure) Updates.push(o);
|
|
950
|
+
else Effects.push(o);
|
|
864
951
|
o.observers && markDownstream(o);
|
|
865
952
|
}
|
|
866
953
|
}
|
|
@@ -897,7 +984,8 @@ function cleanNode(node) {
|
|
|
897
984
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
898
985
|
node.cleanups = null;
|
|
899
986
|
}
|
|
900
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
987
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
988
|
+
else node.state = 0;
|
|
901
989
|
node.context = null;
|
|
902
990
|
}
|
|
903
991
|
function reset(node, top) {
|
|
@@ -915,29 +1003,32 @@ function castError(err) {
|
|
|
915
1003
|
cause: err
|
|
916
1004
|
});
|
|
917
1005
|
}
|
|
1006
|
+
function runErrors(err, fns, owner) {
|
|
1007
|
+
try {
|
|
1008
|
+
for (const f of fns) f(err);
|
|
1009
|
+
} catch (e) {
|
|
1010
|
+
handleError(e, (owner && owner.owner) || null);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
918
1013
|
function handleError(err, owner = Owner) {
|
|
919
1014
|
const fns = ERROR && lookup(owner, ERROR);
|
|
920
1015
|
const error = castError(err);
|
|
921
1016
|
if (!fns) throw error;
|
|
922
|
-
if (Effects)
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
state: STALE
|
|
931
|
-
});else {
|
|
932
|
-
try {
|
|
933
|
-
for (const f of fns) f(error);
|
|
934
|
-
} catch (e) {
|
|
935
|
-
handleError(e, owner?.owner || null);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
1017
|
+
if (Effects)
|
|
1018
|
+
Effects.push({
|
|
1019
|
+
fn() {
|
|
1020
|
+
runErrors(error, fns, owner);
|
|
1021
|
+
},
|
|
1022
|
+
state: STALE
|
|
1023
|
+
});
|
|
1024
|
+
else runErrors(error, fns, owner);
|
|
938
1025
|
}
|
|
939
1026
|
function lookup(owner, key) {
|
|
940
|
-
return owner
|
|
1027
|
+
return owner
|
|
1028
|
+
? owner.context && owner.context[key] !== undefined
|
|
1029
|
+
? owner.context[key]
|
|
1030
|
+
: lookup(owner.owner, key)
|
|
1031
|
+
: undefined;
|
|
941
1032
|
}
|
|
942
1033
|
function resolveChildren(children) {
|
|
943
1034
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -954,12 +1045,16 @@ function resolveChildren(children) {
|
|
|
954
1045
|
function createProvider(id, options) {
|
|
955
1046
|
return function provider(props) {
|
|
956
1047
|
let res;
|
|
957
|
-
createRenderEffect(
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1048
|
+
createRenderEffect(
|
|
1049
|
+
() =>
|
|
1050
|
+
(res = untrack(() => {
|
|
1051
|
+
Owner.context = {
|
|
1052
|
+
[id]: props.value
|
|
1053
|
+
};
|
|
1054
|
+
return children(() => props.children);
|
|
1055
|
+
})),
|
|
1056
|
+
undefined
|
|
1057
|
+
);
|
|
963
1058
|
return res;
|
|
964
1059
|
};
|
|
965
1060
|
}
|
|
@@ -970,7 +1065,8 @@ function observable(input) {
|
|
|
970
1065
|
if (!(observer instanceof Object) || observer == null) {
|
|
971
1066
|
throw new TypeError("Expected the observer to be an object.");
|
|
972
1067
|
}
|
|
973
|
-
const handler =
|
|
1068
|
+
const handler =
|
|
1069
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
974
1070
|
if (!handler) {
|
|
975
1071
|
return {
|
|
976
1072
|
unsubscribe() {}
|
|
@@ -1001,7 +1097,7 @@ function from(producer) {
|
|
|
1001
1097
|
});
|
|
1002
1098
|
if ("subscribe" in producer) {
|
|
1003
1099
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1004
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1100
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1005
1101
|
} else {
|
|
1006
1102
|
const clean = producer(set);
|
|
1007
1103
|
onCleanup(clean);
|
|
@@ -1053,8 +1149,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1053
1149
|
});
|
|
1054
1150
|
len = 1;
|
|
1055
1151
|
}
|
|
1056
|
-
}
|
|
1057
|
-
else if (len === 0) {
|
|
1152
|
+
} else if (len === 0) {
|
|
1058
1153
|
mapped = new Array(newLen);
|
|
1059
1154
|
for (j = 0; j < newLen; j++) {
|
|
1060
1155
|
items[j] = newItems[j];
|
|
@@ -1065,8 +1160,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1065
1160
|
temp = new Array(newLen);
|
|
1066
1161
|
tempdisposers = new Array(newLen);
|
|
1067
1162
|
indexes && (tempIndexes = new Array(newLen));
|
|
1068
|
-
for (
|
|
1069
|
-
|
|
1163
|
+
for (
|
|
1164
|
+
start = 0, end = Math.min(len, newLen);
|
|
1165
|
+
start < end && items[start] === newItems[start];
|
|
1166
|
+
start++
|
|
1167
|
+
);
|
|
1168
|
+
for (
|
|
1169
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1170
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1171
|
+
end--, newEnd--
|
|
1172
|
+
) {
|
|
1070
1173
|
temp[newEnd] = mapped[end];
|
|
1071
1174
|
tempdisposers[newEnd] = disposers[end];
|
|
1072
1175
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1100,7 +1203,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1100
1203
|
}
|
|
1101
1204
|
} else mapped[j] = createRoot(mapper);
|
|
1102
1205
|
}
|
|
1103
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1206
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1104
1207
|
items = newItems.slice(0);
|
|
1105
1208
|
}
|
|
1106
1209
|
return mapped;
|
|
@@ -1166,7 +1269,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1166
1269
|
}
|
|
1167
1270
|
len = signals.length = disposers.length = newItems.length;
|
|
1168
1271
|
items = newItems.slice(0);
|
|
1169
|
-
return mapped = mapped.slice(0, len);
|
|
1272
|
+
return (mapped = mapped.slice(0, len));
|
|
1170
1273
|
});
|
|
1171
1274
|
function mapper(disposer) {
|
|
1172
1275
|
disposers[i] = disposer;
|
|
@@ -1235,29 +1338,33 @@ function mergeProps(...sources) {
|
|
|
1235
1338
|
let proxy = false;
|
|
1236
1339
|
for (let i = 0; i < sources.length; i++) {
|
|
1237
1340
|
const s = sources[i];
|
|
1238
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1239
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1341
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1342
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1240
1343
|
}
|
|
1241
1344
|
if (proxy) {
|
|
1242
|
-
return new Proxy(
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1345
|
+
return new Proxy(
|
|
1346
|
+
{
|
|
1347
|
+
get(property) {
|
|
1348
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1349
|
+
const v = resolveSource(sources[i])[property];
|
|
1350
|
+
if (v !== undefined) return v;
|
|
1351
|
+
}
|
|
1352
|
+
},
|
|
1353
|
+
has(property) {
|
|
1354
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1355
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1356
|
+
}
|
|
1357
|
+
return false;
|
|
1358
|
+
},
|
|
1359
|
+
keys() {
|
|
1360
|
+
const keys = [];
|
|
1361
|
+
for (let i = 0; i < sources.length; i++)
|
|
1362
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1363
|
+
return [...new Set(keys)];
|
|
1252
1364
|
}
|
|
1253
|
-
return false;
|
|
1254
1365
|
},
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1258
|
-
return [...new Set(keys)];
|
|
1259
|
-
}
|
|
1260
|
-
}, propTraps);
|
|
1366
|
+
propTraps
|
|
1367
|
+
);
|
|
1261
1368
|
}
|
|
1262
1369
|
const target = {};
|
|
1263
1370
|
const sourcesMap = {};
|
|
@@ -1276,7 +1383,7 @@ function mergeProps(...sources) {
|
|
|
1276
1383
|
Object.defineProperty(target, key, {
|
|
1277
1384
|
enumerable: true,
|
|
1278
1385
|
configurable: true,
|
|
1279
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1386
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1280
1387
|
});
|
|
1281
1388
|
} else {
|
|
1282
1389
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1300,47 +1407,60 @@ function splitProps(props, ...keys) {
|
|
|
1300
1407
|
if ($PROXY in props) {
|
|
1301
1408
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1302
1409
|
const res = keys.map(k => {
|
|
1303
|
-
return new Proxy(
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1410
|
+
return new Proxy(
|
|
1411
|
+
{
|
|
1412
|
+
get(property) {
|
|
1413
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1414
|
+
},
|
|
1415
|
+
has(property) {
|
|
1416
|
+
return k.includes(property) && property in props;
|
|
1417
|
+
},
|
|
1418
|
+
keys() {
|
|
1419
|
+
return k.filter(property => property in props);
|
|
1420
|
+
}
|
|
1309
1421
|
},
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
}
|
|
1313
|
-
}, propTraps);
|
|
1422
|
+
propTraps
|
|
1423
|
+
);
|
|
1314
1424
|
});
|
|
1315
|
-
res.push(
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1425
|
+
res.push(
|
|
1426
|
+
new Proxy(
|
|
1427
|
+
{
|
|
1428
|
+
get(property) {
|
|
1429
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1430
|
+
},
|
|
1431
|
+
has(property) {
|
|
1432
|
+
return blocked.has(property) ? false : property in props;
|
|
1433
|
+
},
|
|
1434
|
+
keys() {
|
|
1435
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1436
|
+
}
|
|
1437
|
+
},
|
|
1438
|
+
propTraps
|
|
1439
|
+
)
|
|
1440
|
+
);
|
|
1326
1441
|
return res;
|
|
1327
1442
|
}
|
|
1328
1443
|
const otherObject = {};
|
|
1329
1444
|
const objects = keys.map(() => ({}));
|
|
1330
1445
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1331
1446
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1332
|
-
const isDefaultDesc =
|
|
1447
|
+
const isDefaultDesc =
|
|
1448
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1333
1449
|
let blocked = false;
|
|
1334
1450
|
let objectIndex = 0;
|
|
1335
1451
|
for (const k of keys) {
|
|
1336
1452
|
if (k.includes(propName)) {
|
|
1337
1453
|
blocked = true;
|
|
1338
|
-
isDefaultDesc
|
|
1454
|
+
isDefaultDesc
|
|
1455
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1456
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1339
1457
|
}
|
|
1340
1458
|
++objectIndex;
|
|
1341
1459
|
}
|
|
1342
1460
|
if (!blocked) {
|
|
1343
|
-
isDefaultDesc
|
|
1461
|
+
isDefaultDesc
|
|
1462
|
+
? (otherObject[propName] = desc.value)
|
|
1463
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1344
1464
|
}
|
|
1345
1465
|
}
|
|
1346
1466
|
return [...objects, otherObject];
|
|
@@ -1352,8 +1472,11 @@ function lazy(fn) {
|
|
|
1352
1472
|
const ctx = sharedConfig.context;
|
|
1353
1473
|
if (ctx) {
|
|
1354
1474
|
const [s, set] = createSignal();
|
|
1475
|
+
sharedConfig.count || (sharedConfig.count = 0);
|
|
1476
|
+
sharedConfig.count++;
|
|
1355
1477
|
(p || (p = fn())).then(mod => {
|
|
1356
1478
|
setHydrateContext(ctx);
|
|
1479
|
+
sharedConfig.count--;
|
|
1357
1480
|
set(() => mod.default);
|
|
1358
1481
|
setHydrateContext();
|
|
1359
1482
|
});
|
|
@@ -1363,17 +1486,21 @@ function lazy(fn) {
|
|
|
1363
1486
|
comp = s;
|
|
1364
1487
|
}
|
|
1365
1488
|
let Comp;
|
|
1366
|
-
return createMemo(
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1489
|
+
return createMemo(
|
|
1490
|
+
() =>
|
|
1491
|
+
(Comp = comp()) &&
|
|
1492
|
+
untrack(() => {
|
|
1493
|
+
if (false);
|
|
1494
|
+
if (!ctx) return Comp(props);
|
|
1495
|
+
const c = sharedConfig.context;
|
|
1496
|
+
setHydrateContext(ctx);
|
|
1497
|
+
const r = Comp(props);
|
|
1498
|
+
setHydrateContext(c);
|
|
1499
|
+
return r;
|
|
1500
|
+
})
|
|
1501
|
+
);
|
|
1375
1502
|
};
|
|
1376
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1503
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1377
1504
|
return wrap;
|
|
1378
1505
|
}
|
|
1379
1506
|
let counter = 0;
|
|
@@ -1398,49 +1525,78 @@ function Index(props) {
|
|
|
1398
1525
|
function Show(props) {
|
|
1399
1526
|
const keyed = props.keyed;
|
|
1400
1527
|
const condition = createMemo(() => props.when, undefined, {
|
|
1401
|
-
equals: (a, b) => keyed ? a === b : !a === !b
|
|
1528
|
+
equals: (a, b) => (keyed ? a === b : !a === !b)
|
|
1402
1529
|
});
|
|
1403
|
-
return createMemo(
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1530
|
+
return createMemo(
|
|
1531
|
+
() => {
|
|
1532
|
+
const c = condition();
|
|
1533
|
+
if (c) {
|
|
1534
|
+
const child = props.children;
|
|
1535
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1536
|
+
return fn
|
|
1537
|
+
? untrack(() =>
|
|
1538
|
+
child(
|
|
1539
|
+
keyed
|
|
1540
|
+
? c
|
|
1541
|
+
: () => {
|
|
1542
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1543
|
+
return props.when;
|
|
1544
|
+
}
|
|
1545
|
+
)
|
|
1546
|
+
)
|
|
1547
|
+
: child;
|
|
1548
|
+
}
|
|
1549
|
+
return props.fallback;
|
|
1550
|
+
},
|
|
1551
|
+
undefined,
|
|
1552
|
+
undefined
|
|
1553
|
+
);
|
|
1415
1554
|
}
|
|
1416
1555
|
function Switch(props) {
|
|
1417
1556
|
let keyed = false;
|
|
1418
|
-
const equals = (a, b) =>
|
|
1557
|
+
const equals = (a, b) =>
|
|
1558
|
+
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1419
1559
|
const conditions = children(() => props.children),
|
|
1420
|
-
evalConditions = createMemo(
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1560
|
+
evalConditions = createMemo(
|
|
1561
|
+
() => {
|
|
1562
|
+
let conds = conditions();
|
|
1563
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1564
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1565
|
+
const c = conds[i].when;
|
|
1566
|
+
if (c) {
|
|
1567
|
+
keyed = !!conds[i].keyed;
|
|
1568
|
+
return [i, c, conds[i]];
|
|
1569
|
+
}
|
|
1428
1570
|
}
|
|
1571
|
+
return [-1];
|
|
1572
|
+
},
|
|
1573
|
+
undefined,
|
|
1574
|
+
{
|
|
1575
|
+
equals
|
|
1429
1576
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1577
|
+
);
|
|
1578
|
+
return createMemo(
|
|
1579
|
+
() => {
|
|
1580
|
+
const [index, when, cond] = evalConditions();
|
|
1581
|
+
if (index < 0) return props.fallback;
|
|
1582
|
+
const c = cond.children;
|
|
1583
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1584
|
+
return fn
|
|
1585
|
+
? untrack(() =>
|
|
1586
|
+
c(
|
|
1587
|
+
keyed
|
|
1588
|
+
? when
|
|
1589
|
+
: () => {
|
|
1590
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1591
|
+
return cond.when;
|
|
1592
|
+
}
|
|
1593
|
+
)
|
|
1594
|
+
)
|
|
1595
|
+
: c;
|
|
1596
|
+
},
|
|
1597
|
+
undefined,
|
|
1598
|
+
undefined
|
|
1599
|
+
);
|
|
1444
1600
|
}
|
|
1445
1601
|
function Match(props) {
|
|
1446
1602
|
return props;
|
|
@@ -1452,22 +1608,32 @@ function resetErrorBoundaries() {
|
|
|
1452
1608
|
function ErrorBoundary(props) {
|
|
1453
1609
|
let err;
|
|
1454
1610
|
let v;
|
|
1455
|
-
if (
|
|
1611
|
+
if (
|
|
1612
|
+
sharedConfig.context &&
|
|
1613
|
+
sharedConfig.load &&
|
|
1614
|
+
(v = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count))
|
|
1615
|
+
)
|
|
1616
|
+
err = v[0];
|
|
1456
1617
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1457
1618
|
Errors || (Errors = new Set());
|
|
1458
1619
|
Errors.add(setErrored);
|
|
1459
1620
|
onCleanup(() => Errors.delete(setErrored));
|
|
1460
|
-
return createMemo(
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1621
|
+
return createMemo(
|
|
1622
|
+
() => {
|
|
1623
|
+
let e;
|
|
1624
|
+
if ((e = errored())) {
|
|
1625
|
+
const f = props.fallback;
|
|
1626
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1627
|
+
}
|
|
1628
|
+
return catchError(() => props.children, setErrored);
|
|
1629
|
+
},
|
|
1630
|
+
undefined,
|
|
1631
|
+
undefined
|
|
1632
|
+
);
|
|
1468
1633
|
}
|
|
1469
1634
|
|
|
1470
|
-
const suspenseListEquals = (a, b) =>
|
|
1635
|
+
const suspenseListEquals = (a, b) =>
|
|
1636
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1471
1637
|
const SuspenseListContext = createContext();
|
|
1472
1638
|
function SuspenseList(props) {
|
|
1473
1639
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1479,51 +1645,51 @@ function SuspenseList(props) {
|
|
|
1479
1645
|
if (listContext) {
|
|
1480
1646
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1481
1647
|
}
|
|
1482
|
-
const resolved = createMemo(
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
showContent = true,
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
const res = reg.map(() => ({
|
|
1494
|
-
showContent: all && showContent,
|
|
1495
|
-
showFallback
|
|
1496
|
-
}));
|
|
1497
|
-
res.inFallback = !all;
|
|
1498
|
-
return res;
|
|
1499
|
-
}
|
|
1500
|
-
let stop = false;
|
|
1501
|
-
let inFallback = prev.inFallback;
|
|
1502
|
-
const res = [];
|
|
1503
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1504
|
-
const n = reverse ? len - i - 1 : i,
|
|
1505
|
-
s = reg[n]();
|
|
1506
|
-
if (!stop && !s) {
|
|
1507
|
-
res[n] = {
|
|
1508
|
-
showContent,
|
|
1648
|
+
const resolved = createMemo(
|
|
1649
|
+
prev => {
|
|
1650
|
+
const reveal = props.revealOrder,
|
|
1651
|
+
tail = props.tail,
|
|
1652
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1653
|
+
reg = registry(),
|
|
1654
|
+
reverse = reveal === "backwards";
|
|
1655
|
+
if (reveal === "together") {
|
|
1656
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1657
|
+
const res = reg.map(() => ({
|
|
1658
|
+
showContent: all && showContent,
|
|
1509
1659
|
showFallback
|
|
1510
|
-
};
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
if (next) inFallback = true;
|
|
1514
|
-
res[n] = {
|
|
1515
|
-
showContent: next,
|
|
1516
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1517
|
-
};
|
|
1518
|
-
stop = true;
|
|
1660
|
+
}));
|
|
1661
|
+
res.inFallback = !all;
|
|
1662
|
+
return res;
|
|
1519
1663
|
}
|
|
1664
|
+
let stop = false;
|
|
1665
|
+
let inFallback = prev.inFallback;
|
|
1666
|
+
const res = [];
|
|
1667
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1668
|
+
const n = reverse ? len - i - 1 : i,
|
|
1669
|
+
s = reg[n]();
|
|
1670
|
+
if (!stop && !s) {
|
|
1671
|
+
res[n] = {
|
|
1672
|
+
showContent,
|
|
1673
|
+
showFallback
|
|
1674
|
+
};
|
|
1675
|
+
} else {
|
|
1676
|
+
const next = !stop;
|
|
1677
|
+
if (next) inFallback = true;
|
|
1678
|
+
res[n] = {
|
|
1679
|
+
showContent: next,
|
|
1680
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1681
|
+
};
|
|
1682
|
+
stop = true;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
if (!stop) inFallback = false;
|
|
1686
|
+
res.inFallback = inFallback;
|
|
1687
|
+
return res;
|
|
1688
|
+
},
|
|
1689
|
+
{
|
|
1690
|
+
inFallback: false
|
|
1520
1691
|
}
|
|
1521
|
-
|
|
1522
|
-
res.inFallback = inFallback;
|
|
1523
|
-
return res;
|
|
1524
|
-
}, {
|
|
1525
|
-
inFallback: false
|
|
1526
|
-
});
|
|
1692
|
+
);
|
|
1527
1693
|
setWrapper(() => resolved);
|
|
1528
1694
|
return createComponent(SuspenseListContext.Provider, {
|
|
1529
1695
|
value: {
|
|
@@ -1597,17 +1763,14 @@ function Suspense(props) {
|
|
|
1597
1763
|
ctx = sharedConfig.context;
|
|
1598
1764
|
if (flicker) {
|
|
1599
1765
|
flicker();
|
|
1600
|
-
return flicker = undefined;
|
|
1766
|
+
return (flicker = undefined);
|
|
1601
1767
|
}
|
|
1602
1768
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1603
1769
|
const rendered = createMemo(() => props.children);
|
|
1604
1770
|
return createMemo(prev => {
|
|
1605
1771
|
const inFallback = store.inFallback(),
|
|
1606
|
-
{
|
|
1607
|
-
|
|
1608
|
-
showFallback = true
|
|
1609
|
-
} = show ? show() : {};
|
|
1610
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1772
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1773
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1611
1774
|
store.resolved = true;
|
|
1612
1775
|
dispose && dispose();
|
|
1613
1776
|
dispose = ctx = p = undefined;
|
|
@@ -1635,4 +1798,59 @@ function Suspense(props) {
|
|
|
1635
1798
|
|
|
1636
1799
|
const DEV = undefined;
|
|
1637
1800
|
|
|
1638
|
-
export {
|
|
1801
|
+
export {
|
|
1802
|
+
$DEVCOMP,
|
|
1803
|
+
$PROXY,
|
|
1804
|
+
$TRACK,
|
|
1805
|
+
DEV,
|
|
1806
|
+
ErrorBoundary,
|
|
1807
|
+
For,
|
|
1808
|
+
Index,
|
|
1809
|
+
Match,
|
|
1810
|
+
Show,
|
|
1811
|
+
Suspense,
|
|
1812
|
+
SuspenseList,
|
|
1813
|
+
Switch,
|
|
1814
|
+
batch,
|
|
1815
|
+
cancelCallback,
|
|
1816
|
+
catchError,
|
|
1817
|
+
children,
|
|
1818
|
+
createComponent,
|
|
1819
|
+
createComputed,
|
|
1820
|
+
createContext,
|
|
1821
|
+
createDeferred,
|
|
1822
|
+
createEffect,
|
|
1823
|
+
createMemo,
|
|
1824
|
+
createReaction,
|
|
1825
|
+
createRenderEffect,
|
|
1826
|
+
createResource,
|
|
1827
|
+
createRoot,
|
|
1828
|
+
createSelector,
|
|
1829
|
+
createSignal,
|
|
1830
|
+
createUniqueId,
|
|
1831
|
+
enableExternalSource,
|
|
1832
|
+
enableHydration,
|
|
1833
|
+
enableScheduling,
|
|
1834
|
+
equalFn,
|
|
1835
|
+
from,
|
|
1836
|
+
getListener,
|
|
1837
|
+
getOwner,
|
|
1838
|
+
indexArray,
|
|
1839
|
+
lazy,
|
|
1840
|
+
mapArray,
|
|
1841
|
+
mergeProps,
|
|
1842
|
+
observable,
|
|
1843
|
+
on,
|
|
1844
|
+
onCleanup,
|
|
1845
|
+
onError,
|
|
1846
|
+
onMount,
|
|
1847
|
+
requestCallback,
|
|
1848
|
+
resetErrorBoundaries,
|
|
1849
|
+
runWithOwner,
|
|
1850
|
+
sharedConfig,
|
|
1851
|
+
splitProps,
|
|
1852
|
+
startTransition,
|
|
1853
|
+
untrack,
|
|
1854
|
+
useContext,
|
|
1855
|
+
useTransition
|
|
1856
|
+
};
|