sanity 5.28.0-next.11 → 5.28.0-next.12
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/lib/_chunks-dts/types2.d.ts +1 -0
- package/lib/_chunks-es/PostMessagePerspective.js +8 -7
- package/lib/_chunks-es/PostMessagePerspective.js.map +1 -1
- package/lib/_chunks-es/PresentationToolGrantsCheck.js +28 -27
- package/lib/_chunks-es/PresentationToolGrantsCheck.js.map +1 -1
- package/lib/_chunks-es/version.js +2 -2
- package/package.json +11 -11
|
@@ -209,6 +209,7 @@ interface PreviewProps {
|
|
|
209
209
|
viewport: PresentationViewport;
|
|
210
210
|
vercelProtectionBypass: string | null;
|
|
211
211
|
previewUrlRef: PreviewUrlRef;
|
|
212
|
+
handlesPerspectiveChange: boolean;
|
|
212
213
|
}
|
|
213
214
|
/** @public */
|
|
214
215
|
interface PreviewHeaderProps extends PreviewProps {
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { c } from "react/compiler-runtime";
|
|
2
|
-
import { memo, useEffect } from "react";
|
|
2
|
+
import { memo, useEffect, startTransition } from "react";
|
|
3
3
|
const PostMessagePerspective = (props) => {
|
|
4
|
-
const $ = c(
|
|
4
|
+
const $ = c(9), {
|
|
5
5
|
comlink,
|
|
6
|
-
perspective
|
|
6
|
+
perspective,
|
|
7
|
+
setHandlesPerspectiveChange
|
|
7
8
|
} = props;
|
|
8
9
|
let t0, t1;
|
|
9
|
-
$[0] !== comlink || $[1] !== perspective ? (t0 = () => comlink.on("visual-editing/fetch-perspective", () => ({
|
|
10
|
+
$[0] !== comlink || $[1] !== perspective || $[2] !== setHandlesPerspectiveChange ? (t0 = () => comlink.on("visual-editing/fetch-perspective", (payload) => (startTransition(() => setHandlesPerspectiveChange(payload?.handlesPerspectiveChange === !0)), {
|
|
10
11
|
perspective
|
|
11
|
-
})), t1 = [comlink, perspective], $[0] = comlink, $[1] = perspective, $[2] =
|
|
12
|
+
})), t1 = [comlink, perspective, setHandlesPerspectiveChange], $[0] = comlink, $[1] = perspective, $[2] = setHandlesPerspectiveChange, $[3] = t0, $[4] = t1) : (t0 = $[3], t1 = $[4]), useEffect(t0, t1);
|
|
12
13
|
let t2, t3;
|
|
13
|
-
return $[
|
|
14
|
+
return $[5] !== comlink || $[6] !== perspective ? (t2 = () => {
|
|
14
15
|
comlink.post("presentation/perspective", {
|
|
15
16
|
perspective
|
|
16
17
|
});
|
|
17
|
-
}, t3 = [comlink, perspective], $[
|
|
18
|
+
}, t3 = [comlink, perspective], $[5] = comlink, $[6] = perspective, $[7] = t2, $[8] = t3) : (t2 = $[7], t3 = $[8]), useEffect(t2, t3), null;
|
|
18
19
|
};
|
|
19
20
|
var PostMessagePerspective_default = memo(PostMessagePerspective);
|
|
20
21
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostMessagePerspective.js","sources":["../../src/presentation/PostMessagePerspective.tsx"],"sourcesContent":["import {type ClientPerspective} from '@sanity/client'\nimport {type FC, memo, useEffect} from 'react'\n\nimport {type VisualEditingConnection} from './types'\n\nexport interface PostMessagePerspectiveProps {\n comlink: VisualEditingConnection\n perspective: ClientPerspective\n}\n\nconst PostMessagePerspective: FC<PostMessagePerspectiveProps> = (props) => {\n const {comlink, perspective} = props\n\n // Return the perspective when requested\n useEffect(() => {\n return comlink.on('visual-editing/fetch-perspective', () =>
|
|
1
|
+
{"version":3,"file":"PostMessagePerspective.js","sources":["../../src/presentation/PostMessagePerspective.tsx"],"sourcesContent":["import {type ClientPerspective} from '@sanity/client'\nimport {type FC, memo, startTransition, useEffect} from 'react'\n\nimport {type VisualEditingConnection} from './types'\n\nexport interface PostMessagePerspectiveProps {\n comlink: VisualEditingConnection\n perspective: ClientPerspective\n setHandlesPerspectiveChange: (payload: boolean) => void\n}\n\nconst PostMessagePerspective: FC<PostMessagePerspectiveProps> = (props) => {\n const {comlink, perspective, setHandlesPerspectiveChange} = props\n\n // Return the perspective when requested\n useEffect(() => {\n return comlink.on('visual-editing/fetch-perspective', (payload) => {\n // Report back whether the visual editing handler is set up to own perspective switching or not, if the payload is `undefined` then it means the visual editing instance isn't recent enough and we treat it as false\n startTransition(() => setHandlesPerspectiveChange(payload?.handlesPerspectiveChange === true))\n return {perspective}\n })\n }, [comlink, perspective, setHandlesPerspectiveChange])\n\n // Dispatch a perspective message when the perspective changes\n useEffect(() => {\n comlink.post('presentation/perspective', {perspective})\n }, [comlink, perspective])\n\n return null\n}\n\nexport default memo(PostMessagePerspective)\n"],"names":["PostMessagePerspective","props","$","_c","comlink","perspective","setHandlesPerspectiveChange","t0","t1","on","payload","startTransition","handlesPerspectiveChange","useEffect","t2","t3","post","memo"],"mappings":";;AAWA,MAAMA,yBAA0DC,CAAAA,UAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAC9D;AAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAA4DL;AAAK,MAAAM,IAAAC;AAAAN,IAAA,CAAA,MAAAE,WAAAF,SAAAG,eAAAH,EAAA,CAAA,MAAAI,+BAGvDC,KAAAA,MACDH,QAAOK,GAAI,oCAAoCC,CAAAA,aAEpDC,gBAAgB,MAAML,4BAA4BI,SAAOE,6BAA+B,EAAI,CAAC,GACtF;AAAA,IAAAP;AAAAA,EAAAA,EACR,GACAG,MAACJ,SAASC,aAAaC,2BAA2B,GAACJ,OAAAE,SAAAF,OAAAG,aAAAH,OAAAI,6BAAAJ,OAAAK,IAAAL,OAAAM,OAAAD,KAAAL,EAAA,CAAA,GAAAM,KAAAN,EAAA,CAAA,IANtDW,UAAUN,IAMPC,EAAmD;AAAC,MAAAM,IAAAC;AAAA,SAAAb,EAAA,CAAA,MAAAE,WAAAF,SAAAG,eAG7CS,KAAAA,MAAA;AACRV,YAAOY,KAAM,4BAA4B;AAAA,MAAAX;AAAAA,IAAAA,CAAa;AAAA,EAAC,GACtDU,KAAA,CAACX,SAASC,WAAW,GAACH,OAAAE,SAAAF,OAAAG,aAAAH,OAAAY,IAAAZ,OAAAa,OAAAD,KAAAZ,EAAA,CAAA,GAAAa,KAAAb,EAAA,CAAA,IAFzBW,UAAUC,IAEPC,EAAsB,GAElB;AAAI;AAGb,IAAA,iCAAeE,KAAKjB,sBAAsB;"}
|
|
@@ -1841,14 +1841,15 @@ const MotionFlex = motion.create(Flex), Preview = memo(forwardRef(function(props
|
|
|
1841
1841
|
viewport,
|
|
1842
1842
|
vercelProtectionBypass,
|
|
1843
1843
|
presentationRef,
|
|
1844
|
-
previewUrlRef
|
|
1844
|
+
previewUrlRef,
|
|
1845
|
+
handlesPerspectiveChange
|
|
1845
1846
|
} = props, [stablePerspective, setStablePerspective] = useState(null), urlPerspective = encodeStudioPerspective(stablePerspective === null ? perspective : stablePerspective), previewUrl = useMemo(() => {
|
|
1846
1847
|
const url = new URL(initialUrl);
|
|
1847
1848
|
return url.searchParams.set(urlSearchParamPreviewPerspective, urlPerspective), (vercelProtectionBypass || url.searchParams.get(urlSearchParamVercelProtectionBypass)) && url.searchParams.set(urlSearchParamVercelSetBypassCookie, "samesitenone"), vercelProtectionBypass && !url.searchParams.get(urlSearchParamVercelProtectionBypass) && url.searchParams.set(urlSearchParamVercelProtectionBypass, vercelProtectionBypass), url;
|
|
1848
1849
|
}, [initialUrl, urlPerspective, vercelProtectionBypass]);
|
|
1849
1850
|
useEffect(() => {
|
|
1850
|
-
|
|
1851
|
-
}, [
|
|
1851
|
+
handlesPerspectiveChange && setStablePerspective((prev) => prev === null ? perspective : prev);
|
|
1852
|
+
}, [handlesPerspectiveChange, perspective]);
|
|
1852
1853
|
const {
|
|
1853
1854
|
t
|
|
1854
1855
|
} = useTranslation(presentationLocaleNamespace), {
|
|
@@ -2597,7 +2598,7 @@ const LiveQueries = lazy(() => import("./LiveQueries.js")), PostMessageDocuments
|
|
|
2597
2598
|
componentId: "sc-1f7om43-0"
|
|
2598
2599
|
})`overflow-x:auto;`;
|
|
2599
2600
|
function PresentationTool(props) {
|
|
2600
|
-
const $ = c(
|
|
2601
|
+
const $ = c(197), {
|
|
2601
2602
|
canToggleSharePreviewAccess,
|
|
2602
2603
|
canUseSharedPreviewAccess,
|
|
2603
2604
|
tool,
|
|
@@ -2659,7 +2660,7 @@ function PresentationTool(props) {
|
|
|
2659
2660
|
resolvers: t6,
|
|
2660
2661
|
perspective
|
|
2661
2662
|
}, $[14] = navigate, $[15] = navigationHistory, $[16] = params.preview, $[17] = perspective, $[18] = t6, $[19] = targetOrigin, $[20] = t7) : t7 = $[20];
|
|
2662
|
-
const mainDocumentState = useMainDocument(t7), [overlaysConnection, setOverlaysConnection] = useStatus(), [loadersConnection, setLoadersConnection] = useStatus(), [previewKitConnection, setPreviewKitConnection] = useStatus(), {
|
|
2663
|
+
const mainDocumentState = useMainDocument(t7), [overlaysConnection, setOverlaysConnection] = useStatus(), [loadersConnection, setLoadersConnection] = useStatus(), [previewKitConnection, setPreviewKitConnection] = useStatus(), [_handlesPerspectiveChange, setHandlesPerspectiveChange] = useState(!1), handlesPerspectiveChange = _handlesPerspectiveChange || loadersConnection === "connected", {
|
|
2663
2664
|
open: handleOpenPopup
|
|
2664
2665
|
} = usePopups(controller), isLoading = useSelector(presentationRef, _temp2$2);
|
|
2665
2666
|
let t8, t9;
|
|
@@ -2912,45 +2913,45 @@ function PresentationTool(props) {
|
|
|
2912
2913
|
$[93] !== PresentationNavigator ? (t31 = /* @__PURE__ */ jsx(PresentationNavigator, {}), $[93] = PresentationNavigator, $[94] = t31) : t31 = $[94];
|
|
2913
2914
|
const t32 = navigatorEnabled ? 50 : 75;
|
|
2914
2915
|
let t33;
|
|
2915
|
-
$[95] !== canSharePreviewAccess || $[96] !== canToggleSharePreviewAccess || $[97] !== canUseSharedPreviewAccess || $[98] !== handleOpenPopup || $[99] !== handlePreviewPath || $[100] !== handleRefresh || $[101] !==
|
|
2916
|
+
$[95] !== canSharePreviewAccess || $[96] !== canToggleSharePreviewAccess || $[97] !== canUseSharedPreviewAccess || $[98] !== handleOpenPopup || $[99] !== handlePreviewPath || $[100] !== handleRefresh || $[101] !== handlesPerspectiveChange || $[102] !== initialPreviewUrl || $[103] !== loadersConnection || $[104] !== navigatorEnabled || $[105] !== overlaysConnection || $[106] !== params.preview || $[107] !== perspective || $[108] !== presentationRef || $[109] !== previewUrlRef || $[110] !== setViewport || $[111] !== targetOrigin || $[112] !== toggleNavigator || $[113] !== toggleOverlay || $[114] !== unstable_header || $[115] !== vercelProtectionBypass || $[116] !== viewport ? (t33 = /* @__PURE__ */ jsx(Preview, { canSharePreviewAccess, canToggleSharePreviewAccess, canUseSharedPreviewAccess, header: unstable_header, initialUrl: initialPreviewUrl, loadersConnection, navigatorEnabled, onPathChange: handlePreviewPath, onRefresh: handleRefresh, openPopup: handleOpenPopup, overlaysConnection, previewUrl: params.preview, perspective, ref: iframeRef, setViewport, targetOrigin, toggleNavigator, toggleOverlay, viewport, vercelProtectionBypass, presentationRef, previewUrlRef, handlesPerspectiveChange }, targetOrigin), $[95] = canSharePreviewAccess, $[96] = canToggleSharePreviewAccess, $[97] = canUseSharedPreviewAccess, $[98] = handleOpenPopup, $[99] = handlePreviewPath, $[100] = handleRefresh, $[101] = handlesPerspectiveChange, $[102] = initialPreviewUrl, $[103] = loadersConnection, $[104] = navigatorEnabled, $[105] = overlaysConnection, $[106] = params.preview, $[107] = perspective, $[108] = presentationRef, $[109] = previewUrlRef, $[110] = setViewport, $[111] = targetOrigin, $[112] = toggleNavigator, $[113] = toggleOverlay, $[114] = unstable_header, $[115] = vercelProtectionBypass, $[116] = viewport, $[117] = t33) : t33 = $[117];
|
|
2916
2917
|
let t34;
|
|
2917
|
-
$[
|
|
2918
|
+
$[118] !== boundaryElement || $[119] !== t33 ? (t34 = /* @__PURE__ */ jsx(Flex, { direction: "column", flex: 1, height: "fill", ref: setBoundaryElement, children: /* @__PURE__ */ jsx(BoundaryElementProvider, { element: boundaryElement, children: t33 }) }), $[118] = boundaryElement, $[119] = t33, $[120] = t34) : t34 = $[120];
|
|
2918
2919
|
let t35;
|
|
2919
|
-
$[
|
|
2920
|
+
$[121] !== t32 || $[122] !== t34 ? (t35 = /* @__PURE__ */ jsx(Panel, { id: "preview", minWidth: 325, defaultSize: t32, order: 3, children: t34 }), $[121] = t32, $[122] = t34, $[123] = t35) : t35 = $[123];
|
|
2920
2921
|
let t36;
|
|
2921
|
-
$[
|
|
2922
|
+
$[124] !== documentsOnPage || $[125] !== getCommentIntent || $[126] !== handleEditReference || $[127] !== handleFocusPath || $[128] !== handleStructureParams || $[129] !== mainDocumentState || $[130] !== params.id || $[131] !== params.type || $[132] !== searchParams || $[133] !== structureParams ? (t36 = /* @__PURE__ */ jsx(PresentationContent, { documentId: params.id, documentsOnPage, documentType: params.type, getCommentIntent, mainDocumentState, onEditReference: handleEditReference, onFocusPath: handleFocusPath, onStructureParams: handleStructureParams, searchParams, setDisplayedDocument, structureParams }), $[124] = documentsOnPage, $[125] = getCommentIntent, $[126] = handleEditReference, $[127] = handleFocusPath, $[128] = handleStructureParams, $[129] = mainDocumentState, $[130] = params.id, $[131] = params.type, $[132] = searchParams, $[133] = structureParams, $[134] = t36) : t36 = $[134];
|
|
2922
2923
|
let t37;
|
|
2923
|
-
$[
|
|
2924
|
+
$[135] !== t31 || $[136] !== t35 || $[137] !== t36 ? (t37 = /* @__PURE__ */ jsx(Container, { "data-testid": "presentation-root", height: "fill", children: /* @__PURE__ */ jsxs(Panels, { children: [
|
|
2924
2925
|
t31,
|
|
2925
2926
|
t35,
|
|
2926
2927
|
t36
|
|
2927
|
-
] }) }), $[
|
|
2928
|
+
] }) }), $[135] = t31, $[136] = t35, $[137] = t36, $[138] = t37) : t37 = $[138];
|
|
2928
2929
|
let t38;
|
|
2929
|
-
$[
|
|
2930
|
+
$[139] !== t37 || $[140] !== visualEditingComlink ? (t38 = /* @__PURE__ */ jsx(SharedStateProvider, { comlink: visualEditingComlink, children: t37 }), $[139] = t37, $[140] = visualEditingComlink, $[141] = t38) : t38 = $[141];
|
|
2930
2931
|
let t39;
|
|
2931
|
-
$[
|
|
2932
|
+
$[142] !== params || $[143] !== t38 ? (t39 = /* @__PURE__ */ jsx(PresentationParamsProvider, { params, children: t38 }), $[142] = params, $[143] = t38, $[144] = t39) : t39 = $[144];
|
|
2932
2933
|
let t40;
|
|
2933
|
-
$[
|
|
2934
|
+
$[145] !== navigate || $[146] !== t39 ? (t40 = /* @__PURE__ */ jsx(PresentationNavigateProvider, { navigate, children: t39 }), $[145] = navigate, $[146] = t39, $[147] = t40) : t40 = $[147];
|
|
2934
2935
|
let t41;
|
|
2935
|
-
$[
|
|
2936
|
+
$[148] !== devMode || $[149] !== name || $[150] !== navigate || $[151] !== params || $[152] !== searchParams || $[153] !== structureParams || $[154] !== t40 ? (t41 = /* @__PURE__ */ jsx(PresentationProvider, { devMode, name, navigate, params, searchParams, structureParams, children: t40 }), $[148] = devMode, $[149] = name, $[150] = navigate, $[151] = params, $[152] = searchParams, $[153] = structureParams, $[154] = t40, $[155] = t41) : t41 = $[155];
|
|
2936
2937
|
let t42;
|
|
2937
|
-
$[
|
|
2938
|
+
$[156] !== controller || $[157] !== displayedDocument || $[158] !== perspective || $[159] !== setDocumentsOnPage || $[160] !== setLoadersConnection ? (t42 = controller && /* @__PURE__ */ jsx(LiveQueries, { controller, perspective, liveDocument: displayedDocument, onDocumentsOnPage: setDocumentsOnPage, onLoadersConnection: setLoadersConnection }), $[156] = controller, $[157] = displayedDocument, $[158] = perspective, $[159] = setDocumentsOnPage, $[160] = setLoadersConnection, $[161] = t42) : t42 = $[161];
|
|
2938
2939
|
let t43;
|
|
2939
|
-
$[
|
|
2940
|
+
$[162] !== loadersConnection || $[163] !== params.id || $[164] !== params.type || $[165] !== previewKitConnection || $[166] !== visualEditingComlink ? (t43 = visualEditingComlink && params.id && params.type && /* @__PURE__ */ jsx(PostMessageRefreshMutations, { comlink: visualEditingComlink, id: params.id, type: params.type, loadersConnection, previewKitConnection }), $[162] = loadersConnection, $[163] = params.id, $[164] = params.type, $[165] = previewKitConnection, $[166] = visualEditingComlink, $[167] = t43) : t43 = $[167];
|
|
2940
2941
|
let t44;
|
|
2941
|
-
$[
|
|
2942
|
+
$[168] !== perspective || $[169] !== visualEditingComlink ? (t44 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessageSchema, { comlink: visualEditingComlink, perspective }), $[168] = perspective, $[169] = visualEditingComlink, $[170] = t44) : t44 = $[170];
|
|
2942
2943
|
let t45;
|
|
2943
|
-
$[
|
|
2944
|
+
$[171] !== documentsOnPage || $[172] !== perspective || $[173] !== visualEditingComlink ? (t45 = visualEditingComlink && documentsOnPage.length > 0 && /* @__PURE__ */ jsx(PostMessagePreviewSnapshots, { comlink: visualEditingComlink, perspective, refs: documentsOnPage }), $[171] = documentsOnPage, $[172] = perspective, $[173] = visualEditingComlink, $[174] = t45) : t45 = $[174];
|
|
2944
2945
|
let t46;
|
|
2945
|
-
$[
|
|
2946
|
+
$[175] !== perspective || $[176] !== visualEditingComlink ? (t46 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessageDocuments, { comlink: visualEditingComlink, perspective }), $[175] = perspective, $[176] = visualEditingComlink, $[177] = t46) : t46 = $[177];
|
|
2946
2947
|
let t47;
|
|
2947
|
-
$[
|
|
2948
|
+
$[178] !== visualEditingComlink ? (t47 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessageFeatures, { comlink: visualEditingComlink }), $[178] = visualEditingComlink, $[179] = t47) : t47 = $[179];
|
|
2948
2949
|
let t48;
|
|
2949
|
-
$[
|
|
2950
|
+
$[180] !== perspective || $[181] !== visualEditingComlink ? (t48 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessagePerspective, { comlink: visualEditingComlink, perspective, setHandlesPerspectiveChange }), $[180] = perspective, $[181] = visualEditingComlink, $[182] = t48) : t48 = $[182];
|
|
2950
2951
|
let t49;
|
|
2951
|
-
$[
|
|
2952
|
+
$[183] !== visualEditingComlink ? (t49 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessageTelemetry, { comlink: visualEditingComlink }), $[183] = visualEditingComlink, $[184] = t49) : t49 = $[184];
|
|
2952
2953
|
let t50;
|
|
2953
|
-
$[
|
|
2954
|
+
$[185] !== t42 || $[186] !== t43 || $[187] !== t44 || $[188] !== t45 || $[189] !== t46 || $[190] !== t47 || $[191] !== t48 || $[192] !== t49 ? (t50 = /* @__PURE__ */ jsxs(Suspense, { children: [
|
|
2954
2955
|
t42,
|
|
2955
2956
|
t43,
|
|
2956
2957
|
t44,
|
|
@@ -2959,12 +2960,12 @@ function PresentationTool(props) {
|
|
|
2959
2960
|
t47,
|
|
2960
2961
|
t48,
|
|
2961
2962
|
t49
|
|
2962
|
-
] }), $[
|
|
2963
|
+
] }), $[185] = t42, $[186] = t43, $[187] = t44, $[188] = t45, $[189] = t46, $[190] = t47, $[191] = t48, $[192] = t49, $[193] = t50) : t50 = $[193];
|
|
2963
2964
|
let t51;
|
|
2964
|
-
return $[
|
|
2965
|
+
return $[194] !== t41 || $[195] !== t50 ? (t51 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2965
2966
|
t41,
|
|
2966
2967
|
t50
|
|
2967
|
-
] }), $[
|
|
2968
|
+
] }), $[194] = t41, $[195] = t50, $[196] = t51) : t51 = $[196], t51;
|
|
2968
2969
|
}
|
|
2969
2970
|
function _temp2$2(state_0) {
|
|
2970
2971
|
return state_0.matches("loading");
|