solid-js 2.0.0-beta.6 → 2.0.0-beta.8
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 +66 -104
- package/dist/dev.js +66 -104
- package/dist/server.cjs +331 -132
- package/dist/server.js +331 -132
- package/dist/solid.cjs +66 -104
- package/dist/solid.js +66 -104
- package/package.json +78 -30
- package/types/client/flow.d.ts +34 -13
- package/types/client/hydration.d.ts +35 -9
- package/types/jsx-properties.d.ts +92 -0
- package/types/jsx.d.ts +390 -314
- package/types/server/flow.d.ts +40 -7
- package/types/server/hydration.d.ts +18 -1
- package/types/server/signals.d.ts +33 -15
- package/types-cjs/client/component.d.cts +75 -0
- package/types-cjs/client/core.d.cts +58 -0
- package/types-cjs/client/flow.d.cts +163 -0
- package/types-cjs/client/hydration.d.cts +121 -0
- package/types-cjs/index.d.cts +17 -0
- package/types-cjs/jsx-properties.d.cts +92 -0
- package/types-cjs/jsx.d.cts +4294 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/server/component.d.cts +67 -0
- package/types-cjs/server/core.d.cts +44 -0
- package/types-cjs/server/flow.d.cts +115 -0
- package/types-cjs/server/hydration.d.cts +63 -0
- package/types-cjs/server/index.d.cts +12 -0
- package/types-cjs/server/shared.d.cts +50 -0
- package/types-cjs/server/signals.d.cts +87 -0
package/dist/solid.cjs
CHANGED
|
@@ -20,10 +20,10 @@ function useContext(context) {
|
|
|
20
20
|
return signals.getContext(context);
|
|
21
21
|
}
|
|
22
22
|
function children(fn) {
|
|
23
|
-
const c = signals.createMemo(fn,
|
|
23
|
+
const c = signals.createMemo(fn, {
|
|
24
24
|
lazy: true
|
|
25
25
|
});
|
|
26
|
-
const memo = signals.createMemo(() => signals.flatten(c()),
|
|
26
|
+
const memo = signals.createMemo(() => signals.flatten(c()), {
|
|
27
27
|
lazy: true
|
|
28
28
|
});
|
|
29
29
|
memo.toArray = () => {
|
|
@@ -265,7 +265,7 @@ function wrapFirstYield(iterable, activate) {
|
|
|
265
265
|
}
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
|
-
function hydrateSignalFromAsyncIterable(coreFn, compute,
|
|
268
|
+
function hydrateSignalFromAsyncIterable(coreFn, compute, options) {
|
|
269
269
|
const parent = signals.getOwner();
|
|
270
270
|
const expectedId = signals.peekNextChildId(parent);
|
|
271
271
|
if (!sharedConfig.has(expectedId)) return null;
|
|
@@ -277,9 +277,12 @@ function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
|
|
|
277
277
|
return it;
|
|
278
278
|
}
|
|
279
279
|
};
|
|
280
|
-
return coreFn(
|
|
280
|
+
return coreFn(prev => {
|
|
281
|
+
subFetch(compute, prev);
|
|
282
|
+
return iterable;
|
|
283
|
+
}, options);
|
|
281
284
|
}
|
|
282
|
-
function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
285
|
+
function hydrateStoreFromAsyncIterable(coreFn, fn, initialValue, options) {
|
|
283
286
|
const parent = signals.getOwner();
|
|
284
287
|
const expectedId = signals.peekNextChildId(parent);
|
|
285
288
|
if (!sharedConfig.has(expectedId)) return null;
|
|
@@ -289,6 +292,10 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
|
289
292
|
let isFirst = true;
|
|
290
293
|
let buffered = null;
|
|
291
294
|
return coreFn(draft => {
|
|
295
|
+
const {
|
|
296
|
+
proxy
|
|
297
|
+
} = createShadowDraft(draft);
|
|
298
|
+
subFetch(fn, proxy);
|
|
292
299
|
const process = res => {
|
|
293
300
|
if (res.done) return {
|
|
294
301
|
done: true,
|
|
@@ -296,11 +303,16 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
|
296
303
|
};
|
|
297
304
|
if (isFirst) {
|
|
298
305
|
isFirst = false;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
306
|
+
signals.setSnapshotCapture(false);
|
|
307
|
+
try {
|
|
308
|
+
if (Array.isArray(res.value)) {
|
|
309
|
+
for (let i = 0; i < res.value.length; i++) draft[i] = res.value[i];
|
|
310
|
+
draft.length = res.value.length;
|
|
311
|
+
} else {
|
|
312
|
+
Object.assign(draft, res.value);
|
|
313
|
+
}
|
|
314
|
+
} finally {
|
|
315
|
+
signals.setSnapshotCapture(true);
|
|
304
316
|
}
|
|
305
317
|
} else {
|
|
306
318
|
applyPatches(draft, res.value);
|
|
@@ -352,59 +364,45 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
|
352
364
|
};
|
|
353
365
|
}, initialValue, options);
|
|
354
366
|
}
|
|
355
|
-
function hydratedCreateMemo(compute,
|
|
367
|
+
function hydratedCreateMemo(compute, options) {
|
|
356
368
|
if (!sharedConfig.hydrating || options?.transparent) {
|
|
357
|
-
return signals.createMemo(compute,
|
|
369
|
+
return signals.createMemo(compute, options);
|
|
358
370
|
}
|
|
359
371
|
markTopLevelSnapshotScope();
|
|
360
372
|
const ssrSource = options?.ssrSource;
|
|
361
373
|
if (ssrSource === "client") {
|
|
362
374
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
363
|
-
|
|
375
|
+
ownedWrite: true
|
|
364
376
|
});
|
|
365
377
|
const memo = signals.createMemo(prev => {
|
|
366
|
-
if (!hydrated()) return prev
|
|
378
|
+
if (!hydrated()) return prev;
|
|
367
379
|
return compute(prev);
|
|
368
|
-
},
|
|
380
|
+
}, options);
|
|
369
381
|
setHydrated(true);
|
|
370
382
|
return memo;
|
|
371
383
|
}
|
|
372
|
-
|
|
373
|
-
return signals.createMemo(prev => {
|
|
374
|
-
if (!sharedConfig.hydrating) return compute(prev);
|
|
375
|
-
subFetch(compute, prev);
|
|
376
|
-
return prev ?? value;
|
|
377
|
-
}, value, options);
|
|
378
|
-
}
|
|
379
|
-
const aiResult = hydrateSignalFromAsyncIterable(signals.createMemo, compute, value, options);
|
|
384
|
+
const aiResult = hydrateSignalFromAsyncIterable(signals.createMemo, compute, options);
|
|
380
385
|
if (aiResult !== null) return aiResult;
|
|
381
|
-
return signals.createMemo(prev => readSerializedOrCompute(compute, prev),
|
|
386
|
+
return signals.createMemo(prev => readSerializedOrCompute(compute, prev), options);
|
|
382
387
|
}
|
|
383
|
-
function hydratedCreateSignal(fn, second
|
|
384
|
-
if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second
|
|
388
|
+
function hydratedCreateSignal(fn, second) {
|
|
389
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second);
|
|
385
390
|
markTopLevelSnapshotScope();
|
|
386
|
-
const ssrSource =
|
|
391
|
+
const ssrSource = second?.ssrSource;
|
|
387
392
|
if (ssrSource === "client") {
|
|
388
393
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
389
|
-
|
|
394
|
+
ownedWrite: true
|
|
390
395
|
});
|
|
391
396
|
const sig = signals.createSignal(prev => {
|
|
392
|
-
if (!hydrated()) return prev
|
|
397
|
+
if (!hydrated()) return prev;
|
|
393
398
|
return fn(prev);
|
|
394
|
-
}, second
|
|
399
|
+
}, second);
|
|
395
400
|
setHydrated(true);
|
|
396
401
|
return sig;
|
|
397
402
|
}
|
|
398
|
-
|
|
399
|
-
return signals.createSignal(prev => {
|
|
400
|
-
if (!sharedConfig.hydrating) return fn(prev);
|
|
401
|
-
subFetch(fn, prev);
|
|
402
|
-
return prev ?? second;
|
|
403
|
-
}, second, third);
|
|
404
|
-
}
|
|
405
|
-
const aiResult = hydrateSignalFromAsyncIterable(signals.createSignal, fn, second, third);
|
|
403
|
+
const aiResult = hydrateSignalFromAsyncIterable(signals.createSignal, fn, second);
|
|
406
404
|
if (aiResult !== null) return aiResult;
|
|
407
|
-
return signals.createSignal(prev => readSerializedOrCompute(fn, prev), second
|
|
405
|
+
return signals.createSignal(prev => readSerializedOrCompute(fn, prev), second);
|
|
408
406
|
}
|
|
409
407
|
function hydratedCreateErrorBoundary(fn, fallback) {
|
|
410
408
|
if (!sharedConfig.hydrating) return signals.createErrorBoundary(fn, fallback);
|
|
@@ -426,31 +424,24 @@ function hydratedCreateErrorBoundary(fn, fallback) {
|
|
|
426
424
|
}
|
|
427
425
|
return signals.createErrorBoundary(fn, fallback);
|
|
428
426
|
}
|
|
429
|
-
function hydratedCreateOptimistic(fn, second
|
|
430
|
-
if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createOptimistic(fn, second
|
|
427
|
+
function hydratedCreateOptimistic(fn, second) {
|
|
428
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createOptimistic(fn, second);
|
|
431
429
|
markTopLevelSnapshotScope();
|
|
432
|
-
const ssrSource =
|
|
430
|
+
const ssrSource = second?.ssrSource;
|
|
433
431
|
if (ssrSource === "client") {
|
|
434
432
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
435
|
-
|
|
433
|
+
ownedWrite: true
|
|
436
434
|
});
|
|
437
435
|
const sig = signals.createOptimistic(prev => {
|
|
438
|
-
if (!hydrated()) return prev
|
|
436
|
+
if (!hydrated()) return prev;
|
|
439
437
|
return fn(prev);
|
|
440
|
-
}, second
|
|
438
|
+
}, second);
|
|
441
439
|
setHydrated(true);
|
|
442
440
|
return sig;
|
|
443
441
|
}
|
|
444
|
-
|
|
445
|
-
return signals.createOptimistic(prev => {
|
|
446
|
-
if (!sharedConfig.hydrating) return fn(prev);
|
|
447
|
-
subFetch(fn, prev);
|
|
448
|
-
return prev ?? second;
|
|
449
|
-
}, second, third);
|
|
450
|
-
}
|
|
451
|
-
const aiResult = hydrateSignalFromAsyncIterable(signals.createOptimistic, fn, second, third);
|
|
442
|
+
const aiResult = hydrateSignalFromAsyncIterable(signals.createOptimistic, fn, second);
|
|
452
443
|
if (aiResult !== null) return aiResult;
|
|
453
|
-
return signals.createOptimistic(prev => readSerializedOrCompute(fn, prev), second
|
|
444
|
+
return signals.createOptimistic(prev => readSerializedOrCompute(fn, prev), second);
|
|
454
445
|
}
|
|
455
446
|
function wrapStoreFn(fn) {
|
|
456
447
|
return draft => readSerializedOrCompute(() => fn(draft), draft);
|
|
@@ -458,7 +449,7 @@ function wrapStoreFn(fn) {
|
|
|
458
449
|
function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
459
450
|
if (ssrSource === "client") {
|
|
460
451
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
461
|
-
|
|
452
|
+
ownedWrite: true
|
|
462
453
|
});
|
|
463
454
|
const result = coreFn(draft => {
|
|
464
455
|
if (!hydrated()) return;
|
|
@@ -469,7 +460,7 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
|
469
460
|
}
|
|
470
461
|
if (ssrSource === "hybrid") {
|
|
471
462
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
472
|
-
|
|
463
|
+
ownedWrite: true
|
|
473
464
|
});
|
|
474
465
|
const result = coreFn(draft => {
|
|
475
466
|
const o = signals.getOwner();
|
|
@@ -491,7 +482,7 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
|
491
482
|
setHydrated(true);
|
|
492
483
|
return result;
|
|
493
484
|
}
|
|
494
|
-
const aiResult = hydrateStoreFromAsyncIterable(coreFn, initialValue, options);
|
|
485
|
+
const aiResult = hydrateStoreFromAsyncIterable(coreFn, fn, initialValue, options);
|
|
495
486
|
if (aiResult !== null) return aiResult;
|
|
496
487
|
return coreFn(wrapStoreFn(fn), initialValue, options);
|
|
497
488
|
}
|
|
@@ -499,58 +490,47 @@ function hydratedCreateStore(first, second, third) {
|
|
|
499
490
|
if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createStore(first, second, third);
|
|
500
491
|
markTopLevelSnapshotScope();
|
|
501
492
|
const ssrSource = third?.ssrSource;
|
|
502
|
-
if (ssrSource === "initial") return signals.createStore(second ?? {}, undefined, third);
|
|
503
493
|
return hydrateStoreLikeFn(signals.createStore, first, second ?? {}, third, ssrSource);
|
|
504
494
|
}
|
|
505
495
|
function hydratedCreateOptimisticStore(first, second, third) {
|
|
506
496
|
if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createOptimisticStore(first, second, third);
|
|
507
497
|
markTopLevelSnapshotScope();
|
|
508
498
|
const ssrSource = third?.ssrSource;
|
|
509
|
-
if (ssrSource === "initial") return signals.createOptimisticStore(second ?? {}, undefined, third);
|
|
510
499
|
return hydrateStoreLikeFn(signals.createOptimisticStore, first, second ?? {}, third, ssrSource);
|
|
511
500
|
}
|
|
512
501
|
function hydratedCreateProjection(fn, initialValue, options) {
|
|
513
502
|
if (!sharedConfig.hydrating) return signals.createProjection(fn, initialValue, options);
|
|
514
503
|
markTopLevelSnapshotScope();
|
|
515
504
|
const ssrSource = options?.ssrSource;
|
|
516
|
-
if (ssrSource === "initial") return signals.createProjection(draft => draft, initialValue, options);
|
|
517
505
|
return hydrateStoreLikeFn(signals.createProjection, fn, initialValue, options, ssrSource);
|
|
518
506
|
}
|
|
519
|
-
function hydratedEffect(coreFn, compute, effectFn,
|
|
520
|
-
if (!sharedConfig.hydrating) return coreFn(compute, effectFn,
|
|
507
|
+
function hydratedEffect(coreFn, compute, effectFn, options) {
|
|
508
|
+
if (!sharedConfig.hydrating || options?.transparent) return coreFn(compute, effectFn, options);
|
|
521
509
|
const ssrSource = options?.ssrSource;
|
|
522
510
|
if (ssrSource === "client") {
|
|
523
511
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
524
|
-
|
|
512
|
+
ownedWrite: true
|
|
525
513
|
});
|
|
526
514
|
let active = false;
|
|
527
515
|
coreFn(prev => {
|
|
528
|
-
if (!hydrated()) return
|
|
516
|
+
if (!hydrated()) return prev;
|
|
529
517
|
active = true;
|
|
530
518
|
return compute(prev);
|
|
531
519
|
}, (next, prev) => {
|
|
532
520
|
if (!active) return;
|
|
533
521
|
return effectFn(next, prev);
|
|
534
|
-
},
|
|
522
|
+
}, options);
|
|
535
523
|
setHydrated(true);
|
|
536
524
|
return;
|
|
537
525
|
}
|
|
538
|
-
if (ssrSource === "initial") {
|
|
539
|
-
coreFn(prev => {
|
|
540
|
-
if (!sharedConfig.hydrating) return compute(prev);
|
|
541
|
-
subFetch(compute, prev);
|
|
542
|
-
return prev ?? value;
|
|
543
|
-
}, effectFn, value, options);
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
526
|
markTopLevelSnapshotScope();
|
|
547
|
-
coreFn(prev => readSerializedOrCompute(compute, prev), effectFn,
|
|
527
|
+
coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, options);
|
|
548
528
|
}
|
|
549
|
-
function hydratedCreateRenderEffect(compute, effectFn,
|
|
550
|
-
return hydratedEffect(signals.createRenderEffect, compute, effectFn,
|
|
529
|
+
function hydratedCreateRenderEffect(compute, effectFn, options) {
|
|
530
|
+
return hydratedEffect(signals.createRenderEffect, compute, effectFn, options);
|
|
551
531
|
}
|
|
552
|
-
function hydratedCreateEffect(compute, effectFn,
|
|
553
|
-
return hydratedEffect(signals.createEffect, compute, effectFn,
|
|
532
|
+
function hydratedCreateEffect(compute, effectFn, options) {
|
|
533
|
+
return hydratedEffect(signals.createEffect, compute, effectFn, options);
|
|
554
534
|
}
|
|
555
535
|
function enableHydration() {
|
|
556
536
|
_createMemo = hydratedCreateMemo;
|
|
@@ -609,24 +589,6 @@ const createStore = (...args) => (_createStore || signals.createStore)(...args);
|
|
|
609
589
|
const createOptimisticStore = (...args) => (_createOptimisticStore || signals.createOptimisticStore)(...args);
|
|
610
590
|
const createRenderEffect = (...args) => (_createRenderEffect || signals.createRenderEffect)(...args);
|
|
611
591
|
const createEffect = (...args) => (_createEffect || signals.createEffect)(...args);
|
|
612
|
-
function loadModuleAssets(mapping) {
|
|
613
|
-
const hy = globalThis._$HY;
|
|
614
|
-
if (!hy) return;
|
|
615
|
-
if (!hy.modules) hy.modules = {};
|
|
616
|
-
if (!hy.loading) hy.loading = {};
|
|
617
|
-
const pending = [];
|
|
618
|
-
for (const moduleUrl in mapping) {
|
|
619
|
-
if (hy.modules[moduleUrl]) continue;
|
|
620
|
-
const entryUrl = mapping[moduleUrl];
|
|
621
|
-
if (!hy.loading[moduleUrl]) {
|
|
622
|
-
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
623
|
-
hy.modules[moduleUrl] = mod;
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
pending.push(hy.loading[moduleUrl]);
|
|
627
|
-
}
|
|
628
|
-
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
629
|
-
}
|
|
630
592
|
function createBoundaryTrigger() {
|
|
631
593
|
signals.setSnapshotCapture(false);
|
|
632
594
|
const [s, set] = signals.createSignal(undefined, {
|
|
@@ -695,7 +657,7 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
695
657
|
let assetPromise;
|
|
696
658
|
if (sharedConfig.hydrating && sharedConfig.has(id + "_assets")) {
|
|
697
659
|
const mapping = sharedConfig.load(id + "_assets");
|
|
698
|
-
if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
|
|
660
|
+
if (mapping && typeof mapping === "object") assetPromise = sharedConfig.loadModuleAssets?.(mapping);
|
|
699
661
|
}
|
|
700
662
|
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
701
663
|
const ref = sharedConfig.load(id);
|
|
@@ -809,8 +771,8 @@ function Repeat(props) {
|
|
|
809
771
|
}
|
|
810
772
|
function Show(props) {
|
|
811
773
|
const keyed = props.keyed;
|
|
812
|
-
const conditionValue = signals.createMemo(() => props.when, undefined
|
|
813
|
-
const condition = keyed ? conditionValue : signals.createMemo(conditionValue,
|
|
774
|
+
const conditionValue = signals.createMemo(() => props.when, undefined);
|
|
775
|
+
const condition = keyed ? conditionValue : signals.createMemo(conditionValue, {
|
|
814
776
|
equals: (a, b) => !a === !b
|
|
815
777
|
});
|
|
816
778
|
return signals.createMemo(() => {
|
|
@@ -824,7 +786,7 @@ function Show(props) {
|
|
|
824
786
|
}), IS_DEV) : child;
|
|
825
787
|
}
|
|
826
788
|
return props.fallback;
|
|
827
|
-
}, undefined
|
|
789
|
+
}, undefined);
|
|
828
790
|
}
|
|
829
791
|
function Switch(props) {
|
|
830
792
|
const chs = children(() => props.children);
|
|
@@ -835,8 +797,8 @@ function Switch(props) {
|
|
|
835
797
|
const index = i;
|
|
836
798
|
const mp = mps[i];
|
|
837
799
|
const prevFunc = func;
|
|
838
|
-
const conditionValue = signals.createMemo(() => prevFunc() ? undefined : mp.when, undefined
|
|
839
|
-
const condition = mp.keyed ? conditionValue : signals.createMemo(conditionValue,
|
|
800
|
+
const conditionValue = signals.createMemo(() => prevFunc() ? undefined : mp.when, undefined);
|
|
801
|
+
const condition = mp.keyed ? conditionValue : signals.createMemo(conditionValue, {
|
|
840
802
|
equals: (a, b) => !a === !b
|
|
841
803
|
});
|
|
842
804
|
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
@@ -853,7 +815,7 @@ function Switch(props) {
|
|
|
853
815
|
if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
854
816
|
return conditionValue();
|
|
855
817
|
}), IS_DEV) : child;
|
|
856
|
-
}, undefined
|
|
818
|
+
}, undefined);
|
|
857
819
|
}
|
|
858
820
|
function Match(props) {
|
|
859
821
|
return props;
|
|
@@ -872,7 +834,7 @@ function Loading(props) {
|
|
|
872
834
|
}
|
|
873
835
|
function Reveal(props) {
|
|
874
836
|
return signals.createRevealOrder(() => props.children, {
|
|
875
|
-
|
|
837
|
+
order: () => props.order ?? "sequential",
|
|
876
838
|
collapsed: () => !!props.collapsed
|
|
877
839
|
});
|
|
878
840
|
}
|