@prismicio/next 2.3.3-pr.162.8e0acbb → 2.3.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 (158) hide show
  1. package/dist/PrismicNextImage.cjs +5 -6
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.cts +4 -5
  4. package/dist/PrismicNextImage.d.cts.map +1 -1
  5. package/dist/PrismicNextImage.d.ts +4 -5
  6. package/dist/PrismicNextImage.d.ts.map +1 -1
  7. package/dist/PrismicNextImage.js +4 -5
  8. package/dist/PrismicNextImage.js.map +1 -1
  9. package/dist/PrismicNextLink.cjs +2 -3
  10. package/dist/PrismicNextLink.cjs.map +1 -1
  11. package/dist/PrismicNextLink.d.cts +11 -8
  12. package/dist/PrismicNextLink.d.cts.map +1 -1
  13. package/dist/PrismicNextLink.d.ts +10 -7
  14. package/dist/PrismicNextLink.d.ts.map +1 -1
  15. package/dist/PrismicNextLink.js +1 -2
  16. package/dist/PrismicNextLink.js.map +1 -1
  17. package/dist/PrismicPreview.cjs +2 -2
  18. package/dist/PrismicPreview.cjs.map +1 -1
  19. package/dist/PrismicPreview.d.cts +2 -2
  20. package/dist/PrismicPreview.d.cts.map +1 -1
  21. package/dist/PrismicPreview.d.ts +2 -2
  22. package/dist/PrismicPreview.d.ts.map +1 -1
  23. package/dist/PrismicPreview.js +1 -1
  24. package/dist/PrismicPreview.js.map +1 -1
  25. package/dist/PrismicPreviewClient.cjs +1 -0
  26. package/dist/PrismicPreviewClient.cjs.map +1 -1
  27. package/dist/PrismicPreviewClient.js.map +1 -1
  28. package/dist/SliceSimulator.cjs +2 -3
  29. package/dist/SliceSimulator.cjs.map +1 -1
  30. package/dist/SliceSimulator.d.cts +1 -0
  31. package/dist/SliceSimulator.d.cts.map +1 -1
  32. package/dist/SliceSimulator.d.ts +1 -0
  33. package/dist/SliceSimulator.d.ts.map +1 -1
  34. package/dist/SliceSimulator.js +1 -2
  35. package/dist/SliceSimulator.js.map +1 -1
  36. package/dist/SliceSimulatorWrapper.cjs +1 -0
  37. package/dist/SliceSimulatorWrapper.cjs.map +1 -1
  38. package/dist/SliceSimulatorWrapper.js.map +1 -1
  39. package/dist/_virtual/_rolldown/runtime.cjs +1 -1
  40. package/dist/cacheTagPrismicPages.cjs +1 -1
  41. package/dist/cacheTagPrismicPages.cjs.map +1 -1
  42. package/dist/cacheTagPrismicPages.d.cts +1 -0
  43. package/dist/cacheTagPrismicPages.d.cts.map +1 -1
  44. package/dist/cacheTagPrismicPages.d.ts +1 -0
  45. package/dist/cacheTagPrismicPages.d.ts.map +1 -1
  46. package/dist/cacheTagPrismicPages.js.map +1 -1
  47. package/dist/createLocaleRedirect.cjs.map +1 -1
  48. package/dist/createLocaleRedirect.d.cts.map +1 -1
  49. package/dist/createLocaleRedirect.d.ts.map +1 -1
  50. package/dist/createLocaleRedirect.js.map +1 -1
  51. package/dist/enableAutoPreviews.cjs.map +1 -1
  52. package/dist/enableAutoPreviews.d.cts +2 -2
  53. package/dist/enableAutoPreviews.d.cts.map +1 -1
  54. package/dist/enableAutoPreviews.d.ts +2 -2
  55. package/dist/enableAutoPreviews.d.ts.map +1 -1
  56. package/dist/enableAutoPreviews.js.map +1 -1
  57. package/dist/exitPreview.cjs +1 -0
  58. package/dist/exitPreview.cjs.map +1 -1
  59. package/dist/exitPreview.d.cts.map +1 -1
  60. package/dist/exitPreview.d.ts.map +1 -1
  61. package/dist/exitPreview.js.map +1 -1
  62. package/dist/getPreviewRef.cjs +1 -0
  63. package/dist/getPreviewRef.cjs.map +1 -1
  64. package/dist/getPreviewRef.d.cts.map +1 -1
  65. package/dist/getPreviewRef.d.ts.map +1 -1
  66. package/dist/getPreviewRef.js.map +1 -1
  67. package/dist/getPrismicCacheTags.cjs +2 -4
  68. package/dist/getPrismicCacheTags.cjs.map +1 -1
  69. package/dist/getPrismicCacheTags.d.cts +1 -0
  70. package/dist/getPrismicCacheTags.d.cts.map +1 -1
  71. package/dist/getPrismicCacheTags.d.ts +1 -0
  72. package/dist/getPrismicCacheTags.d.ts.map +1 -1
  73. package/dist/getPrismicCacheTags.js +2 -4
  74. package/dist/getPrismicCacheTags.js.map +1 -1
  75. package/dist/getSlices.cjs +1 -1
  76. package/dist/getSlices.cjs.map +1 -1
  77. package/dist/getSlices.d.cts +1 -0
  78. package/dist/getSlices.d.cts.map +1 -1
  79. package/dist/getSlices.d.ts +1 -0
  80. package/dist/getSlices.d.ts.map +1 -1
  81. package/dist/getSlices.js.map +1 -1
  82. package/dist/imgixLoader.cjs +1 -0
  83. package/dist/imgixLoader.cjs.map +1 -1
  84. package/dist/imgixLoader.d.cts +1 -0
  85. package/dist/imgixLoader.d.cts.map +1 -1
  86. package/dist/imgixLoader.d.ts +1 -0
  87. package/dist/imgixLoader.d.ts.map +1 -1
  88. package/dist/imgixLoader.js.map +1 -1
  89. package/dist/lib/devMsg.cjs.map +1 -1
  90. package/dist/lib/devMsg.js.map +1 -1
  91. package/dist/lib/resolveDefaultExport.cjs.map +1 -1
  92. package/dist/lib/resolveDefaultExport.js.map +1 -1
  93. package/dist/package.cjs +1 -1
  94. package/dist/package.js +1 -1
  95. package/dist/pages/PrismicPreview.cjs +1 -1
  96. package/dist/pages/PrismicPreview.cjs.map +1 -1
  97. package/dist/pages/PrismicPreview.d.cts +2 -2
  98. package/dist/pages/PrismicPreview.d.cts.map +1 -1
  99. package/dist/pages/PrismicPreview.d.ts +2 -2
  100. package/dist/pages/PrismicPreview.d.ts.map +1 -1
  101. package/dist/pages/PrismicPreview.js.map +1 -1
  102. package/dist/pages/SliceSimulator.cjs +1 -0
  103. package/dist/pages/SliceSimulator.cjs.map +1 -1
  104. package/dist/pages/SliceSimulator.d.cts +1 -0
  105. package/dist/pages/SliceSimulator.d.cts.map +1 -1
  106. package/dist/pages/SliceSimulator.d.ts +1 -0
  107. package/dist/pages/SliceSimulator.d.ts.map +1 -1
  108. package/dist/pages/SliceSimulator.js.map +1 -1
  109. package/dist/pages/enableAutoPreviews.cjs.map +1 -1
  110. package/dist/pages/enableAutoPreviews.d.cts +2 -2
  111. package/dist/pages/enableAutoPreviews.d.cts.map +1 -1
  112. package/dist/pages/enableAutoPreviews.d.ts +2 -2
  113. package/dist/pages/enableAutoPreviews.d.ts.map +1 -1
  114. package/dist/pages/enableAutoPreviews.js.map +1 -1
  115. package/dist/pages/exitPreview.cjs.map +1 -1
  116. package/dist/pages/exitPreview.d.cts +1 -0
  117. package/dist/pages/exitPreview.d.cts.map +1 -1
  118. package/dist/pages/exitPreview.d.ts +1 -0
  119. package/dist/pages/exitPreview.d.ts.map +1 -1
  120. package/dist/pages/exitPreview.js.map +1 -1
  121. package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
  122. package/dist/pages/redirectToPreviewURL.d.cts +2 -2
  123. package/dist/pages/redirectToPreviewURL.d.cts.map +1 -1
  124. package/dist/pages/redirectToPreviewURL.d.ts +2 -2
  125. package/dist/pages/redirectToPreviewURL.d.ts.map +1 -1
  126. package/dist/pages/redirectToPreviewURL.js.map +1 -1
  127. package/dist/pages/setPreviewData.cjs +1 -0
  128. package/dist/pages/setPreviewData.cjs.map +1 -1
  129. package/dist/pages/setPreviewData.d.cts +5 -1
  130. package/dist/pages/setPreviewData.d.cts.map +1 -1
  131. package/dist/pages/setPreviewData.d.ts +5 -1
  132. package/dist/pages/setPreviewData.d.ts.map +1 -1
  133. package/dist/pages/setPreviewData.js.map +1 -1
  134. package/dist/pages/types.d.cts +1 -0
  135. package/dist/pages/types.d.cts.map +1 -1
  136. package/dist/pages/types.d.ts +1 -0
  137. package/dist/pages/types.d.ts.map +1 -1
  138. package/dist/redirectToPreviewURL.cjs +1 -0
  139. package/dist/redirectToPreviewURL.cjs.map +1 -1
  140. package/dist/redirectToPreviewURL.d.cts +2 -2
  141. package/dist/redirectToPreviewURL.d.cts.map +1 -1
  142. package/dist/redirectToPreviewURL.d.ts +2 -2
  143. package/dist/redirectToPreviewURL.d.ts.map +1 -1
  144. package/dist/redirectToPreviewURL.js.map +1 -1
  145. package/dist/revalidatePrismicPages.cjs +2 -4
  146. package/dist/revalidatePrismicPages.cjs.map +1 -1
  147. package/dist/revalidatePrismicPages.d.cts.map +1 -1
  148. package/dist/revalidatePrismicPages.d.ts.map +1 -1
  149. package/dist/revalidatePrismicPages.js +1 -4
  150. package/dist/revalidatePrismicPages.js.map +1 -1
  151. package/dist/types.d.cts +1 -0
  152. package/dist/types.d.cts.map +1 -1
  153. package/dist/types.d.ts +1 -0
  154. package/dist/types.d.ts.map +1 -1
  155. package/package.json +15 -15
  156. package/src/PrismicNextImage.tsx +5 -5
  157. package/src/PrismicNextLink.tsx +2 -2
  158. package/src/PrismicPreview.tsx +2 -2
