sanity 3.83.1-canary.23 → 3.84.1-next.0
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-cjs/PostMessageSchema.js.map +1 -1
- package/lib/_chunks-cjs/PostMessageTelemetry.js +1 -1
- package/lib/_chunks-cjs/PostMessageTelemetry.js.map +1 -1
- package/lib/_chunks-cjs/PresentationToolGrantsCheck.js +429 -1417
- package/lib/_chunks-cjs/PresentationToolGrantsCheck.js.map +1 -1
- package/lib/_chunks-cjs/presentation.js +70 -22
- package/lib/_chunks-cjs/presentation.js.map +1 -1
- package/lib/_chunks-cjs/resources6.js +0 -8
- package/lib/_chunks-cjs/resources6.js.map +1 -1
- package/lib/_chunks-cjs/version.js +1 -1
- package/lib/_chunks-es/PostMessageSchema.mjs.map +1 -1
- package/lib/_chunks-es/PostMessageTelemetry.mjs +1 -1
- package/lib/_chunks-es/PostMessageTelemetry.mjs.map +1 -1
- package/lib/_chunks-es/PresentationToolGrantsCheck.mjs +437 -1406
- package/lib/_chunks-es/PresentationToolGrantsCheck.mjs.map +1 -1
- package/lib/_chunks-es/presentation.mjs +73 -24
- package/lib/_chunks-es/presentation.mjs.map +1 -1
- package/lib/_chunks-es/resources6.mjs +0 -8
- package/lib/_chunks-es/resources6.mjs.map +1 -1
- package/lib/_chunks-es/version.mjs +1 -1
- package/lib/_singletons.d.mts +61 -2889
- package/lib/_singletons.d.ts +61 -2889
- package/lib/presentation.d.mts +57 -2887
- package/lib/presentation.d.ts +57 -2887
- package/lib/presentation.js +4 -0
- package/lib/presentation.js.map +1 -1
- package/lib/presentation.mjs +5 -1
- package/package.json +15 -16
- package/src/presentation/PostMessageTelemetry.tsx +1 -1
- package/src/presentation/PresentationTool.tsx +76 -85
- package/src/presentation/PresentationToolGrantsCheck.tsx +75 -39
- package/src/presentation/document/LocationsBanner.tsx +13 -52
- package/src/presentation/i18n/resources.ts +0 -10
- package/src/presentation/index.ts +13 -0
- package/src/presentation/{util → lib}/parse.ts +1 -2
- package/src/presentation/overlays/schema/PostMessageSchema.tsx +0 -1
- package/src/presentation/panels/usePanelsStorage.ts +1 -1
- package/src/presentation/preview/IFrame.tsx +35 -83
- package/src/presentation/preview/Preview.tsx +56 -172
- package/src/presentation/preview/PreviewHeader.tsx +10 -43
- package/src/presentation/preview/PreviewLocationInput.tsx +24 -48
- package/src/presentation/preview/SharePreviewMenu.tsx +2 -2
- package/src/presentation/reducers/presentationReducer.ts +134 -0
- package/src/presentation/types.ts +7 -139
- package/src/presentation/useMainDocument.ts +12 -4
- package/src/presentation/useParams.ts +3 -2
- package/src/presentation/usePreviewUrl.ts +133 -0
- package/src/presentation/actors/create-preview-secret.ts +0 -19
- package/src/presentation/actors/read-shared-secret.ts +0 -18
- package/src/presentation/actors/resolve-allow-patterns.ts +0 -55
- package/src/presentation/actors/resolve-initial-url.ts +0 -65
- package/src/presentation/actors/resolve-preview-mode-url.ts +0 -72
- package/src/presentation/actors/resolve-preview-mode.ts +0 -66
- package/src/presentation/actors/resolve-url-from-preview-search-param.ts +0 -29
- package/src/presentation/machines/presentation-machine.ts +0 -101
- package/src/presentation/machines/preview-url.ts +0 -568
- package/src/presentation/useAllowPatterns.ts +0 -12
- package/src/presentation/useId.ts +0 -7
- package/src/presentation/usePresentationPerspective.ts +0 -14
- package/src/presentation/usePreviewUrlActorRef.ts +0 -96
- package/src/presentation/useReportInvalidPreviewSearchParam.tsx +0 -43
- package/src/presentation/useTargetOrigin.ts +0 -11
- /package/src/presentation/{util → lib}/debounce.ts +0 -0
@@ -1,26 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
8
|
-
if (from && typeof from == "object" || typeof from == "function")
|
9
|
-
for (let key of __getOwnPropNames(from))
|
10
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
-
return to;
|
12
|
-
};
|
13
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
14
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
15
|
-
// file that has been converted to a CommonJS file using a Babel-
|
16
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
17
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
18
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
19
|
-
mod
|
20
|
-
));
|
21
|
-
var jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), react = require("@xstate/react"), presentation = require("./presentation.js"), csm = require("@sanity/client/csm"), comlink = require("@sanity/comlink"), presentationComlink = require("@sanity/presentation-comlink"), constants = require("@sanity/preview-url-secret/constants"), ui = require("@sanity/ui"), React = require("react"), sanity = require("sanity"), router = require("sanity/router"), styledComponents = require("styled-components"), useEffectEvent = require("use-effect-event"), xstate = require("xstate"), _singletons = require("sanity/_singletons"), icons = require("@sanity/icons"), structure = require("sanity/structure"), TooltipDelayGroupProvider = require("./TooltipDelayGroupProvider.js");
|
2
|
+
var jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), constants = require("@sanity/preview-url-secret/constants"), ui = require("@sanity/ui"), uuid$1 = require("@sanity/uuid"), React = require("react"), sanity = require("sanity"), presentation = require("./presentation.js"), csm = require("@sanity/client/csm"), comlink = require("@sanity/comlink"), presentationComlink = require("@sanity/presentation-comlink"), router = require("sanity/router"), styledComponents = require("styled-components"), useEffectEvent = require("use-effect-event"), _singletons = require("sanity/_singletons"), icons = require("@sanity/icons"), structure = require("sanity/structure"), TooltipDelayGroupProvider = require("./TooltipDelayGroupProvider.js");
|
22
3
|
require("../_singletons.js");
|
23
|
-
var StructureToolProvider = require("./StructureToolProvider.js"), DisplayedDocumentBroadcaster = require("./DisplayedDocumentBroadcaster.js"), uuid = require("uuid"), framerMotion = require("framer-motion"), reactDom = require("react-dom"), withoutSecretSearchParams = require("@sanity/preview-url-secret/without-secret-search-params"), logos = require("@sanity/logos"), togglePreviewAccessSharing = require("@sanity/preview-url-secret/toggle-preview-access-sharing"), client = require("@sanity/client"), isEqual = require("fast-deep-equal"), pathToRegexp = require("path-to-regexp"), createSecret = require("@sanity/preview-url-secret/create-secret"),
|
4
|
+
var StructureToolProvider = require("./StructureToolProvider.js"), DisplayedDocumentBroadcaster = require("./DisplayedDocumentBroadcaster.js"), uuid = require("uuid"), framerMotion = require("framer-motion"), reactDom = require("react-dom"), withoutSecretSearchParams = require("@sanity/preview-url-secret/without-secret-search-params"), logos = require("@sanity/logos"), togglePreviewAccessSharing = require("@sanity/preview-url-secret/toggle-preview-access-sharing"), client = require("@sanity/client"), isEqual = require("fast-deep-equal"), pathToRegexp = require("path-to-regexp"), valibot = require("valibot"), createSecret = require("@sanity/preview-url-secret/create-secret"), definePreviewUrl = require("@sanity/preview-url-secret/define-preview-url"), suspendReact = require("suspend-react"), toggleVercelProtectionBypass = require("@sanity/preview-url-secret/toggle-vercel-protection-bypass");
|
24
5
|
function _interopDefaultCompat(e) {
|
25
6
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
26
7
|
}
|
@@ -30,97 +11,25 @@ const PostMessageFeatures = (props) => {
|
|
30
11
|
comlink: comlink2
|
31
12
|
} = props;
|
32
13
|
let t0, t1;
|
33
|
-
return $[0] !== comlink2 ? (t0 = () => comlink2.on("visual-editing/features", _temp$
|
14
|
+
return $[0] !== comlink2 ? (t0 = () => comlink2.on("visual-editing/features", _temp$a), t1 = [comlink2], $[0] = comlink2, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), React.useEffect(t0, t1), null;
|
34
15
|
};
|
35
16
|
var PostMessageFeatures$1 = React.memo(PostMessageFeatures);
|
36
|
-
function _temp$
|
17
|
+
function _temp$a() {
|
37
18
|
return {
|
38
19
|
features: {
|
39
20
|
optimistic: !0
|
40
21
|
}
|
41
22
|
};
|
42
23
|
}
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
//
|
53
|
-
}
|
54
|
-
}).createMachine({
|
55
|
-
// eslint-disable-next-line tsdoc/syntax
|
56
|
-
/** @xstate-layout N4IgpgJg5mDOIC5QAUBOcwDsAuBDbAlgPaYAEAKkUQDYDEBAZqrgLZinrVG4QDaADAF1EoAA5FYBQiREgAHogAsAJgA0IAJ6IAHAEYAdIoCcJowFY9R-vzPLlAX3vq0GHPmJlKNfVx4FMUPRMrOy+EJACwkgg4pLSmLIKCLoAbIr6Zoop2tqKAMxpJnnF6loIZkbK+uZ5umapKXmK-Cm6js7osFh48RRU1D7c4RC02ERQUNTsAG4EsACuuNSkkFL+UKRE02Co1LgasJGysWsy0UnaZinVyrpGAOx1Rim2efeliPe3hma1Zvy6XT8W4OJwgFxdNy9LwDMKQILMNgcMBMOAACyO0RO8USiAK930LWU-3uiiB9yaKXemkQjW01V+txS-GKqUe7XBnW67hIfW8cJGjER7E4Q0xYgkpwS5zxVMJKWJ-FJ5Mp1LKFn4Pz+DSaLTaYIh3Oh-UGPEg+nQqNgaPWCJCpAF4pikpxMoQKWZ+gp+TSZLy1hSH3deXpNSZLNqVP1HVcPQ8fNhQ3Nor8ATtSMdQmOLo8uPdnu9BUUfoDQY1WrqOuarUcYMwRHC8Gihqh8Zh2biubdAFpAzSEL2OS247yYfodqgiKgO1K8yog7ptATFL9dFljMDrHkh1zW6OTWF1jPXaAkmY1YgKnktfxtC9dPd+Io9DvYzzPAekxBj13T3i7vKirKkqqpBsYVQ1HUFjFs0t6KK+kIjh+-JfvoBAQFMP5nH+CDaMo16KjYyjMvUNh5GWOT6MoLL8A8ygrk0dQIUabafmaEAWiinQ2gEWHSjhjJUYuj73Pcd63noQaNEYFb-Dk2S0cxe7IYm7GcYevFYjm2HyJeeQQb8tFkikVjGNoFGajUt73o+z61vYQA */
|
57
|
-
id: "Presentation Tool",
|
58
|
-
context: {
|
59
|
-
url: null,
|
60
|
-
error: null,
|
61
|
-
visualEditingOverlaysEnabled: !1
|
62
|
-
},
|
63
|
-
on: {
|
64
|
-
"iframe reload": {
|
65
|
-
actions: xstate.assign({
|
66
|
-
url: null
|
67
|
-
}),
|
68
|
-
target: ".loading"
|
69
|
-
}
|
70
|
-
},
|
71
|
-
states: {
|
72
|
-
error: {
|
73
|
-
description: "Failed to load, either because of a misconfiguration, a network error, or an unexpected error",
|
74
|
-
tags: ["error"]
|
75
|
-
},
|
76
|
-
loading: {
|
77
|
-
on: {
|
78
|
-
"iframe loaded": {
|
79
|
-
target: "loaded"
|
80
|
-
}
|
81
|
-
},
|
82
|
-
tags: ["busy"]
|
83
|
-
},
|
84
|
-
loaded: {
|
85
|
-
on: {
|
86
|
-
"toggle visual editing overlays": {
|
87
|
-
actions: xstate.assign({
|
88
|
-
visualEditingOverlaysEnabled: ({
|
89
|
-
event
|
90
|
-
}) => event.enabled
|
91
|
-
})
|
92
|
-
},
|
93
|
-
"iframe refresh": {
|
94
|
-
target: ".refreshing"
|
95
|
-
},
|
96
|
-
"iframe reload": {
|
97
|
-
target: ".reloading"
|
98
|
-
}
|
99
|
-
},
|
100
|
-
states: {
|
101
|
-
idle: {},
|
102
|
-
refreshing: {
|
103
|
-
on: {
|
104
|
-
"iframe loaded": {
|
105
|
-
target: "idle"
|
106
|
-
}
|
107
|
-
},
|
108
|
-
tags: ["busy"]
|
109
|
-
},
|
110
|
-
reloading: {
|
111
|
-
on: {
|
112
|
-
"iframe loaded": {
|
113
|
-
target: "idle"
|
114
|
-
}
|
115
|
-
},
|
116
|
-
tags: ["busy"]
|
117
|
-
}
|
118
|
-
},
|
119
|
-
initial: "idle"
|
120
|
-
}
|
121
|
-
},
|
122
|
-
initial: "loading"
|
123
|
-
}), SharedStateProvider = function(props) {
|
24
|
+
function debounce(fn, timeout) {
|
25
|
+
let timer;
|
26
|
+
return (...args) => {
|
27
|
+
clearTimeout(timer), timer = setTimeout(() => {
|
28
|
+
fn.apply(fn, args);
|
29
|
+
}, timeout);
|
30
|
+
};
|
31
|
+
}
|
32
|
+
const SharedStateProvider = function(props) {
|
124
33
|
const $ = reactCompilerRuntime.c(14), {
|
125
34
|
comlink: comlink2,
|
126
35
|
children
|
@@ -191,22 +100,13 @@ const presentationMachine = xstate.setup({
|
|
191
100
|
}), t5 = [id, defaultSize, order, maxWidth, minWidth, registerElement, unregisterElement], $[3] = defaultSize, $[4] = id, $[5] = maxWidth, $[6] = minWidth, $[7] = order, $[8] = registerElement, $[9] = unregisterElement, $[10] = t4, $[11] = t5) : (t4 = $[10], t5 = $[11]), React.useLayoutEffect(t4, t5);
|
192
101
|
let t6;
|
193
102
|
return $[12] !== children || $[13] !== style ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(Root$1, { style, children }), $[12] = children, $[13] = style, $[14] = t6) : t6 = $[14], t6;
|
194
|
-
}
|
195
|
-
function debounce(fn, timeout) {
|
196
|
-
let timer;
|
197
|
-
return (...args) => {
|
198
|
-
clearTimeout(timer), timer = setTimeout(() => {
|
199
|
-
fn.apply(fn, args);
|
200
|
-
}, timeout);
|
201
|
-
};
|
202
|
-
}
|
203
|
-
const itemKey = "presentation/panels", getStoredItem = () => JSON.parse(localStorage.getItem(itemKey) || "{}"), setStoredItem = (data) => {
|
103
|
+
}, itemKey = "presentation/panels", getStoredItem = () => JSON.parse(localStorage.getItem(itemKey) || "{}"), setStoredItem = (data) => {
|
204
104
|
localStorage.setItem(itemKey, JSON.stringify(data));
|
205
105
|
}, getKeyForPanels = (panels) => panels.map((panel) => [panel.id, panel.order].join(":")).join(",");
|
206
106
|
function usePanelsStorage() {
|
207
107
|
const $ = reactCompilerRuntime.c(1);
|
208
108
|
let t0;
|
209
|
-
const get = _temp2$
|
109
|
+
const get = _temp2$5, set = _temp3$2;
|
210
110
|
let t1;
|
211
111
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
212
112
|
const setDebounced = debounce(set, 100);
|
@@ -219,18 +119,18 @@ function usePanelsStorage() {
|
|
219
119
|
t1 = $[0];
|
220
120
|
return t0 = t1, t0;
|
221
121
|
}
|
222
|
-
function _temp3$
|
122
|
+
function _temp3$2(panels_0, widths) {
|
223
123
|
const stored_0 = getStoredItem(), key_0 = getKeyForPanels(panels_0), data = {
|
224
124
|
...stored_0,
|
225
125
|
[key_0]: widths
|
226
126
|
};
|
227
127
|
setStoredItem(data);
|
228
128
|
}
|
229
|
-
function _temp2$
|
129
|
+
function _temp2$5(panels) {
|
230
130
|
const stored = getStoredItem(), key = getKeyForPanels(panels);
|
231
|
-
return Array.isArray(stored[key]) && stored[key].some(_temp$
|
131
|
+
return Array.isArray(stored[key]) && stored[key].some(_temp$9) ? void 0 : stored[key];
|
232
132
|
}
|
233
|
-
function _temp$
|
133
|
+
function _temp$9(val) {
|
234
134
|
return val === null;
|
235
135
|
}
|
236
136
|
function getNextWidth(panel, nextWidth, containerWidth) {
|
@@ -651,13 +551,13 @@ function PresentationPaneRouterProvider(props) {
|
|
651
551
|
ChildLink: t6,
|
652
552
|
BackLink: t7,
|
653
553
|
ReferenceChildLink: t8,
|
654
|
-
ParameterizedLink: _temp$
|
655
|
-
closeCurrentAndAfter: _temp2$
|
656
|
-
handleEditReference: _temp3$
|
657
|
-
replaceCurrent: _temp4
|
658
|
-
closeCurrent: _temp5
|
659
|
-
duplicateCurrent: _temp6
|
660
|
-
setView: _temp7
|
554
|
+
ParameterizedLink: _temp$8,
|
555
|
+
closeCurrentAndAfter: _temp2$4,
|
556
|
+
handleEditReference: _temp3$1,
|
557
|
+
replaceCurrent: _temp4,
|
558
|
+
closeCurrent: _temp5,
|
559
|
+
duplicateCurrent: _temp6,
|
560
|
+
setView: _temp7,
|
661
561
|
setParams: t9,
|
662
562
|
setPayload: _temp8,
|
663
563
|
navigateIntent: _temp9,
|
@@ -673,25 +573,25 @@ function _temp9(intentName, intentParams, options_0) {
|
|
673
573
|
function _temp8(payload) {
|
674
574
|
console.warn("setPayload", payload);
|
675
575
|
}
|
676
|
-
function _temp7
|
576
|
+
function _temp7(viewId) {
|
677
577
|
console.warn("setView", viewId);
|
678
578
|
}
|
679
|
-
function _temp6
|
579
|
+
function _temp6(pane_0) {
|
680
580
|
console.warn("duplicateCurrent", pane_0);
|
681
581
|
}
|
682
|
-
function _temp5
|
582
|
+
function _temp5() {
|
683
583
|
console.warn("closeCurrent");
|
684
584
|
}
|
685
|
-
function _temp4
|
585
|
+
function _temp4(pane) {
|
686
586
|
console.warn("replaceCurrent", pane);
|
687
587
|
}
|
688
|
-
function _temp3$
|
588
|
+
function _temp3$1(options) {
|
689
589
|
console.warn("handleEditReference", options);
|
690
590
|
}
|
691
|
-
function _temp2$
|
591
|
+
function _temp2$4() {
|
692
592
|
console.warn("closeCurrentAndAfter");
|
693
593
|
}
|
694
|
-
function _temp$
|
594
|
+
function _temp$8() {
|
695
595
|
throw new Error("ParameterizedLink not implemented");
|
696
596
|
}
|
697
597
|
const RootLayout = styledComponents.styled(structure.PaneLayout)`
|
@@ -718,7 +618,7 @@ function DocumentListPane(props) {
|
|
718
618
|
let t0, t1;
|
719
619
|
if ($[0] !== mainDocumentState?.document?._id || $[1] !== refs) {
|
720
620
|
let t22;
|
721
|
-
$[3] !== mainDocumentState?.document?._id ? (t22 = (r) => sanity.getPublishedId(r._id) !== mainDocumentState?.document?._id, $[3] = mainDocumentState?.document?._id, $[4] = t22) : t22 = $[4], t1 = refs.filter(t22).map(_temp$
|
621
|
+
$[3] !== mainDocumentState?.document?._id ? (t22 = (r) => sanity.getPublishedId(r._id) !== mainDocumentState?.document?._id, $[3] = mainDocumentState?.document?._id, $[4] = t22) : t22 = $[4], t1 = refs.filter(t22).map(_temp$7), $[0] = mainDocumentState?.document?._id, $[1] = refs, $[2] = t1;
|
722
622
|
} else
|
723
623
|
t1 = $[2];
|
724
624
|
t0 = t1;
|
@@ -743,7 +643,7 @@ function DocumentListPane(props) {
|
|
743
643
|
const pane = t2, [errorParams, setErrorParams] = React.useState(null);
|
744
644
|
let t6;
|
745
645
|
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => setErrorParams(null), $[12] = t6) : t6 = $[12];
|
746
|
-
const handleRetry = t6, [structureParams] = React.useState(_temp2$
|
646
|
+
const handleRetry = t6, [structureParams] = React.useState(_temp2$3);
|
747
647
|
let t7;
|
748
648
|
$[13] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => setErrorParams(null), $[13] = t7) : t7 = $[13];
|
749
649
|
let t8;
|
@@ -763,10 +663,10 @@ function DocumentListPane(props) {
|
|
763
663
|
let t10;
|
764
664
|
return $[27] !== onStructureParams || $[28] !== refs || $[29] !== searchParams || $[30] !== structureParams || $[31] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsxRuntime.jsx(RootLayout, { children: /* @__PURE__ */ jsxRuntime.jsx(structure.StructureToolProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(PresentationPaneRouterProvider, { onStructureParams, structureParams, searchParams, refs, children: t9 }) }) }) }), $[27] = onStructureParams, $[28] = refs, $[29] = searchParams, $[30] = structureParams, $[31] = t9, $[32] = t10) : t10 = $[32], t10;
|
765
665
|
}
|
766
|
-
function _temp2$
|
666
|
+
function _temp2$3() {
|
767
667
|
return {};
|
768
668
|
}
|
769
|
-
function _temp$
|
669
|
+
function _temp$7(r_0) {
|
770
670
|
return sanity.getPublishedId(r_0._id);
|
771
671
|
}
|
772
672
|
const WrappedCode = styledComponents.styled(ui.Code)`
|
@@ -1121,7 +1021,7 @@ function usePresentationNavigator(props) {
|
|
1121
1021
|
break bb0;
|
1122
1022
|
}
|
1123
1023
|
let t12;
|
1124
|
-
$[0] !== setNavigatorEnabled ? (t12 = () => setNavigatorEnabled(_temp$
|
1024
|
+
$[0] !== setNavigatorEnabled ? (t12 = () => setNavigatorEnabled(_temp$6), $[0] = setNavigatorEnabled, $[1] = t12) : t12 = $[1], t0 = t12;
|
1125
1025
|
}
|
1126
1026
|
const toggleNavigator = t0;
|
1127
1027
|
let t1;
|
@@ -1137,7 +1037,7 @@ function usePresentationNavigator(props) {
|
|
1137
1037
|
let t3;
|
1138
1038
|
return $[8] !== Component || $[9] !== t2 ? (t3 = [t2, Component], $[8] = Component, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
|
1139
1039
|
}
|
1140
|
-
function _temp$
|
1040
|
+
function _temp$6(enabled) {
|
1141
1041
|
return !enabled;
|
1142
1042
|
}
|
1143
1043
|
function NavigatorComponent(props) {
|
@@ -1191,68 +1091,10 @@ const Navigator = React.memo(NavigatorComponent), PresentationParamsProvider = f
|
|
1191
1091
|
let t2;
|
1192
1092
|
return $[7] !== children || $[8] !== context ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(_singletons.PresentationContext.Provider, { value: context, children }), $[7] = children, $[8] = context, $[9] = t2) : t2 = $[9], t2;
|
1193
1093
|
};
|
1194
|
-
function useAllowPatterns(previewUrlRef) {
|
1195
|
-
const allowPatterns = react.useSelector(previewUrlRef, _temp$a);
|
1196
|
-
if (!Array.isArray(allowPatterns))
|
1197
|
-
throw new TypeError("allowPatterns must be an array");
|
1198
|
-
return allowPatterns;
|
1199
|
-
}
|
1200
|
-
function _temp$a(state) {
|
1201
|
-
return state.context.allowOrigins;
|
1202
|
-
}
|
1203
1094
|
function encodeStudioPerspective(studioPerspective) {
|
1204
1095
|
return Array.isArray(studioPerspective) ? studioPerspective.join(",") : studioPerspective;
|
1205
1096
|
}
|
1206
|
-
|
1207
|
-
const $ = reactCompilerRuntime.c(2), id = React.useId();
|
1208
|
-
let t0;
|
1209
|
-
return $[0] !== id ? (t0 = id.startsWith(":") ? id.replace(/^:(.+):$/, "\xAB$1\xBB") : id, $[0] = id, $[1] = t0) : t0 = $[1], t0;
|
1210
|
-
}
|
1211
|
-
const IFrame = React.forwardRef(function(props, forwardedRef) {
|
1212
|
-
const $ = reactCompilerRuntime.c(19), {
|
1213
|
-
animate,
|
1214
|
-
initial,
|
1215
|
-
onLoad,
|
1216
|
-
preventClick,
|
1217
|
-
src,
|
1218
|
-
variants,
|
1219
|
-
style
|
1220
|
-
} = props, ref = React.useRef(null);
|
1221
|
-
let t0;
|
1222
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => ref.current, $[0] = t0) : t0 = $[0], React.useImperativeHandle(forwardedRef, t0);
|
1223
|
-
let t1, t2;
|
1224
|
-
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => {
|
1225
|
-
if (!ref.current)
|
1226
|
-
return;
|
1227
|
-
const instance = ref.current, handleBlur = function() {
|
1228
|
-
instance === document.activeElement && instance.dispatchEvent(new MouseEvent("mousedown", {
|
1229
|
-
bubbles: !0,
|
1230
|
-
cancelable: !0
|
1231
|
-
}));
|
1232
|
-
};
|
1233
|
-
return window.addEventListener("blur", handleBlur), () => {
|
1234
|
-
window.removeEventListener("blur", handleBlur);
|
1235
|
-
};
|
1236
|
-
}, t2 = [], $[1] = t1, $[2] = t2) : (t1 = $[1], t2 = $[2]), React.useEffect(t1, t2);
|
1237
|
-
const viewTransitionName = useId();
|
1238
|
-
let t3;
|
1239
|
-
$[3] !== style || $[4] !== viewTransitionName ? (t3 = {
|
1240
|
-
...style,
|
1241
|
-
viewTransitionName
|
1242
|
-
}, $[3] = style, $[4] = viewTransitionName, $[5] = t3) : t3 = $[5];
|
1243
|
-
let t4;
|
1244
|
-
$[6] !== animate || $[7] !== initial || $[8] !== onLoad || $[9] !== src || $[10] !== t3 || $[11] !== variants ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(IFrameElement, { style: t3, animate, initial, onLoad, ref, src, variants }), $[6] = animate, $[7] = initial, $[8] = onLoad, $[9] = src, $[10] = t3, $[11] = variants, $[12] = t4) : t4 = $[12];
|
1245
|
-
let t5;
|
1246
|
-
$[13] !== preventClick ? (t5 = preventClick && /* @__PURE__ */ jsxRuntime.jsx(IFrameOverlay, {}), $[13] = preventClick, $[14] = t5) : t5 = $[14];
|
1247
|
-
let t6;
|
1248
|
-
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(GlobalViewTransition, {}), $[15] = t6) : t6 = $[15];
|
1249
|
-
let t7;
|
1250
|
-
return $[16] !== t4 || $[17] !== t5 ? (t7 = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
1251
|
-
t4,
|
1252
|
-
t5,
|
1253
|
-
t6
|
1254
|
-
] }), $[16] = t4, $[17] = t5, $[18] = t7) : t7 = $[18], t7;
|
1255
|
-
}), IFrameElement = framerMotion.motion.create(styledComponents.styled.iframe`
|
1097
|
+
const IFrameElement = framerMotion.motion.create(styledComponents.styled.iframe`
|
1256
1098
|
box-shadow: 0 0 0 1px var(--card-border-color);
|
1257
1099
|
border: 0;
|
1258
1100
|
max-height: 100%;
|
@@ -1262,20 +1104,31 @@ const IFrame = React.forwardRef(function(props, forwardedRef) {
|
|
1262
1104
|
position: absolute;
|
1263
1105
|
inset: 0;
|
1264
1106
|
background: transparent;
|
1265
|
-
`,
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1107
|
+
`, IFrame = React.forwardRef(function(props, ref) {
|
1108
|
+
const $ = reactCompilerRuntime.c(16), {
|
1109
|
+
animate,
|
1110
|
+
initial,
|
1111
|
+
onLoad,
|
1112
|
+
preventClick,
|
1113
|
+
src,
|
1114
|
+
variants,
|
1115
|
+
style
|
1116
|
+
} = props, t0 = `presentation-tool-iframe-${React.useId().replace(/[^a-zA-Z0-9-_]/g, "_")}`;
|
1117
|
+
let t1;
|
1118
|
+
$[0] !== style || $[1] !== t0 ? (t1 = {
|
1119
|
+
...style,
|
1120
|
+
viewTransitionName: t0
|
1121
|
+
}, $[0] = style, $[1] = t0, $[2] = t1) : t1 = $[2];
|
1122
|
+
let t2;
|
1123
|
+
$[3] !== animate || $[4] !== initial || $[5] !== onLoad || $[6] !== ref || $[7] !== src || $[8] !== t1 || $[9] !== variants ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(IFrameElement, { style: t1, animate, initial, onLoad, ref, src, variants }), $[3] = animate, $[4] = initial, $[5] = onLoad, $[6] = ref, $[7] = src, $[8] = t1, $[9] = variants, $[10] = t2) : t2 = $[10];
|
1124
|
+
let t3;
|
1125
|
+
$[11] !== preventClick ? (t3 = preventClick && /* @__PURE__ */ jsxRuntime.jsx(IFrameOverlay, {}), $[11] = preventClick, $[12] = t3) : t3 = $[12];
|
1126
|
+
let t4;
|
1127
|
+
return $[13] !== t2 || $[14] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
1128
|
+
t2,
|
1129
|
+
t3
|
1130
|
+
] }), $[13] = t2, $[14] = t3, $[15] = t4) : t4 = $[15], t4;
|
1131
|
+
});
|
1279
1132
|
function OpenPreviewButton(props) {
|
1280
1133
|
const $ = reactCompilerRuntime.c(16), {
|
1281
1134
|
openPopup,
|
@@ -1313,25 +1166,16 @@ function OpenPreviewButton(props) {
|
|
1313
1166
|
let t7;
|
1314
1167
|
return $[13] !== t3 || $[14] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Tooltip, { animate: !0, content: t3, fallbackPlacements: t4, placement: "bottom", portal: !0, children: t6 }), $[13] = t3, $[14] = t6, $[15] = t7) : t7 = $[15], t7;
|
1315
1168
|
}
|
1316
|
-
function
|
1317
|
-
const
|
1318
|
-
if (!targetOrigin)
|
1319
|
-
throw new TypeError("targetOrigin is required");
|
1320
|
-
return targetOrigin;
|
1321
|
-
}
|
1322
|
-
function _temp$9(state) {
|
1323
|
-
return state.context.previewUrl?.origin;
|
1324
|
-
}
|
1325
|
-
function PreviewLocationInput(props) {
|
1326
|
-
const $ = reactCompilerRuntime.c(32), {
|
1169
|
+
const PreviewLocationInput = function(props) {
|
1170
|
+
const $ = reactCompilerRuntime.c(27), {
|
1327
1171
|
fontSize: t0,
|
1328
1172
|
onChange,
|
1173
|
+
origin,
|
1329
1174
|
padding: t1,
|
1330
1175
|
prefix,
|
1331
1176
|
suffix,
|
1332
|
-
value
|
1333
|
-
|
1334
|
-
} = props, fontSize = t0 === void 0 ? 1 : t0, padding = t1 === void 0 ? 3 : t1, allowOrigins = useAllowPatterns(previewUrlRef), targetOrigin = useTargetOrigin(previewUrlRef), {
|
1177
|
+
value
|
1178
|
+
} = props, fontSize = t0 === void 0 ? 1 : t0, padding = t1 === void 0 ? 3 : t1, {
|
1335
1179
|
t
|
1336
1180
|
} = sanity.useTranslation(presentation.presentationLocaleNamespace), {
|
1337
1181
|
basePath: t2
|
@@ -1342,74 +1186,59 @@ function PreviewLocationInput(props) {
|
|
1342
1186
|
}, $[0] = t3) : t3 = $[0];
|
1343
1187
|
const handleChange = t3;
|
1344
1188
|
let t4;
|
1345
|
-
$[1] !==
|
1189
|
+
$[1] !== basePath || $[2] !== onChange || $[3] !== origin || $[4] !== sessionValue || $[5] !== t ? (t4 = (event_0) => {
|
1346
1190
|
if (event_0.key === "Enter") {
|
1347
1191
|
if (sessionValue === void 0)
|
1348
1192
|
return;
|
1349
|
-
|
1350
|
-
absoluteValue
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1193
|
+
const absoluteValue = sessionValue.startsWith("/") || sessionValue === "" ? `${origin}${sessionValue}` : sessionValue;
|
1194
|
+
if (!absoluteValue.startsWith(`${origin}/`) && absoluteValue !== origin) {
|
1195
|
+
setCustomValidity(t("preview-location-input.error", {
|
1196
|
+
origin,
|
1197
|
+
context: "missing-origin"
|
1198
|
+
}));
|
1199
|
+
return;
|
1354
1200
|
}
|
1355
|
-
if (
|
1356
|
-
if (!allowOrigins.some((pattern) => pattern.test(absoluteValue))) {
|
1357
|
-
setCustomValidity(t("preview-location-input.error", {
|
1358
|
-
origin: targetOrigin,
|
1359
|
-
context: "origin-not-allowed"
|
1360
|
-
})), event_0.currentTarget.reportValidity();
|
1361
|
-
return;
|
1362
|
-
}
|
1363
|
-
} else if (!targetOrigin && (absoluteValue.startsWith(`${basePath}/`) || absoluteValue === basePath)) {
|
1201
|
+
if (!origin && (absoluteValue.startsWith(`${basePath}/`) || absoluteValue === basePath)) {
|
1364
1202
|
setCustomValidity(t("preview-location-input.error", {
|
1365
1203
|
basePath,
|
1366
1204
|
context: "same-base-path"
|
1367
1205
|
}));
|
1368
1206
|
return;
|
1369
1207
|
}
|
1370
|
-
const nextValue = absoluteValue ===
|
1371
|
-
setCustomValidity(void 0), setSessionValue(void 0), onChange(nextValue), inputRef.current?.blur();
|
1208
|
+
const nextValue = absoluteValue === origin ? `${origin}/` : absoluteValue;
|
1209
|
+
setCustomValidity(void 0), setSessionValue(void 0), onChange(nextValue.slice(origin.length)), inputRef.current?.blur();
|
1372
1210
|
}
|
1373
1211
|
event_0.key === "Escape" && (setCustomValidity(void 0), setSessionValue(void 0));
|
1374
|
-
}, $[1] =
|
1212
|
+
}, $[1] = basePath, $[2] = onChange, $[3] = origin, $[4] = sessionValue, $[5] = t, $[6] = t4) : t4 = $[6];
|
1375
1213
|
const handleKeyDown = t4;
|
1376
1214
|
let t5;
|
1377
|
-
$[
|
1215
|
+
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
|
1378
1216
|
setCustomValidity(void 0), setSessionValue(void 0);
|
1379
|
-
}, $[
|
1217
|
+
}, $[7] = t5) : t5 = $[7];
|
1380
1218
|
const handleBlur = t5;
|
1381
1219
|
let t6;
|
1382
|
-
$[
|
1383
|
-
setCustomValidity(void 0);
|
1384
|
-
let nextValue_0 = value;
|
1385
|
-
try {
|
1386
|
-
nextValue_0 = new URL(value, targetOrigin).toString();
|
1387
|
-
} catch {
|
1388
|
-
}
|
1389
|
-
setSessionValue(nextValue_0);
|
1390
|
-
}, $[9] = targetOrigin, $[10] = value, $[11] = t6) : t6 = $[11];
|
1391
|
-
const handleClear = t6;
|
1392
|
-
let t7;
|
1393
|
-
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => {
|
1220
|
+
$[8] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => {
|
1394
1221
|
setCustomValidity(void 0), setSessionValue(void 0);
|
1395
|
-
}, $[
|
1396
|
-
let
|
1397
|
-
$[
|
1398
|
-
let
|
1399
|
-
$[
|
1222
|
+
}, $[8] = t6) : t6 = $[8];
|
1223
|
+
let t7;
|
1224
|
+
$[9] !== origin || $[10] !== value ? (t7 = [origin, value], $[9] = origin, $[10] = value, $[11] = t7) : t7 = $[11], React.useEffect(t6, t7);
|
1225
|
+
let t8, t9;
|
1226
|
+
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t9 = {
|
1400
1227
|
icon: icons.ResetIcon
|
1401
|
-
}, $[
|
1402
|
-
const
|
1228
|
+
}, $[12] = t9) : t9 = $[12], t8 = t9;
|
1229
|
+
const t10 = customValidity ? t8 : void 0;
|
1230
|
+
let t11;
|
1231
|
+
$[13] !== origin || $[14] !== value ? (t11 = () => {
|
1232
|
+
setCustomValidity(void 0), setSessionValue(origin + value);
|
1233
|
+
}, $[13] = origin, $[14] = value, $[15] = t11) : t11 = $[15];
|
1403
1234
|
let t12;
|
1404
|
-
$[
|
1235
|
+
$[16] === Symbol.for("react.memo_cache_sentinel") ? (t12 = {
|
1405
1236
|
zIndex: 1
|
1406
|
-
}, $[
|
1407
|
-
|
1408
|
-
$[18] !== sessionValue || $[19] !== targetOrigin || $[20] !== value ? (t13 = sessionValue === void 0 ? new URL(value, targetOrigin).toString() : sessionValue, $[18] = sessionValue, $[19] = targetOrigin, $[20] = value, $[21] = t13) : t13 = $[21];
|
1237
|
+
}, $[16] = t12) : t12 = $[16];
|
1238
|
+
const t13 = sessionValue === void 0 ? `${origin}${value}` : sessionValue;
|
1409
1239
|
let t14;
|
1410
|
-
return $[
|
1411
|
-
}
|
1412
|
-
const QRCodeSVG = React.lazy(() => Promise.resolve().then(function() {
|
1240
|
+
return $[17] !== customValidity || $[18] !== fontSize || $[19] !== handleKeyDown || $[20] !== padding || $[21] !== prefix || $[22] !== suffix || $[23] !== t10 || $[24] !== t11 || $[25] !== t13 ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.TextInput, { clearButton: t10, customValidity, fontSize, onBlur: handleBlur, onClear: t11, onChange: handleChange, onKeyDownCapture: handleKeyDown, padding, prefix, style: t12, radius: 2, ref: inputRef, space: padding, suffix, value: t13 }) }), $[17] = customValidity, $[18] = fontSize, $[19] = handleKeyDown, $[20] = padding, $[21] = prefix, $[22] = suffix, $[23] = t10, $[24] = t11, $[25] = t13, $[26] = t14) : t14 = $[26], t14;
|
1241
|
+
}, QRCodeSVG = React.lazy(() => Promise.resolve().then(function() {
|
1413
1242
|
return require("./QRCodeSVG.js");
|
1414
1243
|
})), QrCodeLogoSize = 24, QrCodeLogoPadding = 16, QrSize = 224, StyledSanityMonogram = styledComponents.styled(logos.SanityMonogram)`
|
1415
1244
|
position: absolute;
|
@@ -1444,7 +1273,7 @@ const QRCodeSVG = React.lazy(() => Promise.resolve().then(function() {
|
|
1444
1273
|
});
|
1445
1274
|
}, [pushToast, t]), handleDisableSharing = React.useCallback(async () => {
|
1446
1275
|
try {
|
1447
|
-
setDisabling(!0), await togglePreviewAccessSharing.disablePreviewAccessSharing(client2, "sanity/presentation", typeof window > "u" ? "" : location.href, currentUser?.id), setSecret(null);
|
1276
|
+
setDisabling(!0), await togglePreviewAccessSharing.disablePreviewAccessSharing(client2, "@sanity/presentation", typeof window > "u" ? "" : location.href, currentUser?.id), setSecret(null);
|
1448
1277
|
} catch (error_0) {
|
1449
1278
|
setError(error_0);
|
1450
1279
|
} finally {
|
@@ -1453,7 +1282,7 @@ const QRCodeSVG = React.lazy(() => Promise.resolve().then(function() {
|
|
1453
1282
|
}, [client2, currentUser?.id]), handleEnableSharing = React.useCallback(async () => {
|
1454
1283
|
try {
|
1455
1284
|
setEnabling(!0);
|
1456
|
-
const previewUrlSecret = await togglePreviewAccessSharing.enablePreviewAccessSharing(client2, "sanity/presentation", typeof window > "u" ? "" : location.href, currentUser?.id);
|
1285
|
+
const previewUrlSecret = await togglePreviewAccessSharing.enablePreviewAccessSharing(client2, "@sanity/presentation", typeof window > "u" ? "" : location.href, currentUser?.id);
|
1457
1286
|
setSecret(previewUrlSecret.secret);
|
1458
1287
|
} catch (error_1) {
|
1459
1288
|
setError(error_1);
|
@@ -1570,10 +1399,12 @@ const QRCodeSVG = React.lazy(() => Promise.resolve().then(function() {
|
|
1570
1399
|
});
|
1571
1400
|
SharePreviewMenu.displayName = "Memo(SharePreviewMenu)";
|
1572
1401
|
const PreviewHeaderDefault = (props) => {
|
1573
|
-
const $ = reactCompilerRuntime.c(
|
1402
|
+
const $ = reactCompilerRuntime.c(100), {
|
1574
1403
|
canSharePreviewAccess,
|
1575
1404
|
canToggleSharePreviewAccess,
|
1576
1405
|
canUseSharedPreviewAccess,
|
1406
|
+
dispatch,
|
1407
|
+
iframe,
|
1577
1408
|
iframeRef,
|
1578
1409
|
initialUrl,
|
1579
1410
|
navigatorEnabled,
|
@@ -1581,7 +1412,6 @@ const PreviewHeaderDefault = (props) => {
|
|
1581
1412
|
onRefresh,
|
1582
1413
|
openPopup,
|
1583
1414
|
overlaysConnection,
|
1584
|
-
presentationRef,
|
1585
1415
|
perspective,
|
1586
1416
|
previewUrl,
|
1587
1417
|
setViewport,
|
@@ -1589,147 +1419,145 @@ const PreviewHeaderDefault = (props) => {
|
|
1589
1419
|
toggleNavigator,
|
1590
1420
|
toggleOverlay,
|
1591
1421
|
viewport,
|
1592
|
-
|
1422
|
+
visualEditing: t0
|
1593
1423
|
} = props, {
|
1424
|
+
overlaysEnabled
|
1425
|
+
} = t0, {
|
1594
1426
|
t
|
1595
1427
|
} = sanity.useTranslation(presentation.presentationLocaleNamespace);
|
1596
|
-
let t0;
|
1597
|
-
$[0] !== setViewport || $[1] !== viewport ? (t0 = () => setViewport(viewport === "desktop" ? "mobile" : "desktop"), $[0] = setViewport, $[1] = viewport, $[2] = t0) : t0 = $[2];
|
1598
|
-
const toggleViewportSize = t0;
|
1599
1428
|
let t1;
|
1600
|
-
t1 =
|
1601
|
-
const
|
1429
|
+
$[0] !== setViewport || $[1] !== viewport ? (t1 = () => setViewport(viewport === "desktop" ? "mobile" : "desktop"), $[0] = setViewport, $[1] = viewport, $[2] = t1) : t1 = $[2];
|
1430
|
+
const toggleViewportSize = t1;
|
1602
1431
|
let t2;
|
1603
|
-
|
1432
|
+
t2 = targetOrigin === location.origin ? "" : targetOrigin;
|
1433
|
+
const previewLocationOrigin = t2;
|
1434
|
+
let t3;
|
1435
|
+
$[3] !== dispatch || $[4] !== iframeRef || $[5] !== onRefresh || $[6] !== previewUrl || $[7] !== targetOrigin ? (t3 = () => {
|
1604
1436
|
onRefresh(() => {
|
1605
|
-
iframeRef.current && (
|
1606
|
-
type:
|
1437
|
+
iframeRef.current && (dispatch({
|
1438
|
+
type: presentation.ACTION_IFRAME_RELOAD
|
1607
1439
|
}), Object.assign(iframeRef.current, {
|
1608
1440
|
src: `${targetOrigin}${previewUrl || "/"}`
|
1609
1441
|
}));
|
1610
1442
|
});
|
1611
|
-
}, $[3] =
|
1612
|
-
const handleRefresh =
|
1613
|
-
let
|
1443
|
+
}, $[3] = dispatch, $[4] = iframeRef, $[5] = onRefresh, $[6] = previewUrl, $[7] = targetOrigin, $[8] = t3) : t3 = $[8];
|
1444
|
+
const handleRefresh = t3;
|
1445
|
+
let t4;
|
1614
1446
|
const previewURL = new URL(previewUrl || "/", targetOrigin), {
|
1615
1447
|
pathname,
|
1616
1448
|
search
|
1617
1449
|
} = withoutSecretSearchParams.withoutSecretSearchParams(previewURL);
|
1618
|
-
|
1619
|
-
const previewLocationRoute =
|
1620
|
-
let t4;
|
1621
|
-
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {
|
1622
|
-
width: "100%"
|
1623
|
-
}, $[9] = t4) : t4 = $[9];
|
1450
|
+
t4 = `${pathname}${search}`;
|
1451
|
+
const previewLocationRoute = t4;
|
1624
1452
|
let t5;
|
1625
|
-
$[
|
1453
|
+
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t5 = {
|
1454
|
+
width: "100%"
|
1455
|
+
}, $[9] = t5) : t5 = $[9];
|
1456
|
+
let t6;
|
1457
|
+
$[10] !== navigatorEnabled || $[11] !== t || $[12] !== toggleNavigator ? (t6 = toggleNavigator && /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Button, { "aria-label": t("preview-frame.navigator.toggle-button.aria-label"), icon: icons.PanelLeftIcon, mode: "bleed", onClick: toggleNavigator, selected: navigatorEnabled, tooltipProps: {
|
1626
1458
|
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: t("preview-frame.navigator.toggle-button.tooltip") }),
|
1627
1459
|
fallbackPlacements: ["bottom-start"],
|
1628
1460
|
placement: "bottom"
|
1629
|
-
} }), $[10] = navigatorEnabled, $[11] = t, $[12] = toggleNavigator, $[13] =
|
1630
|
-
let
|
1631
|
-
$[14] === Symbol.for("react.memo_cache_sentinel") ? (
|
1461
|
+
} }), $[10] = navigatorEnabled, $[11] = t, $[12] = toggleNavigator, $[13] = t6) : t6 = $[13];
|
1462
|
+
let t7;
|
1463
|
+
$[14] === Symbol.for("react.memo_cache_sentinel") ? (t7 = {
|
1632
1464
|
whiteSpace: "nowrap"
|
1633
|
-
}, $[14] =
|
1634
|
-
const
|
1635
|
-
let t8;
|
1636
|
-
$[15] !== t || $[16] !== t7 ? (t8 = t("preview-frame.overlay.toggle-button.tooltip", {
|
1637
|
-
context: t7
|
1638
|
-
}), $[15] = t, $[16] = t7, $[17] = t8) : t8 = $[17];
|
1465
|
+
}, $[14] = t7) : t7 = $[14];
|
1466
|
+
const t8 = overlaysEnabled ? "disable" : "enable";
|
1639
1467
|
let t9;
|
1640
|
-
$[
|
1468
|
+
$[15] !== t || $[16] !== t8 ? (t9 = t("preview-frame.overlay.toggle-button.tooltip", {
|
1469
|
+
context: t8
|
1470
|
+
}), $[15] = t, $[16] = t8, $[17] = t9) : t9 = $[17];
|
1641
1471
|
let t10;
|
1642
|
-
$[
|
1472
|
+
$[18] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: t9 }) }), $[18] = t9, $[19] = t10) : t10 = $[19];
|
1473
|
+
let t11;
|
1474
|
+
$[20] === Symbol.for("react.memo_cache_sentinel") ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingY: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Hotkeys, { keys: ["Alt"], style: {
|
1643
1475
|
marginTop: -4,
|
1644
1476
|
marginBottom: -4
|
1645
|
-
} }) }), $[20] =
|
1646
|
-
let t11;
|
1647
|
-
$[21] !== t9 ? (t11 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", style: t6, children: [
|
1648
|
-
t9,
|
1649
|
-
t10
|
1650
|
-
] }), $[21] = t9, $[22] = t11) : t11 = $[22];
|
1477
|
+
} }) }), $[20] = t11) : t11 = $[20];
|
1651
1478
|
let t12;
|
1652
|
-
$[
|
1479
|
+
$[21] !== t10 ? (t12 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", style: t7, children: [
|
1480
|
+
t10,
|
1481
|
+
t11
|
1482
|
+
] }), $[21] = t10, $[22] = t12) : t12 = $[22];
|
1653
1483
|
let t13;
|
1654
|
-
$[
|
1484
|
+
$[23] === Symbol.for("react.memo_cache_sentinel") ? (t13 = ["bottom-start"], $[23] = t13) : t13 = $[23];
|
1485
|
+
let t14;
|
1486
|
+
$[24] === Symbol.for("react.memo_cache_sentinel") ? (t14 = {
|
1655
1487
|
lineHeight: 0,
|
1656
1488
|
borderRadius: 999,
|
1657
1489
|
userSelect: "none"
|
1658
|
-
}, $[24] =
|
1659
|
-
const
|
1660
|
-
let
|
1661
|
-
$[25] === Symbol.for("react.memo_cache_sentinel") ? (
|
1490
|
+
}, $[24] = t14) : t14 = $[24];
|
1491
|
+
const t15 = overlaysEnabled ? "transparent" : void 0;
|
1492
|
+
let t16;
|
1493
|
+
$[25] === Symbol.for("react.memo_cache_sentinel") ? (t16 = {
|
1662
1494
|
margin: -4
|
1663
|
-
}, $[25] =
|
1664
|
-
const
|
1495
|
+
}, $[25] = t16) : t16 = $[25];
|
1496
|
+
const t17 = iframe.status === "loading" || overlaysConnection !== "connected";
|
1665
1497
|
let t18;
|
1666
|
-
$[26] !== overlaysEnabled || $[27] !==
|
1498
|
+
$[26] !== overlaysEnabled || $[27] !== t17 || $[28] !== toggleOverlay ? (t18 = /* @__PURE__ */ jsxRuntime.jsx("div", { style: t16, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Switch, { checked: overlaysEnabled, onChange: toggleOverlay, disabled: t17 }) }), $[26] = overlaysEnabled, $[27] = t17, $[28] = toggleOverlay, $[29] = t18) : t18 = $[29];
|
1667
1499
|
const t19 = !overlaysEnabled;
|
1668
1500
|
let t20;
|
1669
|
-
$[
|
1501
|
+
$[30] !== t ? (t20 = t("preview-frame.overlay.toggle-button.text"), $[30] = t, $[31] = t20) : t20 = $[31];
|
1670
1502
|
let t21;
|
1671
|
-
$[
|
1503
|
+
$[32] !== t19 || $[33] !== t20 ? (t21 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: t19, size: 1, weight: "medium", children: t20 }) }), $[32] = t19, $[33] = t20, $[34] = t21) : t21 = $[34];
|
1672
1504
|
let t22;
|
1673
|
-
$[
|
1505
|
+
$[35] !== t18 || $[36] !== t21 ? (t22 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 3, children: [
|
1674
1506
|
t18,
|
1675
1507
|
t21
|
1676
|
-
] }), $[
|
1508
|
+
] }), $[35] = t18, $[36] = t21, $[37] = t22) : t22 = $[37];
|
1677
1509
|
let t23;
|
1678
|
-
$[
|
1510
|
+
$[38] !== t15 || $[39] !== t22 ? (t23 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { as: "label", flex: "none", padding: 3, marginX: 1, style: t14, tone: t15, children: t22 }), $[38] = t15, $[39] = t22, $[40] = t23) : t23 = $[40];
|
1679
1511
|
let t24;
|
1680
|
-
$[
|
1512
|
+
$[41] !== t12 || $[42] !== t23 ? (t24 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Tooltip, { animate: !0, content: t12, fallbackPlacements: t13, placement: "bottom", portal: !0, children: t23 }), $[41] = t12, $[42] = t23, $[43] = t24) : t24 = $[43];
|
1681
1513
|
let t25;
|
1682
|
-
$[
|
1683
|
-
context:
|
1684
|
-
}), $[
|
1514
|
+
$[44] !== iframe.status || $[45] !== t ? (t25 = iframe.status === "loaded" ? t("preview-frame.refresh-button.tooltip") : t("preview-frame.status", {
|
1515
|
+
context: iframe.status
|
1516
|
+
}), $[44] = iframe.status, $[45] = t, $[46] = t25) : t25 = $[46];
|
1685
1517
|
let t26;
|
1686
|
-
$[
|
1518
|
+
$[47] !== t25 ? (t26 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: t25 }), $[47] = t25, $[48] = t26) : t26 = $[48];
|
1687
1519
|
let t27;
|
1688
|
-
$[
|
1520
|
+
$[49] === Symbol.for("react.memo_cache_sentinel") ? (t27 = ["bottom-end"], $[49] = t27) : t27 = $[49];
|
1689
1521
|
let t28;
|
1690
|
-
$[
|
1691
|
-
const t29 =
|
1522
|
+
$[50] !== t ? (t28 = t("preview-frame.refresh-button.aria-label"), $[50] = t, $[51] = t28) : t28 = $[51];
|
1523
|
+
const t29 = iframe.status === "reloading" || iframe.status === "refreshing";
|
1692
1524
|
let t30;
|
1693
|
-
$[
|
1525
|
+
$[52] !== handleRefresh || $[53] !== t28 || $[54] !== t29 ? (t30 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Button, { "aria-label": t28, icon: icons.RefreshIcon, mode: "bleed", loading: t29, onClick: handleRefresh, tooltipProps: null }), $[52] = handleRefresh, $[53] = t28, $[54] = t29, $[55] = t30) : t30 = $[55];
|
1694
1526
|
let t31;
|
1695
|
-
$[
|
1527
|
+
$[56] !== t26 || $[57] !== t30 ? (t31 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Tooltip, { animate: !0, content: t26, fallbackPlacements: t27, placement: "bottom", portal: !0, children: t30 }) }), $[56] = t26, $[57] = t30, $[58] = t31) : t31 = $[58];
|
1696
1528
|
let t32;
|
1697
|
-
$[
|
1529
|
+
$[59] !== openPopup || $[60] !== perspective || $[61] !== previewLocationOrigin || $[62] !== previewLocationRoute || $[63] !== targetOrigin ? (t32 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(OpenPreviewButton, { openPopup, previewLocationOrigin, previewLocationRoute, perspective, targetOrigin }) }), $[59] = openPopup, $[60] = perspective, $[61] = previewLocationOrigin, $[62] = previewLocationRoute, $[63] = targetOrigin, $[64] = t32) : t32 = $[64];
|
1698
1530
|
let t33;
|
1699
|
-
$[
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1531
|
+
$[65] !== onPathChange || $[66] !== previewLocationOrigin || $[67] !== previewLocationRoute || $[68] !== t31 || $[69] !== t32 ? (t33 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(PreviewLocationInput, { prefix: t31, onChange: onPathChange, origin: previewLocationOrigin, suffix: t32, value: previewLocationRoute }) }), $[65] = onPathChange, $[66] = previewLocationOrigin, $[67] = previewLocationRoute, $[68] = t31, $[69] = t32, $[70] = t33) : t33 = $[70];
|
1532
|
+
const t34 = viewport === "desktop" ? "narrow" : "full";
|
1533
|
+
let t35;
|
1534
|
+
$[71] !== t || $[72] !== t34 ? (t35 = t("preview-frame.viewport-button.tooltip", {
|
1535
|
+
context: t34
|
1536
|
+
}), $[71] = t, $[72] = t34, $[73] = t35) : t35 = $[73];
|
1705
1537
|
let t36;
|
1706
|
-
$[
|
1707
|
-
context: t35
|
1708
|
-
}), $[77] = t, $[78] = t35, $[79] = t36) : t36 = $[79];
|
1538
|
+
$[74] !== t35 ? (t36 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: t35 }), $[74] = t35, $[75] = t36) : t36 = $[75];
|
1709
1539
|
let t37;
|
1710
|
-
$[
|
1540
|
+
$[76] === Symbol.for("react.memo_cache_sentinel") ? (t37 = ["bottom-start"], $[76] = t37) : t37 = $[76];
|
1711
1541
|
let t38;
|
1712
|
-
$[
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1542
|
+
$[77] !== t ? (t38 = t("preview-frame.viewport-button.aria-label"), $[77] = t, $[78] = t38) : t38 = $[78];
|
1543
|
+
const t39 = viewport === "desktop" ? icons.MobileDeviceIcon : icons.DesktopIcon;
|
1544
|
+
let t40;
|
1545
|
+
$[79] !== t38 || $[80] !== t39 || $[81] !== toggleViewportSize || $[82] !== viewport ? (t40 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Button, { "data-testid": "preview-viewport-toggle", "data-viewport": viewport, "aria-label": t38, icon: t39, mode: "bleed", onClick: toggleViewportSize, tooltipProps: null }), $[79] = t38, $[80] = t39, $[81] = toggleViewportSize, $[82] = viewport, $[83] = t40) : t40 = $[83];
|
1716
1546
|
let t41;
|
1717
|
-
$[
|
1547
|
+
$[84] !== t36 || $[85] !== t40 ? (t41 = /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", flex: "none", gap: 1, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Tooltip, { animate: !0, content: t36, fallbackPlacements: t37, placement: "bottom", portal: !0, children: t40 }) }), $[84] = t36, $[85] = t40, $[86] = t41) : t41 = $[86];
|
1718
1548
|
let t42;
|
1719
|
-
$[90] !==
|
1549
|
+
$[87] !== canSharePreviewAccess || $[88] !== canToggleSharePreviewAccess || $[89] !== canUseSharedPreviewAccess || $[90] !== initialUrl || $[91] !== perspective || $[92] !== previewLocationRoute ? (t42 = canSharePreviewAccess && /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", flex: "none", gap: 1, children: /* @__PURE__ */ jsxRuntime.jsx(SharePreviewMenu, { canToggleSharePreviewAccess, canUseSharedPreviewAccess, previewLocationRoute, initialUrl, perspective }) }), $[87] = canSharePreviewAccess, $[88] = canToggleSharePreviewAccess, $[89] = canUseSharedPreviewAccess, $[90] = initialUrl, $[91] = perspective, $[92] = previewLocationRoute, $[93] = t42) : t42 = $[93];
|
1720
1550
|
let t43;
|
1721
|
-
$[94] !==
|
1722
|
-
|
1723
|
-
return $[101] !== t24 || $[102] !== t33 || $[103] !== t42 || $[104] !== t43 || $[105] !== t5 ? (t44 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 1, paddingX: 1, style: t4, children: [
|
1724
|
-
t5,
|
1551
|
+
return $[94] !== t24 || $[95] !== t33 || $[96] !== t41 || $[97] !== t42 || $[98] !== t6 ? (t43 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 1, paddingX: 1, style: t5, children: [
|
1552
|
+
t6,
|
1725
1553
|
t24,
|
1726
1554
|
t33,
|
1727
|
-
|
1728
|
-
|
1729
|
-
] }), $[
|
1555
|
+
t41,
|
1556
|
+
t42
|
1557
|
+
] }), $[94] = t24, $[95] = t33, $[96] = t41, $[97] = t42, $[98] = t6, $[99] = t43) : t43 = $[99], t43;
|
1730
1558
|
};
|
1731
1559
|
function PreviewHeader(props) {
|
1732
|
-
const $ = reactCompilerRuntime.c(7), renderDefault =
|
1560
|
+
const $ = reactCompilerRuntime.c(7), renderDefault = _temp$5, HeaderComponent = props.options?.component;
|
1733
1561
|
let t0;
|
1734
1562
|
$[0] !== HeaderComponent || $[1] !== props ? (t0 = HeaderComponent ? /* @__PURE__ */ jsxRuntime.jsx(HeaderComponent, { ...props, renderDefault }) : renderDefault(props), $[0] = HeaderComponent, $[1] = props, $[2] = t0) : t0 = $[2];
|
1735
1563
|
const header = t0;
|
@@ -1744,42 +1572,20 @@ function PreviewHeader(props) {
|
|
1744
1572
|
let t3;
|
1745
1573
|
return $[5] !== header ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { flex: "none", padding: 2, borderBottom: !0, style: t1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", style: t2, children: header }) }), $[5] = header, $[6] = t3) : t3 = $[6], t3;
|
1746
1574
|
}
|
1747
|
-
function
|
1575
|
+
function _temp$5(props_0) {
|
1748
1576
|
return /* @__PURE__ */ jsxRuntime.jsx(PreviewHeaderDefault, { ...props_0 });
|
1749
1577
|
}
|
1750
|
-
function _temp$8(state) {
|
1751
|
-
return state.matches("loading");
|
1752
|
-
}
|
1753
|
-
function _temp2$5(state_0) {
|
1754
|
-
return state_0.matches("loaded");
|
1755
|
-
}
|
1756
|
-
function _temp3$2(state_1) {
|
1757
|
-
return state_1.matches({
|
1758
|
-
loaded: "refreshing"
|
1759
|
-
});
|
1760
|
-
}
|
1761
|
-
function _temp4$1(state_2) {
|
1762
|
-
return state_2.matches({
|
1763
|
-
loaded: "reloading"
|
1764
|
-
});
|
1765
|
-
}
|
1766
|
-
function _temp5$1(state_3) {
|
1767
|
-
return state_3.context.visualEditingOverlaysEnabled;
|
1768
|
-
}
|
1769
|
-
function _temp6(state_4) {
|
1770
|
-
return state_4.hasTag("busy");
|
1771
|
-
}
|
1772
1578
|
const MotionFlex = framerMotion.motion.create(ui.Flex), Preview = React.memo(React.forwardRef(function(props, forwardedRef) {
|
1773
1579
|
const {
|
1580
|
+
dispatch,
|
1581
|
+
iframe,
|
1774
1582
|
header,
|
1775
1583
|
initialUrl,
|
1776
1584
|
loadersConnection,
|
1777
1585
|
overlaysConnection,
|
1778
1586
|
perspective,
|
1779
1587
|
viewport,
|
1780
|
-
vercelProtectionBypass
|
1781
|
-
presentationRef,
|
1782
|
-
previewUrlRef
|
1588
|
+
vercelProtectionBypass
|
1783
1589
|
} = props, [stablePerspective, setStablePerspective] = React.useState(null), urlPerspective = encodeStudioPerspective(stablePerspective === null ? perspective : stablePerspective), previewUrl = React.useMemo(() => {
|
1784
1590
|
const url = new URL(initialUrl);
|
1785
1591
|
return url.searchParams.get(constants.urlSearchParamPreviewPerspective) || url.searchParams.set(constants.urlSearchParamPreviewPerspective, urlPerspective), (vercelProtectionBypass || url.searchParams.get(constants.urlSearchParamVercelProtectionBypass)) && url.searchParams.set(constants.urlSearchParamVercelSetBypassCookie, "samesitenone"), vercelProtectionBypass && !url.searchParams.get(constants.urlSearchParamVercelProtectionBypass) && url.searchParams.set(constants.urlSearchParamVercelProtectionBypass, vercelProtectionBypass), url;
|
@@ -1793,26 +1599,22 @@ const MotionFlex = framerMotion.motion.create(ui.Flex), Preview = React.memo(Rea
|
|
1793
1599
|
devMode
|
1794
1600
|
} = presentation.usePresentationTool(), prefersReducedMotion = ui.usePrefersReducedMotion(), ref = React.useRef(null), previewHeader = /* @__PURE__ */ jsxRuntime.jsx(PreviewHeader, { ...props, iframeRef: ref, options: header });
|
1795
1601
|
React.useImperativeHandle(forwardedRef, () => ref.current);
|
1796
|
-
const
|
1797
|
-
|
1798
|
-
|
1799
|
-
loaded: "refreshing"
|
1800
|
-
})), [somethingIsWrong, setSomethingIsWrong] = React.useState(!1), iframeIsBusy = isLoading || isRefreshing || overlaysConnection === "connecting", handleRetry = React.useCallback(() => {
|
1801
|
-
ref.current && (ref.current.src = previewUrl.toString(), presentationRef.send({
|
1802
|
-
type: "iframe reload"
|
1602
|
+
const loading = iframe.status === "loading" || iframe.status === "reloading", [timedOut, setTimedOut] = React.useState(!1), refreshing = iframe.status === "refreshing", [somethingIsWrong, setSomethingIsWrong] = React.useState(!1), iframeIsBusy = loading || refreshing || overlaysConnection === "connecting", handleRetry = React.useCallback(() => {
|
1603
|
+
ref.current && (ref.current.src = previewUrl.toString(), dispatch({
|
1604
|
+
type: presentation.ACTION_IFRAME_RELOAD
|
1803
1605
|
}));
|
1804
|
-
}, [
|
1606
|
+
}, [dispatch, previewUrl]), handleContinueAnyway = React.useCallback(() => {
|
1805
1607
|
setContinueAnyway(!0);
|
1806
1608
|
}, []), [continueAnyway, setContinueAnyway] = React.useState(!1), [showOverlaysConnectionStatus, setShowOverlaysConnectionState] = React.useState(!1);
|
1807
1609
|
React.useEffect(() => {
|
1808
|
-
if (!(
|
1610
|
+
if (!(loading || refreshing) && (overlaysConnection === "connecting" || overlaysConnection === "reconnecting")) {
|
1809
1611
|
const timeout = setTimeout(() => {
|
1810
1612
|
setShowOverlaysConnectionState(!0);
|
1811
1613
|
}, 5e3);
|
1812
1614
|
return () => clearTimeout(timeout);
|
1813
1615
|
}
|
1814
|
-
}, [overlaysConnection,
|
1815
|
-
if (!(
|
1616
|
+
}, [overlaysConnection, loading, refreshing]), React.useEffect(() => {
|
1617
|
+
if (!(loading || refreshing || !showOverlaysConnectionStatus)) {
|
1816
1618
|
if (overlaysConnection === "connected" && (setSomethingIsWrong(!1), setShowOverlaysConnectionState(!1), setTimedOut(!1), setContinueAnyway(!1)), overlaysConnection === "connecting") {
|
1817
1619
|
const timeout_0 = setTimeout(() => {
|
1818
1620
|
setTimedOut(!0), console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly");
|
@@ -1826,110 +1628,46 @@ const MotionFlex = framerMotion.motion.create(ui.Flex), Preview = React.memo(Rea
|
|
1826
1628
|
return () => clearTimeout(timeout_1);
|
1827
1629
|
}
|
1828
1630
|
}
|
1829
|
-
}, [
|
1631
|
+
}, [loading, overlaysConnection, refreshing, showOverlaysConnectionStatus]);
|
1830
1632
|
const onIFrameLoad = React.useCallback(() => {
|
1831
|
-
|
1832
|
-
type:
|
1633
|
+
dispatch({
|
1634
|
+
type: presentation.ACTION_IFRAME_LOADED
|
1833
1635
|
});
|
1834
|
-
}, [
|
1636
|
+
}, [dispatch]);
|
1637
|
+
React.useEffect(() => {
|
1638
|
+
if (!ref.current)
|
1639
|
+
return;
|
1640
|
+
const instance = ref.current;
|
1641
|
+
function handleBlur() {
|
1642
|
+
instance === document.activeElement && instance.dispatchEvent(new MouseEvent("mousedown", {
|
1643
|
+
bubbles: !0,
|
1644
|
+
cancelable: !0
|
1645
|
+
}));
|
1646
|
+
}
|
1647
|
+
return window.addEventListener("blur", handleBlur), () => {
|
1648
|
+
window.removeEventListener("blur", handleBlur);
|
1649
|
+
};
|
1650
|
+
}, []);
|
1651
|
+
const preventIframeInteraction = React.useMemo(() => (loading || overlaysConnection === "connecting" && iframe.status !== "refreshing") && !continueAnyway, [continueAnyway, iframe.status, loading, overlaysConnection]), canUseViewTransition = React.useSyncExternalStore(
|
1835
1652
|
// eslint-disable-next-line no-empty-function
|
1836
1653
|
React.useCallback(() => () => {
|
1837
1654
|
}, []),
|
1838
1655
|
() => CSS.supports("(view-transition-name: test)")
|
1839
1656
|
), iframeAnimations = React.useMemo(() => [
|
1840
1657
|
preventIframeInteraction ? "background" : "active",
|
1841
|
-
|
1658
|
+
loading ? "reloading" : "idle",
|
1842
1659
|
// If CSS View Transitions are supported, then transition iframe viewport dimensions with that instead of Motion
|
1843
1660
|
canUseViewTransition ? "" : viewport,
|
1844
1661
|
showOverlaysConnectionStatus && !continueAnyway ? "timedOut" : ""
|
1845
|
-
], [canUseViewTransition, continueAnyway,
|
1846
|
-
React.useEffect(() => {
|
1662
|
+
], [canUseViewTransition, continueAnyway, loading, preventIframeInteraction, showOverlaysConnectionStatus, viewport]), [currentViewport, setCurrentViewport] = React.useState(viewport), [iframeStyle, setIframeStyle] = React.useState(iframeVariants[viewport]);
|
1663
|
+
return React.useEffect(() => {
|
1847
1664
|
if (canUseViewTransition && viewport !== currentViewport) {
|
1848
1665
|
const update = () => {
|
1849
1666
|
setCurrentViewport(viewport), setIframeStyle(iframeVariants[viewport]);
|
1850
1667
|
};
|
1851
|
-
!prefersReducedMotion && "startViewTransition" in document && typeof document.startViewTransition == "function" ? document.startViewTransition(
|
1852
|
-
// @ts-expect-error - fix typings
|
1853
|
-
update: () => reactDom.flushSync(() => update()),
|
1854
|
-
types: ["sanity-iframe-viewport"]
|
1855
|
-
}) : update();
|
1856
|
-
}
|
1857
|
-
}, [canUseViewTransition, prefersReducedMotion, currentViewport, viewport]);
|
1858
|
-
const toast = ui.useToast(), allowOrigins = useAllowPatterns(previewUrlRef), [checkOrigin, setCheckOrigin] = React.useState(!1), [reportedMismatches] = React.useState(/* @__PURE__ */ new Set()), reportMismatchingOrigin = useEffectEvent.useEffectEvent((reportedOrigin) => {
|
1859
|
-
if (allowOrigins.some((allow) => allow.test(reportedOrigin))) {
|
1860
|
-
setCheckOrigin(reportedOrigin);
|
1861
|
-
return;
|
1862
|
-
}
|
1863
|
-
reportedMismatches.has(reportedOrigin) || (reportedMismatches.add(reportedOrigin), console.warn("Visual Editing is here but misconfigured", {
|
1864
|
-
reportedOrigin
|
1865
|
-
}), toast.push({
|
1866
|
-
closable: !0,
|
1867
|
-
id: `presentation-iframe-origin-mismatch-${reportedOrigin}`,
|
1868
|
-
status: "error",
|
1869
|
-
duration: 1 / 0,
|
1870
|
-
title: t("preview-frame.configuration.error.title"),
|
1871
|
-
description: /* @__PURE__ */ jsxRuntime.jsx(sanity.Translate, { t, i18nKey: "preview-frame.configuration.error.description", components: {
|
1872
|
-
Code: "code"
|
1873
|
-
}, values: {
|
1874
|
-
targetOrigin: previewUrl.origin,
|
1875
|
-
reportedOrigin
|
1876
|
-
} })
|
1877
|
-
}));
|
1878
|
-
}), navigate = presentation.usePresentationNavigate(), navigateEvent = useEffectEvent.useEffectEvent((url_0) => {
|
1879
|
-
if (!checkOrigin) return;
|
1880
|
-
const nextUrl = new URL(url_0, checkOrigin);
|
1881
|
-
navigate(`${checkOrigin}${nextUrl.pathname}${nextUrl.search}${nextUrl.hash}`);
|
1882
|
-
});
|
1883
|
-
return React.useEffect(() => {
|
1884
|
-
if (!checkOrigin)
|
1885
|
-
return;
|
1886
|
-
const target = ref.current?.contentWindow;
|
1887
|
-
if (!target)
|
1888
|
-
return;
|
1889
|
-
const controller = comlink.createController({
|
1890
|
-
targetOrigin: checkOrigin
|
1891
|
-
});
|
1892
|
-
controller.addTarget(target);
|
1893
|
-
const comlink$1 = controller.createChannel({
|
1894
|
-
name: "presentation",
|
1895
|
-
heartbeat: !0,
|
1896
|
-
connectTo: "visual-editing"
|
1897
|
-
}, comlink.createConnectionMachine().provide({
|
1898
|
-
actors: presentationComlink.createCompatibilityActors()
|
1899
|
-
}));
|
1900
|
-
comlink$1.on("visual-editing/navigate", (data) => {
|
1901
|
-
navigateEvent(data.url);
|
1902
|
-
});
|
1903
|
-
const stop = comlink$1.start();
|
1904
|
-
return () => {
|
1905
|
-
stop(), controller.destroy();
|
1906
|
-
};
|
1907
|
-
}, [checkOrigin]), React.useEffect(() => {
|
1908
|
-
if (overlaysConnection === "connecting" || overlaysConnection === "reconnecting") {
|
1909
|
-
const interval = setInterval(() => {
|
1910
|
-
ref.current?.contentWindow?.postMessage(
|
1911
|
-
{
|
1912
|
-
domain: "sanity/channels",
|
1913
|
-
from: "presentation",
|
1914
|
-
type: "presentation/status"
|
1915
|
-
},
|
1916
|
-
/**
|
1917
|
-
* The targetOrigin is set to '*' intentionally here, as we need to find out if the iframe is misconfigured and has the wrong origin
|
1918
|
-
*/
|
1919
|
-
"*"
|
1920
|
-
);
|
1921
|
-
}, 1e3), controller_0 = new AbortController();
|
1922
|
-
return window.addEventListener("message", ({
|
1923
|
-
data: data_0
|
1924
|
-
}) => {
|
1925
|
-
data_0 && typeof data_0 == "object" && "domain" in data_0 && data_0.domain === "sanity/channels" && "type" in data_0 && data_0.type === "visual-editing/status" && "data" in data_0 && typeof data_0.data == "object" && data_0.data && "origin" in data_0.data && typeof data_0.data.origin == "string" && reportMismatchingOrigin(data_0.data.origin);
|
1926
|
-
}, {
|
1927
|
-
signal: controller_0.signal
|
1928
|
-
}), () => {
|
1929
|
-
controller_0.abort(), clearInterval(interval);
|
1930
|
-
};
|
1668
|
+
!prefersReducedMotion && "startViewTransition" in document && typeof document.startViewTransition == "function" ? document.startViewTransition(() => reactDom.flushSync(() => update())) : update();
|
1931
1669
|
}
|
1932
|
-
}, [
|
1670
|
+
}, [canUseViewTransition, prefersReducedMotion, currentViewport, viewport]), /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: prefersReducedMotion ? {
|
1933
1671
|
duration: 0
|
1934
1672
|
} : void 0, children: /* @__PURE__ */ jsxRuntime.jsxs(TooltipDelayGroupProvider.TooltipDelayGroupProvider, { children: [
|
1935
1673
|
previewHeader,
|
@@ -1937,7 +1675,7 @@ const MotionFlex = framerMotion.motion.create(ui.Flex), Preview = React.memo(Rea
|
|
1937
1675
|
position: "relative",
|
1938
1676
|
cursor: iframeIsBusy ? "wait" : void 0
|
1939
1677
|
}, children: [
|
1940
|
-
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: !somethingIsWrong && !
|
1678
|
+
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: !somethingIsWrong && !loading && !refreshing && // viewport, // using CSS View Transitions instead of framer motion to drive this
|
1941
1679
|
showOverlaysConnectionStatus && !continueAnyway ? /* @__PURE__ */ jsxRuntime.jsx(MotionFlex, { initial: "initial", animate: "animate", exit: "exit", variants: spinnerVariants, justify: "center", align: "center", style: {
|
1942
1680
|
inset: "0",
|
1943
1681
|
position: "absolute",
|
@@ -1969,7 +1707,7 @@ const MotionFlex = framerMotion.motion.create(ui.Flex), Preview = React.memo(Rea
|
|
1969
1707
|
text: t("preview-frame.continue-button.text")
|
1970
1708
|
}
|
1971
1709
|
)
|
1972
|
-
] }) }) : (
|
1710
|
+
] }) }) : (loading || overlaysConnection === "connecting" && iframe.status !== "refreshing") && !continueAnyway ? /* @__PURE__ */ jsxRuntime.jsx(MotionFlex, { initial: "initial", animate: "animate", exit: "exit", variants: spinnerVariants, justify: "center", align: "center", style: {
|
1973
1711
|
inset: "0",
|
1974
1712
|
position: "absolute"
|
1975
1713
|
// boxShadow: '0 0 0 1px var(--card-shadow-outline-color)',
|
@@ -2077,7 +1815,7 @@ function useDocumentsOnPage(perspective, frameStateRef) {
|
|
2077
1815
|
const [previewDrafts, setPreviewDrafts] = React.useState(t1), urlRef = React.useRef("");
|
2078
1816
|
let t2;
|
2079
1817
|
$[2] !== frameStateRef ? (t2 = (key, perspective_0, t32) => {
|
2080
|
-
const documents = (t32 === void 0 ? [] : t32).filter(_temp$
|
1818
|
+
const documents = (t32 === void 0 ? [] : t32).filter(_temp$4);
|
2081
1819
|
(perspective_0 === "published" ? setPublished : setPreviewDrafts)((cache) => {
|
2082
1820
|
const next = {};
|
2083
1821
|
for (const document2 of documents)
|
@@ -2098,7 +1836,7 @@ function useDocumentsOnPage(perspective, frameStateRef) {
|
|
2098
1836
|
const keyedCache = perspective === "published" ? published : previewDrafts;
|
2099
1837
|
let t4;
|
2100
1838
|
if ($[4] !== keyedCache) {
|
2101
|
-
const uniqueDocuments = Object.values(keyedCache).reduce(_temp2$
|
1839
|
+
const uniqueDocuments = Object.values(keyedCache).reduce(_temp2$2, {});
|
2102
1840
|
t4 = Object.values(uniqueDocuments), $[4] = keyedCache, $[5] = t4;
|
2103
1841
|
} else
|
2104
1842
|
t4 = $[5];
|
@@ -2107,12 +1845,12 @@ function useDocumentsOnPage(perspective, frameStateRef) {
|
|
2107
1845
|
let t5;
|
2108
1846
|
return $[6] !== documentsOnPage || $[7] !== setDocumentsOnPage ? (t5 = [documentsOnPage, setDocumentsOnPage], $[6] = documentsOnPage, $[7] = setDocumentsOnPage, $[8] = t5) : t5 = $[8], t5;
|
2109
1847
|
}
|
2110
|
-
function _temp2$
|
1848
|
+
function _temp2$2(acc, cache_0) {
|
2111
1849
|
return Object.values(cache_0).forEach((doc) => {
|
2112
1850
|
acc[doc._id] = doc;
|
2113
1851
|
}), acc;
|
2114
1852
|
}
|
2115
|
-
function _temp$
|
1853
|
+
function _temp$4(sourceDocument) {
|
2116
1854
|
return "_projectId" in sourceDocument && sourceDocument._projectId ? (warnOnceAboutCrossDatasetReference("Cross dataset references are not supported yet, ignoring source document", sourceDocument), !1) : sourceDocument;
|
2117
1855
|
}
|
2118
1856
|
function fnOrObj(arg, context) {
|
@@ -2134,14 +1872,14 @@ function getParamsFromResult(resolver, context) {
|
|
2134
1872
|
function getRouteContext(route, url) {
|
2135
1873
|
const routes = Array.isArray(route) ? route : [route];
|
2136
1874
|
for (route of routes) {
|
2137
|
-
let
|
1875
|
+
let origin, path = route;
|
2138
1876
|
if (typeof route == "string")
|
2139
1877
|
try {
|
2140
1878
|
const absolute = new URL(route);
|
2141
|
-
|
1879
|
+
origin = absolute.origin, path = absolute.pathname;
|
2142
1880
|
} catch {
|
2143
1881
|
}
|
2144
|
-
if (!(
|
1882
|
+
if (!(origin && url.origin !== origin))
|
2145
1883
|
try {
|
2146
1884
|
const result = pathToRegexp.match(path, {
|
2147
1885
|
decode: decodeURIComponent
|
@@ -2152,7 +1890,7 @@ function getRouteContext(route, url) {
|
|
2152
1890
|
path: path2
|
2153
1891
|
} = result;
|
2154
1892
|
return {
|
2155
|
-
origin
|
1893
|
+
origin,
|
2156
1894
|
params,
|
2157
1895
|
path: path2
|
2158
1896
|
};
|
@@ -2167,7 +1905,7 @@ function useMainDocument(props) {
|
|
2167
1905
|
navigate,
|
2168
1906
|
navigationHistory,
|
2169
1907
|
path,
|
2170
|
-
|
1908
|
+
previewUrl,
|
2171
1909
|
resolvers: t0
|
2172
1910
|
} = props;
|
2173
1911
|
let t1;
|
@@ -2183,7 +1921,7 @@ function useMainDocument(props) {
|
|
2183
1921
|
}, $[2] = t2) : t2 = $[2];
|
2184
1922
|
const client2 = sanity.useClient(t2);
|
2185
1923
|
let t3;
|
2186
|
-
$[3] !== path || $[4] !== routerState ? (t3 = path || routerState._searchParams?.find(_temp$
|
1924
|
+
$[3] !== path || $[4] !== routerState ? (t3 = path || routerState._searchParams?.find(_temp$3)?.[1] || "", $[3] = path, $[4] = routerState, $[5] = t3) : t3 = $[5];
|
2187
1925
|
const relativeUrl = t3, [mainDocumentState, setMainDocumentState] = React.useState(void 0), mainDocumentIdRef = React.useRef(void 0);
|
2188
1926
|
let t4;
|
2189
1927
|
$[6] !== navigate || $[7] !== navigationHistory ? (t4 = (doc, url) => {
|
@@ -2197,8 +1935,8 @@ function useMainDocument(props) {
|
|
2197
1935
|
}, $[6] = navigate, $[7] = navigationHistory, $[8] = t4) : t4 = $[8];
|
2198
1936
|
const handleResponse = useEffectEvent.useEffectEvent(t4);
|
2199
1937
|
let t5;
|
2200
|
-
$[9] !== client2 || $[10] !== handleResponse || $[11] !== perspectiveStack || $[12] !==
|
2201
|
-
const url_0 = new URL(relativeUrl,
|
1938
|
+
$[9] !== client2 || $[10] !== handleResponse || $[11] !== perspectiveStack || $[12] !== previewUrl || $[13] !== relativeUrl || $[14] !== resolvers ? (t5 = () => {
|
1939
|
+
const base = typeof previewUrl == "string" ? previewUrl : typeof previewUrl == "object" && previewUrl?.origin || location.origin, url_0 = new URL(relativeUrl, base);
|
2202
1940
|
if (resolvers.length) {
|
2203
1941
|
let result;
|
2204
1942
|
for (const resolver of resolvers) {
|
@@ -2231,14 +1969,25 @@ function useMainDocument(props) {
|
|
2231
1969
|
}
|
2232
1970
|
}
|
2233
1971
|
setMainDocumentState(void 0), mainDocumentIdRef.current = void 0;
|
2234
|
-
}, $[9] = client2, $[10] = handleResponse, $[11] = perspectiveStack, $[12] =
|
1972
|
+
}, $[9] = client2, $[10] = handleResponse, $[11] = perspectiveStack, $[12] = previewUrl, $[13] = relativeUrl, $[14] = resolvers, $[15] = t5) : t5 = $[15];
|
2235
1973
|
let t6;
|
2236
|
-
return $[16] !== client2 || $[17] !== perspectiveStack || $[18] !==
|
1974
|
+
return $[16] !== client2 || $[17] !== perspectiveStack || $[18] !== previewUrl || $[19] !== relativeUrl || $[20] !== resolvers ? (t6 = [client2, previewUrl, relativeUrl, resolvers, perspectiveStack], $[16] = client2, $[17] = perspectiveStack, $[18] = previewUrl, $[19] = relativeUrl, $[20] = resolvers, $[21] = t6) : t6 = $[21], React.useEffect(t5, t6), mainDocumentState;
|
2237
1975
|
}
|
2238
|
-
function _temp$
|
1976
|
+
function _temp$3(t0) {
|
2239
1977
|
const [key] = t0;
|
2240
1978
|
return key === "preview";
|
2241
1979
|
}
|
1980
|
+
const lengthyStr$1 = valibot.pipe(valibot.string(), valibot.minLength(1)), optionalLengthyStr = valibot.optional(lengthyStr$1);
|
1981
|
+
valibot.object({
|
1982
|
+
baseUrl: lengthyStr$1,
|
1983
|
+
dataset: optionalLengthyStr,
|
1984
|
+
id: lengthyStr$1,
|
1985
|
+
path: lengthyStr$1,
|
1986
|
+
projectId: optionalLengthyStr,
|
1987
|
+
tool: optionalLengthyStr,
|
1988
|
+
type: optionalLengthyStr,
|
1989
|
+
workspace: optionalLengthyStr
|
1990
|
+
});
|
2242
1991
|
const RE_SEGMENT_WITH_INDEX = /^([\w-]+):(0|[1-9][0-9]*)$/, RE_SEGMENT_WITH_TUPLE = /^([\w-]+):([0-9]+),([0-9]+)$/, RE_SEGMENT_WITH_KEY = /^([\w-]+):([\w-]+)$/;
|
2243
1992
|
function urlStringToPath(str) {
|
2244
1993
|
const path = [];
|
@@ -2264,6 +2013,12 @@ function urlStringToPath(str) {
|
|
2264
2013
|
}
|
2265
2014
|
return path;
|
2266
2015
|
}
|
2016
|
+
const lengthyStr = valibot.pipe(valibot.string(), valibot.minLength(1));
|
2017
|
+
valibot.object({
|
2018
|
+
origin: lengthyStr,
|
2019
|
+
href: lengthyStr,
|
2020
|
+
data: valibot.optional(valibot.record(valibot.string(), valibot.unknown()))
|
2021
|
+
});
|
2267
2022
|
function parseId(rawId) {
|
2268
2023
|
if (rawId === void 0)
|
2269
2024
|
return;
|
@@ -2301,7 +2056,7 @@ function useParams({
|
|
2301
2056
|
id,
|
2302
2057
|
type,
|
2303
2058
|
path,
|
2304
|
-
preview: routerSearchParams.preview || initialPreviewUrl.
|
2059
|
+
preview: routerSearchParams.preview || `${initialPreviewUrl.pathname}${initialPreviewUrl.search}`,
|
2305
2060
|
perspective: routerSearchParams.perspective,
|
2306
2061
|
viewport: routerSearchParams.viewport,
|
2307
2062
|
inspect: routerSearchParams.inspect,
|
@@ -2366,7 +2121,7 @@ function useParams({
|
|
2366
2121
|
};
|
2367
2122
|
}
|
2368
2123
|
const usePopups = (controller) => {
|
2369
|
-
const $ = reactCompilerRuntime.c(10), [popups, setPopups] = React.useState(_temp$
|
2124
|
+
const $ = reactCompilerRuntime.c(10), [popups, setPopups] = React.useState(_temp$2);
|
2370
2125
|
let t0;
|
2371
2126
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (url) => {
|
2372
2127
|
const source = window.open(url, "_blank");
|
@@ -2380,7 +2135,7 @@ const usePopups = (controller) => {
|
|
2380
2135
|
for (const source_0 of popups)
|
2381
2136
|
source_0 && "closed" in source_0 && !source_0.closed && unsubs.push(controller.addTarget(source_0));
|
2382
2137
|
return () => {
|
2383
|
-
unsubs.forEach(_temp2$
|
2138
|
+
unsubs.forEach(_temp2$1);
|
2384
2139
|
};
|
2385
2140
|
}, t2 = [controller, popups], $[1] = controller, $[2] = popups, $[3] = t1, $[4] = t2) : (t1 = $[3], t2 = $[4]), React.useEffect(t1, t2);
|
2386
2141
|
let t3, t4;
|
@@ -2408,19 +2163,85 @@ const usePopups = (controller) => {
|
|
2408
2163
|
open
|
2409
2164
|
}, $[8] = popups, $[9] = t5) : t5 = $[9], t5;
|
2410
2165
|
};
|
2411
|
-
function _temp$
|
2166
|
+
function _temp$2() {
|
2412
2167
|
return /* @__PURE__ */ new Set();
|
2413
2168
|
}
|
2414
|
-
function _temp2$
|
2169
|
+
function _temp2$1(unsub) {
|
2415
2170
|
return unsub();
|
2416
2171
|
}
|
2417
|
-
function
|
2418
|
-
const
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
} =
|
2423
|
-
|
2172
|
+
function usePreviewUrl(previewUrl, toolName, studioPreviewPerspective, previewSearchParam, canCreateUrlPreviewSecrets) {
|
2173
|
+
const $ = reactCompilerRuntime.c(12);
|
2174
|
+
let t0;
|
2175
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
2176
|
+
apiVersion: presentation.API_VERSION
|
2177
|
+
}, $[0] = t0) : t0 = $[0];
|
2178
|
+
const client2 = sanity.useClient(t0), workspace = sanity.useActiveWorkspace(), basePath = workspace?.activeWorkspace?.basePath || "/", workspaceName = workspace?.activeWorkspace?.name || "default", deps = useSuspendCacheKeys(toolName, basePath, workspaceName, previewSearchParam), previewUrlSecret = usePreviewUrlSecret(canCreateUrlPreviewSecrets && typeof previewUrl == "object" || typeof previewUrl == "function", deps);
|
2179
|
+
let t1;
|
2180
|
+
$[1] !== basePath || $[2] !== client2 || $[3] !== previewSearchParam || $[4] !== previewUrl || $[5] !== previewUrlSecret || $[6] !== studioPreviewPerspective ? (t1 = async () => {
|
2181
|
+
if (typeof previewUrl == "string") {
|
2182
|
+
const resolvedUrl = new URL(previewUrl, location.origin);
|
2183
|
+
let resultUrl = resolvedUrl;
|
2184
|
+
try {
|
2185
|
+
if (previewSearchParam) {
|
2186
|
+
const restoredUrl = new URL(previewSearchParam, resolvedUrl);
|
2187
|
+
restoredUrl.origin === resolvedUrl.origin && (resultUrl = restoredUrl);
|
2188
|
+
}
|
2189
|
+
} catch {
|
2190
|
+
}
|
2191
|
+
return location.origin === resultUrl.origin && (resultUrl.pathname.startsWith(`${basePath}/`) || resultUrl.pathname === basePath) ? resolvedUrl : resultUrl;
|
2192
|
+
}
|
2193
|
+
const resolvedUrl_0 = await (typeof previewUrl == "object" ? definePreviewUrl.definePreviewUrl(previewUrl) : previewUrl)({
|
2194
|
+
client: client2,
|
2195
|
+
previewUrlSecret,
|
2196
|
+
studioPreviewPerspective: encodeStudioPerspective(studioPreviewPerspective),
|
2197
|
+
previewSearchParam,
|
2198
|
+
studioBasePath: basePath
|
2199
|
+
});
|
2200
|
+
return new URL(resolvedUrl_0, location.origin);
|
2201
|
+
}, $[1] = basePath, $[2] = client2, $[3] = previewSearchParam, $[4] = previewUrl, $[5] = previewUrlSecret, $[6] = studioPreviewPerspective, $[7] = t1) : t1 = $[7];
|
2202
|
+
let t2;
|
2203
|
+
return $[8] !== deps || $[9] !== previewUrlSecret || $[10] !== t1 ? (t2 = suspendReact.suspend(t1, [...deps, previewUrlSecret]), $[8] = deps, $[9] = previewUrlSecret, $[10] = t1, $[11] = t2) : t2 = $[11], t2;
|
2204
|
+
}
|
2205
|
+
const resolveUUID = Symbol("sanity/presentation/resolveUUID");
|
2206
|
+
function useSuspendCacheKeys(toolName, basePath, workspaceName, previewSearchParam) {
|
2207
|
+
const $ = reactCompilerRuntime.c(12);
|
2208
|
+
let t0;
|
2209
|
+
$[0] !== previewSearchParam ? (t0 = () => previewSearchParam || "", $[0] = previewSearchParam, $[1] = t0) : t0 = $[1];
|
2210
|
+
const [cachedPreviewSearchParam, setCachedPreviewSearchParam] = React.useState(t0), timeoutRef = React.useRef(0);
|
2211
|
+
let t1, t2;
|
2212
|
+
$[2] !== cachedPreviewSearchParam || $[3] !== previewSearchParam ? (t1 = () => {
|
2213
|
+
if (cachedPreviewSearchParam && previewSearchParam)
|
2214
|
+
return window.clearTimeout(timeoutRef.current), () => {
|
2215
|
+
timeoutRef.current = window.setTimeout(() => {
|
2216
|
+
setCachedPreviewSearchParam("");
|
2217
|
+
}, 100);
|
2218
|
+
};
|
2219
|
+
}, t2 = [cachedPreviewSearchParam, previewSearchParam], $[2] = cachedPreviewSearchParam, $[3] = previewSearchParam, $[4] = t1, $[5] = t2) : (t1 = $[4], t2 = $[5]), React.useEffect(t1, t2);
|
2220
|
+
const currentUser = sanity.useCurrentUser();
|
2221
|
+
let t3;
|
2222
|
+
const t4 = currentUser?.id;
|
2223
|
+
let t5;
|
2224
|
+
return $[6] !== basePath || $[7] !== cachedPreviewSearchParam || $[8] !== t4 || $[9] !== toolName || $[10] !== workspaceName ? (t5 = ["sanity/presentation", basePath, workspaceName, toolName, t4, resolveUUID, cachedPreviewSearchParam], $[6] = basePath, $[7] = cachedPreviewSearchParam, $[8] = t4, $[9] = toolName, $[10] = workspaceName, $[11] = t5) : t5 = $[11], t3 = t5, t3;
|
2225
|
+
}
|
2226
|
+
function usePreviewUrlSecret(enabled, deps) {
|
2227
|
+
const $ = reactCompilerRuntime.c(10);
|
2228
|
+
let t0;
|
2229
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
2230
|
+
apiVersion: presentation.API_VERSION
|
2231
|
+
}, $[0] = t0) : t0 = $[0];
|
2232
|
+
const client2 = sanity.useClient(t0), currentUser = sanity.useCurrentUser(), [secretLastExpiredAt, setSecretLastExpiredAt] = React.useState("");
|
2233
|
+
let t1;
|
2234
|
+
$[1] !== client2 || $[2] !== currentUser?.id || $[3] !== deps || $[4] !== enabled || $[5] !== secretLastExpiredAt ? (t1 = enabled ? suspendReact.suspend(async () => await createSecret.createPreviewSecret(client2, "@sanity/presentation", typeof window > "u" ? "" : location.href, currentUser?.id), [...deps, secretLastExpiredAt]) : null, $[1] = client2, $[2] = currentUser?.id, $[3] = deps, $[4] = enabled, $[5] = secretLastExpiredAt, $[6] = t1) : t1 = $[6];
|
2235
|
+
const previewUrlSecret = t1;
|
2236
|
+
let t2, t3;
|
2237
|
+
return $[7] !== previewUrlSecret ? (t2 = () => {
|
2238
|
+
if (!previewUrlSecret)
|
2239
|
+
return;
|
2240
|
+
const timeout = setTimeout(() => {
|
2241
|
+
React.startTransition(() => setSecretLastExpiredAt(previewUrlSecret.expiresAt.toString()));
|
2242
|
+
}, previewUrlSecret.expiresAt.getTime() - Date.now());
|
2243
|
+
return () => clearTimeout(timeout);
|
2244
|
+
}, t3 = [previewUrlSecret], $[7] = previewUrlSecret, $[8] = t2, $[9] = t3) : (t2 = $[8], t3 = $[9]), React.useEffect(t2, t3), previewUrlSecret?.secret || null;
|
2424
2245
|
}
|
2425
2246
|
function useStatus() {
|
2426
2247
|
const $ = reactCompilerRuntime.c(4);
|
@@ -2430,13 +2251,13 @@ function useStatus() {
|
|
2430
2251
|
let t1;
|
2431
2252
|
bb0: {
|
2432
2253
|
const values = Array.from(statusMap.values());
|
2433
|
-
if (values.find(_temp$
|
2254
|
+
if (values.find(_temp$1)) {
|
2434
2255
|
t1 = "connected";
|
2435
2256
|
break bb0;
|
2436
2257
|
}
|
2437
|
-
const handshaking = values.filter(_temp2
|
2258
|
+
const handshaking = values.filter(_temp2);
|
2438
2259
|
if (handshaking.length) {
|
2439
|
-
t1 = handshaking.some(_temp3
|
2260
|
+
t1 = handshaking.some(_temp3) ? "connecting" : "reconnecting";
|
2440
2261
|
break bb0;
|
2441
2262
|
}
|
2442
2263
|
t1 = "idle";
|
@@ -2462,19 +2283,19 @@ function useStatus() {
|
|
2462
2283
|
let t3;
|
2463
2284
|
return $[2] !== memoStatus ? (t3 = [memoStatus, setStatusFromEvent], $[2] = memoStatus, $[3] = t3) : t3 = $[3], t3;
|
2464
2285
|
}
|
2465
|
-
function _temp3
|
2286
|
+
function _temp3(t0) {
|
2466
2287
|
const {
|
2467
2288
|
hasConnected
|
2468
2289
|
} = t0;
|
2469
2290
|
return !hasConnected;
|
2470
2291
|
}
|
2471
|
-
function _temp2
|
2292
|
+
function _temp2(t0) {
|
2472
2293
|
const {
|
2473
2294
|
status: status_0
|
2474
2295
|
} = t0;
|
2475
2296
|
return status_0 === "connecting";
|
2476
2297
|
}
|
2477
|
-
function _temp$
|
2298
|
+
function _temp$1(t0) {
|
2478
2299
|
const {
|
2479
2300
|
status
|
2480
2301
|
} = t0;
|
@@ -2499,22 +2320,25 @@ const LiveQueries = React.lazy(() => Promise.resolve().then(function() {
|
|
2499
2320
|
`;
|
2500
2321
|
function PresentationTool(props) {
|
2501
2322
|
const {
|
2323
|
+
canCreateUrlPreviewSecrets,
|
2502
2324
|
canToggleSharePreviewAccess,
|
2503
2325
|
canUseSharedPreviewAccess,
|
2504
2326
|
tool,
|
2505
|
-
vercelProtectionBypass
|
2506
|
-
|
2507
|
-
previewUrlRef
|
2508
|
-
} = props, allowOrigins = useAllowPatterns(previewUrlRef), targetOrigin = useTargetOrigin(previewUrlRef), components = tool.options?.components, name = tool.name || presentation.DEFAULT_TOOL_NAME, {
|
2327
|
+
vercelProtectionBypass
|
2328
|
+
} = props, components = tool.options?.components, _previewUrl = tool.options?.previewUrl, name = tool.name || presentation.DEFAULT_TOOL_NAME, {
|
2509
2329
|
unstable_navigator,
|
2510
2330
|
unstable_header
|
2511
2331
|
} = components || {}, {
|
2512
2332
|
navigate: routerNavigate,
|
2513
2333
|
state: routerState
|
2514
|
-
} = router.useRouter(), routerSearchParams = sanity.useUnique(Object.fromEntries(routerState._searchParams || [])),
|
2334
|
+
} = router.useRouter(), routerSearchParams = sanity.useUnique(Object.fromEntries(routerState._searchParams || [])), {
|
2335
|
+
perspectiveStack,
|
2336
|
+
selectedPerspectiveName = "drafts",
|
2337
|
+
selectedReleaseId
|
2338
|
+
} = sanity.usePerspective(), perspective = selectedReleaseId ? perspectiveStack : selectedPerspectiveName, initialPreviewUrl = usePreviewUrl(_previewUrl || "/", name, perspective, routerSearchParams.preview || null, canCreateUrlPreviewSecrets), canSharePreviewAccess = React.useMemo(() => _previewUrl && typeof _previewUrl == "object" && "draftMode" in _previewUrl && _previewUrl.draftMode ? (console.warn("previewUrl.draftMode is deprecated, use previewUrl.previewMode instead"), _previewUrl.draftMode.shareAccess !== !1) : _previewUrl && typeof _previewUrl == "object" && "previewMode" in _previewUrl && _previewUrl.previewMode ? _previewUrl.previewMode.shareAccess !== !1 : !1, [_previewUrl]), [devMode] = React.useState(() => {
|
2515
2339
|
const option = tool.options?.devMode;
|
2516
2340
|
return typeof option == "function" ? option() : typeof option == "boolean" ? option : typeof window < "u" && window.location.hostname === "localhost";
|
2517
|
-
}), iframeRef = React.useRef(null), [controller, setController] = React.useState(), [visualEditingComlink, setVisualEditingComlink] = React.useState(null), frameStateRef = React.useRef({
|
2341
|
+
}), targetOrigin = React.useMemo(() => initialPreviewUrl.origin, [initialPreviewUrl.origin]), iframeRef = React.useRef(null), [controller, setController] = React.useState(), [visualEditingComlink, setVisualEditingComlink] = React.useState(null), frameStateRef = React.useRef({
|
2518
2342
|
title: void 0,
|
2519
2343
|
url: void 0
|
2520
2344
|
}), {
|
@@ -2529,16 +2353,16 @@ function PresentationTool(props) {
|
|
2529
2353
|
routerState,
|
2530
2354
|
routerSearchParams,
|
2531
2355
|
frameStateRef
|
2532
|
-
}), navigate = React.useMemo(() => debounce(_navigate, 50), [_navigate]),
|
2356
|
+
}), navigate = React.useMemo(() => debounce(_navigate, 50), [_navigate]), [state, dispatch] = React.useReducer(presentation.presentationReducer, {}, presentation.presentationReducerInit), viewport = React.useMemo(() => params.viewport ? "mobile" : "desktop", [params.viewport]), [documentsOnPage, setDocumentsOnPage] = useDocumentsOnPage(perspective, frameStateRef), projectId = sanity.useProjectId(), dataset = sanity.useDataset(), mainDocumentState = useMainDocument({
|
2533
2357
|
// Prevent flash of content by using immediate navigation
|
2534
2358
|
navigate: _navigate,
|
2535
2359
|
navigationHistory,
|
2536
2360
|
path: params.preview,
|
2537
|
-
|
2361
|
+
previewUrl: tool.options?.previewUrl,
|
2538
2362
|
resolvers: tool.options?.resolve?.mainDocuments
|
2539
2363
|
}), [overlaysConnection, setOverlaysConnection] = useStatus(), [loadersConnection, setLoadersConnection] = useStatus(), [previewKitConnection, setPreviewKitConnection] = useStatus(), {
|
2540
2364
|
open: handleOpenPopup
|
2541
|
-
} = usePopups(controller), isLoading =
|
2365
|
+
} = usePopups(controller), isLoading = state.iframe.status === "loading";
|
2542
2366
|
React.useEffect(() => {
|
2543
2367
|
const target = iframeRef.current?.contentWindow;
|
2544
2368
|
if (!target || isLoading) return;
|
@@ -2567,14 +2391,9 @@ function PresentationTool(props) {
|
|
2567
2391
|
});
|
2568
2392
|
}), comlink$1.on("visual-editing/navigate", (data_0) => {
|
2569
2393
|
const {
|
2570
|
-
title
|
2394
|
+
title,
|
2395
|
+
url
|
2571
2396
|
} = data_0;
|
2572
|
-
let url = data_0.url;
|
2573
|
-
if (!url.startsWith("http"))
|
2574
|
-
try {
|
2575
|
-
url = new URL(url, targetOrigin).toString();
|
2576
|
-
} catch {
|
2577
|
-
}
|
2578
2397
|
if (frameStateRef.current.url !== url)
|
2579
2398
|
try {
|
2580
2399
|
const [urlWithoutSearch, search] = url.split("?"), searchParams_0 = new URLSearchParams(search);
|
@@ -2593,8 +2412,8 @@ function PresentationTool(props) {
|
|
2593
2412
|
}), comlink$1.on("visual-editing/meta", (data_1) => {
|
2594
2413
|
frameStateRef.current.title = data_1.title;
|
2595
2414
|
}), comlink$1.on("visual-editing/toggle", (data_2) => {
|
2596
|
-
|
2597
|
-
type:
|
2415
|
+
dispatch({
|
2416
|
+
type: presentation.ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE,
|
2598
2417
|
enabled: data_2.enabled
|
2599
2418
|
});
|
2600
2419
|
}), comlink$1.on("visual-editing/documents", (data_3) => {
|
@@ -2605,19 +2424,19 @@ function PresentationTool(props) {
|
|
2605
2424
|
data_3.documents
|
2606
2425
|
);
|
2607
2426
|
}), comlink$1.on("visual-editing/refreshing", (data_4) => {
|
2608
|
-
data_4.source === "manual" ? clearTimeout(refreshRef.current) : data_4.source === "mutation" &&
|
2609
|
-
type:
|
2427
|
+
data_4.source === "manual" ? clearTimeout(refreshRef.current) : data_4.source === "mutation" && dispatch({
|
2428
|
+
type: presentation.ACTION_IFRAME_REFRESH
|
2610
2429
|
});
|
2611
2430
|
}), comlink$1.on("visual-editing/refreshed", () => {
|
2612
|
-
|
2613
|
-
type:
|
2431
|
+
dispatch({
|
2432
|
+
type: presentation.ACTION_IFRAME_LOADED
|
2614
2433
|
});
|
2615
2434
|
}), comlink$1.onStatus(setOverlaysConnection);
|
2616
2435
|
const stop = comlink$1.start();
|
2617
2436
|
return setVisualEditingComlink(comlink$1), () => {
|
2618
2437
|
stop(), setVisualEditingComlink(null);
|
2619
2438
|
};
|
2620
|
-
}, [controller,
|
2439
|
+
}, [controller, setDocumentsOnPage, setOverlaysConnection, targetOrigin]), React.useEffect(() => {
|
2621
2440
|
if (!controller) return;
|
2622
2441
|
const comlink_0 = controller.createChannel({
|
2623
2442
|
name: "presentation",
|
@@ -2640,13 +2459,11 @@ function PresentationTool(props) {
|
|
2640
2459
|
path: csm.studioPath.toString(nextPath)
|
2641
2460
|
}, {}, !0);
|
2642
2461
|
}, [navigate]), handlePreviewPath = React.useCallback((nextPath_0) => {
|
2643
|
-
const url_0 = new URL(nextPath_0,
|
2644
|
-
|
2645
|
-
preview
|
2646
|
-
}) : url_0.origin === targetOrigin && navigate({}, {
|
2462
|
+
const url_0 = new URL(nextPath_0, initialPreviewUrl.origin), preview = url_0.pathname + url_0.search;
|
2463
|
+
url_0.origin === initialPreviewUrl.origin && preview !== params.preview && navigate({}, {
|
2647
2464
|
preview
|
2648
|
-
})
|
2649
|
-
}, [
|
2465
|
+
});
|
2466
|
+
}, [initialPreviewUrl, params, navigate]), handleStructureParams = React.useCallback((structureParams_0) => {
|
2650
2467
|
navigate({}, structureParams_0);
|
2651
2468
|
}, [navigate]);
|
2652
2469
|
React.useEffect(() => {
|
@@ -2655,27 +2472,10 @@ function PresentationTool(props) {
|
|
2655
2472
|
path: params.path
|
2656
2473
|
}) : visualEditingComlink?.post("presentation/blur");
|
2657
2474
|
}, [params.id, params.path, visualEditingComlink]), React.useEffect(() => {
|
2658
|
-
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2662
|
-
return;
|
2663
|
-
} catch {
|
2664
|
-
}
|
2665
|
-
if (frameStateRef.current.url = params.preview, overlaysConnection === "connected") {
|
2666
|
-
let url_1 = params.preview;
|
2667
|
-
if (url_1.startsWith("http"))
|
2668
|
-
try {
|
2669
|
-
const newUrl = new URL(params.preview, targetOrigin);
|
2670
|
-
url_1 = newUrl.pathname + newUrl.search + newUrl.hash;
|
2671
|
-
} catch {
|
2672
|
-
}
|
2673
|
-
visualEditingComlink?.post("presentation/navigate", {
|
2674
|
-
url: url_1,
|
2675
|
-
type: "replace"
|
2676
|
-
});
|
2677
|
-
}
|
2678
|
-
}
|
2475
|
+
frameStateRef.current.url && params.preview && frameStateRef.current.url !== params.preview && (frameStateRef.current.url = params.preview, overlaysConnection !== "connected" && iframeRef.current ? iframeRef.current.src = `${targetOrigin}${params.preview}` : visualEditingComlink?.post("presentation/navigate", {
|
2476
|
+
url: params.preview,
|
2477
|
+
type: "replace"
|
2478
|
+
}));
|
2679
2479
|
}, [overlaysConnection, targetOrigin, params.preview, visualEditingComlink]);
|
2680
2480
|
const toggleOverlay = React.useCallback(() => visualEditingComlink?.post("presentation/toggle-overlay"), [visualEditingComlink]), [displayedDocument, setDisplayedDocument] = React.useState(null);
|
2681
2481
|
React.useEffect(() => {
|
@@ -2694,8 +2494,8 @@ function PresentationTool(props) {
|
|
2694
2494
|
}, PresentationNavigator] = usePresentationNavigator({
|
2695
2495
|
unstable_navigator
|
2696
2496
|
}), refreshRef = React.useRef(void 0), handleRefresh = React.useCallback((fallback) => {
|
2697
|
-
if (
|
2698
|
-
type:
|
2497
|
+
if (dispatch({
|
2498
|
+
type: presentation.ACTION_IFRAME_REFRESH
|
2699
2499
|
}), visualEditingComlink) {
|
2700
2500
|
refreshRef.current = window.setTimeout(fallback, 300), visualEditingComlink.post("presentation/refresh", {
|
2701
2501
|
source: "manual",
|
@@ -2704,7 +2504,7 @@ function PresentationTool(props) {
|
|
2704
2504
|
return;
|
2705
2505
|
}
|
2706
2506
|
fallback();
|
2707
|
-
}, [loadersConnection,
|
2507
|
+
}, [loadersConnection, previewKitConnection, visualEditingComlink]), workspace = sanity.useWorkspace(), getCommentIntent = React.useCallback(({
|
2708
2508
|
id,
|
2709
2509
|
type,
|
2710
2510
|
path
|
@@ -2737,7 +2537,9 @@ function PresentationTool(props) {
|
|
2737
2537
|
canSharePreviewAccess,
|
2738
2538
|
canToggleSharePreviewAccess,
|
2739
2539
|
canUseSharedPreviewAccess,
|
2540
|
+
dispatch,
|
2740
2541
|
header: unstable_header,
|
2542
|
+
iframe: state.iframe,
|
2741
2543
|
initialUrl: initialPreviewUrl,
|
2742
2544
|
loadersConnection,
|
2743
2545
|
navigatorEnabled,
|
@@ -2753,9 +2555,8 @@ function PresentationTool(props) {
|
|
2753
2555
|
toggleNavigator,
|
2754
2556
|
toggleOverlay,
|
2755
2557
|
viewport,
|
2756
|
-
|
2757
|
-
|
2758
|
-
previewUrlRef
|
2558
|
+
visualEditing: state.visualEditing,
|
2559
|
+
vercelProtectionBypass
|
2759
2560
|
},
|
2760
2561
|
targetOrigin
|
2761
2562
|
) }) }) }),
|
@@ -2785,824 +2586,13 @@ const IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigat
|
|
2785
2586
|
function isHotkey(keys, event) {
|
2786
2587
|
return keys.every((key) => MODIFIERS[key] ? event[MODIFIERS[key]] : event.key === key.toUpperCase());
|
2787
2588
|
}
|
2788
|
-
function defineCreatePreviewSecretActor({
|
2789
|
-
client: client2,
|
2790
|
-
currentUserId
|
2791
|
-
}) {
|
2792
|
-
return xstate.fromPromise(async () => await createSecret.createPreviewSecret(client2, "sanity/presentation", location.href, currentUserId));
|
2793
|
-
}
|
2794
|
-
function defineReadSharedSecretActor({
|
2795
|
-
client: client2
|
2796
|
-
}) {
|
2797
|
-
return xstate.fromPromise(async () => client2.fetch(constants.fetchSharedAccessQuery, {}, {
|
2798
|
-
tag: "presentation.fallback-to-shared-access-secret"
|
2799
|
-
}));
|
2800
|
-
}
|
2801
|
-
function defineResolveAllowPatternsActor({
|
2802
|
-
client: client2,
|
2803
|
-
allowOption
|
2804
|
-
}) {
|
2805
|
-
return xstate.fromPromise(async ({
|
2806
|
-
input
|
2807
|
-
}) => {
|
2808
|
-
const {
|
2809
|
-
initialUrl
|
2810
|
-
} = input;
|
2811
|
-
if (typeof URLPattern > "u" && await import("urlpattern-polyfill"), !allowOption)
|
2812
|
-
return [new URLPattern(initialUrl.origin)];
|
2813
|
-
const maybePatterns = typeof allowOption == "function" ? await allowOption({
|
2814
|
-
client: client2,
|
2815
|
-
origin,
|
2816
|
-
initialUrl
|
2817
|
-
}) : allowOption, urlPatterns = (Array.isArray(maybePatterns) ? maybePatterns : [maybePatterns]).map((value) => {
|
2818
|
-
const urlPattern = new URLPattern(value);
|
2819
|
-
if (urlPattern.hostname === "*")
|
2820
|
-
throw new Error("It's insecure to allow any hostname, it could disclose data to a malicious site");
|
2821
|
-
return urlPattern;
|
2822
|
-
});
|
2823
|
-
return urlPatterns.some((pattern) => pattern.test(initialUrl.origin)) ? urlPatterns : [...urlPatterns, new URLPattern(initialUrl.origin)];
|
2824
|
-
});
|
2825
|
-
}
|
2826
|
-
function defineResolveInitialUrlActor({
|
2827
|
-
client: client2,
|
2828
|
-
studioBasePath,
|
2829
|
-
previewUrlOption,
|
2830
|
-
perspective
|
2831
|
-
}) {
|
2832
|
-
return xstate.fromPromise(async ({
|
2833
|
-
input
|
2834
|
-
}) => {
|
2835
|
-
const {
|
2836
|
-
origin: origin2
|
2837
|
-
} = location;
|
2838
|
-
if (typeof previewUrlOption == "function") {
|
2839
|
-
const initial = await previewUrlOption({
|
2840
|
-
client: client2,
|
2841
|
-
studioBasePath,
|
2842
|
-
// @TODO handle checking permissions here, and then generating a secret
|
2843
|
-
previewUrlSecret: "",
|
2844
|
-
studioPreviewPerspective: encodeStudioPerspective(perspective),
|
2845
|
-
previewSearchParam: input.previewSearchParam
|
2846
|
-
});
|
2847
|
-
return new URL(initial, origin2);
|
2848
|
-
}
|
2849
|
-
if (!previewUrlOption)
|
2850
|
-
return new URL("/", origin2);
|
2851
|
-
if (typeof previewUrlOption == "string")
|
2852
|
-
return new URL(previewUrlOption, origin2);
|
2853
|
-
if (typeof previewUrlOption.initial == "function") {
|
2854
|
-
const initial = await previewUrlOption.initial({
|
2855
|
-
client: client2,
|
2856
|
-
origin: origin2
|
2857
|
-
});
|
2858
|
-
return new URL(initial, origin2);
|
2859
|
-
}
|
2860
|
-
return typeof previewUrlOption.initial == "string" ? new URL(previewUrlOption.initial, origin2) : new URL(previewUrlOption.preview || "/", previewUrlOption.origin || origin2);
|
2861
|
-
});
|
2862
|
-
}
|
2863
|
-
function defineResolvePreviewModeActor({
|
2864
|
-
client: client2,
|
2865
|
-
previewUrlOption
|
2866
|
-
}) {
|
2867
|
-
return xstate.fromPromise(async ({
|
2868
|
-
input
|
2869
|
-
}) => {
|
2870
|
-
const {
|
2871
|
-
targetOrigin
|
2872
|
-
} = input;
|
2873
|
-
if (typeof previewUrlOption == "object" && previewUrlOption?.draftMode)
|
2874
|
-
return {
|
2875
|
-
enable: previewUrlOption.draftMode.enable,
|
2876
|
-
shareAccess: previewUrlOption.draftMode.shareAccess ?? !0
|
2877
|
-
};
|
2878
|
-
if (!previewUrlOption || typeof previewUrlOption == "string" || typeof previewUrlOption == "function" || !previewUrlOption.previewMode)
|
2879
|
-
return !1;
|
2880
|
-
const previewMode = typeof previewUrlOption.previewMode == "function" ? await previewUrlOption.previewMode({
|
2881
|
-
client: client2,
|
2882
|
-
origin,
|
2883
|
-
targetOrigin
|
2884
|
-
}) : previewUrlOption.previewMode;
|
2885
|
-
return previewMode === !1 ? !1 : {
|
2886
|
-
enable: previewMode.enable,
|
2887
|
-
shareAccess: previewMode.shareAccess ?? !0
|
2888
|
-
};
|
2889
|
-
});
|
2890
|
-
}
|
2891
|
-
function defineResolvePreviewModeUrlActor({
|
2892
|
-
client: client2,
|
2893
|
-
studioBasePath,
|
2894
|
-
previewUrlOption,
|
2895
|
-
perspective
|
2896
|
-
}) {
|
2897
|
-
return xstate.fromPromise(async ({
|
2898
|
-
input
|
2899
|
-
}) => {
|
2900
|
-
const {
|
2901
|
-
previewUrlSecret,
|
2902
|
-
resolvedPreviewMode,
|
2903
|
-
initialUrl
|
2904
|
-
} = input;
|
2905
|
-
if (typeof previewUrlOption == "function") {
|
2906
|
-
const initial = await previewUrlOption({
|
2907
|
-
client: client2,
|
2908
|
-
studioBasePath,
|
2909
|
-
previewUrlSecret,
|
2910
|
-
studioPreviewPerspective: encodeStudioPerspective(perspective),
|
2911
|
-
previewSearchParam: initialUrl.toString()
|
2912
|
-
});
|
2913
|
-
return new URL(initial, initialUrl);
|
2914
|
-
}
|
2915
|
-
if (!resolvedPreviewMode)
|
2916
|
-
throw new Error("Resolved preview mode is false");
|
2917
|
-
const url = new URL(resolvedPreviewMode.enable, initialUrl);
|
2918
|
-
return url.searchParams.set(constants.urlSearchParamPreviewSecret, previewUrlSecret), url.searchParams.set(constants.urlSearchParamPreviewPerspective, encodeStudioPerspective(perspective)), initialUrl.pathname !== url.pathname && url.searchParams.set(constants.urlSearchParamPreviewPathname, `${initialUrl.pathname}${initialUrl.search}${initialUrl.hash}`), url;
|
2919
|
-
});
|
2920
|
-
}
|
2921
|
-
const resolveUrlFromPreviewSearchParamActor = xstate.fromPromise(async ({
|
2922
|
-
input
|
2923
|
-
}) => {
|
2924
|
-
const {
|
2925
|
-
previewSearchParam,
|
2926
|
-
initialUrl,
|
2927
|
-
allowOrigins
|
2928
|
-
} = input;
|
2929
|
-
if (!previewSearchParam)
|
2930
|
-
return initialUrl;
|
2931
|
-
try {
|
2932
|
-
const previewSearchParamUrl = new URL(previewSearchParam, initialUrl.origin);
|
2933
|
-
return allowOrigins.some((pattern) => pattern.test(previewSearchParamUrl.origin)) ? previewSearchParamUrl : initialUrl;
|
2934
|
-
} catch {
|
2935
|
-
return initialUrl;
|
2936
|
-
}
|
2937
|
-
}), shareAccessSingletonDocument = {
|
2938
|
-
_id: constants.schemaIdSingleton,
|
2939
|
-
_type: constants.schemaTypeSingleton
|
2940
|
-
}, previewUrlSecretDocument = {
|
2941
|
-
_id: `drafts.${uuid$1.uuid()}`,
|
2942
|
-
_type: constants.schemaType
|
2943
|
-
}, previewUrlMachine = xstate.setup({
|
2944
|
-
types: {},
|
2945
|
-
actions: {
|
2946
|
-
"notify preview will likely fail": xstate.log("Missing permissions to create preview secret, or read shared preview secret. Preview will likely fail loading."),
|
2947
|
-
"assign preview search param": xstate.assign({
|
2948
|
-
previewSearchParam: (_, params) => params.previewSearchParam
|
2949
|
-
}),
|
2950
|
-
"assign error": xstate.assign({
|
2951
|
-
error: (_, params) => params.error instanceof Error ? params.error : new Error(params.message, {
|
2952
|
-
cause: params.error
|
2953
|
-
})
|
2954
|
-
})
|
2955
|
-
},
|
2956
|
-
actors: {
|
2957
|
-
"check permission": xstate.fromObservable(() => rxjs.throwError(() => new Error("The 'check permission' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'check permission': fromObservable(({input}: {input: CheckPermissionInput}) => ...)}})"))),
|
2958
|
-
"resolve initial url": xstate.fromPromise(() => Promise.reject(new Error("The 'resolve initial url' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'resolve initial url': fromPromise(...)}})"))),
|
2959
|
-
"resolve allow patterns": xstate.fromPromise(() => Promise.reject(new Error("The 'resolve allow patterns' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'resolve allow pattern': fromPromise(...)}})"))),
|
2960
|
-
"resolve url from preview search param": resolveUrlFromPreviewSearchParamActor,
|
2961
|
-
"resolve preview mode": xstate.fromPromise(() => Promise.reject(new Error("The 'resolve preview mode' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'resolve preview mode': fromPromise(...)}})"))),
|
2962
|
-
"create preview secret": xstate.fromPromise(async () => Promise.reject(new Error("The 'create preview secret' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'create preview secret': fromPromise(...)}})"))),
|
2963
|
-
"read shared preview secret": xstate.fromPromise(async () => Promise.reject(new Error("The 'read shared preview secret' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'read shared preview secret': fromPromise(...)}})"))),
|
2964
|
-
"resolve preview mode url": xstate.fromPromise(() => Promise.reject(new Error("The 'resolve preview mode url' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'resolve preview mode url': fromPromise(...)}})")))
|
2965
|
-
},
|
2966
|
-
guards: {
|
2967
|
-
"has checked permissions": ({
|
2968
|
-
context
|
2969
|
-
}) => !!(context.previewAccessSharingCreatePermission && context.previewAccessSharingReadPermission && context.previewAccessSharingUpdatePermission && context.previewUrlSecretPermission),
|
2970
|
-
"search param has new origin": ({
|
2971
|
-
context,
|
2972
|
-
event
|
2973
|
-
}) => {
|
2974
|
-
if (!context.previewUrl || !event.previewSearchParam)
|
2975
|
-
return !1;
|
2976
|
-
try {
|
2977
|
-
const previewSearchParamUrl = new URL(event.previewSearchParam, context.previewUrl);
|
2978
|
-
return context.previewUrl.origin !== previewSearchParamUrl.origin;
|
2979
|
-
} catch {
|
2980
|
-
return !1;
|
2981
|
-
}
|
2982
|
-
},
|
2983
|
-
"can create preview secret": ({
|
2984
|
-
context
|
2985
|
-
}) => context.previewUrlSecretPermission?.granted === !0,
|
2986
|
-
"has preview mode with created secret": ({
|
2987
|
-
context
|
2988
|
-
}, params) => params === !1 ? !1 : context.previewUrlSecretPermission?.granted === !0,
|
2989
|
-
"has preview mode with share access": ({
|
2990
|
-
context
|
2991
|
-
}, params) => params === !1 ? !1 : context.previewAccessSharingReadPermission?.granted === !0,
|
2992
|
-
"has preview mode without permissions": ({
|
2993
|
-
context
|
2994
|
-
}, params) => params === !1 ? !1 : context.previewAccessSharingReadPermission?.granted === !1 && context.previewUrlSecretPermission?.granted === !1
|
2995
|
-
},
|
2996
|
-
delays: {
|
2997
|
-
expiredSecret: ({
|
2998
|
-
context
|
2999
|
-
}) => {
|
3000
|
-
if (!context.previewUrlSecret?.expiresAt)
|
3001
|
-
return 0;
|
3002
|
-
const now = Date.now(), expiresAt = context.previewUrlSecret.expiresAt.getTime();
|
3003
|
-
return Math.max(expiresAt - now, 0);
|
3004
|
-
}
|
3005
|
-
}
|
3006
|
-
}).createMachine({
|
3007
|
-
// eslint-disable-next-line tsdoc/syntax
|
3008
|
-
/** @xstate-layout N4IgpgJg5mDOIC5QAUBOYBuBLMB3ABAKoBKAMgMRiqoD2qAdAA4A2AhgC4BmdAtvWphwESpBFgB2GGgGMOWGuIDaABgC6K1YlCMasLO3nitIAB6IArAA56AZgCcAdkcBGS8vMAmO+YBszgDQgAJ6Izs4+9M7KACzKztGWHg4OPubmAL7pgQLYeERklNR0TGxcvPzoucJkYpIycgqKzupqxjp6BgrGZggAtM520ZHRdjZjNjFe7oEhCGERUbHxicmpGVkgOUL5FFS0DCwc3Kh8W3kitVKynUoeLZpIIO36ht2IvV62Hl7elmE2lh83xmoXCkRicQSSRS5gSmWylW2IkK+xKR3KZ2qogkVwaShs9zauheXUePV6gPo3jSUyi-xBczBi0hKxh5mc8M2iPOBVgYHY+EY3IIfNYqGkAAtBWLWDwNESOq8yaCbM56A4bB5fGllHYvD4fAz4h56CNfG5LKqHMpLdFOZidvRJWBpABrCRQZBUHhYWB6BSwcjyx7PG5vPrs5TqjWqyyjTXRDwMjwxei68J2ZQ2nyWXN2jYOkT0dCwGjMbDiKAASXEL1YzEIqGY5AgCjA9BxNFd7cLZGLcDLFertYM9cbzEu9RuGmD2mJYeVfRGdipyh86Yc0XiE3MDK3JssIwcrmtPjGSXzCMEPNI-dL5Y9NbrDabKOKhzKJwq16xd8Hj5HLAxybSdrkMGdWhDeclVAclN3odlzBsKwBjSSxjwcZM7DVeJ1w8P4xmidk7HtYVHRLf9KwAQWYZgaFwZAOHYKhxEDVtxHbTtu2-KpyIHB9qNo+jGPYZjUFY0C8Qgh450VUlYPedkHHoHwnDSZDVOiGwfGiBlUhXXwwjsQYtKSYzSJ-Pj7yHGi6IYpiWMDPZ31KY5TjIosKIEqBbOEhzxNgSTpzUWcnmg+TTHePV6Hw3MYgzaItJ0hlYRNTNkLiHxBl1GILN4zz+KHccADFaB4TEAGUwDFSVGNQWUWzbDs6m43tby8oqm1KmhyuFKqaolOrZSC8CQsg2SSSMRdel8ZSNUTdlcw8M07AZQZrDXdaDRtUZnHWK98r7DqPRKsrKuq8VBplHg3wOVyMQ8o7CpOrqzr6i7auukbGjGmSwrkqaFL6MJlLiWFlC1EGty0hknAiXVVPMRx12UJwOQLR72ueytMQAWRoCAwEajjmqkVrMb-by8YJsBvqUX6FUm8Nem2+hbWPUZErGTcjS8NUJg8AE9T1ZwHHwvKkSe6yPWpwnic4lqewp46ceFfHCbpmdmkZhcgZmyxzFsDmTPcXUUiNRKDy3ZQJlVLSkYlm9KaHWWifYhWyaVyyCul1Wf3V2nOzAn71DuHWYMivovGsBxPCy74beWaJDWCUJzBSFTrUcQYdMzIFHd-FXPTVmn5dJrsvcOrHfeL-2ac1kKCXDiLyWcNKJiiHM-BtONwgtnMEM1DVNwhhI7B8AurMo2uqgD260U-dzval6fXYbwkoIB5moijLLkm5tvYRBo1nGQtND11ZaIdzEiMeX6vV5LuW+QFIVLNFS7pXquVxv+pnF1FtYP4OY7AG3QohJMqcEDeGUq4NwYQBhLEnkWWAABXaQ0g4CBhfoKMiH9JRf1lKFUMEceiizVPA0+7gtQQy8LzXU6obaJTFtEJwHhXDIL7G-WepccHcO2PgqUjBrrEPCoDSOFI3C2AGHtQ8sIiJJGTILZS7JRaeGSKw7CnDbz8LwAHJ06AOBgHOtIdA7Ay5cUrpLHRT92ymOqsxExZj16iK3gAqI6oaQ6QtE4YylhkynzmkCBGNgNR7VvgdaxTBbEGIccY969jzHOTuuiL8bVol10JrEoxTj+QuN-iQlu7xwjKX1P8bSTC0hGhcKaBIOZAQGkBKE7RGSeFZMMRACqEoxRgCohgrBFjFY8Sibo3A+iOldJ6X0zBfp8l-UKeIshjgqTGTiPYPaGotS7igd8QWtgsp6iQnFOEd8q6tKEOM6qnTunoGmQM5JC83LDKdqMy5rBrlTP6bMoOUkGab3-kDU+ERVEpnsEjDRVSdljBXKeQY3h5gOBaa8mmzt4k-nHIMz2zzfzIvaYVNFVRxxzObosxAfg1Q2jSOERIh5kIBNGKaNZ2lvjhFhEimJHUCVCAxQ8j8Tz0m4vbJyzERKfnBQ3hNXWkdyWeJsCMVhqNsK6mTO4Q2Q9DysLCEhDw7LMntjQV8wMJhYDsCMfQVgnAxIAAowAmEYFgdAnSXRmIAJTkAFTEg1MzYCuIBZHKYKlUiqWwrCMJkDZgDAYceRMfwUisPYZYTIGxxA03gI8NqJLmZ6msKqENcjErqIZL0cethvDGXLew9hiYWnOjdDLb0vp-SsUzdNcwEMEJ7WTohDMfgU4RpTCpUJnhYrHghuEFpRcnyjhfMwFtet2Q2FNOwsWZarBan8TsuMkRvhIzPJGDwmkWnJLnf6g0aZl0mQTURDdsxYiGwwsRIEgwEwTuxj5IS9lRKORPeSJCOF4XgrUZqbZsxwZszcJtbC4RUg2FfTXU6PVzoDSGjwH9ik-gxRGG4NtxkkZblhgyxIhFQG5lSPEODj89VoYjKqGKURkij0zImXSUCwiozZuDLUCQQY6tOVEr1WDqMsxNCkP4RFPBZj+I4I0qoRMODjIlceBzkK6raWAIT7DDZlNPhUuVkKI0pEXbHBISF1yAiIqpi5KL7E5ISWYoTna2b6Qg+DcFN7EAphLdpdOWVoPJ0RXxl5HKrmTNuYahzaQviaQPVERa8mlGeBUnnQyDStSwcCzi4L1kuV4HHNR4DCFdRaVVFSzcZ4VVIVsDEVhZ5QnWlYZZvRKLj3-KlT0FIKjVRZghkCXwqkjQGzVFxvOMisoWYy46QV9ABN+mo3mFZZ427lp032jzVa2bJGtCUtciak1AA */
|
3009
|
-
id: "Preview URL",
|
3010
|
-
context: ({
|
3011
|
-
input
|
3012
|
-
}) => ({
|
3013
|
-
initialUrl: null,
|
3014
|
-
previewUrl: null,
|
3015
|
-
error: null,
|
3016
|
-
allowOrigins: null,
|
3017
|
-
previewSearchParam: input.previewSearchParam,
|
3018
|
-
previewUrlSecret: null,
|
3019
|
-
previewAccessSharingCreatePermission: null,
|
3020
|
-
previewAccessSharingReadPermission: null,
|
3021
|
-
previewAccessSharingUpdatePermission: null,
|
3022
|
-
previewUrlSecretPermission: null,
|
3023
|
-
previewMode: null
|
3024
|
-
}),
|
3025
|
-
invoke: [{
|
3026
|
-
src: "check permission",
|
3027
|
-
input: () => ({
|
3028
|
-
checkPermissionName: "read",
|
3029
|
-
document: shareAccessSingletonDocument
|
3030
|
-
}),
|
3031
|
-
onError: {
|
3032
|
-
target: ".error",
|
3033
|
-
actions: {
|
3034
|
-
type: "assign error",
|
3035
|
-
params: ({
|
3036
|
-
event
|
3037
|
-
}) => ({
|
3038
|
-
message: "Failed to check permission",
|
3039
|
-
error: event.error
|
3040
|
-
})
|
3041
|
-
}
|
3042
|
-
},
|
3043
|
-
onSnapshot: {
|
3044
|
-
actions: xstate.assign({
|
3045
|
-
previewAccessSharingReadPermission: ({
|
3046
|
-
event
|
3047
|
-
}) => event.snapshot.context ?? null
|
3048
|
-
})
|
3049
|
-
}
|
3050
|
-
}, {
|
3051
|
-
src: "check permission",
|
3052
|
-
input: () => ({
|
3053
|
-
checkPermissionName: "create",
|
3054
|
-
document: shareAccessSingletonDocument
|
3055
|
-
}),
|
3056
|
-
onError: {
|
3057
|
-
target: ".error",
|
3058
|
-
actions: {
|
3059
|
-
type: "assign error",
|
3060
|
-
params: ({
|
3061
|
-
event
|
3062
|
-
}) => ({
|
3063
|
-
message: "Failed to check permission",
|
3064
|
-
error: event.error
|
3065
|
-
})
|
3066
|
-
}
|
3067
|
-
},
|
3068
|
-
onSnapshot: {
|
3069
|
-
actions: xstate.assign({
|
3070
|
-
previewAccessSharingCreatePermission: ({
|
3071
|
-
event
|
3072
|
-
}) => event.snapshot.context ?? null
|
3073
|
-
})
|
3074
|
-
}
|
3075
|
-
}, {
|
3076
|
-
src: "check permission",
|
3077
|
-
input: () => ({
|
3078
|
-
checkPermissionName: "update",
|
3079
|
-
document: shareAccessSingletonDocument
|
3080
|
-
}),
|
3081
|
-
onError: {
|
3082
|
-
target: ".error",
|
3083
|
-
actions: {
|
3084
|
-
type: "assign error",
|
3085
|
-
params: ({
|
3086
|
-
event
|
3087
|
-
}) => ({
|
3088
|
-
message: "Failed to check permission",
|
3089
|
-
error: event.error
|
3090
|
-
})
|
3091
|
-
}
|
3092
|
-
},
|
3093
|
-
onSnapshot: {
|
3094
|
-
actions: xstate.assign({
|
3095
|
-
previewAccessSharingUpdatePermission: ({
|
3096
|
-
event
|
3097
|
-
}) => event.snapshot.context ?? null
|
3098
|
-
})
|
3099
|
-
}
|
3100
|
-
}, {
|
3101
|
-
src: "check permission",
|
3102
|
-
input: () => ({
|
3103
|
-
checkPermissionName: "create",
|
3104
|
-
document: previewUrlSecretDocument
|
3105
|
-
}),
|
3106
|
-
onError: {
|
3107
|
-
target: ".error",
|
3108
|
-
actions: {
|
3109
|
-
type: "assign error",
|
3110
|
-
params: ({
|
3111
|
-
event
|
3112
|
-
}) => ({
|
3113
|
-
message: "Failed to check permission",
|
3114
|
-
error: event.error
|
3115
|
-
})
|
3116
|
-
}
|
3117
|
-
},
|
3118
|
-
onSnapshot: {
|
3119
|
-
actions: xstate.assign({
|
3120
|
-
previewUrlSecretPermission: ({
|
3121
|
-
event
|
3122
|
-
}) => event.snapshot.context ?? null
|
3123
|
-
})
|
3124
|
-
}
|
3125
|
-
}],
|
3126
|
-
on: {
|
3127
|
-
"set preview search param": {
|
3128
|
-
actions: {
|
3129
|
-
type: "assign preview search param",
|
3130
|
-
params: ({
|
3131
|
-
event
|
3132
|
-
}) => ({
|
3133
|
-
previewSearchParam: event.previewSearchParam
|
3134
|
-
})
|
3135
|
-
}
|
3136
|
-
}
|
3137
|
-
},
|
3138
|
-
states: {
|
3139
|
-
checkingPermissions: {
|
3140
|
-
always: {
|
3141
|
-
guard: "has checked permissions",
|
3142
|
-
target: "resolvingInitialUrl"
|
3143
|
-
},
|
3144
|
-
tags: "busy"
|
3145
|
-
},
|
3146
|
-
resolvingInitialUrl: {
|
3147
|
-
invoke: {
|
3148
|
-
src: "resolve initial url",
|
3149
|
-
input: ({
|
3150
|
-
context
|
3151
|
-
}) => ({
|
3152
|
-
previewSearchParam: context.previewSearchParam
|
3153
|
-
}),
|
3154
|
-
onError: {
|
3155
|
-
target: "error",
|
3156
|
-
actions: {
|
3157
|
-
type: "assign error",
|
3158
|
-
params: ({
|
3159
|
-
event
|
3160
|
-
}) => ({
|
3161
|
-
message: "Failed to resolve initial url",
|
3162
|
-
error: event.error
|
3163
|
-
})
|
3164
|
-
}
|
3165
|
-
},
|
3166
|
-
onDone: {
|
3167
|
-
target: "resolvingAllowPatterns",
|
3168
|
-
actions: xstate.assign({
|
3169
|
-
initialUrl: ({
|
3170
|
-
event
|
3171
|
-
}) => event.output
|
3172
|
-
})
|
3173
|
-
}
|
3174
|
-
},
|
3175
|
-
tags: "busy"
|
3176
|
-
},
|
3177
|
-
error: {
|
3178
|
-
type: "final",
|
3179
|
-
tags: "error"
|
3180
|
-
},
|
3181
|
-
resolvingAllowPatterns: {
|
3182
|
-
invoke: {
|
3183
|
-
src: "resolve allow patterns",
|
3184
|
-
input: ({
|
3185
|
-
context
|
3186
|
-
}) => ({
|
3187
|
-
initialUrl: context.initialUrl
|
3188
|
-
}),
|
3189
|
-
onError: {
|
3190
|
-
target: "error",
|
3191
|
-
actions: {
|
3192
|
-
type: "assign error",
|
3193
|
-
params: ({
|
3194
|
-
event
|
3195
|
-
}) => ({
|
3196
|
-
message: "Failed to resolve preview url allow patterns",
|
3197
|
-
error: event.error
|
3198
|
-
})
|
3199
|
-
}
|
3200
|
-
},
|
3201
|
-
onDone: {
|
3202
|
-
target: "resolvingUrlFromPreviewSearchParam",
|
3203
|
-
actions: xstate.assign({
|
3204
|
-
allowOrigins: ({
|
3205
|
-
event
|
3206
|
-
}) => event.output
|
3207
|
-
})
|
3208
|
-
}
|
3209
|
-
},
|
3210
|
-
tags: ["busy"]
|
3211
|
-
},
|
3212
|
-
resolvingUrlFromPreviewSearchParam: {
|
3213
|
-
id: "loop",
|
3214
|
-
invoke: {
|
3215
|
-
src: "resolve url from preview search param",
|
3216
|
-
input: ({
|
3217
|
-
context
|
3218
|
-
}) => ({
|
3219
|
-
initialUrl: context.initialUrl,
|
3220
|
-
allowOrigins: context.allowOrigins,
|
3221
|
-
previewSearchParam: context.previewSearchParam
|
3222
|
-
}),
|
3223
|
-
onError: {
|
3224
|
-
target: "error",
|
3225
|
-
actions: {
|
3226
|
-
type: "assign error",
|
3227
|
-
params: ({
|
3228
|
-
event
|
3229
|
-
}) => ({
|
3230
|
-
message: "Failed to resolve preview url from search param",
|
3231
|
-
error: event.error
|
3232
|
-
})
|
3233
|
-
}
|
3234
|
-
},
|
3235
|
-
onDone: {
|
3236
|
-
target: "resolvingPreviewMode",
|
3237
|
-
actions: xstate.assign({
|
3238
|
-
initialUrl: ({
|
3239
|
-
event
|
3240
|
-
}) => event.output
|
3241
|
-
})
|
3242
|
-
}
|
3243
|
-
},
|
3244
|
-
tags: ["busy"]
|
3245
|
-
},
|
3246
|
-
resolvingPreviewMode: {
|
3247
|
-
on: {
|
3248
|
-
"set preview search param": {
|
3249
|
-
guard: "search param has new origin",
|
3250
|
-
actions: {
|
3251
|
-
type: "assign preview search param",
|
3252
|
-
params: ({
|
3253
|
-
event
|
3254
|
-
}) => ({
|
3255
|
-
previewSearchParam: event.previewSearchParam
|
3256
|
-
})
|
3257
|
-
},
|
3258
|
-
target: "#loop",
|
3259
|
-
reenter: !0
|
3260
|
-
}
|
3261
|
-
},
|
3262
|
-
invoke: {
|
3263
|
-
src: "resolve preview mode",
|
3264
|
-
input: ({
|
3265
|
-
context
|
3266
|
-
}) => ({
|
3267
|
-
targetOrigin: context.initialUrl.origin
|
3268
|
-
}),
|
3269
|
-
onError: {
|
3270
|
-
target: "error",
|
3271
|
-
actions: {
|
3272
|
-
type: "assign error",
|
3273
|
-
params: ({
|
3274
|
-
event
|
3275
|
-
}) => ({
|
3276
|
-
message: "Failed to resolve preview url allow patterns",
|
3277
|
-
error: event.error
|
3278
|
-
})
|
3279
|
-
}
|
3280
|
-
},
|
3281
|
-
onDone: [{
|
3282
|
-
guard: {
|
3283
|
-
type: "has preview mode with created secret",
|
3284
|
-
params: ({
|
3285
|
-
event
|
3286
|
-
}) => event.output
|
3287
|
-
},
|
3288
|
-
actions: xstate.assign({
|
3289
|
-
previewMode: ({
|
3290
|
-
event
|
3291
|
-
}) => event.output
|
3292
|
-
}),
|
3293
|
-
target: "previewMode.createPreviewSecret"
|
3294
|
-
}, {
|
3295
|
-
guard: {
|
3296
|
-
type: "has preview mode with share access",
|
3297
|
-
params: ({
|
3298
|
-
event
|
3299
|
-
}) => event.output
|
3300
|
-
},
|
3301
|
-
actions: xstate.assign({
|
3302
|
-
previewMode: ({
|
3303
|
-
event
|
3304
|
-
}) => event.output
|
3305
|
-
}),
|
3306
|
-
target: "previewMode.readShareAccess"
|
3307
|
-
}, {
|
3308
|
-
guard: {
|
3309
|
-
type: "has preview mode without permissions",
|
3310
|
-
params: ({
|
3311
|
-
event
|
3312
|
-
}) => event.output
|
3313
|
-
},
|
3314
|
-
actions: [xstate.assign({
|
3315
|
-
previewUrl: ({
|
3316
|
-
context
|
3317
|
-
}) => context.initialUrl
|
3318
|
-
}), "notify preview will likely fail"],
|
3319
|
-
target: "success"
|
3320
|
-
}, {
|
3321
|
-
actions: xstate.assign({
|
3322
|
-
previewUrl: ({
|
3323
|
-
context
|
3324
|
-
}) => context.initialUrl
|
3325
|
-
}),
|
3326
|
-
target: "success"
|
3327
|
-
}]
|
3328
|
-
},
|
3329
|
-
tags: ["busy"]
|
3330
|
-
},
|
3331
|
-
success: {
|
3332
|
-
on: {
|
3333
|
-
"set preview search param": {
|
3334
|
-
guard: "search param has new origin",
|
3335
|
-
actions: {
|
3336
|
-
type: "assign preview search param",
|
3337
|
-
params: ({
|
3338
|
-
event
|
3339
|
-
}) => ({
|
3340
|
-
previewSearchParam: event.previewSearchParam
|
3341
|
-
})
|
3342
|
-
},
|
3343
|
-
target: "#loop",
|
3344
|
-
reenter: !0
|
3345
|
-
}
|
3346
|
-
}
|
3347
|
-
},
|
3348
|
-
previewMode: {
|
3349
|
-
on: {
|
3350
|
-
"set preview search param": {
|
3351
|
-
guard: "search param has new origin",
|
3352
|
-
actions: {
|
3353
|
-
type: "assign preview search param",
|
3354
|
-
params: ({
|
3355
|
-
event
|
3356
|
-
}) => ({
|
3357
|
-
previewSearchParam: event.previewSearchParam
|
3358
|
-
})
|
3359
|
-
},
|
3360
|
-
target: "#loop",
|
3361
|
-
reenter: !0
|
3362
|
-
}
|
3363
|
-
},
|
3364
|
-
states: {
|
3365
|
-
createPreviewSecret: {
|
3366
|
-
invoke: {
|
3367
|
-
src: "create preview secret",
|
3368
|
-
onError: {
|
3369
|
-
target: "error",
|
3370
|
-
actions: {
|
3371
|
-
type: "assign error",
|
3372
|
-
params: ({
|
3373
|
-
event
|
3374
|
-
}) => ({
|
3375
|
-
message: "Failed to create preview secret",
|
3376
|
-
error: event.error
|
3377
|
-
})
|
3378
|
-
}
|
3379
|
-
},
|
3380
|
-
onDone: {
|
3381
|
-
target: "resolvePreviewUrl",
|
3382
|
-
actions: xstate.assign({
|
3383
|
-
previewUrlSecret: ({
|
3384
|
-
event
|
3385
|
-
}) => event.output
|
3386
|
-
})
|
3387
|
-
}
|
3388
|
-
},
|
3389
|
-
tags: ["busy"]
|
3390
|
-
},
|
3391
|
-
readShareAccess: {
|
3392
|
-
invoke: {
|
3393
|
-
src: "read shared preview secret",
|
3394
|
-
onError: {
|
3395
|
-
target: "error",
|
3396
|
-
actions: {
|
3397
|
-
type: "assign error",
|
3398
|
-
params: ({
|
3399
|
-
event
|
3400
|
-
}) => ({
|
3401
|
-
message: "Failed to read shared preview secret",
|
3402
|
-
error: event.error
|
3403
|
-
})
|
3404
|
-
}
|
3405
|
-
},
|
3406
|
-
onDone: {
|
3407
|
-
target: "resolvePreviewUrl",
|
3408
|
-
actions: xstate.assign({
|
3409
|
-
previewUrlSecret: ({
|
3410
|
-
event
|
3411
|
-
}) => ({
|
3412
|
-
secret: event.output,
|
3413
|
-
expiresAt: new Date(Date.now() + 1e3 * 60 * 60 * 60 * 24)
|
3414
|
-
})
|
3415
|
-
})
|
3416
|
-
}
|
3417
|
-
},
|
3418
|
-
tags: ["busy"]
|
3419
|
-
},
|
3420
|
-
resolvePreviewUrl: {
|
3421
|
-
invoke: {
|
3422
|
-
src: "resolve preview mode url",
|
3423
|
-
input: ({
|
3424
|
-
context
|
3425
|
-
}) => ({
|
3426
|
-
initialUrl: context.initialUrl,
|
3427
|
-
resolvedPreviewMode: context.previewMode,
|
3428
|
-
previewUrlSecret: context.previewUrlSecret.secret
|
3429
|
-
}),
|
3430
|
-
onError: {
|
3431
|
-
target: "error",
|
3432
|
-
actions: {
|
3433
|
-
type: "assign error",
|
3434
|
-
params: ({
|
3435
|
-
event
|
3436
|
-
}) => ({
|
3437
|
-
message: "Failed to resolve preview url",
|
3438
|
-
error: event.error
|
3439
|
-
})
|
3440
|
-
}
|
3441
|
-
},
|
3442
|
-
onDone: {
|
3443
|
-
target: "success",
|
3444
|
-
actions: xstate.assign({
|
3445
|
-
previewUrl: ({
|
3446
|
-
event
|
3447
|
-
}) => event.output
|
3448
|
-
})
|
3449
|
-
}
|
3450
|
-
},
|
3451
|
-
tags: ["busy"]
|
3452
|
-
},
|
3453
|
-
error: {
|
3454
|
-
type: "final",
|
3455
|
-
tags: ["error"]
|
3456
|
-
},
|
3457
|
-
success: {
|
3458
|
-
after: {
|
3459
|
-
expiredSecret: {
|
3460
|
-
guard: "can create preview secret",
|
3461
|
-
actions: xstate.assign({
|
3462
|
-
previewUrlSecret: null
|
3463
|
-
}),
|
3464
|
-
target: "createPreviewSecret",
|
3465
|
-
reenter: !0
|
3466
|
-
}
|
3467
|
-
}
|
3468
|
-
}
|
3469
|
-
},
|
3470
|
-
initial: "readShareAccess"
|
3471
|
-
}
|
3472
|
-
},
|
3473
|
-
initial: "checkingPermissions"
|
3474
|
-
});
|
3475
|
-
function usePreviewUrlActorRef(previewUrlOption, allowOption) {
|
3476
|
-
const $ = reactCompilerRuntime.c(24), grantsStore = sanity.useGrantsStore();
|
3477
|
-
let t0;
|
3478
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
3479
|
-
apiVersion: presentation.API_VERSION
|
3480
|
-
}, $[0] = t0) : t0 = $[0];
|
3481
|
-
const client2 = sanity.useClient(t0), currentUserId = sanity.useCurrentUser()?.id, studioBasePath = sanity.useActiveWorkspace()?.activeWorkspace?.basePath || "/", router$1 = router.useRouter();
|
3482
|
-
let t1;
|
3483
|
-
$[1] !== router$1.state._searchParams ? (t1 = new URLSearchParams(router$1.state._searchParams).get("preview"), $[1] = router$1.state._searchParams, $[2] = t1) : t1 = $[2];
|
3484
|
-
const previewSearchParam = t1, {
|
3485
|
-
push: pushToast
|
3486
|
-
} = ui.useToast(), {
|
3487
|
-
t
|
3488
|
-
} = sanity.useTranslation(presentation.presentationLocaleNamespace), perspective = usePresentationPerspective();
|
3489
|
-
let t2;
|
3490
|
-
if ($[3] !== allowOption || $[4] !== client2 || $[5] !== currentUserId || $[6] !== grantsStore || $[7] !== perspective || $[8] !== previewUrlOption || $[9] !== pushToast || $[10] !== studioBasePath || $[11] !== t) {
|
3491
|
-
let t32;
|
3492
|
-
$[13] !== pushToast || $[14] !== t ? (t32 = () => pushToast({
|
3493
|
-
id: "preview-url-secret.missing-grants",
|
3494
|
-
closable: !0,
|
3495
|
-
status: "error",
|
3496
|
-
duration: 1 / 0,
|
3497
|
-
title: t("preview-url-secret.missing-grants")
|
3498
|
-
}), $[13] = pushToast, $[14] = t, $[15] = t32) : t32 = $[15];
|
3499
|
-
let t42;
|
3500
|
-
$[16] !== grantsStore ? (t42 = (t52) => {
|
3501
|
-
const {
|
3502
|
-
input
|
3503
|
-
} = t52;
|
3504
|
-
return grantsStore.checkDocumentPermission(input.checkPermissionName, input.document);
|
3505
|
-
}, $[16] = grantsStore, $[17] = t42) : t42 = $[17], t2 = previewUrlMachine.provide({
|
3506
|
-
actions: {
|
3507
|
-
"notify preview will likely fail": t32
|
3508
|
-
},
|
3509
|
-
actors: {
|
3510
|
-
"create preview secret": defineCreatePreviewSecretActor({
|
3511
|
-
client: client2,
|
3512
|
-
currentUserId
|
3513
|
-
}),
|
3514
|
-
"read shared preview secret": defineReadSharedSecretActor({
|
3515
|
-
client: client2
|
3516
|
-
}),
|
3517
|
-
"resolve allow patterns": defineResolveAllowPatternsActor({
|
3518
|
-
client: client2,
|
3519
|
-
allowOption
|
3520
|
-
}),
|
3521
|
-
"resolve initial url": defineResolveInitialUrlActor({
|
3522
|
-
client: client2,
|
3523
|
-
studioBasePath,
|
3524
|
-
previewUrlOption,
|
3525
|
-
perspective
|
3526
|
-
}),
|
3527
|
-
"resolve preview mode": defineResolvePreviewModeActor({
|
3528
|
-
client: client2,
|
3529
|
-
previewUrlOption
|
3530
|
-
}),
|
3531
|
-
"resolve preview mode url": defineResolvePreviewModeUrlActor({
|
3532
|
-
client: client2,
|
3533
|
-
studioBasePath,
|
3534
|
-
previewUrlOption,
|
3535
|
-
perspective
|
3536
|
-
}),
|
3537
|
-
"check permission": xstate.fromObservable(t42)
|
3538
|
-
}
|
3539
|
-
}), $[3] = allowOption, $[4] = client2, $[5] = currentUserId, $[6] = grantsStore, $[7] = perspective, $[8] = previewUrlOption, $[9] = pushToast, $[10] = studioBasePath, $[11] = t, $[12] = t2;
|
3540
|
-
} else
|
3541
|
-
t2 = $[12];
|
3542
|
-
let t3;
|
3543
|
-
$[18] !== previewSearchParam ? (t3 = {
|
3544
|
-
input: {
|
3545
|
-
previewSearchParam
|
3546
|
-
}
|
3547
|
-
}, $[18] = previewSearchParam, $[19] = t3) : t3 = $[19];
|
3548
|
-
const actorRef = react.useActorRef(t2, t3);
|
3549
|
-
let t4, t5;
|
3550
|
-
$[20] !== actorRef || $[21] !== previewSearchParam ? (t4 = () => {
|
3551
|
-
actorRef.send({
|
3552
|
-
type: "set preview search param",
|
3553
|
-
previewSearchParam
|
3554
|
-
});
|
3555
|
-
}, t5 = [actorRef, previewSearchParam], $[20] = actorRef, $[21] = previewSearchParam, $[22] = t4, $[23] = t5) : (t4 = $[22], t5 = $[23]), React.useEffect(t4, t5);
|
3556
|
-
const error = react.useSelector(actorRef, _temp$3);
|
3557
|
-
if (error)
|
3558
|
-
throw error;
|
3559
|
-
return actorRef;
|
3560
|
-
}
|
3561
|
-
function _temp$3(state) {
|
3562
|
-
return state.status === "error" ? state.error : state.hasTag("error") ? state.context.error : null;
|
3563
|
-
}
|
3564
|
-
function useReportInvalidPreviewSearchParam(previewUrlRef) {
|
3565
|
-
const $ = reactCompilerRuntime.c(9), {
|
3566
|
-
t
|
3567
|
-
} = sanity.useTranslation(presentation.presentationLocaleNamespace), {
|
3568
|
-
push: pushToast
|
3569
|
-
} = ui.useToast(), router$1 = router.useRouter();
|
3570
|
-
let t0;
|
3571
|
-
$[0] !== router$1.state._searchParams ? (t0 = new URLSearchParams(router$1.state._searchParams).get("preview"), $[0] = router$1.state._searchParams, $[1] = t0) : t0 = $[1];
|
3572
|
-
const previewSearchParam = t0, allowOrigins = react.useSelector(previewUrlRef, _temp$2), currentOrigin = react.useSelector(previewUrlRef, _temp2$1);
|
3573
|
-
let t1, t2;
|
3574
|
-
$[2] !== allowOrigins || $[3] !== currentOrigin || $[4] !== previewSearchParam || $[5] !== pushToast || $[6] !== t ? (t1 = () => {
|
3575
|
-
if (!Array.isArray(allowOrigins) || !previewSearchParam || !currentOrigin)
|
3576
|
-
return;
|
3577
|
-
const nextOrigin = new URL(previewSearchParam, currentOrigin).origin;
|
3578
|
-
allowOrigins.some((pattern) => pattern.test(nextOrigin)) || pushToast({
|
3579
|
-
closable: !0,
|
3580
|
-
id: `presentation-iframe-origin-mismatch-${nextOrigin}`,
|
3581
|
-
status: "error",
|
3582
|
-
duration: 1 / 0,
|
3583
|
-
title: t("preview-search-param.configuration.error.title"),
|
3584
|
-
description: /* @__PURE__ */ jsxRuntime.jsx(sanity.Translate, { t, i18nKey: "preview-search-param.configuration.error.description", components: {
|
3585
|
-
Code: "code"
|
3586
|
-
}, values: {
|
3587
|
-
previewSearchParam,
|
3588
|
-
blockedOrigin: nextOrigin
|
3589
|
-
} })
|
3590
|
-
});
|
3591
|
-
}, t2 = [allowOrigins, currentOrigin, previewSearchParam, pushToast, t], $[2] = allowOrigins, $[3] = currentOrigin, $[4] = previewSearchParam, $[5] = pushToast, $[6] = t, $[7] = t1, $[8] = t2) : (t1 = $[7], t2 = $[8]), React.useEffect(t1, t2);
|
3592
|
-
}
|
3593
|
-
function _temp2$1(state_0) {
|
3594
|
-
return state_0.context.previewUrl?.origin;
|
3595
|
-
}
|
3596
|
-
function _temp$2(state) {
|
3597
|
-
return state.context.allowOrigins;
|
3598
|
-
}
|
3599
2589
|
function useVercelBypassSecret() {
|
3600
2590
|
const $ = reactCompilerRuntime.c(7);
|
3601
2591
|
let t0;
|
3602
2592
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
3603
2593
|
apiVersion: presentation.API_VERSION
|
3604
2594
|
}, $[0] = t0) : t0 = $[0];
|
3605
|
-
const client2 = sanity.useClient(t0), [vercelProtectionBypassReadyState, ready] = React.useReducer(_temp
|
2595
|
+
const client2 = sanity.useClient(t0), [vercelProtectionBypassReadyState, ready] = React.useReducer(_temp, "loading"), [vercelProtectionBypassSecret, setVercelProtectionBypassSecret] = React.useState(null);
|
3606
2596
|
let t1, t2;
|
3607
2597
|
$[1] !== client2 ? (t1 = () => {
|
3608
2598
|
const unsubscribe = toggleVercelProtectionBypass.subcribeToVercelProtectionBypass(client2, (secret) => {
|
@@ -3613,37 +2603,59 @@ function useVercelBypassSecret() {
|
|
3613
2603
|
let t3;
|
3614
2604
|
return $[4] !== vercelProtectionBypassReadyState || $[5] !== vercelProtectionBypassSecret ? (t3 = [vercelProtectionBypassSecret, vercelProtectionBypassReadyState], $[4] = vercelProtectionBypassReadyState, $[5] = vercelProtectionBypassSecret, $[6] = t3) : t3 = $[6], t3;
|
3615
2605
|
}
|
3616
|
-
function _temp
|
2606
|
+
function _temp() {
|
3617
2607
|
return "ready";
|
3618
2608
|
}
|
3619
|
-
function PresentationToolGrantsCheck(
|
3620
|
-
const $ = reactCompilerRuntime.c(
|
3621
|
-
|
3622
|
-
} =
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
2609
|
+
function PresentationToolGrantsCheck(props) {
|
2610
|
+
const $ = reactCompilerRuntime.c(17), {
|
2611
|
+
t
|
2612
|
+
} = sanity.useTranslation(presentation.presentationLocaleNamespace), {
|
2613
|
+
previewUrl
|
2614
|
+
} = props.tool.options ?? {}, {
|
2615
|
+
push: pushToast
|
2616
|
+
} = ui.useToast(), willGeneratePreviewUrlSecret = typeof previewUrl == "object" || typeof previewUrl == "function", grantsStore = sanity.useGrantsStore(), [previewAccessSharingCreatePermission, setCreateAccessSharingPermission] = React.useState(null), [previewAccessSharingUpdatePermission, setUpdateAccessSharingPermission] = React.useState(null), [previewAccessSharingReadPermission, setReadAccessSharingPermission] = React.useState(null), [previewUrlSecretPermission, setPreviewUrlSecretPermission] = React.useState(null);
|
2617
|
+
let t0, t1;
|
2618
|
+
$[0] !== grantsStore || $[1] !== willGeneratePreviewUrlSecret ? (t0 = () => {
|
2619
|
+
if (!willGeneratePreviewUrlSecret)
|
2620
|
+
return;
|
2621
|
+
const previewCreateAccessSharingPermissionSubscription = grantsStore.checkDocumentPermission("create", {
|
2622
|
+
_id: constants.schemaIdSingleton,
|
2623
|
+
_type: constants.schemaTypeSingleton
|
2624
|
+
}).subscribe(setCreateAccessSharingPermission), previewUpdateAccessSharingPermissionSubscription = grantsStore.checkDocumentPermission("update", {
|
2625
|
+
_id: constants.schemaIdSingleton,
|
2626
|
+
_type: constants.schemaTypeSingleton
|
2627
|
+
}).subscribe(setUpdateAccessSharingPermission), previewReadAccessSharingPermissionSubscription = grantsStore.checkDocumentPermission("read", {
|
2628
|
+
_id: constants.schemaIdSingleton,
|
2629
|
+
_type: constants.schemaTypeSingleton
|
2630
|
+
}).subscribe(setReadAccessSharingPermission), previewUrlSecretPermissionSubscription = grantsStore.checkDocumentPermission("create", {
|
2631
|
+
_id: `drafts.${uuid$1.uuid()}`,
|
2632
|
+
_type: constants.schemaType
|
2633
|
+
}).subscribe(setPreviewUrlSecretPermission);
|
2634
|
+
return () => {
|
2635
|
+
previewCreateAccessSharingPermissionSubscription.unsubscribe(), previewUpdateAccessSharingPermissionSubscription.unsubscribe(), previewReadAccessSharingPermissionSubscription.unsubscribe(), previewUrlSecretPermissionSubscription.unsubscribe();
|
2636
|
+
};
|
2637
|
+
}, t1 = [grantsStore, willGeneratePreviewUrlSecret], $[0] = grantsStore, $[1] = willGeneratePreviewUrlSecret, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), React.useEffect(t0, t1);
|
2638
|
+
const canCreateUrlPreviewSecrets = previewUrlSecretPermission?.granted;
|
2639
|
+
let t2, t3;
|
2640
|
+
$[4] !== canCreateUrlPreviewSecrets || $[5] !== pushToast || $[6] !== t || $[7] !== willGeneratePreviewUrlSecret ? (t2 = () => {
|
2641
|
+
if (!willGeneratePreviewUrlSecret || canCreateUrlPreviewSecrets !== !1)
|
2642
|
+
return;
|
2643
|
+
const raf = requestAnimationFrame(() => pushToast({
|
2644
|
+
closable: !0,
|
2645
|
+
status: "error",
|
2646
|
+
duration: 3e4,
|
2647
|
+
title: t("preview-url-secret.missing-grants")
|
2648
|
+
}));
|
2649
|
+
return () => cancelAnimationFrame(raf);
|
2650
|
+
}, t3 = [canCreateUrlPreviewSecrets, pushToast, t, willGeneratePreviewUrlSecret], $[4] = canCreateUrlPreviewSecrets, $[5] = pushToast, $[6] = t, $[7] = willGeneratePreviewUrlSecret, $[8] = t2, $[9] = t3) : (t2 = $[8], t3 = $[9]), React.useEffect(t2, t3);
|
2651
|
+
const [vercelProtectionBypass, vercelProtectionBypassReadyState] = useVercelBypassSecret();
|
2652
|
+
if (vercelProtectionBypassReadyState === "loading" || willGeneratePreviewUrlSecret && (!previewAccessSharingCreatePermission || typeof previewAccessSharingCreatePermission.granted > "u" || !previewAccessSharingUpdatePermission || typeof previewAccessSharingUpdatePermission.granted > "u" || !previewUrlSecretPermission || !previewAccessSharingReadPermission || typeof previewAccessSharingReadPermission.granted > "u" || typeof previewUrlSecretPermission.granted > "u")) {
|
2653
|
+
let t42;
|
2654
|
+
return $[10] === Symbol.for("react.memo_cache_sentinel") ? (t42 = /* @__PURE__ */ jsxRuntime.jsx(presentation.PresentationSpinner, {}), $[10] = t42) : t42 = $[10], t42;
|
3628
2655
|
}
|
3629
|
-
const
|
3630
|
-
let
|
3631
|
-
return $[
|
3632
|
-
}
|
3633
|
-
function _temp5(state_3) {
|
3634
|
-
return state_3.context.previewUrl;
|
3635
|
-
}
|
3636
|
-
function _temp4(state_2) {
|
3637
|
-
return state_2.context.previewUrlSecretPermission;
|
3638
|
-
}
|
3639
|
-
function _temp3(state_1) {
|
3640
|
-
return state_1.context.previewAccessSharingReadPermission;
|
3641
|
-
}
|
3642
|
-
function _temp2(state_0) {
|
3643
|
-
return state_0.context.previewAccessSharingUpdatePermission;
|
3644
|
-
}
|
3645
|
-
function _temp(state) {
|
3646
|
-
return state.context.previewAccessSharingCreatePermission;
|
2656
|
+
const t4 = canCreateUrlPreviewSecrets === !0, t5 = previewAccessSharingCreatePermission?.granted === !0 && previewAccessSharingUpdatePermission?.granted === !0, t6 = previewAccessSharingReadPermission?.granted === !0;
|
2657
|
+
let t7;
|
2658
|
+
return $[11] !== props || $[12] !== t4 || $[13] !== t5 || $[14] !== t6 || $[15] !== vercelProtectionBypass ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(PresentationTool, { ...props, vercelProtectionBypass, canCreateUrlPreviewSecrets: t4, canToggleSharePreviewAccess: t5, canUseSharedPreviewAccess: t6 }), $[11] = props, $[12] = t4, $[13] = t5, $[14] = t6, $[15] = vercelProtectionBypass, $[16] = t7) : t7 = $[16], t7;
|
3647
2659
|
}
|
3648
2660
|
exports.default = PresentationToolGrantsCheck;
|
3649
2661
|
//# sourceMappingURL=PresentationToolGrantsCheck.js.map
|