solid-js 1.8.5 → 1.8.7
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 +13 -10
- package/dist/dev.js +545 -307
- package/dist/server.js +170 -75
- package/dist/solid.cjs +8 -7
- package/dist/solid.js +467 -262
- package/h/dist/h.js +34 -8
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +12 -5
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -33
- package/package.json +7 -2
- package/store/dist/dev.js +114 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +105 -39
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +75 -9
- package/types/jsx.d.ts +11 -5
- 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 +229 -140
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +62 -31
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +167 -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.cjs +1 -1
- package/web/dist/dev.js +620 -81
- package/web/dist/server.cjs +28 -13
- package/web/dist/server.js +201 -104
- package/web/dist/storage.js +3 -3
- package/web/dist/web.cjs +1 -1
- package/web/dist/web.js +614 -80
- 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
|
}
|
|
@@ -157,28 +159,33 @@ let Effects = null;
|
|
|
157
159
|
let ExecCount = 0;
|
|
158
160
|
const DevHooks = {
|
|
159
161
|
afterUpdate: null,
|
|
160
|
-
afterCreateOwner: null
|
|
162
|
+
afterCreateOwner: null,
|
|
163
|
+
afterCreateSignal: null
|
|
161
164
|
};
|
|
162
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
163
165
|
function createRoot(fn, detachedOwner) {
|
|
164
166
|
const listener = Listener,
|
|
165
167
|
owner = Owner,
|
|
166
168
|
unowned = fn.length === 0,
|
|
167
169
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
168
|
-
root = unowned
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
170
|
+
root = unowned
|
|
171
|
+
? {
|
|
172
|
+
owned: null,
|
|
173
|
+
cleanups: null,
|
|
174
|
+
context: null,
|
|
175
|
+
owner: null
|
|
176
|
+
}
|
|
177
|
+
: {
|
|
178
|
+
owned: null,
|
|
179
|
+
cleanups: null,
|
|
180
|
+
context: current ? current.context : null,
|
|
181
|
+
owner: current
|
|
182
|
+
},
|
|
183
|
+
updateFn = unowned
|
|
184
|
+
? () =>
|
|
185
|
+
fn(() => {
|
|
186
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
187
|
+
})
|
|
188
|
+
: () => fn(() => untrack(() => cleanNode(root)));
|
|
182
189
|
DevHooks.afterCreateOwner && DevHooks.afterCreateOwner(root);
|
|
183
190
|
Owner = root;
|
|
184
191
|
Listener = null;
|
|
@@ -197,29 +204,33 @@ function createSignal(value, options) {
|
|
|
197
204
|
observerSlots: null,
|
|
198
205
|
comparator: options.equals || undefined
|
|
199
206
|
};
|
|
200
|
-
|
|
207
|
+
{
|
|
201
208
|
if (options.name) s.name = options.name;
|
|
202
|
-
|
|
209
|
+
if (DevHooks.afterCreateSignal) DevHooks.afterCreateSignal(s);
|
|
210
|
+
if (!options.internal) registerGraph(s);
|
|
203
211
|
}
|
|
204
212
|
const setter = value => {
|
|
205
213
|
if (typeof value === "function") {
|
|
206
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
214
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
215
|
+
else value = value(s.value);
|
|
207
216
|
}
|
|
208
217
|
return writeSignal(s, value);
|
|
209
218
|
};
|
|
210
219
|
return [readSignal.bind(s), setter];
|
|
211
220
|
}
|
|
212
221
|
function createComputed(fn, value, options) {
|
|
213
|
-
const c = createComputation(fn, value, true, STALE, options
|
|
214
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
222
|
+
const c = createComputation(fn, value, true, STALE, options);
|
|
223
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
224
|
+
else updateComputation(c);
|
|
215
225
|
}
|
|
216
226
|
function createRenderEffect(fn, value, options) {
|
|
217
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
218
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
227
|
+
const c = createComputation(fn, value, false, STALE, options);
|
|
228
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
229
|
+
else updateComputation(c);
|
|
219
230
|
}
|
|
220
231
|
function createEffect(fn, value, options) {
|
|
221
232
|
runEffects = runUserEffects;
|
|
222
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
233
|
+
const c = createComputation(fn, value, false, STALE, options),
|
|
223
234
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
224
235
|
if (s) c.suspense = s;
|
|
225
236
|
if (!options || !options.render) c.user = true;
|
|
@@ -227,10 +238,16 @@ function createEffect(fn, value, options) {
|
|
|
227
238
|
}
|
|
228
239
|
function createReaction(onInvalidate, options) {
|
|
229
240
|
let fn;
|
|
230
|
-
const c = createComputation(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
241
|
+
const c = createComputation(
|
|
242
|
+
() => {
|
|
243
|
+
fn ? fn() : untrack(onInvalidate);
|
|
244
|
+
fn = undefined;
|
|
245
|
+
},
|
|
246
|
+
undefined,
|
|
247
|
+
false,
|
|
248
|
+
0,
|
|
249
|
+
options
|
|
250
|
+
),
|
|
234
251
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
235
252
|
if (s) c.suspense = s;
|
|
236
253
|
c.user = true;
|
|
@@ -241,7 +258,7 @@ function createReaction(onInvalidate, options) {
|
|
|
241
258
|
}
|
|
242
259
|
function createMemo(fn, value, options) {
|
|
243
260
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
244
|
-
const c = createComputation(fn, value, true, 0, options
|
|
261
|
+
const c = createComputation(fn, value, true, 0, options);
|
|
245
262
|
c.observers = null;
|
|
246
263
|
c.observerSlots = null;
|
|
247
264
|
c.comparator = options.equals || undefined;
|
|
@@ -258,7 +275,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
258
275
|
let source;
|
|
259
276
|
let fetcher;
|
|
260
277
|
let options;
|
|
261
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
278
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
262
279
|
source = true;
|
|
263
280
|
fetcher = pSource;
|
|
264
281
|
options = pFetcher || {};
|
|
@@ -272,7 +289,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
272
289
|
id = null,
|
|
273
290
|
loadedUnderTransition = false,
|
|
274
291
|
scheduled = false,
|
|
275
|
-
resolved =
|
|
292
|
+
resolved = "initialValue" in options,
|
|
276
293
|
dynamic = typeof source === "function" && createMemo(source);
|
|
277
294
|
const contexts = new Set(),
|
|
278
295
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -284,15 +301,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
284
301
|
if (sharedConfig.context) {
|
|
285
302
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
286
303
|
let v;
|
|
287
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
304
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
305
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v;
|
|
288
306
|
}
|
|
289
307
|
function loadEnd(p, v, error, key) {
|
|
290
308
|
if (pr === p) {
|
|
291
309
|
pr = null;
|
|
292
310
|
key !== undefined && (resolved = true);
|
|
293
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
294
|
-
|
|
295
|
-
|
|
311
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
312
|
+
queueMicrotask(() =>
|
|
313
|
+
options.onHydrated(key, {
|
|
314
|
+
value: v
|
|
315
|
+
})
|
|
316
|
+
);
|
|
296
317
|
initP = NO_INIT;
|
|
297
318
|
if (Transition && p && loadedUnderTransition) {
|
|
298
319
|
Transition.promises.delete(p);
|
|
@@ -323,7 +344,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
323
344
|
createComputed(() => {
|
|
324
345
|
track();
|
|
325
346
|
if (pr) {
|
|
326
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
347
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
348
|
+
else if (!contexts.has(c)) {
|
|
327
349
|
c.increment();
|
|
328
350
|
contexts.add(c);
|
|
329
351
|
}
|
|
@@ -342,26 +364,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
342
364
|
return;
|
|
343
365
|
}
|
|
344
366
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
345
|
-
const p =
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
367
|
+
const p =
|
|
368
|
+
initP !== NO_INIT
|
|
369
|
+
? initP
|
|
370
|
+
: untrack(() =>
|
|
371
|
+
fetcher(lookup, {
|
|
372
|
+
value: value(),
|
|
373
|
+
refetching
|
|
374
|
+
})
|
|
375
|
+
);
|
|
349
376
|
if (!isPromise(p)) {
|
|
350
377
|
loadEnd(pr, p, undefined, lookup);
|
|
351
378
|
return p;
|
|
352
379
|
}
|
|
353
380
|
pr = p;
|
|
354
381
|
if ("value" in p) {
|
|
355
|
-
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
382
|
+
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);
|
|
383
|
+
else loadEnd(pr, undefined, undefined, lookup);
|
|
356
384
|
return p;
|
|
357
385
|
}
|
|
358
386
|
scheduled = true;
|
|
359
|
-
queueMicrotask(() => scheduled = false);
|
|
387
|
+
queueMicrotask(() => (scheduled = false));
|
|
360
388
|
runUpdates(() => {
|
|
361
389
|
setState(resolved ? "refreshing" : "pending");
|
|
362
390
|
trigger();
|
|
363
391
|
}, false);
|
|
364
|
-
return p.then(
|
|
392
|
+
return p.then(
|
|
393
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
394
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
395
|
+
);
|
|
365
396
|
}
|
|
366
397
|
Object.defineProperties(read, {
|
|
367
398
|
state: {
|
|
@@ -385,50 +416,81 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
385
416
|
}
|
|
386
417
|
}
|
|
387
418
|
});
|
|
388
|
-
if (dynamic) createComputed(() => load(false));
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
419
|
+
if (dynamic) createComputed(() => load(false));
|
|
420
|
+
else load(false);
|
|
421
|
+
return [
|
|
422
|
+
read,
|
|
423
|
+
{
|
|
424
|
+
refetch: load,
|
|
425
|
+
mutate: setValue
|
|
426
|
+
}
|
|
427
|
+
];
|
|
393
428
|
}
|
|
394
429
|
function createDeferred(source, options) {
|
|
395
430
|
let t,
|
|
396
431
|
timeout = options ? options.timeoutMs : undefined;
|
|
397
|
-
const node = createComputation(
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
432
|
+
const node = createComputation(
|
|
433
|
+
() => {
|
|
434
|
+
if (!t || !t.fn)
|
|
435
|
+
t = requestCallback(
|
|
436
|
+
() => setDeferred(() => node.value),
|
|
437
|
+
timeout !== undefined
|
|
438
|
+
? {
|
|
439
|
+
timeout
|
|
440
|
+
}
|
|
441
|
+
: undefined
|
|
442
|
+
);
|
|
443
|
+
return source();
|
|
444
|
+
},
|
|
445
|
+
undefined,
|
|
446
|
+
true
|
|
447
|
+
);
|
|
448
|
+
const [deferred, setDeferred] = createSignal(
|
|
449
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
450
|
+
options
|
|
451
|
+
);
|
|
404
452
|
updateComputation(node);
|
|
405
|
-
setDeferred(() =>
|
|
453
|
+
setDeferred(() =>
|
|
454
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
455
|
+
);
|
|
406
456
|
return deferred;
|
|
407
457
|
}
|
|
408
458
|
function createSelector(source, fn = equalFn, options) {
|
|
409
459
|
const subs = new Map();
|
|
410
|
-
const node = createComputation(
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
for (const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
460
|
+
const node = createComputation(
|
|
461
|
+
p => {
|
|
462
|
+
const v = source();
|
|
463
|
+
for (const [key, val] of subs.entries())
|
|
464
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
465
|
+
for (const c of val.values()) {
|
|
466
|
+
c.state = STALE;
|
|
467
|
+
if (c.pure) Updates.push(c);
|
|
468
|
+
else Effects.push(c);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return v;
|
|
472
|
+
},
|
|
473
|
+
undefined,
|
|
474
|
+
true,
|
|
475
|
+
STALE,
|
|
476
|
+
options
|
|
477
|
+
);
|
|
420
478
|
updateComputation(node);
|
|
421
479
|
return key => {
|
|
422
480
|
const listener = Listener;
|
|
423
481
|
if (listener) {
|
|
424
482
|
let l;
|
|
425
|
-
if (l = subs.get(key)) l.add(listener);
|
|
483
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
484
|
+
else subs.set(key, (l = new Set([listener])));
|
|
426
485
|
onCleanup(() => {
|
|
427
486
|
l.delete(listener);
|
|
428
487
|
!l.size && subs.delete(key);
|
|
429
488
|
});
|
|
430
489
|
}
|
|
431
|
-
return fn(
|
|
490
|
+
return fn(
|
|
491
|
+
key,
|
|
492
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
493
|
+
);
|
|
432
494
|
};
|
|
433
495
|
}
|
|
434
496
|
function batch(fn) {
|
|
@@ -467,7 +529,10 @@ function onMount(fn) {
|
|
|
467
529
|
createEffect(() => untrack(fn));
|
|
468
530
|
}
|
|
469
531
|
function onCleanup(fn) {
|
|
470
|
-
if (Owner === null)
|
|
532
|
+
if (Owner === null)
|
|
533
|
+
console.warn("cleanups created outside a `createRoot` or `render` will never be run");
|
|
534
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
535
|
+
else Owner.cleanups.push(fn);
|
|
471
536
|
return fn;
|
|
472
537
|
}
|
|
473
538
|
function catchError(fn, handler) {
|
|
@@ -521,15 +586,17 @@ function startTransition(fn) {
|
|
|
521
586
|
Owner = o;
|
|
522
587
|
let t;
|
|
523
588
|
if (Scheduler || SuspenseContext) {
|
|
524
|
-
t =
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
589
|
+
t =
|
|
590
|
+
Transition ||
|
|
591
|
+
(Transition = {
|
|
592
|
+
sources: new Set(),
|
|
593
|
+
effects: [],
|
|
594
|
+
promises: new Set(),
|
|
595
|
+
disposed: new Set(),
|
|
596
|
+
queue: new Set(),
|
|
597
|
+
running: true
|
|
598
|
+
});
|
|
599
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
533
600
|
t.running = true;
|
|
534
601
|
}
|
|
535
602
|
runUpdates(fn, false);
|
|
@@ -537,6 +604,7 @@ function startTransition(fn) {
|
|
|
537
604
|
return t ? t.done : undefined;
|
|
538
605
|
});
|
|
539
606
|
}
|
|
607
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
540
608
|
function useTransition() {
|
|
541
609
|
return [transPending, startTransition];
|
|
542
610
|
}
|
|
@@ -545,12 +613,18 @@ function resumeEffects(e) {
|
|
|
545
613
|
e.length = 0;
|
|
546
614
|
}
|
|
547
615
|
function devComponent(Comp, props) {
|
|
548
|
-
const c = createComputation(
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
616
|
+
const c = createComputation(
|
|
617
|
+
() =>
|
|
618
|
+
untrack(() => {
|
|
619
|
+
Object.assign(Comp, {
|
|
620
|
+
[$DEVCOMP]: true
|
|
621
|
+
});
|
|
622
|
+
return Comp(props);
|
|
623
|
+
}),
|
|
624
|
+
undefined,
|
|
625
|
+
true,
|
|
626
|
+
0
|
|
627
|
+
);
|
|
554
628
|
c.props = props;
|
|
555
629
|
c.observers = null;
|
|
556
630
|
c.observerSlots = null;
|
|
@@ -561,7 +635,8 @@ function devComponent(Comp, props) {
|
|
|
561
635
|
}
|
|
562
636
|
function registerGraph(value) {
|
|
563
637
|
if (!Owner) return;
|
|
564
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
638
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
639
|
+
else Owner.sourceMap = [value];
|
|
565
640
|
value.graph = Owner;
|
|
566
641
|
}
|
|
567
642
|
function createContext(defaultValue, options) {
|
|
@@ -573,13 +648,15 @@ function createContext(defaultValue, options) {
|
|
|
573
648
|
};
|
|
574
649
|
}
|
|
575
650
|
function useContext(context) {
|
|
576
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
651
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
652
|
+
? Owner.context[context.id]
|
|
653
|
+
: context.defaultValue;
|
|
577
654
|
}
|
|
578
655
|
function children(fn) {
|
|
579
656
|
const children = createMemo(fn);
|
|
580
657
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
581
658
|
name: "children"
|
|
582
|
-
})
|
|
659
|
+
});
|
|
583
660
|
memo.toArray = () => {
|
|
584
661
|
const c = memo();
|
|
585
662
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -611,7 +688,8 @@ function enableExternalSource(factory) {
|
|
|
611
688
|
function readSignal() {
|
|
612
689
|
const runningTransition = Transition && Transition.running;
|
|
613
690
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
614
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
691
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
692
|
+
else {
|
|
615
693
|
const updates = Updates;
|
|
616
694
|
Updates = null;
|
|
617
695
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -639,11 +717,12 @@ function readSignal() {
|
|
|
639
717
|
return this.value;
|
|
640
718
|
}
|
|
641
719
|
function writeSignal(node, value, isComp) {
|
|
642
|
-
let current =
|
|
720
|
+
let current =
|
|
721
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
643
722
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
644
723
|
if (Transition) {
|
|
645
724
|
const TransitionRunning = Transition.running;
|
|
646
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
725
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
647
726
|
Transition.sources.add(node);
|
|
648
727
|
node.tValue = value;
|
|
649
728
|
}
|
|
@@ -656,10 +735,12 @@ function writeSignal(node, value, isComp) {
|
|
|
656
735
|
const TransitionRunning = Transition && Transition.running;
|
|
657
736
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
658
737
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
659
|
-
if (o.pure) Updates.push(o);
|
|
738
|
+
if (o.pure) Updates.push(o);
|
|
739
|
+
else Effects.push(o);
|
|
660
740
|
if (o.observers) markDownstream(o);
|
|
661
741
|
}
|
|
662
|
-
if (!TransitionRunning) o.state = STALE;
|
|
742
|
+
if (!TransitionRunning) o.state = STALE;
|
|
743
|
+
else o.tState = STALE;
|
|
663
744
|
}
|
|
664
745
|
if (Updates.length > 10e5) {
|
|
665
746
|
Updates = [];
|
|
@@ -674,11 +755,12 @@ function writeSignal(node, value, isComp) {
|
|
|
674
755
|
function updateComputation(node) {
|
|
675
756
|
if (!node.fn) return;
|
|
676
757
|
cleanNode(node);
|
|
677
|
-
const
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
758
|
+
const time = ExecCount;
|
|
759
|
+
runComputation(
|
|
760
|
+
node,
|
|
761
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
762
|
+
time
|
|
763
|
+
);
|
|
682
764
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
683
765
|
queueMicrotask(() => {
|
|
684
766
|
runUpdates(() => {
|
|
@@ -689,11 +771,12 @@ function updateComputation(node) {
|
|
|
689
771
|
}, false);
|
|
690
772
|
});
|
|
691
773
|
}
|
|
692
|
-
Listener = listener;
|
|
693
|
-
Owner = owner;
|
|
694
774
|
}
|
|
695
775
|
function runComputation(node, value, time) {
|
|
696
776
|
let nextValue;
|
|
777
|
+
const owner = Owner,
|
|
778
|
+
listener = Listener;
|
|
779
|
+
Listener = Owner = node;
|
|
697
780
|
try {
|
|
698
781
|
nextValue = node.fn(value);
|
|
699
782
|
} catch (err) {
|
|
@@ -710,6 +793,9 @@ function runComputation(node, value, time) {
|
|
|
710
793
|
}
|
|
711
794
|
node.updatedAt = time + 1;
|
|
712
795
|
return handleError(err);
|
|
796
|
+
} finally {
|
|
797
|
+
Listener = listener;
|
|
798
|
+
Owner = owner;
|
|
713
799
|
}
|
|
714
800
|
if (!node.updatedAt || node.updatedAt <= time) {
|
|
715
801
|
if (node.updatedAt != null && "observers" in node) {
|
|
@@ -739,11 +825,15 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
739
825
|
c.state = 0;
|
|
740
826
|
c.tState = state;
|
|
741
827
|
}
|
|
742
|
-
if (Owner === null)
|
|
828
|
+
if (Owner === null)
|
|
829
|
+
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
830
|
+
else if (Owner !== UNOWNED) {
|
|
743
831
|
if (Transition && Transition.running && Owner.pure) {
|
|
744
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
832
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
833
|
+
else Owner.tOwned.push(c);
|
|
745
834
|
} else {
|
|
746
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
835
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
836
|
+
else Owner.owned.push(c);
|
|
747
837
|
}
|
|
748
838
|
}
|
|
749
839
|
if (options && options.name) c.name = options.name;
|
|
@@ -796,7 +886,8 @@ function runUpdates(fn, init) {
|
|
|
796
886
|
if (Updates) return fn();
|
|
797
887
|
let wait = false;
|
|
798
888
|
if (!init) Updates = [];
|
|
799
|
-
if (Effects) wait = true;
|
|
889
|
+
if (Effects) wait = true;
|
|
890
|
+
else Effects = [];
|
|
800
891
|
ExecCount++;
|
|
801
892
|
try {
|
|
802
893
|
const res = fn();
|
|
@@ -810,7 +901,8 @@ function runUpdates(fn, init) {
|
|
|
810
901
|
}
|
|
811
902
|
function completeUpdates(wait) {
|
|
812
903
|
if (Updates) {
|
|
813
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
904
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
905
|
+
else runQueue(Updates);
|
|
814
906
|
Updates = null;
|
|
815
907
|
}
|
|
816
908
|
if (wait) return;
|
|
@@ -850,7 +942,8 @@ function completeUpdates(wait) {
|
|
|
850
942
|
}
|
|
851
943
|
const e = Effects;
|
|
852
944
|
Effects = null;
|
|
853
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
945
|
+
if (e.length) runUpdates(() => runEffects(e), false);
|
|
946
|
+
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
854
947
|
if (res) res();
|
|
855
948
|
}
|
|
856
949
|
function runQueue(queue) {
|
|
@@ -878,7 +971,8 @@ function runUserEffects(queue) {
|
|
|
878
971
|
userLength = 0;
|
|
879
972
|
for (i = 0; i < queue.length; i++) {
|
|
880
973
|
const e = queue[i];
|
|
881
|
-
if (!e.user) runTop(e);
|
|
974
|
+
if (!e.user) runTop(e);
|
|
975
|
+
else queue[userLength++] = e;
|
|
882
976
|
}
|
|
883
977
|
if (sharedConfig.context) {
|
|
884
978
|
if (sharedConfig.count) {
|
|
@@ -896,13 +990,15 @@ function runUserEffects(queue) {
|
|
|
896
990
|
}
|
|
897
991
|
function lookUpstream(node, ignore) {
|
|
898
992
|
const runningTransition = Transition && Transition.running;
|
|
899
|
-
if (runningTransition) node.tState = 0;
|
|
993
|
+
if (runningTransition) node.tState = 0;
|
|
994
|
+
else node.state = 0;
|
|
900
995
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
901
996
|
const source = node.sources[i];
|
|
902
997
|
if (source.sources) {
|
|
903
998
|
const state = runningTransition ? source.tState : source.state;
|
|
904
999
|
if (state === STALE) {
|
|
905
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
1000
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
1001
|
+
runTop(source);
|
|
906
1002
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
907
1003
|
}
|
|
908
1004
|
}
|
|
@@ -912,8 +1008,10 @@ function markDownstream(node) {
|
|
|
912
1008
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
913
1009
|
const o = node.observers[i];
|
|
914
1010
|
if (runningTransition ? !o.tState : !o.state) {
|
|
915
|
-
if (runningTransition) o.tState = PENDING;
|
|
916
|
-
|
|
1011
|
+
if (runningTransition) o.tState = PENDING;
|
|
1012
|
+
else o.state = PENDING;
|
|
1013
|
+
if (o.pure) Updates.push(o);
|
|
1014
|
+
else Effects.push(o);
|
|
917
1015
|
o.observers && markDownstream(o);
|
|
918
1016
|
}
|
|
919
1017
|
}
|
|
@@ -950,7 +1048,8 @@ function cleanNode(node) {
|
|
|
950
1048
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
951
1049
|
node.cleanups = null;
|
|
952
1050
|
}
|
|
953
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1051
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1052
|
+
else node.state = 0;
|
|
954
1053
|
delete node.sourceMap;
|
|
955
1054
|
}
|
|
956
1055
|
function reset(node, top) {
|
|
@@ -972,19 +1071,21 @@ function runErrors(err, fns, owner) {
|
|
|
972
1071
|
try {
|
|
973
1072
|
for (const f of fns) f(err);
|
|
974
1073
|
} catch (e) {
|
|
975
|
-
handleError(e, owner && owner.owner || null);
|
|
1074
|
+
handleError(e, (owner && owner.owner) || null);
|
|
976
1075
|
}
|
|
977
1076
|
}
|
|
978
1077
|
function handleError(err, owner = Owner) {
|
|
979
1078
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
980
1079
|
const error = castError(err);
|
|
981
1080
|
if (!fns) throw error;
|
|
982
|
-
if (Effects)
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1081
|
+
if (Effects)
|
|
1082
|
+
Effects.push({
|
|
1083
|
+
fn() {
|
|
1084
|
+
runErrors(error, fns, owner);
|
|
1085
|
+
},
|
|
1086
|
+
state: STALE
|
|
1087
|
+
});
|
|
1088
|
+
else runErrors(error, fns, owner);
|
|
988
1089
|
}
|
|
989
1090
|
function resolveChildren(children) {
|
|
990
1091
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1001,19 +1102,26 @@ function resolveChildren(children) {
|
|
|
1001
1102
|
function createProvider(id, options) {
|
|
1002
1103
|
return function provider(props) {
|
|
1003
1104
|
let res;
|
|
1004
|
-
createRenderEffect(
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1105
|
+
createRenderEffect(
|
|
1106
|
+
() =>
|
|
1107
|
+
(res = untrack(() => {
|
|
1108
|
+
Owner.context = {
|
|
1109
|
+
...Owner.context,
|
|
1110
|
+
[id]: props.value
|
|
1111
|
+
};
|
|
1112
|
+
return children(() => props.children);
|
|
1113
|
+
})),
|
|
1114
|
+
undefined,
|
|
1115
|
+
options
|
|
1116
|
+
);
|
|
1011
1117
|
return res;
|
|
1012
1118
|
};
|
|
1013
1119
|
}
|
|
1014
1120
|
function onError(fn) {
|
|
1015
1121
|
ERROR || (ERROR = Symbol("error"));
|
|
1016
|
-
if (Owner === null)
|
|
1122
|
+
if (Owner === null)
|
|
1123
|
+
console.warn("error handlers created outside a `createRoot` or `render` will never be run");
|
|
1124
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1017
1125
|
Owner.context = {
|
|
1018
1126
|
...Owner.context,
|
|
1019
1127
|
[ERROR]: [fn]
|
|
@@ -1042,7 +1150,8 @@ function observable(input) {
|
|
|
1042
1150
|
if (!(observer instanceof Object) || observer == null) {
|
|
1043
1151
|
throw new TypeError("Expected the observer to be an object.");
|
|
1044
1152
|
}
|
|
1045
|
-
const handler =
|
|
1153
|
+
const handler =
|
|
1154
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1046
1155
|
if (!handler) {
|
|
1047
1156
|
return {
|
|
1048
1157
|
unsubscribe() {}
|
|
@@ -1073,7 +1182,7 @@ function from(producer) {
|
|
|
1073
1182
|
});
|
|
1074
1183
|
if ("subscribe" in producer) {
|
|
1075
1184
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1076
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1185
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1077
1186
|
} else {
|
|
1078
1187
|
const clean = producer(set);
|
|
1079
1188
|
onCleanup(clean);
|
|
@@ -1125,8 +1234,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1125
1234
|
});
|
|
1126
1235
|
len = 1;
|
|
1127
1236
|
}
|
|
1128
|
-
}
|
|
1129
|
-
else if (len === 0) {
|
|
1237
|
+
} else if (len === 0) {
|
|
1130
1238
|
mapped = new Array(newLen);
|
|
1131
1239
|
for (j = 0; j < newLen; j++) {
|
|
1132
1240
|
items[j] = newItems[j];
|
|
@@ -1137,8 +1245,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1137
1245
|
temp = new Array(newLen);
|
|
1138
1246
|
tempdisposers = new Array(newLen);
|
|
1139
1247
|
indexes && (tempIndexes = new Array(newLen));
|
|
1140
|
-
for (
|
|
1141
|
-
|
|
1248
|
+
for (
|
|
1249
|
+
start = 0, end = Math.min(len, newLen);
|
|
1250
|
+
start < end && items[start] === newItems[start];
|
|
1251
|
+
start++
|
|
1252
|
+
);
|
|
1253
|
+
for (
|
|
1254
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1255
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1256
|
+
end--, newEnd--
|
|
1257
|
+
) {
|
|
1142
1258
|
temp[newEnd] = mapped[end];
|
|
1143
1259
|
tempdisposers[newEnd] = disposers[end];
|
|
1144
1260
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1172,7 +1288,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1172
1288
|
}
|
|
1173
1289
|
} else mapped[j] = createRoot(mapper);
|
|
1174
1290
|
}
|
|
1175
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1291
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1176
1292
|
items = newItems.slice(0);
|
|
1177
1293
|
}
|
|
1178
1294
|
return mapped;
|
|
@@ -1182,7 +1298,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1182
1298
|
if (indexes) {
|
|
1183
1299
|
const [s, set] = createSignal(j, {
|
|
1184
1300
|
name: "index"
|
|
1185
|
-
})
|
|
1301
|
+
});
|
|
1186
1302
|
indexes[j] = set;
|
|
1187
1303
|
return mapFn(newItems[j], s);
|
|
1188
1304
|
}
|
|
@@ -1240,13 +1356,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1240
1356
|
}
|
|
1241
1357
|
len = signals.length = disposers.length = newItems.length;
|
|
1242
1358
|
items = newItems.slice(0);
|
|
1243
|
-
return mapped = mapped.slice(0, len);
|
|
1359
|
+
return (mapped = mapped.slice(0, len));
|
|
1244
1360
|
});
|
|
1245
1361
|
function mapper(disposer) {
|
|
1246
1362
|
disposers[i] = disposer;
|
|
1247
1363
|
const [s, set] = createSignal(newItems[i], {
|
|
1248
1364
|
name: "value"
|
|
1249
|
-
})
|
|
1365
|
+
});
|
|
1250
1366
|
signals[i] = set;
|
|
1251
1367
|
return mapFn(s, i);
|
|
1252
1368
|
}
|
|
@@ -1262,7 +1378,7 @@ function createComponent(Comp, props) {
|
|
|
1262
1378
|
if (sharedConfig.context) {
|
|
1263
1379
|
const c = sharedConfig.context;
|
|
1264
1380
|
setHydrateContext(nextHydrateContext());
|
|
1265
|
-
const r = devComponent(Comp, props || {})
|
|
1381
|
+
const r = devComponent(Comp, props || {});
|
|
1266
1382
|
setHydrateContext(c);
|
|
1267
1383
|
return r;
|
|
1268
1384
|
}
|
|
@@ -1311,29 +1427,33 @@ function mergeProps(...sources) {
|
|
|
1311
1427
|
let proxy = false;
|
|
1312
1428
|
for (let i = 0; i < sources.length; i++) {
|
|
1313
1429
|
const s = sources[i];
|
|
1314
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1315
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1430
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1431
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1316
1432
|
}
|
|
1317
1433
|
if (proxy) {
|
|
1318
|
-
return new Proxy(
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1434
|
+
return new Proxy(
|
|
1435
|
+
{
|
|
1436
|
+
get(property) {
|
|
1437
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1438
|
+
const v = resolveSource(sources[i])[property];
|
|
1439
|
+
if (v !== undefined) return v;
|
|
1440
|
+
}
|
|
1441
|
+
},
|
|
1442
|
+
has(property) {
|
|
1443
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1444
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1445
|
+
}
|
|
1446
|
+
return false;
|
|
1447
|
+
},
|
|
1448
|
+
keys() {
|
|
1449
|
+
const keys = [];
|
|
1450
|
+
for (let i = 0; i < sources.length; i++)
|
|
1451
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1452
|
+
return [...new Set(keys)];
|
|
1328
1453
|
}
|
|
1329
|
-
return false;
|
|
1330
1454
|
},
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1334
|
-
return [...new Set(keys)];
|
|
1335
|
-
}
|
|
1336
|
-
}, propTraps);
|
|
1455
|
+
propTraps
|
|
1456
|
+
);
|
|
1337
1457
|
}
|
|
1338
1458
|
const target = {};
|
|
1339
1459
|
const sourcesMap = {};
|
|
@@ -1352,7 +1472,7 @@ function mergeProps(...sources) {
|
|
|
1352
1472
|
Object.defineProperty(target, key, {
|
|
1353
1473
|
enumerable: true,
|
|
1354
1474
|
configurable: true,
|
|
1355
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1475
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1356
1476
|
});
|
|
1357
1477
|
} else {
|
|
1358
1478
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1376,47 +1496,60 @@ function splitProps(props, ...keys) {
|
|
|
1376
1496
|
if ($PROXY in props) {
|
|
1377
1497
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1378
1498
|
const res = keys.map(k => {
|
|
1379
|
-
return new Proxy(
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1499
|
+
return new Proxy(
|
|
1500
|
+
{
|
|
1501
|
+
get(property) {
|
|
1502
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1503
|
+
},
|
|
1504
|
+
has(property) {
|
|
1505
|
+
return k.includes(property) && property in props;
|
|
1506
|
+
},
|
|
1507
|
+
keys() {
|
|
1508
|
+
return k.filter(property => property in props);
|
|
1509
|
+
}
|
|
1385
1510
|
},
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
}
|
|
1389
|
-
}, propTraps);
|
|
1511
|
+
propTraps
|
|
1512
|
+
);
|
|
1390
1513
|
});
|
|
1391
|
-
res.push(
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1514
|
+
res.push(
|
|
1515
|
+
new Proxy(
|
|
1516
|
+
{
|
|
1517
|
+
get(property) {
|
|
1518
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1519
|
+
},
|
|
1520
|
+
has(property) {
|
|
1521
|
+
return blocked.has(property) ? false : property in props;
|
|
1522
|
+
},
|
|
1523
|
+
keys() {
|
|
1524
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1527
|
+
propTraps
|
|
1528
|
+
)
|
|
1529
|
+
);
|
|
1402
1530
|
return res;
|
|
1403
1531
|
}
|
|
1404
1532
|
const otherObject = {};
|
|
1405
1533
|
const objects = keys.map(() => ({}));
|
|
1406
1534
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1407
1535
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1408
|
-
const isDefaultDesc =
|
|
1536
|
+
const isDefaultDesc =
|
|
1537
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1409
1538
|
let blocked = false;
|
|
1410
1539
|
let objectIndex = 0;
|
|
1411
1540
|
for (const k of keys) {
|
|
1412
1541
|
if (k.includes(propName)) {
|
|
1413
1542
|
blocked = true;
|
|
1414
|
-
isDefaultDesc
|
|
1543
|
+
isDefaultDesc
|
|
1544
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1545
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1415
1546
|
}
|
|
1416
1547
|
++objectIndex;
|
|
1417
1548
|
}
|
|
1418
1549
|
if (!blocked) {
|
|
1419
|
-
isDefaultDesc
|
|
1550
|
+
isDefaultDesc
|
|
1551
|
+
? (otherObject[propName] = desc.value)
|
|
1552
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1420
1553
|
}
|
|
1421
1554
|
}
|
|
1422
1555
|
return [...objects, otherObject];
|
|
@@ -1442,19 +1575,24 @@ function lazy(fn) {
|
|
|
1442
1575
|
comp = s;
|
|
1443
1576
|
}
|
|
1444
1577
|
let Comp;
|
|
1445
|
-
return createMemo(
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1578
|
+
return createMemo(
|
|
1579
|
+
() =>
|
|
1580
|
+
(Comp = comp()) &&
|
|
1581
|
+
untrack(() => {
|
|
1582
|
+
if (true)
|
|
1583
|
+
Object.assign(Comp, {
|
|
1584
|
+
[$DEVCOMP]: true
|
|
1585
|
+
});
|
|
1586
|
+
if (!ctx) return Comp(props);
|
|
1587
|
+
const c = sharedConfig.context;
|
|
1588
|
+
setHydrateContext(ctx);
|
|
1589
|
+
const r = Comp(props);
|
|
1590
|
+
setHydrateContext(c);
|
|
1591
|
+
return r;
|
|
1592
|
+
})
|
|
1593
|
+
);
|
|
1456
1594
|
};
|
|
1457
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1595
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1458
1596
|
return wrap;
|
|
1459
1597
|
}
|
|
1460
1598
|
let counter = 0;
|
|
@@ -1463,75 +1601,113 @@ function createUniqueId() {
|
|
|
1463
1601
|
return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
|
|
1464
1602
|
}
|
|
1465
1603
|
|
|
1466
|
-
const narrowedError = name =>
|
|
1604
|
+
const narrowedError = name =>
|
|
1605
|
+
`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.`;
|
|
1467
1606
|
function For(props) {
|
|
1468
1607
|
const fallback = "fallback" in props && {
|
|
1469
1608
|
fallback: () => props.fallback
|
|
1470
1609
|
};
|
|
1471
|
-
return createMemo(
|
|
1472
|
-
|
|
1473
|
-
|
|
1610
|
+
return createMemo(
|
|
1611
|
+
mapArray(() => props.each, props.children, fallback || undefined),
|
|
1612
|
+
undefined,
|
|
1613
|
+
{
|
|
1614
|
+
name: "value"
|
|
1615
|
+
}
|
|
1616
|
+
);
|
|
1474
1617
|
}
|
|
1475
1618
|
function Index(props) {
|
|
1476
1619
|
const fallback = "fallback" in props && {
|
|
1477
1620
|
fallback: () => props.fallback
|
|
1478
1621
|
};
|
|
1479
|
-
return createMemo(
|
|
1480
|
-
|
|
1481
|
-
|
|
1622
|
+
return createMemo(
|
|
1623
|
+
indexArray(() => props.each, props.children, fallback || undefined),
|
|
1624
|
+
undefined,
|
|
1625
|
+
{
|
|
1626
|
+
name: "value"
|
|
1627
|
+
}
|
|
1628
|
+
);
|
|
1482
1629
|
}
|
|
1483
1630
|
function Show(props) {
|
|
1484
1631
|
const keyed = props.keyed;
|
|
1485
1632
|
const condition = createMemo(() => props.when, undefined, {
|
|
1486
|
-
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1633
|
+
equals: (a, b) => (keyed ? a === b : !a === !b),
|
|
1487
1634
|
name: "condition"
|
|
1488
|
-
}
|
|
1489
|
-
return createMemo(
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1635
|
+
});
|
|
1636
|
+
return createMemo(
|
|
1637
|
+
() => {
|
|
1638
|
+
const c = condition();
|
|
1639
|
+
if (c) {
|
|
1640
|
+
const child = props.children;
|
|
1641
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1642
|
+
return fn
|
|
1643
|
+
? untrack(() =>
|
|
1644
|
+
child(
|
|
1645
|
+
keyed
|
|
1646
|
+
? c
|
|
1647
|
+
: () => {
|
|
1648
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1649
|
+
return props.when;
|
|
1650
|
+
}
|
|
1651
|
+
)
|
|
1652
|
+
)
|
|
1653
|
+
: child;
|
|
1654
|
+
}
|
|
1655
|
+
return props.fallback;
|
|
1656
|
+
},
|
|
1657
|
+
undefined,
|
|
1658
|
+
{
|
|
1659
|
+
name: "value"
|
|
1498
1660
|
}
|
|
1499
|
-
|
|
1500
|
-
}, undefined, {
|
|
1501
|
-
name: "value"
|
|
1502
|
-
} );
|
|
1661
|
+
);
|
|
1503
1662
|
}
|
|
1504
1663
|
function Switch(props) {
|
|
1505
1664
|
let keyed = false;
|
|
1506
|
-
const equals = (a, b) =>
|
|
1665
|
+
const equals = (a, b) =>
|
|
1666
|
+
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1507
1667
|
const conditions = children(() => props.children),
|
|
1508
|
-
evalConditions = createMemo(
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1668
|
+
evalConditions = createMemo(
|
|
1669
|
+
() => {
|
|
1670
|
+
let conds = conditions();
|
|
1671
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1672
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1673
|
+
const c = conds[i].when;
|
|
1674
|
+
if (c) {
|
|
1675
|
+
keyed = !!conds[i].keyed;
|
|
1676
|
+
return [i, c, conds[i]];
|
|
1677
|
+
}
|
|
1516
1678
|
}
|
|
1679
|
+
return [-1];
|
|
1680
|
+
},
|
|
1681
|
+
undefined,
|
|
1682
|
+
{
|
|
1683
|
+
equals,
|
|
1684
|
+
name: "eval conditions"
|
|
1517
1685
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1686
|
+
);
|
|
1687
|
+
return createMemo(
|
|
1688
|
+
() => {
|
|
1689
|
+
const [index, when, cond] = evalConditions();
|
|
1690
|
+
if (index < 0) return props.fallback;
|
|
1691
|
+
const c = cond.children;
|
|
1692
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1693
|
+
return fn
|
|
1694
|
+
? untrack(() =>
|
|
1695
|
+
c(
|
|
1696
|
+
keyed
|
|
1697
|
+
? when
|
|
1698
|
+
: () => {
|
|
1699
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1700
|
+
return cond.when;
|
|
1701
|
+
}
|
|
1702
|
+
)
|
|
1703
|
+
)
|
|
1704
|
+
: c;
|
|
1705
|
+
},
|
|
1706
|
+
undefined,
|
|
1707
|
+
{
|
|
1708
|
+
name: "value"
|
|
1709
|
+
}
|
|
1710
|
+
);
|
|
1535
1711
|
}
|
|
1536
1712
|
function Match(props) {
|
|
1537
1713
|
return props;
|
|
@@ -1542,27 +1718,33 @@ function resetErrorBoundaries() {
|
|
|
1542
1718
|
}
|
|
1543
1719
|
function ErrorBoundary(props) {
|
|
1544
1720
|
let err;
|
|
1545
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1721
|
+
if (sharedConfig.context && sharedConfig.load)
|
|
1722
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1546
1723
|
const [errored, setErrored] = createSignal(err, {
|
|
1547
1724
|
name: "errored"
|
|
1548
|
-
}
|
|
1725
|
+
});
|
|
1549
1726
|
Errors || (Errors = new Set());
|
|
1550
1727
|
Errors.add(setErrored);
|
|
1551
1728
|
onCleanup(() => Errors.delete(setErrored));
|
|
1552
|
-
return createMemo(
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1729
|
+
return createMemo(
|
|
1730
|
+
() => {
|
|
1731
|
+
let e;
|
|
1732
|
+
if ((e = errored())) {
|
|
1733
|
+
const f = props.fallback;
|
|
1734
|
+
if (typeof f !== "function" || f.length == 0) console.error(e);
|
|
1735
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1736
|
+
}
|
|
1737
|
+
return catchError(() => props.children, setErrored);
|
|
1738
|
+
},
|
|
1739
|
+
undefined,
|
|
1740
|
+
{
|
|
1741
|
+
name: "value"
|
|
1558
1742
|
}
|
|
1559
|
-
|
|
1560
|
-
}, undefined, {
|
|
1561
|
-
name: "value"
|
|
1562
|
-
} );
|
|
1743
|
+
);
|
|
1563
1744
|
}
|
|
1564
1745
|
|
|
1565
|
-
const suspenseListEquals = (a, b) =>
|
|
1746
|
+
const suspenseListEquals = (a, b) =>
|
|
1747
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1566
1748
|
const SuspenseListContext = createContext();
|
|
1567
1749
|
function SuspenseList(props) {
|
|
1568
1750
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1574,51 +1756,51 @@ function SuspenseList(props) {
|
|
|
1574
1756
|
if (listContext) {
|
|
1575
1757
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1576
1758
|
}
|
|
1577
|
-
const resolved = createMemo(
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
showContent = true,
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
const res = reg.map(() => ({
|
|
1589
|
-
showContent: all && showContent,
|
|
1590
|
-
showFallback
|
|
1591
|
-
}));
|
|
1592
|
-
res.inFallback = !all;
|
|
1593
|
-
return res;
|
|
1594
|
-
}
|
|
1595
|
-
let stop = false;
|
|
1596
|
-
let inFallback = prev.inFallback;
|
|
1597
|
-
const res = [];
|
|
1598
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1599
|
-
const n = reverse ? len - i - 1 : i,
|
|
1600
|
-
s = reg[n]();
|
|
1601
|
-
if (!stop && !s) {
|
|
1602
|
-
res[n] = {
|
|
1603
|
-
showContent,
|
|
1759
|
+
const resolved = createMemo(
|
|
1760
|
+
prev => {
|
|
1761
|
+
const reveal = props.revealOrder,
|
|
1762
|
+
tail = props.tail,
|
|
1763
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1764
|
+
reg = registry(),
|
|
1765
|
+
reverse = reveal === "backwards";
|
|
1766
|
+
if (reveal === "together") {
|
|
1767
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1768
|
+
const res = reg.map(() => ({
|
|
1769
|
+
showContent: all && showContent,
|
|
1604
1770
|
showFallback
|
|
1605
|
-
};
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
if (next) inFallback = true;
|
|
1609
|
-
res[n] = {
|
|
1610
|
-
showContent: next,
|
|
1611
|
-
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1612
|
-
};
|
|
1613
|
-
stop = true;
|
|
1771
|
+
}));
|
|
1772
|
+
res.inFallback = !all;
|
|
1773
|
+
return res;
|
|
1614
1774
|
}
|
|
1775
|
+
let stop = false;
|
|
1776
|
+
let inFallback = prev.inFallback;
|
|
1777
|
+
const res = [];
|
|
1778
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1779
|
+
const n = reverse ? len - i - 1 : i,
|
|
1780
|
+
s = reg[n]();
|
|
1781
|
+
if (!stop && !s) {
|
|
1782
|
+
res[n] = {
|
|
1783
|
+
showContent,
|
|
1784
|
+
showFallback
|
|
1785
|
+
};
|
|
1786
|
+
} else {
|
|
1787
|
+
const next = !stop;
|
|
1788
|
+
if (next) inFallback = true;
|
|
1789
|
+
res[n] = {
|
|
1790
|
+
showContent: next,
|
|
1791
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1792
|
+
};
|
|
1793
|
+
stop = true;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
if (!stop) inFallback = false;
|
|
1797
|
+
res.inFallback = inFallback;
|
|
1798
|
+
return res;
|
|
1799
|
+
},
|
|
1800
|
+
{
|
|
1801
|
+
inFallback: false
|
|
1615
1802
|
}
|
|
1616
|
-
|
|
1617
|
-
res.inFallback = inFallback;
|
|
1618
|
-
return res;
|
|
1619
|
-
}, {
|
|
1620
|
-
inFallback: false
|
|
1621
|
-
});
|
|
1803
|
+
);
|
|
1622
1804
|
setWrapper(() => resolved);
|
|
1623
1805
|
return createComponent(SuspenseListContext.Provider, {
|
|
1624
1806
|
value: {
|
|
@@ -1693,17 +1875,14 @@ function Suspense(props) {
|
|
|
1693
1875
|
ctx = sharedConfig.context;
|
|
1694
1876
|
if (flicker) {
|
|
1695
1877
|
flicker();
|
|
1696
|
-
return flicker = undefined;
|
|
1878
|
+
return (flicker = undefined);
|
|
1697
1879
|
}
|
|
1698
1880
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1699
1881
|
const rendered = createMemo(() => props.children);
|
|
1700
1882
|
return createMemo(prev => {
|
|
1701
1883
|
const inFallback = store.inFallback(),
|
|
1702
|
-
{
|
|
1703
|
-
|
|
1704
|
-
showFallback = true
|
|
1705
|
-
} = show ? show() : {};
|
|
1706
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1884
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1885
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1707
1886
|
store.resolved = true;
|
|
1708
1887
|
dispose && dispose();
|
|
1709
1888
|
dispose = ctx = p = undefined;
|
|
@@ -1733,9 +1912,68 @@ const DEV = {
|
|
|
1733
1912
|
hooks: DevHooks,
|
|
1734
1913
|
writeSignal,
|
|
1735
1914
|
registerGraph
|
|
1736
|
-
}
|
|
1915
|
+
};
|
|
1737
1916
|
if (globalThis) {
|
|
1738
|
-
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1917
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1918
|
+
else
|
|
1919
|
+
console.warn(
|
|
1920
|
+
"You appear to have multiple instances of Solid. This can lead to unexpected behavior."
|
|
1921
|
+
);
|
|
1739
1922
|
}
|
|
1740
1923
|
|
|
1741
|
-
export {
|
|
1924
|
+
export {
|
|
1925
|
+
$DEVCOMP,
|
|
1926
|
+
$PROXY,
|
|
1927
|
+
$TRACK,
|
|
1928
|
+
DEV,
|
|
1929
|
+
ErrorBoundary,
|
|
1930
|
+
For,
|
|
1931
|
+
Index,
|
|
1932
|
+
Match,
|
|
1933
|
+
Show,
|
|
1934
|
+
Suspense,
|
|
1935
|
+
SuspenseList,
|
|
1936
|
+
Switch,
|
|
1937
|
+
batch,
|
|
1938
|
+
cancelCallback,
|
|
1939
|
+
catchError,
|
|
1940
|
+
children,
|
|
1941
|
+
createComponent,
|
|
1942
|
+
createComputed,
|
|
1943
|
+
createContext,
|
|
1944
|
+
createDeferred,
|
|
1945
|
+
createEffect,
|
|
1946
|
+
createMemo,
|
|
1947
|
+
createReaction,
|
|
1948
|
+
createRenderEffect,
|
|
1949
|
+
createResource,
|
|
1950
|
+
createRoot,
|
|
1951
|
+
createSelector,
|
|
1952
|
+
createSignal,
|
|
1953
|
+
createUniqueId,
|
|
1954
|
+
enableExternalSource,
|
|
1955
|
+
enableHydration,
|
|
1956
|
+
enableScheduling,
|
|
1957
|
+
equalFn,
|
|
1958
|
+
from,
|
|
1959
|
+
getListener,
|
|
1960
|
+
getOwner,
|
|
1961
|
+
indexArray,
|
|
1962
|
+
lazy,
|
|
1963
|
+
mapArray,
|
|
1964
|
+
mergeProps,
|
|
1965
|
+
observable,
|
|
1966
|
+
on,
|
|
1967
|
+
onCleanup,
|
|
1968
|
+
onError,
|
|
1969
|
+
onMount,
|
|
1970
|
+
requestCallback,
|
|
1971
|
+
resetErrorBoundaries,
|
|
1972
|
+
runWithOwner,
|
|
1973
|
+
sharedConfig,
|
|
1974
|
+
splitProps,
|
|
1975
|
+
startTransition,
|
|
1976
|
+
untrack,
|
|
1977
|
+
useContext,
|
|
1978
|
+
useTransition
|
|
1979
|
+
};
|