@@ -8,9 +8,8 @@ let react = require("react");
8
8
  let react_jsx_runtime = require("react/jsx-runtime");
9
9
  let imgix_url_builder = require("imgix-url-builder");
10
10
  let next_image_js = require("next/image.js");
11
- next_image_js = require_runtime.__toESM(next_image_js, 1);
11
+ next_image_js = require_runtime.__toESM(next_image_js);
12
12
  //#region src/PrismicNextImage.tsx
13
- const ResolvedImage = require_resolveDefaultExport.resolveDefaultExport(next_image_js.default);
14
13
  const castInt = (input) => {
15
14
  if (typeof input === "number" || typeof input === "undefined") return input;
16
15
  else {
@@ -39,9 +38,9 @@ const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage({ field
39
38
  if (typeof fallbackAlt === "string" && fallbackAlt !== "") console.warn(`[PrismicNextImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${require_devMsg.devMsg("alt-must-be-an-empty-string")}`);
40
39
  }
41
40
  if (!_prismicio_client.isFilled.imageThumbnail(field)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: fallback });
42
- const resolvedImgixParams = { ...imgixParams };
43
- for (const x in resolvedImgixParams) if (resolvedImgixParams[x] === null) resolvedImgixParams[x] = void 0;
44
- const src = (0, imgix_url_builder.buildURL)(field.url, resolvedImgixParams);
41
+ const resolvedImgixParams = imgixParams;
42
+ for (const x in imgixParams) if (resolvedImgixParams[x] === null) resolvedImgixParams[x] = void 0;
43
+ const src = (0, imgix_url_builder.buildURL)(field.url, imgixParams);
45
44
  const ar = field.dimensions.width / field.dimensions.height;
46
45
  const castedWidth = castInt(width);
47
46
  const castedHeight = castInt(height);
@@ -51,7 +50,7 @@ const PrismicNextImage = (0, react.forwardRef)(function PrismicNextImage({ field
51
50
  else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
52
51
  const resolvedAlt = alt ?? (field.alt || fallbackAlt);
53
52
  if (process.env.NODE_ENV === "development" && typeof resolvedAlt !== "string") console.error(`[PrismicNextImage] The following image is missing an "alt" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \`alt=""\` or \`fallbackAlt=""\`.`, src);
54
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedImage, {
53
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_resolveDefaultExport.resolveDefaultExport(next_image_js.default), {
55
54
  ref,
56
55
  src,
57
56
  width: fill ? void 0 : resolvedWidth,
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextImage.cjs","names":["resolveDefaultExport","Image","forwardRef","imgixLoader","devMsg","isFilled","buildURL"],"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 ResolvedImage = resolveDefaultExport(Image)\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 resolvedImgixParams) {\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, resolvedImgixParams 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\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,gBAAgBA,6BAAAA,qBAAqBC,cAAAA,OAAK;AAEhD,MAAM,WAAW,UAA2D;CAC3E,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aACjD,OAAO;MACD;EACN,MAAM,SAAS,OAAO,SAAS,KAAK;EAEpC,IAAI,OAAO,MAAM,MAAM,GACtB;OAEA,OAAO;CAET;AACD;;;;;;;;;;;;;;;AAiDA,MAAa,oBAAA,GAETC,MAAAA,WAAAA,CAAoD,SAAS,iBAChE,EACC,OACA,cAAc,CAAC,GACf,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAASC,oBAAAA,aACT,GAAG,aAEJ,KACC;CACD,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC3C,IAAI,OAAO,QAAQ,YAAY,QAAQ,IACtC,QAAQ,KACP,yQAAyQC,eAAAA,OACxQ,6BACD,GACD;EAGD,IAAI,OAAO,gBAAgB,YAAY,gBAAgB,IACtD,QAAQ,KACP,ySAAySA,eAAAA,OACxS,6BACD,GACD;CAEF;CAEA,IAAI,CAACC,kBAAAA,SAAS,eAAe,KAAK,GACjC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAA,UAAG,SAAW,CAAA;CAGtB,MAAM,sBAAsB,EAAE,GAAG,YAAY;CAC7C,KAAK,MAAM,KAAK,qBACf,IAAI,oBAAoB,OAA2C,MAClE,oBAAoB,KAAyC,KAAA;CAI/D,MAAM,OAAA,GAAMC,kBAAAA,SAAAA,CAAS,MAAM,KAAK,mBAAqC;CAErE,MAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;CAErD,MAAM,cAAc,QAAQ,KAAK;CACjC,MAAM,eAAe,QAAQ,MAAM;CAEnC,IAAI,gBAAgB,eAAe,MAAM,WAAW;CACpD,IAAI,iBAAiB,gBAAgB,MAAM,WAAW;CAEtD,IAAI,eAAe,QAAQ,gBAAgB,MAC1C,iBAAiB,cAAc;MACzB,IAAI,eAAe,QAAQ,gBAAgB,MACjD,gBAAgB,eAAe;CAKhC,MAAM,cAAe,QAAQ,MAAM,OAAO;CAE1C,IAAI,QAAQ,IAAI,aAAa,iBAAiB,OAAO,gBAAgB,UACpE,QAAQ,MACP,mNACA,GACD;CAGD,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAD;EACM;EACA;EACL,OAAO,OAAO,KAAA,IAAY;EAC1B,QAAQ,OAAO,KAAA,IAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,KAAA,IAAY;EACtC,GAAI;CACJ,CAAA;AAEH,CAAC"}
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"}
@@ -2,16 +2,16 @@ import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react
2
2
  import { ImageFieldImage } from "@prismicio/client";
3
3
  import { ImgixURLParams } from "imgix-url-builder";
4
4
  import { ImageProps } from "next/image.js";
5
+
5
6
  //#region src/PrismicNextImage.d.ts
6
7
  type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
7
- /** The Prismic Image field or thumbnail to render. */
8
- field: ImageFieldImage | null | undefined;
8
+ /** The Prismic Image field or thumbnail to render. */field: ImageFieldImage | null | undefined;
9
9
  /**
10
10
  * An object of Imgix URL API parameters to transform the image.
11
11
  *
12
12
  * @see https://docs.imgix.com/apis/rendering
13
13
  */
14
- imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null; };
14
+ imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };
15
15
  /**
16
16
  * Declare an image as decorative by providing `alt=""`.
17
17
  *
@@ -24,8 +24,7 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
24
24
  *
25
25
  * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
26
26
  */
27
- fallbackAlt?: "";
28
- /** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */
27
+ fallbackAlt?: ""; /** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */
29
28
  fallback?: React.ReactNode;
30
29
  loader?: ImageProps["loader"] | null;
31
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextImage.d.cts","names":[],"sources":["../src/PrismicNextImage.tsx"],"mappings":";;;;;KA+BY,wBAAwB,KAAK;;EAExC,OAAO;;;;;;EAOP,iBAAiB,WAAW,iBAAiB,eAAe;;;;;;EAO5D;;;;;;;EAQA;;EAGA,WAAW,MAAM;EAEjB,SAAS;;;;;;;;;;;;;;;;cAkBG,kBAAkB,0BAC9B,gBAAgB,yBAAyB,cAAc"}
1
+ {"version":3,"file":"PrismicNextImage.d.cts","names":[],"sources":["../src/PrismicNextImage.tsx"],"mappings":";;;;;;KA6BY,qBAAA,GAAwB,IAAA,CAAK,UAAA;wDAExC,KAAA,EAAO,eAAA;EAFyB;;;;;EAShC,WAAA,iBAA4B,cAAA,GAAiB,cAAA,CAAe,CAAA;EAkBjD;;;;;EAXX,GAAA;EAdA;;;;;;EAsBA,WAAA,OARA;EAWA,QAAA,GAAW,KAAA,CAAM,SAAA;EAEjB,MAAA,GAAS,UAAA;AAAA;;;;;;AAkBV;;;;;;;;;cAAa,gBAAA,EAAkB,yBAAA,CAC9B,eAAA,CAAgB,qBAAA,IAAyB,aAAA,CAAc,gBAAA"}
@@ -2,16 +2,16 @@ import { ImageFieldImage } from "@prismicio/client";
2
2
  import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
3
3
  import { ImgixURLParams } from "imgix-url-builder";
4
4
  import { ImageProps } from "next/image.js";
5
+
5
6
  //#region src/PrismicNextImage.d.ts
6
7
  type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
7
- /** The Prismic Image field or thumbnail to render. */
8
- field: ImageFieldImage | null | undefined;
8
+ /** The Prismic Image field or thumbnail to render. */field: ImageFieldImage | null | undefined;
9
9
  /**
10
10
  * An object of Imgix URL API parameters to transform the image.
11
11
  *
12
12
  * @see https://docs.imgix.com/apis/rendering
13
13
  */
14
- imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null; };
14
+ imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };
15
15
  /**
16
16
  * Declare an image as decorative by providing `alt=""`.
17
17
  *
@@ -24,8 +24,7 @@ type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
24
24
  *
25
25
  * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
26
26
  */
27
- fallbackAlt?: "";
28
- /** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */
27
+ fallbackAlt?: ""; /** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */
29
28
  fallback?: React.ReactNode;
30
29
  loader?: ImageProps["loader"] | null;
31
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextImage.d.ts","names":[],"sources":["../src/PrismicNextImage.tsx"],"mappings":";;;;;KA+BY,wBAAwB,KAAK;;EAExC,OAAO;;;;;;EAOP,iBAAiB,WAAW,iBAAiB,eAAe;;;;;;EAO5D;;;;;;;EAQA;;EAGA,WAAW,MAAM;EAEjB,SAAS;;;;;;;;;;;;;;;;cAkBG,kBAAkB,0BAC9B,gBAAgB,yBAAyB,cAAc"}
1
+ {"version":3,"file":"PrismicNextImage.d.ts","names":[],"sources":["../src/PrismicNextImage.tsx"],"mappings":";;;;;;KA6BY,qBAAA,GAAwB,IAAA,CAAK,UAAA;wDAExC,KAAA,EAAO,eAAA;EAFyB;;;;;EAShC,WAAA,iBAA4B,cAAA,GAAiB,cAAA,CAAe,CAAA;EAkBjD;;;;;EAXX,GAAA;EAdA;;;;;;EAsBA,WAAA,OARA;EAWA,QAAA,GAAW,KAAA,CAAM,SAAA;EAEjB,MAAA,GAAS,UAAA;AAAA;;;;;;AAkBV;;;;;;;;;cAAa,gBAAA,EAAkB,yBAAA,CAC9B,eAAA,CAAgB,qBAAA,IAAyB,aAAA,CAAc,gBAAA"}
@@ -8,7 +8,6 @@ import { Fragment, jsx } from "react/jsx-runtime";
8
8
  import { buildURL } from "imgix-url-builder";
9
9
  import Image from "next/image.js";
10
10
  //#region src/PrismicNextImage.tsx
11
- const ResolvedImage = resolveDefaultExport(Image);
12
11
  const castInt = (input) => {
13
12
  if (typeof input === "number" || typeof input === "undefined") return input;
14
13
  else {
@@ -37,9 +36,9 @@ const PrismicNextImage = forwardRef(function PrismicNextImage({ field, imgixPara
37
36
  if (typeof fallbackAlt === "string" && fallbackAlt !== "") console.warn(`[PrismicNextImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
38
37
  }
39
38
  if (!isFilled.imageThumbnail(field)) return /* @__PURE__ */ jsx(Fragment, { children: fallback });
40
- const resolvedImgixParams = { ...imgixParams };
41
- for (const x in resolvedImgixParams) if (resolvedImgixParams[x] === null) resolvedImgixParams[x] = void 0;
42
- const src = buildURL(field.url, resolvedImgixParams);
39
+ const resolvedImgixParams = imgixParams;
40
+ for (const x in imgixParams) if (resolvedImgixParams[x] === null) resolvedImgixParams[x] = void 0;
41
+ const src = buildURL(field.url, imgixParams);
43
42
  const ar = field.dimensions.width / field.dimensions.height;
44
43
  const castedWidth = castInt(width);
45
44
  const castedHeight = castInt(height);
@@ -49,7 +48,7 @@ const PrismicNextImage = forwardRef(function PrismicNextImage({ field, imgixPara
49
48
  else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
50
49
  const resolvedAlt = alt ?? (field.alt || fallbackAlt);
51
50
  if (process.env.NODE_ENV === "development" && typeof resolvedAlt !== "string") console.error(`[PrismicNextImage] The following image is missing an "alt" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \`alt=""\` or \`fallbackAlt=""\`.`, src);
52
- return /* @__PURE__ */ jsx(ResolvedImage, {
51
+ return /* @__PURE__ */ jsx(resolveDefaultExport(Image), {
53
52
  ref,
54
53
  src,
55
54
  width: fill ? void 0 : resolvedWidth,
@@ -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 ResolvedImage = resolveDefaultExport(Image)\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 resolvedImgixParams) {\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, resolvedImgixParams 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\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,gBAAgB,qBAAqB,KAAK;AAEhD,MAAM,WAAW,UAA2D;CAC3E,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aACjD,OAAO;MACD;EACN,MAAM,SAAS,OAAO,SAAS,KAAK;EAEpC,IAAI,OAAO,MAAM,MAAM,GACtB;OAEA,OAAO;CAET;AACD;;;;;;;;;;;;;;;AAiDA,MAAa,mBAET,WAAoD,SAAS,iBAChE,EACC,OACA,cAAc,CAAC,GACf,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAAS,aACT,GAAG,aAEJ,KACC;CACD,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC3C,IAAI,OAAO,QAAQ,YAAY,QAAQ,IACtC,QAAQ,KACP,yQAAyQ,OACxQ,6BACD,GACD;EAGD,IAAI,OAAO,gBAAgB,YAAY,gBAAgB,IACtD,QAAQ,KACP,ySAAyS,OACxS,6BACD,GACD;CAEF;CAEA,IAAI,CAAC,SAAS,eAAe,KAAK,GACjC,OAAO,oBAAA,UAAA,EAAA,UAAG,SAAW,CAAA;CAGtB,MAAM,sBAAsB,EAAE,GAAG,YAAY;CAC7C,KAAK,MAAM,KAAK,qBACf,IAAI,oBAAoB,OAA2C,MAClE,oBAAoB,KAAyC,KAAA;CAI/D,MAAM,MAAM,SAAS,MAAM,KAAK,mBAAqC;CAErE,MAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;CAErD,MAAM,cAAc,QAAQ,KAAK;CACjC,MAAM,eAAe,QAAQ,MAAM;CAEnC,IAAI,gBAAgB,eAAe,MAAM,WAAW;CACpD,IAAI,iBAAiB,gBAAgB,MAAM,WAAW;CAEtD,IAAI,eAAe,QAAQ,gBAAgB,MAC1C,iBAAiB,cAAc;MACzB,IAAI,eAAe,QAAQ,gBAAgB,MACjD,gBAAgB,eAAe;CAKhC,MAAM,cAAe,QAAQ,MAAM,OAAO;CAE1C,IAAI,QAAQ,IAAI,aAAa,iBAAiB,OAAO,gBAAgB,UACpE,QAAQ,MACP,mNACA,GACD;CAGD,OACC,oBAAC,eAAD;EACM;EACA;EACL,OAAO,OAAO,KAAA,IAAY;EAC1B,QAAQ,OAAO,KAAA,IAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,KAAA,IAAY;EACtC,GAAI;CACJ,CAAA;AAEH,CAAC"}
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"}
@@ -4,9 +4,8 @@ let _prismicio_client = require("@prismicio/client");
4
4
  let react = require("react");
5
5
  let react_jsx_runtime = require("react/jsx-runtime");
6
6
  let next_link_js = require("next/link.js");
7
- next_link_js = require_runtime.__toESM(next_link_js, 1);
7
+ next_link_js = require_runtime.__toESM(next_link_js);
8
8
  //#region src/PrismicNextLink.tsx
9
- const ResolvedLink = require_resolveDefaultExport.resolveDefaultExport(next_link_js.default);
10
9
  const PrismicNextLink = (0, react.forwardRef)(function PrismicNextLink(props, ref) {
11
10
  const { field, document, linkResolver, children, ...restProps } = props;
12
11
  const { href: computedHref, rel: computedRel, ...attrs } = (0, _prismicio_client.asLinkAttrs)(field ?? document, {
@@ -16,7 +15,7 @@ const PrismicNextLink = (0, react.forwardRef)(function PrismicNextLink(props, re
16
15
  const href = ("href" in restProps ? restProps.href : computedHref) || "";
17
16
  let rel = computedRel;
18
17
  if ("rel" in restProps && typeof restProps.rel !== "function") rel = restProps.rel;
19
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedLink, {
18
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_resolveDefaultExport.resolveDefaultExport(next_link_js.default), {
20
19
  ref,
21
20
  ...attrs,
22
21
  ...restProps,
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextLink.cjs","names":["resolveDefaultExport","Link","forwardRef","asLinkAttrs"],"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\nconst ResolvedLink = resolveDefaultExport(Link)\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\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":";;;;;;;;AAaA,MAAM,eAAeA,6BAAAA,qBAAqBC,aAAAA,OAAI;AA0B9C,MAAa,mBAAA,GAAkBC,MAAAA,WAAAA,CAC9B,SAAS,gBAAgB,OAAO,KAAK;CACpC,MAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;CAClE,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,WAAA,GACAC,kBAAAA,YAAAA,CAAY,SAAS,UAAU;EAClC;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM,KAAA;CAC5D,CAAC;CAED,MAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;CAEtE,IAAI,MAAM;CACV,IAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAClD,MAAM,UAAU;CAGjB,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;EAAmB;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;EACjE,UAAA,cAAc,QAAQ,WAAW,OAAO;CAC5B,CAAA;AAEhB,CACD"}
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,6 +1,9 @@
1
+ import * as _$react from "react";
1
2
  import { ComponentProps } from "react";
2
- import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
3
+ import * as _$next_link0 from "next/link.js";
3
4
  import Link from "next/link.js";
5
+ import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
6
+
4
7
  //#region src/PrismicNextLink.d.ts
5
8
  type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
6
9
  linkResolver?: LinkResolverFunction;
@@ -18,34 +21,34 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
18
21
  document?: never;
19
22
  href: ComponentProps<typeof Link>["href"];
20
23
  });
21
- declare const PrismicNextLink: import("react").ForwardRefExoticComponent<(Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
24
+ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
22
25
  children?: React.ReactNode | undefined;
23
- } & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
26
+ } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
24
27
  linkResolver?: LinkResolverFunction;
25
28
  rel?: string | AsLinkAttrsConfig["rel"];
26
29
  } & {
27
30
  field: LinkField | null | undefined;
28
31
  document?: never;
29
32
  href?: never;
30
- }, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
33
+ }, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
31
34
  children?: React.ReactNode | undefined;
32
- } & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
35
+ } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
33
36
  linkResolver?: LinkResolverFunction;
34
37
  rel?: string | AsLinkAttrsConfig["rel"];
35
38
  } & {
36
39
  field?: never;
37
40
  document: PrismicDocument | null | undefined;
38
41
  href?: never;
39
- }, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
42
+ }, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
40
43
  children?: React.ReactNode | undefined;
41
- } & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
44
+ } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
42
45
  linkResolver?: LinkResolverFunction;
43
46
  rel?: string | AsLinkAttrsConfig["rel"];
44
47
  } & {
45
48
  field?: never;
46
49
  document?: never;
47
50
  href: ComponentProps<typeof Link>["href"];
48
- }, "ref">) & import("react").RefAttributes<HTMLAnchorElement>>;
51
+ }, "ref">) & _$react.RefAttributes<HTMLAnchorElement>>;
49
52
  //#endregion
50
53
  export { PrismicNextLink, PrismicNextLinkProps };
51
54
  //# sourceMappingURL=PrismicNextLink.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextLink.d.cts","names":[],"sources":["../src/PrismicNextLink.tsx"],"mappings":";;;;KAeY,uBAAuB,KAClC,sBAAsB;EAGtB,eAAe;EACf,eAAe;;EAGZ,OAAO;EACP;EACA;;EAGA;EACA,UAAU;EACV;;EAGA;EACA;EACA,MAAM,sBAAsB;;cAInB,iCAAe,2BAAA,KAAA,KAAA,qBAAA,qBAAA,8CAAA,sCAAA;;;EApBZ,eAAA;EACT,eAAS;;EAGL,OAAA;EACI;EACJ;;;;;;;EAGC;EACE,UAAA;EACH;;;;;;;EAGC;EACG;EACL,MAAA,sBAAsB;6BA6B/B,cAAA"}
1
+ {"version":3,"file":"PrismicNextLink.d.cts","names":[],"sources":["../src/PrismicNextLink.tsx"],"mappings":";;;;;;;KAaY,oBAAA,GAAuB,IAAA,CAClC,cAAA,QAAsB,IAAA;EAGtB,YAAA,GAAe,oBAAA;EACf,GAAA,YAAe,iBAAA;AAAA;EAGZ,KAAA,EAAO,SAAA;EACP,QAAA;EACA,IAAA;AAAA;EAGA,KAAA;EACA,QAAA,EAAU,eAAA;EACV,IAAA;AAAA;EAGA,KAAA;EACA,QAAA;EACA,IAAA,EAAM,cAAA,QAAsB,IAAA;AAAA;AAAA,cAInB,eAAA,UAAe,yBAAA,EAAA,IAAA,CAAA,IAAA,CAAA,IAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,iBAAA,SAAA,YAAA,CAAA,SAAA,SAAA,YAAA,CAAA,SAAA;;;iBApBZ,oBAAA;iBACA,iBAAA;AAAA;SAGL,SAAA;;;;;;iBAJK,oBAAA;iBACA,iBAAA;AAAA;;YASF,eAAA;;;;;iBAVE,oBAAA;iBACA,iBAAA;AAAA;;;QAeN,cAAA,QAAsB,IAAA;AAAA"}
@@ -1,6 +1,9 @@
1
1
  import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
2
+ import * as _$react from "react";
2
3
  import { ComponentProps } from "react";
4
+ import * as _$next_link0 from "next/link.js";
3
5
  import Link from "next/link.js";
6
+
4
7
  //#region src/PrismicNextLink.d.ts
5
8
  type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
6
9
  linkResolver?: LinkResolverFunction;
@@ -18,34 +21,34 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
18
21
  document?: never;
19
22
  href: ComponentProps<typeof Link>["href"];
20
23
  });
21
- declare const PrismicNextLink: import("react").ForwardRefExoticComponent<(Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
24
+ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
22
25
  children?: React.ReactNode | undefined;
23
- } & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
26
+ } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
24
27
  linkResolver?: LinkResolverFunction;
25
28
  rel?: string | AsLinkAttrsConfig["rel"];
26
29
  } & {
27
30
  field: LinkField | null | undefined;
28
31
  document?: never;
29
32
  href?: never;
30
- }, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
33
+ }, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
31
34
  children?: React.ReactNode | undefined;
