solid-js 1.8.22 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.cjs +7 -6
- package/dist/dev.js +567 -325
- package/dist/server.cjs +1 -1
- package/dist/server.js +169 -75
- package/dist/solid.cjs +7 -6
- package/dist/solid.js +494 -283
- package/h/dist/h.js +40 -9
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +13 -10
- package/h/jsx-runtime/types/jsx.d.ts +22 -1
- package/h/types/hyperscript.d.ts +11 -11
- package/h/types/index.d.ts +1 -1
- package/html/dist/html.cjs +4 -2
- package/html/dist/html.js +222 -95
- package/html/types/index.d.ts +1 -1
- package/html/types/lit.d.ts +52 -33
- package/package.json +1 -5
- package/store/dist/dev.cjs +1 -1
- package/store/dist/dev.js +123 -43
- package/store/dist/server.cjs +4 -0
- package/store/dist/server.js +23 -8
- package/store/dist/store.cjs +1 -1
- package/store/dist/store.js +114 -40
- package/store/package.json +0 -4
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +26 -5
- package/store/types/store.d.ts +219 -62
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +35 -8
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +236 -143
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +64 -33
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +15 -15
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +169 -98
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.cjs +57 -24
- package/web/dist/dev.js +679 -101
- package/web/dist/server.cjs +96 -15
- package/web/dist/server.js +676 -105
- package/web/dist/web.cjs +53 -23
- package/web/dist/web.js +664 -99
- package/web/package.json +0 -4
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +5 -3
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
- package/web/types/server.d.ts +88 -0
package/dist/dev.js
CHANGED
|
@@ -52,9 +52,11 @@ function enqueue(taskQueue, task) {
|
|
|
52
52
|
let m = 0;
|
|
53
53
|
let n = taskQueue.length - 1;
|
|
54
54
|
while (m <= n) {
|
|
55
|
-
const k = n + m >> 1;
|
|
55
|
+
const k = (n + m) >> 1;
|
|
56
56
|
const cmp = task.expirationTime - taskQueue[k].expirationTime;
|
|
57
|
-
if (cmp > 0) m = k + 1;
|
|
57
|
+
if (cmp > 0) m = k + 1;
|
|
58
|
+
else if (cmp < 0) n = k - 1;
|
|
59
|
+
else return k;
|
|
58
60
|
}
|
|
59
61
|
return m;
|
|
60
62
|
}
|
|
@@ -144,6 +146,7 @@ function nextHydrateContext() {
|
|
|
144
146
|
|
|
145
147
|
const equalFn = (a, b) => a === b;
|
|
146
148
|
const $PROXY = Symbol("solid-proxy");
|
|
149
|
+
const SUPPORTS_PROXY = typeof Proxy === "function";
|
|
147
150
|
const $TRACK = Symbol("solid-track");
|
|
148
151
|
const $DEVCOMP = Symbol("solid-dev-component");
|
|
149
152
|
const signalOptions = {
|
|
@@ -178,20 +181,25 @@ function createRoot(fn, detachedOwner) {
|
|
|
178
181
|
owner = Owner,
|
|
179
182
|
unowned = fn.length === 0,
|
|
180
183
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
181
|
-
root = unowned
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
184
|
+
root = unowned
|
|
185
|
+
? {
|
|
186
|
+
owned: null,
|
|
187
|
+
cleanups: null,
|
|
188
|
+
context: null,
|
|
189
|
+
owner: null
|
|
190
|
+
}
|
|
191
|
+
: {
|
|
192
|
+
owned: null,
|
|
193
|
+
cleanups: null,
|
|
194
|
+
context: current ? current.context : null,
|
|
195
|
+
owner: current
|
|
196
|
+
},
|
|
197
|
+
updateFn = unowned
|
|
198
|
+
? () =>
|
|
199
|
+
fn(() => {
|
|
200
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
201
|
+
})
|
|
202
|
+
: () => fn(() => untrack(() => cleanNode(root)));
|
|
195
203
|
DevHooks.afterCreateOwner && DevHooks.afterCreateOwner(root);
|
|
196
204
|
Owner = root;
|
|
197
205
|
Listener = null;
|
|
@@ -217,23 +225,26 @@ function createSignal(value, options) {
|
|
|
217
225
|
}
|
|
218
226
|
const setter = value => {
|
|
219
227
|
if (typeof value === "function") {
|
|
220
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
228
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
229
|
+
else value = value(s.value);
|
|
221
230
|
}
|
|
222
231
|
return writeSignal(s, value);
|
|
223
232
|
};
|
|
224
233
|
return [readSignal.bind(s), setter];
|
|
225
234
|
}
|
|
226
235
|
function createComputed(fn, value, options) {
|
|
227
|
-
const c = createComputation(fn, value, true, STALE, options
|
|
228
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
236
|
+
const c = createComputation(fn, value, true, STALE, options);
|
|
237
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
238
|
+
else updateComputation(c);
|
|
229
239
|
}
|
|
230
240
|
function createRenderEffect(fn, value, options) {
|
|
231
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
232
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
241
|
+
const c = createComputation(fn, value, false, STALE, options);
|
|
242
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
243
|
+
else updateComputation(c);
|
|
233
244
|
}
|
|
234
245
|
function createEffect(fn, value, options) {
|
|
235
246
|
runEffects = runUserEffects;
|
|
236
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
247
|
+
const c = createComputation(fn, value, false, STALE, options),
|
|
237
248
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
238
249
|
if (s) c.suspense = s;
|
|
239
250
|
if (!options || !options.render) c.user = true;
|
|
@@ -241,10 +252,16 @@ function createEffect(fn, value, options) {
|
|
|
241
252
|
}
|
|
242
253
|
function createReaction(onInvalidate, options) {
|
|
243
254
|
let fn;
|
|
244
|
-
const c = createComputation(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
255
|
+
const c = createComputation(
|
|
256
|
+
() => {
|
|
257
|
+
fn ? fn() : untrack(onInvalidate);
|
|
258
|
+
fn = undefined;
|
|
259
|
+
},
|
|
260
|
+
undefined,
|
|
261
|
+
false,
|
|
262
|
+
0,
|
|
263
|
+
options
|
|
264
|
+
),
|
|
248
265
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
249
266
|
if (s) c.suspense = s;
|
|
250
267
|
c.user = true;
|
|
@@ -255,7 +272,7 @@ function createReaction(onInvalidate, options) {
|
|
|
255
272
|
}
|
|
256
273
|
function createMemo(fn, value, options) {
|
|
257
274
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
258
|
-
const c = createComputation(fn, value, true, 0, options
|
|
275
|
+
const c = createComputation(fn, value, true, 0, options);
|
|
259
276
|
c.observers = null;
|
|
260
277
|
c.observerSlots = null;
|
|
261
278
|
c.comparator = options.equals || undefined;
|
|
@@ -272,7 +289,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
272
289
|
let source;
|
|
273
290
|
let fetcher;
|
|
274
291
|
let options;
|
|
275
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
292
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
276
293
|
source = true;
|
|
277
294
|
fetcher = pSource;
|
|
278
295
|
options = pFetcher || {};
|
|
@@ -286,7 +303,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
286
303
|
id = null,
|
|
287
304
|
loadedUnderTransition = false,
|
|
288
305
|
scheduled = false,
|
|
289
|
-
resolved =
|
|
306
|
+
resolved = "initialValue" in options,
|
|
290
307
|
dynamic = typeof source === "function" && createMemo(source);
|
|
291
308
|
const contexts = new Set(),
|
|
292
309
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -297,15 +314,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
297
314
|
[state, setState] = createSignal(resolved ? "ready" : "unresolved");
|
|
298
315
|
if (sharedConfig.context) {
|
|
299
316
|
id = sharedConfig.getNextContextId();
|
|
300
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
317
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
318
|
+
else if (sharedConfig.load && sharedConfig.has(id)) initP = sharedConfig.load(id);
|
|
301
319
|
}
|
|
302
320
|
function loadEnd(p, v, error, key) {
|
|
303
321
|
if (pr === p) {
|
|
304
322
|
pr = null;
|
|
305
323
|
key !== undefined && (resolved = true);
|
|
306
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
307
|
-
|
|
308
|
-
|
|
324
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
325
|
+
queueMicrotask(() =>
|
|
326
|
+
options.onHydrated(key, {
|
|
327
|
+
value: v
|
|
328
|
+
})
|
|
329
|
+
);
|
|
309
330
|
initP = NO_INIT;
|
|
310
331
|
if (Transition && p && loadedUnderTransition) {
|
|
311
332
|
Transition.promises.delete(p);
|
|
@@ -336,7 +357,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
336
357
|
createComputed(() => {
|
|
337
358
|
track();
|
|
338
359
|
if (pr) {
|
|
339
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
360
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
361
|
+
else if (!contexts.has(c)) {
|
|
340
362
|
c.increment();
|
|
341
363
|
contexts.add(c);
|
|
342
364
|
}
|
|
@@ -355,26 +377,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
355
377
|
return;
|
|
356
378
|
}
|
|
357
379
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
358
|
-
const p =
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
380
|
+
const p =
|
|
381
|
+
initP !== NO_INIT
|
|
382
|
+
? initP
|
|
383
|
+
: untrack(() =>
|
|
384
|
+
fetcher(lookup, {
|
|
385
|
+
value: value(),
|
|
386
|
+
refetching
|
|
387
|
+
})
|
|
388
|
+
);
|
|
362
389
|
if (!isPromise(p)) {
|
|
363
390
|
loadEnd(pr, p, undefined, lookup);
|
|
364
391
|
return p;
|
|
365
392
|
}
|
|
366
393
|
pr = p;
|
|
367
394
|
if ("value" in p) {
|
|
368
|
-
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
395
|
+
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
396
|
+
else loadEnd(pr, undefined, castError(p.value), lookup);
|
|
369
397
|
return p;
|
|
370
398
|
}
|
|
371
399
|
scheduled = true;
|
|
372
|
-
queueMicrotask(() => scheduled = false);
|
|
400
|
+
queueMicrotask(() => (scheduled = false));
|
|
373
401
|
runUpdates(() => {
|
|
374
402
|
setState(resolved ? "refreshing" : "pending");
|
|
375
403
|
trigger();
|
|
376
404
|
}, false);
|
|
377
|
-
return p.then(
|
|
405
|
+
return p.then(
|
|
406
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
407
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
408
|
+
);
|
|
378
409
|
}
|
|
379
410
|
Object.defineProperties(read, {
|
|
380
411
|
state: {
|
|
@@ -398,50 +429,81 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
398
429
|
}
|
|
399
430
|
}
|
|
400
431
|
});
|
|
401
|
-
if (dynamic) createComputed(() => load(false));
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
432
|
+
if (dynamic) createComputed(() => load(false));
|
|
433
|
+
else load(false);
|
|
434
|
+
return [
|
|
435
|
+
read,
|
|
436
|
+
{
|
|
437
|
+
refetch: load,
|
|
438
|
+
mutate: setValue
|
|
439
|
+
}
|
|
440
|
+
];
|
|
406
441
|
}
|
|
407
442
|
function createDeferred(source, options) {
|
|
408
443
|
let t,
|
|
409
444
|
timeout = options ? options.timeoutMs : undefined;
|
|
410
|
-
const node = createComputation(
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
445
|
+
const node = createComputation(
|
|
446
|
+
() => {
|
|
447
|
+
if (!t || !t.fn)
|
|
448
|
+
t = requestCallback(
|
|
449
|
+
() => setDeferred(() => node.value),
|
|
450
|
+
timeout !== undefined
|
|
451
|
+
? {
|
|
452
|
+
timeout
|
|
453
|
+
}
|
|
454
|
+
: undefined
|
|
455
|
+
);
|
|
456
|
+
return source();
|
|
457
|
+
},
|
|
458
|
+
undefined,
|
|
459
|
+
true
|
|
460
|
+
);
|
|
461
|
+
const [deferred, setDeferred] = createSignal(
|
|
462
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
463
|
+
options
|
|
464
|
+
);
|
|
417
465
|
updateComputation(node);
|
|
418
|
-
setDeferred(() =>
|
|
466
|
+
setDeferred(() =>
|
|
467
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
468
|
+
);
|
|
419
469
|
return deferred;
|
|
420
470
|
}
|
|
421
471
|
function createSelector(source, fn = equalFn, options) {
|
|
422
472
|
const subs = new Map();
|
|
423
|
-
const node = createComputation(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
for (const
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
473
|
+
const node = createComputation(
|
|
474
|
+
p => {
|
|
475
|
+
const v = source();
|
|
476
|
+
for (const [key, val] of subs.entries())
|
|
477
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
478
|
+
for (const c of val.values()) {
|
|
479
|
+
c.state = STALE;
|
|
480
|
+
if (c.pure) Updates.push(c);
|
|
481
|
+
else Effects.push(c);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return v;
|
|
485
|
+
},
|
|
486
|
+
undefined,
|
|
487
|
+
true,
|
|
488
|
+
STALE,
|
|
489
|
+
options
|
|
490
|
+
);
|
|
433
491
|
updateComputation(node);
|
|
434
492
|
return key => {
|
|
435
493
|
const listener = Listener;
|
|
436
494
|
if (listener) {
|
|
437
495
|
let l;
|
|
438
|
-
if (l = subs.get(key)) l.add(listener);
|
|
496
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
497
|
+
else subs.set(key, (l = new Set([listener])));
|
|
439
498
|
onCleanup(() => {
|
|
440
499
|
l.delete(listener);
|
|
441
500
|
!l.size && subs.delete(key);
|
|
442
501
|
});
|
|
443
502
|
}
|
|
444
|
-
return fn(
|
|
503
|
+
return fn(
|
|
504
|
+
key,
|
|
505
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
506
|
+
);
|
|
445
507
|
};
|
|
446
508
|
}
|
|
447
509
|
function batch(fn) {
|
|
@@ -481,7 +543,10 @@ function onMount(fn) {
|
|
|
481
543
|
createEffect(() => untrack(fn));
|
|
482
544
|
}
|
|
483
545
|
function onCleanup(fn) {
|
|
484
|
-
if (Owner === null)
|
|
546
|
+
if (Owner === null)
|
|
547
|
+
console.warn("cleanups created outside a `createRoot` or `render` will never be run");
|
|
548
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
549
|
+
else Owner.cleanups.push(fn);
|
|
485
550
|
return fn;
|
|
486
551
|
}
|
|
487
552
|
function catchError(fn, handler) {
|
|
@@ -535,15 +600,17 @@ function startTransition(fn) {
|
|
|
535
600
|
Owner = o;
|
|
536
601
|
let t;
|
|
537
602
|
if (Scheduler || SuspenseContext) {
|
|
538
|
-
t =
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
603
|
+
t =
|
|
604
|
+
Transition ||
|
|
605
|
+
(Transition = {
|
|
606
|
+
sources: new Set(),
|
|
607
|
+
effects: [],
|
|
608
|
+
promises: new Set(),
|
|
609
|
+
disposed: new Set(),
|
|
610
|
+
queue: new Set(),
|
|
611
|
+
running: true
|
|
612
|
+
});
|
|
613
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
547
614
|
t.running = true;
|
|
548
615
|
}
|
|
549
616
|
runUpdates(fn, false);
|
|
@@ -551,7 +618,7 @@ function startTransition(fn) {
|
|
|
551
618
|
return t ? t.done : undefined;
|
|
552
619
|
});
|
|
553
620
|
}
|
|
554
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
621
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
555
622
|
function useTransition() {
|
|
556
623
|
return [transPending, startTransition];
|
|
557
624
|
}
|
|
@@ -560,12 +627,18 @@ function resumeEffects(e) {
|
|
|
560
627
|
e.length = 0;
|
|
561
628
|
}
|
|
562
629
|
function devComponent(Comp, props) {
|
|
563
|
-
const c = createComputation(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
630
|
+
const c = createComputation(
|
|
631
|
+
() =>
|
|
632
|
+
untrack(() => {
|
|
633
|
+
Object.assign(Comp, {
|
|
634
|
+
[$DEVCOMP]: true
|
|
635
|
+
});
|
|
636
|
+
return Comp(props);
|
|
637
|
+
}),
|
|
638
|
+
undefined,
|
|
639
|
+
true,
|
|
640
|
+
0
|
|
641
|
+
);
|
|
569
642
|
c.props = props;
|
|
570
643
|
c.observers = null;
|
|
571
644
|
c.observerSlots = null;
|
|
@@ -576,7 +649,8 @@ function devComponent(Comp, props) {
|
|
|
576
649
|
}
|
|
577
650
|
function registerGraph(value) {
|
|
578
651
|
if (!Owner) return;
|
|
579
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
652
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
653
|
+
else Owner.sourceMap = [value];
|
|
580
654
|
value.graph = Owner;
|
|
581
655
|
}
|
|
582
656
|
function createContext(defaultValue, options) {
|
|
@@ -589,13 +663,15 @@ function createContext(defaultValue, options) {
|
|
|
589
663
|
}
|
|
590
664
|
function useContext(context) {
|
|
591
665
|
let value;
|
|
592
|
-
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
|
|
666
|
+
return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined
|
|
667
|
+
? value
|
|
668
|
+
: context.defaultValue;
|
|
593
669
|
}
|
|
594
670
|
function children(fn) {
|
|
595
671
|
const children = createMemo(fn);
|
|
596
672
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
597
673
|
name: "children"
|
|
598
|
-
})
|
|
674
|
+
});
|
|
599
675
|
memo.toArray = () => {
|
|
600
676
|
const c = memo();
|
|
601
677
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -608,10 +684,7 @@ function getSuspenseContext() {
|
|
|
608
684
|
}
|
|
609
685
|
function enableExternalSource(factory, untrack = fn => fn()) {
|
|
610
686
|
if (ExternalSourceConfig) {
|
|
611
|
-
const {
|
|
612
|
-
factory: oldFactory,
|
|
613
|
-
untrack: oldUntrack
|
|
614
|
-
} = ExternalSourceConfig;
|
|
687
|
+
const { factory: oldFactory, untrack: oldUntrack } = ExternalSourceConfig;
|
|
615
688
|
ExternalSourceConfig = {
|
|
616
689
|
factory: (fn, trigger) => {
|
|
617
690
|
const oldSource = oldFactory(fn, trigger);
|
|
@@ -636,7 +709,8 @@ function enableExternalSource(factory, untrack = fn => fn()) {
|
|
|
636
709
|
function readSignal() {
|
|
637
710
|
const runningTransition = Transition && Transition.running;
|
|
638
711
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
639
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
712
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
713
|
+
else {
|
|
640
714
|
const updates = Updates;
|
|
641
715
|
Updates = null;
|
|
642
716
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -664,11 +738,12 @@ function readSignal() {
|
|
|
664
738
|
return this.value;
|
|
665
739
|
}
|
|
666
740
|
function writeSignal(node, value, isComp) {
|
|
667
|
-
let current =
|
|
741
|
+
let current =
|
|
742
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
668
743
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
669
744
|
if (Transition) {
|
|
670
745
|
const TransitionRunning = Transition.running;
|
|
671
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
746
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
672
747
|
Transition.sources.add(node);
|
|
673
748
|
node.tValue = value;
|
|
674
749
|
}
|
|
@@ -681,10 +756,12 @@ function writeSignal(node, value, isComp) {
|
|
|
681
756
|
const TransitionRunning = Transition && Transition.running;
|
|
682
757
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
683
758
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
684
|
-
if (o.pure) Updates.push(o);
|
|
759
|
+
if (o.pure) Updates.push(o);
|
|
760
|
+
else Effects.push(o);
|
|
685
761
|
if (o.observers) markDownstream(o);
|
|
686
762
|
}
|
|
687
|
-
if (!TransitionRunning) o.state = STALE;
|
|
763
|
+
if (!TransitionRunning) o.state = STALE;
|
|
764
|
+
else o.tState = STALE;
|
|
688
765
|
}
|
|
689
766
|
if (Updates.length > 10e5) {
|
|
690
767
|
Updates = [];
|
|
@@ -700,7 +777,11 @@ function updateComputation(node) {
|
|
|
700
777
|
if (!node.fn) return;
|
|
701
778
|
cleanNode(node);
|
|
702
779
|
const time = ExecCount;
|
|
703
|
-
runComputation(
|
|
780
|
+
runComputation(
|
|
781
|
+
node,
|
|
782
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
783
|
+
time
|
|
784
|
+
);
|
|
704
785
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
705
786
|
queueMicrotask(() => {
|
|
706
787
|
runUpdates(() => {
|
|
@@ -765,11 +846,15 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
765
846
|
c.state = 0;
|
|
766
847
|
c.tState = state;
|
|
767
848
|
}
|
|
768
|
-
if (Owner === null)
|
|
849
|
+
if (Owner === null)
|
|
850
|
+
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
851
|
+
else if (Owner !== UNOWNED) {
|
|
769
852
|
if (Transition && Transition.running && Owner.pure) {
|
|
770
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
853
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
854
|
+
else Owner.tOwned.push(c);
|
|
771
855
|
} else {
|
|
772
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
856
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
857
|
+
else Owner.owned.push(c);
|
|
773
858
|
}
|
|
774
859
|
}
|
|
775
860
|
if (options && options.name) c.name = options.name;
|
|
@@ -822,7 +907,8 @@ function runUpdates(fn, init) {
|
|
|
822
907
|
if (Updates) return fn();
|
|
823
908
|
let wait = false;
|
|
824
909
|
if (!init) Updates = [];
|
|
825
|
-
if (Effects) wait = true;
|
|
910
|
+
if (Effects) wait = true;
|
|
911
|
+
else Effects = [];
|
|
826
912
|
ExecCount++;
|
|
827
913
|
try {
|
|
828
914
|
const res = fn();
|
|
@@ -836,7 +922,8 @@ function runUpdates(fn, init) {
|
|
|
836
922
|
}
|
|
837
923
|
function completeUpdates(wait) {
|
|
838
924
|
if (Updates) {
|
|
839
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
925
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
926
|
+
else runQueue(Updates);
|
|
840
927
|
Updates = null;
|
|
841
928
|
}
|
|
842
929
|
if (wait) return;
|
|
@@ -876,7 +963,8 @@ function completeUpdates(wait) {
|
|
|
876
963
|
}
|
|
877
964
|
const e = Effects;
|
|
878
965
|
Effects = null;
|
|
879
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
966
|
+
if (e.length) runUpdates(() => runEffects(e), false);
|
|
967
|
+
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
880
968
|
if (res) res();
|
|
881
969
|
}
|
|
882
970
|
function runQueue(queue) {
|
|
@@ -904,7 +992,8 @@ function runUserEffects(queue) {
|
|
|
904
992
|
userLength = 0;
|
|
905
993
|
for (i = 0; i < queue.length; i++) {
|
|
906
994
|
const e = queue[i];
|
|
907
|
-
if (!e.user) runTop(e);
|
|
995
|
+
if (!e.user) runTop(e);
|
|
996
|
+
else queue[userLength++] = e;
|
|
908
997
|
}
|
|
909
998
|
if (sharedConfig.context) {
|
|
910
999
|
if (sharedConfig.count) {
|
|
@@ -923,13 +1012,15 @@ function runUserEffects(queue) {
|
|
|
923
1012
|
}
|
|
924
1013
|
function lookUpstream(node, ignore) {
|
|
925
1014
|
const runningTransition = Transition && Transition.running;
|
|
926
|
-
if (runningTransition) node.tState = 0;
|
|
1015
|
+
if (runningTransition) node.tState = 0;
|
|
1016
|
+
else node.state = 0;
|
|
927
1017
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
928
1018
|
const source = node.sources[i];
|
|
929
1019
|
if (source.sources) {
|
|
930
1020
|
const state = runningTransition ? source.tState : source.state;
|
|
931
1021
|
if (state === STALE) {
|
|
932
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
1022
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
1023
|
+
runTop(source);
|
|
933
1024
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
934
1025
|
}
|
|
935
1026
|
}
|
|
@@ -939,8 +1030,10 @@ function markDownstream(node) {
|
|
|
939
1030
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
940
1031
|
const o = node.observers[i];
|
|
941
1032
|
if (runningTransition ? !o.tState : !o.state) {
|
|
942
|
-
if (runningTransition) o.tState = PENDING;
|
|
943
|
-
|
|
1033
|
+
if (runningTransition) o.tState = PENDING;
|
|
1034
|
+
else o.state = PENDING;
|
|
1035
|
+
if (o.pure) Updates.push(o);
|
|
1036
|
+
else Effects.push(o);
|
|
944
1037
|
o.observers && markDownstream(o);
|
|
945
1038
|
}
|
|
946
1039
|
}
|
|
@@ -963,11 +1056,11 @@ function cleanNode(node) {
|
|
|
963
1056
|
}
|
|
964
1057
|
}
|
|
965
1058
|
}
|
|
1059
|
+
if (node.tOwned) {
|
|
1060
|
+
for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
|
|
1061
|
+
delete node.tOwned;
|
|
1062
|
+
}
|
|
966
1063
|
if (Transition && Transition.running && node.pure) {
|
|
967
|
-
if (node.tOwned) {
|
|
968
|
-
for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
|
|
969
|
-
delete node.tOwned;
|
|
970
|
-
}
|
|
971
1064
|
reset(node, true);
|
|
972
1065
|
} else if (node.owned) {
|
|
973
1066
|
for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
|
|
@@ -977,7 +1070,8 @@ function cleanNode(node) {
|
|
|
977
1070
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
978
1071
|
node.cleanups = null;
|
|
979
1072
|
}
|
|
980
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1073
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1074
|
+
else node.state = 0;
|
|
981
1075
|
delete node.sourceMap;
|
|
982
1076
|
}
|
|
983
1077
|
function reset(node, top) {
|
|
@@ -999,19 +1093,21 @@ function runErrors(err, fns, owner) {
|
|
|
999
1093
|
try {
|
|
1000
1094
|
for (const f of fns) f(err);
|
|
1001
1095
|
} catch (e) {
|
|
1002
|
-
handleError(e, owner && owner.owner || null);
|
|
1096
|
+
handleError(e, (owner && owner.owner) || null);
|
|
1003
1097
|
}
|
|
1004
1098
|
}
|
|
1005
1099
|
function handleError(err, owner = Owner) {
|
|
1006
1100
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
1007
1101
|
const error = castError(err);
|
|
1008
1102
|
if (!fns) throw error;
|
|
1009
|
-
if (Effects)
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1103
|
+
if (Effects)
|
|
1104
|
+
Effects.push({
|
|
1105
|
+
fn() {
|
|
1106
|
+
runErrors(error, fns, owner);
|
|
1107
|
+
},
|
|
1108
|
+
state: STALE
|
|
1109
|
+
});
|
|
1110
|
+
else runErrors(error, fns, owner);
|
|
1015
1111
|
}
|
|
1016
1112
|
function resolveChildren(children) {
|
|
1017
1113
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1028,19 +1124,26 @@ function resolveChildren(children) {
|
|
|
1028
1124
|
function createProvider(id, options) {
|
|
1029
1125
|
return function provider(props) {
|
|
1030
1126
|
let res;
|
|
1031
|
-
createRenderEffect(
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1127
|
+
createRenderEffect(
|
|
1128
|
+
() =>
|
|
1129
|
+
(res = untrack(() => {
|
|
1130
|
+
Owner.context = {
|
|
1131
|
+
...Owner.context,
|
|
1132
|
+
[id]: props.value
|
|
1133
|
+
};
|
|
1134
|
+
return children(() => props.children);
|
|
1135
|
+
})),
|
|
1136
|
+
undefined,
|
|
1137
|
+
options
|
|
1138
|
+
);
|
|
1038
1139
|
return res;
|
|
1039
1140
|
};
|
|
1040
1141
|
}
|
|
1041
1142
|
function onError(fn) {
|
|
1042
1143
|
ERROR || (ERROR = Symbol("error"));
|
|
1043
|
-
if (Owner === null)
|
|
1144
|
+
if (Owner === null)
|
|
1145
|
+
console.warn("error handlers created outside a `createRoot` or `render` will never be run");
|
|
1146
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1044
1147
|
Owner.context = {
|
|
1045
1148
|
...Owner.context,
|
|
1046
1149
|
[ERROR]: [fn]
|
|
@@ -1069,7 +1172,8 @@ function observable(input) {
|
|
|
1069
1172
|
if (!(observer instanceof Object) || observer == null) {
|
|
1070
1173
|
throw new TypeError("Expected the observer to be an object.");
|
|
1071
1174
|
}
|
|
1072
|
-
const handler =
|
|
1175
|
+
const handler =
|
|
1176
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1073
1177
|
if (!handler) {
|
|
1074
1178
|
return {
|
|
1075
1179
|
unsubscribe() {}
|
|
@@ -1100,7 +1204,7 @@ function from(producer) {
|
|
|
1100
1204
|
});
|
|
1101
1205
|
if ("subscribe" in producer) {
|
|
1102
1206
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1103
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1207
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1104
1208
|
} else {
|
|
1105
1209
|
const clean = producer(set);
|
|
1106
1210
|
onCleanup(clean);
|
|
@@ -1144,8 +1248,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1144
1248
|
});
|
|
1145
1249
|
len = 1;
|
|
1146
1250
|
}
|
|
1147
|
-
}
|
|
1148
|
-
else if (len === 0) {
|
|
1251
|
+
} else if (len === 0) {
|
|
1149
1252
|
mapped = new Array(newLen);
|
|
1150
1253
|
for (j = 0; j < newLen; j++) {
|
|
1151
1254
|
items[j] = newItems[j];
|
|
@@ -1156,8 +1259,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1156
1259
|
temp = new Array(newLen);
|
|
1157
1260
|
tempdisposers = new Array(newLen);
|
|
1158
1261
|
indexes && (tempIndexes = new Array(newLen));
|
|
1159
|
-
for (
|
|
1160
|
-
|
|
1262
|
+
for (
|
|
1263
|
+
start = 0, end = Math.min(len, newLen);
|
|
1264
|
+
start < end && items[start] === newItems[start];
|
|
1265
|
+
start++
|
|
1266
|
+
);
|
|
1267
|
+
for (
|
|
1268
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1269
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1270
|
+
end--, newEnd--
|
|
1271
|
+
) {
|
|
1161
1272
|
temp[newEnd] = mapped[end];
|
|
1162
1273
|
tempdisposers[newEnd] = disposers[end];
|
|
1163
1274
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1191,7 +1302,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1191
1302
|
}
|
|
1192
1303
|
} else mapped[j] = createRoot(mapper);
|
|
1193
1304
|
}
|
|
1194
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1305
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1195
1306
|
items = newItems.slice(0);
|
|
1196
1307
|
}
|
|
1197
1308
|
return mapped;
|
|
@@ -1201,7 +1312,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1201
1312
|
if (indexes) {
|
|
1202
1313
|
const [s, set] = createSignal(j, {
|
|
1203
1314
|
name: "index"
|
|
1204
|
-
})
|
|
1315
|
+
});
|
|
1205
1316
|
indexes[j] = set;
|
|
1206
1317
|
return mapFn(newItems[j], s);
|
|
1207
1318
|
}
|
|
@@ -1260,13 +1371,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1260
1371
|
}
|
|
1261
1372
|
len = signals.length = disposers.length = newLen;
|
|
1262
1373
|
items = newItems.slice(0);
|
|
1263
|
-
return mapped = mapped.slice(0, len);
|
|
1374
|
+
return (mapped = mapped.slice(0, len));
|
|
1264
1375
|
});
|
|
1265
1376
|
function mapper(disposer) {
|
|
1266
1377
|
disposers[i] = disposer;
|
|
1267
1378
|
const [s, set] = createSignal(newItems[i], {
|
|
1268
1379
|
name: "value"
|
|
1269
|
-
})
|
|
1380
|
+
});
|
|
1270
1381
|
signals[i] = set;
|
|
1271
1382
|
return mapFn(s, i);
|
|
1272
1383
|
}
|
|
@@ -1282,7 +1393,7 @@ function createComponent(Comp, props) {
|
|
|
1282
1393
|
if (sharedConfig.context) {
|
|
1283
1394
|
const c = sharedConfig.context;
|
|
1284
1395
|
setHydrateContext(nextHydrateContext());
|
|
1285
|
-
const r = devComponent(Comp, props || {})
|
|
1396
|
+
const r = devComponent(Comp, props || {});
|
|
1286
1397
|
setHydrateContext(c);
|
|
1287
1398
|
return r;
|
|
1288
1399
|
}
|
|
@@ -1331,29 +1442,33 @@ function mergeProps(...sources) {
|
|
|
1331
1442
|
let proxy = false;
|
|
1332
1443
|
for (let i = 0; i < sources.length; i++) {
|
|
1333
1444
|
const s = sources[i];
|
|
1334
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1335
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1445
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1446
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1336
1447
|
}
|
|
1337
|
-
if (proxy) {
|
|
1338
|
-
return new Proxy(
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1448
|
+
if (SUPPORTS_PROXY && proxy) {
|
|
1449
|
+
return new Proxy(
|
|
1450
|
+
{
|
|
1451
|
+
get(property) {
|
|
1452
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1453
|
+
const v = resolveSource(sources[i])[property];
|
|
1454
|
+
if (v !== undefined) return v;
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
has(property) {
|
|
1458
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1459
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1460
|
+
}
|
|
1461
|
+
return false;
|
|
1462
|
+
},
|
|
1463
|
+
keys() {
|
|
1464
|
+
const keys = [];
|
|
1465
|
+
for (let i = 0; i < sources.length; i++)
|
|
1466
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1467
|
+
return [...new Set(keys)];
|
|
1348
1468
|
}
|
|
1349
|
-
return false;
|
|
1350
1469
|
},
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1354
|
-
return [...new Set(keys)];
|
|
1355
|
-
}
|
|
1356
|
-
}, propTraps);
|
|
1470
|
+
propTraps
|
|
1471
|
+
);
|
|
1357
1472
|
}
|
|
1358
1473
|
const sourcesMap = {};
|
|
1359
1474
|
const defined = Object.create(null);
|
|
@@ -1366,15 +1481,20 @@ function mergeProps(...sources) {
|
|
|
1366
1481
|
if (key === "__proto__" || key === "constructor") continue;
|
|
1367
1482
|
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
1368
1483
|
if (!defined[key]) {
|
|
1369
|
-
defined[key] = desc.get
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1484
|
+
defined[key] = desc.get
|
|
1485
|
+
? {
|
|
1486
|
+
enumerable: true,
|
|
1487
|
+
configurable: true,
|
|
1488
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1489
|
+
}
|
|
1490
|
+
: desc.value !== undefined
|
|
1491
|
+
? desc
|
|
1492
|
+
: undefined;
|
|
1374
1493
|
} else {
|
|
1375
1494
|
const sources = sourcesMap[key];
|
|
1376
1495
|
if (sources) {
|
|
1377
|
-
if (desc.get) sources.push(desc.get.bind(source));
|
|
1496
|
+
if (desc.get) sources.push(desc.get.bind(source));
|
|
1497
|
+
else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1378
1498
|
}
|
|
1379
1499
|
}
|
|
1380
1500
|
}
|
|
@@ -1384,55 +1504,69 @@ function mergeProps(...sources) {
|
|
|
1384
1504
|
for (let i = definedKeys.length - 1; i >= 0; i--) {
|
|
1385
1505
|
const key = definedKeys[i],
|
|
1386
1506
|
desc = defined[key];
|
|
1387
|
-
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1507
|
+
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1508
|
+
else target[key] = desc ? desc.value : undefined;
|
|
1388
1509
|
}
|
|
1389
1510
|
return target;
|
|
1390
1511
|
}
|
|
1391
1512
|
function splitProps(props, ...keys) {
|
|
1392
|
-
if ($PROXY in props) {
|
|
1513
|
+
if (SUPPORTS_PROXY && $PROXY in props) {
|
|
1393
1514
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1394
1515
|
const res = keys.map(k => {
|
|
1395
|
-
return new Proxy(
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1516
|
+
return new Proxy(
|
|
1517
|
+
{
|
|
1518
|
+
get(property) {
|
|
1519
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1520
|
+
},
|
|
1521
|
+
has(property) {
|
|
1522
|
+
return k.includes(property) && property in props;
|
|
1523
|
+
},
|
|
1524
|
+
keys() {
|
|
1525
|
+
return k.filter(property => property in props);
|
|
1526
|
+
}
|
|
1401
1527
|
},
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
}
|
|
1405
|
-
}, propTraps);
|
|
1528
|
+
propTraps
|
|
1529
|
+
);
|
|
1406
1530
|
});
|
|
1407
|
-
res.push(
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1531
|
+
res.push(
|
|
1532
|
+
new Proxy(
|
|
1533
|
+
{
|
|
1534
|
+
get(property) {
|
|
1535
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1536
|
+
},
|
|
1537
|
+
has(property) {
|
|
1538
|
+
return blocked.has(property) ? false : property in props;
|
|
1539
|
+
},
|
|
1540
|
+
keys() {
|
|
1541
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1542
|
+
}
|
|
1543
|
+
},
|
|
1544
|
+
propTraps
|
|
1545
|
+
)
|
|
1546
|
+
);
|
|
1418
1547
|
return res;
|
|
1419
1548
|
}
|
|
1420
1549
|
const otherObject = {};
|
|
1421
1550
|
const objects = keys.map(() => ({}));
|
|
1422
1551
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1423
1552
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1424
|
-
const isDefaultDesc =
|
|
1553
|
+
const isDefaultDesc =
|
|
1554
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1425
1555
|
let blocked = false;
|
|
1426
1556
|
let objectIndex = 0;
|
|
1427
1557
|
for (const k of keys) {
|
|
1428
1558
|
if (k.includes(propName)) {
|
|
1429
1559
|
blocked = true;
|
|
1430
|
-
isDefaultDesc
|
|
1560
|
+
isDefaultDesc
|
|
1561
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1562
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1431
1563
|
}
|
|
1432
1564
|
++objectIndex;
|
|
1433
1565
|
}
|
|
1434
1566
|
if (!blocked) {
|
|
1435
|
-
isDefaultDesc
|
|
1567
|
+
isDefaultDesc
|
|
1568
|
+
? (otherObject[propName] = desc.value)
|
|
1569
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1436
1570
|
}
|
|
1437
1571
|
}
|
|
1438
1572
|
return [...objects, otherObject];
|
|
@@ -1458,19 +1592,24 @@ function lazy(fn) {
|
|
|
1458
1592
|
comp = s;
|
|
1459
1593
|
}
|
|
1460
1594
|
let Comp;
|
|
1461
|
-
return createMemo(() =>
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1595
|
+
return createMemo(() =>
|
|
1596
|
+
(Comp = comp())
|
|
1597
|
+
? untrack(() => {
|
|
1598
|
+
if (true)
|
|
1599
|
+
Object.assign(Comp, {
|
|
1600
|
+
[$DEVCOMP]: true
|
|
1601
|
+
});
|
|
1602
|
+
if (!ctx || sharedConfig.done) return Comp(props);
|
|
1603
|
+
const c = sharedConfig.context;
|
|
1604
|
+
setHydrateContext(ctx);
|
|
1605
|
+
const r = Comp(props);
|
|
1606
|
+
setHydrateContext(c);
|
|
1607
|
+
return r;
|
|
1608
|
+
})
|
|
1609
|
+
: ""
|
|
1610
|
+
);
|
|
1472
1611
|
};
|
|
1473
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1612
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1474
1613
|
return wrap;
|
|
1475
1614
|
}
|
|
1476
1615
|
let counter = 0;
|
|
@@ -1479,75 +1618,112 @@ function createUniqueId() {
|
|
|
1479
1618
|
return ctx ? sharedConfig.getNextContextId() : `cl-${counter++}`;
|
|
1480
1619
|
}
|
|
1481
1620
|
|
|
1482
|
-
const narrowedError = name =>
|
|
1621
|
+
const narrowedError = name =>
|
|
1622
|
+
`Attempting to access a stale value from <${name}> that could possibly be undefined. This may occur because you are reading the accessor returned from the component at a time where it has already been unmounted. We recommend cleaning up any stale timers or async, or reading from the initial condition.`;
|
|
1483
1623
|
function For(props) {
|
|
1484
1624
|
const fallback = "fallback" in props && {
|
|
1485
1625
|
fallback: () => props.fallback
|
|
1486
1626
|
};
|
|
1487
|
-
return createMemo(
|
|
1488
|
-
|
|
1489
|
-
|
|
1627
|
+
return createMemo(
|
|
1628
|
+
mapArray(() => props.each, props.children, fallback || undefined),
|
|
1629
|
+
undefined,
|
|
1630
|
+
{
|
|
1631
|
+
name: "value"
|
|
1632
|
+
}
|
|
1633
|
+
);
|
|
1490
1634
|
}
|
|
1491
1635
|
function Index(props) {
|
|
1492
1636
|
const fallback = "fallback" in props && {
|
|
1493
1637
|
fallback: () => props.fallback
|
|
1494
1638
|
};
|
|
1495
|
-
return createMemo(
|
|
1496
|
-
|
|
1497
|
-
|
|
1639
|
+
return createMemo(
|
|
1640
|
+
indexArray(() => props.each, props.children, fallback || undefined),
|
|
1641
|
+
undefined,
|
|
1642
|
+
{
|
|
1643
|
+
name: "value"
|
|
1644
|
+
}
|
|
1645
|
+
);
|
|
1498
1646
|
}
|
|
1499
1647
|
function Show(props) {
|
|
1500
1648
|
const keyed = props.keyed;
|
|
1501
1649
|
const condition = createMemo(() => props.when, undefined, {
|
|
1502
|
-
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1650
|
+
equals: (a, b) => (keyed ? a === b : !a === !b),
|
|
1503
1651
|
name: "condition"
|
|
1504
|
-
}
|
|
1505
|
-
return createMemo(
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1652
|
+
});
|
|
1653
|
+
return createMemo(
|
|
1654
|
+
() => {
|
|
1655
|
+
const c = condition();
|
|
1656
|
+
if (c) {
|
|
1657
|
+
const child = props.children;
|
|
1658
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1659
|
+
return fn
|
|
1660
|
+
? untrack(() =>
|
|
1661
|
+
child(
|
|
1662
|
+
keyed
|
|
1663
|
+
? c
|
|
1664
|
+
: () => {
|
|
1665
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1666
|
+
return props.when;
|
|
1667
|
+
}
|
|
1668
|
+
)
|
|
1669
|
+
)
|
|
1670
|
+
: child;
|
|
1671
|
+
}
|
|
1672
|
+
return props.fallback;
|
|
1673
|
+
},
|
|
1674
|
+
undefined,
|
|
1675
|
+
{
|
|
1676
|
+
name: "value"
|
|
1514
1677
|
}
|
|
1515
|
-
|
|
1516
|
-
}, undefined, {
|
|
1517
|
-
name: "value"
|
|
1518
|
-
} );
|
|
1678
|
+
);
|
|
1519
1679
|
}
|
|
1520
1680
|
function Switch(props) {
|
|
1521
1681
|
let keyed = false;
|
|
1522
1682
|
const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1523
1683
|
const conditions = children(() => props.children),
|
|
1524
|
-
evalConditions = createMemo(
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1684
|
+
evalConditions = createMemo(
|
|
1685
|
+
() => {
|
|
1686
|
+
let conds = conditions();
|
|
1687
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1688
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1689
|
+
const c = conds[i].when;
|
|
1690
|
+
if (c) {
|
|
1691
|
+
keyed = !!conds[i].keyed;
|
|
1692
|
+
return [i, c, conds[i]];
|
|
1693
|
+
}
|
|
1532
1694
|
}
|
|
1695
|
+
return [-1];
|
|
1696
|
+
},
|
|
1697
|
+
undefined,
|
|
1698
|
+
{
|
|
1699
|
+
equals,
|
|
1700
|
+
name: "eval conditions"
|
|
1533
1701
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1702
|
+
);
|
|
1703
|
+
return createMemo(
|
|
1704
|
+
() => {
|
|
1705
|
+
const [index, when, cond] = evalConditions();
|
|
1706
|
+
if (index < 0) return props.fallback;
|
|
1707
|
+
const c = cond.children;
|
|
1708
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1709
|
+
return fn
|
|
1710
|
+
? untrack(() =>
|
|
1711
|
+
c(
|
|
1712
|
+
keyed
|
|
1713
|
+
? when
|
|
1714
|
+
: () => {
|
|
1715
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1716
|
+
return cond.when;
|
|
1717
|
+
}
|
|
1718
|
+
)
|
|
1719
|
+
)
|
|
1720
|
+
: c;
|
|
1721
|
+
},
|
|
1722
|
+
undefined,
|
|
1723
|
+
{
|
|
1724
|
+
name: "value"
|
|
1725
|
+
}
|
|
1726
|
+
);
|
|
1551
1727
|
}
|
|
1552
1728
|
function Match(props) {
|
|
1553
1729
|
return props;
|
|
@@ -1558,28 +1734,34 @@ function resetErrorBoundaries() {
|
|
|
1558
1734
|
}
|
|
1559
1735
|
function ErrorBoundary(props) {
|
|
1560
1736
|
let err;
|
|
1561
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1737
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1738
|
+
err = sharedConfig.load(sharedConfig.getContextId());
|
|
1562
1739
|
const [errored, setErrored] = createSignal(err, {
|
|
1563
1740
|
name: "errored"
|
|
1564
|
-
}
|
|
1741
|
+
});
|
|
1565
1742
|
Errors || (Errors = new Set());
|
|
1566
1743
|
Errors.add(setErrored);
|
|
1567
1744
|
onCleanup(() => Errors.delete(setErrored));
|
|
1568
|
-
return createMemo(
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1745
|
+
return createMemo(
|
|
1746
|
+
() => {
|
|
1747
|
+
let e;
|
|
1748
|
+
if ((e = errored())) {
|
|
1749
|
+
const f = props.fallback;
|
|
1750
|
+
if (typeof f !== "function" || f.length == 0) console.error(e);
|
|
1751
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1752
|
+
}
|
|
1753
|
+
return catchError(() => props.children, setErrored);
|
|
1754
|
+
},
|
|
1755
|
+
undefined,
|
|
1756
|
+
{
|
|
1757
|
+
name: "value"
|
|
1574
1758
|
}
|
|
1575
|
-
|
|
1576
|
-
}, undefined, {
|
|
1577
|
-
name: "value"
|
|
1578
|
-
} );
|
|
1759
|
+
);
|
|
1579
1760
|
}
|
|
1580
1761
|
|
|
1581
|
-
const suspenseListEquals = (a, b) =>
|
|
1582
|
-
|
|
1762
|
+
const suspenseListEquals = (a, b) =>
|
|
1763
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1764
|
+
const SuspenseListContext = /* #__PURE__ */ createContext();
|
|
1583
1765
|
function SuspenseList(props) {
|
|
1584
1766
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1585
1767
|
inFallback: false
|
|
@@ -1590,51 +1772,51 @@ function SuspenseList(props) {
|
|
|
1590
1772
|
if (listContext) {
|
|
1591
1773
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1592
1774
|
}
|
|
1593
|
-
const resolved = createMemo(
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
showContent = true,
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
const res = reg.map(() => ({
|
|
1605
|
-
showContent: all && showContent,
|
|
1606
|
-
showFallback
|
|
1607
|
-
}));
|
|
1608
|
-
res.inFallback = !all;
|
|
1609
|
-
return res;
|
|
1610
|
-
}
|
|
1611
|
-
let stop = false;
|
|
1612
|
-
let inFallback = prev.inFallback;
|
|
1613
|
-
const res = [];
|
|
1614
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1615
|
-
const n = reverse ? len - i - 1 : i,
|
|
1616
|
-
s = reg[n]();
|
|
1617
|
-
if (!stop && !s) {
|
|
1618
|
-
res[n] = {
|
|
1619
|
-
showContent,
|
|
1775
|
+
const resolved = createMemo(
|
|
1776
|
+
prev => {
|
|
1777
|
+
const reveal = props.revealOrder,
|
|
1778
|
+
tail = props.tail,
|
|
1779
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1780
|
+
reg = registry(),
|
|
1781
|
+
reverse = reveal === "backwards";
|
|
1782
|
+
if (reveal === "together") {
|
|
1783
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1784
|
+
const res = reg.map(() => ({
|
|
1785
|
+
showContent: all && showContent,
|
|
1620
1786
|
showFallback
|
|
1621
|
-
};
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
if (next) inFallback = true;
|
|
1625
|
-
res[n] = {
|
|
1626
|
-
showContent: next,
|
|
1627
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1628
|
-
};
|
|
1629
|
-
stop = true;
|
|
1787
|
+
}));
|
|
1788
|
+
res.inFallback = !all;
|
|
1789
|
+
return res;
|
|
1630
1790
|
}
|
|
1791
|
+
let stop = false;
|
|
1792
|
+
let inFallback = prev.inFallback;
|
|
1793
|
+
const res = [];
|
|
1794
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1795
|
+
const n = reverse ? len - i - 1 : i,
|
|
1796
|
+
s = reg[n]();
|
|
1797
|
+
if (!stop && !s) {
|
|
1798
|
+
res[n] = {
|
|
1799
|
+
showContent,
|
|
1800
|
+
showFallback
|
|
1801
|
+
};
|
|
1802
|
+
} else {
|
|
1803
|
+
const next = !stop;
|
|
1804
|
+
if (next) inFallback = true;
|
|
1805
|
+
res[n] = {
|
|
1806
|
+
showContent: next,
|
|
1807
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1808
|
+
};
|
|
1809
|
+
stop = true;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
if (!stop) inFallback = false;
|
|
1813
|
+
res.inFallback = inFallback;
|
|
1814
|
+
return res;
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
inFallback: false
|
|
1631
1818
|
}
|
|
1632
|
-
|
|
1633
|
-
res.inFallback = inFallback;
|
|
1634
|
-
return res;
|
|
1635
|
-
}, {
|
|
1636
|
-
inFallback: false
|
|
1637
|
-
});
|
|
1819
|
+
);
|
|
1638
1820
|
setWrapper(() => resolved);
|
|
1639
1821
|
return createComponent(SuspenseListContext.Provider, {
|
|
1640
1822
|
value: {
|
|
@@ -1679,23 +1861,27 @@ function Suspense(props) {
|
|
|
1679
1861
|
const key = sharedConfig.getContextId();
|
|
1680
1862
|
let ref = sharedConfig.load(key);
|
|
1681
1863
|
if (ref) {
|
|
1682
|
-
if (typeof ref !== "object" || ref.status !== "success") p = ref;
|
|
1864
|
+
if (typeof ref !== "object" || ref.status !== "success") p = ref;
|
|
1865
|
+
else sharedConfig.gather(key);
|
|
1683
1866
|
}
|
|
1684
1867
|
if (p && p !== "$$f") {
|
|
1685
1868
|
const [s, set] = createSignal(undefined, {
|
|
1686
1869
|
equals: false
|
|
1687
1870
|
});
|
|
1688
1871
|
flicker = s;
|
|
1689
|
-
p.then(
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1872
|
+
p.then(
|
|
1873
|
+
() => {
|
|
1874
|
+
if (sharedConfig.done) return set();
|
|
1875
|
+
sharedConfig.gather(key);
|
|
1876
|
+
setHydrateContext(ctx);
|
|
1877
|
+
set();
|
|
1878
|
+
setHydrateContext();
|
|
1879
|
+
},
|
|
1880
|
+
err => {
|
|
1881
|
+
error = err;
|
|
1882
|
+
set();
|
|
1883
|
+
}
|
|
1884
|
+
);
|
|
1699
1885
|
}
|
|
1700
1886
|
}
|
|
1701
1887
|
const listContext = useContext(SuspenseListContext);
|
|
@@ -1710,17 +1896,14 @@ function Suspense(props) {
|
|
|
1710
1896
|
ctx = sharedConfig.context;
|
|
1711
1897
|
if (flicker) {
|
|
1712
1898
|
flicker();
|
|
1713
|
-
return flicker = undefined;
|
|
1899
|
+
return (flicker = undefined);
|
|
1714
1900
|
}
|
|
1715
1901
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1716
1902
|
const rendered = createMemo(() => props.children);
|
|
1717
1903
|
return createMemo(prev => {
|
|
1718
1904
|
const inFallback = store.inFallback(),
|
|
1719
|
-
{
|
|
1720
|
-
|
|
1721
|
-
showFallback = true
|
|
1722
|
-
} = show ? show() : {};
|
|
1723
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1905
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1906
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1724
1907
|
store.resolved = true;
|
|
1725
1908
|
dispose && dispose();
|
|
1726
1909
|
dispose = ctx = p = undefined;
|
|
@@ -1750,9 +1933,68 @@ const DEV = {
|
|
|
1750
1933
|
hooks: DevHooks,
|
|
1751
1934
|
writeSignal,
|
|
1752
1935
|
registerGraph
|
|
1753
|
-
}
|
|
1936
|
+
};
|
|
1754
1937
|
if (globalThis) {
|
|
1755
|
-
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1938
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1939
|
+
else
|
|
1940
|
+
console.warn(
|
|
1941
|
+
"You appear to have multiple instances of Solid. This can lead to unexpected behavior."
|
|
1942
|
+
);
|
|
1756
1943
|
}
|
|
1757
1944
|
|
|
1758
|
-
export {
|
|
1945
|
+
export {
|
|
1946
|
+
$DEVCOMP,
|
|
1947
|
+
$PROXY,
|
|
1948
|
+
$TRACK,
|
|
1949
|
+
DEV,
|
|
1950
|
+
ErrorBoundary,
|
|
1951
|
+
For,
|
|
1952
|
+
Index,
|
|
1953
|
+
Match,
|
|
1954
|
+
Show,
|
|
1955
|
+
Suspense,
|
|
1956
|
+
SuspenseList,
|
|
1957
|
+
Switch,
|
|
1958
|
+
batch,
|
|
1959
|
+
cancelCallback,
|
|
1960
|
+
catchError,
|
|
1961
|
+
children,
|
|
1962
|
+
createComponent,
|
|
1963
|
+
createComputed,
|
|
1964
|
+
createContext,
|
|
1965
|
+
createDeferred,
|
|
1966
|
+
createEffect,
|
|
1967
|
+
createMemo,
|
|
1968
|
+
createReaction,
|
|
1969
|
+
createRenderEffect,
|
|
1970
|
+
createResource,
|
|
1971
|
+
createRoot,
|
|
1972
|
+
createSelector,
|
|
1973
|
+
createSignal,
|
|
1974
|
+
createUniqueId,
|
|
1975
|
+
enableExternalSource,
|
|
1976
|
+
enableHydration,
|
|
1977
|
+
enableScheduling,
|
|
1978
|
+
equalFn,
|
|
1979
|
+
from,
|
|
1980
|
+
getListener,
|
|
1981
|
+
getOwner,
|
|
1982
|
+
indexArray,
|
|
1983
|
+
lazy,
|
|
1984
|
+
mapArray,
|
|
1985
|
+
mergeProps,
|
|
1986
|
+
observable,
|
|
1987
|
+
on,
|
|
1988
|
+
onCleanup,
|
|
1989
|
+
onError,
|
|
1990
|
+
onMount,
|
|
1991
|
+
requestCallback,
|
|
1992
|
+
resetErrorBoundaries,
|
|
1993
|
+
runWithOwner,
|
|
1994
|
+
sharedConfig,
|
|
1995
|
+
splitProps,
|
|
1996
|
+
startTransition,
|
|
1997
|
+
untrack,
|
|
1998
|
+
useContext,
|
|
1999
|
+
useTransition
|
|
2000
|
+
};
|