@prismicio/next 2.2.2 → 2.2.3-canary.1abb259

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 (178) hide show
  1. package/dist/PrismicNextImage.cjs +16 -20
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.cts +14 -23
  4. package/dist/PrismicNextImage.d.cts.map +1 -0
  5. package/dist/PrismicNextImage.d.ts +14 -23
  6. package/dist/PrismicNextImage.d.ts.map +1 -0
  7. package/dist/PrismicNextImage.js +11 -15
  8. package/dist/PrismicNextImage.js.map +1 -1
  9. package/dist/PrismicNextLink.cjs +7 -8
  10. package/dist/PrismicNextLink.cjs.map +1 -1
  11. package/dist/PrismicNextLink.d.cts +10 -10
  12. package/dist/PrismicNextLink.d.cts.map +1 -0
  13. package/dist/PrismicNextLink.d.ts +10 -10
  14. package/dist/PrismicNextLink.d.ts.map +1 -0
  15. package/dist/PrismicNextLink.js +3 -4
  16. package/dist/PrismicNextLink.js.map +1 -1
  17. package/dist/PrismicPreview.cjs +13 -15
  18. package/dist/PrismicPreview.cjs.map +1 -1
  19. package/dist/PrismicPreview.d.cts +12 -14
  20. package/dist/PrismicPreview.d.cts.map +1 -0
  21. package/dist/PrismicPreview.d.ts +12 -14
  22. package/dist/PrismicPreview.d.ts.map +1 -0
  23. package/dist/PrismicPreview.js +8 -10
  24. package/dist/PrismicPreview.js.map +1 -1
  25. package/dist/PrismicPreviewClient.cjs +5 -9
  26. package/dist/PrismicPreviewClient.cjs.map +1 -1
  27. package/dist/PrismicPreviewClient.js +6 -10
  28. package/dist/PrismicPreviewClient.js.map +1 -1
  29. package/dist/SliceSimulator.cjs +6 -8
  30. package/dist/SliceSimulator.cjs.map +1 -1
  31. package/dist/SliceSimulator.d.cts +3 -6
  32. package/dist/SliceSimulator.d.cts.map +1 -0
  33. package/dist/SliceSimulator.d.ts +3 -6
  34. package/dist/SliceSimulator.d.ts.map +1 -0
  35. package/dist/SliceSimulator.js +4 -6
  36. package/dist/SliceSimulator.js.map +1 -1
  37. package/dist/SliceSimulatorWrapper.cjs +3 -7
  38. package/dist/SliceSimulatorWrapper.cjs.map +1 -1
  39. package/dist/SliceSimulatorWrapper.js +2 -6
  40. package/dist/SliceSimulatorWrapper.js.map +1 -1
  41. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +8 -14
  42. package/dist/createLocaleRedirect.cjs +2 -3
  43. package/dist/createLocaleRedirect.cjs.map +1 -1
  44. package/dist/createLocaleRedirect.d.cts.map +1 -0
  45. package/dist/createLocaleRedirect.d.ts.map +1 -0
  46. package/dist/createLocaleRedirect.js +1 -2
  47. package/dist/createLocaleRedirect.js.map +1 -1
  48. package/dist/enableAutoPreviews.cjs +4 -6
  49. package/dist/enableAutoPreviews.cjs.map +1 -1
  50. package/dist/enableAutoPreviews.d.cts +2 -4
  51. package/dist/enableAutoPreviews.d.cts.map +1 -0
  52. package/dist/enableAutoPreviews.d.ts +2 -4
  53. package/dist/enableAutoPreviews.d.ts.map +1 -0
  54. package/dist/enableAutoPreviews.js +3 -5
  55. package/dist/enableAutoPreviews.js.map +1 -1
  56. package/dist/exitPreview.cjs +11 -13
  57. package/dist/exitPreview.cjs.map +1 -1
  58. package/dist/exitPreview.d.cts +9 -10
  59. package/dist/exitPreview.d.cts.map +1 -0
  60. package/dist/exitPreview.d.ts +9 -10
  61. package/dist/exitPreview.d.ts.map +1 -0
  62. package/dist/exitPreview.js +11 -12
  63. package/dist/exitPreview.js.map +1 -1
  64. package/dist/getSlices.cjs +2 -3
  65. package/dist/getSlices.cjs.map +1 -1
  66. package/dist/getSlices.d.cts.map +1 -0
  67. package/dist/getSlices.d.ts.map +1 -0
  68. package/dist/getSlices.js +1 -2
  69. package/dist/getSlices.js.map +1 -1
  70. package/dist/imgixLoader.cjs +4 -5
  71. package/dist/imgixLoader.cjs.map +1 -1
  72. package/dist/imgixLoader.d.cts +3 -4
  73. package/dist/imgixLoader.d.cts.map +1 -0
  74. package/dist/imgixLoader.d.ts +3 -4
  75. package/dist/imgixLoader.d.ts.map +1 -0
  76. package/dist/imgixLoader.js +3 -4
  77. package/dist/imgixLoader.js.map +1 -1
  78. package/dist/index.cjs +12 -12
  79. package/dist/index.js +1 -2
  80. package/dist/lib/devMsg.cjs +8 -11
  81. package/dist/lib/devMsg.cjs.map +1 -1
  82. package/dist/lib/devMsg.js +7 -10
  83. package/dist/lib/devMsg.js.map +1 -1
  84. package/dist/lib/resolveDefaultExport.cjs +9 -14
  85. package/dist/lib/resolveDefaultExport.cjs.map +1 -1
  86. package/dist/lib/resolveDefaultExport.js +9 -13
  87. package/dist/lib/resolveDefaultExport.js.map +1 -1
  88. package/dist/package.cjs +7 -8
  89. package/dist/package.js +2 -2
  90. package/dist/pages/PrismicPreview.cjs +12 -14
  91. package/dist/pages/PrismicPreview.cjs.map +1 -1
  92. package/dist/pages/PrismicPreview.d.cts +12 -14
  93. package/dist/pages/PrismicPreview.d.cts.map +1 -0
  94. package/dist/pages/PrismicPreview.d.ts +12 -14
  95. package/dist/pages/PrismicPreview.d.ts.map +1 -0
  96. package/dist/pages/PrismicPreview.js +8 -10
  97. package/dist/pages/PrismicPreview.js.map +1 -1
  98. package/dist/pages/SliceSimulator.cjs +5 -6
  99. package/dist/pages/SliceSimulator.cjs.map +1 -1
  100. package/dist/pages/SliceSimulator.d.cts +10 -13
  101. package/dist/pages/SliceSimulator.d.cts.map +1 -0
  102. package/dist/pages/SliceSimulator.d.ts +10 -13
  103. package/dist/pages/SliceSimulator.d.ts.map +1 -0
  104. package/dist/pages/SliceSimulator.js +3 -4
  105. package/dist/pages/SliceSimulator.js.map +1 -1
  106. package/dist/pages/enableAutoPreviews.cjs +4 -5
  107. package/dist/pages/enableAutoPreviews.cjs.map +1 -1
  108. package/dist/pages/enableAutoPreviews.d.cts +6 -8
  109. package/dist/pages/enableAutoPreviews.d.cts.map +1 -0
  110. package/dist/pages/enableAutoPreviews.d.ts +6 -8
  111. package/dist/pages/enableAutoPreviews.d.ts.map +1 -0
  112. package/dist/pages/enableAutoPreviews.js +4 -4
  113. package/dist/pages/enableAutoPreviews.js.map +1 -1
  114. package/dist/pages/exitPreview.cjs +10 -12
  115. package/dist/pages/exitPreview.cjs.map +1 -1
  116. package/dist/pages/exitPreview.d.cts +9 -10
  117. package/dist/pages/exitPreview.d.cts.map +1 -0
  118. package/dist/pages/exitPreview.d.ts +9 -10
  119. package/dist/pages/exitPreview.d.ts.map +1 -0
  120. package/dist/pages/exitPreview.js +10 -11
  121. package/dist/pages/exitPreview.js.map +1 -1
  122. package/dist/pages/redirectToPreviewURL.cjs +1 -2
  123. package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
  124. package/dist/pages/redirectToPreviewURL.d.cts +8 -11
  125. package/dist/pages/redirectToPreviewURL.d.cts.map +1 -0
  126. package/dist/pages/redirectToPreviewURL.d.ts +8 -11
  127. package/dist/pages/redirectToPreviewURL.d.ts.map +1 -0
  128. package/dist/pages/redirectToPreviewURL.js +1 -1
  129. package/dist/pages/redirectToPreviewURL.js.map +1 -1
  130. package/dist/pages/setPreviewData.cjs +2 -3
  131. package/dist/pages/setPreviewData.cjs.map +1 -1
  132. package/dist/pages/setPreviewData.d.cts.map +1 -0
  133. package/dist/pages/setPreviewData.d.ts.map +1 -0
  134. package/dist/pages/setPreviewData.js +1 -2
  135. package/dist/pages/setPreviewData.js.map +1 -1
  136. package/dist/pages/types.d.cts +3 -9
  137. package/dist/pages/types.d.cts.map +1 -0
  138. package/dist/pages/types.d.ts +3 -9
  139. package/dist/pages/types.d.ts.map +1 -0
  140. package/dist/pages.cjs +12 -12
  141. package/dist/pages.js +1 -2
  142. package/dist/redirectToPreviewURL.cjs +3 -4
  143. package/dist/redirectToPreviewURL.cjs.map +1 -1
  144. package/dist/redirectToPreviewURL.d.cts +4 -7
  145. package/dist/redirectToPreviewURL.d.cts.map +1 -0
  146. package/dist/redirectToPreviewURL.d.ts +4 -7
  147. package/dist/redirectToPreviewURL.d.ts.map +1 -0
  148. package/dist/redirectToPreviewURL.js +2 -3
  149. package/dist/redirectToPreviewURL.js.map +1 -1
  150. package/dist/types.d.cts +1 -2
  151. package/dist/types.d.cts.map +1 -0
  152. package/dist/types.d.ts +1 -2
  153. package/dist/types.d.ts.map +1 -0
  154. package/package.json +34 -36
  155. package/src/PrismicNextImage.tsx +113 -134
  156. package/src/PrismicNextLink.tsx +43 -45
  157. package/src/PrismicPreview.tsx +28 -29
  158. package/src/PrismicPreviewClient.tsx +42 -44
  159. package/src/SliceSimulator.tsx +38 -43
  160. package/src/SliceSimulatorWrapper.tsx +15 -25
  161. package/src/createLocaleRedirect.ts +3 -3
  162. package/src/enableAutoPreviews.ts +15 -16
  163. package/src/exitPreview.ts +12 -13
  164. package/src/getSlices.ts +6 -10
  165. package/src/imgixLoader.ts +10 -10
  166. package/src/index.ts +18 -21
  167. package/src/lib/devMsg.ts +9 -11
  168. package/src/lib/resolveDefaultExport.ts +9 -13
  169. package/src/pages/PrismicPreview.tsx +47 -51
  170. package/src/pages/SliceSimulator.tsx +35 -37
  171. package/src/pages/enableAutoPreviews.ts +17 -17
  172. package/src/pages/exitPreview.ts +17 -18
  173. package/src/pages/index.ts +20 -23
  174. package/src/pages/redirectToPreviewURL.ts +22 -33
  175. package/src/pages/setPreviewData.ts +7 -7
  176. package/src/pages/types.ts +16 -20
  177. package/src/redirectToPreviewURL.ts +21 -30
  178. package/src/types.ts +12 -13
