solid-js 1.8.0-beta.2 → 1.8.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.js +532 -297
- package/dist/server.js +168 -74
- package/dist/solid.js +459 -255
- 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/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +45 -31
- package/package.json +1 -1
- package/store/dist/dev.js +114 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +105 -39
- 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 +218 -61
- package/types/index.d.ts +72 -9
- 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 +228 -140
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +62 -31
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +56 -2
- package/types/server/reactive.d.ts +67 -40
- package/types/server/rendering.d.ts +166 -95
- 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.js +611 -79
- package/web/dist/server.js +175 -92
- package/web/dist/web.js +611 -79
- package/web/types/client.d.ts +2 -2
- 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/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
|
}
|
|
@@ -159,26 +161,31 @@ const DevHooks = {
|
|
|
159
161
|
afterUpdate: null,
|
|
160
162
|
afterCreateOwner: null
|
|
161
163
|
};
|
|
162
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
164
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
163
165
|
function createRoot(fn, detachedOwner) {
|
|
164
166
|
const listener = Listener,
|
|
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;
|
|
@@ -203,23 +210,26 @@ function createSignal(value, options) {
|
|
|
203
210
|
}
|
|
204
211
|
const setter = value => {
|
|
205
212
|
if (typeof value === "function") {
|
|
206
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
213
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
214
|
+
else value = value(s.value);
|
|
207
215
|
}
|
|
208
216
|
return writeSignal(s, value);
|
|
209
217
|
};
|
|
210
218
|
return [readSignal.bind(s), setter];
|
|
211
219
|
}
|
|
212
220
|
function createComputed(fn, value, options) {
|
|
213
|
-
const c = createComputation(fn, value, true, STALE, options
|
|
214
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
221
|
+
const c = createComputation(fn, value, true, STALE, options);
|
|
222
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
223
|
+
else updateComputation(c);
|
|
215
224
|
}
|
|
216
225
|
function createRenderEffect(fn, value, options) {
|
|
217
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
218
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
226
|
+
const c = createComputation(fn, value, false, STALE, options);
|
|
227
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
228
|
+
else updateComputation(c);
|
|
219
229
|
}
|
|
220
230
|
function createEffect(fn, value, options) {
|
|
221
231
|
runEffects = runUserEffects;
|
|
222
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
232
|
+
const c = createComputation(fn, value, false, STALE, options),
|
|
223
233
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
224
234
|
if (s) c.suspense = s;
|
|
225
235
|
if (!options || !options.render) c.user = true;
|
|
@@ -227,10 +237,16 @@ function createEffect(fn, value, options) {
|
|
|
227
237
|
}
|
|
228
238
|
function createReaction(onInvalidate, options) {
|
|
229
239
|
let fn;
|
|
230
|
-
const c = createComputation(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
240
|
+
const c = createComputation(
|
|
241
|
+
() => {
|
|
242
|
+
fn ? fn() : untrack(onInvalidate);
|
|
243
|
+
fn = undefined;
|
|
244
|
+
},
|
|
245
|
+
undefined,
|
|
246
|
+
false,
|
|
247
|
+
0,
|
|
248
|
+
options
|
|
249
|
+
),
|
|
234
250
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
235
251
|
if (s) c.suspense = s;
|
|
236
252
|
c.user = true;
|
|
@@ -241,7 +257,7 @@ function createReaction(onInvalidate, options) {
|
|
|
241
257
|
}
|
|
242
258
|
function createMemo(fn, value, options) {
|
|
243
259
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
244
|
-
const c = createComputation(fn, value, true, 0, options
|
|
260
|
+
const c = createComputation(fn, value, true, 0, options);
|
|
245
261
|
c.observers = null;
|
|
246
262
|
c.observerSlots = null;
|
|
247
263
|
c.comparator = options.equals || undefined;
|
|
@@ -258,7 +274,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
258
274
|
let source;
|
|
259
275
|
let fetcher;
|
|
260
276
|
let options;
|
|
261
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
277
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
262
278
|
source = true;
|
|
263
279
|
fetcher = pSource;
|
|
264
280
|
options = pFetcher || {};
|
|
@@ -272,7 +288,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
272
288
|
id = null,
|
|
273
289
|
loadedUnderTransition = false,
|
|
274
290
|
scheduled = false,
|
|
275
|
-
resolved =
|
|
291
|
+
resolved = "initialValue" in options,
|
|
276
292
|
dynamic = typeof source === "function" && createMemo(source);
|
|
277
293
|
const contexts = new Set(),
|
|
278
294
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -284,15 +300,20 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
284
300
|
if (sharedConfig.context) {
|
|
285
301
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
286
302
|
let v;
|
|
287
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
303
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
304
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id)))
|
|
305
|
+
initP = isPromise(v) && "value" in v ? v.value : v;
|
|
288
306
|
}
|
|
289
307
|
function loadEnd(p, v, error, key) {
|
|
290
308
|
if (pr === p) {
|
|
291
309
|
pr = null;
|
|
292
310
|
key !== undefined && (resolved = true);
|
|
293
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
294
|
-
|
|
295
|
-
|
|
311
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
312
|
+
queueMicrotask(() =>
|
|
313
|
+
options.onHydrated(key, {
|
|
314
|
+
value: v
|
|
315
|
+
})
|
|
316
|
+
);
|
|
296
317
|
initP = NO_INIT;
|
|
297
318
|
if (Transition && p && loadedUnderTransition) {
|
|
298
319
|
Transition.promises.delete(p);
|
|
@@ -323,7 +344,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
323
344
|
createComputed(() => {
|
|
324
345
|
track();
|
|
325
346
|
if (pr) {
|
|
326
|
-
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)) {
|
|
327
349
|
c.increment();
|
|
328
350
|
contexts.add(c);
|
|
329
351
|
}
|
|
@@ -342,22 +364,30 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
342
364
|
return;
|
|
343
365
|
}
|
|
344
366
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
345
|
-
const p =
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
367
|
+
const p =
|
|
368
|
+
initP !== NO_INIT
|
|
369
|
+
? initP
|
|
370
|
+
: untrack(() =>
|
|
371
|
+
fetcher(lookup, {
|
|
372
|
+
value: value(),
|
|
373
|
+
refetching
|
|
374
|
+
})
|
|
375
|
+
);
|
|
349
376
|
if (!isPromise(p)) {
|
|
350
377
|
loadEnd(pr, p, undefined, lookup);
|
|
351
378
|
return p;
|
|
352
379
|
}
|
|
353
380
|
pr = p;
|
|
354
381
|
scheduled = true;
|
|
355
|
-
queueMicrotask(() => scheduled = false);
|
|
382
|
+
queueMicrotask(() => (scheduled = false));
|
|
356
383
|
runUpdates(() => {
|
|
357
384
|
setState(resolved ? "refreshing" : "pending");
|
|
358
385
|
trigger();
|
|
359
386
|
}, false);
|
|
360
|
-
return p.then(
|
|
387
|
+
return p.then(
|
|
388
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
389
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
390
|
+
);
|
|
361
391
|
}
|
|
362
392
|
Object.defineProperties(read, {
|
|
363
393
|
state: {
|
|
@@ -381,50 +411,81 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
381
411
|
}
|
|
382
412
|
}
|
|
383
413
|
});
|
|
384
|
-
if (dynamic) createComputed(() => load(false));
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
414
|
+
if (dynamic) createComputed(() => load(false));
|
|
415
|
+
else load(false);
|
|
416
|
+
return [
|
|
417
|
+
read,
|
|
418
|
+
{
|
|
419
|
+
refetch: load,
|
|
420
|
+
mutate: setValue
|
|
421
|
+
}
|
|
422
|
+
];
|
|
389
423
|
}
|
|
390
424
|
function createDeferred(source, options) {
|
|
391
425
|
let t,
|
|
392
426
|
timeout = options ? options.timeoutMs : undefined;
|
|
393
|
-
const node = createComputation(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
427
|
+
const node = createComputation(
|
|
428
|
+
() => {
|
|
429
|
+
if (!t || !t.fn)
|
|
430
|
+
t = requestCallback(
|
|
431
|
+
() => setDeferred(() => node.value),
|
|
432
|
+
timeout !== undefined
|
|
433
|
+
? {
|
|
434
|
+
timeout
|
|
435
|
+
}
|
|
436
|
+
: undefined
|
|
437
|
+
);
|
|
438
|
+
return source();
|
|
439
|
+
},
|
|
440
|
+
undefined,
|
|
441
|
+
true
|
|
442
|
+
);
|
|
443
|
+
const [deferred, setDeferred] = createSignal(
|
|
444
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
445
|
+
options
|
|
446
|
+
);
|
|
400
447
|
updateComputation(node);
|
|
401
|
-
setDeferred(() =>
|
|
448
|
+
setDeferred(() =>
|
|
449
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
450
|
+
);
|
|
402
451
|
return deferred;
|
|
403
452
|
}
|
|
404
453
|
function createSelector(source, fn = equalFn, options) {
|
|
405
454
|
const subs = new Map();
|
|
406
|
-
const node = createComputation(
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
for (const
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
455
|
+
const node = createComputation(
|
|
456
|
+
p => {
|
|
457
|
+
const v = source();
|
|
458
|
+
for (const [key, val] of subs.entries())
|
|
459
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
460
|
+
for (const c of val.values()) {
|
|
461
|
+
c.state = STALE;
|
|
462
|
+
if (c.pure) Updates.push(c);
|
|
463
|
+
else Effects.push(c);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return v;
|
|
467
|
+
},
|
|
468
|
+
undefined,
|
|
469
|
+
true,
|
|
470
|
+
STALE,
|
|
471
|
+
options
|
|
472
|
+
);
|
|
416
473
|
updateComputation(node);
|
|
417
474
|
return key => {
|
|
418
475
|
const listener = Listener;
|
|
419
476
|
if (listener) {
|
|
420
477
|
let l;
|
|
421
|
-
if (l = subs.get(key)) l.add(listener);
|
|
478
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
479
|
+
else subs.set(key, (l = new Set([listener])));
|
|
422
480
|
onCleanup(() => {
|
|
423
481
|
l.delete(listener);
|
|
424
482
|
!l.size && subs.delete(key);
|
|
425
483
|
});
|
|
426
484
|
}
|
|
427
|
-
return fn(
|
|
485
|
+
return fn(
|
|
486
|
+
key,
|
|
487
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
488
|
+
);
|
|
428
489
|
};
|
|
429
490
|
}
|
|
430
491
|
function batch(fn) {
|
|
@@ -463,7 +524,10 @@ function onMount(fn) {
|
|
|
463
524
|
createEffect(() => untrack(fn));
|
|
464
525
|
}
|
|
465
526
|
function onCleanup(fn) {
|
|
466
|
-
if (Owner === null)
|
|
527
|
+
if (Owner === null)
|
|
528
|
+
console.warn("cleanups created outside a `createRoot` or `render` will never be run");
|
|
529
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
530
|
+
else Owner.cleanups.push(fn);
|
|
467
531
|
return fn;
|
|
468
532
|
}
|
|
469
533
|
function catchError(fn, handler) {
|
|
@@ -517,15 +581,17 @@ function startTransition(fn) {
|
|
|
517
581
|
Owner = o;
|
|
518
582
|
let t;
|
|
519
583
|
if (Scheduler || SuspenseContext) {
|
|
520
|
-
t =
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
584
|
+
t =
|
|
585
|
+
Transition ||
|
|
586
|
+
(Transition = {
|
|
587
|
+
sources: new Set(),
|
|
588
|
+
effects: [],
|
|
589
|
+
promises: new Set(),
|
|
590
|
+
disposed: new Set(),
|
|
591
|
+
queue: new Set(),
|
|
592
|
+
running: true
|
|
593
|
+
});
|
|
594
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
529
595
|
t.running = true;
|
|
530
596
|
}
|
|
531
597
|
runUpdates(fn, false);
|
|
@@ -541,12 +607,18 @@ function resumeEffects(e) {
|
|
|
541
607
|
e.length = 0;
|
|
542
608
|
}
|
|
543
609
|
function devComponent(Comp, props) {
|
|
544
|
-
const c = createComputation(
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
610
|
+
const c = createComputation(
|
|
611
|
+
() =>
|
|
612
|
+
untrack(() => {
|
|
613
|
+
Object.assign(Comp, {
|
|
614
|
+
[$DEVCOMP]: true
|
|
615
|
+
});
|
|
616
|
+
return Comp(props);
|
|
617
|
+
}),
|
|
618
|
+
undefined,
|
|
619
|
+
true,
|
|
620
|
+
0
|
|
621
|
+
);
|
|
550
622
|
c.props = props;
|
|
551
623
|
c.observers = null;
|
|
552
624
|
c.observerSlots = null;
|
|
@@ -557,7 +629,8 @@ function devComponent(Comp, props) {
|
|
|
557
629
|
}
|
|
558
630
|
function registerGraph(value) {
|
|
559
631
|
if (!Owner) return;
|
|
560
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
632
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
633
|
+
else Owner.sourceMap = [value];
|
|
561
634
|
value.graph = Owner;
|
|
562
635
|
}
|
|
563
636
|
function createContext(defaultValue, options) {
|
|
@@ -569,13 +642,15 @@ function createContext(defaultValue, options) {
|
|
|
569
642
|
};
|
|
570
643
|
}
|
|
571
644
|
function useContext(context) {
|
|
572
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
645
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
646
|
+
? Owner.context[context.id]
|
|
647
|
+
: context.defaultValue;
|
|
573
648
|
}
|
|
574
649
|
function children(fn) {
|
|
575
650
|
const children = createMemo(fn);
|
|
576
651
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
577
652
|
name: "children"
|
|
578
|
-
})
|
|
653
|
+
});
|
|
579
654
|
memo.toArray = () => {
|
|
580
655
|
const c = memo();
|
|
581
656
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -607,7 +682,8 @@ function enableExternalSource(factory) {
|
|
|
607
682
|
function readSignal() {
|
|
608
683
|
const runningTransition = Transition && Transition.running;
|
|
609
684
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
610
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
685
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
686
|
+
else {
|
|
611
687
|
const updates = Updates;
|
|
612
688
|
Updates = null;
|
|
613
689
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -635,11 +711,12 @@ function readSignal() {
|
|
|
635
711
|
return this.value;
|
|
636
712
|
}
|
|
637
713
|
function writeSignal(node, value, isComp) {
|
|
638
|
-
let current =
|
|
714
|
+
let current =
|
|
715
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
639
716
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
640
717
|
if (Transition) {
|
|
641
718
|
const TransitionRunning = Transition.running;
|
|
642
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
719
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
643
720
|
Transition.sources.add(node);
|
|
644
721
|
node.tValue = value;
|
|
645
722
|
}
|
|
@@ -652,10 +729,12 @@ function writeSignal(node, value, isComp) {
|
|
|
652
729
|
const TransitionRunning = Transition && Transition.running;
|
|
653
730
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
654
731
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
655
|
-
if (o.pure) Updates.push(o);
|
|
732
|
+
if (o.pure) Updates.push(o);
|
|
733
|
+
else Effects.push(o);
|
|
656
734
|
if (o.observers) markDownstream(o);
|
|
657
735
|
}
|
|
658
|
-
if (!TransitionRunning) o.state = STALE;
|
|
736
|
+
if (!TransitionRunning) o.state = STALE;
|
|
737
|
+
else o.tState = STALE;
|
|
659
738
|
}
|
|
660
739
|
if (Updates.length > 10e5) {
|
|
661
740
|
Updates = [];
|
|
@@ -674,7 +753,11 @@ function updateComputation(node) {
|
|
|
674
753
|
listener = Listener,
|
|
675
754
|
time = ExecCount;
|
|
676
755
|
Listener = Owner = node;
|
|
677
|
-
runComputation(
|
|
756
|
+
runComputation(
|
|
757
|
+
node,
|
|
758
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
759
|
+
time
|
|
760
|
+
);
|
|
678
761
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
679
762
|
queueMicrotask(() => {
|
|
680
763
|
runUpdates(() => {
|
|
@@ -735,11 +818,15 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
735
818
|
c.state = 0;
|
|
736
819
|
c.tState = state;
|
|
737
820
|
}
|
|
738
|
-
if (Owner === null)
|
|
821
|
+
if (Owner === null)
|
|
822
|
+
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
823
|
+
else if (Owner !== UNOWNED) {
|
|
739
824
|
if (Transition && Transition.running && Owner.pure) {
|
|
740
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
825
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
826
|
+
else Owner.tOwned.push(c);
|
|
741
827
|
} else {
|
|
742
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
828
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
829
|
+
else Owner.owned.push(c);
|
|
743
830
|
}
|
|
744
831
|
}
|
|
745
832
|
if (options && options.name) c.name = options.name;
|
|
@@ -792,7 +879,8 @@ function runUpdates(fn, init) {
|
|
|
792
879
|
if (Updates) return fn();
|
|
793
880
|
let wait = false;
|
|
794
881
|
if (!init) Updates = [];
|
|
795
|
-
if (Effects) wait = true;
|
|
882
|
+
if (Effects) wait = true;
|
|
883
|
+
else Effects = [];
|
|
796
884
|
ExecCount++;
|
|
797
885
|
try {
|
|
798
886
|
const res = fn();
|
|
@@ -806,7 +894,8 @@ function runUpdates(fn, init) {
|
|
|
806
894
|
}
|
|
807
895
|
function completeUpdates(wait) {
|
|
808
896
|
if (Updates) {
|
|
809
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
897
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
898
|
+
else runQueue(Updates);
|
|
810
899
|
Updates = null;
|
|
811
900
|
}
|
|
812
901
|
if (wait) return;
|
|
@@ -846,7 +935,8 @@ function completeUpdates(wait) {
|
|
|
846
935
|
}
|
|
847
936
|
const e = Effects;
|
|
848
937
|
Effects = null;
|
|
849
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
938
|
+
if (e.length) runUpdates(() => runEffects(e), false);
|
|
939
|
+
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
850
940
|
if (res) res();
|
|
851
941
|
}
|
|
852
942
|
function runQueue(queue) {
|
|
@@ -874,7 +964,8 @@ function runUserEffects(queue) {
|
|
|
874
964
|
userLength = 0;
|
|
875
965
|
for (i = 0; i < queue.length; i++) {
|
|
876
966
|
const e = queue[i];
|
|
877
|
-
if (!e.user) runTop(e);
|
|
967
|
+
if (!e.user) runTop(e);
|
|
968
|
+
else queue[userLength++] = e;
|
|
878
969
|
}
|
|
879
970
|
if (sharedConfig.context) {
|
|
880
971
|
if (sharedConfig.count) {
|
|
@@ -892,13 +983,15 @@ function runUserEffects(queue) {
|
|
|
892
983
|
}
|
|
893
984
|
function lookUpstream(node, ignore) {
|
|
894
985
|
const runningTransition = Transition && Transition.running;
|
|
895
|
-
if (runningTransition) node.tState = 0;
|
|
986
|
+
if (runningTransition) node.tState = 0;
|
|
987
|
+
else node.state = 0;
|
|
896
988
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
897
989
|
const source = node.sources[i];
|
|
898
990
|
if (source.sources) {
|
|
899
991
|
const state = runningTransition ? source.tState : source.state;
|
|
900
992
|
if (state === STALE) {
|
|
901
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
993
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
994
|
+
runTop(source);
|
|
902
995
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
903
996
|
}
|
|
904
997
|
}
|
|
@@ -908,8 +1001,10 @@ function markDownstream(node) {
|
|
|
908
1001
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
909
1002
|
const o = node.observers[i];
|
|
910
1003
|
if (runningTransition ? !o.tState : !o.state) {
|
|
911
|
-
if (runningTransition) o.tState = PENDING;
|
|
912
|
-
|
|
1004
|
+
if (runningTransition) o.tState = PENDING;
|
|
1005
|
+
else o.state = PENDING;
|
|
1006
|
+
if (o.pure) Updates.push(o);
|
|
1007
|
+
else Effects.push(o);
|
|
913
1008
|
o.observers && markDownstream(o);
|
|
914
1009
|
}
|
|
915
1010
|
}
|
|
@@ -946,7 +1041,8 @@ function cleanNode(node) {
|
|
|
946
1041
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
947
1042
|
node.cleanups = null;
|
|
948
1043
|
}
|
|
949
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1044
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1045
|
+
else node.state = 0;
|
|
950
1046
|
delete node.sourceMap;
|
|
951
1047
|
}
|
|
952
1048
|
function reset(node, top) {
|
|
@@ -968,19 +1064,21 @@ function runErrors(err, fns, owner) {
|
|
|
968
1064
|
try {
|
|
969
1065
|
for (const f of fns) f(err);
|
|
970
1066
|
} catch (e) {
|
|
971
|
-
handleError(e, owner && owner.owner || null);
|
|
1067
|
+
handleError(e, (owner && owner.owner) || null);
|
|
972
1068
|
}
|
|
973
1069
|
}
|
|
974
1070
|
function handleError(err, owner = Owner) {
|
|
975
1071
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
976
1072
|
const error = castError(err);
|
|
977
1073
|
if (!fns) throw error;
|
|
978
|
-
if (Effects)
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1074
|
+
if (Effects)
|
|
1075
|
+
Effects.push({
|
|
1076
|
+
fn() {
|
|
1077
|
+
runErrors(error, fns, owner);
|
|
1078
|
+
},
|
|
1079
|
+
state: STALE
|
|
1080
|
+
});
|
|
1081
|
+
else runErrors(error, fns, owner);
|
|
984
1082
|
}
|
|
985
1083
|
function resolveChildren(children) {
|
|
986
1084
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -997,19 +1095,26 @@ function resolveChildren(children) {
|
|
|
997
1095
|
function createProvider(id, options) {
|
|
998
1096
|
return function provider(props) {
|
|
999
1097
|
let res;
|
|
1000
|
-
createRenderEffect(
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1098
|
+
createRenderEffect(
|
|
1099
|
+
() =>
|
|
1100
|
+
(res = untrack(() => {
|
|
1101
|
+
Owner.context = {
|
|
1102
|
+
...Owner.context,
|
|
1103
|
+
[id]: props.value
|
|
1104
|
+
};
|
|
1105
|
+
return children(() => props.children);
|
|
1106
|
+
})),
|
|
1107
|
+
undefined,
|
|
1108
|
+
options
|
|
1109
|
+
);
|
|
1007
1110
|
return res;
|
|
1008
1111
|
};
|
|
1009
1112
|
}
|
|
1010
1113
|
function onError(fn) {
|
|
1011
1114
|
ERROR || (ERROR = Symbol("error"));
|
|
1012
|
-
if (Owner === null)
|
|
1115
|
+
if (Owner === null)
|
|
1116
|
+
console.warn("error handlers created outside a `createRoot` or `render` will never be run");
|
|
1117
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1013
1118
|
Owner.context = {
|
|
1014
1119
|
...Owner.context,
|
|
1015
1120
|
[ERROR]: [fn]
|
|
@@ -1038,7 +1143,8 @@ function observable(input) {
|
|
|
1038
1143
|
if (!(observer instanceof Object) || observer == null) {
|
|
1039
1144
|
throw new TypeError("Expected the observer to be an object.");
|
|
1040
1145
|
}
|
|
1041
|
-
const handler =
|
|
1146
|
+
const handler =
|
|
1147
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1042
1148
|
if (!handler) {
|
|
1043
1149
|
return {
|
|
1044
1150
|
unsubscribe() {}
|
|
@@ -1069,7 +1175,7 @@ function from(producer) {
|
|
|
1069
1175
|
});
|
|
1070
1176
|
if ("subscribe" in producer) {
|
|
1071
1177
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1072
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1178
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1073
1179
|
} else {
|
|
1074
1180
|
const clean = producer(set);
|
|
1075
1181
|
onCleanup(clean);
|
|
@@ -1121,8 +1227,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1121
1227
|
});
|
|
1122
1228
|
len = 1;
|
|
1123
1229
|
}
|
|
1124
|
-
}
|
|
1125
|
-
else if (len === 0) {
|
|
1230
|
+
} else if (len === 0) {
|
|
1126
1231
|
mapped = new Array(newLen);
|
|
1127
1232
|
for (j = 0; j < newLen; j++) {
|
|
1128
1233
|
items[j] = newItems[j];
|
|
@@ -1133,8 +1238,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1133
1238
|
temp = new Array(newLen);
|
|
1134
1239
|
tempdisposers = new Array(newLen);
|
|
1135
1240
|
indexes && (tempIndexes = new Array(newLen));
|
|
1136
|
-
for (
|
|
1137
|
-
|
|
1241
|
+
for (
|
|
1242
|
+
start = 0, end = Math.min(len, newLen);
|
|
1243
|
+
start < end && items[start] === newItems[start];
|
|
1244
|
+
start++
|
|
1245
|
+
);
|
|
1246
|
+
for (
|
|
1247
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1248
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1249
|
+
end--, newEnd--
|
|
1250
|
+
) {
|
|
1138
1251
|
temp[newEnd] = mapped[end];
|
|
1139
1252
|
tempdisposers[newEnd] = disposers[end];
|
|
1140
1253
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1168,7 +1281,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1168
1281
|
}
|
|
1169
1282
|
} else mapped[j] = createRoot(mapper);
|
|
1170
1283
|
}
|
|
1171
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1284
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1172
1285
|
items = newItems.slice(0);
|
|
1173
1286
|
}
|
|
1174
1287
|
return mapped;
|
|
@@ -1178,7 +1291,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1178
1291
|
if (indexes) {
|
|
1179
1292
|
const [s, set] = createSignal(j, {
|
|
1180
1293
|
name: "index"
|
|
1181
|
-
})
|
|
1294
|
+
});
|
|
1182
1295
|
indexes[j] = set;
|
|
1183
1296
|
return mapFn(newItems[j], s);
|
|
1184
1297
|
}
|
|
@@ -1236,13 +1349,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1236
1349
|
}
|
|
1237
1350
|
len = signals.length = disposers.length = newItems.length;
|
|
1238
1351
|
items = newItems.slice(0);
|
|
1239
|
-
return mapped = mapped.slice(0, len);
|
|
1352
|
+
return (mapped = mapped.slice(0, len));
|
|
1240
1353
|
});
|
|
1241
1354
|
function mapper(disposer) {
|
|
1242
1355
|
disposers[i] = disposer;
|
|
1243
1356
|
const [s, set] = createSignal(newItems[i], {
|
|
1244
1357
|
name: "value"
|
|
1245
|
-
})
|
|
1358
|
+
});
|
|
1246
1359
|
signals[i] = set;
|
|
1247
1360
|
return mapFn(s, i);
|
|
1248
1361
|
}
|
|
@@ -1258,7 +1371,7 @@ function createComponent(Comp, props) {
|
|
|
1258
1371
|
if (sharedConfig.context) {
|
|
1259
1372
|
const c = sharedConfig.context;
|
|
1260
1373
|
setHydrateContext(nextHydrateContext());
|
|
1261
|
-
const r = devComponent(Comp, props || {})
|
|
1374
|
+
const r = devComponent(Comp, props || {});
|
|
1262
1375
|
setHydrateContext(c);
|
|
1263
1376
|
return r;
|
|
1264
1377
|
}
|
|
@@ -1307,29 +1420,33 @@ function mergeProps(...sources) {
|
|
|
1307
1420
|
let proxy = false;
|
|
1308
1421
|
for (let i = 0; i < sources.length; i++) {
|
|
1309
1422
|
const s = sources[i];
|
|
1310
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1311
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1423
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1424
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1312
1425
|
}
|
|
1313
1426
|
if (proxy) {
|
|
1314
|
-
return new Proxy(
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1427
|
+
return new Proxy(
|
|
1428
|
+
{
|
|
1429
|
+
get(property) {
|
|
1430
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1431
|
+
const v = resolveSource(sources[i])[property];
|
|
1432
|
+
if (v !== undefined) return v;
|
|
1433
|
+
}
|
|
1434
|
+
},
|
|
1435
|
+
has(property) {
|
|
1436
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1437
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1438
|
+
}
|
|
1439
|
+
return false;
|
|
1440
|
+
},
|
|
1441
|
+
keys() {
|
|
1442
|
+
const keys = [];
|
|
1443
|
+
for (let i = 0; i < sources.length; i++)
|
|
1444
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1445
|
+
return [...new Set(keys)];
|
|
1324
1446
|
}
|
|
1325
|
-
return false;
|
|
1326
1447
|
},
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1330
|
-
return [...new Set(keys)];
|
|
1331
|
-
}
|
|
1332
|
-
}, propTraps);
|
|
1448
|
+
propTraps
|
|
1449
|
+
);
|
|
1333
1450
|
}
|
|
1334
1451
|
const target = {};
|
|
1335
1452
|
const sourcesMap = {};
|
|
@@ -1348,7 +1465,7 @@ function mergeProps(...sources) {
|
|
|
1348
1465
|
Object.defineProperty(target, key, {
|
|
1349
1466
|
enumerable: true,
|
|
1350
1467
|
configurable: true,
|
|
1351
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1468
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1352
1469
|
});
|
|
1353
1470
|
} else {
|
|
1354
1471
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1372,47 +1489,60 @@ function splitProps(props, ...keys) {
|
|
|
1372
1489
|
if ($PROXY in props) {
|
|
1373
1490
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1374
1491
|
const res = keys.map(k => {
|
|
1375
|
-
return new Proxy(
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1492
|
+
return new Proxy(
|
|
1493
|
+
{
|
|
1494
|
+
get(property) {
|
|
1495
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1496
|
+
},
|
|
1497
|
+
has(property) {
|
|
1498
|
+
return k.includes(property) && property in props;
|
|
1499
|
+
},
|
|
1500
|
+
keys() {
|
|
1501
|
+
return k.filter(property => property in props);
|
|
1502
|
+
}
|
|
1381
1503
|
},
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
}
|
|
1385
|
-
}, propTraps);
|
|
1504
|
+
propTraps
|
|
1505
|
+
);
|
|
1386
1506
|
});
|
|
1387
|
-
res.push(
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1507
|
+
res.push(
|
|
1508
|
+
new Proxy(
|
|
1509
|
+
{
|
|
1510
|
+
get(property) {
|
|
1511
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1512
|
+
},
|
|
1513
|
+
has(property) {
|
|
1514
|
+
return blocked.has(property) ? false : property in props;
|
|
1515
|
+
},
|
|
1516
|
+
keys() {
|
|
1517
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1518
|
+
}
|
|
1519
|
+
},
|
|
1520
|
+
propTraps
|
|
1521
|
+
)
|
|
1522
|
+
);
|
|
1398
1523
|
return res;
|
|
1399
1524
|
}
|
|
1400
1525
|
const otherObject = {};
|
|
1401
1526
|
const objects = keys.map(() => ({}));
|
|
1402
1527
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1403
1528
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1404
|
-
const isDefaultDesc =
|
|
1529
|
+
const isDefaultDesc =
|
|
1530
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1405
1531
|
let blocked = false;
|
|
1406
1532
|
let objectIndex = 0;
|
|
1407
1533
|
for (const k of keys) {
|
|
1408
1534
|
if (k.includes(propName)) {
|
|
1409
1535
|
blocked = true;
|
|
1410
|
-
isDefaultDesc
|
|
1536
|
+
isDefaultDesc
|
|
1537
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1538
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1411
1539
|
}
|
|
1412
1540
|
++objectIndex;
|
|
1413
1541
|
}
|
|
1414
1542
|
if (!blocked) {
|
|
1415
|
-
isDefaultDesc
|
|
1543
|
+
isDefaultDesc
|
|
1544
|
+
? (otherObject[propName] = desc.value)
|
|
1545
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1416
1546
|
}
|
|
1417
1547
|
}
|
|
1418
1548
|
return [...objects, otherObject];
|
|
@@ -1438,19 +1568,24 @@ function lazy(fn) {
|
|
|
1438
1568
|
comp = s;
|
|
1439
1569
|
}
|
|
1440
1570
|
let Comp;
|
|
1441
|
-
return createMemo(
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1571
|
+
return createMemo(
|
|
1572
|
+
() =>
|
|
1573
|
+
(Comp = comp()) &&
|
|
1574
|
+
untrack(() => {
|
|
1575
|
+
if (true)
|
|
1576
|
+
Object.assign(Comp, {
|
|
1577
|
+
[$DEVCOMP]: true
|
|
1578
|
+
});
|
|
1579
|
+
if (!ctx) return Comp(props);
|
|
1580
|
+
const c = sharedConfig.context;
|
|
1581
|
+
setHydrateContext(ctx);
|
|
1582
|
+
const r = Comp(props);
|
|
1583
|
+
setHydrateContext(c);
|
|
1584
|
+
return r;
|
|
1585
|
+
})
|
|
1586
|
+
);
|
|
1452
1587
|
};
|
|
1453
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1588
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1454
1589
|
return wrap;
|
|
1455
1590
|
}
|
|
1456
1591
|
let counter = 0;
|
|
@@ -1459,75 +1594,113 @@ function createUniqueId() {
|
|
|
1459
1594
|
return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
|
|
1460
1595
|
}
|
|
1461
1596
|
|
|
1462
|
-
const narrowedError = name =>
|
|
1597
|
+
const narrowedError = name =>
|
|
1598
|
+
`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.`;
|
|
1463
1599
|
function For(props) {
|
|
1464
1600
|
const fallback = "fallback" in props && {
|
|
1465
1601
|
fallback: () => props.fallback
|
|
1466
1602
|
};
|
|
1467
|
-
return createMemo(
|
|
1468
|
-
|
|
1469
|
-
|
|
1603
|
+
return createMemo(
|
|
1604
|
+
mapArray(() => props.each, props.children, fallback || undefined),
|
|
1605
|
+
undefined,
|
|
1606
|
+
{
|
|
1607
|
+
name: "value"
|
|
1608
|
+
}
|
|
1609
|
+
);
|
|
1470
1610
|
}
|
|
1471
1611
|
function Index(props) {
|
|
1472
1612
|
const fallback = "fallback" in props && {
|
|
1473
1613
|
fallback: () => props.fallback
|
|
1474
1614
|
};
|
|
1475
|
-
return createMemo(
|
|
1476
|
-
|
|
1477
|
-
|
|
1615
|
+
return createMemo(
|
|
1616
|
+
indexArray(() => props.each, props.children, fallback || undefined),
|
|
1617
|
+
undefined,
|
|
1618
|
+
{
|
|
1619
|
+
name: "value"
|
|
1620
|
+
}
|
|
1621
|
+
);
|
|
1478
1622
|
}
|
|
1479
1623
|
function Show(props) {
|
|
1480
1624
|
const keyed = props.keyed;
|
|
1481
1625
|
const condition = createMemo(() => props.when, undefined, {
|
|
1482
|
-
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1626
|
+
equals: (a, b) => (keyed ? a === b : !a === !b),
|
|
1483
1627
|
name: "condition"
|
|
1484
|
-
}
|
|
1485
|
-
return createMemo(
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1628
|
+
});
|
|
1629
|
+
return createMemo(
|
|
1630
|
+
() => {
|
|
1631
|
+
const c = condition();
|
|
1632
|
+
if (c) {
|
|
1633
|
+
const child = props.children;
|
|
1634
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1635
|
+
return fn
|
|
1636
|
+
? untrack(() =>
|
|
1637
|
+
child(
|
|
1638
|
+
keyed
|
|
1639
|
+
? c
|
|
1640
|
+
: () => {
|
|
1641
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1642
|
+
return props.when;
|
|
1643
|
+
}
|
|
1644
|
+
)
|
|
1645
|
+
)
|
|
1646
|
+
: child;
|
|
1647
|
+
}
|
|
1648
|
+
return props.fallback;
|
|
1649
|
+
},
|
|
1650
|
+
undefined,
|
|
1651
|
+
{
|
|
1652
|
+
name: "value"
|
|
1494
1653
|
}
|
|
1495
|
-
|
|
1496
|
-
}, undefined, {
|
|
1497
|
-
name: "value"
|
|
1498
|
-
} );
|
|
1654
|
+
);
|
|
1499
1655
|
}
|
|
1500
1656
|
function Switch(props) {
|
|
1501
1657
|
let keyed = false;
|
|
1502
|
-
const equals = (a, b) =>
|
|
1658
|
+
const equals = (a, b) =>
|
|
1659
|
+
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1503
1660
|
const conditions = children(() => props.children),
|
|
1504
|
-
evalConditions = createMemo(
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1661
|
+
evalConditions = createMemo(
|
|
1662
|
+
() => {
|
|
1663
|
+
let conds = conditions();
|
|
1664
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1665
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1666
|
+
const c = conds[i].when;
|
|
1667
|
+
if (c) {
|
|
1668
|
+
keyed = !!conds[i].keyed;
|
|
1669
|
+
return [i, c, conds[i]];
|
|
1670
|
+
}
|
|
1512
1671
|
}
|
|
1672
|
+
return [-1];
|
|
1673
|
+
},
|
|
1674
|
+
undefined,
|
|
1675
|
+
{
|
|
1676
|
+
equals,
|
|
1677
|
+
name: "eval conditions"
|
|
1513
1678
|
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1679
|
+
);
|
|
1680
|
+
return createMemo(
|
|
1681
|
+
() => {
|
|
1682
|
+
const [index, when, cond] = evalConditions();
|
|
1683
|
+
if (index < 0) return props.fallback;
|
|
1684
|
+
const c = cond.children;
|
|
1685
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1686
|
+
return fn
|
|
1687
|
+
? untrack(() =>
|
|
1688
|
+
c(
|
|
1689
|
+
keyed
|
|
1690
|
+
? when
|
|
1691
|
+
: () => {
|
|
1692
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1693
|
+
return cond.when;
|
|
1694
|
+
}
|
|
1695
|
+
)
|
|
1696
|
+
)
|
|
1697
|
+
: c;
|
|
1698
|
+
},
|
|
1699
|
+
undefined,
|
|
1700
|
+
{
|
|
1701
|
+
name: "value"
|
|
1702
|
+
}
|
|
1703
|
+
);
|
|
1531
1704
|
}
|
|
1532
1705
|
function Match(props) {
|
|
1533
1706
|
return props;
|
|
@@ -1538,27 +1711,33 @@ function resetErrorBoundaries() {
|
|
|
1538
1711
|
}
|
|
1539
1712
|
function ErrorBoundary(props) {
|
|
1540
1713
|
let err;
|
|
1541
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1714
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1715
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1542
1716
|
const [errored, setErrored] = createSignal(err, {
|
|
1543
1717
|
name: "errored"
|
|
1544
|
-
}
|
|
1718
|
+
});
|
|
1545
1719
|
Errors || (Errors = new Set());
|
|
1546
1720
|
Errors.add(setErrored);
|
|
1547
1721
|
onCleanup(() => Errors.delete(setErrored));
|
|
1548
|
-
return createMemo(
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1722
|
+
return createMemo(
|
|
1723
|
+
() => {
|
|
1724
|
+
let e;
|
|
1725
|
+
if ((e = errored())) {
|
|
1726
|
+
const f = props.fallback;
|
|
1727
|
+
if (typeof f !== "function" || f.length == 0) console.error(e);
|
|
1728
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1729
|
+
}
|
|
1730
|
+
return catchError(() => props.children, setErrored);
|
|
1731
|
+
},
|
|
1732
|
+
undefined,
|
|
1733
|
+
{
|
|
1734
|
+
name: "value"
|
|
1554
1735
|
}
|
|
1555
|
-
|
|
1556
|
-
}, undefined, {
|
|
1557
|
-
name: "value"
|
|
1558
|
-
} );
|
|
1736
|
+
);
|
|
1559
1737
|
}
|
|
1560
1738
|
|
|
1561
|
-
const suspenseListEquals = (a, b) =>
|
|
1739
|
+
const suspenseListEquals = (a, b) =>
|
|
1740
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1562
1741
|
const SuspenseListContext = createContext();
|
|
1563
1742
|
function SuspenseList(props) {
|
|
1564
1743
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1570,51 +1749,51 @@ function SuspenseList(props) {
|
|
|
1570
1749
|
if (listContext) {
|
|
1571
1750
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1572
1751
|
}
|
|
1573
|
-
const resolved = createMemo(
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
showContent = true,
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
const res = reg.map(() => ({
|
|
1585
|
-
showContent: all && showContent,
|
|
1586
|
-
showFallback
|
|
1587
|
-
}));
|
|
1588
|
-
res.inFallback = !all;
|
|
1589
|
-
return res;
|
|
1590
|
-
}
|
|
1591
|
-
let stop = false;
|
|
1592
|
-
let inFallback = prev.inFallback;
|
|
1593
|
-
const res = [];
|
|
1594
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1595
|
-
const n = reverse ? len - i - 1 : i,
|
|
1596
|
-
s = reg[n]();
|
|
1597
|
-
if (!stop && !s) {
|
|
1598
|
-
res[n] = {
|
|
1599
|
-
showContent,
|
|
1752
|
+
const resolved = createMemo(
|
|
1753
|
+
prev => {
|
|
1754
|
+
const reveal = props.revealOrder,
|
|
1755
|
+
tail = props.tail,
|
|
1756
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1757
|
+
reg = registry(),
|
|
1758
|
+
reverse = reveal === "backwards";
|
|
1759
|
+
if (reveal === "together") {
|
|
1760
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1761
|
+
const res = reg.map(() => ({
|
|
1762
|
+
showContent: all && showContent,
|
|
1600
1763
|
showFallback
|
|
1601
|
-
};
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
if (next) inFallback = true;
|
|
1605
|
-
res[n] = {
|
|
1606
|
-
showContent: next,
|
|
1607
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1608
|
-
};
|
|
1609
|
-
stop = true;
|
|
1764
|
+
}));
|
|
1765
|
+
res.inFallback = !all;
|
|
1766
|
+
return res;
|
|
1610
1767
|
}
|
|
1768
|
+
let stop = false;
|
|
1769
|
+
let inFallback = prev.inFallback;
|
|
1770
|
+
const res = [];
|
|
1771
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1772
|
+
const n = reverse ? len - i - 1 : i,
|
|
1773
|
+
s = reg[n]();
|
|
1774
|
+
if (!stop && !s) {
|
|
1775
|
+
res[n] = {
|
|
1776
|
+
showContent,
|
|
1777
|
+
showFallback
|
|
1778
|
+
};
|
|
1779
|
+
} else {
|
|
1780
|
+
const next = !stop;
|
|
1781
|
+
if (next) inFallback = true;
|
|
1782
|
+
res[n] = {
|
|
1783
|
+
showContent: next,
|
|
1784
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1785
|
+
};
|
|
1786
|
+
stop = true;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
if (!stop) inFallback = false;
|
|
1790
|
+
res.inFallback = inFallback;
|
|
1791
|
+
return res;
|
|
1792
|
+
},
|
|
1793
|
+
{
|
|
1794
|
+
inFallback: false
|
|
1611
1795
|
}
|
|
1612
|
-
|
|
1613
|
-
res.inFallback = inFallback;
|
|
1614
|
-
return res;
|
|
1615
|
-
}, {
|
|
1616
|
-
inFallback: false
|
|
1617
|
-
});
|
|
1796
|
+
);
|
|
1618
1797
|
setWrapper(() => resolved);
|
|
1619
1798
|
return createComponent(SuspenseListContext.Provider, {
|
|
1620
1799
|
value: {
|
|
@@ -1689,17 +1868,14 @@ function Suspense(props) {
|
|
|
1689
1868
|
ctx = sharedConfig.context;
|
|
1690
1869
|
if (flicker) {
|
|
1691
1870
|
flicker();
|
|
1692
|
-
return flicker = undefined;
|
|
1871
|
+
return (flicker = undefined);
|
|
1693
1872
|
}
|
|
1694
1873
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1695
1874
|
const rendered = createMemo(() => props.children);
|
|
1696
1875
|
return createMemo(prev => {
|
|
1697
1876
|
const inFallback = store.inFallback(),
|
|
1698
|
-
{
|
|
1699
|
-
|
|
1700
|
-
showFallback = true
|
|
1701
|
-
} = show ? show() : {};
|
|
1702
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1877
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1878
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1703
1879
|
store.resolved = true;
|
|
1704
1880
|
dispose && dispose();
|
|
1705
1881
|
dispose = ctx = p = undefined;
|
|
@@ -1729,9 +1905,68 @@ const DEV = {
|
|
|
1729
1905
|
hooks: DevHooks,
|
|
1730
1906
|
writeSignal,
|
|
1731
1907
|
registerGraph
|
|
1732
|
-
}
|
|
1908
|
+
};
|
|
1733
1909
|
if (globalThis) {
|
|
1734
|
-
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1910
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1911
|
+
else
|
|
1912
|
+
console.warn(
|
|
1913
|
+
"You appear to have multiple instances of Solid. This can lead to unexpected behavior."
|
|
1914
|
+
);
|
|
1735
1915
|
}
|
|
1736
1916
|
|
|
1737
|
-
export {
|
|
1917
|
+
export {
|
|
1918
|
+
$DEVCOMP,
|
|
1919
|
+
$PROXY,
|
|
1920
|
+
$TRACK,
|
|
1921
|
+
DEV,
|
|
1922
|
+
ErrorBoundary,
|
|
1923
|
+
For,
|
|
1924
|
+
Index,
|
|
1925
|
+
Match,
|
|
1926
|
+
Show,
|
|
1927
|
+
Suspense,
|
|
1928
|
+
SuspenseList,
|
|
1929
|
+
Switch,
|
|
1930
|
+
batch,
|
|
1931
|
+
cancelCallback,
|
|
1932
|
+
catchError,
|
|
1933
|
+
children,
|
|
1934
|
+
createComponent,
|
|
1935
|
+
createComputed,
|
|
1936
|
+
createContext,
|
|
1937
|
+
createDeferred,
|
|
1938
|
+
createEffect,
|
|
1939
|
+
createMemo,
|
|
1940
|
+
createReaction,
|
|
1941
|
+
createRenderEffect,
|
|
1942
|
+
createResource,
|
|
1943
|
+
createRoot,
|
|
1944
|
+
createSelector,
|
|
1945
|
+
createSignal,
|
|
1946
|
+
createUniqueId,
|
|
1947
|
+
enableExternalSource,
|
|
1948
|
+
enableHydration,
|
|
1949
|
+
enableScheduling,
|
|
1950
|
+
equalFn,
|
|
1951
|
+
from,
|
|
1952
|
+
getListener,
|
|
1953
|
+
getOwner,
|
|
1954
|
+
indexArray,
|
|
1955
|
+
lazy,
|
|
1956
|
+
mapArray,
|
|
1957
|
+
mergeProps,
|
|
1958
|
+
observable,
|
|
1959
|
+
on,
|
|
1960
|
+
onCleanup,
|
|
1961
|
+
onError,
|
|
1962
|
+
onMount,
|
|
1963
|
+
requestCallback,
|
|
1964
|
+
resetErrorBoundaries,
|
|
1965
|
+
runWithOwner,
|
|
1966
|
+
sharedConfig,
|
|
1967
|
+
splitProps,
|
|
1968
|
+
startTransition,
|
|
1969
|
+
untrack,
|
|
1970
|
+
useContext,
|
|
1971
|
+
useTransition
|
|
1972
|
+
};
|