sanity-plugin-visual-editor 1.1.0 → 1.2.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/dist/next.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"next.js","names":[],"sources":["../src/next/index.ts"],"sourcesContent":["/**\n * Next.js (App Router) adapter, for sites using `next-sanity`'s draft mode. Server side: route\n * handlers, the bar page's data and the short-link checks. The client components live in\n * `sanity-plugin-visual-editor/next/client`. See the README for the routes.\n *\n * Opening a short link takes two steps because a page can't set cookies while it renders:\n * `/p/[code]` checks the link (rendering the expired page with a 404 when it's gone) and redirects\n * live ones to `<basePath>/open/<code>`, a route handler that turns draft mode on and redirects to\n * the stored page.\n *\n * Draft mode is one cookie (`__prerender_bypass`) whose value is fixed per build, so a link's\n * recipient holds a value that turns draft mode on until the next deploy. `openLink` caps that\n * cookie's lifetime to the link's, and marks the session so it can't mint links, but a recipient\n * who copies the cookie by hand keeps draft mode until the next build. See the README.\n */\nimport {cookies, draftMode, headers} from 'next/headers'\nimport {notFound, redirect} from 'next/navigation'\n\nimport type {PreviewBarData} from '../core/data'\nimport {parsePerspective, PERSPECTIVE_COOKIE, serializePerspective} from '../core/perspective'\nimport type {PreviewBar, PreviewClient, PreviewContext} from '../server'\nimport {LINK_SESSION_COOKIE} from '../server/link-session'\n\n/** Next's draft mode cookie. */\nconst DRAFT_MODE_COOKIE = '__prerender_bypass'\n\nexport type NextPreviewBarOptions = {\n /** From `createPreviewBar` (`sanity-plugin-visual-editor/server`). */\n bar: PreviewBar\n /** A server Sanity client with a read token (e.g. `client.withConfig({token})`). */\n client: PreviewClient\n}\n\ntype RouteContext = {params: Promise<Record<string, string | string[] | undefined>>}\n\nfunction param(value: string | string[] | undefined) {\n return Array.isArray(value) ? value[0] : value\n}\n\n/** `next-sanity` and Next's draft mode use these attributes: `None; Secure` off localhost. */\nfunction cookieOptions(secure: boolean) {\n return {httpOnly: true, path: '/', sameSite: secure ? 'none' : 'lax', secure} as const\n}\n\nexport function createNextPreviewBar(options: NextPreviewBarOptions) {\n const {bar, client} = options\n const basePath = bar.options.basePath\n\n async function context(request: Request): Promise<PreviewContext> {\n const jar = await cookies()\n // The marker holds the link's expiry (seconds); a stale one doesn't count.\n const linkExpires = Number(jar.get(LINK_SESSION_COOKIE)?.value)\n return {\n request,\n previewEnabled: (await draftMode()).isEnabled,\n client,\n perspective: parsePerspective(jar.get(PERSPECTIVE_COOKIE)?.value),\n linkSession: Number.isFinite(linkExpires) && linkExpires * 1000 > Date.now(),\n }\n }\n\n /** A stand-in request for server components, which have headers but no `Request`. */\n async function currentRequest() {\n const list = await headers()\n const host = list.get('x-forwarded-host') ?? list.get('host') ?? 'localhost'\n const protocol =\n list.get('x-forwarded-proto') ?? (host.startsWith('localhost') ? 'http' : 'https')\n return new Request(`${protocol}://${host}${basePath}`, {headers: list})\n }\n\n async function handle(request: Request, {params}: RouteContext) {\n const action = param((await params).action)\n if (request.method === 'GET' && action === 'document') {\n return bar.pageDocument(await context(request))\n }\n if (request.method === 'GET' && action === 'resolve') {\n return bar.resolveHref(await context(request))\n }\n if (request.method === 'POST') {\n switch (action) {\n case 'perspective':\n return bar.perspective(await context(request))\n case 'share':\n return bar.share(await context(request))\n case 'exit':\n // Draft mode's own cookie goes through Next, which merges it into the response.\n return bar.exit({request}, async () => {\n ;(await draftMode()).disable()\n ;(await cookies()).delete(LINK_SESSION_COOKIE)\n })\n }\n }\n return new Response('Not found', {status: 404})\n }\n\n return {\n /** `app/__visual-editor/[action]/route.ts`: `export const {GET, POST} = previewBar.handlers`. */\n handlers: {GET: handle, POST: handle},\n\n /**\n * `app/__visual-editor/page.tsx`: the bar's data, or a 404 outside draft mode. Pass it to\n * `<PreviewBarFrame data={…} />`.\n */\n async loadBar(): Promise<PreviewBarData> {\n const data = await bar.loadBar(await context(await currentRequest()))\n if (!data) notFound()\n return data\n },\n\n /**\n * `app/p/[code]/page.tsx`: redirects a live link to the open handler; calls `notFound()` for\n * an unknown, malformed or expired one (render `<PreviewLinkErrorFrame expired />` in that\n * segment's `not-found.tsx`). Returns `'unavailable'` when the store can't be read, for the\n * page to render `<PreviewLinkErrorFrame expired={false} />`.\n */\n async checkLink(code: string): Promise<'unavailable'> {\n const result = await bar.resolveLink(code)\n if (result.status === 200) redirect(`${basePath}/open/${code}`)\n if (result.status === 404) notFound()\n return 'unavailable'\n },\n\n /**\n * `app/__visual-editor/open/[code]/route.ts`: `export const GET = previewBar.openLink`. Turns\n * draft mode on until the link expires, marks the session as opened from a link (so it can't\n * mint links), sets the stored perspective and redirects to the stored page; a link that has\n * gone meanwhile goes back to `/p/<code>` for the expired page.\n */\n async openLink(request: Request, {params}: RouteContext): Promise<Response> {\n const code = param((await params).code) ?? ''\n const result = await bar.resolveLink(code)\n if (result.status !== 200) redirect(`${bar.options.linkRoute}${code}`)\n const {expiresAt} = result.link\n const maxAge = Math.floor((expiresAt - Date.now()) / 1000)\n if (maxAge <= 0) redirect(`${bar.options.linkRoute}${code}`)\n const secure = new URL(request.url).protocol === 'https:'\n const options = cookieOptions(secure)\n const jar = await cookies()\n const draft = await draftMode()\n // A recipient already in draft mode (an editor) keeps their own session, unmarked.\n if (!draft.isEnabled) {\n draft.enable()\n // `enable()` sets a session cookie; set it again with the link's lifetime. Its value is\n // fixed per build, so this bounds the browser's copy, not a copy taken by hand.\n const bypass = jar.get(DRAFT_MODE_COOKIE)?.value\n if (bypass) jar.set(DRAFT_MODE_COOKIE, bypass, {...options, maxAge})\n jar.set(LINK_SESSION_COOKIE, String(Math.floor(expiresAt / 1000)), {...options, maxAge})\n }\n jar.set(PERSPECTIVE_COOKIE, serializePerspective(result.link.perspective), options)\n redirect(result.link.pathname)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,oBAAoB;AAW1B,SAAS,MAAM,OAAsC;CACnD,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;AAC3C;;AAGA,SAAS,cAAc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AAY,GAAI,CAAC,GAAG;KAAC,GAAG;KAAS;IAAM,CAAC;GACzF;GACA,IAAI,IAAI,oBAAoB,qBAAqB,OAAO,KAAK,WAAW,GAAG,OAAO,GAClF,SAAS,OAAO,KAAK,QAAQ;EAC/B;CACF;AACF"}
1
+ {"version":3,"file":"next.js","names":[],"sources":["../src/next/index.ts"],"sourcesContent":["/**\n * Next.js (App Router) adapter, for sites using `next-sanity`'s draft mode. Server side: route\n * handlers, the bar page's data, the short-link checks and the realtime preview hub. The client\n * components live in `sanity-plugin-visual-editor/next/client`. See the README for the routes.\n *\n * Live preview keeps Next's own model: Server Components fetch, and draft mode skips every cache.\n * In draft mode they read through the hub (`visualEditor.hub()`), which holds each result in\n * memory, Studio keystrokes included. The tab follows the hub over a WebSocket and calls\n * `router.refresh()` when a result it shows changes, so the Server Components run again and read\n * the new result. No `revalidateTag`: draft requests never touch the cache.\n *\n * Opening a short link takes two steps because a page can't set cookies while it renders:\n * `/p/[code]` checks the link (rendering the expired page with a 404 when it's gone) and redirects\n * live ones to `<basePath>/open/<code>`, a route handler that turns draft mode on and redirects to\n * the stored page.\n *\n * Draft mode is one cookie (`__prerender_bypass`) whose value is fixed per build, so a link's\n * recipient holds a value that turns draft mode on until the next deploy. `openLink` caps that\n * cookie's lifetime to the link's, and marks the session so it can't mint links, but a recipient\n * who copies the cookie by hand keeps draft mode until the next build. See the README.\n */\nimport {cookies, draftMode, headers} from 'next/headers'\nimport {notFound, redirect} from 'next/navigation'\n\nimport type {validatePreviewUrl} from '@sanity/preview-url-secret'\n\nimport type {PreviewBarData} from '../core/data'\nimport {parsePerspective, PERSPECTIVE_COOKIE, serializePerspective} from '../core/perspective'\nimport {\n createPreviewBar,\n createPreviewHubClient,\n createLiveTicket,\n createPreviewRoutes,\n previewHubName,\n type PreviewBar,\n type PreviewBarOptions,\n type PreviewClient,\n type PreviewContext,\n type PreviewHub,\n type PreviewHubFetcher,\n} from '../server'\nimport {LINK_SESSION_COOKIE} from '../server/link-session'\n\n/** Next's draft mode cookie. */\nconst DRAFT_MODE_COOKIE = '__prerender_bypass'\n\nexport type NextPreviewBarOptions = {\n /** From `createPreviewBar` (`sanity-plugin-visual-editor/server`). */\n bar: PreviewBar\n /** A server Sanity client with a read token (e.g. `client.withConfig({token})`). */\n client: PreviewClient\n}\n\ntype RouteContext = {params: Promise<Record<string, string | string[] | undefined>>}\n\nfunction param(value: string | string[] | undefined) {\n return Array.isArray(value) ? value[0] : value\n}\n\n/** `next-sanity` and Next's draft mode use these attributes: `None; Secure` off localhost. */\nfunction cookieOptions(secure: boolean) {\n return {httpOnly: true, path: '/', sameSite: secure ? 'none' : 'lax', secure} as const\n}\n\nexport function createNextPreviewBar(options: NextPreviewBarOptions) {\n const {bar, client} = options\n const basePath = bar.options.basePath\n\n async function context(request: Request): Promise<PreviewContext> {\n const jar = await cookies()\n // The marker holds the link's expiry (seconds); a stale one doesn't count.\n const linkExpires = Number(jar.get(LINK_SESSION_COOKIE)?.value)\n return {\n request,\n previewEnabled: (await draftMode()).isEnabled,\n client,\n perspective: parsePerspective(jar.get(PERSPECTIVE_COOKIE)?.value),\n linkSession: Number.isFinite(linkExpires) && linkExpires * 1000 > Date.now(),\n }\n }\n\n /** A stand-in request for server components, which have headers but no `Request`. */\n async function currentRequest() {\n const list = await headers()\n const host = list.get('x-forwarded-host') ?? list.get('host') ?? 'localhost'\n const protocol =\n list.get('x-forwarded-proto') ?? (host.startsWith('localhost') ? 'http' : 'https')\n return new Request(`${protocol}://${host}${basePath}`, {headers: list})\n }\n\n async function handle(request: Request, {params}: RouteContext) {\n const action = param((await params).action)\n if (request.method === 'GET' && action === 'document') {\n return bar.pageDocument(await context(request))\n }\n if (request.method === 'GET' && action === 'resolve') {\n return bar.resolveHref(await context(request))\n }\n if (request.method === 'POST') {\n switch (action) {\n case 'perspective':\n return bar.perspective(await context(request))\n case 'share':\n return bar.share(await context(request))\n case 'exit':\n // Draft mode's own cookie goes through Next, which merges it into the response.\n return bar.exit({request}, async () => {\n ;(await draftMode()).disable()\n ;(await cookies()).delete(LINK_SESSION_COOKIE)\n })\n }\n }\n return new Response('Not found', {status: 404})\n }\n\n return {\n /** `app/__visual-editor/[action]/route.ts`: `export const {GET, POST} = previewBar.handlers`. */\n handlers: {GET: handle, POST: handle},\n\n /**\n * `app/__visual-editor/page.tsx`: the bar's data, or a 404 outside draft mode. Pass it to\n * `<PreviewBarFrame data={…} />`.\n */\n async loadBar(): Promise<PreviewBarData> {\n const data = await bar.loadBar(await context(await currentRequest()))\n if (!data) notFound()\n return data\n },\n\n /**\n * `app/p/[code]/page.tsx`: redirects a live link to the open handler; calls `notFound()` for\n * an unknown, malformed or expired one (render `<PreviewLinkErrorFrame expired />` in that\n * segment's `not-found.tsx`). Returns `'unavailable'` when the store can't be read, for the\n * page to render `<PreviewLinkErrorFrame expired={false} />`.\n */\n async checkLink(code: string): Promise<'unavailable'> {\n const result = await bar.resolveLink(code)\n if (result.status === 200) redirect(`${basePath}/open/${code}`)\n if (result.status === 404) notFound()\n return 'unavailable'\n },\n\n /**\n * `app/__visual-editor/open/[code]/route.ts`: `export const GET = previewBar.openLink`. Turns\n * draft mode on until the link expires, marks the session as opened from a link (so it can't\n * mint links), sets the stored perspective and redirects to the stored page; a link that has\n * gone meanwhile goes back to `/p/<code>` for the expired page.\n */\n async openLink(request: Request, {params}: RouteContext): Promise<Response> {\n const code = param((await params).code) ?? ''\n const result = await bar.resolveLink(code)\n if (result.status !== 200) redirect(`${bar.options.linkRoute}${code}`)\n const {expiresAt} = result.link\n const maxAge = Math.floor((expiresAt - Date.now()) / 1000)\n if (maxAge <= 0) redirect(`${bar.options.linkRoute}${code}`)\n const secure = new URL(request.url).protocol === 'https:'\n const options = cookieOptions(secure)\n const jar = await cookies()\n const draft = await draftMode()\n // A recipient already in draft mode (an editor) keeps their own session, unmarked.\n if (!draft.isEnabled) {\n draft.enable()\n // `enable()` sets a session cookie; set it again with the link's lifetime. Its value is\n // fixed per build, so this bounds the browser's copy, not a copy taken by hand.\n const bypass = jar.get(DRAFT_MODE_COOKIE)?.value\n if (bypass) jar.set(DRAFT_MODE_COOKIE, bypass, {...options, maxAge})\n jar.set(LINK_SESSION_COOKIE, String(Math.floor(expiresAt / 1000)), {...options, maxAge})\n }\n jar.set(PERSPECTIVE_COOKIE, serializePerspective(result.link.perspective), options)\n redirect(result.link.pathname)\n },\n }\n}\n\nexport type NextPreviewBar = ReturnType<typeof createNextPreviewBar>\n\n/** What a draft-mode page hands its tab to follow the hub: see `PreviewBarHost`'s `live`. */\nexport type LiveTicket = {ticket: string}\n\nexport type NextVisualEditorOptions = PreviewBarOptions & {\n /** A server Sanity client with a read token (e.g. `client.withConfig({token})`). */\n client: PreviewClient & Parameters<typeof validatePreviewUrl>[0]\n /**\n * The realtime preview hub's service binding, e.g. `() => getCloudflareContext().env.PREVIEW_HUB`.\n * Without it (or when it returns `undefined`), there is no live preview: `live()` and `hub()`\n * return `null` and the site reads Sanity directly.\n */\n hub?: () => PreviewHubFetcher | undefined\n /**\n * Signs live tickets and the Studio's live-edit cookie; without it there is no live preview,\n * as without `hub`. The Worker entry (`createPreviewRoutes(...).upgrade`) must use the same value.\n */\n secret?: string | (() => string)\n /** The hub routes' base path. Default `/api/preview`. */\n routesPath?: string\n}\n\n/**\n * One-stop Next.js setup: the preview bar (`createPreviewBar` + `createNextPreviewBar`) and the\n * realtime preview hub. Route files re-export its handlers; see the README.\n */\nexport function createNextVisualEditor(options: NextVisualEditorOptions) {\n const {client, hub: hubBinding, secret, routesPath, ...barOptions} = options\n const bar = createNextPreviewBar({bar: createPreviewBar(barOptions), client})\n const getService = () => hubBinding?.()\n const {hubFor} = createPreviewHubClient(getService)\n const getSecret = () => (typeof secret === 'function' ? secret() : secret) ?? ''\n\n /** This request's hub name: draft mode on, a preview perspective, a hub binding and a secret. */\n async function requestHub(): Promise<string | null> {\n if (!hubBinding || !getService() || !getSecret()) return null\n if (!(await draftMode()).isEnabled) return null\n const perspective = parsePerspective((await cookies()).get(PERSPECTIVE_COOKIE)?.value)\n return previewHubName(perspective)\n }\n\n const routes = createPreviewRoutes({\n secret: getSecret,\n hub: getService,\n client,\n basePath: routesPath,\n fallbackHub: requestHub,\n })\n\n async function handleRoute(request: Request) {\n return (await routes.handle(request)) ?? new Response('Not found', {status: 404})\n }\n\n return {\n ...bar,\n bar,\n\n /** `app/api/preview/[...path]/route.ts`: `export const {GET, POST} = visualEditor.routes`. */\n routes: {GET: handleRoute, POST: handleRoute},\n\n /**\n * For the root layout, in draft mode: `<PreviewBarHost live={await visualEditor.live()} />`.\n * A signed ticket for this request's hub, or `null` when there is nothing to follow\n * (no hub binding, draft mode off, or the Published perspective). Fresh on every render, so a\n * perspective switch (which refreshes the page) moves the tab to the new hub.\n */\n async live(): Promise<LiveTicket | null> {\n const name = await requestHub()\n return name ? {ticket: await createLiveTicket(getSecret(), name)} : null\n },\n\n /**\n * For Server Components' reads in draft mode: this request's hub, or `null` (read Sanity as\n * usual). `await hub.query(query, params)` returns the result, unsaved Studio edits included.\n */\n async hub(): Promise<PreviewHub | null> {\n const name = await requestHub()\n return name ? hubFor(name) : null\n },\n }\n}\n\nexport type NextVisualEditor = ReturnType<typeof createNextVisualEditor>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAM,oBAAoB;AAW1B,SAAS,MAAM,OAAsC;CACnD,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;AAC3C;;AAGA,SAAS,cAAc,QAAiB;CACtC,OAAO;EAAC,UAAU;EAAM,MAAM;EAAK,UAAU,SAAS,SAAS;EAAO;CAAM;AAC9E;AAEA,SAAgB,qBAAqB,SAAgC;CACnE,IAAM,EAAC,KAAK,WAAU,SAChB,WAAW,IAAI,QAAQ;CAE7B,eAAe,QAAQ,SAA2C;EAChE,IAAM,MAAM,MAAM,QAAQ,GAEpB,cAAc,OAAO,IAAI,IAAI,mBAAmB,CAAC,EAAE,KAAK;EAC9D,OAAO;GACL;GACA,iBAAiB,MAAM,UA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