solid-js 1.7.8 → 1.7.10
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 +35 -19
- package/dist/dev.js +558 -309
- package/dist/server.cjs +38 -23
- package/dist/server.js +202 -94
- package/dist/solid.cjs +35 -19
- package/dist/solid.js +485 -267
- package/h/dist/h.cjs +2 -2
- package/h/dist/h.js +36 -10
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +3 -0
- package/h/types/hyperscript.d.ts +11 -11
- package/h/types/index.d.ts +3 -2
- package/html/dist/html.cjs +2 -2
- package/html/dist/html.js +218 -96
- package/html/types/index.d.ts +3 -2
- package/html/types/lit.d.ts +45 -31
- package/package.json +1 -1
- package/store/dist/dev.cjs +36 -33
- package/store/dist/dev.js +143 -68
- package/store/dist/server.js +19 -8
- package/store/dist/store.cjs +36 -33
- package/store/dist/store.js +134 -65
- 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 +220 -63
- package/types/index.d.ts +72 -9
- package/types/jsx.d.ts +3 -0
- 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 +237 -146
- 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 +71 -45
- package/types/server/rendering.d.ts +171 -95
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.js +610 -79
- package/web/dist/server.cjs +5 -1
- package/web/dist/server.js +181 -78
- package/web/dist/web.js +610 -79
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
- package/web/types/server.d.ts +1 -1
package/dist/solid.js
CHANGED
|
@@ -52,9 +52,11 @@ function enqueue(taskQueue, task) {
|
|
|
52
52
|
let m = 0;
|
|
53
53
|
let n = taskQueue.length - 1;
|
|
54
54
|
while (m <= n) {
|
|
55
|
-
const k = n + m >> 1;
|
|
55
|
+
const k = (n + m) >> 1;
|
|
56
56
|
const cmp = task.expirationTime - taskQueue[k].expirationTime;
|
|
57
|
-
if (cmp > 0) m = k + 1;
|
|
57
|
+
if (cmp > 0) m = k + 1;
|
|
58
|
+
else if (cmp < 0) n = k - 1;
|
|
59
|
+
else return k;
|
|
58
60
|
}
|
|
59
61
|
return m;
|
|
60
62
|
}
|
|
@@ -155,17 +157,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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
166
|
+
root = unowned
|
|
167
|
+
? UNOWNED
|
|
168
|
+
: {
|
|
169
|
+
owned: null,
|
|
170
|
+
cleanups: null,
|
|
171
|
+
context: current ? current.context : null,
|
|
172
|
+
owner: current
|
|
173
|
+
},
|
|
169
174
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
170
175
|
Owner = root;
|
|
171
176
|
Listener = null;
|
|
@@ -186,7 +191,8 @@ function createSignal(value, options) {
|
|
|
186
191
|
};
|
|
187
192
|
const setter = value => {
|
|
188
193
|
if (typeof value === "function") {
|
|
189
|
-
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);
|
|
190
196
|
}
|
|
191
197
|
return writeSignal(s, value);
|
|
192
198
|
};
|
|
@@ -194,27 +200,34 @@ function createSignal(value, options) {
|
|
|
194
200
|
}
|
|
195
201
|
function createComputed(fn, value, options) {
|
|
196
202
|
const c = createComputation(fn, value, true, STALE);
|
|
197
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
203
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
204
|
+
else updateComputation(c);
|
|
198
205
|
}
|
|
199
206
|
function createRenderEffect(fn, value, options) {
|
|
200
207
|
const c = createComputation(fn, value, false, STALE);
|
|
201
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
208
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
209
|
+
else updateComputation(c);
|
|
202
210
|
}
|
|
203
211
|
function createEffect(fn, value, options) {
|
|
204
212
|
runEffects = runUserEffects;
|
|
205
213
|
const c = createComputation(fn, value, false, STALE),
|
|
206
|
-
s = SuspenseContext &&
|
|
214
|
+
s = SuspenseContext && useContext(SuspenseContext);
|
|
207
215
|
if (s) c.suspense = s;
|
|
208
216
|
if (!options || !options.render) c.user = true;
|
|
209
217
|
Effects ? Effects.push(c) : updateComputation(c);
|
|
210
218
|
}
|
|
211
219
|
function createReaction(onInvalidate, options) {
|
|
212
220
|
let fn;
|
|
213
|
-
const c = createComputation(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
const c = createComputation(
|
|
222
|
+
() => {
|
|
223
|
+
fn ? fn() : untrack(onInvalidate);
|
|
224
|
+
fn = undefined;
|
|
225
|
+
},
|
|
226
|
+
undefined,
|
|
227
|
+
false,
|
|
228
|
+
0
|
|
229
|
+
),
|
|
230
|
+
s = SuspenseContext && useContext(SuspenseContext);
|
|
218
231
|
if (s) c.suspense = s;
|
|
219
232
|
c.user = true;
|
|
220
233
|
return tracking => {
|
|
@@ -238,7 +251,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
238
251
|
let source;
|
|
239
252
|
let fetcher;
|
|
240
253
|
let options;
|
|
241
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
254
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
242
255
|
source = true;
|
|
243
256
|
fetcher = pSource;
|
|
244
257
|
options = pFetcher || {};
|
|
@@ -252,7 +265,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
252
265
|
id = null,
|
|
253
266
|
loadedUnderTransition = false,
|
|
254
267
|
scheduled = false,
|
|
255
|
-
resolved =
|
|
268
|
+
resolved = "initialValue" in options,
|
|
256
269
|
dynamic = typeof source === "function" && createMemo(source);
|
|
257
270
|
const contexts = new Set(),
|
|
258
271
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -264,15 +277,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
264
277
|
if (sharedConfig.context) {
|
|
265
278
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
266
279
|
let v;
|
|
267
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
280
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
281
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
268
282
|
}
|
|
269
283
|
function loadEnd(p, v, error, key) {
|
|
270
284
|
if (pr === p) {
|
|
271
285
|
pr = null;
|
|
272
286
|
key !== undefined && (resolved = true);
|
|
273
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
274
|
-
|
|
275
|
-
|
|
287
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
288
|
+
queueMicrotask(() =>
|
|
289
|
+
options.onHydrated(key, {
|
|
290
|
+
value: v
|
|
291
|
+
})
|
|
292
|
+
);
|
|
276
293
|
initP = NO_INIT;
|
|
277
294
|
if (Transition && p && loadedUnderTransition) {
|
|
278
295
|
Transition.promises.delete(p);
|
|
@@ -295,7 +312,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
295
312
|
}, false);
|
|
296
313
|
}
|
|
297
314
|
function read() {
|
|
298
|
-
const c = SuspenseContext &&
|
|
315
|
+
const c = SuspenseContext && useContext(SuspenseContext),
|
|
299
316
|
v = value(),
|
|
300
317
|
err = error();
|
|
301
318
|
if (err !== undefined && !pr) throw err;
|
|
@@ -303,7 +320,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
303
320
|
createComputed(() => {
|
|
304
321
|
track();
|
|
305
322
|
if (pr) {
|
|
306
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
323
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
324
|
+
else if (!contexts.has(c)) {
|
|
307
325
|
c.increment();
|
|
308
326
|
contexts.add(c);
|
|
309
327
|
}
|
|
@@ -322,22 +340,30 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
322
340
|
return;
|
|
323
341
|
}
|
|
324
342
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
325
|
-
const p =
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
343
|
+
const p =
|
|
344
|
+
initP !== NO_INIT
|
|
345
|
+
? initP
|
|
346
|
+
: untrack(() =>
|
|
347
|
+
fetcher(lookup, {
|
|
348
|
+
value: value(),
|
|
349
|
+
refetching
|
|
350
|
+
})
|
|
351
|
+
);
|
|
329
352
|
if (typeof p !== "object" || !(p && "then" in p)) {
|
|
330
353
|
loadEnd(pr, p, undefined, lookup);
|
|
331
354
|
return p;
|
|
332
355
|
}
|
|
333
356
|
pr = p;
|
|
334
357
|
scheduled = true;
|
|
335
|
-
queueMicrotask(() => scheduled = false);
|
|
358
|
+
queueMicrotask(() => (scheduled = false));
|
|
336
359
|
runUpdates(() => {
|
|
337
360
|
setState(resolved ? "refreshing" : "pending");
|
|
338
361
|
trigger();
|
|
339
362
|
}, false);
|
|
340
|
-
return p.then(
|
|
363
|
+
return p.then(
|
|
364
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
365
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
366
|
+
);
|
|
341
367
|
}
|
|
342
368
|
Object.defineProperties(read, {
|
|
343
369
|
state: {
|
|
@@ -361,21 +387,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
361
387
|
}
|
|
362
388
|
}
|
|
363
389
|
});
|
|
364
|
-
if (dynamic) createComputed(() => load(false));
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
390
|
+
if (dynamic) createComputed(() => load(false));
|
|
391
|
+
else load(false);
|
|
392
|
+
return [
|
|
393
|
+
read,
|
|
394
|
+
{
|
|
395
|
+
refetch: load,
|
|
396
|
+
mutate: setValue
|
|
397
|
+
}
|
|
398
|
+
];
|
|
369
399
|
}
|
|
370
400
|
function createDeferred(source, options) {
|
|
371
401
|
let t,
|
|
372
402
|
timeout = options ? options.timeoutMs : undefined;
|
|
373
|
-
const node = createComputation(
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
403
|
+
const node = createComputation(
|
|
404
|
+
() => {
|
|
405
|
+
if (!t || !t.fn)
|
|
406
|
+
t = requestCallback(
|
|
407
|
+
() => setDeferred(() => node.value),
|
|
408
|
+
timeout !== undefined
|
|
409
|
+
? {
|
|
410
|
+
timeout
|
|
411
|
+
}
|
|
412
|
+
: undefined
|
|
413
|
+
);
|
|
414
|
+
return source();
|
|
415
|
+
},
|
|
416
|
+
undefined,
|
|
417
|
+
true
|
|
418
|
+
);
|
|
379
419
|
const [deferred, setDeferred] = createSignal(node.value, options);
|
|
380
420
|
updateComputation(node);
|
|
381
421
|
setDeferred(() => node.value);
|
|
@@ -383,28 +423,39 @@ function createDeferred(source, options) {
|
|
|
383
423
|
}
|
|
384
424
|
function createSelector(source, fn = equalFn, options) {
|
|
385
425
|
const subs = new Map();
|
|
386
|
-
const node = createComputation(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
for (const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
426
|
+
const node = createComputation(
|
|
427
|
+
p => {
|
|
428
|
+
const v = source();
|
|
429
|
+
for (const [key, val] of subs.entries())
|
|
430
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
431
|
+
for (const c of val.values()) {
|
|
432
|
+
c.state = STALE;
|
|
433
|
+
if (c.pure) Updates.push(c);
|
|
434
|
+
else Effects.push(c);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return v;
|
|
438
|
+
},
|
|
439
|
+
undefined,
|
|
440
|
+
true,
|
|
441
|
+
STALE
|
|
442
|
+
);
|
|
396
443
|
updateComputation(node);
|
|
397
444
|
return key => {
|
|
398
445
|
const listener = Listener;
|
|
399
446
|
if (listener) {
|
|
400
447
|
let l;
|
|
401
|
-
if (l = subs.get(key)) l.add(listener);
|
|
448
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
449
|
+
else subs.set(key, (l = new Set([listener])));
|
|
402
450
|
onCleanup(() => {
|
|
403
451
|
l.delete(listener);
|
|
404
452
|
!l.size && subs.delete(key);
|
|
405
453
|
});
|
|
406
454
|
}
|
|
407
|
-
return fn(
|
|
455
|
+
return fn(
|
|
456
|
+
key,
|
|
457
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
458
|
+
);
|
|
408
459
|
};
|
|
409
460
|
}
|
|
410
461
|
function batch(fn) {
|
|
@@ -443,13 +494,16 @@ function onMount(fn) {
|
|
|
443
494
|
createEffect(() => untrack(fn));
|
|
444
495
|
}
|
|
445
496
|
function onCleanup(fn) {
|
|
446
|
-
if (Owner === null)
|
|
497
|
+
if (Owner === null);
|
|
498
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
499
|
+
else Owner.cleanups.push(fn);
|
|
447
500
|
return fn;
|
|
448
501
|
}
|
|
449
502
|
function catchError(fn, handler) {
|
|
450
503
|
ERROR || (ERROR = Symbol("error"));
|
|
451
504
|
Owner = createComputation(undefined, undefined, true);
|
|
452
505
|
Owner.context = {
|
|
506
|
+
...Owner.context,
|
|
453
507
|
[ERROR]: [handler]
|
|
454
508
|
};
|
|
455
509
|
if (Transition && Transition.running) Transition.sources.add(Owner);
|
|
@@ -461,12 +515,6 @@ function catchError(fn, handler) {
|
|
|
461
515
|
Owner = Owner.owner;
|
|
462
516
|
}
|
|
463
517
|
}
|
|
464
|
-
function onError(fn) {
|
|
465
|
-
ERROR || (ERROR = Symbol("error"));
|
|
466
|
-
if (Owner === null) ;else if (Owner.context === null) Owner.context = {
|
|
467
|
-
[ERROR]: [fn]
|
|
468
|
-
};else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];else Owner.context[ERROR].push(fn);
|
|
469
|
-
}
|
|
470
518
|
function getListener() {
|
|
471
519
|
return Listener;
|
|
472
520
|
}
|
|
@@ -502,15 +550,17 @@ function startTransition(fn) {
|
|
|
502
550
|
Owner = o;
|
|
503
551
|
let t;
|
|
504
552
|
if (Scheduler || SuspenseContext) {
|
|
505
|
-
t =
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
553
|
+
t =
|
|
554
|
+
Transition ||
|
|
555
|
+
(Transition = {
|
|
556
|
+
sources: new Set(),
|
|
557
|
+
effects: [],
|
|
558
|
+
promises: new Set(),
|
|
559
|
+
disposed: new Set(),
|
|
560
|
+
queue: new Set(),
|
|
561
|
+
running: true
|
|
562
|
+
});
|
|
563
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
514
564
|
t.running = true;
|
|
515
565
|
}
|
|
516
566
|
runUpdates(fn, false);
|
|
@@ -534,8 +584,9 @@ function createContext(defaultValue, options) {
|
|
|
534
584
|
};
|
|
535
585
|
}
|
|
536
586
|
function useContext(context) {
|
|
537
|
-
|
|
538
|
-
|
|
587
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
588
|
+
? Owner.context[context.id]
|
|
589
|
+
: context.defaultValue;
|
|
539
590
|
}
|
|
540
591
|
function children(fn) {
|
|
541
592
|
const children = createMemo(fn);
|
|
@@ -571,7 +622,8 @@ function enableExternalSource(factory) {
|
|
|
571
622
|
function readSignal() {
|
|
572
623
|
const runningTransition = Transition && Transition.running;
|
|
573
624
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
574
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
625
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
626
|
+
else {
|
|
575
627
|
const updates = Updates;
|
|
576
628
|
Updates = null;
|
|
577
629
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -599,11 +651,12 @@ function readSignal() {
|
|
|
599
651
|
return this.value;
|
|
600
652
|
}
|
|
601
653
|
function writeSignal(node, value, isComp) {
|
|
602
|
-
let current =
|
|
654
|
+
let current =
|
|
655
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
603
656
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
604
657
|
if (Transition) {
|
|
605
658
|
const TransitionRunning = Transition.running;
|
|
606
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
659
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
607
660
|
Transition.sources.add(node);
|
|
608
661
|
node.tValue = value;
|
|
609
662
|
}
|
|
@@ -616,14 +669,16 @@ function writeSignal(node, value, isComp) {
|
|
|
616
669
|
const TransitionRunning = Transition && Transition.running;
|
|
617
670
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
618
671
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
619
|
-
if (o.pure) Updates.push(o);
|
|
672
|
+
if (o.pure) Updates.push(o);
|
|
673
|
+
else Effects.push(o);
|
|
620
674
|
if (o.observers) markDownstream(o);
|
|
621
675
|
}
|
|
622
|
-
if (!TransitionRunning) o.state = STALE;
|
|
676
|
+
if (!TransitionRunning) o.state = STALE;
|
|
677
|
+
else o.tState = STALE;
|
|
623
678
|
}
|
|
624
679
|
if (Updates.length > 10e5) {
|
|
625
680
|
Updates = [];
|
|
626
|
-
if (false)
|
|
681
|
+
if (false);
|
|
627
682
|
throw new Error();
|
|
628
683
|
}
|
|
629
684
|
}, false);
|
|
@@ -638,7 +693,11 @@ function updateComputation(node) {
|
|
|
638
693
|
listener = Listener,
|
|
639
694
|
time = ExecCount;
|
|
640
695
|
Listener = Owner = node;
|
|
641
|
-
runComputation(
|
|
696
|
+
runComputation(
|
|
697
|
+
node,
|
|
698
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
699
|
+
time
|
|
700
|
+
);
|
|
642
701
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
643
702
|
queueMicrotask(() => {
|
|
644
703
|
runUpdates(() => {
|
|
@@ -692,18 +751,21 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
692
751
|
cleanups: null,
|
|
693
752
|
value: init,
|
|
694
753
|
owner: Owner,
|
|
695
|
-
context: null,
|
|
754
|
+
context: Owner ? Owner.context : null,
|
|
696
755
|
pure
|
|
697
756
|
};
|
|
698
757
|
if (Transition && Transition.running) {
|
|
699
758
|
c.state = 0;
|
|
700
759
|
c.tState = state;
|
|
701
760
|
}
|
|
702
|
-
if (Owner === null)
|
|
761
|
+
if (Owner === null);
|
|
762
|
+
else if (Owner !== UNOWNED) {
|
|
703
763
|
if (Transition && Transition.running && Owner.pure) {
|
|
704
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
764
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
765
|
+
else Owner.tOwned.push(c);
|
|
705
766
|
} else {
|
|
706
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
767
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
768
|
+
else Owner.owned.push(c);
|
|
707
769
|
}
|
|
708
770
|
}
|
|
709
771
|
if (ExternalSourceFactory) {
|
|
@@ -754,7 +816,8 @@ function runUpdates(fn, init) {
|
|
|
754
816
|
if (Updates) return fn();
|
|
755
817
|
let wait = false;
|
|
756
818
|
if (!init) Updates = [];
|
|
757
|
-
if (Effects) wait = true;
|
|
819
|
+
if (Effects) wait = true;
|
|
820
|
+
else Effects = [];
|
|
758
821
|
ExecCount++;
|
|
759
822
|
try {
|
|
760
823
|
const res = fn();
|
|
@@ -768,7 +831,8 @@ function runUpdates(fn, init) {
|
|
|
768
831
|
}
|
|
769
832
|
function completeUpdates(wait) {
|
|
770
833
|
if (Updates) {
|
|
771
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
834
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
835
|
+
else runQueue(Updates);
|
|
772
836
|
Updates = null;
|
|
773
837
|
}
|
|
774
838
|
if (wait) return;
|
|
@@ -836,7 +900,8 @@ function runUserEffects(queue) {
|
|
|
836
900
|
userLength = 0;
|
|
837
901
|
for (i = 0; i < queue.length; i++) {
|
|
838
902
|
const e = queue[i];
|
|
839
|
-
if (!e.user) runTop(e);
|
|
903
|
+
if (!e.user) runTop(e);
|
|
904
|
+
else queue[userLength++] = e;
|
|
840
905
|
}
|
|
841
906
|
if (sharedConfig.context) {
|
|
842
907
|
if (sharedConfig.count) {
|
|
@@ -854,13 +919,15 @@ function runUserEffects(queue) {
|
|
|
854
919
|
}
|
|
855
920
|
function lookUpstream(node, ignore) {
|
|
856
921
|
const runningTransition = Transition && Transition.running;
|
|
857
|
-
if (runningTransition) node.tState = 0;
|
|
922
|
+
if (runningTransition) node.tState = 0;
|
|
923
|
+
else node.state = 0;
|
|
858
924
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
859
925
|
const source = node.sources[i];
|
|
860
926
|
if (source.sources) {
|
|
861
927
|
const state = runningTransition ? source.tState : source.state;
|
|
862
928
|
if (state === STALE) {
|
|
863
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
929
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
930
|
+
runTop(source);
|
|
864
931
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
865
932
|
}
|
|
866
933
|
}
|
|
@@ -870,8 +937,10 @@ function markDownstream(node) {
|
|
|
870
937
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
871
938
|
const o = node.observers[i];
|
|
872
939
|
if (runningTransition ? !o.tState : !o.state) {
|
|
873
|
-
if (runningTransition) o.tState = PENDING;
|
|
874
|
-
|
|
940
|
+
if (runningTransition) o.tState = PENDING;
|
|
941
|
+
else o.state = PENDING;
|
|
942
|
+
if (o.pure) Updates.push(o);
|
|
943
|
+
else Effects.push(o);
|
|
875
944
|
o.observers && markDownstream(o);
|
|
876
945
|
}
|
|
877
946
|
}
|
|
@@ -908,8 +977,8 @@ function cleanNode(node) {
|
|
|
908
977
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
909
978
|
node.cleanups = null;
|
|
910
979
|
}
|
|
911
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
912
|
-
node.
|
|
980
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
981
|
+
else node.state = 0;
|
|
913
982
|
}
|
|
914
983
|
function reset(node, top) {
|
|
915
984
|
if (!top) {
|
|
@@ -930,22 +999,21 @@ function runErrors(err, fns, owner) {
|
|
|
930
999
|
try {
|
|
931
1000
|
for (const f of fns) f(err);
|
|
932
1001
|
} catch (e) {
|
|
933
|
-
handleError(e, owner && owner.owner || null);
|
|
1002
|
+
handleError(e, (owner && owner.owner) || null);
|
|
934
1003
|
}
|
|
935
1004
|
}
|
|
936
1005
|
function handleError(err, owner = Owner) {
|
|
937
|
-
const fns = ERROR &&
|
|
1006
|
+
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
938
1007
|
const error = castError(err);
|
|
939
1008
|
if (!fns) throw error;
|
|
940
|
-
if (Effects)
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
|
|
1009
|
+
if (Effects)
|
|
1010
|
+
Effects.push({
|
|
1011
|
+
fn() {
|
|
1012
|
+
runErrors(error, fns, owner);
|
|
1013
|
+
},
|
|
1014
|
+
state: STALE
|
|
1015
|
+
});
|
|
1016
|
+
else runErrors(error, fns, owner);
|
|
949
1017
|
}
|
|
950
1018
|
function resolveChildren(children) {
|
|
951
1019
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -962,15 +1030,45 @@ function resolveChildren(children) {
|
|
|
962
1030
|
function createProvider(id, options) {
|
|
963
1031
|
return function provider(props) {
|
|
964
1032
|
let res;
|
|
965
|
-
createRenderEffect(
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1033
|
+
createRenderEffect(
|
|
1034
|
+
() =>
|
|
1035
|
+
(res = untrack(() => {
|
|
1036
|
+
Owner.context = {
|
|
1037
|
+
...Owner.context,
|
|
1038
|
+
[id]: props.value
|
|
1039
|
+
};
|
|
1040
|
+
return children(() => props.children);
|
|
1041
|
+
})),
|
|
1042
|
+
undefined
|
|
1043
|
+
);
|
|
971
1044
|
return res;
|
|
972
1045
|
};
|
|
973
1046
|
}
|
|
1047
|
+
function onError(fn) {
|
|
1048
|
+
ERROR || (ERROR = Symbol("error"));
|
|
1049
|
+
if (Owner === null);
|
|
1050
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1051
|
+
Owner.context = {
|
|
1052
|
+
...Owner.context,
|
|
1053
|
+
[ERROR]: [fn]
|
|
1054
|
+
};
|
|
1055
|
+
mutateContext(Owner, ERROR, [fn]);
|
|
1056
|
+
} else Owner.context[ERROR].push(fn);
|
|
1057
|
+
}
|
|
1058
|
+
function mutateContext(o, key, value) {
|
|
1059
|
+
if (o.owned) {
|
|
1060
|
+
for (let i = 0; i < o.owned.length; i++) {
|
|
1061
|
+
if (o.owned[i].context === o.context) mutateContext(o.owned[i], key, value);
|
|
1062
|
+
if (!o.owned[i].context) {
|
|
1063
|
+
o.owned[i].context = o.context;
|
|
1064
|
+
mutateContext(o.owned[i], key, value);
|
|
1065
|
+
} else if (!o.owned[i].context[key]) {
|
|
1066
|
+
o.owned[i].context[key] = value;
|
|
1067
|
+
mutateContext(o.owned[i], key, value);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
974
1072
|
|
|
975
1073
|
function observable(input) {
|
|
976
1074
|
return {
|
|
@@ -978,7 +1076,8 @@ function observable(input) {
|
|
|
978
1076
|
if (!(observer instanceof Object) || observer == null) {
|
|
979
1077
|
throw new TypeError("Expected the observer to be an object.");
|
|
980
1078
|
}
|
|
981
|
-
const handler =
|
|
1079
|
+
const handler =
|
|
1080
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
982
1081
|
if (!handler) {
|
|
983
1082
|
return {
|
|
984
1083
|
unsubscribe() {}
|
|
@@ -1009,7 +1108,7 @@ function from(producer) {
|
|
|
1009
1108
|
});
|
|
1010
1109
|
if ("subscribe" in producer) {
|
|
1011
1110
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1012
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1111
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1013
1112
|
} else {
|
|
1014
1113
|
const clean = producer(set);
|
|
1015
1114
|
onCleanup(clean);
|
|
@@ -1061,8 +1160,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1061
1160
|
});
|
|
1062
1161
|
len = 1;
|
|
1063
1162
|
}
|
|
1064
|
-
}
|
|
1065
|
-
else if (len === 0) {
|
|
1163
|
+
} else if (len === 0) {
|
|
1066
1164
|
mapped = new Array(newLen);
|
|
1067
1165
|
for (j = 0; j < newLen; j++) {
|
|
1068
1166
|
items[j] = newItems[j];
|
|
@@ -1073,8 +1171,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1073
1171
|
temp = new Array(newLen);
|
|
1074
1172
|
tempdisposers = new Array(newLen);
|
|
1075
1173
|
indexes && (tempIndexes = new Array(newLen));
|
|
1076
|
-
for (
|
|
1077
|
-
|
|
1174
|
+
for (
|
|
1175
|
+
start = 0, end = Math.min(len, newLen);
|
|
1176
|
+
start < end && items[start] === newItems[start];
|
|
1177
|
+
start++
|
|
1178
|
+
);
|
|
1179
|
+
for (
|
|
1180
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1181
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1182
|
+
end--, newEnd--
|
|
1183
|
+
) {
|
|
1078
1184
|
temp[newEnd] = mapped[end];
|
|
1079
1185
|
tempdisposers[newEnd] = disposers[end];
|
|
1080
1186
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1108,7 +1214,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1108
1214
|
}
|
|
1109
1215
|
} else mapped[j] = createRoot(mapper);
|
|
1110
1216
|
}
|
|
1111
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1217
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1112
1218
|
items = newItems.slice(0);
|
|
1113
1219
|
}
|
|
1114
1220
|
return mapped;
|
|
@@ -1174,7 +1280,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1174
1280
|
}
|
|
1175
1281
|
len = signals.length = disposers.length = newItems.length;
|
|
1176
1282
|
items = newItems.slice(0);
|
|
1177
|
-
return mapped = mapped.slice(0, len);
|
|
1283
|
+
return (mapped = mapped.slice(0, len));
|
|
1178
1284
|
});
|
|
1179
1285
|
function mapper(disposer) {
|
|
1180
1286
|
disposers[i] = disposer;
|
|
@@ -1243,29 +1349,33 @@ function mergeProps(...sources) {
|
|
|
1243
1349
|
let proxy = false;
|
|
1244
1350
|
for (let i = 0; i < sources.length; i++) {
|
|
1245
1351
|
const s = sources[i];
|
|
1246
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1247
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1352
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1353
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1248
1354
|
}
|
|
1249
1355
|
if (proxy) {
|
|
1250
|
-
return new Proxy(
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1356
|
+
return new Proxy(
|
|
1357
|
+
{
|
|
1358
|
+
get(property) {
|
|
1359
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1360
|
+
const v = resolveSource(sources[i])[property];
|
|
1361
|
+
if (v !== undefined) return v;
|
|
1362
|
+
}
|
|
1363
|
+
},
|
|
1364
|
+
has(property) {
|
|
1365
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1366
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1367
|
+
}
|
|
1368
|
+
return false;
|
|
1369
|
+
},
|
|
1370
|
+
keys() {
|
|
1371
|
+
const keys = [];
|
|
1372
|
+
for (let i = 0; i < sources.length; i++)
|
|
1373
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1374
|
+
return [...new Set(keys)];
|
|
1260
1375
|
}
|
|
1261
|
-
return false;
|
|
1262
1376
|
},
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1266
|
-
return [...new Set(keys)];
|
|
1267
|
-
}
|
|
1268
|
-
}, propTraps);
|
|
1377
|
+
propTraps
|
|
1378
|
+
);
|
|
1269
1379
|
}
|
|
1270
1380
|
const target = {};
|
|
1271
1381
|
const sourcesMap = {};
|
|
@@ -1284,7 +1394,7 @@ function mergeProps(...sources) {
|
|
|
1284
1394
|
Object.defineProperty(target, key, {
|
|
1285
1395
|
enumerable: true,
|
|
1286
1396
|
configurable: true,
|
|
1287
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1397
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1288
1398
|
});
|
|
1289
1399
|
} else {
|
|
1290
1400
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1308,47 +1418,60 @@ function splitProps(props, ...keys) {
|
|
|
1308
1418
|
if ($PROXY in props) {
|
|
1309
1419
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1310
1420
|
const res = keys.map(k => {
|
|
1311
|
-
return new Proxy(
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1421
|
+
return new Proxy(
|
|
1422
|
+
{
|
|
1423
|
+
get(property) {
|
|
1424
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1425
|
+
},
|
|
1426
|
+
has(property) {
|
|
1427
|
+
return k.includes(property) && property in props;
|
|
1428
|
+
},
|
|
1429
|
+
keys() {
|
|
1430
|
+
return k.filter(property => property in props);
|
|
1431
|
+
}
|
|
1317
1432
|
},
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
}
|
|
1321
|
-
}, propTraps);
|
|
1433
|
+
propTraps
|
|
1434
|
+
);
|
|
1322
1435
|
});
|
|
1323
|
-
res.push(
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1436
|
+
res.push(
|
|
1437
|
+
new Proxy(
|
|
1438
|
+
{
|
|
1439
|
+
get(property) {
|
|
1440
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1441
|
+
},
|
|
1442
|
+
has(property) {
|
|
1443
|
+
return blocked.has(property) ? false : property in props;
|
|
1444
|
+
},
|
|
1445
|
+
keys() {
|
|
1446
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
propTraps
|
|
1450
|
+
)
|
|
1451
|
+
);
|
|
1334
1452
|
return res;
|
|
1335
1453
|
}
|
|
1336
1454
|
const otherObject = {};
|
|
1337
1455
|
const objects = keys.map(() => ({}));
|
|
1338
1456
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1339
1457
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1340
|
-
const isDefaultDesc =
|
|
1458
|
+
const isDefaultDesc =
|
|
1459
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1341
1460
|
let blocked = false;
|
|
1342
1461
|
let objectIndex = 0;
|
|
1343
1462
|
for (const k of keys) {
|
|
1344
1463
|
if (k.includes(propName)) {
|
|
1345
1464
|
blocked = true;
|
|
1346
|
-
isDefaultDesc
|
|
1465
|
+
isDefaultDesc
|
|
1466
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1467
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1347
1468
|
}
|
|
1348
1469
|
++objectIndex;
|
|
1349
1470
|
}
|
|
1350
1471
|
if (!blocked) {
|
|
1351
|
-
isDefaultDesc
|
|
1472
|
+
isDefaultDesc
|
|
1473
|
+
? (otherObject[propName] = desc.value)
|
|
1474
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1352
1475
|
}
|
|
1353
1476
|
}
|
|
1354
1477
|
return [...objects, otherObject];
|
|
@@ -1374,17 +1497,21 @@ function lazy(fn) {
|
|
|
1374
1497
|
comp = s;
|
|
1375
1498
|
}
|
|
1376
1499
|
let Comp;
|
|
1377
|
-
return createMemo(
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1500
|
+
return createMemo(
|
|
1501
|
+
() =>
|
|
1502
|
+
(Comp = comp()) &&
|
|
1503
|
+
untrack(() => {
|
|
1504
|
+
if (false);
|
|
1505
|
+
if (!ctx) return Comp(props);
|
|
1506
|
+
const c = sharedConfig.context;
|
|
1507
|
+
setHydrateContext(ctx);
|
|
1508
|
+
const r = Comp(props);
|
|
1509
|
+
setHydrateContext(c);
|
|
1510
|
+
return r;
|
|
1511
|
+
})
|
|
1512
|
+
);
|
|
1386
1513
|
};
|
|
1387
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1514
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1388
1515
|
return wrap;
|
|
1389
1516
|
}
|
|
1390
1517
|
let counter = 0;
|
|
@@ -1409,49 +1536,78 @@ function Index(props) {
|
|
|
1409
1536
|
function Show(props) {
|
|
1410
1537
|
const keyed = props.keyed;
|
|
1411
1538
|
const condition = createMemo(() => props.when, undefined, {
|
|
1412
|
-
equals: (a, b) => keyed ? a === b : !a === !b
|
|
1539
|
+
equals: (a, b) => (keyed ? a === b : !a === !b)
|
|
1413
1540
|
});
|
|
1414
|
-
return createMemo(
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1541
|
+
return createMemo(
|
|
1542
|
+
() => {
|
|
1543
|
+
const c = condition();
|
|
1544
|
+
if (c) {
|
|
1545
|
+
const child = props.children;
|
|
1546
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1547
|
+
return fn
|
|
1548
|
+
? untrack(() =>
|
|
1549
|
+
child(
|
|
1550
|
+
keyed
|
|
1551
|
+
? c
|
|
1552
|
+
: () => {
|
|
1553
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1554
|
+
return props.when;
|
|
1555
|
+
}
|
|
1556
|
+
)
|
|
1557
|
+
)
|
|
1558
|
+
: child;
|
|
1559
|
+
}
|
|
1560
|
+
return props.fallback;
|
|
1561
|
+
},
|
|
1562
|
+
undefined,
|
|
1563
|
+
undefined
|
|
1564
|
+
);
|
|
1426
1565
|
}
|
|
1427
1566
|
function Switch(props) {
|
|
1428
1567
|
let keyed = false;
|
|
1429
|
-
const equals = (a, b) =>
|
|
1568
|
+
const equals = (a, b) =>
|
|
1569
|
+
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1430
1570
|
const conditions = children(() => props.children),
|
|
1431
|
-
evalConditions = createMemo(
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1571
|
+
evalConditions = createMemo(
|
|
1572
|
+
() => {
|
|
1573
|
+
let conds = conditions();
|
|
1574
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1575
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1576
|
+
const c = conds[i].when;
|
|
1577
|
+
if (c) {
|
|
1578
|
+
keyed = !!conds[i].keyed;
|
|
1579
|
+
return [i, c, conds[i]];
|
|
1580
|
+
}
|
|
1439
1581
|
}
|
|
1582
|
+
return [-1];
|
|
1583
|
+
},
|
|
1584
|
+
undefined,
|
|
1585
|
+
{
|
|
1586
|
+
equals
|
|
1440
1587
|
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1588
|
+
);
|
|
1589
|
+
return createMemo(
|
|
1590
|
+
() => {
|
|
1591
|
+
const [index, when, cond] = evalConditions();
|
|
1592
|
+
if (index < 0) return props.fallback;
|
|
1593
|
+
const c = cond.children;
|
|
1594
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1595
|
+
return fn
|
|
1596
|
+
? untrack(() =>
|
|
1597
|
+
c(
|
|
1598
|
+
keyed
|
|
1599
|
+
? when
|
|
1600
|
+
: () => {
|
|
1601
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1602
|
+
return cond.when;
|
|
1603
|
+
}
|
|
1604
|
+
)
|
|
1605
|
+
)
|
|
1606
|
+
: c;
|
|
1607
|
+
},
|
|
1608
|
+
undefined,
|
|
1609
|
+
undefined
|
|
1610
|
+
);
|
|
1455
1611
|
}
|
|
1456
1612
|
function Match(props) {
|
|
1457
1613
|
return props;
|
|
@@ -1463,22 +1619,32 @@ function resetErrorBoundaries() {
|
|
|
1463
1619
|
function ErrorBoundary(props) {
|
|
1464
1620
|
let err;
|
|
1465
1621
|
let v;
|
|
1466
|
-
if (
|
|
1622
|
+
if (
|
|
1623
|
+
sharedConfig.context &&
|
|
1624
|
+
sharedConfig.load &&
|
|
1625
|
+
(v = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count))
|
|
1626
|
+
)
|
|
1627
|
+
err = v[0];
|
|
1467
1628
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1468
1629
|
Errors || (Errors = new Set());
|
|
1469
1630
|
Errors.add(setErrored);
|
|
1470
1631
|
onCleanup(() => Errors.delete(setErrored));
|
|
1471
|
-
return createMemo(
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1632
|
+
return createMemo(
|
|
1633
|
+
() => {
|
|
1634
|
+
let e;
|
|
1635
|
+
if ((e = errored())) {
|
|
1636
|
+
const f = props.fallback;
|
|
1637
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1638
|
+
}
|
|
1639
|
+
return catchError(() => props.children, setErrored);
|
|
1640
|
+
},
|
|
1641
|
+
undefined,
|
|
1642
|
+
undefined
|
|
1643
|
+
);
|
|
1479
1644
|
}
|
|
1480
1645
|
|
|
1481
|
-
const suspenseListEquals = (a, b) =>
|
|
1646
|
+
const suspenseListEquals = (a, b) =>
|
|
1647
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1482
1648
|
const SuspenseListContext = createContext();
|
|
1483
1649
|
function SuspenseList(props) {
|
|
1484
1650
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1490,51 +1656,51 @@ function SuspenseList(props) {
|
|
|
1490
1656
|
if (listContext) {
|
|
1491
1657
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1492
1658
|
}
|
|
1493
|
-
const resolved = createMemo(
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
showContent = true,
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
const res = reg.map(() => ({
|
|
1505
|
-
showContent: all && showContent,
|
|
1506
|
-
showFallback
|
|
1507
|
-
}));
|
|
1508
|
-
res.inFallback = !all;
|
|
1509
|
-
return res;
|
|
1510
|
-
}
|
|
1511
|
-
let stop = false;
|
|
1512
|
-
let inFallback = prev.inFallback;
|
|
1513
|
-
const res = [];
|
|
1514
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1515
|
-
const n = reverse ? len - i - 1 : i,
|
|
1516
|
-
s = reg[n]();
|
|
1517
|
-
if (!stop && !s) {
|
|
1518
|
-
res[n] = {
|
|
1519
|
-
showContent,
|
|
1659
|
+
const resolved = createMemo(
|
|
1660
|
+
prev => {
|
|
1661
|
+
const reveal = props.revealOrder,
|
|
1662
|
+
tail = props.tail,
|
|
1663
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1664
|
+
reg = registry(),
|
|
1665
|
+
reverse = reveal === "backwards";
|
|
1666
|
+
if (reveal === "together") {
|
|
1667
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1668
|
+
const res = reg.map(() => ({
|
|
1669
|
+
showContent: all && showContent,
|
|
1520
1670
|
showFallback
|
|
1521
|
-
};
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
if (next) inFallback = true;
|
|
1525
|
-
res[n] = {
|
|
1526
|
-
showContent: next,
|
|
1527
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1528
|
-
};
|
|
1529
|
-
stop = true;
|
|
1671
|
+
}));
|
|
1672
|
+
res.inFallback = !all;
|
|
1673
|
+
return res;
|
|
1530
1674
|
}
|
|
1675
|
+
let stop = false;
|
|
1676
|
+
let inFallback = prev.inFallback;
|
|
1677
|
+
const res = [];
|
|
1678
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1679
|
+
const n = reverse ? len - i - 1 : i,
|
|
1680
|
+
s = reg[n]();
|
|
1681
|
+
if (!stop && !s) {
|
|
1682
|
+
res[n] = {
|
|
1683
|
+
showContent,
|
|
1684
|
+
showFallback
|
|
1685
|
+
};
|
|
1686
|
+
} else {
|
|
1687
|
+
const next = !stop;
|
|
1688
|
+
if (next) inFallback = true;
|
|
1689
|
+
res[n] = {
|
|
1690
|
+
showContent: next,
|
|
1691
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1692
|
+
};
|
|
1693
|
+
stop = true;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
if (!stop) inFallback = false;
|
|
1697
|
+
res.inFallback = inFallback;
|
|
1698
|
+
return res;
|
|
1699
|
+
},
|
|
1700
|
+
{
|
|
1701
|
+
inFallback: false
|
|
1531
1702
|
}
|
|
1532
|
-
|
|
1533
|
-
res.inFallback = inFallback;
|
|
1534
|
-
return res;
|
|
1535
|
-
}, {
|
|
1536
|
-
inFallback: false
|
|
1537
|
-
});
|
|
1703
|
+
);
|
|
1538
1704
|
setWrapper(() => resolved);
|
|
1539
1705
|
return createComponent(SuspenseListContext.Provider, {
|
|
1540
1706
|
value: {
|
|
@@ -1608,17 +1774,14 @@ function Suspense(props) {
|
|
|
1608
1774
|
ctx = sharedConfig.context;
|
|
1609
1775
|
if (flicker) {
|
|
1610
1776
|
flicker();
|
|
1611
|
-
return flicker = undefined;
|
|
1777
|
+
return (flicker = undefined);
|
|
1612
1778
|
}
|
|
1613
1779
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1614
1780
|
const rendered = createMemo(() => props.children);
|
|
1615
1781
|
return createMemo(prev => {
|
|
1616
1782
|
const inFallback = store.inFallback(),
|
|
1617
|
-
{
|
|
1618
|
-
|
|
1619
|
-
showFallback = true
|
|
1620
|
-
} = show ? show() : {};
|
|
1621
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1783
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1784
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1622
1785
|
store.resolved = true;
|
|
1623
1786
|
dispose && dispose();
|
|
1624
1787
|
dispose = ctx = p = undefined;
|
|
@@ -1646,4 +1809,59 @@ function Suspense(props) {
|
|
|
1646
1809
|
|
|
1647
1810
|
const DEV = undefined;
|
|
1648
1811
|
|
|
1649
|
-
export {
|
|
1812
|
+
export {
|
|
1813
|
+
$DEVCOMP,
|
|
1814
|
+
$PROXY,
|
|
1815
|
+
$TRACK,
|
|
1816
|
+
DEV,
|
|
1817
|
+
ErrorBoundary,
|
|
1818
|
+
For,
|
|
1819
|
+
Index,
|
|
1820
|
+
Match,
|
|
1821
|
+
Show,
|
|
1822
|
+
Suspense,
|
|
1823
|
+
SuspenseList,
|
|
1824
|
+
Switch,
|
|
1825
|
+
batch,
|
|
1826
|
+
cancelCallback,
|
|
1827
|
+
catchError,
|
|
1828
|
+
children,
|
|
1829
|
+
createComponent,
|
|
1830
|
+
createComputed,
|
|
1831
|
+
createContext,
|
|
1832
|
+
createDeferred,
|
|
1833
|
+
createEffect,
|
|
1834
|
+
createMemo,
|
|
1835
|
+
createReaction,
|
|
1836
|
+
createRenderEffect,
|
|
1837
|
+
createResource,
|
|
1838
|
+
createRoot,
|
|
1839
|
+
createSelector,
|
|
1840
|
+
createSignal,
|
|
1841
|
+
createUniqueId,
|
|
1842
|
+
enableExternalSource,
|
|
1843
|
+
enableHydration,
|
|
1844
|
+
enableScheduling,
|
|
1845
|
+
equalFn,
|
|
1846
|
+
from,
|
|
1847
|
+
getListener,
|
|
1848
|
+
getOwner,
|
|
1849
|
+
indexArray,
|
|
1850
|
+
lazy,
|
|
1851
|
+
mapArray,
|
|
1852
|
+
mergeProps,
|
|
1853
|
+
observable,
|
|
1854
|
+
on,
|
|
1855
|
+
onCleanup,
|
|
1856
|
+
onError,
|
|
1857
|
+
onMount,
|
|
1858
|
+
requestCallback,
|
|
1859
|
+
resetErrorBoundaries,
|
|
1860
|
+
runWithOwner,
|
|
1861
|
+
sharedConfig,
|
|
1862
|
+
splitProps,
|
|
1863
|
+
startTransition,
|
|
1864
|
+
untrack,
|
|
1865
|
+
useContext,
|
|
1866
|
+
useTransition
|
|
1867
|
+
};
|