solid-js 1.8.11 → 1.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +544 -307
- package/dist/server.js +170 -75
- package/dist/solid.js +471 -265
- 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 +47 -33
- package/package.json +9 -4
- package/store/dist/dev.cjs +12 -2
- package/store/dist/dev.js +133 -44
- package/store/dist/server.js +19 -8
- package/store/dist/store.cjs +12 -2
- package/store/dist/store.js +124 -41
- 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/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 +13 -13
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +167 -96
- 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 +3 -0
- package/web/dist/dev.js +625 -81
- package/web/dist/server.cjs +10 -15
- package/web/dist/server.js +216 -107
- package/web/dist/web.js +614 -80
- package/web/storage/dist/storage.js +10 -0
- package/web/storage/package.json +15 -0
- package/web/storage/types/index.d.ts +2 -0
- package/web/storage/types/index.js +13 -0
- 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/web/dist/storage.js +0 -10
- package/web/types/storage.d.ts +0 -2
- /package/web/{dist → storage/dist}/storage.cjs +0 -0
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
|
}
|
|
@@ -160,12 +162,14 @@ function createRoot(fn, detachedOwner) {
|
|
|
160
162
|
owner = Owner,
|
|
161
163
|
unowned = fn.length === 0,
|
|
162
164
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
163
|
-
root = unowned
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
root = unowned
|
|
166
|
+
? UNOWNED
|
|
167
|
+
: {
|
|
168
|
+
owned: null,
|
|
169
|
+
cleanups: null,
|
|
170
|
+
context: current ? current.context : null,
|
|
171
|
+
owner: current
|
|
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 && useContext(SuspenseContext);
|
|
218
230
|
if (s) c.suspense = s;
|
|
219
231
|
c.user = true;
|
|
@@ -241,7 +253,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
241
253
|
let source;
|
|
242
254
|
let fetcher;
|
|
243
255
|
let options;
|
|
244
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
256
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
245
257
|
source = true;
|
|
246
258
|
fetcher = pSource;
|
|
247
259
|
options = pFetcher || {};
|
|
@@ -255,7 +267,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
255
267
|
id = null,
|
|
256
268
|
loadedUnderTransition = false,
|
|
257
269
|
scheduled = false,
|
|
258
|
-
resolved =
|
|
270
|
+
resolved = "initialValue" in options,
|
|
259
271
|
dynamic = typeof source === "function" && createMemo(source);
|
|
260
272
|
const contexts = new Set(),
|
|
261
273
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -267,15 +279,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
267
279
|
if (sharedConfig.context) {
|
|
268
280
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
269
281
|
let v;
|
|
270
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
282
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
283
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
|
|
271
284
|
}
|
|
272
285
|
function loadEnd(p, v, error, key) {
|
|
273
286
|
if (pr === p) {
|
|
274
287
|
pr = null;
|
|
275
288
|
key !== undefined && (resolved = true);
|
|
276
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
277
|
-
|
|
278
|
-
|
|
289
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
290
|
+
queueMicrotask(() =>
|
|
291
|
+
options.onHydrated(key, {
|
|
292
|
+
value: v
|
|
293
|
+
})
|
|
294
|
+
);
|
|
279
295
|
initP = NO_INIT;
|
|
280
296
|
if (Transition && p && loadedUnderTransition) {
|
|
281
297
|
Transition.promises.delete(p);
|
|
@@ -306,7 +322,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
306
322
|
createComputed(() => {
|
|
307
323
|
track();
|
|
308
324
|
if (pr) {
|
|
309
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
325
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
326
|
+
else if (!contexts.has(c)) {
|
|
310
327
|
c.increment();
|
|
311
328
|
contexts.add(c);
|
|
312
329
|
}
|
|
@@ -325,26 +342,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
325
342
|
return;
|
|
326
343
|
}
|
|
327
344
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
328
|
-
const p =
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
345
|
+
const p =
|
|
346
|
+
initP !== NO_INIT
|
|
347
|
+
? initP
|
|
348
|
+
: untrack(() =>
|
|
349
|
+
fetcher(lookup, {
|
|
350
|
+
value: value(),
|
|
351
|
+
refetching
|
|
352
|
+
})
|
|
353
|
+
);
|
|
332
354
|
if (!isPromise(p)) {
|
|
333
355
|
loadEnd(pr, p, undefined, lookup);
|
|
334
356
|
return p;
|
|
335
357
|
}
|
|
336
358
|
pr = p;
|
|
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
|
scheduled = true;
|
|
342
|
-
queueMicrotask(() => scheduled = false);
|
|
365
|
+
queueMicrotask(() => (scheduled = false));
|
|
343
366
|
runUpdates(() => {
|
|
344
367
|
setState(resolved ? "refreshing" : "pending");
|
|
345
368
|
trigger();
|
|
346
369
|
}, false);
|
|
347
|
-
return p.then(
|
|
370
|
+
return p.then(
|
|
371
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
372
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
373
|
+
);
|
|
348
374
|
}
|
|
349
375
|
Object.defineProperties(read, {
|
|
350
376
|
state: {
|
|
@@ -368,50 +394,80 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
368
394
|
}
|
|
369
395
|
}
|
|
370
396
|
});
|
|
371
|
-
if (dynamic) createComputed(() => load(false));
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
397
|
+
if (dynamic) createComputed(() => load(false));
|
|
398
|
+
else load(false);
|
|
399
|
+
return [
|
|
400
|
+
read,
|
|
401
|
+
{
|
|
402
|
+
refetch: load,
|
|
403
|
+
mutate: setValue
|
|
404
|
+
}
|
|
405
|
+
];
|
|
376
406
|
}
|
|
377
407
|
function createDeferred(source, options) {
|
|
378
408
|
let t,
|
|
379
409
|
timeout = options ? options.timeoutMs : undefined;
|
|
380
|
-
const node = createComputation(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
410
|
+
const node = createComputation(
|
|
411
|
+
() => {
|
|
412
|
+
if (!t || !t.fn)
|
|
413
|
+
t = requestCallback(
|
|
414
|
+
() => setDeferred(() => node.value),
|
|
415
|
+
timeout !== undefined
|
|
416
|
+
? {
|
|
417
|
+
timeout
|
|
418
|
+
}
|
|
419
|
+
: undefined
|
|
420
|
+
);
|
|
421
|
+
return source();
|
|
422
|
+
},
|
|
423
|
+
undefined,
|
|
424
|
+
true
|
|
425
|
+
);
|
|
426
|
+
const [deferred, setDeferred] = createSignal(
|
|
427
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
428
|
+
options
|
|
429
|
+
);
|
|
387
430
|
updateComputation(node);
|
|
388
|
-
setDeferred(() =>
|
|
431
|
+
setDeferred(() =>
|
|
432
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
433
|
+
);
|
|
389
434
|
return deferred;
|
|
390
435
|
}
|
|
391
436
|
function createSelector(source, fn = equalFn, options) {
|
|
392
437
|
const subs = new Map();
|
|
393
|
-
const node = createComputation(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
for (const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
438
|
+
const node = createComputation(
|
|
439
|
+
p => {
|
|
440
|
+
const v = source();
|
|
441
|
+
for (const [key, val] of subs.entries())
|
|
442
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
443
|
+
for (const c of val.values()) {
|
|
444
|
+
c.state = STALE;
|
|
445
|
+
if (c.pure) Updates.push(c);
|
|
446
|
+
else Effects.push(c);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return v;
|
|
450
|
+
},
|
|
451
|
+
undefined,
|
|
452
|
+
true,
|
|
453
|
+
STALE
|
|
454
|
+
);
|
|
403
455
|
updateComputation(node);
|
|
404
456
|
return key => {
|
|
405
457
|
const listener = Listener;
|
|
406
458
|
if (listener) {
|
|
407
459
|
let l;
|
|
408
|
-
if (l = subs.get(key)) l.add(listener);
|
|
460
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
461
|
+
else subs.set(key, (l = new Set([listener])));
|
|
409
462
|
onCleanup(() => {
|
|
410
463
|
l.delete(listener);
|
|
411
464
|
!l.size && subs.delete(key);
|
|
412
465
|
});
|
|
413
466
|
}
|
|
414
|
-
return fn(
|
|
467
|
+
return fn(
|
|
468
|
+
key,
|
|
469
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
470
|
+
);
|
|
415
471
|
};
|
|
416
472
|
}
|
|
417
473
|
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);
|
|
@@ -521,7 +581,7 @@ function startTransition(fn) {
|
|
|
521
581
|
return t ? t.done : undefined;
|
|
522
582
|
});
|
|
523
583
|
}
|
|
524
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
584
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
525
585
|
function useTransition() {
|
|
526
586
|
return [transPending, startTransition];
|
|
527
587
|
}
|
|
@@ -538,7 +598,9 @@ function createContext(defaultValue, options) {
|
|
|
538
598
|
};
|
|
539
599
|
}
|
|
540
600
|
function useContext(context) {
|
|
541
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
601
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
602
|
+
? Owner.context[context.id]
|
|
603
|
+
: context.defaultValue;
|
|
542
604
|
}
|
|
543
605
|
function children(fn) {
|
|
544
606
|
const children = createMemo(fn);
|
|
@@ -555,10 +617,7 @@ function getSuspenseContext() {
|
|
|
555
617
|
}
|
|
556
618
|
function enableExternalSource(factory, untrack = fn => fn()) {
|
|
557
619
|
if (ExternalSourceConfig) {
|
|
558
|
-
const {
|
|
559
|
-
factory: oldFactory,
|
|
560
|
-
untrack: oldUntrack
|
|
561
|
-
} = ExternalSourceConfig;
|
|
620
|
+
const { factory: oldFactory, untrack: oldUntrack } = ExternalSourceConfig;
|
|
562
621
|
ExternalSourceConfig = {
|
|
563
622
|
factory: (fn, trigger) => {
|
|
564
623
|
const oldSource = oldFactory(fn, trigger);
|
|
@@ -583,7 +642,8 @@ function enableExternalSource(factory, untrack = fn => fn()) {
|
|
|
583
642
|
function readSignal() {
|
|
584
643
|
const runningTransition = Transition && Transition.running;
|
|
585
644
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
586
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
645
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
646
|
+
else {
|
|
587
647
|
const updates = Updates;
|
|
588
648
|
Updates = null;
|
|
589
649
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -611,11 +671,12 @@ function readSignal() {
|
|
|
611
671
|
return this.value;
|
|
612
672
|
}
|
|
613
673
|
function writeSignal(node, value, isComp) {
|
|
614
|
-
let current =
|
|
674
|
+
let current =
|
|
675
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
615
676
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
616
677
|
if (Transition) {
|
|
617
678
|
const TransitionRunning = Transition.running;
|
|
618
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
679
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
619
680
|
Transition.sources.add(node);
|
|
620
681
|
node.tValue = value;
|
|
621
682
|
}
|
|
@@ -628,14 +689,16 @@ function writeSignal(node, value, isComp) {
|
|
|
628
689
|
const TransitionRunning = Transition && Transition.running;
|
|
629
690
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
630
691
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
631
|
-
if (o.pure) Updates.push(o);
|
|
692
|
+
if (o.pure) Updates.push(o);
|
|
693
|
+
else Effects.push(o);
|
|
632
694
|
if (o.observers) markDownstream(o);
|
|
633
695
|
}
|
|
634
|
-
if (!TransitionRunning) o.state = STALE;
|
|
696
|
+
if (!TransitionRunning) o.state = STALE;
|
|
697
|
+
else o.tState = STALE;
|
|
635
698
|
}
|
|
636
699
|
if (Updates.length > 10e5) {
|
|
637
700
|
Updates = [];
|
|
638
|
-
if (false)
|
|
701
|
+
if (false);
|
|
639
702
|
throw new Error();
|
|
640
703
|
}
|
|
641
704
|
}, false);
|
|
@@ -647,7 +710,11 @@ function updateComputation(node) {
|
|
|
647
710
|
if (!node.fn) return;
|
|
648
711
|
cleanNode(node);
|
|
649
712
|
const time = ExecCount;
|
|
650
|
-
runComputation(
|
|
713
|
+
runComputation(
|
|
714
|
+
node,
|
|
715
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
716
|
+
time
|
|
717
|
+
);
|
|
651
718
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
652
719
|
queueMicrotask(() => {
|
|
653
720
|
runUpdates(() => {
|
|
@@ -712,11 +779,14 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
712
779
|
c.state = 0;
|
|
713
780
|
c.tState = state;
|
|
714
781
|
}
|
|
715
|
-
if (Owner === null)
|
|
782
|
+
if (Owner === null);
|
|
783
|
+
else if (Owner !== UNOWNED) {
|
|
716
784
|
if (Transition && Transition.running && Owner.pure) {
|
|
717
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
785
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
786
|
+
else Owner.tOwned.push(c);
|
|
718
787
|
} else {
|
|
719
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
788
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
789
|
+
else Owner.owned.push(c);
|
|
720
790
|
}
|
|
721
791
|
}
|
|
722
792
|
if (ExternalSourceConfig && c.fn) {
|
|
@@ -767,7 +837,8 @@ function runUpdates(fn, init) {
|
|
|
767
837
|
if (Updates) return fn();
|
|
768
838
|
let wait = false;
|
|
769
839
|
if (!init) Updates = [];
|
|
770
|
-
if (Effects) wait = true;
|
|
840
|
+
if (Effects) wait = true;
|
|
841
|
+
else Effects = [];
|
|
771
842
|
ExecCount++;
|
|
772
843
|
try {
|
|
773
844
|
const res = fn();
|
|
@@ -781,7 +852,8 @@ function runUpdates(fn, init) {
|
|
|
781
852
|
}
|
|
782
853
|
function completeUpdates(wait) {
|
|
783
854
|
if (Updates) {
|
|
784
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
855
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
856
|
+
else runQueue(Updates);
|
|
785
857
|
Updates = null;
|
|
786
858
|
}
|
|
787
859
|
if (wait) return;
|
|
@@ -849,7 +921,8 @@ function runUserEffects(queue) {
|
|
|
849
921
|
userLength = 0;
|
|
850
922
|
for (i = 0; i < queue.length; i++) {
|
|
851
923
|
const e = queue[i];
|
|
852
|
-
if (!e.user) runTop(e);
|
|
924
|
+
if (!e.user) runTop(e);
|
|
925
|
+
else queue[userLength++] = e;
|
|
853
926
|
}
|
|
854
927
|
if (sharedConfig.context) {
|
|
855
928
|
if (sharedConfig.count) {
|
|
@@ -867,13 +940,15 @@ function runUserEffects(queue) {
|
|
|
867
940
|
}
|
|
868
941
|
function lookUpstream(node, ignore) {
|
|
869
942
|
const runningTransition = Transition && Transition.running;
|
|
870
|
-
if (runningTransition) node.tState = 0;
|
|
943
|
+
if (runningTransition) node.tState = 0;
|
|
944
|
+
else node.state = 0;
|
|
871
945
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
872
946
|
const source = node.sources[i];
|
|
873
947
|
if (source.sources) {
|
|
874
948
|
const state = runningTransition ? source.tState : source.state;
|
|
875
949
|
if (state === STALE) {
|
|
876
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
950
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
951
|
+
runTop(source);
|
|
877
952
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
878
953
|
}
|
|
879
954
|
}
|
|
@@ -883,8 +958,10 @@ function markDownstream(node) {
|
|
|
883
958
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
884
959
|
const o = node.observers[i];
|
|
885
960
|
if (runningTransition ? !o.tState : !o.state) {
|
|
886
|
-
if (runningTransition) o.tState = PENDING;
|
|
887
|
-
|
|
961
|
+
if (runningTransition) o.tState = PENDING;
|
|
962
|
+
else o.state = PENDING;
|
|
963
|
+
if (o.pure) Updates.push(o);
|
|
964
|
+
else Effects.push(o);
|
|
888
965
|
o.observers && markDownstream(o);
|
|
889
966
|
}
|
|
890
967
|
}
|
|
@@ -921,7 +998,8 @@ function cleanNode(node) {
|
|
|
921
998
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
922
999
|
node.cleanups = null;
|
|
923
1000
|
}
|
|
924
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1001
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1002
|
+
else node.state = 0;
|
|
925
1003
|
}
|
|
926
1004
|
function reset(node, top) {
|
|
927
1005
|
if (!top) {
|
|
@@ -942,19 +1020,21 @@ function runErrors(err, fns, owner) {
|
|
|
942
1020
|
try {
|
|
943
1021
|
for (const f of fns) f(err);
|
|
944
1022
|
} catch (e) {
|
|
945
|
-
handleError(e, owner && owner.owner || null);
|
|
1023
|
+
handleError(e, (owner && owner.owner) || null);
|
|
946
1024
|
}
|
|
947
1025
|
}
|
|
948
1026
|
function handleError(err, owner = Owner) {
|
|
949
1027
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
950
1028
|
const error = castError(err);
|
|
951
1029
|
if (!fns) throw error;
|
|
952
|
-
if (Effects)
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1030
|
+
if (Effects)
|
|
1031
|
+
Effects.push({
|
|
1032
|
+
fn() {
|
|
1033
|
+
runErrors(error, fns, owner);
|
|
1034
|
+
},
|
|
1035
|
+
state: STALE
|
|
1036
|
+
});
|
|
1037
|
+
else runErrors(error, fns, owner);
|
|
958
1038
|
}
|
|
959
1039
|
function resolveChildren(children) {
|
|
960
1040
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -971,19 +1051,24 @@ function resolveChildren(children) {
|
|
|
971
1051
|
function createProvider(id, options) {
|
|
972
1052
|
return function provider(props) {
|
|
973
1053
|
let res;
|
|
974
|
-
createRenderEffect(
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1054
|
+
createRenderEffect(
|
|
1055
|
+
() =>
|
|
1056
|
+
(res = untrack(() => {
|
|
1057
|
+
Owner.context = {
|
|
1058
|
+
...Owner.context,
|
|
1059
|
+
[id]: props.value
|
|
1060
|
+
};
|
|
1061
|
+
return children(() => props.children);
|
|
1062
|
+
})),
|
|
1063
|
+
undefined
|
|
1064
|
+
);
|
|
981
1065
|
return res;
|
|
982
1066
|
};
|
|
983
1067
|
}
|
|
984
1068
|
function onError(fn) {
|
|
985
1069
|
ERROR || (ERROR = Symbol("error"));
|
|
986
|
-
if (Owner === null)
|
|
1070
|
+
if (Owner === null);
|
|
1071
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
987
1072
|
Owner.context = {
|
|
988
1073
|
...Owner.context,
|
|
989
1074
|
[ERROR]: [fn]
|
|
@@ -1012,7 +1097,8 @@ function observable(input) {
|
|
|
1012
1097
|
if (!(observer instanceof Object) || observer == null) {
|
|
1013
1098
|
throw new TypeError("Expected the observer to be an object.");
|
|
1014
1099
|
}
|
|
1015
|
-
const handler =
|
|
1100
|
+
const handler =
|
|
1101
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1016
1102
|
if (!handler) {
|
|
1017
1103
|
return {
|
|
1018
1104
|
unsubscribe() {}
|
|
@@ -1043,7 +1129,7 @@ function from(producer) {
|
|
|
1043
1129
|
});
|
|
1044
1130
|
if ("subscribe" in producer) {
|
|
1045
1131
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1046
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1132
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1047
1133
|
} else {
|
|
1048
1134
|
const clean = producer(set);
|
|
1049
1135
|
onCleanup(clean);
|
|
@@ -1095,8 +1181,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1095
1181
|
});
|
|
1096
1182
|
len = 1;
|
|
1097
1183
|
}
|
|
1098
|
-
}
|
|
1099
|
-
else if (len === 0) {
|
|
1184
|
+
} else if (len === 0) {
|
|
1100
1185
|
mapped = new Array(newLen);
|
|
1101
1186
|
for (j = 0; j < newLen; j++) {
|
|
1102
1187
|
items[j] = newItems[j];
|
|
@@ -1107,8 +1192,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1107
1192
|
temp = new Array(newLen);
|
|
1108
1193
|
tempdisposers = new Array(newLen);
|
|
1109
1194
|
indexes && (tempIndexes = new Array(newLen));
|
|
1110
|
-
for (
|
|
1111
|
-
|
|
1195
|
+
for (
|
|
1196
|
+
start = 0, end = Math.min(len, newLen);
|
|
1197
|
+
start < end && items[start] === newItems[start];
|
|
1198
|
+
start++
|
|
1199
|
+
);
|
|
1200
|
+
for (
|
|
1201
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1202
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1203
|
+
end--, newEnd--
|
|
1204
|
+
) {
|
|
1112
1205
|
temp[newEnd] = mapped[end];
|
|
1113
1206
|
tempdisposers[newEnd] = disposers[end];
|
|
1114
1207
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1142,7 +1235,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1142
1235
|
}
|
|
1143
1236
|
} else mapped[j] = createRoot(mapper);
|
|
1144
1237
|
}
|
|
1145
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1238
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1146
1239
|
items = newItems.slice(0);
|
|
1147
1240
|
}
|
|
1148
1241
|
return mapped;
|
|
@@ -1208,7 +1301,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1208
1301
|
}
|
|
1209
1302
|
len = signals.length = disposers.length = newItems.length;
|
|
1210
1303
|
items = newItems.slice(0);
|
|
1211
|
-
return mapped = mapped.slice(0, len);
|
|
1304
|
+
return (mapped = mapped.slice(0, len));
|
|
1212
1305
|
});
|
|
1213
1306
|
function mapper(disposer) {
|
|
1214
1307
|
disposers[i] = disposer;
|
|
@@ -1277,29 +1370,33 @@ function mergeProps(...sources) {
|
|
|
1277
1370
|
let proxy = false;
|
|
1278
1371
|
for (let i = 0; i < sources.length; i++) {
|
|
1279
1372
|
const s = sources[i];
|
|
1280
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1281
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1373
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1374
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1282
1375
|
}
|
|
1283
1376
|
if (proxy) {
|
|
1284
|
-
return new Proxy(
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1377
|
+
return new Proxy(
|
|
1378
|
+
{
|
|
1379
|
+
get(property) {
|
|
1380
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1381
|
+
const v = resolveSource(sources[i])[property];
|
|
1382
|
+
if (v !== undefined) return v;
|
|
1383
|
+
}
|
|
1384
|
+
},
|
|
1385
|
+
has(property) {
|
|
1386
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1387
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1388
|
+
}
|
|
1389
|
+
return false;
|
|
1390
|
+
},
|
|
1391
|
+
keys() {
|
|
1392
|
+
const keys = [];
|
|
1393
|
+
for (let i = 0; i < sources.length; i++)
|
|
1394
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1395
|
+
return [...new Set(keys)];
|
|
1294
1396
|
}
|
|
1295
|
-
return false;
|
|
1296
1397
|
},
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1300
|
-
return [...new Set(keys)];
|
|
1301
|
-
}
|
|
1302
|
-
}, propTraps);
|
|
1398
|
+
propTraps
|
|
1399
|
+
);
|
|
1303
1400
|
}
|
|
1304
1401
|
const sourcesMap = {};
|
|
1305
1402
|
const defined = Object.create(null);
|
|
@@ -1312,15 +1409,20 @@ function mergeProps(...sources) {
|
|
|
1312
1409
|
if (key === "__proto__" || key === "constructor") continue;
|
|
1313
1410
|
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
1314
1411
|
if (!defined[key]) {
|
|
1315
|
-
defined[key] = desc.get
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1412
|
+
defined[key] = desc.get
|
|
1413
|
+
? {
|
|
1414
|
+
enumerable: true,
|
|
1415
|
+
configurable: true,
|
|
1416
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1417
|
+
}
|
|
1418
|
+
: desc.value !== undefined
|
|
1419
|
+
? desc
|
|
1420
|
+
: undefined;
|
|
1320
1421
|
} else {
|
|
1321
1422
|
const sources = sourcesMap[key];
|
|
1322
1423
|
if (sources) {
|
|
1323
|
-
if (desc.get) sources.push(desc.get.bind(source));
|
|
1424
|
+
if (desc.get) sources.push(desc.get.bind(source));
|
|
1425
|
+
else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1324
1426
|
}
|
|
1325
1427
|
}
|
|
1326
1428
|
}
|
|
@@ -1330,7 +1432,8 @@ function mergeProps(...sources) {
|
|
|
1330
1432
|
for (let i = definedKeys.length - 1; i >= 0; i--) {
|
|
1331
1433
|
const key = definedKeys[i],
|
|
1332
1434
|
desc = defined[key];
|
|
1333
|
-
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1435
|
+
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1436
|
+
else target[key] = desc ? desc.value : undefined;
|
|
1334
1437
|
}
|
|
1335
1438
|
return target;
|
|
1336
1439
|
}
|
|
@@ -1338,47 +1441,60 @@ function splitProps(props, ...keys) {
|
|
|
1338
1441
|
if ($PROXY in props) {
|
|
1339
1442
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1340
1443
|
const res = keys.map(k => {
|
|
1341
|
-
return new Proxy(
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1444
|
+
return new Proxy(
|
|
1445
|
+
{
|
|
1446
|
+
get(property) {
|
|
1447
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1448
|
+
},
|
|
1449
|
+
has(property) {
|
|
1450
|
+
return k.includes(property) && property in props;
|
|
1451
|
+
},
|
|
1452
|
+
keys() {
|
|
1453
|
+
return k.filter(property => property in props);
|
|
1454
|
+
}
|
|
1347
1455
|
},
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
}
|
|
1351
|
-
}, propTraps);
|
|
1456
|
+
propTraps
|
|
1457
|
+
);
|
|
1352
1458
|
});
|
|
1353
|
-
res.push(
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1459
|
+
res.push(
|
|
1460
|
+
new Proxy(
|
|
1461
|
+
{
|
|
1462
|
+
get(property) {
|
|
1463
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1464
|
+
},
|
|
1465
|
+
has(property) {
|
|
1466
|
+
return blocked.has(property) ? false : property in props;
|
|
1467
|
+
},
|
|
1468
|
+
keys() {
|
|
1469
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1470
|
+
}
|
|
1471
|
+
},
|
|
1472
|
+
propTraps
|
|
1473
|
+
)
|
|
1474
|
+
);
|
|
1364
1475
|
return res;
|
|
1365
1476
|
}
|
|
1366
1477
|
const otherObject = {};
|
|
1367
1478
|
const objects = keys.map(() => ({}));
|
|
1368
1479
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1369
1480
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1370
|
-
const isDefaultDesc =
|
|
1481
|
+
const isDefaultDesc =
|
|
1482
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1371
1483
|
let blocked = false;
|
|
1372
1484
|
let objectIndex = 0;
|
|
1373
1485
|
for (const k of keys) {
|
|
1374
1486
|
if (k.includes(propName)) {
|
|
1375
1487
|
blocked = true;
|
|
1376
|
-
isDefaultDesc
|
|
1488
|
+
isDefaultDesc
|
|
1489
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1490
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1377
1491
|
}
|
|
1378
1492
|
++objectIndex;
|
|
1379
1493
|
}
|
|
1380
1494
|
if (!blocked) {
|
|
1381
|
-
isDefaultDesc
|
|
1495
|
+
isDefaultDesc
|
|
1496
|
+
? (otherObject[propName] = desc.value)
|
|
1497
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1382
1498
|
}
|
|
1383
1499
|
}
|
|
1384
1500
|
return [...objects, otherObject];
|
|
@@ -1404,17 +1520,21 @@ function lazy(fn) {
|
|
|
1404
1520
|
comp = s;
|
|
1405
1521
|
}
|
|
1406
1522
|
let Comp;
|
|
1407
|
-
return createMemo(
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1523
|
+
return createMemo(
|
|
1524
|
+
() =>
|
|
1525
|
+
(Comp = comp()) &&
|
|
1526
|
+
untrack(() => {
|
|
1527
|
+
if (false);
|
|
1528
|
+
if (!ctx) return Comp(props);
|
|
1529
|
+
const c = sharedConfig.context;
|
|
1530
|
+
setHydrateContext(ctx);
|
|
1531
|
+
const r = Comp(props);
|
|
1532
|
+
setHydrateContext(c);
|
|
1533
|
+
return r;
|
|
1534
|
+
})
|
|
1535
|
+
);
|
|
1416
1536
|
};
|
|
1417
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1537
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1418
1538
|
return wrap;
|
|
1419
1539
|
}
|
|
1420
1540
|
let counter = 0;
|
|
@@ -1439,49 +1559,77 @@ function Index(props) {
|
|
|
1439
1559
|
function Show(props) {
|
|
1440
1560
|
const keyed = props.keyed;
|
|
1441
1561
|
const condition = createMemo(() => props.when, undefined, {
|
|
1442
|
-
equals: (a, b) => keyed ? a === b : !a === !b
|
|
1562
|
+
equals: (a, b) => (keyed ? a === b : !a === !b)
|
|
1443
1563
|
});
|
|
1444
|
-
return createMemo(
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1564
|
+
return createMemo(
|
|
1565
|
+
() => {
|
|
1566
|
+
const c = condition();
|
|
1567
|
+
if (c) {
|
|
1568
|
+
const child = props.children;
|
|
1569
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1570
|
+
return fn
|
|
1571
|
+
? untrack(() =>
|
|
1572
|
+
child(
|
|
1573
|
+
keyed
|
|
1574
|
+
? c
|
|
1575
|
+
: () => {
|
|
1576
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1577
|
+
return props.when;
|
|
1578
|
+
}
|
|
1579
|
+
)
|
|
1580
|
+
)
|
|
1581
|
+
: child;
|
|
1582
|
+
}
|
|
1583
|
+
return props.fallback;
|
|
1584
|
+
},
|
|
1585
|
+
undefined,
|
|
1586
|
+
undefined
|
|
1587
|
+
);
|
|
1456
1588
|
}
|
|
1457
1589
|
function Switch(props) {
|
|
1458
1590
|
let keyed = false;
|
|
1459
1591
|
const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1460
1592
|
const conditions = children(() => props.children),
|
|
1461
|
-
evalConditions = createMemo(
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1593
|
+
evalConditions = createMemo(
|
|
1594
|
+
() => {
|
|
1595
|
+
let conds = conditions();
|
|
1596
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1597
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1598
|
+
const c = conds[i].when;
|
|
1599
|
+
if (c) {
|
|
1600
|
+
keyed = !!conds[i].keyed;
|
|
1601
|
+
return [i, c, conds[i]];
|
|
1602
|
+
}
|
|
1469
1603
|
}
|
|
1604
|
+
return [-1];
|
|
1605
|
+
},
|
|
1606
|
+
undefined,
|
|
1607
|
+
{
|
|
1608
|
+
equals
|
|
1470
1609
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1610
|
+
);
|
|
1611
|
+
return createMemo(
|
|
1612
|
+
() => {
|
|
1613
|
+
const [index, when, cond] = evalConditions();
|
|
1614
|
+
if (index < 0) return props.fallback;
|
|
1615
|
+
const c = cond.children;
|
|
1616
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1617
|
+
return fn
|
|
1618
|
+
? untrack(() =>
|
|
1619
|
+
c(
|
|
1620
|
+
keyed
|
|
1621
|
+
? when
|
|
1622
|
+
: () => {
|
|
1623
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1624
|
+
return cond.when;
|
|
1625
|
+
}
|
|
1626
|
+
)
|
|
1627
|
+
)
|
|
1628
|
+
: c;
|
|
1629
|
+
},
|
|
1630
|
+
undefined,
|
|
1631
|
+
undefined
|
|
1632
|
+
);
|
|
1485
1633
|
}
|
|
1486
1634
|
function Match(props) {
|
|
1487
1635
|
return props;
|
|
@@ -1492,22 +1640,28 @@ function resetErrorBoundaries() {
|
|
|
1492
1640
|
}
|
|
1493
1641
|
function ErrorBoundary(props) {
|
|
1494
1642
|
let err;
|
|
1495
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1643
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1644
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1496
1645
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1497
1646
|
Errors || (Errors = new Set());
|
|
1498
1647
|
Errors.add(setErrored);
|
|
1499
1648
|
onCleanup(() => Errors.delete(setErrored));
|
|
1500
|
-
return createMemo(
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1649
|
+
return createMemo(
|
|
1650
|
+
() => {
|
|
1651
|
+
let e;
|
|
1652
|
+
if ((e = errored())) {
|
|
1653
|
+
const f = props.fallback;
|
|
1654
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1655
|
+
}
|
|
1656
|
+
return catchError(() => props.children, setErrored);
|
|
1657
|
+
},
|
|
1658
|
+
undefined,
|
|
1659
|
+
undefined
|
|
1660
|
+
);
|
|
1508
1661
|
}
|
|
1509
1662
|
|
|
1510
|
-
const suspenseListEquals = (a, b) =>
|
|
1663
|
+
const suspenseListEquals = (a, b) =>
|
|
1664
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1511
1665
|
const SuspenseListContext = createContext();
|
|
1512
1666
|
function SuspenseList(props) {
|
|
1513
1667
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1519,51 +1673,51 @@ function SuspenseList(props) {
|
|
|
1519
1673
|
if (listContext) {
|
|
1520
1674
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1521
1675
|
}
|
|
1522
|
-
const resolved = createMemo(
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
showContent = true,
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
const res = reg.map(() => ({
|
|
1534
|
-
showContent: all && showContent,
|
|
1535
|
-
showFallback
|
|
1536
|
-
}));
|
|
1537
|
-
res.inFallback = !all;
|
|
1538
|
-
return res;
|
|
1539
|
-
}
|
|
1540
|
-
let stop = false;
|
|
1541
|
-
let inFallback = prev.inFallback;
|
|
1542
|
-
const res = [];
|
|
1543
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1544
|
-
const n = reverse ? len - i - 1 : i,
|
|
1545
|
-
s = reg[n]();
|
|
1546
|
-
if (!stop && !s) {
|
|
1547
|
-
res[n] = {
|
|
1548
|
-
showContent,
|
|
1676
|
+
const resolved = createMemo(
|
|
1677
|
+
prev => {
|
|
1678
|
+
const reveal = props.revealOrder,
|
|
1679
|
+
tail = props.tail,
|
|
1680
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1681
|
+
reg = registry(),
|
|
1682
|
+
reverse = reveal === "backwards";
|
|
1683
|
+
if (reveal === "together") {
|
|
1684
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1685
|
+
const res = reg.map(() => ({
|
|
1686
|
+
showContent: all && showContent,
|
|
1549
1687
|
showFallback
|
|
1550
|
-
};
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
if (next) inFallback = true;
|
|
1554
|
-
res[n] = {
|
|
1555
|
-
showContent: next,
|
|
1556
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1557
|
-
};
|
|
1558
|
-
stop = true;
|
|
1688
|
+
}));
|
|
1689
|
+
res.inFallback = !all;
|
|
1690
|
+
return res;
|
|
1559
1691
|
}
|
|
1692
|
+
let stop = false;
|
|
1693
|
+
let inFallback = prev.inFallback;
|
|
1694
|
+
const res = [];
|
|
1695
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1696
|
+
const n = reverse ? len - i - 1 : i,
|
|
1697
|
+
s = reg[n]();
|
|
1698
|
+
if (!stop && !s) {
|
|
1699
|
+
res[n] = {
|
|
1700
|
+
showContent,
|
|
1701
|
+
showFallback
|
|
1702
|
+
};
|
|
1703
|
+
} else {
|
|
1704
|
+
const next = !stop;
|
|
1705
|
+
if (next) inFallback = true;
|
|
1706
|
+
res[n] = {
|
|
1707
|
+
showContent: next,
|
|
1708
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1709
|
+
};
|
|
1710
|
+
stop = true;
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
if (!stop) inFallback = false;
|
|
1714
|
+
res.inFallback = inFallback;
|
|
1715
|
+
return res;
|
|
1716
|
+
},
|
|
1717
|
+
{
|
|
1718
|
+
inFallback: false
|
|
1560
1719
|
}
|
|
1561
|
-
|
|
1562
|
-
res.inFallback = inFallback;
|
|
1563
|
-
return res;
|
|
1564
|
-
}, {
|
|
1565
|
-
inFallback: false
|
|
1566
|
-
});
|
|
1720
|
+
);
|
|
1567
1721
|
setWrapper(() => resolved);
|
|
1568
1722
|
return createComponent(SuspenseListContext.Provider, {
|
|
1569
1723
|
value: {
|
|
@@ -1638,17 +1792,14 @@ function Suspense(props) {
|
|
|
1638
1792
|
ctx = sharedConfig.context;
|
|
1639
1793
|
if (flicker) {
|
|
1640
1794
|
flicker();
|
|
1641
|
-
return flicker = undefined;
|
|
1795
|
+
return (flicker = undefined);
|
|
1642
1796
|
}
|
|
1643
1797
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1644
1798
|
const rendered = createMemo(() => props.children);
|
|
1645
1799
|
return createMemo(prev => {
|
|
1646
1800
|
const inFallback = store.inFallback(),
|
|
1647
|
-
{
|
|
1648
|
-
|
|
1649
|
-
showFallback = true
|
|
1650
|
-
} = show ? show() : {};
|
|
1651
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1801
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1802
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1652
1803
|
store.resolved = true;
|
|
1653
1804
|
dispose && dispose();
|
|
1654
1805
|
dispose = ctx = p = undefined;
|
|
@@ -1676,4 +1827,59 @@ function Suspense(props) {
|
|
|
1676
1827
|
|
|
1677
1828
|
const DEV = undefined;
|
|
1678
1829
|
|
|
1679
|
-
export {
|
|
1830
|
+
export {
|
|
1831
|
+
$DEVCOMP,
|
|
1832
|
+
$PROXY,
|
|
1833
|
+
$TRACK,
|
|
1834
|
+
DEV,
|
|
1835
|
+
ErrorBoundary,
|
|
1836
|
+
For,
|
|
1837
|
+
Index,
|
|
1838
|
+
Match,
|
|
1839
|
+
Show,
|
|
1840
|
+
Suspense,
|
|
1841
|
+
SuspenseList,
|
|
1842
|
+
Switch,
|
|
1843
|
+
batch,
|
|
1844
|
+
cancelCallback,
|
|
1845
|
+
catchError,
|
|
1846
|
+
children,
|
|
1847
|
+
createComponent,
|
|
1848
|
+
createComputed,
|
|
1849
|
+
createContext,
|
|
1850
|
+
createDeferred,
|
|
1851
|
+
createEffect,
|
|
1852
|
+
createMemo,
|
|
1853
|
+
createReaction,
|
|
1854
|
+
createRenderEffect,
|
|
1855
|
+
createResource,
|
|
1856
|
+
createRoot,
|
|
1857
|
+
createSelector,
|
|
1858
|
+
createSignal,
|
|
1859
|
+
createUniqueId,
|
|
1860
|
+
enableExternalSource,
|
|
1861
|
+
enableHydration,
|
|
1862
|
+
enableScheduling,
|
|
1863
|
+
equalFn,
|
|
1864
|
+
from,
|
|
1865
|
+
getListener,
|
|
1866
|
+
getOwner,
|
|
1867
|
+
indexArray,
|
|
1868
|
+
lazy,
|
|
1869
|
+
mapArray,
|
|
1870
|
+
mergeProps,
|
|
1871
|
+
observable,
|
|
1872
|
+
on,
|
|
1873
|
+
onCleanup,
|
|
1874
|
+
onError,
|
|
1875
|
+
onMount,
|
|
1876
|
+
requestCallback,
|
|
1877
|
+
resetErrorBoundaries,
|
|
1878
|
+
runWithOwner,
|
|
1879
|
+
sharedConfig,
|
|
1880
|
+
splitProps,
|
|
1881
|
+
startTransition,
|
|
1882
|
+
untrack,
|
|
1883
|
+
useContext,
|
|
1884
|
+
useTransition
|
|
1885
|
+
};
|