@prismicio/next 1.1.0-alpha.0 → 1.1.0-alpha.2

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 (108) hide show
  1. package/dist/PrismicNextImage.cjs +2 -19
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.js +2 -2
  4. package/dist/PrismicNextLink.cjs +3 -4
  5. package/dist/PrismicNextLink.cjs.map +1 -1
  6. package/dist/PrismicNextLink.d.ts +16 -16
  7. package/dist/PrismicNextLink.js +3 -3
  8. package/dist/PrismicNextLink.js.map +1 -1
  9. package/dist/PrismicPreview.cjs +5 -74
  10. package/dist/PrismicPreview.cjs.map +1 -1
  11. package/dist/PrismicPreview.d.ts +8 -11
  12. package/dist/PrismicPreview.js +5 -57
  13. package/dist/PrismicPreview.js.map +1 -1
  14. package/dist/PrismicPreviewClient.cjs +85 -0
  15. package/dist/PrismicPreviewClient.cjs.map +1 -0
  16. package/dist/PrismicPreviewClient.d.ts +4 -0
  17. package/dist/PrismicPreviewClient.js +85 -0
  18. package/dist/PrismicPreviewClient.js.map +1 -0
  19. package/dist/_node_modules/@prismicio/client/dist/cookie.cjs +5 -0
  20. package/dist/_node_modules/@prismicio/client/dist/cookie.cjs.map +1 -0
  21. package/dist/_node_modules/@prismicio/client/dist/cookie.js +5 -0
  22. package/dist/_node_modules/@prismicio/client/dist/cookie.js.map +1 -0
  23. package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs +19 -0
  24. package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs.map +1 -0
  25. package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js +19 -0
  26. package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js.map +1 -0
  27. package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs +13 -0
  28. package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs.map +1 -0
  29. package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js +13 -0
  30. package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js.map +1 -0
  31. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs +38 -0
  32. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs.map +1 -0
  33. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js +38 -0
  34. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js.map +1 -0
  35. package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs +28 -0
  36. package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs.map +1 -0
  37. package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js +28 -0
  38. package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js.map +1 -0
  39. package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs +26 -0
  40. package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs.map +1 -0
  41. package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js +26 -0
  42. package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js.map +1 -0
  43. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs +14 -0
  44. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs.map +1 -0
  45. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js +14 -0
  46. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js.map +1 -0
  47. package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs +7 -0
  48. package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs.map +1 -0
  49. package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js +7 -0
  50. package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js.map +1 -0
  51. package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs +9 -0
  52. package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs.map +1 -0
  53. package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js +9 -0
  54. package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js.map +1 -0
  55. package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs +10 -0
  56. package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs.map +1 -0
  57. package/dist/_node_modules/@prismicio/client/dist/types/value/link.js +10 -0
  58. package/dist/_node_modules/@prismicio/client/dist/types/value/link.js.map +1 -0
  59. package/dist/enableAutoPreviews.cjs +12 -6
  60. package/dist/enableAutoPreviews.cjs.map +1 -1
  61. package/dist/enableAutoPreviews.d.ts +11 -12
  62. package/dist/enableAutoPreviews.js +12 -6
  63. package/dist/enableAutoPreviews.js.map +1 -1
  64. package/dist/exitPreview.cjs +1 -1
  65. package/dist/exitPreview.cjs.map +1 -1
  66. package/dist/exitPreview.d.ts +11 -16
  67. package/dist/exitPreview.js +1 -1
  68. package/dist/exitPreview.js.map +1 -1
  69. package/dist/lib/getPrismicPreviewCookie.cjs +4 -21
  70. package/dist/lib/getPrismicPreviewCookie.cjs.map +1 -1
  71. package/dist/lib/getPrismicPreviewCookie.js +2 -2
  72. package/dist/lib/getPrismicPreviewCookie.js.map +1 -1
  73. package/dist/package.json.cjs +1 -1
  74. package/dist/package.json.js +1 -1
  75. package/dist/redirectToPreviewURL.cjs +13 -12
  76. package/dist/redirectToPreviewURL.cjs.map +1 -1
  77. package/dist/redirectToPreviewURL.d.ts +23 -21
  78. package/dist/redirectToPreviewURL.js +13 -12
  79. package/dist/redirectToPreviewURL.js.map +1 -1
  80. package/dist/setPreviewData.cjs +2 -19
  81. package/dist/setPreviewData.cjs.map +1 -1
  82. package/dist/setPreviewData.d.ts +9 -14
  83. package/dist/setPreviewData.js +2 -2
  84. package/dist/setPreviewData.js.map +1 -1
  85. package/dist/types.d.ts +52 -9
  86. package/package.json +5 -11
  87. package/src/PrismicNextLink.tsx +10 -10
  88. package/src/PrismicPreview.tsx +13 -131
  89. package/src/PrismicPreviewClient.tsx +159 -0
  90. package/src/enableAutoPreviews.ts +56 -45
  91. package/src/exitPreview.ts +14 -26
  92. package/src/redirectToPreviewURL.ts +58 -64
  93. package/src/setPreviewData.ts +10 -14
  94. package/src/types.ts +58 -9
  95. package/dist/react-server/PrismicPreview.d.ts +0 -22
  96. package/dist/react-server/index.d.ts +0 -2
  97. package/dist/react-server/unsupported.cjs +0 -26
  98. package/dist/react-server/unsupported.cjs.map +0 -1
  99. package/dist/react-server/unsupported.d.ts +0 -6
  100. package/dist/react-server/unsupported.js +0 -26
  101. package/dist/react-server/unsupported.js.map +0 -1
  102. package/dist/react-server.cjs +0 -15
  103. package/dist/react-server.cjs.map +0 -1
  104. package/dist/react-server.js +0 -15
  105. package/dist/react-server.js.map +0 -1
  106. package/src/react-server/PrismicPreview.tsx +0 -74
  107. package/src/react-server/index.ts +0 -11
  108. package/src/react-server/unsupported.ts +0 -26
@@ -5,27 +5,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5
5
  const jsxRuntime = require("react/jsx-runtime");
6
6
  const Image = require("next/image");
