@sanity/vision 4.13.1-next.2 → 4.14.0-next.4
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/SanityVision.js +107 -236
- package/lib/_chunks-cjs/SanityVision.js.map +1 -1
- package/lib/_chunks-cjs/resources.js +2 -0
- package/lib/_chunks-cjs/resources.js.map +1 -1
- package/lib/_chunks-es/SanityVision.mjs +109 -238
- package/lib/_chunks-es/SanityVision.mjs.map +1 -1
- package/lib/_chunks-es/resources.mjs +2 -0
- package/lib/_chunks-es/resources.mjs.map +1 -1
- package/lib/index.d.mts +2 -0
- package/lib/index.d.ts +2 -0
- package/package.json +7 -7
|
@@ -186,7 +186,7 @@ const EditorRoot = styledComponents.styled.div`
|
|
|
186
186
|
return $[3] !== initialValue || $[4] !== props.onChange || $[5] !== theme ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(EditorRoot, { children: /* @__PURE__ */ jsxRuntime.jsx(CodeMirror__default.default, { ref: codeMirrorRef, basicSetup: !1, theme, extensions: codemirrorExtensions, value: initialValue, onChange: props.onChange }) }), $[3] = initialValue, $[4] = props.onChange, $[5] = theme, $[6] = t3) : t3 = $[6], t3;
|
|
187
187
|
});
|
|
188
188
|
VisionCodeMirror.displayName = "VisionCodeMirror";
|
|
189
|
-
const SUPPORTED_PERSPECTIVES = ["pinnedRelease", "raw", "published", "drafts"], VIRTUAL_PERSPECTIVES = ["pinnedRelease"];
|
|
189
|
+
const SUPPORTED_PERSPECTIVES = ["pinnedRelease", "scheduledDrafts", "raw", "published", "drafts"], VIRTUAL_PERSPECTIVES = ["pinnedRelease", "scheduledDrafts"];
|
|
190
190
|
function isSupportedPerspective(p) {
|
|
191
191
|
return SUPPORTED_PERSPECTIVES.includes(p);
|
|
192
192
|
}
|
|
@@ -200,9 +200,10 @@ function hasPinnedPerspective({
|
|
|
200
200
|
}
|
|
201
201
|
function getActivePerspective({
|
|
202
202
|
visionPerspective,
|
|
203
|
-
perspectiveStack
|
|
203
|
+
perspectiveStack,
|
|
204
|
+
scheduledDraftsStack
|
|
204
205
|
}) {
|
|
205
|
-
return visionPerspective
|
|
206
|
+
return visionPerspective === "pinnedRelease" ? perspectiveStack : visionPerspective === "scheduledDrafts" ? scheduledDraftsStack : visionPerspective;
|
|
206
207
|
}
|
|
207
208
|
function encodeQueryString(query, params = {}, options = {}) {
|
|
208
209
|
const searchParams = new URLSearchParams();
|
|
@@ -980,7 +981,7 @@ const PinnedReleasePerspectiveOption = (t0) => {
|
|
|
980
981
|
return $[6] !== t3 || $[7] !== text ? (t4 = /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pinnedRelease", disabled: t3, children: text }), $[6] = t3, $[7] = text, $[8] = t4) : t4 = $[8], t4;
|
|
981
982
|
};
|
|
982
983
|
function VisionGuiHeader(t0) {
|
|
983
|
-
const $ = reactCompilerRuntime.c(
|
|
984
|
+
const $ = reactCompilerRuntime.c(65), {
|
|
984
985
|
onChangeDataset,
|
|
985
986
|
dataset,
|
|
986
987
|
customApiVersion,
|
|
@@ -992,7 +993,8 @@ function VisionGuiHeader(t0) {
|
|
|
992
993
|
isValidApiVersion,
|
|
993
994
|
onChangePerspective,
|
|
994
995
|
url,
|
|
995
|
-
perspective
|
|
996
|
+
perspective,
|
|
997
|
+
isScheduledDraftsEnabled
|
|
996
998
|
} = t0, pinnedPerspective = sanity.usePerspective(), {
|
|
997
999
|
t
|
|
998
1000
|
} = sanity.useTranslation(index.visionLocaleNamespace), operationUrlElement = react.useRef(null);
|
|
@@ -1061,20 +1063,20 @@ function VisionGuiHeader(t0) {
|
|
|
1061
1063
|
] }) }), $[42] = t18, $[43] = t20) : t20 = $[43];
|
|
1062
1064
|
const t21 = perspective || "default";
|
|
1063
1065
|
let t22;
|
|
1064
|
-
$[44] !==
|
|
1066
|
+
$[44] !== isScheduledDraftsEnabled || $[45] !== pinnedPerspective || $[46] !== t ? (t22 = SUPPORTED_PERSPECTIVES.map((perspectiveName) => perspectiveName === "pinnedRelease" ? /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
1065
1067
|
/* @__PURE__ */ jsxRuntime.jsx(PinnedReleasePerspectiveOption, { pinnedPerspective, t }),
|
|
1066
1068
|
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "default", children: t("settings.perspectives.default") }, "default"),
|
|
1067
1069
|
/* @__PURE__ */ jsxRuntime.jsx("hr", {})
|
|
1068
|
-
] }, "pinnedRelease") : /* @__PURE__ */ jsxRuntime.jsx("option", { children: perspectiveName }, perspectiveName)), $[44] =
|
|
1070
|
+
] }, "pinnedRelease") : perspectiveName === "scheduledDrafts" ? isScheduledDraftsEnabled ? /* @__PURE__ */ jsxRuntime.jsx("option", { value: "scheduledDrafts", children: t("settings.perspectives.scheduled-drafts") }, "scheduledDrafts") : null : /* @__PURE__ */ jsxRuntime.jsx("option", { children: perspectiveName }, perspectiveName)), $[44] = isScheduledDraftsEnabled, $[45] = pinnedPerspective, $[46] = t, $[47] = t22) : t22 = $[47];
|
|
1069
1071
|
let t23;
|
|
1070
|
-
$[
|
|
1072
|
+
$[48] !== onChangePerspective || $[49] !== t21 || $[50] !== t22 ? (t23 = /* @__PURE__ */ jsxRuntime.jsx(ui.Select, { value: t21, onChange: onChangePerspective, children: t22 }), $[48] = onChangePerspective, $[49] = t21, $[50] = t22, $[51] = t23) : t23 = $[51];
|
|
1071
1073
|
let t24;
|
|
1072
|
-
$[
|
|
1074
|
+
$[52] !== t20 || $[53] !== t23 ? (t24 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, column: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { children: [
|
|
1073
1075
|
t20,
|
|
1074
1076
|
t23
|
|
1075
|
-
] }) }), $[
|
|
1077
|
+
] }) }), $[52] = t20, $[53] = t23, $[54] = t24) : t24 = $[54];
|
|
1076
1078
|
let t25;
|
|
1077
|
-
$[
|
|
1079
|
+
$[55] !== customApiVersion || $[56] !== t || $[57] !== url ? (t25 = typeof url == "string" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, flex: 1, column: customApiVersion === !1 ? 6 : 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { children: [
|
|
1078
1080
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Card, { paddingTop: 2, paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(StyledLabel, { children: [
|
|
1079
1081
|
t("query.url"),
|
|
1080
1082
|
"\xA0",
|
|
@@ -1088,15 +1090,15 @@ function VisionGuiHeader(t0) {
|
|
|
1088
1090
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.TextInput, { readOnly: !0, type: "url", ref: operationUrlElement, value: url }) }),
|
|
1089
1091
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: t("action.copy-url-to-clipboard"), children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { "aria-label": t("action.copy-url-to-clipboard"), type: "button", mode: "ghost", icon: icons.CopyIcon, onClick: handleCopyUrl }) })
|
|
1090
1092
|
] })
|
|
1091
|
-
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1 }), $[
|
|
1093
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1 }), $[55] = customApiVersion, $[56] = t, $[57] = url, $[58] = t25) : t25 = $[58];
|
|
1092
1094
|
let t26;
|
|
1093
|
-
return $[
|
|
1095
|
+
return $[59] !== t15 || $[60] !== t16 || $[61] !== t24 || $[62] !== t25 || $[63] !== t7 ? (t26 = /* @__PURE__ */ jsxRuntime.jsx(Header, { paddingX: 3, paddingY: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Grid, { columns: t2, children: [
|
|
1094
1096
|
t7,
|
|
1095
1097
|
t15,
|
|
1096
1098
|
t16,
|
|
1097
1099
|
t24,
|
|
1098
1100
|
t25
|
|
1099
|
-
] }) }), $[
|
|
1101
|
+
] }) }), $[59] = t15, $[60] = t16, $[61] = t24, $[62] = t25, $[63] = t7, $[64] = t26) : t26 = $[64], t26;
|
|
1100
1102
|
}
|
|
1101
1103
|
function _temp3$1(version) {
|
|
1102
1104
|
return /* @__PURE__ */ jsxRuntime.jsx("option", { children: version }, version);
|
|
@@ -1491,7 +1493,7 @@ function nodeContains(node, other) {
|
|
|
1491
1493
|
}
|
|
1492
1494
|
const sanityUrl = /\.(?:api|apicdn)\.sanity\.(?:io|work)\/(vX|v1|v\d{4}-\d\d-\d\d)\/.*?(?:query|listen)\/(.*?)\?(.*)/, isRunHotkey = (event) => isHotkeyEsm.isHotkey("ctrl+enter", event) || isHotkeyEsm.isHotkey("mod+enter", event);
|
|
1493
1495
|
function VisionGui(props) {
|
|
1494
|
-
const
|
|
1496
|
+
const {
|
|
1495
1497
|
datasets,
|
|
1496
1498
|
config,
|
|
1497
1499
|
projectId,
|
|
@@ -1500,84 +1502,35 @@ function VisionGui(props) {
|
|
|
1500
1502
|
t
|
|
1501
1503
|
} = sanity.useTranslation(index.visionLocaleNamespace), {
|
|
1502
1504
|
perspectiveStack
|
|
1503
|
-
} = sanity.usePerspective(),
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
const [localStorage2] = react.useState(t0);
|
|
1507
|
-
let t1;
|
|
1508
|
-
$[2] !== defaultDataset || $[3] !== localStorage2 ? (t1 = localStorage2.get("dataset", defaultDataset), $[2] = defaultDataset, $[3] = localStorage2, $[4] = t1) : t1 = $[4];
|
|
1509
|
-
const storedDataset = t1;
|
|
1510
|
-
let t2;
|
|
1511
|
-
$[5] !== config.defaultApiVersion || $[6] !== localStorage2 ? (t2 = localStorage2.get("apiVersion", prefixApiVersion(`${config.defaultApiVersion}`)), $[5] = config.defaultApiVersion, $[6] = localStorage2, $[7] = t2) : t2 = $[7];
|
|
1512
|
-
const storedApiVersion = t2;
|
|
1513
|
-
let t3;
|
|
1514
|
-
$[8] !== localStorage2 ? (t3 = localStorage2.get("query", ""), $[8] = localStorage2, $[9] = t3) : t3 = $[9];
|
|
1515
|
-
const storedQuery = t3;
|
|
1516
|
-
let t4;
|
|
1517
|
-
$[10] !== localStorage2 ? (t4 = localStorage2.get("params", `{
|
|
1505
|
+
} = sanity.usePerspective(), isScheduledDraftsEnabled = sanity.useScheduledDraftsEnabled(), {
|
|
1506
|
+
data: releases = []
|
|
1507
|
+
} = sanity.useActiveReleases(), isDraftModelEnabled = sanity.useWorkspace().document.drafts.enabled, editorQueryRef = react.useRef(null), editorParamsRef = react.useRef(null), visionRootRef = react.useRef(null), customApiVersionElementRef = react.useRef(null), querySubscriptionRef = react.useRef(void 0), listenSubscriptionRef = react.useRef(void 0), [localStorage2] = react.useState(() => getLocalStorage(projectId || "default")), storedDataset = localStorage2.get("dataset", defaultDataset), storedApiVersion = localStorage2.get("apiVersion", prefixApiVersion(`${config.defaultApiVersion}`)), storedQuery = localStorage2.get("query", ""), storedParams = localStorage2.get("params", `{
|
|
1518
1508
|
|
|
1519
|
-
}`),
|
|
1520
|
-
const storedParams = t4;
|
|
1521
|
-
let t5;
|
|
1522
|
-
$[12] !== localStorage2 ? (t5 = localStorage2.get("perspective", void 0), $[12] = localStorage2, $[13] = t5) : t5 = $[13];
|
|
1523
|
-
const storedPerspective = t5;
|
|
1524
|
-
let t6;
|
|
1525
|
-
$[14] !== datasets || $[15] !== defaultDataset || $[16] !== storedDataset ? (t6 = () => datasets.includes(storedDataset) ? storedDataset : datasets.includes(defaultDataset) ? defaultDataset : datasets[0], $[14] = datasets, $[15] = defaultDataset, $[16] = storedDataset, $[17] = t6) : t6 = $[17];
|
|
1526
|
-
const [dataset, setDataset] = react.useState(t6);
|
|
1527
|
-
let t7;
|
|
1528
|
-
$[18] !== storedApiVersion ? (t7 = () => API_VERSIONS.includes(storedApiVersion) ? storedApiVersion : DEFAULT_API_VERSION, $[18] = storedApiVersion, $[19] = t7) : t7 = $[19];
|
|
1529
|
-
const [apiVersion, setApiVersion] = react.useState(t7);
|
|
1530
|
-
let t8;
|
|
1531
|
-
$[20] !== storedApiVersion ? (t8 = () => API_VERSIONS.includes(storedApiVersion) ? !1 : storedApiVersion, $[20] = storedApiVersion, $[21] = t8) : t8 = $[21];
|
|
1532
|
-
const [customApiVersion, setCustomApiVersion] = react.useState(t8), [perspective, setPerspectiveState] = react.useState(storedPerspective || "raw");
|
|
1533
|
-
let t9;
|
|
1534
|
-
$[22] !== customApiVersion ? (t9 = customApiVersion ? validateApiVersion(customApiVersion) : !0, $[22] = customApiVersion, $[23] = t9) : t9 = $[23];
|
|
1535
|
-
const isValidApiVersion = t9, [url, setUrl] = react.useState(void 0);
|
|
1536
|
-
let t10;
|
|
1537
|
-
$[24] !== storedQuery ? (t10 = () => typeof storedQuery == "string" ? storedQuery : "", $[24] = storedQuery, $[25] = t10) : t10 = $[25];
|
|
1538
|
-
const [query, setQuery] = react.useState(t10), [rawParams, setRawParams] = react.useState(storedParams);
|
|
1539
|
-
let t11;
|
|
1540
|
-
$[26] !== rawParams || $[27] !== t ? (t11 = parseParams(rawParams, t), $[26] = rawParams, $[27] = t, $[28] = t11) : t11 = $[28];
|
|
1541
|
-
const params = t11, [queryResult, setQueryResult] = react.useState(void 0);
|
|
1542
|
-
let t12;
|
|
1543
|
-
$[29] === Symbol.for("react.memo_cache_sentinel") ? (t12 = [], $[29] = t12) : t12 = $[29];
|
|
1544
|
-
const [listenMutations, setListenMutations] = react.useState(t12), [error, setError] = react.useState(void 0), [queryTime, setQueryTime] = react.useState(void 0), [e2eTime, setE2eTime] = react.useState(void 0), [queryInProgress, setQueryInProgress] = react.useState(!1), [listenInProgress, setListenInProgress] = react.useState(!1), [isQueryRecallCollapsed, setIsQueryRecallCollapsed] = react.useState(!1);
|
|
1545
|
-
let t13;
|
|
1546
|
-
$[30] === Symbol.for("react.memo_cache_sentinel") ? (t13 = {
|
|
1547
|
-
visionRootRef
|
|
1548
|
-
}, $[30] = t13) : t13 = $[30];
|
|
1549
|
-
const {
|
|
1509
|
+
}`), storedPerspective = localStorage2.get("perspective", void 0), [dataset, setDataset] = react.useState(() => datasets.includes(storedDataset) ? storedDataset : datasets.includes(defaultDataset) ? defaultDataset : datasets[0]), [apiVersion, setApiVersion] = react.useState(() => API_VERSIONS.includes(storedApiVersion) ? storedApiVersion : DEFAULT_API_VERSION), [customApiVersion, setCustomApiVersion] = react.useState(() => API_VERSIONS.includes(storedApiVersion) ? !1 : storedApiVersion), [perspective, setPerspectiveState] = react.useState(storedPerspective || "raw"), isValidApiVersion = customApiVersion ? validateApiVersion(customApiVersion) : !0, [url, setUrl] = react.useState(void 0), [query, setQuery] = react.useState(() => typeof storedQuery == "string" ? storedQuery : ""), [rawParams, setRawParams] = react.useState(storedParams), params = react.useMemo(() => parseParams(rawParams, t), [rawParams, t]), [queryResult, setQueryResult] = react.useState(void 0), [listenMutations, setListenMutations] = react.useState([]), [error, setError] = react.useState(void 0), [queryTime, setQueryTime] = react.useState(void 0), [e2eTime, setE2eTime] = react.useState(void 0), [queryInProgress, setQueryInProgress] = react.useState(!1), [listenInProgress, setListenInProgress] = react.useState(!1), [isQueryRecallCollapsed, setIsQueryRecallCollapsed] = react.useState(!1), {
|
|
1550
1510
|
paneSizeOptions,
|
|
1551
1511
|
isNarrowBreakpoint
|
|
1552
|
-
} = usePaneSize(
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1512
|
+
} = usePaneSize({
|
|
1513
|
+
visionRootRef
|
|
1514
|
+
}), scheduledDraftsStack = react.useMemo(() => {
|
|
1515
|
+
if (!isScheduledDraftsEnabled) return;
|
|
1516
|
+
const scheduledDraftReleases = releases.filter((release) => sanity.isCardinalityOneRelease(release) && release.state === "scheduled"), releaseIds = sanity.sortReleases(scheduledDraftReleases).map((release_0) => sanity.getReleaseIdFromReleaseDocumentId(release_0._id)), defaultPerspective = isDraftModelEnabled ? ["drafts"] : ["published"];
|
|
1517
|
+
return [...releaseIds, ...defaultPerspective];
|
|
1518
|
+
}, [releases, isDraftModelEnabled, isScheduledDraftsEnabled]), _client = sanity.useClient({
|
|
1519
|
+
apiVersion: isValidApiVersion && customApiVersion ? customApiVersion : apiVersion
|
|
1520
|
+
}), client = react.useMemo(() => _client.withConfig({
|
|
1560
1521
|
apiVersion: isValidApiVersion && customApiVersion ? customApiVersion : apiVersion,
|
|
1561
1522
|
perspective: getActivePerspective({
|
|
1562
1523
|
visionPerspective: perspective,
|
|
1563
|
-
perspectiveStack
|
|
1524
|
+
perspectiveStack,
|
|
1525
|
+
scheduledDraftsStack
|
|
1564
1526
|
}),
|
|
1565
1527
|
dataset,
|
|
1566
1528
|
allowReconfigure: !0
|
|
1567
|
-
}),
|
|
1568
|
-
const client = t16;
|
|
1569
|
-
let t17;
|
|
1570
|
-
$[41] === Symbol.for("react.memo_cache_sentinel") ? (t17 = () => {
|
|
1529
|
+
}), [perspectiveStack, scheduledDraftsStack, perspective, customApiVersion, apiVersion, dataset, _client, isValidApiVersion]), cancelQuerySubscription = react.useCallback(() => {
|
|
1571
1530
|
querySubscriptionRef.current && (querySubscriptionRef.current.unsubscribe(), querySubscriptionRef.current = void 0);
|
|
1572
|
-
},
|
|
1573
|
-
const cancelQuerySubscription = t17;
|
|
1574
|
-
let t18;
|
|
1575
|
-
$[42] === Symbol.for("react.memo_cache_sentinel") ? (t18 = () => {
|
|
1531
|
+
}, []), cancelListenerSubscription = react.useCallback(() => {
|
|
1576
1532
|
listenSubscriptionRef.current && (listenSubscriptionRef.current.unsubscribe(), listenSubscriptionRef.current = void 0);
|
|
1577
|
-
},
|
|
1578
|
-
const cancelListenerSubscription = t18;
|
|
1579
|
-
let t19;
|
|
1580
|
-
$[43] !== apiVersion || $[44] !== client || $[45] !== customApiVersion || $[46] !== dataset || $[47] !== isValidApiVersion || $[48] !== localStorage2 || $[49] !== params.parsed || $[50] !== perspective || $[51] !== perspectiveStack || $[52] !== query || $[53] !== queryInProgress || $[54] !== t ? (t19 = (options) => {
|
|
1533
|
+
}, []), handleQueryExecution = react.useCallback((options) => {
|
|
1581
1534
|
if (queryInProgress) {
|
|
1582
1535
|
cancelQuerySubscription(), cancelListenerSubscription(), setQueryInProgress(!1);
|
|
1583
1536
|
return;
|
|
@@ -1587,8 +1540,9 @@ function VisionGui(props) {
|
|
|
1587
1540
|
dataset: options?.dataset || dataset,
|
|
1588
1541
|
params: parseParams(JSON.stringify(options?.params || params.parsed, null, 2), t),
|
|
1589
1542
|
perspective: getActivePerspective({
|
|
1590
|
-
visionPerspective: options
|
|
1591
|
-
perspectiveStack
|
|
1543
|
+
visionPerspective: options && "perspective" in options ? options.perspective : perspective,
|
|
1544
|
+
perspectiveStack,
|
|
1545
|
+
scheduledDraftsStack
|
|
1592
1546
|
}),
|
|
1593
1547
|
apiVersion: options?.apiVersion || (customApiVersion && isValidApiVersion ? customApiVersion : apiVersion)
|
|
1594
1548
|
};
|
|
@@ -1614,25 +1568,16 @@ function VisionGui(props) {
|
|
|
1614
1568
|
setError(err), setQueryInProgress(!1);
|
|
1615
1569
|
}
|
|
1616
1570
|
});
|
|
1617
|
-
},
|
|
1618
|
-
const handleQueryExecution = t19;
|
|
1619
|
-
let t20;
|
|
1620
|
-
$[56] !== handleQueryExecution || $[57] !== localStorage2 ? (t20 = (newPerspective) => {
|
|
1571
|
+
}, [queryInProgress, query, dataset, params.parsed, t, perspective, perspectiveStack, scheduledDraftsStack, customApiVersion, isValidApiVersion, apiVersion, localStorage2, cancelListenerSubscription, client, cancelQuerySubscription]), setPerspective = react.useCallback((newPerspective) => {
|
|
1621
1572
|
newPerspective !== void 0 && !isSupportedPerspective(newPerspective) || (setPerspectiveState(newPerspective), localStorage2.set("perspective", newPerspective), handleQueryExecution({
|
|
1622
1573
|
perspective: newPerspective
|
|
1623
1574
|
}));
|
|
1624
|
-
},
|
|
1625
|
-
const setPerspective = t20;
|
|
1626
|
-
let t21;
|
|
1627
|
-
$[59] !== handleQueryExecution || $[60] !== localStorage2 ? (t21 = (evt) => {
|
|
1575
|
+
}, [localStorage2, handleQueryExecution]), handleChangeDataset = react.useCallback((evt) => {
|
|
1628
1576
|
const newDataset = evt.target.value;
|
|
1629
1577
|
localStorage2.set("dataset", newDataset), setDataset(newDataset), handleQueryExecution({
|
|
1630
1578
|
dataset: newDataset
|
|
1631
1579
|
});
|
|
1632
|
-
},
|
|
1633
|
-
const handleChangeDataset = t21;
|
|
1634
|
-
let t22;
|
|
1635
|
-
$[62] !== handleQueryExecution || $[63] !== localStorage2 ? (t22 = (evt_0) => {
|
|
1580
|
+
}, [localStorage2, handleQueryExecution]), handleChangeApiVersion = react.useCallback((evt_0) => {
|
|
1636
1581
|
const newApiVersion = evt_0.target.value;
|
|
1637
1582
|
if (newApiVersion?.toLowerCase() === "other") {
|
|
1638
1583
|
setCustomApiVersion("v"), customApiVersionElementRef.current?.focus();
|
|
@@ -1641,29 +1586,17 @@ function VisionGui(props) {
|
|
|
1641
1586
|
setApiVersion(newApiVersion), setCustomApiVersion(!1), localStorage2.set("apiVersion", newApiVersion), handleQueryExecution({
|
|
1642
1587
|
apiVersion: newApiVersion
|
|
1643
1588
|
});
|
|
1644
|
-
},
|
|
1645
|
-
const handleChangeApiVersion = t22;
|
|
1646
|
-
let t23;
|
|
1647
|
-
$[65] !== handleQueryExecution || $[66] !== localStorage2 ? (t23 = (evt_1) => {
|
|
1589
|
+
}, [localStorage2, handleQueryExecution]), handleCustomApiVersionChange = react.useCallback((evt_1) => {
|
|
1648
1590
|
const newCustomApiVersion = evt_1.target.value || "";
|
|
1649
1591
|
setCustomApiVersion(newCustomApiVersion || "v"), validateApiVersion(newCustomApiVersion) && (setApiVersion(newCustomApiVersion), localStorage2.set("apiVersion", newCustomApiVersion), handleQueryExecution({
|
|
1650
1592
|
apiVersion: newCustomApiVersion
|
|
1651
1593
|
}));
|
|
1652
|
-
},
|
|
1653
|
-
const handleCustomApiVersionChange = t23;
|
|
1654
|
-
let t24;
|
|
1655
|
-
$[68] !== setPerspective ? (t24 = (evt_2) => {
|
|
1594
|
+
}, [localStorage2, handleQueryExecution]), handleChangePerspective = react.useCallback((evt_2) => {
|
|
1656
1595
|
const newPerspective_0 = evt_2.target.value;
|
|
1657
1596
|
setPerspective(newPerspective_0 === "default" ? void 0 : newPerspective_0);
|
|
1658
|
-
},
|
|
1659
|
-
const handleChangePerspective = t24;
|
|
1660
|
-
let t25;
|
|
1661
|
-
$[70] === Symbol.for("react.memo_cache_sentinel") ? (t25 = (evt_3) => {
|
|
1597
|
+
}, [setPerspective]), handleListenerEvent = react.useCallback((evt_3) => {
|
|
1662
1598
|
evt_3.type === "mutation" && setListenMutations((prevMutations) => prevMutations.length === 50 ? [evt_3, ...prevMutations.slice(0, 49)] : [evt_3, ...prevMutations]);
|
|
1663
|
-
},
|
|
1664
|
-
const handleListenerEvent = t25;
|
|
1665
|
-
let t26;
|
|
1666
|
-
$[71] !== client || $[72] !== listenInProgress || $[73] !== localStorage2 || $[74] !== params.error || $[75] !== params.parsed || $[76] !== params.raw || $[77] !== query ? (t26 = () => {
|
|
1599
|
+
}, []), handleListenExecution = react.useCallback(() => {
|
|
1667
1600
|
if (listenInProgress) {
|
|
1668
1601
|
cancelListenerSubscription(), setListenInProgress(!1);
|
|
1669
1602
|
return;
|
|
@@ -1678,21 +1611,14 @@ function VisionGui(props) {
|
|
|
1678
1611
|
setError(err_0), setListenInProgress(!1);
|
|
1679
1612
|
}
|
|
1680
1613
|
}));
|
|
1681
|
-
},
|
|
1682
|
-
const handleListenExecution = t26;
|
|
1683
|
-
let t27;
|
|
1684
|
-
$[79] !== localStorage2 ? (t27 = (value) => {
|
|
1614
|
+
}, [listenInProgress, params, query, localStorage2, cancelQuerySubscription, handleListenerEvent, cancelListenerSubscription, client]), handleParamsChange = react.useCallback((value) => {
|
|
1685
1615
|
setRawParams(value), localStorage2.set("params", value);
|
|
1686
|
-
},
|
|
1687
|
-
const handleParamsChange = t27;
|
|
1688
|
-
let t28;
|
|
1689
|
-
$[81] !== apiVersion || $[82] !== dataset || $[83] !== datasets || $[84] !== perspective || $[85] !== toast ? (t28 = (data) => {
|
|
1616
|
+
}, [localStorage2]), getStateFromUrl = react.useCallback((data) => {
|
|
1690
1617
|
const match = data.match(sanityUrl);
|
|
1691
1618
|
if (!match)
|
|
1692
1619
|
return null;
|
|
1693
1620
|
const [, usedApiVersion, usedDataset, urlQuery] = match, qs = new URLSearchParams(urlQuery), parts = parseApiQueryString(qs);
|
|
1694
|
-
if (!parts)
|
|
1695
|
-
return null;
|
|
1621
|
+
if (!parts) return null;
|
|
1696
1622
|
let newApiVersion_0, newCustomApiVersion_0;
|
|
1697
1623
|
validateApiVersion(usedApiVersion) && (API_VERSIONS.includes(usedApiVersion) ? (newApiVersion_0 = usedApiVersion, newCustomApiVersion_0 = !1) : newCustomApiVersion_0 = usedApiVersion);
|
|
1698
1624
|
const newPerspective_1 = isSupportedPerspective(parts.options.perspective) && !isVirtualPerspective(parts.options.perspective) ? parts.options.perspective : void 0;
|
|
@@ -1711,10 +1637,7 @@ function VisionGui(props) {
|
|
|
1711
1637
|
perspective: newPerspective_1 || perspective,
|
|
1712
1638
|
url: data
|
|
1713
1639
|
};
|
|
1714
|
-
},
|
|
1715
|
-
const getStateFromUrl = t28;
|
|
1716
|
-
let t29;
|
|
1717
|
-
$[87] !== handleQueryExecution || $[88] !== localStorage2 ? (t29 = (parsedUrlObj) => {
|
|
1640
|
+
}, [datasets, dataset, apiVersion, perspective, toast]), setStateFromParsedUrl = react.useCallback((parsedUrlObj) => {
|
|
1718
1641
|
setDataset(parsedUrlObj.dataset), setQuery(parsedUrlObj.query), setRawParams(parsedUrlObj.rawParams), setApiVersion(parsedUrlObj.apiVersion), parsedUrlObj.customApiVersion && setCustomApiVersion(parsedUrlObj.customApiVersion), setPerspectiveState(parsedUrlObj.perspective), setUrl(parsedUrlObj.url), editorQueryRef.current?.resetEditorContent(parsedUrlObj.query), editorParamsRef.current?.resetEditorContent(parsedUrlObj.rawParams), localStorage2.merge({
|
|
1719
1642
|
query: parsedUrlObj.query,
|
|
1720
1643
|
params: parsedUrlObj.rawParams,
|
|
@@ -1722,10 +1645,7 @@ function VisionGui(props) {
|
|
|
1722
1645
|
apiVersion: parsedUrlObj.customApiVersion || parsedUrlObj.apiVersion,
|
|
1723
1646
|
perspective: parsedUrlObj.perspective
|
|
1724
1647
|
}), handleQueryExecution(parsedUrlObj);
|
|
1725
|
-
},
|
|
1726
|
-
const setStateFromParsedUrl = t29;
|
|
1727
|
-
let t30;
|
|
1728
|
-
$[90] !== getStateFromUrl || $[91] !== setStateFromParsedUrl || $[92] !== toast ? (t30 = (evt_4) => {
|
|
1648
|
+
}, [localStorage2, handleQueryExecution]), handlePaste = react.useCallback((evt_4) => {
|
|
1729
1649
|
if (!evt_4.clipboardData)
|
|
1730
1650
|
return;
|
|
1731
1651
|
const data_0 = evt_4.clipboardData.getData("text/plain");
|
|
@@ -1737,124 +1657,75 @@ function VisionGui(props) {
|
|
|
1737
1657
|
status: "info",
|
|
1738
1658
|
title: "Parsed URL to query"
|
|
1739
1659
|
}));
|
|
1740
|
-
},
|
|
1741
|
-
const handlePaste = t30;
|
|
1742
|
-
let t31;
|
|
1743
|
-
$[94] !== handleQueryExecution || $[95] !== params.valid ? (t31 = (event) => {
|
|
1660
|
+
}, [getStateFromUrl, setStateFromParsedUrl, toast]), handleKeyDown = react.useCallback((event) => {
|
|
1744
1661
|
const isWithinRoot = visionRootRef.current && nodeContains(visionRootRef.current, event.target);
|
|
1745
1662
|
isRunHotkey(event) && isWithinRoot && params.valid && (handleQueryExecution(), event.preventDefault(), event.stopPropagation());
|
|
1746
|
-
},
|
|
1747
|
-
|
|
1748
|
-
let t32, t33;
|
|
1749
|
-
$[97] !== handleKeyDown || $[98] !== handlePaste ? (t32 = () => (window.document.addEventListener("paste", handlePaste), window.document.addEventListener("keydown", handleKeyDown), () => {
|
|
1663
|
+
}, [params.valid, handleQueryExecution]);
|
|
1664
|
+
react.useEffect(() => (window.document.addEventListener("paste", handlePaste), window.document.addEventListener("keydown", handleKeyDown), () => {
|
|
1750
1665
|
window.document.removeEventListener("paste", handlePaste), window.document.removeEventListener("keydown", handleKeyDown);
|
|
1751
|
-
}),
|
|
1752
|
-
let t34, t35;
|
|
1753
|
-
$[101] === Symbol.for("react.memo_cache_sentinel") ? (t34 = () => () => {
|
|
1666
|
+
}), [handleKeyDown, handlePaste]), react.useEffect(() => () => {
|
|
1754
1667
|
cancelQuerySubscription(), cancelListenerSubscription();
|
|
1755
|
-
},
|
|
1756
|
-
|
|
1757
|
-
$[103] !== setPerspective ? (t36 = (stack) => {
|
|
1668
|
+
}, [cancelQuerySubscription, cancelListenerSubscription]);
|
|
1669
|
+
const handleStudioPerspectiveChange = useEffectEvent.useEffectEvent((stack) => {
|
|
1758
1670
|
stack.length > 0 && setPerspective("pinnedRelease");
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
let t37;
|
|
1762
|
-
$[105] !== handleStudioPerspectiveChange || $[106] !== perspectiveStack ? (t37 = () => {
|
|
1671
|
+
});
|
|
1672
|
+
react.useEffect(() => {
|
|
1763
1673
|
handleStudioPerspectiveChange(perspectiveStack);
|
|
1764
|
-
},
|
|
1765
|
-
|
|
1766
|
-
$[108] !== perspectiveStack ? (t38 = [perspectiveStack], $[108] = perspectiveStack, $[109] = t38) : t38 = $[109], react.useEffect(t37, t38);
|
|
1767
|
-
let t39;
|
|
1768
|
-
$[110] !== client || $[111] !== perspective || $[112] !== perspectiveStack ? (t39 = (queryString, queryParams) => {
|
|
1674
|
+
}, [perspectiveStack]);
|
|
1675
|
+
const generateUrl = react.useCallback((queryString, queryParams) => {
|
|
1769
1676
|
const urlQueryOpts_0 = {
|
|
1770
1677
|
perspective: getActivePerspective({
|
|
1771
1678
|
visionPerspective: perspective,
|
|
1772
|
-
perspectiveStack
|
|
1679
|
+
perspectiveStack,
|
|
1680
|
+
scheduledDraftsStack
|
|
1773
1681
|
}) ?? []
|
|
1774
1682
|
};
|
|
1775
1683
|
return client.getUrl(client.getDataUrl("query", encodeQueryString(queryString, queryParams, urlQueryOpts_0)));
|
|
1776
|
-
},
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
left: -32,
|
|
1822
|
-
top: "50%",
|
|
1823
|
-
transform: "translateY(-50%)",
|
|
1824
|
-
zIndex: 100,
|
|
1825
|
-
pointerEvents: "auto"
|
|
1826
|
-
}, $[171] = t59) : t59 = $[171];
|
|
1827
|
-
let t60;
|
|
1828
|
-
$[172] !== isQueryRecallCollapsed ? (t60 = () => setIsQueryRecallCollapsed(!isQueryRecallCollapsed), $[172] = isQueryRecallCollapsed, $[173] = t60) : t60 = $[173];
|
|
1829
|
-
let t61;
|
|
1830
|
-
$[174] === Symbol.for("react.memo_cache_sentinel") ? (t61 = {
|
|
1831
|
-
display: "flex",
|
|
1832
|
-
alignItems: "center",
|
|
1833
|
-
height: "100%"
|
|
1834
|
-
}, $[174] = t61) : t61 = $[174];
|
|
1835
|
-
let t62;
|
|
1836
|
-
$[175] !== isQueryRecallCollapsed ? (t62 = /* @__PURE__ */ jsxRuntime.jsx("div", { style: t61, children: isQueryRecallCollapsed ? /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronLeftIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}) }), $[175] = isQueryRecallCollapsed, $[176] = t62) : t62 = $[176];
|
|
1837
|
-
let t63;
|
|
1838
|
-
$[177] !== t60 || $[178] !== t62 ? (t63 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { mode: "ghost", padding: 2, style: t59, onClick: t60, children: t62 }), $[177] = t60, $[178] = t62, $[179] = t63) : t63 = $[179];
|
|
1839
|
-
let t64;
|
|
1840
|
-
$[180] !== params.parsed ? (t64 = params.parsed || {}, $[180] = params.parsed, $[181] = t64) : t64 = $[181];
|
|
1841
|
-
let t65;
|
|
1842
|
-
$[182] !== generateUrl || $[183] !== getStateFromUrl || $[184] !== query || $[185] !== setStateFromParsedUrl || $[186] !== t64 || $[187] !== url ? (t65 = /* @__PURE__ */ jsxRuntime.jsx(QueryRecall, { url, getStateFromUrl, setStateFromParsedUrl, currentQuery: query, currentParams: t64, generateUrl }), $[182] = generateUrl, $[183] = getStateFromUrl, $[184] = query, $[185] = setStateFromParsedUrl, $[186] = t64, $[187] = url, $[188] = t65) : t65 = $[188];
|
|
1843
|
-
let t66;
|
|
1844
|
-
$[189] !== t63 || $[190] !== t65 ? (t66 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { style: t58, children: [
|
|
1845
|
-
t63,
|
|
1846
|
-
t65
|
|
1847
|
-
] }), $[189] = t63, $[190] = t65, $[191] = t66) : t66 = $[191];
|
|
1848
|
-
let t67;
|
|
1849
|
-
$[192] !== t41 || $[193] !== t57 || $[194] !== t66 ? (t67 = /* @__PURE__ */ jsxRuntime.jsx(SplitpaneContainer, { flex: "auto", children: /* @__PURE__ */ jsxRuntime.jsxs(reactSplitPane.SplitPane, { minSize: 800, defaultSize: window.innerWidth - 275, size: t41, maxSize: -225, primary: "first", children: [
|
|
1850
|
-
t57,
|
|
1851
|
-
t66
|
|
1852
|
-
] }) }), $[192] = t41, $[193] = t57, $[194] = t66, $[195] = t67) : t67 = $[195];
|
|
1853
|
-
let t68;
|
|
1854
|
-
return $[196] !== t40 || $[197] !== t67 ? (t68 = /* @__PURE__ */ jsxRuntime.jsxs(Root, { direction: "column", height: "fill", ref: visionRootRef, sizing: "border", overflow: "hidden", "data-testid": "vision-root", children: [
|
|
1855
|
-
t40,
|
|
1856
|
-
t67
|
|
1857
|
-
] }), $[196] = t40, $[197] = t67, $[198] = t68) : t68 = $[198], t68;
|
|
1684
|
+
}, [client, perspective, perspectiveStack, scheduledDraftsStack]);
|
|
1685
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Root, { direction: "column", height: "fill", ref: visionRootRef, sizing: "border", overflow: "hidden", "data-testid": "vision-root", children: [
|
|
1686
|
+
/* @__PURE__ */ jsxRuntime.jsx(VisionGuiHeader, { apiVersion, customApiVersion, dataset, datasets, onChangeDataset: handleChangeDataset, onChangeApiVersion: handleChangeApiVersion, customApiVersionElementRef, onCustomApiVersionChange: handleCustomApiVersionChange, isValidApiVersion, onChangePerspective: handleChangePerspective, url, perspective, isScheduledDraftsEnabled }),
|
|
1687
|
+
/* @__PURE__ */ jsxRuntime.jsx(SplitpaneContainer, { flex: "auto", children: /* @__PURE__ */ jsxRuntime.jsxs(reactSplitPane.SplitPane, { minSize: 800, defaultSize: window.innerWidth - 275, size: isQueryRecallCollapsed ? window.innerWidth : window.innerWidth - 275, maxSize: -225, primary: "first", children: [
|
|
1688
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { height: "stretch", flex: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1689
|
+
reactSplitPane.SplitPane,
|
|
1690
|
+
{
|
|
1691
|
+
className: "sidebarPanes",
|
|
1692
|
+
split: isNarrowBreakpoint ? "vertical" : "horizontal",
|
|
1693
|
+
minSize: 300,
|
|
1694
|
+
children: [
|
|
1695
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { height: "stretch", flex: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(reactSplitPane.SplitPane, { className: "sidebarPanes", split: "horizontal", defaultSize: isNarrowBreakpoint ? paneSizeOptions.defaultSize : paneSizeOptions.minSize, size: paneSizeOptions.size, allowResize: paneSizeOptions.allowResize, minSize: isNarrowBreakpoint ? paneSizeOptions.minSize : 100, maxSize: paneSizeOptions.maxSize, primary: "first", children: [
|
|
1696
|
+
/* @__PURE__ */ jsxRuntime.jsx(InputContainer, { display: "flex", "data-testid": "vision-query-editor", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { flex: 1, children: [
|
|
1697
|
+
/* @__PURE__ */ jsxRuntime.jsx(InputBackgroundContainerLeft, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { muted: !0, children: t("query.label") }) }) }),
|
|
1698
|
+
/* @__PURE__ */ jsxRuntime.jsx(VisionCodeMirror, { initialValue: query, onChange: setQuery, ref: editorQueryRef })
|
|
1699
|
+
] }) }),
|
|
1700
|
+
/* @__PURE__ */ jsxRuntime.jsxs(InputContainer, { display: "flex", children: [
|
|
1701
|
+
/* @__PURE__ */ jsxRuntime.jsx(ParamsEditor, { value: params.raw, onChange: handleParamsChange, paramsError: params.error, hasValidParams: params.valid, editorRef: editorParamsRef }),
|
|
1702
|
+
/* @__PURE__ */ jsxRuntime.jsx(VisionGuiControls, { hasValidParams: params.valid, queryInProgress, listenInProgress, onQueryExecution: handleQueryExecution, onListenExecution: handleListenExecution })
|
|
1703
|
+
] })
|
|
1704
|
+
] }) }),
|
|
1705
|
+
/* @__PURE__ */ jsxRuntime.jsx(VisionGuiResult, { error, queryInProgress, queryResult, listenInProgress, listenMutations, dataset, queryTime, e2eTime })
|
|
1706
|
+
]
|
|
1707
|
+
}
|
|
1708
|
+
) }),
|
|
1709
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { style: {
|
|
1710
|
+
position: "relative",
|
|
1711
|
+
height: "100%"
|
|
1712
|
+
}, children: [
|
|
1713
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { mode: "ghost", padding: 2, style: {
|
|
1714
|
+
position: "absolute",
|
|
1715
|
+
left: -32,
|
|
1716
|
+
top: "50%",
|
|
1717
|
+
transform: "translateY(-50%)",
|
|
1718
|
+
zIndex: 100,
|
|
1719
|
+
pointerEvents: "auto"
|
|
1720
|
+
}, onClick: () => setIsQueryRecallCollapsed(!isQueryRecallCollapsed), children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1721
|
+
display: "flex",
|
|
1722
|
+
alignItems: "center",
|
|
1723
|
+
height: "100%"
|
|
1724
|
+
}, children: isQueryRecallCollapsed ? /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronLeftIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}) }) }),
|
|
1725
|
+
/* @__PURE__ */ jsxRuntime.jsx(QueryRecall, { url, getStateFromUrl, setStateFromParsedUrl, currentQuery: query, currentParams: params.parsed || {}, generateUrl })
|
|
1726
|
+
] })
|
|
1727
|
+
] }) })
|
|
1728
|
+
] });
|
|
1858
1729
|
}
|
|
1859
1730
|
function useDatasets(t0) {
|
|
1860
1731
|
const $ = reactCompilerRuntime.c(7), {
|