@prismicio/next 2.2.3-pr.136.19d76d2 → 2.2.3

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 (159) hide show
  1. package/dist/PrismicNextImage.cjs +11 -9
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.cts +21 -13
  4. package/dist/PrismicNextImage.d.ts +21 -13
  5. package/dist/PrismicNextImage.js +11 -9
  6. package/dist/PrismicNextImage.js.map +1 -1
  7. package/dist/PrismicNextLink.cjs.map +1 -1
  8. package/dist/PrismicNextLink.js.map +1 -1
  9. package/dist/PrismicPreview.cjs +7 -6
  10. package/dist/PrismicPreview.cjs.map +1 -1
  11. package/dist/PrismicPreview.d.cts +12 -11
  12. package/dist/PrismicPreview.d.ts +12 -11
  13. package/dist/PrismicPreview.js +7 -6
  14. package/dist/PrismicPreview.js.map +1 -1
  15. package/dist/PrismicPreviewClient.cjs +3 -1
  16. package/dist/PrismicPreviewClient.cjs.map +1 -1
  17. package/dist/PrismicPreviewClient.js +3 -1
  18. package/dist/PrismicPreviewClient.js.map +1 -1
  19. package/dist/SliceSimulator.cjs +3 -3
  20. package/dist/SliceSimulator.cjs.map +1 -1
  21. package/dist/SliceSimulator.d.cts +5 -3
  22. package/dist/SliceSimulator.d.ts +5 -3
  23. package/dist/SliceSimulator.js +3 -3
  24. package/dist/SliceSimulator.js.map +1 -1
  25. package/dist/SliceSimulatorWrapper.cjs +4 -1
  26. package/dist/SliceSimulatorWrapper.cjs.map +1 -1
  27. package/dist/SliceSimulatorWrapper.js +4 -1
  28. package/dist/SliceSimulatorWrapper.js.map +1 -1
  29. package/dist/createLocaleRedirect.cjs.map +1 -1
  30. package/dist/createLocaleRedirect.js.map +1 -1
  31. package/dist/enableAutoPreviews.cjs +2 -1
  32. package/dist/enableAutoPreviews.cjs.map +1 -1
  33. package/dist/enableAutoPreviews.d.cts +2 -1
  34. package/dist/enableAutoPreviews.d.ts +2 -1
  35. package/dist/enableAutoPreviews.js +2 -1
  36. package/dist/enableAutoPreviews.js.map +1 -1
  37. package/dist/exitPreview.cjs +10 -9
  38. package/dist/exitPreview.cjs.map +1 -1
  39. package/dist/exitPreview.d.cts +10 -9
  40. package/dist/exitPreview.d.ts +10 -9
  41. package/dist/exitPreview.js +10 -9
  42. package/dist/exitPreview.js.map +1 -1
  43. package/dist/getSlices.cjs.map +1 -1
  44. package/dist/getSlices.js.map +1 -1
  45. package/dist/imgixLoader.cjs +2 -2
  46. package/dist/imgixLoader.cjs.map +1 -1
  47. package/dist/imgixLoader.d.cts +2 -2
  48. package/dist/imgixLoader.d.ts +2 -2
  49. package/dist/imgixLoader.js +2 -2
  50. package/dist/imgixLoader.js.map +1 -1
  51. package/dist/lib/devMsg.cjs +8 -6
  52. package/dist/lib/devMsg.cjs.map +1 -1
  53. package/dist/lib/devMsg.js +8 -6
  54. package/dist/lib/devMsg.js.map +1 -1
  55. package/dist/lib/resolveDefaultExport.cjs +12 -8
  56. package/dist/lib/resolveDefaultExport.cjs.map +1 -1
  57. package/dist/lib/resolveDefaultExport.js +12 -8
  58. package/dist/lib/resolveDefaultExport.js.map +1 -1
  59. package/dist/package.cjs +1 -1
  60. package/dist/package.js +1 -1
  61. package/dist/pages/PrismicPreview.cjs +7 -6
  62. package/dist/pages/PrismicPreview.cjs.map +1 -1
  63. package/dist/pages/PrismicPreview.d.cts +12 -11
  64. package/dist/pages/PrismicPreview.d.ts +12 -11
  65. package/dist/pages/PrismicPreview.js +7 -6
  66. package/dist/pages/PrismicPreview.js.map +1 -1
  67. package/dist/pages/SliceSimulator.cjs +2 -2
  68. package/dist/pages/SliceSimulator.cjs.map +1 -1
  69. package/dist/pages/SliceSimulator.d.cts +13 -10
  70. package/dist/pages/SliceSimulator.d.ts +13 -10
  71. package/dist/pages/SliceSimulator.js +2 -2
  72. package/dist/pages/SliceSimulator.js.map +1 -1
  73. package/dist/pages/enableAutoPreviews.cjs +3 -3
  74. package/dist/pages/enableAutoPreviews.cjs.map +1 -1
  75. package/dist/pages/enableAutoPreviews.d.cts +5 -5
  76. package/dist/pages/enableAutoPreviews.d.ts +5 -5
  77. package/dist/pages/enableAutoPreviews.js +3 -3
  78. package/dist/pages/enableAutoPreviews.js.map +1 -1
  79. package/dist/pages/exitPreview.cjs +10 -9
  80. package/dist/pages/exitPreview.cjs.map +1 -1
  81. package/dist/pages/exitPreview.d.cts +10 -9
  82. package/dist/pages/exitPreview.d.ts +10 -9
  83. package/dist/pages/exitPreview.js +10 -9
  84. package/dist/pages/exitPreview.js.map +1 -1
  85. package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
  86. package/dist/pages/redirectToPreviewURL.d.cts +9 -7
  87. package/dist/pages/redirectToPreviewURL.d.ts +9 -7
  88. package/dist/pages/redirectToPreviewURL.js.map +1 -1
  89. package/dist/pages/setPreviewData.cjs.map +1 -1
  90. package/dist/pages/setPreviewData.js.map +1 -1
  91. package/dist/pages/types.d.cts +8 -3
  92. package/dist/pages/types.d.ts +8 -3
  93. package/dist/redirectToPreviewURL.cjs.map +1 -1
  94. package/dist/redirectToPreviewURL.d.cts +5 -3
  95. package/dist/redirectToPreviewURL.d.ts +5 -3
  96. package/dist/redirectToPreviewURL.js.map +1 -1
  97. package/dist/types.d.cts +2 -1
  98. package/dist/types.d.ts +2 -1
  99. package/package.json +25 -23
  100. package/src/PrismicNextImage.tsx +134 -113
  101. package/src/PrismicNextLink.tsx +45 -43
  102. package/src/PrismicPreview.tsx +29 -28
  103. package/src/PrismicPreviewClient.tsx +44 -42
  104. package/src/SliceSimulator.tsx +43 -38
  105. package/src/SliceSimulatorWrapper.tsx +25 -15
  106. package/src/createLocaleRedirect.ts +3 -3
  107. package/src/enableAutoPreviews.ts +16 -15
  108. package/src/exitPreview.ts +13 -12
  109. package/src/getSlices.ts +10 -6
  110. package/src/imgixLoader.ts +10 -10
  111. package/src/index.ts +21 -18
  112. package/src/lib/devMsg.ts +11 -9
  113. package/src/lib/resolveDefaultExport.ts +13 -9
  114. package/src/pages/PrismicPreview.tsx +51 -47
  115. package/src/pages/SliceSimulator.tsx +37 -35
  116. package/src/pages/enableAutoPreviews.ts +17 -17
  117. package/src/pages/exitPreview.ts +18 -17
  118. package/src/pages/index.ts +23 -20
  119. package/src/pages/redirectToPreviewURL.ts +33 -22
  120. package/src/pages/setPreviewData.ts +7 -7
  121. package/src/pages/types.ts +20 -16
  122. package/src/redirectToPreviewURL.ts +30 -21
  123. package/src/types.ts +13 -12
  124. package/dist/PrismicNextImage.d.cts.map +0 -1
  125. package/dist/PrismicNextImage.d.ts.map +0 -1
  126. package/dist/PrismicNextLink.d.cts.map +0 -1
  127. package/dist/PrismicNextLink.d.ts.map +0 -1
  128. package/dist/PrismicPreview.d.cts.map +0 -1
  129. package/dist/PrismicPreview.d.ts.map +0 -1
  130. package/dist/SliceSimulator.d.cts.map +0 -1
  131. package/dist/SliceSimulator.d.ts.map +0 -1
  132. package/dist/createLocaleRedirect.d.cts.map +0 -1
  133. package/dist/createLocaleRedirect.d.ts.map +0 -1
  134. package/dist/enableAutoPreviews.d.cts.map +0 -1
  135. package/dist/enableAutoPreviews.d.ts.map +0 -1
  136. package/dist/exitPreview.d.cts.map +0 -1
  137. package/dist/exitPreview.d.ts.map +0 -1
  138. package/dist/getSlices.d.cts.map +0 -1
  139. package/dist/getSlices.d.ts.map +0 -1
  140. package/dist/imgixLoader.d.cts.map +0 -1
  141. package/dist/imgixLoader.d.ts.map +0 -1
  142. package/dist/pages/PrismicPreview.d.cts.map +0 -1
  143. package/dist/pages/PrismicPreview.d.ts.map +0 -1
  144. package/dist/pages/SliceSimulator.d.cts.map +0 -1
  145. package/dist/pages/SliceSimulator.d.ts.map +0 -1
  146. package/dist/pages/enableAutoPreviews.d.cts.map +0 -1
  147. package/dist/pages/enableAutoPreviews.d.ts.map +0 -1
  148. package/dist/pages/exitPreview.d.cts.map +0 -1
  149. package/dist/pages/exitPreview.d.ts.map +0 -1
  150. package/dist/pages/redirectToPreviewURL.d.cts.map +0 -1
  151. package/dist/pages/redirectToPreviewURL.d.ts.map +0 -1
  152. package/dist/pages/setPreviewData.d.cts.map +0 -1
  153. package/dist/pages/setPreviewData.d.ts.map +0 -1
  154. package/dist/pages/types.d.cts.map +0 -1
  155. package/dist/pages/types.d.ts.map +0 -1
  156. package/dist/redirectToPreviewURL.d.cts.map +0 -1
  157. package/dist/redirectToPreviewURL.d.ts.map +0 -1
  158. package/dist/types.d.cts.map +0 -1
  159. package/dist/types.d.ts.map +0 -1
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
3
3
  const require_resolveDefaultExport = require("./lib/resolveDefaultExport.cjs");
