@prismicio/next 2.3.3-pr.164.c2620e4 → 2.3.3-pr.165.b556bb0
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/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/{router-pages → pages}/PrismicPreview.cjs +1 -1
- package/dist/pages/PrismicPreview.cjs.map +1 -0
- package/dist/{router-pages → pages}/PrismicPreview.d.cts +1 -1
- package/dist/pages/PrismicPreview.d.cts.map +1 -0
- package/dist/{router-pages → pages}/PrismicPreview.d.ts +1 -1
- package/dist/pages/PrismicPreview.d.ts.map +1 -0
- package/dist/{router-pages → pages}/PrismicPreview.js +1 -1
- package/dist/pages/PrismicPreview.js.map +1 -0
- package/dist/{router-pages → pages}/SliceSimulator.cjs +1 -1
- package/dist/pages/SliceSimulator.cjs.map +1 -0
- package/dist/{router-pages → pages}/SliceSimulator.d.cts +1 -1
- package/dist/pages/SliceSimulator.d.cts.map +1 -0
- package/dist/{router-pages → pages}/SliceSimulator.d.ts +1 -1
- package/dist/pages/SliceSimulator.d.ts.map +1 -0
- package/dist/{router-pages → pages}/SliceSimulator.js +1 -1
- package/dist/pages/SliceSimulator.js.map +1 -0
- package/dist/{router-pages → pages}/enableAutoPreviews.cjs +1 -1
- package/dist/pages/enableAutoPreviews.cjs.map +1 -0
- package/dist/{router-pages → pages}/enableAutoPreviews.d.cts +1 -1
- package/dist/pages/enableAutoPreviews.d.cts.map +1 -0
- package/dist/{router-pages → pages}/enableAutoPreviews.d.ts +1 -1
- package/dist/pages/enableAutoPreviews.d.ts.map +1 -0
- package/dist/{router-pages → pages}/enableAutoPreviews.js +1 -1
- package/dist/pages/enableAutoPreviews.js.map +1 -0
- package/dist/{router-pages → pages}/exitPreview.cjs +1 -1
- package/dist/pages/exitPreview.cjs.map +1 -0
- package/dist/{router-pages → pages}/exitPreview.d.cts +1 -1
- package/dist/pages/exitPreview.d.cts.map +1 -0
- package/dist/{router-pages → pages}/exitPreview.d.ts +1 -1
- package/dist/pages/exitPreview.d.ts.map +1 -0
- package/dist/{router-pages → pages}/exitPreview.js +1 -1
- package/dist/pages/exitPreview.js.map +1 -0
- package/dist/{router-pages → pages}/redirectToPreviewURL.cjs +1 -1
- package/dist/pages/redirectToPreviewURL.cjs.map +1 -0
- package/dist/{router-pages → pages}/redirectToPreviewURL.d.cts +1 -1
- package/dist/pages/redirectToPreviewURL.d.cts.map +1 -0
- package/dist/{router-pages → pages}/redirectToPreviewURL.d.ts +1 -1
- package/dist/pages/redirectToPreviewURL.d.ts.map +1 -0
- package/dist/{router-pages → pages}/redirectToPreviewURL.js +1 -1
- package/dist/pages/redirectToPreviewURL.js.map +1 -0
- package/dist/{router-pages → pages}/setPreviewData.cjs +1 -1
- package/dist/pages/setPreviewData.cjs.map +1 -0
- package/dist/{router-pages → pages}/setPreviewData.d.cts +1 -1
- package/dist/pages/setPreviewData.d.cts.map +1 -0
- package/dist/{router-pages → pages}/setPreviewData.d.ts +1 -1
- package/dist/pages/setPreviewData.d.ts.map +1 -0
- package/dist/{router-pages → pages}/setPreviewData.js +1 -1
- package/dist/pages/setPreviewData.js.map +1 -0
- package/dist/{router-pages → pages}/types.d.cts +1 -1
- package/dist/pages/types.d.cts.map +1 -0
- package/dist/{router-pages → pages}/types.d.ts +1 -1
- package/dist/pages/types.d.ts.map +1 -0
- package/dist/{router-pages.cjs → pages.cjs} +6 -6
- package/dist/{router-pages.d.cts → pages.d.cts} +7 -7
- package/dist/{router-pages.d.ts → pages.d.ts} +7 -7
- package/dist/pages.js +11 -0
- package/package.json +3 -4
- package/dist/router-pages/PrismicPreview.cjs.map +0 -1
- package/dist/router-pages/PrismicPreview.d.cts.map +0 -1
- package/dist/router-pages/PrismicPreview.d.ts.map +0 -1
- package/dist/router-pages/PrismicPreview.js.map +0 -1
- package/dist/router-pages/SliceSimulator.cjs.map +0 -1
- package/dist/router-pages/SliceSimulator.d.cts.map +0 -1
- package/dist/router-pages/SliceSimulator.d.ts.map +0 -1
- package/dist/router-pages/SliceSimulator.js.map +0 -1
- package/dist/router-pages/enableAutoPreviews.cjs.map +0 -1
- package/dist/router-pages/enableAutoPreviews.d.cts.map +0 -1
- package/dist/router-pages/enableAutoPreviews.d.ts.map +0 -1
- package/dist/router-pages/enableAutoPreviews.js.map +0 -1
- package/dist/router-pages/exitPreview.cjs.map +0 -1
- package/dist/router-pages/exitPreview.d.cts.map +0 -1
- package/dist/router-pages/exitPreview.d.ts.map +0 -1
- package/dist/router-pages/exitPreview.js.map +0 -1
- package/dist/router-pages/redirectToPreviewURL.cjs.map +0 -1
- package/dist/router-pages/redirectToPreviewURL.d.cts.map +0 -1
- package/dist/router-pages/redirectToPreviewURL.d.ts.map +0 -1
- package/dist/router-pages/redirectToPreviewURL.js.map +0 -1
- package/dist/router-pages/setPreviewData.cjs.map +0 -1
- package/dist/router-pages/setPreviewData.d.cts.map +0 -1
- package/dist/router-pages/setPreviewData.d.ts.map +0 -1
- package/dist/router-pages/setPreviewData.js.map +0 -1
- package/dist/router-pages/types.d.cts.map +0 -1
- package/dist/router-pages/types.d.ts.map +0 -1
- package/dist/router-pages.js +0 -11
- /package/src/{router-pages → pages}/PrismicPreview.tsx +0 -0
- /package/src/{router-pages → pages}/SliceSimulator.tsx +0 -0
- /package/src/{router-pages → pages}/enableAutoPreviews.ts +0 -0
- /package/src/{router-pages → pages}/exitPreview.ts +0 -0
- /package/src/{router-pages → pages}/index.ts +0 -0
- /package/src/{router-pages → pages}/redirectToPreviewURL.ts +0 -0
- /package/src/{router-pages → pages}/setPreviewData.ts +0 -0
- /package/src/{router-pages → pages}/types.ts +0 -0
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
|
@@ -5,7 +5,7 @@ next_script_js = require_runtime.__toESM(next_script_js, 1);
|
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
let next_router_js = require("next/router.js");
|
|
8
|
-
//#region src/
|
|
8
|
+
//#region src/pages/PrismicPreview.tsx
|
|
9
9
|
/**
|
|
10
10
|
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
11
11
|
* send events to the browser, such as on preview updates and exiting, this component will
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreview.cjs","names":["useRouter","getToolbarSrc","Script","prismicCookie"],"sources":["../../src/pages/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc, cookie as prismicCookie } from \"@prismicio/client\"\nimport { useRouter } from \"next/router\"\nimport Script from \"next/script\"\nimport type { FC } from \"react\"\nimport { type ReactNode, useEffect } from \"react\"\n\n/** Props for `<PrismicPreview>`. */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be\n\t * fetched on preview exit events.\n\t */\n\texitPreviewURL?: string\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: ReactNode\n}\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * rendered on every page.\n */\nexport const PrismicPreview: FC<PrismicPreviewProps> = (props) => {\n\tconst {\n\t\trepositoryName,\n\t\tupdatePreviewURL = \"/api/preview\",\n\t\texitPreviewURL = \"/api/exit-preview\",\n\t\tchildren,\n\t} = props\n\n\tconst router = useRouter()\n\n\tconst toolbarSrc = getToolbarSrc(repositoryName)\n\n\tuseEffect(() => {\n\t\tconst controller = new AbortController()\n\n\t\twindow.addEventListener(\"prismicPreviewUpdate\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\t\twindow.addEventListener(\"prismicPreviewEnd\", onEnd, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\n\t\t// Start the preview for preview share links. Previews from\n\t\t// share links do not go to the `updatePreviewURL` like a normal\n\t\t// preview.\n\t\t//\n\t\t// We check that the current URL is a descendant of the base\n\t\t// path to prevent infinite refrehes.\n\t\tif (\n\t\t\twindow.location.href.startsWith(window.location.origin + router.basePath) &&\n\t\t\tgetPreviewCookieRepositoryName() === repositoryName &&\n\t\t\t!router.isPreview\n\t\t) {\n\t\t\tstart()\n\t\t}\n\n\t\tfunction onEnd(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tfetch(router.basePath + exitPreviewURL, { signal: controller.signal })\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (!res.ok) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${exitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {})\n\t\t}\n\n\t\tfunction onUpdate(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tstart()\n\t\t}\n\n\t\tfunction start() {\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and at least\n\t\t\t// attempted to set preview data.\n\t\t\tfetch(router.basePath + updatePreviewURL, {\n\t\t\t\tredirect: \"manual\",\n\t\t\t\tsignal: controller.signal,\n\t\t\t})\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (res.type !== \"opaqueredirect\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to start or update the preview using \"${updatePreviewURL}\". Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {})\n\t\t}\n\n\t\tfunction refresh() {\n\t\t\trouter.replace(router.asPath, undefined, { scroll: false })\n\t\t}\n\n\t\treturn () => controller.abort()\n\t}, [exitPreviewURL, updatePreviewURL, repositoryName, router])\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t)\n}\n\nfunction getPreviewCookieRepositoryName() {\n\tconst cookie = window.document.cookie\n\t\t.split(\"; \")\n\t\t.find((row) => row.startsWith(`${prismicCookie.preview}=`))\n\t\t?.split(\"=\")[1]\n\n\treturn (decodeURIComponent(cookie ?? \"\").match(/\"([^\"]+)\\.prismic\\.io\"/) || [])[1]\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsCA,MAAa,kBAA2C,UAAU;CACjE,MAAM,EACL,gBACA,mBAAmB,gBACnB,iBAAiB,qBACjB,aACG;CAEJ,MAAM,UAAA,GAASA,eAAAA,UAAAA,CAAU;CAEzB,MAAM,cAAA,GAAaC,kBAAAA,cAAAA,CAAc,cAAc;CAE/C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACf,MAAM,aAAa,IAAI,gBAAgB;EAEvC,OAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,OACpB,CAAC;EACD,OAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,OACpB,CAAC;EAQD,IACC,OAAO,SAAS,KAAK,WAAW,OAAO,SAAS,SAAS,OAAO,QAAQ,KACxE,+BAA+B,MAAM,kBACrC,CAAC,OAAO,WAER,MAAM;EAGP,SAAS,MAAM,OAAc;GAC5B,MAAM,eAAe;GACrB,MAAM,OAAO,WAAW,gBAAgB,EAAE,QAAQ,WAAW,OAAO,CAAC,CAAC,CACpE,MAAM,QAAQ;IACd,IAAI,CAAC,IAAI,IAAI;KACZ,QAAQ,MACP,6DAA6D,eAAe,+BAC7E;KAEA;IACD;IAEA,QAAQ;GACT,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACjB;EAEA,SAAS,SAAS,OAAc;GAC/B,MAAM,eAAe;GACrB,MAAM;EACP;EAEA,SAAS,QAAQ;GAKhB,MAAM,OAAO,WAAW,kBAAkB;IACzC,UAAU;IACV,QAAQ,WAAW;GACpB,CAAC,CAAC,CACA,MAAM,QAAQ;IACd,IAAI,IAAI,SAAS,kBAAkB;KAClC,QAAQ,MACP,mEAAmE,iBAAiB,kBACrF;KAEA;IACD;IAEA,QAAQ;GACT,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACjB;EAEA,SAAS,UAAU;GAClB,OAAO,QAAQ,OAAO,QAAQ,KAAA,GAAW,EAAE,QAAQ,MAAM,CAAC;EAC3D;EAEA,aAAa,WAAW,MAAM;CAC/B,GAAG;EAAC;EAAgB;EAAkB;EAAgB;CAAM,CAAC;CAE7D,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA,CACE,UACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,eAAAA,SAAD;EAAQ,KAAK;EAAY,UAAS;CAAc,CAAA,CAC/C,EAAA,CAAA;AAEJ;AAEA,SAAS,iCAAiC;CACzC,MAAM,SAAS,OAAO,SAAS,OAC7B,MAAM,IAAI,CAAC,CACX,MAAM,QAAQ,IAAI,WAAW,GAAGC,kBAAAA,OAAc,QAAQ,EAAE,CAAC,CAAC,EACzD,MAAM,GAAG,CAAC,CAAC;CAEd,QAAQ,mBAAmB,UAAU,EAAE,CAAC,CAAC,MAAM,wBAAwB,KAAK,CAAC,EAAA,CAAG;AACjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreview.d.cts","names":[],"sources":["../../src/pages/PrismicPreview.tsx"],"mappings":";;;YAOY;;;;;EAKX;;;;;EAMA;;;;;EAMA;;EAGA,WAAW;;;;;;;;;;qBAWC,gBAAgB,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreview.d.ts","names":[],"sources":["../../src/pages/PrismicPreview.tsx"],"mappings":";;;YAOY;;;;;EAKX;;;;;EAMA;;;;;EAMA;;EAGA,WAAW;;;;;;;;;;qBAWC,gBAAgB,GAAG"}
|
|
@@ -3,7 +3,7 @@ import Script from "next/script.js";
|
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { useRouter } from "next/router.js";
|
|
6
|
-
//#region src/
|
|
6
|
+
//#region src/pages/PrismicPreview.tsx
|
|
7
7
|
/**
|
|
8
8
|
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
9
9
|
* send events to the browser, such as on preview updates and exiting, this component will
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreview.js","names":["cookie","prismicCookie"],"sources":["../../src/pages/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc, cookie as prismicCookie } from \"@prismicio/client\"\nimport { useRouter } from \"next/router\"\nimport Script from \"next/script\"\nimport type { FC } from \"react\"\nimport { type ReactNode, useEffect } from \"react\"\n\n/** Props for `<PrismicPreview>`. */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be\n\t * fetched on preview exit events.\n\t */\n\texitPreviewURL?: string\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: ReactNode\n}\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * rendered on every page.\n */\nexport const PrismicPreview: FC<PrismicPreviewProps> = (props) => {\n\tconst {\n\t\trepositoryName,\n\t\tupdatePreviewURL = \"/api/preview\",\n\t\texitPreviewURL = \"/api/exit-preview\",\n\t\tchildren,\n\t} = props\n\n\tconst router = useRouter()\n\n\tconst toolbarSrc = getToolbarSrc(repositoryName)\n\n\tuseEffect(() => {\n\t\tconst controller = new AbortController()\n\n\t\twindow.addEventListener(\"prismicPreviewUpdate\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\t\twindow.addEventListener(\"prismicPreviewEnd\", onEnd, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\n\t\t// Start the preview for preview share links. Previews from\n\t\t// share links do not go to the `updatePreviewURL` like a normal\n\t\t// preview.\n\t\t//\n\t\t// We check that the current URL is a descendant of the base\n\t\t// path to prevent infinite refrehes.\n\t\tif (\n\t\t\twindow.location.href.startsWith(window.location.origin + router.basePath) &&\n\t\t\tgetPreviewCookieRepositoryName() === repositoryName &&\n\t\t\t!router.isPreview\n\t\t) {\n\t\t\tstart()\n\t\t}\n\n\t\tfunction onEnd(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tfetch(router.basePath + exitPreviewURL, { signal: controller.signal })\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (!res.ok) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${exitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {})\n\t\t}\n\n\t\tfunction onUpdate(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tstart()\n\t\t}\n\n\t\tfunction start() {\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and at least\n\t\t\t// attempted to set preview data.\n\t\t\tfetch(router.basePath + updatePreviewURL, {\n\t\t\t\tredirect: \"manual\",\n\t\t\t\tsignal: controller.signal,\n\t\t\t})\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (res.type !== \"opaqueredirect\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to start or update the preview using \"${updatePreviewURL}\". Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {})\n\t\t}\n\n\t\tfunction refresh() {\n\t\t\trouter.replace(router.asPath, undefined, { scroll: false })\n\t\t}\n\n\t\treturn () => controller.abort()\n\t}, [exitPreviewURL, updatePreviewURL, repositoryName, router])\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t)\n}\n\nfunction getPreviewCookieRepositoryName() {\n\tconst cookie = window.document.cookie\n\t\t.split(\"; \")\n\t\t.find((row) => row.startsWith(`${prismicCookie.preview}=`))\n\t\t?.split(\"=\")[1]\n\n\treturn (decodeURIComponent(cookie ?? \"\").match(/\"([^\"]+)\\.prismic\\.io\"/) || [])[1]\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAa,kBAA2C,UAAU;CACjE,MAAM,EACL,gBACA,mBAAmB,gBACnB,iBAAiB,qBACjB,aACG;CAEJ,MAAM,SAAS,UAAU;CAEzB,MAAM,aAAa,cAAc,cAAc;CAE/C,gBAAgB;EACf,MAAM,aAAa,IAAI,gBAAgB;EAEvC,OAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,OACpB,CAAC;EACD,OAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,OACpB,CAAC;EAQD,IACC,OAAO,SAAS,KAAK,WAAW,OAAO,SAAS,SAAS,OAAO,QAAQ,KACxE,+BAA+B,MAAM,kBACrC,CAAC,OAAO,WAER,MAAM;EAGP,SAAS,MAAM,OAAc;GAC5B,MAAM,eAAe;GACrB,MAAM,OAAO,WAAW,gBAAgB,EAAE,QAAQ,WAAW,OAAO,CAAC,CAAC,CACpE,MAAM,QAAQ;IACd,IAAI,CAAC,IAAI,IAAI;KACZ,QAAQ,MACP,6DAA6D,eAAe,+BAC7E;KAEA;IACD;IAEA,QAAQ;GACT,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACjB;EAEA,SAAS,SAAS,OAAc;GAC/B,MAAM,eAAe;GACrB,MAAM;EACP;EAEA,SAAS,QAAQ;GAKhB,MAAM,OAAO,WAAW,kBAAkB;IACzC,UAAU;IACV,QAAQ,WAAW;GACpB,CAAC,CAAC,CACA,MAAM,QAAQ;IACd,IAAI,IAAI,SAAS,kBAAkB;KAClC,QAAQ,MACP,mEAAmE,iBAAiB,kBACrF;KAEA;IACD;IAEA,QAAQ;GACT,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACjB;EAEA,SAAS,UAAU;GAClB,OAAO,QAAQ,OAAO,QAAQ,KAAA,GAAW,EAAE,QAAQ,MAAM,CAAC;EAC3D;EAEA,aAAa,WAAW,MAAM;CAC/B,GAAG;EAAC;EAAgB;EAAkB;EAAgB;CAAM,CAAC;CAE7D,OACC,qBAAA,UAAA,EAAA,UAAA,CACE,UACD,oBAAC,QAAD;EAAQ,KAAK;EAAY,UAAS;CAAc,CAAA,CAC/C,EAAA,CAAA;AAEJ;AAEA,SAAS,iCAAiC;CACzC,MAAMA,WAAS,OAAO,SAAS,OAC7B,MAAM,IAAI,CAAC,CACX,MAAM,QAAQ,IAAI,WAAW,GAAGC,OAAc,QAAQ,EAAE,CAAC,CAAC,EACzD,MAAM,GAAG,CAAC,CAAC;CAEd,QAAQ,mBAAmBD,YAAU,EAAE,CAAC,CAAC,MAAM,wBAAwB,KAAK,CAAC,EAAA,CAAG;AACjF"}
|
|
@@ -2,7 +2,7 @@ const require_SliceSimulatorWrapper = require("../SliceSimulatorWrapper.cjs");
|
|
|
2
2
|
let react = require("react");
|
|
3
3
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
4
|
let _prismicio_simulator_kit = require("@prismicio/simulator/kit");
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/pages/SliceSimulator.tsx
|
|
6
6
|
const simulatorManager = new _prismicio_simulator_kit.SimulatorManager();
|
|
7
7
|
/**
|
|
8
8
|
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","useState","getDefaultSlices","getDefaultMessage","StateEventType","SliceSimulatorWrapper"],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\"\nimport type {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n} from \"@prismicio/simulator/kit\"\nimport { useEffect, useState } from \"react\"\nimport type { ComponentType, FC } from \"react\"\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\"\n\nconst simulatorManager = new SimulatorManager()\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"]\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t * \t;```tsx\n\t * \timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\"\n\t * \timport { SliceZone } from \"@prismicio/react\"\n\t *\n\t * \timport { components } from \"../slices\"\n\t *\n\t * \t;<SliceSimulator\n\t * \t\tsliceZone={({ slices }) => <SliceZone slices={slices} components={components} />}\n\t * \t/>\n\t * \t```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>\n\tclassName?: string\n}\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine\n * and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tbackground,\n\tzIndex,\n\tclassName,\n\tsliceZone: SliceZoneComp,\n}) => {\n\tconst [slices, setSlices] = useState(() => getDefaultSlices())\n\tconst [message, setMessage] = useState(() => getDefaultMessage())\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices)\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t)\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message)\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t)\n\n\t\tsimulatorManager.init()\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\")\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\")\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={slices.length > 0}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<SliceZoneComp slices={slices} />\n\t\t</SliceSimulatorWrapper>\n\t)\n}\n"],"mappings":";;;;;AAeA,MAAM,mBAAmB,IAAIA,yBAAAA,iBAAiB;;;;;AA8B9C,MAAa,kBAA2C,EACvD,YACA,QACA,WACA,WAAW,oBACN;CACL,MAAM,CAAC,QAAQ,cAAA,GAAaC,MAAAA,SAAAA,QAAAA,GAAeC,yBAAAA,iBAAAA,CAAiB,CAAC;CAC7D,MAAM,CAAC,SAAS,eAAA,GAAcD,MAAAA,SAAAA,QAAAA,GAAeE,yBAAAA,kBAAAA,CAAkB,CAAC;CAEhE,CAAA,GAAA,MAAA,UAAA,OAAgB;EACf,iBAAiB,MAAM,GACtBC,yBAAAA,eAAe,SACd,YAAY;GACZ,UAAU,OAAO;EAClB,GACA,kBACD;EACA,iBAAiB,MAAM,GACtBA,yBAAAA,eAAe,UACd,aAAa;GACb,WAAW,QAAQ;EACpB,GACA,mBACD;EAEA,iBAAiB,KAAK;EAEtB,aAAa;GACZ,iBAAiB,MAAM,IAAIA,yBAAAA,eAAe,QAAQ,kBAAkB;GAEpE,iBAAiB,MAAM,IAAIA,yBAAAA,eAAe,SAAS,mBAAmB;EACvE;CACD,GAAG,CAAC,CAAC;CAEL,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,uBAAD;EACU;EACT,WAAW,OAAO,SAAS;EACf;EACJ;EACG;EAEX,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAD,EAAuB,OAAS,CAAA;CACV,CAAA;AAEzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentType, FC } from "react";
|
|
2
2
|
import { SliceSimulatorProps, SliceSimulatorState } from "@prismicio/simulator/kit";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/pages/SliceSimulator.d.ts
|
|
4
4
|
export type SliceSimulatorSliceZoneProps = {
|
|
5
5
|
slices: SliceSimulatorState["slices"];
|
|
6
6
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.d.cts","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"mappings":";;;YAiBY;EACX,QAAQ;;KAGG,wBAAsB;;;;;;;;;;;;;;;;EAgBjC,WAAW,cAAc;EACzB;;;;;;qBAOY,gBAAgB,GAAG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentType, FC } from "react";
|
|
2
2
|
import { SliceSimulatorProps, SliceSimulatorState } from "@prismicio/simulator/kit";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/pages/SliceSimulator.d.ts
|
|
4
4
|
export type SliceSimulatorSliceZoneProps = {
|
|
5
5
|
slices: SliceSimulatorState["slices"];
|
|
6
6
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.d.ts","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"mappings":";;;YAiBY;EACX,QAAQ;;KAGG,wBAAsB;;;;;;;;;;;;;;;;EAgBjC,WAAW,cAAc;EACzB;;;;;;qBAOY,gBAAgB,GAAG"}
|
|
@@ -2,7 +2,7 @@ import { SliceSimulatorWrapper } from "../SliceSimulatorWrapper.js";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { SimulatorManager, StateEventType, getDefaultMessage, getDefaultSlices } from "@prismicio/simulator/kit";
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/pages/SliceSimulator.tsx
|
|
6
6
|
const simulatorManager = new SimulatorManager();
|
|
7
7
|
/**
|
|
8
8
|
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\"\nimport type {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n} from \"@prismicio/simulator/kit\"\nimport { useEffect, useState } from \"react\"\nimport type { ComponentType, FC } from \"react\"\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\"\n\nconst simulatorManager = new SimulatorManager()\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"]\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t * \t;```tsx\n\t * \timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\"\n\t * \timport { SliceZone } from \"@prismicio/react\"\n\t *\n\t * \timport { components } from \"../slices\"\n\t *\n\t * \t;<SliceSimulator\n\t * \t\tsliceZone={({ slices }) => <SliceZone slices={slices} components={components} />}\n\t * \t/>\n\t * \t```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>\n\tclassName?: string\n}\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine\n * and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tbackground,\n\tzIndex,\n\tclassName,\n\tsliceZone: SliceZoneComp,\n}) => {\n\tconst [slices, setSlices] = useState(() => getDefaultSlices())\n\tconst [message, setMessage] = useState(() => getDefaultMessage())\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices)\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t)\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message)\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t)\n\n\t\tsimulatorManager.init()\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\")\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\")\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={slices.length > 0}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<SliceZoneComp slices={slices} />\n\t\t</SliceSimulatorWrapper>\n\t)\n}\n"],"mappings":";;;;;AAeA,MAAM,mBAAmB,IAAI,iBAAiB;;;;;AA8B9C,MAAa,kBAA2C,EACvD,YACA,QACA,WACA,WAAW,oBACN;CACL,MAAM,CAAC,QAAQ,aAAa,eAAe,iBAAiB,CAAC;CAC7D,MAAM,CAAC,SAAS,cAAc,eAAe,kBAAkB,CAAC;CAEhE,gBAAgB;EACf,iBAAiB,MAAM,GACtB,eAAe,SACd,YAAY;GACZ,UAAU,OAAO;EAClB,GACA,kBACD;EACA,iBAAiB,MAAM,GACtB,eAAe,UACd,aAAa;GACb,WAAW,QAAQ;EACpB,GACA,mBACD;EAEA,iBAAiB,KAAK;EAEtB,aAAa;GACZ,iBAAiB,MAAM,IAAI,eAAe,QAAQ,kBAAkB;GAEpE,iBAAiB,MAAM,IAAI,eAAe,SAAS,mBAAmB;EACvE;CACD,GAAG,CAAC,CAAC;CAEL,OACC,oBAAC,uBAAD;EACU;EACT,WAAW,OAAO,SAAS;EACf;EACJ;EACG;EAEX,UAAA,oBAAC,eAAD,EAAuB,OAAS,CAAA;CACV,CAAA;AAEzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/pages/enableAutoPreviews.ts
|
|
2
2
|
/**
|
|
3
3
|
* Configures a Prismic client to automatically query draft content during a preview session. It
|
|
4
4
|
* either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableAutoPreviews.cjs","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"sourcesContent":["import type { Client } from \"@prismicio/client\"\nimport type { PreviewData } from \"next\"\n\nimport type { NextApiRequestLike } from \"./types\"\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig = {\n\t/** Prismic client with which automatic previews will be enabled. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"queryContentFromRef\" | \"enableAutoPreviewsFromReq\">\n\n\t/**\n\t * The `previewData` object provided in the `getStaticProps()` or `getServerSideProps()` context\n\t * object.\n\t */\n\tpreviewData?: PreviewData\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n}\n\n/**\n * Configures a Prismic client to automatically query draft content during a preview session. It\n * either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request\n * object.\n *\n * @param config - Configuration for the function.\n */\nexport function enableAutoPreviews(config: EnableAutoPreviewsConfig): void {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// Assume we are in `getStaticProps()` or\n\t\t// `getServerSideProps()` with active Preview Mode.\n\n\t\tif (isPrismicPreviewData(config.previewData)) {\n\t\t\tconfig.client.queryContentFromRef(config.previewData.ref)\n\t\t}\n\n\t\treturn\n\t}\n\n\tif (\"req\" in config && config.req) {\n\t\t// Assume we are in an API Route.\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req)\n\n\t\treturn\n\t}\n}\n\nfunction isPrismicPreviewData(input: unknown): input is { ref: string } {\n\treturn typeof input === \"object\" && input !== null && \"ref\" in input\n}\n"],"mappings":";;;;;;;;AAsCA,SAAgB,mBAAmB,QAAwC;CAC1E,IAAI,iBAAiB,UAAU,OAAO,aAAa;EAIlD,IAAI,qBAAqB,OAAO,WAAW,GAC1C,OAAO,OAAO,oBAAoB,OAAO,YAAY,GAAG;EAGzD;CACD;CAEA,IAAI,SAAS,UAAU,OAAO,KAAK;EAGlC,OAAO,OAAO,0BAA0B,OAAO,GAAG;EAElD;CACD;AACD;AAEA,SAAS,qBAAqB,OAA0C;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;AAChE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextApiRequestLike } from "./types.cjs";
|
|
2
2
|
import { Client } from "@prismicio/client";
|
|
3
3
|
import { PreviewData } from "next";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/pages/enableAutoPreviews.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Configuration for `enableAutoPreviews`.
|
|
7
7
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableAutoPreviews.d.cts","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"mappings":";;;;;;;;;YAUY;;EAKX,QAAQ,KAAK;;;;;EAMb,cAAc;;;;;;EAOd,MAAM;;;;;;;;;wBAUS,mBAAmB,QAAQ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextApiRequestLike } from "./types.js";
|
|
2
2
|
import { Client } from "@prismicio/client";
|
|
3
3
|
import { PreviewData } from "next";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/pages/enableAutoPreviews.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Configuration for `enableAutoPreviews`.
|
|
7
7
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableAutoPreviews.d.ts","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"mappings":";;;;;;;;;YAUY;;EAKX,QAAQ,KAAK;;;;;EAMb,cAAc;;;;;;EAOd,MAAM;;;;;;;;;wBAUS,mBAAmB,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/pages/enableAutoPreviews.ts
|
|
2
2
|
/**
|
|
3
3
|
* Configures a Prismic client to automatically query draft content during a preview session. It
|
|
4
4
|
* either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableAutoPreviews.js","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"sourcesContent":["import type { Client } from \"@prismicio/client\"\nimport type { PreviewData } from \"next\"\n\nimport type { NextApiRequestLike } from \"./types\"\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig = {\n\t/** Prismic client with which automatic previews will be enabled. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"queryContentFromRef\" | \"enableAutoPreviewsFromReq\">\n\n\t/**\n\t * The `previewData` object provided in the `getStaticProps()` or `getServerSideProps()` context\n\t * object.\n\t */\n\tpreviewData?: PreviewData\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n}\n\n/**\n * Configures a Prismic client to automatically query draft content during a preview session. It\n * either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request\n * object.\n *\n * @param config - Configuration for the function.\n */\nexport function enableAutoPreviews(config: EnableAutoPreviewsConfig): void {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// Assume we are in `getStaticProps()` or\n\t\t// `getServerSideProps()` with active Preview Mode.\n\n\t\tif (isPrismicPreviewData(config.previewData)) {\n\t\t\tconfig.client.queryContentFromRef(config.previewData.ref)\n\t\t}\n\n\t\treturn\n\t}\n\n\tif (\"req\" in config && config.req) {\n\t\t// Assume we are in an API Route.\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req)\n\n\t\treturn\n\t}\n}\n\nfunction isPrismicPreviewData(input: unknown): input is { ref: string } {\n\treturn typeof input === \"object\" && input !== null && \"ref\" in input\n}\n"],"mappings":";;;;;;;;AAsCA,SAAgB,mBAAmB,QAAwC;CAC1E,IAAI,iBAAiB,UAAU,OAAO,aAAa;EAIlD,IAAI,qBAAqB,OAAO,WAAW,GAC1C,OAAO,OAAO,oBAAoB,OAAO,YAAY,GAAG;EAGzD;CACD;CAEA,IAAI,SAAS,UAAU,OAAO,KAAK;EAGlC,OAAO,OAAO,0BAA0B,OAAO,GAAG;EAElD;CACD;AACD;AAEA,SAAS,qBAAqB,OAA0C;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;AAChE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exitPreview.cjs","names":[],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\tconfig.res.setHeader(\"Cache-Control\", \"no-store\")\n\n\tconfig.res.json({ success: true })\n\n\treturn\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAgB,YAAY,QAAyC;CACpE,OAAO,IAAI,iBAAiB;CAG5B,OAAO,IAAI,UAAU,iBAAiB,UAAU;CAEhD,OAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC;AAGlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exitPreview.d.cts","names":[],"sources":["../../src/pages/exitPreview.ts"],"mappings":";;;YAGY;;;;;;EAMX,MAAM;;;;;;EAON,KAAK;;;;;;;;;;;;;;;;;wBAkBU,YAAY,QAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exitPreview.d.ts","names":[],"sources":["../../src/pages/exitPreview.ts"],"mappings":";;;YAGY;;;;;;EAMX,MAAM;;;;;;EAON,KAAK;;;;;;;;;;;;;;;;;wBAkBU,YAAY,QAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exitPreview.js","names":[],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\tconfig.res.setHeader(\"Cache-Control\", \"no-store\")\n\n\tconfig.res.json({ success: true })\n\n\treturn\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAgB,YAAY,QAAyC;CACpE,OAAO,IAAI,iBAAiB;CAG5B,OAAO,IAAI,UAAU,iBAAiB,UAAU;CAEhD,OAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC;AAGlC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/pages/redirectToPreviewURL.ts
|
|
2
2
|
async function redirectToPreviewURL(config) {
|
|
3
3
|
const { client, req, res, linkResolver, defaultURL = "/", basePath = "" } = config;
|
|
4
4
|
const previewToken = req.query.token?.toString();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirectToPreviewURL.cjs","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the `defaultURL` option must\n\t * _not_ include it. Instead, provide the `basePath` property using the `basePath` option.\n\t */\n\tdefaultURL?: string\n\n\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`. This option can be\n\t * omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath` automatically. It\n\t * must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void> {\n\tconst { client, req, res, linkResolver, defaultURL = \"/\", basePath = \"\" } = config\n\n\tconst previewToken = req.query.token?.toString()\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t})\n\n\tres.redirect(basePath + previewURL)\n\n\treturn\n}\n"],"mappings":";AAmDA,eAAsB,qBAAqB,QAAmD;CAC7F,MAAM,EAAE,QAAQ,KAAK,KAAK,cAAc,aAAa,KAAK,WAAW,OAAO;CAE5E,MAAM,eAAe,IAAI,MAAM,OAAO,SAAS;CAE/C,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;CACD,CAAC;CAED,IAAI,SAAS,WAAW,UAAU;AAGnC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextApiRequestLike, NextApiResponseLike } from "./types.cjs";
|
|
2
2
|
import { Client, LinkResolverFunction } from "@prismicio/client";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/pages/redirectToPreviewURL.d.ts
|
|
4
4
|
export type RedirectToPreviewURLConfig = {
|
|
5
5
|
/** The Prismic client configured for the preview session's repository. */
|
|
6
6
|
client: Pick<Client, "resolvePreviewURL">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirectToPreviewURL.d.cts","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"mappings":";;;YAIY;;EAKX,QAAQ,KAAK;;;;;;EAOb,KAAK;;;;;;EAOL,KAAK;;;;;;EAOL,eAAe;;;;;;;EAQf;;;;;;;;;EAUA;;wBAGqB,qBAAqB,QAAQ,6BAA6B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextApiRequestLike, NextApiResponseLike } from "./types.js";
|
|
2
2
|
import { Client, LinkResolverFunction } from "@prismicio/client";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/pages/redirectToPreviewURL.d.ts
|
|
4
4
|
export type RedirectToPreviewURLConfig = {
|
|
5
5
|
/** The Prismic client configured for the preview session's repository. */
|
|
6
6
|
client: Pick<Client, "resolvePreviewURL">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirectToPreviewURL.d.ts","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"mappings":";;;YAIY;;EAKX,QAAQ,KAAK;;;;;;EAOb,KAAK;;;;;;EAOL,KAAK;;;;;;EAOL,eAAe;;;;;;;EAQf;;;;;;;;;EAUA;;wBAGqB,qBAAqB,QAAQ,6BAA6B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/pages/redirectToPreviewURL.ts
|
|
2
2
|
async function redirectToPreviewURL(config) {
|
|
3
3
|
const { client, req, res, linkResolver, defaultURL = "/", basePath = "" } = config;
|
|
4
4
|
const previewToken = req.query.token?.toString();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirectToPreviewURL.js","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the `defaultURL` option must\n\t * _not_ include it. Instead, provide the `basePath` property using the `basePath` option.\n\t */\n\tdefaultURL?: string\n\n\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`. This option can be\n\t * omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath` automatically. It\n\t * must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void> {\n\tconst { client, req, res, linkResolver, defaultURL = \"/\", basePath = \"\" } = config\n\n\tconst previewToken = req.query.token?.toString()\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t})\n\n\tres.redirect(basePath + previewURL)\n\n\treturn\n}\n"],"mappings":";AAmDA,eAAsB,qBAAqB,QAAmD;CAC7F,MAAM,EAAE,QAAQ,KAAK,KAAK,cAAc,aAAa,KAAK,WAAW,OAAO;CAE5E,MAAM,eAAe,IAAI,MAAM,OAAO,SAAS;CAE/C,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;CACD,CAAC;CAED,IAAI,SAAS,WAAW,UAAU;AAGnC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
let _prismicio_client = require("@prismicio/client");
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/pages/setPreviewData.ts
|
|
3
3
|
/** Set Prismic preview data for Next.js's Preview Mode. */
|
|
4
4
|
function setPreviewData({ req, res }) {
|
|
5
5
|
const ref = req.query.token || req.cookies[_prismicio_client.cookie.preview];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setPreviewData.cjs","names":["cookie"],"sources":["../../src/pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview]\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref })\n\t}\n}\n"],"mappings":";;;AAsBA,SAAgB,eAAe,EAAE,KAAK,OAAmC;CACxE,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQA,kBAAAA,OAAO;CAElD,IAAI,KACH,IAAI,eAAe,EAAE,IAAI,CAAC;AAE5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setPreviewData.d.cts","names":[],"sources":["../../src/pages/setPreviewData.ts"],"mappings":";;;YAKY;;;;;;EAMX,KAAK;;;;;;EAOL,KAAK;;;wBAIU,iBAAiB,KAAK,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setPreviewData.d.ts","names":[],"sources":["../../src/pages/setPreviewData.ts"],"mappings":";;;YAKY;;;;;;EAMX,KAAK;;;;;;EAOL,KAAK;;;wBAIU,iBAAiB,KAAK,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cookie } from "@prismicio/client";
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/pages/setPreviewData.ts
|
|
3
3
|
/** Set Prismic preview data for Next.js's Preview Mode. */
|
|
4
4
|
function setPreviewData({ req, res }) {
|
|
5
5
|
const ref = req.query.token || req.cookies[cookie.preview];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setPreviewData.js","names":[],"sources":["../../src/pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview]\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref })\n\t}\n}\n"],"mappings":";;;AAsBA,SAAgB,eAAe,EAAE,KAAK,OAAmC;CACxE,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,OAAO;CAElD,IAAI,KACH,IAAI,eAAe,EAAE,IAAI,CAAC;AAE5B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnableAutoPreviewsConfig } from "./enableAutoPreviews.cjs";
|
|
2
2
|
import { ClientConfig } from "@prismicio/client";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/pages/types.d.ts
|
|
4
4
|
/** Configuration for creating a Prismic client with automatic preview support in Next.js apps. */
|
|
5
5
|
export type CreateClientConfig = ClientConfig & Pick<EnableAutoPreviewsConfig, "previewData" | "req">;
|
|
6
6
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/pages/types.ts"],"mappings":";;;;YAKY,qBAAqB,eAChC,KAAK;;;;;;YAOM;EACX,OAAO,QAAQ;EACf,SAAS,QAAQ;;;;;;;YAQN;EACX,SAAS,cAAc;EACvB,oBAAoB;EACpB,UAAU,cAAc,2BAA2B;EAEnD,KAAK;EACL,eAAe,wBAAwB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnableAutoPreviewsConfig } from "./enableAutoPreviews.js";
|
|
2
2
|
import { ClientConfig } from "@prismicio/client";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/pages/types.d.ts
|
|
4
4
|
/** Configuration for creating a Prismic client with automatic preview support in Next.js apps. */
|
|
5
5
|
export type CreateClientConfig = ClientConfig & Pick<EnableAutoPreviewsConfig, "previewData" | "req">;
|
|
6
6
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/pages/types.ts"],"mappings":";;;;YAKY,qBAAqB,eAChC,KAAK;;;;;;YAOM;EACX,OAAO,QAAQ;EACf,SAAS,QAAQ;;;;;;;YAQN;EACX,SAAS,cAAc;EACvB,oBAAoB;EACpB,UAAU,cAAc,2BAA2B;EAEnD,KAAK;EACL,eAAe,wBAAwB"}
|
|
@@ -3,12 +3,12 @@ const require_PrismicNextLink = require("./PrismicNextLink.cjs");
|
|
|
3
3
|
const require_imgixLoader = require("./imgixLoader.cjs");
|
|
4
4
|
const require_PrismicNextImage = require("./PrismicNextImage.cjs");
|
|
5
5
|
const require_createLocaleRedirect = require("./createLocaleRedirect.cjs");
|
|
6
|
-
const require_SliceSimulator = require("./
|
|
7
|
-
const require_PrismicPreview = require("./
|
|
8
|
-
const require_enableAutoPreviews = require("./
|
|
9
|
-
const require_redirectToPreviewURL = require("./
|
|
10
|
-
const require_exitPreview = require("./
|
|
11
|
-
const require_setPreviewData = require("./
|
|
6
|
+
const require_SliceSimulator = require("./pages/SliceSimulator.cjs");
|
|
7
|
+
const require_PrismicPreview = require("./pages/PrismicPreview.cjs");
|
|
8
|
+
const require_enableAutoPreviews = require("./pages/enableAutoPreviews.cjs");
|
|
9
|
+
const require_redirectToPreviewURL = require("./pages/redirectToPreviewURL.cjs");
|
|
10
|
+
const require_exitPreview = require("./pages/exitPreview.cjs");
|
|
11
|
+
const require_setPreviewData = require("./pages/setPreviewData.cjs");
|
|
12
12
|
exports.PrismicNextImage = require_PrismicNextImage.PrismicNextImage;
|
|
13
13
|
exports.PrismicNextLink = require_PrismicNextLink.PrismicNextLink;
|
|
14
14
|
exports.PrismicPreview = require_PrismicPreview.PrismicPreview;
|
|
@@ -2,11 +2,11 @@ import { PrismicNextLink, PrismicNextLinkProps } from "./PrismicNextLink.cjs";
|
|
|
2
2
|
import { PrismicNextImage, PrismicNextImageProps } from "./PrismicNextImage.cjs";
|
|
3
3
|
import { imgixLoader } from "./imgixLoader.cjs";
|
|
4
4
|
import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.cjs";
|
|
5
|
-
import { SliceSimulator, SliceSimulatorProps, SliceSimulatorSliceZoneProps } from "./
|
|
6
|
-
import { PrismicPreview, PrismicPreviewProps } from "./
|
|
7
|
-
import { CreateClientConfig } from "./
|
|
8
|
-
import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./
|
|
9
|
-
import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./
|
|
10
|
-
import { ExitPreviewAPIRouteConfig, exitPreview } from "./
|
|
11
|
-
import { SetPreviewDataConfig, setPreviewData } from "./
|
|
5
|
+
import { SliceSimulator, SliceSimulatorProps, SliceSimulatorSliceZoneProps } from "./pages/SliceSimulator.cjs";
|
|
6
|
+
import { PrismicPreview, PrismicPreviewProps } from "./pages/PrismicPreview.cjs";
|
|
7
|
+
import { CreateClientConfig } from "./pages/types.cjs";
|
|
8
|
+
import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./pages/enableAutoPreviews.cjs";
|
|
9
|
+
import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./pages/redirectToPreviewURL.cjs";
|
|
10
|
+
import { ExitPreviewAPIRouteConfig, exitPreview } from "./pages/exitPreview.cjs";
|
|
11
|
+
import { SetPreviewDataConfig, setPreviewData } from "./pages/setPreviewData.cjs";
|
|
12
12
|
export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, type ExitPreviewAPIRouteConfig, PrismicNextImage, type PrismicNextImageProps, PrismicNextLink, type PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, type RedirectToPreviewURLConfig, type SetPreviewDataConfig, SliceSimulator, type SliceSimulatorProps, type SliceSimulatorSliceZoneProps, createLocaleRedirect, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL, setPreviewData };
|
|
@@ -2,11 +2,11 @@ import { PrismicNextLink, PrismicNextLinkProps } from "./PrismicNextLink.js";
|
|
|
2
2
|
import { PrismicNextImage, PrismicNextImageProps } from "./PrismicNextImage.js";
|
|
3
3
|
import { imgixLoader } from "./imgixLoader.js";
|
|
4
4
|
import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.js";
|
|
5
|
-
import { SliceSimulator, SliceSimulatorProps, SliceSimulatorSliceZoneProps } from "./
|
|
6
|
-
import { PrismicPreview, PrismicPreviewProps } from "./
|
|
7
|
-
import { CreateClientConfig } from "./
|
|
8
|
-
import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./
|
|
9
|
-
import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./
|
|
10
|
-
import { ExitPreviewAPIRouteConfig, exitPreview } from "./
|
|
11
|
-
import { SetPreviewDataConfig, setPreviewData } from "./
|
|
5
|
+
import { SliceSimulator, SliceSimulatorProps, SliceSimulatorSliceZoneProps } from "./pages/SliceSimulator.js";
|
|
6
|
+
import { PrismicPreview, PrismicPreviewProps } from "./pages/PrismicPreview.js";
|
|
7
|
+
import { CreateClientConfig } from "./pages/types.js";
|
|
8
|
+
import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./pages/enableAutoPreviews.js";
|
|
9
|
+
import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./pages/redirectToPreviewURL.js";
|
|
10
|
+
import { ExitPreviewAPIRouteConfig, exitPreview } from "./pages/exitPreview.js";
|
|
11
|
+
import { SetPreviewDataConfig, setPreviewData } from "./pages/setPreviewData.js";
|
|
12
12
|
export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, type ExitPreviewAPIRouteConfig, PrismicNextImage, type PrismicNextImageProps, PrismicNextLink, type PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, type RedirectToPreviewURLConfig, type SetPreviewDataConfig, SliceSimulator, type SliceSimulatorProps, type SliceSimulatorSliceZoneProps, createLocaleRedirect, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL, setPreviewData };
|
package/dist/pages.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PrismicNextLink } from "./PrismicNextLink.js";
|
|
2
|
+
import { imgixLoader } from "./imgixLoader.js";
|
|
3
|
+
import { PrismicNextImage } from "./PrismicNextImage.js";
|
|
4
|
+
import { createLocaleRedirect } from "./createLocaleRedirect.js";
|
|
5
|
+
import { SliceSimulator } from "./pages/SliceSimulator.js";
|
|
6
|
+
import { PrismicPreview } from "./pages/PrismicPreview.js";
|
|
7
|
+
import { enableAutoPreviews } from "./pages/enableAutoPreviews.js";
|
|
8
|
+
import { redirectToPreviewURL } from "./pages/redirectToPreviewURL.js";
|
|
9
|
+
import { exitPreview } from "./pages/exitPreview.js";
|
|
10
|
+
import { setPreviewData } from "./pages/setPreviewData.js";
|
|
11
|
+
export { PrismicNextImage, PrismicNextLink, PrismicPreview, SliceSimulator, createLocaleRedirect, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL, setPreviewData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/next",
|
|
3
|
-
"version": "2.3.3-pr.
|
|
3
|
+
"version": "2.3.3-pr.165.b556bb0",
|
|
4
4
|
"description": "Helpers to integrate Prismic into Next.js apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"next",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"workspaces": [
|
|
19
19
|
".",
|
|
20
20
|
"e2e-projects/*",
|
|
21
|
-
"!e2e-projects/next-14",
|
|
22
21
|
"!e2e-projects/next-15"
|
|
23
22
|
],
|
|
24
23
|
"files": [
|
|
@@ -35,8 +34,8 @@
|
|
|
35
34
|
"require": "./dist/index.cjs"
|
|
36
35
|
},
|
|
37
36
|
"./pages": {
|
|
38
|
-
"import": "./dist/
|
|
39
|
-
"require": "./dist/
|
|
37
|
+
"import": "./dist/pages.js",
|
|
38
|
+
"require": "./dist/pages.cjs"
|
|
40
39
|
},
|
|
41
40
|
"./package.json": "./package.json"
|
|
42
41
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.cjs","names":["useRouter","getToolbarSrc","Script","prismicCookie"],"sources":["../../src/router-pages/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc, cookie as prismicCookie } from \"@prismicio/client\"\nimport { useRouter } from \"next/router\"\nimport Script from \"next/script\"\nimport type { FC } from \"react\"\nimport { type ReactNode, useEffect } from \"react\"\n\n/** Props for `<PrismicPreview>`. */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be\n\t * fetched on preview exit events.\n\t */\n\texitPreviewURL?: string\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: ReactNode\n}\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * rendered on every page.\n */\nexport const PrismicPreview: FC<PrismicPreviewProps> = (props) => {\n\tconst {\n\t\trepositoryName,\n\t\tupdatePreviewURL = \"/api/preview\",\n\t\texitPreviewURL = \"/api/exit-preview\",\n\t\tchildren,\n\t} = props\n\n\tconst router = useRouter()\n\n\tconst toolbarSrc = getToolbarSrc(repositoryName)\n\n\tuseEffect(() => {\n\t\tconst controller = new AbortController()\n\n\t\twindow.addEventListener(\"prismicPreviewUpdate\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\t\twindow.addEventListener(\"prismicPreviewEnd\", onEnd, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\n\t\t// Start the preview for preview share links. Previews from\n\t\t// share links do not go to the `updatePreviewURL` like a normal\n\t\t// preview.\n\t\t//\n\t\t// We check that the current URL is a descendant of the base\n\t\t// path to prevent infinite refrehes.\n\t\tif (\n\t\t\twindow.location.href.startsWith(window.location.origin + router.basePath) &&\n\t\t\tgetPreviewCookieRepositoryName() === repositoryName &&\n\t\t\t!router.isPreview\n\t\t) {\n\t\t\tstart()\n\t\t}\n\n\t\tfunction onEnd(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tfetch(router.basePath + exitPreviewURL, { signal: controller.signal })\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (!res.ok) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${exitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {})\n\t\t}\n\n\t\tfunction onUpdate(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tstart()\n\t\t}\n\n\t\tfunction start() {\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and at least\n\t\t\t// attempted to set preview data.\n\t\t\tfetch(router.basePath + updatePreviewURL, {\n\t\t\t\tredirect: \"manual\",\n\t\t\t\tsignal: controller.signal,\n\t\t\t})\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (res.type !== \"opaqueredirect\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to start or update the preview using \"${updatePreviewURL}\". Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {})\n\t\t}\n\n\t\tfunction refresh() {\n\t\t\trouter.replace(router.asPath, undefined, { scroll: false })\n\t\t}\n\n\t\treturn () => controller.abort()\n\t}, [exitPreviewURL, updatePreviewURL, repositoryName, router])\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t)\n}\n\nfunction getPreviewCookieRepositoryName() {\n\tconst cookie = window.document.cookie\n\t\t.split(\"; \")\n\t\t.find((row) => row.startsWith(`${prismicCookie.preview}=`))\n\t\t?.split(\"=\")[1]\n\n\treturn (decodeURIComponent(cookie ?? \"\").match(/\"([^\"]+)\\.prismic\\.io\"/) || [])[1]\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsCA,MAAa,kBAA2C,UAAU;CACjE,MAAM,EACL,gBACA,mBAAmB,gBACnB,iBAAiB,qBACjB,aACG;CAEJ,MAAM,UAAA,GAASA,eAAAA,UAAAA,CAAU;CAEzB,MAAM,cAAA,GAAaC,kBAAAA,cAAAA,CAAc,cAAc;CAE/C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACf,MAAM,aAAa,IAAI,gBAAgB;EAEvC,OAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,OACpB,CAAC;EACD,OAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,OACpB,CAAC;EAQD,IACC,OAAO,SAAS,KAAK,WAAW,OAAO,SAAS,SAAS,OAAO,QAAQ,KACxE,+BAA+B,MAAM,kBACrC,CAAC,OAAO,WAER,MAAM;EAGP,SAAS,MAAM,OAAc;GAC5B,MAAM,eAAe;GACrB,MAAM,OAAO,WAAW,gBAAgB,EAAE,QAAQ,WAAW,OAAO,CAAC,CAAC,CACpE,MAAM,QAAQ;IACd,IAAI,CAAC,IAAI,IAAI;KACZ,QAAQ,MACP,6DAA6D,eAAe,+BAC7E;KAEA;IACD;IAEA,QAAQ;GACT,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACjB;EAEA,SAAS,SAAS,OAAc;GAC/B,MAAM,eAAe;GACrB,MAAM;EACP;EAEA,SAAS,QAAQ;GAKhB,MAAM,OAAO,WAAW,kBAAkB;IACzC,UAAU;IACV,QAAQ,WAAW;GACpB,CAAC,CAAC,CACA,MAAM,QAAQ;IACd,IAAI,IAAI,SAAS,kBAAkB;KAClC,QAAQ,MACP,mEAAmE,iBAAiB,kBACrF;KAEA;IACD;IAEA,QAAQ;GACT,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACjB;EAEA,SAAS,UAAU;GAClB,OAAO,QAAQ,OAAO,QAAQ,KAAA,GAAW,EAAE,QAAQ,MAAM,CAAC;EAC3D;EAEA,aAAa,WAAW,MAAM;CAC/B,GAAG;EAAC;EAAgB;EAAkB;EAAgB;CAAM,CAAC;CAE7D,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA,CACE,UACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,eAAAA,SAAD;EAAQ,KAAK;EAAY,UAAS;CAAc,CAAA,CAC/C,EAAA,CAAA;AAEJ;AAEA,SAAS,iCAAiC;CACzC,MAAM,SAAS,OAAO,SAAS,OAC7B,MAAM,IAAI,CAAC,CACX,MAAM,QAAQ,IAAI,WAAW,GAAGC,kBAAAA,OAAc,QAAQ,EAAE,CAAC,CAAC,EACzD,MAAM,GAAG,CAAC,CAAC;CAEd,QAAQ,mBAAmB,UAAU,EAAE,CAAC,CAAC,MAAM,wBAAwB,KAAK,CAAC,EAAA,CAAG;AACjF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.d.cts","names":[],"sources":["../../src/router-pages/PrismicPreview.tsx"],"mappings":";;;YAOY;;;;;EAKX;;;;;EAMA;;;;;EAMA;;EAGA,WAAW;;;;;;;;;;qBAWC,gBAAgB,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.d.ts","names":[],"sources":["../../src/router-pages/PrismicPreview.tsx"],"mappings":";;;YAOY;;;;;EAKX;;;;;EAMA;;;;;EAMA;;EAGA,WAAW;;;;;;;;;;qBAWC,gBAAgB,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.js","names":["cookie","prismicCookie"],"sources":["../../src/router-pages/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc, cookie as prismicCookie } from \"@prismicio/client\"\nimport { useRouter } from \"next/router\"\nimport Script from \"next/script\"\nimport type { FC } from \"react\"\nimport { type ReactNode, useEffect } from \"react\"\n\n/** Props for `<PrismicPreview>`. */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be\n\t * fetched on preview exit events.\n\t */\n\texitPreviewURL?: string\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: ReactNode\n}\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * rendered on every page.\n */\nexport const PrismicPreview: FC<PrismicPreviewProps> = (props) => {\n\tconst {\n\t\trepositoryName,\n\t\tupdatePreviewURL = \"/api/preview\",\n\t\texitPreviewURL = \"/api/exit-preview\",\n\t\tchildren,\n\t} = props\n\n\tconst router = useRouter()\n\n\tconst toolbarSrc = getToolbarSrc(repositoryName)\n\n\tuseEffect(() => {\n\t\tconst controller = new AbortController()\n\n\t\twindow.addEventListener(\"prismicPreviewUpdate\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\t\twindow.addEventListener(\"prismicPreviewEnd\", onEnd, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\n\t\t// Start the preview for preview share links. Previews from\n\t\t// share links do not go to the `updatePreviewURL` like a normal\n\t\t// preview.\n\t\t//\n\t\t// We check that the current URL is a descendant of the base\n\t\t// path to prevent infinite refrehes.\n\t\tif (\n\t\t\twindow.location.href.startsWith(window.location.origin + router.basePath) &&\n\t\t\tgetPreviewCookieRepositoryName() === repositoryName &&\n\t\t\t!router.isPreview\n\t\t) {\n\t\t\tstart()\n\t\t}\n\n\t\tfunction onEnd(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tfetch(router.basePath + exitPreviewURL, { signal: controller.signal })\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (!res.ok) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${exitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {})\n\t\t}\n\n\t\tfunction onUpdate(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tstart()\n\t\t}\n\n\t\tfunction start() {\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and at least\n\t\t\t// attempted to set preview data.\n\t\t\tfetch(router.basePath + updatePreviewURL, {\n\t\t\t\tredirect: \"manual\",\n\t\t\t\tsignal: controller.signal,\n\t\t\t})\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (res.type !== \"opaqueredirect\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to start or update the preview using \"${updatePreviewURL}\". Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {})\n\t\t}\n\n\t\tfunction refresh() {\n\t\t\trouter.replace(router.asPath, undefined, { scroll: false })\n\t\t}\n\n\t\treturn () => controller.abort()\n\t}, [exitPreviewURL, updatePreviewURL, repositoryName, router])\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t)\n}\n\nfunction getPreviewCookieRepositoryName() {\n\tconst cookie = window.document.cookie\n\t\t.split(\"; \")\n\t\t.find((row) => row.startsWith(`${prismicCookie.preview}=`))\n\t\t?.split(\"=\")[1]\n\n\treturn (decodeURIComponent(cookie ?? \"\").match(/\"([^\"]+)\\.prismic\\.io\"/) || [])[1]\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAa,kBAA2C,UAAU;CACjE,MAAM,EACL,gBACA,mBAAmB,gBACnB,iBAAiB,qBACjB,aACG;CAEJ,MAAM,SAAS,UAAU;CAEzB,MAAM,aAAa,cAAc,cAAc;CAE/C,gBAAgB;EACf,MAAM,aAAa,IAAI,gBAAgB;EAEvC,OAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,OACpB,CAAC;EACD,OAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,OACpB,CAAC;EAQD,IACC,OAAO,SAAS,KAAK,WAAW,OAAO,SAAS,SAAS,OAAO,QAAQ,KACxE,+BAA+B,MAAM,kBACrC,CAAC,OAAO,WAER,MAAM;EAGP,SAAS,MAAM,OAAc;GAC5B,MAAM,eAAe;GACrB,MAAM,OAAO,WAAW,gBAAgB,EAAE,QAAQ,WAAW,OAAO,CAAC,CAAC,CACpE,MAAM,QAAQ;IACd,IAAI,CAAC,IAAI,IAAI;KACZ,QAAQ,MACP,6DAA6D,eAAe,+BAC7E;KAEA;IACD;IAEA,QAAQ;GACT,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACjB;EAEA,SAAS,SAAS,OAAc;GAC/B,MAAM,eAAe;GACrB,MAAM;EACP;EAEA,SAAS,QAAQ;GAKhB,MAAM,OAAO,WAAW,kBAAkB;IACzC,UAAU;IACV,QAAQ,WAAW;GACpB,CAAC,CAAC,CACA,MAAM,QAAQ;IACd,IAAI,IAAI,SAAS,kBAAkB;KAClC,QAAQ,MACP,mEAAmE,iBAAiB,kBACrF;KAEA;IACD;IAEA,QAAQ;GACT,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACjB;EAEA,SAAS,UAAU;GAClB,OAAO,QAAQ,OAAO,QAAQ,KAAA,GAAW,EAAE,QAAQ,MAAM,CAAC;EAC3D;EAEA,aAAa,WAAW,MAAM;CAC/B,GAAG;EAAC;EAAgB;EAAkB;EAAgB;CAAM,CAAC;CAE7D,OACC,qBAAA,UAAA,EAAA,UAAA,CACE,UACD,oBAAC,QAAD;EAAQ,KAAK;EAAY,UAAS;CAAc,CAAA,CAC/C,EAAA,CAAA;AAEJ;AAEA,SAAS,iCAAiC;CACzC,MAAMA,WAAS,OAAO,SAAS,OAC7B,MAAM,IAAI,CAAC,CACX,MAAM,QAAQ,IAAI,WAAW,GAAGC,OAAc,QAAQ,EAAE,CAAC,CAAC,EACzD,MAAM,GAAG,CAAC,CAAC;CAEd,QAAQ,mBAAmBD,YAAU,EAAE,CAAC,CAAC,MAAM,wBAAwB,KAAK,CAAC,EAAA,CAAG;AACjF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","useState","getDefaultSlices","getDefaultMessage","StateEventType","SliceSimulatorWrapper"],"sources":["../../src/router-pages/SliceSimulator.tsx"],"sourcesContent":["import {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\"\nimport type {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n} from \"@prismicio/simulator/kit\"\nimport { useEffect, useState } from \"react\"\nimport type { ComponentType, FC } from \"react\"\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\"\n\nconst simulatorManager = new SimulatorManager()\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"]\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t * \t;```tsx\n\t * \timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\"\n\t * \timport { SliceZone } from \"@prismicio/react\"\n\t *\n\t * \timport { components } from \"../slices\"\n\t *\n\t * \t;<SliceSimulator\n\t * \t\tsliceZone={({ slices }) => <SliceZone slices={slices} components={components} />}\n\t * \t/>\n\t * \t```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>\n\tclassName?: string\n}\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine\n * and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tbackground,\n\tzIndex,\n\tclassName,\n\tsliceZone: SliceZoneComp,\n}) => {\n\tconst [slices, setSlices] = useState(() => getDefaultSlices())\n\tconst [message, setMessage] = useState(() => getDefaultMessage())\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices)\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t)\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message)\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t)\n\n\t\tsimulatorManager.init()\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\")\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\")\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={slices.length > 0}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<SliceZoneComp slices={slices} />\n\t\t</SliceSimulatorWrapper>\n\t)\n}\n"],"mappings":";;;;;AAeA,MAAM,mBAAmB,IAAIA,yBAAAA,iBAAiB;;;;;AA8B9C,MAAa,kBAA2C,EACvD,YACA,QACA,WACA,WAAW,oBACN;CACL,MAAM,CAAC,QAAQ,cAAA,GAAaC,MAAAA,SAAAA,QAAAA,GAAeC,yBAAAA,iBAAAA,CAAiB,CAAC;CAC7D,MAAM,CAAC,SAAS,eAAA,GAAcD,MAAAA,SAAAA,QAAAA,GAAeE,yBAAAA,kBAAAA,CAAkB,CAAC;CAEhE,CAAA,GAAA,MAAA,UAAA,OAAgB;EACf,iBAAiB,MAAM,GACtBC,yBAAAA,eAAe,SACd,YAAY;GACZ,UAAU,OAAO;EAClB,GACA,kBACD;EACA,iBAAiB,MAAM,GACtBA,yBAAAA,eAAe,UACd,aAAa;GACb,WAAW,QAAQ;EACpB,GACA,mBACD;EAEA,iBAAiB,KAAK;EAEtB,aAAa;GACZ,iBAAiB,MAAM,IAAIA,yBAAAA,eAAe,QAAQ,kBAAkB;GAEpE,iBAAiB,MAAM,IAAIA,yBAAAA,eAAe,SAAS,mBAAmB;EACvE;CACD,GAAG,CAAC,CAAC;CAEL,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,uBAAD;EACU;EACT,WAAW,OAAO,SAAS;EACf;EACJ;EACG;EAEX,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAD,EAAuB,OAAS,CAAA;CACV,CAAA;AAEzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.d.cts","names":[],"sources":["../../src/router-pages/SliceSimulator.tsx"],"mappings":";;;YAiBY;EACX,QAAQ;;KAGG,wBAAsB;;;;;;;;;;;;;;;;EAgBjC,WAAW,cAAc;EACzB;;;;;;qBAOY,gBAAgB,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.d.ts","names":[],"sources":["../../src/router-pages/SliceSimulator.tsx"],"mappings":";;;YAiBY;EACX,QAAQ;;KAGG,wBAAsB;;;;;;;;;;;;;;;;EAgBjC,WAAW,cAAc;EACzB;;;;;;qBAOY,gBAAgB,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../../src/router-pages/SliceSimulator.tsx"],"sourcesContent":["import {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\"\nimport type {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n} from \"@prismicio/simulator/kit\"\nimport { useEffect, useState } from \"react\"\nimport type { ComponentType, FC } from \"react\"\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\"\n\nconst simulatorManager = new SimulatorManager()\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"]\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t * \t;```tsx\n\t * \timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\"\n\t * \timport { SliceZone } from \"@prismicio/react\"\n\t *\n\t * \timport { components } from \"../slices\"\n\t *\n\t * \t;<SliceSimulator\n\t * \t\tsliceZone={({ slices }) => <SliceZone slices={slices} components={components} />}\n\t * \t/>\n\t * \t```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>\n\tclassName?: string\n}\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine\n * and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tbackground,\n\tzIndex,\n\tclassName,\n\tsliceZone: SliceZoneComp,\n}) => {\n\tconst [slices, setSlices] = useState(() => getDefaultSlices())\n\tconst [message, setMessage] = useState(() => getDefaultMessage())\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices)\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t)\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message)\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t)\n\n\t\tsimulatorManager.init()\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\")\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\")\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={slices.length > 0}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<SliceZoneComp slices={slices} />\n\t\t</SliceSimulatorWrapper>\n\t)\n}\n"],"mappings":";;;;;AAeA,MAAM,mBAAmB,IAAI,iBAAiB;;;;;AA8B9C,MAAa,kBAA2C,EACvD,YACA,QACA,WACA,WAAW,oBACN;CACL,MAAM,CAAC,QAAQ,aAAa,eAAe,iBAAiB,CAAC;CAC7D,MAAM,CAAC,SAAS,cAAc,eAAe,kBAAkB,CAAC;CAEhE,gBAAgB;EACf,iBAAiB,MAAM,GACtB,eAAe,SACd,YAAY;GACZ,UAAU,OAAO;EAClB,GACA,kBACD;EACA,iBAAiB,MAAM,GACtB,eAAe,UACd,aAAa;GACb,WAAW,QAAQ;EACpB,GACA,mBACD;EAEA,iBAAiB,KAAK;EAEtB,aAAa;GACZ,iBAAiB,MAAM,IAAI,eAAe,QAAQ,kBAAkB;GAEpE,iBAAiB,MAAM,IAAI,eAAe,SAAS,mBAAmB;EACvE;CACD,GAAG,CAAC,CAAC;CAEL,OACC,oBAAC,uBAAD;EACU;EACT,WAAW,OAAO,SAAS;EACf;EACJ;EACG;EAEX,UAAA,oBAAC,eAAD,EAAuB,OAAS,CAAA;CACV,CAAA;AAEzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.cjs","names":[],"sources":["../../src/router-pages/enableAutoPreviews.ts"],"sourcesContent":["import type { Client } from \"@prismicio/client\"\nimport type { PreviewData } from \"next\"\n\nimport type { NextApiRequestLike } from \"./types\"\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig = {\n\t/** Prismic client with which automatic previews will be enabled. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"queryContentFromRef\" | \"enableAutoPreviewsFromReq\">\n\n\t/**\n\t * The `previewData` object provided in the `getStaticProps()` or `getServerSideProps()` context\n\t * object.\n\t */\n\tpreviewData?: PreviewData\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n}\n\n/**\n * Configures a Prismic client to automatically query draft content during a preview session. It\n * either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request\n * object.\n *\n * @param config - Configuration for the function.\n */\nexport function enableAutoPreviews(config: EnableAutoPreviewsConfig): void {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// Assume we are in `getStaticProps()` or\n\t\t// `getServerSideProps()` with active Preview Mode.\n\n\t\tif (isPrismicPreviewData(config.previewData)) {\n\t\t\tconfig.client.queryContentFromRef(config.previewData.ref)\n\t\t}\n\n\t\treturn\n\t}\n\n\tif (\"req\" in config && config.req) {\n\t\t// Assume we are in an API Route.\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req)\n\n\t\treturn\n\t}\n}\n\nfunction isPrismicPreviewData(input: unknown): input is { ref: string } {\n\treturn typeof input === \"object\" && input !== null && \"ref\" in input\n}\n"],"mappings":";;;;;;;;AAsCA,SAAgB,mBAAmB,QAAwC;CAC1E,IAAI,iBAAiB,UAAU,OAAO,aAAa;EAIlD,IAAI,qBAAqB,OAAO,WAAW,GAC1C,OAAO,OAAO,oBAAoB,OAAO,YAAY,GAAG;EAGzD;CACD;CAEA,IAAI,SAAS,UAAU,OAAO,KAAK;EAGlC,OAAO,OAAO,0BAA0B,OAAO,GAAG;EAElD;CACD;AACD;AAEA,SAAS,qBAAqB,OAA0C;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;AAChE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.d.cts","names":[],"sources":["../../src/router-pages/enableAutoPreviews.ts"],"mappings":";;;;;;;;;YAUY;;EAKX,QAAQ,KAAK;;;;;EAMb,cAAc;;;;;;EAOd,MAAM;;;;;;;;;wBAUS,mBAAmB,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.d.ts","names":[],"sources":["../../src/router-pages/enableAutoPreviews.ts"],"mappings":";;;;;;;;;YAUY;;EAKX,QAAQ,KAAK;;;;;EAMb,cAAc;;;;;;EAOd,MAAM;;;;;;;;;wBAUS,mBAAmB,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.js","names":[],"sources":["../../src/router-pages/enableAutoPreviews.ts"],"sourcesContent":["import type { Client } from \"@prismicio/client\"\nimport type { PreviewData } from \"next\"\n\nimport type { NextApiRequestLike } from \"./types\"\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig = {\n\t/** Prismic client with which automatic previews will be enabled. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"queryContentFromRef\" | \"enableAutoPreviewsFromReq\">\n\n\t/**\n\t * The `previewData` object provided in the `getStaticProps()` or `getServerSideProps()` context\n\t * object.\n\t */\n\tpreviewData?: PreviewData\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n}\n\n/**\n * Configures a Prismic client to automatically query draft content during a preview session. It\n * either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request\n * object.\n *\n * @param config - Configuration for the function.\n */\nexport function enableAutoPreviews(config: EnableAutoPreviewsConfig): void {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// Assume we are in `getStaticProps()` or\n\t\t// `getServerSideProps()` with active Preview Mode.\n\n\t\tif (isPrismicPreviewData(config.previewData)) {\n\t\t\tconfig.client.queryContentFromRef(config.previewData.ref)\n\t\t}\n\n\t\treturn\n\t}\n\n\tif (\"req\" in config && config.req) {\n\t\t// Assume we are in an API Route.\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req)\n\n\t\treturn\n\t}\n}\n\nfunction isPrismicPreviewData(input: unknown): input is { ref: string } {\n\treturn typeof input === \"object\" && input !== null && \"ref\" in input\n}\n"],"mappings":";;;;;;;;AAsCA,SAAgB,mBAAmB,QAAwC;CAC1E,IAAI,iBAAiB,UAAU,OAAO,aAAa;EAIlD,IAAI,qBAAqB,OAAO,WAAW,GAC1C,OAAO,OAAO,oBAAoB,OAAO,YAAY,GAAG;EAGzD;CACD;CAEA,IAAI,SAAS,UAAU,OAAO,KAAK;EAGlC,OAAO,OAAO,0BAA0B,OAAO,GAAG;EAElD;CACD;AACD;AAEA,SAAS,qBAAqB,OAA0C;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;AAChE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.cjs","names":[],"sources":["../../src/router-pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\tconfig.res.setHeader(\"Cache-Control\", \"no-store\")\n\n\tconfig.res.json({ success: true })\n\n\treturn\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAgB,YAAY,QAAyC;CACpE,OAAO,IAAI,iBAAiB;CAG5B,OAAO,IAAI,UAAU,iBAAiB,UAAU;CAEhD,OAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC;AAGlC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.d.cts","names":[],"sources":["../../src/router-pages/exitPreview.ts"],"mappings":";;;YAGY;;;;;;EAMX,MAAM;;;;;;EAON,KAAK;;;;;;;;;;;;;;;;;wBAkBU,YAAY,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.d.ts","names":[],"sources":["../../src/router-pages/exitPreview.ts"],"mappings":";;;YAGY;;;;;;EAMX,MAAM;;;;;;EAON,KAAK;;;;;;;;;;;;;;;;;wBAkBU,YAAY,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.js","names":[],"sources":["../../src/router-pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\tconfig.res.setHeader(\"Cache-Control\", \"no-store\")\n\n\tconfig.res.json({ success: true })\n\n\treturn\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAgB,YAAY,QAAyC;CACpE,OAAO,IAAI,iBAAiB;CAG5B,OAAO,IAAI,UAAU,iBAAiB,UAAU;CAEhD,OAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC;AAGlC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redirectToPreviewURL.cjs","names":[],"sources":["../../src/router-pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the `defaultURL` option must\n\t * _not_ include it. Instead, provide the `basePath` property using the `basePath` option.\n\t */\n\tdefaultURL?: string\n\n\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`. This option can be\n\t * omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath` automatically. It\n\t * must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void> {\n\tconst { client, req, res, linkResolver, defaultURL = \"/\", basePath = \"\" } = config\n\n\tconst previewToken = req.query.token?.toString()\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t})\n\n\tres.redirect(basePath + previewURL)\n\n\treturn\n}\n"],"mappings":";AAmDA,eAAsB,qBAAqB,QAAmD;CAC7F,MAAM,EAAE,QAAQ,KAAK,KAAK,cAAc,aAAa,KAAK,WAAW,OAAO;CAE5E,MAAM,eAAe,IAAI,MAAM,OAAO,SAAS;CAE/C,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;CACD,CAAC;CAED,IAAI,SAAS,WAAW,UAAU;AAGnC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redirectToPreviewURL.d.cts","names":[],"sources":["../../src/router-pages/redirectToPreviewURL.ts"],"mappings":";;;YAIY;;EAKX,QAAQ,KAAK;;;;;;EAOb,KAAK;;;;;;EAOL,KAAK;;;;;;EAOL,eAAe;;;;;;;EAQf;;;;;;;;;EAUA;;wBAGqB,qBAAqB,QAAQ,6BAA6B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redirectToPreviewURL.d.ts","names":[],"sources":["../../src/router-pages/redirectToPreviewURL.ts"],"mappings":";;;YAIY;;EAKX,QAAQ,KAAK;;;;;;EAOb,KAAK;;;;;;EAOL,KAAK;;;;;;EAOL,eAAe;;;;;;;EAQf;;;;;;;;;EAUA;;wBAGqB,qBAAqB,QAAQ,6BAA6B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redirectToPreviewURL.js","names":[],"sources":["../../src/router-pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the `defaultURL` option must\n\t * _not_ include it. Instead, provide the `basePath` property using the `basePath` option.\n\t */\n\tdefaultURL?: string\n\n\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`. This option can be\n\t * omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath` automatically. It\n\t * must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void> {\n\tconst { client, req, res, linkResolver, defaultURL = \"/\", basePath = \"\" } = config\n\n\tconst previewToken = req.query.token?.toString()\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t})\n\n\tres.redirect(basePath + previewURL)\n\n\treturn\n}\n"],"mappings":";AAmDA,eAAsB,qBAAqB,QAAmD;CAC7F,MAAM,EAAE,QAAQ,KAAK,KAAK,cAAc,aAAa,KAAK,WAAW,OAAO;CAE5E,MAAM,eAAe,IAAI,MAAM,OAAO,SAAS;CAE/C,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;CACD,CAAC;CAED,IAAI,SAAS,WAAW,UAAU;AAGnC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setPreviewData.cjs","names":["cookie"],"sources":["../../src/router-pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview]\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref })\n\t}\n}\n"],"mappings":";;;AAsBA,SAAgB,eAAe,EAAE,KAAK,OAAmC;CACxE,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQA,kBAAAA,OAAO;CAElD,IAAI,KACH,IAAI,eAAe,EAAE,IAAI,CAAC;AAE5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setPreviewData.d.cts","names":[],"sources":["../../src/router-pages/setPreviewData.ts"],"mappings":";;;YAKY;;;;;;EAMX,KAAK;;;;;;EAOL,KAAK;;;wBAIU,iBAAiB,KAAK,OAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setPreviewData.d.ts","names":[],"sources":["../../src/router-pages/setPreviewData.ts"],"mappings":";;;YAKY;;;;;;EAMX,KAAK;;;;;;EAOL,KAAK;;;wBAIU,iBAAiB,KAAK,OAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setPreviewData.js","names":[],"sources":["../../src/router-pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview]\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref })\n\t}\n}\n"],"mappings":";;;AAsBA,SAAgB,eAAe,EAAE,KAAK,OAAmC;CACxE,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,OAAO;CAElD,IAAI,KACH,IAAI,eAAe,EAAE,IAAI,CAAC;AAE5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/router-pages/types.ts"],"mappings":";;;;YAKY,qBAAqB,eAChC,KAAK;;;;;;YAOM;EACX,OAAO,QAAQ;EACf,SAAS,QAAQ;;;;;;;YAQN;EACX,SAAS,cAAc;EACvB,oBAAoB;EACpB,UAAU,cAAc,2BAA2B;EAEnD,KAAK;EACL,eAAe,wBAAwB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/router-pages/types.ts"],"mappings":";;;;YAKY,qBAAqB,eAChC,KAAK;;;;;;YAOM;EACX,OAAO,QAAQ;EACf,SAAS,QAAQ;;;;;;;YAQN;EACX,SAAS,cAAc;EACvB,oBAAoB;EACpB,UAAU,cAAc,2BAA2B;EAEnD,KAAK;EACL,eAAe,wBAAwB"}
|
package/dist/router-pages.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { PrismicNextLink } from "./PrismicNextLink.js";
|
|
2
|
-
import { imgixLoader } from "./imgixLoader.js";
|
|
3
|
-
import { PrismicNextImage } from "./PrismicNextImage.js";
|
|
4
|
-
import { createLocaleRedirect } from "./createLocaleRedirect.js";
|
|
5
|
-
import { SliceSimulator } from "./router-pages/SliceSimulator.js";
|
|
6
|
-
import { PrismicPreview } from "./router-pages/PrismicPreview.js";
|
|
7
|
-
import { enableAutoPreviews } from "./router-pages/enableAutoPreviews.js";
|
|
8
|
-
import { redirectToPreviewURL } from "./router-pages/redirectToPreviewURL.js";
|
|
9
|
-
import { exitPreview } from "./router-pages/exitPreview.js";
|
|
10
|
-
import { setPreviewData } from "./router-pages/setPreviewData.js";
|
|
11
|
-
export { PrismicNextImage, PrismicNextLink, PrismicPreview, SliceSimulator, createLocaleRedirect, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL, setPreviewData };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|