package/dist/pages.cjs CHANGED
@@ -1,14 +1,14 @@
1
- const require_PrismicNextLink = require('./PrismicNextLink.cjs');
2
- const require_imgixLoader = require('./imgixLoader.cjs');
3
- const require_PrismicNextImage = require('./PrismicNextImage.cjs');
4
- const require_createLocaleRedirect = require('./createLocaleRedirect.cjs');
5
- const require_SliceSimulator = require('./pages/SliceSimulator.cjs');
6
- const require_PrismicPreview = require('./pages/PrismicPreview.cjs');
7
- const require_enableAutoPreviews = require('./pages/enableAutoPreviews.cjs');
8
- const require_redirectToPreviewURL = require('./pages/redirectToPreviewURL.cjs');
9
- const require_exitPreview = require('./pages/exitPreview.cjs');
10
- const require_setPreviewData = require('./pages/setPreviewData.cjs');
11
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_PrismicNextLink = require("./PrismicNextLink.cjs");
3
+ const require_imgixLoader = require("./imgixLoader.cjs");
4
+ const require_PrismicNextImage = require("./PrismicNextImage.cjs");
5
+ const require_createLocaleRedirect = require("./createLocaleRedirect.cjs");
6
+ const require_SliceSimulator = require("./pages/SliceSimulator.cjs");
7
+ const require_PrismicPreview = require("./pages/PrismicPreview.cjs");
8
+ const require_enableAutoPreviews = require("./pages/enableAutoPreviews.cjs");
9
+ const require_redirectToPreviewURL = require("./pages/redirectToPreviewURL.cjs");
10
+ const require_exitPreview = require("./pages/exitPreview.cjs");
11
+ const require_setPreviewData = require("./pages/setPreviewData.cjs");
12
12
  exports.PrismicNextImage = require_PrismicNextImage.PrismicNextImage;