4
- const require_imgixLoader = require("./imgixLoader.cjs");
5
4
  const require_devMsg = require("./lib/devMsg.cjs");
5
+ const require_imgixLoader = require("./imgixLoader.cjs");
6
6
  let _prismicio_client = require("@prismicio/client");
7
7
  let react = require("react");
8
8
  let react_jsx_runtime = require("react/jsx-runtime");
9
- let imgix_url_builder = require("imgix-url-builder");
10
9
  let next_image_js = require("next/image.js");
11
10
  next_image_js = require_runtime.__toESM(next_image_js);
11
+ let imgix_url_builder = require("imgix-url-builder");
12
12
  //#region src/PrismicNextImage.tsx
13
13
  const castInt = (input) => {
14
14
  if (typeof input === "number" || typeof input === "undefined") return input;
@@ -19,17 +19,19 @@ const castInt = (input) => {
19
19
  }
20
20
  };
21
21
  /**
22
- * React component that renders an image from a Prismic Image field or one of its thumbnails using
23
- * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`
24
- * property.
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
25
  *
26
- * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`
27
- * prop. If you would like to use the Next.js Image Optimization API instead, set
28
- * `loader={undefined}`.
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
29
  *
30
30
  * @param props - Props for the component.
31
+ *
31
32
  * @returns A responsive image component using `next/image` for the given Image
32
- * field.
33
+ * field.
34
+ *
33
35
  * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
34
36
  */
