solid-js 2.0.0-beta.4 → 2.0.0-beta.6
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 +136 -113
- package/dist/dev.js +128 -108
- package/dist/server.cjs +350 -131
- package/dist/server.js +347 -134
- package/dist/solid.cjs +130 -99
- package/dist/solid.js +122 -94
- package/package.json +2 -2
- package/types/client/core.d.ts +1 -8
- package/types/client/flow.d.ts +47 -5
- package/types/client/hydration.d.ts +9 -13
- package/types/index.d.ts +4 -7
- package/types/jsx.d.ts +160 -115
- package/types/server/flow.d.ts +27 -5
- package/types/server/hydration.d.ts +11 -4
- package/types/server/index.d.ts +2 -2
- package/types/server/shared.d.ts +5 -1
- package/types/server/signals.d.ts +7 -2
package/dist/solid.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext,
|
|
2
|
-
export { $PROXY, $REFRESH, $TRACK, NotReadyError, action,
|
|
1
|
+
import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createOwner, runWithOwner, createEffect as createEffect$1, createErrorBoundary as createErrorBoundary$1, createLoadingBoundary as createLoadingBoundary$1, getOwner, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createRenderEffect as createRenderEffect$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, getNextChildId, onCleanup, isDisposed, peekNextChildId, clearSnapshots, flush, markSnapshotScope, untrack, mapArray, repeat, createRevealOrder } from '@solidjs/signals';
|
|
2
|
+
export { $PROXY, $REFRESH, $TRACK, NotReadyError, action, createOwner, createReaction, createRevealOrder, createRoot, createTrackedEffect, deep, enableExternalSource, enforceLoadingBoundary, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isPending, isRefreshing, isWrappable, latest, mapArray, merge, omit, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, storePath, untrack } from '@solidjs/signals';
|
|
3
3
|
|
|
4
4
|
const IS_DEV = false;
|
|
5
5
|
const $DEVCOMP = Symbol(0);
|
|
@@ -71,6 +71,7 @@ function drainHydrationCallbacks() {
|
|
|
71
71
|
if (cbs) for (const cb of cbs) cb();
|
|
72
72
|
setTimeout(() => {
|
|
73
73
|
if (globalThis._$HY) globalThis._$HY.done = true;
|
|
74
|
+
sharedConfig.registry?.clear();
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
function checkHydrationComplete() {
|
|
@@ -88,23 +89,10 @@ let _createOptimisticStore;
|
|
|
88
89
|
let _createRenderEffect;
|
|
89
90
|
let _createEffect;
|
|
90
91
|
class MockPromise {
|
|
91
|
-
static
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return new MockPromise();
|
|
96
|
-
}
|
|
97
|
-
static any() {
|
|
98
|
-
return new MockPromise();
|
|
99
|
-
}
|
|
100
|
-
static race() {
|
|
101
|
-
return new MockPromise();
|
|
102
|
-
}
|
|
103
|
-
static reject() {
|
|
104
|
-
return new MockPromise();
|
|
105
|
-
}
|
|
106
|
-
static resolve() {
|
|
107
|
-
return new MockPromise();
|
|
92
|
+
static {
|
|
93
|
+
for (const k of ["all", "allSettled", "any", "race", "reject", "resolve"]) {
|
|
94
|
+
MockPromise[k] = () => new MockPromise();
|
|
95
|
+
}
|
|
108
96
|
}
|
|
109
97
|
catch() {
|
|
110
98
|
return new MockPromise();
|
|
@@ -139,6 +127,28 @@ function syncThenable(value) {
|
|
|
139
127
|
}
|
|
140
128
|
};
|
|
141
129
|
}
|
|
130
|
+
const NO_HYDRATED_VALUE = Symbol("NO_HYDRATED_VALUE");
|
|
131
|
+
function readHydratedValue(initP, refresh) {
|
|
132
|
+
if (initP == null) return NO_HYDRATED_VALUE;
|
|
133
|
+
refresh();
|
|
134
|
+
if (typeof initP === "object" && initP.s === 2) throw initP.v;
|
|
135
|
+
return initP?.v ?? initP;
|
|
136
|
+
}
|
|
137
|
+
function readSerializedOrCompute(compute, prev) {
|
|
138
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
139
|
+
const o = getOwner();
|
|
140
|
+
let initP;
|
|
141
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
142
|
+
const init = readHydratedValue(initP, () => subFetch(compute, prev));
|
|
143
|
+
return init !== NO_HYDRATED_VALUE ? init : compute(prev);
|
|
144
|
+
}
|
|
145
|
+
function forwardIteratorReturn(it, value) {
|
|
146
|
+
const returned = it.return?.(value);
|
|
147
|
+
return returned && typeof returned.then === "function" ? returned : syncThenable(returned ?? {
|
|
148
|
+
done: true,
|
|
149
|
+
value
|
|
150
|
+
});
|
|
151
|
+
}
|
|
142
152
|
function normalizeIterator(it) {
|
|
143
153
|
let first = true;
|
|
144
154
|
let buffered = null;
|
|
@@ -165,6 +175,10 @@ function normalizeIterator(it) {
|
|
|
165
175
|
latest = peek;
|
|
166
176
|
}
|
|
167
177
|
return Promise.resolve(latest);
|
|
178
|
+
},
|
|
179
|
+
return(value) {
|
|
180
|
+
buffered = null;
|
|
181
|
+
return forwardIteratorReturn(it, value);
|
|
168
182
|
}
|
|
169
183
|
};
|
|
170
184
|
}
|
|
@@ -242,6 +256,9 @@ function wrapFirstYield(iterable, activate) {
|
|
|
242
256
|
});
|
|
243
257
|
}
|
|
244
258
|
return p;
|
|
259
|
+
},
|
|
260
|
+
return(value) {
|
|
261
|
+
return forwardIteratorReturn(srcIt, value);
|
|
245
262
|
}
|
|
246
263
|
};
|
|
247
264
|
}
|
|
@@ -324,6 +341,10 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
|
324
341
|
if (!r.done) result = process(r);
|
|
325
342
|
}
|
|
326
343
|
return Promise.resolve(result);
|
|
344
|
+
},
|
|
345
|
+
return(value) {
|
|
346
|
+
buffered = null;
|
|
347
|
+
return forwardIteratorReturn(srcIt, value);
|
|
327
348
|
}
|
|
328
349
|
};
|
|
329
350
|
}
|
|
@@ -356,14 +377,7 @@ function hydratedCreateMemo(compute, value, options) {
|
|
|
356
377
|
}
|
|
357
378
|
const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, value, options);
|
|
358
379
|
if (aiResult !== null) return aiResult;
|
|
359
|
-
return createMemo$1(prev =>
|
|
360
|
-
const o = getOwner();
|
|
361
|
-
if (!sharedConfig.hydrating) return compute(prev);
|
|
362
|
-
let initP;
|
|
363
|
-
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
364
|
-
const init = initP?.v ?? initP;
|
|
365
|
-
return init != null ? (subFetch(compute, prev), init) : compute(prev);
|
|
366
|
-
}, value, options);
|
|
380
|
+
return createMemo$1(prev => readSerializedOrCompute(compute, prev), value, options);
|
|
367
381
|
}
|
|
368
382
|
function hydratedCreateSignal(fn, second, third) {
|
|
369
383
|
if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second, third);
|
|
@@ -389,14 +403,7 @@ function hydratedCreateSignal(fn, second, third) {
|
|
|
389
403
|
}
|
|
390
404
|
const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second, third);
|
|
391
405
|
if (aiResult !== null) return aiResult;
|
|
392
|
-
return createSignal$1(prev =>
|
|
393
|
-
if (!sharedConfig.hydrating) return fn(prev);
|
|
394
|
-
const o = getOwner();
|
|
395
|
-
let initP;
|
|
396
|
-
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
397
|
-
const init = initP?.v ?? initP;
|
|
398
|
-
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
399
|
-
}, second, third);
|
|
406
|
+
return createSignal$1(prev => readSerializedOrCompute(fn, prev), second, third);
|
|
400
407
|
}
|
|
401
408
|
function hydratedCreateErrorBoundary(fn, fallback) {
|
|
402
409
|
if (!sharedConfig.hydrating) return createErrorBoundary$1(fn, fallback);
|
|
@@ -442,24 +449,10 @@ function hydratedCreateOptimistic(fn, second, third) {
|
|
|
442
449
|
}
|
|
443
450
|
const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second, third);
|
|
444
451
|
if (aiResult !== null) return aiResult;
|
|
445
|
-
return createOptimistic$1(prev =>
|
|
446
|
-
const o = getOwner();
|
|
447
|
-
if (!sharedConfig.hydrating) return fn(prev);
|
|
448
|
-
let initP;
|
|
449
|
-
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
450
|
-
const init = initP?.v ?? initP;
|
|
451
|
-
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
452
|
-
}, second, third);
|
|
452
|
+
return createOptimistic$1(prev => readSerializedOrCompute(fn, prev), second, third);
|
|
453
453
|
}
|
|
454
454
|
function wrapStoreFn(fn) {
|
|
455
|
-
return draft =>
|
|
456
|
-
const o = getOwner();
|
|
457
|
-
if (!sharedConfig.hydrating) return fn(draft);
|
|
458
|
-
let initP;
|
|
459
|
-
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
460
|
-
const init = initP?.v ?? initP;
|
|
461
|
-
return init != null ? (subFetch(fn, draft), init) : fn(draft);
|
|
462
|
-
};
|
|
455
|
+
return draft => readSerializedOrCompute(() => fn(draft), draft);
|
|
463
456
|
}
|
|
464
457
|
function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
465
458
|
if (ssrSource === "client") {
|
|
@@ -482,11 +475,8 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
|
482
475
|
if (!hydrated()) {
|
|
483
476
|
if (sharedConfig.has(o.id)) {
|
|
484
477
|
const initP = sharedConfig.load(o.id);
|
|
485
|
-
const init = initP
|
|
486
|
-
if (init
|
|
487
|
-
subFetch(fn, draft);
|
|
488
|
-
return init;
|
|
489
|
-
}
|
|
478
|
+
const init = readHydratedValue(initP, () => subFetch(fn, draft));
|
|
479
|
+
if (init !== NO_HYDRATED_VALUE) return init;
|
|
490
480
|
}
|
|
491
481
|
return fn(draft);
|
|
492
482
|
}
|
|
@@ -553,14 +543,7 @@ function hydratedEffect(coreFn, compute, effectFn, value, options) {
|
|
|
553
543
|
return;
|
|
554
544
|
}
|
|
555
545
|
markTopLevelSnapshotScope();
|
|
556
|
-
coreFn(prev =>
|
|
557
|
-
const o = getOwner();
|
|
558
|
-
if (!sharedConfig.hydrating) return compute(prev);
|
|
559
|
-
let initP;
|
|
560
|
-
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
561
|
-
const init = initP?.v ?? initP;
|
|
562
|
-
return init != null ? (subFetch(compute, prev), init) : compute(prev);
|
|
563
|
-
}, effectFn, value, options);
|
|
546
|
+
coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, value, options);
|
|
564
547
|
}
|
|
565
548
|
function hydratedCreateRenderEffect(compute, effectFn, value, options) {
|
|
566
549
|
return hydratedEffect(createRenderEffect$1, compute, effectFn, value, options);
|
|
@@ -658,7 +641,7 @@ function resumeBoundaryHydration(o, id, set) {
|
|
|
658
641
|
checkHydrationComplete();
|
|
659
642
|
return;
|
|
660
643
|
}
|
|
661
|
-
sharedConfig.gather(id);
|
|
644
|
+
sharedConfig.gather?.(id);
|
|
662
645
|
_hydratingValue = true;
|
|
663
646
|
markSnapshotScope(o);
|
|
664
647
|
_snapshotRootOwner = o;
|
|
@@ -670,11 +653,41 @@ function resumeBoundaryHydration(o, id, set) {
|
|
|
670
653
|
flush();
|
|
671
654
|
checkHydrationComplete();
|
|
672
655
|
}
|
|
673
|
-
function
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
656
|
+
function initBoundaryResume(o, id) {
|
|
657
|
+
_pendingBoundaries++;
|
|
658
|
+
onCleanup(() => {
|
|
659
|
+
if (!isDisposed(o)) return;
|
|
660
|
+
sharedConfig.cleanupFragment?.(id);
|
|
661
|
+
});
|
|
662
|
+
const set = createBoundaryTrigger();
|
|
663
|
+
return [set, () => resumeBoundaryHydration(o, id, set)];
|
|
664
|
+
}
|
|
665
|
+
function waitAndResume(p, resume, assetPromise) {
|
|
666
|
+
const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
|
|
667
|
+
waitFor.then(() => {
|
|
668
|
+
if (p && typeof p === "object") p.s = 1;
|
|
669
|
+
resume();
|
|
670
|
+
}, err => {
|
|
671
|
+
if (p && typeof p === "object") {
|
|
672
|
+
p.s = 2;
|
|
673
|
+
p.v = err;
|
|
674
|
+
}
|
|
675
|
+
resume();
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
function scheduleResumeAfterAssets(id, resume, assetPromise) {
|
|
679
|
+
sharedConfig.gather?.(id);
|
|
680
|
+
const doResume = () => queueMicrotask(resume);
|
|
681
|
+
if (assetPromise) {
|
|
682
|
+
assetPromise.then(doResume);
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
doResume();
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
function createLoadingBoundary(fn, fallback, options) {
|
|
689
|
+
if (!sharedConfig.hydrating) return createLoadingBoundary$1(fn, fallback, options);
|
|
690
|
+
let settledSerializationResumeQueued = false;
|
|
678
691
|
return createMemo$1(() => {
|
|
679
692
|
const o = getOwner();
|
|
680
693
|
const id = o.id;
|
|
@@ -684,27 +697,21 @@ function Loading(props) {
|
|
|
684
697
|
if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
|
|
685
698
|
}
|
|
686
699
|
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
687
|
-
|
|
700
|
+
const ref = sharedConfig.load(id);
|
|
688
701
|
let p;
|
|
689
702
|
if (ref) {
|
|
690
|
-
if (typeof ref !== "object" || ref.s
|
|
703
|
+
if (typeof ref !== "object" || ref.s == null) p = ref;else if (ref.s === 1 || ref.s === 2) sharedConfig.gather?.(id);else p = ref;
|
|
704
|
+
}
|
|
705
|
+
if (ref && typeof ref === "object" && ref.s === 1 && p == null && !settledSerializationResumeQueued) {
|
|
706
|
+
settledSerializationResumeQueued = true;
|
|
707
|
+
const [, resume] = initBoundaryResume(o, id);
|
|
708
|
+
if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
|
|
709
|
+
return fallback();
|
|
691
710
|
}
|
|
692
711
|
if (p) {
|
|
693
|
-
|
|
694
|
-
onCleanup(() => {
|
|
695
|
-
if (!isDisposed(o)) return;
|
|
696
|
-
sharedConfig.cleanupFragment?.(id);
|
|
697
|
-
});
|
|
698
|
-
const set = createBoundaryTrigger();
|
|
712
|
+
const [set, resume] = initBoundaryResume(o, id);
|
|
699
713
|
if (p !== "$$f") {
|
|
700
|
-
|
|
701
|
-
waitFor.then(() => resumeBoundaryHydration(o, id, set), err => {
|
|
702
|
-
_pendingBoundaries--;
|
|
703
|
-
checkHydrationComplete();
|
|
704
|
-
runWithOwner(o, () => {
|
|
705
|
-
throw err;
|
|
706
|
-
});
|
|
707
|
-
});
|
|
714
|
+
waitAndResume(p, resume, assetPromise);
|
|
708
715
|
} else {
|
|
709
716
|
const afterAssets = () => {
|
|
710
717
|
_pendingBoundaries--;
|
|
@@ -713,17 +720,26 @@ function Loading(props) {
|
|
|
713
720
|
};
|
|
714
721
|
if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
|
|
715
722
|
}
|
|
716
|
-
return
|
|
723
|
+
return fallback();
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (sharedConfig.hydrating && sharedConfig.has(id + "_fr") && !settledSerializationResumeQueued) {
|
|
727
|
+
settledSerializationResumeQueued = true;
|
|
728
|
+
const fr = sharedConfig.load(id + "_fr");
|
|
729
|
+
const [, resume] = initBoundaryResume(o, id);
|
|
730
|
+
if (fr && typeof fr === "object" && (fr.s === 1 || fr.s === 2)) {
|
|
731
|
+
if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
|
|
732
|
+
return fallback();
|
|
717
733
|
}
|
|
734
|
+
waitAndResume(fr, resume, assetPromise);
|
|
735
|
+
return fallback();
|
|
718
736
|
}
|
|
719
|
-
if (assetPromise) {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
assetPromise.then(() => resumeBoundaryHydration(o, id, set));
|
|
737
|
+
if (assetPromise && !sharedConfig.has(id)) {
|
|
738
|
+
const [, resume] = initBoundaryResume(o, id);
|
|
739
|
+
assetPromise.then(resume);
|
|
723
740
|
return undefined;
|
|
724
741
|
}
|
|
725
|
-
|
|
726
|
-
return boundary;
|
|
742
|
+
return createLoadingBoundary$1(fn, fallback, options);
|
|
727
743
|
});
|
|
728
744
|
}
|
|
729
745
|
function NoHydration(props) {
|
|
@@ -847,9 +863,21 @@ function Errored(props) {
|
|
|
847
863
|
return typeof f === "function" && f.length ? f(err, reset) : f;
|
|
848
864
|
});
|
|
849
865
|
}
|
|
866
|
+
function Loading(props) {
|
|
867
|
+
const onOpt = "on" in props ? {
|
|
868
|
+
on: () => props.on
|
|
869
|
+
} : undefined;
|
|
870
|
+
return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
|
|
871
|
+
}
|
|
872
|
+
function Reveal(props) {
|
|
873
|
+
return createRevealOrder(() => props.children, {
|
|
874
|
+
together: () => !!props.together,
|
|
875
|
+
collapsed: () => !!props.collapsed
|
|
876
|
+
});
|
|
877
|
+
}
|
|
850
878
|
|
|
851
879
|
function ssrHandleError() {}
|
|
852
880
|
function ssrRunInScope() {}
|
|
853
881
|
const DEV = undefined;
|
|
854
882
|
|
|
855
|
-
export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Show, Switch, children, createComponent, createContext, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
|
|
883
|
+
export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.6",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"performance"
|
|
80
80
|
],
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@solidjs/signals": "^0.13.
|
|
82
|
+
"@solidjs/signals": "^0.13.11",
|
|
83
83
|
"csstype": "^3.1.0",
|
|
84
84
|
"seroval": "~1.5.0",
|
|
85
85
|
"seroval-plugins": "~1.5.0"
|
package/types/client/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Accessor,
|
|
1
|
+
import type { Accessor, EffectOptions } from "@solidjs/signals";
|
|
2
2
|
import type { JSX } from "../jsx.js";
|
|
3
3
|
import { FlowComponent } from "./component.js";
|
|
4
4
|
export declare const IS_DEV: string | boolean;
|
|
@@ -56,10 +56,3 @@ export type ChildrenReturn = Accessor<ResolvedChildren> & {
|
|
|
56
56
|
*/
|
|
57
57
|
export declare function children(fn: Accessor<JSX.Element>): ChildrenReturn;
|
|
58
58
|
export declare function devComponent<P, V>(Comp: (props: P) => V, props: P): V;
|
|
59
|
-
interface SourceMapValue {
|
|
60
|
-
value: unknown;
|
|
61
|
-
name?: string;
|
|
62
|
-
graph?: Owner;
|
|
63
|
-
}
|
|
64
|
-
export declare function registerGraph(value: SourceMapValue): void;
|
|
65
|
-
export {};
|
package/types/client/flow.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Accessor } from "@solidjs/signals";
|
|
2
2
|
import type { JSX } from "../jsx.js";
|
|
3
|
+
type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
|
|
4
|
+
type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => JSX.Element;
|
|
5
|
+
type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = JSX.Element | NonZeroParams<F>;
|
|
3
6
|
/**
|
|
4
7
|
* Creates a list of elements from a list
|
|
5
8
|
*
|
|
@@ -40,11 +43,11 @@ export declare function Repeat<T extends JSX.Element>(props: {
|
|
|
40
43
|
* Conditionally render its children or an optional fallback component
|
|
41
44
|
* @description https://docs.solidjs.com/reference/components/show
|
|
42
45
|
*/
|
|
43
|
-
export declare function Show<T
|
|
46
|
+
export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
|
|
44
47
|
when: T | undefined | null | false;
|
|
45
48
|
keyed?: boolean;
|
|
46
49
|
fallback?: JSX.Element;
|
|
47
|
-
children:
|
|
50
|
+
children: ConditionalRenderChildren<T, F>;
|
|
48
51
|
}): JSX.Element;
|
|
49
52
|
/**
|
|
50
53
|
* Switches between content based on mutually exclusive conditions
|
|
@@ -64,10 +67,10 @@ export declare function Switch(props: {
|
|
|
64
67
|
fallback?: JSX.Element;
|
|
65
68
|
children: JSX.Element;
|
|
66
69
|
}): JSX.Element;
|
|
67
|
-
export type MatchProps<T> = {
|
|
70
|
+
export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = {
|
|
68
71
|
when: T | undefined | null | false;
|
|
69
72
|
keyed?: boolean;
|
|
70
|
-
children:
|
|
73
|
+
children: ConditionalRenderChildren<T, F>;
|
|
71
74
|
};
|
|
72
75
|
/**
|
|
73
76
|
* Selects a content based on condition when inside a `<Switch>` control flow
|
|
@@ -78,7 +81,7 @@ export type MatchProps<T> = {
|
|
|
78
81
|
* ```
|
|
79
82
|
* @description https://docs.solidjs.com/reference/components/switch-and-match
|
|
80
83
|
*/
|
|
81
|
-
export declare function Match<T
|
|
84
|
+
export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): JSX.Element;
|
|
82
85
|
/**
|
|
83
86
|
* Catches uncaught errors inside components and renders a fallback content
|
|
84
87
|
*
|
|
@@ -98,3 +101,42 @@ export declare function Errored(props: {
|
|
|
98
101
|
fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
|
|
99
102
|
children: JSX.Element;
|
|
100
103
|
}): JSX.Element;
|
|
104
|
+
/**
|
|
105
|
+
* Tracks all resources inside a component and renders a fallback until they are all resolved
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const AsyncComponent = lazy(() => import('./component'));
|
|
108
|
+
*
|
|
109
|
+
* <Loading fallback={<LoadingIndicator />}>
|
|
110
|
+
* <AsyncComponent />
|
|
111
|
+
* </Loading>
|
|
112
|
+
* ```
|
|
113
|
+
* @description https://docs.solidjs.com/reference/components/suspense
|
|
114
|
+
*/
|
|
115
|
+
export declare function Loading(props: {
|
|
116
|
+
fallback?: JSX.Element;
|
|
117
|
+
on?: any;
|
|
118
|
+
children: JSX.Element;
|
|
119
|
+
}): JSX.Element;
|
|
120
|
+
/**
|
|
121
|
+
* Coordinates the reveal timing of sibling `<Loading>` boundaries.
|
|
122
|
+
*
|
|
123
|
+
* - **Sequential** (default): boundaries reveal in DOM order as each resolves.
|
|
124
|
+
* - **Together** (`together`): all boundaries wait until the group is ready, then reveal at once.
|
|
125
|
+
* - **Collapsed** (`collapsed`, sequential only): only the frontier boundary shows its fallback;
|
|
126
|
+
* later boundaries produce nothing until their turn.
|
|
127
|
+
*
|
|
128
|
+
* ```typescript
|
|
129
|
+
* <Reveal>
|
|
130
|
+
* <Loading fallback={<Skeleton />}><ProfileHeader /></Loading>
|
|
131
|
+
* <Loading fallback={<Skeleton />}><Posts /></Loading>
|
|
132
|
+
* </Reveal>
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @description https://docs.solidjs.com/reference/components/reveal
|
|
136
|
+
*/
|
|
137
|
+
export declare function Reveal(props: {
|
|
138
|
+
together?: boolean;
|
|
139
|
+
collapsed?: boolean;
|
|
140
|
+
children: JSX.Element;
|
|
141
|
+
}): JSX.Element;
|
|
142
|
+
export {};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { createErrorBoundary as coreErrorBoundary, createMemo as coreMemo, createSignal as coreSignal, createOptimistic as coreOptimistic, createRenderEffect as coreRenderEffect, createEffect as coreEffect, $REFRESH, type ProjectionOptions, type Store, type StoreSetter, type Context } from "@solidjs/signals";
|
|
2
2
|
import { JSX } from "../jsx.js";
|
|
3
|
+
type HydrationSsrFields = {
|
|
4
|
+
deferStream?: boolean;
|
|
5
|
+
ssrSource?: "server" | "hybrid" | "initial" | "client";
|
|
6
|
+
};
|
|
3
7
|
declare module "@solidjs/signals" {
|
|
4
|
-
interface MemoOptions<T> {
|
|
5
|
-
deferStream?: boolean;
|
|
6
|
-
ssrSource?: "server" | "hybrid" | "initial" | "client";
|
|
8
|
+
interface MemoOptions<T> extends HydrationSsrFields {
|
|
7
9
|
}
|
|
8
|
-
interface SignalOptions<T> {
|
|
9
|
-
deferStream?: boolean;
|
|
10
|
-
ssrSource?: "server" | "hybrid" | "initial" | "client";
|
|
10
|
+
interface SignalOptions<T> extends HydrationSsrFields {
|
|
11
11
|
}
|
|
12
|
-
interface EffectOptions {
|
|
13
|
-
deferStream?: boolean;
|
|
14
|
-
ssrSource?: "server" | "hybrid" | "initial" | "client";
|
|
12
|
+
interface EffectOptions extends HydrationSsrFields {
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
15
|
export type HydrationProjectionOptions = ProjectionOptions & {
|
|
@@ -76,11 +74,9 @@ export declare const createEffect: typeof coreEffect;
|
|
|
76
74
|
* ```
|
|
77
75
|
* @description https://docs.solidjs.com/reference/components/suspense
|
|
78
76
|
*/
|
|
79
|
-
export declare function
|
|
80
|
-
fallback?: JSX.Element;
|
|
77
|
+
export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
|
|
81
78
|
on?: () => any;
|
|
82
|
-
|
|
83
|
-
}): JSX.Element;
|
|
79
|
+
}): () => unknown;
|
|
84
80
|
/**
|
|
85
81
|
* Disables hydration for its children on the client.
|
|
86
82
|
* During hydration, skips the subtree entirely (returns undefined so DOM is left untouched).
|
package/types/index.d.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
export { $PROXY, $REFRESH, $TRACK, action,
|
|
1
|
+
export { $PROXY, $REFRESH, $TRACK, action, createOwner, createReaction, createRevealOrder, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals";
|
|
2
2
|
export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
|
|
3
3
|
export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
|
|
4
4
|
export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./client/core.js";
|
|
5
5
|
export * from "./client/component.js";
|
|
6
6
|
export * from "./client/flow.js";
|
|
7
|
-
export { sharedConfig,
|
|
7
|
+
export { sharedConfig, enableHydration, createErrorBoundary, createLoadingBoundary, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore, createRenderEffect, createEffect, NoHydration, Hydration, NoHydrateContext } from "./client/hydration.js";
|
|
8
8
|
export declare function ssrHandleError(): void;
|
|
9
9
|
export declare function ssrRunInScope(): void;
|
|
10
10
|
import type { JSX } from "./jsx.js";
|
|
11
11
|
type JSXElement = JSX.Element;
|
|
12
12
|
export type { JSXElement, JSX };
|
|
13
|
-
import {
|
|
14
|
-
export declare const DEV:
|
|
15
|
-
readonly hooks: {};
|
|
16
|
-
readonly registerGraph: typeof registerGraph;
|
|
17
|
-
} | undefined;
|
|
13
|
+
import { type Dev } from "@solidjs/signals";
|
|
14
|
+
export declare const DEV: Dev | undefined;
|
|
18
15
|
declare global {
|
|
19
16
|
var Solid$$: boolean;
|
|
20
17
|
}
|