7
7
  const imgixUrlBuilder = require("imgix-url-builder");
8
- const prismic = require("@prismicio/client");
9
8
  const __PRODUCTION__ = require("./lib/__PRODUCTION__.cjs");
10
9
  const devMsg = require("./lib/devMsg.cjs");
11
10
  const imgixLoader = require("./imgixLoader.cjs");
12
- function _interopNamespaceDefault(e) {
13
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
14
- if (e) {
15
- for (const k in e) {
16
- if (k !== "default") {
17
- const d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: () => e[k]
21
- });
22
- }
23
- }
24
- }
25
- n.default = e;
26
- return Object.freeze(n);
27
- }
28
- const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
11
+ const isFilled = require('./_node_modules/@prismicio/client/dist/helpers/isFilled.cjs');
29
12
  const castInt = (input) => {
30
13
  if (typeof input === "number" || typeof input === "undefined") {
31
14
  return input;
@@ -47,7 +30,7 @@ const PrismicNextImage = ({ field, imgixParams = {}, alt, fallbackAlt, fill, wid
47
30
  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.devMsg("alt-must-be-an-empty-string")}`);
48
31
  }
49
32
  }
50
- if (prismic__namespace.isFilled.imageThumbnail(field)) {
33
+ if (isFilled.imageThumbnail(field)) {
51
34
  const src = imgixUrlBuilder.buildURL(field.url, imgixParams);
52
35
  const ar = field.dimensions.width / field.dimensions.height;
53
36
  const castedWidth = castInt(width);
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextImage.cjs","sources":["../../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\";\n\nimport Image, { ImageProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\nimport { imgixLoader } from \"./imgixLoader\";\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input;\n\t} else {\n\t\tconst parsed = Number.parseInt(input);\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\treturn parsed;\n\t\t}\n\t}\n};\n\nexport type PrismicNextImageProps = Omit<ImageProps, \"src\" | \"alt\"> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismic.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?: ImgixURLParams;\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n\n\t/**\n\t * Rendered when the field is empty. If a fallback is not given, `null` will\n\t * be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails using `next/image`. It will automatically set the `alt`\n * attribute using the Image field's `alt` property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided\n * with the `loader` prop. If you would like to use the Next.js Image\n * Optimization API instead, set `loader={undefined}`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component using `next/image` for the given Image\n * field.\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\nexport const PrismicNextImage = ({\n\tfield,\n\timgixParams = {},\n\talt,\n\tfallbackAlt,\n\tfill,\n\twidth,\n\theight,\n\tfallback = null,\n\t...restProps\n}: PrismicNextImageProps): JSX.Element => {\n\tif (!__PRODUCTION__) {\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 (prismic.isFilled.imageThumbnail(field)) {\n\t\tconst src = buildURL(field.url, imgixParams);\n\n\t\tconst ar = field.dimensions.width / field.dimensions.height;\n\n\t\tconst castedWidth = castInt(width);\n\t\tconst castedHeight = castInt(height);\n\n\t\tlet resolvedWidth = castedWidth ?? field.dimensions.width;\n\t\tlet resolvedHeight = castedHeight ?? field.dimensions.height;\n\n\t\tif (castedWidth != null && castedHeight == null) {\n\t\t\tresolvedHeight = castedWidth / ar;\n\t\t} else if (castedWidth == null && castedHeight != null) {\n\t\t\tresolvedWidth = castedHeight * ar;\n\t\t}\n\n\t\treturn (\n\t\t\t<Image\n\t\t\t\tsrc={src}\n\t\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\t\t// A non-null assertion is required since we\n\t\t\t\t// can't statically know if an alt attribute is\n\t\t\t\t// available.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\talt={(alt ?? (field.alt || fallbackAlt))!}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={imgixLoader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn <>{fallback}</>;\n\t}\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;AACC;AACQ;AAAA;AAED;AAEF;AACI;AAAA;AAEA;AAAA;AACP;AAEH;AAsDO;AAWN;AACC;AACC;AAGI;AAIL;AACC;AAGI;AAEJ;AAGF;AACC;AAEA;AAEM;AACA;AAEF;AACA;AAEA;AACH;AAA+B;AAE/B;AAA+B;AAGhC;AACO;AACL;AAC0B;AACC;AAAA;AAAA;AAAA;AAAA;AAKA;AAC3B;AACQ;AACJ;AACH;AAGH;AAAkB;AAEpB;;"}
1
+ {"version":3,"file":"PrismicNextImage.cjs","sources":["../../src/PrismicNextImage.tsx"],"sourcesContent":["\"use client\";\n\nimport Image, { ImageProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\nimport { imgixLoader } from \"./imgixLoader\";\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input;\n\t} else {\n\t\tconst parsed = Number.parseInt(input);\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\treturn parsed;\n\t\t}\n\t}\n};\n\nexport type PrismicNextImageProps = Omit<ImageProps, \"src\" | \"alt\"> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismic.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?: ImgixURLParams;\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n\n\t/**\n\t * Rendered when the field is empty. If a fallback is not given, `null` will\n\t * be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails using `next/image`. It will automatically set the `alt`\n * attribute using the Image field's `alt` property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided\n * with the `loader` prop. If you would like to use the Next.js Image\n * Optimization API instead, set `loader={undefined}`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component using `next/image` for the given Image\n * field.\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\nexport const PrismicNextImage = ({\n\tfield,\n\timgixParams = {},\n\talt,\n\tfallbackAlt,\n\tfill,\n\twidth,\n\theight,\n\tfallback = null,\n\t...restProps\n}: PrismicNextImageProps): JSX.Element => {\n\tif (!__PRODUCTION__) {\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 (prismic.isFilled.imageThumbnail(field)) {\n\t\tconst src = buildURL(field.url, imgixParams);\n\n\t\tconst ar = field.dimensions.width / field.dimensions.height;\n\n\t\tconst castedWidth = castInt(width);\n\t\tconst castedHeight = castInt(height);\n\n\t\tlet resolvedWidth = castedWidth ?? field.dimensions.width;\n\t\tlet resolvedHeight = castedHeight ?? field.dimensions.height;\n\n\t\tif (castedWidth != null && castedHeight == null) {\n\t\t\tresolvedHeight = castedWidth / ar;\n\t\t} else if (castedWidth == null && castedHeight != null) {\n\t\t\tresolvedWidth = castedHeight * ar;\n\t\t}\n\n\t\treturn (\n\t\t\t<Image\n\t\t\t\tsrc={src}\n\t\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\t\t// A non-null assertion is required since we\n\t\t\t\t// can't statically know if an alt attribute is\n\t\t\t\t// available.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\talt={(alt ?? (field.alt || fallbackAlt))!}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={imgixLoader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn <>{fallback}</>;\n\t}\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAWA;AACC;AACQ;AAAA;AAED;AAEF;AACI;AAAA;AAEA;AAAA;AACP;AAEH;AAsDO;AAWN;AACC;AACC;AAGI;AAIL;AACC;AAGI;AAEJ;AAGF;AACC;AAEA;AAEM;AACA;AAEF;AACA;AAEA;AACH;AAA+B;AAE/B;AAA+B;AAGhC;AACO;AACL;AAC0B;AACC;AAAA;AAAA;AAAA;AAAA;AAKA;AAC3B;AACQ;AACJ;AACH;AAGH;AAAkB;AAEpB;;"}
@@ -3,10 +3,10 @@
3
3
  import { jsx, Fragment } from "react/jsx-runtime";
4
4
  import Image from "next/image";
5
5
  import { buildURL } from "imgix-url-builder";
6
- import * as prismic from "@prismicio/client";
7
6
  import { __PRODUCTION__ } from "./lib/__PRODUCTION__.js";
8
7
  import { devMsg } from "./lib/devMsg.js";
9
8
  import { imgixLoader } from "./imgixLoader.js";
9
+ import { imageThumbnail } from './_node_modules/@prismicio/client/dist/helpers/isFilled.js';
10
10
  const castInt = (input) => {
11
11
  if (typeof input === "number" || typeof input === "undefined") {
12
12
  return input;
@@ -28,7 +28,7 @@ const PrismicNextImage = ({ field, imgixParams = {}, alt, fallbackAlt, fill, wid
28
28
  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")}`);
29
29
  }
30
30
  }