35
37
  const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage({ field, imgixParams = {}, alt, fallbackAlt, fill, width, height, fallback = null, loader = require_imgixLoader.imgixLoader, ...restProps }, ref) {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextImage.cjs","names":["imgixLoader","devMsg","isFilled","resolveDefaultExport","Image"],"sources":["../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ImageFieldImage } from \"@prismicio/client\"\nimport { isFilled } from \"@prismicio/client\"\nimport type { ImgixURLParams } from \"imgix-url-builder\"\nimport { buildURL } from \"imgix-url-builder\"\nimport type { ImageProps } from \"next/image\"\nimport Image from \"next/image\"\nimport type { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from \"react\"\nimport { forwardRef } from \"react\"\n\nimport { imgixLoader } from \"./imgixLoader\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\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<ImageProps, \"src\" | \"alt\" | \"loader\"> & {\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */\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 its thumbnails using\n * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`\n * property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`\n * prop. If you would like to use the Next.js Image Optimization API instead, set\n * `loader={undefined}`.\n *\n * @param props - Props for the component.\n * @returns A responsive image component using `next/image` for the given Image\n * field.\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>(function PrismicNextImage(\n\t{\n\t\tfield,\n\t\timgixParams = {},\n\t\talt,\n\t\tfallbackAlt,\n\t\tfill,\n\t\twidth,\n\t\theight,\n\t\tfallback = null,\n\t\tloader = imgixLoader,\n\t\t...restProps\n\t},\n\tref,\n) {\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\tconsole.warn(\n\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\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\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\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\t}\n\n\tif (!isFilled.imageThumbnail(field)) {\n\t\treturn <>{fallback}</>\n\t}\n\n\tconst resolvedImgixParams = imgixParams\n\tfor (const x in imgixParams) {\n\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined\n\t\t}\n\t}\n\n\tconst src = buildURL(field.url, imgixParams as ImgixURLParams)\n\n\tconst ar = field.dimensions.width / field.dimensions.height\n\n\tconst castedWidth = castInt(width)\n\tconst castedHeight = castInt(height)\n\n\tlet resolvedWidth = castedWidth ?? field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\t// A non-null assertion is required since we can't statically\n\t// know if an alt attribute is available.\n\tconst resolvedAlt = (alt ?? (field.alt || fallbackAlt))!\n\n\tif (process.env.NODE_ENV === \"development\" && typeof resolvedAlt !== \"string\") {\n\t\tconsole.error(\n\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\tsrc,\n\t\t)\n\t}\n\n\tconst ResolvedImage = resolveDefaultExport(Image)\n\n\treturn (\n\t\t<ResolvedImage\n\t\t\tref={ref}\n\t\t\tsrc={src}\n\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\talt={resolvedAlt}\n\t\t\tfill={fill}\n\t\t\tloader={loader === null ? undefined : loader}\n\t\t\t{...restProps}\n\t\t/>\n\t)\n})\n"],"mappings":";;;;;;;;;;;;AAeA,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;;;;;;;;;;;;;;;;;AAoDV,MAAa,oBAAA,GAAA,MAAA,YAE2C,SAAS,iBAChE,EACC,OACA,cAAc,EAAE,EAChB,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAASA,oBAAAA,aACT,GAAG,aAEJ,KACC;AACD,KAAI,QAAQ,IAAI,aAAa,eAAe;AAC3C,MAAI,OAAO,QAAQ,YAAY,QAAQ,GACtC,SAAQ,KACP,yQAAyQC,eAAAA,OACxQ,8BACA,GACD;AAGF,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,GACtD,SAAQ,KACP,ySAAySA,eAAAA,OACxS,8BACA,GACD;;AAIH,KAAI,CAACC,kBAAAA,SAAS,eAAe,MAAM,CAClC,QAAO,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAA,UAAG,UAAY,CAAA;CAGvB,MAAM,sBAAsB;AAC5B,MAAK,MAAM,KAAK,YACf,KAAI,oBAAoB,OAA2C,KAClE,qBAAoB,KAAyC,KAAA;CAI/D,MAAM,OAAA,GAAA,kBAAA,UAAe,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,KAAI,QAAQ,IAAI,aAAa,iBAAiB,OAAO,gBAAgB,SACpE,SAAQ,MACP,mNACA,IACA;AAKF,QACC,iBAAA,GAAA,kBAAA,KAHqBC,6BAAAA,qBAAqBC,cAAAA,QAAM,EAGhD;EACM;EACA;EACL,OAAO,OAAO,KAAA,IAAY;EAC1B,QAAQ,OAAO,KAAA,IAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,KAAA,IAAY;EACtC,GAAI;EACH,CAAA;EAEF"}
1
+ {"version":3,"file":"PrismicNextImage.cjs","names":["imgixLoader","devMsg","isFilled","resolveDefaultExport","Image"],"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,oBAAA,GAAA,MAAA,YAGZ,SAAS,iBACR,EACC,OACA,cAAc,EAAE,EAChB,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAASA,oBAAAA,aACT,GAAG,aAEJ,KACC;AACD,KAAI,QAAQ,IAAI,aAAa,eAAe;AAC3C,MAAI,OAAO,QAAQ,YAAY,QAAQ,GACtC,SAAQ,KACP,yQAAyQC,eAAAA,OACxQ,8BACA,GACD;AAGF,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,GACtD,SAAQ,KACP,ySAAySA,eAAAA,OACxS,8BACA,GACD;;AAIH,KAAI,CAACC,kBAAAA,SAAS,eAAe,MAAM,CAClC,QAAO,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAA,UAAG,UAAY,CAAA;CAGvB,MAAM,sBAAsB;AAC5B,MAAK,MAAM,KAAK,YACf,KAAI,oBAAoB,OAA2C,KAClE,qBAAoB,KAAyC,KAAA;CAI/D,MAAM,OAAA,GAAA,kBAAA,UAAe,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,iBAAA,GAAA,kBAAA,KAHqBC,6BAAAA,qBAAqBC,cAAAA,QAAM,EAGhD;EACM;EACA;EACL,OAAO,OAAO,KAAA,IAAY;EAC1B,QAAQ,OAAO,KAAA,IAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,KAAA,IAAY;EACtC,GAAI;EACH,CAAA;EAGJ"}
@@ -1,7 +1,7 @@
1
1
  import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
