@prismicio/next 2.2.0-canary.070be83 → 2.2.0-canary.9ac189f

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.
Files changed (98) hide show
  1. package/dist/{PrismicNextImage.d.cts → PrismicNextImage.d.ts} +2 -2
  2. package/dist/{PrismicNextImage.cjs → PrismicNextImage.js} +16 -18
  3. package/dist/PrismicNextImage.js.map +1 -0
  4. package/dist/{PrismicNextLink.d.cts → PrismicNextLink.d.ts} +2 -2
  5. package/dist/PrismicNextLink.js +29 -0
  6. package/dist/PrismicNextLink.js.map +1 -0
  7. package/dist/{PrismicPreview.d.cts → PrismicPreview.d.ts} +1 -1
  8. package/dist/PrismicPreview.js +39 -0
  9. package/dist/PrismicPreview.js.map +1 -0
  10. package/dist/{PrismicPreviewClient.cjs → PrismicPreviewClient.js} +12 -13
  11. package/dist/PrismicPreviewClient.js.map +1 -0
  12. package/dist/{SliceSimulator.d.cts → SliceSimulator.d.ts} +1 -1
  13. package/dist/SliceSimulator.js +48 -0
  14. package/dist/SliceSimulator.js.map +1 -0
  15. package/dist/SliceSimulatorWrapper.js +35 -0
  16. package/dist/SliceSimulatorWrapper.js.map +1 -0
  17. package/dist/{createLocaleRedirect.d.cts → createLocaleRedirect.d.ts} +1 -1
  18. package/dist/createLocaleRedirect.js +14 -0
  19. package/dist/createLocaleRedirect.js.map +1 -0
  20. package/dist/{enableAutoPreviews.d.cts → enableAutoPreviews.d.ts} +1 -1
  21. package/dist/{enableAutoPreviews.cjs → enableAutoPreviews.js} +7 -8
  22. package/dist/enableAutoPreviews.js.map +1 -0
  23. package/dist/{exitPreview.d.cts → exitPreview.d.ts} +1 -1
  24. package/dist/{exitPreview.cjs → exitPreview.js} +2 -3
  25. package/dist/exitPreview.js.map +1 -0
  26. package/dist/{getSlices.d.cts → getSlices.d.ts} +1 -1
  27. package/dist/getSlices.js +11 -0
  28. package/dist/getSlices.js.map +1 -0
  29. package/dist/{imgixLoader.d.cts → imgixLoader.d.ts} +1 -1
  30. package/dist/{imgixLoader.cjs → imgixLoader.js} +4 -5
  31. package/dist/imgixLoader.js.map +1 -0
  32. package/dist/{index.d.cts → index.d.ts} +11 -11
  33. package/dist/index.js +12 -0
  34. package/dist/lib/{devMsg.cjs → devMsg.js} +4 -4
  35. package/dist/lib/devMsg.js.map +1 -0
  36. package/dist/lib/{resolveDefaultExport.cjs → resolveDefaultExport.js} +2 -3
  37. package/dist/lib/resolveDefaultExport.js.map +1 -0
  38. package/dist/package.js +6 -0
  39. package/dist/package.js.map +1 -0
  40. package/dist/pages/{PrismicPreview.d.cts → PrismicPreview.d.ts} +1 -1
  41. package/dist/pages/{PrismicPreview.cjs → PrismicPreview.js} +13 -15
  42. package/dist/pages/PrismicPreview.js.map +1 -0
  43. package/dist/pages/{SliceSimulator.d.cts → SliceSimulator.d.ts} +1 -1
  44. package/dist/pages/SliceSimulator.js +40 -0
  45. package/dist/pages/SliceSimulator.js.map +1 -0
  46. package/dist/pages/{enableAutoPreviews.d.cts → enableAutoPreviews.d.ts} +2 -2
  47. package/dist/pages/{enableAutoPreviews.cjs → enableAutoPreviews.js} +2 -3
  48. package/dist/pages/enableAutoPreviews.js.map +1 -0
  49. package/dist/pages/{exitPreview.d.cts → exitPreview.d.ts} +2 -2
  50. package/dist/pages/{exitPreview.cjs → exitPreview.js} +2 -3
  51. package/dist/pages/exitPreview.js.map +1 -0
  52. package/dist/pages/{redirectToPreviewURL.d.cts → redirectToPreviewURL.d.ts} +2 -2
  53. package/dist/pages/{redirectToPreviewURL.cjs → redirectToPreviewURL.js} +2 -3
  54. package/dist/pages/redirectToPreviewURL.js.map +1 -0
  55. package/dist/pages/{setPreviewData.d.cts → setPreviewData.d.ts} +2 -2
  56. package/dist/pages/setPreviewData.js +12 -0
  57. package/dist/pages/setPreviewData.js.map +1 -0
  58. package/dist/pages/{types.d.cts → types.d.ts} +2 -2
  59. package/dist/{pages.d.cts → pages.d.ts} +11 -11
  60. package/dist/pages.js +12 -0
  61. package/dist/{redirectToPreviewURL.d.cts → redirectToPreviewURL.d.ts} +2 -2
  62. package/dist/{redirectToPreviewURL.cjs → redirectToPreviewURL.js} +6 -7
  63. package/dist/redirectToPreviewURL.js.map +1 -0
  64. package/dist/{types.d.cts → types.d.ts} +1 -1
  65. package/package.json +4 -16
  66. package/dist/PrismicNextImage.cjs.map +0 -1
  67. package/dist/PrismicNextLink.cjs +0 -31
  68. package/dist/PrismicNextLink.cjs.map +0 -1
  69. package/dist/PrismicPreview.cjs +0 -41
  70. package/dist/PrismicPreview.cjs.map +0 -1
  71. package/dist/PrismicPreviewClient.cjs.map +0 -1
  72. package/dist/SliceSimulator.cjs +0 -49
  73. package/dist/SliceSimulator.cjs.map +0 -1
  74. package/dist/SliceSimulatorWrapper.cjs +0 -36
  75. package/dist/SliceSimulatorWrapper.cjs.map +0 -1
  76. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  77. package/dist/createLocaleRedirect.cjs +0 -14
  78. package/dist/createLocaleRedirect.cjs.map +0 -1
  79. package/dist/enableAutoPreviews.cjs.map +0 -1
  80. package/dist/exitPreview.cjs.map +0 -1
  81. package/dist/getSlices.cjs +0 -12
  82. package/dist/getSlices.cjs.map +0 -1
  83. package/dist/imgixLoader.cjs.map +0 -1
  84. package/dist/index.cjs +0 -21
  85. package/dist/lib/devMsg.cjs.map +0 -1
  86. package/dist/lib/resolveDefaultExport.cjs.map +0 -1
  87. package/dist/package.cjs +0 -12
  88. package/dist/package.cjs.map +0 -1
  89. package/dist/pages/PrismicPreview.cjs.map +0 -1
  90. package/dist/pages/SliceSimulator.cjs +0 -41
  91. package/dist/pages/SliceSimulator.cjs.map +0 -1
  92. package/dist/pages/enableAutoPreviews.cjs.map +0 -1
  93. package/dist/pages/exitPreview.cjs.map +0 -1
  94. package/dist/pages/redirectToPreviewURL.cjs.map +0 -1
  95. package/dist/pages/setPreviewData.cjs +0 -13
  96. package/dist/pages/setPreviewData.cjs.map +0 -1
  97. package/dist/pages.cjs +0 -21
  98. package/dist/redirectToPreviewURL.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