31
- if (prismic.isFilled.imageThumbnail(field)) {
31
+ if (imageThumbnail(field)) {
32
32
  const src = buildURL(field.url, imgixParams);
33
33
  const ar = field.dimensions.width / field.dimensions.height;
34
34
  const castedWidth = castInt(width);
@@ -4,8 +4,8 @@
4
4
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5
5
  const jsxRuntime = require("react/jsx-runtime");
6
6
  const React = require("react");
7
- const prismic = require("@prismicio/client");
8
7
  const Link = require("next/link");
8
+ const asLinkAttrs = require('./_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs');
9
9
  function _interopNamespaceDefault(e) {
10
10
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
11
11
  if (e) {
@@ -23,17 +23,16 @@ function _interopNamespaceDefault(e) {
23
23
  return Object.freeze(n);
24
24
  }
25
25
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
26
- const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
27
26
  const PrismicNextLink = React__namespace.forwardRef(function PrismicNextLink2({ field, document, linkResolver, ...restProps }, ref) {
28
- const { href: computedHref, rel: computedRel, ...attrs } = prismic__namespace.asLinkAttrs(field ?? document, {
27
+ const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs.asLinkAttrs(field ?? document, {
29
28
  linkResolver,
30
29
  rel: typeof restProps.rel === "function" ? restProps.rel : void 0
31
30
  });
31
+ const href = ("href" in restProps ? restProps.href : computedHref) || "";
32
32
  let rel = computedRel;
33
33
  if ("rel" in restProps && typeof restProps.rel !== "function") {
34
34
  rel = restProps.rel;
35
35
  }
36
- const href = ("href" in restProps ? restProps.href : computedHref) || "";
37
36
  return jsxRuntime.jsx(Link, { ref, ...attrs, ...restProps, href, rel });
38
37
  });
39
38
  exports.PrismicNextLink = PrismicNextLink;
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextLink.cjs","sources":["../../src/PrismicNextLink.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport Link, { LinkProps } from \"next/link\";\n\nexport type PrismicNextLinkProps = Omit<\n\tReact.ComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: prismic.LinkResolverFunction;\n\trel?: string | prismic.AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tdocument: prismic.PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: prismic.LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: prismic.LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\nexport const PrismicNextLink = React.forwardRef<\n\tHTMLAnchorElement,\n\tPrismicNextLinkProps\n>(function PrismicNextLink(\n\t{ field, document, linkResolver, ...restProps },\n\tref,\n): JSX.Element | null {\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = prismic.asLinkAttrs(field ?? document, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\treturn <Link ref={ref} {...attrs} {...restProps} href={href} rel={rel} />;\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8BO;AAOA;AAIqC;AAC1C;AAC2D;AAG5D;AACA;AACC;AAAgB;AAGjB;AAEO;AACR;;"}
1
+ {"version":3,"file":"PrismicNextLink.cjs","sources":["../../src/PrismicNextLink.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport Link from \"next/link\";\n\nexport type PrismicNextLinkProps = Omit<\n\tReact.ComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: prismic.LinkResolverFunction;\n\trel?: string | prismic.AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tfield: prismic.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: prismic.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: React.ComponentProps<typeof Link>[\"href\"];\n\t\t }\n\t);\n\nexport const PrismicNextLink = React.forwardRef<\n\tHTMLAnchorElement,\n\tPrismicNextLinkProps\n>(function PrismicNextLink(\n\t{ field, document, linkResolver, ...restProps },\n\tref,\n): JSX.Element | null {\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = prismic.asLinkAttrs(field ?? document, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tlet rel = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\treturn <Link ref={ref} {...attrs} {...restProps} href={href} rel={rel} />;\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BO;AAOA;AAIqC;AAC1C;AAC2D;AAG5D;AAEA;AACA;AACC;AAAgB;AAGV;AACR;;"}
@@ -1,22 +1,22 @@
1
1
  /// <reference types="node" />
2
2
  import * as React from "react";
3
3
  import * as prismic from "@prismicio/client";
4
- import Link, { LinkProps } from "next/link";
4
+ import Link from "next/link";
5
5
  export type PrismicNextLinkProps = Omit<React.ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
6
6
  linkResolver?: prismic.LinkResolverFunction;
7
7
  rel?: string | prismic.AsLinkAttrsConfig["rel"];
8
8
  } & ({
9
- document: prismic.PrismicDocument | null | undefined;
9
+ field: prismic.LinkField | null | undefined;
10
+ document?: never;
10
11
  href?: never;
11
- field?: never;
12
12
  } | {
13
- field: prismic.LinkField | null | undefined;
13
+ field?: never;
14
+ document: prismic.PrismicDocument | null | undefined;
14
15
  href?: never;
15
- document?: never;
16
16
  } | {
17
- href: LinkProps["href"];
18
- field?: prismic.LinkField | null | undefined;
17
+ field?: never;
19
18
  document?: never;
19
+ href: React.ComponentProps<typeof Link>["href"];
20
20
  });
21
21
  export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
22
22
  href: string | import("url").UrlObject;
@@ -50,10 +50,10 @@ export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Pick<Omit
50
50
  linkResolver?: prismic.LinkResolverFunction | undefined;
51
51
  rel?: string | prismic.AsLinkAttrsConfig["rel"];
52
52
  } & {
53
- document: prismic.PrismicDocument | null | undefined;
53
+ field: prismic.LinkField | null | undefined;
54
+ document?: undefined;
54
55
  href?: undefined;
55
- field?: undefined;
56
- }, "key" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver"> | Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
56
+ }, "key" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "tw" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver"> | Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
57
57
  href: string | import("url").UrlObject;
58
58
  as?: (string | import("url").UrlObject) | undefined;
59
59
  replace?: boolean | undefined;
@@ -85,10 +85,10 @@ export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Pick<Omit
85
85
  linkResolver?: prismic.LinkResolverFunction | undefined;
86
86
  rel?: string | prismic.AsLinkAttrsConfig["rel"];
87
87
  } & {
88
- field: prismic.LinkField | null | undefined;
88
+ field?: undefined;
89
+ document: prismic.PrismicDocument | null | undefined;
89
90
  href?: undefined;
90
- document?: undefined;
91
- }, "key" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver"> | Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
91
+ }, "key" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "tw" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver"> | Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
92
92
  href: string | import("url").UrlObject;
93
93
  as?: (string | import("url").UrlObject) | undefined;
94
94
  replace?: boolean | undefined;
@@ -120,7 +120,7 @@ export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Pick<Omit
120
120
  linkResolver?: prismic.LinkResolverFunction | undefined;
121
121
  rel?: string | prismic.AsLinkAttrsConfig["rel"];
122
122
  } & {
123
- href: LinkProps["href"];
124
- field?: prismic.LinkField | null | undefined;
123
+ field?: undefined;
125
124
  document?: undefined;
126
- }, "key" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver">) & React.RefAttributes<HTMLAnchorElement>>;
125
+ href: React.ComponentProps<typeof Link>["href"];
126
+ }, "key" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "tw" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver">) & React.RefAttributes<HTMLAnchorElement>>;
@@ -2,18 +2,18 @@
2
2
  'use client';
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import * as React from "react";
5
- import * as prismic from "@prismicio/client";
6
5
  import Link from "next/link";
