@prismicio/next 2.2.1 → 2.2.2-canary.ef9a0f2
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 +2 -3
- package/dist/PrismicNextImage.d.ts +2 -3
- package/dist/PrismicNextImage.js +3 -5
- package/dist/PrismicNextImage.js.map +1 -1
- package/dist/PrismicNextLink.cjs +7 -8
- package/dist/PrismicNextLink.cjs.map +1 -1
- package/dist/PrismicNextLink.d.cts +10 -10
- package/dist/PrismicNextLink.d.ts +10 -10
- package/dist/PrismicNextLink.js +3 -4
- package/dist/PrismicNextLink.js.map +1 -1
- package/dist/PrismicPreview.cjs +8 -9
- package/dist/PrismicPreview.cjs.map +1 -1
- package/dist/PrismicPreview.d.cts +1 -2
- package/dist/PrismicPreview.d.ts +1 -2
- package/dist/PrismicPreview.js +3 -4
- package/dist/PrismicPreview.js.map +1 -1
- package/dist/PrismicPreviewClient.cjs +4 -6
- package/dist/PrismicPreviewClient.cjs.map +1 -1
- package/dist/PrismicPreviewClient.js +5 -7
- package/dist/PrismicPreviewClient.js.map +1 -1
- package/dist/SliceSimulator.cjs +4 -6
- package/dist/SliceSimulator.cjs.map +1 -1
- package/dist/SliceSimulator.d.cts +0 -1
- package/dist/SliceSimulator.d.ts +0 -1
- package/dist/SliceSimulator.js +1 -3
- package/dist/SliceSimulator.js.map +1 -1
- package/dist/SliceSimulatorWrapper.cjs +2 -3
- package/dist/SliceSimulatorWrapper.cjs.map +1 -1
- package/dist/SliceSimulatorWrapper.js +1 -2
- package/dist/SliceSimulatorWrapper.js.map +1 -1
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +8 -14
- package/dist/createLocaleRedirect.cjs +2 -3
- package/dist/createLocaleRedirect.cjs.map +1 -1
- package/dist/createLocaleRedirect.js +1 -2
- package/dist/createLocaleRedirect.js.map +1 -1
- package/dist/enableAutoPreviews.cjs +3 -4
- package/dist/enableAutoPreviews.cjs.map +1 -1
- package/dist/enableAutoPreviews.d.cts +1 -2
- package/dist/enableAutoPreviews.d.ts +1 -2
- package/dist/enableAutoPreviews.js +2 -3
- package/dist/enableAutoPreviews.js.map +1 -1
- package/dist/exitPreview.cjs +2 -3
- package/dist/exitPreview.cjs.map +1 -1
- package/dist/exitPreview.js +2 -2
- package/dist/getSlices.cjs +2 -3
- package/dist/getSlices.cjs.map +1 -1
- package/dist/getSlices.js +1 -2
- package/dist/getSlices.js.map +1 -1
- package/dist/imgixLoader.cjs +2 -3
- package/dist/imgixLoader.cjs.map +1 -1
- package/dist/imgixLoader.d.cts +1 -2
- package/dist/imgixLoader.d.ts +1 -2
- package/dist/imgixLoader.js +1 -2
- package/dist/imgixLoader.js.map +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.js +1 -2
- package/dist/lib/devMsg.cjs +2 -3
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +1 -2
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/resolveDefaultExport.cjs +1 -2
- package/dist/lib/resolveDefaultExport.cjs.map +1 -1
- package/dist/lib/resolveDefaultExport.js +1 -1
- package/dist/package.cjs +7 -8
- package/dist/package.js +2 -2
- package/dist/pages/PrismicPreview.cjs +7 -8
- package/dist/pages/PrismicPreview.cjs.map +1 -1
- package/dist/pages/PrismicPreview.d.cts +1 -2
- package/dist/pages/PrismicPreview.d.ts +1 -2
- package/dist/pages/PrismicPreview.js +3 -4
- package/dist/pages/PrismicPreview.js.map +1 -1
- package/dist/pages/SliceSimulator.cjs +3 -4
- package/dist/pages/SliceSimulator.cjs.map +1 -1
- package/dist/pages/SliceSimulator.js +1 -2
- package/dist/pages/SliceSimulator.js.map +1 -1
- package/dist/pages/enableAutoPreviews.cjs +1 -2
- package/dist/pages/enableAutoPreviews.cjs.map +1 -1
- package/dist/pages/enableAutoPreviews.d.cts +1 -3
- package/dist/pages/enableAutoPreviews.d.ts +1 -3
- package/dist/pages/enableAutoPreviews.js +1 -1
- package/dist/pages/exitPreview.cjs +1 -2
- package/dist/pages/exitPreview.cjs.map +1 -1
- package/dist/pages/exitPreview.js +1 -1
- package/dist/pages/redirectToPreviewURL.cjs +1 -2
- package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
- package/dist/pages/redirectToPreviewURL.d.cts +1 -2
- package/dist/pages/redirectToPreviewURL.d.ts +1 -2
- package/dist/pages/redirectToPreviewURL.js +1 -1
- package/dist/pages/setPreviewData.cjs +2 -3
- package/dist/pages/setPreviewData.cjs.map +1 -1
- package/dist/pages/setPreviewData.js +1 -2
- package/dist/pages/setPreviewData.js.map +1 -1
- package/dist/pages/types.d.cts +0 -1
- package/dist/pages/types.d.ts +0 -1
- package/dist/pages.cjs +12 -12
- package/dist/pages.js +1 -2
- package/dist/redirectToPreviewURL.cjs +3 -4
- package/dist/redirectToPreviewURL.cjs.map +1 -1
- package/dist/redirectToPreviewURL.d.cts +1 -2
- package/dist/redirectToPreviewURL.d.ts +1 -2
- package/dist/redirectToPreviewURL.js +2 -3
- package/dist/redirectToPreviewURL.js.map +1 -1
- package/package.json +19 -20
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_exitPreview = require("./exitPreview.cjs");
|
|
3
|
+
const require_PrismicPreview = require("./PrismicPreview.cjs");
|
|
4
|
+
const require_PrismicNextLink = require("./PrismicNextLink.cjs");
|
|
5
|
+
const require_enableAutoPreviews = require("./enableAutoPreviews.cjs");
|
|
6
|
+
const require_redirectToPreviewURL = require("./redirectToPreviewURL.cjs");
|
|
7
|
+
const require_imgixLoader = require("./imgixLoader.cjs");
|
|
8
|
+
const require_PrismicNextImage = require("./PrismicNextImage.cjs");
|
|
9
|
+
const require_getSlices = require("./getSlices.cjs");
|
|
10
|
+
const require_SliceSimulator = require("./SliceSimulator.cjs");
|
|
11
|
+
const require_createLocaleRedirect = require("./createLocaleRedirect.cjs");
|
|
12
12
|
exports.PrismicNextImage = require_PrismicNextImage.PrismicNextImage;
|
|
13
13
|
exports.PrismicNextLink = require_PrismicNextLink.PrismicNextLink;
|
|
14
14
|
exports.PrismicPreview = require_PrismicPreview.PrismicPreview;
|
|
@@ -18,4 +18,4 @@ exports.enableAutoPreviews = require_enableAutoPreviews.enableAutoPreviews;
|
|
|
18
18
|
exports.exitPreview = require_exitPreview.exitPreview;
|
|
19
19
|
exports.getSlices = require_getSlices.getSlices;
|
|
20
20
|
exports.imgixLoader = require_imgixLoader.imgixLoader;
|
|
21
|
-
exports.redirectToPreviewURL = require_redirectToPreviewURL.redirectToPreviewURL;
|
|
21
|
+
exports.redirectToPreviewURL = require_redirectToPreviewURL.redirectToPreviewURL;
|
package/dist/index.js
CHANGED
|
@@ -8,5 +8,4 @@ import { PrismicNextImage } from "./PrismicNextImage.js";
|
|
|
8
8
|
import { getSlices } from "./getSlices.js";
|
|
9
9
|
import { SliceSimulator } from "./SliceSimulator.js";
|
|
10
10
|
import { createLocaleRedirect } from "./createLocaleRedirect.js";
|
|
11
|
-
|
|
12
|
-
export { PrismicNextImage, PrismicNextLink, PrismicPreview, SliceSimulator, createLocaleRedirect, enableAutoPreviews, exitPreview, getSlices, imgixLoader, redirectToPreviewURL };
|
|
11
|
+
export { PrismicNextImage, PrismicNextLink, PrismicPreview, SliceSimulator, createLocaleRedirect, enableAutoPreviews, exitPreview, getSlices, imgixLoader, redirectToPreviewURL };
|
package/dist/lib/devMsg.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const require_package = require(
|
|
2
|
-
|
|
1
|
+
const require_package = require("../package.cjs");
|
|
3
2
|
//#region src/lib/devMsg.ts
|
|
4
3
|
/**
|
|
5
4
|
* Returns a `prismic.dev/msg` URL for a given message slug.
|
|
@@ -19,7 +18,7 @@ const require_package = require('../package.cjs');
|
|
|
19
18
|
const devMsg = (slug) => {
|
|
20
19
|
return `https://prismic.dev/msg/next/v${require_package.version}/${slug}`;
|
|
21
20
|
};
|
|
22
|
-
|
|
23
21
|
//#endregion
|
|
24
22
|
exports.devMsg = devMsg;
|
|
23
|
+
|
|
25
24
|
//# sourceMappingURL=devMsg.cjs.map
|
package/dist/lib/devMsg.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devMsg.cjs","names":["version"],"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\"\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): string => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"devMsg.cjs","names":["version"],"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\"\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): string => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,UAAU,SAAyB;AAC/C,QAAO,iCAAiCA,gBAAAA,QAAQ,GAAG"}
|
package/dist/lib/devMsg.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { version } from "../package.js";
|
|
2
|
-
|
|
3
2
|
//#region src/lib/devMsg.ts
|
|
4
3
|
/**
|
|
5
4
|
* Returns a `prismic.dev/msg` URL for a given message slug.
|
|
@@ -19,7 +18,7 @@ import { version } from "../package.js";
|
|
|
19
18
|
const devMsg = (slug) => {
|
|
20
19
|
return `https://prismic.dev/msg/next/v${version}/${slug}`;
|
|
21
20
|
};
|
|
22
|
-
|
|
23
21
|
//#endregion
|
|
24
22
|
export { devMsg };
|
|
23
|
+
|
|
25
24
|
//# sourceMappingURL=devMsg.js.map
|
package/dist/lib/devMsg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devMsg.js","names":[],"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\"\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): string => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"devMsg.js","names":[],"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\"\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): string => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,UAAU,SAAyB;AAC/C,QAAO,iCAAiC,QAAQ,GAAG"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/lib/resolveDefaultExport.ts
|
|
3
2
|
/**
|
|
4
3
|
* Resolves a module's default export. The module may provide its default export
|
|
@@ -20,7 +19,7 @@
|
|
|
20
19
|
function resolveDefaultExport(mod) {
|
|
21
20
|
return "default" in mod ? mod.default : mod;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
//#endregion
|
|
25
23
|
exports.resolveDefaultExport = resolveDefaultExport;
|
|
24
|
+
|
|
26
25
|
//# sourceMappingURL=resolveDefaultExport.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveDefaultExport.cjs","names":[],"sources":["../../src/lib/resolveDefaultExport.ts"],"sourcesContent":["/**\n * Resolves a module's default export. The module may provide its default export\n * as a `default` property on an object. This happens when named and default\n * exports are mixed in modules.\n *\n * In ES Modules, mixing is fine since the module resolver can distinguish\n * default and named exports. In transpiled modules, however, all exports are\n * put into a single object, and the default export is provided at a property\n * called `default`.\n *\n * This helper is needed by Next.js uses CJS files with named and default\n * exports.\n *\n * This helper _should_ be a temporary hack until Next.js and Node.js resolve\n * their ESM difficulties. This will likely not be removed any time soon,\n * unfortunately.\n */\nexport function resolveDefaultExport<T>(mod: T): T {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\treturn \"default\" in (mod as any) ? (mod as any).default : mod;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveDefaultExport.cjs","names":[],"sources":["../../src/lib/resolveDefaultExport.ts"],"sourcesContent":["/**\n * Resolves a module's default export. The module may provide its default export\n * as a `default` property on an object. This happens when named and default\n * exports are mixed in modules.\n *\n * In ES Modules, mixing is fine since the module resolver can distinguish\n * default and named exports. In transpiled modules, however, all exports are\n * put into a single object, and the default export is provided at a property\n * called `default`.\n *\n * This helper is needed by Next.js uses CJS files with named and default\n * exports.\n *\n * This helper _should_ be a temporary hack until Next.js and Node.js resolve\n * their ESM difficulties. This will likely not be removed any time soon,\n * unfortunately.\n */\nexport function resolveDefaultExport<T>(mod: T): T {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\treturn \"default\" in (mod as any) ? (mod as any).default : mod;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,qBAAwB,KAAW;AAElD,QAAO,aAAc,MAAe,IAAY,UAAU"}
|
package/dist/package.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
1
|
//#region package.json
|
|
3
|
-
var version = "2.2.
|
|
4
|
-
|
|
2
|
+
var version = "2.2.2-canary.ef9a0f2";
|
|
5
3
|
//#endregion
|
|
6
|
-
Object.defineProperty(exports,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
Object.defineProperty(exports, "version", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function() {
|
|
7
|
+
return version;
|
|
8
|
+
}
|
|
11
9
|
});
|
|
10
|
+
|
|
12
11
|
//# sourceMappingURL=package.cjs.map
|
package/dist/package.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
let
|
|
3
|
-
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let next_script_js = require("next/script.js");
|
|
3
|
+
next_script_js = require_runtime.__toESM(next_script_js);
|
|
4
4
|
let _prismicio_client = require("@prismicio/client");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
-
let
|
|
8
|
-
|
|
7
|
+
let next_router_js = require("next/router.js");
|
|
9
8
|
//#region src/pages/PrismicPreview.tsx
|
|
10
9
|
/**
|
|
11
10
|
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
@@ -18,7 +17,7 @@ let next_router = require("next/router");
|
|
|
18
17
|
*/
|
|
19
18
|
const PrismicPreview = (props) => {
|
|
20
19
|
const { repositoryName, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview", children } = props;
|
|
21
|
-
const router = (0,
|
|
20
|
+
const router = (0, next_router_js.useRouter)();
|
|
22
21
|
const toolbarSrc = (0, _prismicio_client.getToolbarSrc)(repositoryName);
|
|
23
22
|
(0, react.useEffect)(() => {
|
|
24
23
|
const controller = new AbortController();
|
|
@@ -61,7 +60,7 @@ const PrismicPreview = (props) => {
|
|
|
61
60
|
repositoryName,
|
|
62
61
|
router
|
|
63
62
|
]);
|
|
64
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
63
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(next_script_js.default, {
|
|
65
64
|
src: toolbarSrc,
|
|
66
65
|
strategy: "lazyOnload"
|
|
67
66
|
})] });
|
|
@@ -70,7 +69,7 @@ function getPreviewCookieRepositoryName() {
|
|
|
70
69
|
const cookie = window.document.cookie.split("; ").find((row) => row.startsWith(`${_prismicio_client.cookie.preview}=`))?.split("=")[1];
|
|
71
70
|
return (decodeURIComponent(cookie ?? "").match(/"([^"]+)\.prismic\.io"/) || [])[1];
|
|
72
71
|
}
|
|
73
|
-
|
|
74
72
|
//#endregion
|
|
75
73
|
exports.PrismicPreview = PrismicPreview;
|
|
74
|
+
|
|
76
75
|
//# sourceMappingURL=PrismicPreview.cjs.map
|
|
@@ -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\";\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\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\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\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\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically refresh the page with the\n * changes.\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 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(\n\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t) &&\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\"/) ||\n\t\t[])[1];\n}\n"],"mappings":"
|
|
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\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\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\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\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically refresh the page with the\n * changes.\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 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(\n\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t) &&\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\"/) ||\n\t\t[])[1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,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,WACpB,OAAO,SAAS,SAAS,OAAO,SAChC,IACD,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,IACvE,EAAE,EAAE"}
|
|
@@ -17,8 +17,7 @@ type PrismicPreviewProps = {
|
|
|
17
17
|
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
|
|
18
18
|
* This URL will be fetched on preview exit events.
|
|
19
19
|
*/
|
|
20
|
-
exitPreviewURL?: string;
|
|
21
|
-
/** Children to render adjacent to the Prismic Toolbar. */
|
|
20
|
+
exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
|
|
22
21
|
children?: ReactNode;
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
@@ -17,8 +17,7 @@ type PrismicPreviewProps = {
|
|
|
17
17
|
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
|
|
18
18
|
* This URL will be fetched on preview exit events.
|
|
19
19
|
*/
|
|
20
|
-
exitPreviewURL?: string;
|
|
21
|
-
/** Children to render adjacent to the Prismic Toolbar. */
|
|
20
|
+
exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
|
|
22
21
|
children?: ReactNode;
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import Script from "next/script";
|
|
1
|
+
import Script from "next/script.js";
|
|
2
2
|
import { cookie, getToolbarSrc } from "@prismicio/client";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { useRouter } from "next/router";
|
|
6
|
-
|
|
5
|
+
import { useRouter } from "next/router.js";
|
|
7
6
|
//#region src/pages/PrismicPreview.tsx
|
|
8
7
|
/**
|
|
9
8
|
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
@@ -68,7 +67,7 @@ function getPreviewCookieRepositoryName() {
|
|
|
68
67
|
const cookie$1 = window.document.cookie.split("; ").find((row) => row.startsWith(`${cookie.preview}=`))?.split("=")[1];
|
|
69
68
|
return (decodeURIComponent(cookie$1 ?? "").match(/"([^"]+)\.prismic\.io"/) || [])[1];
|
|
70
69
|
}
|
|
71
|
-
|
|
72
70
|
//#endregion
|
|
73
71
|
export { PrismicPreview };
|
|
72
|
+
|
|
74
73
|
//# sourceMappingURL=PrismicPreview.js.map
|
|
@@ -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\";\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\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\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\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\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically refresh the page with the\n * changes.\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 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(\n\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t) &&\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\"/) ||\n\t\t[])[1];\n}\n"],"mappings":"
|
|
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\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\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\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\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically refresh the page with the\n * changes.\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 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(\n\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t) &&\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\"/) ||\n\t\t[])[1];\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,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,WACpB,OAAO,SAAS,SAAS,OAAO,SAChC,IACD,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,IACvE,EAAE,EAAE"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const require_SliceSimulatorWrapper = require(
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_SliceSimulatorWrapper = require("../SliceSimulatorWrapper.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
let _prismicio_simulator_kit = require("@prismicio/simulator/kit");
|
|
6
|
-
|
|
7
6
|
//#region src/pages/SliceSimulator.tsx
|
|
8
7
|
const simulatorManager = new _prismicio_simulator_kit.SimulatorManager();
|
|
9
8
|
/**
|
|
@@ -35,7 +34,7 @@ const SliceSimulator = ({ background, zIndex, className, sliceZone: SliceZoneCom
|
|
|
35
34
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SliceZoneComp, { slices })
|
|
36
35
|
});
|
|
37
36
|
};
|
|
38
|
-
|
|
39
37
|
//#endregion
|
|
40
38
|
exports.SliceSimulator = SliceSimulator;
|
|
39
|
+
|
|
41
40
|
//# sourceMappingURL=SliceSimulator.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","StateEventType","SliceSimulatorWrapper"],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\";\nimport {\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\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 *\n\t * ```tsx\n\t * import { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t * import { SliceZone } from \"@prismicio/react\";\n\t *\n\t * import { components } from \"../slices\";\n\t *\n\t * <SliceSimulator\n\t * \tsliceZone={({ slices }) => (\n\t * \t\t<SliceZone slices={slices} components={components} />\n\t * \t)}\n\t * />;\n\t * ```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>;\n\tclassName?: string;\n};\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice\n * development in Slice Machine 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":"
|
|
1
|
+
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","StateEventType","SliceSimulatorWrapper"],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\";\nimport {\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\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 *\n\t * ```tsx\n\t * import { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t * import { SliceZone } from \"@prismicio/react\";\n\t *\n\t * import { components } from \"../slices\";\n\t *\n\t * <SliceSimulator\n\t * \tsliceZone={({ slices }) => (\n\t * \t\t<SliceZone slices={slices} components={components} />\n\t * \t)}\n\t * />;\n\t * ```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>;\n\tclassName?: string;\n};\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice\n * development in Slice Machine 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":";;;;;;AAcA,MAAM,mBAAmB,IAAIA,yBAAAA,kBAAkB;;;;;AAiC/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"}
|
|
@@ -2,7 +2,6 @@ import { SliceSimulatorWrapper } from "../SliceSimulatorWrapper.js";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { SimulatorManager, StateEventType, getDefaultMessage, getDefaultSlices } from "@prismicio/simulator/kit";
|
|
5
|
-
|
|
6
5
|
//#region src/pages/SliceSimulator.tsx
|
|
7
6
|
const simulatorManager = new SimulatorManager();
|
|
8
7
|
/**
|
|
@@ -34,7 +33,7 @@ const SliceSimulator = ({ background, zIndex, className, sliceZone: SliceZoneCom
|
|
|
34
33
|
children: /* @__PURE__ */ jsx(SliceZoneComp, { slices })
|
|
35
34
|
});
|
|
36
35
|
};
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
39
37
|
export { SliceSimulator };
|
|
38
|
+
|
|
40
39
|
//# sourceMappingURL=SliceSimulator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\";\nimport {\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\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 *\n\t * ```tsx\n\t * import { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t * import { SliceZone } from \"@prismicio/react\";\n\t *\n\t * import { components } from \"../slices\";\n\t *\n\t * <SliceSimulator\n\t * \tsliceZone={({ slices }) => (\n\t * \t\t<SliceZone slices={slices} components={components} />\n\t * \t)}\n\t * />;\n\t * ```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>;\n\tclassName?: string;\n};\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice\n * development in Slice Machine 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":"
|
|
1
|
+
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../../src/pages/SliceSimulator.tsx"],"sourcesContent":["import { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\";\nimport {\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\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 *\n\t * ```tsx\n\t * import { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t * import { SliceZone } from \"@prismicio/react\";\n\t *\n\t * import { components } from \"../slices\";\n\t *\n\t * <SliceSimulator\n\t * \tsliceZone={({ slices }) => (\n\t * \t\t<SliceZone slices={slices} components={components} />\n\t * \t)}\n\t * />;\n\t * ```\n\t */\n\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>;\n\tclassName?: string;\n};\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice\n * development in Slice Machine 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":";;;;;AAcA,MAAM,mBAAmB,IAAI,kBAAkB;;;;;AAiC/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,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/pages/enableAutoPreviews.ts
|
|
3
2
|
/**
|
|
4
3
|
* Configures a Prismic client to automatically query draft content during a
|
|
@@ -20,7 +19,7 @@ function enableAutoPreviews(config) {
|
|
|
20
19
|
function isPrismicPreviewData(input) {
|
|
21
20
|
return typeof input === "object" && input !== null && "ref" in input;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
//#endregion
|
|
25
23
|
exports.enableAutoPreviews = enableAutoPreviews;
|
|
24
|
+
|
|
26
25
|
//# sourceMappingURL=enableAutoPreviews.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableAutoPreviews.cjs","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"sourcesContent":["import type { PreviewData } from \"next\";\nimport type { Client } from \"@prismicio/client\";\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\n\t * `getServerSideProps()` context 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\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 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":"
|
|
1
|
+
{"version":3,"file":"enableAutoPreviews.cjs","names":[],"sources":["../../src/pages/enableAutoPreviews.ts"],"sourcesContent":["import type { PreviewData } from \"next\";\nimport type { Client } from \"@prismicio/client\";\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\n\t * `getServerSideProps()` context 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\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 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"}
|
|
@@ -3,15 +3,13 @@ import { Client } from "@prismicio/client";
|
|
|
3
3
|
import { PreviewData } from "next";
|
|
4
4
|
|
|
5
5
|
//#region src/pages/enableAutoPreviews.d.ts
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* Configuration for `enableAutoPreviews`.
|
|
9
8
|
*
|
|
10
9
|
* @typeParam TPreviewData - Next.js preview data object.
|
|
11
10
|
*/
|
|
12
11
|
type EnableAutoPreviewsConfig = {
|
|
13
|
-
/** Prismic client with which automatic previews will be enabled. */
|
|
14
|
-
client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
|
|
12
|
+
/** Prismic client with which automatic previews will be enabled. */client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
|
|
15
13
|
/**
|
|
16
14
|
* The `previewData` object provided in the `getStaticProps()` or
|
|
17
15
|
* `getServerSideProps()` context object.
|
|
@@ -3,15 +3,13 @@ import { Client } from "@prismicio/client";
|
|
|
3
3
|
import { PreviewData } from "next";
|
|
4
4
|
|
|
5
5
|
//#region src/pages/enableAutoPreviews.d.ts
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* Configuration for `enableAutoPreviews`.
|
|
9
8
|
*
|
|
10
9
|
* @typeParam TPreviewData - Next.js preview data object.
|
|
11
10
|
*/
|
|
12
11
|
type EnableAutoPreviewsConfig = {
|
|
13
|
-
/** Prismic client with which automatic previews will be enabled. */
|
|
14
|
-
client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
|
|
12
|
+
/** Prismic client with which automatic previews will be enabled. */client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
|
|
15
13
|
/**
|
|
16
14
|
* The `previewData` object provided in the `getStaticProps()` or
|
|
17
15
|
* `getServerSideProps()` context object.
|
|
@@ -19,7 +19,7 @@ function enableAutoPreviews(config) {
|
|
|
19
19
|
function isPrismicPreviewData(input) {
|
|
20
20
|
return typeof input === "object" && input !== null && "ref" in input;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
//#endregion
|
|
24
23
|
export { enableAutoPreviews };
|
|
24
|
+
|
|
25
25
|
//# sourceMappingURL=enableAutoPreviews.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/pages/exitPreview.ts
|
|
3
2
|
/**
|
|
4
3
|
* Ends a Prismic preview session within a Next.js app. This function should be
|
|
@@ -21,7 +20,7 @@ function exitPreview(config) {
|
|
|
21
20
|
config.res.setHeader("Cache-Control", "no-store");
|
|
22
21
|
config.res.json({ success: true });
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
//#endregion
|
|
26
24
|
exports.exitPreview = exitPreview;
|
|
25
|
+
|
|
27
26
|
//# sourceMappingURL=exitPreview.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.cjs","names":[],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import type { NextApiRequestLike, NextApiResponseLike } from \"./types\";\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike;\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike;\n};\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be\n * used in an API route.\n *\n * @example\n *\n * ```typescript\n * // src/pages/api/exit-preview.js\n *\n * import { exitPreview } from \"@prismicio/next\";\n *\n * export default function handler(_req, res) {\n * \treturn exitPreview({ res });\n * }\n * ```\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":"
|
|
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\n * used in an API route.\n *\n * @example\n *\n * ```typescript\n * // src/pages/api/exit-preview.js\n *\n * import { exitPreview } from \"@prismicio/next\";\n *\n * export default function handler(_req, res) {\n * \treturn exitPreview({ res });\n * }\n * ```\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":";;;;;;;;;;;;;;;;;AAmCA,SAAgB,YAAY,QAAyC;AACpE,QAAO,IAAI,kBAAkB;AAG7B,QAAO,IAAI,UAAU,iBAAiB,WAAW;AAEjD,QAAO,IAAI,KAAK,EAAE,SAAS,MAAM,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/pages/redirectToPreviewURL.ts
|
|
3
2
|
async function redirectToPreviewURL(config) {
|
|
4
3
|
const { client, req, res, linkResolver, defaultURL = "/", basePath = "" } = config;
|
|
@@ -10,7 +9,7 @@ async function redirectToPreviewURL(config) {
|
|
|
10
9
|
});
|
|
11
10
|
res.redirect(basePath + previewURL);
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
13
|
exports.redirectToPreviewURL = redirectToPreviewURL;
|
|
14
|
+
|
|
16
15
|
//# sourceMappingURL=redirectToPreviewURL.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirectToPreviewURL.cjs","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\";\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\";\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">;\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike;\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike;\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed\n\t * document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the\n\t * `defaultURL` option must _not_ include it. Instead, provide the `basePath`\n\t * property using the `basePath` option.\n\t */\n\tdefaultURL?: string;\n\n\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`.\n\t * This option can be omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath`\n\t * automatically. It must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string;\n};\n\nexport async function redirectToPreviewURL(\n\tconfig: RedirectToPreviewURLConfig,\n): Promise<void> {\n\tconst {\n\t\tclient,\n\t\treq,\n\t\tres,\n\t\tlinkResolver,\n\t\tdefaultURL = \"/\",\n\t\tbasePath = \"\",\n\t} = config;\n\n\tconst previewToken = req.query.token?.toString();\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t});\n\n\tres.redirect(basePath + previewURL);\n\n\treturn;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"redirectToPreviewURL.cjs","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\";\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\";\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">;\n\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike;\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike;\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed\n\t * document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the\n\t * `defaultURL` option must _not_ include it. Instead, provide the `basePath`\n\t * property using the `basePath` option.\n\t */\n\tdefaultURL?: string;\n\n\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`.\n\t * This option can be omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath`\n\t * automatically. It must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string;\n};\n\nexport async function redirectToPreviewURL(\n\tconfig: RedirectToPreviewURLConfig,\n): Promise<void> {\n\tconst {\n\t\tclient,\n\t\treq,\n\t\tres,\n\t\tlinkResolver,\n\t\tdefaultURL = \"/\",\n\t\tbasePath = \"\",\n\t} = config;\n\n\tconst previewToken = req.query.token?.toString();\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t});\n\n\tres.redirect(basePath + previewURL);\n\n\treturn;\n}\n"],"mappings":";AAqDA,eAAsB,qBACrB,QACgB;CAChB,MAAM,EACL,QACA,KACA,KACA,cACA,aAAa,KACb,WAAW,OACR;CAEJ,MAAM,eAAe,IAAI,MAAM,OAAO,UAAU;CAEhD,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;EACA,CAAC;AAEF,KAAI,SAAS,WAAW,WAAW"}
|
|
@@ -3,8 +3,7 @@ import { Client, LinkResolverFunction } from "@prismicio/client";
|
|
|
3
3
|
|
|
4
4
|
//#region src/pages/redirectToPreviewURL.d.ts
|
|
5
5
|
type RedirectToPreviewURLConfig = {
|
|
6
|
-
/** The Prismic client configured for the preview session's repository. */
|
|
7
|
-
client: Pick<Client, "resolvePreviewURL">;
|
|
6
|
+
/** The Prismic client configured for the preview session's repository. */client: Pick<Client, "resolvePreviewURL">;
|
|
8
7
|
/**
|
|
9
8
|
* The `req` object from a Next.js API route.
|
|
10
9
|
*
|
|
@@ -3,8 +3,7 @@ import { Client, LinkResolverFunction } from "@prismicio/client";
|
|
|
3
3
|
|
|
4
4
|
//#region src/pages/redirectToPreviewURL.d.ts
|
|
5
5
|
type RedirectToPreviewURLConfig = {
|
|
6
|
-
/** The Prismic client configured for the preview session's repository. */
|
|
7
|
-
client: Pick<Client, "resolvePreviewURL">;
|
|
6
|
+
/** The Prismic client configured for the preview session's repository. */client: Pick<Client, "resolvePreviewURL">;
|
|
8
7
|
/**
|
|
9
8
|
* The `req` object from a Next.js API route.
|
|
10
9
|
*
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let _prismicio_client = require("@prismicio/client");
|
|
3
|
-
|
|
4
3
|
//#region src/pages/setPreviewData.ts
|
|
5
4
|
/** Set Prismic preview data for Next.js's Preview Mode. */
|
|
6
5
|
function setPreviewData({ req, res }) {
|
|
7
6
|
const ref = req.query.token || req.cookies[_prismicio_client.cookie.preview];
|
|
8
7
|
if (ref) res.setPreviewData({ ref });
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
//#endregion
|
|
12
10
|
exports.setPreviewData = setPreviewData;
|
|
11
|
+
|
|
13
12
|
//# sourceMappingURL=setPreviewData.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setPreviewData.cjs","names":["cookie"],"sources":["../../src/pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\";\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\";\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike;\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike;\n};\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview];\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref });\n\t}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"setPreviewData.cjs","names":["cookie"],"sources":["../../src/pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\";\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\";\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike;\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike;\n};\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview];\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref });\n\t}\n}\n"],"mappings":";;;;AAsBA,SAAgB,eAAe,EAAE,KAAK,OAAmC;CACxE,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQA,kBAAAA,OAAO;AAElD,KAAI,IACH,KAAI,eAAe,EAAE,KAAK,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { cookie } from "@prismicio/client";
|
|
2
|
-
|
|
3
2
|
//#region src/pages/setPreviewData.ts
|
|
4
3
|
/** Set Prismic preview data for Next.js's Preview Mode. */
|
|
5
4
|
function setPreviewData({ req, res }) {
|
|
6
5
|
const ref = req.query.token || req.cookies[cookie.preview];
|
|
7
6
|
if (ref) res.setPreviewData({ ref });
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
//#endregion
|
|
11
9
|
export { setPreviewData };
|
|
10
|
+
|
|
12
11
|
//# sourceMappingURL=setPreviewData.js.map
|