2
1
  import { ImageFieldImage } from "@prismicio/client";
2
+ import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
3
3
  import { ImageProps } from "next/image";
4
4
  import { ImgixURLParams } from "imgix-url-builder";
5
5
 
@@ -54,4 +54,4 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
54
54
  declare const PrismicNextImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>>;
55
55
  //#endregion
56
56
  export { PrismicNextImage, PrismicNextImageProps };
57
- //# sourceMappingURL=PrismicNextImage.d.cts.map
57
+ //# sourceMappingURL=PrismicNextImage.d.ts.map
@@ -1,15 +1,13 @@
1
1
  "use client";
2
2
 
3
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
4
- const require_resolveDefaultExport = require('./lib/resolveDefaultExport.cjs');
5
- const require_devMsg = require('./lib/devMsg.cjs');
6
- const require_imgixLoader = require('./imgixLoader.cjs');
7
- let _prismicio_client = require("@prismicio/client");
8
- let react = require("react");
9
- let react_jsx_runtime = require("react/jsx-runtime");
10
- let next_image = require("next/image");
11
- next_image = require_rolldown_runtime.__toESM(next_image);
12
- let imgix_url_builder = require("imgix-url-builder");
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";
13
11
 
14
12
  //#region src/PrismicNextImage.tsx
