solid-js 1.7.9 → 1.7.11
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 +36 -20
- package/dist/dev.js +326 -548
- package/dist/server.cjs +38 -23
- package/dist/server.js +108 -192
- package/dist/solid.cjs +36 -20
- package/dist/solid.js +284 -475
- 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/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +94 -216
- package/html/types/lit.d.ts +31 -45
- package/package.json +1 -1
- package/store/dist/dev.cjs +4 -3
- package/store/dist/dev.js +46 -117
- package/store/dist/server.js +8 -19
- package/store/dist/store.cjs +4 -3
- package/store/dist/store.js +43 -108
- 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 -215
- package/types/index.d.ts +9 -69
- 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 +150 -236
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +31 -62
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +12 -12
- package/types/server/index.d.ts +2 -55
- package/types/server/reactive.d.ts +44 -72
- package/types/server/rendering.d.ts +95 -171
- 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 +79 -610
- package/web/dist/server.cjs +5 -1
- package/web/dist/server.js +82 -177
- package/web/dist/web.js +79 -610
- 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/web/types/server.d.ts +1 -1
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
|
}
|
|
@@ -157,19 +155,18 @@ let Listener = null;
|
|
|
157
155
|
let Updates = null;
|
|
158
156
|
let Effects = null;
|
|
159
157
|
let ExecCount = 0;
|
|
160
|
-
const [transPending, setTransPending] = /*@__PURE__*/
|
|
158
|
+
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
161
159
|
function createRoot(fn, detachedOwner) {
|
|
162
160
|
const listener = Listener,
|
|
163
161
|
owner = Owner,
|
|
164
162
|
unowned = fn.length === 0,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
},
|
|
163
|
+
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
164
|
+
root = unowned ? UNOWNED : {
|
|
165
|
+
owned: null,
|
|
166
|
+
cleanups: null,
|
|
167
|
+
context: current ? current.context : null,
|
|
168
|
+
owner: current
|
|
169
|
+
},
|
|
173
170
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
174
171
|
Owner = root;
|
|
175
172
|
Listener = null;
|
|
@@ -190,8 +187,7 @@ function createSignal(value, options) {
|
|
|
190
187
|
};
|
|
191
188
|
const setter = value => {
|
|
192
189
|
if (typeof value === "function") {
|
|
193
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
194
|
-
else value = value(s.value);
|
|
190
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);else value = value(s.value);
|
|
195
191
|
}
|
|
196
192
|
return writeSignal(s, value);
|
|
197
193
|
};
|
|
@@ -199,34 +195,27 @@ function createSignal(value, options) {
|
|
|
199
195
|
}
|
|
200
196
|
function createComputed(fn, value, options) {
|
|
201
197
|
const c = createComputation(fn, value, true, STALE);
|
|
202
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
203
|
-
else updateComputation(c);
|
|
198
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
204
199
|
}
|
|
205
200
|
function createRenderEffect(fn, value, options) {
|
|
206
201
|
const c = createComputation(fn, value, false, STALE);
|
|
207
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
208
|
-
else updateComputation(c);
|
|
202
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
209
203
|
}
|
|
210
204
|
function createEffect(fn, value, options) {
|
|
211
205
|
runEffects = runUserEffects;
|
|
212
206
|
const c = createComputation(fn, value, false, STALE),
|
|
213
|
-
s = SuspenseContext &&
|
|
207
|
+
s = SuspenseContext && useContext(SuspenseContext);
|
|
214
208
|
if (s) c.suspense = s;
|
|
215
209
|
if (!options || !options.render) c.user = true;
|
|
216
210
|
Effects ? Effects.push(c) : updateComputation(c);
|
|
217
211
|
}
|
|
218
212
|
function createReaction(onInvalidate, options) {
|
|
219
213
|
let fn;
|
|
220
|
-
const c = createComputation(
|
|
221
|
-
()
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
undefined,
|
|
226
|
-
false,
|
|
227
|
-
0
|
|
228
|
-
),
|
|
229
|
-
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
214
|
+
const c = createComputation(() => {
|
|
215
|
+
fn ? fn() : untrack(onInvalidate);
|
|
216
|
+
fn = undefined;
|
|
217
|
+
}, undefined, false, 0),
|
|
218
|
+
s = SuspenseContext && useContext(SuspenseContext);
|
|
230
219
|
if (s) c.suspense = s;
|
|
231
220
|
c.user = true;
|
|
232
221
|
return tracking => {
|
|
@@ -250,7 +239,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
250
239
|
let source;
|
|
251
240
|
let fetcher;
|
|
252
241
|
let options;
|
|
253
|
-
if (
|
|
242
|
+
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
254
243
|
source = true;
|
|
255
244
|
fetcher = pSource;
|
|
256
245
|
options = pFetcher || {};
|
|
@@ -264,7 +253,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
264
253
|
id = null,
|
|
265
254
|
loadedUnderTransition = false,
|
|
266
255
|
scheduled = false,
|
|
267
|
-
resolved = "initialValue" in options,
|
|
256
|
+
resolved = ("initialValue" in options),
|
|
268
257
|
dynamic = typeof source === "function" && createMemo(source);
|
|
269
258
|
const contexts = new Set(),
|
|
270
259
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -276,19 +265,15 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
276
265
|
if (sharedConfig.context) {
|
|
277
266
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
278
267
|
let v;
|
|
279
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
280
|
-
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
268
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
281
269
|
}
|
|
282
270
|
function loadEnd(p, v, error, key) {
|
|
283
271
|
if (pr === p) {
|
|
284
272
|
pr = null;
|
|
285
273
|
key !== undefined && (resolved = true);
|
|
286
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
value: v
|
|
290
|
-
})
|
|
291
|
-
);
|
|
274
|
+
if ((p === initP || v === initP) && options.onHydrated) queueMicrotask(() => options.onHydrated(key, {
|
|
275
|
+
value: v
|
|
276
|
+
}));
|
|
292
277
|
initP = NO_INIT;
|
|
293
278
|
if (Transition && p && loadedUnderTransition) {
|
|
294
279
|
Transition.promises.delete(p);
|
|
@@ -311,7 +296,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
311
296
|
}, false);
|
|
312
297
|
}
|
|
313
298
|
function read() {
|
|
314
|
-
const c = SuspenseContext &&
|
|
299
|
+
const c = SuspenseContext && useContext(SuspenseContext),
|
|
315
300
|
v = value(),
|
|
316
301
|
err = error();
|
|
317
302
|
if (err !== undefined && !pr) throw err;
|
|
@@ -319,8 +304,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
319
304
|
createComputed(() => {
|
|
320
305
|
track();
|
|
321
306
|
if (pr) {
|
|
322
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
323
|
-
else if (!contexts.has(c)) {
|
|
307
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);else if (!contexts.has(c)) {
|
|
324
308
|
c.increment();
|
|
325
309
|
contexts.add(c);
|
|
326
310
|
}
|
|
@@ -339,30 +323,22 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
339
323
|
return;
|
|
340
324
|
}
|
|
341
325
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
342
|
-
const p =
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
fetcher(lookup, {
|
|
347
|
-
value: value(),
|
|
348
|
-
refetching
|
|
349
|
-
})
|
|
350
|
-
);
|
|
326
|
+
const p = initP !== NO_INIT ? initP : untrack(() => fetcher(lookup, {
|
|
327
|
+
value: value(),
|
|
328
|
+
refetching
|
|
329
|
+
}));
|
|
351
330
|
if (typeof p !== "object" || !(p && "then" in p)) {
|
|
352
331
|
loadEnd(pr, p, undefined, lookup);
|
|
353
332
|
return p;
|
|
354
333
|
}
|
|
355
334
|
pr = p;
|
|
356
335
|
scheduled = true;
|
|
357
|
-
queueMicrotask(() =>
|
|
336
|
+
queueMicrotask(() => scheduled = false);
|
|
358
337
|
runUpdates(() => {
|
|
359
338
|
setState(resolved ? "refreshing" : "pending");
|
|
360
339
|
trigger();
|
|
361
340
|
}, false);
|
|
362
|
-
return p.then(
|
|
363
|
-
v => loadEnd(p, v, undefined, lookup),
|
|
364
|
-
e => loadEnd(p, undefined, castError(e), lookup)
|
|
365
|
-
);
|
|
341
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, undefined, castError(e), lookup));
|
|
366
342
|
}
|
|
367
343
|
Object.defineProperties(read, {
|
|
368
344
|
state: {
|
|
@@ -386,35 +362,21 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
386
362
|
}
|
|
387
363
|
}
|
|
388
364
|
});
|
|
389
|
-
if (dynamic) createComputed(() => load(false));
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
refetch: load,
|
|
395
|
-
mutate: setValue
|
|
396
|
-
}
|
|
397
|
-
];
|
|
365
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
366
|
+
return [read, {
|
|
367
|
+
refetch: load,
|
|
368
|
+
mutate: setValue
|
|
369
|
+
}];
|
|
398
370
|
}
|
|
399
371
|
function createDeferred(source, options) {
|
|
400
372
|
let t,
|
|
401
373
|
timeout = options ? options.timeoutMs : undefined;
|
|
402
|
-
const node = createComputation(
|
|
403
|
-
() => {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
? {
|
|
409
|
-
timeout
|
|
410
|
-
}
|
|
411
|
-
: undefined
|
|
412
|
-
);
|
|
413
|
-
return source();
|
|
414
|
-
},
|
|
415
|
-
undefined,
|
|
416
|
-
true
|
|
417
|
-
);
|
|
374
|
+
const node = createComputation(() => {
|
|
375
|
+
if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
|
|
376
|
+
timeout
|
|
377
|
+
} : undefined);
|
|
378
|
+
return source();
|
|
379
|
+
}, undefined, true);
|
|
418
380
|
const [deferred, setDeferred] = createSignal(node.value, options);
|
|
419
381
|
updateComputation(node);
|
|
420
382
|
setDeferred(() => node.value);
|
|
@@ -422,39 +384,28 @@ function createDeferred(source, options) {
|
|
|
422
384
|
}
|
|
423
385
|
function createSelector(source, fn = equalFn, options) {
|
|
424
386
|
const subs = new Map();
|
|
425
|
-
const node = createComputation(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
for (const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
return v;
|
|
437
|
-
},
|
|
438
|
-
undefined,
|
|
439
|
-
true,
|
|
440
|
-
STALE
|
|
441
|
-
);
|
|
387
|
+
const node = createComputation(p => {
|
|
388
|
+
const v = source();
|
|
389
|
+
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
390
|
+
for (const c of val.values()) {
|
|
391
|
+
c.state = STALE;
|
|
392
|
+
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return v;
|
|
396
|
+
}, undefined, true, STALE);
|
|
442
397
|
updateComputation(node);
|
|
443
398
|
return key => {
|
|
444
399
|
const listener = Listener;
|
|
445
400
|
if (listener) {
|
|
446
401
|
let l;
|
|
447
|
-
if (
|
|
448
|
-
else subs.set(key, (l = new Set([listener])));
|
|
402
|
+
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
449
403
|
onCleanup(() => {
|
|
450
404
|
l.delete(listener);
|
|
451
405
|
!l.size && subs.delete(key);
|
|
452
406
|
});
|
|
453
407
|
}
|
|
454
|
-
return fn(
|
|
455
|
-
key,
|
|
456
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
457
|
-
);
|
|
408
|
+
return fn(key, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
458
409
|
};
|
|
459
410
|
}
|
|
460
411
|
function batch(fn) {
|
|
@@ -493,15 +444,14 @@ function onMount(fn) {
|
|
|
493
444
|
createEffect(() => untrack(fn));
|
|
494
445
|
}
|
|
495
446
|
function onCleanup(fn) {
|
|
496
|
-
if (Owner === null);
|
|
497
|
-
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
498
|
-
else Owner.cleanups.push(fn);
|
|
447
|
+
if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
499
448
|
return fn;
|
|
500
449
|
}
|
|
501
450
|
function catchError(fn, handler) {
|
|
502
451
|
ERROR || (ERROR = Symbol("error"));
|
|
503
452
|
Owner = createComputation(undefined, undefined, true);
|
|
504
453
|
Owner.context = {
|
|
454
|
+
...Owner.context,
|
|
505
455
|
[ERROR]: [handler]
|
|
506
456
|
};
|
|
507
457
|
if (Transition && Transition.running) Transition.sources.add(Owner);
|
|
@@ -513,16 +463,6 @@ function catchError(fn, handler) {
|
|
|
513
463
|
Owner = Owner.owner;
|
|
514
464
|
}
|
|
515
465
|
}
|
|
516
|
-
function onError(fn) {
|
|
517
|
-
ERROR || (ERROR = Symbol("error"));
|
|
518
|
-
if (Owner === null);
|
|
519
|
-
else if (Owner.context === null)
|
|
520
|
-
Owner.context = {
|
|
521
|
-
[ERROR]: [fn]
|
|
522
|
-
};
|
|
523
|
-
else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];
|
|
524
|
-
else Owner.context[ERROR].push(fn);
|
|
525
|
-
}
|
|
526
466
|
function getListener() {
|
|
527
467
|
return Listener;
|
|
528
468
|
}
|
|
@@ -558,17 +498,15 @@ function startTransition(fn) {
|
|
|
558
498
|
Owner = o;
|
|
559
499
|
let t;
|
|
560
500
|
if (Scheduler || SuspenseContext) {
|
|
561
|
-
t =
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
});
|
|
571
|
-
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
501
|
+
t = Transition || (Transition = {
|
|
502
|
+
sources: new Set(),
|
|
503
|
+
effects: [],
|
|
504
|
+
promises: new Set(),
|
|
505
|
+
disposed: new Set(),
|
|
506
|
+
queue: new Set(),
|
|
507
|
+
running: true
|
|
508
|
+
});
|
|
509
|
+
t.done || (t.done = new Promise(res => t.resolve = res));
|
|
572
510
|
t.running = true;
|
|
573
511
|
}
|
|
574
512
|
runUpdates(fn, false);
|
|
@@ -592,8 +530,7 @@ function createContext(defaultValue, options) {
|
|
|
592
530
|
};
|
|
593
531
|
}
|
|
594
532
|
function useContext(context) {
|
|
595
|
-
|
|
596
|
-
return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
|
|
533
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
|
|
597
534
|
}
|
|
598
535
|
function children(fn) {
|
|
599
536
|
const children = createMemo(fn);
|
|
@@ -606,7 +543,7 @@ function children(fn) {
|
|
|
606
543
|
}
|
|
607
544
|
let SuspenseContext;
|
|
608
545
|
function getSuspenseContext() {
|
|
609
|
-
return SuspenseContext || (SuspenseContext = createContext(
|
|
546
|
+
return SuspenseContext || (SuspenseContext = createContext());
|
|
610
547
|
}
|
|
611
548
|
function enableExternalSource(factory) {
|
|
612
549
|
if (ExternalSourceFactory) {
|
|
@@ -629,8 +566,7 @@ function enableExternalSource(factory) {
|
|
|
629
566
|
function readSignal() {
|
|
630
567
|
const runningTransition = Transition && Transition.running;
|
|
631
568
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
632
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
633
|
-
else {
|
|
569
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
|
|
634
570
|
const updates = Updates;
|
|
635
571
|
Updates = null;
|
|
636
572
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -658,12 +594,11 @@ function readSignal() {
|
|
|
658
594
|
return this.value;
|
|
659
595
|
}
|
|
660
596
|
function writeSignal(node, value, isComp) {
|
|
661
|
-
let current =
|
|
662
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
597
|
+
let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
663
598
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
664
599
|
if (Transition) {
|
|
665
600
|
const TransitionRunning = Transition.running;
|
|
666
|
-
if (TransitionRunning ||
|
|
601
|
+
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
667
602
|
Transition.sources.add(node);
|
|
668
603
|
node.tValue = value;
|
|
669
604
|
}
|
|
@@ -676,16 +611,14 @@ function writeSignal(node, value, isComp) {
|
|
|
676
611
|
const TransitionRunning = Transition && Transition.running;
|
|
677
612
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
678
613
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
679
|
-
if (o.pure) Updates.push(o);
|
|
680
|
-
else Effects.push(o);
|
|
614
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
681
615
|
if (o.observers) markDownstream(o);
|
|
682
616
|
}
|
|
683
|
-
if (!TransitionRunning) o.state = STALE;
|
|
684
|
-
else o.tState = STALE;
|
|
617
|
+
if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
|
|
685
618
|
}
|
|
686
619
|
if (Updates.length > 10e5) {
|
|
687
620
|
Updates = [];
|
|
688
|
-
if (false);
|
|
621
|
+
if (false) ;
|
|
689
622
|
throw new Error();
|
|
690
623
|
}
|
|
691
624
|
}, false);
|
|
@@ -700,11 +633,7 @@ function updateComputation(node) {
|
|
|
700
633
|
listener = Listener,
|
|
701
634
|
time = ExecCount;
|
|
702
635
|
Listener = Owner = node;
|
|
703
|
-
runComputation(
|
|
704
|
-
node,
|
|
705
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
706
|
-
time
|
|
707
|
-
);
|
|
636
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
708
637
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
709
638
|
queueMicrotask(() => {
|
|
710
639
|
runUpdates(() => {
|
|
@@ -758,21 +687,18 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
758
687
|
cleanups: null,
|
|
759
688
|
value: init,
|
|
760
689
|
owner: Owner,
|
|
761
|
-
context: null,
|
|
690
|
+
context: Owner ? Owner.context : null,
|
|
762
691
|
pure
|
|
763
692
|
};
|
|
764
693
|
if (Transition && Transition.running) {
|
|
765
694
|
c.state = 0;
|
|
766
695
|
c.tState = state;
|
|
767
696
|
}
|
|
768
|
-
if (Owner === null);
|
|
769
|
-
else if (Owner !== UNOWNED) {
|
|
697
|
+
if (Owner === null) ;else if (Owner !== UNOWNED) {
|
|
770
698
|
if (Transition && Transition.running && Owner.pure) {
|
|
771
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
772
|
-
else Owner.tOwned.push(c);
|
|
699
|
+
if (!Owner.tOwned) Owner.tOwned = [c];else Owner.tOwned.push(c);
|
|
773
700
|
} else {
|
|
774
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
775
|
-
else Owner.owned.push(c);
|
|
701
|
+
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
776
702
|
}
|
|
777
703
|
}
|
|
778
704
|
if (ExternalSourceFactory) {
|
|
@@ -823,8 +749,7 @@ function runUpdates(fn, init) {
|
|
|
823
749
|
if (Updates) return fn();
|
|
824
750
|
let wait = false;
|
|
825
751
|
if (!init) Updates = [];
|
|
826
|
-
if (Effects) wait = true;
|
|
827
|
-
else Effects = [];
|
|
752
|
+
if (Effects) wait = true;else Effects = [];
|
|
828
753
|
ExecCount++;
|
|
829
754
|
try {
|
|
830
755
|
const res = fn();
|
|
@@ -838,8 +763,7 @@ function runUpdates(fn, init) {
|
|
|
838
763
|
}
|
|
839
764
|
function completeUpdates(wait) {
|
|
840
765
|
if (Updates) {
|
|
841
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
842
|
-
else runQueue(Updates);
|
|
766
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);else runQueue(Updates);
|
|
843
767
|
Updates = null;
|
|
844
768
|
}
|
|
845
769
|
if (wait) return;
|
|
@@ -907,8 +831,7 @@ function runUserEffects(queue) {
|
|
|
907
831
|
userLength = 0;
|
|
908
832
|
for (i = 0; i < queue.length; i++) {
|
|
909
833
|
const e = queue[i];
|
|
910
|
-
if (!e.user) runTop(e);
|
|
911
|
-
else queue[userLength++] = e;
|
|
834
|
+
if (!e.user) runTop(e);else queue[userLength++] = e;
|
|
912
835
|
}
|
|
913
836
|
if (sharedConfig.context) {
|
|
914
837
|
if (sharedConfig.count) {
|
|
@@ -926,15 +849,13 @@ function runUserEffects(queue) {
|
|
|
926
849
|
}
|
|
927
850
|
function lookUpstream(node, ignore) {
|
|
928
851
|
const runningTransition = Transition && Transition.running;
|
|
929
|
-
if (runningTransition) node.tState = 0;
|
|
930
|
-
else node.state = 0;
|
|
852
|
+
if (runningTransition) node.tState = 0;else node.state = 0;
|
|
931
853
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
932
854
|
const source = node.sources[i];
|
|
933
855
|
if (source.sources) {
|
|
934
856
|
const state = runningTransition ? source.tState : source.state;
|
|
935
857
|
if (state === STALE) {
|
|
936
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
937
|
-
runTop(source);
|
|
858
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
|
|
938
859
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
939
860
|
}
|
|
940
861
|
}
|
|
@@ -944,10 +865,8 @@ function markDownstream(node) {
|
|
|
944
865
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
945
866
|
const o = node.observers[i];
|
|
946
867
|
if (runningTransition ? !o.tState : !o.state) {
|
|
947
|
-
if (runningTransition) o.tState = PENDING;
|
|
948
|
-
|
|
949
|
-
if (o.pure) Updates.push(o);
|
|
950
|
-
else Effects.push(o);
|
|
868
|
+
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
869
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
951
870
|
o.observers && markDownstream(o);
|
|
952
871
|
}
|
|
953
872
|
}
|
|
@@ -984,9 +903,7 @@ function cleanNode(node) {
|
|
|
984
903
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
985
904
|
node.cleanups = null;
|
|
986
905
|
}
|
|
987
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
988
|
-
else node.state = 0;
|
|
989
|
-
node.context = null;
|
|
906
|
+
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
990
907
|
}
|
|
991
908
|
function reset(node, top) {
|
|
992
909
|
if (!top) {
|
|
@@ -1007,28 +924,19 @@ function runErrors(err, fns, owner) {
|
|
|
1007
924
|
try {
|
|
1008
925
|
for (const f of fns) f(err);
|
|
1009
926
|
} catch (e) {
|
|
1010
|
-
handleError(e,
|
|
927
|
+
handleError(e, owner && owner.owner || null);
|
|
1011
928
|
}
|
|
1012
929
|
}
|
|
1013
930
|
function handleError(err, owner = Owner) {
|
|
1014
|
-
const fns = ERROR &&
|
|
931
|
+
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
1015
932
|
const error = castError(err);
|
|
1016
933
|
if (!fns) throw error;
|
|
1017
|
-
if (Effects)
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
});
|
|
1024
|
-
else runErrors(error, fns, owner);
|
|
1025
|
-
}
|
|
1026
|
-
function lookup(owner, key) {
|
|
1027
|
-
return owner
|
|
1028
|
-
? owner.context && owner.context[key] !== undefined
|
|
1029
|
-
? owner.context[key]
|
|
1030
|
-
: lookup(owner.owner, key)
|
|
1031
|
-
: undefined;
|
|
934
|
+
if (Effects) Effects.push({
|
|
935
|
+
fn() {
|
|
936
|
+
runErrors(error, fns, owner);
|
|
937
|
+
},
|
|
938
|
+
state: STALE
|
|
939
|
+
});else runErrors(error, fns, owner);
|
|
1032
940
|
}
|
|
1033
941
|
function resolveChildren(children) {
|
|
1034
942
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1045,19 +953,40 @@ function resolveChildren(children) {
|
|
|
1045
953
|
function createProvider(id, options) {
|
|
1046
954
|
return function provider(props) {
|
|
1047
955
|
let res;
|
|
1048
|
-
createRenderEffect(
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
})),
|
|
1056
|
-
undefined
|
|
1057
|
-
);
|
|
956
|
+
createRenderEffect(() => res = untrack(() => {
|
|
957
|
+
Owner.context = {
|
|
958
|
+
...Owner.context,
|
|
959
|
+
[id]: props.value
|
|
960
|
+
};
|
|
961
|
+
return children(() => props.children);
|
|
962
|
+
}), undefined);
|
|
1058
963
|
return res;
|
|
1059
964
|
};
|
|
1060
965
|
}
|
|
966
|
+
function onError(fn) {
|
|
967
|
+
ERROR || (ERROR = Symbol("error"));
|
|
968
|
+
if (Owner === null) ;else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
969
|
+
Owner.context = {
|
|
970
|
+
...Owner.context,
|
|
971
|
+
[ERROR]: [fn]
|
|
972
|
+
};
|
|
973
|
+
mutateContext(Owner, ERROR, [fn]);
|
|
974
|
+
} else Owner.context[ERROR].push(fn);
|
|
975
|
+
}
|
|
976
|
+
function mutateContext(o, key, value) {
|
|
977
|
+
if (o.owned) {
|
|
978
|
+
for (let i = 0; i < o.owned.length; i++) {
|
|
979
|
+
if (o.owned[i].context === o.context) mutateContext(o.owned[i], key, value);
|
|
980
|
+
if (!o.owned[i].context) {
|
|
981
|
+
o.owned[i].context = o.context;
|
|
982
|
+
mutateContext(o.owned[i], key, value);
|
|
983
|
+
} else if (!o.owned[i].context[key]) {
|
|
984
|
+
o.owned[i].context[key] = value;
|
|
985
|
+
mutateContext(o.owned[i], key, value);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
}
|
|
1061
990
|
|
|
1062
991
|
function observable(input) {
|
|
1063
992
|
return {
|
|
@@ -1065,8 +994,7 @@ function observable(input) {
|
|
|
1065
994
|
if (!(observer instanceof Object) || observer == null) {
|
|
1066
995
|
throw new TypeError("Expected the observer to be an object.");
|
|
1067
996
|
}
|
|
1068
|
-
const handler =
|
|
1069
|
-
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
997
|
+
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1070
998
|
if (!handler) {
|
|
1071
999
|
return {
|
|
1072
1000
|
unsubscribe() {}
|
|
@@ -1097,7 +1025,7 @@ function from(producer) {
|
|
|
1097
1025
|
});
|
|
1098
1026
|
if ("subscribe" in producer) {
|
|
1099
1027
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1100
|
-
onCleanup(() =>
|
|
1028
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1101
1029
|
} else {
|
|
1102
1030
|
const clean = producer(set);
|
|
1103
1031
|
onCleanup(clean);
|
|
@@ -1149,7 +1077,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1149
1077
|
});
|
|
1150
1078
|
len = 1;
|
|
1151
1079
|
}
|
|
1152
|
-
}
|
|
1080
|
+
}
|
|
1081
|
+
else if (len === 0) {
|
|
1153
1082
|
mapped = new Array(newLen);
|
|
1154
1083
|
for (j = 0; j < newLen; j++) {
|
|
1155
1084
|
items[j] = newItems[j];
|
|
@@ -1160,16 +1089,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1160
1089
|
temp = new Array(newLen);
|
|
1161
1090
|
tempdisposers = new Array(newLen);
|
|
1162
1091
|
indexes && (tempIndexes = new Array(newLen));
|
|
1163
|
-
for (
|
|
1164
|
-
|
|
1165
|
-
start < end && items[start] === newItems[start];
|
|
1166
|
-
start++
|
|
1167
|
-
);
|
|
1168
|
-
for (
|
|
1169
|
-
end = len - 1, newEnd = newLen - 1;
|
|
1170
|
-
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1171
|
-
end--, newEnd--
|
|
1172
|
-
) {
|
|
1092
|
+
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
|
|
1093
|
+
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
|
|
1173
1094
|
temp[newEnd] = mapped[end];
|
|
1174
1095
|
tempdisposers[newEnd] = disposers[end];
|
|
1175
1096
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1203,7 +1124,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1203
1124
|
}
|
|
1204
1125
|
} else mapped[j] = createRoot(mapper);
|
|
1205
1126
|
}
|
|
1206
|
-
mapped = mapped.slice(0,
|
|
1127
|
+
mapped = mapped.slice(0, len = newLen);
|
|
1207
1128
|
items = newItems.slice(0);
|
|
1208
1129
|
}
|
|
1209
1130
|
return mapped;
|
|
@@ -1269,7 +1190,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1269
1190
|
}
|
|
1270
1191
|
len = signals.length = disposers.length = newItems.length;
|
|
1271
1192
|
items = newItems.slice(0);
|
|
1272
|
-
return
|
|
1193
|
+
return mapped = mapped.slice(0, len);
|
|
1273
1194
|
});
|
|
1274
1195
|
function mapper(disposer) {
|
|
1275
1196
|
disposers[i] = disposer;
|
|
@@ -1338,33 +1259,29 @@ function mergeProps(...sources) {
|
|
|
1338
1259
|
let proxy = false;
|
|
1339
1260
|
for (let i = 0; i < sources.length; i++) {
|
|
1340
1261
|
const s = sources[i];
|
|
1341
|
-
proxy = proxy ||
|
|
1342
|
-
sources[i] = typeof s === "function" ? (
|
|
1262
|
+
proxy = proxy || !!s && $PROXY in s;
|
|
1263
|
+
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1343
1264
|
}
|
|
1344
1265
|
if (proxy) {
|
|
1345
|
-
return new Proxy(
|
|
1346
|
-
{
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
if (property in resolveSource(sources[i])) return true;
|
|
1356
|
-
}
|
|
1357
|
-
return false;
|
|
1358
|
-
},
|
|
1359
|
-
keys() {
|
|
1360
|
-
const keys = [];
|
|
1361
|
-
for (let i = 0; i < sources.length; i++)
|
|
1362
|
-
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1363
|
-
return [...new Set(keys)];
|
|
1266
|
+
return new Proxy({
|
|
1267
|
+
get(property) {
|
|
1268
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1269
|
+
const v = resolveSource(sources[i])[property];
|
|
1270
|
+
if (v !== undefined) return v;
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
has(property) {
|
|
1274
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1275
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1364
1276
|
}
|
|
1277
|
+
return false;
|
|
1365
1278
|
},
|
|
1366
|
-
|
|
1367
|
-
|
|
1279
|
+
keys() {
|
|
1280
|
+
const keys = [];
|
|
1281
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1282
|
+
return [...new Set(keys)];
|
|
1283
|
+
}
|
|
1284
|
+
}, propTraps);
|
|
1368
1285
|
}
|
|
1369
1286
|
const target = {};
|
|
1370
1287
|
const sourcesMap = {};
|
|
@@ -1383,7 +1300,7 @@ function mergeProps(...sources) {
|
|
|
1383
1300
|
Object.defineProperty(target, key, {
|
|
1384
1301
|
enumerable: true,
|
|
1385
1302
|
configurable: true,
|
|
1386
|
-
get: resolveSources.bind(
|
|
1303
|
+
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1387
1304
|
});
|
|
1388
1305
|
} else {
|
|
1389
1306
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1407,60 +1324,47 @@ function splitProps(props, ...keys) {
|
|
|
1407
1324
|
if ($PROXY in props) {
|
|
1408
1325
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1409
1326
|
const res = keys.map(k => {
|
|
1410
|
-
return new Proxy(
|
|
1411
|
-
{
|
|
1412
|
-
|
|
1413
|
-
return k.includes(property) ? props[property] : undefined;
|
|
1414
|
-
},
|
|
1415
|
-
has(property) {
|
|
1416
|
-
return k.includes(property) && property in props;
|
|
1417
|
-
},
|
|
1418
|
-
keys() {
|
|
1419
|
-
return k.filter(property => property in props);
|
|
1420
|
-
}
|
|
1327
|
+
return new Proxy({
|
|
1328
|
+
get(property) {
|
|
1329
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1421
1330
|
},
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
});
|
|
1425
|
-
res.push(
|
|
1426
|
-
new Proxy(
|
|
1427
|
-
{
|
|
1428
|
-
get(property) {
|
|
1429
|
-
return blocked.has(property) ? undefined : props[property];
|
|
1430
|
-
},
|
|
1431
|
-
has(property) {
|
|
1432
|
-
return blocked.has(property) ? false : property in props;
|
|
1433
|
-
},
|
|
1434
|
-
keys() {
|
|
1435
|
-
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1436
|
-
}
|
|
1331
|
+
has(property) {
|
|
1332
|
+
return k.includes(property) && property in props;
|
|
1437
1333
|
},
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1334
|
+
keys() {
|
|
1335
|
+
return k.filter(property => property in props);
|
|
1336
|
+
}
|
|
1337
|
+
}, propTraps);
|
|
1338
|
+
});
|
|
1339
|
+
res.push(new Proxy({
|
|
1340
|
+
get(property) {
|
|
1341
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1342
|
+
},
|
|
1343
|
+
has(property) {
|
|
1344
|
+
return blocked.has(property) ? false : property in props;
|
|
1345
|
+
},
|
|
1346
|
+
keys() {
|
|
1347
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1348
|
+
}
|
|
1349
|
+
}, propTraps));
|
|
1441
1350
|
return res;
|
|
1442
1351
|
}
|
|
1443
1352
|
const otherObject = {};
|
|
1444
1353
|
const objects = keys.map(() => ({}));
|
|
1445
1354
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1446
1355
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1447
|
-
const isDefaultDesc =
|
|
1448
|
-
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1356
|
+
const isDefaultDesc = !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1449
1357
|
let blocked = false;
|
|
1450
1358
|
let objectIndex = 0;
|
|
1451
1359
|
for (const k of keys) {
|
|
1452
1360
|
if (k.includes(propName)) {
|
|
1453
1361
|
blocked = true;
|
|
1454
|
-
isDefaultDesc
|
|
1455
|
-
? (objects[objectIndex][propName] = desc.value)
|
|
1456
|
-
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1362
|
+
isDefaultDesc ? objects[objectIndex][propName] = desc.value : Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1457
1363
|
}
|
|
1458
1364
|
++objectIndex;
|
|
1459
1365
|
}
|
|
1460
1366
|
if (!blocked) {
|
|
1461
|
-
isDefaultDesc
|
|
1462
|
-
? (otherObject[propName] = desc.value)
|
|
1463
|
-
: Object.defineProperty(otherObject, propName, desc);
|
|
1367
|
+
isDefaultDesc ? otherObject[propName] = desc.value : Object.defineProperty(otherObject, propName, desc);
|
|
1464
1368
|
}
|
|
1465
1369
|
}
|
|
1466
1370
|
return [...objects, otherObject];
|
|
@@ -1486,21 +1390,17 @@ function lazy(fn) {
|
|
|
1486
1390
|
comp = s;
|
|
1487
1391
|
}
|
|
1488
1392
|
let Comp;
|
|
1489
|
-
return createMemo(
|
|
1490
|
-
()
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
setHydrateContext(c);
|
|
1499
|
-
return r;
|
|
1500
|
-
})
|
|
1501
|
-
);
|
|
1393
|
+
return createMemo(() => (Comp = comp()) && untrack(() => {
|
|
1394
|
+
if (false) ;
|
|
1395
|
+
if (!ctx) return Comp(props);
|
|
1396
|
+
const c = sharedConfig.context;
|
|
1397
|
+
setHydrateContext(ctx);
|
|
1398
|
+
const r = Comp(props);
|
|
1399
|
+
setHydrateContext(c);
|
|
1400
|
+
return r;
|
|
1401
|
+
}));
|
|
1502
1402
|
};
|
|
1503
|
-
wrap.preload = () => p || ((p = fn()).then(mod =>
|
|
1403
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1504
1404
|
return wrap;
|
|
1505
1405
|
}
|
|
1506
1406
|
let counter = 0;
|
|
@@ -1525,78 +1425,49 @@ function Index(props) {
|
|
|
1525
1425
|
function Show(props) {
|
|
1526
1426
|
const keyed = props.keyed;
|
|
1527
1427
|
const condition = createMemo(() => props.when, undefined, {
|
|
1528
|
-
equals: (a, b) =>
|
|
1428
|
+
equals: (a, b) => keyed ? a === b : !a === !b
|
|
1529
1429
|
});
|
|
1530
|
-
return createMemo(
|
|
1531
|
-
()
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
if (!untrack(condition)) throw narrowedError("Show");
|
|
1543
|
-
return props.when;
|
|
1544
|
-
}
|
|
1545
|
-
)
|
|
1546
|
-
)
|
|
1547
|
-
: child;
|
|
1548
|
-
}
|
|
1549
|
-
return props.fallback;
|
|
1550
|
-
},
|
|
1551
|
-
undefined,
|
|
1552
|
-
undefined
|
|
1553
|
-
);
|
|
1430
|
+
return createMemo(() => {
|
|
1431
|
+
const c = condition();
|
|
1432
|
+
if (c) {
|
|
1433
|
+
const child = props.children;
|
|
1434
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1435
|
+
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1436
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1437
|
+
return props.when;
|
|
1438
|
+
})) : child;
|
|
1439
|
+
}
|
|
1440
|
+
return props.fallback;
|
|
1441
|
+
}, undefined, undefined);
|
|
1554
1442
|
}
|
|
1555
1443
|
function Switch(props) {
|
|
1556
1444
|
let keyed = false;
|
|
1557
|
-
const equals = (a, b) =>
|
|
1558
|
-
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1445
|
+
const equals = (a, b) => a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1559
1446
|
const conditions = children(() => props.children),
|
|
1560
|
-
evalConditions = createMemo(
|
|
1561
|
-
()
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
return [i, c, conds[i]];
|
|
1569
|
-
}
|
|
1447
|
+
evalConditions = createMemo(() => {
|
|
1448
|
+
let conds = conditions();
|
|
1449
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1450
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1451
|
+
const c = conds[i].when;
|
|
1452
|
+
if (c) {
|
|
1453
|
+
keyed = !!conds[i].keyed;
|
|
1454
|
+
return [i, c, conds[i]];
|
|
1570
1455
|
}
|
|
1571
|
-
return [-1];
|
|
1572
|
-
},
|
|
1573
|
-
undefined,
|
|
1574
|
-
{
|
|
1575
|
-
equals
|
|
1576
1456
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
return cond.when;
|
|
1592
|
-
}
|
|
1593
|
-
)
|
|
1594
|
-
)
|
|
1595
|
-
: c;
|
|
1596
|
-
},
|
|
1597
|
-
undefined,
|
|
1598
|
-
undefined
|
|
1599
|
-
);
|
|
1457
|
+
return [-1];
|
|
1458
|
+
}, undefined, {
|
|
1459
|
+
equals
|
|
1460
|
+
});
|
|
1461
|
+
return createMemo(() => {
|
|
1462
|
+
const [index, when, cond] = evalConditions();
|
|
1463
|
+
if (index < 0) return props.fallback;
|
|
1464
|
+
const c = cond.children;
|
|
1465
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1466
|
+
return fn ? untrack(() => c(keyed ? when : () => {
|
|
1467
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1468
|
+
return cond.when;
|
|
1469
|
+
})) : c;
|
|
1470
|
+
}, undefined, undefined);
|
|
1600
1471
|
}
|
|
1601
1472
|
function Match(props) {
|
|
1602
1473
|
return props;
|
|
@@ -1608,32 +1479,22 @@ function resetErrorBoundaries() {
|
|
|
1608
1479
|
function ErrorBoundary(props) {
|
|
1609
1480
|
let err;
|
|
1610
1481
|
let v;
|
|
1611
|
-
if (
|
|
1612
|
-
sharedConfig.context &&
|
|
1613
|
-
sharedConfig.load &&
|
|
1614
|
-
(v = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count))
|
|
1615
|
-
)
|
|
1616
|
-
err = v[0];
|
|
1482
|
+
if (sharedConfig.context && sharedConfig.load && (v = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count))) err = v[0];
|
|
1617
1483
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1618
1484
|
Errors || (Errors = new Set());
|
|
1619
1485
|
Errors.add(setErrored);
|
|
1620
1486
|
onCleanup(() => Errors.delete(setErrored));
|
|
1621
|
-
return createMemo(
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
},
|
|
1630
|
-
undefined,
|
|
1631
|
-
undefined
|
|
1632
|
-
);
|
|
1487
|
+
return createMemo(() => {
|
|
1488
|
+
let e;
|
|
1489
|
+
if (e = errored()) {
|
|
1490
|
+
const f = props.fallback;
|
|
1491
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1492
|
+
}
|
|
1493
|
+
return catchError(() => props.children, setErrored);
|
|
1494
|
+
}, undefined, undefined);
|
|
1633
1495
|
}
|
|
1634
1496
|
|
|
1635
|
-
const suspenseListEquals = (a, b) =>
|
|
1636
|
-
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1497
|
+
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1637
1498
|
const SuspenseListContext = createContext();
|
|
1638
1499
|
function SuspenseList(props) {
|
|
1639
1500
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1645,51 +1506,51 @@ function SuspenseList(props) {
|
|
|
1645
1506
|
if (listContext) {
|
|
1646
1507
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1647
1508
|
}
|
|
1648
|
-
const resolved = createMemo(
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1509
|
+
const resolved = createMemo(prev => {
|
|
1510
|
+
const reveal = props.revealOrder,
|
|
1511
|
+
tail = props.tail,
|
|
1512
|
+
{
|
|
1513
|
+
showContent = true,
|
|
1514
|
+
showFallback = true
|
|
1515
|
+
} = show ? show() : {},
|
|
1516
|
+
reg = registry(),
|
|
1517
|
+
reverse = reveal === "backwards";
|
|
1518
|
+
if (reveal === "together") {
|
|
1519
|
+
const all = reg.every(inFallback => !inFallback());
|
|
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,
|
|
1659
1536
|
showFallback
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
s = reg[n]();
|
|
1670
|
-
if (!stop && !s) {
|
|
1671
|
-
res[n] = {
|
|
1672
|
-
showContent,
|
|
1673
|
-
showFallback
|
|
1674
|
-
};
|
|
1675
|
-
} else {
|
|
1676
|
-
const next = !stop;
|
|
1677
|
-
if (next) inFallback = true;
|
|
1678
|
-
res[n] = {
|
|
1679
|
-
showContent: next,
|
|
1680
|
-
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1681
|
-
};
|
|
1682
|
-
stop = true;
|
|
1683
|
-
}
|
|
1537
|
+
};
|
|
1538
|
+
} else {
|
|
1539
|
+
const next = !stop;
|
|
1540
|
+
if (next) inFallback = true;
|
|
1541
|
+
res[n] = {
|
|
1542
|
+
showContent: next,
|
|
1543
|
+
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1544
|
+
};
|
|
1545
|
+
stop = true;
|
|
1684
1546
|
}
|
|
1685
|
-
if (!stop) inFallback = false;
|
|
1686
|
-
res.inFallback = inFallback;
|
|
1687
|
-
return res;
|
|
1688
|
-
},
|
|
1689
|
-
{
|
|
1690
|
-
inFallback: false
|
|
1691
1547
|
}
|
|
1692
|
-
|
|
1548
|
+
if (!stop) inFallback = false;
|
|
1549
|
+
res.inFallback = inFallback;
|
|
1550
|
+
return res;
|
|
1551
|
+
}, {
|
|
1552
|
+
inFallback: false
|
|
1553
|
+
});
|
|
1693
1554
|
setWrapper(() => resolved);
|
|
1694
1555
|
return createComponent(SuspenseListContext.Provider, {
|
|
1695
1556
|
value: {
|
|
@@ -1763,14 +1624,17 @@ function Suspense(props) {
|
|
|
1763
1624
|
ctx = sharedConfig.context;
|
|
1764
1625
|
if (flicker) {
|
|
1765
1626
|
flicker();
|
|
1766
|
-
return
|
|
1627
|
+
return flicker = undefined;
|
|
1767
1628
|
}
|
|
1768
1629
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1769
1630
|
const rendered = createMemo(() => props.children);
|
|
1770
1631
|
return createMemo(prev => {
|
|
1771
1632
|
const inFallback = store.inFallback(),
|
|
1772
|
-
{
|
|
1773
|
-
|
|
1633
|
+
{
|
|
1634
|
+
showContent = true,
|
|
1635
|
+
showFallback = true
|
|
1636
|
+
} = show ? show() : {};
|
|
1637
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1774
1638
|
store.resolved = true;
|
|
1775
1639
|
dispose && dispose();
|
|
1776
1640
|
dispose = ctx = p = undefined;
|
|
@@ -1798,59 +1662,4 @@ function Suspense(props) {
|
|
|
1798
1662
|
|
|
1799
1663
|
const DEV = undefined;
|
|
1800
1664
|
|
|
1801
|
-
export {
|
|
1802
|
-
$DEVCOMP,
|
|
1803
|
-
$PROXY,
|
|
1804
|
-
$TRACK,
|
|
1805
|
-
DEV,
|
|
1806
|
-
ErrorBoundary,
|
|
1807
|
-
For,
|
|
1808
|
-
Index,
|
|
1809
|
-
Match,
|
|
1810
|
-
Show,
|
|
1811
|
-
Suspense,
|
|
1812
|
-
SuspenseList,
|
|
1813
|
-
Switch,
|
|
1814
|
-
batch,
|
|
1815
|
-
cancelCallback,
|
|
1816
|
-
catchError,
|
|
1817
|
-
children,
|
|
1818
|
-
createComponent,
|
|
1819
|
-
createComputed,
|
|
1820
|
-
createContext,
|
|
1821
|
-
createDeferred,
|
|
1822
|
-
createEffect,
|
|
1823
|
-
createMemo,
|
|
1824
|
-
createReaction,
|
|
1825
|
-
createRenderEffect,
|
|
1826
|
-
createResource,
|
|
1827
|
-
createRoot,
|
|
1828
|
-
createSelector,
|
|
1829
|
-
createSignal,
|
|
1830
|
-
createUniqueId,
|
|
1831
|
-
enableExternalSource,
|
|
1832
|
-
enableHydration,
|
|
1833
|
-
enableScheduling,
|
|
1834
|
-
equalFn,
|
|
1835
|
-
from,
|
|
1836
|
-
getListener,
|
|
1837
|
-
getOwner,
|
|
1838
|
-
indexArray,
|
|
1839
|
-
lazy,
|
|
1840
|
-
mapArray,
|
|
1841
|
-
mergeProps,
|
|
1842
|
-
observable,
|
|
1843
|
-
on,
|
|
1844
|
-
onCleanup,
|
|
1845
|
-
onError,
|
|
1846
|
-
onMount,
|
|
1847
|
-
requestCallback,
|
|
1848
|
-
resetErrorBoundaries,
|
|
1849
|
-
runWithOwner,
|
|
1850
|
-
sharedConfig,
|
|
1851
|
-
splitProps,
|
|
1852
|
-
startTransition,
|
|
1853
|
-
untrack,
|
|
1854
|
-
useContext,
|
|
1855
|
-
useTransition
|
|
1856
|
-
};
|
|
1665
|
+
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 };
|