@prismicio/next 2.2.1 → 2.2.2-pr.133.b4cce33

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 (106) hide show
  1. package/dist/PrismicNextImage.cjs +9 -11
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.cts +2 -3
  4. package/dist/PrismicNextImage.d.ts +2 -3
  5. package/dist/PrismicNextImage.js +3 -5
  6. package/dist/PrismicNextImage.js.map +1 -1
  7. package/dist/PrismicNextLink.cjs +7 -8
  8. package/dist/PrismicNextLink.cjs.map +1 -1
  9. package/dist/PrismicNextLink.d.cts +10 -10
  10. package/dist/PrismicNextLink.d.ts +10 -10
  11. package/dist/PrismicNextLink.js +3 -4
  12. package/dist/PrismicNextLink.js.map +1 -1
  13. package/dist/PrismicPreview.cjs +8 -9
  14. package/dist/PrismicPreview.cjs.map +1 -1
  15. package/dist/PrismicPreview.d.cts +1 -2
  16. package/dist/PrismicPreview.d.ts +1 -2
  17. package/dist/PrismicPreview.js +3 -4
  18. package/dist/PrismicPreview.js.map +1 -1
  19. package/dist/PrismicPreviewClient.cjs +6 -8
  20. package/dist/PrismicPreviewClient.cjs.map +1 -1
  21. package/dist/PrismicPreviewClient.js +6 -8
  22. package/dist/PrismicPreviewClient.js.map +1 -1
  23. package/dist/SliceSimulator.cjs +6 -8
  24. package/dist/SliceSimulator.cjs.map +1 -1
  25. package/dist/SliceSimulator.d.cts +0 -1
  26. package/dist/SliceSimulator.d.ts +0 -1
  27. package/dist/SliceSimulator.js +2 -4
  28. package/dist/SliceSimulator.js.map +1 -1
  29. package/dist/SliceSimulatorWrapper.cjs +2 -3
  30. package/dist/SliceSimulatorWrapper.cjs.map +1 -1
  31. package/dist/SliceSimulatorWrapper.js +1 -2
  32. package/dist/SliceSimulatorWrapper.js.map +1 -1
  33. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +8 -14
  34. package/dist/createLocaleRedirect.cjs +2 -3
  35. package/dist/createLocaleRedirect.cjs.map +1 -1
  36. package/dist/createLocaleRedirect.js +1 -2
  37. package/dist/createLocaleRedirect.js.map +1 -1
  38. package/dist/enableAutoPreviews.cjs +3 -4
  39. package/dist/enableAutoPreviews.cjs.map +1 -1
  40. package/dist/enableAutoPreviews.d.cts +1 -2
  41. package/dist/enableAutoPreviews.d.ts +1 -2
  42. package/dist/enableAutoPreviews.js +2 -3
  43. package/dist/enableAutoPreviews.js.map +1 -1
  44. package/dist/exitPreview.cjs +2 -3
  45. package/dist/exitPreview.cjs.map +1 -1
  46. package/dist/exitPreview.js +2 -2
  47. package/dist/getSlices.cjs +2 -3
  48. package/dist/getSlices.cjs.map +1 -1
  49. package/dist/getSlices.js +1 -2
  50. package/dist/getSlices.js.map +1 -1
  51. package/dist/imgixLoader.cjs +2 -3
  52. package/dist/imgixLoader.cjs.map +1 -1
  53. package/dist/imgixLoader.d.cts +1 -2
  54. package/dist/imgixLoader.d.ts +1 -2
  55. package/dist/imgixLoader.js +1 -2
  56. package/dist/imgixLoader.js.map +1 -1
  57. package/dist/index.cjs +12 -12
  58. package/dist/index.js +1 -2
  59. package/dist/lib/devMsg.cjs +2 -3
  60. package/dist/lib/devMsg.cjs.map +1 -1
  61. package/dist/lib/devMsg.js +1 -2
  62. package/dist/lib/devMsg.js.map +1 -1
  63. package/dist/lib/resolveDefaultExport.cjs +1 -2
  64. package/dist/lib/resolveDefaultExport.cjs.map +1 -1
  65. package/dist/lib/resolveDefaultExport.js +1 -1
  66. package/dist/package.cjs +7 -8
  67. package/dist/package.js +2 -2
  68. package/dist/pages/PrismicPreview.cjs +7 -8
  69. package/dist/pages/PrismicPreview.cjs.map +1 -1
  70. package/dist/pages/PrismicPreview.d.cts +1 -2
  71. package/dist/pages/PrismicPreview.d.ts +1 -2
  72. package/dist/pages/PrismicPreview.js +3 -4
  73. package/dist/pages/PrismicPreview.js.map +1 -1
  74. package/dist/pages/SliceSimulator.cjs +3 -4
  75. package/dist/pages/SliceSimulator.cjs.map +1 -1
  76. package/dist/pages/SliceSimulator.js +1 -2
  77. package/dist/pages/SliceSimulator.js.map +1 -1
  78. package/dist/pages/enableAutoPreviews.cjs +1 -2
  79. package/dist/pages/enableAutoPreviews.cjs.map +1 -1
  80. package/dist/pages/enableAutoPreviews.d.cts +1 -3
  81. package/dist/pages/enableAutoPreviews.d.ts +1 -3
  82. package/dist/pages/enableAutoPreviews.js +1 -1
  83. package/dist/pages/exitPreview.cjs +1 -2
  84. package/dist/pages/exitPreview.cjs.map +1 -1
  85. package/dist/pages/exitPreview.js +1 -1
  86. package/dist/pages/redirectToPreviewURL.cjs +1 -2
  87. package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
  88. package/dist/pages/redirectToPreviewURL.d.cts +1 -2
  89. package/dist/pages/redirectToPreviewURL.d.ts +1 -2
  90. package/dist/pages/redirectToPreviewURL.js +1 -1
  91. package/dist/pages/setPreviewData.cjs +2 -3
  92. package/dist/pages/setPreviewData.cjs.map +1 -1
  93. package/dist/pages/setPreviewData.js +1 -2
  94. package/dist/pages/setPreviewData.js.map +1 -1
  95. package/dist/pages/types.d.cts +0 -1
  96. package/dist/pages/types.d.ts +0 -1
  97. package/dist/pages.cjs +12 -12
  98. package/dist/pages.js +1 -2
  99. package/dist/redirectToPreviewURL.cjs +4 -6
  100. package/dist/redirectToPreviewURL.cjs.map +1 -1
  101. package/dist/redirectToPreviewURL.d.cts +2 -3
  102. package/dist/redirectToPreviewURL.d.ts +2 -3
  103. package/dist/redirectToPreviewURL.js +3 -5
  104. package/dist/redirectToPreviewURL.js.map +1 -1
  105. package/package.json +19 -20
  106. package/src/redirectToPreviewURL.ts +2 -3
