solid-js 1.7.7 → 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.cjs +24 -13
- package/dist/dev.js +555 -306
- package/dist/server.cjs +3 -3
- package/dist/server.js +177 -79
- package/dist/solid.cjs +24 -13
- package/dist/solid.js +482 -264
- 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 +130 -100
- 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 +10 -6
- 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 +13 -10
- 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.cjs +4 -4
- package/web/dist/server.js +180 -81
- 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,20 +963,34 @@ 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;
|
|
968
|
+
}
|
|
969
|
+
if (sharedConfig.context) {
|
|
970
|
+
if (sharedConfig.count) {
|
|
971
|
+
sharedConfig.effects || (sharedConfig.effects = []);
|
|
972
|
+
sharedConfig.effects.push(...queue.slice(0, userLength));
|
|
973
|
+
return;
|
|
974
|
+
} else if (sharedConfig.effects) {
|
|
975
|
+
queue = [...sharedConfig.effects, ...queue];
|
|
976
|
+
userLength += sharedConfig.effects.length;
|
|
977
|
+
delete sharedConfig.effects;
|
|
978
|
+
}
|
|
979
|
+
setHydrateContext();
|
|
880
980
|
}
|
|
881
|
-
if (sharedConfig.context) setHydrateContext();
|
|
882
981
|
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
883
982
|
}
|
|
884
983
|
function lookUpstream(node, ignore) {
|
|
885
984
|
const runningTransition = Transition && Transition.running;
|
|
886
|
-
if (runningTransition) node.tState = 0;
|
|
985
|
+
if (runningTransition) node.tState = 0;
|
|
986
|
+
else node.state = 0;
|
|
887
987
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
888
988
|
const source = node.sources[i];
|
|
889
989
|
if (source.sources) {
|
|
890
990
|
const state = runningTransition ? source.tState : source.state;
|
|
891
991
|
if (state === STALE) {
|
|
892
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
992
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
993
|
+
runTop(source);
|
|
893
994
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
894
995
|
}
|
|
895
996
|
}
|
|
@@ -899,8 +1000,10 @@ function markDownstream(node) {
|
|
|
899
1000
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
900
1001
|
const o = node.observers[i];
|
|
901
1002
|
if (runningTransition ? !o.tState : !o.state) {
|
|
902
|
-
if (runningTransition) o.tState = PENDING;
|
|
903
|
-
|
|
1003
|
+
if (runningTransition) o.tState = PENDING;
|
|
1004
|
+
else o.state = PENDING;
|
|
1005
|
+
if (o.pure) Updates.push(o);
|
|
1006
|
+
else Effects.push(o);
|
|
904
1007
|
o.observers && markDownstream(o);
|
|
905
1008
|
}
|
|
906
1009
|
}
|
|
@@ -937,7 +1040,8 @@ function cleanNode(node) {
|
|
|
937
1040
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
938
1041
|
node.cleanups = null;
|
|
939
1042
|
}
|
|
940
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1043
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1044
|
+
else node.state = 0;
|
|
941
1045
|
node.context = null;
|
|
942
1046
|
delete node.sourceMap;
|
|
943
1047
|
}
|
|
@@ -956,29 +1060,32 @@ function castError(err) {
|
|
|
956
1060
|
cause: err
|
|
957
1061
|
});
|
|
958
1062
|
}
|
|
1063
|
+
function runErrors(err, fns, owner) {
|
|
1064
|
+
try {
|
|
1065
|
+
for (const f of fns) f(err);
|
|
1066
|
+
} catch (e) {
|
|
1067
|
+
handleError(e, (owner && owner.owner) || null);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
959
1070
|
function handleError(err, owner = Owner) {
|
|
960
1071
|
const fns = ERROR && lookup(owner, ERROR);
|
|
961
1072
|
const error = castError(err);
|
|
962
1073
|
if (!fns) throw error;
|
|
963
|
-
if (Effects)
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
state: STALE
|
|
972
|
-
});else {
|
|
973
|
-
try {
|
|
974
|
-
for (const f of fns) f(error);
|
|
975
|
-
} catch (e) {
|
|
976
|
-
handleError(e, owner?.owner || null);
|
|
977
|
-
}
|
|
978
|
-
}
|
|
1074
|
+
if (Effects)
|
|
1075
|
+
Effects.push({
|
|
1076
|
+
fn() {
|
|
1077
|
+
runErrors(error, fns, owner);
|
|
1078
|
+
},
|
|
1079
|
+
state: STALE
|
|
1080
|
+
});
|
|
1081
|
+
else runErrors(error, fns, owner);
|
|
979
1082
|
}
|
|
980
1083
|
function lookup(owner, key) {
|
|
981
|
-
return owner
|
|
1084
|
+
return owner
|
|
1085
|
+
? owner.context && owner.context[key] !== undefined
|
|
1086
|
+
? owner.context[key]
|
|
1087
|
+
: lookup(owner.owner, key)
|
|
1088
|
+
: undefined;
|
|
982
1089
|
}
|
|
983
1090
|
function resolveChildren(children) {
|
|
984
1091
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -995,12 +1102,17 @@ function resolveChildren(children) {
|
|
|
995
1102
|
function createProvider(id, options) {
|
|
996
1103
|
return function provider(props) {
|
|
997
1104
|
let res;
|
|
998
|
-
createRenderEffect(
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
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
|
+
);
|
|
1004
1116
|
return res;
|
|
1005
1117
|
};
|
|
1006
1118
|
}
|
|
@@ -1011,7 +1123,8 @@ function observable(input) {
|
|
|
1011
1123
|
if (!(observer instanceof Object) || observer == null) {
|
|
1012
1124
|
throw new TypeError("Expected the observer to be an object.");
|
|
1013
1125
|
}
|
|
1014
|
-
const handler =
|
|
1126
|
+
const handler =
|
|
1127
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1015
1128
|
if (!handler) {
|
|
1016
1129
|
return {
|
|
1017
1130
|
unsubscribe() {}
|
|
@@ -1042,7 +1155,7 @@ function from(producer) {
|
|
|
1042
1155
|
});
|
|
1043
1156
|
if ("subscribe" in producer) {
|
|
1044
1157
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1045
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1158
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1046
1159
|
} else {
|
|
1047
1160
|
const clean = producer(set);
|
|
1048
1161
|
onCleanup(clean);
|
|
@@ -1094,8 +1207,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1094
1207
|
});
|
|
1095
1208
|
len = 1;
|
|
1096
1209
|
}
|
|
1097
|
-
}
|
|
1098
|
-
else if (len === 0) {
|
|
1210
|
+
} else if (len === 0) {
|
|
1099
1211
|
mapped = new Array(newLen);
|
|
1100
1212
|
for (j = 0; j < newLen; j++) {
|
|
1101
1213
|
items[j] = newItems[j];
|
|
@@ -1106,8 +1218,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1106
1218
|
temp = new Array(newLen);
|
|
1107
1219
|
tempdisposers = new Array(newLen);
|
|
1108
1220
|
indexes && (tempIndexes = new Array(newLen));
|
|
1109
|
-
for (
|
|
1110
|
-
|
|
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
|
+
) {
|
|
1111
1231
|
temp[newEnd] = mapped[end];
|
|
1112
1232
|
tempdisposers[newEnd] = disposers[end];
|
|
1113
1233
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1141,7 +1261,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1141
1261
|
}
|
|
1142
1262
|
} else mapped[j] = createRoot(mapper);
|
|
1143
1263
|
}
|
|
1144
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1264
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1145
1265
|
items = newItems.slice(0);
|
|
1146
1266
|
}
|
|
1147
1267
|
return mapped;
|
|
@@ -1151,7 +1271,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1151
1271
|
if (indexes) {
|
|
1152
1272
|
const [s, set] = createSignal(j, {
|
|
1153
1273
|
name: "index"
|
|
1154
|
-
})
|
|
1274
|
+
});
|
|
1155
1275
|
indexes[j] = set;
|
|
1156
1276
|
return mapFn(newItems[j], s);
|
|
1157
1277
|
}
|
|
@@ -1209,13 +1329,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1209
1329
|
}
|
|
1210
1330
|
len = signals.length = disposers.length = newItems.length;
|
|
1211
1331
|
items = newItems.slice(0);
|
|
1212
|
-
return mapped = mapped.slice(0, len);
|
|
1332
|
+
return (mapped = mapped.slice(0, len));
|
|
1213
1333
|
});
|
|
1214
1334
|
function mapper(disposer) {
|
|
1215
1335
|
disposers[i] = disposer;
|
|
1216
1336
|
const [s, set] = createSignal(newItems[i], {
|
|
1217
1337
|
name: "value"
|
|
1218
|
-
})
|
|
1338
|
+
});
|
|
1219
1339
|
signals[i] = set;
|
|
1220
1340
|
return mapFn(s, i);
|
|
1221
1341
|
}
|
|
@@ -1231,7 +1351,7 @@ function createComponent(Comp, props) {
|
|
|
1231
1351
|
if (sharedConfig.context) {
|
|
1232
1352
|
const c = sharedConfig.context;
|
|
1233
1353
|
setHydrateContext(nextHydrateContext());
|
|
1234
|
-
const r = devComponent(Comp, props || {})
|
|
1354
|
+
const r = devComponent(Comp, props || {});
|
|
1235
1355
|
setHydrateContext(c);
|
|
1236
1356
|
return r;
|
|
1237
1357
|
}
|
|
@@ -1280,29 +1400,33 @@ function mergeProps(...sources) {
|
|
|
1280
1400
|
let proxy = false;
|
|
1281
1401
|
for (let i = 0; i < sources.length; i++) {
|
|
1282
1402
|
const s = sources[i];
|
|
1283
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1284
|
-
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;
|
|
1285
1405
|
}
|
|
1286
1406
|
if (proxy) {
|
|
1287
|
-
return new Proxy(
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
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)];
|
|
1297
1426
|
}
|
|
1298
|
-
return false;
|
|
1299
1427
|
},
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1303
|
-
return [...new Set(keys)];
|
|
1304
|
-
}
|
|
1305
|
-
}, propTraps);
|
|
1428
|
+
propTraps
|
|
1429
|
+
);
|
|
1306
1430
|
}
|
|
1307
1431
|
const target = {};
|
|
1308
1432
|
const sourcesMap = {};
|
|
@@ -1321,7 +1445,7 @@ function mergeProps(...sources) {
|
|
|
1321
1445
|
Object.defineProperty(target, key, {
|
|
1322
1446
|
enumerable: true,
|
|
1323
1447
|
configurable: true,
|
|
1324
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1448
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1325
1449
|
});
|
|
1326
1450
|
} else {
|
|
1327
1451
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1345,47 +1469,60 @@ function splitProps(props, ...keys) {
|
|
|
1345
1469
|
if ($PROXY in props) {
|
|
1346
1470
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1347
1471
|
const res = keys.map(k => {
|
|
1348
|
-
return new Proxy(
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
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
|
+
}
|
|
1354
1483
|
},
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
}
|
|
1358
|
-
}, propTraps);
|
|
1484
|
+
propTraps
|
|
1485
|
+
);
|
|
1359
1486
|
});
|
|
1360
|
-
res.push(
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
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
|
+
);
|
|
1371
1503
|
return res;
|
|
1372
1504
|
}
|
|
1373
1505
|
const otherObject = {};
|
|
1374
1506
|
const objects = keys.map(() => ({}));
|
|
1375
1507
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1376
1508
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1377
|
-
const isDefaultDesc =
|
|
1509
|
+
const isDefaultDesc =
|
|
1510
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1378
1511
|
let blocked = false;
|
|
1379
1512
|
let objectIndex = 0;
|
|
1380
1513
|
for (const k of keys) {
|
|
1381
1514
|
if (k.includes(propName)) {
|
|
1382
1515
|
blocked = true;
|
|
1383
|
-
isDefaultDesc
|
|
1516
|
+
isDefaultDesc
|
|
1517
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1518
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1384
1519
|
}
|
|
1385
1520
|
++objectIndex;
|
|
1386
1521
|
}
|
|
1387
1522
|
if (!blocked) {
|
|
1388
|
-
isDefaultDesc
|
|
1523
|
+
isDefaultDesc
|
|
1524
|
+
? (otherObject[propName] = desc.value)
|
|
1525
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1389
1526
|
}
|
|
1390
1527
|
}
|
|
1391
1528
|
return [...objects, otherObject];
|
|
@@ -1397,8 +1534,11 @@ function lazy(fn) {
|
|
|
1397
1534
|
const ctx = sharedConfig.context;
|
|
1398
1535
|
if (ctx) {
|
|
1399
1536
|
const [s, set] = createSignal();
|
|
1537
|
+
sharedConfig.count || (sharedConfig.count = 0);
|
|
1538
|
+
sharedConfig.count++;
|
|
1400
1539
|
(p || (p = fn())).then(mod => {
|
|
1401
1540
|
setHydrateContext(ctx);
|
|
1541
|
+
sharedConfig.count--;
|
|
1402
1542
|
set(() => mod.default);
|
|
1403
1543
|
setHydrateContext();
|
|
1404
1544
|
});
|
|
@@ -1408,19 +1548,24 @@ function lazy(fn) {
|
|
|
1408
1548
|
comp = s;
|
|
1409
1549
|
}
|
|
1410
1550
|
let Comp;
|
|
1411
|
-
return createMemo(
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
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
|
+
);
|
|
1422
1567
|
};
|
|
1423
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1568
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1424
1569
|
return wrap;
|
|
1425
1570
|
}
|
|
1426
1571
|
let counter = 0;
|
|
@@ -1429,75 +1574,113 @@ function createUniqueId() {
|
|
|
1429
1574
|
return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
|
|
1430
1575
|
}
|
|
1431
1576
|
|
|
1432
|
-
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.`;
|
|
1433
1579
|
function For(props) {
|
|
1434
1580
|
const fallback = "fallback" in props && {
|
|
1435
1581
|
fallback: () => props.fallback
|
|
1436
1582
|
};
|
|
1437
|
-
return createMemo(
|
|
1438
|
-
|
|
1439
|
-
|
|
1583
|
+
return createMemo(
|
|
1584
|
+
mapArray(() => props.each, props.children, fallback || undefined),
|
|
1585
|
+
undefined,
|
|
1586
|
+
{
|
|
1587
|
+
name: "value"
|
|
1588
|
+
}
|
|
1589
|
+
);
|
|
1440
1590
|
}
|
|
1441
1591
|
function Index(props) {
|
|
1442
1592
|
const fallback = "fallback" in props && {
|
|
1443
1593
|
fallback: () => props.fallback
|
|
1444
1594
|
};
|
|
1445
|
-
return createMemo(
|
|
1446
|
-
|
|
1447
|
-
|
|
1595
|
+
return createMemo(
|
|
1596
|
+
indexArray(() => props.each, props.children, fallback || undefined),
|
|
1597
|
+
undefined,
|
|
1598
|
+
{
|
|
1599
|
+
name: "value"
|
|
1600
|
+
}
|
|
1601
|
+
);
|
|
1448
1602
|
}
|
|
1449
1603
|
function Show(props) {
|
|
1450
1604
|
const keyed = props.keyed;
|
|
1451
1605
|
const condition = createMemo(() => props.when, undefined, {
|
|
1452
|
-
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1606
|
+
equals: (a, b) => (keyed ? a === b : !a === !b),
|
|
1453
1607
|
name: "condition"
|
|
1454
|
-
}
|
|
1455
|
-
return createMemo(
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
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"
|
|
1464
1633
|
}
|
|
1465
|
-
|
|
1466
|
-
}, undefined, {
|
|
1467
|
-
name: "value"
|
|
1468
|
-
} );
|
|
1634
|
+
);
|
|
1469
1635
|
}
|
|
1470
1636
|
function Switch(props) {
|
|
1471
1637
|
let keyed = false;
|
|
1472
|
-
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];
|
|
1473
1640
|
const conditions = children(() => props.children),
|
|
1474
|
-
evalConditions = createMemo(
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
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
|
+
}
|
|
1482
1651
|
}
|
|
1652
|
+
return [-1];
|
|
1653
|
+
},
|
|
1654
|
+
undefined,
|
|
1655
|
+
{
|
|
1656
|
+
equals,
|
|
1657
|
+
name: "eval conditions"
|
|
1483
1658
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
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
|
+
);
|
|
1501
1684
|
}
|
|
1502
1685
|
function Match(props) {
|
|
1503
1686
|
return props;
|
|
@@ -1509,27 +1692,37 @@ function resetErrorBoundaries() {
|
|
|
1509
1692
|
function ErrorBoundary(props) {
|
|
1510
1693
|
let err;
|
|
1511
1694
|
let v;
|
|
1512
|
-
if (
|
|
1695
|
+
if (
|
|
1696
|
+
sharedConfig.context &&
|
|
1697
|
+
sharedConfig.load &&
|
|
1698
|
+
(v = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count))
|
|
1699
|
+
)
|
|
1700
|
+
err = v[0];
|
|
1513
1701
|
const [errored, setErrored] = createSignal(err, {
|
|
1514
1702
|
name: "errored"
|
|
1515
|
-
}
|
|
1703
|
+
});
|
|
1516
1704
|
Errors || (Errors = new Set());
|
|
1517
1705
|
Errors.add(setErrored);
|
|
1518
1706
|
onCleanup(() => Errors.delete(setErrored));
|
|
1519
|
-
return createMemo(
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
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"
|
|
1525
1720
|
}
|
|
1526
|
-
|
|
1527
|
-
}, undefined, {
|
|
1528
|
-
name: "value"
|
|
1529
|
-
} );
|
|
1721
|
+
);
|
|
1530
1722
|
}
|
|
1531
1723
|
|
|
1532
|
-
const suspenseListEquals = (a, b) =>
|
|
1724
|
+
const suspenseListEquals = (a, b) =>
|
|
1725
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1533
1726
|
const SuspenseListContext = createContext();
|
|
1534
1727
|
function SuspenseList(props) {
|
|
1535
1728
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1541,51 +1734,51 @@ function SuspenseList(props) {
|
|
|
1541
1734
|
if (listContext) {
|
|
1542
1735
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1543
1736
|
}
|
|
1544
|
-
const resolved = createMemo(
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
showContent = true,
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
const res = reg.map(() => ({
|
|
1556
|
-
showContent: all && showContent,
|
|
1557
|
-
showFallback
|
|
1558
|
-
}));
|
|
1559
|
-
res.inFallback = !all;
|
|
1560
|
-
return res;
|
|
1561
|
-
}
|
|
1562
|
-
let stop = false;
|
|
1563
|
-
let inFallback = prev.inFallback;
|
|
1564
|
-
const res = [];
|
|
1565
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1566
|
-
const n = reverse ? len - i - 1 : i,
|
|
1567
|
-
s = reg[n]();
|
|
1568
|
-
if (!stop && !s) {
|
|
1569
|
-
res[n] = {
|
|
1570
|
-
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,
|
|
1571
1748
|
showFallback
|
|
1572
|
-
};
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1749
|
+
}));
|
|
1750
|
+
res.inFallback = !all;
|
|
1751
|
+
return res;
|
|
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
|
+
}
|
|
1581
1773
|
}
|
|
1774
|
+
if (!stop) inFallback = false;
|
|
1775
|
+
res.inFallback = inFallback;
|
|
1776
|
+
return res;
|
|
1777
|
+
},
|
|
1778
|
+
{
|
|
1779
|
+
inFallback: false
|
|
1582
1780
|
}
|
|
1583
|
-
|
|
1584
|
-
res.inFallback = inFallback;
|
|
1585
|
-
return res;
|
|
1586
|
-
}, {
|
|
1587
|
-
inFallback: false
|
|
1588
|
-
});
|
|
1781
|
+
);
|
|
1589
1782
|
setWrapper(() => resolved);
|
|
1590
1783
|
return createComponent(SuspenseListContext.Provider, {
|
|
1591
1784
|
value: {
|
|
@@ -1659,17 +1852,14 @@ function Suspense(props) {
|
|
|
1659
1852
|
ctx = sharedConfig.context;
|
|
1660
1853
|
if (flicker) {
|
|
1661
1854
|
flicker();
|
|
1662
|
-
return flicker = undefined;
|
|
1855
|
+
return (flicker = undefined);
|
|
1663
1856
|
}
|
|
1664
1857
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1665
1858
|
const rendered = createMemo(() => props.children);
|
|
1666
1859
|
return createMemo(prev => {
|
|
1667
1860
|
const inFallback = store.inFallback(),
|
|
1668
|
-
{
|
|
1669
|
-
|
|
1670
|
-
showFallback = true
|
|
1671
|
-
} = show ? show() : {};
|
|
1672
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1861
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1862
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1673
1863
|
store.resolved = true;
|
|
1674
1864
|
dispose && dispose();
|
|
1675
1865
|
dispose = ctx = p = undefined;
|
|
@@ -1699,9 +1889,68 @@ const DEV = {
|
|
|
1699
1889
|
hooks: DevHooks,
|
|
1700
1890
|
writeSignal,
|
|
1701
1891
|
registerGraph
|
|
1702
|
-
}
|
|
1892
|
+
};
|
|
1703
1893
|
if (globalThis) {
|
|
1704
|
-
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
|
+
);
|
|
1705
1899
|
}
|
|
1706
1900
|
|
|
1707
|
-
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
|
+
};
|