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