2
2
  import { ImageFieldImage } from "@prismicio/client";
3
- import { ImgixURLParams } from "imgix-url-builder";
4
3
  import { ImageProps } from "next/image.js";
4
+ import { ImgixURLParams } from "imgix-url-builder";
5
5
 
6
6
  //#region src/PrismicNextImage.d.ts
7
7
  type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
@@ -15,31 +15,39 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
15
15
  /**
16
16
  * Declare an image as decorative by providing `alt=""`.
17
17
  *
18
- * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
18
+ * See:
19
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
19
20
  */
20
21
  alt?: "";
21
22
  /**
22
- * Declare an image as decorative only if the Image field does not have alternative text by
23
- * providing `fallbackAlt=""`.
23
+ * Declare an image as decorative only if the Image field does not have
24
+ * alternative text by providing `fallbackAlt=""`.
24
25
  *
25
- * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
26
+ * See:
27
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
28
+ */
29
+ fallbackAlt?: "";
30
+ /**
31
+ * Rendered when the field is empty. If a fallback is not given, `null` will
32
+ * be rendered.
26
33
  */
27
- fallbackAlt?: ""; /** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */
28
34
  fallback?: React.ReactNode;
29
35
  loader?: ImageProps["loader"] | null;
30
36
  };
31
37
  /**
32
- * React component that renders an image from a Prismic Image field or one of its thumbnails using
33
- * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`
34
- * property.
38
+ * React component that renders an image from a Prismic Image field or one of
39
+ * its thumbnails using `next/image`. It will automatically set the `alt`
40
+ * attribute using the Image field's `alt` property.
35
41
  *
36
- * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`
37
- * prop. If you would like to use the Next.js Image Optimization API instead, set
38
- * `loader={undefined}`.
42
+ * It uses an Imgix URL-based loader by default. A custom loader can be provided
43
+ * with the `loader` prop. If you would like to use the Next.js Image
44
+ * Optimization API instead, set `loader={undefined}`.
39
45
  *
40
46
  * @param props - Props for the component.
47
+ *
41
48
  * @returns A responsive image component using `next/image` for the given Image
42
- * field.
49
+ * field.
50
+ *
43
51
  * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
44
52
  */
45
53
  declare const PrismicNextImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>>;
@@ -1,7 +1,7 @@
1
1
  import { ImageFieldImage } from "@prismicio/client";
2
2
  import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
3
- import { ImgixURLParams } from "imgix-url-builder";
4
3
  import { ImageProps } from "next/image.js";
4
+ import { ImgixURLParams } from "imgix-url-builder";
5
5
 
6
6
  //#region src/PrismicNextImage.d.ts
7
7
  type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
@@ -15,31 +15,39 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
15
15
  /**
16
16
  * Declare an image as decorative by providing `alt=""`.
17
17
  *
18
- * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
18
+ * See:
19
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
19
20
  */
20
21
  alt?: "";
21
22
  /**
22
- * Declare an image as decorative only if the Image field does not have alternative text by
23
- * providing `fallbackAlt=""`.
23
+ * Declare an image as decorative only if the Image field does not have
24
+ * alternative text by providing `fallbackAlt=""`.
24
25
  *
25
- * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
26
+ * See:
27
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
28
+ */
29
+ fallbackAlt?: "";
30
+ /**
31
+ * Rendered when the field is empty. If a fallback is not given, `null` will
32
+ * be rendered.
26
33
  */
27
- fallbackAlt?: ""; /** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */
28
34
  fallback?: React.ReactNode;
29
35
  loader?: ImageProps["loader"] | null;
30
36
  };
31
37
  /**
32
- * React component that renders an image from a Prismic Image field or one of its thumbnails using
33
- * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`
34
- * property.
38
+ * React component that renders an image from a Prismic Image field or one of
39
+ * its thumbnails using `next/image`. It will automatically set the `alt`
40
+ * attribute using the Image field's `alt` property.
35
41
  *
36
- * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`
37
- * prop. If you would like to use the Next.js Image Optimization API instead, set
38
- * `loader={undefined}`.
42
+ * It uses an Imgix URL-based loader by default. A custom loader can be provided
43
+ * with the `loader` prop. If you would like to use the Next.js Image
44
+ * Optimization API instead, set `loader={undefined}`.
39
45
  *
40
46
  * @param props - Props for the component.
47
+ *
41
48
  * @returns A responsive image component using `next/image` for the given Image
42
- * field.
49
+ * field.
50
+ *
43
51
  * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
44
52
  */
45
53
  declare const PrismicNextImage: ForwardRefExoticComponent<PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>>;
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  import { resolveDefaultExport } from "./lib/resolveDefaultExport.js";
3
- import { imgixLoader } from "./imgixLoader.js";
4
3
  import { devMsg } from "./lib/devMsg.js";
4
+ import { imgixLoader } from "./imgixLoader.js";
5
5
  import { isFilled } from "@prismicio/client";
6
6
  import { forwardRef } from "react";
7
7
  import { Fragment, jsx } from "react/jsx-runtime";
8
- import { buildURL } from "imgix-url-builder";
9
8
  import Image from "next/image.js";
9
+ import { buildURL } from "imgix-url-builder";
10
10
  //#region src/PrismicNextImage.tsx
11
11
  const castInt = (input) => {
12
12
  if (typeof input === "number" || typeof input === "undefined") return input;
@@ -17,17 +17,19 @@ const castInt = (input) => {
17
17
  }
18
18
  };