13
13
  exports.PrismicNextLink = require_PrismicNextLink.PrismicNextLink;
14
14
  exports.PrismicPreview = require_PrismicPreview.PrismicPreview;
@@ -18,4 +18,4 @@ exports.enableAutoPreviews = require_enableAutoPreviews.enableAutoPreviews;
18
18
  exports.exitPreview = require_exitPreview.exitPreview;
19
19
  exports.imgixLoader = require_imgixLoader.imgixLoader;
20
20
  exports.redirectToPreviewURL = require_redirectToPreviewURL.redirectToPreviewURL;
21
- exports.setPreviewData = require_setPreviewData.setPreviewData;
21
+ exports.setPreviewData = require_setPreviewData.setPreviewData;
package/dist/pages.js CHANGED
@@ -8,5 +8,4 @@ import { enableAutoPreviews } from "./pages/enableAutoPreviews.js";
8
8
  import { redirectToPreviewURL } from "./pages/redirectToPreviewURL.js";
9
9
  import { exitPreview } from "./pages/exitPreview.js";
10
10
  import { setPreviewData } from "./pages/setPreviewData.js";
11
-
12
- export { PrismicNextImage, PrismicNextLink, PrismicPreview, SliceSimulator, createLocaleRedirect, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL, setPreviewData };
11
+ export { PrismicNextImage, PrismicNextLink, PrismicPreview, SliceSimulator, createLocaleRedirect, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL, setPreviewData };
@@ -1,11 +1,10 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ require("./_virtual/_rolldown/runtime.cjs");
2
2
  let _prismicio_client = require("@prismicio/client");
3
3
  let next_navigation = require("next/navigation");
4
-
5
4
  //#region src/redirectToPreviewURL.ts
