@prismicio/next 2.3.2 → 2.3.3-canary.6920973

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 (166) hide show
  1. package/dist/PrismicNextImage.cjs +6 -5
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.cts +5 -4
  4. package/dist/PrismicNextImage.d.cts.map +1 -1
  5. package/dist/PrismicNextImage.d.ts +5 -4
  6. package/dist/PrismicNextImage.d.ts.map +1 -1
  7. package/dist/PrismicNextImage.js +5 -4
  8. package/dist/PrismicNextImage.js.map +1 -1
  9. package/dist/PrismicNextLink.cjs +3 -2
  10. package/dist/PrismicNextLink.cjs.map +1 -1
  11. package/dist/PrismicNextLink.d.cts +8 -11
  12. package/dist/PrismicNextLink.d.cts.map +1 -1
  13. package/dist/PrismicNextLink.d.ts +7 -10
  14. package/dist/PrismicNextLink.d.ts.map +1 -1
  15. package/dist/PrismicNextLink.js +2 -1
  16. package/dist/PrismicNextLink.js.map +1 -1
  17. package/dist/PrismicPreview.cjs +2 -2
  18. package/dist/PrismicPreview.cjs.map +1 -1
  19. package/dist/PrismicPreview.d.cts +2 -2
  20. package/dist/PrismicPreview.d.cts.map +1 -1
  21. package/dist/PrismicPreview.d.ts +2 -2
  22. package/dist/PrismicPreview.d.ts.map +1 -1
  23. package/dist/PrismicPreview.js +1 -1
  24. package/dist/PrismicPreview.js.map +1 -1
  25. package/dist/PrismicPreviewClient.cjs +18 -13
  26. package/dist/PrismicPreviewClient.cjs.map +1 -1
  27. package/dist/PrismicPreviewClient.js +18 -12
  28. package/dist/PrismicPreviewClient.js.map +1 -1
  29. package/dist/SliceSimulator.cjs +3 -2
  30. package/dist/SliceSimulator.cjs.map +1 -1
  31. package/dist/SliceSimulator.d.cts +0 -1
  32. package/dist/SliceSimulator.d.cts.map +1 -1
  33. package/dist/SliceSimulator.d.ts +0 -1
  34. package/dist/SliceSimulator.d.ts.map +1 -1
  35. package/dist/SliceSimulator.js +2 -1
  36. package/dist/SliceSimulator.js.map +1 -1
  37. package/dist/SliceSimulatorWrapper.cjs +0 -1
  38. package/dist/SliceSimulatorWrapper.cjs.map +1 -1
  39. package/dist/SliceSimulatorWrapper.js.map +1 -1
  40. package/dist/_virtual/_rolldown/runtime.cjs +1 -1
  41. package/dist/cacheTagPrismicPages.cjs +1 -1
  42. package/dist/cacheTagPrismicPages.cjs.map +1 -1
  43. package/dist/cacheTagPrismicPages.d.cts +0 -1
  44. package/dist/cacheTagPrismicPages.d.cts.map +1 -1
  45. package/dist/cacheTagPrismicPages.d.ts +0 -1
  46. package/dist/cacheTagPrismicPages.d.ts.map +1 -1
  47. package/dist/cacheTagPrismicPages.js.map +1 -1
  48. package/dist/createLocaleRedirect.cjs.map +1 -1
  49. package/dist/createLocaleRedirect.d.cts.map +1 -1
  50. package/dist/createLocaleRedirect.d.ts.map +1 -1
  51. package/dist/createLocaleRedirect.js.map +1 -1
  52. package/dist/enableAutoPreviews.cjs.map +1 -1
  53. package/dist/enableAutoPreviews.d.cts +2 -2
  54. package/dist/enableAutoPreviews.d.cts.map +1 -1
  55. package/dist/enableAutoPreviews.d.ts +2 -2
  56. package/dist/enableAutoPreviews.d.ts.map +1 -1
  57. package/dist/enableAutoPreviews.js.map +1 -1
  58. package/dist/exitPreview.cjs +12 -4
  59. package/dist/exitPreview.cjs.map +1 -1
  60. package/dist/exitPreview.d.cts.map +1 -1
  61. package/dist/exitPreview.d.ts.map +1 -1
  62. package/dist/exitPreview.js +12 -3
  63. package/dist/exitPreview.js.map +1 -1
  64. package/dist/getPreviewRef.cjs +1 -2
  65. package/dist/getPreviewRef.cjs.map +1 -1
  66. package/dist/getPreviewRef.d.cts.map +1 -1
  67. package/dist/getPreviewRef.d.ts.map +1 -1
  68. package/dist/getPreviewRef.js +1 -1
  69. package/dist/getPreviewRef.js.map +1 -1
  70. package/dist/getPrismicCacheTags.cjs +4 -2
  71. package/dist/getPrismicCacheTags.cjs.map +1 -1
  72. package/dist/getPrismicCacheTags.d.cts +0 -1
  73. package/dist/getPrismicCacheTags.d.cts.map +1 -1
  74. package/dist/getPrismicCacheTags.d.ts +0 -1
  75. package/dist/getPrismicCacheTags.d.ts.map +1 -1
  76. package/dist/getPrismicCacheTags.js +4 -2
  77. package/dist/getPrismicCacheTags.js.map +1 -1
  78. package/dist/getSlices.cjs +1 -1
  79. package/dist/getSlices.cjs.map +1 -1
  80. package/dist/getSlices.d.cts +0 -1
  81. package/dist/getSlices.d.cts.map +1 -1
  82. package/dist/getSlices.d.ts +0 -1
  83. package/dist/getSlices.d.ts.map +1 -1
  84. package/dist/getSlices.js.map +1 -1
  85. package/dist/imgixLoader.cjs +0 -1
  86. package/dist/imgixLoader.cjs.map +1 -1
  87. package/dist/imgixLoader.d.cts +0 -1
  88. package/dist/imgixLoader.d.cts.map +1 -1
  89. package/dist/imgixLoader.d.ts +0 -1
  90. package/dist/imgixLoader.d.ts.map +1 -1
  91. package/dist/imgixLoader.js.map +1 -1
  92. package/dist/lib/devMsg.cjs.map +1 -1
  93. package/dist/lib/devMsg.js.map +1 -1
  94. package/dist/lib/resolveDefaultExport.cjs.map +1 -1
  95. package/dist/lib/resolveDefaultExport.js.map +1 -1
  96. package/dist/package.cjs +1 -1
  97. package/dist/package.js +1 -1
  98. package/dist/pages/PrismicPreview.cjs +1 -1
  99. package/dist/pages/PrismicPreview.cjs.map +1 -1
  100. package/dist/pages/PrismicPreview.d.cts +2 -2
  101. package/dist/pages/PrismicPreview.d.cts.map +1 -1
  102. package/dist/pages/PrismicPreview.d.ts +2 -2
  103. package/dist/pages/PrismicPreview.d.ts.map +1 -1
  104. package/dist/pages/PrismicPreview.js.map +1 -1
  105. package/dist/pages/SliceSimulator.cjs +0 -1
  106. package/dist/pages/SliceSimulator.cjs.map +1 -1
  107. package/dist/pages/SliceSimulator.d.cts +0 -1
  108. package/dist/pages/SliceSimulator.d.cts.map +1 -1
  109. package/dist/pages/SliceSimulator.d.ts +0 -1
  110. package/dist/pages/SliceSimulator.d.ts.map +1 -1
  111. package/dist/pages/SliceSimulator.js.map +1 -1
  112. package/dist/pages/enableAutoPreviews.cjs.map +1 -1
  113. package/dist/pages/enableAutoPreviews.d.cts +2 -2
  114. package/dist/pages/enableAutoPreviews.d.cts.map +1 -1
  115. package/dist/pages/enableAutoPreviews.d.ts +2 -2
  116. package/dist/pages/enableAutoPreviews.d.ts.map +1 -1
  117. package/dist/pages/enableAutoPreviews.js.map +1 -1
  118. package/dist/pages/exitPreview.cjs.map +1 -1
  119. package/dist/pages/exitPreview.d.cts +0 -1
  120. package/dist/pages/exitPreview.d.cts.map +1 -1
  121. package/dist/pages/exitPreview.d.ts +0 -1
  122. package/dist/pages/exitPreview.d.ts.map +1 -1
  123. package/dist/pages/exitPreview.js.map +1 -1
  124. package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
  125. package/dist/pages/redirectToPreviewURL.d.cts +2 -2
  126. package/dist/pages/redirectToPreviewURL.d.cts.map +1 -1
  127. package/dist/pages/redirectToPreviewURL.d.ts +2 -2
  128. package/dist/pages/redirectToPreviewURL.d.ts.map +1 -1
  129. package/dist/pages/redirectToPreviewURL.js.map +1 -1
  130. package/dist/pages/setPreviewData.cjs +0 -1
  131. package/dist/pages/setPreviewData.cjs.map +1 -1
  132. package/dist/pages/setPreviewData.d.cts +1 -5
  133. package/dist/pages/setPreviewData.d.cts.map +1 -1
  134. package/dist/pages/setPreviewData.d.ts +1 -5
  135. package/dist/pages/setPreviewData.d.ts.map +1 -1
  136. package/dist/pages/setPreviewData.js.map +1 -1
  137. package/dist/pages/types.d.cts +0 -1
  138. package/dist/pages/types.d.cts.map +1 -1
  139. package/dist/pages/types.d.ts +0 -1
  140. package/dist/pages/types.d.ts.map +1 -1
  141. package/dist/redirectToPreviewURL.cjs +11 -2
  142. package/dist/redirectToPreviewURL.cjs.map +1 -1
  143. package/dist/redirectToPreviewURL.d.cts +2 -2
  144. package/dist/redirectToPreviewURL.d.cts.map +1 -1
  145. package/dist/redirectToPreviewURL.d.ts +2 -2
  146. package/dist/redirectToPreviewURL.d.ts.map +1 -1
  147. package/dist/redirectToPreviewURL.js +11 -1
  148. package/dist/redirectToPreviewURL.js.map +1 -1
  149. package/dist/revalidatePrismicPages.cjs +4 -2
  150. package/dist/revalidatePrismicPages.cjs.map +1 -1
  151. package/dist/revalidatePrismicPages.d.cts.map +1 -1
  152. package/dist/revalidatePrismicPages.d.ts.map +1 -1
  153. package/dist/revalidatePrismicPages.js +4 -1
  154. package/dist/revalidatePrismicPages.js.map +1 -1
  155. package/dist/types.d.cts +0 -1
  156. package/dist/types.d.cts.map +1 -1
  157. package/dist/types.d.ts +0 -1
  158. package/dist/types.d.ts.map +1 -1
  159. package/package.json +15 -15
  160. package/src/PrismicNextImage.tsx +5 -5
  161. package/src/PrismicNextLink.tsx +2 -2
  162. package/src/PrismicPreview.tsx +2 -2
  163. package/src/PrismicPreviewClient.tsx +26 -11
  164. package/src/exitPreview.ts +4 -6
  165. package/src/getPreviewRef.ts +3 -2
  166. package/src/redirectToPreviewURL.ts +10 -2
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.cjs","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } 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 `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike\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\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`. This option can be\n\t * omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath` automatically. It\n\t * must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void> {\n\tconst { client, req, res, linkResolver, defaultURL = \"/\", basePath = \"\" } = config\n\n\tconst previewToken = req.query.token?.toString()\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t})\n\n\tres.redirect(basePath + previewURL)\n\n\treturn\n}\n"],"mappings":";AAmDA,eAAsB,qBAAqB,QAAmD;CAC7F,MAAM,EAAE,QAAQ,KAAK,KAAK,cAAc,aAAa,KAAK,WAAW,OAAO;CAE5E,MAAM,eAAe,IAAI,MAAM,OAAO,UAAU;CAEhD,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;EACA,CAAC;AAEF,KAAI,SAAS,WAAW,WAAW"}
1
+ {"version":3,"file":"redirectToPreviewURL.cjs","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } 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 `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike\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\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`. This option can be\n\t * omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath` automatically. It\n\t * must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void> {\n\tconst { client, req, res, linkResolver, defaultURL = \"/\", basePath = \"\" } = config\n\n\tconst previewToken = req.query.token?.toString()\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t})\n\n\tres.redirect(basePath + previewURL)\n\n\treturn\n}\n"],"mappings":";AAmDA,eAAsB,qBAAqB,QAAmD;CAC7F,MAAM,EAAE,QAAQ,KAAK,KAAK,cAAc,aAAa,KAAK,WAAW,OAAO;CAE5E,MAAM,eAAe,IAAI,MAAM,OAAO,SAAS;CAE/C,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;CACD,CAAC;CAED,IAAI,SAAS,WAAW,UAAU;AAGnC"}
@@ -1,9 +1,9 @@
1
1
  import { NextApiRequestLike, NextApiResponseLike } from "./types.cjs";