19
19
  /**
20
- * React component that renders an image from a Prismic Image field or one of its thumbnails using
21
- * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`
22
- * property.
20
+ * React component that renders an image from a Prismic Image field or one of
21
+ * its thumbnails using `next/image`. It will automatically set the `alt`
22
+ * attribute using the Image field's `alt` property.
23
23
  *
24
- * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`
25
- * prop. If you would like to use the Next.js Image Optimization API instead, set
26
- * `loader={undefined}`.
24
+ * It uses an Imgix URL-based loader by default. A custom loader can be provided
25
+ * with the `loader` prop. If you would like to use the Next.js Image
26
+ * Optimization API instead, set `loader={undefined}`.
27
27
  *
28
28
  * @param props - Props for the component.
29
+ *
29
30
  * @returns A responsive image component using `next/image` for the given Image
30
- * field.
31
+ * field.
32
+ *
31
33
  * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
32
34
  */
33
35
  const PrismicNextImage = forwardRef(function PrismicNextImage({ field, imgixParams = {}, alt, fallbackAlt, fill, width, height, fallback = null, loader = imgixLoader, ...restProps }, ref) {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextImage.js","names":[],"sources":["../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ImageFieldImage } from \"@prismicio/client\"\nimport { isFilled } from \"@prismicio/client\"\nimport type { ImgixURLParams } from \"imgix-url-builder\"\nimport { buildURL } from \"imgix-url-builder\"\nimport type { ImageProps } from \"next/image\"\nimport Image from \"next/image\"\nimport type { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from \"react\"\nimport { forwardRef } from \"react\"\n\nimport { imgixLoader } from \"./imgixLoader\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\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<ImageProps, \"src\" | \"alt\" | \"loader\"> & {\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */\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 its thumbnails using\n * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`\n * property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`\n * prop. If you would like to use the Next.js Image Optimization API instead, set\n * `loader={undefined}`.\n *\n * @param props - Props for the component.\n * @returns A responsive image component using `next/image` for the given Image\n * field.\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>(function PrismicNextImage(\n\t{\n\t\tfield,\n\t\timgixParams = {},\n\t\talt,\n\t\tfallbackAlt,\n\t\tfill,\n\t\twidth,\n\t\theight,\n\t\tfallback = null,\n\t\tloader = imgixLoader,\n\t\t...restProps\n\t},\n\tref,\n) {\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\tconsole.warn(\n\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\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\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\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\t}\n\n\tif (!isFilled.imageThumbnail(field)) {\n\t\treturn <>{fallback}</>\n\t}\n\n\tconst resolvedImgixParams = imgixParams\n\tfor (const x in imgixParams) {\n\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined\n\t\t}\n\t}\n\n\tconst src = buildURL(field.url, imgixParams as ImgixURLParams)\n\n\tconst ar = field.dimensions.width / field.dimensions.height\n\n\tconst castedWidth = castInt(width)\n\tconst castedHeight = castInt(height)\n\n\tlet resolvedWidth = castedWidth ?? field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\t// A non-null assertion is required since we can't statically\n\t// know if an alt attribute is available.\n\tconst resolvedAlt = (alt ?? (field.alt || fallbackAlt))!\n\n\tif (process.env.NODE_ENV === \"development\" && typeof resolvedAlt !== \"string\") {\n\t\tconsole.error(\n\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\tsrc,\n\t\t)\n\t}\n\n\tconst ResolvedImage = resolveDefaultExport(Image)\n\n\treturn (\n\t\t<ResolvedImage\n\t\t\tref={ref}\n\t\t\tsrc={src}\n\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\talt={resolvedAlt}\n\t\t\tfill={fill}\n\t\t\tloader={loader === null ? undefined : loader}\n\t\t\t{...restProps}\n\t\t/>\n\t)\n})\n"],"mappings":";;;;;;;;;;AAeA,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;;;;;;;;;;;;;;;;;AAoDV,MAAa,mBAET,WAAoD,SAAS,iBAChE,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,oBAAA,UAAA,EAAA,UAAG,UAAY,CAAA;CAGvB,MAAM,sBAAsB;AAC5B,MAAK,MAAM,KAAK,YACf,KAAI,oBAAoB,OAA2C,KAClE,qBAAoB,KAAyC,KAAA;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,KAAI,QAAQ,IAAI,aAAa,iBAAiB,OAAO,gBAAgB,SACpE,SAAQ,MACP,mNACA,IACA;AAKF,QACC,oBAHqB,qBAAqB,MAAM,EAGhD;EACM;EACA;EACL,OAAO,OAAO,KAAA,IAAY;EAC1B,QAAQ,OAAO,KAAA,IAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,KAAA,IAAY;EACtC,GAAI;EACH,CAAA;EAEF"}
