solid-js 2.0.0-beta.5 → 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 +70 -48
- package/dist/dev.js +64 -51
- package/dist/server.cjs +124 -3
- package/dist/server.js +120 -5
- package/dist/solid.cjs +64 -34
- package/dist/solid.js +58 -37
- package/package.json +2 -2
- package/types/client/core.d.ts +1 -8
- package/types/client/flow.d.ts +22 -0
- package/types/index.d.ts +3 -6
- package/types/jsx.d.ts +156 -122
- package/types/server/flow.d.ts +9 -0
- package/types/server/hydration.d.ts +9 -0
- package/types/server/index.d.ts +1 -1
- package/types/server/shared.d.ts +5 -1
- package/types/server/signals.d.ts +5 -1
package/dist/dev.cjs
CHANGED
|
@@ -35,9 +35,11 @@ function children(fn) {
|
|
|
35
35
|
function devComponent(Comp, props) {
|
|
36
36
|
return signals.createRoot(() => {
|
|
37
37
|
const owner = signals.getOwner();
|
|
38
|
-
owner.
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
owner._component = {
|
|
39
|
+
fn: Comp,
|
|
40
|
+
props,
|
|
41
|
+
name: Comp.name
|
|
42
|
+
};
|
|
41
43
|
Object.assign(Comp, {
|
|
42
44
|
[$DEVCOMP]: true
|
|
43
45
|
});
|
|
@@ -46,12 +48,6 @@ function devComponent(Comp, props) {
|
|
|
46
48
|
transparent: true
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
|
-
function registerGraph(value) {
|
|
50
|
-
const owner = signals.getOwner();
|
|
51
|
-
if (!owner) return;
|
|
52
|
-
if (owner.sourceMap) owner.sourceMap.push(value);else owner.sourceMap = [value];
|
|
53
|
-
value.graph = owner;
|
|
54
|
-
}
|
|
55
51
|
|
|
56
52
|
const NoHydrateContext = {
|
|
57
53
|
id: Symbol("NoHydrateContext"),
|
|
@@ -675,6 +671,38 @@ function resumeBoundaryHydration(o, id, set) {
|
|
|
675
671
|
signals.flush();
|
|
676
672
|
checkHydrationComplete();
|
|
677
673
|
}
|
|
674
|
+
function initBoundaryResume(o, id) {
|
|
675
|
+
_pendingBoundaries++;
|
|
676
|
+
signals.onCleanup(() => {
|
|
677
|
+
if (!signals.isDisposed(o)) return;
|
|
678
|
+
sharedConfig.cleanupFragment?.(id);
|
|
679
|
+
});
|
|
680
|
+
const set = createBoundaryTrigger();
|
|
681
|
+
return [set, () => resumeBoundaryHydration(o, id, set)];
|
|
682
|
+
}
|
|
683
|
+
function waitAndResume(p, resume, assetPromise) {
|
|
684
|
+
const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
|
|
685
|
+
waitFor.then(() => {
|
|
686
|
+
if (p && typeof p === "object") p.s = 1;
|
|
687
|
+
resume();
|
|
688
|
+
}, err => {
|
|
689
|
+
if (p && typeof p === "object") {
|
|
690
|
+
p.s = 2;
|
|
691
|
+
p.v = err;
|
|
692
|
+
}
|
|
693
|
+
resume();
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
function scheduleResumeAfterAssets(id, resume, assetPromise) {
|
|
697
|
+
sharedConfig.gather?.(id);
|
|
698
|
+
const doResume = () => queueMicrotask(resume);
|
|
699
|
+
if (assetPromise) {
|
|
700
|
+
assetPromise.then(doResume);
|
|
701
|
+
return true;
|
|
702
|
+
}
|
|
703
|
+
doResume();
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
678
706
|
function createLoadingBoundary(fn, fallback, options) {
|
|
679
707
|
if (!sharedConfig.hydrating) return signals.createLoadingBoundary(fn, fallback, options);
|
|
680
708
|
let settledSerializationResumeQueued = false;
|
|
@@ -694,41 +722,14 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
694
722
|
}
|
|
695
723
|
if (ref && typeof ref === "object" && ref.s === 1 && p == null && !settledSerializationResumeQueued) {
|
|
696
724
|
settledSerializationResumeQueued = true;
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
if (!signals.isDisposed(o)) return;
|
|
700
|
-
sharedConfig.cleanupFragment?.(id);
|
|
701
|
-
});
|
|
702
|
-
const set = createBoundaryTrigger();
|
|
703
|
-
const scheduleResume = () => queueMicrotask(() => resumeBoundaryHydration(o, id, set));
|
|
704
|
-
if (assetPromise) {
|
|
705
|
-
assetPromise.then(scheduleResume);
|
|
706
|
-
return undefined;
|
|
707
|
-
}
|
|
708
|
-
scheduleResume();
|
|
725
|
+
const [, resume] = initBoundaryResume(o, id);
|
|
726
|
+
if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
|
|
709
727
|
return fallback();
|
|
710
728
|
}
|
|
711
729
|
if (p) {
|
|
712
|
-
|
|
713
|
-
signals.onCleanup(() => {
|
|
714
|
-
if (!signals.isDisposed(o)) return;
|
|
715
|
-
sharedConfig.cleanupFragment?.(id);
|
|
716
|
-
});
|
|
717
|
-
const set = createBoundaryTrigger();
|
|
730
|
+
const [set, resume] = initBoundaryResume(o, id);
|
|
718
731
|
if (p !== "$$f") {
|
|
719
|
-
|
|
720
|
-
waitFor.then(() => {
|
|
721
|
-
if (p && typeof p === "object") {
|
|
722
|
-
p.s = 1;
|
|
723
|
-
}
|
|
724
|
-
resumeBoundaryHydration(o, id, set);
|
|
725
|
-
}, err => {
|
|
726
|
-
if (p && typeof p === "object") {
|
|
727
|
-
p.s = 2;
|
|
728
|
-
p.v = err;
|
|
729
|
-
}
|
|
730
|
-
resumeBoundaryHydration(o, id, set);
|
|
731
|
-
});
|
|
732
|
+
waitAndResume(p, resume, assetPromise);
|
|
732
733
|
} else {
|
|
733
734
|
const afterAssets = () => {
|
|
734
735
|
_pendingBoundaries--;
|
|
@@ -740,10 +741,20 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
740
741
|
return fallback();
|
|
741
742
|
}
|
|
742
743
|
}
|
|
744
|
+
if (sharedConfig.hydrating && sharedConfig.has(id + "_fr") && !settledSerializationResumeQueued) {
|
|
745
|
+
settledSerializationResumeQueued = true;
|
|
746
|
+
const fr = sharedConfig.load(id + "_fr");
|
|
747
|
+
const [, resume] = initBoundaryResume(o, id);
|
|
748
|
+
if (fr && typeof fr === "object" && (fr.s === 1 || fr.s === 2)) {
|
|
749
|
+
if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
|
|
750
|
+
return fallback();
|
|
751
|
+
}
|
|
752
|
+
waitAndResume(fr, resume, assetPromise);
|
|
753
|
+
return fallback();
|
|
754
|
+
}
|
|
743
755
|
if (assetPromise && !sharedConfig.has(id)) {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
assetPromise.then(() => resumeBoundaryHydration(o, id, set));
|
|
756
|
+
const [, resume] = initBoundaryResume(o, id);
|
|
757
|
+
assetPromise.then(resume);
|
|
747
758
|
return undefined;
|
|
748
759
|
}
|
|
749
760
|
return signals.createLoadingBoundary(fn, fallback, options);
|
|
@@ -892,14 +903,16 @@ function Loading(props) {
|
|
|
892
903
|
} : undefined;
|
|
893
904
|
return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
|
|
894
905
|
}
|
|
906
|
+
function Reveal(props) {
|
|
907
|
+
return signals.createRevealOrder(() => props.children, {
|
|
908
|
+
together: () => !!props.together,
|
|
909
|
+
collapsed: () => !!props.collapsed
|
|
910
|
+
});
|
|
911
|
+
}
|
|
895
912
|
|
|
896
913
|
function ssrHandleError() {}
|
|
897
914
|
function ssrRunInScope() {}
|
|
898
|
-
const
|
|
899
|
-
const DEV = {
|
|
900
|
-
hooks: DevHooks,
|
|
901
|
-
registerGraph
|
|
902
|
-
} ;
|
|
915
|
+
const DEV = signals.DEV ;
|
|
903
916
|
if (globalThis) {
|
|
904
917
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
905
918
|
}
|
|
@@ -932,6 +945,10 @@ Object.defineProperty(exports, "createReaction", {
|
|
|
932
945
|
enumerable: true,
|
|
933
946
|
get: function () { return signals.createReaction; }
|
|
934
947
|
});
|
|
948
|
+
Object.defineProperty(exports, "createRevealOrder", {
|
|
949
|
+
enumerable: true,
|
|
950
|
+
get: function () { return signals.createRevealOrder; }
|
|
951
|
+
});
|
|
935
952
|
Object.defineProperty(exports, "createRoot", {
|
|
936
953
|
enumerable: true,
|
|
937
954
|
get: function () { return signals.createRoot; }
|
|
@@ -972,6 +989,10 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
972
989
|
enumerable: true,
|
|
973
990
|
get: function () { return signals.getOwner; }
|
|
974
991
|
});
|
|
992
|
+
Object.defineProperty(exports, "isDisposed", {
|
|
993
|
+
enumerable: true,
|
|
994
|
+
get: function () { return signals.isDisposed; }
|
|
995
|
+
});
|
|
975
996
|
Object.defineProperty(exports, "isEqual", {
|
|
976
997
|
enumerable: true,
|
|
977
998
|
get: function () { return signals.isEqual; }
|
|
@@ -1054,6 +1075,7 @@ exports.Match = Match;
|
|
|
1054
1075
|
exports.NoHydrateContext = NoHydrateContext;
|
|
1055
1076
|
exports.NoHydration = NoHydration;
|
|
1056
1077
|
exports.Repeat = Repeat;
|
|
1078
|
+
exports.Reveal = Reveal;
|
|
1057
1079
|
exports.Show = Show;
|
|
1058
1080
|
exports.Switch = Switch;
|
|
1059
1081
|
exports.children = children;
|
package/dist/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getContext, createMemo as createMemo$1, flatten,
|
|
2
|
-
export { $PROXY, $REFRESH, $TRACK, NotReadyError, action, createOwner, createReaction, createRoot, createTrackedEffect, deep, enableExternalSource, enforceLoadingBoundary, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, latest, mapArray, merge, omit, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, storePath, untrack } from '@solidjs/signals';
|
|
1
|
+
import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, getOwner, untrack, createOwner, runWithOwner, createEffect as createEffect$1, createErrorBoundary as createErrorBoundary$1, createLoadingBoundary as createLoadingBoundary$1, 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, mapArray, repeat, createRevealOrder, DEV as DEV$1 } 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 $DEVCOMP = Symbol("COMPONENT_DEV" );
|
|
5
5
|
function createContext(defaultValue, options) {
|
|
@@ -34,9 +34,11 @@ function children(fn) {
|
|
|
34
34
|
function devComponent(Comp, props) {
|
|
35
35
|
return createRoot(() => {
|
|
36
36
|
const owner = getOwner();
|
|
37
|
-
owner.
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
owner._component = {
|
|
38
|
+
fn: Comp,
|
|
39
|
+
props,
|
|
40
|
+
name: Comp.name
|
|
41
|
+
};
|
|
40
42
|
Object.assign(Comp, {
|
|
41
43
|
[$DEVCOMP]: true
|
|
42
44
|
});
|
|
@@ -45,12 +47,6 @@ function devComponent(Comp, props) {
|
|
|
45
47
|
transparent: true
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
|
-
function registerGraph(value) {
|
|
49
|
-
const owner = getOwner();
|
|
50
|
-
if (!owner) return;
|
|
51
|
-
if (owner.sourceMap) owner.sourceMap.push(value);else owner.sourceMap = [value];
|
|
52
|
-
value.graph = owner;
|
|
53
|
-
}
|
|
54
50
|
|
|
55
51
|
const NoHydrateContext = {
|
|
56
52
|
id: Symbol("NoHydrateContext"),
|
|
@@ -674,6 +670,38 @@ function resumeBoundaryHydration(o, id, set) {
|
|
|
674
670
|
flush();
|
|
675
671
|
checkHydrationComplete();
|
|
676
672
|
}
|
|
673
|
+
function initBoundaryResume(o, id) {
|
|
674
|
+
_pendingBoundaries++;
|
|
675
|
+
onCleanup(() => {
|
|
676
|
+
if (!isDisposed(o)) return;
|
|
677
|
+
sharedConfig.cleanupFragment?.(id);
|
|
678
|
+
});
|
|
679
|
+
const set = createBoundaryTrigger();
|
|
680
|
+
return [set, () => resumeBoundaryHydration(o, id, set)];
|
|
681
|
+
}
|
|
682
|
+
function waitAndResume(p, resume, assetPromise) {
|
|
683
|
+
const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
|
|
684
|
+
waitFor.then(() => {
|
|
685
|
+
if (p && typeof p === "object") p.s = 1;
|
|
686
|
+
resume();
|
|
687
|
+
}, err => {
|
|
688
|
+
if (p && typeof p === "object") {
|
|
689
|
+
p.s = 2;
|
|
690
|
+
p.v = err;
|
|
691
|
+
}
|
|
692
|
+
resume();
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
function scheduleResumeAfterAssets(id, resume, assetPromise) {
|
|
696
|
+
sharedConfig.gather?.(id);
|
|
697
|
+
const doResume = () => queueMicrotask(resume);
|
|
698
|
+
if (assetPromise) {
|
|
699
|
+
assetPromise.then(doResume);
|
|
700
|
+
return true;
|
|
701
|
+
}
|
|
702
|
+
doResume();
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
677
705
|
function createLoadingBoundary(fn, fallback, options) {
|
|
678
706
|
if (!sharedConfig.hydrating) return createLoadingBoundary$1(fn, fallback, options);
|
|
679
707
|
let settledSerializationResumeQueued = false;
|
|
@@ -693,41 +721,14 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
693
721
|
}
|
|
694
722
|
if (ref && typeof ref === "object" && ref.s === 1 && p == null && !settledSerializationResumeQueued) {
|
|
695
723
|
settledSerializationResumeQueued = true;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
if (!isDisposed(o)) return;
|
|
699
|
-
sharedConfig.cleanupFragment?.(id);
|
|
700
|
-
});
|
|
701
|
-
const set = createBoundaryTrigger();
|
|
702
|
-
const scheduleResume = () => queueMicrotask(() => resumeBoundaryHydration(o, id, set));
|
|
703
|
-
if (assetPromise) {
|
|
704
|
-
assetPromise.then(scheduleResume);
|
|
705
|
-
return undefined;
|
|
706
|
-
}
|
|
707
|
-
scheduleResume();
|
|
724
|
+
const [, resume] = initBoundaryResume(o, id);
|
|
725
|
+
if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
|
|
708
726
|
return fallback();
|
|
709
727
|
}
|
|
710
728
|
if (p) {
|
|
711
|
-
|
|
712
|
-
onCleanup(() => {
|
|
713
|
-
if (!isDisposed(o)) return;
|
|
714
|
-
sharedConfig.cleanupFragment?.(id);
|
|
715
|
-
});
|
|
716
|
-
const set = createBoundaryTrigger();
|
|
729
|
+
const [set, resume] = initBoundaryResume(o, id);
|
|
717
730
|
if (p !== "$$f") {
|
|
718
|
-
|
|
719
|
-
waitFor.then(() => {
|
|
720
|
-
if (p && typeof p === "object") {
|
|
721
|
-
p.s = 1;
|
|
722
|
-
}
|
|
723
|
-
resumeBoundaryHydration(o, id, set);
|
|
724
|
-
}, err => {
|
|
725
|
-
if (p && typeof p === "object") {
|
|
726
|
-
p.s = 2;
|
|
727
|
-
p.v = err;
|
|
728
|
-
}
|
|
729
|
-
resumeBoundaryHydration(o, id, set);
|
|
730
|
-
});
|
|
731
|
+
waitAndResume(p, resume, assetPromise);
|
|
731
732
|
} else {
|
|
732
733
|
const afterAssets = () => {
|
|
733
734
|
_pendingBoundaries--;
|
|
@@ -739,10 +740,20 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
739
740
|
return fallback();
|
|
740
741
|
}
|
|
741
742
|
}
|
|
743
|
+
if (sharedConfig.hydrating && sharedConfig.has(id + "_fr") && !settledSerializationResumeQueued) {
|
|
744
|
+
settledSerializationResumeQueued = true;
|
|
745
|
+
const fr = sharedConfig.load(id + "_fr");
|
|
746
|
+
const [, resume] = initBoundaryResume(o, id);
|
|
747
|
+
if (fr && typeof fr === "object" && (fr.s === 1 || fr.s === 2)) {
|
|
748
|
+
if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
|
|
749
|
+
return fallback();
|
|
750
|
+
}
|
|
751
|
+
waitAndResume(fr, resume, assetPromise);
|
|
752
|
+
return fallback();
|
|
753
|
+
}
|
|
742
754
|
if (assetPromise && !sharedConfig.has(id)) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
assetPromise.then(() => resumeBoundaryHydration(o, id, set));
|
|
755
|
+
const [, resume] = initBoundaryResume(o, id);
|
|
756
|
+
assetPromise.then(resume);
|
|
746
757
|
return undefined;
|
|
747
758
|
}
|
|
748
759
|
return createLoadingBoundary$1(fn, fallback, options);
|
|
@@ -891,16 +902,18 @@ function Loading(props) {
|
|
|
891
902
|
} : undefined;
|
|
892
903
|
return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
|
|
893
904
|
}
|
|
905
|
+
function Reveal(props) {
|
|
906
|
+
return createRevealOrder(() => props.children, {
|
|
907
|
+
together: () => !!props.together,
|
|
908
|
+
collapsed: () => !!props.collapsed
|
|
909
|
+
});
|
|
910
|
+
}
|
|
894
911
|
|
|
895
912
|
function ssrHandleError() {}
|
|
896
913
|
function ssrRunInScope() {}
|
|
897
|
-
const
|
|
898
|
-
const DEV = {
|
|
899
|
-
hooks: DevHooks,
|
|
900
|
-
registerGraph
|
|
901
|
-
} ;
|
|
914
|
+
const DEV = DEV$1 ;
|
|
902
915
|
if (globalThis) {
|
|
903
916
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
904
917
|
}
|
|
905
918
|
|
|
906
|
-
export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
|
|
919
|
+
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/dist/server.cjs
CHANGED
|
@@ -417,13 +417,14 @@ function createProjection(fn, initialValue = {}, options) {
|
|
|
417
417
|
promise.s = 1;
|
|
418
418
|
if (disposed) {
|
|
419
419
|
promise.v = state;
|
|
420
|
-
return;
|
|
420
|
+
return state;
|
|
421
421
|
}
|
|
422
422
|
if (v !== undefined && v !== state) {
|
|
423
423
|
Object.assign(state, v);
|
|
424
424
|
}
|
|
425
425
|
promise.v = state;
|
|
426
426
|
markReady();
|
|
427
|
+
return state;
|
|
427
428
|
}, () => {});
|
|
428
429
|
if (ctx?.async && !signals.getContext(NoHydrateContext) && owner.id) ctx.serialize(owner.id, promise, options?.deferStream);
|
|
429
430
|
const [pending, markReady] = createPendingProxy(state, promise);
|
|
@@ -568,6 +569,10 @@ function createLoadingBoundary$1(fn, fallback, options) {
|
|
|
568
569
|
throw err;
|
|
569
570
|
}
|
|
570
571
|
}
|
|
572
|
+
function createRevealOrder(fn, _options) {
|
|
573
|
+
const o = signals.createOwner();
|
|
574
|
+
return signals.runWithOwner(o, fn);
|
|
575
|
+
}
|
|
571
576
|
function untrack(fn) {
|
|
572
577
|
return fn();
|
|
573
578
|
}
|
|
@@ -692,6 +697,10 @@ function createUniqueId() {
|
|
|
692
697
|
return signals.getNextChildId(o);
|
|
693
698
|
}
|
|
694
699
|
|
|
700
|
+
const RevealGroupContext = {
|
|
701
|
+
id: Symbol("RevealGroupContext"),
|
|
702
|
+
defaultValue: null
|
|
703
|
+
};
|
|
695
704
|
function ssrHandleError(err) {
|
|
696
705
|
if (err instanceof signals.NotReadyError) {
|
|
697
706
|
return err.source;
|
|
@@ -717,6 +726,7 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
717
726
|
const ctx = currentCtx;
|
|
718
727
|
const parent = signals.getOwner();
|
|
719
728
|
const parentHandler = parent && signals.runWithOwner(parent, () => signals.getContext(ErrorContext));
|
|
729
|
+
const revealGroup = parent && signals.runWithOwner(parent, () => signals.getContext(RevealGroupContext));
|
|
720
730
|
const o = signals.createOwner();
|
|
721
731
|
const id = o.id;
|
|
722
732
|
o.id = id + "00";
|
|
@@ -779,12 +789,25 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
779
789
|
commitBoundaryState();
|
|
780
790
|
return () => ret;
|
|
781
791
|
}
|
|
792
|
+
const collapseFallback = revealGroup ? revealGroup.register(id) : false;
|
|
793
|
+
if (collapseFallback && !ctx.async) {
|
|
794
|
+
commitBoundaryState();
|
|
795
|
+
ctx.serialize(id, "$$f");
|
|
796
|
+
return () => undefined;
|
|
797
|
+
}
|
|
782
798
|
const fallbackOwner = signals.createOwner({
|
|
783
799
|
id
|
|
784
800
|
});
|
|
785
|
-
const fallbackResult = signals.runWithOwner(fallbackOwner, () =>
|
|
801
|
+
const fallbackResult = signals.runWithOwner(fallbackOwner, () => {
|
|
802
|
+
if (!ctx.async) return fallback();
|
|
803
|
+
const tpl = collapseFallback ? [`<template id="pl-${id}">`, `</template><!--pl-${id}-->`] : [`<template id="pl-${id}"></template>`, `<!--pl-${id}-->`];
|
|
804
|
+
return ctx.ssr(tpl, ctx.escape(fallback()));
|
|
805
|
+
});
|
|
786
806
|
if (ctx.async) {
|
|
787
|
-
|
|
807
|
+
const regOpts = revealGroup ? {
|
|
808
|
+
revealGroup: revealGroup.id
|
|
809
|
+
} : undefined;
|
|
810
|
+
done = ctx.registerFragment(id, regOpts);
|
|
788
811
|
(async () => {
|
|
789
812
|
try {
|
|
790
813
|
commitBoundaryState();
|
|
@@ -794,6 +817,7 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
794
817
|
}
|
|
795
818
|
flushSerializeBuffer();
|
|
796
819
|
done(ret.t[0]);
|
|
820
|
+
if (revealGroup) revealGroup.onResolved(id);
|
|
797
821
|
} catch (err) {
|
|
798
822
|
finalizeError(err);
|
|
799
823
|
}
|
|
@@ -885,6 +909,97 @@ function Errored(props) {
|
|
|
885
909
|
function Loading(props) {
|
|
886
910
|
return createLoadingBoundary(() => props.children, () => props.fallback);
|
|
887
911
|
}
|
|
912
|
+
function Reveal(props) {
|
|
913
|
+
const o = signals.createOwner();
|
|
914
|
+
const id = o.id;
|
|
915
|
+
const together = !!props.together;
|
|
916
|
+
const collapsed = !!props.collapsed;
|
|
917
|
+
if (!sharedConfig.context?.async) {
|
|
918
|
+
const parent = signals.getOwner();
|
|
919
|
+
const parentGroup = parent ? signals.runWithOwner(parent, () => signals.getContext(RevealGroupContext)) : null;
|
|
920
|
+
let collapsedByParent = false;
|
|
921
|
+
if (parentGroup) {
|
|
922
|
+
collapsedByParent = parentGroup.register(id);
|
|
923
|
+
if (collapsed || together) console.warn("Nested <Reveal> with collapsed/together won't coordinate correctly with renderToString. Use renderToStream for full support.");
|
|
924
|
+
}
|
|
925
|
+
let count = 0;
|
|
926
|
+
return signals.runWithOwner(o, () => {
|
|
927
|
+
signals.setContext(RevealGroupContext, {
|
|
928
|
+
id,
|
|
929
|
+
register(_key) {
|
|
930
|
+
count++;
|
|
931
|
+
if (collapsedByParent) return true;
|
|
932
|
+
return !together && collapsed && count > 1;
|
|
933
|
+
},
|
|
934
|
+
onResolved() {}
|
|
935
|
+
});
|
|
936
|
+
return props.children;
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
const ctx = sharedConfig.context;
|
|
940
|
+
const keys = [];
|
|
941
|
+
const resolved = new Set();
|
|
942
|
+
const composites = new Map();
|
|
943
|
+
let frontier = 0;
|
|
944
|
+
const parent = signals.getOwner();
|
|
945
|
+
const parentGroup = parent ? signals.runWithOwner(parent, () => signals.getContext(RevealGroupContext)) : null;
|
|
946
|
+
let collapsedByParent = false;
|
|
947
|
+
if (parentGroup) {
|
|
948
|
+
collapsedByParent = parentGroup.register(id, {
|
|
949
|
+
onActivate: () => {
|
|
950
|
+
collapsedByParent = false;
|
|
951
|
+
advanceFrontier();
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
function notifyParentIfDone() {
|
|
956
|
+
if (parentGroup && resolved.size === keys.length) {
|
|
957
|
+
parentGroup.onResolved(id);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
function advanceFrontier() {
|
|
961
|
+
while (frontier < keys.length && resolved.has(keys[frontier])) {
|
|
962
|
+
if (!composites.has(keys[frontier])) ctx.revealFragments?.([keys[frontier]]);
|
|
963
|
+
frontier++;
|
|
964
|
+
}
|
|
965
|
+
if (frontier < keys.length) {
|
|
966
|
+
const activate = composites.get(keys[frontier]);
|
|
967
|
+
if (activate) activate();else if (!together && collapsed) ctx.revealFallbacks?.(keys.slice(frontier));
|
|
968
|
+
}
|
|
969
|
+
notifyParentIfDone();
|
|
970
|
+
}
|
|
971
|
+
return signals.runWithOwner(o, () => {
|
|
972
|
+
signals.setContext(RevealGroupContext, {
|
|
973
|
+
id,
|
|
974
|
+
register(key, options) {
|
|
975
|
+
keys.push(key);
|
|
976
|
+
if (options?.onActivate) composites.set(key, options.onActivate);
|
|
977
|
+
if (collapsedByParent) return true;
|
|
978
|
+
return !together && collapsed && keys.length > 1;
|
|
979
|
+
},
|
|
980
|
+
onResolved(key) {
|
|
981
|
+
resolved.add(key);
|
|
982
|
+
if (collapsedByParent) {
|
|
983
|
+
notifyParentIfDone();
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
if (together) {
|
|
987
|
+
if (resolved.size === keys.length) {
|
|
988
|
+
ctx.revealFragments?.(id);
|
|
989
|
+
notifyParentIfDone();
|
|
990
|
+
}
|
|
991
|
+
} else {
|
|
992
|
+
advanceFrontier();
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
const result = props.children;
|
|
997
|
+
if (parentGroup && keys.length === 0) {
|
|
998
|
+
parentGroup.onResolved(id);
|
|
999
|
+
}
|
|
1000
|
+
return result;
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
888
1003
|
|
|
889
1004
|
const DEV = undefined;
|
|
890
1005
|
|
|
@@ -932,6 +1047,10 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
932
1047
|
enumerable: true,
|
|
933
1048
|
get: function () { return signals.getOwner; }
|
|
934
1049
|
});
|
|
1050
|
+
Object.defineProperty(exports, "isDisposed", {
|
|
1051
|
+
enumerable: true,
|
|
1052
|
+
get: function () { return signals.isDisposed; }
|
|
1053
|
+
});
|
|
935
1054
|
Object.defineProperty(exports, "isEqual", {
|
|
936
1055
|
enumerable: true,
|
|
937
1056
|
get: function () { return signals.isEqual; }
|
|
@@ -974,6 +1093,7 @@ exports.Match = Match;
|
|
|
974
1093
|
exports.NoHydrateContext = NoHydrateContext;
|
|
975
1094
|
exports.NoHydration = NoHydration;
|
|
976
1095
|
exports.Repeat = Repeat;
|
|
1096
|
+
exports.Reveal = Reveal;
|
|
977
1097
|
exports.Show = Show;
|
|
978
1098
|
exports.Switch = Switch;
|
|
979
1099
|
exports.action = action;
|
|
@@ -990,6 +1110,7 @@ exports.createOptimisticStore = createOptimisticStore;
|
|
|
990
1110
|
exports.createProjection = createProjection;
|
|
991
1111
|
exports.createReaction = createReaction;
|
|
992
1112
|
exports.createRenderEffect = createRenderEffect;
|
|
1113
|
+
exports.createRevealOrder = createRevealOrder;
|
|
993
1114
|
exports.createSignal = createSignal;
|
|
994
1115
|
exports.createStore = createStore;
|
|
995
1116
|
exports.createTrackedEffect = createTrackedEffect;
|