6
+ import { asLinkAttrs } from './_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js';
7
7
  const PrismicNextLink = React.forwardRef(function PrismicNextLink2({ field, document, linkResolver, ...restProps }, ref) {
8
- const { href: computedHref, rel: computedRel, ...attrs } = prismic.asLinkAttrs(field ?? document, {
8
+ const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs(field ?? document, {
9
9
  linkResolver,
10
10
  rel: typeof restProps.rel === "function" ? restProps.rel : void 0
11
11
  });
12
+ const href = ("href" in restProps ? restProps.href : computedHref) || "";
12
13
  let rel = computedRel;
13
14
  if ("rel" in restProps && typeof restProps.rel !== "function") {
14
15
  rel = restProps.rel;
15
16
  }
16
- const href = ("href" in restProps ? restProps.href : computedHref) || "";
17
17
  return jsx(Link, { ref, ...attrs, ...restProps, href, rel });
18
18
  });
19
19
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicNextLink.js","sources":["../../src/PrismicNextLink.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport Link, { LinkProps } from \"next/link\";\n\nexport type PrismicNextLinkProps = Omit<\n\tReact.ComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: prismic.LinkResolverFunction;\n\trel?: string | prismic.AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tdocument: prismic.PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: prismic.LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: prismic.LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\nexport const PrismicNextLink = React.forwardRef<\n\tHTMLAnchorElement,\n\tPrismicNextLinkProps\n>(function PrismicNextLink(\n\t{ field, document, linkResolver, ...restProps },\n\tref,\n): JSX.Element | null {\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = prismic.asLinkAttrs(field ?? document, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\treturn <Link ref={ref} {...attrs} {...restProps} href={href} rel={rel} />;\n});\n"],"names":[],"mappings":";;;;;;AA8BO;AAOA;AAIqC;AAC1C;AAC2D;AAG5D;AACA;AACC;AAAgB;AAGjB;AAEO;AACR;;;;"}
1
+ {"version":3,"file":"PrismicNextLink.js","sources":["../../src/PrismicNextLink.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport Link from \"next/link\";\n\nexport type PrismicNextLinkProps = Omit<\n\tReact.ComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: prismic.LinkResolverFunction;\n\trel?: string | prismic.AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tfield: prismic.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: prismic.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: React.ComponentProps<typeof Link>[\"href\"];\n\t\t }\n\t);\n\nexport const PrismicNextLink = React.forwardRef<\n\tHTMLAnchorElement,\n\tPrismicNextLinkProps\n>(function PrismicNextLink(\n\t{ field, document, linkResolver, ...restProps },\n\tref,\n): JSX.Element | null {\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = prismic.asLinkAttrs(field ?? document, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tlet rel = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\treturn <Link ref={ref} {...attrs} {...restProps} href={href} rel={rel} />;\n});\n"],"names":[],"mappings":";;;;;;AA8BO;AAOA;AAIqC;AAC1C;AAC2D;AAG5D;AAEA;AACA;AACC;AAAgB;AAGV;AACR;;;;"}
@@ -1,81 +1,12 @@
1
- 'use client';
2
- 'use client';
3
1
  "use strict";
