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