@sanity/vision
Advanced tools
Comparing version 3.71.1-corel.541 to 3.71.1
@@ -65,4 +65,2 @@ "use strict"; | ||
"settings.perspectives.description": 'Perspectives allow your query to run against different "views" of the content in your dataset', | ||
/** Label for the pinned release perspective */ | ||
"settings.perspectives.pinned-release-label": "pinned release", | ||
/** Title for popover that explains what "Perspectives" are */ | ||
@@ -69,0 +67,0 @@ "settings.perspectives.title": "Perspectives" |
@@ -64,4 +64,2 @@ import { defineLocalesResources } from "sanity"; | ||
"settings.perspectives.description": 'Perspectives allow your query to run against different "views" of the content in your dataset', | ||
/** Label for the pinned release perspective */ | ||
"settings.perspectives.pinned-release-label": "pinned release", | ||
/** Title for popover that explains what "Perspectives" are */ | ||
@@ -68,0 +66,0 @@ "settings.perspectives.title": "Perspectives" |
import { jsx, jsxs, Fragment } from "react/jsx-runtime"; | ||
import { c } from "react-compiler-runtime"; | ||
import { useTranslation, useDataset, Translate, useClient, usePerspective } from "sanity"; | ||
import { useTranslation, useDataset, Translate, useClient } from "sanity"; | ||
import { Spinner, rem, useTheme, Box, useClickOutsideEvent, Text, Badge, Inline, Card, Stack, Button, Popover, Code, Tooltip, Flex, Label, Grid, Select, TextInput, Hotkeys, useToast, Container, Heading } from "@sanity/ui"; | ||
@@ -10,3 +10,2 @@ import { useState, useEffect, useRef, PureComponent, createRef, Component } from "react"; | ||
import debounce from "lodash/debounce.js"; | ||
import isEqual from "react-fast-compare"; | ||
import CodeMirror from "@uiw/react-codemirror"; | ||
@@ -191,9 +190,6 @@ import { closeBrackets } from "@codemirror/autocomplete"; | ||
} | ||
const SUPPORTED_PERSPECTIVES = ["pinnedRelease", "raw", "previewDrafts", "published", "drafts"], VIRTUAL_PERSPECTIVES = ["pinnedRelease"], DEFAULT_PERSPECTIVE = "raw"; | ||
const SUPPORTED_PERSPECTIVES = ["raw", "previewDrafts", "published", "drafts"], DEFAULT_PERSPECTIVE = SUPPORTED_PERSPECTIVES[0]; | ||
function isSupportedPerspective(p) { | ||
return SUPPORTED_PERSPECTIVES.includes(p); | ||
} | ||
function isVirtualPerspective(maybeVirtualPerspective) { | ||
return typeof maybeVirtualPerspective == "string" && VIRTUAL_PERSPECTIVES.includes(maybeVirtualPerspective); | ||
} | ||
function encodeQueryString(query, params = {}, options = {}) { | ||
@@ -374,3 +370,3 @@ const searchParams = new URLSearchParams(); | ||
let t0; | ||
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setOpen(_temp$2), $[0] = t0) : t0 = $[0]; | ||
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setOpen(_temp$1), $[0] = t0) : t0 = $[0]; | ||
const handleClick = t0, { | ||
@@ -416,3 +412,3 @@ t | ||
} | ||
function _temp$2(o) { | ||
function _temp$1(o) { | ||
return !o; | ||
@@ -857,3 +853,3 @@ } | ||
let perspective = this._localStorage.get("perspective", defaultPerspective); | ||
datasets.includes(dataset) || (dataset = datasets.includes(defaultDataset) ? defaultDataset : datasets[0]), API_VERSIONS.includes(apiVersion) || (apiVersion = DEFAULT_API_VERSION), SUPPORTED_PERSPECTIVES.includes(perspective) || (perspective = DEFAULT_PERSPECTIVE), perspective == "pinnedRelease" && !hasPinnedPerspective(this.props.pinnedPerspective) && (perspective = DEFAULT_PERSPECTIVE), perspective !== "pinnedRelease" && hasPinnedPerspective(this.props.pinnedPerspective) && (perspective = "pinnedRelease"), typeof lastQuery != "string" && (lastQuery = ""), typeof lastParams != "string" && (lastParams = `{ | ||
datasets.includes(dataset) || (dataset = datasets.includes(defaultDataset) ? defaultDataset : datasets[0]), API_VERSIONS.includes(apiVersion) || (apiVersion = DEFAULT_API_VERSION), SUPPORTED_PERSPECTIVES.includes(perspective) || (perspective = DEFAULT_PERSPECTIVE), typeof lastQuery != "string" && (lastQuery = ""), typeof lastParams != "string" && (lastParams = `{ | ||
@@ -863,6 +859,3 @@ }`), this._visionRoot = createRef(), this._operationUrlElement = createRef(), this._queryEditorContainer = createRef(), this._paramsEditorContainer = createRef(), this._customApiVersionElement = createRef(), this._client = props.client.withConfig({ | ||
dataset, | ||
perspective: getActivePerspective({ | ||
visionPerspective: perspective, | ||
pinnedPerspective: this.props.pinnedPerspective | ||
}), | ||
perspective, | ||
allowReconfigure: !0 | ||
@@ -892,3 +885,3 @@ }); | ||
paneSizeOptions: calculatePaneSizeOptions(bodyHeight) | ||
}, this.handleChangeDataset = this.handleChangeDataset.bind(this), this.handleChangeApiVersion = this.handleChangeApiVersion.bind(this), this.handleCustomApiVersionChange = this.handleCustomApiVersionChange.bind(this), this.handleChangePerspective = this.handleChangePerspective.bind(this), this.handleListenExecution = this.handleListenExecution.bind(this), this.handleListenerEvent = this.handleListenerEvent.bind(this), this.handleQueryExecution = this.handleQueryExecution.bind(this), this.handleQueryChange = debounce(this.handleQueryChange, 300).bind(this), this.handleParamsChange = this.handleParamsChange.bind(this), this.handleCopyUrl = this.handleCopyUrl.bind(this), this.handlePaste = this.handlePaste.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this), this.handleResize = this.handleResize.bind(this), this.handleOnPasteCapture = this.handleOnPasteCapture.bind(this), this.setPerspective = this.setPerspective.bind(this); | ||
}, this.handleChangeDataset = this.handleChangeDataset.bind(this), this.handleChangeApiVersion = this.handleChangeApiVersion.bind(this), this.handleCustomApiVersionChange = this.handleCustomApiVersionChange.bind(this), this.handleChangePerspective = this.handleChangePerspective.bind(this), this.handleListenExecution = this.handleListenExecution.bind(this), this.handleListenerEvent = this.handleListenerEvent.bind(this), this.handleQueryExecution = this.handleQueryExecution.bind(this), this.handleQueryChange = debounce(this.handleQueryChange, 300).bind(this), this.handleParamsChange = this.handleParamsChange.bind(this), this.handleCopyUrl = this.handleCopyUrl.bind(this), this.handlePaste = this.handlePaste.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this), this.handleResize = this.handleResize.bind(this), this.handleOnPasteCapture = this.handleOnPasteCapture.bind(this); | ||
} | ||
@@ -901,15 +894,2 @@ componentDidMount() { | ||
} | ||
componentDidUpdate(prevProps) { | ||
if (hasPinnedPerspectiveChanged(prevProps.pinnedPerspective, this.props.pinnedPerspective)) { | ||
if (this.state.perspective !== "pinnedRelease" && hasPinnedPerspective(this.props.pinnedPerspective)) { | ||
this.setPerspective("pinnedRelease"); | ||
return; | ||
} | ||
if (this.state.perspective === "pinnedRelease" && !hasPinnedPerspective(this.props.pinnedPerspective)) { | ||
this.setPerspective("raw"); | ||
return; | ||
} | ||
this.state.perspective === "pinnedRelease" && this.setPerspective("pinnedRelease"); | ||
} | ||
} | ||
handleResizeListen() { | ||
@@ -945,4 +925,4 @@ this._visionRoot.current && (this._resizeListener = new RO(this.handleResize), this._resizeListener.observe(this._visionRoot.current)); | ||
validateApiVersion(usedApiVersion) && (API_VERSIONS.includes(usedApiVersion) ? (apiVersion = usedApiVersion, customApiVersion = !1) : customApiVersion = usedApiVersion); | ||
const perspective = isSupportedPerspective(parts.options.perspective) && !isVirtualPerspective(parts.options.perspective) ? parts.options.perspective : void 0; | ||
perspective && (!isSupportedPerspective(parts.options.perspective) || isVirtualPerspective(parts.options.perspective)) && this.props.toast.push({ | ||
const perspective = isSupportedPerspective(parts.options.perspective) ? parts.options.perspective : void 0; | ||
perspective && !isSupportedPerspective(perspective) && this.props.toast.push({ | ||
closable: !0, | ||
@@ -970,6 +950,3 @@ id: "vision-paste-unsupported-perspective", | ||
apiVersion: customApiVersion || apiVersion, | ||
perspective: getActivePerspective({ | ||
visionPerspective: this.state.perspective, | ||
pinnedPerspective: this.props.pinnedPerspective | ||
}) | ||
perspective: this.state.perspective | ||
}), this.handleQueryExecution(), this.props.toast.push({ | ||
@@ -1036,5 +1013,2 @@ closable: !0, | ||
const perspective = evt.target.value; | ||
this.setPerspective(perspective); | ||
} | ||
setPerspective(perspective) { | ||
isSupportedPerspective(perspective) && this.setState({ | ||
@@ -1044,6 +1018,3 @@ perspective | ||
this._localStorage.set("perspective", this.state.perspective), this._client.config({ | ||
perspective: getActivePerspective({ | ||
visionPerspective: this.state.perspective, | ||
pinnedPerspective: this.props.pinnedPerspective | ||
}) | ||
perspective: this.state.perspective | ||
}), this.handleQueryExecution(); | ||
@@ -1142,6 +1113,3 @@ }); | ||
const urlQueryOpts = {}; | ||
this.state.perspective !== "raw" && (urlQueryOpts.perspective = getActivePerspective({ | ||
visionPerspective: this.state.perspective, | ||
pinnedPerspective: this.props.pinnedPerspective | ||
}) ?? []); | ||
this.state.perspective !== "raw" && (urlQueryOpts.perspective = this.state.perspective); | ||
const url = this._client.getUrl(this._client.getDataUrl("query", encodeQueryString(query, params, urlQueryOpts))); | ||
@@ -1156,18 +1124,14 @@ this.setState({ | ||
}).subscribe({ | ||
next: (res) => { | ||
this.setState({ | ||
queryTime: res.ms, | ||
e2eTime: Date.now() - queryStart, | ||
queryResult: res.result, | ||
queryInProgress: !1, | ||
error: void 0 | ||
}); | ||
}, | ||
error: (error) => { | ||
this.setState({ | ||
error, | ||
query, | ||
queryInProgress: !1 | ||
}); | ||
} | ||
next: (res) => this.setState({ | ||
queryTime: res.ms, | ||
e2eTime: Date.now() - queryStart, | ||
queryResult: res.result, | ||
queryInProgress: !1, | ||
error: void 0 | ||
}), | ||
error: (error) => this.setState({ | ||
error, | ||
query, | ||
queryInProgress: !1 | ||
}) | ||
}), !0; | ||
@@ -1210,4 +1174,3 @@ } | ||
datasets, | ||
t, | ||
pinnedPerspective | ||
t | ||
} = this.props, { | ||
@@ -1255,6 +1218,3 @@ apiVersion, | ||
] }) }), | ||
/* @__PURE__ */ jsx(Select, { value: perspective, onChange: this.handleChangePerspective, children: SUPPORTED_PERSPECTIVES.map((perspectiveName) => perspectiveName === "pinnedRelease" ? /* @__PURE__ */ jsxs(Fragment, { children: [ | ||
/* @__PURE__ */ jsx(PinnedReleasePerspectiveOption, { pinnedPerspective, t }, "pinnedRelease"), | ||
/* @__PURE__ */ jsx("hr", {}) | ||
] }) : /* @__PURE__ */ jsx("option", { children: perspectiveName }, perspectiveName)) }) | ||
/* @__PURE__ */ jsx(Select, { value: perspective, onChange: this.handleChangePerspective, children: SUPPORTED_PERSPECTIVES.map((p) => /* @__PURE__ */ jsx("option", { children: p }, p)) }) | ||
] }) }), | ||
@@ -1343,39 +1303,2 @@ typeof url == "string" ? /* @__PURE__ */ jsx(Box, { padding: 1, flex: 1, column: customApiVersion === !1 ? 6 : 4, children: /* @__PURE__ */ jsxs(Stack, { children: [ | ||
} | ||
function getActivePerspective({ | ||
visionPerspective, | ||
pinnedPerspective | ||
}) { | ||
if (visionPerspective !== "pinnedRelease") | ||
return visionPerspective; | ||
if (pinnedPerspective.perspectiveStack.length !== 0) | ||
return pinnedPerspective.perspectiveStack; | ||
if (typeof pinnedPerspective.selectedPerspectiveName < "u") | ||
return [pinnedPerspective.selectedPerspectiveName]; | ||
} | ||
const PinnedReleasePerspectiveOption = (t0) => { | ||
const $ = c(9), { | ||
pinnedPerspective, | ||
t | ||
} = t0, name = typeof pinnedPerspective.selectedPerspective == "object" ? pinnedPerspective.selectedPerspective.metadata.title : pinnedPerspective.selectedPerspectiveName; | ||
let t1; | ||
$[0] !== pinnedPerspective || $[1] !== t ? (t1 = hasPinnedPerspective(pinnedPerspective) ? `(${t("settings.perspectives.pinned-release-label")})` : t("settings.perspectives.pinned-release-label"), $[0] = pinnedPerspective, $[1] = t, $[2] = t1) : t1 = $[2]; | ||
const label = t1; | ||
let t2, t3; | ||
$[3] !== label || $[4] !== name ? (t3 = [name, label].filter(_temp$1), $[3] = label, $[4] = name, $[5] = t3) : t3 = $[5], t2 = t3.join(" "); | ||
const text = t2, t4 = !hasPinnedPerspective(pinnedPerspective); | ||
let t5; | ||
return $[6] !== t4 || $[7] !== text ? (t5 = /* @__PURE__ */ jsx("option", { value: "pinnedRelease", disabled: t4, children: text }), $[6] = t4, $[7] = text, $[8] = t5) : t5 = $[8], t5; | ||
}; | ||
function hasPinnedPerspective({ | ||
selectedPerspectiveName | ||
}) { | ||
return typeof selectedPerspectiveName < "u"; | ||
} | ||
function hasPinnedPerspectiveChanged(previous, next) { | ||
const hasPerspectiveStackChanged = !isEqual(previous.perspectiveStack, next.perspectiveStack); | ||
return previous.selectedPerspectiveName !== next.selectedPerspectiveName || hasPerspectiveStackChanged; | ||
} | ||
function _temp$1(value) { | ||
return typeof value < "u"; | ||
} | ||
function useDatasets(client) { | ||
@@ -1448,3 +1371,3 @@ const $ = c(7); | ||
function SanityVision(props) { | ||
const $ = c(7); | ||
const $ = c(6); | ||
let t0; | ||
@@ -1454,3 +1377,3 @@ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { | ||
}, $[0] = t0) : t0 = $[0]; | ||
const client = useClient(t0), perspective = usePerspective(); | ||
const client = useClient(t0); | ||
let t1; | ||
@@ -1463,3 +1386,3 @@ $[1] !== props.tool.options ? (t1 = { | ||
let t2; | ||
return $[3] !== client || $[4] !== config || $[5] !== perspective ? (t2 = /* @__PURE__ */ jsx(VisionErrorBoundary, { children: /* @__PURE__ */ jsx(VisionContainer, { client, config, pinnedPerspective: perspective }) }), $[3] = client, $[4] = config, $[5] = perspective, $[6] = t2) : t2 = $[6], t2; | ||
return $[3] !== client || $[4] !== config ? (t2 = /* @__PURE__ */ jsx(VisionErrorBoundary, { children: /* @__PURE__ */ jsx(VisionContainer, { client, config }) }), $[3] = client, $[4] = config, $[5] = t2) : t2 = $[5], t2; | ||
} | ||
@@ -1466,0 +1389,0 @@ export { |
@@ -81,4 +81,2 @@ import {ComponentType} from 'react' | ||
readonly 'settings.perspectives.description': 'Perspectives allow your query to run against different "views" of the content in your dataset' | ||
/** Label for the pinned release perspective */ | ||
readonly 'settings.perspectives.pinned-release-label': 'pinned release' | ||
/** Title for popover that explains what "Perspectives" are */ | ||
@@ -85,0 +83,0 @@ readonly 'settings.perspectives.title': 'Perspectives' |
{ | ||
"name": "@sanity/vision", | ||
"version": "3.71.1-corel.541+9cac7ffdfb", | ||
"version": "3.71.1", | ||
"description": "Sanity plugin for running/debugging GROQ-queries against Sanity datasets", | ||
@@ -73,20 +73,19 @@ "keywords": [ | ||
"quick-lru": "^5.1.1", | ||
"react-compiler-runtime": "19.0.0-beta-decd7b8-20250118", | ||
"react-fast-compare": "^3.2.2" | ||
"react-compiler-runtime": "19.0.0-beta-decd7b8-20250118" | ||
}, | ||
"devDependencies": { | ||
"@repo/package.config": "3.71.0", | ||
"@sanity/cli": "3.71.1-corel.541+9cac7ffdfb", | ||
"@repo/package.config": "3.71.1", | ||
"@sanity/cli": "3.71.1", | ||
"@sanity/client": "^6.25.0", | ||
"@sanity/codegen": "3.71.1-corel.541+9cac7ffdfb", | ||
"@sanity/diff": "3.71.1-corel.541+9cac7ffdfb", | ||
"@sanity/migrate": "3.71.1-corel.541+9cac7ffdfb", | ||
"@sanity/mutator": "3.71.1-corel.541+9cac7ffdfb", | ||
"@sanity/schema": "3.71.1-corel.541+9cac7ffdfb", | ||
"@sanity/types": "3.71.1-corel.541+9cac7ffdfb", | ||
"@sanity/util": "3.71.1-corel.541+9cac7ffdfb", | ||
"@sanity/codegen": "3.71.1", | ||
"@sanity/diff": "3.71.1", | ||
"@sanity/migrate": "3.71.1", | ||
"@sanity/mutator": "3.71.1", | ||
"@sanity/schema": "3.71.1", | ||
"@sanity/types": "3.71.1", | ||
"@sanity/util": "3.71.1", | ||
"@types/lodash": "^4.17.7", | ||
"babel-plugin-react-compiler": "19.0.0-beta-decd7b8-20250118", | ||
"react": "^18.3.1", | ||
"sanity": "3.71.1-corel.541+9cac7ffdfb", | ||
"sanity": "3.71.1", | ||
"styled-components": "^6.1.14" | ||
@@ -98,3 +97,3 @@ }, | ||
}, | ||
"gitHead": "9cac7ffdfb1922119c7848bc555e18e4d3df5981" | ||
"gitHead": "a678039922ac8edb8d9567ae276f9f2b5a2cec3d" | ||
} |
@@ -77,4 +77,2 @@ /* eslint sort-keys: "error" */ | ||
'Perspectives allow your query to run against different "views" of the content in your dataset', | ||
/** Label for the pinned release perspective */ | ||
'settings.perspectives.pinned-release-label': 'pinned release', | ||
/** Title for popover that explains what "Perspectives" are */ | ||
@@ -81,0 +79,0 @@ 'settings.perspectives.title': 'Perspectives', |
@@ -0,3 +1,6 @@ | ||
import {type ClientPerspective} from '@sanity/client' | ||
export type SupportedPerspective = 'raw' | 'previewDrafts' | 'published' | 'drafts' | ||
export const SUPPORTED_PERSPECTIVES = [ | ||
'pinnedRelease', | ||
'raw', | ||
@@ -7,31 +10,7 @@ 'previewDrafts', | ||
'drafts', | ||
] as const | ||
] satisfies ClientPerspective[] | ||
export const DEFAULT_PERSPECTIVE = SUPPORTED_PERSPECTIVES[0] | ||
export type SupportedPerspective = (typeof SUPPORTED_PERSPECTIVES)[number] | ||
/** | ||
* Virtual perspectives are recognised by Vision, but do not concretely reflect the names of real | ||
* perspectives. Virtual perspectives are transformed into real perspectives before being used to | ||
* interact with data. | ||
* | ||
* For example, the `pinnedRelease` virtual perspective is transformed to the real perspective | ||
* currently pinned in Studio. | ||
*/ | ||
export const VIRTUAL_PERSPECTIVES = ['pinnedRelease'] as const | ||
export type VirtualPerspective = (typeof VIRTUAL_PERSPECTIVES)[number] | ||
export const DEFAULT_PERSPECTIVE: SupportedPerspective = 'raw' | ||
export function isSupportedPerspective(p: string): p is SupportedPerspective { | ||
return SUPPORTED_PERSPECTIVES.includes(p as SupportedPerspective) | ||
} | ||
export function isVirtualPerspective( | ||
maybeVirtualPerspective: unknown, | ||
): maybeVirtualPerspective is VirtualPerspective { | ||
return ( | ||
typeof maybeVirtualPerspective === 'string' && | ||
VIRTUAL_PERSPECTIVES.includes(maybeVirtualPerspective as VirtualPerspective) | ||
) | ||
} |
import {type SanityClient} from '@sanity/client' | ||
import {type ComponentType} from 'react' | ||
import {type PerspectiveValue} from 'sanity' | ||
@@ -8,3 +7,2 @@ export interface VisionProps { | ||
config: VisionConfig | ||
pinnedPerspective: PerspectiveValue | ||
} | ||
@@ -11,0 +9,0 @@ |
export function encodeQueryString( | ||
query: string, | ||
params: Record<string, unknown> = {}, | ||
options: Record<string, string | string[]> = {}, | ||
options: Record<string, string> = {}, | ||
): string { | ||
@@ -6,0 +6,0 @@ const searchParams = new URLSearchParams() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
23
0
0
664521
6573
- Removedreact-fast-compare@^3.2.2
- Removedreact-fast-compare@3.2.2(transitive)