4
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5
3
  const jsxRuntime = require("react/jsx-runtime");
6
- const React = require("react");
7
- const router = require("next/router");
8
4
  const Script = require("next/script");
9
- const getPrismicPreviewCookie = require("./lib/getPrismicPreviewCookie.cjs");
10
- const getPreviewCookieRepositoryName = require("./lib/getPreviewCookieRepositoryName.cjs");
11
- function _interopNamespaceDefault(e) {
12
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
13
- if (e) {
14
- for (const k in e) {
15
- if (k !== "default") {
16
- const d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: () => e[k]
20
- });
21
- }
22
- }
23
- }
24
- n.default = e;
25
- return Object.freeze(n);
26
- }
27
- const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
28
- function PrismicPreview({ repositoryName, children, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview" }) {
29
- const router$1 = router.useRouter();
30
- const resolvedUpdatePreviewURL = router$1.basePath + updatePreviewURL;
31
- const resolvedExitPreviewURL = router$1.basePath + exitPreviewURL;
32
- React__namespace.useEffect(() => {
33
- const startPreviewMode = async () => {
34
- const res = await globalThis.fetch(resolvedUpdatePreviewURL);
35
- if (res.redirected) {
36
- globalThis.location.reload();
37
- } else {
38
- console.error(`[<PrismicPreview>] Failed to start or update Preview Mode using the "${resolvedUpdatePreviewURL}" API endpoint. Does it exist?`);
39
- }
40
- };
41
- const handlePrismicPreviewUpdate = async (event) => {
42
- event.preventDefault();
43
- await startPreviewMode();
44
- };
45
- const handlePrismicPreviewEnd = async (event) => {
46
- event.preventDefault();
47
- const res = await globalThis.fetch(resolvedExitPreviewURL);
48
- if (res.ok) {
49
- globalThis.location.reload();
50
- } else {
51
- console.error(`[<PrismicPreview>] Failed to exit Preview Mode using the "${resolvedExitPreviewURL}" API endpoint. Does it exist?`);
52
- }
53
- };
54
- if (router$1.isPreview) {
55
- window.addEventListener("prismicPreviewUpdate", handlePrismicPreviewUpdate);
56
- window.addEventListener("prismicPreviewEnd", handlePrismicPreviewEnd);
57
- } else {
58
- const prismicPreviewCookie = getPrismicPreviewCookie.getPrismicPreviewCookie(globalThis.document.cookie);
59
- if (prismicPreviewCookie) {
60
- const locationIsDescendantOfBasePath = window.location.href.startsWith(window.location.origin + router$1.basePath);
61
- const prismicPreviewCookieRepositoryName = getPreviewCookieRepositoryName.getPreviewCookieRepositoryName(prismicPreviewCookie);
62
- if (locationIsDescendantOfBasePath && prismicPreviewCookieRepositoryName === repositoryName) {
63
- startPreviewMode();
64
- }
65
- }
66
- }
67
- return () => {
68
- window.removeEventListener("prismicPreviewUpdate", handlePrismicPreviewUpdate);
69
- window.removeEventListener("prismicPreviewEnd", handlePrismicPreviewEnd);
70
- };
71
- }, [
72
- repositoryName,
73
- resolvedExitPreviewURL,
74
- resolvedUpdatePreviewURL,
75
- router$1.isPreview,
76
- router$1.basePath
77
- ]);
78
- return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [children, jsxRuntime.jsx(Script, { src: `https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`, strategy: "lazyOnload" })] });
5
+ const PrismicPreviewClient = require("./PrismicPreviewClient.cjs");
6
+ const getToolbarSrc = require('./_node_modules/@prismicio/client/dist/getToolbarSrc.cjs');
7
+ function PrismicPreview({ repositoryName, children, ...props }) {
8
+ const toolbarSrc = getToolbarSrc.getToolbarSrc(repositoryName);
9
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [children, jsxRuntime.jsx(PrismicPreviewClient.PrismicPreviewClient, { repositoryName, ...props }), jsxRuntime.jsx(Script, { src: toolbarSrc, strategy: "lazyOnload" })] });
79
10
  }
80
11
  exports.PrismicPreview = PrismicPreview;