32
- } & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
35
+ } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
33
36
  linkResolver?: LinkResolverFunction;
34
37
  rel?: string | AsLinkAttrsConfig["rel"];
35
38
  } & {
36
39
  field?: never;
37
40
  document: PrismicDocument | null | undefined;
38
41
  href?: never;
39
- }, "ref"> | Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof import("next/link").LinkProps<any>> & import("next/link").LinkProps<any> & {
42
+ }, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
40
43
  children?: React.ReactNode | undefined;
41
- } & import("react").RefAttributes<HTMLAnchorElement>, "document" | "field" | "href" | "rel"> & {
44
+ } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
42
45
  linkResolver?: LinkResolverFunction;
43
46
  rel?: string | AsLinkAttrsConfig["rel"];
44
47
  } & {
45
48
  field?: never;
46
49
  document?: never;
47
50
  href: ComponentProps<typeof Link>["href"];
48
- }, "ref">) & import("react").RefAttributes<HTMLAnchorElement>>;
51
+ }, "ref">) & _$react.RefAttributes<HTMLAnchorElement>>;
49
52
  //#endregion
50
53
  export { PrismicNextLink, PrismicNextLinkProps };
51
54
  //# sourceMappingURL=PrismicNextLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextLink.d.ts","names":[],"sources":["../src/PrismicNextLink.tsx"],"mappings":";;;;KAeY,uBAAuB,KAClC,sBAAsB;EAGtB,eAAe;EACf,eAAe;;EAGZ,OAAO;EACP;EACA;;EAGA;EACA,UAAU;EACV;;EAGA;EACA;EACA,MAAM,sBAAsB;;cAInB,iCAAe,2BAAA,KAAA,KAAA,qBAAA,qBAAA,8CAAA,sCAAA;;;EApBZ,eAAA;EACT,eAAS;;EAGL,OAAA;EACI;EACJ;;;;;;;EAGC;EACE,UAAA;EACH;;;;;;;EAGC;EACG;EACL,MAAA,sBAAsB;6BA6B/B,cAAA"}