1
+ {"version":3,"file":"PrismicNextImage.js","names":[],"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,SAAS,iBACR,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,oBAAA,UAAA,EAAA,UAAG,UAAY,CAAA;CAGvB,MAAM,sBAAsB;AAC5B,MAAK,MAAM,KAAK,YACf,KAAI,oBAAoB,OAA2C,KAClE,qBAAoB,KAAyC,KAAA;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,EAGhD;EACM;EACA;EACL,OAAO,OAAO,KAAA,IAAY;EAC1B,QAAQ,OAAO,KAAA,IAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,KAAA,IAAY;EACtC,GAAI;EACH,CAAA;EAGJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextLink.cjs","names":["resolveDefaultExport","Link"],"sources":["../src/PrismicNextLink.tsx"],"sourcesContent":["import type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n} from \"@prismicio/client\"\nimport { asLinkAttrs } from \"@prismicio/client\"\nimport Link from \"next/link\"\nimport type { ComponentProps } from \"react\"\nimport { forwardRef } from \"react\"\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<HTMLAnchorElement, PrismicNextLinkProps>(\n\tfunction PrismicNextLink(props, ref) {\n\t\tconst { field, document, linkResolver, children, ...restProps } = props\n\t\tconst {\n\t\t\thref: computedHref,\n\t\t\trel: computedRel,\n\t\t\t...attrs\n\t\t} = asLinkAttrs(field ?? document, {\n\t\t\tlinkResolver,\n\t\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t\t})\n\n\t\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\"\n\n\t\tlet rel = computedRel\n\t\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\t\trel = restProps.rel\n\t\t}\n\n\t\tconst ResolvedLink = resolveDefaultExport(Link)\n\n\t\treturn (\n\t\t\t<ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t\t{\"children\" in props ? children : field?.text}\n\t\t\t</ResolvedLink>\n\t\t)\n\t},\n)\n"],"mappings":";;;;;;;;AAqCA,MAAa,mBAAA,GAAA,MAAA,YACZ,SAAS,gBAAgB,OAAO,KAAK;CACpC,MAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;CAClE,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,WAAA,GAAA,kBAAA,aACY,SAAS,UAAU;EAClC;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM,KAAA;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,iBAAA,GAAA,kBAAA,KAHoBA,6BAAAA,qBAAqBC,aAAAA,QAAK,EAG9C;EAAmB;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;YACjE,cAAc,QAAQ,WAAW,OAAO;EAC3B,CAAA;EAGjB"}
1
+ {"version":3,"file":"PrismicNextLink.cjs","names":["resolveDefaultExport","Link"],"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,mBAAA,GAAA,MAAA,YAGX,SAAS,gBAAgB,OAAO,KAAK;CACtC,MAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;CAClE,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,WAAA,GAAA,kBAAA,aACY,SAAS,UAAU;EAClC;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM,KAAA;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,iBAAA,GAAA,kBAAA,KAHoBA,6BAAAA,qBAAqBC,aAAAA,QAAK,EAG9C;EAAmB;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;YACjE,cAAc,QAAQ,WAAW,OAAO;EAC3B,CAAA;EAEf"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextLink.js","names":[],"sources":["../src/PrismicNextLink.tsx"],"sourcesContent":["import type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n} from \"@prismicio/client\"\nimport { asLinkAttrs } from \"@prismicio/client\"\nimport Link from \"next/link\"\nimport type { ComponentProps } from \"react\"\nimport { forwardRef } from \"react\"\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<HTMLAnchorElement, PrismicNextLinkProps>(\n\tfunction PrismicNextLink(props, ref) {\n\t\tconst { field, document, linkResolver, children, ...restProps } = props\n\t\tconst {\n\t\t\thref: computedHref,\n\t\t\trel: computedRel,\n\t\t\t...attrs\n\t\t} = asLinkAttrs(field ?? document, {\n\t\t\tlinkResolver,\n\t\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t\t})\n\n\t\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\"\n\n\t\tlet rel = computedRel\n\t\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\t\trel = restProps.rel\n\t\t}\n\n\t\tconst ResolvedLink = resolveDefaultExport(Link)\n\n\t\treturn (\n\t\t\t<ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t\t{\"children\" in props ? children : field?.text}\n\t\t\t</ResolvedLink>\n\t\t)\n\t},\n)\n"],"mappings":";;;;;;AAqCA,MAAa,kBAAkB,WAC9B,SAAS,gBAAgB,OAAO,KAAK;CACpC,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,KAAA;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,EAG9C;EAAmB;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;YACjE,cAAc,QAAQ,WAAW,OAAO;EAC3B,CAAA;EAGjB"}
1
+ {"version":3,"file":"PrismicNextLink.js","names":[],"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,SAAS,gBAAgB,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,KAAA;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,EAG9C;EAAmB;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;YACjE,cAAc,QAAQ,WAAW,OAAO;EAC3B,CAAA;EAEf"}
@@ -1,18 +1,19 @@
1
1
  const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
2
  const require_resolveDefaultExport = require("./lib/resolveDefaultExport.cjs");
3
3
  const require_PrismicPreviewClient = require("./PrismicPreviewClient.cjs");
4
- let _prismicio_client = require("@prismicio/client");
5
4
  let next_script_js = require("next/script.js");
6
5
  next_script_js = require_runtime.__toESM(next_script_js);
6
+ let _prismicio_client = require("@prismicio/client");
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
8
  //#region src/PrismicPreview.tsx
9
9
  /**
10
- * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
11
- * send events to the browser, such as on preview updates and exiting, this component will
12
- * automatically refresh the page with the changes.
10
+ * React component that sets up Prismic Previews using the Prismic Toolbar. When
11
+ * the Prismic Toolbar send events to the browser, such as on preview updates
12
+ * and exiting, this component will automatically refresh the page with the
13
+ * changes.
13
14
  *
14
- * This component can be wrapped around your app or added anywhere in your app's tree. It must be
15
- * rendered on every page.
15
+ * This component can be wrapped around your app or added anywhere in your app's
16
+ * tree. It must be rendered on every page.
16
17
  */
