sanity-plugin-visual-editor 1.0.0 → 1.1.0
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/LICENSE +1 -1
- package/README.md +137 -16
- package/TESTING.md +133 -0
- package/dist/PreviewBar-D_rw0bhP.js +3503 -0
- package/dist/PreviewBar-D_rw0bhP.js.map +1 -0
- package/dist/bar.d.ts +22 -0
- package/dist/bar.js +67 -0
- package/dist/bar.js.map +1 -0
- package/dist/cloudflare.d.ts +76 -0
- package/dist/cloudflare.js +1071 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/data-D0qotTtt.d.ts +177 -0
- package/dist/host-DreYJEmR.js +615 -0
- package/dist/host-DreYJEmR.js.map +1 -0
- package/dist/host.d.ts +160 -0
- package/dist/host.js +3 -0
- package/dist/index-4Zm_NjhC.d.ts +221 -0
- package/dist/index.d.ts +18 -18
- package/dist/index.js +7 -8
- package/dist/link-search-JtZkxz4k.js +14 -0
- package/dist/link-search-JtZkxz4k.js.map +1 -0
- package/dist/link-session-Dr4YkKFy.js +52 -0
- package/dist/link-session-Dr4YkKFy.js.map +1 -0
- package/dist/next-client.d.ts +15 -0
- package/dist/next-client.js +78 -0
- package/dist/next-client.js.map +1 -0
- package/dist/next.d.ts +38 -0
- package/dist/next.js +117 -0
- package/dist/next.js.map +1 -0
- package/dist/node-labels-CDiW5rMq.js +122 -0
- package/dist/node-labels-CDiW5rMq.js.map +1 -0
- package/dist/page-documents-BFFcH8lD.d.ts +54 -0
- package/dist/page-documents-mGfw_flR.js +67 -0
- package/dist/page-documents-mGfw_flR.js.map +1 -0
- package/dist/perspective-BmS9TVtr.js +106 -0
- package/dist/perspective-BmS9TVtr.js.map +1 -0
- package/dist/preview-links-BZDZyIey.js +119 -0
- package/dist/preview-links-BZDZyIey.js.map +1 -0
- package/dist/preview-links-DM6BCiLV.d.ts +87 -0
- package/dist/protocol-BNO38gYy.js +280 -0
- package/dist/protocol-BNO38gYy.js.map +1 -0
- package/dist/protocol-BnRCy2wJ.d.ts +386 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +495 -0
- package/dist/server.js.map +1 -0
- package/dist/shell-DZotxRXX.d.ts +37 -0
- package/dist/studio.d.ts +93 -0
- package/dist/studio.js +1263 -0
- package/dist/studio.js.map +1 -0
- package/dist/sveltekit.d.ts +281 -0
- package/dist/sveltekit.js +395 -0
- package/dist/sveltekit.js.map +1 -0
- package/package.json +120 -39
- package/dist/index.d.mts +0 -21
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -8
- package/dist/index.mjs.map +0 -1
- package/sanity.json +0 -8
- package/src/index.ts +0 -27
- package/v2-incompatible.js +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-BNO38gYy.js","names":[],"sources":["../src/core/paths.ts","../src/core/sanity-node.ts","../src/core/protocol.ts"],"sourcesContent":["/**\n * Same-origin path checks, shared by everything that turns an untrusted string into a page on this\n * site: short links, `postMessage` paths and the Visual Editor's `?preview=` parameter.\n */\n\n// eslint-disable-next-line no-control-regex\nconst CONTROL_CHARACTERS = /[\\u0000-\\u001f\\u007f]/\nconst BASE = 'https://same-origin.invalid'\n\n/**\n * `value` as a root-relative path on this site (pathname, query and hash, normalized), or `null`.\n *\n * Checks the input and the result: browsers read `\\` as `/` and drop tabs and newlines, and\n * resolving dot segments can turn `/.//host` or `/%2e%2e//host` into `//host`, which is another\n * site once it lands in a `Location` header or `new URL(path, origin)`. A path whose first segment\n * starts with an encoded slash or backslash (`/%2f…`, `/%5c…`) is refused too, since a server that\n * decodes it before redirecting would do the same.\n */\nexport function sameOriginPath(value: unknown): string | null {\n if (typeof value !== 'string' || !value.startsWith('/')) return null\n if (value.startsWith('//') || value.includes('\\\\') || CONTROL_CHARACTERS.test(value)) return null\n let url: URL\n try {\n url = new URL(value, BASE)\n } catch {\n return null\n }\n if (url.origin !== BASE) return null\n const {pathname} = url\n if (\n !pathname.startsWith('/') ||\n pathname.startsWith('//') ||\n pathname.includes('\\\\') ||\n /^\\/%(2f|5c)/i.test(pathname)\n ) {\n return null\n }\n return `${pathname}${url.search}${url.hash}`\n}\n\n/** Whether `value` is a root-relative path that stays on this site; see `sameOriginPath`. */\nexport function isSameOriginPath(value: unknown): value is string {\n return sameOriginPath(value) !== null\n}\n","/**\n * The `data-sanity` attribute that marks an element as editable, and its path, without\n * dependencies. Storefronts write it with `createDataAttribute({id, type, path})` or by hand:\n *\n * data-sanity=\"id=page-home;type=page;path=sections:k1.heading\"\n *\n * `base=` and `workspace=` may follow; they're read but unused. `path` is Sanity's URL path form:\n * `.` between segments, `field:key` for a keyed array item, and `field:3` (up to 9 digits) for an\n * index, so `sections:k1.heading` is `sections[_key==\"k1\"].heading`.\n */\n\nexport const SANITY_NODE_ATTRIBUTE = 'data-sanity'\n\n/** An editable element's document and path (URL form, as written in the attribute). */\nexport type SanityNode = {\n id: string\n type: string\n path: string\n base?: string\n workspace?: string\n}\n\n/** A Studio path: field names, keyed array items and indexes. */\nexport type StudioPathSegment = string | number | {_key: string}\nexport type StudioPath = StudioPathSegment[]\n\n/** Longest path the edit message carries. */\nexport const MAX_EDIT_PATH_LENGTH = 1000\n\nconst INDEX = /^\\d{1,9}$/\n\nfunction decode(value: string) {\n try {\n return decodeURIComponent(value)\n } catch {\n return null\n }\n}\n\n/**\n * Reads a `data-sanity` value: pairs split on `;`, each on its first `=`, values URI-decoded.\n * Returns `null` unless `id`, `type` and `path` are all present and non-empty.\n */\nexport function parseSanityNode(value: string | null | undefined): SanityNode | null {\n if (!value) return null\n const fields: Record<string, string> = {}\n for (const pair of value.split(';')) {\n const separator = pair.indexOf('=')\n if (separator < 0) continue\n const key = pair.slice(0, separator).trim()\n const decoded = decode(pair.slice(separator + 1))\n if (!key || decoded === null) continue\n fields[key] = decoded\n }\n const {id, type, path, base, workspace} = fields\n if (!id || !type || !path || path.length > MAX_EDIT_PATH_LENGTH) return null\n const node: SanityNode = {id, type, path}\n if (base) node.base = base\n if (workspace) node.workspace = workspace\n return node\n}\n\n/**\n * Sanity's URL path form to a Studio path: `sections:k1.heading` →\n * `['sections', {_key: 'k1'}, 'heading']`, `items:3` → `['items', 3]`. Chained items\n * (`rows:r1:c2`) are nested arrays. Returns `null` for an empty or malformed path.\n */\nexport function toStudioPath(urlPath: string): StudioPath | null {\n if (!urlPath) return null\n const path: StudioPath = []\n for (const segment of urlPath.split('.')) {\n const [field, ...items] = segment.split(':')\n if (!field) return null\n path.push(field)\n for (const item of items) {\n if (!item) return null\n path.push(INDEX.test(item) ? Number(item) : {_key: item})\n }\n }\n return path\n}\n\n/**\n * A Studio path as the document pane's `path` param reads it (`@sanity/util/paths` `toString`):\n * `sections[_key==\"k1\"].heading`, `items[3]`.\n */\nexport function studioPathToString(path: StudioPath): string {\n let result = ''\n for (const segment of path) {\n if (typeof segment === 'string') result += result ? `.${segment}` : segment\n else if (typeof segment === 'number') result += `[${segment}]`\n else result += `[_key==\"${segment._key}\"]`\n }\n return result\n}\n\n/** The pane param for a URL-form path, or `null` when it doesn't parse. */\nexport function toPanePath(urlPath: string): string | null {\n const path = toStudioPath(urlPath)\n return path ? studioPathToString(path) : null\n}\n\n/** `heroImage` → `Hero image`, `section_title` → `Section title`. */\nexport function humanizeFieldName(name: string): string {\n const words = name\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .split(/[\\s_-]+/)\n .filter(Boolean)\n if (!words.length) return name\n return words\n .map((word, index) => {\n // Acronyms (`SEO`, `CTA`) keep their case.\n if (word.length > 1 && word === word.toUpperCase()) return word\n const lower = word.toLowerCase()\n return index === 0 ? lower.charAt(0).toUpperCase() + lower.slice(1) : lower\n })\n .join(' ')\n}\n\n/**\n * A label for a path's last segment: the field's name, humanized (`sections:k1.heading` →\n * `Heading`), or `Sections item` when it ends in an array item.\n */\nexport function describeSanityPath(urlPath: string): string {\n const path = toStudioPath(urlPath)\n if (!path?.length) return urlPath\n const last = path[path.length - 1]!\n if (typeof last === 'string') return humanizeFieldName(last)\n for (let index = path.length - 1; index >= 0; index--) {\n const segment = path[index]\n if (typeof segment === 'string') return `${humanizeFieldName(segment)} item`\n }\n return urlPath\n}\n\n/** A document's published ID (`drafts.` and `versions.<release>.` prefixes removed). */\nexport function publishedDocumentId(id: string): string {\n return id.replace(/^drafts\\./, '').replace(/^versions\\.[^.]+\\./, '')\n}\n\n/** A Studio path in Sanity's URL form: `['sections', {_key: 'k1'}, 'heading']` → `sections:k1.heading`. */\nexport function toUrlPath(path: readonly StudioPathSegment[]): string {\n let result = ''\n for (const segment of path) {\n if (typeof segment === 'string') result += result ? `.${segment}` : segment\n else result += `:${typeof segment === 'number' ? segment : segment._key}`\n }\n return result\n}\n\nexport type SanityAttrDocument =\n | {_id?: string | null; _type?: string | null}\n | {id?: string | null; type?: string | null}\n | null\n | undefined\n\nexport type SanityAttrPath = string | readonly StudioPathSegment[]\n\nexport type SanityAttrOptions = {\n /** Only emit `data-sanity` when true (e.g. `data.preview`). Default `true`. */\n enabled?: boolean\n base?: string\n workspace?: string\n}\n\nexport type SanityDataAttribute = {readonly 'data-sanity'?: string}\n\n/** Formats a `SanityNode` into a `data-sanity` attribute value (`id=...;type=...;path=...`). */\nexport function encodeSanityNode(node: SanityNode): string {\n const parts = [\n `id=${encodeURIComponent(publishedDocumentId(node.id))}`,\n `type=${encodeURIComponent(node.type)}`,\n `path=${encodeURIComponent(node.path)}`,\n ]\n if (node.base) parts.push(`base=${encodeURIComponent(node.base)}`)\n if (node.workspace) parts.push(`workspace=${encodeURIComponent(node.workspace)}`)\n return parts.join(';')\n}\n\n/**\n * Returns `{ 'data-sanity': '...' }` for click-to-edit overlays, or `{}` when `enabled` is `false`\n * or `doc`/`path` is incomplete. Spread directly onto any Svelte or JSX element:\n *\n * <h1 {...sanityAttr(page, 'heading', { enabled: preview })}>\n * <section {...sanityAttr(page, ['sections', { _key: section._key }, 'title'])}>\n */\nexport function sanityAttr(\n doc: SanityAttrDocument,\n path: SanityAttrPath,\n options?: SanityAttrOptions,\n): SanityDataAttribute {\n if (options?.enabled === false || !doc) return {}\n const id = '_id' in doc ? doc._id : 'id' in doc ? doc.id : undefined\n const type = '_type' in doc ? doc._type : 'type' in doc ? doc.type : undefined\n const urlPath = typeof path === 'string' ? path : toUrlPath(path)\n if (!id || !type || !urlPath || urlPath.length > MAX_EDIT_PATH_LENGTH) return {}\n return {\n [SANITY_NODE_ATTRIBUTE]: encodeSanityNode({\n id,\n type,\n path: urlPath,\n ...(options?.base ? {base: options.base} : {}),\n ...(options?.workspace ? {workspace: options.workspace} : {}),\n }),\n }\n}\n\n/**\n * Scoped `sanityAttr` bound to one document and option set:\n *\n * const attr = createSanityAttr(page, { enabled: preview })\n * <h1 {...attr('heading')}>\n */\nexport function createSanityAttr(\n doc: SanityAttrDocument,\n options?: SanityAttrOptions,\n): (path: SanityAttrPath) => SanityDataAttribute {\n return (path) => sanityAttr(doc, path, options)\n}\n\nfunction sameSegment(a: StudioPathSegment, b: StudioPathSegment) {\n if (typeof a === 'string' || typeof a === 'number') return a === b\n return typeof b === 'object' && a._key === b._key\n}\n\n/**\n * The nodes that show a focused field: those of the same document whose path is the longest\n * prefix of the focused path (the field itself, or the nearest annotated element around it).\n * A field can render more than once (a desktop and a mobile variant), so all of them match.\n */\nexport function matchFocusedNodes<T extends {node: SanityNode}>(\n items: readonly T[],\n focus: {id: string; path: string},\n): T[] {\n const focused = toStudioPath(focus.path)\n if (!focused) return []\n const id = publishedDocumentId(focus.id)\n let best = 0\n let matches: T[] = []\n for (const item of items) {\n if (publishedDocumentId(item.node.id) !== id) continue\n const path = toStudioPath(item.node.path)\n if (!path || path.length > focused.length || path.length < best) continue\n if (!path.every((segment, index) => sameSegment(segment, focused[index]!))) continue\n if (path.length > best) {\n best = path.length\n matches = []\n }\n matches.push(item)\n }\n return matches\n}\n","/**\n * The site's host (`sanity-plugin-visual-editor/host`) frames the bar's route, which renders the React bar\n * (`sanity-plugin-visual-editor/bar`) with `@sanity/ui`. Only this protocol is shared, so the site never\n * imports React or Sanity UI. Both sides post to, and accept from, this origin and their\n * counterpart window only.\n */\nimport type {NodeLabel} from './node-labels'\nimport {isSameOriginPath} from './paths'\nimport {MAX_EDIT_PATH_LENGTH, type SanityNode} from './sanity-node'\n\n/** Most nodes one `describe` or `labels` message carries. */\nexport const MAX_DESCRIBE_NODES = 500\n\n/** Default route for the framed bar; its endpoints live under it (`/__visual-editor/resolve`, …). */\nexport const PREVIEW_BAR_ROUTE = '/__visual-editor'\n\n/**\n * Query parameter on storefront URLs loaded as Studio thumbnails: suppresses preview mode,\n * overlays, and storefront analytics so editors see published content cleanly.\n */\nexport const STUDIO_PREVIEW_PARAM = 'studio-preview'\n\n/** Visible height of the bar in CSS pixels; the host reserves this much at the bottom of the page. */\nexport const PREVIEW_BAR_HEIGHT = 50\n\n/**\n * With the document pane open, the page (and the bar) keep at least this many CSS pixels beside\n * it. On a narrower viewport the pane overlays the page instead, above a full-width bar.\n */\nexport const PREVIEW_PANEL_MIN_PAGE_WIDTH = 360\n\n/** Which edge of the viewport the document pane sits on. */\nexport type PaneSide = 'left' | 'right'\n\n/** Which edge of the viewport the bar sits on. */\nexport type PreviewBarPosition = 'top' | 'bottom'\n\n/**\n * The host tells the framed bar its position in the frame's URL (`/__visual-editor?position=top`), so\n * the bar renders in place from its first frame.\n */\nexport const PREVIEW_BAR_POSITION_PARAM = 'position'\n\nexport function readPreviewBarPosition(search: string): PreviewBarPosition {\n return new URLSearchParams(search).get(PREVIEW_BAR_POSITION_PARAM) === 'top' ? 'top' : 'bottom'\n}\n\n/**\n * Where the bar is framed: on the site (by `sanity-plugin-visual-editor/host`) or in the Studio's Visual\n * Editor tool (`sanity-plugin-visual-editor/studio`), which passes `?context=tool` in the frame's URL.\n */\nexport type PreviewBarContext = 'site' | 'tool'\n\nexport const PREVIEW_BAR_CONTEXT_PARAM = 'context'\n\nexport function readPreviewBarContext(search: string): PreviewBarContext {\n return new URLSearchParams(search).get(PREVIEW_BAR_CONTEXT_PARAM) === 'tool' ? 'tool' : 'site'\n}\n\n/**\n * The Visual Editor tool frames the site under this window name. It survives navigation inside\n * the frame, so the site can tell it's in the tool (not another embed) on every page.\n */\nexport const PREVIEW_BAR_FRAME_NAME = 'sanity-plugin-visual-editor-frame'\n\n/**\n * Whether this window is the site framed by the Visual Editor tool, where the page reads like a\n * normal preview tab and mounts `mountPreviewBarFrame` instead of the host.\n */\nexport function isPreviewBarFrame() {\n return (\n typeof window !== 'undefined' &&\n window.self !== window.top &&\n window.name === PREVIEW_BAR_FRAME_NAME\n )\n}\n\n/** The Visual Editor's viewport sizes. */\nexport type PreviewBarViewport = 'desktop' | 'tablet' | 'mobile'\n\n/** A document to open in the Visual Editor's pane; a new one carries its template. */\nexport type PreviewBarDocument = {\n id: string\n type: string\n template?: string\n templateParameters?: Record<string, unknown>\n}\n\n/** The bar's perspective as a menu selection: the chosen layer and the hidden ones. */\nexport type PreviewBarSelection = {selected: string; excluded: string[]}\n\nexport type PreviewBarMessage =\n /** Bar → host, once mounted: asks for the current storefront path. */\n | {type: 'sanity-visual-editor:ready'}\n /** Bar → host: hide the bar until the next full page load (preview mode stays on). */\n | {type: 'sanity-visual-editor:hide'}\n /** Bar → host: the perspective menu opened or closed; the host grows the frame so it fits. */\n | {type: 'sanity-visual-editor:menu'; open: boolean}\n /** Bar → host: the perspective cookie changed; rerun every query and load in place. */\n | {type: 'sanity-visual-editor:refresh'}\n /** Host → bar: the storefront finished refreshing after `refresh`. */\n | {type: 'sanity-visual-editor:refreshed'}\n /** Host → bar: the storefront path and query, sent on `ready` and after every navigation. */\n | {type: 'sanity-visual-editor:path'; path: string}\n /** Host → bar: ⌘K / Ctrl+K was pressed on the storefront page; open search. */\n | {type: 'sanity-visual-editor:search'}\n /** Host → bar: `E` was pressed on the storefront page (not while typing); toggle the pane. */\n | {type: 'sanity-visual-editor:pane'}\n /** Bar → host: a search result was chosen; navigate the storefront there (client-side). */\n | {type: 'sanity-visual-editor:navigate'; href: string}\n /** Bar → Visual Editor tool: open this document in the tool's pane (Edit, Create new document). */\n | {type: 'sanity-visual-editor:open-document'; document: PreviewBarDocument}\n /**\n * Visual Editor tool → bar: the tool's pane opened or closed (Edit hides while it's open), and\n * whether the page has a document to edit (Edit shows only then).\n */\n | {\n type: 'sanity-visual-editor:editor-state'\n open: boolean\n available?: boolean\n /**\n * The tool is too narrow for the pane beside the page: one shows at a time, and Edit stays,\n * pressed while the document shows, and toggles between them (`close-editor` goes back).\n */\n toggle?: boolean\n }\n /** Visual Editor tool → bar: the current page's document (the page picker previews it), if any. */\n | {type: 'sanity-visual-editor:page-document'; document: {id: string; type: string} | null}\n /** Bar → Visual Editor tool: Edit was clicked; open the page's document in the pane. */\n | {type: 'sanity-visual-editor:open-editor'}\n /** Bar → Visual Editor tool: Edit was clicked again (narrow, `toggle`); show the page. */\n | {type: 'sanity-visual-editor:close-editor'}\n /** Bar → Visual Editor tool: show the site at desktop width, as a 768px tablet or a 375px phone. */\n | {type: 'sanity-visual-editor:viewport'; mode: PreviewBarViewport}\n /** Bar → Visual Editor tool: the bar's perspective changed; the Studio follows it. */\n | {type: 'sanity-visual-editor:perspective'; selection: PreviewBarSelection}\n /** Visual Editor tool → bar: the Studio's perspective changed (pane chips, navbar); switch to it. */\n | {type: 'sanity-visual-editor:set-perspective'; selection: PreviewBarSelection}\n /** Bar → Visual Editor tool: the logo was clicked; go to the Studio (its router, no reload). */\n | {type: 'sanity-visual-editor:studio-home'}\n /** Site framed by the Visual Editor tool → tool: its path and query, on load and navigation. */\n | {type: 'sanity-visual-editor:frame-path'; path: string}\n /**\n * Bar → host: the document pane opened (a full-height column `width` CSS pixels wide on `side`)\n * or closed. The host clips the frame to that column plus the bar and reflows the page beside it.\n */\n | {type: 'sanity-visual-editor:panel'; open: boolean; width: number; side: PaneSide}\n /**\n * Site framed by the Visual Editor tool → tool: an element marked with `data-sanity` was clicked\n * while the inspector is on (click-to-edit, `sanity-plugin-visual-editor/host`'s overlay). Open `id` in the document pane\n * at `path`, which is in Sanity's URL form as written in the attribute (`sections:k1.heading`);\n * `toPanePath` turns it into the pane's `path` param. The page's own document opens at the path\n * (an array item opens its editor, a field gets focus); any other document goes on the pane's\n * stack.\n */\n | {type: 'sanity-visual-editor:edit'; id: string; documentType: string; path: string}\n /**\n * Visual Editor tool → framed site: the document pane focused a field (`path` in\n * URL form) of document `id`; the overlay outlines the elements that show it and scrolls one into\n * view. Empty `id` and `path` clear it.\n */\n | {type: 'sanity-visual-editor:focus'; id: string; path: string}\n /**\n * Bar → Visual Editor tool → framed site: the inspector (the bar's \"Activate inspector\" button or\n * ⌘⇧I) turned click-to-edit on or off. The tool resends it after every page load in the frame.\n */\n | {type: 'sanity-visual-editor:inspector'; active: boolean}\n /** Framed site → Visual Editor tool → bar: ⌘⇧I was pressed on the page; toggle the inspector. */\n | {type: 'sanity-visual-editor:toggle-inspector'}\n /**\n * Framed site → Visual Editor tool: label these `data-sanity` nodes (field titles\n * from the Studio's schema) and check that their paths resolve. Answered with `labels`.\n */\n | {type: 'sanity-visual-editor:describe'; nodes: SanityNode[]}\n /** Visual Editor tool → framed site: the answer to `describe`. */\n | {type: 'sanity-visual-editor:labels'; labels: NodeLabel[]}\n /**\n * Host → bar: how the storefront is following the preview hub. `connected` is a WebSocket;\n * `polling` is the degraded long-poll fallback; `offline` means live updates are paused while\n * retrying. The bar shows a toast on `polling` / `offline` (and on recovery to `connected`).\n */\n | {type: 'sanity-visual-editor:live-status'; status: 'connected' | 'polling' | 'offline'}\n\n/** ⌘⇧I / Ctrl+Shift+I: the inspector's shortcut, in the bar and on the framed page. */\nexport function isInspectorShortcut(event: {\n key: string\n code?: string\n metaKey: boolean\n ctrlKey: boolean\n shiftKey: boolean\n altKey: boolean\n repeat?: boolean\n}) {\n return (\n (event.key.toLowerCase() === 'i' || event.code === 'KeyI') &&\n (event.metaKey || event.ctrlKey) &&\n event.shiftKey &&\n !event.altKey &&\n !event.repeat\n )\n}\n\nexport function isPreviewBarMessage(data: unknown): data is PreviewBarMessage {\n if (typeof data !== 'object' || data === null || !('type' in data)) return false\n switch (data.type) {\n case 'sanity-visual-editor:ready':\n case 'sanity-visual-editor:hide':\n case 'sanity-visual-editor:refresh':\n case 'sanity-visual-editor:refreshed':\n case 'sanity-visual-editor:search':\n case 'sanity-visual-editor:pane':\n case 'sanity-visual-editor:studio-home':\n case 'sanity-visual-editor:open-editor':\n case 'sanity-visual-editor:close-editor':\n case 'sanity-visual-editor:toggle-inspector':\n return true\n case 'sanity-visual-editor:inspector':\n return 'active' in data && typeof data.active === 'boolean'\n case 'sanity-visual-editor:navigate':\n return 'href' in data && isRootRelative(data.href)\n case 'sanity-visual-editor:menu':\n return 'open' in data && typeof data.open === 'boolean'\n case 'sanity-visual-editor:panel':\n return (\n 'open' in data &&\n typeof data.open === 'boolean' &&\n 'width' in data &&\n typeof data.width === 'number' &&\n Number.isFinite(data.width) &&\n data.width >= 0 &&\n 'side' in data &&\n (data.side === 'left' || data.side === 'right')\n )\n case 'sanity-visual-editor:path':\n case 'sanity-visual-editor:frame-path':\n // Root-relative only: the bar builds its Studio links from it.\n return 'path' in data && isRootRelative(data.path)\n case 'sanity-visual-editor:page-document':\n return (\n 'document' in data &&\n (data.document === null ||\n (typeof data.document === 'object' &&\n typeof (data.document as Record<string, unknown>).id === 'string' &&\n typeof (data.document as Record<string, unknown>).type === 'string'))\n )\n case 'sanity-visual-editor:open-document':\n return 'document' in data && isDocument(data.document)\n case 'sanity-visual-editor:editor-state':\n return (\n 'open' in data &&\n typeof data.open === 'boolean' &&\n (!('available' in data) ||\n data.available === undefined ||\n typeof data.available === 'boolean') &&\n (!('toggle' in data) || data.toggle === undefined || typeof data.toggle === 'boolean')\n )\n case 'sanity-visual-editor:viewport':\n return (\n 'mode' in data &&\n (data.mode === 'desktop' || data.mode === 'tablet' || data.mode === 'mobile')\n )\n case 'sanity-visual-editor:perspective':\n case 'sanity-visual-editor:set-perspective':\n return 'selection' in data && isSelection(data.selection)\n case 'sanity-visual-editor:edit':\n return (\n 'id' in data &&\n isNonEmptyString(data.id) &&\n 'documentType' in data &&\n isNonEmptyString(data.documentType) &&\n 'path' in data &&\n isNonEmptyString(data.path) &&\n data.path.length <= MAX_EDIT_PATH_LENGTH\n )\n case 'sanity-visual-editor:focus':\n return (\n 'id' in data &&\n typeof data.id === 'string' &&\n 'path' in data &&\n typeof data.path === 'string' &&\n data.path.length <= MAX_EDIT_PATH_LENGTH\n )\n case 'sanity-visual-editor:describe':\n return (\n 'nodes' in data &&\n Array.isArray(data.nodes) &&\n data.nodes.length <= MAX_DESCRIBE_NODES &&\n data.nodes.every(isNode)\n )\n case 'sanity-visual-editor:labels':\n return (\n 'labels' in data &&\n Array.isArray(data.labels) &&\n data.labels.length <= MAX_DESCRIBE_NODES &&\n data.labels.every(isLabel)\n )\n case 'sanity-visual-editor:live-status':\n return (\n 'status' in data &&\n (data.status === 'connected' || data.status === 'polling' || data.status === 'offline')\n )\n default:\n return false\n }\n}\n\nfunction isNode(value: unknown): value is SanityNode {\n if (typeof value !== 'object' || value === null) return false\n const node = value as Record<string, unknown>\n return (\n isNonEmptyString(node.id) &&\n isNonEmptyString(node.type) &&\n isNonEmptyString(node.path) &&\n node.path.length <= MAX_EDIT_PATH_LENGTH\n )\n}\n\nfunction isLabel(value: unknown): value is NodeLabel {\n if (typeof value !== 'object' || value === null) return false\n const label = value as Record<string, unknown>\n return (\n isNonEmptyString(label.id) &&\n isNonEmptyString(label.path) &&\n label.path.length <= MAX_EDIT_PATH_LENGTH &&\n typeof label.label === 'string' &&\n label.label.length <= 200 &&\n (label.missing === undefined || typeof label.missing === 'boolean')\n )\n}\n\nfunction isDocument(value: unknown): value is PreviewBarDocument {\n if (typeof value !== 'object' || value === null) return false\n const doc = value as Record<string, unknown>\n return (\n typeof doc.id === 'string' &&\n doc.id.length > 0 &&\n typeof doc.type === 'string' &&\n doc.type.length > 0 &&\n (doc.template === undefined || typeof doc.template === 'string') &&\n (doc.templateParameters === undefined ||\n (typeof doc.templateParameters === 'object' && doc.templateParameters !== null))\n )\n}\n\nfunction isSelection(value: unknown): value is PreviewBarSelection {\n if (typeof value !== 'object' || value === null) return false\n const selection = value as Record<string, unknown>\n return (\n typeof selection.selected === 'string' &&\n Array.isArray(selection.excluded) &&\n selection.excluded.every((id) => typeof id === 'string')\n )\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0\n}\n\n/** Same-site paths only: the bar builds links from them and the host navigates to them. */\nfunction isRootRelative(value: unknown): value is string {\n return isSameOriginPath(value)\n}\n"],"mappings":";;;;AAMA,MAAM,qBAAqB,yBACrB,OAAO;;;;;;;;;;AAWb,SAAgB,eAAe,OAA+B;CAE5D,IADI,OAAO,SAAU,YAAY,CAAC,MAAM,WAAW,GAAG,KAClD,MAAM,WAAW,IAAI,KAAK,MAAM,SAAS,IAAI,KAAK,mBAAmB,KAAK,KAAK,GAAG,OAAO;CAC7F,IAAI;CACJ,IAAI;EACF,MAAM,IAAI,IAAI,OAAO,IAAI;CAC3B,QAAQ;EACN,OAAO;CACT;CACA,IAAI,IAAI,WAAW,MAAM,OAAO;CAChC,IAAM,EAAC,aAAY;CASnB,OAPE,CAAC,SAAS,WAAW,GAAG,KACxB,SAAS,WAAW,IAAI,KACxB,SAAS,SAAS,IAAI,KACtB,eAAe,KAAK,QAAQ,IAErB,OAEF,GAAG,WAAW,IAAI,SAAS,IAAI;AACxC;;AAGA,SAAgB,iBAAiB,OAAiC;CAChE,OAAO,eAAe,KAAK,MAAM;AACnC;;;;;;;;;;;AChCA,MAAa,wBAAwB,eAgBxB,uBAAuB,KAE9B,QAAQ;AAEd,SAAS,OAAO,OAAe;CAC7B,IAAI;EACF,OAAO,mBAAmB,KAAK;CACjC,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAgB,gBAAgB,OAAqD;CACnF,IAAI,CAAC,OAAO,OAAO;CACnB,IAAM,SAAiC,CAAC;CACxC,KAAK,IAAM,QAAQ,MAA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AU,YAAY,MAAM,SAAS;AACrD;;AAGA,SAAS,eAAe,OAAiC;CACvD,OAAO,iBAAiB,KAAK;AAC/B"}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `data-sanity` attribute that marks an element as editable, and its path, without
|
|
3
|
+
* dependencies. Storefronts write it with `createDataAttribute({id, type, path})` or by hand:
|
|
4
|
+
*
|
|
5
|
+
* data-sanity="id=page-home;type=page;path=sections:k1.heading"
|
|
6
|
+
*
|
|
7
|
+
* `base=` and `workspace=` may follow; they're read but unused. `path` is Sanity's URL path form:
|
|
8
|
+
* `.` between segments, `field:key` for a keyed array item, and `field:3` (up to 9 digits) for an
|
|
9
|
+
* index, so `sections:k1.heading` is `sections[_key=="k1"].heading`.
|
|
10
|
+
*/
|
|
11
|
+
declare const SANITY_NODE_ATTRIBUTE = "data-sanity";
|
|
12
|
+
/** An editable element's document and path (URL form, as written in the attribute). */
|
|
13
|
+
type SanityNode = {
|
|
14
|
+
id: string;
|
|
15
|
+
type: string;
|
|
16
|
+
path: string;
|
|
17
|
+
base?: string;
|
|
18
|
+
workspace?: string;
|
|
19
|
+
};
|
|
20
|
+
/** A Studio path: field names, keyed array items and indexes. */
|
|
21
|
+
type StudioPathSegment = string | number | {
|
|
22
|
+
_key: string;
|
|
23
|
+
};
|
|
24
|
+
type StudioPath = StudioPathSegment[];
|
|
25
|
+
/** Longest path the edit message carries. */
|
|
26
|
+
declare const MAX_EDIT_PATH_LENGTH = 1000;
|
|
27
|
+
/**
|
|
28
|
+
* Reads a `data-sanity` value: pairs split on `;`, each on its first `=`, values URI-decoded.
|
|
29
|
+
* Returns `null` unless `id`, `type` and `path` are all present and non-empty.
|
|
30
|
+
*/
|
|
31
|
+
declare function parseSanityNode(value: string | null | undefined): SanityNode | null;
|
|
32
|
+
/**
|
|
33
|
+
* Sanity's URL path form to a Studio path: `sections:k1.heading` →
|
|
34
|
+
* `['sections', {_key: 'k1'}, 'heading']`, `items:3` → `['items', 3]`. Chained items
|
|
35
|
+
* (`rows:r1:c2`) are nested arrays. Returns `null` for an empty or malformed path.
|
|
36
|
+
*/
|
|
37
|
+
declare function toStudioPath(urlPath: string): StudioPath | null;
|
|
38
|
+
/**
|
|
39
|
+
* A Studio path as the document pane's `path` param reads it (`@sanity/util/paths` `toString`):
|
|
40
|
+
* `sections[_key=="k1"].heading`, `items[3]`.
|
|
41
|
+
*/
|
|
42
|
+
declare function studioPathToString(path: StudioPath): string;
|
|
43
|
+
/** The pane param for a URL-form path, or `null` when it doesn't parse. */
|
|
44
|
+
declare function toPanePath(urlPath: string): string | null;
|
|
45
|
+
/** `heroImage` → `Hero image`, `section_title` → `Section title`. */
|
|
46
|
+
declare function humanizeFieldName(name: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* A label for a path's last segment: the field's name, humanized (`sections:k1.heading` →
|
|
49
|
+
* `Heading`), or `Sections item` when it ends in an array item.
|
|
50
|
+
*/
|
|
51
|
+
declare function describeSanityPath(urlPath: string): string;
|
|
52
|
+
/** A document's published ID (`drafts.` and `versions.<release>.` prefixes removed). */
|
|
53
|
+
declare function publishedDocumentId(id: string): string;
|
|
54
|
+
/** A Studio path in Sanity's URL form: `['sections', {_key: 'k1'}, 'heading']` → `sections:k1.heading`. */
|
|
55
|
+
declare function toUrlPath(path: readonly StudioPathSegment[]): string;
|
|
56
|
+
type SanityAttrDocument = {
|
|
57
|
+
_id?: string | null;
|
|
58
|
+
_type?: string | null;
|
|
59
|
+
} | {
|
|
60
|
+
id?: string | null;
|
|
61
|
+
type?: string | null;
|
|
62
|
+
} | null | undefined;
|
|
63
|
+
type SanityAttrPath = string | readonly StudioPathSegment[];
|
|
64
|
+
type SanityAttrOptions = {
|
|
65
|
+
/** Only emit `data-sanity` when true (e.g. `data.preview`). Default `true`. */
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
base?: string;
|
|
68
|
+
workspace?: string;
|
|
69
|
+
};
|
|
70
|
+
type SanityDataAttribute = {
|
|
71
|
+
readonly 'data-sanity'?: string;
|
|
72
|
+
};
|
|
73
|
+
/** Formats a `SanityNode` into a `data-sanity` attribute value (`id=...;type=...;path=...`). */
|
|
74
|
+
declare function encodeSanityNode(node: SanityNode): string;
|
|
75
|
+
/**
|
|
76
|
+
* Returns `{ 'data-sanity': '...' }` for click-to-edit overlays, or `{}` when `enabled` is `false`
|
|
77
|
+
* or `doc`/`path` is incomplete. Spread directly onto any Svelte or JSX element:
|
|
78
|
+
*
|
|
79
|
+
* <h1 {...sanityAttr(page, 'heading', { enabled: preview })}>
|
|
80
|
+
* <section {...sanityAttr(page, ['sections', { _key: section._key }, 'title'])}>
|
|
81
|
+
*/
|
|
82
|
+
declare function sanityAttr(doc: SanityAttrDocument, path: SanityAttrPath, options?: SanityAttrOptions): SanityDataAttribute;
|
|
83
|
+
/**
|
|
84
|
+
* Scoped `sanityAttr` bound to one document and option set:
|
|
85
|
+
*
|
|
86
|
+
* const attr = createSanityAttr(page, { enabled: preview })
|
|
87
|
+
* <h1 {...attr('heading')}>
|
|
88
|
+
*/
|
|
89
|
+
declare function createSanityAttr(doc: SanityAttrDocument, options?: SanityAttrOptions): (path: SanityAttrPath) => SanityDataAttribute;
|
|
90
|
+
/**
|
|
91
|
+
* The nodes that show a focused field: those of the same document whose path is the longest
|
|
92
|
+
* prefix of the focused path (the field itself, or the nearest annotated element around it).
|
|
93
|
+
* A field can render more than once (a desktop and a mobile variant), so all of them match.
|
|
94
|
+
*/
|
|
95
|
+
declare function matchFocusedNodes<T extends {
|
|
96
|
+
node: SanityNode;
|
|
97
|
+
}>(items: readonly T[], focus: {
|
|
98
|
+
id: string;
|
|
99
|
+
path: string;
|
|
100
|
+
}): T[];
|
|
101
|
+
/** The parts of a compiled Sanity schema type the labels read. */
|
|
102
|
+
type LabelSchemaType = {
|
|
103
|
+
name: string;
|
|
104
|
+
title?: string;
|
|
105
|
+
jsonType?: string;
|
|
106
|
+
fields?: readonly {
|
|
107
|
+
name: string;
|
|
108
|
+
type: LabelSchemaType;
|
|
109
|
+
}[];
|
|
110
|
+
of?: readonly LabelSchemaType[];
|
|
111
|
+
to?: readonly LabelSchemaType[];
|
|
112
|
+
options?: {
|
|
113
|
+
list?: readonly unknown[];
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
type LabelSchema = {
|
|
117
|
+
get(name: string): LabelSchemaType | undefined;
|
|
118
|
+
};
|
|
119
|
+
/** A node's label for the overlay, keyed by the node's `id` and `path` as the page sent them. */
|
|
120
|
+
type NodeLabel = {
|
|
121
|
+
id: string;
|
|
122
|
+
path: string;
|
|
123
|
+
label: string;
|
|
124
|
+
missing?: boolean;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* The label of a path's last segment, and whether the path resolves. `document` is the document's
|
|
128
|
+
* value, `null` when it doesn't exist, or `undefined` when it wasn't loaded (then only the schema
|
|
129
|
+
* is checked).
|
|
130
|
+
*/
|
|
131
|
+
declare function describePath(schema: LabelSchema, documentType: string, document: unknown, urlPath: string): {
|
|
132
|
+
label: string;
|
|
133
|
+
missing: boolean;
|
|
134
|
+
};
|
|
135
|
+
/** Fetches documents by published ID, in the editor's perspective; absent ones are left out. */
|
|
136
|
+
type DocumentFetcher = (ids: string[]) => Promise<Record<string, unknown>>;
|
|
137
|
+
/**
|
|
138
|
+
* Answers the overlay's `describe`: one fetch for the documents involved (cached briefly, since
|
|
139
|
+
* hovering asks a few at a time), then each node's label and drift.
|
|
140
|
+
*/
|
|
141
|
+
declare function createNodeDescriber(schema: LabelSchema, fetchDocuments: DocumentFetcher, cacheMs?: number): (nodes: readonly SanityNode[]) => Promise<NodeLabel[]>;
|
|
142
|
+
type PerspectiveClient = {
|
|
143
|
+
withConfig(config: {
|
|
144
|
+
perspective: unknown;
|
|
145
|
+
}): {
|
|
146
|
+
fetch(query: string, params: Record<string, unknown>, options?: unknown): Promise<unknown>;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
/** A `DocumentFetcher` over a Sanity client, in a perspective stack (`['drafts']`, a release…). */
|
|
150
|
+
declare function clientDocumentFetcher(client: PerspectiveClient, perspective: unknown): DocumentFetcher;
|
|
151
|
+
/** Most nodes one `describe` or `labels` message carries. */
|
|
152
|
+
declare const MAX_DESCRIBE_NODES = 500;
|
|
153
|
+
/** Default route for the framed bar; its endpoints live under it (`/__visual-editor/resolve`, …). */
|
|
154
|
+
declare const PREVIEW_BAR_ROUTE = "/__visual-editor";
|
|
155
|
+
/**
|
|
156
|
+
* Query parameter on storefront URLs loaded as Studio thumbnails: suppresses preview mode,
|
|
157
|
+
* overlays, and storefront analytics so editors see published content cleanly.
|
|
158
|
+
*/
|
|
159
|
+
declare const STUDIO_PREVIEW_PARAM = "studio-preview";
|
|
160
|
+
/** Visible height of the bar in CSS pixels; the host reserves this much at the bottom of the page. */
|
|
161
|
+
declare const PREVIEW_BAR_HEIGHT = 50;
|
|
162
|
+
/**
|
|
163
|
+
* With the document pane open, the page (and the bar) keep at least this many CSS pixels beside
|
|
164
|
+
* it. On a narrower viewport the pane overlays the page instead, above a full-width bar.
|
|
165
|
+
*/
|
|
166
|
+
declare const PREVIEW_PANEL_MIN_PAGE_WIDTH = 360;
|
|
167
|
+
/** Which edge of the viewport the document pane sits on. */
|
|
168
|
+
type PaneSide = 'left' | 'right';
|
|
169
|
+
/** Which edge of the viewport the bar sits on. */
|
|
170
|
+
type PreviewBarPosition = 'top' | 'bottom';
|
|
171
|
+
/**
|
|
172
|
+
* The host tells the framed bar its position in the frame's URL (`/__visual-editor?position=top`), so
|
|
173
|
+
* the bar renders in place from its first frame.
|
|
174
|
+
*/
|
|
175
|
+
declare const PREVIEW_BAR_POSITION_PARAM = "position";
|
|
176
|
+
declare function readPreviewBarPosition(search: string): PreviewBarPosition;
|
|
177
|
+
/**
|
|
178
|
+
* Where the bar is framed: on the site (by `sanity-plugin-visual-editor/host`) or in the Studio's Visual
|
|
179
|
+
* Editor tool (`sanity-plugin-visual-editor/studio`), which passes `?context=tool` in the frame's URL.
|
|
180
|
+
*/
|
|
181
|
+
type PreviewBarContext = 'site' | 'tool';
|
|
182
|
+
declare const PREVIEW_BAR_CONTEXT_PARAM = "context";
|
|
183
|
+
declare function readPreviewBarContext(search: string): PreviewBarContext;
|
|
184
|
+
/**
|
|
185
|
+
* The Visual Editor tool frames the site under this window name. It survives navigation inside
|
|
186
|
+
* the frame, so the site can tell it's in the tool (not another embed) on every page.
|
|
187
|
+
*/
|
|
188
|
+
declare const PREVIEW_BAR_FRAME_NAME = "sanity-plugin-visual-editor-frame";
|
|
189
|
+
/**
|
|
190
|
+
* Whether this window is the site framed by the Visual Editor tool, where the page reads like a
|
|
191
|
+
* normal preview tab and mounts `mountPreviewBarFrame` instead of the host.
|
|
192
|
+
*/
|
|
193
|
+
declare function isPreviewBarFrame(): boolean;
|
|
194
|
+
/** The Visual Editor's viewport sizes. */
|
|
195
|
+
type PreviewBarViewport = 'desktop' | 'tablet' | 'mobile';
|
|
196
|
+
/** A document to open in the Visual Editor's pane; a new one carries its template. */
|
|
197
|
+
type PreviewBarDocument = {
|
|
198
|
+
id: string;
|
|
199
|
+
type: string;
|
|
200
|
+
template?: string;
|
|
201
|
+
templateParameters?: Record<string, unknown>;
|
|
202
|
+
};
|
|
203
|
+
/** The bar's perspective as a menu selection: the chosen layer and the hidden ones. */
|
|
204
|
+
type PreviewBarSelection = {
|
|
205
|
+
selected: string;
|
|
206
|
+
excluded: string[];
|
|
207
|
+
};
|
|
208
|
+
type PreviewBarMessage =
|
|
209
|
+
/** Bar → host, once mounted: asks for the current storefront path. */
|
|
210
|
+
{
|
|
211
|
+
type: 'sanity-visual-editor:ready';
|
|
212
|
+
} |
|
|
213
|
+
/** Bar → host: hide the bar until the next full page load (preview mode stays on). */
|
|
214
|
+
{
|
|
215
|
+
type: 'sanity-visual-editor:hide';
|
|
216
|
+
} |
|
|
217
|
+
/** Bar → host: the perspective menu opened or closed; the host grows the frame so it fits. */
|
|
218
|
+
{
|
|
219
|
+
type: 'sanity-visual-editor:menu';
|
|
220
|
+
open: boolean;
|
|
221
|
+
} |
|
|
222
|
+
/** Bar → host: the perspective cookie changed; rerun every query and load in place. */
|
|
223
|
+
{
|
|
224
|
+
type: 'sanity-visual-editor:refresh';
|
|
225
|
+
} |
|
|
226
|
+
/** Host → bar: the storefront finished refreshing after `refresh`. */
|
|
227
|
+
{
|
|
228
|
+
type: 'sanity-visual-editor:refreshed';
|
|
229
|
+
} |
|
|
230
|
+
/** Host → bar: the storefront path and query, sent on `ready` and after every navigation. */
|
|
231
|
+
{
|
|
232
|
+
type: 'sanity-visual-editor:path';
|
|
233
|
+
path: string;
|
|
234
|
+
} |
|
|
235
|
+
/** Host → bar: ⌘K / Ctrl+K was pressed on the storefront page; open search. */
|
|
236
|
+
{
|
|
237
|
+
type: 'sanity-visual-editor:search';
|
|
238
|
+
} |
|
|
239
|
+
/** Host → bar: `E` was pressed on the storefront page (not while typing); toggle the pane. */
|
|
240
|
+
{
|
|
241
|
+
type: 'sanity-visual-editor:pane';
|
|
242
|
+
} |
|
|
243
|
+
/** Bar → host: a search result was chosen; navigate the storefront there (client-side). */
|
|
244
|
+
{
|
|
245
|
+
type: 'sanity-visual-editor:navigate';
|
|
246
|
+
href: string;
|
|
247
|
+
} |
|
|
248
|
+
/** Bar → Visual Editor tool: open this document in the tool's pane (Edit, Create new document). */
|
|
249
|
+
{
|
|
250
|
+
type: 'sanity-visual-editor:open-document';
|
|
251
|
+
document: PreviewBarDocument;
|
|
252
|
+
} |
|
|
253
|
+
/**
|
|
254
|
+
* Visual Editor tool → bar: the tool's pane opened or closed (Edit hides while it's open), and
|
|
255
|
+
* whether the page has a document to edit (Edit shows only then).
|
|
256
|
+
*/
|
|
257
|
+
{
|
|
258
|
+
type: 'sanity-visual-editor:editor-state';
|
|
259
|
+
open: boolean;
|
|
260
|
+
available?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* The tool is too narrow for the pane beside the page: one shows at a time, and Edit stays,
|
|
263
|
+
* pressed while the document shows, and toggles between them (`close-editor` goes back).
|
|
264
|
+
*/
|
|
265
|
+
toggle?: boolean;
|
|
266
|
+
} |
|
|
267
|
+
/** Visual Editor tool → bar: the current page's document (the page picker previews it), if any. */
|
|
268
|
+
{
|
|
269
|
+
type: 'sanity-visual-editor:page-document';
|
|
270
|
+
document: {
|
|
271
|
+
id: string;
|
|
272
|
+
type: string;
|
|
273
|
+
} | null;
|
|
274
|
+
} |
|
|
275
|
+
/** Bar → Visual Editor tool: Edit was clicked; open the page's document in the pane. */
|
|
276
|
+
{
|
|
277
|
+
type: 'sanity-visual-editor:open-editor';
|
|
278
|
+
} |
|
|
279
|
+
/** Bar → Visual Editor tool: Edit was clicked again (narrow, `toggle`); show the page. */
|
|
280
|
+
{
|
|
281
|
+
type: 'sanity-visual-editor:close-editor';
|
|
282
|
+
} |
|
|
283
|
+
/** Bar → Visual Editor tool: show the site at desktop width, as a 768px tablet or a 375px phone. */
|
|
284
|
+
{
|
|
285
|
+
type: 'sanity-visual-editor:viewport';
|
|
286
|
+
mode: PreviewBarViewport;
|
|
287
|
+
} |
|
|
288
|
+
/** Bar → Visual Editor tool: the bar's perspective changed; the Studio follows it. */
|
|
289
|
+
{
|
|
290
|
+
type: 'sanity-visual-editor:perspective';
|
|
291
|
+
selection: PreviewBarSelection;
|
|
292
|
+
} |
|
|
293
|
+
/** Visual Editor tool → bar: the Studio's perspective changed (pane chips, navbar); switch to it. */
|
|
294
|
+
{
|
|
295
|
+
type: 'sanity-visual-editor:set-perspective';
|
|
296
|
+
selection: PreviewBarSelection;
|
|
297
|
+
} |
|
|
298
|
+
/** Bar → Visual Editor tool: the logo was clicked; go to the Studio (its router, no reload). */
|
|
299
|
+
{
|
|
300
|
+
type: 'sanity-visual-editor:studio-home';
|
|
301
|
+
} |
|
|
302
|
+
/** Site framed by the Visual Editor tool → tool: its path and query, on load and navigation. */
|
|
303
|
+
{
|
|
304
|
+
type: 'sanity-visual-editor:frame-path';
|
|
305
|
+
path: string;
|
|
306
|
+
} |
|
|
307
|
+
/**
|
|
308
|
+
* Bar → host: the document pane opened (a full-height column `width` CSS pixels wide on `side`)
|
|
309
|
+
* or closed. The host clips the frame to that column plus the bar and reflows the page beside it.
|
|
310
|
+
*/
|
|
311
|
+
{
|
|
312
|
+
type: 'sanity-visual-editor:panel';
|
|
313
|
+
open: boolean;
|
|
314
|
+
width: number;
|
|
315
|
+
side: PaneSide;
|
|
316
|
+
} |
|
|
317
|
+
/**
|
|
318
|
+
* Site framed by the Visual Editor tool → tool: an element marked with `data-sanity` was clicked
|
|
319
|
+
* while the inspector is on (click-to-edit, `sanity-plugin-visual-editor/host`'s overlay). Open `id` in the document pane
|
|
320
|
+
* at `path`, which is in Sanity's URL form as written in the attribute (`sections:k1.heading`);
|
|
321
|
+
* `toPanePath` turns it into the pane's `path` param. The page's own document opens at the path
|
|
322
|
+
* (an array item opens its editor, a field gets focus); any other document goes on the pane's
|
|
323
|
+
* stack.
|
|
324
|
+
*/
|
|
325
|
+
{
|
|
326
|
+
type: 'sanity-visual-editor:edit';
|
|
327
|
+
id: string;
|
|
328
|
+
documentType: string;
|
|
329
|
+
path: string;
|
|
330
|
+
} |
|
|
331
|
+
/**
|
|
332
|
+
* Visual Editor tool → framed site: the document pane focused a field (`path` in
|
|
333
|
+
* URL form) of document `id`; the overlay outlines the elements that show it and scrolls one into
|
|
334
|
+
* view. Empty `id` and `path` clear it.
|
|
335
|
+
*/
|
|
336
|
+
{
|
|
337
|
+
type: 'sanity-visual-editor:focus';
|
|
338
|
+
id: string;
|
|
339
|
+
path: string;
|
|
340
|
+
} |
|
|
341
|
+
/**
|
|
342
|
+
* Bar → Visual Editor tool → framed site: the inspector (the bar's "Activate inspector" button or
|
|
343
|
+
* ⌘⇧I) turned click-to-edit on or off. The tool resends it after every page load in the frame.
|
|
344
|
+
*/
|
|
345
|
+
{
|
|
346
|
+
type: 'sanity-visual-editor:inspector';
|
|
347
|
+
active: boolean;
|
|
348
|
+
} |
|
|
349
|
+
/** Framed site → Visual Editor tool → bar: ⌘⇧I was pressed on the page; toggle the inspector. */
|
|
350
|
+
{
|
|
351
|
+
type: 'sanity-visual-editor:toggle-inspector';
|
|
352
|
+
} |
|
|
353
|
+
/**
|
|
354
|
+
* Framed site → Visual Editor tool: label these `data-sanity` nodes (field titles
|
|
355
|
+
* from the Studio's schema) and check that their paths resolve. Answered with `labels`.
|
|
356
|
+
*/
|
|
357
|
+
{
|
|
358
|
+
type: 'sanity-visual-editor:describe';
|
|
359
|
+
nodes: SanityNode[];
|
|
360
|
+
} |
|
|
361
|
+
/** Visual Editor tool → framed site: the answer to `describe`. */
|
|
362
|
+
{
|
|
363
|
+
type: 'sanity-visual-editor:labels';
|
|
364
|
+
labels: NodeLabel[];
|
|
365
|
+
} |
|
|
366
|
+
/**
|
|
367
|
+
* Host → bar: how the storefront is following the preview hub. `connected` is a WebSocket;
|
|
368
|
+
* `polling` is the degraded long-poll fallback; `offline` means live updates are paused while
|
|
369
|
+
* retrying. The bar shows a toast on `polling` / `offline` (and on recovery to `connected`).
|
|
370
|
+
*/
|
|
371
|
+
{
|
|
372
|
+
type: 'sanity-visual-editor:live-status';
|
|
373
|
+
status: 'connected' | 'polling' | 'offline';
|
|
374
|
+
};
|
|
375
|
+
/** ⌘⇧I / Ctrl+Shift+I: the inspector's shortcut, in the bar and on the framed page. */
|
|
376
|
+
declare function isInspectorShortcut(event: {
|
|
377
|
+
key: string;
|
|
378
|
+
code?: string;
|
|
379
|
+
metaKey: boolean;
|
|
380
|
+
ctrlKey: boolean;
|
|
381
|
+
shiftKey: boolean;
|
|
382
|
+
altKey: boolean;
|
|
383
|
+
repeat?: boolean;
|
|
384
|
+
}): boolean;
|
|
385
|
+
declare function isPreviewBarMessage(data: unknown): data is PreviewBarMessage;
|
|
386
|
+
export { SanityAttrDocument as A, humanizeFieldName as B, LabelSchemaType as C, describePath as D, createNodeDescriber as E, StudioPath as F, studioPathToString as G, parseSanityNode as H, StudioPathSegment as I, toUrlPath as J, toPanePath as K, createSanityAttr as L, SanityAttrPath as M, SanityDataAttribute as N, MAX_EDIT_PATH_LENGTH as O, SanityNode as P, describeSanityPath as R, LabelSchema as S, clientDocumentFetcher as T, publishedDocumentId as U, matchFocusedNodes as V, sanityAttr as W, isPreviewBarFrame as _, PREVIEW_BAR_POSITION_PARAM as a, readPreviewBarPosition as b, PaneSide as c, PreviewBarMessage as d, PreviewBarPosition as f, isInspectorShortcut as g, STUDIO_PREVIEW_PARAM as h, PREVIEW_BAR_HEIGHT as i, SanityAttrOptions as j, SANITY_NODE_ATTRIBUTE as k, PreviewBarContext as l, PreviewBarViewport as m, PREVIEW_BAR_CONTEXT_PARAM as n, PREVIEW_BAR_ROUTE as o, PreviewBarSelection as p, toStudioPath as q, PREVIEW_BAR_FRAME_NAME as r, PREVIEW_PANEL_MIN_PAGE_WIDTH as s, MAX_DESCRIBE_NODES as t, PreviewBarDocument as u, isPreviewBarMessage as v, NodeLabel as w, DocumentFetcher as x, readPreviewBarContext as y, encodeSanityNode as z };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { C as SearchConfig, D as SearchRoute, n as PreviewBarData, t as PreviewBarBrand, w as SearchDocumentType } from "./data-D0qotTtt.js";
|
|
2
|
+
import { m as memoryStore, p as kvStore, s as PreviewLinkStore, t as KVNamespaceLike } from "./preview-links-DM6BCiLV.js";
|
|
3
|
+
import { C as createPreviewHubClient, D as verifyLinkSession, E as signLinkSession, S as createLiveEditToken, T as LINK_SESSION_COOKIE, _ as LIVE_EDIT_PATH, a as PreviewModeSwitch, b as PreviewHubClientLike, c as createVisualEditor, d as previewCookieAttributes, f as setCookieHeader, g as LIVE_EDIT_COOKIE, h as renderPreviewLinkErrorHtml, i as PreviewContext, l as deleteCookieHeader, m as PreviewLinkErrorRenderer, n as PreviewBarOptions, o as VisualEditor, p as PreviewLinkErrorRenderContext, r as PreviewClient, s as createPreviewBar, t as PreviewBar, u as fetchReleases, v as LIVE_EDIT_TTL_S, w as verifyLiveEditToken, x as PreviewHubFetcher, y as PreviewHub } from "./index-4Zm_NjhC.js";
|
|
4
|
+
export { type KVNamespaceLike, LINK_SESSION_COOKIE, LIVE_EDIT_COOKIE, LIVE_EDIT_PATH, LIVE_EDIT_TTL_S, PreviewBar, type PreviewBarBrand, type PreviewBarData, PreviewBarOptions, PreviewClient, PreviewContext, PreviewHub, PreviewHubClientLike, PreviewHubFetcher, PreviewLinkErrorRenderContext, PreviewLinkErrorRenderer, type PreviewLinkStore, PreviewModeSwitch, type SearchConfig, type SearchDocumentType, type SearchRoute, VisualEditor, createLiveEditToken, createPreviewBar, createPreviewHubClient, createVisualEditor, deleteCookieHeader, fetchReleases, kvStore, memoryStore, previewCookieAttributes, renderPreviewLinkErrorHtml, setCookieHeader, signLinkSession, verifyLinkSession, verifyLiveEditToken };
|