@prismicio/next 2.2.3 → 2.2.4-pr.114.39a5b55
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/PrismicNextImage.cjs +9 -11
- package/dist/PrismicNextImage.cjs.map +1 -1
- package/dist/PrismicNextImage.d.cts +13 -21
- package/dist/PrismicNextImage.d.cts.map +1 -0
- package/dist/PrismicNextImage.d.ts +13 -21
- package/dist/PrismicNextImage.d.ts.map +1 -0
- package/dist/PrismicNextImage.js +9 -11
- package/dist/PrismicNextImage.js.map +1 -1
- package/dist/PrismicNextLink.cjs.map +1 -1
- package/dist/PrismicNextLink.d.cts.map +1 -0
- package/dist/PrismicNextLink.d.ts.map +1 -0
- package/dist/PrismicNextLink.js.map +1 -1
- package/dist/PrismicPreview.cjs +6 -7
- package/dist/PrismicPreview.cjs.map +1 -1
- package/dist/PrismicPreview.d.cts +11 -12
- package/dist/PrismicPreview.d.cts.map +1 -0
- package/dist/PrismicPreview.d.ts +11 -12
- package/dist/PrismicPreview.d.ts.map +1 -0
- package/dist/PrismicPreview.js +6 -7
- package/dist/PrismicPreview.js.map +1 -1
- package/dist/PrismicPreviewClient.cjs +1 -3
- package/dist/PrismicPreviewClient.cjs.map +1 -1
- package/dist/PrismicPreviewClient.js +1 -3
- package/dist/PrismicPreviewClient.js.map +1 -1
- package/dist/SliceSimulator.cjs +3 -3
- package/dist/SliceSimulator.cjs.map +1 -1
- package/dist/SliceSimulator.d.cts +3 -5
- package/dist/SliceSimulator.d.cts.map +1 -0
- package/dist/SliceSimulator.d.ts +3 -5
- package/dist/SliceSimulator.d.ts.map +1 -0
- package/dist/SliceSimulator.js +3 -3
- package/dist/SliceSimulator.js.map +1 -1
- package/dist/SliceSimulatorWrapper.cjs +1 -4
- package/dist/SliceSimulatorWrapper.cjs.map +1 -1
- package/dist/SliceSimulatorWrapper.js +1 -4
- package/dist/SliceSimulatorWrapper.js.map +1 -1
- package/dist/cacheTagPrismicPages.cjs +11 -0
- package/dist/cacheTagPrismicPages.cjs.map +1 -0
- package/dist/cacheTagPrismicPages.d.cts +7 -0
- package/dist/cacheTagPrismicPages.d.cts.map +1 -0
- package/dist/cacheTagPrismicPages.d.ts +7 -0
- package/dist/cacheTagPrismicPages.d.ts.map +1 -0
- package/dist/cacheTagPrismicPages.js +10 -0
- package/dist/cacheTagPrismicPages.js.map +1 -0
- package/dist/createLocaleRedirect.cjs.map +1 -1
- package/dist/createLocaleRedirect.d.cts.map +1 -0
- package/dist/createLocaleRedirect.d.ts.map +1 -0
- package/dist/createLocaleRedirect.js.map +1 -1
- package/dist/enableAutoPreviews.cjs +3 -18
- package/dist/enableAutoPreviews.cjs.map +1 -1
- package/dist/enableAutoPreviews.d.cts +1 -2
- package/dist/enableAutoPreviews.d.cts.map +1 -0
- package/dist/enableAutoPreviews.d.ts +1 -2
- package/dist/enableAutoPreviews.d.ts.map +1 -0
- package/dist/enableAutoPreviews.js +3 -17
- package/dist/enableAutoPreviews.js.map +1 -1
- package/dist/exitPreview.cjs +13 -11
- package/dist/exitPreview.cjs.map +1 -1
- package/dist/exitPreview.d.cts +9 -10
- package/dist/exitPreview.d.cts.map +1 -0
- package/dist/exitPreview.d.ts +9 -10
- package/dist/exitPreview.d.ts.map +1 -0
- package/dist/exitPreview.js +12 -11
- package/dist/exitPreview.js.map +1 -1
- package/dist/getPreviewRef.cjs +39 -0
- package/dist/getPreviewRef.cjs.map +1 -0
- package/dist/getPreviewRef.d.cts +23 -0
- package/dist/getPreviewRef.d.cts.map +1 -0
- package/dist/getPreviewRef.d.ts +23 -0
- package/dist/getPreviewRef.d.ts.map +1 -0
- package/dist/getPreviewRef.js +38 -0
- package/dist/getPreviewRef.js.map +1 -0
- package/dist/getPrismicCacheTags.cjs +29 -0
- package/dist/getPrismicCacheTags.cjs.map +1 -0
- package/dist/getPrismicCacheTags.d.cts +14 -0
- package/dist/getPrismicCacheTags.d.cts.map +1 -0
- package/dist/getPrismicCacheTags.d.ts +14 -0
- package/dist/getPrismicCacheTags.d.ts.map +1 -0
- package/dist/getPrismicCacheTags.js +28 -0
- package/dist/getPrismicCacheTags.js.map +1 -0
- package/dist/getSlices.cjs.map +1 -1
- package/dist/getSlices.d.cts.map +1 -0
- package/dist/getSlices.d.ts.map +1 -0
- package/dist/getSlices.js.map +1 -1
- package/dist/imgixLoader.cjs +2 -2
- package/dist/imgixLoader.cjs.map +1 -1
- package/dist/imgixLoader.d.cts +2 -2
- package/dist/imgixLoader.d.cts.map +1 -0
- package/dist/imgixLoader.d.ts +2 -2
- package/dist/imgixLoader.d.ts.map +1 -0
- package/dist/imgixLoader.js +2 -2
- package/dist/imgixLoader.js.map +1 -1
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/lib/devMsg.cjs +6 -8
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +6 -8
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/resolveDefaultExport.cjs +8 -12
- package/dist/lib/resolveDefaultExport.cjs.map +1 -1
- package/dist/lib/resolveDefaultExport.js +8 -12
- package/dist/lib/resolveDefaultExport.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/pages/PrismicPreview.cjs +6 -7
- package/dist/pages/PrismicPreview.cjs.map +1 -1
- package/dist/pages/PrismicPreview.d.cts +11 -12
- package/dist/pages/PrismicPreview.d.cts.map +1 -0
- package/dist/pages/PrismicPreview.d.ts +11 -12
- package/dist/pages/PrismicPreview.d.ts.map +1 -0
- package/dist/pages/PrismicPreview.js +6 -7
- package/dist/pages/PrismicPreview.js.map +1 -1
- package/dist/pages/SliceSimulator.cjs +2 -2
- package/dist/pages/SliceSimulator.cjs.map +1 -1
- package/dist/pages/SliceSimulator.d.cts +10 -13
- package/dist/pages/SliceSimulator.d.cts.map +1 -0
- package/dist/pages/SliceSimulator.d.ts +10 -13
- package/dist/pages/SliceSimulator.d.ts.map +1 -0
- package/dist/pages/SliceSimulator.js +2 -2
- package/dist/pages/SliceSimulator.js.map +1 -1
- package/dist/pages/enableAutoPreviews.cjs +3 -3
- package/dist/pages/enableAutoPreviews.cjs.map +1 -1
- package/dist/pages/enableAutoPreviews.d.cts +5 -5
- package/dist/pages/enableAutoPreviews.d.cts.map +1 -0
- package/dist/pages/enableAutoPreviews.d.ts +5 -5
- package/dist/pages/enableAutoPreviews.d.ts.map +1 -0
- package/dist/pages/enableAutoPreviews.js +3 -3
- package/dist/pages/enableAutoPreviews.js.map +1 -1
- package/dist/pages/exitPreview.cjs +9 -10
- package/dist/pages/exitPreview.cjs.map +1 -1
- package/dist/pages/exitPreview.d.cts +9 -10
- package/dist/pages/exitPreview.d.cts.map +1 -0
- package/dist/pages/exitPreview.d.ts +9 -10
- package/dist/pages/exitPreview.d.ts.map +1 -0
- package/dist/pages/exitPreview.js +9 -10
- package/dist/pages/exitPreview.js.map +1 -1
- package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
- package/dist/pages/redirectToPreviewURL.d.cts +7 -9
- package/dist/pages/redirectToPreviewURL.d.cts.map +1 -0
- package/dist/pages/redirectToPreviewURL.d.ts +7 -9
- package/dist/pages/redirectToPreviewURL.d.ts.map +1 -0
- package/dist/pages/redirectToPreviewURL.js.map +1 -1
- package/dist/pages/setPreviewData.cjs.map +1 -1
- package/dist/pages/setPreviewData.d.cts.map +1 -0
- package/dist/pages/setPreviewData.d.ts.map +1 -0
- package/dist/pages/setPreviewData.js.map +1 -1
- package/dist/pages/types.d.cts +3 -8
- package/dist/pages/types.d.cts.map +1 -0
- package/dist/pages/types.d.ts +3 -8
- package/dist/pages/types.d.ts.map +1 -0
- package/dist/redirectToPreviewURL.cjs.map +1 -1
- package/dist/redirectToPreviewURL.d.cts +3 -5
- package/dist/redirectToPreviewURL.d.cts.map +1 -0
- package/dist/redirectToPreviewURL.d.ts +3 -5
- package/dist/redirectToPreviewURL.d.ts.map +1 -0
- package/dist/redirectToPreviewURL.js.map +1 -1
- package/dist/revalidatePrismicPages.cjs +18 -0
- package/dist/revalidatePrismicPages.cjs.map +1 -0
- package/dist/revalidatePrismicPages.d.cts +12 -0
- package/dist/revalidatePrismicPages.d.cts.map +1 -0
- package/dist/revalidatePrismicPages.d.ts +12 -0
- package/dist/revalidatePrismicPages.d.ts.map +1 -0
- package/dist/revalidatePrismicPages.js +17 -0
- package/dist/revalidatePrismicPages.js.map +1 -0
- package/dist/types.d.cts +1 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -0
- package/package.json +32 -34
- package/src/PrismicNextImage.tsx +113 -134
- package/src/PrismicNextLink.tsx +43 -45
- package/src/PrismicPreview.tsx +28 -29
- package/src/PrismicPreviewClient.tsx +42 -44
- package/src/SliceSimulator.tsx +38 -43
- package/src/SliceSimulatorWrapper.tsx +15 -25
- package/src/cacheTagPrismicPages.ts +8 -0
- package/src/createLocaleRedirect.ts +3 -3
- package/src/enableAutoPreviews.ts +7 -37
- package/src/exitPreview.ts +18 -13
- package/src/getPreviewRef.ts +52 -0
- package/src/getPrismicCacheTags.ts +44 -0
- package/src/getSlices.ts +6 -10
- package/src/imgixLoader.ts +10 -10
- package/src/index.ts +26 -21
- package/src/lib/devMsg.ts +9 -11
- package/src/lib/resolveDefaultExport.ts +9 -13
- package/src/pages/PrismicPreview.tsx +47 -51
- package/src/pages/SliceSimulator.tsx +35 -37
- package/src/pages/enableAutoPreviews.ts +17 -17
- package/src/pages/exitPreview.ts +17 -18
- package/src/pages/index.ts +20 -23
- package/src/pages/redirectToPreviewURL.ts +22 -33
- package/src/pages/setPreviewData.ts +7 -7
- package/src/pages/types.ts +16 -20
- package/src/redirectToPreviewURL.ts +21 -30
- package/src/revalidatePrismicPages.ts +17 -0
- package/src/types.ts +12 -13
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _prismicio_client = require("@prismicio/client");
|
|
2
3
|
let next_script_js = require("next/script.js");
|
|
3
4
|
next_script_js = require_runtime.__toESM(next_script_js);
|
|
4
|
-
let _prismicio_client = require("@prismicio/client");
|
|
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
8
|
//#region src/pages/PrismicPreview.tsx
|
|
9
9
|
/**
|
|
10
|
-
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* changes.
|
|
10
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
11
|
+
* send events to the browser, such as on preview updates and exiting, this component will
|
|
12
|
+
* automatically refresh the page with the changes.
|
|
14
13
|
*
|
|
15
|
-
* This component can be wrapped around your app or added anywhere in your app's
|
|
16
|
-
*
|
|
14
|
+
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
15
|
+
* rendered on every page.
|
|
17
16
|
*/
|
|
18
17
|
const PrismicPreview = (props) => {
|
|
19
18
|
const { repositoryName, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview", children } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.cjs","names":["Script","prismicCookie"],"sources":["../../src/pages/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc, cookie as prismicCookie } from \"@prismicio/client\"
|
|
1
|
+
{"version":3,"file":"PrismicPreview.cjs","names":["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,GAAA,eAAA,YAAoB;CAE1B,MAAM,cAAA,GAAA,kBAAA,eAA2B,eAAe;AAEhD,EAAA,GAAA,MAAA,iBAAgB;EACf,MAAM,aAAa,IAAI,iBAAiB;AAExC,SAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,QACnB,CAAC;AACF,SAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,QACnB,CAAC;AAQF,MACC,OAAO,SAAS,KAAK,WAAW,OAAO,SAAS,SAAS,OAAO,SAAS,IACzE,gCAAgC,KAAK,kBACrC,CAAC,OAAO,UAER,QAAO;EAGR,SAAS,MAAM,OAAc;AAC5B,SAAM,gBAAgB;AACtB,SAAM,OAAO,WAAW,gBAAgB,EAAE,QAAQ,WAAW,QAAQ,CAAC,CACpE,MAAM,QAAQ;AACd,QAAI,CAAC,IAAI,IAAI;AACZ,aAAQ,MACP,6DAA6D,eAAe,gCAC5E;AAED;;AAGD,aAAS;KACR,CACD,YAAY,GAAG;;EAGlB,SAAS,SAAS,OAAc;AAC/B,SAAM,gBAAgB;AACtB,UAAO;;EAGR,SAAS,QAAQ;AAKhB,SAAM,OAAO,WAAW,kBAAkB;IACzC,UAAU;IACV,QAAQ,WAAW;IACnB,CAAC,CACA,MAAM,QAAQ;AACd,QAAI,IAAI,SAAS,kBAAkB;AAClC,aAAQ,MACP,mEAAmE,iBAAiB,mBACpF;AAED;;AAGD,aAAS;KACR,CACD,YAAY,GAAG;;EAGlB,SAAS,UAAU;AAClB,UAAO,QAAQ,OAAO,QAAQ,KAAA,GAAW,EAAE,QAAQ,OAAO,CAAC;;AAG5D,eAAa,WAAW,OAAO;IAC7B;EAAC;EAAgB;EAAkB;EAAgB;EAAO,CAAC;AAE9D,QACC,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA,CACE,UACD,iBAAA,GAAA,kBAAA,KAACA,eAAAA,SAAD;EAAQ,KAAK;EAAY,UAAS;EAAe,CAAA,CAC/C,EAAA,CAAA;;AAIL,SAAS,iCAAiC;CACzC,MAAM,SAAS,OAAO,SAAS,OAC7B,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAGC,kBAAAA,OAAc,QAAQ,GAAG,CAAC,EACzD,MAAM,IAAI,CAAC;AAEd,SAAQ,mBAAmB,UAAU,GAAG,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE"}
|
|
@@ -4,30 +4,29 @@ import { FC, ReactNode } from "react";
|
|
|
4
4
|
/** Props for `<PrismicPreview>`. */
|
|
5
5
|
type PrismicPreviewProps = {
|
|
6
6
|
/**
|
|
7
|
-
* The name of your Prismic repository. A Prismic Toolbar will be registered
|
|
8
|
-
*
|
|
7
|
+
* The name of your Prismic repository. A Prismic Toolbar will be registered using this
|
|
8
|
+
* repository.
|
|
9
9
|
*/
|
|
10
10
|
repositoryName: string;
|
|
11
11
|
/**
|
|
12
|
-
* The URL of your app's Prismic preview endpoint (default: `/api/preview`).
|
|
13
|
-
*
|
|
12
|
+
* The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be
|
|
13
|
+
* fetched on preview update events.
|
|
14
14
|
*/
|
|
15
15
|
updatePreviewURL?: string;
|
|
16
16
|
/**
|
|
17
|
-
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
|
|
18
|
-
*
|
|
17
|
+
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
|
|
18
|
+
* fetched on preview exit events.
|
|
19
19
|
*/
|
|
20
20
|
exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
|
|
21
21
|
children?: ReactNode;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
|
-
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* changes.
|
|
24
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
25
|
+
* send events to the browser, such as on preview updates and exiting, this component will
|
|
26
|
+
* automatically refresh the page with the changes.
|
|
28
27
|
*
|
|
29
|
-
* This component can be wrapped around your app or added anywhere in your app's
|
|
30
|
-
*
|
|
28
|
+
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
29
|
+
* rendered on every page.
|
|
31
30
|
*/
|
|
32
31
|
declare const PrismicPreview: FC<PrismicPreviewProps>;
|
|
33
32
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreview.d.cts","names":[],"sources":["../../src/pages/PrismicPreview.tsx"],"mappings":";;;;KAOY,mBAAA;EAAmB;;;;EAK9B,cAAA;EAYA;;;;EANA,gBAAA;EAoBY;;;;EAdZ,cAAA;EAGA,QAAA,GAAW,SAAA;AAAA;;;;;;;;;cAWC,cAAA,EAAgB,EAAA,CAAG,mBAAA"}
|
|
@@ -4,30 +4,29 @@ import { FC, ReactNode } from "react";
|
|
|
4
4
|
/** Props for `<PrismicPreview>`. */
|
|
5
5
|
type PrismicPreviewProps = {
|
|
6
6
|
/**
|
|
7
|
-
* The name of your Prismic repository. A Prismic Toolbar will be registered
|
|
8
|
-
*
|
|
7
|
+
* The name of your Prismic repository. A Prismic Toolbar will be registered using this
|
|
8
|
+
* repository.
|
|
9
9
|
*/
|
|
10
10
|
repositoryName: string;
|
|
11
11
|
/**
|
|
12
|
-
* The URL of your app's Prismic preview endpoint (default: `/api/preview`).
|
|
13
|
-
*
|
|
12
|
+
* The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be
|
|
13
|
+
* fetched on preview update events.
|
|
14
14
|
*/
|
|
15
15
|
updatePreviewURL?: string;
|
|
16
16
|
/**
|
|
17
|
-
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
|
|
18
|
-
*
|
|
17
|
+
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
|
|
18
|
+
* fetched on preview exit events.
|
|
19
19
|
*/
|
|
20
20
|
exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
|
|
21
21
|
children?: ReactNode;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
|
-
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* changes.
|
|
24
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
25
|
+
* send events to the browser, such as on preview updates and exiting, this component will
|
|
26
|
+
* automatically refresh the page with the changes.
|
|
28
27
|
*
|
|
29
|
-
* This component can be wrapped around your app or added anywhere in your app's
|
|
30
|
-
*
|
|
28
|
+
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
29
|
+
* rendered on every page.
|
|
31
30
|
*/
|
|
32
31
|
declare const PrismicPreview: FC<PrismicPreviewProps>;
|
|
33
32
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreview.d.ts","names":[],"sources":["../../src/pages/PrismicPreview.tsx"],"mappings":";;;;KAOY,mBAAA;EAAmB;;;;EAK9B,cAAA;EAYA;;;;EANA,gBAAA;EAoBY;;;;EAdZ,cAAA;EAGA,QAAA,GAAW,SAAA;AAAA;;;;;;;;;cAWC,cAAA,EAAgB,EAAA,CAAG,mBAAA"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import Script from "next/script.js";
|
|
2
1
|
import { cookie, getToolbarSrc } from "@prismicio/client";
|
|
2
|
+
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
6
|
//#region src/pages/PrismicPreview.tsx
|
|
7
7
|
/**
|
|
8
|
-
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* changes.
|
|
8
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
9
|
+
* send events to the browser, such as on preview updates and exiting, this component will
|
|
10
|
+
* automatically refresh the page with the changes.
|
|
12
11
|
*
|
|
13
|
-
* This component can be wrapped around your app or added anywhere in your app's
|
|
14
|
-
*
|
|
12
|
+
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
13
|
+
* rendered on every page.
|
|
15
14
|
*/
|
|
16
15
|
const PrismicPreview = (props) => {
|
|
17
16
|
const { repositoryName, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview", children } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.js","names":["cookie","prismicCookie"],"sources":["../../src/pages/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc, cookie as prismicCookie } from \"@prismicio/client\"
|
|
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,WAAW;CAE1B,MAAM,aAAa,cAAc,eAAe;AAEhD,iBAAgB;EACf,MAAM,aAAa,IAAI,iBAAiB;AAExC,SAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,QACnB,CAAC;AACF,SAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,QACnB,CAAC;AAQF,MACC,OAAO,SAAS,KAAK,WAAW,OAAO,SAAS,SAAS,OAAO,SAAS,IACzE,gCAAgC,KAAK,kBACrC,CAAC,OAAO,UAER,QAAO;EAGR,SAAS,MAAM,OAAc;AAC5B,SAAM,gBAAgB;AACtB,SAAM,OAAO,WAAW,gBAAgB,EAAE,QAAQ,WAAW,QAAQ,CAAC,CACpE,MAAM,QAAQ;AACd,QAAI,CAAC,IAAI,IAAI;AACZ,aAAQ,MACP,6DAA6D,eAAe,gCAC5E;AAED;;AAGD,aAAS;KACR,CACD,YAAY,GAAG;;EAGlB,SAAS,SAAS,OAAc;AAC/B,SAAM,gBAAgB;AACtB,UAAO;;EAGR,SAAS,QAAQ;AAKhB,SAAM,OAAO,WAAW,kBAAkB;IACzC,UAAU;IACV,QAAQ,WAAW;IACnB,CAAC,CACA,MAAM,QAAQ;AACd,QAAI,IAAI,SAAS,kBAAkB;AAClC,aAAQ,MACP,mEAAmE,iBAAiB,mBACpF;AAED;;AAGD,aAAS;KACR,CACD,YAAY,GAAG;;EAGlB,SAAS,UAAU;AAClB,UAAO,QAAQ,OAAO,QAAQ,KAAA,GAAW,EAAE,QAAQ,OAAO,CAAC;;AAG5D,eAAa,WAAW,OAAO;IAC7B;EAAC;EAAgB;EAAkB;EAAgB;EAAO,CAAC;AAE9D,QACC,qBAAA,UAAA,EAAA,UAAA,CACE,UACD,oBAAC,QAAD;EAAQ,KAAK;EAAY,UAAS;EAAe,CAAA,CAC/C,EAAA,CAAA;;AAIL,SAAS,iCAAiC;CACzC,MAAMA,WAAS,OAAO,SAAS,OAC7B,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAGC,OAAc,QAAQ,GAAG,CAAC,EACzD,MAAM,IAAI,CAAC;AAEd,SAAQ,mBAAmBD,YAAU,GAAG,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE"}
|
|
@@ -6,8 +6,8 @@ let _prismicio_simulator_kit = require("@prismicio/simulator/kit");
|
|
|
6
6
|
//#region src/pages/SliceSimulator.tsx
|
|
7
7
|
const simulatorManager = new _prismicio_simulator_kit.SimulatorManager();
|
|
8
8
|
/**
|
|
9
|
-
* Simulate slices in isolation. The slice simulator enables live slice
|
|
10
|
-
*
|
|
9
|
+
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
10
|
+
* and live previews in the Page Builder.
|
|
11
11
|
*/
|
|
12
12
|
const SliceSimulator = ({ background, zIndex, className, sliceZone: SliceZoneComp }) => {
|
|
13
13
|
const [slices, setSlices] = (0, react.useState)(() => (0, _prismicio_simulator_kit.getDefaultSlices)());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","StateEventType","SliceSimulatorWrapper"],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","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,kBAAkB;;;;;AA8B/C,MAAa,kBAA2C,EACvD,YACA,QACA,WACA,WAAW,oBACN;CACL,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,iBAAA,GAAA,yBAAA,mBAA8C,CAAC;CAC9D,MAAM,CAAC,SAAS,eAAA,GAAA,MAAA,iBAAA,GAAA,yBAAA,oBAAgD,CAAC;AAEjE,EAAA,GAAA,MAAA,iBAAgB;AACf,mBAAiB,MAAM,GACtBC,yBAAAA,eAAe,SACd,YAAY;AACZ,aAAU,QAAQ;KAEnB,mBACA;AACD,mBAAiB,MAAM,GACtBA,yBAAAA,eAAe,UACd,aAAa;AACb,cAAW,SAAS;KAErB,oBACA;AAED,mBAAiB,MAAM;AAEvB,eAAa;AACZ,oBAAiB,MAAM,IAAIA,yBAAAA,eAAe,QAAQ,mBAAmB;AAErE,oBAAiB,MAAM,IAAIA,yBAAAA,eAAe,SAAS,oBAAoB;;IAEtE,EAAE,CAAC;AAEN,QACC,iBAAA,GAAA,kBAAA,KAACC,8BAAAA,uBAAD;EACU;EACT,WAAW,OAAO,SAAS;EACf;EACJ;EACG;YAEX,iBAAA,GAAA,kBAAA,KAAC,eAAD,EAAuB,QAAU,CAAA;EACV,CAAA"}
|
|
@@ -10,26 +10,23 @@ type SliceSimulatorProps$1 = SliceSimulatorProps & {
|
|
|
10
10
|
* React component to render simulated Slices.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
+
* ;```tsx
|
|
14
|
+
* import { SliceSimulator } from "@slicemachine/adapter-next/simulator"
|
|
15
|
+
* import { SliceZone } from "@prismicio/react"
|
|
13
16
|
*
|
|
14
|
-
*
|
|
15
|
-
* import { SliceSimulator } from "@slicemachine/adapter-next/simulator";
|
|
16
|
-
* import { SliceZone } from "@prismicio/react";
|
|
17
|
+
* import { components } from "../slices"
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* <SliceZone slices={slices} components={components} />
|
|
23
|
-
* )}
|
|
24
|
-
* />;
|
|
25
|
-
* ```
|
|
19
|
+
* ;<SliceSimulator
|
|
20
|
+
* sliceZone={({ slices }) => <SliceZone slices={slices} components={components} />}
|
|
21
|
+
* />
|
|
22
|
+
* ```
|
|
26
23
|
*/
|
|
27
24
|
sliceZone: ComponentType<SliceSimulatorSliceZoneProps>;
|
|
28
25
|
className?: string;
|
|
29
26
|
};
|
|
30
27
|
/**
|
|
31
|
-
* Simulate slices in isolation. The slice simulator enables live slice
|
|
32
|
-
*
|
|
28
|
+
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
29
|
+
* and live previews in the Page Builder.
|
|
33
30
|
*/
|
|
34
31
|
declare const SliceSimulator: FC<SliceSimulatorProps$1>;
|
|
35
32
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.d.cts","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"mappings":";;;;KAiBY,4BAAA;EACX,MAAA,EAAQ,mBAAA;AAAA;AAAA,KAGG,qBAAA,GAAsB,mBAAA;;;;AAAlC;;;;;;;;;;;;EAgBC,SAAA,EAAW,aAAA,CAAc,4BAAA;EACzB,SAAA;AAAA;AAOD;;;;AAAA,cAAa,cAAA,EAAgB,EAAA,CAAG,qBAAA"}
|
|
@@ -10,26 +10,23 @@ type SliceSimulatorProps$1 = SliceSimulatorProps & {
|
|
|
10
10
|
* React component to render simulated Slices.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
+
* ;```tsx
|
|
14
|
+
* import { SliceSimulator } from "@slicemachine/adapter-next/simulator"
|
|
15
|
+
* import { SliceZone } from "@prismicio/react"
|
|
13
16
|
*
|
|
14
|
-
*
|
|
15
|
-
* import { SliceSimulator } from "@slicemachine/adapter-next/simulator";
|
|
16
|
-
* import { SliceZone } from "@prismicio/react";
|
|
17
|
+
* import { components } from "../slices"
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* <SliceZone slices={slices} components={components} />
|
|
23
|
-
* )}
|
|
24
|
-
* />;
|
|
25
|
-
* ```
|
|
19
|
+
* ;<SliceSimulator
|
|
20
|
+
* sliceZone={({ slices }) => <SliceZone slices={slices} components={components} />}
|
|
21
|
+
* />
|
|
22
|
+
* ```
|
|
26
23
|
*/
|
|
27
24
|
sliceZone: ComponentType<SliceSimulatorSliceZoneProps>;
|
|
28
25
|
className?: string;
|
|
29
26
|
};
|
|
30
27
|
/**
|
|
31
|
-
* Simulate slices in isolation. The slice simulator enables live slice
|
|
32
|
-
*
|
|
28
|
+
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
29
|
+
* and live previews in the Page Builder.
|
|
33
30
|
*/
|
|
34
31
|
declare const SliceSimulator: FC<SliceSimulatorProps$1>;
|
|
35
32
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.d.ts","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"mappings":";;;;KAiBY,4BAAA;EACX,MAAA,EAAQ,mBAAA;AAAA;AAAA,KAGG,qBAAA,GAAsB,mBAAA;;;;AAAlC;;;;;;;;;;;;EAgBC,SAAA,EAAW,aAAA,CAAc,4BAAA;EACzB,SAAA;AAAA;AAOD;;;;AAAA,cAAa,cAAA,EAAgB,EAAA,CAAG,qBAAA"}
|
|
@@ -5,8 +5,8 @@ import { SimulatorManager, StateEventType, getDefaultMessage, getDefaultSlices }
|
|
|
5
5
|
//#region src/pages/SliceSimulator.tsx
|
|
6
6
|
const simulatorManager = new SimulatorManager();
|
|
7
7
|
/**
|
|
8
|
-
* Simulate slices in isolation. The slice simulator enables live slice
|
|
9
|
-
*
|
|
8
|
+
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
9
|
+
* and live previews in the Page Builder.
|
|
10
10
|
*/
|
|
11
11
|
const SliceSimulator = ({ background, zIndex, className, sliceZone: SliceZoneComp }) => {
|
|
12
12
|
const [slices, setSlices] = useState(() => getDefaultSlices());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import {
|
|
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,kBAAkB;;;;;AA8B/C,MAAa,kBAA2C,EACvD,YACA,QACA,WACA,WAAW,oBACN;CACL,MAAM,CAAC,QAAQ,aAAa,eAAe,kBAAkB,CAAC;CAC9D,MAAM,CAAC,SAAS,cAAc,eAAe,mBAAmB,CAAC;AAEjE,iBAAgB;AACf,mBAAiB,MAAM,GACtB,eAAe,SACd,YAAY;AACZ,aAAU,QAAQ;KAEnB,mBACA;AACD,mBAAiB,MAAM,GACtB,eAAe,UACd,aAAa;AACb,cAAW,SAAS;KAErB,oBACA;AAED,mBAAiB,MAAM;AAEvB,eAAa;AACZ,oBAAiB,MAAM,IAAI,eAAe,QAAQ,mBAAmB;AAErE,oBAAiB,MAAM,IAAI,eAAe,SAAS,oBAAoB;;IAEtE,EAAE,CAAC;AAEN,QACC,oBAAC,uBAAD;EACU;EACT,WAAW,OAAO,SAAS;EACf;EACJ;EACG;YAEX,oBAAC,eAAD,EAAuB,QAAU,CAAA;EACV,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/pages/enableAutoPreviews.ts
|
|
2
2
|
/**
|
|
3
|
-
* Configures a Prismic client to automatically query draft content during a
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Configures a Prismic client to automatically query draft content during a preview session. It
|
|
4
|
+
* either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request
|
|
5
|
+
* object.
|
|
6
6
|
*
|
|
7
7
|
* @param config - Configuration for the function.
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.cjs","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"sourcesContent":["import type {
|
|
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;AAC1E,KAAI,iBAAiB,UAAU,OAAO,aAAa;AAIlD,MAAI,qBAAqB,OAAO,YAAY,CAC3C,QAAO,OAAO,oBAAoB,OAAO,YAAY,IAAI;AAG1D;;AAGD,KAAI,SAAS,UAAU,OAAO,KAAK;AAGlC,SAAO,OAAO,0BAA0B,OAAO,IAAI;AAEnD;;;AAIF,SAAS,qBAAqB,OAA0C;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS"}
|
|
@@ -11,8 +11,8 @@ import { PreviewData } from "next";
|
|
|
11
11
|
type EnableAutoPreviewsConfig = {
|
|
12
12
|
/** Prismic client with which automatic previews will be enabled. */client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
|
|
13
13
|
/**
|
|
14
|
-
* The `previewData` object provided in the `getStaticProps()` or
|
|
15
|
-
*
|
|
14
|
+
* The `previewData` object provided in the `getStaticProps()` or `getServerSideProps()` context
|
|
15
|
+
* object.
|
|
16
16
|
*/
|
|
17
17
|
previewData?: PreviewData;
|
|
18
18
|
/**
|
|
@@ -23,9 +23,9 @@ type EnableAutoPreviewsConfig = {
|
|
|
23
23
|
req?: NextApiRequestLike;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
* Configures a Prismic client to automatically query draft content during a
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Configures a Prismic client to automatically query draft content during a preview session. It
|
|
27
|
+
* either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request
|
|
28
|
+
* object.
|
|
29
29
|
*
|
|
30
30
|
* @param config - Configuration for the function.
|
|
31
31
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableAutoPreviews.d.cts","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"mappings":";;;;;;;AAUA;;;KAAY,wBAAA;EAKH,oEAAR,MAAA,EAAQ,IAAA,CAAK,MAAA;EAaP;;;;EAPN,WAAA,GAAc,WAAA;EAND;;;;;EAab,GAAA,GAAM,kBAAA;AAAA;AAUP;;;;;;;AAAA,iBAAgB,kBAAA,CAAmB,MAAA,EAAQ,wBAAA"}
|
|
@@ -11,8 +11,8 @@ import { PreviewData } from "next";
|
|
|
11
11
|
type EnableAutoPreviewsConfig = {
|
|
12
12
|
/** Prismic client with which automatic previews will be enabled. */client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
|
|
13
13
|
/**
|
|
14
|
-
* The `previewData` object provided in the `getStaticProps()` or
|
|
15
|
-
*
|
|
14
|
+
* The `previewData` object provided in the `getStaticProps()` or `getServerSideProps()` context
|
|
15
|
+
* object.
|
|
16
16
|
*/
|
|
17
17
|
previewData?: PreviewData;
|
|
18
18
|
/**
|
|
@@ -23,9 +23,9 @@ type EnableAutoPreviewsConfig = {
|
|
|
23
23
|
req?: NextApiRequestLike;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
* Configures a Prismic client to automatically query draft content during a
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Configures a Prismic client to automatically query draft content during a preview session. It
|
|
27
|
+
* either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request
|
|
28
|
+
* object.
|
|
29
29
|
*
|
|
30
30
|
* @param config - Configuration for the function.
|
|
31
31
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableAutoPreviews.d.ts","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"mappings":";;;;;;;AAUA;;;KAAY,wBAAA;EAKH,oEAAR,MAAA,EAAQ,IAAA,CAAK,MAAA;EAaP;;;;EAPN,WAAA,GAAc,WAAA;EAND;;;;;EAab,GAAA,GAAM,kBAAA;AAAA;AAUP;;;;;;;AAAA,iBAAgB,kBAAA,CAAmB,MAAA,EAAQ,wBAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/pages/enableAutoPreviews.ts
|
|
2
2
|
/**
|
|
3
|
-
* Configures a Prismic client to automatically query draft content during a
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Configures a Prismic client to automatically query draft content during a preview session. It
|
|
4
|
+
* either takes in a Next.js `getStaticProps` context object or a Next.js API endpoint request
|
|
5
|
+
* object.
|
|
6
6
|
*
|
|
7
7
|
* @param config - Configuration for the function.
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.js","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"sourcesContent":["import type {
|
|
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;AAC1E,KAAI,iBAAiB,UAAU,OAAO,aAAa;AAIlD,MAAI,qBAAqB,OAAO,YAAY,CAC3C,QAAO,OAAO,oBAAoB,OAAO,YAAY,IAAI;AAG1D;;AAGD,KAAI,SAAS,UAAU,OAAO,KAAK;AAGlC,SAAO,OAAO,0BAA0B,OAAO,IAAI;AAEnD;;;AAIF,SAAS,qBAAqB,OAA0C;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS"}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
//#region src/pages/exitPreview.ts
|
|
2
2
|
/**
|
|
3
|
-
* Ends a Prismic preview session within a Next.js app. This function should be
|
|
4
|
-
*
|
|
3
|
+
* Ends a Prismic preview session within a Next.js app. This function should be used in an API
|
|
4
|
+
* route.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
|
+
* ;```typescript
|
|
8
|
+
* // src/pages/api/exit-preview.js
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
* // src/pages/api/exit-preview.js
|
|
10
|
+
* import { exitPreview } from "@prismicio/next"
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
12
|
+
* export default function handler(_req, res) {
|
|
13
|
+
* return exitPreview({ res })
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
17
16
|
*/
|
|
18
17
|
function exitPreview(config) {
|
|
19
18
|
config.res.clearPreviewData();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.cjs","names":[],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\"
|
|
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;AACpE,QAAO,IAAI,kBAAkB;AAG7B,QAAO,IAAI,UAAU,iBAAiB,WAAW;AAEjD,QAAO,IAAI,KAAK,EAAE,SAAS,MAAM,CAAC"}
|
|
@@ -17,20 +17,19 @@ type ExitPreviewAPIRouteConfig = {
|
|
|
17
17
|
res: NextApiResponseLike;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* Ends a Prismic preview session within a Next.js app. This function should be
|
|
21
|
-
*
|
|
20
|
+
* Ends a Prismic preview session within a Next.js app. This function should be used in an API
|
|
21
|
+
* route.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
+
* ;```typescript
|
|
25
|
+
* // src/pages/api/exit-preview.js
|
|
24
26
|
*
|
|
25
|
-
*
|
|
26
|
-
* // src/pages/api/exit-preview.js
|
|
27
|
+
* import { exitPreview } from "@prismicio/next"
|
|
27
28
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
29
|
+
* export default function handler(_req, res) {
|
|
30
|
+
* return exitPreview({ res })
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
34
33
|
*/
|
|
35
34
|
declare function exitPreview(config: ExitPreviewAPIRouteConfig): void;
|
|
36
35
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exitPreview.d.cts","names":[],"sources":["../../src/pages/exitPreview.ts"],"mappings":";;;;KAGY,yBAAA;EAAA;;;;;EAMX,GAAA,GAAM,kBAAA;EAON;;;;AAkBD;EAlBC,GAAA,EAAK,mBAAA;AAAA;;;;;;;;;;;;;;;;iBAkBU,WAAA,CAAY,MAAA,EAAQ,yBAAA"}
|
|
@@ -17,20 +17,19 @@ type ExitPreviewAPIRouteConfig = {
|
|
|
17
17
|
res: NextApiResponseLike;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* Ends a Prismic preview session within a Next.js app. This function should be
|
|
21
|
-
*
|
|
20
|
+
* Ends a Prismic preview session within a Next.js app. This function should be used in an API
|
|
21
|
+
* route.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
+
* ;```typescript
|
|
25
|
+
* // src/pages/api/exit-preview.js
|
|
24
26
|
*
|
|
25
|
-
*
|
|
26
|
-
* // src/pages/api/exit-preview.js
|
|
27
|
+
* import { exitPreview } from "@prismicio/next"
|
|
27
28
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
29
|
+
* export default function handler(_req, res) {
|
|
30
|
+
* return exitPreview({ res })
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
34
33
|
*/
|
|
35
34
|
declare function exitPreview(config: ExitPreviewAPIRouteConfig): void;
|
|
36
35
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exitPreview.d.ts","names":[],"sources":["../../src/pages/exitPreview.ts"],"mappings":";;;;KAGY,yBAAA;EAAA;;;;;EAMX,GAAA,GAAM,kBAAA;EAON;;;;AAkBD;EAlBC,GAAA,EAAK,mBAAA;AAAA;;;;;;;;;;;;;;;;iBAkBU,WAAA,CAAY,MAAA,EAAQ,yBAAA"}
|