81
12
  //# sourceMappingURL=PrismicPreview.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.cjs","sources":["../../src/PrismicPreview.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { useRouter } from \"next/router\";\nimport Script from \"next/script\";\n\nimport { getPrismicPreviewCookie } from \"./lib/getPrismicPreviewCookie\";\nimport { getPreviewCookieRepositoryName } from \"./lib/getPreviewCookieRepositoryName\";\n\n/**\n * Props for `<PrismicPreview>`.\n */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered\n\t * using this repository.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`).\n\t * This URL will be fetched on preview update events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\tupdatePreviewURL?: string;\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).\n\t * This URL will be fetched on preview exit events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\texitPreviewURL?: string;\n\n\t/**\n\t * Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar\n\t * will be rendered last.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically update the Next.js preview\n * cookie and refresh the page.\n *\n * This component can be wrapped around your app or added anywhere in your app's\n * tree. It must be rendered on every page.\n */\nexport function PrismicPreview({\n\trepositoryName,\n\tchildren,\n\tupdatePreviewURL = \"/api/preview\",\n\texitPreviewURL = \"/api/exit-preview\",\n}: PrismicPreviewProps): JSX.Element {\n\tconst router = useRouter();\n\n\tconst resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;\n\tconst resolvedExitPreviewURL = router.basePath + exitPreviewURL;\n\n\tReact.useEffect(() => {\n\t\t/**\n\t\t * Starts Preview Mode and refreshes the page's props.\n\t\t */\n\t\tconst startPreviewMode = async () => {\n\t\t\t// Start Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedUpdatePreviewURL);\n\n\t\t\t// We check for `res.redirected` rather than `res.ok`\n\t\t\t// since the update preview endpoint may redirect to a\n\t\t\t// 404 page. As long as it redirects, we know the\n\t\t\t// endpoint exists and at least attempted to set\n\t\t\t// preview data.\n\t\t\tif (res.redirected) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to start or update Preview Mode using the \"${resolvedUpdatePreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst handlePrismicPreviewUpdate = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\tawait startPreviewMode();\n\t\t};\n\n\t\tconst handlePrismicPreviewEnd = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\t// Exit Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedExitPreviewURL);\n\n\t\t\tif (res.ok) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${resolvedExitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tif (router.isPreview) {\n\t\t\t// Register Prismic Toolbar event handlers.\n\t\t\twindow.addEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.addEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t} else {\n\t\t\tconst prismicPreviewCookie = getPrismicPreviewCookie(\n\t\t\t\tglobalThis.document.cookie,\n\t\t\t);\n\n\t\t\tif (prismicPreviewCookie) {\n\t\t\t\t// If a Prismic preview cookie is present, but Next.js Preview\n\t\t\t\t// Mode is not active, we must activate Preview Mode manually.\n\t\t\t\t//\n\t\t\t\t// This will happen when a visitor accesses the page using a\n\t\t\t\t// Prismic preview share link.\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the current location is a descendant of the app's base\n\t\t\t\t * path.\n\t\t\t\t *\n\t\t\t\t * This is used to prevent infinite refrehes; when\n\t\t\t\t * `isDescendantOfBasePath` is `false`, `router.isPreview` is also\n\t\t\t\t * `false`.\n\t\t\t\t *\n\t\t\t\t * If the app does not have a base path, this should always be `true`.\n\t\t\t\t */\n\t\t\t\tconst locationIsDescendantOfBasePath = window.location.href.startsWith(\n\t\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t\t);\n\n\t\t\t\tconst prismicPreviewCookieRepositoryName =\n\t\t\t\t\tgetPreviewCookieRepositoryName(prismicPreviewCookie);\n\n\t\t\t\tif (\n\t\t\t\t\tlocationIsDescendantOfBasePath &&\n\t\t\t\t\tprismicPreviewCookieRepositoryName === repositoryName\n\t\t\t\t) {\n\t\t\t\t\tstartPreviewMode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// On cleanup, unregister Prismic Toolbar event handlers.\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.removeEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t};\n\t}, [\n\t\trepositoryName,\n\t\tresolvedExitPreviewURL,\n\t\tresolvedUpdatePreviewURL,\n\t\trouter.isPreview,\n\t\trouter.basePath,\n\t]);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script\n\t\t\t\tsrc={`https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`}\n\t\t\t\tstrategy=\"lazyOnload\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDgB;AAMf;AAEM;AACA;AAENA;AAIC;AAEC;AAOA;AACC;;AAEQ;AACyH;AAEjI;AAGI;AAEL;AAEA;;AAGK;AAEL;AAGA;AAEA;AACC;;AAEQ;AAC4G;AAEpH;AAGF;AAEQ;AAIA;AAA6D;AAEpE;AAIA;AAiBO;AAIA;AAIL;;;AAIA;AACD;AAIF;AACQ;AAIA;AAAgE;AAAA;AAEtE;AACF;AACA;AACA;AACO;AACA;AAGR;AASD;;"}
1
+ {"version":3,"file":"PrismicPreview.cjs","sources":["../../src/PrismicPreview.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport Script from \"next/script\";\n\nimport { PrismicPreviewClient } from \"./PrismicPreviewClient\";\n\n/**\n * Props for `<PrismicPreview>`.\n */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered\n\t * using this repository.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`).\n\t * This URL will be fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).\n\t * This URL will be fetched on preview exit events.\n\t */\n\texitPreviewURL?: string;\n\n\t/**\n\t * Children to render adjacent to the Prismic Toolbar.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically refresh the page with the\n * changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's\n * tree. It must be rendered on every page.\n */\nexport function PrismicPreview({\n\trepositoryName,\n\tchildren,\n\t...props\n}: PrismicPreviewProps): JSX.Element {\n\tconst toolbarSrc = prismic.getToolbarSrc(repositoryName);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<PrismicPreviewClient repositoryName={repositoryName} {...props} />\n\t\t\t<Script src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t);\n}\n"],"names":["prismic.getToolbarSrc","_jsxs","_Fragment","_jsx","PrismicPreviewClient"],"mappings":";;;;;;AA+CM,SAAU,eAAe,EAC9B,gBACA,UACA,GAAG,SACkB;AACf,QAAA,aAAaA,4BAAsB,cAAc;AAGtD,SAAAC,WAAA,KACEC,qBAAA,EAAA,UAAA,CAAA,UACDC,eAACC,qBAAAA,sBAAoB,EAAC,gBAA8B,GAAM,MAAK,CAAA,GAC/DD,WAAA,IAAC,QAAM,EAAC,KAAK,YAAY,UAAS,aAAY,CAAA,CAAG,EAAA,CAC/C;AAEL;;"}
@@ -9,34 +9,31 @@ export type PrismicPreviewProps = {
9
9
  */
10
10
  repositoryName: string;
11
11
  /**
12
+ * **Only used in the Pages Directory (/pages).**
13
+ *
12
14
  * The URL of your app's Prismic preview endpoint (default: `/api/preview`).
13
15
  * This URL will be fetched on preview update events.
14
- *
15
- * **Note**: If your `next.config.js` file contains a `basePath`, it is
16
- * automatically included.
17
16
  */
18
17
  updatePreviewURL?: string;
19
18
  /**
19
+ * **Only used in the Pages Directory (/pages).**
20
+ *
20
21
  * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
21
22
  * This URL will be fetched on preview exit events.
22
- *
23
- * **Note**: If your `next.config.js` file contains a `basePath`, it is
24
- * automatically included.
25
23
  */
26
24
  exitPreviewURL?: string;
27
25
  /**
28
- * Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar
29
- * will be rendered last.
26
+ * Children to render adjacent to the Prismic Toolbar.
30
27
  */
31
28
  children?: React.ReactNode;
32
29
  };
