solid-js 1.9.6 → 1.9.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 +26 -15
- package/dist/dev.js +334 -564
- package/dist/server.cjs +3 -1
- package/dist/server.js +83 -178
- package/dist/solid.cjs +26 -15
- package/dist/solid.js +290 -493
- package/h/dist/h.js +9 -40
- 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 +246 -234
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +94 -219
- package/html/types/lit.d.ts +33 -52
- package/package.json +3 -3
- package/store/dist/dev.cjs +9 -5
- package/store/dist/dev.js +50 -126
- package/store/dist/server.js +8 -20
- package/store/dist/store.cjs +9 -5
- package/store/dist/store.js +47 -117
- 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 +5 -25
- package/store/types/store.d.ts +61 -218
- package/types/index.d.ts +11 -78
- package/types/jsx.d.ts +245 -229
- package/types/reactive/array.d.ts +4 -12
- package/types/reactive/observable.d.ts +16 -22
- package/types/reactive/scheduler.d.ts +6 -9
- package/types/reactive/signal.d.ts +145 -236
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +37 -73
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +15 -15
- package/types/server/index.d.ts +2 -57
- package/types/server/reactive.d.ts +45 -76
- package/types/server/rendering.d.ts +98 -169
- package/universal/dist/dev.js +12 -28
- package/universal/dist/universal.js +12 -28
- package/universal/types/index.d.ts +2 -3
- package/universal/types/universal.d.ts +3 -2
- package/web/dist/dev.cjs +89 -6
- package/web/dist/dev.js +174 -646
- package/web/dist/server.cjs +90 -5
- package/web/dist/server.js +194 -647
- package/web/dist/web.cjs +89 -6
- package/web/dist/web.js +172 -634
- package/web/storage/dist/storage.js +3 -3
- package/web/types/core.d.ts +1 -9
- package/web/types/index.d.ts +11 -31
- package/web/types/server-mock.d.ts +32 -47
package/dist/solid.js
CHANGED
|
@@ -7,6 +7,7 @@ let taskIdCounter = 1,
|
|
|
7
7
|
yieldInterval = 5,
|
|
8
8
|
deadline = 0,
|
|
9
9
|
maxYieldInterval = 300,
|
|
10
|
+
maxDeadline = 0,
|
|
10
11
|
scheduleCallback = null,
|
|
11
12
|
scheduledCallback = null;
|
|
12
13
|
const maxSigned31BitInt = 1073741823;
|
|
@@ -18,9 +19,9 @@ function setupScheduler() {
|
|
|
18
19
|
if (scheduledCallback !== null) {
|
|
19
20
|
const currentTime = performance.now();
|
|
20
21
|
deadline = currentTime + yieldInterval;
|
|
21
|
-
|
|
22
|
+
maxDeadline = currentTime + maxYieldInterval;
|
|
22
23
|
try {
|
|
23
|
-
const hasMoreWork = scheduledCallback(
|
|
24
|
+
const hasMoreWork = scheduledCallback(currentTime);
|
|
24
25
|
if (!hasMoreWork) {
|
|
25
26
|
scheduledCallback = null;
|
|
26
27
|
} else port.postMessage(null);
|
|
@@ -38,7 +39,7 @@ function setupScheduler() {
|
|
|
38
39
|
if (scheduling.isInputPending()) {
|
|
39
40
|
return true;
|
|
40
41
|
}
|
|
41
|
-
return currentTime >=
|
|
42
|
+
return currentTime >= maxDeadline;
|
|
42
43
|
} else {
|
|
43
44
|
return false;
|
|
44
45
|
}
|
|
@@ -52,11 +53,9 @@ function enqueue(taskQueue, task) {
|
|
|
52
53
|
let m = 0;
|
|
53
54
|
let n = taskQueue.length - 1;
|
|
54
55
|
while (m <= n) {
|
|
55
|
-
const k =
|
|
56
|
+
const k = n + m >> 1;
|
|
56
57
|
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;
|
|
58
|
+
if (cmp > 0) m = k + 1;else if (cmp < 0) n = k - 1;else return k;
|
|
60
59
|
}
|
|
61
60
|
return m;
|
|
62
61
|
}
|
|
@@ -84,21 +83,21 @@ function requestCallback(fn, options) {
|
|
|
84
83
|
function cancelCallback(task) {
|
|
85
84
|
task.fn = null;
|
|
86
85
|
}
|
|
87
|
-
function flushWork(
|
|
86
|
+
function flushWork(initialTime) {
|
|
88
87
|
isCallbackScheduled = false;
|
|
89
88
|
isPerformingWork = true;
|
|
90
89
|
try {
|
|
91
|
-
return workLoop(
|
|
90
|
+
return workLoop(initialTime);
|
|
92
91
|
} finally {
|
|
93
92
|
currentTask = null;
|
|
94
93
|
isPerformingWork = false;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
|
-
function workLoop(
|
|
96
|
+
function workLoop(initialTime) {
|
|
98
97
|
let currentTime = initialTime;
|
|
99
98
|
currentTask = taskQueue[0] || null;
|
|
100
99
|
while (currentTask !== null) {
|
|
101
|
-
if (currentTask.expirationTime > currentTime &&
|
|
100
|
+
if (currentTask.expirationTime > currentTime && shouldYieldToHost()) {
|
|
102
101
|
break;
|
|
103
102
|
}
|
|
104
103
|
const callback = currentTask.fn;
|
|
@@ -177,14 +176,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
177
176
|
owner = Owner,
|
|
178
177
|
unowned = fn.length === 0,
|
|
179
178
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
180
|
-
root = unowned
|
|
181
|
-
|
|
182
|
-
:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
owner: current
|
|
187
|
-
},
|
|
179
|
+
root = unowned ? UNOWNED : {
|
|
180
|
+
owned: null,
|
|
181
|
+
cleanups: null,
|
|
182
|
+
context: current ? current.context : null,
|
|
183
|
+
owner: current
|
|
184
|
+
},
|
|
188
185
|
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
189
186
|
Owner = root;
|
|
190
187
|
Listener = null;
|
|
@@ -205,8 +202,7 @@ function createSignal(value, options) {
|
|
|
205
202
|
};
|
|
206
203
|
const setter = value => {
|
|
207
204
|
if (typeof value === "function") {
|
|
208
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
209
|
-
else value = value(s.value);
|
|
205
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);else value = value(s.value);
|
|
210
206
|
}
|
|
211
207
|
return writeSignal(s, value);
|
|
212
208
|
};
|
|
@@ -214,13 +210,11 @@ function createSignal(value, options) {
|
|
|
214
210
|
}
|
|
215
211
|
function createComputed(fn, value, options) {
|
|
216
212
|
const c = createComputation(fn, value, true, STALE);
|
|
217
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
218
|
-
else updateComputation(c);
|
|
213
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
219
214
|
}
|
|
220
215
|
function createRenderEffect(fn, value, options) {
|
|
221
216
|
const c = createComputation(fn, value, false, STALE);
|
|
222
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
223
|
-
else updateComputation(c);
|
|
217
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
224
218
|
}
|
|
225
219
|
function createEffect(fn, value, options) {
|
|
226
220
|
runEffects = runUserEffects;
|
|
@@ -232,15 +226,10 @@ function createEffect(fn, value, options) {
|
|
|
232
226
|
}
|
|
233
227
|
function createReaction(onInvalidate, options) {
|
|
234
228
|
let fn;
|
|
235
|
-
const c = createComputation(
|
|
236
|
-
()
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
},
|
|
240
|
-
undefined,
|
|
241
|
-
false,
|
|
242
|
-
0
|
|
243
|
-
),
|
|
229
|
+
const c = createComputation(() => {
|
|
230
|
+
fn ? fn() : untrack(onInvalidate);
|
|
231
|
+
fn = undefined;
|
|
232
|
+
}, undefined, false, 0),
|
|
244
233
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
245
234
|
if (s) c.suspense = s;
|
|
246
235
|
c.user = true;
|
|
@@ -293,19 +282,15 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
293
282
|
[state, setState] = createSignal(resolved ? "ready" : "unresolved");
|
|
294
283
|
if (sharedConfig.context) {
|
|
295
284
|
id = sharedConfig.getNextContextId();
|
|
296
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
297
|
-
else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
|
|
285
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
|
|
298
286
|
}
|
|
299
287
|
function loadEnd(p, v, error, key) {
|
|
300
288
|
if (pr === p) {
|
|
301
289
|
pr = null;
|
|
302
290
|
key !== undefined && (resolved = true);
|
|
303
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
value: v
|
|
307
|
-
})
|
|
308
|
-
);
|
|
291
|
+
if ((p === initP || v === initP) && options.onHydrated) queueMicrotask(() => options.onHydrated(key, {
|
|
292
|
+
value: v
|
|
293
|
+
}));
|
|
309
294
|
initP = NO_INIT;
|
|
310
295
|
if (Transition && p && loadedUnderTransition) {
|
|
311
296
|
Transition.promises.delete(p);
|
|
@@ -336,8 +321,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
336
321
|
createComputed(() => {
|
|
337
322
|
track();
|
|
338
323
|
if (pr) {
|
|
339
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
340
|
-
else if (!contexts.has(c)) {
|
|
324
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);else if (!contexts.has(c)) {
|
|
341
325
|
c.increment();
|
|
342
326
|
contexts.add(c);
|
|
343
327
|
}
|
|
@@ -356,35 +340,36 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
356
340
|
return;
|
|
357
341
|
}
|
|
358
342
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
343
|
+
let error;
|
|
344
|
+
const p = initP !== NO_INIT ? initP : untrack(() => {
|
|
345
|
+
try {
|
|
346
|
+
return fetcher(lookup, {
|
|
347
|
+
value: value(),
|
|
348
|
+
refetching
|
|
349
|
+
});
|
|
350
|
+
} catch (fetcherError) {
|
|
351
|
+
error = fetcherError;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
if (error !== undefined) {
|
|
355
|
+
loadEnd(pr, undefined, castError(error), lookup);
|
|
356
|
+
return;
|
|
357
|
+
} else if (!isPromise(p)) {
|
|
369
358
|
loadEnd(pr, p, undefined, lookup);
|
|
370
359
|
return p;
|
|
371
360
|
}
|
|
372
361
|
pr = p;
|
|
373
|
-
if ("
|
|
374
|
-
if (p.
|
|
375
|
-
else loadEnd(pr, undefined, castError(p.value), lookup);
|
|
362
|
+
if ("v" in p) {
|
|
363
|
+
if (p.s === 1) loadEnd(pr, p.v, undefined, lookup);else loadEnd(pr, undefined, castError(p.v), lookup);
|
|
376
364
|
return p;
|
|
377
365
|
}
|
|
378
366
|
scheduled = true;
|
|
379
|
-
queueMicrotask(() =>
|
|
367
|
+
queueMicrotask(() => scheduled = false);
|
|
380
368
|
runUpdates(() => {
|
|
381
369
|
setState(resolved ? "refreshing" : "pending");
|
|
382
370
|
trigger();
|
|
383
371
|
}, false);
|
|
384
|
-
return p.then(
|
|
385
|
-
v => loadEnd(p, v, undefined, lookup),
|
|
386
|
-
e => loadEnd(p, undefined, castError(e), lookup)
|
|
387
|
-
);
|
|
372
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, undefined, castError(e), lookup));
|
|
388
373
|
}
|
|
389
374
|
Object.defineProperties(read, {
|
|
390
375
|
state: {
|
|
@@ -409,80 +394,50 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
409
394
|
}
|
|
410
395
|
});
|
|
411
396
|
let owner = Owner;
|
|
412
|
-
if (dynamic) createComputed(() => (
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
refetch: info => runWithOwner(owner, () => load(info)),
|
|
418
|
-
mutate: setValue
|
|
419
|
-
}
|
|
420
|
-
];
|
|
397
|
+
if (dynamic) createComputed(() => (owner = Owner, load(false)));else load(false);
|
|
398
|
+
return [read, {
|
|
399
|
+
refetch: info => runWithOwner(owner, () => load(info)),
|
|
400
|
+
mutate: setValue
|
|
401
|
+
}];
|
|
421
402
|
}
|
|
422
403
|
function createDeferred(source, options) {
|
|
423
404
|
let t,
|
|
424
405
|
timeout = options ? options.timeoutMs : undefined;
|
|
425
|
-
const node = createComputation(
|
|
426
|
-
() => {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
timeout
|
|
433
|
-
}
|
|
434
|
-
: undefined
|
|
435
|
-
);
|
|
436
|
-
return source();
|
|
437
|
-
},
|
|
438
|
-
undefined,
|
|
439
|
-
true
|
|
440
|
-
);
|
|
441
|
-
const [deferred, setDeferred] = createSignal(
|
|
442
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
443
|
-
options
|
|
444
|
-
);
|
|
406
|
+
const node = createComputation(() => {
|
|
407
|
+
if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
|
|
408
|
+
timeout
|
|
409
|
+
} : undefined);
|
|
410
|
+
return source();
|
|
411
|
+
}, undefined, true);
|
|
412
|
+
const [deferred, setDeferred] = createSignal(Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, options);
|
|
445
413
|
updateComputation(node);
|
|
446
|
-
setDeferred(() =>
|
|
447
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
448
|
-
);
|
|
414
|
+
setDeferred(() => Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
449
415
|
return deferred;
|
|
450
416
|
}
|
|
451
417
|
function createSelector(source, fn = equalFn, options) {
|
|
452
418
|
const subs = new Map();
|
|
453
|
-
const node = createComputation(
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
for (const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
return v;
|
|
465
|
-
},
|
|
466
|
-
undefined,
|
|
467
|
-
true,
|
|
468
|
-
STALE
|
|
469
|
-
);
|
|
419
|
+
const node = createComputation(p => {
|
|
420
|
+
const v = source();
|
|
421
|
+
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
422
|
+
for (const c of val.values()) {
|
|
423
|
+
c.state = STALE;
|
|
424
|
+
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return v;
|
|
428
|
+
}, undefined, true, STALE);
|
|
470
429
|
updateComputation(node);
|
|
471
430
|
return key => {
|
|
472
431
|
const listener = Listener;
|
|
473
432
|
if (listener) {
|
|
474
433
|
let l;
|
|
475
|
-
if (
|
|
476
|
-
else subs.set(key, (l = new Set([listener])));
|
|
434
|
+
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
477
435
|
onCleanup(() => {
|
|
478
436
|
l.delete(listener);
|
|
479
437
|
!l.size && subs.delete(key);
|
|
480
438
|
});
|
|
481
439
|
}
|
|
482
|
-
return fn(
|
|
483
|
-
key,
|
|
484
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
485
|
-
);
|
|
440
|
+
return fn(key, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
486
441
|
};
|
|
487
442
|
}
|
|
488
443
|
function batch(fn) {
|
|
@@ -522,9 +477,7 @@ function onMount(fn) {
|
|
|
522
477
|
createEffect(() => untrack(fn));
|
|
523
478
|
}
|
|
524
479
|
function onCleanup(fn) {
|
|
525
|
-
if (Owner === null);
|
|
526
|
-
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
527
|
-
else Owner.cleanups.push(fn);
|
|
480
|
+
if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
528
481
|
return fn;
|
|
529
482
|
}
|
|
530
483
|
function catchError(fn, handler) {
|
|
@@ -578,17 +531,15 @@ function startTransition(fn) {
|
|
|
578
531
|
Owner = o;
|
|
579
532
|
let t;
|
|
580
533
|
if (Scheduler || SuspenseContext) {
|
|
581
|
-
t =
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
});
|
|
591
|
-
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
534
|
+
t = Transition || (Transition = {
|
|
535
|
+
sources: new Set(),
|
|
536
|
+
effects: [],
|
|
537
|
+
promises: new Set(),
|
|
538
|
+
disposed: new Set(),
|
|
539
|
+
queue: new Set(),
|
|
540
|
+
running: true
|
|
541
|
+
});
|
|
542
|
+
t.done || (t.done = new Promise(res => t.resolve = res));
|
|
592
543
|
t.running = true;
|
|
593
544
|
}
|
|
594
545
|
runUpdates(fn, false);
|
|
@@ -596,7 +547,7 @@ function startTransition(fn) {
|
|
|
596
547
|
return t ? t.done : undefined;
|
|
597
548
|
});
|
|
598
549
|
}
|
|
599
|
-
const [transPending, setTransPending] = /*@__PURE__*/
|
|
550
|
+
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
600
551
|
function useTransition() {
|
|
601
552
|
return [transPending, startTransition];
|
|
602
553
|
}
|
|
@@ -614,9 +565,7 @@ function createContext(defaultValue, options) {
|
|
|
614
565
|
}
|
|
615
566
|
function useContext(context) {
|
|
616
567
|
let value;
|
|
617
|
-
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
|
|
618
|
-
? value
|
|
619
|
-
: context.defaultValue;
|
|
568
|
+
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined ? value : context.defaultValue;
|
|
620
569
|
}
|
|
621
570
|
function children(fn) {
|
|
622
571
|
const children = createMemo(fn);
|
|
@@ -633,7 +582,10 @@ function getSuspenseContext() {
|
|
|
633
582
|
}
|
|
634
583
|
function enableExternalSource(factory, untrack = fn => fn()) {
|
|
635
584
|
if (ExternalSourceConfig) {
|
|
636
|
-
const {
|
|
585
|
+
const {
|
|
586
|
+
factory: oldFactory,
|
|
587
|
+
untrack: oldUntrack
|
|
588
|
+
} = ExternalSourceConfig;
|
|
637
589
|
ExternalSourceConfig = {
|
|
638
590
|
factory: (fn, trigger) => {
|
|
639
591
|
const oldSource = oldFactory(fn, trigger);
|
|
@@ -658,8 +610,7 @@ function enableExternalSource(factory, untrack = fn => fn()) {
|
|
|
658
610
|
function readSignal() {
|
|
659
611
|
const runningTransition = Transition && Transition.running;
|
|
660
612
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
661
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
662
|
-
else {
|
|
613
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
|
|
663
614
|
const updates = Updates;
|
|
664
615
|
Updates = null;
|
|
665
616
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -687,12 +638,11 @@ function readSignal() {
|
|
|
687
638
|
return this.value;
|
|
688
639
|
}
|
|
689
640
|
function writeSignal(node, value, isComp) {
|
|
690
|
-
let current =
|
|
691
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
641
|
+
let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
692
642
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
693
643
|
if (Transition) {
|
|
694
644
|
const TransitionRunning = Transition.running;
|
|
695
|
-
if (TransitionRunning ||
|
|
645
|
+
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
696
646
|
Transition.sources.add(node);
|
|
697
647
|
node.tValue = value;
|
|
698
648
|
}
|
|
@@ -705,16 +655,14 @@ function writeSignal(node, value, isComp) {
|
|
|
705
655
|
const TransitionRunning = Transition && Transition.running;
|
|
706
656
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
707
657
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
708
|
-
if (o.pure) Updates.push(o);
|
|
709
|
-
else Effects.push(o);
|
|
658
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
710
659
|
if (o.observers) markDownstream(o);
|
|
711
660
|
}
|
|
712
|
-
if (!TransitionRunning) o.state = STALE;
|
|
713
|
-
else o.tState = STALE;
|
|
661
|
+
if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
|
|
714
662
|
}
|
|
715
663
|
if (Updates.length > 10e5) {
|
|
716
664
|
Updates = [];
|
|
717
|
-
if (IS_DEV);
|
|
665
|
+
if (IS_DEV) ;
|
|
718
666
|
throw new Error();
|
|
719
667
|
}
|
|
720
668
|
}, false);
|
|
@@ -726,11 +674,7 @@ function updateComputation(node) {
|
|
|
726
674
|
if (!node.fn) return;
|
|
727
675
|
cleanNode(node);
|
|
728
676
|
const time = ExecCount;
|
|
729
|
-
runComputation(
|
|
730
|
-
node,
|
|
731
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
732
|
-
time
|
|
733
|
-
);
|
|
677
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
734
678
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
735
679
|
queueMicrotask(() => {
|
|
736
680
|
runUpdates(() => {
|
|
@@ -795,14 +739,11 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
795
739
|
c.state = 0;
|
|
796
740
|
c.tState = state;
|
|
797
741
|
}
|
|
798
|
-
if (Owner === null);
|
|
799
|
-
else if (Owner !== UNOWNED) {
|
|
742
|
+
if (Owner === null) ;else if (Owner !== UNOWNED) {
|
|
800
743
|
if (Transition && Transition.running && Owner.pure) {
|
|
801
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
802
|
-
else Owner.tOwned.push(c);
|
|
744
|
+
if (!Owner.tOwned) Owner.tOwned = [c];else Owner.tOwned.push(c);
|
|
803
745
|
} else {
|
|
804
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
805
|
-
else Owner.owned.push(c);
|
|
746
|
+
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
806
747
|
}
|
|
807
748
|
}
|
|
808
749
|
if (ExternalSourceConfig && c.fn) {
|
|
@@ -853,8 +794,7 @@ function runUpdates(fn, init) {
|
|
|
853
794
|
if (Updates) return fn();
|
|
854
795
|
let wait = false;
|
|
855
796
|
if (!init) Updates = [];
|
|
856
|
-
if (Effects) wait = true;
|
|
857
|
-
else Effects = [];
|
|
797
|
+
if (Effects) wait = true;else Effects = [];
|
|
858
798
|
ExecCount++;
|
|
859
799
|
try {
|
|
860
800
|
const res = fn();
|
|
@@ -868,8 +808,7 @@ function runUpdates(fn, init) {
|
|
|
868
808
|
}
|
|
869
809
|
function completeUpdates(wait) {
|
|
870
810
|
if (Updates) {
|
|
871
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
872
|
-
else runQueue(Updates);
|
|
811
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);else runQueue(Updates);
|
|
873
812
|
Updates = null;
|
|
874
813
|
}
|
|
875
814
|
if (wait) return;
|
|
@@ -937,8 +876,7 @@ function runUserEffects(queue) {
|
|
|
937
876
|
userLength = 0;
|
|
938
877
|
for (i = 0; i < queue.length; i++) {
|
|
939
878
|
const e = queue[i];
|
|
940
|
-
if (!e.user) runTop(e);
|
|
941
|
-
else queue[userLength++] = e;
|
|
879
|
+
if (!e.user) runTop(e);else queue[userLength++] = e;
|
|
942
880
|
}
|
|
943
881
|
if (sharedConfig.context) {
|
|
944
882
|
if (sharedConfig.count) {
|
|
@@ -957,15 +895,13 @@ function runUserEffects(queue) {
|
|
|
957
895
|
}
|
|
958
896
|
function lookUpstream(node, ignore) {
|
|
959
897
|
const runningTransition = Transition && Transition.running;
|
|
960
|
-
if (runningTransition) node.tState = 0;
|
|
961
|
-
else node.state = 0;
|
|
898
|
+
if (runningTransition) node.tState = 0;else node.state = 0;
|
|
962
899
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
963
900
|
const source = node.sources[i];
|
|
964
901
|
if (source.sources) {
|
|
965
902
|
const state = runningTransition ? source.tState : source.state;
|
|
966
903
|
if (state === STALE) {
|
|
967
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
968
|
-
runTop(source);
|
|
904
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
|
|
969
905
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
970
906
|
}
|
|
971
907
|
}
|
|
@@ -975,10 +911,8 @@ function markDownstream(node) {
|
|
|
975
911
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
976
912
|
const o = node.observers[i];
|
|
977
913
|
if (runningTransition ? !o.tState : !o.state) {
|
|
978
|
-
if (runningTransition) o.tState = PENDING;
|
|
979
|
-
|
|
980
|
-
if (o.pure) Updates.push(o);
|
|
981
|
-
else Effects.push(o);
|
|
914
|
+
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
915
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
982
916
|
o.observers && markDownstream(o);
|
|
983
917
|
}
|
|
984
918
|
}
|
|
@@ -1015,8 +949,7 @@ function cleanNode(node) {
|
|
|
1015
949
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
1016
950
|
node.cleanups = null;
|
|
1017
951
|
}
|
|
1018
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1019
|
-
else node.state = 0;
|
|
952
|
+
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
1020
953
|
}
|
|
1021
954
|
function reset(node, top) {
|
|
1022
955
|
if (!top) {
|
|
@@ -1037,21 +970,19 @@ function runErrors(err, fns, owner) {
|
|
|
1037
970
|
try {
|
|
1038
971
|
for (const f of fns) f(err);
|
|
1039
972
|
} catch (e) {
|
|
1040
|
-
handleError(e,
|
|
973
|
+
handleError(e, owner && owner.owner || null);
|
|
1041
974
|
}
|
|
1042
975
|
}
|
|
1043
976
|
function handleError(err, owner = Owner) {
|
|
1044
977
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
1045
978
|
const error = castError(err);
|
|
1046
979
|
if (!fns) throw error;
|
|
1047
|
-
if (Effects)
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
});
|
|
1054
|
-
else runErrors(error, fns, owner);
|
|
980
|
+
if (Effects) Effects.push({
|
|
981
|
+
fn() {
|
|
982
|
+
runErrors(error, fns, owner);
|
|
983
|
+
},
|
|
984
|
+
state: STALE
|
|
985
|
+
});else runErrors(error, fns, owner);
|
|
1055
986
|
}
|
|
1056
987
|
function resolveChildren(children) {
|
|
1057
988
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1068,24 +999,19 @@ function resolveChildren(children) {
|
|
|
1068
999
|
function createProvider(id, options) {
|
|
1069
1000
|
return function provider(props) {
|
|
1070
1001
|
let res;
|
|
1071
|
-
createRenderEffect(
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
return children(() => props.children);
|
|
1079
|
-
})),
|
|
1080
|
-
undefined
|
|
1081
|
-
);
|
|
1002
|
+
createRenderEffect(() => res = untrack(() => {
|
|
1003
|
+
Owner.context = {
|
|
1004
|
+
...Owner.context,
|
|
1005
|
+
[id]: props.value
|
|
1006
|
+
};
|
|
1007
|
+
return children(() => props.children);
|
|
1008
|
+
}), undefined);
|
|
1082
1009
|
return res;
|
|
1083
1010
|
};
|
|
1084
1011
|
}
|
|
1085
1012
|
function onError(fn) {
|
|
1086
1013
|
ERROR || (ERROR = Symbol("error"));
|
|
1087
|
-
if (Owner === null);
|
|
1088
|
-
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1014
|
+
if (Owner === null) ;else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1089
1015
|
Owner.context = {
|
|
1090
1016
|
...Owner.context,
|
|
1091
1017
|
[ERROR]: [fn]
|
|
@@ -1114,8 +1040,7 @@ function observable(input) {
|
|
|
1114
1040
|
if (!(observer instanceof Object) || observer == null) {
|
|
1115
1041
|
throw new TypeError("Expected the observer to be an object.");
|
|
1116
1042
|
}
|
|
1117
|
-
const handler =
|
|
1118
|
-
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1043
|
+
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1119
1044
|
if (!handler) {
|
|
1120
1045
|
return {
|
|
1121
1046
|
unsubscribe() {}
|
|
@@ -1146,7 +1071,7 @@ function from(producer, initalValue = undefined) {
|
|
|
1146
1071
|
});
|
|
1147
1072
|
if ("subscribe" in producer) {
|
|
1148
1073
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1149
|
-
onCleanup(() =>
|
|
1074
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1150
1075
|
} else {
|
|
1151
1076
|
const clean = producer(set);
|
|
1152
1077
|
onCleanup(clean);
|
|
@@ -1190,7 +1115,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1190
1115
|
});
|
|
1191
1116
|
len = 1;
|
|
1192
1117
|
}
|
|
1193
|
-
}
|
|
1118
|
+
}
|
|
1119
|
+
else if (len === 0) {
|
|
1194
1120
|
mapped = new Array(newLen);
|
|
1195
1121
|
for (j = 0; j < newLen; j++) {
|
|
1196
1122
|
items[j] = newItems[j];
|
|
@@ -1201,16 +1127,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1201
1127
|
temp = new Array(newLen);
|
|
1202
1128
|
tempdisposers = new Array(newLen);
|
|
1203
1129
|
indexes && (tempIndexes = new Array(newLen));
|
|
1204
|
-
for (
|
|
1205
|
-
|
|
1206
|
-
start < end && items[start] === newItems[start];
|
|
1207
|
-
start++
|
|
1208
|
-
);
|
|
1209
|
-
for (
|
|
1210
|
-
end = len - 1, newEnd = newLen - 1;
|
|
1211
|
-
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1212
|
-
end--, newEnd--
|
|
1213
|
-
) {
|
|
1130
|
+
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
|
|
1131
|
+
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
|
|
1214
1132
|
temp[newEnd] = mapped[end];
|
|
1215
1133
|
tempdisposers[newEnd] = disposers[end];
|
|
1216
1134
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1244,7 +1162,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1244
1162
|
}
|
|
1245
1163
|
} else mapped[j] = createRoot(mapper);
|
|
1246
1164
|
}
|
|
1247
|
-
mapped = mapped.slice(0,
|
|
1165
|
+
mapped = mapped.slice(0, len = newLen);
|
|
1248
1166
|
items = newItems.slice(0);
|
|
1249
1167
|
}
|
|
1250
1168
|
return mapped;
|
|
@@ -1311,7 +1229,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1311
1229
|
}
|
|
1312
1230
|
len = signals.length = disposers.length = newLen;
|
|
1313
1231
|
items = newItems.slice(0);
|
|
1314
|
-
return
|
|
1232
|
+
return mapped = mapped.slice(0, len);
|
|
1315
1233
|
});
|
|
1316
1234
|
function mapper(disposer) {
|
|
1317
1235
|
disposers[i] = disposer;
|
|
@@ -1380,33 +1298,29 @@ function mergeProps(...sources) {
|
|
|
1380
1298
|
let proxy = false;
|
|
1381
1299
|
for (let i = 0; i < sources.length; i++) {
|
|
1382
1300
|
const s = sources[i];
|
|
1383
|
-
proxy = proxy ||
|
|
1384
|
-
sources[i] = typeof s === "function" ? (
|
|
1301
|
+
proxy = proxy || !!s && $PROXY in s;
|
|
1302
|
+
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1385
1303
|
}
|
|
1386
1304
|
if (SUPPORTS_PROXY && proxy) {
|
|
1387
|
-
return new Proxy(
|
|
1388
|
-
{
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
if (v !== undefined) return v;
|
|
1393
|
-
}
|
|
1394
|
-
},
|
|
1395
|
-
has(property) {
|
|
1396
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1397
|
-
if (property in resolveSource(sources[i])) return true;
|
|
1398
|
-
}
|
|
1399
|
-
return false;
|
|
1400
|
-
},
|
|
1401
|
-
keys() {
|
|
1402
|
-
const keys = [];
|
|
1403
|
-
for (let i = 0; i < sources.length; i++)
|
|
1404
|
-
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1405
|
-
return [...new Set(keys)];
|
|
1305
|
+
return new Proxy({
|
|
1306
|
+
get(property) {
|
|
1307
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1308
|
+
const v = resolveSource(sources[i])[property];
|
|
1309
|
+
if (v !== undefined) return v;
|
|
1406
1310
|
}
|
|
1407
1311
|
},
|
|
1408
|
-
|
|
1409
|
-
|
|
1312
|
+
has(property) {
|
|
1313
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1314
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1315
|
+
}
|
|
1316
|
+
return false;
|
|
1317
|
+
},
|
|
1318
|
+
keys() {
|
|
1319
|
+
const keys = [];
|
|
1320
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1321
|
+
return [...new Set(keys)];
|
|
1322
|
+
}
|
|
1323
|
+
}, propTraps);
|
|
1410
1324
|
}
|
|
1411
1325
|
const sourcesMap = {};
|
|
1412
1326
|
const defined = Object.create(null);
|
|
@@ -1419,20 +1333,15 @@ function mergeProps(...sources) {
|
|
|
1419
1333
|
if (key === "__proto__" || key === "constructor") continue;
|
|
1420
1334
|
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
1421
1335
|
if (!defined[key]) {
|
|
1422
|
-
defined[key] = desc.get
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
}
|
|
1428
|
-
: desc.value !== undefined
|
|
1429
|
-
? desc
|
|
1430
|
-
: undefined;
|
|
1336
|
+
defined[key] = desc.get ? {
|
|
1337
|
+
enumerable: true,
|
|
1338
|
+
configurable: true,
|
|
1339
|
+
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1340
|
+
} : desc.value !== undefined ? desc : undefined;
|
|
1431
1341
|
} else {
|
|
1432
1342
|
const sources = sourcesMap[key];
|
|
1433
1343
|
if (sources) {
|
|
1434
|
-
if (desc.get) sources.push(desc.get.bind(source));
|
|
1435
|
-
else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1344
|
+
if (desc.get) sources.push(desc.get.bind(source));else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1436
1345
|
}
|
|
1437
1346
|
}
|
|
1438
1347
|
}
|
|
@@ -1442,8 +1351,7 @@ function mergeProps(...sources) {
|
|
|
1442
1351
|
for (let i = definedKeys.length - 1; i >= 0; i--) {
|
|
1443
1352
|
const key = definedKeys[i],
|
|
1444
1353
|
desc = defined[key];
|
|
1445
|
-
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1446
|
-
else target[key] = desc ? desc.value : undefined;
|
|
1354
|
+
if (desc && desc.get) Object.defineProperty(target, key, desc);else target[key] = desc ? desc.value : undefined;
|
|
1447
1355
|
}
|
|
1448
1356
|
return target;
|
|
1449
1357
|
}
|
|
@@ -1451,60 +1359,47 @@ function splitProps(props, ...keys) {
|
|
|
1451
1359
|
if (SUPPORTS_PROXY && $PROXY in props) {
|
|
1452
1360
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1453
1361
|
const res = keys.map(k => {
|
|
1454
|
-
return new Proxy(
|
|
1455
|
-
{
|
|
1456
|
-
|
|
1457
|
-
return k.includes(property) ? props[property] : undefined;
|
|
1458
|
-
},
|
|
1459
|
-
has(property) {
|
|
1460
|
-
return k.includes(property) && property in props;
|
|
1461
|
-
},
|
|
1462
|
-
keys() {
|
|
1463
|
-
return k.filter(property => property in props);
|
|
1464
|
-
}
|
|
1362
|
+
return new Proxy({
|
|
1363
|
+
get(property) {
|
|
1364
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1465
1365
|
},
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
});
|
|
1469
|
-
res.push(
|
|
1470
|
-
new Proxy(
|
|
1471
|
-
{
|
|
1472
|
-
get(property) {
|
|
1473
|
-
return blocked.has(property) ? undefined : props[property];
|
|
1474
|
-
},
|
|
1475
|
-
has(property) {
|
|
1476
|
-
return blocked.has(property) ? false : property in props;
|
|
1477
|
-
},
|
|
1478
|
-
keys() {
|
|
1479
|
-
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1480
|
-
}
|
|
1366
|
+
has(property) {
|
|
1367
|
+
return k.includes(property) && property in props;
|
|
1481
1368
|
},
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1369
|
+
keys() {
|
|
1370
|
+
return k.filter(property => property in props);
|
|
1371
|
+
}
|
|
1372
|
+
}, propTraps);
|
|
1373
|
+
});
|
|
1374
|
+
res.push(new Proxy({
|
|
1375
|
+
get(property) {
|
|
1376
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1377
|
+
},
|
|
1378
|
+
has(property) {
|
|
1379
|
+
return blocked.has(property) ? false : property in props;
|
|
1380
|
+
},
|
|
1381
|
+
keys() {
|
|
1382
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1383
|
+
}
|
|
1384
|
+
}, propTraps));
|
|
1485
1385
|
return res;
|
|
1486
1386
|
}
|
|
1487
1387
|
const otherObject = {};
|
|
1488
1388
|
const objects = keys.map(() => ({}));
|
|
1489
1389
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1490
1390
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1491
|
-
const isDefaultDesc =
|
|
1492
|
-
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1391
|
+
const isDefaultDesc = !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1493
1392
|
let blocked = false;
|
|
1494
1393
|
let objectIndex = 0;
|
|
1495
1394
|
for (const k of keys) {
|
|
1496
1395
|
if (k.includes(propName)) {
|
|
1497
1396
|
blocked = true;
|
|
1498
|
-
isDefaultDesc
|
|
1499
|
-
? (objects[objectIndex][propName] = desc.value)
|
|
1500
|
-
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1397
|
+
isDefaultDesc ? objects[objectIndex][propName] = desc.value : Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1501
1398
|
}
|
|
1502
1399
|
++objectIndex;
|
|
1503
1400
|
}
|
|
1504
1401
|
if (!blocked) {
|
|
1505
|
-
isDefaultDesc
|
|
1506
|
-
? (otherObject[propName] = desc.value)
|
|
1507
|
-
: Object.defineProperty(otherObject, propName, desc);
|
|
1402
|
+
isDefaultDesc ? otherObject[propName] = desc.value : Object.defineProperty(otherObject, propName, desc);
|
|
1508
1403
|
}
|
|
1509
1404
|
}
|
|
1510
1405
|
return [...objects, otherObject];
|
|
@@ -1530,21 +1425,17 @@ function lazy(fn) {
|
|
|
1530
1425
|
comp = s;
|
|
1531
1426
|
}
|
|
1532
1427
|
let Comp;
|
|
1533
|
-
return createMemo(() =>
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
return r;
|
|
1543
|
-
})
|
|
1544
|
-
: ""
|
|
1545
|
-
);
|
|
1428
|
+
return createMemo(() => (Comp = comp()) ? untrack(() => {
|
|
1429
|
+
if (IS_DEV) ;
|
|
1430
|
+
if (!ctx || sharedConfig.done) return Comp(props);
|
|
1431
|
+
const c = sharedConfig.context;
|
|
1432
|
+
setHydrateContext(ctx);
|
|
1433
|
+
const r = Comp(props);
|
|
1434
|
+
setHydrateContext(c);
|
|
1435
|
+
return r;
|
|
1436
|
+
}) : "");
|
|
1546
1437
|
};
|
|
1547
|
-
wrap.preload = () => p || ((p = fn()).then(mod =>
|
|
1438
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1548
1439
|
return wrap;
|
|
1549
1440
|
}
|
|
1550
1441
|
let counter = 0;
|
|
@@ -1569,35 +1460,21 @@ function Index(props) {
|
|
|
1569
1460
|
function Show(props) {
|
|
1570
1461
|
const keyed = props.keyed;
|
|
1571
1462
|
const conditionValue = createMemo(() => props.when, undefined, undefined);
|
|
1572
|
-
const condition = keyed
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
? c
|
|
1588
|
-
: () => {
|
|
1589
|
-
if (!untrack(condition)) throw narrowedError("Show");
|
|
1590
|
-
return conditionValue();
|
|
1591
|
-
}
|
|
1592
|
-
)
|
|
1593
|
-
)
|
|
1594
|
-
: child;
|
|
1595
|
-
}
|
|
1596
|
-
return props.fallback;
|
|
1597
|
-
},
|
|
1598
|
-
undefined,
|
|
1599
|
-
undefined
|
|
1600
|
-
);
|
|
1463
|
+
const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1464
|
+
equals: (a, b) => !a === !b
|
|
1465
|
+
});
|
|
1466
|
+
return createMemo(() => {
|
|
1467
|
+
const c = condition();
|
|
1468
|
+
if (c) {
|
|
1469
|
+
const child = props.children;
|
|
1470
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1471
|
+
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1472
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1473
|
+
return conditionValue();
|
|
1474
|
+
})) : child;
|
|
1475
|
+
}
|
|
1476
|
+
return props.fallback;
|
|
1477
|
+
}, undefined, undefined);
|
|
1601
1478
|
}
|
|
1602
1479
|
function Switch(props) {
|
|
1603
1480
|
const chs = children(() => props.children);
|
|
@@ -1609,43 +1486,25 @@ function Switch(props) {
|
|
|
1609
1486
|
const index = i;
|
|
1610
1487
|
const mp = mps[i];
|
|
1611
1488
|
const prevFunc = func;
|
|
1612
|
-
const conditionValue = createMemo(
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
);
|
|
1617
|
-
const condition = mp.keyed
|
|
1618
|
-
? conditionValue
|
|
1619
|
-
: createMemo(conditionValue, undefined, {
|
|
1620
|
-
equals: (a, b) => !a === !b
|
|
1621
|
-
});
|
|
1489
|
+
const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, undefined);
|
|
1490
|
+
const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1491
|
+
equals: (a, b) => !a === !b
|
|
1492
|
+
});
|
|
1622
1493
|
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
1623
1494
|
}
|
|
1624
1495
|
return func;
|
|
1625
1496
|
});
|
|
1626
|
-
return createMemo(
|
|
1627
|
-
()
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
? conditionValue()
|
|
1638
|
-
: () => {
|
|
1639
|
-
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
1640
|
-
return conditionValue();
|
|
1641
|
-
}
|
|
1642
|
-
)
|
|
1643
|
-
)
|
|
1644
|
-
: child;
|
|
1645
|
-
},
|
|
1646
|
-
undefined,
|
|
1647
|
-
undefined
|
|
1648
|
-
);
|
|
1497
|
+
return createMemo(() => {
|
|
1498
|
+
const sel = switchFunc()();
|
|
1499
|
+
if (!sel) return props.fallback;
|
|
1500
|
+
const [index, conditionValue, mp] = sel;
|
|
1501
|
+
const child = mp.children;
|
|
1502
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1503
|
+
return fn ? untrack(() => child(mp.keyed ? conditionValue() : () => {
|
|
1504
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
1505
|
+
return conditionValue();
|
|
1506
|
+
})) : child;
|
|
1507
|
+
}, undefined, undefined);
|
|
1649
1508
|
}
|
|
1650
1509
|
function Match(props) {
|
|
1651
1510
|
return props;
|
|
@@ -1656,29 +1515,23 @@ function resetErrorBoundaries() {
|
|
|
1656
1515
|
}
|
|
1657
1516
|
function ErrorBoundary(props) {
|
|
1658
1517
|
let err;
|
|
1659
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1660
|
-
err = sharedConfig.load(sharedConfig.getContextId());
|
|
1518
|
+
if (sharedConfig.context && sharedConfig.load) err = sharedConfig.load(sharedConfig.getContextId());
|
|
1661
1519
|
const [errored, setErrored] = createSignal(err, undefined);
|
|
1662
1520
|
Errors || (Errors = new Set());
|
|
1663
1521
|
Errors.add(setErrored);
|
|
1664
1522
|
onCleanup(() => Errors.delete(setErrored));
|
|
1665
|
-
return createMemo(
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
},
|
|
1674
|
-
undefined,
|
|
1675
|
-
undefined
|
|
1676
|
-
);
|
|
1523
|
+
return createMemo(() => {
|
|
1524
|
+
let e;
|
|
1525
|
+
if (e = errored()) {
|
|
1526
|
+
const f = props.fallback;
|
|
1527
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1528
|
+
}
|
|
1529
|
+
return catchError(() => props.children, setErrored);
|
|
1530
|
+
}, undefined, undefined);
|
|
1677
1531
|
}
|
|
1678
1532
|
|
|
1679
|
-
const suspenseListEquals = (a, b) =>
|
|
1680
|
-
|
|
1681
|
-
const SuspenseListContext = /* #__PURE__ */ createContext();
|
|
1533
|
+
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1534
|
+
const SuspenseListContext = /* #__PURE__ */createContext();
|
|
1682
1535
|
function SuspenseList(props) {
|
|
1683
1536
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1684
1537
|
inFallback: false
|
|
@@ -1689,51 +1542,51 @@ function SuspenseList(props) {
|
|
|
1689
1542
|
if (listContext) {
|
|
1690
1543
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1691
1544
|
}
|
|
1692
|
-
const resolved = createMemo(
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1545
|
+
const resolved = createMemo(prev => {
|
|
1546
|
+
const reveal = props.revealOrder,
|
|
1547
|
+
tail = props.tail,
|
|
1548
|
+
{
|
|
1549
|
+
showContent = true,
|
|
1550
|
+
showFallback = true
|
|
1551
|
+
} = show ? show() : {},
|
|
1552
|
+
reg = registry(),
|
|
1553
|
+
reverse = reveal === "backwards";
|
|
1554
|
+
if (reveal === "together") {
|
|
1555
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1556
|
+
const res = reg.map(() => ({
|
|
1557
|
+
showContent: all && showContent,
|
|
1558
|
+
showFallback
|
|
1559
|
+
}));
|
|
1560
|
+
res.inFallback = !all;
|
|
1561
|
+
return res;
|
|
1562
|
+
}
|
|
1563
|
+
let stop = false;
|
|
1564
|
+
let inFallback = prev.inFallback;
|
|
1565
|
+
const res = [];
|
|
1566
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1567
|
+
const n = reverse ? len - i - 1 : i,
|
|
1568
|
+
s = reg[n]();
|
|
1569
|
+
if (!stop && !s) {
|
|
1570
|
+
res[n] = {
|
|
1571
|
+
showContent,
|
|
1703
1572
|
showFallback
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
s = reg[n]();
|
|
1714
|
-
if (!stop && !s) {
|
|
1715
|
-
res[n] = {
|
|
1716
|
-
showContent,
|
|
1717
|
-
showFallback
|
|
1718
|
-
};
|
|
1719
|
-
} else {
|
|
1720
|
-
const next = !stop;
|
|
1721
|
-
if (next) inFallback = true;
|
|
1722
|
-
res[n] = {
|
|
1723
|
-
showContent: next,
|
|
1724
|
-
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1725
|
-
};
|
|
1726
|
-
stop = true;
|
|
1727
|
-
}
|
|
1573
|
+
};
|
|
1574
|
+
} else {
|
|
1575
|
+
const next = !stop;
|
|
1576
|
+
if (next) inFallback = true;
|
|
1577
|
+
res[n] = {
|
|
1578
|
+
showContent: next,
|
|
1579
|
+
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1580
|
+
};
|
|
1581
|
+
stop = true;
|
|
1728
1582
|
}
|
|
1729
|
-
if (!stop) inFallback = false;
|
|
1730
|
-
res.inFallback = inFallback;
|
|
1731
|
-
return res;
|
|
1732
|
-
},
|
|
1733
|
-
{
|
|
1734
|
-
inFallback: false
|
|
1735
1583
|
}
|
|
1736
|
-
|
|
1584
|
+
if (!stop) inFallback = false;
|
|
1585
|
+
res.inFallback = inFallback;
|
|
1586
|
+
return res;
|
|
1587
|
+
}, {
|
|
1588
|
+
inFallback: false
|
|
1589
|
+
});
|
|
1737
1590
|
setWrapper(() => resolved);
|
|
1738
1591
|
return createComponent(SuspenseListContext.Provider, {
|
|
1739
1592
|
value: {
|
|
@@ -1778,27 +1631,23 @@ function Suspense(props) {
|
|
|
1778
1631
|
const key = sharedConfig.getContextId();
|
|
1779
1632
|
let ref = sharedConfig.load(key);
|
|
1780
1633
|
if (ref) {
|
|
1781
|
-
if (typeof ref !== "object" || ref.
|
|
1782
|
-
else sharedConfig.gather(key);
|
|
1634
|
+
if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(key);
|
|
1783
1635
|
}
|
|
1784
1636
|
if (p && p !== "$$f") {
|
|
1785
1637
|
const [s, set] = createSignal(undefined, {
|
|
1786
1638
|
equals: false
|
|
1787
1639
|
});
|
|
1788
1640
|
flicker = s;
|
|
1789
|
-
p.then(
|
|
1790
|
-
()
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
set();
|
|
1800
|
-
}
|
|
1801
|
-
);
|
|
1641
|
+
p.then(() => {
|
|
1642
|
+
if (sharedConfig.done) return set();
|
|
1643
|
+
sharedConfig.gather(key);
|
|
1644
|
+
setHydrateContext(ctx);
|
|
1645
|
+
set();
|
|
1646
|
+
setHydrateContext();
|
|
1647
|
+
}, err => {
|
|
1648
|
+
error = err;
|
|
1649
|
+
set();
|
|
1650
|
+
});
|
|
1802
1651
|
}
|
|
1803
1652
|
}
|
|
1804
1653
|
const listContext = useContext(SuspenseListContext);
|
|
@@ -1813,14 +1662,17 @@ function Suspense(props) {
|
|
|
1813
1662
|
ctx = sharedConfig.context;
|
|
1814
1663
|
if (flicker) {
|
|
1815
1664
|
flicker();
|
|
1816
|
-
return
|
|
1665
|
+
return flicker = undefined;
|
|
1817
1666
|
}
|
|
1818
1667
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1819
1668
|
const rendered = createMemo(() => props.children);
|
|
1820
1669
|
return createMemo(prev => {
|
|
1821
1670
|
const inFallback = store.inFallback(),
|
|
1822
|
-
{
|
|
1823
|
-
|
|
1671
|
+
{
|
|
1672
|
+
showContent = true,
|
|
1673
|
+
showFallback = true
|
|
1674
|
+
} = show ? show() : {};
|
|
1675
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1824
1676
|
store.resolved = true;
|
|
1825
1677
|
dispose && dispose();
|
|
1826
1678
|
dispose = ctx = p = undefined;
|
|
@@ -1848,59 +1700,4 @@ function Suspense(props) {
|
|
|
1848
1700
|
|
|
1849
1701
|
const DEV = undefined;
|
|
1850
1702
|
|
|
1851
|
-
export {
|
|
1852
|
-
$DEVCOMP,
|
|
1853
|
-
$PROXY,
|
|
1854
|
-
$TRACK,
|
|
1855
|
-
DEV,
|
|
1856
|
-
ErrorBoundary,
|
|
1857
|
-
For,
|
|
1858
|
-
Index,
|
|
1859
|
-
Match,
|
|
1860
|
-
Show,
|
|
1861
|
-
Suspense,
|
|
1862
|
-
SuspenseList,
|
|
1863
|
-
Switch,
|
|
1864
|
-
batch,
|
|
1865
|
-
cancelCallback,
|
|
1866
|
-
catchError,
|
|
1867
|
-
children,
|
|
1868
|
-
createComponent,
|
|
1869
|
-
createComputed,
|
|
1870
|
-
createContext,
|
|
1871
|
-
createDeferred,
|
|
1872
|
-
createEffect,
|
|
1873
|
-
createMemo,
|
|
1874
|
-
createReaction,
|
|
1875
|
-
createRenderEffect,
|
|
1876
|
-
createResource,
|
|
1877
|
-
createRoot,
|
|
1878
|
-
createSelector,
|
|
1879
|
-
createSignal,
|
|
1880
|
-
createUniqueId,
|
|
1881
|
-
enableExternalSource,
|
|
1882
|
-
enableHydration,
|
|
1883
|
-
enableScheduling,
|
|
1884
|
-
equalFn,
|
|
1885
|
-
from,
|
|
1886
|
-
getListener,
|
|
1887
|
-
getOwner,
|
|
1888
|
-
indexArray,
|
|
1889
|
-
lazy,
|
|
1890
|
-
mapArray,
|
|
1891
|
-
mergeProps,
|
|
1892
|
-
observable,
|
|
1893
|
-
on,
|
|
1894
|
-
onCleanup,
|
|
1895
|
-
onError,
|
|
1896
|
-
onMount,
|
|
1897
|
-
requestCallback,
|
|
1898
|
-
resetErrorBoundaries,
|
|
1899
|
-
runWithOwner,
|
|
1900
|
-
sharedConfig,
|
|
1901
|
-
splitProps,
|
|
1902
|
-
startTransition,
|
|
1903
|
-
untrack,
|
|
1904
|
-
useContext,
|
|
1905
|
-
useTransition
|
|
1906
|
-
};
|
|
1703
|
+
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 };
|