17
18
  const PrismicPreview = async (props) => {
18
19
  const { repositoryName, children, ...otherProps } = props;
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.cjs","names":["resolveDefaultExport","Script","PrismicPreviewClient"],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc } from \"@prismicio/client\"\nimport Script from \"next/script\"\nimport type { FC, ReactNode } from \"react\"\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 using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be\n\t * fetched on preview exit events.\n\t */\n\texitPreviewURL?: string\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: ReactNode\n}\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * rendered on every page.\n */\nexport const PrismicPreview: FC<PrismicPreviewProps> = 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":";;;;;;;;;;;;;;;;AAuCA,MAAa,iBAA0C,OAAO,UAAU;CACvE,MAAM,EAAE,gBAAgB,UAAU,GAAG,eAAe;CAKpD,MAAM,EAAE,cAAc,MAAM,OAAO;CAEnC,MAAM,cAAA,GAAA,kBAAA,eAA2B,eAAe;CAChD,MAAM,eAAe,MAAM,WAAW,EAAE;CAExC,MAAM,iBAAiBA,6BAAAA,qBAAqBC,eAAAA,QAAO;AAEnD,QACC,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA;EACE;EACD,iBAAA,GAAA,kBAAA,KAACC,6BAAAA,sBAAD;GACiB;GACH;GACb,GAAI;GACH,CAAA;EACF,iBAAA,GAAA,kBAAA,KAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;GAAe,CAAA;EACvD,EAAA,CAAA"}
1
+ {"version":3,"file":"PrismicPreview.cjs","names":["resolveDefaultExport","Script","PrismicPreviewClient"],"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,cAAA,GAAA,kBAAA,eAA2B,eAAe;CAChD,MAAM,eAAe,MAAM,WAAW,EAAE;CAExC,MAAM,iBAAiBA,6BAAAA,qBAAqBC,eAAAA,QAAO;AAEnD,QACC,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA;EACE;EACD,iBAAA,GAAA,kBAAA,KAACC,6BAAAA,sBAAD;GACiB;GACH;GACb,GAAI;GACH,CAAA;EACF,iBAAA,GAAA,kBAAA,KAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;GAAe,CAAA;EACvD,EAAA,CAAA"}
@@ -4,29 +4,30 @@ import { FC, ReactNode } from "react";
4
4
  /** Props for `<PrismicPreview>`. */
5
5
  type PrismicPreviewProps = {
6
6
  /**
7
- * The name of your Prismic repository. A Prismic Toolbar will be registered using this
8
- * repository.
7
+ * The name of your Prismic repository. A Prismic Toolbar will be registered
8
+ * using this repository.
9
9
  */
10
10
  repositoryName: string;
11
11
  /**
12
- * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be
13
- * fetched on preview update events.
12
+ * The URL of your app's Prismic preview endpoint (default: `/api/preview`).
13
+ * This URL will be fetched on preview update events.
14
14
  */
15
15
  updatePreviewURL?: string;
16
16
  /**
17
- * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
18
- * fetched on preview exit events.
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
19
  */
20
20
  exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
21
21
  children?: ReactNode;
22
22
  };
23
23
  /**
24
- * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
25
- * send events to the browser, such as on preview updates and exiting, this component will
26
- * automatically refresh the page with the changes.
24
+ * React component that sets up Prismic Previews using the Prismic Toolbar. When
25
+ * the Prismic Toolbar send events to the browser, such as on preview updates
26
+ * and exiting, this component will automatically refresh the page with the
27
+ * changes.
27
28
  *
28
- * This component can be wrapped around your app or added anywhere in your app's tree. It must be
29
- * rendered on every page.
29
+ * This component can be wrapped around your app or added anywhere in your app's
30
+ * tree. It must be rendered on every page.
30
31
  */
31
32
  declare const PrismicPreview: FC<PrismicPreviewProps>;
32
33
  //#endregion
@@ -4,29 +4,30 @@ import { FC, ReactNode } from "react";
4
4
  /** Props for `<PrismicPreview>`. */
5
5
  type PrismicPreviewProps = {
6
6
  /**
7
- * The name of your Prismic repository. A Prismic Toolbar will be registered using this
8
- * repository.
7
+ * The name of your Prismic repository. A Prismic Toolbar will be registered
8
+ * using this repository.
9
9
  */
10
10
  repositoryName: string;
11
11
  /**
12
- * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be
13
- * fetched on preview update events.
12
+ * The URL of your app's Prismic preview endpoint (default: `/api/preview`).
13
+ * This URL will be fetched on preview update events.
14
14
  */
15
15
  updatePreviewURL?: string;
16
16
  /**
17
- * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
18
- * fetched on preview exit events.
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
19
  */
20
20
  exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
21
21
  children?: ReactNode;
22
22
  };
23
23
  /**
24
- * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
25
- * send events to the browser, such as on preview updates and exiting, this component will
26
- * automatically refresh the page with the changes.
24
+ * React component that sets up Prismic Previews using the Prismic Toolbar. When
25
+ * the Prismic Toolbar send events to the browser, such as on preview updates
26
+ * and exiting, this component will automatically refresh the page with the
27
+ * changes.
27
28
  *
28
- * This component can be wrapped around your app or added anywhere in your app's tree. It must be
29
- * rendered on every page.
29
+ * This component can be wrapped around your app or added anywhere in your app's
30
+ * tree. It must be rendered on every page.
30
31
  */
31
32
  declare const PrismicPreview: FC<PrismicPreviewProps>;
32
33
  //#endregion
@@ -1,16 +1,17 @@
1
1
  import { resolveDefaultExport } from "./lib/resolveDefaultExport.js";
2
2
  import { PrismicPreviewClient } from "./PrismicPreviewClient.js";
3
- import { getToolbarSrc } from "@prismicio/client";
4
3
  import Script from "next/script.js";
4
+ import { getToolbarSrc } from "@prismicio/client";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/PrismicPreview.tsx
7
7
  /**
8
- * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
9
- * send events to the browser, such as on preview updates and exiting, this component will
10
- * automatically refresh the page with the changes.
8
+ * React component that sets up Prismic Previews using the Prismic Toolbar. When
9
+ * the Prismic Toolbar send events to the browser, such as on preview updates
10
+ * and exiting, this component will automatically refresh the page with the
11
+ * changes.
11
12
  *
12
- * This component can be wrapped around your app or added anywhere in your app's tree. It must be
13
- * rendered on every page.
13
+ * This component can be wrapped around your app or added anywhere in your app's
14
+ * tree. It must be rendered on every page.
14
15
  */