1
+ {"version":3,"file":"PrismicNextLink.d.ts","names":[],"sources":["../src/PrismicNextLink.tsx"],"mappings":";;;;;;;KAaY,oBAAA,GAAuB,IAAA,CAClC,cAAA,QAAsB,IAAA;EAGtB,YAAA,GAAe,oBAAA;EACf,GAAA,YAAe,iBAAA;AAAA;EAGZ,KAAA,EAAO,SAAA;EACP,QAAA;EACA,IAAA;AAAA;EAGA,KAAA;EACA,QAAA,EAAU,eAAA;EACV,IAAA;AAAA;EAGA,KAAA;EACA,QAAA;EACA,IAAA,EAAM,cAAA,QAAsB,IAAA;AAAA;AAAA,cAInB,eAAA,UAAe,yBAAA,EAAA,IAAA,CAAA,IAAA,CAAA,IAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,iBAAA,SAAA,YAAA,CAAA,SAAA,SAAA,YAAA,CAAA,SAAA;;;iBApBZ,oBAAA;iBACA,iBAAA;AAAA;SAGL,SAAA;;;;;;iBAJK,oBAAA;iBACA,iBAAA;AAAA;;YASF,eAAA;;;;;iBAVE,oBAAA;iBACA,iBAAA;AAAA;;;QAeN,cAAA,QAAsB,IAAA;AAAA"}
@@ -4,7 +4,6 @@ import { forwardRef } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  import Link from "next/link.js";
6
6
  //#region src/PrismicNextLink.tsx
