solid-js 1.8.7 → 1.8.8
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 +30 -20
- package/dist/dev.js +327 -552
- package/dist/server.js +75 -170
- package/dist/solid.cjs +30 -20
- package/dist/solid.js +285 -479
- package/h/dist/h.js +8 -34
- 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 +15 -1
- 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 +2 -2
- package/store/dist/dev.cjs +3 -2
- package/store/dist/dev.js +44 -115
- package/store/dist/server.js +8 -19
- package/store/dist/store.cjs +3 -2
- package/store/dist/store.js +41 -106
- 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 +15 -1
- 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 -231
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +33 -62
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +2 -57
- package/types/server/reactive.d.ts +42 -73
- package/types/server/rendering.d.ts +96 -167
- 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 +81 -620
- package/web/dist/server.cjs +7 -2
- package/web/dist/server.js +102 -179
- package/web/dist/storage.js +3 -3
- package/web/dist/web.js +80 -614
- 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
|
}
|
|
@@ -152,7 +150,7 @@ const NO_INIT = {};
|
|
|
152
150
|
var Owner = null;
|
|
153
151
|
let Transition = null;
|
|
154
152
|
let Scheduler = null;
|
|
155
|
-
let
|
|
153
|
+
let ExternalSourceConfig = null;
|
|
156
154
|
let Listener = null;
|
|
157
155
|
let Updates = null;
|
|
158
156
|
let Effects = null;
|
|
@@ -162,14 +160,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
162
160
|
owner = Owner,
|
|
163
161
|
unowned = fn.length === 0,
|
|
164
162
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
165
|
-
root = unowned
|
|
166
|
-
|
|
167
|
-
:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
owner: current
|
|
172
|
-
},
|
|
163
|
+
root = unowned ? UNOWNED : {
|
|
164
|
+
owned: null,
|
|
165
|
+
cleanups: null,
|
|
166
|
+
context: current ? current.context : null,
|
|
167
|
+
owner: current
|
|
168
|
+
},
|
|
173
169
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
174
170
|
Owner = root;
|
|
175
171
|
Listener = null;
|
|
@@ -190,8 +186,7 @@ function createSignal(value, options) {
|
|
|
190
186
|
};
|
|
191
187
|
const setter = value => {
|
|
192
188
|
if (typeof value === "function") {
|
|
193
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
194
|
-
else value = value(s.value);
|
|
189
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);else value = value(s.value);
|
|
195
190
|
}
|
|
196
191
|
return writeSignal(s, value);
|
|
197
192
|
};
|
|
@@ -199,13 +194,11 @@ function createSignal(value, options) {
|
|
|
199
194
|
}
|
|
200
195
|
function createComputed(fn, value, options) {
|
|
201
196
|
const c = createComputation(fn, value, true, STALE);
|
|
202
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
203
|
-
else updateComputation(c);
|
|
197
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
204
198
|
}
|
|
205
199
|
function createRenderEffect(fn, value, options) {
|
|
206
200
|
const c = createComputation(fn, value, false, STALE);
|
|
207
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
208
|
-
else updateComputation(c);
|
|
201
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
209
202
|
}
|
|
210
203
|
function createEffect(fn, value, options) {
|
|
211
204
|
runEffects = runUserEffects;
|
|
@@ -217,15 +210,10 @@ function createEffect(fn, value, options) {
|
|
|
217
210
|
}
|
|
218
211
|
function createReaction(onInvalidate, options) {
|
|
219
212
|
let fn;
|
|
220
|
-
const c = createComputation(
|
|
221
|
-
()
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
},
|
|
225
|
-
undefined,
|
|
226
|
-
false,
|
|
227
|
-
0
|
|
228
|
-
),
|
|
213
|
+
const c = createComputation(() => {
|
|
214
|
+
fn ? fn() : untrack(onInvalidate);
|
|
215
|
+
fn = undefined;
|
|
216
|
+
}, undefined, false, 0),
|
|
229
217
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
230
218
|
if (s) c.suspense = s;
|
|
231
219
|
c.user = true;
|
|
@@ -253,7 +241,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
253
241
|
let source;
|
|
254
242
|
let fetcher;
|
|
255
243
|
let options;
|
|
256
|
-
if (
|
|
244
|
+
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
257
245
|
source = true;
|
|
258
246
|
fetcher = pSource;
|
|
259
247
|
options = pFetcher || {};
|
|
@@ -267,7 +255,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
267
255
|
id = null,
|
|
268
256
|
loadedUnderTransition = false,
|
|
269
257
|
scheduled = false,
|
|
270
|
-
resolved = "initialValue" in options,
|
|
258
|
+
resolved = ("initialValue" in options),
|
|
271
259
|
dynamic = typeof source === "function" && createMemo(source);
|
|
272
260
|
const contexts = new Set(),
|
|
273
261
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -279,19 +267,15 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
279
267
|
if (sharedConfig.context) {
|
|
280
268
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
281
269
|
let v;
|
|
282
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
283
|
-
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
|
|
270
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
|
|
284
271
|
}
|
|
285
272
|
function loadEnd(p, v, error, key) {
|
|
286
273
|
if (pr === p) {
|
|
287
274
|
pr = null;
|
|
288
275
|
key !== undefined && (resolved = true);
|
|
289
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
value: v
|
|
293
|
-
})
|
|
294
|
-
);
|
|
276
|
+
if ((p === initP || v === initP) && options.onHydrated) queueMicrotask(() => options.onHydrated(key, {
|
|
277
|
+
value: v
|
|
278
|
+
}));
|
|
295
279
|
initP = NO_INIT;
|
|
296
280
|
if (Transition && p && loadedUnderTransition) {
|
|
297
281
|
Transition.promises.delete(p);
|
|
@@ -322,8 +306,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
322
306
|
createComputed(() => {
|
|
323
307
|
track();
|
|
324
308
|
if (pr) {
|
|
325
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
326
|
-
else if (!contexts.has(c)) {
|
|
309
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);else if (!contexts.has(c)) {
|
|
327
310
|
c.increment();
|
|
328
311
|
contexts.add(c);
|
|
329
312
|
}
|
|
@@ -342,35 +325,26 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
342
325
|
return;
|
|
343
326
|
}
|
|
344
327
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
345
|
-
const p =
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
fetcher(lookup, {
|
|
350
|
-
value: value(),
|
|
351
|
-
refetching
|
|
352
|
-
})
|
|
353
|
-
);
|
|
328
|
+
const p = initP !== NO_INIT ? initP : untrack(() => fetcher(lookup, {
|
|
329
|
+
value: value(),
|
|
330
|
+
refetching
|
|
331
|
+
}));
|
|
354
332
|
if (!isPromise(p)) {
|
|
355
333
|
loadEnd(pr, p, undefined, lookup);
|
|
356
334
|
return p;
|
|
357
335
|
}
|
|
358
336
|
pr = p;
|
|
359
337
|
if ("value" in p) {
|
|
360
|
-
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
361
|
-
else loadEnd(pr, undefined, undefined, lookup);
|
|
338
|
+
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);else loadEnd(pr, undefined, undefined, lookup);
|
|
362
339
|
return p;
|
|
363
340
|
}
|
|
364
341
|
scheduled = true;
|
|
365
|
-
queueMicrotask(() =>
|
|
342
|
+
queueMicrotask(() => scheduled = false);
|
|
366
343
|
runUpdates(() => {
|
|
367
344
|
setState(resolved ? "refreshing" : "pending");
|
|
368
345
|
trigger();
|
|
369
346
|
}, false);
|
|
370
|
-
return p.then(
|
|
371
|
-
v => loadEnd(p, v, undefined, lookup),
|
|
372
|
-
e => loadEnd(p, undefined, castError(e), lookup)
|
|
373
|
-
);
|
|
347
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, undefined, castError(e), lookup));
|
|
374
348
|
}
|
|
375
349
|
Object.defineProperties(read, {
|
|
376
350
|
state: {
|
|
@@ -394,90 +368,61 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
394
368
|
}
|
|
395
369
|
}
|
|
396
370
|
});
|
|
397
|
-
if (dynamic) createComputed(() => load(false));
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
refetch: load,
|
|
403
|
-
mutate: setValue
|
|
404
|
-
}
|
|
405
|
-
];
|
|
371
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
372
|
+
return [read, {
|
|
373
|
+
refetch: load,
|
|
374
|
+
mutate: setValue
|
|
375
|
+
}];
|
|
406
376
|
}
|
|
407
377
|
function createDeferred(source, options) {
|
|
408
378
|
let t,
|
|
409
379
|
timeout = options ? options.timeoutMs : undefined;
|
|
410
|
-
const node = createComputation(
|
|
411
|
-
() => {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
timeout
|
|
418
|
-
}
|
|
419
|
-
: undefined
|
|
420
|
-
);
|
|
421
|
-
return source();
|
|
422
|
-
},
|
|
423
|
-
undefined,
|
|
424
|
-
true
|
|
425
|
-
);
|
|
426
|
-
const [deferred, setDeferred] = createSignal(
|
|
427
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
428
|
-
options
|
|
429
|
-
);
|
|
380
|
+
const node = createComputation(() => {
|
|
381
|
+
if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
|
|
382
|
+
timeout
|
|
383
|
+
} : undefined);
|
|
384
|
+
return source();
|
|
385
|
+
}, undefined, true);
|
|
386
|
+
const [deferred, setDeferred] = createSignal(Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, options);
|
|
430
387
|
updateComputation(node);
|
|
431
|
-
setDeferred(() =>
|
|
432
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
433
|
-
);
|
|
388
|
+
setDeferred(() => Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
434
389
|
return deferred;
|
|
435
390
|
}
|
|
436
391
|
function createSelector(source, fn = equalFn, options) {
|
|
437
392
|
const subs = new Map();
|
|
438
|
-
const node = createComputation(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
for (const
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
return v;
|
|
450
|
-
},
|
|
451
|
-
undefined,
|
|
452
|
-
true,
|
|
453
|
-
STALE
|
|
454
|
-
);
|
|
393
|
+
const node = createComputation(p => {
|
|
394
|
+
const v = source();
|
|
395
|
+
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
396
|
+
for (const c of val.values()) {
|
|
397
|
+
c.state = STALE;
|
|
398
|
+
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return v;
|
|
402
|
+
}, undefined, true, STALE);
|
|
455
403
|
updateComputation(node);
|
|
456
404
|
return key => {
|
|
457
405
|
const listener = Listener;
|
|
458
406
|
if (listener) {
|
|
459
407
|
let l;
|
|
460
|
-
if (
|
|
461
|
-
else subs.set(key, (l = new Set([listener])));
|
|
408
|
+
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
462
409
|
onCleanup(() => {
|
|
463
410
|
l.delete(listener);
|
|
464
411
|
!l.size && subs.delete(key);
|
|
465
412
|
});
|
|
466
413
|
}
|
|
467
|
-
return fn(
|
|
468
|
-
key,
|
|
469
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
470
|
-
);
|
|
414
|
+
return fn(key, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
471
415
|
};
|
|
472
416
|
}
|
|
473
417
|
function batch(fn) {
|
|
474
418
|
return runUpdates(fn, false);
|
|
475
419
|
}
|
|
476
420
|
function untrack(fn) {
|
|
477
|
-
if (Listener === null) return fn();
|
|
421
|
+
if (!ExternalSourceConfig && Listener === null) return fn();
|
|
478
422
|
const listener = Listener;
|
|
479
423
|
Listener = null;
|
|
480
424
|
try {
|
|
425
|
+
if (ExternalSourceConfig) return ExternalSourceConfig.untrack(fn);
|
|
481
426
|
return fn();
|
|
482
427
|
} finally {
|
|
483
428
|
Listener = listener;
|
|
@@ -506,9 +451,7 @@ function onMount(fn) {
|
|
|
506
451
|
createEffect(() => untrack(fn));
|
|
507
452
|
}
|
|
508
453
|
function onCleanup(fn) {
|
|
509
|
-
if (Owner === null);
|
|
510
|
-
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
511
|
-
else Owner.cleanups.push(fn);
|
|
454
|
+
if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
512
455
|
return fn;
|
|
513
456
|
}
|
|
514
457
|
function catchError(fn, handler) {
|
|
@@ -562,17 +505,15 @@ function startTransition(fn) {
|
|
|
562
505
|
Owner = o;
|
|
563
506
|
let t;
|
|
564
507
|
if (Scheduler || SuspenseContext) {
|
|
565
|
-
t =
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
});
|
|
575
|
-
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
508
|
+
t = Transition || (Transition = {
|
|
509
|
+
sources: new Set(),
|
|
510
|
+
effects: [],
|
|
511
|
+
promises: new Set(),
|
|
512
|
+
disposed: new Set(),
|
|
513
|
+
queue: new Set(),
|
|
514
|
+
running: true
|
|
515
|
+
});
|
|
516
|
+
t.done || (t.done = new Promise(res => t.resolve = res));
|
|
576
517
|
t.running = true;
|
|
577
518
|
}
|
|
578
519
|
runUpdates(fn, false);
|
|
@@ -580,7 +521,7 @@ function startTransition(fn) {
|
|
|
580
521
|
return t ? t.done : undefined;
|
|
581
522
|
});
|
|
582
523
|
}
|
|
583
|
-
const [transPending, setTransPending] = /*@__PURE__*/
|
|
524
|
+
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
584
525
|
function useTransition() {
|
|
585
526
|
return [transPending, startTransition];
|
|
586
527
|
}
|
|
@@ -597,9 +538,7 @@ function createContext(defaultValue, options) {
|
|
|
597
538
|
};
|
|
598
539
|
}
|
|
599
540
|
function useContext(context) {
|
|
600
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
601
|
-
? Owner.context[context.id]
|
|
602
|
-
: context.defaultValue;
|
|
541
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
|
|
603
542
|
}
|
|
604
543
|
function children(fn) {
|
|
605
544
|
const children = createMemo(fn);
|
|
@@ -614,29 +553,37 @@ let SuspenseContext;
|
|
|
614
553
|
function getSuspenseContext() {
|
|
615
554
|
return SuspenseContext || (SuspenseContext = createContext());
|
|
616
555
|
}
|
|
617
|
-
function enableExternalSource(factory) {
|
|
618
|
-
if (
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
556
|
+
function enableExternalSource(factory, untrack = fn => fn()) {
|
|
557
|
+
if (ExternalSourceConfig) {
|
|
558
|
+
const {
|
|
559
|
+
factory: oldFactory,
|
|
560
|
+
untrack: oldUntrack
|
|
561
|
+
} = ExternalSourceConfig;
|
|
562
|
+
ExternalSourceConfig = {
|
|
563
|
+
factory: (fn, trigger) => {
|
|
564
|
+
const oldSource = oldFactory(fn, trigger);
|
|
565
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
566
|
+
return {
|
|
567
|
+
track: x => source.track(x),
|
|
568
|
+
dispose() {
|
|
569
|
+
source.dispose();
|
|
570
|
+
oldSource.dispose();
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
},
|
|
574
|
+
untrack: fn => oldUntrack(() => untrack(fn))
|
|
630
575
|
};
|
|
631
576
|
} else {
|
|
632
|
-
|
|
577
|
+
ExternalSourceConfig = {
|
|
578
|
+
factory,
|
|
579
|
+
untrack
|
|
580
|
+
};
|
|
633
581
|
}
|
|
634
582
|
}
|
|
635
583
|
function readSignal() {
|
|
636
584
|
const runningTransition = Transition && Transition.running;
|
|
637
585
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
638
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
639
|
-
else {
|
|
586
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
|
|
640
587
|
const updates = Updates;
|
|
641
588
|
Updates = null;
|
|
642
589
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -664,12 +611,11 @@ function readSignal() {
|
|
|
664
611
|
return this.value;
|
|
665
612
|
}
|
|
666
613
|
function writeSignal(node, value, isComp) {
|
|
667
|
-
let current =
|
|
668
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
614
|
+
let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
669
615
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
670
616
|
if (Transition) {
|
|
671
617
|
const TransitionRunning = Transition.running;
|
|
672
|
-
if (TransitionRunning ||
|
|
618
|
+
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
673
619
|
Transition.sources.add(node);
|
|
674
620
|
node.tValue = value;
|
|
675
621
|
}
|
|
@@ -682,16 +628,14 @@ function writeSignal(node, value, isComp) {
|
|
|
682
628
|
const TransitionRunning = Transition && Transition.running;
|
|
683
629
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
684
630
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
685
|
-
if (o.pure) Updates.push(o);
|
|
686
|
-
else Effects.push(o);
|
|
631
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
687
632
|
if (o.observers) markDownstream(o);
|
|
688
633
|
}
|
|
689
|
-
if (!TransitionRunning) o.state = STALE;
|
|
690
|
-
else o.tState = STALE;
|
|
634
|
+
if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
|
|
691
635
|
}
|
|
692
636
|
if (Updates.length > 10e5) {
|
|
693
637
|
Updates = [];
|
|
694
|
-
if (false);
|
|
638
|
+
if (false) ;
|
|
695
639
|
throw new Error();
|
|
696
640
|
}
|
|
697
641
|
}, false);
|
|
@@ -703,11 +647,7 @@ function updateComputation(node) {
|
|
|
703
647
|
if (!node.fn) return;
|
|
704
648
|
cleanNode(node);
|
|
705
649
|
const time = ExecCount;
|
|
706
|
-
runComputation(
|
|
707
|
-
node,
|
|
708
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
709
|
-
time
|
|
710
|
-
);
|
|
650
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
711
651
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
712
652
|
queueMicrotask(() => {
|
|
713
653
|
runUpdates(() => {
|
|
@@ -772,24 +712,21 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
772
712
|
c.state = 0;
|
|
773
713
|
c.tState = state;
|
|
774
714
|
}
|
|
775
|
-
if (Owner === null);
|
|
776
|
-
else if (Owner !== UNOWNED) {
|
|
715
|
+
if (Owner === null) ;else if (Owner !== UNOWNED) {
|
|
777
716
|
if (Transition && Transition.running && Owner.pure) {
|
|
778
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
779
|
-
else Owner.tOwned.push(c);
|
|
717
|
+
if (!Owner.tOwned) Owner.tOwned = [c];else Owner.tOwned.push(c);
|
|
780
718
|
} else {
|
|
781
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
782
|
-
else Owner.owned.push(c);
|
|
719
|
+
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
783
720
|
}
|
|
784
721
|
}
|
|
785
|
-
if (
|
|
722
|
+
if (ExternalSourceConfig && c.fn) {
|
|
786
723
|
const [track, trigger] = createSignal(undefined, {
|
|
787
724
|
equals: false
|
|
788
725
|
});
|
|
789
|
-
const ordinary =
|
|
726
|
+
const ordinary = ExternalSourceConfig.factory(c.fn, trigger);
|
|
790
727
|
onCleanup(() => ordinary.dispose());
|
|
791
728
|
const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
|
|
792
|
-
const inTransition =
|
|
729
|
+
const inTransition = ExternalSourceConfig.factory(c.fn, triggerInTransition);
|
|
793
730
|
c.fn = x => {
|
|
794
731
|
track();
|
|
795
732
|
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
@@ -830,8 +767,7 @@ function runUpdates(fn, init) {
|
|
|
830
767
|
if (Updates) return fn();
|
|
831
768
|
let wait = false;
|
|
832
769
|
if (!init) Updates = [];
|
|
833
|
-
if (Effects) wait = true;
|
|
834
|
-
else Effects = [];
|
|
770
|
+
if (Effects) wait = true;else Effects = [];
|
|
835
771
|
ExecCount++;
|
|
836
772
|
try {
|
|
837
773
|
const res = fn();
|
|
@@ -845,8 +781,7 @@ function runUpdates(fn, init) {
|
|
|
845
781
|
}
|
|
846
782
|
function completeUpdates(wait) {
|
|
847
783
|
if (Updates) {
|
|
848
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
849
|
-
else runQueue(Updates);
|
|
784
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);else runQueue(Updates);
|
|
850
785
|
Updates = null;
|
|
851
786
|
}
|
|
852
787
|
if (wait) return;
|
|
@@ -914,8 +849,7 @@ function runUserEffects(queue) {
|
|
|
914
849
|
userLength = 0;
|
|
915
850
|
for (i = 0; i < queue.length; i++) {
|
|
916
851
|
const e = queue[i];
|
|
917
|
-
if (!e.user) runTop(e);
|
|
918
|
-
else queue[userLength++] = e;
|
|
852
|
+
if (!e.user) runTop(e);else queue[userLength++] = e;
|
|
919
853
|
}
|
|
920
854
|
if (sharedConfig.context) {
|
|
921
855
|
if (sharedConfig.count) {
|
|
@@ -933,15 +867,13 @@ function runUserEffects(queue) {
|
|
|
933
867
|
}
|
|
934
868
|
function lookUpstream(node, ignore) {
|
|
935
869
|
const runningTransition = Transition && Transition.running;
|
|
936
|
-
if (runningTransition) node.tState = 0;
|
|
937
|
-
else node.state = 0;
|
|
870
|
+
if (runningTransition) node.tState = 0;else node.state = 0;
|
|
938
871
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
939
872
|
const source = node.sources[i];
|
|
940
873
|
if (source.sources) {
|
|
941
874
|
const state = runningTransition ? source.tState : source.state;
|
|
942
875
|
if (state === STALE) {
|
|
943
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
944
|
-
runTop(source);
|
|
876
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
|
|
945
877
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
946
878
|
}
|
|
947
879
|
}
|
|
@@ -951,10 +883,8 @@ function markDownstream(node) {
|
|
|
951
883
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
952
884
|
const o = node.observers[i];
|
|
953
885
|
if (runningTransition ? !o.tState : !o.state) {
|
|
954
|
-
if (runningTransition) o.tState = PENDING;
|
|
955
|
-
|
|
956
|
-
if (o.pure) Updates.push(o);
|
|
957
|
-
else Effects.push(o);
|
|
886
|
+
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
887
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
958
888
|
o.observers && markDownstream(o);
|
|
959
889
|
}
|
|
960
890
|
}
|
|
@@ -991,8 +921,7 @@ function cleanNode(node) {
|
|
|
991
921
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
992
922
|
node.cleanups = null;
|
|
993
923
|
}
|
|
994
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
995
|
-
else node.state = 0;
|
|
924
|
+
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
996
925
|
}
|
|
997
926
|
function reset(node, top) {
|
|
998
927
|
if (!top) {
|
|
@@ -1013,21 +942,19 @@ function runErrors(err, fns, owner) {
|
|
|
1013
942
|
try {
|
|
1014
943
|
for (const f of fns) f(err);
|
|
1015
944
|
} catch (e) {
|
|
1016
|
-
handleError(e,
|
|
945
|
+
handleError(e, owner && owner.owner || null);
|
|
1017
946
|
}
|
|
1018
947
|
}
|
|
1019
948
|
function handleError(err, owner = Owner) {
|
|
1020
949
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
1021
950
|
const error = castError(err);
|
|
1022
951
|
if (!fns) throw error;
|
|
1023
|
-
if (Effects)
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
});
|
|
1030
|
-
else runErrors(error, fns, owner);
|
|
952
|
+
if (Effects) Effects.push({
|
|
953
|
+
fn() {
|
|
954
|
+
runErrors(error, fns, owner);
|
|
955
|
+
},
|
|
956
|
+
state: STALE
|
|
957
|
+
});else runErrors(error, fns, owner);
|
|
1031
958
|
}
|
|
1032
959
|
function resolveChildren(children) {
|
|
1033
960
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1044,24 +971,19 @@ function resolveChildren(children) {
|
|
|
1044
971
|
function createProvider(id, options) {
|
|
1045
972
|
return function provider(props) {
|
|
1046
973
|
let res;
|
|
1047
|
-
createRenderEffect(
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
return children(() => props.children);
|
|
1055
|
-
})),
|
|
1056
|
-
undefined
|
|
1057
|
-
);
|
|
974
|
+
createRenderEffect(() => res = untrack(() => {
|
|
975
|
+
Owner.context = {
|
|
976
|
+
...Owner.context,
|
|
977
|
+
[id]: props.value
|
|
978
|
+
};
|
|
979
|
+
return children(() => props.children);
|
|
980
|
+
}), undefined);
|
|
1058
981
|
return res;
|
|
1059
982
|
};
|
|
1060
983
|
}
|
|
1061
984
|
function onError(fn) {
|
|
1062
985
|
ERROR || (ERROR = Symbol("error"));
|
|
1063
|
-
if (Owner === null);
|
|
1064
|
-
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
986
|
+
if (Owner === null) ;else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1065
987
|
Owner.context = {
|
|
1066
988
|
...Owner.context,
|
|
1067
989
|
[ERROR]: [fn]
|
|
@@ -1090,8 +1012,7 @@ function observable(input) {
|
|
|
1090
1012
|
if (!(observer instanceof Object) || observer == null) {
|
|
1091
1013
|
throw new TypeError("Expected the observer to be an object.");
|
|
1092
1014
|
}
|
|
1093
|
-
const handler =
|
|
1094
|
-
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1015
|
+
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1095
1016
|
if (!handler) {
|
|
1096
1017
|
return {
|
|
1097
1018
|
unsubscribe() {}
|
|
@@ -1122,7 +1043,7 @@ function from(producer) {
|
|
|
1122
1043
|
});
|
|
1123
1044
|
if ("subscribe" in producer) {
|
|
1124
1045
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1125
|
-
onCleanup(() =>
|
|
1046
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1126
1047
|
} else {
|
|
1127
1048
|
const clean = producer(set);
|
|
1128
1049
|
onCleanup(clean);
|
|
@@ -1174,7 +1095,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1174
1095
|
});
|
|
1175
1096
|
len = 1;
|
|
1176
1097
|
}
|
|
1177
|
-
}
|
|
1098
|
+
}
|
|
1099
|
+
else if (len === 0) {
|
|
1178
1100
|
mapped = new Array(newLen);
|
|
1179
1101
|
for (j = 0; j < newLen; j++) {
|
|
1180
1102
|
items[j] = newItems[j];
|
|
@@ -1185,16 +1107,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1185
1107
|
temp = new Array(newLen);
|
|
1186
1108
|
tempdisposers = new Array(newLen);
|
|
1187
1109
|
indexes && (tempIndexes = new Array(newLen));
|
|
1188
|
-
for (
|
|
1189
|
-
|
|
1190
|
-
start < end && items[start] === newItems[start];
|
|
1191
|
-
start++
|
|
1192
|
-
);
|
|
1193
|
-
for (
|
|
1194
|
-
end = len - 1, newEnd = newLen - 1;
|
|
1195
|
-
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1196
|
-
end--, newEnd--
|
|
1197
|
-
) {
|
|
1110
|
+
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
|
|
1111
|
+
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
|
|
1198
1112
|
temp[newEnd] = mapped[end];
|
|
1199
1113
|
tempdisposers[newEnd] = disposers[end];
|
|
1200
1114
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1228,7 +1142,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1228
1142
|
}
|
|
1229
1143
|
} else mapped[j] = createRoot(mapper);
|
|
1230
1144
|
}
|
|
1231
|
-
mapped = mapped.slice(0,
|
|
1145
|
+
mapped = mapped.slice(0, len = newLen);
|
|
1232
1146
|
items = newItems.slice(0);
|
|
1233
1147
|
}
|
|
1234
1148
|
return mapped;
|
|
@@ -1294,7 +1208,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1294
1208
|
}
|
|
1295
1209
|
len = signals.length = disposers.length = newItems.length;
|
|
1296
1210
|
items = newItems.slice(0);
|
|
1297
|
-
return
|
|
1211
|
+
return mapped = mapped.slice(0, len);
|
|
1298
1212
|
});
|
|
1299
1213
|
function mapper(disposer) {
|
|
1300
1214
|
disposers[i] = disposer;
|
|
@@ -1363,33 +1277,29 @@ function mergeProps(...sources) {
|
|
|
1363
1277
|
let proxy = false;
|
|
1364
1278
|
for (let i = 0; i < sources.length; i++) {
|
|
1365
1279
|
const s = sources[i];
|
|
1366
|
-
proxy = proxy ||
|
|
1367
|
-
sources[i] = typeof s === "function" ? (
|
|
1280
|
+
proxy = proxy || !!s && $PROXY in s;
|
|
1281
|
+
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1368
1282
|
}
|
|
1369
1283
|
if (proxy) {
|
|
1370
|
-
return new Proxy(
|
|
1371
|
-
{
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
if (v !== undefined) return v;
|
|
1376
|
-
}
|
|
1377
|
-
},
|
|
1378
|
-
has(property) {
|
|
1379
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1380
|
-
if (property in resolveSource(sources[i])) return true;
|
|
1381
|
-
}
|
|
1382
|
-
return false;
|
|
1383
|
-
},
|
|
1384
|
-
keys() {
|
|
1385
|
-
const keys = [];
|
|
1386
|
-
for (let i = 0; i < sources.length; i++)
|
|
1387
|
-
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1388
|
-
return [...new Set(keys)];
|
|
1284
|
+
return new Proxy({
|
|
1285
|
+
get(property) {
|
|
1286
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1287
|
+
const v = resolveSource(sources[i])[property];
|
|
1288
|
+
if (v !== undefined) return v;
|
|
1389
1289
|
}
|
|
1390
1290
|
},
|
|
1391
|
-
|
|
1392
|
-
|
|
1291
|
+
has(property) {
|
|
1292
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1293
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1294
|
+
}
|
|
1295
|
+
return false;
|
|
1296
|
+
},
|
|
1297
|
+
keys() {
|
|
1298
|
+
const keys = [];
|
|
1299
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1300
|
+
return [...new Set(keys)];
|
|
1301
|
+
}
|
|
1302
|
+
}, propTraps);
|
|
1393
1303
|
}
|
|
1394
1304
|
const target = {};
|
|
1395
1305
|
const sourcesMap = {};
|
|
@@ -1408,7 +1318,7 @@ function mergeProps(...sources) {
|
|
|
1408
1318
|
Object.defineProperty(target, key, {
|
|
1409
1319
|
enumerable: true,
|
|
1410
1320
|
configurable: true,
|
|
1411
|
-
get: resolveSources.bind(
|
|
1321
|
+
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1412
1322
|
});
|
|
1413
1323
|
} else {
|
|
1414
1324
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1432,60 +1342,47 @@ function splitProps(props, ...keys) {
|
|
|
1432
1342
|
if ($PROXY in props) {
|
|
1433
1343
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1434
1344
|
const res = keys.map(k => {
|
|
1435
|
-
return new Proxy(
|
|
1436
|
-
{
|
|
1437
|
-
|
|
1438
|
-
return k.includes(property) ? props[property] : undefined;
|
|
1439
|
-
},
|
|
1440
|
-
has(property) {
|
|
1441
|
-
return k.includes(property) && property in props;
|
|
1442
|
-
},
|
|
1443
|
-
keys() {
|
|
1444
|
-
return k.filter(property => property in props);
|
|
1445
|
-
}
|
|
1345
|
+
return new Proxy({
|
|
1346
|
+
get(property) {
|
|
1347
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1446
1348
|
},
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
});
|
|
1450
|
-
res.push(
|
|
1451
|
-
new Proxy(
|
|
1452
|
-
{
|
|
1453
|
-
get(property) {
|
|
1454
|
-
return blocked.has(property) ? undefined : props[property];
|
|
1455
|
-
},
|
|
1456
|
-
has(property) {
|
|
1457
|
-
return blocked.has(property) ? false : property in props;
|
|
1458
|
-
},
|
|
1459
|
-
keys() {
|
|
1460
|
-
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1461
|
-
}
|
|
1349
|
+
has(property) {
|
|
1350
|
+
return k.includes(property) && property in props;
|
|
1462
1351
|
},
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1352
|
+
keys() {
|
|
1353
|
+
return k.filter(property => property in props);
|
|
1354
|
+
}
|
|
1355
|
+
}, propTraps);
|
|
1356
|
+
});
|
|
1357
|
+
res.push(new Proxy({
|
|
1358
|
+
get(property) {
|
|
1359
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1360
|
+
},
|
|
1361
|
+
has(property) {
|
|
1362
|
+
return blocked.has(property) ? false : property in props;
|
|
1363
|
+
},
|
|
1364
|
+
keys() {
|
|
1365
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1366
|
+
}
|
|
1367
|
+
}, propTraps));
|
|
1466
1368
|
return res;
|
|
1467
1369
|
}
|
|
1468
1370
|
const otherObject = {};
|
|
1469
1371
|
const objects = keys.map(() => ({}));
|
|
1470
1372
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1471
1373
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1472
|
-
const isDefaultDesc =
|
|
1473
|
-
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1374
|
+
const isDefaultDesc = !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1474
1375
|
let blocked = false;
|
|
1475
1376
|
let objectIndex = 0;
|
|
1476
1377
|
for (const k of keys) {
|
|
1477
1378
|
if (k.includes(propName)) {
|
|
1478
1379
|
blocked = true;
|
|
1479
|
-
isDefaultDesc
|
|
1480
|
-
? (objects[objectIndex][propName] = desc.value)
|
|
1481
|
-
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1380
|
+
isDefaultDesc ? objects[objectIndex][propName] = desc.value : Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1482
1381
|
}
|
|
1483
1382
|
++objectIndex;
|
|
1484
1383
|
}
|
|
1485
1384
|
if (!blocked) {
|
|
1486
|
-
isDefaultDesc
|
|
1487
|
-
? (otherObject[propName] = desc.value)
|
|
1488
|
-
: Object.defineProperty(otherObject, propName, desc);
|
|
1385
|
+
isDefaultDesc ? otherObject[propName] = desc.value : Object.defineProperty(otherObject, propName, desc);
|
|
1489
1386
|
}
|
|
1490
1387
|
}
|
|
1491
1388
|
return [...objects, otherObject];
|
|
@@ -1511,21 +1408,17 @@ function lazy(fn) {
|
|
|
1511
1408
|
comp = s;
|
|
1512
1409
|
}
|
|
1513
1410
|
let Comp;
|
|
1514
|
-
return createMemo(
|
|
1515
|
-
()
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
setHydrateContext(c);
|
|
1524
|
-
return r;
|
|
1525
|
-
})
|
|
1526
|
-
);
|
|
1411
|
+
return createMemo(() => (Comp = comp()) && untrack(() => {
|
|
1412
|
+
if (false) ;
|
|
1413
|
+
if (!ctx) return Comp(props);
|
|
1414
|
+
const c = sharedConfig.context;
|
|
1415
|
+
setHydrateContext(ctx);
|
|
1416
|
+
const r = Comp(props);
|
|
1417
|
+
setHydrateContext(c);
|
|
1418
|
+
return r;
|
|
1419
|
+
}));
|
|
1527
1420
|
};
|
|
1528
|
-
wrap.preload = () => p || ((p = fn()).then(mod =>
|
|
1421
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1529
1422
|
return wrap;
|
|
1530
1423
|
}
|
|
1531
1424
|
let counter = 0;
|
|
@@ -1550,78 +1443,49 @@ function Index(props) {
|
|
|
1550
1443
|
function Show(props) {
|
|
1551
1444
|
const keyed = props.keyed;
|
|
1552
1445
|
const condition = createMemo(() => props.when, undefined, {
|
|
1553
|
-
equals: (a, b) =>
|
|
1446
|
+
equals: (a, b) => keyed ? a === b : !a === !b
|
|
1554
1447
|
});
|
|
1555
|
-
return createMemo(
|
|
1556
|
-
()
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
if (!untrack(condition)) throw narrowedError("Show");
|
|
1568
|
-
return props.when;
|
|
1569
|
-
}
|
|
1570
|
-
)
|
|
1571
|
-
)
|
|
1572
|
-
: child;
|
|
1573
|
-
}
|
|
1574
|
-
return props.fallback;
|
|
1575
|
-
},
|
|
1576
|
-
undefined,
|
|
1577
|
-
undefined
|
|
1578
|
-
);
|
|
1448
|
+
return createMemo(() => {
|
|
1449
|
+
const c = condition();
|
|
1450
|
+
if (c) {
|
|
1451
|
+
const child = props.children;
|
|
1452
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1453
|
+
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1454
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1455
|
+
return props.when;
|
|
1456
|
+
})) : child;
|
|
1457
|
+
}
|
|
1458
|
+
return props.fallback;
|
|
1459
|
+
}, undefined, undefined);
|
|
1579
1460
|
}
|
|
1580
1461
|
function Switch(props) {
|
|
1581
1462
|
let keyed = false;
|
|
1582
|
-
const equals = (a, b) =>
|
|
1583
|
-
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1463
|
+
const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1584
1464
|
const conditions = children(() => props.children),
|
|
1585
|
-
evalConditions = createMemo(
|
|
1586
|
-
()
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
return [i, c, conds[i]];
|
|
1594
|
-
}
|
|
1465
|
+
evalConditions = createMemo(() => {
|
|
1466
|
+
let conds = conditions();
|
|
1467
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1468
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1469
|
+
const c = conds[i].when;
|
|
1470
|
+
if (c) {
|
|
1471
|
+
keyed = !!conds[i].keyed;
|
|
1472
|
+
return [i, c, conds[i]];
|
|
1595
1473
|
}
|
|
1596
|
-
return [-1];
|
|
1597
|
-
},
|
|
1598
|
-
undefined,
|
|
1599
|
-
{
|
|
1600
|
-
equals
|
|
1601
1474
|
}
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
return cond.when;
|
|
1617
|
-
}
|
|
1618
|
-
)
|
|
1619
|
-
)
|
|
1620
|
-
: c;
|
|
1621
|
-
},
|
|
1622
|
-
undefined,
|
|
1623
|
-
undefined
|
|
1624
|
-
);
|
|
1475
|
+
return [-1];
|
|
1476
|
+
}, undefined, {
|
|
1477
|
+
equals
|
|
1478
|
+
});
|
|
1479
|
+
return createMemo(() => {
|
|
1480
|
+
const [index, when, cond] = evalConditions();
|
|
1481
|
+
if (index < 0) return props.fallback;
|
|
1482
|
+
const c = cond.children;
|
|
1483
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1484
|
+
return fn ? untrack(() => c(keyed ? when : () => {
|
|
1485
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1486
|
+
return cond.when;
|
|
1487
|
+
})) : c;
|
|
1488
|
+
}, undefined, undefined);
|
|
1625
1489
|
}
|
|
1626
1490
|
function Match(props) {
|
|
1627
1491
|
return props;
|
|
@@ -1632,28 +1496,22 @@ function resetErrorBoundaries() {
|
|
|
1632
1496
|
}
|
|
1633
1497
|
function ErrorBoundary(props) {
|
|
1634
1498
|
let err;
|
|
1635
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1636
|
-
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1499
|
+
if (sharedConfig.context && sharedConfig.load) err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1637
1500
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1638
1501
|
Errors || (Errors = new Set());
|
|
1639
1502
|
Errors.add(setErrored);
|
|
1640
1503
|
onCleanup(() => Errors.delete(setErrored));
|
|
1641
|
-
return createMemo(
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
},
|
|
1650
|
-
undefined,
|
|
1651
|
-
undefined
|
|
1652
|
-
);
|
|
1504
|
+
return createMemo(() => {
|
|
1505
|
+
let e;
|
|
1506
|
+
if (e = errored()) {
|
|
1507
|
+
const f = props.fallback;
|
|
1508
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1509
|
+
}
|
|
1510
|
+
return catchError(() => props.children, setErrored);
|
|
1511
|
+
}, undefined, undefined);
|
|
1653
1512
|
}
|
|
1654
1513
|
|
|
1655
|
-
const suspenseListEquals = (a, b) =>
|
|
1656
|
-
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1514
|
+
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1657
1515
|
const SuspenseListContext = createContext();
|
|
1658
1516
|
function SuspenseList(props) {
|
|
1659
1517
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1665,51 +1523,51 @@ function SuspenseList(props) {
|
|
|
1665
1523
|
if (listContext) {
|
|
1666
1524
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1667
1525
|
}
|
|
1668
|
-
const resolved = createMemo(
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1526
|
+
const resolved = createMemo(prev => {
|
|
1527
|
+
const reveal = props.revealOrder,
|
|
1528
|
+
tail = props.tail,
|
|
1529
|
+
{
|
|
1530
|
+
showContent = true,
|
|
1531
|
+
showFallback = true
|
|
1532
|
+
} = show ? show() : {},
|
|
1533
|
+
reg = registry(),
|
|
1534
|
+
reverse = reveal === "backwards";
|
|
1535
|
+
if (reveal === "together") {
|
|
1536
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1537
|
+
const res = reg.map(() => ({
|
|
1538
|
+
showContent: all && showContent,
|
|
1539
|
+
showFallback
|
|
1540
|
+
}));
|
|
1541
|
+
res.inFallback = !all;
|
|
1542
|
+
return res;
|
|
1543
|
+
}
|
|
1544
|
+
let stop = false;
|
|
1545
|
+
let inFallback = prev.inFallback;
|
|
1546
|
+
const res = [];
|
|
1547
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1548
|
+
const n = reverse ? len - i - 1 : i,
|
|
1549
|
+
s = reg[n]();
|
|
1550
|
+
if (!stop && !s) {
|
|
1551
|
+
res[n] = {
|
|
1552
|
+
showContent,
|
|
1679
1553
|
showFallback
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
s = reg[n]();
|
|
1690
|
-
if (!stop && !s) {
|
|
1691
|
-
res[n] = {
|
|
1692
|
-
showContent,
|
|
1693
|
-
showFallback
|
|
1694
|
-
};
|
|
1695
|
-
} else {
|
|
1696
|
-
const next = !stop;
|
|
1697
|
-
if (next) inFallback = true;
|
|
1698
|
-
res[n] = {
|
|
1699
|
-
showContent: next,
|
|
1700
|
-
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1701
|
-
};
|
|
1702
|
-
stop = true;
|
|
1703
|
-
}
|
|
1554
|
+
};
|
|
1555
|
+
} else {
|
|
1556
|
+
const next = !stop;
|
|
1557
|
+
if (next) inFallback = true;
|
|
1558
|
+
res[n] = {
|
|
1559
|
+
showContent: next,
|
|
1560
|
+
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1561
|
+
};
|
|
1562
|
+
stop = true;
|
|
1704
1563
|
}
|
|
1705
|
-
if (!stop) inFallback = false;
|
|
1706
|
-
res.inFallback = inFallback;
|
|
1707
|
-
return res;
|
|
1708
|
-
},
|
|
1709
|
-
{
|
|
1710
|
-
inFallback: false
|
|
1711
1564
|
}
|
|
1712
|
-
|
|
1565
|
+
if (!stop) inFallback = false;
|
|
1566
|
+
res.inFallback = inFallback;
|
|
1567
|
+
return res;
|
|
1568
|
+
}, {
|
|
1569
|
+
inFallback: false
|
|
1570
|
+
});
|
|
1713
1571
|
setWrapper(() => resolved);
|
|
1714
1572
|
return createComponent(SuspenseListContext.Provider, {
|
|
1715
1573
|
value: {
|
|
@@ -1784,14 +1642,17 @@ function Suspense(props) {
|
|
|
1784
1642
|
ctx = sharedConfig.context;
|
|
1785
1643
|
if (flicker) {
|
|
1786
1644
|
flicker();
|
|
1787
|
-
return
|
|
1645
|
+
return flicker = undefined;
|
|
1788
1646
|
}
|
|
1789
1647
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1790
1648
|
const rendered = createMemo(() => props.children);
|
|
1791
1649
|
return createMemo(prev => {
|
|
1792
1650
|
const inFallback = store.inFallback(),
|
|
1793
|
-
{
|
|
1794
|
-
|
|
1651
|
+
{
|
|
1652
|
+
showContent = true,
|
|
1653
|
+
showFallback = true
|
|
1654
|
+
} = show ? show() : {};
|
|
1655
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1795
1656
|
store.resolved = true;
|
|
1796
1657
|
dispose && dispose();
|
|
1797
1658
|
dispose = ctx = p = undefined;
|
|
@@ -1819,59 +1680,4 @@ function Suspense(props) {
|
|
|
1819
1680
|
|
|
1820
1681
|
const DEV = undefined;
|
|
1821
1682
|
|
|
1822
|
-
export {
|
|
1823
|
-
$DEVCOMP,
|
|
1824
|
-
$PROXY,
|
|
1825
|
-
$TRACK,
|
|
1826
|
-
DEV,
|
|
1827
|
-
ErrorBoundary,
|
|
1828
|
-
For,
|
|
1829
|
-
Index,
|
|
1830
|
-
Match,
|
|
1831
|
-
Show,
|
|
1832
|
-
Suspense,
|
|
1833
|
-
SuspenseList,
|
|
1834
|
-
Switch,
|
|
1835
|
-
batch,
|
|
1836
|
-
cancelCallback,
|
|
1837
|
-
catchError,
|
|
1838
|
-
children,
|
|
1839
|
-
createComponent,
|
|
1840
|
-
createComputed,
|
|
1841
|
-
createContext,
|
|
1842
|
-
createDeferred,
|
|
1843
|
-
createEffect,
|
|
1844
|
-
createMemo,
|
|
1845
|
-
createReaction,
|
|
1846
|
-
createRenderEffect,
|
|
1847
|
-
createResource,
|
|
1848
|
-
createRoot,
|
|
1849
|
-
createSelector,
|
|
1850
|
-
createSignal,
|
|
1851
|
-
createUniqueId,
|
|
1852
|
-
enableExternalSource,
|
|
1853
|
-
enableHydration,
|
|
1854
|
-
enableScheduling,
|
|
1855
|
-
equalFn,
|
|
1856
|
-
from,
|
|
1857
|
-
getListener,
|
|
1858
|
-
getOwner,
|
|
1859
|
-
indexArray,
|
|
1860
|
-
lazy,
|
|
1861
|
-
mapArray,
|
|
1862
|
-
mergeProps,
|
|
1863
|
-
observable,
|
|
1864
|
-
on,
|
|
1865
|
-
onCleanup,
|
|
1866
|
-
onError,
|
|
1867
|
-
onMount,
|
|
1868
|
-
requestCallback,
|
|
1869
|
-
resetErrorBoundaries,
|
|
1870
|
-
runWithOwner,
|
|
1871
|
-
sharedConfig,
|
|
1872
|
-
splitProps,
|
|
1873
|
-
startTransition,
|
|
1874
|
-
untrack,
|
|
1875
|
-
useContext,
|
|
1876
|
-
useTransition
|
|
1877
|
-
};
|
|
1683
|
+
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 };
|