15
13
  const castInt = (input) => {
@@ -36,15 +34,15 @@ const castInt = (input) => {
36
34
  *
37
35
  * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
38
36
  */
39
- const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage$1({ field, imgixParams = {}, alt, fallbackAlt, fill, width, height, fallback = null, loader = require_imgixLoader.imgixLoader, ...restProps }, ref) {
37
+ const PrismicNextImage = forwardRef(function PrismicNextImage$1({ field, imgixParams = {}, alt, fallbackAlt, fill, width, height, fallback = null, loader = imgixLoader, ...restProps }, ref) {
40
38
  if (process.env.NODE_ENV === "development") {
41
- 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 ${require_devMsg.devMsg("alt-must-be-an-empty-string")}`);
42
- 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 ${require_devMsg.devMsg("alt-must-be-an-empty-string")}`);
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")}`);
43
41
  }
44
- if (!_prismicio_client.isFilled.imageThumbnail(field)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: fallback });
42
+ if (!isFilled.imageThumbnail(field)) return /* @__PURE__ */ jsx(Fragment, { children: fallback });
45
43
  const resolvedImgixParams = imgixParams;
46
44
  for (const x in imgixParams) if (resolvedImgixParams[x] === null) resolvedImgixParams[x] = void 0;
47
- const src = (0, imgix_url_builder.buildURL)(field.url, imgixParams);
45
+ const src = buildURL(field.url, imgixParams);
48
46
  const ar = field.dimensions.width / field.dimensions.height;
49
47
  const castedWidth = castInt(width);
50
48
  const castedHeight = castInt(height);
@@ -54,7 +52,7 @@ const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage$1({ fie
54
52
  else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
55
53
  const resolvedAlt = alt ?? (field.alt || fallbackAlt);
56
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);
57
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_resolveDefaultExport.resolveDefaultExport(next_image.default), {
55
+ return /* @__PURE__ */ jsx(resolveDefaultExport(Image), {
58
56
  ref,
59
57
  src,
60
58
  width: fill ? void 0 : resolvedWidth,
@@ -67,5 +65,5 @@ const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage$1({ fie
67
65
  });
68
66
 
69
67
  //#endregion
70
- exports.PrismicNextImage = PrismicNextImage;
71
- //# sourceMappingURL=PrismicNextImage.cjs.map
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"}
@@ -1,8 +1,8 @@
1
+ import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
1
2
  import * as react0 from "react";
2
3
  import { ComponentProps } from "react";
3
4
  import * as next_link0 from "next/link";
4
5
  import Link from "next/link";
5
- import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
6
6
 
7
7
  //#region src/PrismicNextLink.d.ts
8
8
  type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
@@ -51,4 +51,4 @@ declare const PrismicNextLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<
51
51
  }, "ref">) & react0.RefAttributes<HTMLAnchorElement>>;
52
52
  //#endregion
53
53
  export { PrismicNextLink, PrismicNextLinkProps };
54
- //# sourceMappingURL=PrismicNextLink.d.cts.map
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"}
@@ -33,4 +33,4 @@ type PrismicPreviewProps = {
33
33
  declare const PrismicPreview: FC<PrismicPreviewProps>;
34
34
  //#endregion
35
35
  export { PrismicPreview, PrismicPreviewProps };
36
- //# sourceMappingURL=PrismicPreview.d.cts.map
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"}
@@ -1,20 +1,19 @@
1
1
  "use client";
2
2
 
3
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
4
- let _prismicio_client = require("@prismicio/client");
5
- let next_navigation = require("next/navigation");
6
- let react = require("react");
3
+ import { cookie } from "@prismicio/client";
4
+ import { useRouter } from "next/navigation";
5
+ import { useEffect } from "react";
7
6
 
8
7
  //#region src/PrismicPreviewClient.tsx
9
8
  const PrismicPreviewClient = (props) => {
10
9
  const { repositoryName, isDraftMode, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview" } = props;
11
- const { refresh } = (0, next_navigation.useRouter)();
12
- (0, react.useEffect)(() => {
10
+ const { refresh } = useRouter();
11
+ useEffect(() => {
13
12
  const controller = new AbortController();
14
13
  window.addEventListener("prismicPreviewUpdate", onUpdate, { signal: controller.signal });
15
14
  window.addEventListener("prismicPreviewEnd", onEnd, { signal: controller.signal });
16
- const cookie = getPrismicPreviewCookie(window.document.cookie);
17
- if ((cookie ? (decodeURIComponent(cookie).match(/"([^"]+)\.prismic\.io"/) || [])[1] : void 0) === repositoryName && !isDraftMode) globalThis.fetch(updatePreviewURL, {
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, {
18
17
  redirect: "manual",
19
18
  signal: controller.signal
20
19
  }).then((res) => {
@@ -62,9 +61,9 @@ function getPrismicPreviewCookie(cookieJar) {
62
61
  }
63
62
  const cookies = cookieJar.split("; ");
64
63
  let value;
65
- for (const cookie of cookies) {
66
- const parts = cookie.split("=");
67
- if (readValue(parts[0]).replace(/%3D/g, "=") === _prismicio_client.cookie.preview) {
64
+ for (const cookie$1 of cookies) {
65
+ const parts = cookie$1.split("=");
66
+ if (readValue(parts[0]).replace(/%3D/g, "=") === cookie.preview) {
68
67
  value = readValue(parts.slice(1).join("="));
69
68
  continue;
70
69
  }
@@ -73,5 +72,5 @@ function getPrismicPreviewCookie(cookieJar) {
73
72
  }
74
73
 
75
74
  //#endregion
76
- exports.PrismicPreviewClient = PrismicPreviewClient;
77
- //# sourceMappingURL=PrismicPreviewClient.cjs.map
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"}
@@ -22,4 +22,4 @@ type SliceSimulatorProps$1 = SliceSimulatorProps & {
22
22
  declare const SliceSimulator: FC<SliceSimulatorProps$1>;
23
23
  //#endregion
24
24
  export { SliceSimulator, SliceSimulatorParams, SliceSimulatorProps$1 as SliceSimulatorProps };
25
- //# sourceMappingURL=SliceSimulator.d.cts.map
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"}
@@ -11,4 +11,4 @@ declare function createLocaleRedirect(): never;
11
11
  type CreateLocaleRedirectConfig = never;
12
12
  //#endregion
13
13
  export { CreateLocaleRedirectConfig, createLocaleRedirect };
14
- //# sourceMappingURL=createLocaleRedirect.d.cts.map
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"}
@@ -15,4 +15,4 @@ type EnableAutoPreviewsConfig = {
15
15
  declare function enableAutoPreviews(config: EnableAutoPreviewsConfig): void;
16
16
  //#endregion
17
17
  export { EnableAutoPreviewsConfig, enableAutoPreviews };
18
- //# sourceMappingURL=enableAutoPreviews.d.cts.map
18
+ //# sourceMappingURL=enableAutoPreviews.d.ts.map
@@ -1,5 +1,4 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- let _prismicio_client = require("@prismicio/client");
1
+ import { cookie } from "@prismicio/client";
3
2
 
4
3
  //#region src/enableAutoPreviews.ts
5
4
  /**
@@ -18,13 +17,13 @@ function enableAutoPreviews(config) {
18
17
  return;
19
18
  }
20
19
  if (!isDraftModeEnabled) return;
21
- const cookie = (await cookies()).get(_prismicio_client.cookie.preview)?.value;
22
- if (!cookie) return;
23
- if (!cookie.includes("websitePreviewId=")) return;
24
- return cookie;
20
+ const cookie$1 = (await cookies()).get(cookie.preview)?.value;
21
+ if (!cookie$1) return;
22
+ if (!cookie$1.includes("websitePreviewId=")) return;
23
+ return cookie$1;
25
24
  });
26
25
  }
27
26
 
28
27
  //#endregion
29
- exports.enableAutoPreviews = enableAutoPreviews;
30
- //# sourceMappingURL=enableAutoPreviews.cjs.map
28
+ export { enableAutoPreviews };
29
+ //# sourceMappingURL=enableAutoPreviews.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enableAutoPreviews.js","names":["cookie","prismicCookie"],"sources":["../src/enableAutoPreviews.ts"],"sourcesContent":["import { type Client, cookie as prismicCookie } from \"@prismicio/client\";\n\n/** Configuration for `enableAutoPreviews`. */\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\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session.\n *\n * @param config - Configuration for the function.\n */\nexport function enableAutoPreviews(config: EnableAutoPreviewsConfig): void {\n\t// We use a function value so the cookie is checked on every\n\t// request. We don't have a static value to read from.\n\tconfig.client.queryContentFromRef(async () => {\n\t\t// Need this to avoid the following Next.js build-time error:\n\t\t// You're importing a component that needs next/headers. That only works\n\t\t// in a Server Component which is not supported in the pages/ directory.\n\t\tconst { cookies, draftMode } = await import(\"next/headers\");\n\n\t\tlet isDraftModeEnabled = false;\n\t\ttry {\n\t\t\tisDraftModeEnabled = (await draftMode()).isEnabled;\n\t\t} catch {\n\t\t\t// `draftMode()` may have been called in a palce that\n\t\t\t// does not have access to its async storage. This\n\t\t\t// occurs in places like `generateStaticParams()`. We\n\t\t\t// can ignore this case.\n\t\t\treturn;\n\t\t}\n\t\tif (!isDraftModeEnabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst cookie = (await cookies()).get(prismicCookie.preview)?.value;\n\t\tif (!cookie) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isActiveCookie = cookie.includes(\"websitePreviewId=\");\n\t\tif (!isActiveCookie) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn cookie;\n\t});\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,mBAAmB,QAAwC;AAG1E,QAAO,OAAO,oBAAoB,YAAY;EAI7C,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;EAE5C,IAAI,qBAAqB;AACzB,MAAI;AACH,yBAAsB,MAAM,WAAW,EAAE;UAClC;AAKP;;AAED,MAAI,CAAC,mBACJ;EAGD,MAAMA,YAAU,MAAM,SAAS,EAAE,IAAIC,OAAc,QAAQ,EAAE;AAC7D,MAAI,CAACD,SACJ;AAID,MAAI,CADmBA,SAAO,SAAS,oBAAoB,CAE1D;AAGD,SAAOA;GACN"}
@@ -18,4 +18,4 @@
18
18
  declare function exitPreview(): Promise<Response>;
19
19
  //#endregion
20
20
  export { exitPreview };
21
- //# sourceMappingURL=exitPreview.d.cts.map
21
+ //# sourceMappingURL=exitPreview.d.ts.map
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/exitPreview.ts
3
2
  /**
4
3
  * Ends a Prismic preview session within a Next.js app. This function should be
@@ -23,5 +22,5 @@ async function exitPreview() {
23
22
  }
24
23
 
25
24
  //#endregion
26
- exports.exitPreview = exitPreview;
27
- //# sourceMappingURL=exitPreview.cjs.map
25
+ export { exitPreview };
26
+ //# sourceMappingURL=exitPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exitPreview.js","names":[],"sources":["../src/exitPreview.ts"],"sourcesContent":["/**\n * Ends a Prismic preview session within a Next.js app. This function should be\n * used in a Router Handler.\n *\n * @example\n *\n * ```typescript\n * // src/app/api/exit-preview/route.js\n *\n * import { exitPreview } from \"@prismicio/next\";\n *\n * export async function GET() {\n * \treturn await exitPreview();\n * }\n * ```\n */\nexport async function exitPreview(): Promise<Response> {\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\t(await draftMode()).disable();\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\treturn new Response(JSON.stringify({ success: true }), {\n\t\theaders: {\n\t\t\t\"Cache-Control\": \"no-store\",\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,eAAsB,cAAiC;CAItD,MAAM,EAAE,cAAc,MAAM,OAAO;AAEnC,EAAC,MAAM,WAAW,EAAE,SAAS;AAG7B,QAAO,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,MAAM,CAAC,EAAE,EACtD,SAAS,EACR,iBAAiB,YACjB,EACD,CAAC"}
@@ -4,4 +4,4 @@ import { StateEventType, StateEvents } from "@prismicio/simulator/kit";
4
4
  declare const getSlices: (state: string | null | undefined) => StateEvents[StateEventType.Slices];
5
5
  //#endregion
6
6
  export { getSlices };
7
- //# sourceMappingURL=getSlices.d.cts.map
7
+ //# sourceMappingURL=getSlices.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { getDefaultSlices } from "@prismicio/simulator/kit";
2
+ import { decompressFromEncodedURIComponent } from "lz-string";
3
+
4
+ //#region src/getSlices.ts
5
+ const getSlices = (state) => {
6
+ return state ? JSON.parse(decompressFromEncodedURIComponent(state)) : getDefaultSlices();
7
+ };
8
+
9
+ //#endregion
10
+ export { getSlices };
11
+ //# sourceMappingURL=getSlices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSlices.js","names":[],"sources":["../src/getSlices.ts"],"sourcesContent":["import { getDefaultSlices } from \"@prismicio/simulator/kit\";\nimport type { StateEvents, StateEventType } from \"@prismicio/simulator/kit\";\nimport { decompressFromEncodedURIComponent } from \"lz-string\";\n\nexport const getSlices = (\n\tstate: string | null | undefined,\n): StateEvents[StateEventType.Slices] => {\n\treturn state\n\t\t? JSON.parse(decompressFromEncodedURIComponent(state))\n\t\t: getDefaultSlices();\n};\n"],"mappings":";;;;AAIA,MAAa,aACZ,UACwC;AACxC,QAAO,QACJ,KAAK,MAAM,kCAAkC,MAAM,CAAC,GACpD,kBAAkB"}
@@ -12,4 +12,4 @@ import { ImageLoaderProps } from "next/image";
12
12
  declare const imgixLoader: (args: ImageLoaderProps) => string;
13
13
  //#endregion
14
14
  export { imgixLoader };
15
- //# sourceMappingURL=imgixLoader.d.cts.map
15
+ //# sourceMappingURL=imgixLoader.d.ts.map
@@ -1,5 +1,4 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- let imgix_url_builder = require("imgix-url-builder");
1
+ import { buildURL } from "imgix-url-builder";
3
2
 
4
3
  //#region src/imgixLoader.ts
5
4
  /**
@@ -16,9 +15,9 @@ const imgixLoader = (args) => {
16
15
  h: void 0
17
16
  };
18
17
  if (args.quality) params.q = args.quality;
19
- return (0, imgix_url_builder.buildURL)(args.src, params);
18
+ return buildURL(args.src, params);
20
19
  };
21
20
 
22
21
  //#endregion
23
- exports.imgixLoader = imgixLoader;
24
- //# sourceMappingURL=imgixLoader.cjs.map
22
+ export { imgixLoader };
23
+ //# sourceMappingURL=imgixLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imgixLoader.js","names":[],"sources":["../src/imgixLoader.ts"],"sourcesContent":["import type { ImageLoaderProps } from \"next/image\";\nimport type { ImgixURLParams } from \"imgix-url-builder\";\nimport { buildURL } from \"imgix-url-builder\";\n\n/**\n * A `next/image` loader for Imgix, which Prismic uses, with an optional\n * collection of default Imgix parameters.\n *\n * @see To learn about `next/image` loaders: https://nextjs.org/docs/api-reference/next/image#loader\n * @see To learn about Imgix's URL API: https://docs.imgix.com/apis/rendering\n */\nexport const imgixLoader = (args: ImageLoaderProps): string => {\n\tconst url = new URL(args.src);\n\n\tconst params: ImgixURLParams = {\n\t\tfit: (url.searchParams.get(\"fit\") as ImgixURLParams[\"fit\"]) || \"max\",\n\t\tw: args.width,\n\t\th: undefined,\n\t};\n\n\tif (args.quality) {\n\t\tparams.q = args.quality;\n\t}\n\n\treturn buildURL(args.src, params);\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,eAAe,SAAmC;CAG9D,MAAM,SAAyB;EAC9B,KAHW,IAAI,IAAI,KAAK,IAAI,CAGlB,aAAa,IAAI,MAAM,IAA8B;EAC/D,GAAG,KAAK;EACR,GAAG;EACH;AAED,KAAI,KAAK,QACR,QAAO,IAAI,KAAK;AAGjB,QAAO,SAAS,KAAK,KAAK,OAAO"}
@@ -1,12 +1,12 @@
1
- import { exitPreview } from "./exitPreview.cjs";
2
- import { PrismicPreview, PrismicPreviewProps } from "./PrismicPreview.cjs";
3
- import { PrismicNextLink, PrismicNextLinkProps } from "./PrismicNextLink.cjs";
4
- import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./enableAutoPreviews.cjs";
5
- import { CreateClientConfig } from "./types.cjs";
6
- import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./redirectToPreviewURL.cjs";
7
- import { PrismicNextImage, PrismicNextImageProps } from "./PrismicNextImage.cjs";
8
- import { SliceSimulator, SliceSimulatorParams, SliceSimulatorProps } from "./SliceSimulator.cjs";
9
- import { getSlices } from "./getSlices.cjs";
10
- import { imgixLoader } from "./imgixLoader.cjs";
11
- import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.cjs";
1
+ import { exitPreview } from "./exitPreview.js";
2
+ import { PrismicPreview, PrismicPreviewProps } from "./PrismicPreview.js";
3
+ import { PrismicNextLink, PrismicNextLinkProps } from "./PrismicNextLink.js";
4
+ import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./enableAutoPreviews.js";
5
+ import { CreateClientConfig } from "./types.js";
6
+ import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./redirectToPreviewURL.js";
7
+ import { PrismicNextImage, PrismicNextImageProps } from "./PrismicNextImage.js";
8
+ import { SliceSimulator, SliceSimulatorParams, SliceSimulatorProps } from "./SliceSimulator.js";
9
+ import { getSlices } from "./getSlices.js";
10
+ import { imgixLoader } from "./imgixLoader.js";
11
+ import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.js";
12
12
  export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, PrismicNextImage, type PrismicNextImageProps, PrismicNextLink, type PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, type RedirectToPreviewURLConfig, SliceSimulator, type SliceSimulatorParams, type SliceSimulatorProps, createLocaleRedirect, enableAutoPreviews, exitPreview, getSlices, imgixLoader, redirectToPreviewURL };
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { exitPreview } from "./exitPreview.js";
2
+ import { PrismicPreview } from "./PrismicPreview.js";
3
+ import { PrismicNextLink } from "./PrismicNextLink.js";
4
+ import { enableAutoPreviews } from "./enableAutoPreviews.js";
5
+ import { redirectToPreviewURL } from "./redirectToPreviewURL.js";
6
+ import { imgixLoader } from "./imgixLoader.js";
7
+ import { PrismicNextImage } from "./PrismicNextImage.js";
8
+ import { getSlices } from "./getSlices.js";
9
+ import { SliceSimulator } from "./SliceSimulator.js";
10
+ import { createLocaleRedirect } from "./createLocaleRedirect.js";
11
+
12
+ export { PrismicNextImage, PrismicNextLink, PrismicPreview, SliceSimulator, createLocaleRedirect, enableAutoPreviews, exitPreview, getSlices, imgixLoader, redirectToPreviewURL };
@@ -1,4 +1,4 @@
1
- const require_package = require('../package.cjs');
1
+ import { version } from "../package.js";
2
2
 
3
3
  //#region src/lib/devMsg.ts
4
4
  /**
@@ -17,9 +17,9 @@ const require_package = require('../package.cjs');
17
17
  * @returns The `prismic.dev/msg` URL for the given slug.
18
18
  */
19
19
  const devMsg = (slug) => {
20
- return `https://prismic.dev/msg/next/v${require_package.version}/${slug}`;
20
+ return `https://prismic.dev/msg/next/v${version}/${slug}`;
21
21
  };
22
22
 
23
23
  //#endregion
24
- exports.devMsg = devMsg;
25
- //# sourceMappingURL=devMsg.cjs.map
24
+ export { devMsg };
25
+ //# sourceMappingURL=devMsg.js.map
@@ -0,0 +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":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,UAAU,SAAyB;AAC/C,QAAO,iCAAiC,QAAQ,GAAG"}