@@ -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;AAElD,KAAI,IACH,KAAI,eAAe,EAAE,KAAK,CAAC"}
@@ -2,7 +2,6 @@ import { EnableAutoPreviewsConfig } from "./enableAutoPreviews.cjs";
2
2
  import { ClientConfig } from "@prismicio/client";
3
3
 
4
4
  //#region src/pages/types.d.ts
5
-
6
5
  /**
7
6
  * Configuration for creating a Prismic client with automatic preview support in
8
7
  * Next.js apps.
@@ -2,7 +2,6 @@ import { EnableAutoPreviewsConfig } from "./enableAutoPreviews.js";
2
2
  import { ClientConfig } from "@prismicio/client";
3
3
 
4
4
  //#region src/pages/types.d.ts
5
-
6
5
  /**
7
6
  * Configuration for creating a Prismic client with automatic preview support in
8
7
  * Next.js apps.
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,9 @@
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
- let next_navigation = require("next/navigation");
4
-
5
3
  //#region src/redirectToPreviewURL.ts
6
4
  async function redirectToPreviewURL(config) {
7
5
  const { client, request, linkResolver, defaultURL = "/" } = config;
8
- const { cookies, draftMode } = await import("next/headers");
6
+ const { cookies, draftMode } = await import("next/headers.js");
9
7
  const documentID = request.nextUrl.searchParams.get("documentId") ?? void 0;
10
8
  const previewToken = request.nextUrl.searchParams.get("token") ?? void 0;
11
9
  if (previewToken) (await cookies()).set(_prismicio_client.cookie.preview, previewToken);
@@ -16,9 +14,9 @@ async function redirectToPreviewURL(config) {
16
14
  linkResolver
17
15
  });
18
16
  (await draftMode()).enable();
19
- (0, next_navigation.redirect)(previewURL);
17
+ return Response.redirect(new URL(previewURL, request.url), 307);
20
18
  }
21
-
22
19
  //#endregion
23
20
  exports.redirectToPreviewURL = redirectToPreviewURL;
21
+
24
22
  //# 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 {\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<Response> {\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\treturn Response.redirect(new URL(previewURL, request.url), 307);\n}\n"],"mappings":";;;AAwCA,eAAsB,qBACrB,QACoB;CACpB,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,MAAM,aACL,QAAQ,QAAQ,aAAa,IAAI,aAAa,IAAI,KAAA;CAMnD,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;AAEF,EAAC,MAAM,WAAW,EAAE,QAAQ;AAE5B,QAAO,SAAS,SAAS,IAAI,IAAI,YAAY,QAAQ,IAAI,EAAE,IAAI"}
@@ -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
  *
@@ -27,7 +26,7 @@ type RedirectToPreviewURLConfig = {
27
26
  */