7
- const ResolvedLink = resolveDefaultExport(Link);
8
7
  const PrismicNextLink = forwardRef(function PrismicNextLink(props, ref) {
9
8
  const { field, document, linkResolver, children, ...restProps } = props;
10
9
  const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs(field ?? document, {
@@ -14,7 +13,7 @@ const PrismicNextLink = forwardRef(function PrismicNextLink(props, ref) {
14
13
  const href = ("href" in restProps ? restProps.href : computedHref) || "";
15
14
  let rel = computedRel;
16
15
  if ("rel" in restProps && typeof restProps.rel !== "function") rel = restProps.rel;
17
- return /* @__PURE__ */ jsx(ResolvedLink, {
16
+ return /* @__PURE__ */ jsx(resolveDefaultExport(Link), {
18
17
  ref,
19
18
  ...attrs,
20
19
  ...restProps,
@@ -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\nconst ResolvedLink = resolveDefaultExport(Link)\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\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":";;;;;;AAaA,MAAM,eAAe,qBAAqB,IAAI;AA0B9C,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;CAC5D,CAAC;CAED,MAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;CAEtE,IAAI,MAAM;CACV,IAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAClD,MAAM,UAAU;CAGjB,OACC,oBAAC,cAAD;EAAmB;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;EACjE,UAAA,cAAc,QAAQ,WAAW,OAAO;CAC5B,CAAA;AAEhB,CACD"}
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"}
@@ -3,10 +3,9 @@ const require_resolveDefaultExport = require("./lib/resolveDefaultExport.cjs");
3
3
  const require_PrismicPreviewClient = require("./PrismicPreviewClient.cjs");
4
4
  let _prismicio_client = require("@prismicio/client");
5
5
  let next_script_js = require("next/script.js");
6
- next_script_js = require_runtime.__toESM(next_script_js, 1);
6
+ next_script_js = require_runtime.__toESM(next_script_js);
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
8
  //#region src/PrismicPreview.tsx
9
- const ResolvedScript = require_resolveDefaultExport.resolveDefaultExport(next_script_js.default);
10
9
  /**
11
10
  * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
12
11
  * send events to the browser, such as on preview updates and exiting, this component will
@@ -20,6 +19,7 @@ const PrismicPreview = async (props) => {
20
19
  const { draftMode } = await import("next/headers.js");
21
20
  const toolbarSrc = (0, _prismicio_client.getToolbarSrc)(repositoryName);
22
21
  const isDraftMode = (await draftMode()).isEnabled;
22
+ const ResolvedScript = require_resolveDefaultExport.resolveDefaultExport(next_script_js.default);
23
23
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
24
24
  children,
25
25
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicPreviewClient.PrismicPreviewClient, {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.cjs","names":["resolveDefaultExport","Script","getToolbarSrc","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\nconst ResolvedScript = resolveDefaultExport(Script)\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\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":";;;;;;;;AAOA,MAAM,iBAAiBA,6BAAAA,qBAAqBC,eAAAA,OAAM;;;;;;;;;AAkClD,MAAa,iBAA0C,OAAO,UAAU;CACvE,MAAM,EAAE,gBAAgB,UAAU,GAAG,eAAe;CAKpD,MAAM,EAAE,cAAc,MAAM,OAAO;CAEnC,MAAM,cAAA,GAAaC,kBAAAA,cAAAA,CAAc,cAAc;CAC/C,MAAM,eAAe,MAAM,UAAU,EAAA,CAAG;CAExC,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;EACE;EACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAAA,sBAAD;GACiB;GACH;GACb,GAAI;EACJ,CAAA;EACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;EAAc,CAAA;CACvD,EAAA,CAAA;AAEJ"}
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,4 +1,5 @@
1
1
  import { FC, ReactNode } from "react";
2
+
2
3
  //#region src/PrismicPreview.d.ts
3
4
  /** Props for `<PrismicPreview>`. */
4
5
  type PrismicPreviewProps = {
@@ -16,8 +17,7 @@ type PrismicPreviewProps = {
16
17
  * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
17
18
  * fetched on preview exit events.
18
19
  */
19
- exitPreviewURL?: string;
20
- /** Children to render adjacent to the Prismic Toolbar. */
20
+ exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
21
21
  children?: ReactNode;
22
22
  };
23
23
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.d.cts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":";;;KAUY;;;;;EAKX;;;;;EAMA;;;;;EAMA;;EAGA,WAAW;;;;;;;;;;cAWC,gBAAgB,GAAG"}
1
+ {"version":3,"file":"PrismicPreview.d.cts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":";;;;KAQY,mBAAA;EAAA;;;;EAKX,cAAA;EAMA;;;;EAAA,gBAAA;EASoB;AAWrB;;;EAdC,cAAA,WAckD;EAXlD,QAAA,GAAW,SAAA;AAAA;;;;;;;;;cAWC,cAAA,EAAgB,EAAA,CAAG,mBAAA"}
@@ -1,4 +1,5 @@
1
1
  import { FC, ReactNode } from "react";
2
+
2
3
  //#region src/PrismicPreview.d.ts
3
4
  /** Props for `<PrismicPreview>`. */
4
5
  type PrismicPreviewProps = {
@@ -16,8 +17,7 @@ type PrismicPreviewProps = {
16
17
  * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
17
18
  * fetched on preview exit events.
18
19
  */
19
- exitPreviewURL?: string;
20
- /** Children to render adjacent to the Prismic Toolbar. */
20
+ exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
21
21
  children?: ReactNode;
22
22
  };
23
23
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.d.ts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":";;;KAUY;;;;;EAKX;;;;;EAMA;;;;;EAMA;;EAGA,WAAW;;;;;;;;;;cAWC,gBAAgB,GAAG"}
1
+ {"version":3,"file":"PrismicPreview.d.ts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":";;;;KAQY,mBAAA;EAAA;;;;EAKX,cAAA;EAMA;;;;EAAA,gBAAA;EASoB;AAWrB;;;EAdC,cAAA,WAckD;EAXlD,QAAA,GAAW,SAAA;AAAA;;;;;;;;;cAWC,cAAA,EAAgB,EAAA,CAAG,mBAAA"}
@@ -4,7 +4,6 @@ import { getToolbarSrc } from "@prismicio/client";
4
4
  import Script from "next/script.js";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/PrismicPreview.tsx
7
- const ResolvedScript = resolveDefaultExport(Script);
8
7
  /**
9
8
  * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
10
9
  * send events to the browser, such as on preview updates and exiting, this component will
@@ -18,6 +17,7 @@ const PrismicPreview = async (props) => {
18
17
  const { draftMode } = await import("next/headers.js");
19
18
  const toolbarSrc = getToolbarSrc(repositoryName);
20
19
  const isDraftMode = (await draftMode()).isEnabled;
20
+ const ResolvedScript = resolveDefaultExport(Script);
21
21
  return /* @__PURE__ */ jsxs(Fragment, { children: [
22
22
  children,
23
23
  /* @__PURE__ */ jsx(PrismicPreviewClient, {
@@ -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\nconst ResolvedScript = resolveDefaultExport(Script)\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\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":";;;;;;AAOA,MAAM,iBAAiB,qBAAqB,MAAM;;;;;;;;;AAkClD,MAAa,iBAA0C,OAAO,UAAU;CACvE,MAAM,EAAE,gBAAgB,UAAU,GAAG,eAAe;CAKpD,MAAM,EAAE,cAAc,MAAM,OAAO;CAEnC,MAAM,aAAa,cAAc,cAAc;CAC/C,MAAM,eAAe,MAAM,UAAU,EAAA,CAAG;CAExC,OACC,qBAAA,UAAA,EAAA,UAAA;EACE;EACD,oBAAC,sBAAD;GACiB;GACH;GACb,GAAI;EACJ,CAAA;EACD,oBAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;EAAc,CAAA;CACvD,EAAA,CAAA;AAEJ"}
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,4 +1,5 @@
1
1
  "use client";
2
+ require("./_virtual/_rolldown/runtime.cjs");
2
3
  let _prismicio_client = require("@prismicio/client");
3
4
  let next_navigation_js = require("next/navigation.js");
4
5
  let react = require("react");
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreviewClient.cjs","names":["useRouter","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(\"prismicPreviewStart\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t})\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 = decodeURIComponent(getPrismicPreviewCookie(window.document.cookie) ?? \"\")\n\t\t// A raw ref, or the toolbar's JSON cookie with a preview for this repository.\n\t\tconst hasActiveCookie =\n\t\t\tcookie !== \"\" &&\n\t\t\t(!cookie.startsWith(\"{\") || cookie.includes(`\"${repositoryName}.prismic.io\"`))\n\n\t\t// Start previews that did not go through `updatePreviewURL`, like\n\t\t// share links, and restart after a preview ended in another tab.\n\t\tif (hasActiveCookie && !isDraftMode) {\n\t\t\tstart()\n\t\t}\n\n\t\tfunction start() {\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and 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\t// A soft refresh cannot leave Next.js's not-found boundary, which renders this tag.\n\t\t\t\t\tif (document.querySelector('meta[name=\"robots\"][content=\"noindex\"]')) {\n\t\t\t\t\t\twindow.location.reload()\n\t\t\t\t\t} else {\n\t\t\t\t\t\trefresh()\n\t\t\t\t\t}\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\tif (isDraftMode) {\n\t\t\t\trefresh()\n\t\t\t} else {\n\t\t\t\tstart()\n\t\t\t}\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,GAAYA,mBAAAA,UAAAA,CAAU;CAE9B,CAAA,GAAA,MAAA,UAAA,OAAgB;EACf,MAAM,aAAa,IAAI,gBAAgB;EAEvC,OAAO,iBAAiB,uBAAuB,UAAU,EACxD,QAAQ,WAAW,OACpB,CAAC;EACD,OAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,OACpB,CAAC;EACD,OAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,OACpB,CAAC;EAED,MAAM,SAAS,mBAAmB,wBAAwB,OAAO,SAAS,MAAM,KAAK,EAAE;EAQvF,IALC,WAAW,OACV,CAAC,OAAO,WAAW,GAAG,KAAK,OAAO,SAAS,IAAI,eAAe,aAAa,MAItD,CAAC,aACvB,MAAM;EAGP,SAAS,QAAQ;GAKhB,WACE,MAAM,kBAAkB;IACxB,UAAU;IACV,QAAQ,WAAW;GACpB,CAAC,CAAC,CACD,MAAM,QAAQ;IACd,IAAI,IAAI,SAAS,kBAAkB;KAClC,QAAQ,MACP,yDAAyD,iBAAiB,kBAC3E;KAEA;IACD;IAGA,IAAI,SAAS,cAAc,4CAAwC,GAClE,OAAO,SAAS,OAAO;SAEvB,QAAQ;GAEV,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;EACH;EAEA,SAAS,SAAS,OAAc;GAC/B,MAAM,eAAe;GACrB,IAAI,aACH,QAAQ;QAER,MAAM;EAER;EAEA,SAAS,MAAM,OAAc;GAC5B,MAAM,eAAe;GACrB,WACE,MAAM,gBAAgB,EAAE,QAAQ,WAAW,OAAO,CAAC,CAAC,CACpD,MAAM,QAAQ;IACd,IAAI,CAAC,IAAI,IAAI;KACZ,QAAQ,MACP,6DAA6D,eAAe,+BAC7E;KAEA;IACD;IAEA,QAAQ;GACT,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;EACH;EAEA,aAAa,WAAW,MAAM;CAC/B,GAAG;EAAC;EAAgB;EAAa;EAAkB;EAAgB;CAAO,CAAC;CAE3E,OAAO;AACR;;;;;;;AAQA,SAAS,wBAAwB,WAAuC;CACvE,SAAS,UAAU,OAAuB;EACzC,OAAO,MAAM,QAAQ,QAAQ,GAAG;CACjC;CAEA,MAAM,UAAU,UAAU,MAAM,IAAI;CAEpC,IAAI;CAEJ,KAAK,MAAM,UAAU,SAAS;EAC7B,MAAM,QAAQ,OAAO,MAAM,GAAG;EAG9B,IAFa,UAAU,MAAM,EAAE,CAAC,CAAC,QAAQ,QAAQ,GAE1C,MAAMC,kBAAAA,OAAc,SAAS;GACnC,QAAQ,UAAU,MAAM,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;GAC1C;EACD;CACD;CAEA,OAAO;AACR"}
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(\"prismicPreviewStart\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t})\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 = decodeURIComponent(getPrismicPreviewCookie(window.document.cookie) ?? \"\")\n\t\t// A raw ref, or the toolbar's JSON cookie with a preview for this repository.\n\t\tconst hasActiveCookie =\n\t\t\tcookie !== \"\" &&\n\t\t\t(!cookie.startsWith(\"{\") || cookie.includes(`\"${repositoryName}.prismic.io\"`))\n\n\t\t// Start previews that did not go through `updatePreviewURL`, like\n\t\t// share links, and restart after a preview ended in another tab.\n\t\tif (hasActiveCookie && !isDraftMode) {\n\t\t\tstart()\n\t\t}\n\n\t\tfunction start() {\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and 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\t// A soft refresh cannot leave Next.js's not-found boundary, which renders this tag.\n\t\t\t\t\tif (document.querySelector('meta[name=\"robots\"][content=\"noindex\"]')) {\n\t\t\t\t\t\twindow.location.reload()\n\t\t\t\t\t} else {\n\t\t\t\t\t\trefresh()\n\t\t\t\t\t}\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\tif (isDraftMode) {\n\t\t\t\trefresh()\n\t\t\t} else {\n\t\t\t\tstart()\n\t\t\t}\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,mBAAA,YAAuB;AAE/B,EAAA,GAAA,MAAA,iBAAgB;EACf,MAAM,aAAa,IAAI,iBAAiB;AAExC,SAAO,iBAAiB,uBAAuB,UAAU,EACxD,QAAQ,WAAW,QACnB,CAAC;AACF,SAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,QACnB,CAAC;AACF,SAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,QACnB,CAAC;EAEF,MAAM,SAAS,mBAAmB,wBAAwB,OAAO,SAAS,OAAO,IAAI,GAAG;AAQxF,MALC,WAAW,OACV,CAAC,OAAO,WAAW,IAAI,IAAI,OAAO,SAAS,IAAI,eAAe,cAAc,KAIvD,CAAC,YACvB,QAAO;EAGR,SAAS,QAAQ;AAKhB,cACE,MAAM,kBAAkB;IACxB,UAAU;IACV,QAAQ,WAAW;IACnB,CAAC,CACD,MAAM,QAAQ;AACd,QAAI,IAAI,SAAS,kBAAkB;AAClC,aAAQ,MACP,yDAAyD,iBAAiB,mBAC1E;AAED;;AAID,QAAI,SAAS,cAAc,6CAAyC,CACnE,QAAO,SAAS,QAAQ;QAExB,UAAS;KAET,CACD,YAAY,GAEX;;EAGJ,SAAS,SAAS,OAAc;AAC/B,SAAM,gBAAgB;AACtB,OAAI,YACH,UAAS;OAET,QAAO;;EAIT,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"}