solid-js 1.8.14 → 1.8.16
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 +8 -7
- package/dist/dev.js +561 -319
- package/dist/server.js +170 -75
- package/dist/solid.cjs +8 -7
- package/dist/solid.js +488 -277
- package/h/dist/h.js +34 -8
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +7 -2
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -33
- package/package.json +2 -2
- package/store/dist/dev.js +122 -43
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +113 -40
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +219 -62
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +7 -2
- package/types/reactive/array.d.ts +14 -6
- package/types/reactive/observable.d.ts +26 -18
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +239 -147
- package/types/render/Suspense.d.ts +7 -7
- package/types/render/component.d.ts +64 -33
- package/types/render/flow.d.ts +47 -35
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +167 -96
- 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 +13 -11
- package/web/dist/dev.js +635 -92
- package/web/dist/server.js +210 -96
- package/web/dist/web.cjs +13 -11
- package/web/dist/web.js +626 -90
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +29 -12
- package/web/types/server-mock.d.ts +47 -32
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
|
}
|
|
@@ -165,20 +167,25 @@ function createRoot(fn, detachedOwner) {
|
|
|
165
167
|
owner = Owner,
|
|
166
168
|
unowned = fn.length === 0,
|
|
167
169
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
168
|
-
root = unowned
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
170
|
+
root = unowned
|
|
171
|
+
? {
|
|
172
|
+
owned: null,
|
|
173
|
+
cleanups: null,
|
|
174
|
+
context: null,
|
|
175
|
+
owner: null
|
|
176
|
+
}
|
|
177
|
+
: {
|
|
178
|
+
owned: null,
|
|
179
|
+
cleanups: null,
|
|
180
|
+
context: current ? current.context : null,
|
|
181
|
+
owner: current
|
|
182
|
+
},
|
|
183
|
+
updateFn = unowned
|
|
184
|
+
? () =>
|
|
185
|
+
fn(() => {
|
|
186
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
187
|
+
})
|
|
188
|
+
: () => fn(() => untrack(() => cleanNode(root)));
|
|
182
189
|
DevHooks.afterCreateOwner && DevHooks.afterCreateOwner(root);
|
|
183
190
|
Owner = root;
|
|
184
191
|
Listener = null;
|
|
@@ -204,23 +211,26 @@ function createSignal(value, options) {
|
|
|
204
211
|
}
|
|
205
212
|
const setter = value => {
|
|
206
213
|
if (typeof value === "function") {
|
|
207
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
214
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
215
|
+
else value = value(s.value);
|
|
208
216
|
}
|
|
209
217
|
return writeSignal(s, value);
|
|
210
218
|
};
|
|
211
219
|
return [readSignal.bind(s), setter];
|
|
212
220
|
}
|
|
213
221
|
function createComputed(fn, value, options) {
|
|
214
|
-
const c = createComputation(fn, value, true, STALE, options
|
|
215
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
222
|
+
const c = createComputation(fn, value, true, STALE, options);
|
|
223
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
224
|
+
else updateComputation(c);
|
|
216
225
|
}
|
|
217
226
|
function createRenderEffect(fn, value, options) {
|
|
218
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
219
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
227
|
+
const c = createComputation(fn, value, false, STALE, options);
|
|
228
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
229
|
+
else updateComputation(c);
|
|
220
230
|
}
|
|
221
231
|
function createEffect(fn, value, options) {
|
|
222
232
|
runEffects = runUserEffects;
|
|
223
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
233
|
+
const c = createComputation(fn, value, false, STALE, options),
|
|
224
234
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
225
235
|
if (s) c.suspense = s;
|
|
226
236
|
if (!options || !options.render) c.user = true;
|
|
@@ -228,10 +238,16 @@ function createEffect(fn, value, options) {
|
|
|
228
238
|
}
|
|
229
239
|
function createReaction(onInvalidate, options) {
|
|
230
240
|
let fn;
|
|
231
|
-
const c = createComputation(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
241
|
+
const c = createComputation(
|
|
242
|
+
() => {
|
|
243
|
+
fn ? fn() : untrack(onInvalidate);
|
|
244
|
+
fn = undefined;
|
|
245
|
+
},
|
|
246
|
+
undefined,
|
|
247
|
+
false,
|
|
248
|
+
0,
|
|
249
|
+
options
|
|
250
|
+
),
|
|
235
251
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
236
252
|
if (s) c.suspense = s;
|
|
237
253
|
c.user = true;
|
|
@@ -242,7 +258,7 @@ function createReaction(onInvalidate, options) {
|
|
|
242
258
|
}
|
|
243
259
|
function createMemo(fn, value, options) {
|
|
244
260
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
245
|
-
const c = createComputation(fn, value, true, 0, options
|
|
261
|
+
const c = createComputation(fn, value, true, 0, options);
|
|
246
262
|
c.observers = null;
|
|
247
263
|
c.observerSlots = null;
|
|
248
264
|
c.comparator = options.equals || undefined;
|
|
@@ -259,7 +275,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
259
275
|
let source;
|
|
260
276
|
let fetcher;
|
|
261
277
|
let options;
|
|
262
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
278
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
263
279
|
source = true;
|
|
264
280
|
fetcher = pSource;
|
|
265
281
|
options = pFetcher || {};
|
|
@@ -273,7 +289,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
273
289
|
id = null,
|
|
274
290
|
loadedUnderTransition = false,
|
|
275
291
|
scheduled = false,
|
|
276
|
-
resolved =
|
|
292
|
+
resolved = "initialValue" in options,
|
|
277
293
|
dynamic = typeof source === "function" && createMemo(source);
|
|
278
294
|
const contexts = new Set(),
|
|
279
295
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -285,15 +301,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
285
301
|
if (sharedConfig.context) {
|
|
286
302
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
287
303
|
let v;
|
|
288
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
304
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
305
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
|
|
289
306
|
}
|
|
290
307
|
function loadEnd(p, v, error, key) {
|
|
291
308
|
if (pr === p) {
|
|
292
309
|
pr = null;
|
|
293
310
|
key !== undefined && (resolved = true);
|
|
294
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
295
|
-
|
|
296
|
-
|
|
311
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
312
|
+
queueMicrotask(() =>
|
|
313
|
+
options.onHydrated(key, {
|
|
314
|
+
value: v
|
|
315
|
+
})
|
|
316
|
+
);
|
|
297
317
|
initP = NO_INIT;
|
|
298
318
|
if (Transition && p && loadedUnderTransition) {
|
|
299
319
|
Transition.promises.delete(p);
|
|
@@ -324,7 +344,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
324
344
|
createComputed(() => {
|
|
325
345
|
track();
|
|
326
346
|
if (pr) {
|
|
327
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
347
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
348
|
+
else if (!contexts.has(c)) {
|
|
328
349
|
c.increment();
|
|
329
350
|
contexts.add(c);
|
|
330
351
|
}
|
|
@@ -343,26 +364,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
343
364
|
return;
|
|
344
365
|
}
|
|
345
366
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
346
|
-
const p =
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
367
|
+
const p =
|
|
368
|
+
initP !== NO_INIT
|
|
369
|
+
? initP
|
|
370
|
+
: untrack(() =>
|
|
371
|
+
fetcher(lookup, {
|
|
372
|
+
value: value(),
|
|
373
|
+
refetching
|
|
374
|
+
})
|
|
375
|
+
);
|
|
350
376
|
if (!isPromise(p)) {
|
|
351
377
|
loadEnd(pr, p, undefined, lookup);
|
|
352
378
|
return p;
|
|
353
379
|
}
|
|
354
380
|
pr = p;
|
|
355
381
|
if ("value" in p) {
|
|
356
|
-
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
382
|
+
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
383
|
+
else loadEnd(pr, undefined, undefined, lookup);
|
|
357
384
|
return p;
|
|
358
385
|
}
|
|
359
386
|
scheduled = true;
|
|
360
|
-
queueMicrotask(() => scheduled = false);
|
|
387
|
+
queueMicrotask(() => (scheduled = false));
|
|
361
388
|
runUpdates(() => {
|
|
362
389
|
setState(resolved ? "refreshing" : "pending");
|
|
363
390
|
trigger();
|
|
364
391
|
}, false);
|
|
365
|
-
return p.then(
|
|
392
|
+
return p.then(
|
|
393
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
394
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
395
|
+
);
|
|
366
396
|
}
|
|
367
397
|
Object.defineProperties(read, {
|
|
368
398
|
state: {
|
|
@@ -386,50 +416,81 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
386
416
|
}
|
|
387
417
|
}
|
|
388
418
|
});
|
|
389
|
-
if (dynamic) createComputed(() => load(false));
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
419
|
+
if (dynamic) createComputed(() => load(false));
|
|
420
|
+
else load(false);
|
|
421
|
+
return [
|
|
422
|
+
read,
|
|
423
|
+
{
|
|
424
|
+
refetch: load,
|
|
425
|
+
mutate: setValue
|
|
426
|
+
}
|
|
427
|
+
];
|
|
394
428
|
}
|
|
395
429
|
function createDeferred(source, options) {
|
|
396
430
|
let t,
|
|
397
431
|
timeout = options ? options.timeoutMs : undefined;
|
|
398
|
-
const node = createComputation(
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
432
|
+
const node = createComputation(
|
|
433
|
+
() => {
|
|
434
|
+
if (!t || !t.fn)
|
|
435
|
+
t = requestCallback(
|
|
436
|
+
() => setDeferred(() => node.value),
|
|
437
|
+
timeout !== undefined
|
|
438
|
+
? {
|
|
439
|
+
timeout
|
|
440
|
+
}
|
|
441
|
+
: undefined
|
|
442
|
+
);
|
|
443
|
+
return source();
|
|
444
|
+
},
|
|
445
|
+
undefined,
|
|
446
|
+
true
|
|
447
|
+
);
|
|
448
|
+
const [deferred, setDeferred] = createSignal(
|
|
449
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
450
|
+
options
|
|
451
|
+
);
|
|
405
452
|
updateComputation(node);
|
|
406
|
-
setDeferred(() =>
|
|
453
|
+
setDeferred(() =>
|
|
454
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
455
|
+
);
|
|
407
456
|
return deferred;
|
|
408
457
|
}
|
|
409
458
|
function createSelector(source, fn = equalFn, options) {
|
|
410
459
|
const subs = new Map();
|
|
411
|
-
const node = createComputation(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
for (const
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
460
|
+
const node = createComputation(
|
|
461
|
+
p => {
|
|
462
|
+
const v = source();
|
|
463
|
+
for (const [key, val] of subs.entries())
|
|
464
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
465
|
+
for (const c of val.values()) {
|
|
466
|
+
c.state = STALE;
|
|
467
|
+
if (c.pure) Updates.push(c);
|
|
468
|
+
else Effects.push(c);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return v;
|
|
472
|
+
},
|
|
473
|
+
undefined,
|
|
474
|
+
true,
|
|
475
|
+
STALE,
|
|
476
|
+
options
|
|
477
|
+
);
|
|
421
478
|
updateComputation(node);
|
|
422
479
|
return key => {
|
|
423
480
|
const listener = Listener;
|
|
424
481
|
if (listener) {
|
|
425
482
|
let l;
|
|
426
|
-
if (l = subs.get(key)) l.add(listener);
|
|
483
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
484
|
+
else subs.set(key, (l = new Set([listener])));
|
|
427
485
|
onCleanup(() => {
|
|
428
486
|
l.delete(listener);
|
|
429
487
|
!l.size && subs.delete(key);
|
|
430
488
|
});
|
|
431
489
|
}
|
|
432
|
-
return fn(
|
|
490
|
+
return fn(
|
|
491
|
+
key,
|
|
492
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
493
|
+
);
|
|
433
494
|
};
|
|
434
495
|
}
|
|
435
496
|
function batch(fn) {
|
|
@@ -458,7 +519,7 @@ function on(deps, fn, options) {
|
|
|
458
519
|
} else input = deps();
|
|
459
520
|
if (defer) {
|
|
460
521
|
defer = false;
|
|
461
|
-
return
|
|
522
|
+
return prevValue;
|
|
462
523
|
}
|
|
463
524
|
const result = untrack(() => fn(input, prevInput, prevValue));
|
|
464
525
|
prevInput = input;
|
|
@@ -469,7 +530,10 @@ function onMount(fn) {
|
|
|
469
530
|
createEffect(() => untrack(fn));
|
|
470
531
|
}
|
|
471
532
|
function onCleanup(fn) {
|
|
472
|
-
if (Owner === null)
|
|
533
|
+
if (Owner === null)
|
|
534
|
+
console.warn("cleanups created outside a `createRoot` or `render` will never be run");
|
|
535
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
536
|
+
else Owner.cleanups.push(fn);
|
|
473
537
|
return fn;
|
|
474
538
|
}
|
|
475
539
|
function catchError(fn, handler) {
|
|
@@ -523,15 +587,17 @@ function startTransition(fn) {
|
|
|
523
587
|
Owner = o;
|
|
524
588
|
let t;
|
|
525
589
|
if (Scheduler || SuspenseContext) {
|
|
526
|
-
t =
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
590
|
+
t =
|
|
591
|
+
Transition ||
|
|
592
|
+
(Transition = {
|
|
593
|
+
sources: new Set(),
|
|
594
|
+
effects: [],
|
|
595
|
+
promises: new Set(),
|
|
596
|
+
disposed: new Set(),
|
|
597
|
+
queue: new Set(),
|
|
598
|
+
running: true
|
|
599
|
+
});
|
|
600
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
535
601
|
t.running = true;
|
|
536
602
|
}
|
|
537
603
|
runUpdates(fn, false);
|
|
@@ -539,7 +605,7 @@ function startTransition(fn) {
|
|
|
539
605
|
return t ? t.done : undefined;
|
|
540
606
|
});
|
|
541
607
|
}
|
|
542
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
608
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
543
609
|
function useTransition() {
|
|
544
610
|
return [transPending, startTransition];
|
|
545
611
|
}
|
|
@@ -548,12 +614,18 @@ function resumeEffects(e) {
|
|
|
548
614
|
e.length = 0;
|
|
549
615
|
}
|
|
550
616
|
function devComponent(Comp, props) {
|
|
551
|
-
const c = createComputation(
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
617
|
+
const c = createComputation(
|
|
618
|
+
() =>
|
|
619
|
+
untrack(() => {
|
|
620
|
+
Object.assign(Comp, {
|
|
621
|
+
[$DEVCOMP]: true
|
|
622
|
+
});
|
|
623
|
+
return Comp(props);
|
|
624
|
+
}),
|
|
625
|
+
undefined,
|
|
626
|
+
true,
|
|
627
|
+
0
|
|
628
|
+
);
|
|
557
629
|
c.props = props;
|
|
558
630
|
c.observers = null;
|
|
559
631
|
c.observerSlots = null;
|
|
@@ -564,7 +636,8 @@ function devComponent(Comp, props) {
|
|
|
564
636
|
}
|
|
565
637
|
function registerGraph(value) {
|
|
566
638
|
if (!Owner) return;
|
|
567
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
639
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
640
|
+
else Owner.sourceMap = [value];
|
|
568
641
|
value.graph = Owner;
|
|
569
642
|
}
|
|
570
643
|
function createContext(defaultValue, options) {
|
|
@@ -576,13 +649,15 @@ function createContext(defaultValue, options) {
|
|
|
576
649
|
};
|
|
577
650
|
}
|
|
578
651
|
function useContext(context) {
|
|
579
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
652
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
653
|
+
? Owner.context[context.id]
|
|
654
|
+
: context.defaultValue;
|
|
580
655
|
}
|
|
581
656
|
function children(fn) {
|
|
582
657
|
const children = createMemo(fn);
|
|
583
658
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
584
659
|
name: "children"
|
|
585
|
-
})
|
|
660
|
+
});
|
|
586
661
|
memo.toArray = () => {
|
|
587
662
|
const c = memo();
|
|
588
663
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -595,10 +670,7 @@ function getSuspenseContext() {
|
|
|
595
670
|
}
|
|
596
671
|
function enableExternalSource(factory, untrack = fn => fn()) {
|
|
597
672
|
if (ExternalSourceConfig) {
|
|
598
|
-
const {
|
|
599
|
-
factory: oldFactory,
|
|
600
|
-
untrack: oldUntrack
|
|
601
|
-
} = ExternalSourceConfig;
|
|
673
|
+
const { factory: oldFactory, untrack: oldUntrack } = ExternalSourceConfig;
|
|
602
674
|
ExternalSourceConfig = {
|
|
603
675
|
factory: (fn, trigger) => {
|
|
604
676
|
const oldSource = oldFactory(fn, trigger);
|
|
@@ -623,7 +695,8 @@ function enableExternalSource(factory, untrack = fn => fn()) {
|
|
|
623
695
|
function readSignal() {
|
|
624
696
|
const runningTransition = Transition && Transition.running;
|
|
625
697
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
626
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
698
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
699
|
+
else {
|
|
627
700
|
const updates = Updates;
|
|
628
701
|
Updates = null;
|
|
629
702
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -651,11 +724,12 @@ function readSignal() {
|
|
|
651
724
|
return this.value;
|
|
652
725
|
}
|
|
653
726
|
function writeSignal(node, value, isComp) {
|
|
654
|
-
let current =
|
|
727
|
+
let current =
|
|
728
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
655
729
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
656
730
|
if (Transition) {
|
|
657
731
|
const TransitionRunning = Transition.running;
|
|
658
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
732
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
659
733
|
Transition.sources.add(node);
|
|
660
734
|
node.tValue = value;
|
|
661
735
|
}
|
|
@@ -668,10 +742,12 @@ function writeSignal(node, value, isComp) {
|
|
|
668
742
|
const TransitionRunning = Transition && Transition.running;
|
|
669
743
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
670
744
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
671
|
-
if (o.pure) Updates.push(o);
|
|
745
|
+
if (o.pure) Updates.push(o);
|
|
746
|
+
else Effects.push(o);
|
|
672
747
|
if (o.observers) markDownstream(o);
|
|
673
748
|
}
|
|
674
|
-
if (!TransitionRunning) o.state = STALE;
|
|
749
|
+
if (!TransitionRunning) o.state = STALE;
|
|
750
|
+
else o.tState = STALE;
|
|
675
751
|
}
|
|
676
752
|
if (Updates.length > 10e5) {
|
|
677
753
|
Updates = [];
|
|
@@ -687,7 +763,11 @@ function updateComputation(node) {
|
|
|
687
763
|
if (!node.fn) return;
|
|
688
764
|
cleanNode(node);
|
|
689
765
|
const time = ExecCount;
|
|
690
|
-
runComputation(
|
|
766
|
+
runComputation(
|
|
767
|
+
node,
|
|
768
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
769
|
+
time
|
|
770
|
+
);
|
|
691
771
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
692
772
|
queueMicrotask(() => {
|
|
693
773
|
runUpdates(() => {
|
|
@@ -752,11 +832,15 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
752
832
|
c.state = 0;
|
|
753
833
|
c.tState = state;
|
|
754
834
|
}
|
|
755
|
-
if (Owner === null)
|
|
835
|
+
if (Owner === null)
|
|
836
|
+
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
837
|
+
else if (Owner !== UNOWNED) {
|
|
756
838
|
if (Transition && Transition.running && Owner.pure) {
|
|
757
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
839
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
840
|
+
else Owner.tOwned.push(c);
|
|
758
841
|
} else {
|
|
759
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
842
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
843
|
+
else Owner.owned.push(c);
|
|
760
844
|
}
|
|
761
845
|
}
|
|
762
846
|
if (options && options.name) c.name = options.name;
|
|
@@ -809,7 +893,8 @@ function runUpdates(fn, init) {
|
|
|
809
893
|
if (Updates) return fn();
|
|
810
894
|
let wait = false;
|
|
811
895
|
if (!init) Updates = [];
|
|
812
|
-
if (Effects) wait = true;
|
|
896
|
+
if (Effects) wait = true;
|
|
897
|
+
else Effects = [];
|
|
813
898
|
ExecCount++;
|
|
814
899
|
try {
|
|
815
900
|
const res = fn();
|
|
@@ -823,7 +908,8 @@ function runUpdates(fn, init) {
|
|
|
823
908
|
}
|
|
824
909
|
function completeUpdates(wait) {
|
|
825
910
|
if (Updates) {
|
|
826
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
911
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
912
|
+
else runQueue(Updates);
|
|
827
913
|
Updates = null;
|
|
828
914
|
}
|
|
829
915
|
if (wait) return;
|
|
@@ -863,7 +949,8 @@ function completeUpdates(wait) {
|
|
|
863
949
|
}
|
|
864
950
|
const e = Effects;
|
|
865
951
|
Effects = null;
|
|
866
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
952
|
+
if (e.length) runUpdates(() => runEffects(e), false);
|
|
953
|
+
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
867
954
|
if (res) res();
|
|
868
955
|
}
|
|
869
956
|
function runQueue(queue) {
|
|
@@ -891,7 +978,8 @@ function runUserEffects(queue) {
|
|
|
891
978
|
userLength = 0;
|
|
892
979
|
for (i = 0; i < queue.length; i++) {
|
|
893
980
|
const e = queue[i];
|
|
894
|
-
if (!e.user) runTop(e);
|
|
981
|
+
if (!e.user) runTop(e);
|
|
982
|
+
else queue[userLength++] = e;
|
|
895
983
|
}
|
|
896
984
|
if (sharedConfig.context) {
|
|
897
985
|
if (sharedConfig.count) {
|
|
@@ -909,13 +997,15 @@ function runUserEffects(queue) {
|
|
|
909
997
|
}
|
|
910
998
|
function lookUpstream(node, ignore) {
|
|
911
999
|
const runningTransition = Transition && Transition.running;
|
|
912
|
-
if (runningTransition) node.tState = 0;
|
|
1000
|
+
if (runningTransition) node.tState = 0;
|
|
1001
|
+
else node.state = 0;
|
|
913
1002
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
914
1003
|
const source = node.sources[i];
|
|
915
1004
|
if (source.sources) {
|
|
916
1005
|
const state = runningTransition ? source.tState : source.state;
|
|
917
1006
|
if (state === STALE) {
|
|
918
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
1007
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
1008
|
+
runTop(source);
|
|
919
1009
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
920
1010
|
}
|
|
921
1011
|
}
|
|
@@ -925,8 +1015,10 @@ function markDownstream(node) {
|
|
|
925
1015
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
926
1016
|
const o = node.observers[i];
|
|
927
1017
|
if (runningTransition ? !o.tState : !o.state) {
|
|
928
|
-
if (runningTransition) o.tState = PENDING;
|
|
929
|
-
|
|
1018
|
+
if (runningTransition) o.tState = PENDING;
|
|
1019
|
+
else o.state = PENDING;
|
|
1020
|
+
if (o.pure) Updates.push(o);
|
|
1021
|
+
else Effects.push(o);
|
|
930
1022
|
o.observers && markDownstream(o);
|
|
931
1023
|
}
|
|
932
1024
|
}
|
|
@@ -963,7 +1055,8 @@ function cleanNode(node) {
|
|
|
963
1055
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
964
1056
|
node.cleanups = null;
|
|
965
1057
|
}
|
|
966
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1058
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1059
|
+
else node.state = 0;
|
|
967
1060
|
delete node.sourceMap;
|
|
968
1061
|
}
|
|
969
1062
|
function reset(node, top) {
|
|
@@ -985,19 +1078,21 @@ function runErrors(err, fns, owner) {
|
|
|
985
1078
|
try {
|
|
986
1079
|
for (const f of fns) f(err);
|
|
987
1080
|
} catch (e) {
|
|
988
|
-
handleError(e, owner && owner.owner || null);
|
|
1081
|
+
handleError(e, (owner && owner.owner) || null);
|
|
989
1082
|
}
|
|
990
1083
|
}
|
|
991
1084
|
function handleError(err, owner = Owner) {
|
|
992
1085
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
993
1086
|
const error = castError(err);
|
|
994
1087
|
if (!fns) throw error;
|
|
995
|
-
if (Effects)
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1088
|
+
if (Effects)
|
|
1089
|
+
Effects.push({
|
|
1090
|
+
fn() {
|
|
1091
|
+
runErrors(error, fns, owner);
|
|
1092
|
+
},
|
|
1093
|
+
state: STALE
|
|
1094
|
+
});
|
|
1095
|
+
else runErrors(error, fns, owner);
|
|
1001
1096
|
}
|
|
1002
1097
|
function resolveChildren(children) {
|
|
1003
1098
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1014,19 +1109,26 @@ function resolveChildren(children) {
|
|
|
1014
1109
|
function createProvider(id, options) {
|
|
1015
1110
|
return function provider(props) {
|
|
1016
1111
|
let res;
|
|
1017
|
-
createRenderEffect(
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1112
|
+
createRenderEffect(
|
|
1113
|
+
() =>
|
|
1114
|
+
(res = untrack(() => {
|
|
1115
|
+
Owner.context = {
|
|
1116
|
+
...Owner.context,
|
|
1117
|
+
[id]: props.value
|
|
1118
|
+
};
|
|
1119
|
+
return children(() => props.children);
|
|
1120
|
+
})),
|
|
1121
|
+
undefined,
|
|
1122
|
+
options
|
|
1123
|
+
);
|
|
1024
1124
|
return res;
|
|
1025
1125
|
};
|
|
1026
1126
|
}
|
|
1027
1127
|
function onError(fn) {
|
|
1028
1128
|
ERROR || (ERROR = Symbol("error"));
|
|
1029
|
-
if (Owner === null)
|
|
1129
|
+
if (Owner === null)
|
|
1130
|
+
console.warn("error handlers created outside a `createRoot` or `render` will never be run");
|
|
1131
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1030
1132
|
Owner.context = {
|
|
1031
1133
|
...Owner.context,
|
|
1032
1134
|
[ERROR]: [fn]
|
|
@@ -1055,7 +1157,8 @@ function observable(input) {
|
|
|
1055
1157
|
if (!(observer instanceof Object) || observer == null) {
|
|
1056
1158
|
throw new TypeError("Expected the observer to be an object.");
|
|
1057
1159
|
}
|
|
1058
|
-
const handler =
|
|
1160
|
+
const handler =
|
|
1161
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1059
1162
|
if (!handler) {
|
|
1060
1163
|
return {
|
|
1061
1164
|
unsubscribe() {}
|
|
@@ -1086,7 +1189,7 @@ function from(producer) {
|
|
|
1086
1189
|
});
|
|
1087
1190
|
if ("subscribe" in producer) {
|
|
1088
1191
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1089
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1192
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1090
1193
|
} else {
|
|
1091
1194
|
const clean = producer(set);
|
|
1092
1195
|
onCleanup(clean);
|
|
@@ -1138,8 +1241,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1138
1241
|
});
|
|
1139
1242
|
len = 1;
|
|
1140
1243
|
}
|
|
1141
|
-
}
|
|
1142
|
-
else if (len === 0) {
|
|
1244
|
+
} else if (len === 0) {
|
|
1143
1245
|
mapped = new Array(newLen);
|
|
1144
1246
|
for (j = 0; j < newLen; j++) {
|
|
1145
1247
|
items[j] = newItems[j];
|
|
@@ -1150,8 +1252,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1150
1252
|
temp = new Array(newLen);
|
|
1151
1253
|
tempdisposers = new Array(newLen);
|
|
1152
1254
|
indexes && (tempIndexes = new Array(newLen));
|
|
1153
|
-
for (
|
|
1154
|
-
|
|
1255
|
+
for (
|
|
1256
|
+
start = 0, end = Math.min(len, newLen);
|
|
1257
|
+
start < end && items[start] === newItems[start];
|
|
1258
|
+
start++
|
|
1259
|
+
);
|
|
1260
|
+
for (
|
|
1261
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1262
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1263
|
+
end--, newEnd--
|
|
1264
|
+
) {
|
|
1155
1265
|
temp[newEnd] = mapped[end];
|
|
1156
1266
|
tempdisposers[newEnd] = disposers[end];
|
|
1157
1267
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1185,7 +1295,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1185
1295
|
}
|
|
1186
1296
|
} else mapped[j] = createRoot(mapper);
|
|
1187
1297
|
}
|
|
1188
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1298
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1189
1299
|
items = newItems.slice(0);
|
|
1190
1300
|
}
|
|
1191
1301
|
return mapped;
|
|
@@ -1195,7 +1305,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1195
1305
|
if (indexes) {
|
|
1196
1306
|
const [s, set] = createSignal(j, {
|
|
1197
1307
|
name: "index"
|
|
1198
|
-
})
|
|
1308
|
+
});
|
|
1199
1309
|
indexes[j] = set;
|
|
1200
1310
|
return mapFn(newItems[j], s);
|
|
1201
1311
|
}
|
|
@@ -1253,13 +1363,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1253
1363
|
}
|
|
1254
1364
|
len = signals.length = disposers.length = newItems.length;
|
|
1255
1365
|
items = newItems.slice(0);
|
|
1256
|
-
return mapped = mapped.slice(0, len);
|
|
1366
|
+
return (mapped = mapped.slice(0, len));
|
|
1257
1367
|
});
|
|
1258
1368
|
function mapper(disposer) {
|
|
1259
1369
|
disposers[i] = disposer;
|
|
1260
1370
|
const [s, set] = createSignal(newItems[i], {
|
|
1261
1371
|
name: "value"
|
|
1262
|
-
})
|
|
1372
|
+
});
|
|
1263
1373
|
signals[i] = set;
|
|
1264
1374
|
return mapFn(s, i);
|
|
1265
1375
|
}
|
|
@@ -1275,7 +1385,7 @@ function createComponent(Comp, props) {
|
|
|
1275
1385
|
if (sharedConfig.context) {
|
|
1276
1386
|
const c = sharedConfig.context;
|
|
1277
1387
|
setHydrateContext(nextHydrateContext());
|
|
1278
|
-
const r = devComponent(Comp, props || {})
|
|
1388
|
+
const r = devComponent(Comp, props || {});
|
|
1279
1389
|
setHydrateContext(c);
|
|
1280
1390
|
return r;
|
|
1281
1391
|
}
|
|
@@ -1324,29 +1434,33 @@ function mergeProps(...sources) {
|
|
|
1324
1434
|
let proxy = false;
|
|
1325
1435
|
for (let i = 0; i < sources.length; i++) {
|
|
1326
1436
|
const s = sources[i];
|
|
1327
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1328
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1437
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1438
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1329
1439
|
}
|
|
1330
1440
|
if (proxy) {
|
|
1331
|
-
return new Proxy(
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1441
|
+
return new Proxy(
|
|
1442
|
+
{
|
|
1443
|
+
get(property) {
|
|
1444
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1445
|
+
const v = resolveSource(sources[i])[property];
|
|
1446
|
+
if (v !== undefined) return v;
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
has(property) {
|
|
1450
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1451
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1452
|
+
}
|
|
1453
|
+
return false;
|
|
1454
|
+
},
|
|
1455
|
+
keys() {
|
|
1456
|
+
const keys = [];
|
|
1457
|
+
for (let i = 0; i < sources.length; i++)
|
|
1458
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1459
|
+
return [...new Set(keys)];
|
|
1341
1460
|
}
|
|
1342
|
-
return false;
|
|
1343
1461
|
},
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1347
|
-
return [...new Set(keys)];
|
|
1348
|
-
}
|
|
1349
|
-
}, propTraps);
|
|
1462
|
+
propTraps
|
|
1463
|
+
);
|
|
1350
1464
|
}
|
|
1351
1465
|
const sourcesMap = {};
|
|
1352
1466
|
const defined = Object.create(null);
|
|
@@ -1359,15 +1473,20 @@ function mergeProps(...sources) {
|
|
|
1359
1473
|
if (key === "__proto__" || key === "constructor") continue;
|
|
1360
1474
|
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
1361
1475
|
if (!defined[key]) {
|
|
1362
|
-
defined[key] = desc.get
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1476
|
+
defined[key] = desc.get
|
|
1477
|
+
? {
|
|
1478
|
+
enumerable: true,
|
|
1479
|
+
configurable: true,
|
|
1480
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1481
|
+
}
|
|
1482
|
+
: desc.value !== undefined
|
|
1483
|
+
? desc
|
|
1484
|
+
: undefined;
|
|
1367
1485
|
} else {
|
|
1368
1486
|
const sources = sourcesMap[key];
|
|
1369
1487
|
if (sources) {
|
|
1370
|
-
if (desc.get) sources.push(desc.get.bind(source));
|
|
1488
|
+
if (desc.get) sources.push(desc.get.bind(source));
|
|
1489
|
+
else if (desc.value !== undefined) sources.push(() => desc.value);
|
|
1371
1490
|
}
|
|
1372
1491
|
}
|
|
1373
1492
|
}
|
|
@@ -1377,7 +1496,8 @@ function mergeProps(...sources) {
|
|
|
1377
1496
|
for (let i = definedKeys.length - 1; i >= 0; i--) {
|
|
1378
1497
|
const key = definedKeys[i],
|
|
1379
1498
|
desc = defined[key];
|
|
1380
|
-
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1499
|
+
if (desc && desc.get) Object.defineProperty(target, key, desc);
|
|
1500
|
+
else target[key] = desc ? desc.value : undefined;
|
|
1381
1501
|
}
|
|
1382
1502
|
return target;
|
|
1383
1503
|
}
|
|
@@ -1385,47 +1505,60 @@ function splitProps(props, ...keys) {
|
|
|
1385
1505
|
if ($PROXY in props) {
|
|
1386
1506
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1387
1507
|
const res = keys.map(k => {
|
|
1388
|
-
return new Proxy(
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1508
|
+
return new Proxy(
|
|
1509
|
+
{
|
|
1510
|
+
get(property) {
|
|
1511
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1512
|
+
},
|
|
1513
|
+
has(property) {
|
|
1514
|
+
return k.includes(property) && property in props;
|
|
1515
|
+
},
|
|
1516
|
+
keys() {
|
|
1517
|
+
return k.filter(property => property in props);
|
|
1518
|
+
}
|
|
1394
1519
|
},
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
}
|
|
1398
|
-
}, propTraps);
|
|
1520
|
+
propTraps
|
|
1521
|
+
);
|
|
1399
1522
|
});
|
|
1400
|
-
res.push(
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1523
|
+
res.push(
|
|
1524
|
+
new Proxy(
|
|
1525
|
+
{
|
|
1526
|
+
get(property) {
|
|
1527
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1528
|
+
},
|
|
1529
|
+
has(property) {
|
|
1530
|
+
return blocked.has(property) ? false : property in props;
|
|
1531
|
+
},
|
|
1532
|
+
keys() {
|
|
1533
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1534
|
+
}
|
|
1535
|
+
},
|
|
1536
|
+
propTraps
|
|
1537
|
+
)
|
|
1538
|
+
);
|
|
1411
1539
|
return res;
|
|
1412
1540
|
}
|
|
1413
1541
|
const otherObject = {};
|
|
1414
1542
|
const objects = keys.map(() => ({}));
|
|
1415
1543
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1416
1544
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1417
|
-
const isDefaultDesc =
|
|
1545
|
+
const isDefaultDesc =
|
|
1546
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1418
1547
|
let blocked = false;
|
|
1419
1548
|
let objectIndex = 0;
|
|
1420
1549
|
for (const k of keys) {
|
|
1421
1550
|
if (k.includes(propName)) {
|
|
1422
1551
|
blocked = true;
|
|
1423
|
-
isDefaultDesc
|
|
1552
|
+
isDefaultDesc
|
|
1553
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1554
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1424
1555
|
}
|
|
1425
1556
|
++objectIndex;
|
|
1426
1557
|
}
|
|
1427
1558
|
if (!blocked) {
|
|
1428
|
-
isDefaultDesc
|
|
1559
|
+
isDefaultDesc
|
|
1560
|
+
? (otherObject[propName] = desc.value)
|
|
1561
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1429
1562
|
}
|
|
1430
1563
|
}
|
|
1431
1564
|
return [...objects, otherObject];
|
|
@@ -1451,19 +1584,24 @@ function lazy(fn) {
|
|
|
1451
1584
|
comp = s;
|
|
1452
1585
|
}
|
|
1453
1586
|
let Comp;
|
|
1454
|
-
return createMemo(
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1587
|
+
return createMemo(
|
|
1588
|
+
() =>
|
|
1589
|
+
(Comp = comp()) &&
|
|
1590
|
+
untrack(() => {
|
|
1591
|
+
if (true)
|
|
1592
|
+
Object.assign(Comp, {
|
|
1593
|
+
[$DEVCOMP]: true
|
|
1594
|
+
});
|
|
1595
|
+
if (!ctx) return Comp(props);
|
|
1596
|
+
const c = sharedConfig.context;
|
|
1597
|
+
setHydrateContext(ctx);
|
|
1598
|
+
const r = Comp(props);
|
|
1599
|
+
setHydrateContext(c);
|
|
1600
|
+
return r;
|
|
1601
|
+
})
|
|
1602
|
+
);
|
|
1465
1603
|
};
|
|
1466
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1604
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1467
1605
|
return wrap;
|
|
1468
1606
|
}
|
|
1469
1607
|
let counter = 0;
|
|
@@ -1472,75 +1610,112 @@ function createUniqueId() {
|
|
|
1472
1610
|
return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
|
|
1473
1611
|
}
|
|
1474
1612
|
|
|
1475
|
-
const narrowedError = name =>
|
|
1613
|
+
const narrowedError = name =>
|
|
1614
|
+
`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.`;
|
|
1476
1615
|
function For(props) {
|
|
1477
1616
|
const fallback = "fallback" in props && {
|
|
1478
1617
|
fallback: () => props.fallback
|
|
1479
1618
|
};
|
|
1480
|
-
return createMemo(
|
|
1481
|
-
|
|
1482
|
-
|
|
1619
|
+
return createMemo(
|
|
1620
|
+
mapArray(() => props.each, props.children, fallback || undefined),
|
|
1621
|
+
undefined,
|
|
1622
|
+
{
|
|
1623
|
+
name: "value"
|
|
1624
|
+
}
|
|
1625
|
+
);
|
|
1483
1626
|
}
|
|
1484
1627
|
function Index(props) {
|
|
1485
1628
|
const fallback = "fallback" in props && {
|
|
1486
1629
|
fallback: () => props.fallback
|
|
1487
1630
|
};
|
|
1488
|
-
return createMemo(
|
|
1489
|
-
|
|
1490
|
-
|
|
1631
|
+
return createMemo(
|
|
1632
|
+
indexArray(() => props.each, props.children, fallback || undefined),
|
|
1633
|
+
undefined,
|
|
1634
|
+
{
|
|
1635
|
+
name: "value"
|
|
1636
|
+
}
|
|
1637
|
+
);
|
|
1491
1638
|
}
|
|
1492
1639
|
function Show(props) {
|
|
1493
1640
|
const keyed = props.keyed;
|
|
1494
1641
|
const condition = createMemo(() => props.when, undefined, {
|
|
1495
|
-
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1642
|
+
equals: (a, b) => (keyed ? a === b : !a === !b),
|
|
1496
1643
|
name: "condition"
|
|
1497
|
-
}
|
|
1498
|
-
return createMemo(
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1644
|
+
});
|
|
1645
|
+
return createMemo(
|
|
1646
|
+
() => {
|
|
1647
|
+
const c = condition();
|
|
1648
|
+
if (c) {
|
|
1649
|
+
const child = props.children;
|
|
1650
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1651
|
+
return fn
|
|
1652
|
+
? untrack(() =>
|
|
1653
|
+
child(
|
|
1654
|
+
keyed
|
|
1655
|
+
? c
|
|
1656
|
+
: () => {
|
|
1657
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1658
|
+
return props.when;
|
|
1659
|
+
}
|
|
1660
|
+
)
|
|
1661
|
+
)
|
|
1662
|
+
: child;
|
|
1663
|
+
}
|
|
1664
|
+
return props.fallback;
|
|
1665
|
+
},
|
|
1666
|
+
undefined,
|
|
1667
|
+
{
|
|
1668
|
+
name: "value"
|
|
1507
1669
|
}
|
|
1508
|
-
|
|
1509
|
-
}, undefined, {
|
|
1510
|
-
name: "value"
|
|
1511
|
-
} );
|
|
1670
|
+
);
|
|
1512
1671
|
}
|
|
1513
1672
|
function Switch(props) {
|
|
1514
1673
|
let keyed = false;
|
|
1515
1674
|
const equals = (a, b) => (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1516
1675
|
const conditions = children(() => props.children),
|
|
1517
|
-
evalConditions = createMemo(
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1676
|
+
evalConditions = createMemo(
|
|
1677
|
+
() => {
|
|
1678
|
+
let conds = conditions();
|
|
1679
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1680
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1681
|
+
const c = conds[i].when;
|
|
1682
|
+
if (c) {
|
|
1683
|
+
keyed = !!conds[i].keyed;
|
|
1684
|
+
return [i, c, conds[i]];
|
|
1685
|
+
}
|
|
1525
1686
|
}
|
|
1687
|
+
return [-1];
|
|
1688
|
+
},
|
|
1689
|
+
undefined,
|
|
1690
|
+
{
|
|
1691
|
+
equals,
|
|
1692
|
+
name: "eval conditions"
|
|
1526
1693
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1694
|
+
);
|
|
1695
|
+
return createMemo(
|
|
1696
|
+
() => {
|
|
1697
|
+
const [index, when, cond] = evalConditions();
|
|
1698
|
+
if (index < 0) return props.fallback;
|
|
1699
|
+
const c = cond.children;
|
|
1700
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1701
|
+
return fn
|
|
1702
|
+
? untrack(() =>
|
|
1703
|
+
c(
|
|
1704
|
+
keyed
|
|
1705
|
+
? when
|
|
1706
|
+
: () => {
|
|
1707
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1708
|
+
return cond.when;
|
|
1709
|
+
}
|
|
1710
|
+
)
|
|
1711
|
+
)
|
|
1712
|
+
: c;
|
|
1713
|
+
},
|
|
1714
|
+
undefined,
|
|
1715
|
+
{
|
|
1716
|
+
name: "value"
|
|
1717
|
+
}
|
|
1718
|
+
);
|
|
1544
1719
|
}
|
|
1545
1720
|
function Match(props) {
|
|
1546
1721
|
return props;
|
|
@@ -1551,27 +1726,33 @@ function resetErrorBoundaries() {
|
|
|
1551
1726
|
}
|
|
1552
1727
|
function ErrorBoundary(props) {
|
|
1553
1728
|
let err;
|
|
1554
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1729
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1730
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1555
1731
|
const [errored, setErrored] = createSignal(err, {
|
|
1556
1732
|
name: "errored"
|
|
1557
|
-
}
|
|
1733
|
+
});
|
|
1558
1734
|
Errors || (Errors = new Set());
|
|
1559
1735
|
Errors.add(setErrored);
|
|
1560
1736
|
onCleanup(() => Errors.delete(setErrored));
|
|
1561
|
-
return createMemo(
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1737
|
+
return createMemo(
|
|
1738
|
+
() => {
|
|
1739
|
+
let e;
|
|
1740
|
+
if ((e = errored())) {
|
|
1741
|
+
const f = props.fallback;
|
|
1742
|
+
if (typeof f !== "function" || f.length == 0) console.error(e);
|
|
1743
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1744
|
+
}
|
|
1745
|
+
return catchError(() => props.children, setErrored);
|
|
1746
|
+
},
|
|
1747
|
+
undefined,
|
|
1748
|
+
{
|
|
1749
|
+
name: "value"
|
|
1567
1750
|
}
|
|
1568
|
-
|
|
1569
|
-
}, undefined, {
|
|
1570
|
-
name: "value"
|
|
1571
|
-
} );
|
|
1751
|
+
);
|
|
1572
1752
|
}
|
|
1573
1753
|
|
|
1574
|
-
const suspenseListEquals = (a, b) =>
|
|
1754
|
+
const suspenseListEquals = (a, b) =>
|
|
1755
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1575
1756
|
const SuspenseListContext = createContext();
|
|
1576
1757
|
function SuspenseList(props) {
|
|
1577
1758
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1583,51 +1764,51 @@ function SuspenseList(props) {
|
|
|
1583
1764
|
if (listContext) {
|
|
1584
1765
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1585
1766
|
}
|
|
1586
|
-
const resolved = createMemo(
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
showContent = true,
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
const res = reg.map(() => ({
|
|
1598
|
-
showContent: all && showContent,
|
|
1599
|
-
showFallback
|
|
1600
|
-
}));
|
|
1601
|
-
res.inFallback = !all;
|
|
1602
|
-
return res;
|
|
1603
|
-
}
|
|
1604
|
-
let stop = false;
|
|
1605
|
-
let inFallback = prev.inFallback;
|
|
1606
|
-
const res = [];
|
|
1607
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1608
|
-
const n = reverse ? len - i - 1 : i,
|
|
1609
|
-
s = reg[n]();
|
|
1610
|
-
if (!stop && !s) {
|
|
1611
|
-
res[n] = {
|
|
1612
|
-
showContent,
|
|
1767
|
+
const resolved = createMemo(
|
|
1768
|
+
prev => {
|
|
1769
|
+
const reveal = props.revealOrder,
|
|
1770
|
+
tail = props.tail,
|
|
1771
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1772
|
+
reg = registry(),
|
|
1773
|
+
reverse = reveal === "backwards";
|
|
1774
|
+
if (reveal === "together") {
|
|
1775
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1776
|
+
const res = reg.map(() => ({
|
|
1777
|
+
showContent: all && showContent,
|
|
1613
1778
|
showFallback
|
|
1614
|
-
};
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1779
|
+
}));
|
|
1780
|
+
res.inFallback = !all;
|
|
1781
|
+
return res;
|
|
1782
|
+
}
|
|
1783
|
+
let stop = false;
|
|
1784
|
+
let inFallback = prev.inFallback;
|
|
1785
|
+
const res = [];
|
|
1786
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1787
|
+
const n = reverse ? len - i - 1 : i,
|
|
1788
|
+
s = reg[n]();
|
|
1789
|
+
if (!stop && !s) {
|
|
1790
|
+
res[n] = {
|
|
1791
|
+
showContent,
|
|
1792
|
+
showFallback
|
|
1793
|
+
};
|
|
1794
|
+
} else {
|
|
1795
|
+
const next = !stop;
|
|
1796
|
+
if (next) inFallback = true;
|
|
1797
|
+
res[n] = {
|
|
1798
|
+
showContent: next,
|
|
1799
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1800
|
+
};
|
|
1801
|
+
stop = true;
|
|
1802
|
+
}
|
|
1623
1803
|
}
|
|
1804
|
+
if (!stop) inFallback = false;
|
|
1805
|
+
res.inFallback = inFallback;
|
|
1806
|
+
return res;
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
inFallback: false
|
|
1624
1810
|
}
|
|
1625
|
-
|
|
1626
|
-
res.inFallback = inFallback;
|
|
1627
|
-
return res;
|
|
1628
|
-
}, {
|
|
1629
|
-
inFallback: false
|
|
1630
|
-
});
|
|
1811
|
+
);
|
|
1631
1812
|
setWrapper(() => resolved);
|
|
1632
1813
|
return createComponent(SuspenseListContext.Provider, {
|
|
1633
1814
|
value: {
|
|
@@ -1671,23 +1852,28 @@ function Suspense(props) {
|
|
|
1671
1852
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1672
1853
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1673
1854
|
let ref = sharedConfig.load(key);
|
|
1674
|
-
if (ref
|
|
1855
|
+
if (ref) {
|
|
1856
|
+
if (typeof ref !== "object" || ref.status !== "success") p = ref;
|
|
1857
|
+
else sharedConfig.gather(key);
|
|
1858
|
+
}
|
|
1675
1859
|
if (p && p !== "$$f") {
|
|
1676
1860
|
const [s, set] = createSignal(undefined, {
|
|
1677
1861
|
equals: false
|
|
1678
1862
|
});
|
|
1679
1863
|
flicker = s;
|
|
1680
|
-
p.then(
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1864
|
+
p.then(
|
|
1865
|
+
() => {
|
|
1866
|
+
if (sharedConfig.done) return set();
|
|
1867
|
+
sharedConfig.gather(key);
|
|
1868
|
+
setHydrateContext(ctx);
|
|
1869
|
+
set();
|
|
1870
|
+
setHydrateContext();
|
|
1871
|
+
},
|
|
1872
|
+
err => {
|
|
1873
|
+
error = err;
|
|
1874
|
+
set();
|
|
1689
1875
|
}
|
|
1690
|
-
|
|
1876
|
+
);
|
|
1691
1877
|
}
|
|
1692
1878
|
}
|
|
1693
1879
|
const listContext = useContext(SuspenseListContext);
|
|
@@ -1702,17 +1888,14 @@ function Suspense(props) {
|
|
|
1702
1888
|
ctx = sharedConfig.context;
|
|
1703
1889
|
if (flicker) {
|
|
1704
1890
|
flicker();
|
|
1705
|
-
return flicker = undefined;
|
|
1891
|
+
return (flicker = undefined);
|
|
1706
1892
|
}
|
|
1707
1893
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1708
1894
|
const rendered = createMemo(() => props.children);
|
|
1709
1895
|
return createMemo(prev => {
|
|
1710
1896
|
const inFallback = store.inFallback(),
|
|
1711
|
-
{
|
|
1712
|
-
|
|
1713
|
-
showFallback = true
|
|
1714
|
-
} = show ? show() : {};
|
|
1715
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1897
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1898
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1716
1899
|
store.resolved = true;
|
|
1717
1900
|
dispose && dispose();
|
|
1718
1901
|
dispose = ctx = p = undefined;
|
|
@@ -1742,9 +1925,68 @@ const DEV = {
|
|
|
1742
1925
|
hooks: DevHooks,
|
|
1743
1926
|
writeSignal,
|
|
1744
1927
|
registerGraph
|
|
1745
|
-
}
|
|
1928
|
+
};
|
|
1746
1929
|
if (globalThis) {
|
|
1747
|
-
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1930
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1931
|
+
else
|
|
1932
|
+
console.warn(
|
|
1933
|
+
"You appear to have multiple instances of Solid. This can lead to unexpected behavior."
|
|
1934
|
+
);
|
|
1748
1935
|
}
|
|
1749
1936
|
|
|
1750
|
-
export {
|
|
1937
|
+
export {
|
|
1938
|
+
$DEVCOMP,
|
|
1939
|
+
$PROXY,
|
|
1940
|
+
$TRACK,
|
|
1941
|
+
DEV,
|
|
1942
|
+
ErrorBoundary,
|
|
1943
|
+
For,
|
|
1944
|
+
Index,
|
|
1945
|
+
Match,
|
|
1946
|
+
Show,
|
|
1947
|
+
Suspense,
|
|
1948
|
+
SuspenseList,
|
|
1949
|
+
Switch,
|
|
1950
|
+
batch,
|
|
1951
|
+
cancelCallback,
|
|
1952
|
+
catchError,
|
|
1953
|
+
children,
|
|
1954
|
+
createComponent,
|
|
1955
|
+
createComputed,
|
|
1956
|
+
createContext,
|
|
1957
|
+
createDeferred,
|
|
1958
|
+
createEffect,
|
|
1959
|
+
createMemo,
|
|
1960
|
+
createReaction,
|
|
1961
|
+
createRenderEffect,
|
|
1962
|
+
createResource,
|
|
1963
|
+
createRoot,
|
|
1964
|
+
createSelector,
|
|
1965
|
+
createSignal,
|
|
1966
|
+
createUniqueId,
|
|
1967
|
+
enableExternalSource,
|
|
1968
|
+
enableHydration,
|
|
1969
|
+
enableScheduling,
|
|
1970
|
+
equalFn,
|
|
1971
|
+
from,
|
|
1972
|
+
getListener,
|
|
1973
|
+
getOwner,
|
|
1974
|
+
indexArray,
|
|
1975
|
+
lazy,
|
|
1976
|
+
mapArray,
|
|
1977
|
+
mergeProps,
|
|
1978
|
+
observable,
|
|
1979
|
+
on,
|
|
1980
|
+
onCleanup,
|
|
1981
|
+
onError,
|
|
1982
|
+
onMount,
|
|
1983
|
+
requestCallback,
|
|
1984
|
+
resetErrorBoundaries,
|
|
1985
|
+
runWithOwner,
|
|
1986
|
+
sharedConfig,
|
|
1987
|
+
splitProps,
|
|
1988
|
+
startTransition,
|
|
1989
|
+
untrack,
|
|
1990
|
+
useContext,
|
|
1991
|
+
useTransition
|
|
1992
|
+
};
|