28
27
  defaultURL?: string;
29
28
  };
30
- declare function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<never>;
29
+ declare function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<Response>;
31
30
  //#endregion
32
31
  export { RedirectToPreviewURLConfig, redirectToPreviewURL };
33
32
  //# sourceMappingURL=redirectToPreviewURL.d.cts.map
@@ -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
  *
@@ -27,7 +26,7 @@ type RedirectToPreviewURLConfig = {
27
26
  */
28
27
  defaultURL?: string;
29
28
  };
30
- declare function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<never>;
29
+ declare function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<Response>;
31
30
  //#endregion
32
31
  export { RedirectToPreviewURLConfig, redirectToPreviewURL };
33
32
  //# sourceMappingURL=redirectToPreviewURL.d.ts.map
@@ -1,10 +1,8 @@
1
1
  import { cookie } from "@prismicio/client";
2
- import { redirect } from "next/navigation";
3
-
4
2
  //#region src/redirectToPreviewURL.ts
5
3
  async function redirectToPreviewURL(config) {
6
4
  const { client, request, linkResolver, defaultURL = "/" } = config;
7
- const { cookies, draftMode } = await import("next/headers");
5
+ const { cookies, draftMode } = await import("next/headers.js");
8
6
  const documentID = request.nextUrl.searchParams.get("documentId") ?? void 0;
9
7
  const previewToken = request.nextUrl.searchParams.get("token") ?? void 0;
10
8
  if (previewToken) (await cookies()).set(cookie.preview, previewToken);
@@ -15,9 +13,9 @@ async function redirectToPreviewURL(config) {
15
13
  linkResolver
16
14
  });
17
15
  (await draftMode()).enable();
18
- redirect(previewURL);
16
+ return Response.redirect(new URL(previewURL, request.url), 307);
19
17
  }
20
-
21
18
  //#endregion
22
19
  export { redirectToPreviewURL };
20
+
23
21
  //# 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 {\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<Response> {\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\treturn Response.redirect(new URL(previewURL, request.url), 307);\n}\n"],"mappings":";;AAwCA,eAAsB,qBACrB,QACoB;CACpB,MAAM,EAAE,QAAQ,SAAS,cAAc,aAAa,QAAQ;CAK5D,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,MAAM,aACL,QAAQ,QAAQ,aAAa,IAAI,aAAa,IAAI,KAAA;CAMnD,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;AAEF,EAAC,MAAM,WAAW,EAAE,QAAQ;AAE5B,QAAO,SAAS,SAAS,IAAI,IAAI,YAAY,QAAQ,IAAI,EAAE,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/next",
