@prismicio/next 1.0.2 → 1.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PrismicNextImage.cjs +17 -27
- package/dist/PrismicNextImage.cjs.map +1 -1
- package/dist/PrismicNextImage.d.ts +3 -3
- package/dist/PrismicNextImage.js +13 -19
- package/dist/PrismicNextImage.js.map +1 -1
- package/dist/PrismicNextLink.cjs +40 -0
- package/dist/PrismicNextLink.cjs.map +1 -0
- package/dist/PrismicNextLink.d.ts +126 -0
- package/dist/PrismicNextLink.js +22 -0
- package/dist/PrismicNextLink.js.map +1 -0
- package/dist/PrismicPreview.cjs +14 -20
- package/dist/PrismicPreview.cjs.map +1 -1
- package/dist/PrismicPreview.d.ts +1 -1
- package/dist/PrismicPreview.js +11 -13
- package/dist/PrismicPreview.js.map +1 -1
- package/dist/enableAutoPreviews.cjs +1 -1
- package/dist/enableAutoPreviews.cjs.map +1 -1
- package/dist/enableAutoPreviews.d.ts +4 -4
- package/dist/enableAutoPreviews.js.map +1 -1
- package/dist/exitPreview.cjs +1 -1
- package/dist/exitPreview.cjs.map +1 -1
- package/dist/exitPreview.d.ts +1 -1
- package/dist/exitPreview.js.map +1 -1
- package/dist/imgixLoader.cjs +1 -1
- package/dist/imgixLoader.cjs.map +1 -1
- package/dist/imgixLoader.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -7
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/__PRODUCTION__.cjs +1 -1
- package/dist/lib/__PRODUCTION__.cjs.map +1 -1
- package/dist/lib/__PRODUCTION__.js.map +1 -1
- package/dist/lib/devMsg.cjs +2 -2
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +1 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/getPreviewCookieRepositoryName.cjs +1 -1
- package/dist/lib/getPreviewCookieRepositoryName.cjs.map +1 -1
- package/dist/lib/getPreviewCookieRepositoryName.js.map +1 -1
- package/dist/lib/getPrismicPreviewCookie.cjs +3 -5
- package/dist/lib/getPrismicPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPrismicPreviewCookie.js.map +1 -1
- package/dist/package.json.cjs +5 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/package.json.js +5 -0
- package/dist/package.json.js.map +1 -0
- package/dist/react-server/PrismicPreview.d.ts +22 -0
- package/dist/react-server/index.d.ts +2 -0
- package/dist/react-server/unsupported.cjs +26 -0
- package/dist/react-server/unsupported.cjs.map +1 -0
- package/dist/react-server/unsupported.d.ts +6 -0
- package/dist/react-server/unsupported.js +26 -0
- package/dist/react-server/unsupported.js.map +1 -0
- package/dist/react-server.cjs +15 -0
- package/dist/react-server.cjs.map +1 -0
- package/dist/react-server.js +15 -0
- package/dist/react-server.js.map +1 -0
- package/dist/redirectToPreviewURL.cjs +1 -1
- package/dist/redirectToPreviewURL.cjs.map +1 -1
- package/dist/redirectToPreviewURL.d.ts +4 -5
- package/dist/redirectToPreviewURL.js.map +1 -1
- package/dist/setPreviewData.cjs +3 -5
- package/dist/setPreviewData.cjs.map +1 -1
- package/dist/setPreviewData.d.ts +1 -1
- package/dist/setPreviewData.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +38 -33
- package/src/PrismicNextImage.tsx +6 -5
- package/src/PrismicNextLink.tsx +55 -0
- package/src/PrismicPreview.tsx +2 -0
- package/src/enableAutoPreviews.ts +9 -3
- package/src/index.ts +16 -13
- package/src/react-server/PrismicPreview.tsx +74 -0
- package/src/react-server/index.ts +11 -0
- package/src/react-server/unsupported.ts +26 -0
- package/src/redirectToPreviewURL.ts +7 -5
- package/dist/package.cjs +0 -5
- package/dist/package.cjs.map +0 -1
- package/dist/package.js +0 -5
- package/dist/package.js.map +0 -1
package/dist/PrismicPreview.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use client';
|
|
1
3
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
4
|
import * as React from "react";
|
|
3
5
|
import { useRouter } from "next/router";
|
|
4
6
|
import Script from "next/script";
|
|
5
7
|
import { getPrismicPreviewCookie } from "./lib/getPrismicPreviewCookie.js";
|
|
6
8
|
import { getPreviewCookieRepositoryName } from "./lib/getPreviewCookieRepositoryName.js";
|
|
7
|
-
function PrismicPreview({
|
|
8
|
-
repositoryName,
|
|
9
|
-
children,
|
|
10
|
-
updatePreviewURL = "/api/preview",
|
|
11
|
-
exitPreviewURL = "/api/exit-preview"
|
|
12
|
-
}) {
|
|
9
|
+
function PrismicPreview({ repositoryName, children, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview" }) {
|
|
13
10
|
const router = useRouter();
|
|
14
11
|
const resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;
|
|
15
12
|
const resolvedExitPreviewURL = router.basePath + exitPreviewURL;
|
|
@@ -52,13 +49,14 @@ function PrismicPreview({
|
|
|
52
49
|
window.removeEventListener("prismicPreviewUpdate", handlePrismicPreviewUpdate);
|
|
53
50
|
window.removeEventListener("prismicPreviewEnd", handlePrismicPreviewEnd);
|
|
54
51
|
};
|
|
55
|
-
}, [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
}, [
|
|
53
|
+
repositoryName,
|
|
54
|
+
resolvedExitPreviewURL,
|
|
55
|
+
resolvedUpdatePreviewURL,
|
|
56
|
+
router.isPreview,
|
|
57
|
+
router.basePath
|
|
58
|
+
]);
|
|
59
|
+
return jsxs(Fragment, { children: [children, jsx(Script, { src: `https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`, strategy: "lazyOnload" })] });
|
|
62
60
|
}
|
|
63
61
|
export {
|
|
64
62
|
PrismicPreview
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.js","sources":["
|
|
1
|
+
{"version":3,"file":"PrismicPreview.js","sources":["../../src/PrismicPreview.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { useRouter } from \"next/router\";\nimport Script from \"next/script\";\n\nimport { getPrismicPreviewCookie } from \"./lib/getPrismicPreviewCookie\";\nimport { getPreviewCookieRepositoryName } from \"./lib/getPreviewCookieRepositoryName\";\n\n/**\n * Props for `<PrismicPreview>`.\n */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered\n\t * using this repository.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`).\n\t * This URL will be fetched on preview update events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\tupdatePreviewURL?: string;\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).\n\t * This URL will be fetched on preview exit events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\texitPreviewURL?: string;\n\n\t/**\n\t * Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar\n\t * will be rendered last.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically update the Next.js preview\n * cookie and refresh the page.\n *\n * This component can be wrapped around your app or added anywhere in your app's\n * tree. It must be rendered on every page.\n */\nexport function PrismicPreview({\n\trepositoryName,\n\tchildren,\n\tupdatePreviewURL = \"/api/preview\",\n\texitPreviewURL = \"/api/exit-preview\",\n}: PrismicPreviewProps): JSX.Element {\n\tconst router = useRouter();\n\n\tconst resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;\n\tconst resolvedExitPreviewURL = router.basePath + exitPreviewURL;\n\n\tReact.useEffect(() => {\n\t\t/**\n\t\t * Starts Preview Mode and refreshes the page's props.\n\t\t */\n\t\tconst startPreviewMode = async () => {\n\t\t\t// Start Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedUpdatePreviewURL);\n\n\t\t\t// We check for `res.redirected` rather than `res.ok`\n\t\t\t// since the update preview endpoint may redirect to a\n\t\t\t// 404 page. As long as it redirects, we know the\n\t\t\t// endpoint exists and at least attempted to set\n\t\t\t// preview data.\n\t\t\tif (res.redirected) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to start or update Preview Mode using the \"${resolvedUpdatePreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst handlePrismicPreviewUpdate = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\tawait startPreviewMode();\n\t\t};\n\n\t\tconst handlePrismicPreviewEnd = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\t// Exit Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedExitPreviewURL);\n\n\t\t\tif (res.ok) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${resolvedExitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tif (router.isPreview) {\n\t\t\t// Register Prismic Toolbar event handlers.\n\t\t\twindow.addEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.addEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t} else {\n\t\t\tconst prismicPreviewCookie = getPrismicPreviewCookie(\n\t\t\t\tglobalThis.document.cookie,\n\t\t\t);\n\n\t\t\tif (prismicPreviewCookie) {\n\t\t\t\t// If a Prismic preview cookie is present, but Next.js Preview\n\t\t\t\t// Mode is not active, we must activate Preview Mode manually.\n\t\t\t\t//\n\t\t\t\t// This will happen when a visitor accesses the page using a\n\t\t\t\t// Prismic preview share link.\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the current location is a descendant of the app's base\n\t\t\t\t * path.\n\t\t\t\t *\n\t\t\t\t * This is used to prevent infinite refrehes; when\n\t\t\t\t * `isDescendantOfBasePath` is `false`, `router.isPreview` is also\n\t\t\t\t * `false`.\n\t\t\t\t *\n\t\t\t\t * If the app does not have a base path, this should always be `true`.\n\t\t\t\t */\n\t\t\t\tconst locationIsDescendantOfBasePath = window.location.href.startsWith(\n\t\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t\t);\n\n\t\t\t\tconst prismicPreviewCookieRepositoryName =\n\t\t\t\t\tgetPreviewCookieRepositoryName(prismicPreviewCookie);\n\n\t\t\t\tif (\n\t\t\t\t\tlocationIsDescendantOfBasePath &&\n\t\t\t\t\tprismicPreviewCookieRepositoryName === repositoryName\n\t\t\t\t) {\n\t\t\t\t\tstartPreviewMode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// On cleanup, unregister Prismic Toolbar event handlers.\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.removeEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t};\n\t}, [\n\t\trepositoryName,\n\t\tresolvedExitPreviewURL,\n\t\tresolvedUpdatePreviewURL,\n\t\trouter.isPreview,\n\t\trouter.basePath,\n\t]);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script\n\t\t\t\tsrc={`https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`}\n\t\t\t\tstrategy=\"lazyOnload\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"names":[],"mappings":";;;;;;;;AAqDgB;AAMf;AAEM;AACA;AAEN;AAIC;AAEC;AAOA;AACC;;AAEQ;AACyH;AAEjI;AAGI;AAEL;AAEA;;AAGK;AAEL;AAGA;AAEA;AACC;;AAEQ;AAC4G;AAEpH;AAGF;AAEQ;AAIA;AAA6D;AAEpE;AAIA;AAiBO;AAIA;AAIL;;;AAIA;AACD;AAIF;AACQ;AAIA;AAAgE;AAAA;AAEtE;AACF;AACA;AACA;AACO;AACA;AAGR;AASD;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const isPrismicNextPreviewData = (previewData) => {
|
|
4
4
|
return typeof previewData === "object" && "ref" in previewData;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"enableAutoPreviews.cjs","sources":["../../src/enableAutoPreviews.ts"],"sourcesContent":["import { PreviewData } from \"next\";\nimport type * as prismic from \"@prismicio/client\";\n\ninterface PrismicNextPreviewData {\n\tref: string;\n}\n\n/**\n * Determines if a Next.js preview data object contains Prismic preview data.\n *\n * @param previewData - The Next.js preview data object to check.\n *\n * @returns `true` if `previewData` contains Prismic preview data, `false`\n * otherwise.\n */\nconst isPrismicNextPreviewData = (\n\tpreviewData: PreviewData,\n): previewData is PrismicNextPreviewData => {\n\treturn typeof previewData === \"object\" && \"ref\" in previewData;\n};\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig<\n\tTPreviewData extends PreviewData = PreviewData,\n> = {\n\t/**\n\t * Prismic client with which automatic previews will be enabled.\n\t */\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<\n\t\tprismic.Client,\n\t\t\"queryContentFromRef\" | \"enableAutoPreviewsFromReq\"\n\t>;\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * A Next.js context object (such as the context object from\n\t\t\t * `getStaticProps` or `getServerSideProps`).\n\t\t\t *\n\t\t\t * Pass a `context` object when using `enableAutoPreviews` outside a\n\t\t\t * Next.js API endpoint.\n\t\t\t */\n\t\t\tpreviewData?: TPreviewData;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * A Next.js API endpoint request object.\n\t\t\t *\n\t\t\t * Pass a `req` object when using `enableAutoPreviews` in a Next.js API\n\t\t\t * endpoint.\n\t\t\t */\n\t\t\treq?: prismic.HttpRequestLike;\n\t }\n);\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session. It either takes in a Next.js `getStaticProps` context object\n * or a Next.js API endpoint request object.\n *\n * @param config - Configuration for the function.\n */\nexport const enableAutoPreviews = <TPreviewData extends PreviewData>(\n\tconfig: EnableAutoPreviewsConfig<TPreviewData>,\n): void => {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// If preview data is being passed from Next Context then use queryContentFromRef\n\n\t\tconst { previewData } = config;\n\n\t\tif (isPrismicNextPreviewData(previewData) && previewData.ref) {\n\t\t\tconfig.client.queryContentFromRef(previewData.ref);\n\t\t}\n\t} else if (\"req\" in config && config.req) {\n\t\t// If the req object is passed then use enableAutoPreviewsFromReq\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req);\n\t}\n};\n"],"names":[],"mappings":";;AAeA,MAAM,2BAA2B,CAChC,gBAC0C;AACnC,SAAA,OAAO,gBAAgB,YAAY,SAAS;AACpD;AAgDa,MAAA,qBAAqB,CACjC,WACS;AACL,MAAA,iBAAiB,UAAU,OAAO,aAAa;AAG5C,UAAA,EAAE,YAAgB,IAAA;AAExB,QAAI,yBAAyB,WAAW,KAAK,YAAY,KAAK;AACtD,aAAA,OAAO,oBAAoB,YAAY,GAAG;AAAA,IACjD;AAAA,EACS,WAAA,SAAS,UAAU,OAAO,KAAK;AAGlC,WAAA,OAAO,0BAA0B,OAAO,GAAG;AAAA,EAClD;AACF;;"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { PreviewData } from "next";
|
|
2
|
-
import
|
|
2
|
+
import type * as prismic from "@prismicio/client";
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for `enableAutoPreviews`.
|
|
5
5
|
*
|
|
6
6
|
* @typeParam TPreviewData - Next.js preview data object.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type EnableAutoPreviewsConfig<TPreviewData extends PreviewData = PreviewData> = {
|
|
9
9
|
/**
|
|
10
10
|
* Prismic client with which automatic previews will be enabled.
|
|
11
11
|
*/
|
|
12
|
-
client: Client
|
|
12
|
+
client: Pick<prismic.Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
|
|
13
13
|
} & ({
|
|
14
14
|
/**
|
|
15
15
|
* A Next.js context object (such as the context object from
|
|
@@ -26,7 +26,7 @@ export declare type EnableAutoPreviewsConfig<TPreviewData extends PreviewData =
|
|
|
26
26
|
* Pass a `req` object when using `enableAutoPreviews` in a Next.js API
|
|
27
27
|
* endpoint.
|
|
28
28
|
*/
|
|
29
|
-
req?: HttpRequestLike;
|
|
29
|
+
req?: prismic.HttpRequestLike;
|
|
30
30
|
});
|
|
31
31
|
/**
|
|
32
32
|
* Configures a Prismic client to automatically query draft content during a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.js","sources":["
|
|
1
|
+
{"version":3,"file":"enableAutoPreviews.js","sources":["../../src/enableAutoPreviews.ts"],"sourcesContent":["import { PreviewData } from \"next\";\nimport type * as prismic from \"@prismicio/client\";\n\ninterface PrismicNextPreviewData {\n\tref: string;\n}\n\n/**\n * Determines if a Next.js preview data object contains Prismic preview data.\n *\n * @param previewData - The Next.js preview data object to check.\n *\n * @returns `true` if `previewData` contains Prismic preview data, `false`\n * otherwise.\n */\nconst isPrismicNextPreviewData = (\n\tpreviewData: PreviewData,\n): previewData is PrismicNextPreviewData => {\n\treturn typeof previewData === \"object\" && \"ref\" in previewData;\n};\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig<\n\tTPreviewData extends PreviewData = PreviewData,\n> = {\n\t/**\n\t * Prismic client with which automatic previews will be enabled.\n\t */\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<\n\t\tprismic.Client,\n\t\t\"queryContentFromRef\" | \"enableAutoPreviewsFromReq\"\n\t>;\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * A Next.js context object (such as the context object from\n\t\t\t * `getStaticProps` or `getServerSideProps`).\n\t\t\t *\n\t\t\t * Pass a `context` object when using `enableAutoPreviews` outside a\n\t\t\t * Next.js API endpoint.\n\t\t\t */\n\t\t\tpreviewData?: TPreviewData;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * A Next.js API endpoint request object.\n\t\t\t *\n\t\t\t * Pass a `req` object when using `enableAutoPreviews` in a Next.js API\n\t\t\t * endpoint.\n\t\t\t */\n\t\t\treq?: prismic.HttpRequestLike;\n\t }\n);\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session. It either takes in a Next.js `getStaticProps` context object\n * or a Next.js API endpoint request object.\n *\n * @param config - Configuration for the function.\n */\nexport const enableAutoPreviews = <TPreviewData extends PreviewData>(\n\tconfig: EnableAutoPreviewsConfig<TPreviewData>,\n): void => {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// If preview data is being passed from Next Context then use queryContentFromRef\n\n\t\tconst { previewData } = config;\n\n\t\tif (isPrismicNextPreviewData(previewData) && previewData.ref) {\n\t\t\tconfig.client.queryContentFromRef(previewData.ref);\n\t\t}\n\t} else if (\"req\" in config && config.req) {\n\t\t// If the req object is passed then use enableAutoPreviewsFromReq\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req);\n\t}\n};\n"],"names":[],"mappings":"AAeA,MAAM,2BAA2B,CAChC,gBAC0C;AACnC,SAAA,OAAO,gBAAgB,YAAY,SAAS;AACpD;AAgDa,MAAA,qBAAqB,CACjC,WACS;AACL,MAAA,iBAAiB,UAAU,OAAO,aAAa;AAG5C,UAAA,EAAE,YAAgB,IAAA;AAExB,QAAI,yBAAyB,WAAW,KAAK,YAAY,KAAK;AACtD,aAAA,OAAO,oBAAoB,YAAY,GAAG;AAAA,IACjD;AAAA,EACS,WAAA,SAAS,UAAU,OAAO,KAAK;AAGlC,WAAA,OAAO,0BAA0B,OAAO,GAAG;AAAA,EAClD;AACF;"}
|
package/dist/exitPreview.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
function exitPreview(config) {
|
|
4
4
|
config.res.clearPreviewData();
|
|
5
5
|
config.res.status(205).json({ success: true });
|
package/dist/exitPreview.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"exitPreview.cjs","sources":["../../src/exitPreview.ts"],"sourcesContent":["import type { NextApiResponse, NextApiRequest } from \"next\";\n\n/**\n * Configuration for `exitPreview`.\n */\nexport type ExitPreviewConfig = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\t// `req` is no longer used in `exitPreview()`. It previously would\n\t// redirect the user to the referring URL, but it no longer has that\n\t// behavior.\n\t//\n\t// `req` is retained as a parameter to make setting up an exit preview\n\t// API route easier (this eliminates the awkward need to handle an\n\t// unused `req` param).\n\t//\n\t// It is also retained in case it is needed in the future, such as\n\t// reading headers or metadata about the request.\n\treq: {\n\t\theaders: NextApiRequest[\"headers\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tclearPreviewData: NextApiResponse[\"clearPreviewData\"];\n\t\tstatus: NextApiResponse[\"status\"];\n\t\tjson: NextApiResponse[\"json\"];\n\t};\n};\n\n/**\n * Exits Next.js's Preview Mode from within a Next.js API route.\n */\nexport function exitPreview(config: ExitPreviewConfig): void {\n\t// Exit the current user from Preview Mode.\n\tconfig.res.clearPreviewData();\n\n\t// 205 status is used to prevent CDN-level caching. The default 200\n\t// status code is typically treated as non-changing and cacheable.\n\tconfig.res.status(205).json({ success: true });\n}\n"],"names":[],"mappings":";;AA0CM,SAAU,YAAY,QAAyB;AAEpD,SAAO,IAAI;AAIJ,SAAA,IAAI,OAAO,GAAG,EAAE,KAAK,EAAE,SAAS,MAAM;AAC9C;;"}
|
package/dist/exitPreview.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { NextApiResponse, NextApiRequest } from "next";
|
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for `exitPreview`.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type ExitPreviewConfig = {
|
|
6
6
|
/**
|
|
7
7
|
* The `req` object from a Next.js API route. This is given as a parameter to
|
|
8
8
|
* the API route.
|
package/dist/exitPreview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.js","sources":["
|
|
1
|
+
{"version":3,"file":"exitPreview.js","sources":["../../src/exitPreview.ts"],"sourcesContent":["import type { NextApiResponse, NextApiRequest } from \"next\";\n\n/**\n * Configuration for `exitPreview`.\n */\nexport type ExitPreviewConfig = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\t// `req` is no longer used in `exitPreview()`. It previously would\n\t// redirect the user to the referring URL, but it no longer has that\n\t// behavior.\n\t//\n\t// `req` is retained as a parameter to make setting up an exit preview\n\t// API route easier (this eliminates the awkward need to handle an\n\t// unused `req` param).\n\t//\n\t// It is also retained in case it is needed in the future, such as\n\t// reading headers or metadata about the request.\n\treq: {\n\t\theaders: NextApiRequest[\"headers\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tclearPreviewData: NextApiResponse[\"clearPreviewData\"];\n\t\tstatus: NextApiResponse[\"status\"];\n\t\tjson: NextApiResponse[\"json\"];\n\t};\n};\n\n/**\n * Exits Next.js's Preview Mode from within a Next.js API route.\n */\nexport function exitPreview(config: ExitPreviewConfig): void {\n\t// Exit the current user from Preview Mode.\n\tconfig.res.clearPreviewData();\n\n\t// 205 status is used to prevent CDN-level caching. The default 200\n\t// status code is typically treated as non-changing and cacheable.\n\tconfig.res.status(205).json({ success: true });\n}\n"],"names":[],"mappings":"AA0CM,SAAU,YAAY,QAAyB;AAEpD,SAAO,IAAI;AAIJ,SAAA,IAAI,OAAO,GAAG,EAAE,KAAK,EAAE,SAAS,MAAM;AAC9C;"}
|
package/dist/imgixLoader.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const imgixUrlBuilder = require("imgix-url-builder");
|
|
4
4
|
const imgixLoader = (args) => {
|
|
5
5
|
const url = new URL(args.src);
|
package/dist/imgixLoader.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imgixLoader.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"imgixLoader.cjs","sources":["../../src/imgixLoader.ts"],"sourcesContent":["import { ImageLoaderProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\n\n/**\n * A `next/image` loader for Imgix, which Prismic uses, with an optional\n * collection of default Imgix parameters.\n *\n * @see To learn about `next/image` loaders: https://nextjs.org/docs/api-reference/next/image#loader\n * @see To learn about Imgix's URL API: https://docs.imgix.com/apis/rendering\n */\nexport const imgixLoader = (args: ImageLoaderProps): string => {\n\tconst url = new URL(args.src);\n\n\tconst params: ImgixURLParams = {\n\t\tfit: (url.searchParams.get(\"fit\") as ImgixURLParams[\"fit\"]) || \"max\",\n\t\tw: args.width,\n\t\th: undefined,\n\t};\n\n\tif (args.quality) {\n\t\tparams.q = args.quality;\n\t}\n\n\treturn buildURL(args.src, params);\n};\n"],"names":["buildURL"],"mappings":";;;AAUa,MAAA,cAAc,CAAC,SAAkC;AAC7D,QAAM,MAAM,IAAI,IAAI,KAAK,GAAG;AAE5B,QAAM,SAAyB;AAAA,IAC9B,KAAM,IAAI,aAAa,IAAI,KAAK,KAA+B;AAAA,IAC/D,GAAG,KAAK;AAAA,IACR,GAAG;AAAA,EAAA;AAGJ,MAAI,KAAK,SAAS;AACjB,WAAO,IAAI,KAAK;AAAA,EAChB;AAEM,SAAAA,yBAAS,KAAK,KAAK,MAAM;AACjC;;"}
|
package/dist/imgixLoader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imgixLoader.js","sources":["
|
|
1
|
+
{"version":3,"file":"imgixLoader.js","sources":["../../src/imgixLoader.ts"],"sourcesContent":["import { ImageLoaderProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\n\n/**\n * A `next/image` loader for Imgix, which Prismic uses, with an optional\n * collection of default Imgix parameters.\n *\n * @see To learn about `next/image` loaders: https://nextjs.org/docs/api-reference/next/image#loader\n * @see To learn about Imgix's URL API: https://docs.imgix.com/apis/rendering\n */\nexport const imgixLoader = (args: ImageLoaderProps): string => {\n\tconst url = new URL(args.src);\n\n\tconst params: ImgixURLParams = {\n\t\tfit: (url.searchParams.get(\"fit\") as ImgixURLParams[\"fit\"]) || \"max\",\n\t\tw: args.width,\n\t\th: undefined,\n\t};\n\n\tif (args.quality) {\n\t\tparams.q = args.quality;\n\t}\n\n\treturn buildURL(args.src, params);\n};\n"],"names":[],"mappings":";AAUa,MAAA,cAAc,CAAC,SAAkC;AAC7D,QAAM,MAAM,IAAI,IAAI,KAAK,GAAG;AAE5B,QAAM,SAAyB;AAAA,IAC9B,KAAM,IAAI,aAAa,IAAI,KAAK,KAA+B;AAAA,IAC/D,GAAG,KAAK;AAAA,IACR,GAAG;AAAA,EAAA;AAGJ,MAAI,KAAK,SAAS;AACjB,WAAO,IAAI,KAAK;AAAA,EAChB;AAEM,SAAA,SAAS,KAAK,KAAK,MAAM;AACjC;"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const setPreviewData = require("./setPreviewData.cjs");
|
|
4
4
|
const exitPreview = require("./exitPreview.cjs");
|
|
5
5
|
const PrismicPreview = require("./PrismicPreview.cjs");
|
|
6
|
+
const PrismicNextLink = require("./PrismicNextLink.cjs");
|
|
6
7
|
const enableAutoPreviews = require("./enableAutoPreviews.cjs");
|
|
7
8
|
const redirectToPreviewURL = require("./redirectToPreviewURL.cjs");
|
|
8
9
|
const PrismicNextImage = require("./PrismicNextImage.cjs");
|
|
@@ -10,6 +11,7 @@ const imgixLoader = require("./imgixLoader.cjs");
|
|
|
10
11
|
exports.setPreviewData = setPreviewData.setPreviewData;
|
|
11
12
|
exports.exitPreview = exitPreview.exitPreview;
|
|
12
13
|
exports.PrismicPreview = PrismicPreview.PrismicPreview;
|
|
14
|
+
exports.PrismicNextLink = PrismicNextLink.PrismicNextLink;
|
|
13
15
|
exports.enableAutoPreviews = enableAutoPreviews.enableAutoPreviews;
|
|
14
16
|
exports.redirectToPreviewURL = redirectToPreviewURL.redirectToPreviewURL;
|
|
15
17
|
exports.PrismicNextImage = PrismicNextImage.PrismicNextImage;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
export { setPreviewData
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
export { setPreviewData } from "./setPreviewData";
|
|
2
|
+
export type { SetPreviewDataConfig } from "./setPreviewData";
|
|
3
|
+
export { exitPreview } from "./exitPreview";
|
|
4
|
+
export type { ExitPreviewConfig } from "./exitPreview";
|
|
5
|
+
export { PrismicPreview } from "./PrismicPreview";
|
|
6
|
+
export type { PrismicPreviewProps } from "./PrismicPreview";
|
|
7
|
+
export { PrismicNextLink } from "./PrismicNextLink";
|
|
8
|
+
export type { PrismicNextLinkProps } from "./PrismicNextLink";
|
|
9
|
+
export { enableAutoPreviews } from "./enableAutoPreviews";
|
|
10
|
+
export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
|
|
11
|
+
export { redirectToPreviewURL } from "./redirectToPreviewURL";
|
|
12
|
+
export type { RedirectToPreviewURLConfig } from "./redirectToPreviewURL";
|
|
13
|
+
export { PrismicNextImage } from "./PrismicNextImage";
|
|
14
|
+
export type { PrismicNextImageProps } from "./PrismicNextImage";
|
|
7
15
|
export { imgixLoader } from "./imgixLoader";
|
|
8
|
-
export { CreateClientConfig } from "./types";
|
|
16
|
+
export type { CreateClientConfig } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { setPreviewData } from "./setPreviewData.js";
|
|
2
2
|
import { exitPreview } from "./exitPreview.js";
|
|
3
3
|
import { PrismicPreview } from "./PrismicPreview.js";
|
|
4
|
+
import { PrismicNextLink } from "./PrismicNextLink.js";
|
|
4
5
|
import { enableAutoPreviews } from "./enableAutoPreviews.js";
|
|
5
6
|
import { redirectToPreviewURL } from "./redirectToPreviewURL.js";
|
|
6
7
|
import { PrismicNextImage } from "./PrismicNextImage.js";
|
|
7
8
|
import { imgixLoader } from "./imgixLoader.js";
|
|
8
9
|
export {
|
|
9
10
|
PrismicNextImage,
|
|
11
|
+
PrismicNextLink,
|
|
10
12
|
PrismicPreview,
|
|
11
13
|
enableAutoPreviews,
|
|
12
14
|
exitPreview,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const __PRODUCTION__ = process.env.NODE_ENV === "production";
|
|
4
4
|
exports.__PRODUCTION__ = __PRODUCTION__;
|
|
5
5
|
//# sourceMappingURL=__PRODUCTION__.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__PRODUCTION__.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"__PRODUCTION__.cjs","sources":["../../../src/lib/__PRODUCTION__.ts"],"sourcesContent":["/**\n * `true` if in the production environment, `false` otherwise.\n *\n * This boolean can be used to perform actions only in development environments,\n * such as logging.\n */\nexport const __PRODUCTION__ = process.env.NODE_ENV === \"production\";\n"],"names":[],"mappings":";;AAMa,MAAA,iBAAiB,QAAQ,IAAI,aAAa;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__PRODUCTION__.js","sources":["
|
|
1
|
+
{"version":3,"file":"__PRODUCTION__.js","sources":["../../../src/lib/__PRODUCTION__.ts"],"sourcesContent":["/**\n * `true` if in the production environment, `false` otherwise.\n *\n * This boolean can be used to perform actions only in development environments,\n * such as logging.\n */\nexport const __PRODUCTION__ = process.env.NODE_ENV === \"production\";\n"],"names":[],"mappings":"AAMa,MAAA,iBAAiB,QAAQ,IAAI,aAAa;"}
|
package/dist/lib/devMsg.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
const _package = require("../package.cjs");
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const _package = require("../package.json.cjs");
|
|
4
4
|
const devMsg = (slug) => {
|
|
5
5
|
return `https://prismic.dev/msg/next/v${_package.version}/${slug}`;
|
|
6
6
|
};
|
package/dist/lib/devMsg.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devMsg.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"devMsg.cjs","sources":["../../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/next/v1.2.3/missing-param.md\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string) => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`;\n};\n"],"names":["version"],"mappings":";;;AAiBa,MAAA,SAAS,CAAC,SAAgB;AACtC,SAAO,iCAAiCA,SAAAA,WAAW;AACpD;;"}
|
package/dist/lib/devMsg.js
CHANGED
package/dist/lib/devMsg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devMsg.js","sources":["
|
|
1
|
+
{"version":3,"file":"devMsg.js","sources":["../../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/next/v1.2.3/missing-param.md\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string) => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`;\n};\n"],"names":[],"mappings":";AAiBa,MAAA,SAAS,CAAC,SAAgB;AACtC,SAAO,iCAAiC,WAAW;AACpD;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const getPreviewCookieRepositoryName = (previewCookie) => {
|
|
4
4
|
return (decodeURIComponent(previewCookie).match(/"(.+).prismic.io"/) || [])[1];
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPreviewCookieRepositoryName.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"getPreviewCookieRepositoryName.cjs","sources":["../../../src/lib/getPreviewCookieRepositoryName.ts"],"sourcesContent":["/**\n * Extracts preview reference repo name from stringified Prismic preview cookie\n *\n * @param previewCookie - The Prismic preview cookie.\n *\n * @returns The repository name for the Prismic preview cookie. If the cookie\n * represents an inactive preview session, `undefined` will be returned.\n */\nexport const getPreviewCookieRepositoryName = (\n\tpreviewCookie: string,\n): string | undefined => {\n\treturn (decodeURIComponent(previewCookie).match(/\"(.+).prismic.io\"/) ||\n\t\t[])[1];\n};\n"],"names":[],"mappings":";;AAQa,MAAA,iCAAiC,CAC7C,kBACuB;AACf,UAAA,mBAAmB,aAAa,EAAE,MAAM,mBAAmB,KAClE,CAAA,GAAI,CAAC;AACP;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPreviewCookieRepositoryName.js","sources":["
|
|
1
|
+
{"version":3,"file":"getPreviewCookieRepositoryName.js","sources":["../../../src/lib/getPreviewCookieRepositoryName.ts"],"sourcesContent":["/**\n * Extracts preview reference repo name from stringified Prismic preview cookie\n *\n * @param previewCookie - The Prismic preview cookie.\n *\n * @returns The repository name for the Prismic preview cookie. If the cookie\n * represents an inactive preview session, `undefined` will be returned.\n */\nexport const getPreviewCookieRepositoryName = (\n\tpreviewCookie: string,\n): string | undefined => {\n\treturn (decodeURIComponent(previewCookie).match(/\"(.+).prismic.io\"/) ||\n\t\t[])[1];\n};\n"],"names":[],"mappings":"AAQa,MAAA,iCAAiC,CAC7C,kBACuB;AACf,UAAA,mBAAmB,aAAa,EAAE,MAAM,mBAAmB,KAClE,CAAA,GAAI,CAAC;AACP;"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const prismic = require("@prismicio/client");
|
|
4
|
-
function
|
|
5
|
-
if (e && e.__esModule)
|
|
6
|
-
return e;
|
|
4
|
+
function _interopNamespaceDefault(e) {
|
|
7
5
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
6
|
if (e) {
|
|
9
7
|
for (const k in e) {
|
|
@@ -19,7 +17,7 @@ function _interopNamespace(e) {
|
|
|
19
17
|
n.default = e;
|
|
20
18
|
return Object.freeze(n);
|
|
21
19
|
}
|
|
22
|
-
const prismic__namespace = /* @__PURE__ */
|
|
20
|
+
const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
|
|
23
21
|
const readValue = (value) => {
|
|
24
22
|
return value.replace(/%3B/g, ";");
|
|
25
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrismicPreviewCookie.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"getPrismicPreviewCookie.cjs","sources":["../../../src/lib/getPrismicPreviewCookie.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\");\n};\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nexport const getPrismicPreviewCookie = (\n\tcookieJar: string,\n): string | undefined => {\n\tconst cookies = cookieJar.split(\"; \");\n\n\tlet value: string | undefined;\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\");\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\");\n\n\t\tif (name === prismic.cookie.preview) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"));\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn value;\n};\n"],"names":["prismic"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,0BAA0B,CACtC,cACuB;AACjB,QAAA,UAAU,UAAU,MAAM,IAAI;AAEhC,MAAA;AAEJ,aAAW,UAAU,SAAS;AACvB,UAAA,QAAQ,OAAO,MAAM,GAAG;AACxB,UAAA,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAEhD,QAAA,SAASA,mBAAQ,OAAO,SAAS;AACpC,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACA;AAAA,EACD;AAEM,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrismicPreviewCookie.js","sources":["
|
|
1
|
+
{"version":3,"file":"getPrismicPreviewCookie.js","sources":["../../../src/lib/getPrismicPreviewCookie.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\");\n};\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nexport const getPrismicPreviewCookie = (\n\tcookieJar: string,\n): string | undefined => {\n\tconst cookies = cookieJar.split(\"; \");\n\n\tlet value: string | undefined;\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\");\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\");\n\n\t\tif (name === prismic.cookie.preview) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"));\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn value;\n};\n"],"names":[],"mappings":";AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,0BAA0B,CACtC,cACuB;AACjB,QAAA,UAAU,UAAU,MAAM,IAAI;AAEhC,MAAA;AAEJ,aAAW,UAAU,SAAS;AACvB,UAAA,QAAQ,OAAO,MAAM,GAAG;AACxB,UAAA,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAEhD,QAAA,SAAS,QAAQ,OAAO,SAAS;AACpC,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACA;AAAA,EACD;AAEM,SAAA;AACR;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Props for `<PrismicPreview>`.
|
|
4
|
+
*/
|
|
5
|
+
export type PrismicPreviewProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The name of your Prismic repository. A Prismic Toolbar will be registered
|
|
8
|
+
* using this repository.
|
|
9
|
+
*/
|
|
10
|
+
repositoryName: string;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
15
|
+
* the Prismic Toolbar send events to the browser, such as on preview updates
|
|
16
|
+
* and exiting, this component will automatically update Next.js Preview Mode
|
|
17
|
+
* and refresh the page.
|
|
18
|
+
*
|
|
19
|
+
* This component can be wrapped around your app or added anywhere in your app's
|
|
20
|
+
* tree. It must be rendered on every page.
|
|
21
|
+
*/
|
|
22
|
+
export declare function PrismicPreview({ repositoryName, children, }: PrismicPreviewProps): JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function buildErrorMessage(fnName) {
|
|
4
|
+
return `${fnName} is currently incompatible with App Router. Preview Mode is not supported in App Router at this time. Please remove all uses of ${fnName}.`;
|
|
5
|
+
}
|
|
6
|
+
function PrismicPreview() {
|
|
7
|
+
throw new Error(buildErrorMessage("<PrismicPreview>"));
|
|
8
|
+
}
|
|
9
|
+
function enableAutoPreviews() {
|
|
10
|
+
throw new Error(buildErrorMessage("enableAutoPreviews()"));
|
|
11
|
+
}
|
|
12
|
+
function exitPreview() {
|
|
13
|
+
throw new Error(buildErrorMessage("exitPreview()"));
|
|
14
|
+
}
|
|
15
|
+
function redirectToPreviewURL() {
|
|
16
|
+
throw new Error(buildErrorMessage("redirectToPreviewURL()"));
|
|
17
|
+
}
|
|
18
|
+
function setPreviewData() {
|
|
19
|
+
throw new Error(buildErrorMessage("setPreviewData()"));
|
|
20
|
+
}
|
|
21
|
+
exports.PrismicPreview = PrismicPreview;
|
|
22
|
+
exports.enableAutoPreviews = enableAutoPreviews;
|
|
23
|
+
exports.exitPreview = exitPreview;
|
|
24
|
+
exports.redirectToPreviewURL = redirectToPreviewURL;
|
|
25
|
+
exports.setPreviewData = setPreviewData;
|
|
26
|
+
//# sourceMappingURL=unsupported.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsupported.cjs","sources":["../../../src/react-server/unsupported.ts"],"sourcesContent":["// Exports in this file are unsupported in the react-server environment.\n// All environments should export the same functions to maintian API compatability.\n\nfunction buildErrorMessage(fnName: string) {\n\treturn `${fnName} is currently incompatible with App Router. Preview Mode is not supported in App Router at this time. Please remove all uses of ${fnName}.`;\n}\n\nexport function PrismicPreview(): JSX.Element {\n\tthrow new Error(buildErrorMessage(\"<PrismicPreview>\"));\n}\n\nexport function enableAutoPreviews() {\n\tthrow new Error(buildErrorMessage(\"enableAutoPreviews()\"));\n}\n\nexport function exitPreview() {\n\tthrow new Error(buildErrorMessage(\"exitPreview()\"));\n}\n\nexport function redirectToPreviewURL() {\n\tthrow new Error(buildErrorMessage(\"redirectToPreviewURL()\"));\n}\n\nexport function setPreviewData() {\n\tthrow new Error(buildErrorMessage(\"setPreviewData()\"));\n}\n"],"names":[],"mappings":";;AAGA,SAAS,kBAAkB,QAAc;AACxC,SAAO,GAAG,yIAAyI;AACpJ;SAEgB,iBAAc;AAC7B,QAAM,IAAI,MAAM,kBAAkB,kBAAkB,CAAC;AACtD;SAEgB,qBAAkB;AACjC,QAAM,IAAI,MAAM,kBAAkB,sBAAsB,CAAC;AAC1D;SAEgB,cAAW;AAC1B,QAAM,IAAI,MAAM,kBAAkB,eAAe,CAAC;AACnD;SAEgB,uBAAoB;AACnC,QAAM,IAAI,MAAM,kBAAkB,wBAAwB,CAAC;AAC5D;SAEgB,iBAAc;AAC7B,QAAM,IAAI,MAAM,kBAAkB,kBAAkB,CAAC;AACtD;;;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function PrismicPreview(): JSX.Element;
|
|
3
|
+
export declare function enableAutoPreviews(): void;
|
|
4
|
+
export declare function exitPreview(): void;
|
|
5
|
+
export declare function redirectToPreviewURL(): void;
|
|
6
|
+
export declare function setPreviewData(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function buildErrorMessage(fnName) {
|
|
2
|
+
return `${fnName} is currently incompatible with App Router. Preview Mode is not supported in App Router at this time. Please remove all uses of ${fnName}.`;
|
|
3
|
+
}
|
|
4
|
+
function PrismicPreview() {
|
|
5
|
+
throw new Error(buildErrorMessage("<PrismicPreview>"));
|
|
6
|
+
}
|
|
7
|
+
function enableAutoPreviews() {
|
|
8
|
+
throw new Error(buildErrorMessage("enableAutoPreviews()"));
|
|
9
|
+
}
|
|
10
|
+
function exitPreview() {
|
|
11
|
+
throw new Error(buildErrorMessage("exitPreview()"));
|
|
12
|
+
}
|
|
13
|
+
function redirectToPreviewURL() {
|
|
14
|
+
throw new Error(buildErrorMessage("redirectToPreviewURL()"));
|
|
15
|
+
}
|
|
16
|
+
function setPreviewData() {
|
|
17
|
+
throw new Error(buildErrorMessage("setPreviewData()"));
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
PrismicPreview,
|
|
21
|
+
enableAutoPreviews,
|
|
22
|
+
exitPreview,
|
|
23
|
+
redirectToPreviewURL,
|
|
24
|
+
setPreviewData
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=unsupported.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsupported.js","sources":["../../../src/react-server/unsupported.ts"],"sourcesContent":["// Exports in this file are unsupported in the react-server environment.\n// All environments should export the same functions to maintian API compatability.\n\nfunction buildErrorMessage(fnName: string) {\n\treturn `${fnName} is currently incompatible with App Router. Preview Mode is not supported in App Router at this time. Please remove all uses of ${fnName}.`;\n}\n\nexport function PrismicPreview(): JSX.Element {\n\tthrow new Error(buildErrorMessage(\"<PrismicPreview>\"));\n}\n\nexport function enableAutoPreviews() {\n\tthrow new Error(buildErrorMessage(\"enableAutoPreviews()\"));\n}\n\nexport function exitPreview() {\n\tthrow new Error(buildErrorMessage(\"exitPreview()\"));\n}\n\nexport function redirectToPreviewURL() {\n\tthrow new Error(buildErrorMessage(\"redirectToPreviewURL()\"));\n}\n\nexport function setPreviewData() {\n\tthrow new Error(buildErrorMessage(\"setPreviewData()\"));\n}\n"],"names":[],"mappings":"AAGA,SAAS,kBAAkB,QAAc;AACxC,SAAO,GAAG,yIAAyI;AACpJ;SAEgB,iBAAc;AAC7B,QAAM,IAAI,MAAM,kBAAkB,kBAAkB,CAAC;AACtD;SAEgB,qBAAkB;AACjC,QAAM,IAAI,MAAM,kBAAkB,sBAAsB,CAAC;AAC1D;SAEgB,cAAW;AAC1B,QAAM,IAAI,MAAM,kBAAkB,eAAe,CAAC;AACnD;SAEgB,uBAAoB;AACnC,QAAM,IAAI,MAAM,kBAAkB,wBAAwB,CAAC;AAC5D;SAEgB,iBAAc;AAC7B,QAAM,IAAI,MAAM,kBAAkB,kBAAkB,CAAC;AACtD;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const unsupported = require("./react-server/unsupported.cjs");
|
|
4
|
+
const PrismicNextLink = require("./PrismicNextLink.cjs");
|
|
5
|
+
const PrismicNextImage = require("./PrismicNextImage.cjs");
|
|
6
|
+
const imgixLoader = require("./imgixLoader.cjs");
|
|
7
|
+
exports.PrismicPreview = unsupported.PrismicPreview;
|
|
8
|
+
exports.enableAutoPreviews = unsupported.enableAutoPreviews;
|
|
9
|
+
exports.exitPreview = unsupported.exitPreview;
|
|
10
|
+
exports.redirectToPreviewURL = unsupported.redirectToPreviewURL;
|
|
11
|
+
exports.setPreviewData = unsupported.setPreviewData;
|
|
12
|
+
exports.PrismicNextLink = PrismicNextLink.PrismicNextLink;
|
|
13
|
+
exports.PrismicNextImage = PrismicNextImage.PrismicNextImage;
|
|
14
|
+
exports.imgixLoader = imgixLoader.imgixLoader;
|
|
15
|
+
//# sourceMappingURL=react-server.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-server.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PrismicPreview, enableAutoPreviews, exitPreview, redirectToPreviewURL, setPreviewData } from "./react-server/unsupported.js";
|
|
2
|
+
import { PrismicNextLink } from "./PrismicNextLink.js";
|
|
3
|
+
import { PrismicNextImage } from "./PrismicNextImage.js";
|
|
4
|
+
import { imgixLoader } from "./imgixLoader.js";
|
|
5
|
+
export {
|
|
6
|
+
PrismicNextImage,
|
|
7
|
+
PrismicNextLink,
|
|
8
|
+
PrismicPreview,
|
|
9
|
+
enableAutoPreviews,
|
|
10
|
+
exitPreview,
|
|
11
|
+
imgixLoader,
|
|
12
|
+
redirectToPreviewURL,
|
|
13
|
+
setPreviewData
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=react-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const isPrismicNextQuery = (query) => {
|
|
4
4
|
return typeof query.documentId === "string" && typeof query.token === "string";
|
|
5
5
|
};
|