solid-js 1.7.11 → 1.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.cjs +16 -13
- package/dist/dev.js +544 -306
- package/dist/server.cjs +7 -6
- package/dist/server.js +175 -80
- package/dist/solid.cjs +16 -13
- package/dist/solid.js +471 -264
- 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/jsx-runtime/types/jsx.d.ts +1 -0
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +45 -31
- package/package.json +2 -2
- package/store/dist/dev.js +114 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +105 -39
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +72 -9
- package/types/jsx.d.ts +2 -1
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +228 -140
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +62 -31
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +12 -12
- package/types/server/index.d.ts +56 -2
- package/types/server/reactive.d.ts +67 -40
- package/types/server/rendering.d.ts +166 -95
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.cjs +8 -5
- package/web/dist/dev.js +616 -82
- package/web/dist/server.cjs +91 -56
- package/web/dist/server.js +244 -125
- package/web/dist/web.cjs +8 -5
- package/web/dist/web.js +616 -82
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
package/dist/solid.js
CHANGED
|
@@ -52,9 +52,11 @@ function enqueue(taskQueue, task) {
|
|
|
52
52
|
let m = 0;
|
|
53
53
|
let n = taskQueue.length - 1;
|
|
54
54
|
while (m <= n) {
|
|
55
|
-
const k = n + m >> 1;
|
|
55
|
+
const k = (n + m) >> 1;
|
|
56
56
|
const cmp = task.expirationTime - taskQueue[k].expirationTime;
|
|
57
|
-
if (cmp > 0) m = k + 1;
|
|
57
|
+
if (cmp > 0) m = k + 1;
|
|
58
|
+
else if (cmp < 0) n = k - 1;
|
|
59
|
+
else return k;
|
|
58
60
|
}
|
|
59
61
|
return m;
|
|
60
62
|
}
|
|
@@ -155,18 +157,20 @@ let Listener = null;
|
|
|
155
157
|
let Updates = null;
|
|
156
158
|
let Effects = null;
|
|
157
159
|
let ExecCount = 0;
|
|
158
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
160
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
159
161
|
function createRoot(fn, detachedOwner) {
|
|
160
162
|
const listener = Listener,
|
|
161
163
|
owner = Owner,
|
|
162
164
|
unowned = fn.length === 0,
|
|
163
165
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
164
|
-
root = unowned
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
root = unowned
|
|
167
|
+
? UNOWNED
|
|
168
|
+
: {
|
|
169
|
+
owned: null,
|
|
170
|
+
cleanups: null,
|
|
171
|
+
context: current ? current.context : null,
|
|
172
|
+
owner: current
|
|
173
|
+
},
|
|
170
174
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
171
175
|
Owner = root;
|
|
172
176
|
Listener = null;
|
|
@@ -187,7 +191,8 @@ function createSignal(value, options) {
|
|
|
187
191
|
};
|
|
188
192
|
const setter = value => {
|
|
189
193
|
if (typeof value === "function") {
|
|
190
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
194
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
195
|
+
else value = value(s.value);
|
|
191
196
|
}
|
|
192
197
|
return writeSignal(s, value);
|
|
193
198
|
};
|
|
@@ -195,11 +200,13 @@ function createSignal(value, options) {
|
|
|
195
200
|
}
|
|
196
201
|
function createComputed(fn, value, options) {
|
|
197
202
|
const c = createComputation(fn, value, true, STALE);
|
|
198
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
203
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
204
|
+
else updateComputation(c);
|
|
199
205
|
}
|
|
200
206
|
function createRenderEffect(fn, value, options) {
|
|
201
207
|
const c = createComputation(fn, value, false, STALE);
|
|
202
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
208
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
209
|
+
else updateComputation(c);
|
|
203
210
|
}
|
|
204
211
|
function createEffect(fn, value, options) {
|
|
205
212
|
runEffects = runUserEffects;
|
|
@@ -211,10 +218,15 @@ function createEffect(fn, value, options) {
|
|
|
211
218
|
}
|
|
212
219
|
function createReaction(onInvalidate, options) {
|
|
213
220
|
let fn;
|
|
214
|
-
const c = createComputation(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
const c = createComputation(
|
|
222
|
+
() => {
|
|
223
|
+
fn ? fn() : untrack(onInvalidate);
|
|
224
|
+
fn = undefined;
|
|
225
|
+
},
|
|
226
|
+
undefined,
|
|
227
|
+
false,
|
|
228
|
+
0
|
|
229
|
+
),
|
|
218
230
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
219
231
|
if (s) c.suspense = s;
|
|
220
232
|
c.user = true;
|
|
@@ -235,11 +247,14 @@ function createMemo(fn, value, options) {
|
|
|
235
247
|
} else updateComputation(c);
|
|
236
248
|
return readSignal.bind(c);
|
|
237
249
|
}
|
|
250
|
+
function isPromise(v) {
|
|
251
|
+
return v && typeof v === "object" && "then" in v;
|
|
252
|
+
}
|
|
238
253
|
function createResource(pSource, pFetcher, pOptions) {
|
|
239
254
|
let source;
|
|
240
255
|
let fetcher;
|
|
241
256
|
let options;
|
|
242
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
257
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
243
258
|
source = true;
|
|
244
259
|
fetcher = pSource;
|
|
245
260
|
options = pFetcher || {};
|
|
@@ -253,7 +268,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
253
268
|
id = null,
|
|
254
269
|
loadedUnderTransition = false,
|
|
255
270
|
scheduled = false,
|
|
256
|
-
resolved =
|
|
271
|
+
resolved = "initialValue" in options,
|
|
257
272
|
dynamic = typeof source === "function" && createMemo(source);
|
|
258
273
|
const contexts = new Set(),
|
|
259
274
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -265,15 +280,20 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
265
280
|
if (sharedConfig.context) {
|
|
266
281
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
267
282
|
let v;
|
|
268
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
283
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
284
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id)))
|
|
285
|
+
initP = isPromise(v) && "value" in v ? v.value : v;
|
|
269
286
|
}
|
|
270
287
|
function loadEnd(p, v, error, key) {
|
|
271
288
|
if (pr === p) {
|
|
272
289
|
pr = null;
|
|
273
290
|
key !== undefined && (resolved = true);
|
|
274
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
275
|
-
|
|
276
|
-
|
|
291
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
292
|
+
queueMicrotask(() =>
|
|
293
|
+
options.onHydrated(key, {
|
|
294
|
+
value: v
|
|
295
|
+
})
|
|
296
|
+
);
|
|
277
297
|
initP = NO_INIT;
|
|
278
298
|
if (Transition && p && loadedUnderTransition) {
|
|
279
299
|
Transition.promises.delete(p);
|
|
@@ -304,7 +324,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
304
324
|
createComputed(() => {
|
|
305
325
|
track();
|
|
306
326
|
if (pr) {
|
|
307
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
327
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
328
|
+
else if (!contexts.has(c)) {
|
|
308
329
|
c.increment();
|
|
309
330
|
contexts.add(c);
|
|
310
331
|
}
|
|
@@ -323,22 +344,30 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
323
344
|
return;
|
|
324
345
|
}
|
|
325
346
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
326
|
-
const p =
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
347
|
+
const p =
|
|
348
|
+
initP !== NO_INIT
|
|
349
|
+
? initP
|
|
350
|
+
: untrack(() =>
|
|
351
|
+
fetcher(lookup, {
|
|
352
|
+
value: value(),
|
|
353
|
+
refetching
|
|
354
|
+
})
|
|
355
|
+
);
|
|
356
|
+
if (!isPromise(p)) {
|
|
331
357
|
loadEnd(pr, p, undefined, lookup);
|
|
332
358
|
return p;
|
|
333
359
|
}
|
|
334
360
|
pr = p;
|
|
335
361
|
scheduled = true;
|
|
336
|
-
queueMicrotask(() => scheduled = false);
|
|
362
|
+
queueMicrotask(() => (scheduled = false));
|
|
337
363
|
runUpdates(() => {
|
|
338
364
|
setState(resolved ? "refreshing" : "pending");
|
|
339
365
|
trigger();
|
|
340
366
|
}, false);
|
|
341
|
-
return p.then(
|
|
367
|
+
return p.then(
|
|
368
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
369
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
370
|
+
);
|
|
342
371
|
}
|
|
343
372
|
Object.defineProperties(read, {
|
|
344
373
|
state: {
|
|
@@ -362,50 +391,80 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
362
391
|
}
|
|
363
392
|
}
|
|
364
393
|
});
|
|
365
|
-
if (dynamic) createComputed(() => load(false));
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
394
|
+
if (dynamic) createComputed(() => load(false));
|
|
395
|
+
else load(false);
|
|
396
|
+
return [
|
|
397
|
+
read,
|
|
398
|
+
{
|
|
399
|
+
refetch: load,
|
|
400
|
+
mutate: setValue
|
|
401
|
+
}
|
|
402
|
+
];
|
|
370
403
|
}
|
|
371
404
|
function createDeferred(source, options) {
|
|
372
405
|
let t,
|
|
373
406
|
timeout = options ? options.timeoutMs : undefined;
|
|
374
|
-
const node = createComputation(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
407
|
+
const node = createComputation(
|
|
408
|
+
() => {
|
|
409
|
+
if (!t || !t.fn)
|
|
410
|
+
t = requestCallback(
|
|
411
|
+
() => setDeferred(() => node.value),
|
|
412
|
+
timeout !== undefined
|
|
413
|
+
? {
|
|
414
|
+
timeout
|
|
415
|
+
}
|
|
416
|
+
: undefined
|
|
417
|
+
);
|
|
418
|
+
return source();
|
|
419
|
+
},
|
|
420
|
+
undefined,
|
|
421
|
+
true
|
|
422
|
+
);
|
|
423
|
+
const [deferred, setDeferred] = createSignal(
|
|
424
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
425
|
+
options
|
|
426
|
+
);
|
|
381
427
|
updateComputation(node);
|
|
382
|
-
setDeferred(() =>
|
|
428
|
+
setDeferred(() =>
|
|
429
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
430
|
+
);
|
|
383
431
|
return deferred;
|
|
384
432
|
}
|
|
385
433
|
function createSelector(source, fn = equalFn, options) {
|
|
386
434
|
const subs = new Map();
|
|
387
|
-
const node = createComputation(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
for (const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
435
|
+
const node = createComputation(
|
|
436
|
+
p => {
|
|
437
|
+
const v = source();
|
|
438
|
+
for (const [key, val] of subs.entries())
|
|
439
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
440
|
+
for (const c of val.values()) {
|
|
441
|
+
c.state = STALE;
|
|
442
|
+
if (c.pure) Updates.push(c);
|
|
443
|
+
else Effects.push(c);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return v;
|
|
447
|
+
},
|
|
448
|
+
undefined,
|
|
449
|
+
true,
|
|
450
|
+
STALE
|
|
451
|
+
);
|
|
397
452
|
updateComputation(node);
|
|
398
453
|
return key => {
|
|
399
454
|
const listener = Listener;
|
|
400
455
|
if (listener) {
|
|
401
456
|
let l;
|
|
402
|
-
if (l = subs.get(key)) l.add(listener);
|
|
457
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
458
|
+
else subs.set(key, (l = new Set([listener])));
|
|
403
459
|
onCleanup(() => {
|
|
404
460
|
l.delete(listener);
|
|
405
461
|
!l.size && subs.delete(key);
|
|
406
462
|
});
|
|
407
463
|
}
|
|
408
|
-
return fn(
|
|
464
|
+
return fn(
|
|
465
|
+
key,
|
|
466
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
467
|
+
);
|
|
409
468
|
};
|
|
410
469
|
}
|
|
411
470
|
function batch(fn) {
|
|
@@ -444,7 +503,9 @@ function onMount(fn) {
|
|
|
444
503
|
createEffect(() => untrack(fn));
|
|
445
504
|
}
|
|
446
505
|
function onCleanup(fn) {
|
|
447
|
-
if (Owner === null)
|
|
506
|
+
if (Owner === null);
|
|
507
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
508
|
+
else Owner.cleanups.push(fn);
|
|
448
509
|
return fn;
|
|
449
510
|
}
|
|
450
511
|
function catchError(fn, handler) {
|
|
@@ -498,15 +559,17 @@ function startTransition(fn) {
|
|
|
498
559
|
Owner = o;
|
|
499
560
|
let t;
|
|
500
561
|
if (Scheduler || SuspenseContext) {
|
|
501
|
-
t =
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
562
|
+
t =
|
|
563
|
+
Transition ||
|
|
564
|
+
(Transition = {
|
|
565
|
+
sources: new Set(),
|
|
566
|
+
effects: [],
|
|
567
|
+
promises: new Set(),
|
|
568
|
+
disposed: new Set(),
|
|
569
|
+
queue: new Set(),
|
|
570
|
+
running: true
|
|
571
|
+
});
|
|
572
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
510
573
|
t.running = true;
|
|
511
574
|
}
|
|
512
575
|
runUpdates(fn, false);
|
|
@@ -530,7 +593,9 @@ function createContext(defaultValue, options) {
|
|
|
530
593
|
};
|
|
531
594
|
}
|
|
532
595
|
function useContext(context) {
|
|
533
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
596
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
597
|
+
? Owner.context[context.id]
|
|
598
|
+
: context.defaultValue;
|
|
534
599
|
}
|
|
535
600
|
function children(fn) {
|
|
536
601
|
const children = createMemo(fn);
|
|
@@ -566,7 +631,8 @@ function enableExternalSource(factory) {
|
|
|
566
631
|
function readSignal() {
|
|
567
632
|
const runningTransition = Transition && Transition.running;
|
|
568
633
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
569
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
634
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
635
|
+
else {
|
|
570
636
|
const updates = Updates;
|
|
571
637
|
Updates = null;
|
|
572
638
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -594,11 +660,12 @@ function readSignal() {
|
|
|
594
660
|
return this.value;
|
|
595
661
|
}
|
|
596
662
|
function writeSignal(node, value, isComp) {
|
|
597
|
-
let current =
|
|
663
|
+
let current =
|
|
664
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
598
665
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
599
666
|
if (Transition) {
|
|
600
667
|
const TransitionRunning = Transition.running;
|
|
601
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
668
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
602
669
|
Transition.sources.add(node);
|
|
603
670
|
node.tValue = value;
|
|
604
671
|
}
|
|
@@ -611,14 +678,16 @@ function writeSignal(node, value, isComp) {
|
|
|
611
678
|
const TransitionRunning = Transition && Transition.running;
|
|
612
679
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
613
680
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
614
|
-
if (o.pure) Updates.push(o);
|
|
681
|
+
if (o.pure) Updates.push(o);
|
|
682
|
+
else Effects.push(o);
|
|
615
683
|
if (o.observers) markDownstream(o);
|
|
616
684
|
}
|
|
617
|
-
if (!TransitionRunning) o.state = STALE;
|
|
685
|
+
if (!TransitionRunning) o.state = STALE;
|
|
686
|
+
else o.tState = STALE;
|
|
618
687
|
}
|
|
619
688
|
if (Updates.length > 10e5) {
|
|
620
689
|
Updates = [];
|
|
621
|
-
if (false)
|
|
690
|
+
if (false);
|
|
622
691
|
throw new Error();
|
|
623
692
|
}
|
|
624
693
|
}, false);
|
|
@@ -633,7 +702,11 @@ function updateComputation(node) {
|
|
|
633
702
|
listener = Listener,
|
|
634
703
|
time = ExecCount;
|
|
635
704
|
Listener = Owner = node;
|
|
636
|
-
runComputation(
|
|
705
|
+
runComputation(
|
|
706
|
+
node,
|
|
707
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
708
|
+
time
|
|
709
|
+
);
|
|
637
710
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
638
711
|
queueMicrotask(() => {
|
|
639
712
|
runUpdates(() => {
|
|
@@ -694,11 +767,14 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
694
767
|
c.state = 0;
|
|
695
768
|
c.tState = state;
|
|
696
769
|
}
|
|
697
|
-
if (Owner === null)
|
|
770
|
+
if (Owner === null);
|
|
771
|
+
else if (Owner !== UNOWNED) {
|
|
698
772
|
if (Transition && Transition.running && Owner.pure) {
|
|
699
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
773
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
774
|
+
else Owner.tOwned.push(c);
|
|
700
775
|
} else {
|
|
701
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
776
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
777
|
+
else Owner.owned.push(c);
|
|
702
778
|
}
|
|
703
779
|
}
|
|
704
780
|
if (ExternalSourceFactory) {
|
|
@@ -749,7 +825,8 @@ function runUpdates(fn, init) {
|
|
|
749
825
|
if (Updates) return fn();
|
|
750
826
|
let wait = false;
|
|
751
827
|
if (!init) Updates = [];
|
|
752
|
-
if (Effects) wait = true;
|
|
828
|
+
if (Effects) wait = true;
|
|
829
|
+
else Effects = [];
|
|
753
830
|
ExecCount++;
|
|
754
831
|
try {
|
|
755
832
|
const res = fn();
|
|
@@ -763,7 +840,8 @@ function runUpdates(fn, init) {
|
|
|
763
840
|
}
|
|
764
841
|
function completeUpdates(wait) {
|
|
765
842
|
if (Updates) {
|
|
766
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
843
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
844
|
+
else runQueue(Updates);
|
|
767
845
|
Updates = null;
|
|
768
846
|
}
|
|
769
847
|
if (wait) return;
|
|
@@ -831,7 +909,8 @@ function runUserEffects(queue) {
|
|
|
831
909
|
userLength = 0;
|
|
832
910
|
for (i = 0; i < queue.length; i++) {
|
|
833
911
|
const e = queue[i];
|
|
834
|
-
if (!e.user) runTop(e);
|
|
912
|
+
if (!e.user) runTop(e);
|
|
913
|
+
else queue[userLength++] = e;
|
|
835
914
|
}
|
|
836
915
|
if (sharedConfig.context) {
|
|
837
916
|
if (sharedConfig.count) {
|
|
@@ -849,13 +928,15 @@ function runUserEffects(queue) {
|
|
|
849
928
|
}
|
|
850
929
|
function lookUpstream(node, ignore) {
|
|
851
930
|
const runningTransition = Transition && Transition.running;
|
|
852
|
-
if (runningTransition) node.tState = 0;
|
|
931
|
+
if (runningTransition) node.tState = 0;
|
|
932
|
+
else node.state = 0;
|
|
853
933
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
854
934
|
const source = node.sources[i];
|
|
855
935
|
if (source.sources) {
|
|
856
936
|
const state = runningTransition ? source.tState : source.state;
|
|
857
937
|
if (state === STALE) {
|
|
858
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
938
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
939
|
+
runTop(source);
|
|
859
940
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
860
941
|
}
|
|
861
942
|
}
|
|
@@ -865,8 +946,10 @@ function markDownstream(node) {
|
|
|
865
946
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
866
947
|
const o = node.observers[i];
|
|
867
948
|
if (runningTransition ? !o.tState : !o.state) {
|
|
868
|
-
if (runningTransition) o.tState = PENDING;
|
|
869
|
-
|
|
949
|
+
if (runningTransition) o.tState = PENDING;
|
|
950
|
+
else o.state = PENDING;
|
|
951
|
+
if (o.pure) Updates.push(o);
|
|
952
|
+
else Effects.push(o);
|
|
870
953
|
o.observers && markDownstream(o);
|
|
871
954
|
}
|
|
872
955
|
}
|
|
@@ -903,7 +986,8 @@ function cleanNode(node) {
|
|
|
903
986
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
904
987
|
node.cleanups = null;
|
|
905
988
|
}
|
|
906
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
989
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
990
|
+
else node.state = 0;
|
|
907
991
|
}
|
|
908
992
|
function reset(node, top) {
|
|
909
993
|
if (!top) {
|
|
@@ -924,19 +1008,21 @@ function runErrors(err, fns, owner) {
|
|
|
924
1008
|
try {
|
|
925
1009
|
for (const f of fns) f(err);
|
|
926
1010
|
} catch (e) {
|
|
927
|
-
handleError(e, owner && owner.owner || null);
|
|
1011
|
+
handleError(e, (owner && owner.owner) || null);
|
|
928
1012
|
}
|
|
929
1013
|
}
|
|
930
1014
|
function handleError(err, owner = Owner) {
|
|
931
1015
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
932
1016
|
const error = castError(err);
|
|
933
1017
|
if (!fns) throw error;
|
|
934
|
-
if (Effects)
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1018
|
+
if (Effects)
|
|
1019
|
+
Effects.push({
|
|
1020
|
+
fn() {
|
|
1021
|
+
runErrors(error, fns, owner);
|
|
1022
|
+
},
|
|
1023
|
+
state: STALE
|
|
1024
|
+
});
|
|
1025
|
+
else runErrors(error, fns, owner);
|
|
940
1026
|
}
|
|
941
1027
|
function resolveChildren(children) {
|
|
942
1028
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -953,19 +1039,24 @@ function resolveChildren(children) {
|
|
|
953
1039
|
function createProvider(id, options) {
|
|
954
1040
|
return function provider(props) {
|
|
955
1041
|
let res;
|
|
956
|
-
createRenderEffect(
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1042
|
+
createRenderEffect(
|
|
1043
|
+
() =>
|
|
1044
|
+
(res = untrack(() => {
|
|
1045
|
+
Owner.context = {
|
|
1046
|
+
...Owner.context,
|
|
1047
|
+
[id]: props.value
|
|
1048
|
+
};
|
|
1049
|
+
return children(() => props.children);
|
|
1050
|
+
})),
|
|
1051
|
+
undefined
|
|
1052
|
+
);
|
|
963
1053
|
return res;
|
|
964
1054
|
};
|
|
965
1055
|
}
|
|
966
1056
|
function onError(fn) {
|
|
967
1057
|
ERROR || (ERROR = Symbol("error"));
|
|
968
|
-
if (Owner === null)
|
|
1058
|
+
if (Owner === null);
|
|
1059
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
969
1060
|
Owner.context = {
|
|
970
1061
|
...Owner.context,
|
|
971
1062
|
[ERROR]: [fn]
|
|
@@ -994,7 +1085,8 @@ function observable(input) {
|
|
|
994
1085
|
if (!(observer instanceof Object) || observer == null) {
|
|
995
1086
|
throw new TypeError("Expected the observer to be an object.");
|
|
996
1087
|
}
|
|
997
|
-
const handler =
|
|
1088
|
+
const handler =
|
|
1089
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
998
1090
|
if (!handler) {
|
|
999
1091
|
return {
|
|
1000
1092
|
unsubscribe() {}
|
|
@@ -1025,7 +1117,7 @@ function from(producer) {
|
|
|
1025
1117
|
});
|
|
1026
1118
|
if ("subscribe" in producer) {
|
|
1027
1119
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1028
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1120
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1029
1121
|
} else {
|
|
1030
1122
|
const clean = producer(set);
|
|
1031
1123
|
onCleanup(clean);
|
|
@@ -1077,8 +1169,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1077
1169
|
});
|
|
1078
1170
|
len = 1;
|
|
1079
1171
|
}
|
|
1080
|
-
}
|
|
1081
|
-
else if (len === 0) {
|
|
1172
|
+
} else if (len === 0) {
|
|
1082
1173
|
mapped = new Array(newLen);
|
|
1083
1174
|
for (j = 0; j < newLen; j++) {
|
|
1084
1175
|
items[j] = newItems[j];
|
|
@@ -1089,8 +1180,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1089
1180
|
temp = new Array(newLen);
|
|
1090
1181
|
tempdisposers = new Array(newLen);
|
|
1091
1182
|
indexes && (tempIndexes = new Array(newLen));
|
|
1092
|
-
for (
|
|
1093
|
-
|
|
1183
|
+
for (
|
|
1184
|
+
start = 0, end = Math.min(len, newLen);
|
|
1185
|
+
start < end && items[start] === newItems[start];
|
|
1186
|
+
start++
|
|
1187
|
+
);
|
|
1188
|
+
for (
|
|
1189
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1190
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1191
|
+
end--, newEnd--
|
|
1192
|
+
) {
|
|
1094
1193
|
temp[newEnd] = mapped[end];
|
|
1095
1194
|
tempdisposers[newEnd] = disposers[end];
|
|
1096
1195
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1124,7 +1223,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1124
1223
|
}
|
|
1125
1224
|
} else mapped[j] = createRoot(mapper);
|
|
1126
1225
|
}
|
|
1127
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1226
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1128
1227
|
items = newItems.slice(0);
|
|
1129
1228
|
}
|
|
1130
1229
|
return mapped;
|
|
@@ -1190,7 +1289,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1190
1289
|
}
|
|
1191
1290
|
len = signals.length = disposers.length = newItems.length;
|
|
1192
1291
|
items = newItems.slice(0);
|
|
1193
|
-
return mapped = mapped.slice(0, len);
|
|
1292
|
+
return (mapped = mapped.slice(0, len));
|
|
1194
1293
|
});
|
|
1195
1294
|
function mapper(disposer) {
|
|
1196
1295
|
disposers[i] = disposer;
|
|
@@ -1259,29 +1358,33 @@ function mergeProps(...sources) {
|
|
|
1259
1358
|
let proxy = false;
|
|
1260
1359
|
for (let i = 0; i < sources.length; i++) {
|
|
1261
1360
|
const s = sources[i];
|
|
1262
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1263
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1361
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1362
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1264
1363
|
}
|
|
1265
1364
|
if (proxy) {
|
|
1266
|
-
return new Proxy(
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1365
|
+
return new Proxy(
|
|
1366
|
+
{
|
|
1367
|
+
get(property) {
|
|
1368
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1369
|
+
const v = resolveSource(sources[i])[property];
|
|
1370
|
+
if (v !== undefined) return v;
|
|
1371
|
+
}
|
|
1372
|
+
},
|
|
1373
|
+
has(property) {
|
|
1374
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1375
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1376
|
+
}
|
|
1377
|
+
return false;
|
|
1378
|
+
},
|
|
1379
|
+
keys() {
|
|
1380
|
+
const keys = [];
|
|
1381
|
+
for (let i = 0; i < sources.length; i++)
|
|
1382
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1383
|
+
return [...new Set(keys)];
|
|
1276
1384
|
}
|
|
1277
|
-
return false;
|
|
1278
1385
|
},
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1282
|
-
return [...new Set(keys)];
|
|
1283
|
-
}
|
|
1284
|
-
}, propTraps);
|
|
1386
|
+
propTraps
|
|
1387
|
+
);
|
|
1285
1388
|
}
|
|
1286
1389
|
const target = {};
|
|
1287
1390
|
const sourcesMap = {};
|
|
@@ -1300,7 +1403,7 @@ function mergeProps(...sources) {
|
|
|
1300
1403
|
Object.defineProperty(target, key, {
|
|
1301
1404
|
enumerable: true,
|
|
1302
1405
|
configurable: true,
|
|
1303
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1406
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1304
1407
|
});
|
|
1305
1408
|
} else {
|
|
1306
1409
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1324,47 +1427,60 @@ function splitProps(props, ...keys) {
|
|
|
1324
1427
|
if ($PROXY in props) {
|
|
1325
1428
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1326
1429
|
const res = keys.map(k => {
|
|
1327
|
-
return new Proxy(
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1430
|
+
return new Proxy(
|
|
1431
|
+
{
|
|
1432
|
+
get(property) {
|
|
1433
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1434
|
+
},
|
|
1435
|
+
has(property) {
|
|
1436
|
+
return k.includes(property) && property in props;
|
|
1437
|
+
},
|
|
1438
|
+
keys() {
|
|
1439
|
+
return k.filter(property => property in props);
|
|
1440
|
+
}
|
|
1333
1441
|
},
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
}
|
|
1337
|
-
}, propTraps);
|
|
1442
|
+
propTraps
|
|
1443
|
+
);
|
|
1338
1444
|
});
|
|
1339
|
-
res.push(
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1445
|
+
res.push(
|
|
1446
|
+
new Proxy(
|
|
1447
|
+
{
|
|
1448
|
+
get(property) {
|
|
1449
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1450
|
+
},
|
|
1451
|
+
has(property) {
|
|
1452
|
+
return blocked.has(property) ? false : property in props;
|
|
1453
|
+
},
|
|
1454
|
+
keys() {
|
|
1455
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1456
|
+
}
|
|
1457
|
+
},
|
|
1458
|
+
propTraps
|
|
1459
|
+
)
|
|
1460
|
+
);
|
|
1350
1461
|
return res;
|
|
1351
1462
|
}
|
|
1352
1463
|
const otherObject = {};
|
|
1353
1464
|
const objects = keys.map(() => ({}));
|
|
1354
1465
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1355
1466
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1356
|
-
const isDefaultDesc =
|
|
1467
|
+
const isDefaultDesc =
|
|
1468
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1357
1469
|
let blocked = false;
|
|
1358
1470
|
let objectIndex = 0;
|
|
1359
1471
|
for (const k of keys) {
|
|
1360
1472
|
if (k.includes(propName)) {
|
|
1361
1473
|
blocked = true;
|
|
1362
|
-
isDefaultDesc
|
|
1474
|
+
isDefaultDesc
|
|
1475
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1476
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1363
1477
|
}
|
|
1364
1478
|
++objectIndex;
|
|
1365
1479
|
}
|
|
1366
1480
|
if (!blocked) {
|
|
1367
|
-
isDefaultDesc
|
|
1481
|
+
isDefaultDesc
|
|
1482
|
+
? (otherObject[propName] = desc.value)
|
|
1483
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1368
1484
|
}
|
|
1369
1485
|
}
|
|
1370
1486
|
return [...objects, otherObject];
|
|
@@ -1390,17 +1506,21 @@ function lazy(fn) {
|
|
|
1390
1506
|
comp = s;
|
|
1391
1507
|
}
|
|
1392
1508
|
let Comp;
|
|
1393
|
-
return createMemo(
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1509
|
+
return createMemo(
|
|
1510
|
+
() =>
|
|
1511
|
+
(Comp = comp()) &&
|
|
1512
|
+
untrack(() => {
|
|
1513
|
+
if (false);
|
|
1514
|
+
if (!ctx) return Comp(props);
|
|
1515
|
+
const c = sharedConfig.context;
|
|
1516
|
+
setHydrateContext(ctx);
|
|
1517
|
+
const r = Comp(props);
|
|
1518
|
+
setHydrateContext(c);
|
|
1519
|
+
return r;
|
|
1520
|
+
})
|
|
1521
|
+
);
|
|
1402
1522
|
};
|
|
1403
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1523
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1404
1524
|
return wrap;
|
|
1405
1525
|
}
|
|
1406
1526
|
let counter = 0;
|
|
@@ -1425,49 +1545,78 @@ function Index(props) {
|
|
|
1425
1545
|
function Show(props) {
|
|
1426
1546
|
const keyed = props.keyed;
|
|
1427
1547
|
const condition = createMemo(() => props.when, undefined, {
|
|
1428
|
-
equals: (a, b) => keyed ? a === b : !a === !b
|
|
1548
|
+
equals: (a, b) => (keyed ? a === b : !a === !b)
|
|
1429
1549
|
});
|
|
1430
|
-
return createMemo(
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1550
|
+
return createMemo(
|
|
1551
|
+
() => {
|
|
1552
|
+
const c = condition();
|
|
1553
|
+
if (c) {
|
|
1554
|
+
const child = props.children;
|
|
1555
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1556
|
+
return fn
|
|
1557
|
+
? untrack(() =>
|
|
1558
|
+
child(
|
|
1559
|
+
keyed
|
|
1560
|
+
? c
|
|
1561
|
+
: () => {
|
|
1562
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1563
|
+
return props.when;
|
|
1564
|
+
}
|
|
1565
|
+
)
|
|
1566
|
+
)
|
|
1567
|
+
: child;
|
|
1568
|
+
}
|
|
1569
|
+
return props.fallback;
|
|
1570
|
+
},
|
|
1571
|
+
undefined,
|
|
1572
|
+
undefined
|
|
1573
|
+
);
|
|
1442
1574
|
}
|
|
1443
1575
|
function Switch(props) {
|
|
1444
1576
|
let keyed = false;
|
|
1445
|
-
const equals = (a, b) =>
|
|
1577
|
+
const equals = (a, b) =>
|
|
1578
|
+
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1446
1579
|
const conditions = children(() => props.children),
|
|
1447
|
-
evalConditions = createMemo(
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1580
|
+
evalConditions = createMemo(
|
|
1581
|
+
() => {
|
|
1582
|
+
let conds = conditions();
|
|
1583
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1584
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1585
|
+
const c = conds[i].when;
|
|
1586
|
+
if (c) {
|
|
1587
|
+
keyed = !!conds[i].keyed;
|
|
1588
|
+
return [i, c, conds[i]];
|
|
1589
|
+
}
|
|
1455
1590
|
}
|
|
1591
|
+
return [-1];
|
|
1592
|
+
},
|
|
1593
|
+
undefined,
|
|
1594
|
+
{
|
|
1595
|
+
equals
|
|
1456
1596
|
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1597
|
+
);
|
|
1598
|
+
return createMemo(
|
|
1599
|
+
() => {
|
|
1600
|
+
const [index, when, cond] = evalConditions();
|
|
1601
|
+
if (index < 0) return props.fallback;
|
|
1602
|
+
const c = cond.children;
|
|
1603
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1604
|
+
return fn
|
|
1605
|
+
? untrack(() =>
|
|
1606
|
+
c(
|
|
1607
|
+
keyed
|
|
1608
|
+
? when
|
|
1609
|
+
: () => {
|
|
1610
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1611
|
+
return cond.when;
|
|
1612
|
+
}
|
|
1613
|
+
)
|
|
1614
|
+
)
|
|
1615
|
+
: c;
|
|
1616
|
+
},
|
|
1617
|
+
undefined,
|
|
1618
|
+
undefined
|
|
1619
|
+
);
|
|
1471
1620
|
}
|
|
1472
1621
|
function Match(props) {
|
|
1473
1622
|
return props;
|
|
@@ -1478,23 +1627,28 @@ function resetErrorBoundaries() {
|
|
|
1478
1627
|
}
|
|
1479
1628
|
function ErrorBoundary(props) {
|
|
1480
1629
|
let err;
|
|
1481
|
-
|
|
1482
|
-
|
|
1630
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1631
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1483
1632
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1484
1633
|
Errors || (Errors = new Set());
|
|
1485
1634
|
Errors.add(setErrored);
|
|
1486
1635
|
onCleanup(() => Errors.delete(setErrored));
|
|
1487
|
-
return createMemo(
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1636
|
+
return createMemo(
|
|
1637
|
+
() => {
|
|
1638
|
+
let e;
|
|
1639
|
+
if ((e = errored())) {
|
|
1640
|
+
const f = props.fallback;
|
|
1641
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1642
|
+
}
|
|
1643
|
+
return catchError(() => props.children, setErrored);
|
|
1644
|
+
},
|
|
1645
|
+
undefined,
|
|
1646
|
+
undefined
|
|
1647
|
+
);
|
|
1495
1648
|
}
|
|
1496
1649
|
|
|
1497
|
-
const suspenseListEquals = (a, b) =>
|
|
1650
|
+
const suspenseListEquals = (a, b) =>
|
|
1651
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1498
1652
|
const SuspenseListContext = createContext();
|
|
1499
1653
|
function SuspenseList(props) {
|
|
1500
1654
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1506,51 +1660,51 @@ function SuspenseList(props) {
|
|
|
1506
1660
|
if (listContext) {
|
|
1507
1661
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1508
1662
|
}
|
|
1509
|
-
const resolved = createMemo(
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
showContent = true,
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
const res = reg.map(() => ({
|
|
1521
|
-
showContent: all && showContent,
|
|
1522
|
-
showFallback
|
|
1523
|
-
}));
|
|
1524
|
-
res.inFallback = !all;
|
|
1525
|
-
return res;
|
|
1526
|
-
}
|
|
1527
|
-
let stop = false;
|
|
1528
|
-
let inFallback = prev.inFallback;
|
|
1529
|
-
const res = [];
|
|
1530
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1531
|
-
const n = reverse ? len - i - 1 : i,
|
|
1532
|
-
s = reg[n]();
|
|
1533
|
-
if (!stop && !s) {
|
|
1534
|
-
res[n] = {
|
|
1535
|
-
showContent,
|
|
1663
|
+
const resolved = createMemo(
|
|
1664
|
+
prev => {
|
|
1665
|
+
const reveal = props.revealOrder,
|
|
1666
|
+
tail = props.tail,
|
|
1667
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1668
|
+
reg = registry(),
|
|
1669
|
+
reverse = reveal === "backwards";
|
|
1670
|
+
if (reveal === "together") {
|
|
1671
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1672
|
+
const res = reg.map(() => ({
|
|
1673
|
+
showContent: all && showContent,
|
|
1536
1674
|
showFallback
|
|
1537
|
-
};
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1675
|
+
}));
|
|
1676
|
+
res.inFallback = !all;
|
|
1677
|
+
return res;
|
|
1678
|
+
}
|
|
1679
|
+
let stop = false;
|
|
1680
|
+
let inFallback = prev.inFallback;
|
|
1681
|
+
const res = [];
|
|
1682
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1683
|
+
const n = reverse ? len - i - 1 : i,
|
|
1684
|
+
s = reg[n]();
|
|
1685
|
+
if (!stop && !s) {
|
|
1686
|
+
res[n] = {
|
|
1687
|
+
showContent,
|
|
1688
|
+
showFallback
|
|
1689
|
+
};
|
|
1690
|
+
} else {
|
|
1691
|
+
const next = !stop;
|
|
1692
|
+
if (next) inFallback = true;
|
|
1693
|
+
res[n] = {
|
|
1694
|
+
showContent: next,
|
|
1695
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1696
|
+
};
|
|
1697
|
+
stop = true;
|
|
1698
|
+
}
|
|
1546
1699
|
}
|
|
1700
|
+
if (!stop) inFallback = false;
|
|
1701
|
+
res.inFallback = inFallback;
|
|
1702
|
+
return res;
|
|
1703
|
+
},
|
|
1704
|
+
{
|
|
1705
|
+
inFallback: false
|
|
1547
1706
|
}
|
|
1548
|
-
|
|
1549
|
-
res.inFallback = inFallback;
|
|
1550
|
-
return res;
|
|
1551
|
-
}, {
|
|
1552
|
-
inFallback: false
|
|
1553
|
-
});
|
|
1707
|
+
);
|
|
1554
1708
|
setWrapper(() => resolved);
|
|
1555
1709
|
return createComponent(SuspenseListContext.Provider, {
|
|
1556
1710
|
value: {
|
|
@@ -1594,21 +1748,22 @@ function Suspense(props) {
|
|
|
1594
1748
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1595
1749
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1596
1750
|
let ref = sharedConfig.load(key);
|
|
1597
|
-
if (ref && (
|
|
1598
|
-
|
|
1751
|
+
if (ref && (typeof ref !== "object" || !("value" in ref))) p = ref;
|
|
1752
|
+
if (p && p !== "$$f") {
|
|
1599
1753
|
const [s, set] = createSignal(undefined, {
|
|
1600
1754
|
equals: false
|
|
1601
1755
|
});
|
|
1602
1756
|
flicker = s;
|
|
1603
|
-
p.then(
|
|
1604
|
-
if (err || sharedConfig.done) {
|
|
1605
|
-
err && (error = err);
|
|
1606
|
-
return set();
|
|
1607
|
-
}
|
|
1757
|
+
p.then(() => {
|
|
1608
1758
|
sharedConfig.gather(key);
|
|
1609
1759
|
setHydrateContext(ctx);
|
|
1610
1760
|
set();
|
|
1611
1761
|
setHydrateContext();
|
|
1762
|
+
}).catch(err => {
|
|
1763
|
+
if (err || sharedConfig.done) {
|
|
1764
|
+
err && (error = err);
|
|
1765
|
+
return set();
|
|
1766
|
+
}
|
|
1612
1767
|
});
|
|
1613
1768
|
}
|
|
1614
1769
|
}
|
|
@@ -1624,17 +1779,14 @@ function Suspense(props) {
|
|
|
1624
1779
|
ctx = sharedConfig.context;
|
|
1625
1780
|
if (flicker) {
|
|
1626
1781
|
flicker();
|
|
1627
|
-
return flicker = undefined;
|
|
1782
|
+
return (flicker = undefined);
|
|
1628
1783
|
}
|
|
1629
1784
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1630
1785
|
const rendered = createMemo(() => props.children);
|
|
1631
1786
|
return createMemo(prev => {
|
|
1632
1787
|
const inFallback = store.inFallback(),
|
|
1633
|
-
{
|
|
1634
|
-
|
|
1635
|
-
showFallback = true
|
|
1636
|
-
} = show ? show() : {};
|
|
1637
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1788
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1789
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1638
1790
|
store.resolved = true;
|
|
1639
1791
|
dispose && dispose();
|
|
1640
1792
|
dispose = ctx = p = undefined;
|
|
@@ -1662,4 +1814,59 @@ function Suspense(props) {
|
|
|
1662
1814
|
|
|
1663
1815
|
const DEV = undefined;
|
|
1664
1816
|
|
|
1665
|
-
export {
|
|
1817
|
+
export {
|
|
1818
|
+
$DEVCOMP,
|
|
1819
|
+
$PROXY,
|
|
1820
|
+
$TRACK,
|
|
1821
|
+
DEV,
|
|
1822
|
+
ErrorBoundary,
|
|
1823
|
+
For,
|
|
1824
|
+
Index,
|
|
1825
|
+
Match,
|
|
1826
|
+
Show,
|
|
1827
|
+
Suspense,
|
|
1828
|
+
SuspenseList,
|
|
1829
|
+
Switch,
|
|
1830
|
+
batch,
|
|
1831
|
+
cancelCallback,
|
|
1832
|
+
catchError,
|
|
1833
|
+
children,
|
|
1834
|
+
createComponent,
|
|
1835
|
+
createComputed,
|
|
1836
|
+
createContext,
|
|
1837
|
+
createDeferred,
|
|
1838
|
+
createEffect,
|
|
1839
|
+
createMemo,
|
|
1840
|
+
createReaction,
|
|
1841
|
+
createRenderEffect,
|
|
1842
|
+
createResource,
|
|
1843
|
+
createRoot,
|
|
1844
|
+
createSelector,
|
|
1845
|
+
createSignal,
|
|
1846
|
+
createUniqueId,
|
|
1847
|
+
enableExternalSource,
|
|
1848
|
+
enableHydration,
|
|
1849
|
+
enableScheduling,
|
|
1850
|
+
equalFn,
|
|
1851
|
+
from,
|
|
1852
|
+
getListener,
|
|
1853
|
+
getOwner,
|
|
1854
|
+
indexArray,
|
|
1855
|
+
lazy,
|
|
1856
|
+
mapArray,
|
|
1857
|
+
mergeProps,
|
|
1858
|
+
observable,
|
|
1859
|
+
on,
|
|
1860
|
+
onCleanup,
|
|
1861
|
+
onError,
|
|
1862
|
+
onMount,
|
|
1863
|
+
requestCallback,
|
|
1864
|
+
resetErrorBoundaries,
|
|
1865
|
+
runWithOwner,
|
|
1866
|
+
sharedConfig,
|
|
1867
|
+
splitProps,
|
|
1868
|
+
startTransition,
|
|
1869
|
+
untrack,
|
|
1870
|
+
useContext,
|
|
1871
|
+
useTransition
|
|
1872
|
+
};
|