15
16
  const PrismicPreview = async (props) => {
16
17
  const { repositoryName, children, ...otherProps } = props;
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.js","names":[],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc } from \"@prismicio/client\"\nimport Script from \"next/script\"\nimport type { FC, ReactNode } from \"react\"\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 using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be\n\t * fetched on preview exit events.\n\t */\n\texitPreviewURL?: string\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: ReactNode\n}\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * rendered on every page.\n */\nexport const PrismicPreview: FC<PrismicPreviewProps> = 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":";;;;;;;;;;;;;;AAuCA,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,qBAAA,UAAA,EAAA,UAAA;EACE;EACD,oBAAC,sBAAD;GACiB;GACH;GACb,GAAI;GACH,CAAA;EACF,oBAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;GAAe,CAAA;EACvD,EAAA,CAAA"}
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,qBAAA,UAAA,EAAA,UAAA;EACE;EACD,oBAAC,sBAAD;GACiB;GACH;GACb,GAAI;GACH,CAAA;EACF,oBAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;GAAe,CAAA;EACvD,EAAA,CAAA"}
@@ -49,7 +49,9 @@ const PrismicPreviewClient = (props) => {
49
49
  /**
50
50
  * Returns the value of a cookie from a given cookie store.
51
51
  *
52
- * @param cookieJar - The stringified cookie store from which to read the cookie.
52
+ * @param cookieJar - The stringified cookie store from which to read the
53
+ * cookie.
54
+ *
53
55
  * @returns The value of the cookie, if it exists.
54
56
  */
55
57
  function getPrismicPreviewCookie(cookieJar) {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreviewClient.cjs","names":["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 cookie.\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,aAAA,GAAA,gBAAA,YAAuB;AAE/B,EAAA,GAAA,MAAA,iBAAgB;EACf,MAAM,aAAa,IAAI,iBAAiB;AAExC,SAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,QACnB,CAAC;AACF,SAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,QACnB,CAAC;EAEF,MAAM,SAAS,wBAAwB,OAAO,SAAS,OAAO;AAS9D,OAR6B,UACzB,mBAAmB,OAAO,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE,KACnE,KAAA,OACqD,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;;;;;;;;AASR,SAAS,wBAAwB,WAAuC;CACvE,SAAS,UAAU,OAAuB;AACzC,SAAO,MAAM,QAAQ,QAAQ,IAAI;;CAGlC,MAAM,UAAU,UAAU,MAAM,KAAK;CAErC,IAAI;AAEJ,MAAK,MAAM,UAAU,SAAS;EAC7B,MAAM,QAAQ,OAAO,MAAM,IAAI;AAG/B,MAFa,UAAU,MAAM,GAAG,CAAC,QAAQ,QAAQ,IAAI,KAExCA,kBAAAA,OAAc,SAAS;AACnC,WAAQ,UAAU,MAAM,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;AAC3C;;;AAIF,QAAO"}
1
+ {"version":3,"file":"PrismicPreviewClient.cjs","names":["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,aAAA,GAAA,gBAAA,YAAuB;AAE/B,EAAA,GAAA,MAAA,iBAAgB;EACf,MAAM,aAAa,IAAI,iBAAiB;AAExC,SAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,QACnB,CAAC;AACF,SAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,QACnB,CAAC;EAEF,MAAM,SAAS,wBAAwB,OAAO,SAAS,OAAO;AAS9D,OAR6B,UACzB,mBAAmB,OAAO,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE,KACnE,KAAA,OACqD,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,OAAuB;AACzC,SAAO,MAAM,QAAQ,QAAQ,IAAI;;CAGlC,MAAM,UAAU,UAAU,MAAM,KAAK;CAErC,IAAI;AAEJ,MAAK,MAAM,UAAU,SAAS;EAC7B,MAAM,QAAQ,OAAO,MAAM,IAAI;AAG/B,MAFa,UAAU,MAAM,GAAG,CAAC,QAAQ,QAAQ,IAAI,KAExCA,kBAAAA,OAAc,SAAS;AACnC,WAAQ,UAAU,MAAM,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;AAC3C;;;AAIF,QAAO"}
@@ -48,7 +48,9 @@ const PrismicPreviewClient = (props) => {
48
48
  /**
49
49
  * Returns the value of a cookie from a given cookie store.
50
50
  *
51
- * @param cookieJar - The stringified cookie store from which to read the cookie.
51
+ * @param cookieJar - The stringified cookie store from which to read the
52
+ * cookie.
53
+ *
52
54
  * @returns The value of the cookie, if it exists.
53
55
  */
54
56
  function getPrismicPreviewCookie(cookieJar) {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreviewClient.js","names":["cookie","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 cookie.\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,MAAM,SAAS,wBAAwB,OAAO,SAAS,OAAO;AAS9D,OAR6B,UACzB,mBAAmB,OAAO,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE,KACnE,KAAA,OACqD,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;;;;;;;;AASR,SAAS,wBAAwB,WAAuC;CACvE,SAAS,UAAU,OAAuB;AACzC,SAAO,MAAM,QAAQ,QAAQ,IAAI;;CAGlC,MAAM,UAAU,UAAU,MAAM,KAAK;CAErC,IAAI;AAEJ,MAAK,MAAMA,YAAU,SAAS;EAC7B,MAAM,QAAQA,SAAO,MAAM,IAAI;AAG/B,MAFa,UAAU,MAAM,GAAG,CAAC,QAAQ,QAAQ,IAAI,KAExCC,OAAc,SAAS;AACnC,WAAQ,UAAU,MAAM,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;AAC3C;;;AAIF,QAAO"}
1
+ {"version":3,"file":"PrismicPreviewClient.js","names":["cookie","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,MAAM,SAAS,wBAAwB,OAAO,SAAS,OAAO;AAS9D,OAR6B,UACzB,mBAAmB,OAAO,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE,KACnE,KAAA,OACqD,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,OAAuB;AACzC,SAAO,MAAM,QAAQ,QAAQ,IAAI;;CAGlC,MAAM,UAAU,UAAU,MAAM,KAAK;CAErC,IAAI;AAEJ,MAAK,MAAMA,YAAU,SAAS;EAC7B,MAAM,QAAQA,SAAO,MAAM,IAAI;AAG/B,MAFa,UAAU,MAAM,GAAG,CAAC,QAAQ,QAAQ,IAAI,KAExCC,OAAc,SAAS;AACnC,WAAQ,UAAU,MAAM,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;AAC3C;;;AAIF,QAAO"}