@sanity/vision
Advanced tools
Comparing version 3.41.2 to 3.41.3-before-pane-break.8
@@ -37,2 +37,6 @@ "use strict"; | ||
"result.label": "Result", | ||
/** Tooltip text shown when the query result is not encodable as CSV */ | ||
"result.save-result-as-csv.not-csv-encodable": "Result cannot be encoded as CSV", | ||
/** Label for "Save result as" result action */ | ||
"result.save-result-as-format": "Save result as <SaveResultButtons/>", | ||
/** | ||
@@ -39,0 +43,0 @@ * "Not applicable" message for when there is no Execution time or End to End time information |
"use strict"; | ||
var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), ui = require("@sanity/ui"), react = require("react"), SplitPane = require("@rexxars/react-split-pane"), icons = require("@sanity/icons"), isHotkeyEsm = require("is-hotkey-esm"), CodeMirror = require("@uiw/react-codemirror"), autocomplete = require("@codemirror/autocomplete"), commands = require("@codemirror/commands"), langJavascript = require("@codemirror/lang-javascript"), language = require("@codemirror/language"), search = require("@codemirror/search"), view = require("@codemirror/view"), highlight = require("@lezer/highlight"), color = require("@sanity/color"), styledComponents = require("styled-components"), resizeObserver = require("@juggle/resize-observer"), JSON5 = require("json5"), debounce = require("lodash/debounce.js"), index = require("./index.js"), JSONInspector = require("@rexxars/react-json-inspector"), LRU = require("quick-lru"); | ||
var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), ui = require("@sanity/ui"), react = require("react"), SplitPane = require("@rexxars/react-split-pane"), icons = require("@sanity/icons"), isHotkeyEsm = require("is-hotkey-esm"), CodeMirror = require("@uiw/react-codemirror"), autocomplete = require("@codemirror/autocomplete"), commands = require("@codemirror/commands"), langJavascript = require("@codemirror/lang-javascript"), language = require("@codemirror/language"), search = require("@codemirror/search"), view = require("@codemirror/view"), highlight = require("@lezer/highlight"), color = require("@sanity/color"), styledComponents = require("styled-components"), json2Csv = require("json-2-csv"), resizeObserver = require("@juggle/resize-observer"), JSON5 = require("json5"), debounce = require("lodash/debounce.js"), index = require("./index.js"), JSONInspector = require("@rexxars/react-json-inspector"), LRU = require("quick-lru"); | ||
function _interopDefaultCompat(e) { | ||
@@ -150,2 +150,23 @@ return e && typeof e == "object" && "default" in e ? e : { default: e }; | ||
} | ||
function getBlobUrl(content, mimeType) { | ||
return URL.createObjectURL( | ||
new Blob([content], { | ||
type: mimeType | ||
}) | ||
); | ||
} | ||
function getMemoizedBlobUrlResolver(mimeType, stringEncoder) { | ||
return /* @__PURE__ */ (() => { | ||
let prevResult = "", prevContent = ""; | ||
return (input) => { | ||
const content = stringEncoder(input); | ||
if (!(typeof content != "string" || content === "")) | ||
return content === prevContent || (prevContent = content, prevResult && URL.revokeObjectURL(prevResult), prevResult = getBlobUrl(content, mimeType)), prevResult; | ||
}; | ||
})(); | ||
} | ||
const getJsonBlobUrl = getMemoizedBlobUrlResolver( | ||
"application/json", | ||
(input) => JSON.stringify(input, null, 2) | ||
), getCsvBlobUrl = getMemoizedBlobUrlResolver("text/csv", (input) => json2Csv.json2csv(Array.isArray(input) ? input : [input]).trim()); | ||
function isPlainObject(obj) { | ||
@@ -501,2 +522,36 @@ return !!obj && typeof obj == "object" && Object.prototype.toString.call(obj) === "[object Object]"; | ||
} | ||
function preventSave(evt) { | ||
return evt.preventDefault(); | ||
} | ||
function SaveCsvButton({ blobUrl }) { | ||
const { t } = sanity.useTranslation(index.visionLocaleNamespace), isDisabled = !blobUrl, button = /* @__PURE__ */ jsxRuntime.jsx( | ||
ui.Button, | ||
{ | ||
as: "a", | ||
disabled: isDisabled, | ||
download: isDisabled ? void 0 : "query-result.csv", | ||
href: blobUrl, | ||
icon: icons.DocumentSheetIcon, | ||
mode: "ghost", | ||
onClick: isDisabled ? preventSave : void 0, | ||
text: "CSV", | ||
tone: "default" | ||
} | ||
); | ||
return isDisabled ? /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: t("result.save-result-as-csv.not-csv-encodable"), placement: "top", children: button }) : button; | ||
} | ||
function SaveJsonButton({ blobUrl }) { | ||
return /* @__PURE__ */ jsxRuntime.jsx( | ||
ui.Button, | ||
{ | ||
as: "a", | ||
download: "query-result.json", | ||
href: blobUrl, | ||
icon: icons.DocumentSheetIcon, | ||
mode: "ghost", | ||
text: "JSON", | ||
tone: "default" | ||
} | ||
); | ||
} | ||
const Root = styledComponents.styled(ui.Flex)` | ||
@@ -602,3 +657,3 @@ .sidebarPanes .Pane { | ||
z-index: 20; | ||
`, TimingsFooter = styledComponents.styled(ui.Box)` | ||
`, ResultFooter = styledComponents.styled(ui.Flex)` | ||
border-top: 1px solid var(--card-border-color); | ||
@@ -617,2 +672,15 @@ `, TimingsCard = styledComponents.styled(ui.Card)` | ||
)}; | ||
`, DownloadsCard = styledComponents.styled(ui.Card)` | ||
position: relative; | ||
`, SaveResultLabel = styledComponents.styled(ui.Text)` | ||
transform: initial; | ||
&:before, | ||
&:after { | ||
content: none; | ||
} | ||
> span { | ||
display: flex !important; | ||
gap: ${({ theme }) => ui.rem(theme.sanity.space[3])}; | ||
align-items: center; | ||
} | ||
`, ControlsContainer = styledComponents.styled(ui.Box)` | ||
@@ -931,3 +999,3 @@ border-top: 1px solid var(--card-border-color); | ||
url | ||
} = this.state, hasResult = !error && !queryInProgress && typeof queryResult < "u"; | ||
} = this.state, hasResult = !error && !queryInProgress && typeof queryResult < "u", jsonUrl = hasResult ? getJsonBlobUrl(queryResult) : "", csvUrl = hasResult ? getCsvBlobUrl(queryResult) : ""; | ||
return /* @__PURE__ */ jsxRuntime.jsxs( | ||
@@ -1105,16 +1173,31 @@ Root, | ||
) }), | ||
/* @__PURE__ */ jsxRuntime.jsx(TimingsFooter, { children: /* @__PURE__ */ jsxRuntime.jsx(TimingsCard, { paddingX: 4, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsxRuntime.jsxs(TimingsTextContainer, { align: "center", children: [ | ||
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, children: [ | ||
t("result.execution-time-label"), | ||
":", | ||
" ", | ||
typeof queryTime == "number" ? `${queryTime}ms` : t("result.timing-not-applicable") | ||
/* @__PURE__ */ jsxRuntime.jsxs(ResultFooter, { justify: "space-between", direction: ["column", "column", "row"], children: [ | ||
/* @__PURE__ */ jsxRuntime.jsx(TimingsCard, { paddingX: 4, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsxRuntime.jsxs(TimingsTextContainer, { align: "center", children: [ | ||
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, children: [ | ||
t("result.execution-time-label"), | ||
":", | ||
" ", | ||
typeof queryTime == "number" ? `${queryTime}ms` : t("result.timing-not-applicable") | ||
] }) }), | ||
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginLeft: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, children: [ | ||
t("result.end-to-end-time-label"), | ||
":", | ||
" ", | ||
typeof e2eTime == "number" ? `${e2eTime}ms` : t("result.timing-not-applicable") | ||
] }) }) | ||
] }) }), | ||
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginLeft: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, children: [ | ||
t("result.end-to-end-time-label"), | ||
":", | ||
" ", | ||
typeof e2eTime == "number" ? `${e2eTime}ms` : t("result.timing-not-applicable") | ||
] }) }) | ||
] }) }) }) | ||
hasResult && /* @__PURE__ */ jsxRuntime.jsx(DownloadsCard, { paddingX: 4, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsxRuntime.jsx(SaveResultLabel, { muted: !0, children: /* @__PURE__ */ jsxRuntime.jsx( | ||
sanity.Translate, | ||
{ | ||
components: { | ||
SaveResultButtons: () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ | ||
/* @__PURE__ */ jsxRuntime.jsx(SaveJsonButton, { blobUrl: jsonUrl }), | ||
/* @__PURE__ */ jsxRuntime.jsx(SaveCsvButton, { blobUrl: csvUrl }) | ||
] }) | ||
}, | ||
i18nKey: "result.save-result-as-format", | ||
t | ||
} | ||
) }) }) | ||
] }) | ||
] }) | ||
@@ -1121,0 +1204,0 @@ ] |
@@ -36,2 +36,6 @@ import { defineLocalesResources } from "sanity"; | ||
"result.label": "Result", | ||
/** Tooltip text shown when the query result is not encodable as CSV */ | ||
"result.save-result-as-csv.not-csv-encodable": "Result cannot be encoded as CSV", | ||
/** Label for "Save result as" result action */ | ||
"result.save-result-as-format": "Save result as <SaveResultButtons/>", | ||
/** | ||
@@ -38,0 +42,0 @@ * "Not applicable" message for when there is no Execution time or End to End time information |
@@ -1,7 +0,7 @@ | ||
import { jsx, jsxs } from "react/jsx-runtime"; | ||
import { useTranslation, useClient } from "sanity"; | ||
import { Spinner, rem, useTheme, Box, useClickOutside, Popover, Stack, Inline, Text, Badge, Card, Button, Code, Flex, Label, Grid, Select, TextInput, Tooltip, Hotkeys, useToast, Container, Heading } from "@sanity/ui"; | ||
import { jsx, jsxs, Fragment } from "react/jsx-runtime"; | ||
import { useTranslation, Translate, useClient } from "sanity"; | ||
import { Spinner, rem, useTheme, Box, useClickOutside, Popover, Stack, Inline, Text, Badge, Card, Button, Code, Tooltip, Flex, Label, Grid, Select, TextInput, Hotkeys, useToast, Container, Heading } from "@sanity/ui"; | ||
import { useState, useEffect, useMemo, useCallback, PureComponent, createRef, Component } from "react"; | ||
import SplitPane from "@rexxars/react-split-pane"; | ||
import { HelpCircleIcon, CopyIcon, ErrorOutlineIcon, StopIcon, PlayIcon } from "@sanity/icons"; | ||
import { HelpCircleIcon, DocumentSheetIcon, CopyIcon, ErrorOutlineIcon, StopIcon, PlayIcon } from "@sanity/icons"; | ||
import { isHotkey } from "is-hotkey-esm"; | ||
@@ -18,2 +18,3 @@ import CodeMirror from "@uiw/react-codemirror"; | ||
import { styled, css } from "styled-components"; | ||
import { json2csv } from "json-2-csv"; | ||
import { ResizeObserver } from "@juggle/resize-observer"; | ||
@@ -168,2 +169,23 @@ import JSON5 from "json5"; | ||
} | ||
function getBlobUrl(content, mimeType) { | ||
return URL.createObjectURL( | ||
new Blob([content], { | ||
type: mimeType | ||
}) | ||
); | ||
} | ||
function getMemoizedBlobUrlResolver(mimeType, stringEncoder) { | ||
return /* @__PURE__ */ (() => { | ||
let prevResult = "", prevContent = ""; | ||
return (input) => { | ||
const content = stringEncoder(input); | ||
if (!(typeof content != "string" || content === "")) | ||
return content === prevContent || (prevContent = content, prevResult && URL.revokeObjectURL(prevResult), prevResult = getBlobUrl(content, mimeType)), prevResult; | ||
}; | ||
})(); | ||
} | ||
const getJsonBlobUrl = getMemoizedBlobUrlResolver( | ||
"application/json", | ||
(input) => JSON.stringify(input, null, 2) | ||
), getCsvBlobUrl = getMemoizedBlobUrlResolver("text/csv", (input) => json2csv(Array.isArray(input) ? input : [input]).trim()); | ||
function isPlainObject(obj) { | ||
@@ -519,2 +541,36 @@ return !!obj && typeof obj == "object" && Object.prototype.toString.call(obj) === "[object Object]"; | ||
} | ||
function preventSave(evt) { | ||
return evt.preventDefault(); | ||
} | ||
function SaveCsvButton({ blobUrl }) { | ||
const { t } = useTranslation(visionLocaleNamespace), isDisabled = !blobUrl, button = /* @__PURE__ */ jsx( | ||
Button, | ||
{ | ||
as: "a", | ||
disabled: isDisabled, | ||
download: isDisabled ? void 0 : "query-result.csv", | ||
href: blobUrl, | ||
icon: DocumentSheetIcon, | ||
mode: "ghost", | ||
onClick: isDisabled ? preventSave : void 0, | ||
text: "CSV", | ||
tone: "default" | ||
} | ||
); | ||
return isDisabled ? /* @__PURE__ */ jsx(Tooltip, { content: t("result.save-result-as-csv.not-csv-encodable"), placement: "top", children: button }) : button; | ||
} | ||
function SaveJsonButton({ blobUrl }) { | ||
return /* @__PURE__ */ jsx( | ||
Button, | ||
{ | ||
as: "a", | ||
download: "query-result.json", | ||
href: blobUrl, | ||
icon: DocumentSheetIcon, | ||
mode: "ghost", | ||
text: "JSON", | ||
tone: "default" | ||
} | ||
); | ||
} | ||
const Root = styled(Flex)` | ||
@@ -620,3 +676,3 @@ .sidebarPanes .Pane { | ||
z-index: 20; | ||
`, TimingsFooter = styled(Box)` | ||
`, ResultFooter = styled(Flex)` | ||
border-top: 1px solid var(--card-border-color); | ||
@@ -635,2 +691,15 @@ `, TimingsCard = styled(Card)` | ||
)}; | ||
`, DownloadsCard = styled(Card)` | ||
position: relative; | ||
`, SaveResultLabel = styled(Text)` | ||
transform: initial; | ||
&:before, | ||
&:after { | ||
content: none; | ||
} | ||
> span { | ||
display: flex !important; | ||
gap: ${({ theme }) => rem(theme.sanity.space[3])}; | ||
align-items: center; | ||
} | ||
`, ControlsContainer = styled(Box)` | ||
@@ -949,3 +1018,3 @@ border-top: 1px solid var(--card-border-color); | ||
url | ||
} = this.state, hasResult = !error && !queryInProgress && typeof queryResult < "u"; | ||
} = this.state, hasResult = !error && !queryInProgress && typeof queryResult < "u", jsonUrl = hasResult ? getJsonBlobUrl(queryResult) : "", csvUrl = hasResult ? getCsvBlobUrl(queryResult) : ""; | ||
return /* @__PURE__ */ jsxs( | ||
@@ -1123,16 +1192,31 @@ Root, | ||
) }), | ||
/* @__PURE__ */ jsx(TimingsFooter, { children: /* @__PURE__ */ jsx(TimingsCard, { paddingX: 4, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsxs(TimingsTextContainer, { align: "center", children: [ | ||
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, { muted: !0, children: [ | ||
t("result.execution-time-label"), | ||
":", | ||
" ", | ||
typeof queryTime == "number" ? `${queryTime}ms` : t("result.timing-not-applicable") | ||
/* @__PURE__ */ jsxs(ResultFooter, { justify: "space-between", direction: ["column", "column", "row"], children: [ | ||
/* @__PURE__ */ jsx(TimingsCard, { paddingX: 4, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsxs(TimingsTextContainer, { align: "center", children: [ | ||
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, { muted: !0, children: [ | ||
t("result.execution-time-label"), | ||
":", | ||
" ", | ||
typeof queryTime == "number" ? `${queryTime}ms` : t("result.timing-not-applicable") | ||
] }) }), | ||
/* @__PURE__ */ jsx(Box, { marginLeft: 4, children: /* @__PURE__ */ jsxs(Text, { muted: !0, children: [ | ||
t("result.end-to-end-time-label"), | ||
":", | ||
" ", | ||
typeof e2eTime == "number" ? `${e2eTime}ms` : t("result.timing-not-applicable") | ||
] }) }) | ||
] }) }), | ||
/* @__PURE__ */ jsx(Box, { marginLeft: 4, children: /* @__PURE__ */ jsxs(Text, { muted: !0, children: [ | ||
t("result.end-to-end-time-label"), | ||
":", | ||
" ", | ||
typeof e2eTime == "number" ? `${e2eTime}ms` : t("result.timing-not-applicable") | ||
] }) }) | ||
] }) }) }) | ||
hasResult && /* @__PURE__ */ jsx(DownloadsCard, { paddingX: 4, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsx(SaveResultLabel, { muted: !0, children: /* @__PURE__ */ jsx( | ||
Translate, | ||
{ | ||
components: { | ||
SaveResultButtons: () => /* @__PURE__ */ jsxs(Fragment, { children: [ | ||
/* @__PURE__ */ jsx(SaveJsonButton, { blobUrl: jsonUrl }), | ||
/* @__PURE__ */ jsx(SaveCsvButton, { blobUrl: csvUrl }) | ||
] }) | ||
}, | ||
i18nKey: "result.save-result-as-format", | ||
t | ||
} | ||
) }) }) | ||
] }) | ||
] }) | ||
@@ -1139,0 +1223,0 @@ ] |
@@ -53,2 +53,6 @@ import {ComponentType} from 'react' | ||
readonly 'result.label': 'Result' | ||
/** Tooltip text shown when the query result is not encodable as CSV */ | ||
readonly 'result.save-result-as-csv.not-csv-encodable': 'Result cannot be encoded as CSV' | ||
/** Label for "Save result as" result action */ | ||
readonly 'result.save-result-as-format': 'Save result as <SaveResultButtons/>' | ||
/** | ||
@@ -55,0 +59,0 @@ * "Not applicable" message for when there is no Execution time or End to End time information |
{ | ||
"name": "@sanity/vision", | ||
"version": "3.41.2", | ||
"version": "3.41.3-before-pane-break.8+516ada5d23", | ||
"description": "Sanity plugin for running/debugging GROQ-queries against Sanity datasets", | ||
@@ -69,2 +69,3 @@ "keywords": [ | ||
"is-hotkey-esm": "^1.0.0", | ||
"json-2-csv": "^5.5.1", | ||
"json5": "^2.2.3", | ||
@@ -76,16 +77,16 @@ "lodash": "^4.17.21", | ||
"@repo/package.config": "3.41.2", | ||
"@sanity/block-tools": "3.41.2", | ||
"@sanity/cli": "3.41.2", | ||
"@sanity/client": "^6.17.2", | ||
"@sanity/codegen": "3.41.2", | ||
"@sanity/diff": "3.41.2", | ||
"@sanity/migrate": "3.41.2", | ||
"@sanity/mutator": "3.41.2", | ||
"@sanity/portable-text-editor": "3.41.2", | ||
"@sanity/schema": "3.41.2", | ||
"@sanity/types": "3.41.2", | ||
"@sanity/util": "3.41.2", | ||
"@sanity/block-tools": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@sanity/cli": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@sanity/client": "^6.18.0", | ||
"@sanity/codegen": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@sanity/diff": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@sanity/migrate": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@sanity/mutator": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@sanity/portable-text-editor": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@sanity/schema": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@sanity/types": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@sanity/util": "3.41.3-before-pane-break.8+516ada5d23", | ||
"@types/lodash": "^4.14.149", | ||
"react": "^18.3.1", | ||
"sanity": "3.41.2", | ||
"sanity": "3.41.3-before-pane-break.8+516ada5d23", | ||
"styled-components": "^6.1.10" | ||
@@ -97,3 +98,3 @@ }, | ||
}, | ||
"gitHead": "db06da9b58e954210de6f6f7379d883055fc9c96" | ||
"gitHead": "516ada5d2362ba57a200e359d0d19c610cb3fa6a" | ||
} |
@@ -47,2 +47,6 @@ /* eslint sort-keys: "error" */ | ||
'result.label': 'Result', | ||
/** Tooltip text shown when the query result is not encodable as CSV */ | ||
'result.save-result-as-csv.not-csv-encodable': 'Result cannot be encoded as CSV', | ||
/** Label for "Save result as" result action */ | ||
'result.save-result-as-format': 'Save result as <SaveResultButtons/>', | ||
/** | ||
@@ -49,0 +53,0 @@ * "Not applicable" message for when there is no Execution time or End to End time information |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
598725
66
6276
61
22
1
1
25
2
+ Addedjson-2-csv@^5.5.1
+ Addeddeeks@3.1.0(transitive)
+ Addeddoc-path@4.1.1(transitive)
+ Addedjson-2-csv@5.5.6(transitive)