6
5
  async function redirectToPreviewURL(config) {
7
6
  const { client, request, linkResolver, defaultURL = "/" } = config;
8
- const { cookies, draftMode } = await import("next/headers");
7
+ const { cookies, draftMode } = await import("next/headers.js");
9
8
  const documentID = request.nextUrl.searchParams.get("documentId") ?? void 0;
10
9
  const previewToken = request.nextUrl.searchParams.get("token") ?? void 0;
11
10
  if (previewToken) (await cookies()).set(_prismicio_client.cookie.preview, previewToken);
@@ -18,7 +17,7 @@ async function redirectToPreviewURL(config) {
18
17
  (await draftMode()).enable();
19
18
  (0, next_navigation.redirect)(previewURL);
20
19
  }
21
-
22
20
  //#endregion
23
21
  exports.redirectToPreviewURL = redirectToPreviewURL;
22
+
24
23
  //# sourceMappingURL=redirectToPreviewURL.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.cjs","names":["prismicCookie"],"sources":["../src/redirectToPreviewURL.ts"],"sourcesContent":["import { redirect } from \"next/navigation\";\nimport {\n\tcookie as prismicCookie,\n\ttype Client,\n\ttype LinkResolverFunction,\n} from \"@prismicio/client\";\n\nimport type { NextRequestLike } from \"./types\";\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">;\n\n\t/**\n\t * The `request` object from a Next.js Route Handler.\n\t *\n\t * @see Next.js Route Handler docs: \\<https://nextjs.org/docs/app/building-your-application/routing/route-handlers\\>\n\t */\n\trequest: NextRequestLike;\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed\n\t * document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the\n\t * `defaultURL` option must _not_ include it. Instead, provide the `basePath`\n\t * property using the `basePath` option.\n\t */\n\tdefaultURL?: string;\n};\n\nexport async function redirectToPreviewURL(\n\tconfig: RedirectToPreviewURLConfig,\n): Promise<never> {\n\tconst { client, request, linkResolver, defaultURL = \"/\" } = config;\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 { cookies, draftMode } = await import(\"next/headers\");\n\n\tconst documentID =\n\t\trequest.nextUrl.searchParams.get(\"documentId\") ?? undefined;\n\n\t// Set the initial preview cookie. Setting the cookie here is necessary\n\t// to support unpublished previews. Without setting it here, the page\n\t// will try to render without the preview cookie, leading to a\n\t// PrismicNotFound error.\n\tconst previewToken = request.nextUrl.searchParams.get(\"token\") ?? undefined;\n\tif (previewToken) {\n\t\tconst cookieJar = await cookies();\n\t\tcookieJar.set(prismicCookie.preview, previewToken);\n\t}\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tdocumentID,\n\t\tpreviewToken,\n\t\tdefaultURL,\n\t\tlinkResolver,\n\t});\n\n\t(await draftMode()).enable();\n\n\tredirect(previewURL);\n}\n"],"mappings":";;;;;AAyCA,eAAsB,qBACrB,QACiB;CACjB,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,MAAM,aACL,QAAQ,QAAQ,aAAa,IAAI,aAAa,IAAI;CAMnD,MAAM,eAAe,QAAQ,QAAQ,aAAa,IAAI,QAAQ,IAAI;AAClE,KAAI,aAEH,EADkB,MAAM,SAAS,EACvB,IAAIA,yBAAc,SAAS,aAAa;CAGnD,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;EACA;EACA,CAAC;AAEF,EAAC,MAAM,WAAW,EAAE,QAAQ;AAE5B,+BAAS,WAAW"}
1
+ {"version":3,"file":"redirectToPreviewURL.cjs","names":["prismicCookie"],"sources":["../src/redirectToPreviewURL.ts"],"sourcesContent":["import { cookie as prismicCookie, type Client, type LinkResolverFunction } from \"@prismicio/client\"\nimport { redirect } from \"next/navigation\"\n\nimport type { NextRequestLike } from \"./types\"\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">\n\n\t/**\n\t * The `request` object from a Next.js Route Handler.\n\t *\n\t * @see Next.js Route Handler docs: \\<https://nextjs.org/docs/app/building-your-application/routing/route-handlers\\>\n\t */\n\trequest: NextRequestLike\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the `defaultURL` option must\n\t * _not_ include it. Instead, provide the `basePath` property using the `basePath` option.\n\t */\n\tdefaultURL?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<never> {\n\tconst { client, request, linkResolver, defaultURL = \"/\" } = config\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 { cookies, draftMode } = await import(\"next/headers\")\n\n\tconst documentID = request.nextUrl.searchParams.get(\"documentId\") ?? undefined\n\n\t// Set the initial preview cookie. Setting the cookie here is necessary\n\t// to support unpublished previews. Without setting it here, the page\n\t// will try to render without the preview cookie, leading to a\n\t// PrismicNotFound error.\n\tconst previewToken = request.nextUrl.searchParams.get(\"token\") ?? undefined\n\tif (previewToken) {\n\t\tconst cookieJar = await cookies()\n\t\tcookieJar.set(prismicCookie.preview, previewToken)\n\t}\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tdocumentID,\n\t\tpreviewToken,\n\t\tdefaultURL,\n\t\tlinkResolver,\n\t})\n\n\t;(await draftMode()).enable()\n\n\tredirect(previewURL)\n}\n"],"mappings":";;;;AAmCA,eAAsB,qBAAqB,QAAoD;CAC9F,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,MAAM,aAAa,QAAQ,QAAQ,aAAa,IAAI,aAAa,IAAI,KAAA;CAMrE,MAAM,eAAe,QAAQ,QAAQ,aAAa,IAAI,QAAQ,IAAI,KAAA;AAClE,KAAI,aAEH,EADkB,MAAM,SAAS,EACvB,IAAIA,kBAAAA,OAAc,SAAS,aAAa;CAGnD,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;EACA;EACA,CAAC;AAED,EAAC,MAAM,WAAW,EAAE,QAAQ;AAE7B,EAAA,GAAA,gBAAA,UAAS,WAAW"}
@@ -3,8 +3,7 @@ import { Client, LinkResolverFunction } from "@prismicio/client";
3
3
 
4
4
  //#region src/redirectToPreviewURL.d.ts
5
5
  type RedirectToPreviewURLConfig = {
6
- /** The Prismic client configured for the preview session's repository. */
7
- client: Pick<Client, "resolvePreviewURL">;
6
+ /** The Prismic client configured for the preview session's repository. */client: Pick<Client, "resolvePreviewURL">;
8
7
  /**
9
8
  * The `request` object from a Next.js Route Handler.
10
9
  *
@@ -18,12 +17,10 @@ type RedirectToPreviewURLConfig = {
18
17
  */
19
18
  linkResolver?: LinkResolverFunction;
20
19
  /**
21
- * The default redirect URL if a URL cannot be determined for the previewed
22
- * document.
20
+ * The default redirect URL if a URL cannot be determined for the previewed document.
23
21
  *
24
- * **Note**: If you `next.config.js` file contains a `basePath`, the
25
- * `defaultURL` option must _not_ include it. Instead, provide the `basePath`
26
- * property using the `basePath` option.
22
+ * **Note**: If you `next.config.js` file contains a `basePath`, the `defaultURL` option must
23
+ * _not_ include it. Instead, provide the `basePath` property using the `basePath` option.
27
24
  */
28
25
  defaultURL?: string;
29
26
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirectToPreviewURL.d.cts","names":[],"sources":["../src/redirectToPreviewURL.ts"],"mappings":";;;;KAKY,0BAAA;4EAKX,MAAA,EAAQ,IAAA,CAAK,MAAA;EALwB;;;;;EAYrC,OAAA,EAAS,eAAA;EAO0B;;;;;EAAnC,YAAA,GAAe,oBAAA;EAPN;;;;;;EAeT,UAAA;AAAA;AAAA,iBAGqB,oBAAA,CAAqB,MAAA,EAAQ,0BAAA,GAA6B,OAAA"}
@@ -3,8 +3,7 @@ import { Client, LinkResolverFunction } from "@prismicio/client";
3
3
 
4
4
  //#region src/redirectToPreviewURL.d.ts
5
5
  type RedirectToPreviewURLConfig = {
6
- /** The Prismic client configured for the preview session's repository. */
7
- client: Pick<Client, "resolvePreviewURL">;
6
+ /** The Prismic client configured for the preview session's repository. */client: Pick<Client, "resolvePreviewURL">;
8
7
  /**
9
8
  * The `request` object from a Next.js Route Handler.
10
9
  *
@@ -18,12 +17,10 @@ type RedirectToPreviewURLConfig = {
18
17
  */
19
18
  linkResolver?: LinkResolverFunction;
20
19
  /**
21
- * The default redirect URL if a URL cannot be determined for the previewed
22
- * document.
20
+ * The default redirect URL if a URL cannot be determined for the previewed document.
23
21
  *
24
- * **Note**: If you `next.config.js` file contains a `basePath`, the
25
- * `defaultURL` option must _not_ include it. Instead, provide the `basePath`
26
- * property using the `basePath` option.
22
+ * **Note**: If you `next.config.js` file contains a `basePath`, the `defaultURL` option must
23
+ * _not_ include it. Instead, provide the `basePath` property using the `basePath` option.
27
24
  */
28
25
  defaultURL?: string;
29
26
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirectToPreviewURL.d.ts","names":[],"sources":["../src/redirectToPreviewURL.ts"],"mappings":";;;;KAKY,0BAAA;4EAKX,MAAA,EAAQ,IAAA,CAAK,MAAA;EALwB;;;;;EAYrC,OAAA,EAAS,eAAA;EAO0B;;;;;EAAnC,YAAA,GAAe,oBAAA;EAPN;;;;;;EAeT,UAAA;AAAA;AAAA,iBAGqB,oBAAA,CAAqB,MAAA,EAAQ,0BAAA,GAA6B,OAAA"}
@@ -1,10 +1,9 @@
1
1
  import { cookie } from "@prismicio/client";
2
2
  import { redirect } from "next/navigation";
3
-
4
3
  //#region src/redirectToPreviewURL.ts
5
4
  async function redirectToPreviewURL(config) {
6
5
  const { client, request, linkResolver, defaultURL = "/" } = config;
7
- const { cookies, draftMode } = await import("next/headers");
6
+ const { cookies, draftMode } = await import("next/headers.js");
8
7
  const documentID = request.nextUrl.searchParams.get("documentId") ?? void 0;
9
8
  const previewToken = request.nextUrl.searchParams.get("token") ?? void 0;
10
9
  if (previewToken) (await cookies()).set(cookie.preview, previewToken);
@@ -17,7 +16,7 @@ async function redirectToPreviewURL(config) {
17
16
  (await draftMode()).enable();
18
17
  redirect(previewURL);
19
18
  }
20
-
21
19
  //#endregion
22
20
  export { redirectToPreviewURL };
21
+
23
22
  //# sourceMappingURL=redirectToPreviewURL.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.js","names":["prismicCookie"],"sources":["../src/redirectToPreviewURL.ts"],"sourcesContent":["import { redirect } from \"next/navigation\";\nimport {\n\tcookie as prismicCookie,\n\ttype Client,\n\ttype LinkResolverFunction,\n} from \"@prismicio/client\";\n\nimport type { NextRequestLike } from \"./types\";\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">;\n\n\t/**\n\t * The `request` object from a Next.js Route Handler.\n\t *\n\t * @see Next.js Route Handler docs: \\<https://nextjs.org/docs/app/building-your-application/routing/route-handlers\\>\n\t */\n\trequest: NextRequestLike;\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed\n\t * document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the\n\t * `defaultURL` option must _not_ include it. Instead, provide the `basePath`\n\t * property using the `basePath` option.\n\t */\n\tdefaultURL?: string;\n};\n\nexport async function redirectToPreviewURL(\n\tconfig: RedirectToPreviewURLConfig,\n): Promise<never> {\n\tconst { client, request, linkResolver, defaultURL = \"/\" } = config;\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 { cookies, draftMode } = await import(\"next/headers\");\n\n\tconst documentID =\n\t\trequest.nextUrl.searchParams.get(\"documentId\") ?? undefined;\n\n\t// Set the initial preview cookie. Setting the cookie here is necessary\n\t// to support unpublished previews. Without setting it here, the page\n\t// will try to render without the preview cookie, leading to a\n\t// PrismicNotFound error.\n\tconst previewToken = request.nextUrl.searchParams.get(\"token\") ?? undefined;\n\tif (previewToken) {\n\t\tconst cookieJar = await cookies();\n\t\tcookieJar.set(prismicCookie.preview, previewToken);\n\t}\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tdocumentID,\n\t\tpreviewToken,\n\t\tdefaultURL,\n\t\tlinkResolver,\n\t});\n\n\t(await draftMode()).enable();\n\n\tredirect(previewURL);\n}\n"],"mappings":";;;;AAyCA,eAAsB,qBACrB,QACiB;CACjB,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,MAAM,aACL,QAAQ,QAAQ,aAAa,IAAI,aAAa,IAAI;CAMnD,MAAM,eAAe,QAAQ,QAAQ,aAAa,IAAI,QAAQ,IAAI;AAClE,KAAI,aAEH,EADkB,MAAM,SAAS,EACvB,IAAIA,OAAc,SAAS,aAAa;CAGnD,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;EACA;EACA,CAAC;AAEF,EAAC,MAAM,WAAW,EAAE,QAAQ;AAE5B,UAAS,WAAW"}
1
+ {"version":3,"file":"redirectToPreviewURL.js","names":["prismicCookie"],"sources":["../src/redirectToPreviewURL.ts"],"sourcesContent":["import { cookie as prismicCookie, type Client, type LinkResolverFunction } from \"@prismicio/client\"\nimport { redirect } from \"next/navigation\"\n\nimport type { NextRequestLike } from \"./types\"\n\nexport type RedirectToPreviewURLConfig = {\n\t/** The Prismic client configured for the preview session's repository. */\n\t// `Pick` is used to use the smallest possible subset of\n\t// `prismic.Client`. Doing this reduces the surface area for breaking\n\t// type changes.\n\tclient: Pick<Client, \"resolvePreviewURL\">\n\n\t/**\n\t * The `request` object from a Next.js Route Handler.\n\t *\n\t * @see Next.js Route Handler docs: \\<https://nextjs.org/docs/app/building-your-application/routing/route-handlers\\>\n\t */\n\trequest: NextRequestLike\n\n\t/**\n\t * A Link Resolver used to resolve the previewed document's URL.\n\t *\n\t * @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The default redirect URL if a URL cannot be determined for the previewed document.\n\t *\n\t * **Note**: If you `next.config.js` file contains a `basePath`, the `defaultURL` option must\n\t * _not_ include it. Instead, provide the `basePath` property using the `basePath` option.\n\t */\n\tdefaultURL?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<never> {\n\tconst { client, request, linkResolver, defaultURL = \"/\" } = config\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 { cookies, draftMode } = await import(\"next/headers\")\n\n\tconst documentID = request.nextUrl.searchParams.get(\"documentId\") ?? undefined\n\n\t// Set the initial preview cookie. Setting the cookie here is necessary\n\t// to support unpublished previews. Without setting it here, the page\n\t// will try to render without the preview cookie, leading to a\n\t// PrismicNotFound error.\n\tconst previewToken = request.nextUrl.searchParams.get(\"token\") ?? undefined\n\tif (previewToken) {\n\t\tconst cookieJar = await cookies()\n\t\tcookieJar.set(prismicCookie.preview, previewToken)\n\t}\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tdocumentID,\n\t\tpreviewToken,\n\t\tdefaultURL,\n\t\tlinkResolver,\n\t})\n\n\t;(await draftMode()).enable()\n\n\tredirect(previewURL)\n}\n"],"mappings":";;;AAmCA,eAAsB,qBAAqB,QAAoD;CAC9F,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,MAAM,aAAa,QAAQ,QAAQ,aAAa,IAAI,aAAa,IAAI,KAAA;CAMrE,MAAM,eAAe,QAAQ,QAAQ,aAAa,IAAI,QAAQ,IAAI,KAAA;AAClE,KAAI,aAEH,EADkB,MAAM,SAAS,EACvB,IAAIA,OAAc,SAAS,aAAa;CAGnD,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;EACA;EACA,CAAC;AAED,EAAC,MAAM,WAAW,EAAE,QAAQ;AAE7B,UAAS,WAAW"}
package/dist/types.d.cts CHANGED
@@ -11,8 +11,7 @@ type CreateClientConfig = ClientConfig;
11
11
  /**
12
12
  * The minimal set of properties needed from `next`'s `NextRequest` type.
13
13
  *
14
- * This request type is only compatible with Route Handlers defined in the `app`
15
- * directory.
14
+ * This request type is only compatible with Route Handlers defined in the `app` directory.
16
15
  */
17
16
  type NextRequestLike = {
18
17
  headers: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;YAIW,eAAA;IACT,IAAA,GAAO,WAAA;EAAA;AAAA;;KAKG,kBAAA,GAAqB,YAAA;;;;;;KAOrB,eAAA;EACX,OAAA;IACC,GAAA,CAAI,IAAA;EAAA;EAEL,GAAA;EACA,OAAA;IACC,QAAA;IACA,YAAA;MACC,GAAA,CAAI,IAAA;IAAA;EAAA;AAAA"}
package/dist/types.d.ts CHANGED
@@ -11,8 +11,7 @@ type CreateClientConfig = ClientConfig;
11
11
  /**
12
12
  * The minimal set of properties needed from `next`'s `NextRequest` type.
13
13
  *
14
- * This request type is only compatible with Route Handlers defined in the `app`
15
- * directory.
14
+ * This request type is only compatible with Route Handlers defined in the `app` directory.
16
15
  */
17
16
  type NextRequestLike = {
18
17
  headers: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;YAIW,eAAA;IACT,IAAA,GAAO,WAAA;EAAA;AAAA;;KAKG,kBAAA,GAAqB,YAAA;;;;;;KAOrB,eAAA;EACX,OAAA;IACC,GAAA,CAAI,IAAA;EAAA;EAEL,GAAA;EACA,OAAA;IACC,QAAA;IACA,YAAA;MACC,GAAA,CAAI,IAAA;IAAA;EAAA;AAAA"}
package/package.json CHANGED
@@ -1,22 +1,32 @@
1
1
  {
2
2
  "name": "@prismicio/next",
3
- "version": "2.2.2",
3
+ "version": "2.2.3-canary.1abb259",
4
4
  "description": "Helpers to integrate Prismic into Next.js apps",
5
5
  "keywords": [
6
- "typescript",
7
- "prismic",
8
6
  "next",
9
- "vercel",
10
- "preview"
7
+ "preview",
8
+ "prismic",
9
+ "typescript",
10
+ "vercel"
11
11
  ],
12
+ "license": "Apache-2.0",
13
+ "author": "Prismic <contact@prismic.io> (https://prismic.io)",
12
14
  "repository": {
13
15
  "type": "git",
14
16
  "url": "git+https://github.com/prismicio/prismic-next.git"
15
17
  },
16
- "license": "Apache-2.0",
17
- "author": "Prismic <contact@prismic.io> (https://prismic.io)",
18
- "sideEffects": false,
18
+ "workspaces": [
19
+ ".",
20
+ "e2e-projects/*"
21
+ ],
22
+ "files": [
23
+ "dist",
24
+ "src"
25
+ ],
19
26
  "type": "module",
27
+ "sideEffects": false,
28
+ "main": "./dist/index.cjs",
29
+ "types": "./dist/index.d.ts",
20
30
  "exports": {
21
31
  ".": {
22
32
  "types": "./dist/index.d.ts",
@@ -28,22 +38,15 @@
28
38
  },
29
39
  "./package.json": "./package.json"
30
40
  },
31
- "main": "./dist/index.cjs",
32
- "types": "./dist/index.d.ts",
33
- "files": [
34
- "dist",
35
- "src"
36
- ],
37
- "workspaces": [
38
- ".",
39
- "e2e-projects/*"
40
- ],
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
41
44
  "scripts": {
42
45
  "build": "tsdown",
43
46
  "dev": "tsdown --watch",
44
47
  "e2e": "playwright test",
45
48
  "e2e:ui": "npm run e2e -- --ui",
46
- "format": "prettier --write .",
49
+ "format": "oxfmt",
47
50
  "lint": "oxlint --deny-warnings",
48
51
  "prepare": "npm run build",
49
52
  "test": "npm run lint && npm run types && npm run build && npm run e2e",
@@ -51,24 +54,22 @@
51
54
  },
52
55
  "dependencies": {
53
56
  "@prismicio/simulator": "^0.2.0",
54
- "imgix-url-builder": "^0.0.5",
57
+ "imgix-url-builder": "^0.0.6",
55
58
  "lz-string": "^1.5.0"
56
59
  },
57
60
  "devDependencies": {
58
- "@playwright/test": "^1.49.1",
61
+ "@playwright/test": "^1.58.2",
59
62
  "@prismicio/client": "^7.12.0",
60
- "@trivago/prettier-plugin-sort-imports": "^6.0.2",
61
- "@types/node": "^22.10.2",
62
- "@types/react": "^19.2.3",
63
- "next": "16.0.8",
64
- "oxlint": "^1.38.0",
65
- "playwright": "^1.49.1",
66
- "prettier": "^3.4.2",
67
- "prettier-plugin-jsdoc": "^1.3.0",
68
- "react": "^19.2.1",
69
- "react-dom": "^19.2.1",
70
- "tsdown": "^0.19.0-beta.5",
71
- "typescript": "^5.7.2"
63
+ "@types/node": "^25.5.0",
64
+ "@types/react": "^19.2.14",
65
+ "next": "16.2.1",
66
+ "oxfmt": "^0.43.0",
67
+ "oxlint": "^1.58.0",
68
+ "playwright": "^1.58.2",
69
+ "react": "^19.2.4",
70
+ "react-dom": "^19.2.4",
71
+ "tsdown": "^0.21.7",
72
+ "typescript": "^6.0.2"
72
73
  },
73
74
  "peerDependencies": {
74
75
  "@prismicio/client": "^7",
@@ -77,8 +78,5 @@
77
78
  },
78
79
  "engines": {
79
80
  "node": ">=20"
80
- },
81
- "publishConfig": {
82
- "access": "public"
83
81
  }
84
82
  }
@@ -1,185 +1,164 @@
1
- "use client";
2
-
3
- import type {
4
- ForwardRefExoticComponent,
5
- PropsWithoutRef,
6
- RefAttributes} from "react";
7
- import {
8
- forwardRef
9
- } from "react";
10
- import type { ImageProps } from "next/image";
11
- import Image from "next/image";
12
- import type { ImgixURLParams } from "imgix-url-builder";
13
- import { buildURL } from "imgix-url-builder";
14
- import type { ImageFieldImage} from "@prismicio/client";
15
- import { isFilled } from "@prismicio/client";
16
-
17
- import { devMsg } from "./lib/devMsg";
18
- import { resolveDefaultExport } from "./lib/resolveDefaultExport";
19
-
20
- import { imgixLoader } from "./imgixLoader";
1
+ "use client"
2
+
3
+ import type { ImageFieldImage } from "@prismicio/client"
4
+ import { isFilled } from "@prismicio/client"
5
+ import type { ImgixURLParams } from "imgix-url-builder"
6
+ import { buildURL } from "imgix-url-builder"
7
+ import type { ImageProps } from "next/image"
8
+ import Image from "next/image"
9
+ import type { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react"
10
+ import { forwardRef } from "react"
11
+
12
+ import { imgixLoader } from "./imgixLoader"
13
+ import { devMsg } from "./lib/devMsg"
14
+ import { resolveDefaultExport } from "./lib/resolveDefaultExport"
21
15
 
22
16
  const castInt = (input: string | number | undefined): number | undefined => {
23
17
  if (typeof input === "number" || typeof input === "undefined") {
24
- return input;
18
+ return input
25
19
  } else {
26
- const parsed = Number.parseInt(input);
20
+ const parsed = Number.parseInt(input)
27
21
 
28
22
  if (Number.isNaN(parsed)) {
29
- return undefined;
23
+ return undefined
30
24
  } else {
31
- return parsed;
25
+ return parsed
32
26
  }
33
27
  }
34
- };
28
+ }
35
29
 
36
- export type PrismicNextImageProps = Omit<
37
- ImageProps,
38
- "src" | "alt" | "loader"
39
- > & {
30
+ export type PrismicNextImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
40
31
  /** The Prismic Image field or thumbnail to render. */
41
- field: ImageFieldImage | null | undefined;
32
+ field: ImageFieldImage | null | undefined
42
33
 
43
34
  /**
44
35
  * An object of Imgix URL API parameters to transform the image.
45
36
  *
46
37
  * @see https://docs.imgix.com/apis/rendering
47
38
  */
48
- imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };
39
+ imgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null }
49
40
 
50
41
  /**
51
42
  * Declare an image as decorative by providing `alt=""`.
52
43
  *
53
- * See:
54
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
44
+ * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
55
45
  */
56
- alt?: "";
46
+ alt?: ""
57
47
 
58
48
  /**
59
- * Declare an image as decorative only if the Image field does not have
60
- * alternative text by providing `fallbackAlt=""`.
49
+ * Declare an image as decorative only if the Image field does not have alternative text by
50
+ * providing `fallbackAlt=""`.
61
51
  *
62
- * See:
63
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
52
+ * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
64
53
  */
65
- fallbackAlt?: "";
54
+ fallbackAlt?: ""
66
55
 
67
- /**
68
- * Rendered when the field is empty. If a fallback is not given, `null` will
69
- * be rendered.
70
- */
71
- fallback?: React.ReactNode;
56
+ /** Rendered when the field is empty. If a fallback is not given, `null` will be rendered. */
57
+ fallback?: React.ReactNode
72
58
 
73
- loader?: ImageProps["loader"] | null;
74
- };
59
+ loader?: ImageProps["loader"] | null
60
+ }
75
61
 
76
62
  /**
77
- * React component that renders an image from a Prismic Image field or one of
78
- * its thumbnails using `next/image`. It will automatically set the `alt`
79
- * attribute using the Image field's `alt` property.
63
+ * React component that renders an image from a Prismic Image field or one of its thumbnails using
64
+ * `next/image`. It will automatically set the `alt` attribute using the Image field's `alt`
65
+ * property.
80
66
  *
81
- * It uses an Imgix URL-based loader by default. A custom loader can be provided
82
- * with the `loader` prop. If you would like to use the Next.js Image
83
- * Optimization API instead, set `loader={undefined}`.
67
+ * It uses an Imgix URL-based loader by default. A custom loader can be provided with the `loader`
68
+ * prop. If you would like to use the Next.js Image Optimization API instead, set
69
+ * `loader={undefined}`.
84
70
  *
85
71
  * @param props - Props for the component.
86
- *
87
72
  * @returns A responsive image component using `next/image` for the given Image
88
- * field.
89
- *
73
+ * field.
90
74
  * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image
91
75
  */
92
76
  // The type annotation is necessary to avoid a type reference issue.
93
77
  export const PrismicNextImage: ForwardRefExoticComponent<
94
78
  PropsWithoutRef<PrismicNextImageProps> & RefAttributes<HTMLImageElement>
95
- > = forwardRef<HTMLImageElement, PrismicNextImageProps>(
96
- function PrismicNextImage(
97
- {
98
- field,
99
- imgixParams = {},
100
- alt,
101
- fallbackAlt,
102
- fill,
103
- width,
104
- height,
105
- fallback = null,
106
- loader = imgixLoader,
107
- ...restProps
108
- },
109
- ref,
110
- ) {
111
- if (process.env.NODE_ENV === "development") {
112
- if (typeof alt === "string" && alt !== "") {
113
- console.warn(
114
- `[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(
115
- "alt-must-be-an-empty-string",
116
- )}`,
117
- );
118
- }
119
-
120
- if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
121
- console.warn(
122
- `[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(
123
- "alt-must-be-an-empty-string",
124
- )}`,
125
- );
126
- }
79
+ > = forwardRef<HTMLImageElement, PrismicNextImageProps>(function PrismicNextImage(
80
+ {
81
+ field,
82
+ imgixParams = {},
83
+ alt,
84
+ fallbackAlt,
85
+ fill,
86
+ width,
87
+ height,
88
+ fallback = null,
89
+ loader = imgixLoader,
90
+ ...restProps
91
+ },
92
+ ref,
93
+ ) {
94
+ if (process.env.NODE_ENV === "development") {
95
+ if (typeof alt === "string" && alt !== "") {
96
+ console.warn(
97
+ `[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(
98
+ "alt-must-be-an-empty-string",
99
+ )}`,
100
+ )
127
101
  }
128
102
 
129
- if (!isFilled.imageThumbnail(field)) {
130
- return <>{fallback}</>;
103
+ if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
104
+ console.warn(
105
+ `[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(
106
+ "alt-must-be-an-empty-string",
107
+ )}`,
108
+ )
131
109
  }
110
+ }
132
111
 
133
- const resolvedImgixParams = imgixParams;
134
- for (const x in imgixParams) {
135
- if (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {
136
- resolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;
137
- }
112
+ if (!isFilled.imageThumbnail(field)) {
113
+ return <>{fallback}</>
114
+ }
115
+
116
+ const resolvedImgixParams = imgixParams
117
+ for (const x in imgixParams) {
118
+ if (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {
119
+ resolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined
138
120
  }
121
+ }
139
122
 
140
- const src = buildURL(field.url, imgixParams as ImgixURLParams);
123
+ const src = buildURL(field.url, imgixParams as ImgixURLParams)
141
124
 
142
- const ar = field.dimensions.width / field.dimensions.height;
125
+ const ar = field.dimensions.width / field.dimensions.height
143
126
 
144
- const castedWidth = castInt(width);
145
- const castedHeight = castInt(height);
127
+ const castedWidth = castInt(width)
128
+ const castedHeight = castInt(height)
146
129
 
147
- let resolvedWidth = castedWidth ?? field.dimensions.width;
148
- let resolvedHeight = castedHeight ?? field.dimensions.height;
130
+ let resolvedWidth = castedWidth ?? field.dimensions.width
131
+ let resolvedHeight = castedHeight ?? field.dimensions.height
149
132
 
150
- if (castedWidth != null && castedHeight == null) {
151
- resolvedHeight = castedWidth / ar;
152
- } else if (castedWidth == null && castedHeight != null) {
153
- resolvedWidth = castedHeight * ar;
154
- }
133
+ if (castedWidth != null && castedHeight == null) {
134
+ resolvedHeight = castedWidth / ar
135
+ } else if (castedWidth == null && castedHeight != null) {
136
+ resolvedWidth = castedHeight * ar
137
+ }
155
138
 
156
- // A non-null assertion is required since we can't statically
157
- // know if an alt attribute is available.
158
- const resolvedAlt = (alt ?? (field.alt || fallbackAlt))!;
159
-
160
- if (
161
- process.env.NODE_ENV === "development" &&
162
- typeof resolvedAlt !== "string"
163
- ) {
164
- console.error(
165
- `[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=""\`.`,
166
- src,
167
- );
168
- }
139
+ // A non-null assertion is required since we can't statically
140
+ // know if an alt attribute is available.
141
+ const resolvedAlt = (alt ?? (field.alt || fallbackAlt))!
169
142
 
170
- const ResolvedImage = resolveDefaultExport(Image);
171
-
172
- return (
173
- <ResolvedImage
174
- ref={ref}
175
- src={src}
176
- width={fill ? undefined : resolvedWidth}
177
- height={fill ? undefined : resolvedHeight}
178
- alt={resolvedAlt}
179
- fill={fill}
180
- loader={loader === null ? undefined : loader}
181
- {...restProps}
182
- />
183
- );
184
- },
185
- );
143
+ if (process.env.NODE_ENV === "development" && typeof resolvedAlt !== "string") {
144
+ console.error(
145
+ `[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=""\`.`,
146
+ src,
147
+ )
148
+ }
149
+
150
+ const ResolvedImage = resolveDefaultExport(Image)
151
+
152
+ return (
153
+ <ResolvedImage
154
+ ref={ref}
155
+ src={src}
156
+ width={fill ? undefined : resolvedWidth}
157
+ height={fill ? undefined : resolvedHeight}
158
+ alt={resolvedAlt}
159
+ fill={fill}
160
+ loader={loader === null ? undefined : loader}
161
+ {...restProps}
162
+ />
163
+ )
164
+ })