2
2
  import { Client, LinkResolverFunction } from "@prismicio/client";
3
-
4
3
  //#region src/pages/redirectToPreviewURL.d.ts
5
4
  type RedirectToPreviewURLConfig = {
6
- /** The Prismic client configured for the preview session's repository. */client: Pick<Client, "resolvePreviewURL">;
5
+ /** The Prismic client configured for the preview session's repository. */
6
+ client: Pick<Client, "resolvePreviewURL">;
7
7
  /**
8
8
  * The `req` object from a Next.js API route.
9
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.d.cts","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"mappings":";;;;KAIY,0BAAA;4EAKX,MAAA,EAAQ,IAAA,CAAK,MAAA;EALwB;;;;;EAYrC,GAAA,EAAK,kBAAA;EAcU;;;;;EAPf,GAAA,EAAK,mBAAA;EAPL;;;;;EAcA,YAAA,GAAe,oBAAA;EAQf;;;;AAaD;;EAbC,UAAA;EAasF;;;;;;;;EAHtF,QAAA;AAAA;AAAA,iBAGqB,oBAAA,CAAqB,MAAA,EAAQ,0BAAA,GAA6B,OAAA"}
1
+ {"version":3,"file":"redirectToPreviewURL.d.cts","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"mappings":";;;KAIY;;EAKX,QAAQ,KAAK;;;;;;EAOb,KAAK;;;;;;EAOL,KAAK;;;;;;EAOL,eAAe;;;;;;;EAQf;;;;;;;;;EAUA;;iBAGqB,qBAAqB,QAAQ,6BAA6B"}
@@ -1,9 +1,9 @@
1
1
  import { NextApiRequestLike, NextApiResponseLike } from "./types.js";
2
2
  import { Client, LinkResolverFunction } from "@prismicio/client";
3
-
4
3
  //#region src/pages/redirectToPreviewURL.d.ts
5
4
  type RedirectToPreviewURLConfig = {
6
- /** The Prismic client configured for the preview session's repository. */client: Pick<Client, "resolvePreviewURL">;
5
+ /** The Prismic client configured for the preview session's repository. */
6
+ client: Pick<Client, "resolvePreviewURL">;
7
7
  /**
8
8
  * The `req` object from a Next.js API route.
9
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.d.ts","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"mappings":";;;;KAIY,0BAAA;4EAKX,MAAA,EAAQ,IAAA,CAAK,MAAA;EALwB;;;;;EAYrC,GAAA,EAAK,kBAAA;EAcU;;;;;EAPf,GAAA,EAAK,mBAAA;EAPL;;;;;EAcA,YAAA,GAAe,oBAAA;EAQf;;;;AAaD;;EAbC,UAAA;EAasF;;;;;;;;EAHtF,QAAA;AAAA;AAAA,iBAGqB,oBAAA,CAAqB,MAAA,EAAQ,0BAAA,GAA6B,OAAA"}
1
+ {"version":3,"file":"redirectToPreviewURL.d.ts","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"mappings":";;;KAIY;;EAKX,QAAQ,KAAK;;;;;;EAOb,KAAK;;;;;;EAOL,KAAK;;;;;;EAOL,eAAe;;;;;;;EAQf;;;;;;;;;EAUA;;iBAGqB,qBAAqB,QAAQ,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.js","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } 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 `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike\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\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`. This option can be\n\t * omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath` automatically. It\n\t * must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void> {\n\tconst { client, req, res, linkResolver, defaultURL = \"/\", basePath = \"\" } = config\n\n\tconst previewToken = req.query.token?.toString()\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t})\n\n\tres.redirect(basePath + previewURL)\n\n\treturn\n}\n"],"mappings":";AAmDA,eAAsB,qBAAqB,QAAmD;CAC7F,MAAM,EAAE,QAAQ,KAAK,KAAK,cAAc,aAAa,KAAK,WAAW,OAAO;CAE5E,MAAM,eAAe,IAAI,MAAM,OAAO,UAAU;CAEhD,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;EACA,CAAC;AAEF,KAAI,SAAS,WAAW,WAAW"}
1
+ {"version":3,"file":"redirectToPreviewURL.js","names":[],"sources":["../../src/pages/redirectToPreviewURL.ts"],"sourcesContent":["import type { LinkResolverFunction, Client } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } 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 `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\\>\n\t */\n\tres: NextApiResponseLike\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\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`. This option can be\n\t * omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The Router Handler or API route is unable to detect the app's `basePath` automatically. It\n\t * must be provided to `redirectToPreviewURL()` manually.\n\t */\n\tbasePath?: string\n}\n\nexport async function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void> {\n\tconst { client, req, res, linkResolver, defaultURL = \"/\", basePath = \"\" } = config\n\n\tconst previewToken = req.query.token?.toString()\n\n\tconst previewURL = await client.resolvePreviewURL({\n\t\tlinkResolver,\n\t\tdefaultURL,\n\t\tpreviewToken,\n\t})\n\n\tres.redirect(basePath + previewURL)\n\n\treturn\n}\n"],"mappings":";AAmDA,eAAsB,qBAAqB,QAAmD;CAC7F,MAAM,EAAE,QAAQ,KAAK,KAAK,cAAc,aAAa,KAAK,WAAW,OAAO;CAE5E,MAAM,eAAe,IAAI,MAAM,OAAO,SAAS;CAE/C,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;CACD,CAAC;CAED,IAAI,SAAS,WAAW,UAAU;AAGnC"}
@@ -1,4 +1,3 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
1
  let _prismicio_client = require("@prismicio/client");
3
2
  //#region src/pages/setPreviewData.ts
4
3
  /** Set Prismic preview data for Next.js's Preview Mode. */
@@ -1 +1 @@
1
- {"version":3,"file":"setPreviewData.cjs","names":["cookie"],"sources":["../../src/pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview]\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref })\n\t}\n}\n"],"mappings":";;;;AAsBA,SAAgB,eAAe,EAAE,KAAK,OAAmC;CACxE,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQA,kBAAAA,OAAO;AAElD,KAAI,IACH,KAAI,eAAe,EAAE,KAAK,CAAC"}
1
+ {"version":3,"file":"setPreviewData.cjs","names":["cookie"],"sources":["../../src/pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview]\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref })\n\t}\n}\n"],"mappings":";;;AAsBA,SAAgB,eAAe,EAAE,KAAK,OAAmC;CACxE,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQA,kBAAAA,OAAO;CAElD,IAAI,KACH,IAAI,eAAe,EAAE,IAAI,CAAC;AAE5B"}
@@ -1,5 +1,4 @@
1
1
  import { NextApiRequestLike, NextApiResponseLike } from "./types.cjs";
2
-
3
2
  //#region src/pages/setPreviewData.d.ts
4
3
  /** Configuration for `setPreviewData`. */
5
4
  type SetPreviewDataConfig = {
@@ -17,10 +16,7 @@ type SetPreviewDataConfig = {
17
16
  res: NextApiResponseLike;
18
17
  };
19
18
  /** Set Prismic preview data for Next.js's Preview Mode. */
20
- declare function setPreviewData({
21
- req,
22
- res
23
- }: SetPreviewDataConfig): void;
19
+ declare function setPreviewData({ req, res }: SetPreviewDataConfig): void;
24
20
  //#endregion
25
21
  export { SetPreviewDataConfig, setPreviewData };
26
22
  //# sourceMappingURL=setPreviewData.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setPreviewData.d.cts","names":[],"sources":["../../src/pages/setPreviewData.ts"],"mappings":";;;;KAKY,oBAAA;EAAA;;;;;EAMX,GAAA,EAAK,kBAAA;EAOL;;;;AAID;EAJC,GAAA,EAAK,mBAAA;AAAA;;iBAIU,cAAA,CAAA;EAAiB,GAAA;EAAK;AAAA,GAAO,oBAAA"}
1
+ {"version":3,"file":"setPreviewData.d.cts","names":[],"sources":["../../src/pages/setPreviewData.ts"],"mappings":";;;KAKY;;;;;;EAMX,KAAK;;;;;;EAOL,KAAK;;;iBAIU,iBAAiB,KAAK,OAAO"}
@@ -1,5 +1,4 @@
1
1
  import { NextApiRequestLike, NextApiResponseLike } from "./types.js";
2
-
3
2
  //#region src/pages/setPreviewData.d.ts
4
3
  /** Configuration for `setPreviewData`. */
5
4
  type SetPreviewDataConfig = {
@@ -17,10 +16,7 @@ type SetPreviewDataConfig = {
17
16
  res: NextApiResponseLike;
18
17
  };
19
18
  /** Set Prismic preview data for Next.js's Preview Mode. */
20
- declare function setPreviewData({
21
- req,
22
- res
23
- }: SetPreviewDataConfig): void;
19
+ declare function setPreviewData({ req, res }: SetPreviewDataConfig): void;
24
20
  //#endregion
25
21
  export { SetPreviewDataConfig, setPreviewData };
26
22
  //# sourceMappingURL=setPreviewData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setPreviewData.d.ts","names":[],"sources":["../../src/pages/setPreviewData.ts"],"mappings":";;;;KAKY,oBAAA;EAAA;;;;;EAMX,GAAA,EAAK,kBAAA;EAOL;;;;AAID;EAJC,GAAA,EAAK,mBAAA;AAAA;;iBAIU,cAAA,CAAA;EAAiB,GAAA;EAAK;AAAA,GAAO,oBAAA"}
1
+ {"version":3,"file":"setPreviewData.d.ts","names":[],"sources":["../../src/pages/setPreviewData.ts"],"mappings":";;;KAKY;;;;;;EAMX,KAAK;;;;;;EAOL,KAAK;;;iBAIU,iBAAiB,KAAK,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"setPreviewData.js","names":[],"sources":["../../src/pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview]\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref })\n\t}\n}\n"],"mappings":";;;AAsBA,SAAgB,eAAe,EAAE,KAAK,OAAmC;CACxE,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,OAAO;AAElD,KAAI,IACH,KAAI,eAAe,EAAE,KAAK,CAAC"}
1
+ {"version":3,"file":"setPreviewData.js","names":[],"sources":["../../src/pages/setPreviewData.ts"],"sourcesContent":["import { cookie } from \"@prismicio/client\"\n\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `setPreviewData`. */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/** Set Prismic preview data for Next.js's Preview Mode. */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[cookie.preview]\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref })\n\t}\n}\n"],"mappings":";;;AAsBA,SAAgB,eAAe,EAAE,KAAK,OAAmC;CACxE,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,OAAO;CAElD,IAAI,KACH,IAAI,eAAe,EAAE,IAAI,CAAC;AAE5B"}
@@ -1,6 +1,5 @@
1
1
  import { EnableAutoPreviewsConfig } from "./enableAutoPreviews.cjs";
2
2
  import { ClientConfig } from "@prismicio/client";
3
-
4
3
  //#region src/pages/types.d.ts
5
4
  /** Configuration for creating a Prismic client with automatic preview support in Next.js apps. */
6
5
  type CreateClientConfig = ClientConfig & Pick<EnableAutoPreviewsConfig, "previewData" | "req">;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/pages/types.ts"],"mappings":";;;;;KAKY,kBAAA,GAAqB,YAAA,GAChC,IAAA,CAAK,wBAAA;AADN;;;;;AAAA,KAQY,kBAAA;EACX,KAAA,EAAO,OAAA,CAAQ,MAAA;EACf,OAAA,EAAS,OAAA,CAAQ,MAAA;AAAA;;;;;AAFlB;KAUY,mBAAA;EACX,QAAA,CAAS,GAAA,WAAc,mBAAA;EACvB,gBAAA,IAAoB,mBAAA;EACpB,SAAA,CAAU,IAAA,UAAc,KAAA,sBAA2B,mBAAA;EAEnD,IAAA,CAAK,IAAA;EACL,cAAA,CAAe,IAAA,oBAAwB,mBAAA;AAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/pages/types.ts"],"mappings":";;;;KAKY,qBAAqB,eAChC,KAAK;;;;;;KAOM;EACX,OAAO,QAAQ;EACf,SAAS,QAAQ;;;;;;;KAQN;EACX,SAAS,cAAc;EACvB,oBAAoB;EACpB,UAAU,cAAc,2BAA2B;EAEnD,KAAK;EACL,eAAe,wBAAwB"}
@@ -1,6 +1,5 @@
1
1
  import { EnableAutoPreviewsConfig } from "./enableAutoPreviews.js";
2
2
  import { ClientConfig } from "@prismicio/client";
3
-
4
3
  //#region src/pages/types.d.ts
5
4
  /** Configuration for creating a Prismic client with automatic preview support in Next.js apps. */
6
5
  type CreateClientConfig = ClientConfig & Pick<EnableAutoPreviewsConfig, "previewData" | "req">;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/pages/types.ts"],"mappings":";;;;;KAKY,kBAAA,GAAqB,YAAA,GAChC,IAAA,CAAK,wBAAA;AADN;;;;;AAAA,KAQY,kBAAA;EACX,KAAA,EAAO,OAAA,CAAQ,MAAA;EACf,OAAA,EAAS,OAAA,CAAQ,MAAA;AAAA;;;;;AAFlB;KAUY,mBAAA;EACX,QAAA,CAAS,GAAA,WAAc,mBAAA;EACvB,gBAAA,IAAoB,mBAAA;EACpB,SAAA,CAAU,IAAA,UAAc,KAAA,sBAA2B,mBAAA;EAEnD,IAAA,CAAK,IAAA;EACL,cAAA,CAAe,IAAA,oBAAwB,mBAAA;AAAA"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/pages/types.ts"],"mappings":";;;;KAKY,qBAAqB,eAChC,KAAK;;;;;;KAOM;EACX,OAAO,QAAQ;EACf,SAAS,QAAQ;;;;;;;KAQN;EACX,SAAS,cAAc;EACvB,oBAAoB;EACpB,UAAU,cAAc,2BAA2B;EAEnD,KAAK;EACL,eAAe,wBAAwB"}
@@ -1,4 +1,3 @@
1
- require("./_virtual/_rolldown/runtime.cjs");
2
1
  let _prismicio_client = require("@prismicio/client");
3
2
  //#region src/redirectToPreviewURL.ts
4
3
  async function redirectToPreviewURL(config) {
@@ -6,8 +5,12 @@ async function redirectToPreviewURL(config) {
6
5
  const { cookies, draftMode } = await import("next/headers.js");
7
6
  const { redirect } = await import("next/navigation");
8
7
  const documentID = request.nextUrl.searchParams.get("documentId") ?? void 0;
8
+ const cookieJar = await cookies();
9
9
  const previewToken = request.nextUrl.searchParams.get("token") ?? void 0;
10
- if (previewToken) (await cookies()).set(_prismicio_client.cookie.preview, previewToken);
10
+ if (previewToken) cookieJar.set(_prismicio_client.cookie.preview, previewToken, {
11
+ sameSite: "none",
12
+ secure: true
13
+ });
11
14
  const previewURL = await client.resolvePreviewURL({
12
15
  documentID,
13
16
  previewToken,
@@ -15,6 +18,12 @@ async function redirectToPreviewURL(config) {
15
18
  linkResolver
16
19
  });
17
20
  (await draftMode()).enable();
21
+ cookieJar.set({
22
+ ...cookieJar.get("__prerender_bypass"),
23
+ httpOnly: true,
24
+ sameSite: "none",
25
+ secure: true
26
+ });
18
27
  return redirect(previewURL);
19
28
  }
20
29
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.cjs","names":["prismicCookie"],"sources":["../src/redirectToPreviewURL.ts"],"sourcesContent":["import { cookie as prismicCookie, type Client, type LinkResolverFunction } 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 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\t// Dynamic so Node.js can load this module: the bare specifier (kept by\n\t// tsdown.config.ts for Next.js's server alias) is not resolvable by Node.js.\n\tconst { redirect } = await import(\"next/navigation\")\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\treturn redirect(previewURL)\n}\n"],"mappings":";;;AAkCA,eAAsB,qBAAqB,QAAoD;CAC9F,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAI5C,MAAM,EAAE,aAAa,MAAM,OAAO;CAElC,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,QAAO,SAAS,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\"\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\t// Dynamic so Node.js can load this module: the bare specifier (kept by\n\t// tsdown.config.ts for Next.js's server alias) is not resolvable by Node.js.\n\tconst { redirect } = await import(\"next/navigation\")\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 cookieJar = await cookies()\n\tconst previewToken = request.nextUrl.searchParams.get(\"token\") ?? undefined\n\tif (previewToken) {\n\t\tcookieJar.set(prismicCookie.preview, previewToken, { sameSite: \"none\", secure: true })\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\t// Next.js uses `SameSite=Lax` in development, which cross-site iframes drop.\n\tcookieJar.set({\n\t\t...cookieJar.get(\"__prerender_bypass\")!,\n\t\thttpOnly: true,\n\t\tsameSite: \"none\",\n\t\tsecure: true,\n\t})\n\n\treturn redirect(previewURL)\n}\n"],"mappings":";;AAkCA,eAAsB,qBAAqB,QAAoD;CAC9F,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAI5C,MAAM,EAAE,aAAa,MAAM,OAAO;CAElC,MAAM,aAAa,QAAQ,QAAQ,aAAa,IAAI,YAAY,KAAK,KAAA;CAMrE,MAAM,YAAY,MAAM,QAAQ;CAChC,MAAM,eAAe,QAAQ,QAAQ,aAAa,IAAI,OAAO,KAAK,KAAA;CAClE,IAAI,cACH,UAAU,IAAIA,kBAAAA,OAAc,SAAS,cAAc;EAAE,UAAU;EAAQ,QAAQ;CAAK,CAAC;CAGtF,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;EACA;CACD,CAAC;CAEA,CAAC,MAAM,UAAU,EAAA,CAAG,OAAO;CAG5B,UAAU,IAAI;EACb,GAAG,UAAU,IAAI,oBAAoB;EACrC,UAAU;EACV,UAAU;EACV,QAAQ;CACT,CAAC;CAED,OAAO,SAAS,UAAU;AAC3B"}
@@ -1,9 +1,9 @@
1
1
  import { NextRequestLike } from "./types.cjs";
2
2
  import { Client, LinkResolverFunction } from "@prismicio/client";
3
-
4
3
  //#region src/redirectToPreviewURL.d.ts
5
4
  type RedirectToPreviewURLConfig = {
6
- /** The Prismic client configured for the preview session's repository. */client: Pick<Client, "resolvePreviewURL">;
5
+ /** The Prismic client configured for the preview session's repository. */
6
+ client: Pick<Client, "resolvePreviewURL">;
7
7
  /**
8
8
  * The `request` object from a Next.js Route Handler.
9
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.d.cts","names":[],"sources":["../src/redirectToPreviewURL.ts"],"mappings":";;;;KAIY,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
+ {"version":3,"file":"redirectToPreviewURL.d.cts","names":[],"sources":["../src/redirectToPreviewURL.ts"],"mappings":";;;KAIY;;EAKX,QAAQ,KAAK;;;;;;EAOb,SAAS;;;;;;EAOT,eAAe;;;;;;;EAQf;;iBAGqB,qBAAqB,QAAQ,6BAA6B"}
@@ -1,9 +1,9 @@
1
1
  import { NextRequestLike } from "./types.js";
2
2
  import { Client, LinkResolverFunction } from "@prismicio/client";
3
-
4
3
  //#region src/redirectToPreviewURL.d.ts
5
4
  type RedirectToPreviewURLConfig = {
6
- /** The Prismic client configured for the preview session's repository. */client: Pick<Client, "resolvePreviewURL">;
5
+ /** The Prismic client configured for the preview session's repository. */
6
+ client: Pick<Client, "resolvePreviewURL">;
7
7
  /**
8
8
  * The `request` object from a Next.js Route Handler.
9
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.d.ts","names":[],"sources":["../src/redirectToPreviewURL.ts"],"mappings":";;;;KAIY,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
+ {"version":3,"file":"redirectToPreviewURL.d.ts","names":[],"sources":["../src/redirectToPreviewURL.ts"],"mappings":";;;KAIY;;EAKX,QAAQ,KAAK;;;;;;EAOb,SAAS;;;;;;EAOT,eAAe;;;;;;;EAQf;;iBAGqB,qBAAqB,QAAQ,6BAA6B"}
@@ -5,8 +5,12 @@ async function redirectToPreviewURL(config) {
5
5
  const { cookies, draftMode } = await import("next/headers.js");
6
6
  const { redirect } = await import("next/navigation");
7
7
  const documentID = request.nextUrl.searchParams.get("documentId") ?? void 0;
8
+ const cookieJar = await cookies();
8
9
  const previewToken = request.nextUrl.searchParams.get("token") ?? void 0;
9
- if (previewToken) (await cookies()).set(cookie.preview, previewToken);
10
+ if (previewToken) cookieJar.set(cookie.preview, previewToken, {
11
+ sameSite: "none",
12
+ secure: true
13
+ });
10
14
  const previewURL = await client.resolvePreviewURL({
11
15
  documentID,
12
16
  previewToken,
@@ -14,6 +18,12 @@ async function redirectToPreviewURL(config) {
14
18
  linkResolver
15
19
  });
16
20
  (await draftMode()).enable();
21
+ cookieJar.set({
22
+ ...cookieJar.get("__prerender_bypass"),
23
+ httpOnly: true,
24
+ sameSite: "none",
25
+ secure: true
26
+ });
17
27
  return redirect(previewURL);
18
28
  }
19
29
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.js","names":["prismicCookie"],"sources":["../src/redirectToPreviewURL.ts"],"sourcesContent":["import { cookie as prismicCookie, type Client, type LinkResolverFunction } 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 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\t// Dynamic so Node.js can load this module: the bare specifier (kept by\n\t// tsdown.config.ts for Next.js's server alias) is not resolvable by Node.js.\n\tconst { redirect } = await import(\"next/navigation\")\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\treturn redirect(previewURL)\n}\n"],"mappings":";;AAkCA,eAAsB,qBAAqB,QAAoD;CAC9F,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAI5C,MAAM,EAAE,aAAa,MAAM,OAAO;CAElC,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,QAAO,SAAS,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\"\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\t// Dynamic so Node.js can load this module: the bare specifier (kept by\n\t// tsdown.config.ts for Next.js's server alias) is not resolvable by Node.js.\n\tconst { redirect } = await import(\"next/navigation\")\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 cookieJar = await cookies()\n\tconst previewToken = request.nextUrl.searchParams.get(\"token\") ?? undefined\n\tif (previewToken) {\n\t\tcookieJar.set(prismicCookie.preview, previewToken, { sameSite: \"none\", secure: true })\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\t// Next.js uses `SameSite=Lax` in development, which cross-site iframes drop.\n\tcookieJar.set({\n\t\t...cookieJar.get(\"__prerender_bypass\")!,\n\t\thttpOnly: true,\n\t\tsameSite: \"none\",\n\t\tsecure: true,\n\t})\n\n\treturn redirect(previewURL)\n}\n"],"mappings":";;AAkCA,eAAsB,qBAAqB,QAAoD;CAC9F,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAI5C,MAAM,EAAE,aAAa,MAAM,OAAO;CAElC,MAAM,aAAa,QAAQ,QAAQ,aAAa,IAAI,YAAY,KAAK,KAAA;CAMrE,MAAM,YAAY,MAAM,QAAQ;CAChC,MAAM,eAAe,QAAQ,QAAQ,aAAa,IAAI,OAAO,KAAK,KAAA;CAClE,IAAI,cACH,UAAU,IAAIA,OAAc,SAAS,cAAc;EAAE,UAAU;EAAQ,QAAQ;CAAK,CAAC;CAGtF,MAAM,aAAa,MAAM,OAAO,kBAAkB;EACjD;EACA;EACA;EACA;CACD,CAAC;CAEA,CAAC,MAAM,UAAU,EAAA,CAAG,OAAO;CAG5B,UAAU,IAAI;EACb,GAAG,UAAU,IAAI,oBAAoB;EACrC,UAAU;EACV,UAAU;EACV,QAAQ;CACT,CAAC;CAED,OAAO,SAAS,UAAU;AAC3B"}
@@ -1,4 +1,3 @@
1
- require("./_virtual/_rolldown/runtime.cjs");
2
1
  const require_getPrismicCacheTags = require("./getPrismicCacheTags.cjs");
3
2
  let next_cache_js = require("next/cache.js");
4
3
  //#region src/revalidatePrismicPages.ts
@@ -12,7 +11,10 @@ let next_cache_js = require("next/cache.js");
12
11
  * @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
13
12
  */
14
13
  function revalidatePrismicPages(ids) {
15
- for (const id of ids) (0, next_cache_js.revalidateTag)(require_getPrismicCacheTags.buildPrismicCacheTag(id), { expire: 0 });
14
+ for (const id of ids) {
15
+ const tag = require_getPrismicCacheTags.buildPrismicCacheTag(id);
16
+ (0, next_cache_js.revalidateTag)(tag, { expire: 0 });
17
+ }
16
18
  }
17
19
  //#endregion
18
20
  exports.revalidatePrismicPages = revalidatePrismicPages;
@@ -1 +1 @@
1
- {"version":3,"file":"revalidatePrismicPages.cjs","names":["buildPrismicCacheTag"],"sources":["../src/revalidatePrismicPages.ts"],"sourcesContent":["import { revalidateTag } from \"next/cache\"\n\nimport { buildPrismicCacheTag } from \"./getPrismicCacheTags\"\n\n/**\n * Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs\n * typically comes from a Prismic webhook triggered when publishing content.\n *\n * @param ids - A list of Prismic page IDs to revalidate.\n * @experimental\n *\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}\n */\nexport function revalidatePrismicPages(ids: string[]): void {\n\tfor (const id of ids) {\n\t\tconst tag = buildPrismicCacheTag(id)\n\t\trevalidateTag(tag, { expire: 0 })\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,uBAAuB,KAAqB;AAC3D,MAAK,MAAM,MAAM,IAEhB,EAAA,GAAA,cAAA,eADYA,4BAAAA,qBAAqB,GAAG,EACjB,EAAE,QAAQ,GAAG,CAAC"}
1
+ {"version":3,"file":"revalidatePrismicPages.cjs","names":["buildPrismicCacheTag"],"sources":["../src/revalidatePrismicPages.ts"],"sourcesContent":["import { revalidateTag } from \"next/cache\"\n\nimport { buildPrismicCacheTag } from \"./getPrismicCacheTags\"\n\n/**\n * Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs\n * typically comes from a Prismic webhook triggered when publishing content.\n *\n * @param ids - A list of Prismic page IDs to revalidate.\n * @experimental\n *\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}\n */\nexport function revalidatePrismicPages(ids: string[]): void {\n\tfor (const id of ids) {\n\t\tconst tag = buildPrismicCacheTag(id)\n\t\trevalidateTag(tag, { expire: 0 })\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,uBAAuB,KAAqB;CAC3D,KAAK,MAAM,MAAM,KAAK;EACrB,MAAM,MAAMA,4BAAAA,qBAAqB,EAAE;EACnC,CAAA,GAAA,cAAA,cAAA,CAAc,KAAK,EAAE,QAAQ,EAAE,CAAC;CACjC;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"revalidatePrismicPages.d.cts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;AAaA;;;;;;;;iBAAgB,sBAAA,CAAuB,GAAA"}
1
+ {"version":3,"file":"revalidatePrismicPages.d.cts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;;;;;;;;;iBAagB,uBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"revalidatePrismicPages.d.ts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;AAaA;;;;;;;;iBAAgB,sBAAA,CAAuB,GAAA"}
1
+ {"version":3,"file":"revalidatePrismicPages.d.ts","names":[],"sources":["../src/revalidatePrismicPages.ts"],"mappings":";;;;;;;;;;iBAagB,uBAAuB"}
@@ -11,7 +11,10 @@ import { revalidateTag } from "next/cache.js";
11
11
  * @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}
12
12
  */
13
13
  function revalidatePrismicPages(ids) {
14
- for (const id of ids) revalidateTag(buildPrismicCacheTag(id), { expire: 0 });
14
+ for (const id of ids) {
15
+ const tag = buildPrismicCacheTag(id);
16
+ revalidateTag(tag, { expire: 0 });
17
+ }
15
18
  }
16
19
  //#endregion
17
20
  export { revalidatePrismicPages };
@@ -1 +1 @@
1
- {"version":3,"file":"revalidatePrismicPages.js","names":[],"sources":["../src/revalidatePrismicPages.ts"],"sourcesContent":["import { revalidateTag } from \"next/cache\"\n\nimport { buildPrismicCacheTag } from \"./getPrismicCacheTags\"\n\n/**\n * Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs\n * typically comes from a Prismic webhook triggered when publishing content.\n *\n * @param ids - A list of Prismic page IDs to revalidate.\n * @experimental\n *\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}\n */\nexport function revalidatePrismicPages(ids: string[]): void {\n\tfor (const id of ids) {\n\t\tconst tag = buildPrismicCacheTag(id)\n\t\trevalidateTag(tag, { expire: 0 })\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,uBAAuB,KAAqB;AAC3D,MAAK,MAAM,MAAM,IAEhB,eADY,qBAAqB,GAAG,EACjB,EAAE,QAAQ,GAAG,CAAC"}
1
+ {"version":3,"file":"revalidatePrismicPages.js","names":[],"sources":["../src/revalidatePrismicPages.ts"],"sourcesContent":["import { revalidateTag } from \"next/cache\"\n\nimport { buildPrismicCacheTag } from \"./getPrismicCacheTags\"\n\n/**\n * Immediately revalidates a set of Prismic pages given a list of their IDs. The list of IDs\n * typically comes from a Prismic webhook triggered when publishing content.\n *\n * @param ids - A list of Prismic page IDs to revalidate.\n * @experimental\n *\n * @see {@link https://nextjs.org/docs/app/api-reference/functions/revalidateTag}\n */\nexport function revalidatePrismicPages(ids: string[]): void {\n\tfor (const id of ids) {\n\t\tconst tag = buildPrismicCacheTag(id)\n\t\trevalidateTag(tag, { expire: 0 })\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,uBAAuB,KAAqB;CAC3D,KAAK,MAAM,MAAM,KAAK;EACrB,MAAM,MAAM,qBAAqB,EAAE;EACnC,cAAc,KAAK,EAAE,QAAQ,EAAE,CAAC;CACjC;AACD"}
package/dist/types.d.cts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ClientConfig } from "@prismicio/client";
2
-
3
2
  //#region src/types.d.ts
4
3
  declare module "@prismicio/client" {
5
4
  interface RequestInitLike {
@@ -1 +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"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;YAIW;IACT,OAAO;;;;KAKG,qBAAqB;;;;;;KAOrB;EACX;IACC,IAAI;;EAEL;EACA;IACC;IACA;MACC,IAAI"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ClientConfig } from "@prismicio/client";
2
-
3
2
  //#region src/types.d.ts
4
3
  declare module "@prismicio/client" {
5
4
  interface RequestInitLike {
@@ -1 +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"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;YAIW;IACT,OAAO;;;;KAKG,qBAAqB;;;;;;KAOrB;EACX;IACC,IAAI;;EAEL;EACA;IACC;IACA;MACC,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/next",
3
- "version": "2.3.2",
3
+ "version": "2.3.3-canary.6920973",
4
4
  "description": "Helpers to integrate Prismic into Next.js apps",
5
5
  "keywords": [
6
6
  "next",
@@ -54,23 +54,23 @@
54
54
  "types": "tsc --noEmit"
55
55
  },
56
56
  "dependencies": {
57
- "@prismicio/simulator": "^0.2.2",
57
+ "@prismicio/simulator": "^0.2.4",
58
58
  "imgix-url-builder": "^0.0.6",
59
59
  "lz-string": "^1.5.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@playwright/test": "^1.59.1",
63
- "@prismicio/client": "^7.21.8",
64
- "@types/node": "^25.5.2",
65
- "@types/react": "^19.2.14",
66
- "next": "16.2.3",
67
- "oxfmt": "^0.44.0",
68
- "oxlint": "^1.59.0",
69
- "playwright": "^1.59.1",
70
- "react": "^19.2.5",
71
- "react-dom": "^19.2.5",
72
- "tsdown": "^0.21.7",
73
- "typescript": "^6.0.2"
62
+ "@playwright/test": "^1.63.0",
63
+ "@prismicio/client": "^7.22.1",
64
+ "@types/node": "^26.6.1",
65
+ "@types/react": "^19.3.0",
66
+ "next": "16.3.5",
67
+ "oxfmt": "^0.68.0",
68
+ "oxlint": "^1.83.0",
69
+ "playwright": "^1.63.0",
70
+ "react": "^19.3.0",
71
+ "react-dom": "^19.3.0",
72
+ "tsdown": "^0.22.14",
73
+ "typescript": "^7.0.2"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@prismicio/client": "^7",
@@ -78,6 +78,6 @@
78
78
  "react": "^18 || ^19"
79
79
  },
80
80
  "engines": {
81
- "node": ">=20"
81
+ "node": ">=22"
82
82
  }
83
83
  }
@@ -13,6 +13,8 @@ import { imgixLoader } from "./imgixLoader"
13
13
  import { devMsg } from "./lib/devMsg"
14
14
  import { resolveDefaultExport } from "./lib/resolveDefaultExport"
15
15
 
16
+ const ResolvedImage = resolveDefaultExport(Image)
17
+
16
18
  const castInt = (input: string | number | undefined): number | undefined => {
17
19
  if (typeof input === "number" || typeof input === "undefined") {
18
20
  return input
@@ -113,14 +115,14 @@ export const PrismicNextImage: ForwardRefExoticComponent<
113
115
  return <>{fallback}</>
114
116
  }
115
117
 
116
- const resolvedImgixParams = imgixParams
117
- for (const x in imgixParams) {
118
+ const resolvedImgixParams = { ...imgixParams }
119
+ for (const x in resolvedImgixParams) {
118
120
  if (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {
119
121
  resolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined
120
122
  }
121
123
  }
122
124
 
123
- const src = buildURL(field.url, imgixParams as ImgixURLParams)
125
+ const src = buildURL(field.url, resolvedImgixParams as ImgixURLParams)
124
126
 
125
127
  const ar = field.dimensions.width / field.dimensions.height
126
128
 
@@ -147,8 +149,6 @@ export const PrismicNextImage: ForwardRefExoticComponent<
147
149
  )
148
150
  }
149
151
 
150
- const ResolvedImage = resolveDefaultExport(Image)
151
-
152
152
  return (
153
153
  <ResolvedImage
154
154
  ref={ref}
@@ -11,6 +11,8 @@ import { forwardRef } from "react"
11
11
 
12
12
  import { resolveDefaultExport } from "./lib/resolveDefaultExport"
13
13
 
14
+ const ResolvedLink = resolveDefaultExport(Link)
15
+
14
16
  export type PrismicNextLinkProps = Omit<
15
17
  ComponentProps<typeof Link>,
16
18
  "field" | "document" | "href" | "rel"
@@ -54,8 +56,6 @@ export const PrismicNextLink = forwardRef<HTMLAnchorElement, PrismicNextLinkProp
54
56
  rel = restProps.rel
55
57
  }
56
58
 
57
- const ResolvedLink = resolveDefaultExport(Link)
58
-
59
59
  return (
60
60
  <ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>
61
61
  {"children" in props ? children : field?.text}
@@ -5,6 +5,8 @@ import type { FC, ReactNode } from "react"
5
5
  import { resolveDefaultExport } from "./lib/resolveDefaultExport"
6
6
  import { PrismicPreviewClient } from "./PrismicPreviewClient"
7
7
 
8
+ const ResolvedScript = resolveDefaultExport(Script)
9
+
8
10
  /** Props for `<PrismicPreview>`. */
9
11
  export type PrismicPreviewProps = {
10
12
  /**
@@ -48,8 +50,6 @@ export const PrismicPreview: FC<PrismicPreviewProps> = async (props) => {
48
50
  const toolbarSrc = getToolbarSrc(repositoryName)
49
51
  const isDraftMode = (await draftMode()).isEnabled
50
52
 
51
- const ResolvedScript = resolveDefaultExport(Script)
52
-
53
53
  return (
54
54
  <>
55
55
  {children}
@@ -25,6 +25,9 @@ export const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {
25
25
  useEffect(() => {
26
26
  const controller = new AbortController()
27
27
 
28
+ window.addEventListener("prismicPreviewStart", onUpdate, {
29
+ signal: controller.signal,
30
+ })
28
31
  window.addEventListener("prismicPreviewUpdate", onUpdate, {
29
32
  signal: controller.signal,
30
33
  })
@@ -32,16 +35,19 @@ export const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {
32
35
  signal: controller.signal,
33
36
  })
34
37
 
35
- const cookie = getPrismicPreviewCookie(window.document.cookie)
36
- const cookieRepositoryName = cookie
37
- ? (decodeURIComponent(cookie).match(/"([^"]+)\.prismic\.io"/) || [])[1]
38
- : undefined
39
- const hasCookieForRepository = cookieRepositoryName === repositoryName
38
+ const cookie = decodeURIComponent(getPrismicPreviewCookie(window.document.cookie) ?? "")
39
+ // A raw ref, or the toolbar's JSON cookie with a preview for this repository.
40
+ const hasActiveCookie =
41
+ cookie !== "" &&
42
+ (!cookie.startsWith("{") || cookie.includes(`"${repositoryName}.prismic.io"`))
43
+
44
+ // Start previews that did not go through `updatePreviewURL`, like
45
+ // share links, and restart after a preview ended in another tab.
46
+ if (hasActiveCookie && !isDraftMode) {
47
+ start()
48
+ }
40
49
 
41
- // Start the preview for preview share links. Previews from
42
- // share links do not go to the `updatePreviewURL` like a normal
43
- // preview.
44
- if (hasCookieForRepository && !isDraftMode) {
50
+ function start() {
45
51
  // We check `opaqueredirect` because we don't care if
46
52
  // the redirect was successful or not. As long as it
47
53
  // redirects, we know the endpoint exists and draft mode
@@ -60,7 +66,12 @@ export const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {
60
66
  return
61
67
  }
62
68
 
63
- refresh()
69
+ // A soft refresh cannot leave Next.js's not-found boundary, which renders this tag.
70
+ if (document.querySelector('meta[name="robots"][content="noindex"]')) {
71
+ window.location.reload()
72
+ } else {
73
+ refresh()
74
+ }
64
75
  })
65
76
  .catch(() => {
66
77
  // noop
@@ -69,7 +80,11 @@ export const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {
69
80
 
70
81
  function onUpdate(event: Event) {
71
82
  event.preventDefault()
72
- refresh()
83
+ if (isDraftMode) {
84
+ refresh()
85
+ } else {
86
+ start()
87
+ }
73
88
  }
74
89
 
75
90
  function onEnd(event: Event) {
@@ -19,13 +19,11 @@ export async function exitPreview(): Promise<Response> {
19
19
  // Need this to avoid the following Next.js build-time error:
20
20
  // You're importing a component that needs next/headers. That only works
21
21
  // in a Server Component which is not supported in the pages/ directory.
22
- const { cookies, draftMode } = await import("next/headers")
22
+ const { cookies } = await import("next/headers")
23
23
 
24
- ;(await draftMode()).disable()
25
-
26
- // `redirectToPreviewURL` writes the preview cookie, so `exitPreview`
27
- // clears it to close the preview-cookie loop.
28
- ;(await cookies()).delete(prismicCookie.preview)
24
+ const cookieJar = await cookies()
25
+ cookieJar.delete({ name: "__prerender_bypass", sameSite: "none", secure: true })
26
+ cookieJar.delete({ name: prismicCookie.preview, sameSite: "none", secure: true })
29
27
 
30
28
  // `Cache-Control` header is used to prevent CDN-level caching.
31
29
  return new Response(JSON.stringify({ success: true }), {