@sanity/vision 6.22.0-next.44 → 6.22.0-next.74
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/{SanityVision-Cr8Er2s4.js → SanityVision-CD-bx0vw.js} +32 -297
- package/lib/SanityVision-CD-bx0vw.js.map +1 -0
- package/lib/bundle.css +0 -596
- package/lib/index.d.ts +3 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/lib/CodeDiff-MkS3Q87A.js +0 -61
- package/lib/CodeDiff-MkS3Q87A.js.map +0 -1
- package/lib/SanityVision-Cr8Er2s4.js.map +0 -1
- package/lib/VistaGui-0nZ5Zsoe.js +0 -14448
- package/lib/VistaGui-0nZ5Zsoe.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as visionLocaleNamespace } from "./i18n-DFRqoJ_F.js";
|
|
2
|
-
import { Component, Fragment, Suspense, createContext,
|
|
2
|
+
import { Component, Fragment, Suspense, createContext, use, useEffect, useImperativeHandle, useRef, useState } 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,
|
|
9
|
+
import { Badge, Button, Card, Dialog, Heading, Hotkeys, Inline, Label, Select, Spinner, Tab, TabList, Text, 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
12
|
import { Box, Container, Flex, Grid, VStack } from "ui5";
|
|
@@ -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
|
|
22
|
+
import CodeMirror, { EditorSelection } 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,14 +51,6 @@ 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
|
-
};
|
|
62
54
|
function prefixApiVersion(version) {
|
|
63
55
|
return version[0] !== "v" && version !== "other" ? `v${version}` : version;
|
|
64
56
|
}
|
|
@@ -92,8 +84,8 @@ const VARIANTS_API_VERSION = prefixApiVersion(VARIANTS_STUDIO_CLIENT_OPTIONS.api
|
|
|
92
84
|
...defaultKeymap,
|
|
93
85
|
...historyKeymap
|
|
94
86
|
])
|
|
95
|
-
], groqExtensions = [groq(), ...sharedExtensions], paramsExtensions = [javascriptLanguage, ...sharedExtensions]
|
|
96
|
-
|
|
87
|
+
], groqExtensions = [groq(), ...sharedExtensions], paramsExtensions = [javascriptLanguage, ...sharedExtensions];
|
|
88
|
+
[
|
|
97
89
|
...sharedExtensions,
|
|
98
90
|
foldGutter(),
|
|
99
91
|
EditorState.readOnly.of(!0)
|
|
@@ -339,7 +331,7 @@ function VisionCodeMirror(t0) {
|
|
|
339
331
|
to: currentDoc.length,
|
|
340
332
|
insert: newContent
|
|
341
333
|
},
|
|
342
|
-
selection: EditorSelection
|
|
334
|
+
selection: EditorSelection.cursor(newContent.length)
|
|
343
335
|
}), editorView.scrollDOM.scrollTop = 0, editorView.scrollDOM.scrollLeft = 0);
|
|
344
336
|
}, $[5] = t7) : t7 = $[5];
|
|
345
337
|
let resetEditorContent = t7, t8;
|
|
@@ -360,7 +352,7 @@ function VisionCodeMirror(t0) {
|
|
|
360
352
|
if (!editorView_1) return;
|
|
361
353
|
let length = editorView_1.state.doc.length;
|
|
362
354
|
editorView_1.dispatch({
|
|
363
|
-
selection: EditorSelection
|
|
355
|
+
selection: EditorSelection.range(Math.min(from, length), Math.min(to, length)),
|
|
364
356
|
scrollIntoView: !0
|
|
365
357
|
}), editorView_1.focus();
|
|
366
358
|
}, $[8] = t10) : t10 = $[8];
|
|
@@ -460,17 +452,11 @@ function isPlainObject(obj) {
|
|
|
460
452
|
return !!obj && typeof obj == "object" && Object.prototype.toString.call(obj) === "[object Object]";
|
|
461
453
|
}
|
|
462
454
|
/** Every `localStorage` key Vision writes (classic and redesign alike) starts with this prefix */
|
|
463
|
-
const
|
|
455
|
+
const hasLocalStorage = supportsLocalStorage(), clearListeners = /* @__PURE__ */ new Set();
|
|
464
456
|
/** The `localStorage` instance when it is available and writable, `undefined` otherwise */
|
|
465
457
|
function getStorage() {
|
|
466
458
|
return hasLocalStorage ? globalThis.localStorage : void 0;
|
|
467
459
|
}
|
|
468
|
-
/** Runs `listener` after `clearLocalStorage`, so in-memory copies of stored values can drop too */
|
|
469
|
-
function onLocalStorageCleared(listener) {
|
|
470
|
-
return clearListeners.add(listener), () => {
|
|
471
|
-
clearListeners.delete(listener);
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
460
|
function clearLocalStorage() {
|
|
475
461
|
let storage = getStorage();
|
|
476
462
|
if (storage) {
|
|
@@ -484,7 +470,7 @@ function clearLocalStorage() {
|
|
|
484
470
|
clearListeners.forEach((listener) => listener());
|
|
485
471
|
}
|
|
486
472
|
function getLocalStorage(namespace) {
|
|
487
|
-
let storageKey =
|
|
473
|
+
let storageKey = `sanityVision:${namespace}`, loadedState = null;
|
|
488
474
|
return {
|
|
489
475
|
get,
|
|
490
476
|
set,
|
|
@@ -550,52 +536,7 @@ function validateApiVersion(apiVersion) {
|
|
|
550
536
|
* paste handler has always picked the URL out of the pasted text with it. `parseQueryUrl` is
|
|
551
537
|
* stricter and takes the whole text to be the URL.
|
|
552
538
|
*/
|
|
553
|
-
const SANITY_QUERY_URL = /\/(vX|v1|v\d{4}-\d\d-\d\d)\/.*?(?:query|listen)\/(.*?)\?(.*)
|
|
554
|
-
/** `<project>.apicdn.sanity.io`, where `useCdn` sends queries */
|
|
555
|
-
function isApiCdnHost(hostname) {
|
|
556
|
-
return API_CDN_HOST.test(hostname);
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* Parses a Content Lake query (or listen) URL, as pasted from the browser's network tab, into the
|
|
560
|
-
* pieces of a tab. Returns `null` when the text is not such a URL: the whole text has to be one
|
|
561
|
-
* http(s) URL, since a query URL quoted inside other text is not a paste of that URL, and the
|
|
562
|
-
* redesign claims a paste it parses and replaces the tab's query with it.
|
|
563
|
-
*/
|
|
564
|
-
function parseQueryUrl(data, datasets) {
|
|
565
|
-
let trimmed = data.trim(), url = parseHttpUrl(trimmed), match = url?.pathname.match(QUERY_URL_PATHNAME);
|
|
566
|
-
if (!url || !match) return null;
|
|
567
|
-
let [, usedApiVersion, usedDataset] = match, parts;
|
|
568
|
-
try {
|
|
569
|
-
parts = parseApiQueryString(url.searchParams);
|
|
570
|
-
} catch {
|
|
571
|
-
return null;
|
|
572
|
-
}
|
|
573
|
-
if (!parts.query) return null;
|
|
574
|
-
let urlPerspective = parts.options.perspective, perspective = urlPerspective && isSupportedPerspective(urlPerspective) && !isVirtualPerspective(urlPerspective) ? urlPerspective : void 0, { resultSourceMap } = parts.options, includeSourceMap = resultSourceMap === "true" || resultSourceMap === "withKeyArraySelector";
|
|
575
|
-
return {
|
|
576
|
-
query: parts.query,
|
|
577
|
-
params: parts.params,
|
|
578
|
-
rawParams: JSON.stringify(parts.params, null, 2),
|
|
579
|
-
dataset: usedDataset,
|
|
580
|
-
isKnownDataset: datasets.includes(usedDataset),
|
|
581
|
-
apiVersion: validateApiVersion(usedApiVersion) ? usedApiVersion : void 0,
|
|
582
|
-
urlPerspective: urlPerspective || void 0,
|
|
583
|
-
perspective,
|
|
584
|
-
hasUnsupportedPerspective: !!urlPerspective && perspective === void 0,
|
|
585
|
-
variant: parts.options.variant || void 0,
|
|
586
|
-
includeSourceMap,
|
|
587
|
-
useCdn: isApiCdnHost(url.hostname),
|
|
588
|
-
url: trimmed
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
function parseHttpUrl(text) {
|
|
592
|
-
try {
|
|
593
|
-
let url = new URL(text);
|
|
594
|
-
return url.protocol === "http:" || url.protocol === "https:" ? url : null;
|
|
595
|
-
} catch {
|
|
596
|
-
return null;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
539
|
+
const SANITY_QUERY_URL = /\/(vX|v1|v\d{4}-\d\d-\d\d)\/.*?(?:query|listen)\/(.*?)\?(.*)/;
|
|
599
540
|
function tryParseParams(val, t) {
|
|
600
541
|
try {
|
|
601
542
|
let parsed = val ? JSON5.parse(val) : {};
|
|
@@ -928,7 +869,7 @@ function useSavedQueries() {
|
|
|
928
869
|
let run = () => task().finally(() => {
|
|
929
870
|
--pendingPersonalWritesRef.current;
|
|
930
871
|
}), result = personalWritesRef.current.then(run, run);
|
|
931
|
-
return personalWritesRef.current = result.catch(_temp$
|
|
872
|
+
return personalWritesRef.current = result.catch(_temp$5), result;
|
|
932
873
|
}, $[17] = t12) : t12 = $[17];
|
|
933
874
|
let enqueuePersonalWrite = t12, t13;
|
|
934
875
|
$[18] === Symbol.for("react.memo_cache_sentinel") ? (t13 = (before, attempted, kept) => {
|
|
@@ -1117,7 +1058,7 @@ function _temp3$3(count) {
|
|
|
1117
1058
|
function _temp2$4(a, b) {
|
|
1118
1059
|
return new Date(b.savedAt || 0).getTime() - new Date(a.savedAt || 0).getTime();
|
|
1119
1060
|
}
|
|
1120
|
-
function _temp$
|
|
1061
|
+
function _temp$5() {}
|
|
1121
1062
|
function FixedHeader(props) {
|
|
1122
1063
|
let $ = c(2), t0;
|
|
1123
1064
|
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(VStack, {
|
|
@@ -1747,7 +1688,7 @@ function calculatePaneSizeOptions(height) {
|
|
|
1747
1688
|
};
|
|
1748
1689
|
}
|
|
1749
1690
|
function usePaneSize(t0) {
|
|
1750
|
-
let $ = c(7), { visionRootRef } = t0, [rootSize, setRootSize] = useState(_temp$
|
|
1691
|
+
let $ = c(7), { visionRootRef } = t0, [rootSize, setRootSize] = useState(_temp$4), [isNarrowBreakpoint, setIsNarrowBreakpoint] = useState(_temp2$3), [paneSizeOptions, setPaneSizeOptions] = useState(_temp3$2), t1, t2;
|
|
1751
1692
|
$[0] === visionRootRef ? (t1 = $[1], t2 = $[2]) : (t1 = () => {
|
|
1752
1693
|
if (!visionRootRef.current) return;
|
|
1753
1694
|
let handleResize = (entries) => {
|
|
@@ -1774,7 +1715,7 @@ function _temp3$2() {
|
|
|
1774
1715
|
function _temp2$3() {
|
|
1775
1716
|
return narrowBreakpoint();
|
|
1776
1717
|
}
|
|
1777
|
-
function _temp$
|
|
1718
|
+
function _temp$4() {
|
|
1778
1719
|
return {
|
|
1779
1720
|
width: typeof window < "u" ? window.innerWidth : 1e3,
|
|
1780
1721
|
height: typeof window < "u" ? window.innerHeight : 800
|
|
@@ -1910,7 +1851,7 @@ function Dot(t0) {
|
|
|
1910
1851
|
}
|
|
1911
1852
|
function PerspectivePopover() {
|
|
1912
1853
|
let $ = c(39), [open, setOpen] = useState(!1), buttonRef = useRef(null), popoverRef = useRef(null), t0;
|
|
1913
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setOpen(_temp$
|
|
1854
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setOpen(_temp$3), $[0] = t0) : t0 = $[0];
|
|
1914
1855
|
let handleClick = t0, { t } = useTranslation(visionLocaleNamespace), t1, t2;
|
|
1915
1856
|
$[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);
|
|
1916
1857
|
let t3;
|
|
@@ -1999,7 +1940,7 @@ function PerspectivePopover() {
|
|
|
1999
1940
|
children: t16
|
|
2000
1941
|
}), $[35] = open, $[36] = t14, $[37] = t16, $[38] = t17) : t17 = $[38], t17;
|
|
2001
1942
|
}
|
|
2002
|
-
function _temp$
|
|
1943
|
+
function _temp$3(o) {
|
|
2003
1944
|
return !o;
|
|
2004
1945
|
}
|
|
2005
1946
|
const PinnedReleasePerspectiveOption = (t0) => {
|
|
@@ -2010,7 +1951,7 @@ const PinnedReleasePerspectiveOption = (t0) => {
|
|
|
2010
1951
|
name,
|
|
2011
1952
|
t2,
|
|
2012
1953
|
label
|
|
2013
|
-
].filter(_temp$
|
|
1954
|
+
].filter(_temp$2), $[3] = label, $[4] = name, $[5] = t2, $[6] = t3) : t3 = $[6];
|
|
2014
1955
|
let text = t3.join(" "), t4;
|
|
2015
1956
|
$[7] === pinnedPerspective ? t4 = $[8] : (t4 = hasPinnedPerspective(pinnedPerspective), $[7] = pinnedPerspective, $[8] = t4);
|
|
2016
1957
|
let t5 = !t4, t6;
|
|
@@ -2258,7 +2199,7 @@ function _temp3$1(version) {
|
|
|
2258
2199
|
function _temp2$2(ds) {
|
|
2259
2200
|
return /* @__PURE__ */ jsx("option", { children: ds }, ds);
|
|
2260
2201
|
}
|
|
2261
|
-
function _temp$
|
|
2202
|
+
function _temp$2(value) {
|
|
2262
2203
|
return value !== void 0;
|
|
2263
2204
|
}
|
|
2264
2205
|
function getBlobUrl(content, mimeType) {
|
|
@@ -2282,14 +2223,6 @@ function getMemoizedBlobUrlResolver(mimeType, stringEncoder) {
|
|
|
2282
2223
|
})();
|
|
2283
2224
|
}
|
|
2284
2225
|
const getJsonBlobUrl = getMemoizedBlobUrlResolver("application/json", (input) => JSON.stringify(input, null, 2)), getCsvBlobUrl = getMemoizedBlobUrlResolver("text/csv", (input) => json2csv(Array.isArray(input) ? input : [input]).trim());
|
|
2285
|
-
/**
|
|
2286
|
-
* Whether `getCsvBlobUrl` can produce anything for a result: `json2csv` yields nothing unless at
|
|
2287
|
-
* least one item is an object. A look at the shape, so a download button can be disabled without
|
|
2288
|
-
* converting a result nobody asked to download.
|
|
2289
|
-
*/
|
|
2290
|
-
function canEncodeCsv(input) {
|
|
2291
|
-
return (Array.isArray(input) ? input : [input]).some((item) => typeof item == "object" && !!item && !Array.isArray(item));
|
|
2292
|
-
}
|
|
2293
2226
|
function DelayedSpinner(props) {
|
|
2294
2227
|
let $ = c(5), [show, setShow] = useState(!1), t0, t1;
|
|
2295
2228
|
$[0] === props.delay ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
|
|
@@ -2435,10 +2368,6 @@ function QueryErrorDialog(props) {
|
|
|
2435
2368
|
]
|
|
2436
2369
|
}), $[14] = T0, $[15] = t0, $[16] = t1, $[17] = t2, $[18] = t3, $[19] = t4, $[20] = t5, $[21] = t6) : t6 = $[21], t6;
|
|
2437
2370
|
}
|
|
2438
|
-
/** A dotted key path written the way it reads in code: `0.author.tags.1` as `[0].author.tags[1]` */
|
|
2439
|
-
function describeKeypath(keypath) {
|
|
2440
|
-
return keypath.split(".").map((segment, index) => /^\d+$/.test(segment) ? `[${segment}]` : index === 0 ? segment : `.${segment}`).join("");
|
|
2441
|
-
}
|
|
2442
2371
|
/**
|
|
2443
2372
|
* The value at one of `@rexxars/react-json-inspector`'s dotted key paths (`0.author.name`; empty
|
|
2444
2373
|
* for the root). A key may contain dots itself, so at each step the longest run of segments that
|
|
@@ -2840,7 +2769,7 @@ function VisionGui(props) {
|
|
|
2840
2769
|
}
|
|
2841
2770
|
let t17;
|
|
2842
2771
|
if ($[35] !== isDraftModelEnabled || $[36] !== releases) {
|
|
2843
|
-
let scheduledDraftReleases = releases.filter(_temp$
|
|
2772
|
+
let scheduledDraftReleases = releases.filter(_temp$1), releaseIds = sortReleases(scheduledDraftReleases).map(_temp2$1), t18;
|
|
2844
2773
|
$[38] === isDraftModelEnabled ? t18 = $[39] : (t18 = isDraftModelEnabled ? ["drafts"] : ["published"], $[38] = isDraftModelEnabled, $[39] = t18);
|
|
2845
2774
|
let defaultPerspective = t18;
|
|
2846
2775
|
t17 = [...releaseIds, ...defaultPerspective], $[35] = isDraftModelEnabled, $[36] = releases, $[37] = t17;
|
|
@@ -3237,7 +3166,7 @@ function VisionGui(props) {
|
|
|
3237
3166
|
function _temp2$1(release_0) {
|
|
3238
3167
|
return getReleaseIdFromReleaseDocumentId(release_0._id);
|
|
3239
3168
|
}
|
|
3240
|
-
function _temp$
|
|
3169
|
+
function _temp$1(release) {
|
|
3241
3170
|
return isCardinalityOneRelease(release) && release.state === "scheduled";
|
|
3242
3171
|
}
|
|
3243
3172
|
function useDatasets(t0) {
|
|
@@ -3251,7 +3180,7 @@ function useDatasets(t0) {
|
|
|
3251
3180
|
let t2;
|
|
3252
3181
|
if ($[2] !== client.observable.datasets || $[3] !== configDatasets) {
|
|
3253
3182
|
let t3;
|
|
3254
|
-
$[5] === configDatasets ? t3 = $[6] : (t3 = (result) => typeof configDatasets == "function" ? configDatasets(result).map(_temp
|
|
3183
|
+
$[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;
|
|
3255
3184
|
} else t2 = $[4];
|
|
3256
3185
|
t1 = t2;
|
|
3257
3186
|
}
|
|
@@ -3263,7 +3192,7 @@ function _temp3(err) {
|
|
|
3263
3192
|
function _temp2(ds) {
|
|
3264
3193
|
return ds.name;
|
|
3265
3194
|
}
|
|
3266
|
-
function _temp
|
|
3195
|
+
function _temp(d) {
|
|
3267
3196
|
return d.name;
|
|
3268
3197
|
}
|
|
3269
3198
|
function VisionContainer(props) {
|
|
@@ -3371,173 +3300,8 @@ var VisionErrorBoundary = class extends Component {
|
|
|
3371
3300
|
});
|
|
3372
3301
|
}
|
|
3373
3302
|
};
|
|
3374
|
-
/**
|
|
3375
|
-
* A `lazy()` component whose failed import can be tried again. React keeps a rejected `lazy()`
|
|
3376
|
-
* for good, so `retry` (for the error boundary's Retry) swaps in a fresh one. The rejected one
|
|
3377
|
-
* stays until then: swapped as soon as the import fails, the Suspense boundary's next render
|
|
3378
|
-
* would start another import instead of surfacing the error, so a chunk that keeps failing
|
|
3379
|
-
* would be fetched over and over and never reach the error boundary.
|
|
3380
|
-
*/
|
|
3381
|
-
function createRetryableLazy(load) {
|
|
3382
|
-
let failed = !1, attempt = () => load().catch((error) => {
|
|
3383
|
-
throw failed = !0, error;
|
|
3384
|
-
}), LazyComponent = lazy(attempt);
|
|
3385
|
-
function RetryableLazy(props) {
|
|
3386
|
-
let $ = c(2), t0;
|
|
3387
|
-
return $[0] === props ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(LazyComponent, { ...props }), $[0] = props, $[1] = t0), t0;
|
|
3388
|
-
}
|
|
3389
|
-
return {
|
|
3390
|
-
Component: RetryableLazy,
|
|
3391
|
-
retry: () => {
|
|
3392
|
-
failed && (failed = !1, LazyComponent = lazy(attempt));
|
|
3393
|
-
}
|
|
3394
|
-
};
|
|
3395
|
-
}
|
|
3396
|
-
const TOAST_ID = "vision-redesign-invitation";
|
|
3397
|
-
/**
|
|
3398
|
-
* The toast's body. It renders in the studio's toast layer, which can sit outside the locale
|
|
3399
|
-
* provider that has Vision's strings, so it is handed them translated
|
|
3400
|
-
*/
|
|
3401
|
-
function RedesignToastActions(props) {
|
|
3402
|
-
let $ = c(14), { description, acceptLabel, dismissLabel, onAccept, onDismiss } = props, t0;
|
|
3403
|
-
$[0] === description ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Text, {
|
|
3404
|
-
size: 1,
|
|
3405
|
-
children: description
|
|
3406
|
-
}), $[0] = description, $[1] = t0);
|
|
3407
|
-
let t1;
|
|
3408
|
-
$[2] !== acceptLabel || $[3] !== onAccept ? (t1 = /* @__PURE__ */ jsx(Button, {
|
|
3409
|
-
"data-testid": "vision-redesign-accept",
|
|
3410
|
-
fontSize: 1,
|
|
3411
|
-
onClick: onAccept,
|
|
3412
|
-
padding: 2,
|
|
3413
|
-
text: acceptLabel,
|
|
3414
|
-
tone: "primary"
|
|
3415
|
-
}), $[2] = acceptLabel, $[3] = onAccept, $[4] = t1) : t1 = $[4];
|
|
3416
|
-
let t2;
|
|
3417
|
-
$[5] !== dismissLabel || $[6] !== onDismiss ? (t2 = /* @__PURE__ */ jsx(Button, {
|
|
3418
|
-
"data-testid": "vision-redesign-dismiss",
|
|
3419
|
-
fontSize: 1,
|
|
3420
|
-
mode: "bleed",
|
|
3421
|
-
onClick: onDismiss,
|
|
3422
|
-
padding: 2,
|
|
3423
|
-
text: dismissLabel
|
|
3424
|
-
}), $[5] = dismissLabel, $[6] = onDismiss, $[7] = t2) : t2 = $[7];
|
|
3425
|
-
let t3;
|
|
3426
|
-
$[8] !== t1 || $[9] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Flex, {
|
|
3427
|
-
gap: 2,
|
|
3428
|
-
children: [t1, t2]
|
|
3429
|
-
}), $[8] = t1, $[9] = t2, $[10] = t3) : t3 = $[10];
|
|
3430
|
-
let t4;
|
|
3431
|
-
return $[11] !== t0 || $[12] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Stack, {
|
|
3432
|
-
gap: 3,
|
|
3433
|
-
paddingTop: 1,
|
|
3434
|
-
children: [t0, t3]
|
|
3435
|
-
}), $[11] = t0, $[12] = t3, $[13] = t4) : t4 = $[13], t4;
|
|
3436
|
-
}
|
|
3437
|
-
/**
|
|
3438
|
-
* Invites the user to try the redesigned Vision. Renders nothing itself: it pushes a persistent
|
|
3439
|
-
* toast while mounted and removes it again on unmount, so it disappears as soon as the user opts
|
|
3440
|
-
* in or leaves the tool.
|
|
3441
|
-
*/
|
|
3442
|
-
function RedesignToast(t0) {
|
|
3443
|
-
let $ = c(8), { onAccept, onDismiss } = t0, toast = useToast(), { t } = useTranslation(visionLocaleNamespace), accept = useEffectEvent(onAccept), dismiss = useEffectEvent(onDismiss), t1;
|
|
3444
|
-
$[0] !== accept || $[1] !== dismiss || $[2] !== t || $[3] !== toast ? (t1 = () => {
|
|
3445
|
-
let remove = () => {
|
|
3446
|
-
toast.push({
|
|
3447
|
-
id: TOAST_ID,
|
|
3448
|
-
duration: .01
|
|
3449
|
-
});
|
|
3450
|
-
};
|
|
3451
|
-
return toast.push({
|
|
3452
|
-
id: TOAST_ID,
|
|
3453
|
-
closable: !1,
|
|
3454
|
-
duration: Infinity,
|
|
3455
|
-
status: "info",
|
|
3456
|
-
title: t("vista.redesign.toast.title"),
|
|
3457
|
-
description: /* @__PURE__ */ jsx(RedesignToastActions, {
|
|
3458
|
-
acceptLabel: t("vista.redesign.toast.accept"),
|
|
3459
|
-
description: t("vista.redesign.toast.description"),
|
|
3460
|
-
dismissLabel: t("vista.redesign.toast.dismiss"),
|
|
3461
|
-
onAccept: () => {
|
|
3462
|
-
remove(), accept();
|
|
3463
|
-
},
|
|
3464
|
-
onDismiss: () => {
|
|
3465
|
-
remove(), dismiss();
|
|
3466
|
-
}
|
|
3467
|
-
})
|
|
3468
|
-
}), remove;
|
|
3469
|
-
}, $[0] = accept, $[1] = dismiss, $[2] = t, $[3] = toast, $[4] = t1) : t1 = $[4];
|
|
3470
|
-
let t2;
|
|
3471
|
-
return $[5] !== t || $[6] !== toast ? (t2 = [t, toast], $[5] = t, $[6] = toast, $[7] = t2) : t2 = $[7], useEffect(t1, t2), null;
|
|
3472
|
-
}
|
|
3473
|
-
const DEFAULT_PREFERENCE = {
|
|
3474
|
-
optedIn: !1,
|
|
3475
|
-
dismissed: !1
|
|
3476
|
-
}, cache = /* @__PURE__ */ new Map(), listeners = /* @__PURE__ */ new Set();
|
|
3477
|
-
function storageKey(projectId) {
|
|
3478
|
-
return `${VISION_STORAGE_KEY_PREFIX}redesign:${projectId}`;
|
|
3479
|
-
}
|
|
3480
|
-
function notify() {
|
|
3481
|
-
listeners.forEach((listener) => listener());
|
|
3482
|
-
}
|
|
3483
|
-
function subscribe(listener) {
|
|
3484
|
-
listeners.add(listener);
|
|
3485
|
-
let unsubscribeClear = onLocalStorageCleared(() => {
|
|
3486
|
-
cache.clear(), listener();
|
|
3487
|
-
});
|
|
3488
|
-
return () => {
|
|
3489
|
-
listeners.delete(listener), unsubscribeClear();
|
|
3490
|
-
};
|
|
3491
|
-
}
|
|
3492
|
-
function parsePreference(raw) {
|
|
3493
|
-
if (raw === null) return DEFAULT_PREFERENCE;
|
|
3494
|
-
try {
|
|
3495
|
-
let stored = JSON.parse(raw);
|
|
3496
|
-
return isPlainObject(stored) ? {
|
|
3497
|
-
optedIn: stored.optedIn === !0,
|
|
3498
|
-
dismissed: stored.dismissed === !0
|
|
3499
|
-
} : DEFAULT_PREFERENCE;
|
|
3500
|
-
} catch {
|
|
3501
|
-
return DEFAULT_PREFERENCE;
|
|
3502
|
-
}
|
|
3503
|
-
}
|
|
3504
|
-
function readRedesignPreference(projectId) {
|
|
3505
|
-
let storage = getStorage(), cached = cache.get(projectId);
|
|
3506
|
-
if (!storage) return cached?.preference ?? DEFAULT_PREFERENCE;
|
|
3507
|
-
let raw = storage.getItem(storageKey(projectId));
|
|
3508
|
-
if (cached && cached.raw === raw) return cached.preference;
|
|
3509
|
-
let preference = parsePreference(raw);
|
|
3510
|
-
return cache.set(projectId, {
|
|
3511
|
-
raw,
|
|
3512
|
-
preference
|
|
3513
|
-
}), preference;
|
|
3514
|
-
}
|
|
3515
|
-
function writeRedesignPreference(projectId, patch) {
|
|
3516
|
-
let next = {
|
|
3517
|
-
...readRedesignPreference(projectId),
|
|
3518
|
-
...patch
|
|
3519
|
-
}, storage = getStorage(), raw = JSON.stringify(next);
|
|
3520
|
-
try {
|
|
3521
|
-
storage?.setItem(storageKey(projectId), raw);
|
|
3522
|
-
} catch {
|
|
3523
|
-
raw = storage?.getItem(storageKey(projectId)) ?? null;
|
|
3524
|
-
}
|
|
3525
|
-
return cache.set(projectId, {
|
|
3526
|
-
raw,
|
|
3527
|
-
preference: next
|
|
3528
|
-
}), notify(), next;
|
|
3529
|
-
}
|
|
3530
|
-
function useRedesignPreference(projectId) {
|
|
3531
|
-
let $ = c(2), t0;
|
|
3532
|
-
return $[0] === projectId ? t0 = $[1] : (t0 = () => readRedesignPreference(projectId), $[0] = projectId, $[1] = t0), useSyncExternalStore(subscribe, t0, _temp);
|
|
3533
|
-
}
|
|
3534
|
-
function _temp() {
|
|
3535
|
-
return DEFAULT_PREFERENCE;
|
|
3536
|
-
}
|
|
3537
|
-
var SanityVision_exports = /* @__PURE__ */ __exportAll({ default: () => SanityVision });
|
|
3538
|
-
const vistaGui = createRetryableLazy(() => import("./VistaGui-0nZ5Zsoe.js").then((module) => ({ default: module.VistaGui }))), VistaGuiLoader = vistaGui.Component;
|
|
3539
3303
|
function SanityVision(props) {
|
|
3540
|
-
let $ = c(
|
|
3304
|
+
let $ = c(10), t0;
|
|
3541
3305
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: "1" }, $[0] = t0) : t0 = $[0];
|
|
3542
3306
|
let client = useClient(t0), t1;
|
|
3543
3307
|
$[1] === props.tool.options ? t1 = $[2] : (t1 = {
|
|
@@ -3545,47 +3309,18 @@ function SanityVision(props) {
|
|
|
3545
3309
|
...props.tool.options
|
|
3546
3310
|
}, $[1] = props.tool.options, $[2] = t1);
|
|
3547
3311
|
let config = t1, t2;
|
|
3548
|
-
$[3]
|
|
3549
|
-
let projectId = t2, redesignEnabled = config.beta?.redesign?.enabled === !0, preference = useRedesignPreference(projectId), showRedesign = redesignEnabled && preference.optedIn, t3;
|
|
3550
|
-
$[5] === projectId ? t3 = $[6] : (t3 = () => writeRedesignPreference(projectId, {
|
|
3551
|
-
optedIn: !0,
|
|
3552
|
-
dismissed: !1
|
|
3553
|
-
}), $[5] = projectId, $[6] = t3);
|
|
3554
|
-
let optIn = t3, t4;
|
|
3555
|
-
$[7] === projectId ? t4 = $[8] : (t4 = () => writeRedesignPreference(projectId, { dismissed: !0 }), $[7] = projectId, $[8] = t4);
|
|
3556
|
-
let dismiss = t4, t5;
|
|
3557
|
-
$[9] === projectId ? t5 = $[10] : (t5 = () => writeRedesignPreference(projectId, {
|
|
3558
|
-
optedIn: !1,
|
|
3559
|
-
dismissed: !1
|
|
3560
|
-
}), $[9] = projectId, $[10] = t5);
|
|
3561
|
-
let switchToClassic = t5, t6;
|
|
3562
|
-
$[11] !== client || $[12] !== config || $[13] !== optIn || $[14] !== redesignEnabled || $[15] !== showRedesign || $[16] !== switchToClassic ? (t6 = (loaded) => showRedesign ? /* @__PURE__ */ jsx(VistaGuiLoader, {
|
|
3563
|
-
...loaded,
|
|
3564
|
-
config,
|
|
3565
|
-
onSwitchToClassic: switchToClassic
|
|
3566
|
-
}) : /* @__PURE__ */ jsx(VisionGui, {
|
|
3312
|
+
$[3] !== client || $[4] !== config ? (t2 = (loaded) => /* @__PURE__ */ jsx(VisionGui, {
|
|
3567
3313
|
...loaded,
|
|
3568
3314
|
client,
|
|
3569
|
-
config
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
$[18] !== client || $[19] !== config || $[20] !== t6 ? (t7 = /* @__PURE__ */ jsx(VisionContainer, {
|
|
3315
|
+
config
|
|
3316
|
+
}), $[3] = client, $[4] = config, $[5] = t2) : t2 = $[5];
|
|
3317
|
+
let t3;
|
|
3318
|
+
return $[6] !== client || $[7] !== config || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(VisionErrorBoundary, { children: /* @__PURE__ */ jsx(VisionContainer, {
|
|
3574
3319
|
client,
|
|
3575
3320
|
config,
|
|
3576
|
-
children:
|
|
3577
|
-
}), $[
|
|
3578
|
-
let t8;
|
|
3579
|
-
$[22] !== dismiss || $[23] !== optIn || $[24] !== preference || $[25] !== redesignEnabled || $[26] !== showRedesign ? (t8 = redesignEnabled && !showRedesign && !preference.dismissed && /* @__PURE__ */ jsx(RedesignToast, {
|
|
3580
|
-
onAccept: optIn,
|
|
3581
|
-
onDismiss: dismiss
|
|
3582
|
-
}), $[22] = dismiss, $[23] = optIn, $[24] = preference, $[25] = redesignEnabled, $[26] = showRedesign, $[27] = t8) : t8 = $[27];
|
|
3583
|
-
let t9;
|
|
3584
|
-
return $[28] !== t7 || $[29] !== t8 ? (t9 = /* @__PURE__ */ jsxs(VisionErrorBoundary, {
|
|
3585
|
-
onRetry: vistaGui.retry,
|
|
3586
|
-
children: [t7, t8]
|
|
3587
|
-
}), $[28] = t7, $[29] = t8, $[30] = t9) : t9 = $[30], t9;
|
|
3321
|
+
children: t2
|
|
3322
|
+
}) }), $[6] = client, $[7] = config, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
|
|
3588
3323
|
}
|
|
3589
|
-
export {
|
|
3324
|
+
export { SanityVision as default };
|
|
3590
3325
|
|
|
3591
|
-
//# sourceMappingURL=SanityVision-
|
|
3326
|
+
//# sourceMappingURL=SanityVision-CD-bx0vw.js.map
|