33
30
  /**
34
31
  * React component that sets up Prismic Previews using the Prismic Toolbar. When
35
32
  * the Prismic Toolbar send events to the browser, such as on preview updates
36
- * and exiting, this component will automatically update the Next.js preview
37
- * cookie and refresh the page.
33
+ * and exiting, this component will automatically refresh the page with the
34
+ * changes.
38
35
  *
39
36
  * This component can be wrapped around your app or added anywhere in your app's
40
37
  * tree. It must be rendered on every page.
41
38
  */
42
- export declare function PrismicPreview({ repositoryName, children, updatePreviewURL, exitPreviewURL, }: PrismicPreviewProps): JSX.Element;
39
+ export declare function PrismicPreview({ repositoryName, children, ...props }: PrismicPreviewProps): JSX.Element;
@@ -1,62 +1,10 @@
1
- 'use client';
2
- 'use client';
3
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
4
- import * as React from "react";
5
- import { useRouter } from "next/router";
6
2
  import Script from "next/script";
7
- import { getPrismicPreviewCookie } from "./lib/getPrismicPreviewCookie.js";
8
- import { getPreviewCookieRepositoryName } from "./lib/getPreviewCookieRepositoryName.js";
9
- function PrismicPreview({ repositoryName, children, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview" }) {
10
- const router = useRouter();
11
- const resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;
12
- const resolvedExitPreviewURL = router.basePath + exitPreviewURL;
13
- React.useEffect(() => {
14
- const startPreviewMode = async () => {
15
- const res = await globalThis.fetch(resolvedUpdatePreviewURL);
16
- if (res.redirected) {
17
- globalThis.location.reload();
18
- } else {
19
- console.error(`[<PrismicPreview>] Failed to start or update Preview Mode using the "${resolvedUpdatePreviewURL}" API endpoint. Does it exist?`);
20
- }
21
- };
22
- const handlePrismicPreviewUpdate = async (event) => {
23
- event.preventDefault();
24
- await startPreviewMode();
25
- };
26
- const handlePrismicPreviewEnd = async (event) => {
27
- event.preventDefault();
28
- const res = await globalThis.fetch(resolvedExitPreviewURL);
29
- if (res.ok) {
30
- globalThis.location.reload();
31
- } else {
32
- console.error(`[<PrismicPreview>] Failed to exit Preview Mode using the "${resolvedExitPreviewURL}" API endpoint. Does it exist?`);
33
- }
34
- };
35
- if (router.isPreview) {
36
- window.addEventListener("prismicPreviewUpdate", handlePrismicPreviewUpdate);
37
- window.addEventListener("prismicPreviewEnd", handlePrismicPreviewEnd);
38
- } else {
39
- const prismicPreviewCookie = getPrismicPreviewCookie(globalThis.document.cookie);
40
- if (prismicPreviewCookie) {
41
- const locationIsDescendantOfBasePath = window.location.href.startsWith(window.location.origin + router.basePath);
42
- const prismicPreviewCookieRepositoryName = getPreviewCookieRepositoryName(prismicPreviewCookie);
43
- if (locationIsDescendantOfBasePath && prismicPreviewCookieRepositoryName === repositoryName) {
44
- startPreviewMode();
45
- }
46
- }
47
- }
48
- return () => {
49
- window.removeEventListener("prismicPreviewUpdate", handlePrismicPreviewUpdate);
50
- window.removeEventListener("prismicPreviewEnd", handlePrismicPreviewEnd);
51
- };
52
- }, [
53
- repositoryName,
54
- resolvedExitPreviewURL,
55
- resolvedUpdatePreviewURL,
56
- router.isPreview,
57
- router.basePath
58
- ]);
59
- return jsxs(Fragment, { children: [children, jsx(Script, { src: `https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`, strategy: "lazyOnload" })] });
3
+ import { PrismicPreviewClient } from "./PrismicPreviewClient.js";
4
+ import { getToolbarSrc } from './_node_modules/@prismicio/client/dist/getToolbarSrc.js';
5
+ function PrismicPreview({ repositoryName, children, ...props }) {
6
+ const toolbarSrc = getToolbarSrc(repositoryName);
7
+ return jsxs(Fragment, { children: [children, jsx(PrismicPreviewClient, { repositoryName, ...props }), jsx(Script, { src: toolbarSrc, strategy: "lazyOnload" })] });
60
8
  }
61
9
  export {
62
10
  PrismicPreview
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreview.js","sources":["../../src/PrismicPreview.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { useRouter } from \"next/router\";\nimport Script from \"next/script\";\n\nimport { getPrismicPreviewCookie } from \"./lib/getPrismicPreviewCookie\";\nimport { getPreviewCookieRepositoryName } from \"./lib/getPreviewCookieRepositoryName\";\n\n/**\n * Props for `<PrismicPreview>`.\n */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered\n\t * using this repository.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`).\n\t * This URL will be fetched on preview update events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\tupdatePreviewURL?: string;\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).\n\t * This URL will be fetched on preview exit events.\n\t *\n\t * **Note**: If your `next.config.js` file contains a `basePath`, it is\n\t * automatically included.\n\t */\n\texitPreviewURL?: string;\n\n\t/**\n\t * Children to render adjacent to the Prismic Toolbar. The Prismic Toolbar\n\t * will be rendered last.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically update the Next.js preview\n * cookie and refresh the page.\n *\n * This component can be wrapped around your app or added anywhere in your app's\n * tree. It must be rendered on every page.\n */\nexport function PrismicPreview({\n\trepositoryName,\n\tchildren,\n\tupdatePreviewURL = \"/api/preview\",\n\texitPreviewURL = \"/api/exit-preview\",\n}: PrismicPreviewProps): JSX.Element {\n\tconst router = useRouter();\n\n\tconst resolvedUpdatePreviewURL = router.basePath + updatePreviewURL;\n\tconst resolvedExitPreviewURL = router.basePath + exitPreviewURL;\n\n\tReact.useEffect(() => {\n\t\t/**\n\t\t * Starts Preview Mode and refreshes the page's props.\n\t\t */\n\t\tconst startPreviewMode = async () => {\n\t\t\t// Start Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedUpdatePreviewURL);\n\n\t\t\t// We check for `res.redirected` rather than `res.ok`\n\t\t\t// since the update preview endpoint may redirect to a\n\t\t\t// 404 page. As long as it redirects, we know the\n\t\t\t// endpoint exists and at least attempted to set\n\t\t\t// preview data.\n\t\t\tif (res.redirected) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to start or update Preview Mode using the \"${resolvedUpdatePreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst handlePrismicPreviewUpdate = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\tawait startPreviewMode();\n\t\t};\n\n\t\tconst handlePrismicPreviewEnd = async (event: Event) => {\n\t\t\t// Prevent the toolbar from reloading the page.\n\t\t\tevent.preventDefault();\n\n\t\t\t// Exit Next.js Preview Mode via the given preview API endpoint.\n\t\t\tconst res = await globalThis.fetch(resolvedExitPreviewURL);\n\n\t\t\tif (res.ok) {\n\t\t\t\tglobalThis.location.reload();\n\t\t\t} else {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${resolvedExitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tif (router.isPreview) {\n\t\t\t// Register Prismic Toolbar event handlers.\n\t\t\twindow.addEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.addEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t} else {\n\t\t\tconst prismicPreviewCookie = getPrismicPreviewCookie(\n\t\t\t\tglobalThis.document.cookie,\n\t\t\t);\n\n\t\t\tif (prismicPreviewCookie) {\n\t\t\t\t// If a Prismic preview cookie is present, but Next.js Preview\n\t\t\t\t// Mode is not active, we must activate Preview Mode manually.\n\t\t\t\t//\n\t\t\t\t// This will happen when a visitor accesses the page using a\n\t\t\t\t// Prismic preview share link.\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the current location is a descendant of the app's base\n\t\t\t\t * path.\n\t\t\t\t *\n\t\t\t\t * This is used to prevent infinite refrehes; when\n\t\t\t\t * `isDescendantOfBasePath` is `false`, `router.isPreview` is also\n\t\t\t\t * `false`.\n\t\t\t\t *\n\t\t\t\t * If the app does not have a base path, this should always be `true`.\n\t\t\t\t */\n\t\t\t\tconst locationIsDescendantOfBasePath = window.location.href.startsWith(\n\t\t\t\t\twindow.location.origin + router.basePath,\n\t\t\t\t);\n\n\t\t\t\tconst prismicPreviewCookieRepositoryName =\n\t\t\t\t\tgetPreviewCookieRepositoryName(prismicPreviewCookie);\n\n\t\t\t\tif (\n\t\t\t\t\tlocationIsDescendantOfBasePath &&\n\t\t\t\t\tprismicPreviewCookieRepositoryName === repositoryName\n\t\t\t\t) {\n\t\t\t\t\tstartPreviewMode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// On cleanup, unregister Prismic Toolbar event handlers.\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\n\t\t\t\t\"prismicPreviewUpdate\",\n\t\t\t\thandlePrismicPreviewUpdate,\n\t\t\t);\n\t\t\twindow.removeEventListener(\"prismicPreviewEnd\", handlePrismicPreviewEnd);\n\t\t};\n\t}, [\n\t\trepositoryName,\n\t\tresolvedExitPreviewURL,\n\t\tresolvedUpdatePreviewURL,\n\t\trouter.isPreview,\n\t\trouter.basePath,\n\t]);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Script\n\t\t\t\tsrc={`https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}&new=true`}\n\t\t\t\tstrategy=\"lazyOnload\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"names":[],"mappings":";;;;;;;;AAqDgB;AAMf;AAEM;AACA;AAEN;AAIC;AAEC;AAOA;AACC;;AAEQ;AACyH;AAEjI;AAGI;AAEL;AAEA;;AAGK;AAEL;AAGA;AAEA;AACC;;AAEQ;AAC4G;AAEpH;AAGF;AAEQ;AAIA;AAA6D;AAEpE;AAIA;AAiBO;AAIA;AAIL;;;AAIA;AACD;AAIF;AACQ;AAIA;AAAgE;AAAA;AAEtE;AACF;AACA;AACA;AACO;AACA;AAGR;AASD;;;;"}
1
+ {"version":3,"file":"PrismicPreview.js","sources":["../../src/PrismicPreview.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport Script from \"next/script\";\n\nimport { PrismicPreviewClient } from \"./PrismicPreviewClient\";\n\n/**\n * Props for `<PrismicPreview>`.\n */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered\n\t * using this repository.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`).\n\t * This URL will be fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`).\n\t * This URL will be fetched on preview exit events.\n\t */\n\texitPreviewURL?: string;\n\n\t/**\n\t * Children to render adjacent to the Prismic Toolbar.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When\n * the Prismic Toolbar send events to the browser, such as on preview updates\n * and exiting, this component will automatically refresh the page with the\n * changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's\n * tree. It must be rendered on every page.\n */\nexport function PrismicPreview({\n\trepositoryName,\n\tchildren,\n\t...props\n}: PrismicPreviewProps): JSX.Element {\n\tconst toolbarSrc = prismic.getToolbarSrc(repositoryName);\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<PrismicPreviewClient repositoryName={repositoryName} {...props} />\n\t\t\t<Script src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t);\n}\n"],"names":["prismic.getToolbarSrc","_jsxs","_Fragment","_jsx"],"mappings":";;;;AA+CM,SAAU,eAAe,EAC9B,gBACA,UACA,GAAG,SACkB;AACf,QAAA,aAAaA,cAAsB,cAAc;AAGtD,SAAAC,KACEC,UAAA,EAAA,UAAA,CAAA,UACDC,IAAC,sBAAoB,EAAC,gBAA8B,GAAM,MAAK,CAAA,GAC/DA,IAAC,QAAM,EAAC,KAAK,YAAY,UAAS,aAAY,CAAA,CAAG,EAAA,CAC/C;AAEL;"}