solid-js 1.7.8 → 1.7.9
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 +534 -296
- package/dist/server.js +175 -77
- package/dist/solid.js +461 -254
- package/h/dist/h.cjs +2 -2
- package/h/dist/h.js +36 -10
- 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 +3 -0
- package/h/types/hyperscript.d.ts +11 -11
- package/h/types/index.d.ts +3 -2
- package/html/dist/html.cjs +2 -2
- package/html/dist/html.js +218 -96
- package/html/types/index.d.ts +3 -2
- package/html/types/lit.d.ts +45 -31
- package/package.json +1 -1
- package/store/dist/dev.cjs +34 -32
- package/store/dist/dev.js +141 -67
- package/store/dist/server.js +19 -8
- package/store/dist/store.cjs +34 -32
- package/store/dist/store.js +132 -64
- 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 +217 -63
- package/types/index.d.ts +69 -9
- package/types/jsx.d.ts +3 -0
- 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 +227 -136
- 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 +12 -12
- package/types/server/index.d.ts +55 -2
- package/types/server/reactive.d.ts +67 -40
- package/types/server/rendering.d.ts +171 -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 +610 -79
- package/web/dist/server.js +176 -77
- package/web/dist/web.js +610 -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,25 +161,30 @@ 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
|
-
root = unowned
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
169
|
+
root = unowned
|
|
170
|
+
? {
|
|
171
|
+
owned: null,
|
|
172
|
+
cleanups: null,
|
|
173
|
+
context: null,
|
|
174
|
+
owner: null
|
|
175
|
+
}
|
|
176
|
+
: {
|
|
177
|
+
owned: null,
|
|
178
|
+
cleanups: null,
|
|
179
|
+
context: null,
|
|
180
|
+
owner: detachedOwner === undefined ? owner : detachedOwner
|
|
181
|
+
},
|
|
182
|
+
updateFn = unowned
|
|
183
|
+
? () =>
|
|
184
|
+
fn(() => {
|
|
185
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
186
|
+
})
|
|
187
|
+
: () => fn(() => untrack(() => cleanNode(root)));
|
|
181
188
|
DevHooks.afterCreateOwner && DevHooks.afterCreateOwner(root);
|
|
182
189
|
Owner = root;
|
|
183
190
|
Listener = null;
|
|
@@ -202,23 +209,26 @@ function createSignal(value, options) {
|
|
|
202
209
|
}
|
|
203
210
|
const setter = value => {
|
|
204
211
|
if (typeof value === "function") {
|
|
205
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
212
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
213
|
+
else value = value(s.value);
|
|
206
214
|
}
|
|
207
215
|
return writeSignal(s, value);
|
|
208
216
|
};
|
|
209
217
|
return [readSignal.bind(s), setter];
|
|
210
218
|
}
|
|
211
219
|
function createComputed(fn, value, options) {
|
|
212
|
-
const c = createComputation(fn, value, true, STALE, options
|
|
213
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
220
|
+
const c = createComputation(fn, value, true, STALE, options);
|
|
221
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
222
|
+
else updateComputation(c);
|
|
214
223
|
}
|
|
215
224
|
function createRenderEffect(fn, value, options) {
|
|
216
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
217
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
225
|
+
const c = createComputation(fn, value, false, STALE, options);
|
|
226
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
227
|
+
else updateComputation(c);
|
|
218
228
|
}
|
|
219
229
|
function createEffect(fn, value, options) {
|
|
220
230
|
runEffects = runUserEffects;
|
|
221
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
231
|
+
const c = createComputation(fn, value, false, STALE, options),
|
|
222
232
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
223
233
|
if (s) c.suspense = s;
|
|
224
234
|
if (!options || !options.render) c.user = true;
|
|
@@ -226,10 +236,16 @@ function createEffect(fn, value, options) {
|
|
|
226
236
|
}
|
|
227
237
|
function createReaction(onInvalidate, options) {
|
|
228
238
|
let fn;
|
|
229
|
-
const c = createComputation(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
239
|
+
const c = createComputation(
|
|
240
|
+
() => {
|
|
241
|
+
fn ? fn() : untrack(onInvalidate);
|
|
242
|
+
fn = undefined;
|
|
243
|
+
},
|
|
244
|
+
undefined,
|
|
245
|
+
false,
|
|
246
|
+
0,
|
|
247
|
+
options
|
|
248
|
+
),
|
|
233
249
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
234
250
|
if (s) c.suspense = s;
|
|
235
251
|
c.user = true;
|
|
@@ -240,7 +256,7 @@ function createReaction(onInvalidate, options) {
|
|
|
240
256
|
}
|
|
241
257
|
function createMemo(fn, value, options) {
|
|
242
258
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
243
|
-
const c = createComputation(fn, value, true, 0, options
|
|
259
|
+
const c = createComputation(fn, value, true, 0, options);
|
|
244
260
|
c.observers = null;
|
|
245
261
|
c.observerSlots = null;
|
|
246
262
|
c.comparator = options.equals || undefined;
|
|
@@ -254,7 +270,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
254
270
|
let source;
|
|
255
271
|
let fetcher;
|
|
256
272
|
let options;
|
|
257
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
273
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
258
274
|
source = true;
|
|
259
275
|
fetcher = pSource;
|
|
260
276
|
options = pFetcher || {};
|
|
@@ -268,7 +284,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
268
284
|
id = null,
|
|
269
285
|
loadedUnderTransition = false,
|
|
270
286
|
scheduled = false,
|
|
271
|
-
resolved =
|
|
287
|
+
resolved = "initialValue" in options,
|
|
272
288
|
dynamic = typeof source === "function" && createMemo(source);
|
|
273
289
|
const contexts = new Set(),
|
|
274
290
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -280,15 +296,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
280
296
|
if (sharedConfig.context) {
|
|
281
297
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
282
298
|
let v;
|
|
283
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
299
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
300
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
284
301
|
}
|
|
285
302
|
function loadEnd(p, v, error, key) {
|
|
286
303
|
if (pr === p) {
|
|
287
304
|
pr = null;
|
|
288
305
|
key !== undefined && (resolved = true);
|
|
289
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
290
|
-
|
|
291
|
-
|
|
306
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
307
|
+
queueMicrotask(() =>
|
|
308
|
+
options.onHydrated(key, {
|
|
309
|
+
value: v
|
|
310
|
+
})
|
|
311
|
+
);
|
|
292
312
|
initP = NO_INIT;
|
|
293
313
|
if (Transition && p && loadedUnderTransition) {
|
|
294
314
|
Transition.promises.delete(p);
|
|
@@ -319,7 +339,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
319
339
|
createComputed(() => {
|
|
320
340
|
track();
|
|
321
341
|
if (pr) {
|
|
322
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
342
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
343
|
+
else if (!contexts.has(c)) {
|
|
323
344
|
c.increment();
|
|
324
345
|
contexts.add(c);
|
|
325
346
|
}
|
|
@@ -338,22 +359,30 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
338
359
|
return;
|
|
339
360
|
}
|
|
340
361
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
341
|
-
const p =
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
362
|
+
const p =
|
|
363
|
+
initP !== NO_INIT
|
|
364
|
+
? initP
|
|
365
|
+
: untrack(() =>
|
|
366
|
+
fetcher(lookup, {
|
|
367
|
+
value: value(),
|
|
368
|
+
refetching
|
|
369
|
+
})
|
|
370
|
+
);
|
|
345
371
|
if (typeof p !== "object" || !(p && "then" in p)) {
|
|
346
372
|
loadEnd(pr, p, undefined, lookup);
|
|
347
373
|
return p;
|
|
348
374
|
}
|
|
349
375
|
pr = p;
|
|
350
376
|
scheduled = true;
|
|
351
|
-
queueMicrotask(() => scheduled = false);
|
|
377
|
+
queueMicrotask(() => (scheduled = false));
|
|
352
378
|
runUpdates(() => {
|
|
353
379
|
setState(resolved ? "refreshing" : "pending");
|
|
354
380
|
trigger();
|
|
355
381
|
}, false);
|
|
356
|
-
return p.then(
|
|
382
|
+
return p.then(
|
|
383
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
384
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
385
|
+
);
|
|
357
386
|
}
|
|
358
387
|
Object.defineProperties(read, {
|
|
359
388
|
state: {
|
|
@@ -377,21 +406,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
377
406
|
}
|
|
378
407
|
}
|
|
379
408
|
});
|
|
380
|
-
if (dynamic) createComputed(() => load(false));
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
409
|
+
if (dynamic) createComputed(() => load(false));
|
|
410
|
+
else load(false);
|
|
411
|
+
return [
|
|
412
|
+
read,
|
|
413
|
+
{
|
|
414
|
+
refetch: load,
|
|
415
|
+
mutate: setValue
|
|
416
|
+
}
|
|
417
|
+
];
|
|
385
418
|
}
|
|
386
419
|
function createDeferred(source, options) {
|
|
387
420
|
let t,
|
|
388
421
|
timeout = options ? options.timeoutMs : undefined;
|
|
389
|
-
const node = createComputation(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
422
|
+
const node = createComputation(
|
|
423
|
+
() => {
|
|
424
|
+
if (!t || !t.fn)
|
|
425
|
+
t = requestCallback(
|
|
426
|
+
() => setDeferred(() => node.value),
|
|
427
|
+
timeout !== undefined
|
|
428
|
+
? {
|
|
429
|
+
timeout
|
|
430
|
+
}
|
|
431
|
+
: undefined
|
|
432
|
+
);
|
|
433
|
+
return source();
|
|
434
|
+
},
|
|
435
|
+
undefined,
|
|
436
|
+
true
|
|
437
|
+
);
|
|
395
438
|
const [deferred, setDeferred] = createSignal(node.value, options);
|
|
396
439
|
updateComputation(node);
|
|
397
440
|
setDeferred(() => node.value);
|
|
@@ -399,28 +442,40 @@ function createDeferred(source, options) {
|
|
|
399
442
|
}
|
|
400
443
|
function createSelector(source, fn = equalFn, options) {
|
|
401
444
|
const subs = new Map();
|
|
402
|
-
const node = createComputation(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
for (const
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
445
|
+
const node = createComputation(
|
|
446
|
+
p => {
|
|
447
|
+
const v = source();
|
|
448
|
+
for (const [key, val] of subs.entries())
|
|
449
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
450
|
+
for (const c of val.values()) {
|
|
451
|
+
c.state = STALE;
|
|
452
|
+
if (c.pure) Updates.push(c);
|
|
453
|
+
else Effects.push(c);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return v;
|
|
457
|
+
},
|
|
458
|
+
undefined,
|
|
459
|
+
true,
|
|
460
|
+
STALE,
|
|
461
|
+
options
|
|
462
|
+
);
|
|
412
463
|
updateComputation(node);
|
|
413
464
|
return key => {
|
|
414
465
|
const listener = Listener;
|
|
415
466
|
if (listener) {
|
|
416
467
|
let l;
|
|
417
|
-
if (l = subs.get(key)) l.add(listener);
|
|
468
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
469
|
+
else subs.set(key, (l = new Set([listener])));
|
|
418
470
|
onCleanup(() => {
|
|
419
471
|
l.delete(listener);
|
|
420
472
|
!l.size && subs.delete(key);
|
|
421
473
|
});
|
|
422
474
|
}
|
|
423
|
-
return fn(
|
|
475
|
+
return fn(
|
|
476
|
+
key,
|
|
477
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
478
|
+
);
|
|
424
479
|
};
|
|
425
480
|
}
|
|
426
481
|
function batch(fn) {
|
|
@@ -459,7 +514,10 @@ function onMount(fn) {
|
|
|
459
514
|
createEffect(() => untrack(fn));
|
|
460
515
|
}
|
|
461
516
|
function onCleanup(fn) {
|
|
462
|
-
if (Owner === null)
|
|
517
|
+
if (Owner === null)
|
|
518
|
+
console.warn("cleanups created outside a `createRoot` or `render` will never be run");
|
|
519
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
520
|
+
else Owner.cleanups.push(fn);
|
|
463
521
|
return fn;
|
|
464
522
|
}
|
|
465
523
|
function catchError(fn, handler) {
|
|
@@ -479,9 +537,14 @@ function catchError(fn, handler) {
|
|
|
479
537
|
}
|
|
480
538
|
function onError(fn) {
|
|
481
539
|
ERROR || (ERROR = Symbol("error"));
|
|
482
|
-
if (Owner === null)
|
|
483
|
-
|
|
484
|
-
|
|
540
|
+
if (Owner === null)
|
|
541
|
+
console.warn("error handlers created outside a `createRoot` or `render` will never be run");
|
|
542
|
+
else if (Owner.context === null)
|
|
543
|
+
Owner.context = {
|
|
544
|
+
[ERROR]: [fn]
|
|
545
|
+
};
|
|
546
|
+
else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];
|
|
547
|
+
else Owner.context[ERROR].push(fn);
|
|
485
548
|
}
|
|
486
549
|
function getListener() {
|
|
487
550
|
return Listener;
|
|
@@ -518,15 +581,17 @@ function startTransition(fn) {
|
|
|
518
581
|
Owner = o;
|
|
519
582
|
let t;
|
|
520
583
|
if (Scheduler || SuspenseContext) {
|
|
521
|
-
t =
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
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)));
|
|
530
595
|
t.running = true;
|
|
531
596
|
}
|
|
532
597
|
runUpdates(fn, false);
|
|
@@ -542,12 +607,18 @@ function resumeEffects(e) {
|
|
|
542
607
|
e.length = 0;
|
|
543
608
|
}
|
|
544
609
|
function devComponent(Comp, props) {
|
|
545
|
-
const c = createComputation(
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
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
|
+
);
|
|
551
622
|
c.props = props;
|
|
552
623
|
c.observers = null;
|
|
553
624
|
c.observerSlots = null;
|
|
@@ -558,7 +629,8 @@ function devComponent(Comp, props) {
|
|
|
558
629
|
}
|
|
559
630
|
function registerGraph(value) {
|
|
560
631
|
if (!Owner) return;
|
|
561
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
632
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
633
|
+
else Owner.sourceMap = [value];
|
|
562
634
|
value.graph = Owner;
|
|
563
635
|
}
|
|
564
636
|
function createContext(defaultValue, options) {
|
|
@@ -577,7 +649,7 @@ function children(fn) {
|
|
|
577
649
|
const children = createMemo(fn);
|
|
578
650
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
579
651
|
name: "children"
|
|
580
|
-
})
|
|
652
|
+
});
|
|
581
653
|
memo.toArray = () => {
|
|
582
654
|
const c = memo();
|
|
583
655
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -609,7 +681,8 @@ function enableExternalSource(factory) {
|
|
|
609
681
|
function readSignal() {
|
|
610
682
|
const runningTransition = Transition && Transition.running;
|
|
611
683
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
612
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
684
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
685
|
+
else {
|
|
613
686
|
const updates = Updates;
|
|
614
687
|
Updates = null;
|
|
615
688
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -637,11 +710,12 @@ function readSignal() {
|
|
|
637
710
|
return this.value;
|
|
638
711
|
}
|
|
639
712
|
function writeSignal(node, value, isComp) {
|
|
640
|
-
let current =
|
|
713
|
+
let current =
|
|
714
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
641
715
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
642
716
|
if (Transition) {
|
|
643
717
|
const TransitionRunning = Transition.running;
|
|
644
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
718
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
645
719
|
Transition.sources.add(node);
|
|
646
720
|
node.tValue = value;
|
|
647
721
|
}
|
|
@@ -654,10 +728,12 @@ function writeSignal(node, value, isComp) {
|
|
|
654
728
|
const TransitionRunning = Transition && Transition.running;
|
|
655
729
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
656
730
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
657
|
-
if (o.pure) Updates.push(o);
|
|
731
|
+
if (o.pure) Updates.push(o);
|
|
732
|
+
else Effects.push(o);
|
|
658
733
|
if (o.observers) markDownstream(o);
|
|
659
734
|
}
|
|
660
|
-
if (!TransitionRunning) o.state = STALE;
|
|
735
|
+
if (!TransitionRunning) o.state = STALE;
|
|
736
|
+
else o.tState = STALE;
|
|
661
737
|
}
|
|
662
738
|
if (Updates.length > 10e5) {
|
|
663
739
|
Updates = [];
|
|
@@ -676,7 +752,11 @@ function updateComputation(node) {
|
|
|
676
752
|
listener = Listener,
|
|
677
753
|
time = ExecCount;
|
|
678
754
|
Listener = Owner = node;
|
|
679
|
-
runComputation(
|
|
755
|
+
runComputation(
|
|
756
|
+
node,
|
|
757
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
758
|
+
time
|
|
759
|
+
);
|
|
680
760
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
681
761
|
queueMicrotask(() => {
|
|
682
762
|
runUpdates(() => {
|
|
@@ -737,11 +817,15 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
737
817
|
c.state = 0;
|
|
738
818
|
c.tState = state;
|
|
739
819
|
}
|
|
740
|
-
if (Owner === null)
|
|
820
|
+
if (Owner === null)
|
|
821
|
+
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
822
|
+
else if (Owner !== UNOWNED) {
|
|
741
823
|
if (Transition && Transition.running && Owner.pure) {
|
|
742
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
824
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
825
|
+
else Owner.tOwned.push(c);
|
|
743
826
|
} else {
|
|
744
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
827
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
828
|
+
else Owner.owned.push(c);
|
|
745
829
|
}
|
|
746
830
|
}
|
|
747
831
|
if (options && options.name) c.name = options.name;
|
|
@@ -794,7 +878,8 @@ function runUpdates(fn, init) {
|
|
|
794
878
|
if (Updates) return fn();
|
|
795
879
|
let wait = false;
|
|
796
880
|
if (!init) Updates = [];
|
|
797
|
-
if (Effects) wait = true;
|
|
881
|
+
if (Effects) wait = true;
|
|
882
|
+
else Effects = [];
|
|
798
883
|
ExecCount++;
|
|
799
884
|
try {
|
|
800
885
|
const res = fn();
|
|
@@ -808,7 +893,8 @@ function runUpdates(fn, init) {
|
|
|
808
893
|
}
|
|
809
894
|
function completeUpdates(wait) {
|
|
810
895
|
if (Updates) {
|
|
811
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
896
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
897
|
+
else runQueue(Updates);
|
|
812
898
|
Updates = null;
|
|
813
899
|
}
|
|
814
900
|
if (wait) return;
|
|
@@ -848,7 +934,8 @@ function completeUpdates(wait) {
|
|
|
848
934
|
}
|
|
849
935
|
const e = Effects;
|
|
850
936
|
Effects = null;
|
|
851
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
937
|
+
if (e.length) runUpdates(() => runEffects(e), false);
|
|
938
|
+
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
852
939
|
if (res) res();
|
|
853
940
|
}
|
|
854
941
|
function runQueue(queue) {
|
|
@@ -876,7 +963,8 @@ function runUserEffects(queue) {
|
|
|
876
963
|
userLength = 0;
|
|
877
964
|
for (i = 0; i < queue.length; i++) {
|
|
878
965
|
const e = queue[i];
|
|
879
|
-
if (!e.user) runTop(e);
|
|
966
|
+
if (!e.user) runTop(e);
|
|
967
|
+
else queue[userLength++] = e;
|
|
880
968
|
}
|
|
881
969
|
if (sharedConfig.context) {
|
|
882
970
|
if (sharedConfig.count) {
|
|
@@ -894,13 +982,15 @@ function runUserEffects(queue) {
|
|
|
894
982
|
}
|
|
895
983
|
function lookUpstream(node, ignore) {
|
|
896
984
|
const runningTransition = Transition && Transition.running;
|
|
897
|
-
if (runningTransition) node.tState = 0;
|
|
985
|
+
if (runningTransition) node.tState = 0;
|
|
986
|
+
else node.state = 0;
|
|
898
987
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
899
988
|
const source = node.sources[i];
|
|
900
989
|
if (source.sources) {
|
|
901
990
|
const state = runningTransition ? source.tState : source.state;
|
|
902
991
|
if (state === STALE) {
|
|
903
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
992
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
993
|
+
runTop(source);
|
|
904
994
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
905
995
|
}
|
|
906
996
|
}
|
|
@@ -910,8 +1000,10 @@ function markDownstream(node) {
|
|
|
910
1000
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
911
1001
|
const o = node.observers[i];
|
|
912
1002
|
if (runningTransition ? !o.tState : !o.state) {
|
|
913
|
-
if (runningTransition) o.tState = PENDING;
|
|
914
|
-
|
|
1003
|
+
if (runningTransition) o.tState = PENDING;
|
|
1004
|
+
else o.state = PENDING;
|
|
1005
|
+
if (o.pure) Updates.push(o);
|
|
1006
|
+
else Effects.push(o);
|
|
915
1007
|
o.observers && markDownstream(o);
|
|
916
1008
|
}
|
|
917
1009
|
}
|
|
@@ -948,7 +1040,8 @@ function cleanNode(node) {
|
|
|
948
1040
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
949
1041
|
node.cleanups = null;
|
|
950
1042
|
}
|
|
951
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1043
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1044
|
+
else node.state = 0;
|
|
952
1045
|
node.context = null;
|
|
953
1046
|
delete node.sourceMap;
|
|
954
1047
|
}
|
|
@@ -971,22 +1064,28 @@ function runErrors(err, fns, owner) {
|
|
|
971
1064
|
try {
|
|
972
1065
|
for (const f of fns) f(err);
|
|
973
1066
|
} catch (e) {
|
|
974
|
-
handleError(e, owner && owner.owner || null);
|
|
1067
|
+
handleError(e, (owner && owner.owner) || null);
|
|
975
1068
|
}
|
|
976
1069
|
}
|
|
977
1070
|
function handleError(err, owner = Owner) {
|
|
978
1071
|
const fns = ERROR && lookup(owner, ERROR);
|
|
979
1072
|
const error = castError(err);
|
|
980
1073
|
if (!fns) throw error;
|
|
981
|
-
if (Effects)
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1074
|
+
if (Effects)
|
|
1075
|
+
Effects.push({
|
|
1076
|
+
fn() {
|
|
1077
|
+
runErrors(error, fns, owner);
|
|
1078
|
+
},
|
|
1079
|
+
state: STALE
|
|
1080
|
+
});
|
|
1081
|
+
else runErrors(error, fns, owner);
|
|
987
1082
|
}
|
|
988
1083
|
function lookup(owner, key) {
|
|
989
|
-
return owner
|
|
1084
|
+
return owner
|
|
1085
|
+
? owner.context && owner.context[key] !== undefined
|
|
1086
|
+
? owner.context[key]
|
|
1087
|
+
: lookup(owner.owner, key)
|
|
1088
|
+
: undefined;
|
|
990
1089
|
}
|
|
991
1090
|
function resolveChildren(children) {
|
|
992
1091
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1003,12 +1102,17 @@ function resolveChildren(children) {
|
|
|
1003
1102
|
function createProvider(id, options) {
|
|
1004
1103
|
return function provider(props) {
|
|
1005
1104
|
let res;
|
|
1006
|
-
createRenderEffect(
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1105
|
+
createRenderEffect(
|
|
1106
|
+
() =>
|
|
1107
|
+
(res = untrack(() => {
|
|
1108
|
+
Owner.context = {
|
|
1109
|
+
[id]: props.value
|
|
1110
|
+
};
|
|
1111
|
+
return children(() => props.children);
|
|
1112
|
+
})),
|
|
1113
|
+
undefined,
|
|
1114
|
+
options
|
|
1115
|
+
);
|
|
1012
1116
|
return res;
|
|
1013
1117
|
};
|
|
1014
1118
|
}
|
|
@@ -1019,7 +1123,8 @@ function observable(input) {
|
|
|
1019
1123
|
if (!(observer instanceof Object) || observer == null) {
|
|
1020
1124
|
throw new TypeError("Expected the observer to be an object.");
|
|
1021
1125
|
}
|
|
1022
|
-
const handler =
|
|
1126
|
+
const handler =
|
|
1127
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1023
1128
|
if (!handler) {
|
|
1024
1129
|
return {
|
|
1025
1130
|
unsubscribe() {}
|
|
@@ -1050,7 +1155,7 @@ function from(producer) {
|
|
|
1050
1155
|
});
|
|
1051
1156
|
if ("subscribe" in producer) {
|
|
1052
1157
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1053
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1158
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1054
1159
|
} else {
|
|
1055
1160
|
const clean = producer(set);
|
|
1056
1161
|
onCleanup(clean);
|
|
@@ -1102,8 +1207,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1102
1207
|
});
|
|
1103
1208
|
len = 1;
|
|
1104
1209
|
}
|
|
1105
|
-
}
|
|
1106
|
-
else if (len === 0) {
|
|
1210
|
+
} else if (len === 0) {
|
|
1107
1211
|
mapped = new Array(newLen);
|
|
1108
1212
|
for (j = 0; j < newLen; j++) {
|
|
1109
1213
|
items[j] = newItems[j];
|
|
@@ -1114,8 +1218,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1114
1218
|
temp = new Array(newLen);
|
|
1115
1219
|
tempdisposers = new Array(newLen);
|
|
1116
1220
|
indexes && (tempIndexes = new Array(newLen));
|
|
1117
|
-
for (
|
|
1118
|
-
|
|
1221
|
+
for (
|
|
1222
|
+
start = 0, end = Math.min(len, newLen);
|
|
1223
|
+
start < end && items[start] === newItems[start];
|
|
1224
|
+
start++
|
|
1225
|
+
);
|
|
1226
|
+
for (
|
|
1227
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1228
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1229
|
+
end--, newEnd--
|
|
1230
|
+
) {
|
|
1119
1231
|
temp[newEnd] = mapped[end];
|
|
1120
1232
|
tempdisposers[newEnd] = disposers[end];
|
|
1121
1233
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1149,7 +1261,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1149
1261
|
}
|
|
1150
1262
|
} else mapped[j] = createRoot(mapper);
|
|
1151
1263
|
}
|
|
1152
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1264
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1153
1265
|
items = newItems.slice(0);
|
|
1154
1266
|
}
|
|
1155
1267
|
return mapped;
|
|
@@ -1159,7 +1271,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1159
1271
|
if (indexes) {
|
|
1160
1272
|
const [s, set] = createSignal(j, {
|
|
1161
1273
|
name: "index"
|
|
1162
|
-
})
|
|
1274
|
+
});
|
|
1163
1275
|
indexes[j] = set;
|
|
1164
1276
|
return mapFn(newItems[j], s);
|
|
1165
1277
|
}
|
|
@@ -1217,13 +1329,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1217
1329
|
}
|
|
1218
1330
|
len = signals.length = disposers.length = newItems.length;
|
|
1219
1331
|
items = newItems.slice(0);
|
|
1220
|
-
return mapped = mapped.slice(0, len);
|
|
1332
|
+
return (mapped = mapped.slice(0, len));
|
|
1221
1333
|
});
|
|
1222
1334
|
function mapper(disposer) {
|
|
1223
1335
|
disposers[i] = disposer;
|
|
1224
1336
|
const [s, set] = createSignal(newItems[i], {
|
|
1225
1337
|
name: "value"
|
|
1226
|
-
})
|
|
1338
|
+
});
|
|
1227
1339
|
signals[i] = set;
|
|
1228
1340
|
return mapFn(s, i);
|
|
1229
1341
|
}
|
|
@@ -1239,7 +1351,7 @@ function createComponent(Comp, props) {
|
|
|
1239
1351
|
if (sharedConfig.context) {
|
|
1240
1352
|
const c = sharedConfig.context;
|
|
1241
1353
|
setHydrateContext(nextHydrateContext());
|
|
1242
|
-
const r = devComponent(Comp, props || {})
|
|
1354
|
+
const r = devComponent(Comp, props || {});
|
|
1243
1355
|
setHydrateContext(c);
|
|
1244
1356
|
return r;
|
|
1245
1357
|
}
|
|
@@ -1288,29 +1400,33 @@ function mergeProps(...sources) {
|
|
|
1288
1400
|
let proxy = false;
|
|
1289
1401
|
for (let i = 0; i < sources.length; i++) {
|
|
1290
1402
|
const s = sources[i];
|
|
1291
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1292
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1403
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1404
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1293
1405
|
}
|
|
1294
1406
|
if (proxy) {
|
|
1295
|
-
return new Proxy(
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1407
|
+
return new Proxy(
|
|
1408
|
+
{
|
|
1409
|
+
get(property) {
|
|
1410
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1411
|
+
const v = resolveSource(sources[i])[property];
|
|
1412
|
+
if (v !== undefined) return v;
|
|
1413
|
+
}
|
|
1414
|
+
},
|
|
1415
|
+
has(property) {
|
|
1416
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1417
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1418
|
+
}
|
|
1419
|
+
return false;
|
|
1420
|
+
},
|
|
1421
|
+
keys() {
|
|
1422
|
+
const keys = [];
|
|
1423
|
+
for (let i = 0; i < sources.length; i++)
|
|
1424
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1425
|
+
return [...new Set(keys)];
|
|
1305
1426
|
}
|
|
1306
|
-
return false;
|
|
1307
1427
|
},
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1311
|
-
return [...new Set(keys)];
|
|
1312
|
-
}
|
|
1313
|
-
}, propTraps);
|
|
1428
|
+
propTraps
|
|
1429
|
+
);
|
|
1314
1430
|
}
|
|
1315
1431
|
const target = {};
|
|
1316
1432
|
const sourcesMap = {};
|
|
@@ -1329,7 +1445,7 @@ function mergeProps(...sources) {
|
|
|
1329
1445
|
Object.defineProperty(target, key, {
|
|
1330
1446
|
enumerable: true,
|
|
1331
1447
|
configurable: true,
|
|
1332
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1448
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1333
1449
|
});
|
|
1334
1450
|
} else {
|
|
1335
1451
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1353,47 +1469,60 @@ function splitProps(props, ...keys) {
|
|
|
1353
1469
|
if ($PROXY in props) {
|
|
1354
1470
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1355
1471
|
const res = keys.map(k => {
|
|
1356
|
-
return new Proxy(
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1472
|
+
return new Proxy(
|
|
1473
|
+
{
|
|
1474
|
+
get(property) {
|
|
1475
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1476
|
+
},
|
|
1477
|
+
has(property) {
|
|
1478
|
+
return k.includes(property) && property in props;
|
|
1479
|
+
},
|
|
1480
|
+
keys() {
|
|
1481
|
+
return k.filter(property => property in props);
|
|
1482
|
+
}
|
|
1362
1483
|
},
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
}
|
|
1366
|
-
}, propTraps);
|
|
1484
|
+
propTraps
|
|
1485
|
+
);
|
|
1367
1486
|
});
|
|
1368
|
-
res.push(
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1487
|
+
res.push(
|
|
1488
|
+
new Proxy(
|
|
1489
|
+
{
|
|
1490
|
+
get(property) {
|
|
1491
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1492
|
+
},
|
|
1493
|
+
has(property) {
|
|
1494
|
+
return blocked.has(property) ? false : property in props;
|
|
1495
|
+
},
|
|
1496
|
+
keys() {
|
|
1497
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1498
|
+
}
|
|
1499
|
+
},
|
|
1500
|
+
propTraps
|
|
1501
|
+
)
|
|
1502
|
+
);
|
|
1379
1503
|
return res;
|
|
1380
1504
|
}
|
|
1381
1505
|
const otherObject = {};
|
|
1382
1506
|
const objects = keys.map(() => ({}));
|
|
1383
1507
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1384
1508
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1385
|
-
const isDefaultDesc =
|
|
1509
|
+
const isDefaultDesc =
|
|
1510
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1386
1511
|
let blocked = false;
|
|
1387
1512
|
let objectIndex = 0;
|
|
1388
1513
|
for (const k of keys) {
|
|
1389
1514
|
if (k.includes(propName)) {
|
|
1390
1515
|
blocked = true;
|
|
1391
|
-
isDefaultDesc
|
|
1516
|
+
isDefaultDesc
|
|
1517
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1518
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1392
1519
|
}
|
|
1393
1520
|
++objectIndex;
|
|
1394
1521
|
}
|
|
1395
1522
|
if (!blocked) {
|
|
1396
|
-
isDefaultDesc
|
|
1523
|
+
isDefaultDesc
|
|
1524
|
+
? (otherObject[propName] = desc.value)
|
|
1525
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1397
1526
|
}
|
|
1398
1527
|
}
|
|
1399
1528
|
return [...objects, otherObject];
|
|
@@ -1419,19 +1548,24 @@ function lazy(fn) {
|
|
|
1419
1548
|
comp = s;
|
|
1420
1549
|
}
|
|
1421
1550
|
let Comp;
|
|
1422
|
-
return createMemo(
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1551
|
+
return createMemo(
|
|
1552
|
+
() =>
|
|
1553
|
+
(Comp = comp()) &&
|
|
1554
|
+
untrack(() => {
|
|
1555
|
+
if (true)
|
|
1556
|
+
Object.assign(Comp, {
|
|
1557
|
+
[$DEVCOMP]: true
|
|
1558
|
+
});
|
|
1559
|
+
if (!ctx) return Comp(props);
|
|
1560
|
+
const c = sharedConfig.context;
|
|
1561
|
+
setHydrateContext(ctx);
|
|
1562
|
+
const r = Comp(props);
|
|
1563
|
+
setHydrateContext(c);
|
|
1564
|
+
return r;
|
|
1565
|
+
})
|
|
1566
|
+
);
|
|
1433
1567
|
};
|
|
1434
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1568
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1435
1569
|
return wrap;
|
|
1436
1570
|
}
|
|
1437
1571
|
let counter = 0;
|
|
@@ -1440,75 +1574,113 @@ function createUniqueId() {
|
|
|
1440
1574
|
return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
|
|
1441
1575
|
}
|
|
1442
1576
|
|
|
1443
|
-
const narrowedError = name =>
|
|
1577
|
+
const narrowedError = name =>
|
|
1578
|
+
`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.`;
|
|
1444
1579
|
function For(props) {
|
|
1445
1580
|
const fallback = "fallback" in props && {
|
|
1446
1581
|
fallback: () => props.fallback
|
|
1447
1582
|
};
|
|
1448
|
-
return createMemo(
|
|
1449
|
-
|
|
1450
|
-
|
|
1583
|
+
return createMemo(
|
|
1584
|
+
mapArray(() => props.each, props.children, fallback || undefined),
|
|
1585
|
+
undefined,
|
|
1586
|
+
{
|
|
1587
|
+
name: "value"
|
|
1588
|
+
}
|
|
1589
|
+
);
|
|
1451
1590
|
}
|
|
1452
1591
|
function Index(props) {
|
|
1453
1592
|
const fallback = "fallback" in props && {
|
|
1454
1593
|
fallback: () => props.fallback
|
|
1455
1594
|
};
|
|
1456
|
-
return createMemo(
|
|
1457
|
-
|
|
1458
|
-
|
|
1595
|
+
return createMemo(
|
|
1596
|
+
indexArray(() => props.each, props.children, fallback || undefined),
|
|
1597
|
+
undefined,
|
|
1598
|
+
{
|
|
1599
|
+
name: "value"
|
|
1600
|
+
}
|
|
1601
|
+
);
|
|
1459
1602
|
}
|
|
1460
1603
|
function Show(props) {
|
|
1461
1604
|
const keyed = props.keyed;
|
|
1462
1605
|
const condition = createMemo(() => props.when, undefined, {
|
|
1463
|
-
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1606
|
+
equals: (a, b) => (keyed ? a === b : !a === !b),
|
|
1464
1607
|
name: "condition"
|
|
1465
|
-
}
|
|
1466
|
-
return createMemo(
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1608
|
+
});
|
|
1609
|
+
return createMemo(
|
|
1610
|
+
() => {
|
|
1611
|
+
const c = condition();
|
|
1612
|
+
if (c) {
|
|
1613
|
+
const child = props.children;
|
|
1614
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1615
|
+
return fn
|
|
1616
|
+
? untrack(() =>
|
|
1617
|
+
child(
|
|
1618
|
+
keyed
|
|
1619
|
+
? c
|
|
1620
|
+
: () => {
|
|
1621
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1622
|
+
return props.when;
|
|
1623
|
+
}
|
|
1624
|
+
)
|
|
1625
|
+
)
|
|
1626
|
+
: child;
|
|
1627
|
+
}
|
|
1628
|
+
return props.fallback;
|
|
1629
|
+
},
|
|
1630
|
+
undefined,
|
|
1631
|
+
{
|
|
1632
|
+
name: "value"
|
|
1475
1633
|
}
|
|
1476
|
-
|
|
1477
|
-
}, undefined, {
|
|
1478
|
-
name: "value"
|
|
1479
|
-
} );
|
|
1634
|
+
);
|
|
1480
1635
|
}
|
|
1481
1636
|
function Switch(props) {
|
|
1482
1637
|
let keyed = false;
|
|
1483
|
-
const equals = (a, b) =>
|
|
1638
|
+
const equals = (a, b) =>
|
|
1639
|
+
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1484
1640
|
const conditions = children(() => props.children),
|
|
1485
|
-
evalConditions = createMemo(
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1641
|
+
evalConditions = createMemo(
|
|
1642
|
+
() => {
|
|
1643
|
+
let conds = conditions();
|
|
1644
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1645
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1646
|
+
const c = conds[i].when;
|
|
1647
|
+
if (c) {
|
|
1648
|
+
keyed = !!conds[i].keyed;
|
|
1649
|
+
return [i, c, conds[i]];
|
|
1650
|
+
}
|
|
1493
1651
|
}
|
|
1652
|
+
return [-1];
|
|
1653
|
+
},
|
|
1654
|
+
undefined,
|
|
1655
|
+
{
|
|
1656
|
+
equals,
|
|
1657
|
+
name: "eval conditions"
|
|
1494
1658
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1659
|
+
);
|
|
1660
|
+
return createMemo(
|
|
1661
|
+
() => {
|
|
1662
|
+
const [index, when, cond] = evalConditions();
|
|
1663
|
+
if (index < 0) return props.fallback;
|
|
1664
|
+
const c = cond.children;
|
|
1665
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1666
|
+
return fn
|
|
1667
|
+
? untrack(() =>
|
|
1668
|
+
c(
|
|
1669
|
+
keyed
|
|
1670
|
+
? when
|
|
1671
|
+
: () => {
|
|
1672
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1673
|
+
return cond.when;
|
|
1674
|
+
}
|
|
1675
|
+
)
|
|
1676
|
+
)
|
|
1677
|
+
: c;
|
|
1678
|
+
},
|
|
1679
|
+
undefined,
|
|
1680
|
+
{
|
|
1681
|
+
name: "value"
|
|
1682
|
+
}
|
|
1683
|
+
);
|
|
1512
1684
|
}
|
|
1513
1685
|
function Match(props) {
|
|
1514
1686
|
return props;
|
|
@@ -1520,27 +1692,37 @@ function resetErrorBoundaries() {
|
|
|
1520
1692
|
function ErrorBoundary(props) {
|
|
1521
1693
|
let err;
|
|
1522
1694
|
let v;
|
|
1523
|
-
if (
|
|
1695
|
+
if (
|
|
1696
|
+
sharedConfig.context &&
|
|
1697
|
+
sharedConfig.load &&
|
|
1698
|
+
(v = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count))
|
|
1699
|
+
)
|
|
1700
|
+
err = v[0];
|
|
1524
1701
|
const [errored, setErrored] = createSignal(err, {
|
|
1525
1702
|
name: "errored"
|
|
1526
|
-
}
|
|
1703
|
+
});
|
|
1527
1704
|
Errors || (Errors = new Set());
|
|
1528
1705
|
Errors.add(setErrored);
|
|
1529
1706
|
onCleanup(() => Errors.delete(setErrored));
|
|
1530
|
-
return createMemo(
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1707
|
+
return createMemo(
|
|
1708
|
+
() => {
|
|
1709
|
+
let e;
|
|
1710
|
+
if ((e = errored())) {
|
|
1711
|
+
const f = props.fallback;
|
|
1712
|
+
if (typeof f !== "function" || f.length == 0) console.error(e);
|
|
1713
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1714
|
+
}
|
|
1715
|
+
return catchError(() => props.children, setErrored);
|
|
1716
|
+
},
|
|
1717
|
+
undefined,
|
|
1718
|
+
{
|
|
1719
|
+
name: "value"
|
|
1536
1720
|
}
|
|
1537
|
-
|
|
1538
|
-
}, undefined, {
|
|
1539
|
-
name: "value"
|
|
1540
|
-
} );
|
|
1721
|
+
);
|
|
1541
1722
|
}
|
|
1542
1723
|
|
|
1543
|
-
const suspenseListEquals = (a, b) =>
|
|
1724
|
+
const suspenseListEquals = (a, b) =>
|
|
1725
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1544
1726
|
const SuspenseListContext = createContext();
|
|
1545
1727
|
function SuspenseList(props) {
|
|
1546
1728
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1552,51 +1734,51 @@ function SuspenseList(props) {
|
|
|
1552
1734
|
if (listContext) {
|
|
1553
1735
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1554
1736
|
}
|
|
1555
|
-
const resolved = createMemo(
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
showContent = true,
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
const res = reg.map(() => ({
|
|
1567
|
-
showContent: all && showContent,
|
|
1568
|
-
showFallback
|
|
1569
|
-
}));
|
|
1570
|
-
res.inFallback = !all;
|
|
1571
|
-
return res;
|
|
1572
|
-
}
|
|
1573
|
-
let stop = false;
|
|
1574
|
-
let inFallback = prev.inFallback;
|
|
1575
|
-
const res = [];
|
|
1576
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1577
|
-
const n = reverse ? len - i - 1 : i,
|
|
1578
|
-
s = reg[n]();
|
|
1579
|
-
if (!stop && !s) {
|
|
1580
|
-
res[n] = {
|
|
1581
|
-
showContent,
|
|
1737
|
+
const resolved = createMemo(
|
|
1738
|
+
prev => {
|
|
1739
|
+
const reveal = props.revealOrder,
|
|
1740
|
+
tail = props.tail,
|
|
1741
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1742
|
+
reg = registry(),
|
|
1743
|
+
reverse = reveal === "backwards";
|
|
1744
|
+
if (reveal === "together") {
|
|
1745
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1746
|
+
const res = reg.map(() => ({
|
|
1747
|
+
showContent: all && showContent,
|
|
1582
1748
|
showFallback
|
|
1583
|
-
};
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
if (next) inFallback = true;
|
|
1587
|
-
res[n] = {
|
|
1588
|
-
showContent: next,
|
|
1589
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1590
|
-
};
|
|
1591
|
-
stop = true;
|
|
1749
|
+
}));
|
|
1750
|
+
res.inFallback = !all;
|
|
1751
|
+
return res;
|
|
1592
1752
|
}
|
|
1753
|
+
let stop = false;
|
|
1754
|
+
let inFallback = prev.inFallback;
|
|
1755
|
+
const res = [];
|
|
1756
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1757
|
+
const n = reverse ? len - i - 1 : i,
|
|
1758
|
+
s = reg[n]();
|
|
1759
|
+
if (!stop && !s) {
|
|
1760
|
+
res[n] = {
|
|
1761
|
+
showContent,
|
|
1762
|
+
showFallback
|
|
1763
|
+
};
|
|
1764
|
+
} else {
|
|
1765
|
+
const next = !stop;
|
|
1766
|
+
if (next) inFallback = true;
|
|
1767
|
+
res[n] = {
|
|
1768
|
+
showContent: next,
|
|
1769
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1770
|
+
};
|
|
1771
|
+
stop = true;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
if (!stop) inFallback = false;
|
|
1775
|
+
res.inFallback = inFallback;
|
|
1776
|
+
return res;
|
|
1777
|
+
},
|
|
1778
|
+
{
|
|
1779
|
+
inFallback: false
|
|
1593
1780
|
}
|
|
1594
|
-
|
|
1595
|
-
res.inFallback = inFallback;
|
|
1596
|
-
return res;
|
|
1597
|
-
}, {
|
|
1598
|
-
inFallback: false
|
|
1599
|
-
});
|
|
1781
|
+
);
|
|
1600
1782
|
setWrapper(() => resolved);
|
|
1601
1783
|
return createComponent(SuspenseListContext.Provider, {
|
|
1602
1784
|
value: {
|
|
@@ -1670,17 +1852,14 @@ function Suspense(props) {
|
|
|
1670
1852
|
ctx = sharedConfig.context;
|
|
1671
1853
|
if (flicker) {
|
|
1672
1854
|
flicker();
|
|
1673
|
-
return flicker = undefined;
|
|
1855
|
+
return (flicker = undefined);
|
|
1674
1856
|
}
|
|
1675
1857
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1676
1858
|
const rendered = createMemo(() => props.children);
|
|
1677
1859
|
return createMemo(prev => {
|
|
1678
1860
|
const inFallback = store.inFallback(),
|
|
1679
|
-
{
|
|
1680
|
-
|
|
1681
|
-
showFallback = true
|
|
1682
|
-
} = show ? show() : {};
|
|
1683
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1861
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1862
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1684
1863
|
store.resolved = true;
|
|
1685
1864
|
dispose && dispose();
|
|
1686
1865
|
dispose = ctx = p = undefined;
|
|
@@ -1710,9 +1889,68 @@ const DEV = {
|
|
|
1710
1889
|
hooks: DevHooks,
|
|
1711
1890
|
writeSignal,
|
|
1712
1891
|
registerGraph
|
|
1713
|
-
}
|
|
1892
|
+
};
|
|
1714
1893
|
if (globalThis) {
|
|
1715
|
-
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1894
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1895
|
+
else
|
|
1896
|
+
console.warn(
|
|
1897
|
+
"You appear to have multiple instances of Solid. This can lead to unexpected behavior."
|
|
1898
|
+
);
|
|
1716
1899
|
}
|
|
1717
1900
|
|
|
1718
|
-
export {
|
|
1901
|
+
export {
|
|
1902
|
+
$DEVCOMP,
|
|
1903
|
+
$PROXY,
|
|
1904
|
+
$TRACK,
|
|
1905
|
+
DEV,
|
|
1906
|
+
ErrorBoundary,
|
|
1907
|
+
For,
|
|
1908
|
+
Index,
|
|
1909
|
+
Match,
|
|
1910
|
+
Show,
|
|
1911
|
+
Suspense,
|
|
1912
|
+
SuspenseList,
|
|
1913
|
+
Switch,
|
|
1914
|
+
batch,
|
|
1915
|
+
cancelCallback,
|
|
1916
|
+
catchError,
|
|
1917
|
+
children,
|
|
1918
|
+
createComponent,
|
|
1919
|
+
createComputed,
|
|
1920
|
+
createContext,
|
|
1921
|
+
createDeferred,
|
|
1922
|
+
createEffect,
|
|
1923
|
+
createMemo,
|
|
1924
|
+
createReaction,
|
|
1925
|
+
createRenderEffect,
|
|
1926
|
+
createResource,
|
|
1927
|
+
createRoot,
|
|
1928
|
+
createSelector,
|
|
1929
|
+
createSignal,
|
|
1930
|
+
createUniqueId,
|
|
1931
|
+
enableExternalSource,
|
|
1932
|
+
enableHydration,
|
|
1933
|
+
enableScheduling,
|
|
1934
|
+
equalFn,
|
|
1935
|
+
from,
|
|
1936
|
+
getListener,
|
|
1937
|
+
getOwner,
|
|
1938
|
+
indexArray,
|
|
1939
|
+
lazy,
|
|
1940
|
+
mapArray,
|
|
1941
|
+
mergeProps,
|
|
1942
|
+
observable,
|
|
1943
|
+
on,
|
|
1944
|
+
onCleanup,
|
|
1945
|
+
onError,
|
|
1946
|
+
onMount,
|
|
1947
|
+
requestCallback,
|
|
1948
|
+
resetErrorBoundaries,
|
|
1949
|
+
runWithOwner,
|
|
1950
|
+
sharedConfig,
|
|
1951
|
+
splitProps,
|
|
1952
|
+
startTransition,
|
|
1953
|
+
untrack,
|
|
1954
|
+
useContext,
|
|
1955
|
+
useTransition
|
|
1956
|
+
};
|