@sanity/vision 6.23.0-next.38 → 6.23.0-next.41
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/CodeDiff-MkS3Q87A.js +61 -0
- package/lib/CodeDiff-MkS3Q87A.js.map +1 -0
- package/lib/{SanityVision-e4SHQ7bh.js → SanityVision-BSByYf4K.js} +320 -48
- package/lib/SanityVision-BSByYf4K.js.map +1 -0
- package/lib/VisionRedesign-C3iwsYdI.js +15087 -0
- package/lib/VisionRedesign-C3iwsYdI.js.map +1 -0
- package/lib/bundle.css +600 -3
- package/lib/{i18n-DFRqoJ_F.js → i18n-CaGatdZX.js} +2 -2
- package/lib/{i18n-DFRqoJ_F.js.map → i18n-CaGatdZX.js.map} +1 -1
- package/lib/index.d.ts +385 -374
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/{resources-VRZHPMVB.js → resources-CpTD0UAN.js} +386 -372
- package/lib/resources-CpTD0UAN.js.map +1 -0
- package/package.json +5 -5
- package/lib/SanityVision-e4SHQ7bh.js.map +0 -1
- package/lib/resources-VRZHPMVB.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { t as visionLocaleNamespace } from "./i18n-
|
|
2
|
-
import { Component, Fragment, Suspense, createContext, use, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
1
|
+
import { t as visionLocaleNamespace } from "./i18n-CaGatdZX.js";
|
|
2
|
+
import { Component, Fragment, Suspense, createContext, lazy, use, useEffect, useImperativeHandle, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { ContextMenuButton, RELEASES_STUDIO_CLIENT_OPTIONS, Translate, UserAvatar, VARIANTS_STUDIO_CLIENT_OPTIONS, getDefaultVariant, getReleaseIdFromReleaseDocumentId, getVariantTitle, isCardinalityOneRelease, sortReleases, useActiveReleases, useClient, useCurrentUser, useDataset, useDateTimeFormat, useKeyValueStore, usePerspective, useScheduledDraftsEnabled, useTranslation, useWorkspace } from "sanity";
|
|
4
4
|
import { IntentLink } from "sanity/router";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
import { SplitPane } from "@rexxars/react-split-pane";
|
|
7
7
|
import { ChevronLeftIcon } from "@sanity/icons/ChevronLeft";
|
|
8
8
|
import { ChevronRightIcon } from "@sanity/icons/ChevronRight";
|
|
9
|
-
import { Badge, Button, Card, Dialog, Heading, Hotkeys, Inline, Label, Select, Spinner, Tab, TabList, TextInput, rem, useClickOutsideEvent, useTheme, useTheme_v2 } from "@sanity/ui";
|
|
9
|
+
import { Badge, Button, Card, Dialog, Heading, Hotkeys, Inline, Label, Select, Spinner, Stack, Tab, TabList, TextInput, rem, useClickOutsideEvent, useTheme, useTheme_v2 } from "@sanity/ui";
|
|
10
10
|
import { useToast } from "@sanity/ui/toast";
|
|
11
11
|
import { isHotkey } from "is-hotkey-esm";
|
|
12
|
-
import { Box, Container, Flex, Grid, Icon, Text, VStack } from "ui5";
|
|
12
|
+
import { Box, Container, Flex, Grid, Icon, Link, Text, VStack } from "ui5";
|
|
13
13
|
import { useEffectEvent } from "use-effect-event";
|
|
14
14
|
import { closeBrackets } from "@codemirror/autocomplete";
|
|
15
15
|
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
|
@@ -19,7 +19,7 @@ import { highlightSelectionMatches } from "@codemirror/search";
|
|
|
19
19
|
import { EditorState } from "@codemirror/state";
|
|
20
20
|
import { EditorView, drawSelection, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, keymap, lineNumbers } from "@codemirror/view";
|
|
21
21
|
import { groq } from "@sanity/lezer-groq";
|
|
22
|
-
import CodeMirror, { EditorSelection } from "@uiw/react-codemirror";
|
|
22
|
+
import CodeMirror, { EditorSelection as EditorSelection$1 } from "@uiw/react-codemirror";
|
|
23
23
|
import { tags } from "@lezer/highlight";
|
|
24
24
|
import { hues } from "@sanity/color";
|
|
25
25
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -51,6 +51,14 @@ import LRU from "quick-lru";
|
|
|
51
51
|
import { DocumentSheetIcon } from "@sanity/icons/DocumentSheet";
|
|
52
52
|
import { useObservablePromise } from "react-rx";
|
|
53
53
|
import { catchError, map, of } from "rxjs";
|
|
54
|
+
var __defProp = Object.defineProperty, __exportAll = (all, no_symbols) => {
|
|
55
|
+
let target = {};
|
|
56
|
+
for (var name in all) __defProp(target, name, {
|
|
57
|
+
get: all[name],
|
|
58
|
+
enumerable: !0
|
|
59
|
+
});
|
|
60
|
+
return no_symbols || __defProp(target, Symbol.toStringTag, { value: "Module" }), target;
|
|
61
|
+
};
|
|
54
62
|
function prefixApiVersion(version) {
|
|
55
63
|
return version[0] !== "v" && version !== "other" ? `v${version}` : version;
|
|
56
64
|
}
|
|
@@ -84,8 +92,8 @@ const VARIANTS_API_VERSION = prefixApiVersion(VARIANTS_STUDIO_CLIENT_OPTIONS.api
|
|
|
84
92
|
...defaultKeymap,
|
|
85
93
|
...historyKeymap
|
|
86
94
|
])
|
|
87
|
-
], groqExtensions = [groq(), ...sharedExtensions], paramsExtensions = [javascriptLanguage, ...sharedExtensions]
|
|
88
|
-
|
|
95
|
+
], groqExtensions = [groq(), ...sharedExtensions], paramsExtensions = [javascriptLanguage, ...sharedExtensions], resultJsonExtensions = [
|
|
96
|
+
javascriptLanguage,
|
|
89
97
|
...sharedExtensions,
|
|
90
98
|
foldGutter(),
|
|
91
99
|
EditorState.readOnly.of(!0)
|
|
@@ -131,17 +139,17 @@ function createTheme(theme) {
|
|
|
131
139
|
},
|
|
132
140
|
".cm-panel.cm-panel-lint ul [aria-selected]": { backgroundColor: selection },
|
|
133
141
|
".cm-panel.cm-panel-lint ul [aria-selected] .cm-diagnostic": { color: card.fg },
|
|
134
|
-
".cm-
|
|
142
|
+
".cm-vision-function-doc, .cm-vision-extract-button": {
|
|
135
143
|
fontFamily: fonts.text.family,
|
|
136
144
|
fontSize: rem(fonts.text.sizes[1].fontSize)
|
|
137
145
|
},
|
|
138
|
-
".cm-
|
|
146
|
+
".cm-vision-function-code, .cm-vision-function-doc code": {
|
|
139
147
|
fontFamily: fonts.code.family,
|
|
140
148
|
fontSize: rem(fonts.code.sizes[1].fontSize)
|
|
141
149
|
},
|
|
142
|
-
".cm-
|
|
143
|
-
".cm-
|
|
144
|
-
".cm-
|
|
150
|
+
".cm-vision-function-note": { color: card.muted.fg },
|
|
151
|
+
".cm-vision-function-link": { color: card.link.fg },
|
|
152
|
+
".cm-vision-extract-button:hover, .cm-vision-extract-button:focus-visible": { backgroundColor: selection },
|
|
145
153
|
".cm-tooltip.cm-tooltip-autocomplete > ul": { fontFamily: fonts.code.family },
|
|
146
154
|
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
|
147
155
|
backgroundColor: selection,
|
|
@@ -331,7 +339,7 @@ function VisionCodeMirror(t0) {
|
|
|
331
339
|
to: currentDoc.length,
|
|
332
340
|
insert: newContent
|
|
333
341
|
},
|
|
334
|
-
selection: EditorSelection.cursor(newContent.length)
|
|
342
|
+
selection: EditorSelection$1.cursor(newContent.length)
|
|
335
343
|
}), editorView.scrollDOM.scrollTop = 0, editorView.scrollDOM.scrollLeft = 0);
|
|
336
344
|
}, $[5] = t7) : t7 = $[5];
|
|
337
345
|
let resetEditorContent = t7, t8;
|
|
@@ -352,7 +360,7 @@ function VisionCodeMirror(t0) {
|
|
|
352
360
|
if (!editorView_1) return;
|
|
353
361
|
let length = editorView_1.state.doc.length;
|
|
354
362
|
editorView_1.dispatch({
|
|
355
|
-
selection: EditorSelection.range(Math.min(from, length), Math.min(to, length)),
|
|
363
|
+
selection: EditorSelection$1.range(Math.min(from, length), Math.min(to, length)),
|
|
356
364
|
scrollIntoView: !0
|
|
357
365
|
}), editorView_1.focus();
|
|
358
366
|
}, $[8] = t10) : t10 = $[8];
|
|
@@ -426,10 +434,15 @@ function getActivePerspective({ visionPerspective, perspectiveStack, scheduledDr
|
|
|
426
434
|
function getActiveVariant(visionPerspective, selectedVariantName) {
|
|
427
435
|
if (visionPerspective === "pinnedRelease") return selectedVariantName;
|
|
428
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* The search params of a query request as `@sanity/client` writes them (`encodeQueryString` in
|
|
439
|
+
* its `src/data`): the query, then each param as `$name` with its value as JSON, then the
|
|
440
|
+
* options. A param whose value is `undefined` is left out, as the client leaves it out.
|
|
441
|
+
*/
|
|
429
442
|
function encodeQueryString(query, params = {}, options = {}) {
|
|
430
443
|
let searchParams = new URLSearchParams();
|
|
431
444
|
searchParams.set("query", query);
|
|
432
|
-
for (let [key, value] of Object.entries(params)) searchParams.set(`$${key}`, JSON.stringify(value));
|
|
445
|
+
for (let [key, value] of Object.entries(params)) value !== void 0 && searchParams.set(`$${key}`, JSON.stringify(value));
|
|
433
446
|
for (let [key, value] of Object.entries(options)) value && searchParams.set(key, `${value}`);
|
|
434
447
|
return `?${searchParams}`;
|
|
435
448
|
}
|
|
@@ -452,11 +465,17 @@ function isPlainObject(obj) {
|
|
|
452
465
|
return !!obj && typeof obj == "object" && Object.prototype.toString.call(obj) === "[object Object]";
|
|
453
466
|
}
|
|
454
467
|
/** Every `localStorage` key Vision writes (classic and redesign alike) starts with this prefix */
|
|
455
|
-
const hasLocalStorage = supportsLocalStorage(), clearListeners = /* @__PURE__ */ new Set();
|
|
468
|
+
const VISION_STORAGE_KEY_PREFIX = "sanityVision:", hasLocalStorage = supportsLocalStorage(), clearListeners = /* @__PURE__ */ new Set();
|
|
456
469
|
/** The `localStorage` instance when it is available and writable, `undefined` otherwise */
|
|
457
470
|
function getStorage() {
|
|
458
471
|
return hasLocalStorage ? globalThis.localStorage : void 0;
|
|
459
472
|
}
|
|
473
|
+
/** Runs `listener` after `clearLocalStorage`, so in-memory copies of stored values can drop too */
|
|
474
|
+
function onLocalStorageCleared(listener) {
|
|
475
|
+
return clearListeners.add(listener), () => {
|
|
476
|
+
clearListeners.delete(listener);
|
|
477
|
+
};
|
|
478
|
+
}
|
|
460
479
|
function clearLocalStorage() {
|
|
461
480
|
let storage = getStorage();
|
|
462
481
|
if (storage) {
|
|
@@ -470,7 +489,7 @@ function clearLocalStorage() {
|
|
|
470
489
|
clearListeners.forEach((listener) => listener());
|
|
471
490
|
}
|
|
472
491
|
function getLocalStorage(namespace) {
|
|
473
|
-
let storageKey =
|
|
492
|
+
let storageKey = `${VISION_STORAGE_KEY_PREFIX}${namespace}`, loadedState = null;
|
|
474
493
|
return {
|
|
475
494
|
get,
|
|
476
495
|
set,
|
|
@@ -536,7 +555,52 @@ function validateApiVersion(apiVersion) {
|
|
|
536
555
|
* paste handler has always picked the URL out of the pasted text with it. `parseQueryUrl` is
|
|
537
556
|
* stricter and takes the whole text to be the URL.
|
|
538
557
|
*/
|
|
539
|
-
const SANITY_QUERY_URL = /\/(vX|v1|v\d{4}-\d\d-\d\d)\/.*?(?:query|listen)\/(.*?)\?(.*)
|
|
558
|
+
const SANITY_QUERY_URL = /\/(vX|v1|v\d{4}-\d\d-\d\d)\/.*?(?:query|listen)\/(.*?)\?(.*)/, QUERY_URL_PATHNAME = /^\/(vX|v1|v\d{4}-\d\d-\d\d)\/(?:[^/]+\/)*(?:query|listen)\/([^/]+)\/?$/, API_CDN_HOST = /(?:^|\.)apicdn\.sanity\.(?:io|work)$/;
|
|
559
|
+
/** `<project>.apicdn.sanity.io`, where `useCdn` sends queries */
|
|
560
|
+
function isApiCdnHost(hostname) {
|
|
561
|
+
return API_CDN_HOST.test(hostname);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Parses a Content Lake query (or listen) URL, as pasted from the browser's network tab, into the
|
|
565
|
+
* pieces of a tab. Returns `null` when the text is not such a URL: the whole text has to be one
|
|
566
|
+
* http(s) URL, since a query URL quoted inside other text is not a paste of that URL, and the
|
|
567
|
+
* redesign claims a paste it parses and replaces the tab's query with it.
|
|
568
|
+
*/
|
|
569
|
+
function parseQueryUrl(data, datasets) {
|
|
570
|
+
let trimmed = data.trim(), url = parseHttpUrl(trimmed), match = url?.pathname.match(QUERY_URL_PATHNAME);
|
|
571
|
+
if (!url || !match) return null;
|
|
572
|
+
let [, usedApiVersion, usedDataset] = match, parts;
|
|
573
|
+
try {
|
|
574
|
+
parts = parseApiQueryString(url.searchParams);
|
|
575
|
+
} catch {
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
if (!parts.query) return null;
|
|
579
|
+
let urlPerspective = parts.options.perspective, perspective = urlPerspective && isSupportedPerspective(urlPerspective) && !isVirtualPerspective(urlPerspective) ? urlPerspective : void 0, { resultSourceMap } = parts.options, includeSourceMap = resultSourceMap === "true" || resultSourceMap === "withKeyArraySelector";
|
|
580
|
+
return {
|
|
581
|
+
query: parts.query,
|
|
582
|
+
params: parts.params,
|
|
583
|
+
rawParams: JSON.stringify(parts.params, null, 2),
|
|
584
|
+
dataset: usedDataset,
|
|
585
|
+
isKnownDataset: datasets.includes(usedDataset),
|
|
586
|
+
apiVersion: validateApiVersion(usedApiVersion) ? usedApiVersion : void 0,
|
|
587
|
+
urlPerspective: urlPerspective || void 0,
|
|
588
|
+
perspective,
|
|
589
|
+
hasUnsupportedPerspective: !!urlPerspective && perspective === void 0,
|
|
590
|
+
variant: parts.options.variant || void 0,
|
|
591
|
+
includeSourceMap,
|
|
592
|
+
useCdn: isApiCdnHost(url.hostname),
|
|
593
|
+
url: trimmed
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
function parseHttpUrl(text) {
|
|
597
|
+
try {
|
|
598
|
+
let url = new URL(text);
|
|
599
|
+
return url.protocol === "http:" || url.protocol === "https:" ? url : null;
|
|
600
|
+
} catch {
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
540
604
|
function tryParseParams(val, t) {
|
|
541
605
|
try {
|
|
542
606
|
let parsed = val ? JSON5.parse(val) : {};
|
|
@@ -878,7 +942,7 @@ function useSavedQueries() {
|
|
|
878
942
|
let run = () => task().finally(() => {
|
|
879
943
|
--pendingPersonalWritesRef.current;
|
|
880
944
|
}), result = personalWritesRef.current.then(run, run);
|
|
881
|
-
return personalWritesRef.current = result.catch(_temp$
|
|
945
|
+
return personalWritesRef.current = result.catch(_temp$6), result;
|
|
882
946
|
}, $[17] = t12) : t12 = $[17];
|
|
883
947
|
let enqueuePersonalWrite = t12, t13;
|
|
884
948
|
$[18] === Symbol.for("react.memo_cache_sentinel") ? (t13 = (before, attempted, kept) => {
|
|
@@ -1067,7 +1131,7 @@ function _temp3$3(count) {
|
|
|
1067
1131
|
function _temp2$4(a, b) {
|
|
1068
1132
|
return new Date(b.savedAt || 0).getTime() - new Date(a.savedAt || 0).getTime();
|
|
1069
1133
|
}
|
|
1070
|
-
function _temp$
|
|
1134
|
+
function _temp$6() {}
|
|
1071
1135
|
function FixedHeader(props) {
|
|
1072
1136
|
let $ = c(2), t0;
|
|
1073
1137
|
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(VStack, {
|
|
@@ -1707,7 +1771,7 @@ function calculatePaneSizeOptions(height) {
|
|
|
1707
1771
|
};
|
|
1708
1772
|
}
|
|
1709
1773
|
function usePaneSize(t0) {
|
|
1710
|
-
let $ = c(7), { visionRootRef } = t0, [rootSize, setRootSize] = useState(_temp$
|
|
1774
|
+
let $ = c(7), { visionRootRef } = t0, [rootSize, setRootSize] = useState(_temp$5), [isNarrowBreakpoint, setIsNarrowBreakpoint] = useState(_temp2$3), [paneSizeOptions, setPaneSizeOptions] = useState(_temp3$2), t1, t2;
|
|
1711
1775
|
$[0] === visionRootRef ? (t1 = $[1], t2 = $[2]) : (t1 = () => {
|
|
1712
1776
|
if (!visionRootRef.current) return;
|
|
1713
1777
|
let handleResize = (entries) => {
|
|
@@ -1734,7 +1798,7 @@ function _temp3$2() {
|
|
|
1734
1798
|
function _temp2$3() {
|
|
1735
1799
|
return narrowBreakpoint();
|
|
1736
1800
|
}
|
|
1737
|
-
function _temp$
|
|
1801
|
+
function _temp$5() {
|
|
1738
1802
|
return {
|
|
1739
1803
|
width: typeof window < "u" ? window.innerWidth : 1e3,
|
|
1740
1804
|
height: typeof window < "u" ? window.innerHeight : 800
|
|
@@ -1813,12 +1877,12 @@ function VisionGuiControls(t0) {
|
|
|
1813
1877
|
size: 1,
|
|
1814
1878
|
as: "div",
|
|
1815
1879
|
trim: !0,
|
|
1816
|
-
children: t("
|
|
1880
|
+
children: t("vision.redesign.try.description")
|
|
1817
1881
|
}),
|
|
1818
1882
|
placement: "top",
|
|
1819
1883
|
portal: !0,
|
|
1820
1884
|
children: /* @__PURE__ */ jsx(Button, {
|
|
1821
|
-
"aria-label": t("
|
|
1885
|
+
"aria-label": t("vision.redesign.try"),
|
|
1822
1886
|
"data-testid": "vision-try-redesign",
|
|
1823
1887
|
icon: RocketIcon,
|
|
1824
1888
|
mode: "bleed",
|
|
@@ -1855,26 +1919,26 @@ function PerspectivePopoverContent(props) {
|
|
|
1855
1919
|
let $ = c(2), t0;
|
|
1856
1920
|
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Box, {
|
|
1857
1921
|
...props,
|
|
1858
|
-
className: "
|
|
1922
|
+
className: "_yLaVW_perspectivePopoverContent"
|
|
1859
1923
|
}), $[0] = props, $[1] = t0), t0;
|
|
1860
1924
|
}
|
|
1861
1925
|
function PerspectivePopoverLink(props) {
|
|
1862
1926
|
let $ = c(2), t0;
|
|
1863
|
-
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(
|
|
1927
|
+
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Link, {
|
|
1864
1928
|
...props,
|
|
1865
|
-
className: "
|
|
1929
|
+
className: "_yLaVW_perspectivePopoverLink"
|
|
1866
1930
|
}), $[0] = props, $[1] = t0), t0;
|
|
1867
1931
|
}
|
|
1868
1932
|
function Dot(t0) {
|
|
1869
1933
|
let $ = c(2), { tone } = t0, t1 = `var(--card-badge-${tone}-dot-color)`, t2;
|
|
1870
1934
|
return $[0] === t1 ? t2 = $[1] : (t2 = /* @__PURE__ */ jsx("div", {
|
|
1871
|
-
className: "
|
|
1935
|
+
className: "_yLaVW_dot",
|
|
1872
1936
|
style: { backgroundColor: t1 }
|
|
1873
1937
|
}), $[0] = t1, $[1] = t2), t2;
|
|
1874
1938
|
}
|
|
1875
1939
|
function PerspectivePopover() {
|
|
1876
1940
|
let $ = c(39), [open, setOpen] = useState(!1), buttonRef = useRef(null), popoverRef = useRef(null), t0;
|
|
1877
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setOpen(_temp$
|
|
1941
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setOpen(_temp$4), $[0] = t0) : t0 = $[0];
|
|
1878
1942
|
let handleClick = t0, { t } = useTranslation(visionLocaleNamespace), t1, t2;
|
|
1879
1943
|
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setOpen(!1), t2 = () => [buttonRef.current, popoverRef.current], $[1] = t1, $[2] = t2) : (t1 = $[1], t2 = $[2]), useClickOutsideEvent(t1, t2);
|
|
1880
1944
|
let t3;
|
|
@@ -1930,8 +1994,8 @@ function PerspectivePopover() {
|
|
|
1930
1994
|
trim: !0,
|
|
1931
1995
|
children: /* @__PURE__ */ jsxs(PerspectivePopoverLink, {
|
|
1932
1996
|
href: "https://www.sanity.io/docs/perspectives",
|
|
1933
|
-
|
|
1934
|
-
|
|
1997
|
+
openInNewTab: !0,
|
|
1998
|
+
underlined: !1,
|
|
1935
1999
|
children: [t12, " →"]
|
|
1936
2000
|
})
|
|
1937
2001
|
}) }), $[24] = t12, $[25] = t13);
|
|
@@ -1973,7 +2037,7 @@ function PerspectivePopover() {
|
|
|
1973
2037
|
children: t16
|
|
1974
2038
|
}), $[35] = open, $[36] = t14, $[37] = t16, $[38] = t17) : t17 = $[38], t17;
|
|
1975
2039
|
}
|
|
1976
|
-
function _temp$
|
|
2040
|
+
function _temp$4(o) {
|
|
1977
2041
|
return !o;
|
|
1978
2042
|
}
|
|
1979
2043
|
const PinnedReleasePerspectiveOption = (t0) => {
|
|
@@ -1984,7 +2048,7 @@ const PinnedReleasePerspectiveOption = (t0) => {
|
|
|
1984
2048
|
name,
|
|
1985
2049
|
t2,
|
|
1986
2050
|
label
|
|
1987
|
-
].filter(_temp$
|
|
2051
|
+
].filter(_temp$3), $[3] = label, $[4] = name, $[5] = t2, $[6] = t3) : t3 = $[6];
|
|
1988
2052
|
let text = t3.join(" "), t4;
|
|
1989
2053
|
$[7] === pinnedPerspective ? t4 = $[8] : (t4 = hasPinnedPerspective(pinnedPerspective), $[7] = pinnedPerspective, $[8] = t4);
|
|
1990
2054
|
let t5 = !t4, t6;
|
|
@@ -2234,7 +2298,7 @@ function _temp3$1(version) {
|
|
|
2234
2298
|
function _temp2$2(ds) {
|
|
2235
2299
|
return /* @__PURE__ */ jsx("option", { children: ds }, ds);
|
|
2236
2300
|
}
|
|
2237
|
-
function _temp$
|
|
2301
|
+
function _temp$3(value) {
|
|
2238
2302
|
return value !== void 0;
|
|
2239
2303
|
}
|
|
2240
2304
|
function getBlobUrl(content, mimeType) {
|
|
@@ -2258,6 +2322,14 @@ function getMemoizedBlobUrlResolver(mimeType, stringEncoder) {
|
|
|
2258
2322
|
})();
|
|
2259
2323
|
}
|
|
2260
2324
|
const getJsonBlobUrl = getMemoizedBlobUrlResolver("application/json", (input) => JSON.stringify(input, null, 2)), getCsvBlobUrl = getMemoizedBlobUrlResolver("text/csv", (input) => json2csv(Array.isArray(input) ? input : [input]).trim());
|
|
2325
|
+
/**
|
|
2326
|
+
* Whether `getCsvBlobUrl` can produce anything for a result: `json2csv` yields nothing unless at
|
|
2327
|
+
* least one item is an object. A look at the shape, so a download button can be disabled without
|
|
2328
|
+
* converting a result nobody asked to download.
|
|
2329
|
+
*/
|
|
2330
|
+
function canEncodeCsv(input) {
|
|
2331
|
+
return (Array.isArray(input) ? input : [input]).some((item) => typeof item == "object" && !!item && !Array.isArray(item));
|
|
2332
|
+
}
|
|
2261
2333
|
function DelayedSpinner(props) {
|
|
2262
2334
|
let $ = c(5), [show, setShow] = useState(!1), t0, t1;
|
|
2263
2335
|
$[0] === props.delay ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
|
|
@@ -2405,6 +2477,10 @@ function QueryErrorDialog(props) {
|
|
|
2405
2477
|
]
|
|
2406
2478
|
}), $[14] = T0, $[15] = t0, $[16] = t1, $[17] = t2, $[18] = t3, $[19] = t4, $[20] = t5, $[21] = t6) : t6 = $[21], t6;
|
|
2407
2479
|
}
|
|
2480
|
+
/** A dotted key path written the way it reads in code: `0.author.tags.1` as `[0].author.tags[1]` */
|
|
2481
|
+
function describeKeypath(keypath) {
|
|
2482
|
+
return keypath.split(".").map((segment, index) => /^\d+$/.test(segment) ? `[${segment}]` : index === 0 ? segment : `.${segment}`).join("");
|
|
2483
|
+
}
|
|
2408
2484
|
/**
|
|
2409
2485
|
* The value at one of `@rexxars/react-json-inspector`'s dotted key paths (`0.author.name`; empty
|
|
2410
2486
|
* for the root). A key may contain dots itself, so at each step the longest run of segments that
|
|
@@ -2810,7 +2886,7 @@ function VisionGui(props) {
|
|
|
2810
2886
|
}
|
|
2811
2887
|
let t17;
|
|
2812
2888
|
if ($[35] !== isDraftModelEnabled || $[36] !== releases) {
|
|
2813
|
-
let scheduledDraftReleases = releases.filter(_temp$
|
|
2889
|
+
let scheduledDraftReleases = releases.filter(_temp$2), releaseIds = sortReleases(scheduledDraftReleases).map(_temp2$1), t18;
|
|
2814
2890
|
$[38] === isDraftModelEnabled ? t18 = $[39] : (t18 = isDraftModelEnabled ? ["drafts"] : ["published"], $[38] = isDraftModelEnabled, $[39] = t18);
|
|
2815
2891
|
let defaultPerspective = t18;
|
|
2816
2892
|
t17 = [...releaseIds, ...defaultPerspective], $[35] = isDraftModelEnabled, $[36] = releases, $[37] = t17;
|
|
@@ -3207,7 +3283,7 @@ function VisionGui(props) {
|
|
|
3207
3283
|
function _temp2$1(release_0) {
|
|
3208
3284
|
return getReleaseIdFromReleaseDocumentId(release_0._id);
|
|
3209
3285
|
}
|
|
3210
|
-
function _temp$
|
|
3286
|
+
function _temp$2(release) {
|
|
3211
3287
|
return isCardinalityOneRelease(release) && release.state === "scheduled";
|
|
3212
3288
|
}
|
|
3213
3289
|
function useDatasets(t0) {
|
|
@@ -3221,7 +3297,7 @@ function useDatasets(t0) {
|
|
|
3221
3297
|
let t2;
|
|
3222
3298
|
if ($[2] !== client.observable.datasets || $[3] !== configDatasets) {
|
|
3223
3299
|
let t3;
|
|
3224
|
-
$[5] === configDatasets ? t3 = $[6] : (t3 = (result) => typeof configDatasets == "function" ? configDatasets(result).map(_temp) : result.map(_temp2), $[5] = configDatasets, $[6] = t3), t2 = client.observable.datasets.list().pipe(map(t3), catchError(_temp3)), $[2] = client.observable.datasets, $[3] = configDatasets, $[4] = t2;
|
|
3300
|
+
$[5] === configDatasets ? t3 = $[6] : (t3 = (result) => typeof configDatasets == "function" ? configDatasets(result).map(_temp$1) : result.map(_temp2), $[5] = configDatasets, $[6] = t3), t2 = client.observable.datasets.list().pipe(map(t3), catchError(_temp3)), $[2] = client.observable.datasets, $[3] = configDatasets, $[4] = t2;
|
|
3225
3301
|
} else t2 = $[4];
|
|
3226
3302
|
t1 = t2;
|
|
3227
3303
|
}
|
|
@@ -3233,7 +3309,7 @@ function _temp3(err) {
|
|
|
3233
3309
|
function _temp2(ds) {
|
|
3234
3310
|
return ds.name;
|
|
3235
3311
|
}
|
|
3236
|
-
function _temp(d) {
|
|
3312
|
+
function _temp$1(d) {
|
|
3237
3313
|
return d.name;
|
|
3238
3314
|
}
|
|
3239
3315
|
function VisionContainer(props) {
|
|
@@ -3341,8 +3417,175 @@ var VisionErrorBoundary = class extends Component {
|
|
|
3341
3417
|
});
|
|
3342
3418
|
}
|
|
3343
3419
|
};
|
|
3420
|
+
const TOAST_ID = "vision-redesign-invitation";
|
|
3421
|
+
/**
|
|
3422
|
+
* The toast's body. It renders in the studio's toast layer, which can sit outside the locale
|
|
3423
|
+
* provider that has Vision's strings, so it is handed them translated
|
|
3424
|
+
*/
|
|
3425
|
+
function RedesignToastActions(props) {
|
|
3426
|
+
let $ = c(14), { description, acceptLabel, dismissLabel, onAccept, onDismiss } = props, t0;
|
|
3427
|
+
$[0] === description ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Text, {
|
|
3428
|
+
size: 1,
|
|
3429
|
+
as: "div",
|
|
3430
|
+
trim: !0,
|
|
3431
|
+
children: description
|
|
3432
|
+
}), $[0] = description, $[1] = t0);
|
|
3433
|
+
let t1;
|
|
3434
|
+
$[2] !== acceptLabel || $[3] !== onAccept ? (t1 = /* @__PURE__ */ jsx(Button, {
|
|
3435
|
+
"data-testid": "vision-redesign-accept",
|
|
3436
|
+
fontSize: 1,
|
|
3437
|
+
onClick: onAccept,
|
|
3438
|
+
padding: 2,
|
|
3439
|
+
text: acceptLabel,
|
|
3440
|
+
tone: "primary"
|
|
3441
|
+
}), $[2] = acceptLabel, $[3] = onAccept, $[4] = t1) : t1 = $[4];
|
|
3442
|
+
let t2;
|
|
3443
|
+
$[5] !== dismissLabel || $[6] !== onDismiss ? (t2 = /* @__PURE__ */ jsx(Button, {
|
|
3444
|
+
"data-testid": "vision-redesign-dismiss",
|
|
3445
|
+
fontSize: 1,
|
|
3446
|
+
mode: "bleed",
|
|
3447
|
+
onClick: onDismiss,
|
|
3448
|
+
padding: 2,
|
|
3449
|
+
text: dismissLabel
|
|
3450
|
+
}), $[5] = dismissLabel, $[6] = onDismiss, $[7] = t2) : t2 = $[7];
|
|
3451
|
+
let t3;
|
|
3452
|
+
$[8] !== t1 || $[9] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Flex, {
|
|
3453
|
+
gap: 2,
|
|
3454
|
+
children: [t1, t2]
|
|
3455
|
+
}), $[8] = t1, $[9] = t2, $[10] = t3) : t3 = $[10];
|
|
3456
|
+
let t4;
|
|
3457
|
+
return $[11] !== t0 || $[12] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Stack, {
|
|
3458
|
+
gap: 3,
|
|
3459
|
+
paddingTop: 1,
|
|
3460
|
+
children: [t0, t3]
|
|
3461
|
+
}), $[11] = t0, $[12] = t3, $[13] = t4) : t4 = $[13], t4;
|
|
3462
|
+
}
|
|
3463
|
+
/**
|
|
3464
|
+
* Invites the user to try the redesigned Vision. Renders nothing itself: it pushes a persistent
|
|
3465
|
+
* toast while mounted and removes it again on unmount, so it disappears as soon as the user opts
|
|
3466
|
+
* in or leaves the tool.
|
|
3467
|
+
*/
|
|
3468
|
+
function RedesignToast(t0) {
|
|
3469
|
+
let $ = c(8), { onAccept, onDismiss } = t0, toast = useToast(), { t } = useTranslation(visionLocaleNamespace), accept = useEffectEvent(onAccept), dismiss = useEffectEvent(onDismiss), t1;
|
|
3470
|
+
$[0] !== accept || $[1] !== dismiss || $[2] !== t || $[3] !== toast ? (t1 = () => {
|
|
3471
|
+
let remove = () => {
|
|
3472
|
+
toast.push({
|
|
3473
|
+
id: TOAST_ID,
|
|
3474
|
+
duration: .01
|
|
3475
|
+
});
|
|
3476
|
+
};
|
|
3477
|
+
return toast.push({
|
|
3478
|
+
id: TOAST_ID,
|
|
3479
|
+
closable: !1,
|
|
3480
|
+
duration: Infinity,
|
|
3481
|
+
status: "info",
|
|
3482
|
+
title: t("vision.redesign.toast.title"),
|
|
3483
|
+
description: /* @__PURE__ */ jsx(RedesignToastActions, {
|
|
3484
|
+
acceptLabel: t("vision.redesign.toast.accept"),
|
|
3485
|
+
description: t("vision.redesign.toast.description"),
|
|
3486
|
+
dismissLabel: t("vision.redesign.toast.dismiss"),
|
|
3487
|
+
onAccept: () => {
|
|
3488
|
+
remove(), accept();
|
|
3489
|
+
},
|
|
3490
|
+
onDismiss: () => {
|
|
3491
|
+
remove(), dismiss();
|
|
3492
|
+
}
|
|
3493
|
+
})
|
|
3494
|
+
}), remove;
|
|
3495
|
+
}, $[0] = accept, $[1] = dismiss, $[2] = t, $[3] = toast, $[4] = t1) : t1 = $[4];
|
|
3496
|
+
let t2;
|
|
3497
|
+
return $[5] !== t || $[6] !== toast ? (t2 = [t, toast], $[5] = t, $[6] = toast, $[7] = t2) : t2 = $[7], useEffect(t1, t2), null;
|
|
3498
|
+
}
|
|
3499
|
+
const DEFAULT_PREFERENCE = {
|
|
3500
|
+
optedIn: !1,
|
|
3501
|
+
dismissed: !1
|
|
3502
|
+
}, cache = /* @__PURE__ */ new Map(), listeners = /* @__PURE__ */ new Set();
|
|
3503
|
+
function storageKey(projectId) {
|
|
3504
|
+
return `${VISION_STORAGE_KEY_PREFIX}redesign:${projectId}`;
|
|
3505
|
+
}
|
|
3506
|
+
function notify() {
|
|
3507
|
+
listeners.forEach((listener) => listener());
|
|
3508
|
+
}
|
|
3509
|
+
function subscribe(listener) {
|
|
3510
|
+
listeners.add(listener);
|
|
3511
|
+
let unsubscribeClear = onLocalStorageCleared(() => {
|
|
3512
|
+
cache.clear(), listener();
|
|
3513
|
+
});
|
|
3514
|
+
return () => {
|
|
3515
|
+
listeners.delete(listener), unsubscribeClear();
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3518
|
+
function parsePreference(raw) {
|
|
3519
|
+
if (raw === null) return DEFAULT_PREFERENCE;
|
|
3520
|
+
try {
|
|
3521
|
+
let stored = JSON.parse(raw);
|
|
3522
|
+
return isPlainObject(stored) ? {
|
|
3523
|
+
optedIn: stored.optedIn === !0,
|
|
3524
|
+
dismissed: stored.dismissed === !0
|
|
3525
|
+
} : DEFAULT_PREFERENCE;
|
|
3526
|
+
} catch {
|
|
3527
|
+
return DEFAULT_PREFERENCE;
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
function readRedesignPreference(projectId) {
|
|
3531
|
+
let storage = getStorage(), cached = cache.get(projectId);
|
|
3532
|
+
if (!storage) return cached?.preference ?? DEFAULT_PREFERENCE;
|
|
3533
|
+
let raw = storage.getItem(storageKey(projectId));
|
|
3534
|
+
if (cached && cached.raw === raw) return cached.preference;
|
|
3535
|
+
let preference = parsePreference(raw);
|
|
3536
|
+
return cache.set(projectId, {
|
|
3537
|
+
raw,
|
|
3538
|
+
preference
|
|
3539
|
+
}), preference;
|
|
3540
|
+
}
|
|
3541
|
+
function writeRedesignPreference(projectId, patch) {
|
|
3542
|
+
let next = {
|
|
3543
|
+
...readRedesignPreference(projectId),
|
|
3544
|
+
...patch
|
|
3545
|
+
}, storage = getStorage(), raw = JSON.stringify(next);
|
|
3546
|
+
try {
|
|
3547
|
+
storage?.setItem(storageKey(projectId), raw);
|
|
3548
|
+
} catch {
|
|
3549
|
+
raw = storage?.getItem(storageKey(projectId)) ?? null;
|
|
3550
|
+
}
|
|
3551
|
+
return cache.set(projectId, {
|
|
3552
|
+
raw,
|
|
3553
|
+
preference: next
|
|
3554
|
+
}), notify(), next;
|
|
3555
|
+
}
|
|
3556
|
+
function useRedesignPreference(projectId) {
|
|
3557
|
+
let $ = c(2), t0;
|
|
3558
|
+
return $[0] === projectId ? t0 = $[1] : (t0 = () => readRedesignPreference(projectId), $[0] = projectId, $[1] = t0), useSyncExternalStore(subscribe, t0, _temp);
|
|
3559
|
+
}
|
|
3560
|
+
function _temp() {
|
|
3561
|
+
return DEFAULT_PREFERENCE;
|
|
3562
|
+
}
|
|
3563
|
+
/**
|
|
3564
|
+
* A `lazy()` component whose failed import can be tried again. React keeps a rejected `lazy()`
|
|
3565
|
+
* for good, so `retry` (for the error boundary's Retry) swaps in a fresh one. The rejected one
|
|
3566
|
+
* stays until then: swapped as soon as the import fails, the Suspense boundary's next render
|
|
3567
|
+
* would start another import instead of surfacing the error, so a chunk that keeps failing
|
|
3568
|
+
* would be fetched over and over and never reach the error boundary.
|
|
3569
|
+
*/
|
|
3570
|
+
function createRetryableLazy(load) {
|
|
3571
|
+
let failed = !1, attempt = () => load().catch((error) => {
|
|
3572
|
+
throw failed = !0, error;
|
|
3573
|
+
}), LazyComponent = lazy(attempt);
|
|
3574
|
+
function RetryableLazy(props) {
|
|
3575
|
+
let $ = c(2), t0;
|
|
3576
|
+
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(LazyComponent, { ...props }), $[0] = props, $[1] = t0), t0;
|
|
3577
|
+
}
|
|
3578
|
+
return {
|
|
3579
|
+
Component: RetryableLazy,
|
|
3580
|
+
retry: () => {
|
|
3581
|
+
failed && (failed = !1, LazyComponent = lazy(attempt));
|
|
3582
|
+
}
|
|
3583
|
+
};
|
|
3584
|
+
}
|
|
3585
|
+
var SanityVision_exports = /* @__PURE__ */ __exportAll({ default: () => SanityVision });
|
|
3586
|
+
const visionRedesign = createRetryableLazy(() => import("./VisionRedesign-C3iwsYdI.js").then((module) => ({ default: module.VisionRedesign }))), VisionRedesignLoader = visionRedesign.Component;
|
|
3344
3587
|
function SanityVision(props) {
|
|
3345
|
-
let $ = c(
|
|
3588
|
+
let $ = c(31), t0;
|
|
3346
3589
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: "1" }, $[0] = t0) : t0 = $[0];
|
|
3347
3590
|
let client = useClient(t0), t1;
|
|
3348
3591
|
$[1] === props.tool.options ? t1 = $[2] : (t1 = {
|
|
@@ -3350,18 +3593,47 @@ function SanityVision(props) {
|
|
|
3350
3593
|
...props.tool.options
|
|
3351
3594
|
}, $[1] = props.tool.options, $[2] = t1);
|
|
3352
3595
|
let config = t1, t2;
|
|
3353
|
-
$[3]
|
|
3596
|
+
$[3] === client ? t2 = $[4] : (t2 = client.config().projectId || "default", $[3] = client, $[4] = t2);
|
|
3597
|
+
let projectId = t2, redesignEnabled = config.beta?.redesign?.enabled === !0, preference = useRedesignPreference(projectId), showRedesign = redesignEnabled && preference.optedIn, t3;
|
|
3598
|
+
$[5] === projectId ? t3 = $[6] : (t3 = () => writeRedesignPreference(projectId, {
|
|
3599
|
+
optedIn: !0,
|
|
3600
|
+
dismissed: !1
|
|
3601
|
+
}), $[5] = projectId, $[6] = t3);
|
|
3602
|
+
let optIn = t3, t4;
|
|
3603
|
+
$[7] === projectId ? t4 = $[8] : (t4 = () => writeRedesignPreference(projectId, { dismissed: !0 }), $[7] = projectId, $[8] = t4);
|
|
3604
|
+
let dismiss = t4, t5;
|
|
3605
|
+
$[9] === projectId ? t5 = $[10] : (t5 = () => writeRedesignPreference(projectId, {
|
|
3606
|
+
optedIn: !1,
|
|
3607
|
+
dismissed: !1
|
|
3608
|
+
}), $[9] = projectId, $[10] = t5);
|
|
3609
|
+
let switchToClassic = t5, t6;
|
|
3610
|
+
$[11] !== client || $[12] !== config || $[13] !== optIn || $[14] !== redesignEnabled || $[15] !== showRedesign || $[16] !== switchToClassic ? (t6 = (loaded) => showRedesign ? /* @__PURE__ */ jsx(VisionRedesignLoader, {
|
|
3611
|
+
...loaded,
|
|
3612
|
+
config,
|
|
3613
|
+
onSwitchToClassic: switchToClassic
|
|
3614
|
+
}) : /* @__PURE__ */ jsx(VisionGui, {
|
|
3354
3615
|
...loaded,
|
|
3355
3616
|
client,
|
|
3356
|
-
config
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3617
|
+
config,
|
|
3618
|
+
onSwitchToRedesign: redesignEnabled ? optIn : void 0
|
|
3619
|
+
}), $[11] = client, $[12] = config, $[13] = optIn, $[14] = redesignEnabled, $[15] = showRedesign, $[16] = switchToClassic, $[17] = t6) : t6 = $[17];
|
|
3620
|
+
let t7;
|
|
3621
|
+
$[18] !== client || $[19] !== config || $[20] !== t6 ? (t7 = /* @__PURE__ */ jsx(VisionContainer, {
|
|
3360
3622
|
client,
|
|
3361
3623
|
config,
|
|
3362
|
-
children:
|
|
3363
|
-
})
|
|
3624
|
+
children: t6
|
|
3625
|
+
}), $[18] = client, $[19] = config, $[20] = t6, $[21] = t7) : t7 = $[21];
|
|
3626
|
+
let t8;
|
|
3627
|
+
$[22] !== dismiss || $[23] !== optIn || $[24] !== preference || $[25] !== redesignEnabled || $[26] !== showRedesign ? (t8 = redesignEnabled && !showRedesign && !preference.dismissed && /* @__PURE__ */ jsx(RedesignToast, {
|
|
3628
|
+
onAccept: optIn,
|
|
3629
|
+
onDismiss: dismiss
|
|
3630
|
+
}), $[22] = dismiss, $[23] = optIn, $[24] = preference, $[25] = redesignEnabled, $[26] = showRedesign, $[27] = t8) : t8 = $[27];
|
|
3631
|
+
let t9;
|
|
3632
|
+
return $[28] !== t7 || $[29] !== t8 ? (t9 = /* @__PURE__ */ jsxs(VisionErrorBoundary, {
|
|
3633
|
+
onRetry: visionRedesign.retry,
|
|
3634
|
+
children: [t7, t8]
|
|
3635
|
+
}), $[28] = t7, $[29] = t8, $[30] = t9) : t9 = $[30], t9;
|
|
3364
3636
|
}
|
|
3365
|
-
export { SanityVision as default };
|
|
3637
|
+
export { DEFAULT_API_VERSION as A, getActivePerspective as C, paramsExtensions as D, groqExtensions as E, prefixApiVersion as M, resultJsonExtensions as O, encodeQueryString as S, VisionCodeMirror as T, VISION_STORAGE_KEY_PREFIX as _, getAtKeypath as a, isPlainObject as b, DelayedSpinner as c, getJsonBlobUrl as d, SanityVision as default, useSavedQueries as f, validateApiVersion as g, parseQueryUrl as h, describeKeypath as i, VARIANTS_API_VERSION as j, API_VERSIONS as k, canEncodeCsv as l, isApiCdnHost as m, createRetryableLazy as n, QueryErrorDialog as o, parseParams as p, ResultView as r, isApiVersionBelow as s, SanityVision_exports as t, getCsvBlobUrl as u, getStorage as v, useVariantsEnabled as w, isVisionPasteTarget as x, onLocalStorageCleared as y };
|
|
3366
3638
|
|
|
3367
|
-
//# sourceMappingURL=SanityVision-
|
|
3639
|
+
//# sourceMappingURL=SanityVision-BSByYf4K.js.map
|