3
- "version": "2.2.1",
3
+ "version": "2.2.2-pr.133.b4cce33",
4
4
  "description": "Helpers to integrate Prismic into Next.js apps",
5
5
  "keywords": [
6
6
  "typescript",
@@ -19,18 +19,17 @@
19
19
  "type": "module",
20
20
  "exports": {
21
21
  ".": {
22
- "require": "./dist/index.cjs",
23
- "import": "./dist/index.js"
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.cjs"
24
24
  },
25
25
  "./pages": {
26
- "require": "./dist/pages.cjs",
27
- "import": "./dist/pages.js"
26
+ "types": "./dist/pages.d.ts",
27
+ "default": "./dist/pages.cjs"
28
28
  },
29
29
  "./package.json": "./package.json"
30
30
  },
31
31
  "main": "./dist/index.cjs",
32
- "module": "./dist/index.js",
33
- "types": "./dist/index.d.cts",
32
+ "types": "./dist/index.d.ts",
34
33
  "files": [
35
34
  "dist",
36
35
  "src"
@@ -52,24 +51,24 @@
52
51
  },
53
52
  "dependencies": {
54
53
  "@prismicio/simulator": "^0.2.0",
55
- "imgix-url-builder": "^0.0.5",
54
+ "imgix-url-builder": "^0.0.6",
56
55
  "lz-string": "^1.5.0"
57
56
  },
58
57
  "devDependencies": {
59
- "@playwright/test": "^1.49.1",
58
+ "@playwright/test": "^1.58.2",
60
59
  "@prismicio/client": "^7.12.0",
61
60
  "@trivago/prettier-plugin-sort-imports": "^6.0.2",
62
- "@types/node": "^22.10.2",
63
- "@types/react": "^19.2.3",
64
- "next": "16.0.8",
65
- "oxlint": "^1.38.0",
66
- "playwright": "^1.49.1",
67
- "prettier": "^3.4.2",
68
- "prettier-plugin-jsdoc": "^1.3.0",
69
- "react": "^19.2.1",
70
- "react-dom": "^19.2.1",
71
- "tsdown": "^0.19.0-beta.5",
72
- "typescript": "^5.7.2"
61
+ "@types/node": "^25.5.0",
62
+ "@types/react": "^19.2.14",
63
+ "next": "16.2.1",
64
+ "oxlint": "^1.58.0",
65
+ "playwright": "^1.58.2",
66
+ "prettier": "^3.8.1",
67
+ "prettier-plugin-jsdoc": "^1.8.0",
68
+ "react": "^19.2.4",
69
+ "react-dom": "^19.2.4",
70
+ "tsdown": "^0.21.7",
71
+ "typescript": "^6.0.2"
73
72
  },
74
73
  "peerDependencies": {
75
74
  "@prismicio/client": "^7",
@@ -1,4 +1,3 @@
1
- import { redirect } from "next/navigation";
2
1
  import {
3
2
  cookie as prismicCookie,
4
3
  type Client,
@@ -41,7 +40,7 @@ export type RedirectToPreviewURLConfig = {
41
40
 
42
41
  export async function redirectToPreviewURL(
43
42
  config: RedirectToPreviewURLConfig,
44
- ): Promise<never> {
43
+ ): Promise<Response> {
45
44
  const { client, request, linkResolver, defaultURL = "/" } = config;
46
45
 
47
46
  // Need this to avoid the following Next.js build-time error:
@@ -71,5 +70,5 @@ export async function redirectToPreviewURL(
71
70
 
72
71
  (await draftMode()).enable();
73
72
 
74
- redirect(previewURL);
73
+ return Response.redirect(new URL(previewURL, request.url), 307);
75
74
  }