@prismicio/next 2.2.0 → 2.2.1-canary.0a22932
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.d.ts +57 -0
- package/dist/PrismicNextImage.js +69 -0
- package/dist/PrismicNextImage.js.map +1 -0
- package/dist/PrismicNextLink.d.cts +3 -3
- package/dist/PrismicNextLink.d.ts +54 -0
- package/dist/PrismicNextLink.js +29 -0
- package/dist/PrismicNextLink.js.map +1 -0
- package/dist/PrismicPreview.d.ts +36 -0
- package/dist/PrismicPreview.js +39 -0
- package/dist/PrismicPreview.js.map +1 -0
- package/dist/PrismicPreviewClient.js +76 -0
- package/dist/PrismicPreviewClient.js.map +1 -0
- package/dist/SliceSimulator.d.ts +25 -0
- package/dist/SliceSimulator.js +48 -0
- package/dist/SliceSimulator.js.map +1 -0
- package/dist/SliceSimulatorWrapper.js +35 -0
- package/dist/SliceSimulatorWrapper.js.map +1 -0
- package/dist/createLocaleRedirect.d.ts +14 -0
- package/dist/createLocaleRedirect.js +14 -0
- package/dist/createLocaleRedirect.js.map +1 -0
- package/dist/enableAutoPreviews.d.ts +18 -0
- package/dist/enableAutoPreviews.js +29 -0
- package/dist/enableAutoPreviews.js.map +1 -0
- package/dist/exitPreview.d.ts +21 -0
- package/dist/exitPreview.js +26 -0
- package/dist/exitPreview.js.map +1 -0
- package/dist/getSlices.d.ts +7 -0
- package/dist/getSlices.js +11 -0
- package/dist/getSlices.js.map +1 -0
- package/dist/imgixLoader.d.ts +15 -0
- package/dist/imgixLoader.js +23 -0
- package/dist/imgixLoader.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/lib/devMsg.js +25 -0
- package/dist/lib/devMsg.js.map +1 -0
- package/dist/lib/resolveDefaultExport.js +25 -0
- package/dist/lib/resolveDefaultExport.js.map +1 -0
- package/dist/package.cjs +1 -1
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/pages/PrismicPreview.d.ts +36 -0
- package/dist/pages/PrismicPreview.js +74 -0
- package/dist/pages/PrismicPreview.js.map +1 -0
- package/dist/pages/SliceSimulator.d.ts +37 -0
- package/dist/pages/SliceSimulator.js +40 -0
- package/dist/pages/SliceSimulator.js.map +1 -0
- package/dist/pages/enableAutoPreviews.d.ts +37 -0
- package/dist/pages/enableAutoPreviews.js +25 -0
- package/dist/pages/enableAutoPreviews.js.map +1 -0
- package/dist/pages/exitPreview.d.ts +38 -0
- package/dist/pages/exitPreview.js +26 -0
- package/dist/pages/exitPreview.js.map +1 -0
- package/dist/pages/redirectToPreviewURL.d.ts +48 -0
- package/dist/pages/redirectToPreviewURL.js +15 -0
- package/dist/pages/redirectToPreviewURL.js.map +1 -0
- package/dist/pages/setPreviewData.d.ts +26 -0
- package/dist/pages/setPreviewData.js +12 -0
- package/dist/pages/setPreviewData.js.map +1 -0
- package/dist/pages/types.d.ts +36 -0
- package/dist/pages.d.ts +12 -0
- package/dist/pages.js +12 -0
- package/dist/redirectToPreviewURL.d.ts +33 -0
- package/dist/redirectToPreviewURL.js +23 -0
- package/dist/redirectToPreviewURL.js.map +1 -0
- package/dist/types.d.ts +31 -0
- package/package.json +9 -13
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ImageFieldImage } from "@prismicio/client";
|
|
2
|
+
import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
|
|
3
|
+
import { ImageProps } from "next/image";
|
|
4
|
+
import { ImgixURLParams } from "imgix-url-builder";
|
|
5
|
+
|
|
6
|
+
//#region src/PrismicNextImage.d.ts
|
|
7
|
+
type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
|
|
8
|
+
/** The Prismic Image field or thumbnail to render. */
|
|
9
|
+
field: ImageFieldImage | null | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
12
|
+
*
|
|
13
|
+
* @see https://docs.imgix.com/apis/rendering
|
|
14
|
+
*/
|
|
15
|
+
imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };
|
|
16
|
+
/**
|
|
17
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
18
|
+
*
|
|
19
|
+
* See:
|
|
20
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
21
|
+
*/
|
|
22
|
+
alt?: "";
|
|
23
|
+
/**
|
|
24
|
+
* Declare an image as decorative only if the Image field does not have
|
|
25
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
26
|
+
*
|
|
27
|
+
* See:
|
|
28
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
29
|
+
*/
|
|
30
|
+
fallbackAlt?: "";
|
|
31
|
+
/**
|
|
32
|
+
* Rendered when the field is empty. If a fallback is not given, `null` will
|
|
33
|
+
* be rendered.
|
|
34
|
+
*/
|
|
35
|
+
fallback?: React.ReactNode;
|
|
36
|
+
loader?: ImageProps["loader"] | null;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* React component that renders an image from a Prismic Image field or one of
|
|
40
|
+
* its thumbnails using `next/image`. It will automatically set the `alt`
|
|
41
|
+
* attribute using the Image field's `alt` property.
|
|
42
|
+
*
|
|
43
|
+
* It uses an Imgix URL-based loader by default. A custom loader can be provided
|
|
44
|
+
* with the `loader` prop. If you would like to use the Next.js Image
|
|
45
|
+
* Optimization API instead, set `loader={undefined}`.
|
|
46
|
+
*
|
|
47
|
+
* @param props - Props for the component.
|
|
48
|
+
*
|
|
49
|
+
* @returns A responsive image component using `next/image` for the given Image
|
|
50
|
+
* field.
|
|
51
|
+
*
|
|
52
|
+
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
|
|
53
|
+
*/
|
|
54
|
+
declare const PrismicNextImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>>;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { PrismicNextImage, PrismicNextImageProps };
|
|
57
|
+
//# sourceMappingURL=PrismicNextImage.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { resolveDefaultExport } from "./lib/resolveDefaultExport.js";
|
|
4
|
+
import { devMsg } from "./lib/devMsg.js";
|
|
5
|
+
import { imgixLoader } from "./imgixLoader.js";
|
|
6
|
+
import { isFilled } from "@prismicio/client";
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
9
|
+
import Image from "next/image";
|
|
10
|
+
import { buildURL } from "imgix-url-builder";
|
|
11
|
+
|
|
12
|
+
//#region src/PrismicNextImage.tsx
|
|
13
|
+
const castInt = (input) => {
|
|
14
|
+
if (typeof input === "number" || typeof input === "undefined") return input;
|
|
15
|
+
else {
|
|
16
|
+
const parsed = Number.parseInt(input);
|
|
17
|
+
if (Number.isNaN(parsed)) return;
|
|
18
|
+
else return parsed;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* React component that renders an image from a Prismic Image field or one of
|
|
23
|
+
* its thumbnails using `next/image`. It will automatically set the `alt`
|
|
24
|
+
* attribute using the Image field's `alt` property.
|
|
25
|
+
*
|
|
26
|
+
* It uses an Imgix URL-based loader by default. A custom loader can be provided
|
|
27
|
+
* with the `loader` prop. If you would like to use the Next.js Image
|
|
28
|
+
* Optimization API instead, set `loader={undefined}`.
|
|
29
|
+
*
|
|
30
|
+
* @param props - Props for the component.
|
|
31
|
+
*
|
|
32
|
+
* @returns A responsive image component using `next/image` for the given Image
|
|
33
|
+
* field.
|
|
34
|
+
*
|
|
35
|
+
* @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
|
|
36
|
+
*/
|
|
37
|
+
const PrismicNextImage = forwardRef(function PrismicNextImage$1({ field, imgixParams = {}, alt, fallbackAlt, fill, width, height, fallback = null, loader = imgixLoader, ...restProps }, ref) {
|
|
38
|
+
if (process.env.NODE_ENV === "development") {
|
|
39
|
+
if (typeof alt === "string" && alt !== "") console.warn(`[PrismicNextImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
|
|
40
|
+
if (typeof fallbackAlt === "string" && fallbackAlt !== "") console.warn(`[PrismicNextImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
|
|
41
|
+
}
|
|
42
|
+
if (!isFilled.imageThumbnail(field)) return /* @__PURE__ */ jsx(Fragment, { children: fallback });
|
|
43
|
+
const resolvedImgixParams = imgixParams;
|
|
44
|
+
for (const x in imgixParams) if (resolvedImgixParams[x] === null) resolvedImgixParams[x] = void 0;
|
|
45
|
+
const src = buildURL(field.url, imgixParams);
|
|
46
|
+
const ar = field.dimensions.width / field.dimensions.height;
|
|
47
|
+
const castedWidth = castInt(width);
|
|
48
|
+
const castedHeight = castInt(height);
|
|
49
|
+
let resolvedWidth = castedWidth ?? field.dimensions.width;
|
|
50
|
+
let resolvedHeight = castedHeight ?? field.dimensions.height;
|
|
51
|
+
if (castedWidth != null && castedHeight == null) resolvedHeight = castedWidth / ar;
|
|
52
|
+
else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
|
|
53
|
+
const resolvedAlt = alt ?? (field.alt || fallbackAlt);
|
|
54
|
+
if (process.env.NODE_ENV === "development" && typeof resolvedAlt !== "string") console.error(`[PrismicNextImage] The following image is missing an "alt" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \`alt=""\` or \`fallbackAlt=""\`.`, src);
|
|
55
|
+
return /* @__PURE__ */ jsx(resolveDefaultExport(Image), {
|
|
56
|
+
ref,
|
|
57
|
+
src,
|
|
58
|
+
width: fill ? void 0 : resolvedWidth,
|
|
59
|
+
height: fill ? void 0 : resolvedHeight,
|
|
60
|
+
alt: resolvedAlt,
|
|
61
|
+
fill,
|
|
62
|
+
loader: loader === null ? void 0 : loader,
|
|
63
|
+
...restProps
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { PrismicNextImage };
|
|
69
|
+
//# sourceMappingURL=PrismicNextImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicNextImage.js","names":["PrismicNextImage"],"sources":["../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n\tForwardRefExoticComponent,\n\tPropsWithoutRef,\n\tRefAttributes} from \"react\";\nimport {\n\tforwardRef\n} from \"react\";\nimport type { ImageProps } from \"next/image\";\nimport Image from \"next/image\";\nimport type { ImgixURLParams } from \"imgix-url-builder\";\nimport { buildURL } from \"imgix-url-builder\";\nimport type { ImageFieldImage} from \"@prismicio/client\";\nimport { isFilled } from \"@prismicio/client\";\n\nimport { devMsg } from \"./lib/devMsg\";\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\n\nimport { imgixLoader } from \"./imgixLoader\";\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input;\n\t} else {\n\t\tconst parsed = Number.parseInt(input);\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\treturn parsed;\n\t\t}\n\t}\n};\n\nexport type PrismicNextImageProps = Omit<\n\tImageProps,\n\t\"src\" | \"alt\" | \"loader\"\n> & {\n\t/** The Prismic Image field or thumbnail to render. */\n\tfield: ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * @see https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n\n\t/**\n\t * Rendered when the field is empty. If a fallback is not given, `null` will\n\t * be rendered.\n\t */\n\tfallback?: React.ReactNode;\n\n\tloader?: ImageProps[\"loader\"] | null;\n};\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails using `next/image`. It will automatically set the `alt`\n * attribute using the Image field's `alt` property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided\n * with the `loader` prop. If you would like to use the Next.js Image\n * Optimization API instead, set `loader={undefined}`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component using `next/image` for the given Image\n * field.\n *\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\n// The type annotation is necessary to avoid a type reference issue.\nexport const PrismicNextImage: ForwardRefExoticComponent<\n\tPropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>\n> = forwardRef<HTMLImageElement, PrismicNextImageProps>(\n\tfunction PrismicNextImage(\n\t\t{\n\t\t\tfield,\n\t\t\timgixParams = {},\n\t\t\talt,\n\t\t\tfallbackAlt,\n\t\t\tfill,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tfallback = null,\n\t\t\tloader = imgixLoader,\n\t\t\t...restProps\n\t\t},\n\t\tref,\n\t) {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicNextImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicNextImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!isFilled.imageThumbnail(field)) {\n\t\t\treturn <>{fallback}</>;\n\t\t}\n\n\t\tconst resolvedImgixParams = imgixParams;\n\t\tfor (const x in imgixParams) {\n\t\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst src = buildURL(field.url, imgixParams as ImgixURLParams);\n\n\t\tconst ar = field.dimensions.width / field.dimensions.height;\n\n\t\tconst castedWidth = castInt(width);\n\t\tconst castedHeight = castInt(height);\n\n\t\tlet resolvedWidth = castedWidth ?? field.dimensions.width;\n\t\tlet resolvedHeight = castedHeight ?? field.dimensions.height;\n\n\t\tif (castedWidth != null && castedHeight == null) {\n\t\t\tresolvedHeight = castedWidth / ar;\n\t\t} else if (castedWidth == null && castedHeight != null) {\n\t\t\tresolvedWidth = castedHeight * ar;\n\t\t}\n\n\t\t// A non-null assertion is required since we can't statically\n\t\t// know if an alt attribute is available.\n\t\tconst resolvedAlt = (alt ?? (field.alt || fallbackAlt))!;\n\n\t\tif (\n\t\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\ttypeof resolvedAlt !== \"string\"\n\t\t) {\n\t\t\tconsole.error(\n\t\t\t\t`[PrismicNextImage] The following image is missing an \"alt\" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \\`alt=\"\"\\` or \\`fallbackAlt=\"\"\\`.`,\n\t\t\t\tsrc,\n\t\t\t);\n\t\t}\n\n\t\tconst ResolvedImage = resolveDefaultExport(Image);\n\n\t\treturn (\n\t\t\t<ResolvedImage\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\t\talt={resolvedAlt}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={loader === null ? undefined : loader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,WAAW,UAA2D;AAC3E,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YACjD,QAAO;MACD;EACN,MAAM,SAAS,OAAO,SAAS,MAAM;AAErC,MAAI,OAAO,MAAM,OAAO,CACvB;MAEA,QAAO;;;;;;;;;;;;;;;;;;;AA8DV,MAAa,mBAET,WACH,SAASA,mBACR,EACC,OACA,cAAc,EAAE,EAChB,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAAS,aACT,GAAG,aAEJ,KACC;AACD,KAAI,QAAQ,IAAI,aAAa,eAAe;AAC3C,MAAI,OAAO,QAAQ,YAAY,QAAQ,GACtC,SAAQ,KACP,yQAAyQ,OACxQ,8BACA,GACD;AAGF,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,GACtD,SAAQ,KACP,ySAAyS,OACxS,8BACA,GACD;;AAIH,KAAI,CAAC,SAAS,eAAe,MAAM,CAClC,QAAO,0CAAG,WAAY;CAGvB,MAAM,sBAAsB;AAC5B,MAAK,MAAM,KAAK,YACf,KAAI,oBAAoB,OAA2C,KAClE,qBAAoB,KAAyC;CAI/D,MAAM,MAAM,SAAS,MAAM,KAAK,YAA8B;CAE9D,MAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;CAErD,MAAM,cAAc,QAAQ,MAAM;CAClC,MAAM,eAAe,QAAQ,OAAO;CAEpC,IAAI,gBAAgB,eAAe,MAAM,WAAW;CACpD,IAAI,iBAAiB,gBAAgB,MAAM,WAAW;AAEtD,KAAI,eAAe,QAAQ,gBAAgB,KAC1C,kBAAiB,cAAc;UACrB,eAAe,QAAQ,gBAAgB,KACjD,iBAAgB,eAAe;CAKhC,MAAM,cAAe,QAAQ,MAAM,OAAO;AAE1C,KACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,SAEvB,SAAQ,MACP,mNACA,IACA;AAKF,QACC,oBAHqB,qBAAqB,MAAM;EAI1C;EACA;EACL,OAAO,OAAO,SAAY;EAC1B,QAAQ,OAAO,SAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,SAAY;EACtC,GAAI;GACH;EAGJ"}
|
|
@@ -23,7 +23,7 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
|
|
|
23
23
|
});
|
|
24
24
|
declare const PrismicNextLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
|
|
25
25
|
children?: React.ReactNode | undefined;
|
|
26
|
-
} & react0.RefAttributes<HTMLAnchorElement>, "
|
|
26
|
+
} & react0.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
27
27
|
linkResolver?: LinkResolverFunction;
|
|
28
28
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
29
29
|
} & {
|
|
@@ -32,7 +32,7 @@ declare const PrismicNextLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<
|
|
|
32
32
|
href?: never;
|
|
33
33
|
}, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
|
|
34
34
|
children?: React.ReactNode | undefined;
|
|
35
|
-
} & react0.RefAttributes<HTMLAnchorElement>, "
|
|
35
|
+
} & react0.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
36
36
|
linkResolver?: LinkResolverFunction;
|
|
37
37
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
38
38
|
} & {
|
|
@@ -41,7 +41,7 @@ declare const PrismicNextLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<
|
|
|
41
41
|
href?: never;
|
|
42
42
|
}, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
|
|
43
43
|
children?: React.ReactNode | undefined;
|
|
44
|
-
} & react0.RefAttributes<HTMLAnchorElement>, "
|
|
44
|
+
} & react0.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
45
45
|
linkResolver?: LinkResolverFunction;
|
|
46
46
|
rel?: string | AsLinkAttrsConfig["rel"];
|
|
47
47
|
} & {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
|
|
2
|
+
import * as react0 from "react";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
import * as next_link0 from "next/link";
|
|
5
|
+
import Link from "next/link";
|
|
6
|
+
|
|
7
|
+
//#region src/PrismicNextLink.d.ts
|
|
8
|
+
type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
|
|
9
|
+
linkResolver?: LinkResolverFunction;
|
|
10
|
+
rel?: string | AsLinkAttrsConfig["rel"];
|
|
11
|
+
} & ({
|
|
12
|
+
field: LinkField | null | undefined;
|
|
13
|
+
document?: never;
|
|
14
|
+
href?: never;
|
|
15
|
+
} | {
|
|
16
|
+
field?: never;
|
|
17
|
+
document: PrismicDocument | null | undefined;
|
|
18
|
+
href?: never;
|
|
19
|
+
} | {
|
|
20
|
+
field?: never;
|
|
21
|
+
document?: never;
|
|
22
|
+
href: ComponentProps<typeof Link>["href"];
|
|
23
|
+
});
|
|
24
|
+
declare const PrismicNextLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
|
|
25
|
+
children?: React.ReactNode | undefined;
|
|
26
|
+
} & react0.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
27
|
+
linkResolver?: LinkResolverFunction;
|
|
28
|
+
rel?: string | AsLinkAttrsConfig["rel"];
|
|
29
|
+
} & {
|
|
30
|
+
field: LinkField | null | undefined;
|
|
31
|
+
document?: never;
|
|
32
|
+
href?: never;
|
|
33
|
+
}, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
|
|
34
|
+
children?: React.ReactNode | undefined;
|
|
35
|
+
} & react0.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
36
|
+
linkResolver?: LinkResolverFunction;
|
|
37
|
+
rel?: string | AsLinkAttrsConfig["rel"];
|
|
38
|
+
} & {
|
|
39
|
+
field?: never;
|
|
40
|
+
document: PrismicDocument | null | undefined;
|
|
41
|
+
href?: never;
|
|
42
|
+
}, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
|
|
43
|
+
children?: React.ReactNode | undefined;
|
|
44
|
+
} & react0.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
|
|
45
|
+
linkResolver?: LinkResolverFunction;
|
|
46
|
+
rel?: string | AsLinkAttrsConfig["rel"];
|
|
47
|
+
} & {
|
|
48
|
+
field?: never;
|
|
49
|
+
document?: never;
|
|
50
|
+
href: ComponentProps<typeof Link>["href"];
|
|
51
|
+
}, "ref">) & react0.RefAttributes<HTMLAnchorElement>>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { PrismicNextLink, PrismicNextLinkProps };
|
|
54
|
+
//# sourceMappingURL=PrismicNextLink.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { resolveDefaultExport } from "./lib/resolveDefaultExport.js";
|
|
2
|
+
import { asLinkAttrs } from "@prismicio/client";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import Link from "next/link";
|
|
6
|
+
|
|
7
|
+
//#region src/PrismicNextLink.tsx
|
|
8
|
+
const PrismicNextLink = forwardRef(function PrismicNextLink$1(props, ref) {
|
|
9
|
+
const { field, document, linkResolver, children, ...restProps } = props;
|
|
10
|
+
const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs(field ?? document, {
|
|
11
|
+
linkResolver,
|
|
12
|
+
rel: typeof restProps.rel === "function" ? restProps.rel : void 0
|
|
13
|
+
});
|
|
14
|
+
const href = ("href" in restProps ? restProps.href : computedHref) || "";
|
|
15
|
+
let rel = computedRel;
|
|
16
|
+
if ("rel" in restProps && typeof restProps.rel !== "function") rel = restProps.rel;
|
|
17
|
+
return /* @__PURE__ */ jsx(resolveDefaultExport(Link), {
|
|
18
|
+
ref,
|
|
19
|
+
...attrs,
|
|
20
|
+
...restProps,
|
|
21
|
+
href,
|
|
22
|
+
rel,
|
|
23
|
+
children: "children" in props ? children : field?.text
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { PrismicNextLink };
|
|
29
|
+
//# sourceMappingURL=PrismicNextLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicNextLink.js","names":["PrismicNextLink"],"sources":["../src/PrismicNextLink.tsx"],"sourcesContent":["import type { ComponentProps} from \"react\";\nimport { forwardRef } from \"react\";\nimport Link from \"next/link\";\nimport type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument} from \"@prismicio/client\";\nimport {\n\tasLinkAttrs,\n} from \"@prismicio/client\";\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\n\nexport type PrismicNextLinkProps = Omit<\n\tComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: LinkResolverFunction;\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument?: never;\n\t\t\t\thref: ComponentProps<typeof Link>[\"href\"];\n\t\t }\n\t);\n\nexport const PrismicNextLink = forwardRef<\n\tHTMLAnchorElement,\n\tPrismicNextLinkProps\n>(function PrismicNextLink(props, ref) {\n\tconst { field, document, linkResolver, children, ...restProps } = props;\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? document, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tlet rel = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst ResolvedLink = resolveDefaultExport(Link);\n\n\treturn (\n\t\t<ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t{\"children\" in props ? children : field?.text}\n\t\t</ResolvedLink>\n\t);\n});\n"],"mappings":";;;;;;;AAsCA,MAAa,kBAAkB,WAG7B,SAASA,kBAAgB,OAAO,KAAK;CACtC,MAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;CAClE,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACA,YAAY,SAAS,UAAU;EAClC;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;EAC3D,CAAC;CAEF,MAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;CAEtE,IAAI,MAAM;AACV,KAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,WAClD,OAAM,UAAU;AAKjB,QACC,oBAHoB,qBAAqB,KAAK;EAG3B;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;YACjE,cAAc,QAAQ,WAAW,OAAO;GAC3B;EAEf"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/PrismicPreview.d.ts
|
|
4
|
+
/** Props for `<PrismicPreview>`. */
|
|
5
|
+
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
|
+
/**
|
|
12
|
+
* The URL of your app's Prismic preview endpoint (default: `/api/preview`).
|
|
13
|
+
* This URL will be fetched on preview update events.
|
|
14
|
+
*/
|
|
15
|
+
updatePreviewURL?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
|
|
18
|
+
* This URL will be fetched on preview exit events.
|
|
19
|
+
*/
|
|
20
|
+
exitPreviewURL?: string;
|
|
21
|
+
/** Children to render adjacent to the Prismic Toolbar. */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
26
|
+
* the Prismic Toolbar send events to the browser, such as on preview updates
|
|
27
|
+
* and exiting, this component will automatically refresh the page with the
|
|
28
|
+
* changes.
|
|
29
|
+
*
|
|
30
|
+
* This component can be wrapped around your app or added anywhere in your app's
|
|
31
|
+
* tree. It must be rendered on every page.
|
|
32
|
+
*/
|
|
33
|
+
declare const PrismicPreview: FC<PrismicPreviewProps>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { PrismicPreview, PrismicPreviewProps };
|
|
36
|
+
//# sourceMappingURL=PrismicPreview.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { resolveDefaultExport } from "./lib/resolveDefaultExport.js";
|
|
2
|
+
import { PrismicPreviewClient } from "./PrismicPreviewClient.js";
|
|
3
|
+
import Script from "next/script";
|
|
4
|
+
import { getToolbarSrc } from "@prismicio/client";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/PrismicPreview.tsx
|
|
8
|
+
/**
|
|
9
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
10
|
+
* the Prismic Toolbar send events to the browser, such as on preview updates
|
|
11
|
+
* and exiting, this component will automatically refresh the page with the
|
|
12
|
+
* changes.
|
|
13
|
+
*
|
|
14
|
+
* This component can be wrapped around your app or added anywhere in your app's
|
|
15
|
+
* tree. It must be rendered on every page.
|
|
16
|
+
*/
|
|
17
|
+
const PrismicPreview = async (props) => {
|
|
18
|
+
const { repositoryName, children, ...otherProps } = props;
|
|
19
|
+
const { draftMode } = await import("next/headers");
|
|
20
|
+
const toolbarSrc = getToolbarSrc(repositoryName);
|
|
21
|
+
const isDraftMode = (await draftMode()).isEnabled;
|
|
22
|
+
const ResolvedScript = resolveDefaultExport(Script);
|
|
23
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24
|
+
children,
|
|
25
|
+
/* @__PURE__ */ jsx(PrismicPreviewClient, {
|
|
26
|
+
repositoryName,
|
|
27
|
+
isDraftMode,
|
|
28
|
+
...otherProps
|
|
29
|
+
}),
|
|
30
|
+
/* @__PURE__ */ jsx(ResolvedScript, {
|
|
31
|
+
src: toolbarSrc,
|
|
32
|
+
strategy: "lazyOnload"
|
|
33
|
+
})
|
|
34
|
+
] });
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { PrismicPreview };
|
|
39
|
+
//# sourceMappingURL=PrismicPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreview.js","names":[],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import type { FC, ReactNode } from \"react\";\nimport Script from \"next/script\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\nimport { PrismicPreviewClient } from \"./PrismicPreviewClient\";\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> = async (props) => {\n\tconst { repositoryName, children, ...otherProps } = props;\n\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { draftMode } = await import(\"next/headers\");\n\n\tconst toolbarSrc = getToolbarSrc(repositoryName);\n\tconst isDraftMode = (await draftMode()).isEnabled;\n\n\tconst ResolvedScript = resolveDefaultExport(Script);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<PrismicPreviewClient\n\t\t\t\trepositoryName={repositoryName}\n\t\t\t\tisDraftMode={isDraftMode}\n\t\t\t\t{...otherProps}\n\t\t\t/>\n\t\t\t<ResolvedScript src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAwCA,MAAa,iBAA0C,OAAO,UAAU;CACvE,MAAM,EAAE,gBAAgB,UAAU,GAAG,eAAe;CAKpD,MAAM,EAAE,cAAc,MAAM,OAAO;CAEnC,MAAM,aAAa,cAAc,eAAe;CAChD,MAAM,eAAe,MAAM,WAAW,EAAE;CAExC,MAAM,iBAAiB,qBAAqB,OAAO;AAEnD,QACC;EACE;EACD,oBAAC;GACgB;GACH;GACb,GAAI;IACH;EACF,oBAAC;GAAe,KAAK;GAAY,UAAS;IAAe;KACvD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cookie } from "@prismicio/client";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
|
|
7
|
+
//#region src/PrismicPreviewClient.tsx
|
|
8
|
+
const PrismicPreviewClient = (props) => {
|
|
9
|
+
const { repositoryName, isDraftMode, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview" } = props;
|
|
10
|
+
const { refresh } = useRouter();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
window.addEventListener("prismicPreviewUpdate", onUpdate, { signal: controller.signal });
|
|
14
|
+
window.addEventListener("prismicPreviewEnd", onEnd, { signal: controller.signal });
|
|
15
|
+
const cookie$1 = getPrismicPreviewCookie(window.document.cookie);
|
|
16
|
+
if ((cookie$1 ? (decodeURIComponent(cookie$1).match(/"([^"]+)\.prismic\.io"/) || [])[1] : void 0) === repositoryName && !isDraftMode) globalThis.fetch(updatePreviewURL, {
|
|
17
|
+
redirect: "manual",
|
|
18
|
+
signal: controller.signal
|
|
19
|
+
}).then((res) => {
|
|
20
|
+
if (res.type !== "opaqueredirect") {
|
|
21
|
+
console.error(`[<PrismicPreview>] Failed to start the preview using "${updatePreviewURL}". Does it exist?`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
refresh();
|
|
25
|
+
}).catch(() => {});
|
|
26
|
+
function onUpdate(event) {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
refresh();
|
|
29
|
+
}
|
|
30
|
+
function onEnd(event) {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
globalThis.fetch(exitPreviewURL, { signal: controller.signal }).then((res) => {
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
console.error(`[<PrismicPreview>] Failed to exit Preview Mode using the "${exitPreviewURL}" API endpoint. Does it exist?`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
refresh();
|
|
38
|
+
}).catch(() => {});
|
|
39
|
+
}
|
|
40
|
+
return () => controller.abort();
|
|
41
|
+
}, [
|
|
42
|
+
repositoryName,
|
|
43
|
+
isDraftMode,
|
|
44
|
+
updatePreviewURL,
|
|
45
|
+
exitPreviewURL,
|
|
46
|
+
refresh
|
|
47
|
+
]);
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Returns the value of a cookie from a given cookie store.
|
|
52
|
+
*
|
|
53
|
+
* @param cookieJar - The stringified cookie store from which to read the
|
|
54
|
+
* cookie.
|
|
55
|
+
*
|
|
56
|
+
* @returns The value of the cookie, if it exists.
|
|
57
|
+
*/
|
|
58
|
+
function getPrismicPreviewCookie(cookieJar) {
|
|
59
|
+
function readValue(value$1) {
|
|
60
|
+
return value$1.replace(/%3B/g, ";");
|
|
61
|
+
}
|
|
62
|
+
const cookies = cookieJar.split("; ");
|
|
63
|
+
let value;
|
|
64
|
+
for (const cookie$1 of cookies) {
|
|
65
|
+
const parts = cookie$1.split("=");
|
|
66
|
+
if (readValue(parts[0]).replace(/%3D/g, "=") === cookie.preview) {
|
|
67
|
+
value = readValue(parts.slice(1).join("="));
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { PrismicPreviewClient };
|
|
76
|
+
//# sourceMappingURL=PrismicPreviewClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreviewClient.js","names":["cookie","value","prismicCookie"],"sources":["../src/PrismicPreviewClient.tsx"],"sourcesContent":["\"use client\";\n\nimport { cookie as prismicCookie } from \"@prismicio/client\";\nimport { useRouter } from \"next/navigation\";\nimport type { FC } from \"react\";\nimport { useEffect } from \"react\";\n\ntype PrismicPreviewClientProps = {\n\trepositoryName: string;\n\tisDraftMode: boolean;\n\tupdatePreviewURL?: string;\n\texitPreviewURL?: string;\n};\n\nexport const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {\n\tconst {\n\t\trepositoryName,\n\t\tisDraftMode,\n\t\tupdatePreviewURL = \"/api/preview\",\n\t\texitPreviewURL = \"/api/exit-preview\",\n\t} = props;\n\n\tconst { refresh } = useRouter();\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\tconst cookie = getPrismicPreviewCookie(window.document.cookie);\n\t\tconst cookieRepositoryName = cookie\n\t\t\t? (decodeURIComponent(cookie).match(/\"([^\"]+)\\.prismic\\.io\"/) || [])[1]\n\t\t\t: undefined;\n\t\tconst hasCookieForRepository = cookieRepositoryName === repositoryName;\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\tif (hasCookieForRepository && !isDraftMode) {\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 draft mode\n\t\t\t// is active.\n\t\t\tglobalThis\n\t\t\t\t.fetch(updatePreviewURL, {\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: controller.signal,\n\t\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 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\t\t\t// noop\n\t\t\t\t});\n\t\t}\n\n\t\tfunction onUpdate(event: Event) {\n\t\t\tevent.preventDefault();\n\t\t\trefresh();\n\t\t}\n\n\t\tfunction onEnd(event: Event) {\n\t\t\tevent.preventDefault();\n\t\t\tglobalThis\n\t\t\t\t.fetch(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\t\t\t// noop\n\t\t\t\t});\n\t\t}\n\n\t\treturn () => controller.abort();\n\t}, [repositoryName, isDraftMode, updatePreviewURL, exitPreviewURL, refresh]);\n\n\treturn null;\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 */\nfunction getPrismicPreviewCookie(cookieJar: string): string | undefined {\n\tfunction readValue(value: string): string {\n\t\treturn value.replace(/%3B/g, \";\");\n\t}\n\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 === prismicCookie.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"],"mappings":";;;;;;;AAcA,MAAa,wBAAuD,UAAU;CAC7E,MAAM,EACL,gBACA,aACA,mBAAmB,gBACnB,iBAAiB,wBACd;CAEJ,MAAM,EAAE,YAAY,WAAW;AAE/B,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;EAEF,MAAMA,WAAS,wBAAwB,OAAO,SAAS,OAAO;AAS9D,OAR6BA,YACzB,mBAAmBA,SAAO,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE,KACnE,YACqD,kBAK1B,CAAC,YAK9B,YACE,MAAM,kBAAkB;GACxB,UAAU;GACV,QAAQ,WAAW;GACnB,CAAC,CACD,MAAM,QAAQ;AACd,OAAI,IAAI,SAAS,kBAAkB;AAClC,YAAQ,MACP,yDAAyD,iBAAiB,mBAC1E;AAED;;AAGD,YAAS;IACR,CACD,YAAY,GAEX;EAGJ,SAAS,SAAS,OAAc;AAC/B,SAAM,gBAAgB;AACtB,YAAS;;EAGV,SAAS,MAAM,OAAc;AAC5B,SAAM,gBAAgB;AACtB,cACE,MAAM,gBAAgB,EAAE,QAAQ,WAAW,QAAQ,CAAC,CACpD,MAAM,QAAQ;AACd,QAAI,CAAC,IAAI,IAAI;AACZ,aAAQ,MACP,6DAA6D,eAAe,gCAC5E;AAED;;AAGD,aAAS;KACR,CACD,YAAY,GAEX;;AAGJ,eAAa,WAAW,OAAO;IAC7B;EAAC;EAAgB;EAAa;EAAkB;EAAgB;EAAQ,CAAC;AAE5E,QAAO;;;;;;;;;;AAWR,SAAS,wBAAwB,WAAuC;CACvE,SAAS,UAAU,SAAuB;AACzC,SAAOC,QAAM,QAAQ,QAAQ,IAAI;;CAGlC,MAAM,UAAU,UAAU,MAAM,KAAK;CAErC,IAAI;AAEJ,MAAK,MAAMD,YAAU,SAAS;EAC7B,MAAM,QAAQA,SAAO,MAAM,IAAI;AAG/B,MAFa,UAAU,MAAM,GAAG,CAAC,QAAQ,QAAQ,IAAI,KAExCE,OAAc,SAAS;AACnC,WAAQ,UAAU,MAAM,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;AAC3C;;;AAIF,QAAO"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { SliceSimulatorProps } from "@prismicio/simulator/kit";
|
|
3
|
+
|
|
4
|
+
//#region src/SliceSimulator.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parameters provided to the Slice Simulator page.
|
|
8
|
+
*/
|
|
9
|
+
type SliceSimulatorParams = {
|
|
10
|
+
searchParams: Promise<{
|
|
11
|
+
state?: string;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
type SliceSimulatorProps$1 = SliceSimulatorProps & {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Simulate slices in isolation. The slice simulator enables live slice
|
|
20
|
+
* development in Slice Machine and live previews in the Page Builder.
|
|
21
|
+
*/
|
|
22
|
+
declare const SliceSimulator: FC<SliceSimulatorProps$1>;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { SliceSimulator, SliceSimulatorParams, SliceSimulatorProps$1 as SliceSimulatorProps };
|
|
25
|
+
//# sourceMappingURL=SliceSimulator.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { SliceSimulatorWrapper } from "./SliceSimulatorWrapper.js";
|
|
4
|
+
import { getSlices } from "./getSlices.js";
|
|
5
|
+
import { useRouter } from "next/navigation";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { SimulatorManager, StateEventType, getDefaultMessage } from "@prismicio/simulator/kit";
|
|
9
|
+
import { compressToEncodedURIComponent } from "lz-string";
|
|
10
|
+
|
|
11
|
+
//#region src/SliceSimulator.tsx
|
|
12
|
+
const STATE_PARAMS_KEY = "state";
|
|
13
|
+
const simulatorManager = new SimulatorManager();
|
|
14
|
+
/**
|
|
15
|
+
* Simulate slices in isolation. The slice simulator enables live slice
|
|
16
|
+
* development in Slice Machine and live previews in the Page Builder.
|
|
17
|
+
*/
|
|
18
|
+
const SliceSimulator = ({ children, background, zIndex, className }) => {
|
|
19
|
+
const [message, setMessage] = useState(() => getDefaultMessage());
|
|
20
|
+
const router = useRouter();
|
|
21
|
+
const hasSlices = getSlices(typeof window !== "undefined" ? new URL(window.location.href).searchParams.get(STATE_PARAMS_KEY) : void 0).length > 0;
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
simulatorManager.state.on(StateEventType.Slices, (newSlices) => {
|
|
24
|
+
const url = new URL(window.location.href);
|
|
25
|
+
url.searchParams.set(STATE_PARAMS_KEY, compressToEncodedURIComponent(JSON.stringify(newSlices)));
|
|
26
|
+
window.history.replaceState(null, "", url);
|
|
27
|
+
setTimeout(() => router.refresh(), 0);
|
|
28
|
+
}, "simulator-slices");
|
|
29
|
+
simulatorManager.state.on(StateEventType.Message, (newMessage) => setMessage(newMessage), "simulator-message");
|
|
30
|
+
simulatorManager.init();
|
|
31
|
+
return () => {
|
|
32
|
+
simulatorManager.state.off(StateEventType.Slices, "simulator-slices");
|
|
33
|
+
simulatorManager.state.off(StateEventType.Message, "simulator-message");
|
|
34
|
+
};
|
|
35
|
+
}, [router]);
|
|
36
|
+
return /* @__PURE__ */ jsx(SliceSimulatorWrapper, {
|
|
37
|
+
message,
|
|
38
|
+
hasSlices,
|
|
39
|
+
background,
|
|
40
|
+
zIndex,
|
|
41
|
+
className,
|
|
42
|
+
children
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { SliceSimulator };
|
|
48
|
+
//# sourceMappingURL=SliceSimulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../src/SliceSimulator.tsx"],"sourcesContent":["\"use client\";\n\nimport { SliceSimulatorWrapper } from \"./SliceSimulatorWrapper\";\nimport { getSlices } from \"./getSlices\";\nimport {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n} from \"@prismicio/simulator/kit\";\nimport type { SliceSimulatorProps as BaseSliceSimulatorProps } from \"@prismicio/simulator/kit\";\nimport { compressToEncodedURIComponent } from \"lz-string\";\nimport { useRouter } from \"next/navigation\";\nimport { useEffect, useState } from \"react\";\nimport type { FC, ReactNode } from \"react\";\n\nconst STATE_PARAMS_KEY = \"state\";\n\nconst simulatorManager = new SimulatorManager();\n\n/**\n * Parameters provided to the Slice Simulator page.\n */\nexport type SliceSimulatorParams = {\n\tsearchParams: Promise<{\n\t\tstate?: string;\n\t}>;\n};\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\tchildren: ReactNode;\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\tchildren,\n\tbackground,\n\tzIndex,\n\tclassName,\n}) => {\n\tconst [message, setMessage] = useState(() => getDefaultMessage());\n\tconst router = useRouter();\n\n\tconst state =\n\t\ttypeof window !== \"undefined\"\n\t\t\t? new URL(window.location.href).searchParams.get(STATE_PARAMS_KEY)\n\t\t\t: undefined;\n\tconst hasSlices = getSlices(state).length > 0;\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(newSlices) => {\n\t\t\t\tconst url = new URL(window.location.href);\n\t\t\t\turl.searchParams.set(\n\t\t\t\t\tSTATE_PARAMS_KEY,\n\t\t\t\t\tcompressToEncodedURIComponent(JSON.stringify(newSlices)),\n\t\t\t\t);\n\n\t\t\t\twindow.history.replaceState(null, \"\", url);\n\t\t\t\t// Wait until the next tick to prevent URL state race conditions.\n\t\t\t\tsetTimeout(() => router.refresh(), 0);\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(newMessage) => setMessage(newMessage),\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}, [router]);\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={hasSlices}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t{children}\n\t\t</SliceSimulatorWrapper>\n\t);\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB,IAAI,kBAAkB;;;;;AAoB/C,MAAa,kBAA2C,EACvD,UACA,YACA,QACA,gBACK;CACL,MAAM,CAAC,SAAS,cAAc,eAAe,mBAAmB,CAAC;CACjE,MAAM,SAAS,WAAW;CAM1B,MAAM,YAAY,UAHjB,OAAO,WAAW,cACf,IAAI,IAAI,OAAO,SAAS,KAAK,CAAC,aAAa,IAAI,iBAAiB,GAChE,OAC8B,CAAC,SAAS;AAE5C,iBAAgB;AACf,mBAAiB,MAAM,GACtB,eAAe,SACd,cAAc;GACd,MAAM,MAAM,IAAI,IAAI,OAAO,SAAS,KAAK;AACzC,OAAI,aAAa,IAChB,kBACA,8BAA8B,KAAK,UAAU,UAAU,CAAC,CACxD;AAED,UAAO,QAAQ,aAAa,MAAM,IAAI,IAAI;AAE1C,oBAAiB,OAAO,SAAS,EAAE,EAAE;KAEtC,mBACA;AACD,mBAAiB,MAAM,GACtB,eAAe,UACd,eAAe,WAAW,WAAW,EACtC,oBACA;AAED,mBAAiB,MAAM;AAEvB,eAAa;AACZ,oBAAiB,MAAM,IAAI,eAAe,QAAQ,mBAAmB;AAErE,oBAAiB,MAAM,IAAI,eAAe,SAAS,oBAAoB;;IAEtE,CAAC,OAAO,CAAC;AAEZ,QACC,oBAAC;EACS;EACE;EACC;EACJ;EACG;EAEV;GACsB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { disableEventHandler, getDefaultProps, onClickHandler, simulatorClass, simulatorRootClass } from "@prismicio/simulator/kit";
|
|
3
|
+
|
|
4
|
+
//#region src/SliceSimulatorWrapper.tsx
|
|
5
|
+
/**
|
|
6
|
+
* A wrapper for the slice simulator that isolates the given children from the
|
|
7
|
+
* page's layout.
|
|
8
|
+
*/
|
|
9
|
+
const SliceSimulatorWrapper = ({ className, children, zIndex, background, message, hasSlices }) => {
|
|
10
|
+
const defaultProps = getDefaultProps();
|
|
11
|
+
return /* @__PURE__ */ jsx("div", {
|
|
12
|
+
className: [simulatorClass, className].filter(Boolean).join(" "),
|
|
13
|
+
style: {
|
|
14
|
+
zIndex: typeof zIndex === "undefined" ? defaultProps.zIndex : zIndex ?? void 0,
|
|
15
|
+
position: "fixed",
|
|
16
|
+
top: 0,
|
|
17
|
+
left: 0,
|
|
18
|
+
width: "100%",
|
|
19
|
+
height: "100vh",
|
|
20
|
+
overflow: "auto",
|
|
21
|
+
background: typeof background === "undefined" ? defaultProps.background : background ?? void 0
|
|
22
|
+
},
|
|
23
|
+
children: message ? /* @__PURE__ */ jsx("article", { dangerouslySetInnerHTML: { __html: message } }) : hasSlices ? /* @__PURE__ */ jsx("div", {
|
|
24
|
+
id: "root",
|
|
25
|
+
className: simulatorRootClass,
|
|
26
|
+
onClickCapture: onClickHandler,
|
|
27
|
+
onSubmitCapture: disableEventHandler,
|
|
28
|
+
children
|
|
29
|
+
}) : null
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { SliceSimulatorWrapper };
|
|
35
|
+
//# sourceMappingURL=SliceSimulatorWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulatorWrapper.js","names":[],"sources":["../src/SliceSimulatorWrapper.tsx"],"sourcesContent":["import {\n\tdisableEventHandler,\n\tgetDefaultProps,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/simulator/kit\";\nimport type { SliceSimulatorProps } from \"@prismicio/simulator/kit\";\nimport type { FC, ReactNode } from \"react\";\n\ntype SliceSimulatorWrapperProps = SliceSimulatorProps & {\n\tchildren: ReactNode;\n\tclassName?: string;\n\tmessage?: string;\n\thasSlices: boolean;\n};\n\n/**\n * A wrapper for the slice simulator that isolates the given children from the\n * page's layout.\n */\nexport const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\n\thasSlices,\n}) => {\n\tconst defaultProps = getDefaultProps();\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[simulatorClass, className].filter(Boolean).join(\" \")}\n\t\t\tstyle={{\n\t\t\t\tzIndex:\n\t\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t\t: (zIndex ?? undefined),\n\t\t\t\tposition: \"fixed\",\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100vh\",\n\t\t\t\toverflow: \"auto\",\n\t\t\t\tbackground:\n\t\t\t\t\ttypeof background === \"undefined\"\n\t\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t\t: (background ?? undefined),\n\t\t\t}}\n\t\t>\n\t\t\t{message ? (\n\t\t\t\t<article dangerouslySetInnerHTML={{ __html: message }} />\n\t\t\t) : hasSlices ? (\n\t\t\t\t<div\n\t\t\t\t\tid=\"root\"\n\t\t\t\t\tclassName={simulatorRootClass}\n\t\t\t\t\tonClickCapture={onClickHandler as unknown as React.MouseEventHandler}\n\t\t\t\t\tonSubmitCapture={\n\t\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t);\n};\n"],"mappings":";;;;;;;;AAqBA,MAAa,yBAAyD,EACrE,WACA,UACA,QACA,YACA,SACA,gBACK;CACL,MAAM,eAAe,iBAAiB;AAEtC,QACC,oBAAC;EACA,WAAW,CAAC,gBAAgB,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;EAChE,OAAO;GACN,QACC,OAAO,WAAW,cACf,aAAa,SACZ,UAAU;GACf,UAAU;GACV,KAAK;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,UAAU;GACV,YACC,OAAO,eAAe,cACnB,aAAa,aACZ,cAAc;GACnB;YAEA,UACA,oBAAC,aAAQ,yBAAyB,EAAE,QAAQ,SAAS,GAAI,GACtD,YACH,oBAAC;GACA,IAAG;GACH,WAAW;GACX,gBAAgB;GAChB,iBACC;GAGA;IACI,GACH;GACC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/createLocaleRedirect.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated `createLocaleRedirect()` has been removed due to performance
|
|
4
|
+
* issues.
|
|
5
|
+
*/
|
|
6
|
+
declare function createLocaleRedirect(): never;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated `createLocaleRedirect()` has been removed due to performance
|
|
9
|
+
* issues.
|
|
10
|
+
*/
|
|
11
|
+
type CreateLocaleRedirectConfig = never;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CreateLocaleRedirectConfig, createLocaleRedirect };
|
|
14
|
+
//# sourceMappingURL=createLocaleRedirect.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { devMsg } from "./lib/devMsg.js";
|
|
2
|
+
|
|
3
|
+
//#region src/createLocaleRedirect.ts
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated `createLocaleRedirect()` has been removed due to performance
|
|
6
|
+
* issues.
|
|
7
|
+
*/
|
|
8
|
+
function createLocaleRedirect() {
|
|
9
|
+
throw new Error(`createLocaleRedirect() has been removed due to performance issues. See ${devMsg("replace-createLocaleRedirect")} for more details.`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createLocaleRedirect };
|
|
14
|
+
//# sourceMappingURL=createLocaleRedirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLocaleRedirect.js","names":[],"sources":["../src/createLocaleRedirect.ts"],"sourcesContent":["import { devMsg } from \"./lib/devMsg\";\n\n/**\n * @deprecated `createLocaleRedirect()` has been removed due to performance\n * issues.\n */\nexport function createLocaleRedirect(): never {\n\tthrow new Error(\n\t\t`createLocaleRedirect() has been removed due to performance issues. See ${devMsg(\n\t\t\t\"replace-createLocaleRedirect\",\n\t\t)} for more details.`,\n\t);\n}\n/**\n * @deprecated `createLocaleRedirect()` has been removed due to performance\n * issues.\n */\nexport type CreateLocaleRedirectConfig = never;\n"],"mappings":";;;;;;;AAMA,SAAgB,uBAA8B;AAC7C,OAAM,IAAI,MACT,0EAA0E,OACzE,+BACA,CAAC,oBACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Client } from "@prismicio/client";
|
|
2
|
+
|
|
3
|
+
//#region src/enableAutoPreviews.d.ts
|
|
4
|
+
/** Configuration for `enableAutoPreviews`. */
|
|
5
|
+
type EnableAutoPreviewsConfig = {
|
|
6
|
+
/** Prismic client with which automatic previews will be enabled. */
|
|
7
|
+
client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Configures a Prismic client to automatically query draft content during a
|
|
11
|
+
* preview session.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Configuration for the function.
|
|
14
|
+
*/
|
|
15
|
+
declare function enableAutoPreviews(config: EnableAutoPreviewsConfig): void;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { EnableAutoPreviewsConfig, enableAutoPreviews };
|
|
18
|
+
//# sourceMappingURL=enableAutoPreviews.d.ts.map
|