@prismicio/next 2.0.1 → 2.0.2-canary.6f580fa

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 (92) hide show
  1. package/dist/PrismicNextImage.cjs +66 -56
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.cts +57 -0
  4. package/dist/PrismicNextLink.cjs +29 -21
  5. package/dist/PrismicNextLink.cjs.map +1 -1
  6. package/dist/PrismicNextLink.d.cts +54 -0
  7. package/dist/PrismicNextRichText.cjs +34 -0
  8. package/dist/PrismicNextRichText.cjs.map +1 -0
  9. package/dist/PrismicNextRichText.d.cts +11 -0
  10. package/dist/PrismicPreview.cjs +38 -36
  11. package/dist/PrismicPreview.cjs.map +1 -1
  12. package/dist/PrismicPreview.d.cts +36 -0
  13. package/dist/PrismicPreviewClient.cjs +71 -65
  14. package/dist/PrismicPreviewClient.cjs.map +1 -1
  15. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  16. package/dist/createLocaleRedirect.cjs +11 -5
  17. package/dist/createLocaleRedirect.cjs.map +1 -1
  18. package/dist/createLocaleRedirect.d.cts +14 -0
  19. package/dist/enableAutoPreviews.cjs +27 -48
  20. package/dist/enableAutoPreviews.cjs.map +1 -1
  21. package/dist/enableAutoPreviews.d.cts +18 -0
  22. package/dist/exitPreview.cjs +24 -32
  23. package/dist/exitPreview.cjs.map +1 -1
  24. package/dist/{exitPreview.d.ts → exitPreview.d.cts} +5 -1
  25. package/dist/imgixLoader.cjs +21 -14
  26. package/dist/imgixLoader.cjs.map +1 -1
  27. package/dist/{imgixLoader.d.ts → imgixLoader.d.cts} +7 -1
  28. package/dist/index.cjs +19 -19
  29. package/dist/index.d.cts +11 -0
  30. package/dist/lib/devMsg.cjs +22 -5
  31. package/dist/lib/devMsg.cjs.map +1 -1
  32. package/dist/lib/resolveDefaultExport.cjs +23 -4
  33. package/dist/lib/resolveDefaultExport.cjs.map +1 -1
  34. package/dist/package.cjs +12 -0
  35. package/dist/package.cjs.map +1 -0
  36. package/dist/pages/PrismicPreview.cjs +71 -59
  37. package/dist/pages/PrismicPreview.cjs.map +1 -1
  38. package/dist/pages/PrismicPreview.d.cts +36 -0
  39. package/dist/pages/enableAutoPreviews.cjs +21 -14
  40. package/dist/pages/enableAutoPreviews.cjs.map +1 -1
  41. package/dist/pages/enableAutoPreviews.d.cts +37 -0
  42. package/dist/pages/exitPreview.cjs +24 -7
  43. package/dist/pages/exitPreview.cjs.map +1 -1
  44. package/dist/pages/exitPreview.d.cts +38 -0
  45. package/dist/pages/redirectToPreviewURL.cjs +13 -13
  46. package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
  47. package/dist/pages/redirectToPreviewURL.d.cts +48 -0
  48. package/dist/pages/setPreviewData.cjs +10 -8
  49. package/dist/pages/setPreviewData.cjs.map +1 -1
  50. package/dist/pages/setPreviewData.d.cts +26 -0
  51. package/dist/pages/types.d.cts +36 -0
  52. package/dist/pages.cjs +21 -21
  53. package/dist/pages.d.cts +12 -0
  54. package/dist/redirectToPreviewURL.cjs +21 -43
  55. package/dist/redirectToPreviewURL.cjs.map +1 -1
  56. package/dist/redirectToPreviewURL.d.cts +33 -0
  57. package/dist/types.d.cts +31 -0
  58. package/package.json +34 -49
  59. package/src/PrismicNextImage.tsx +10 -6
  60. package/src/PrismicNextLink.tsx +5 -3
  61. package/src/PrismicNextRichText.tsx +41 -0
  62. package/src/PrismicPreviewClient.tsx +2 -3
  63. package/src/createLocaleRedirect.ts +1 -1
  64. package/src/imgixLoader.ts +3 -2
  65. package/src/index.ts +3 -0
  66. package/src/lib/devMsg.ts +1 -1
  67. package/src/pages/PrismicPreview.tsx +2 -1
  68. package/src/pages/index.ts +3 -0
  69. package/src/pages/types.ts +2 -3
  70. package/src/redirectToPreviewURL.ts +1 -1
  71. package/dist/PrismicNextImage.d.ts +0 -54
  72. package/dist/PrismicNextLink.d.ts +0 -125
  73. package/dist/PrismicPreview.d.ts +0 -31
  74. package/dist/PrismicPreviewClient.d.ts +0 -9
  75. package/dist/createLocaleRedirect.d.ts +0 -10
  76. package/dist/enableAutoPreviews.d.ts +0 -13
  77. package/dist/index.cjs.map +0 -1
  78. package/dist/index.d.ts +0 -15
  79. package/dist/lib/devMsg.d.ts +0 -16
  80. package/dist/lib/resolveDefaultExport.d.ts +0 -18
  81. package/dist/package.json.cjs +0 -5
  82. package/dist/package.json.cjs.map +0 -1
  83. package/dist/pages/PrismicPreview.d.ts +0 -31
  84. package/dist/pages/enableAutoPreviews.d.ts +0 -31
  85. package/dist/pages/exitPreview.d.ts +0 -33
  86. package/dist/pages/index.d.ts +0 -18
  87. package/dist/pages/redirectToPreviewURL.d.ts +0 -43
  88. package/dist/pages/setPreviewData.d.ts +0 -18
  89. package/dist/pages/types.d.ts +0 -30
  90. package/dist/pages.cjs.map +0 -1
  91. package/dist/redirectToPreviewURL.d.ts +0 -28
  92. package/dist/types.d.ts +0 -26
@@ -1,71 +1,77 @@
1
1
  "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const react = require("react");
5
- const client = require("@prismicio/client");
6
- const navigation = require("next/navigation");
2
+
3
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
4
+ let _prismicio_client = require("@prismicio/client");
5
+ let next_navigation = require("next/navigation");
6
+ let react = require("react");
7
+
8
+ //#region src/PrismicPreviewClient.tsx
7
9
  const PrismicPreviewClient = (props) => {
8
- const { repositoryName, isDraftMode, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview" } = props;
9
- const { refresh } = navigation.useRouter();
10
- react.useEffect(() => {
11
- const controller = new AbortController();
12
- window.addEventListener("prismicPreviewUpdate", onUpdate, {
13
- signal: controller.signal
14
- });
15
- window.addEventListener("prismicPreviewEnd", onEnd, {
16
- signal: controller.signal
17
- });
18
- const cookie = getPrismicPreviewCookie(window.document.cookie);
19
- const cookieRepositoryName = cookie ? (decodeURIComponent(cookie).match(/"([^"]+)\.prismic\.io"/) || [])[1] : void 0;
20
- const hasCookieForRepository = cookieRepositoryName === repositoryName;
21
- if (hasCookieForRepository && !isDraftMode) {
22
- console.log("starting preview link");
23
- globalThis.fetch(updatePreviewURL, {
24
- redirect: "manual",
25
- signal: controller.signal
26
- }).then((res) => {
27
- if (res.type !== "opaqueredirect") {
28
- console.error(`[<PrismicPreview>] Failed to start the preview using "${updatePreviewURL}". Does it exist?`);
29
- return;
30
- }
31
- refresh();
32
- }).catch(() => {
33
- });
34
- }
35
- function onUpdate(event) {
36
- event.preventDefault();
37
- refresh();
38
- }
39
- function onEnd(event) {
40
- event.preventDefault();
41
- globalThis.fetch(exitPreviewURL, { signal: controller.signal }).then((res) => {
42
- if (!res.ok) {
43
- console.error(`[<PrismicPreview>] Failed to exit Preview Mode using the "${exitPreviewURL}" API endpoint. Does it exist?`);
44
- return;
45
- }
46
- refresh();
47
- }).catch(() => {
48
- });
49
- }
50
- return () => controller.abort();
51
- }, [repositoryName, isDraftMode, updatePreviewURL, exitPreviewURL, refresh]);
52
- return null;
10
+ const { repositoryName, isDraftMode, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview" } = props;
11
+ const { refresh } = (0, next_navigation.useRouter)();
12
+ (0, react.useEffect)(() => {
13
+ const controller = new AbortController();
14
+ window.addEventListener("prismicPreviewUpdate", onUpdate, { signal: controller.signal });
15
+ window.addEventListener("prismicPreviewEnd", onEnd, { signal: controller.signal });
16
+ const cookie = getPrismicPreviewCookie(window.document.cookie);
17
+ if ((cookie ? (decodeURIComponent(cookie).match(/"([^"]+)\.prismic\.io"/) || [])[1] : void 0) === repositoryName && !isDraftMode) globalThis.fetch(updatePreviewURL, {
18
+ redirect: "manual",
19
+ signal: controller.signal
20
+ }).then((res) => {
21
+ if (res.type !== "opaqueredirect") {
22
+ console.error(`[<PrismicPreview>] Failed to start the preview using "${updatePreviewURL}". Does it exist?`);
23
+ return;
24
+ }
25
+ refresh();
26
+ }).catch(() => {});
27
+ function onUpdate(event) {
28
+ event.preventDefault();
29
+ refresh();
30
+ }
31
+ function onEnd(event) {
32
+ event.preventDefault();
33
+ globalThis.fetch(exitPreviewURL, { signal: controller.signal }).then((res) => {
34
+ if (!res.ok) {
35
+ console.error(`[<PrismicPreview>] Failed to exit Preview Mode using the "${exitPreviewURL}" API endpoint. Does it exist?`);
36
+ return;
37
+ }
38
+ refresh();
39
+ }).catch(() => {});
40
+ }
41
+ return () => controller.abort();
42
+ }, [
43
+ repositoryName,
44
+ isDraftMode,
45
+ updatePreviewURL,
46
+ exitPreviewURL,
47
+ refresh
48
+ ]);
49
+ return null;
53
50
  };
51
+ /**
52
+ * Returns the value of a cookie from a given cookie store.
53
+ *
54
+ * @param cookieJar - The stringified cookie store from which to read the
55
+ * cookie.
56
+ *
57
+ * @returns The value of the cookie, if it exists.
58
+ */
54
59
  function getPrismicPreviewCookie(cookieJar) {
55
- function readValue(value2) {
56
- return value2.replace(/%3B/g, ";");
57
- }
58
- const cookies = cookieJar.split("; ");
59
- let value;
60
- for (const cookie of cookies) {
61
- const parts = cookie.split("=");
62
- const name = readValue(parts[0]).replace(/%3D/g, "=");
63
- if (name === client.cookie.preview) {
64
- value = readValue(parts.slice(1).join("="));
65
- continue;
66
- }
67
- }
68
- return value;
60
+ function readValue(value$1) {
61
+ return value$1.replace(/%3B/g, ";");
62
+ }
63
+ const cookies = cookieJar.split("; ");
64
+ let value;
65
+ for (const cookie of cookies) {
66
+ const parts = cookie.split("=");
67
+ if (readValue(parts[0]).replace(/%3D/g, "=") === _prismicio_client.cookie.preview) {
68
+ value = readValue(parts.slice(1).join("="));
69
+ continue;
70
+ }
71
+ }
72
+ return value;
69
73
  }
74
+
75
+ //#endregion
70
76
  exports.PrismicPreviewClient = PrismicPreviewClient;
71
- //# sourceMappingURL=PrismicPreviewClient.cjs.map
77
+ //# sourceMappingURL=PrismicPreviewClient.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicPreviewClient.cjs","sources":["../src/PrismicPreviewClient.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, useEffect } from \"react\";\nimport { cookie as prismicCookie } from \"@prismicio/client\";\nimport { useRouter } from \"next/navigation\";\n\ntype PrismicPreviewClientProps = {\n\trepositoryName: string;\n\tisDraftMode: boolean;\n\tupdatePreviewURL?: string;\n\texitPreviewURL?: string;\n};\n\nexport const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {\n\tconst {\n\t\trepositoryName,\n\t\tisDraftMode,\n\t\tupdatePreviewURL = \"/api/preview\",\n\t\texitPreviewURL = \"/api/exit-preview\",\n\t} = props;\n\n\tconst { refresh } = useRouter();\n\n\tuseEffect(() => {\n\t\tconst controller = new AbortController();\n\n\t\twindow.addEventListener(\"prismicPreviewUpdate\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\twindow.addEventListener(\"prismicPreviewEnd\", onEnd, {\n\t\t\tsignal: controller.signal,\n\t\t});\n\n\t\tconst cookie = getPrismicPreviewCookie(window.document.cookie);\n\t\tconst cookieRepositoryName = cookie\n\t\t\t? (decodeURIComponent(cookie).match(/\"([^\"]+)\\.prismic\\.io\"/) || [])[1]\n\t\t\t: undefined;\n\t\tconst hasCookieForRepository = cookieRepositoryName === repositoryName;\n\n\t\t// Start the preview for preview share links. Previews from\n\t\t// share links do not go to the `updatePreviewURL` like a normal\n\t\t// preview.\n\t\tif (hasCookieForRepository && !isDraftMode) {\n\t\t\tconsole.log(\"starting preview link\");\n\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and draft mode\n\t\t\t// is active.\n\t\t\tglobalThis\n\t\t\t\t.fetch(updatePreviewURL, {\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t})\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (res.type !== \"opaqueredirect\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to start the preview using \"${updatePreviewURL}\". Does it exist?`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh();\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\t// noop\n\t\t\t\t});\n\t\t}\n\n\t\tfunction onUpdate(event: Event) {\n\t\t\tevent.preventDefault();\n\t\t\trefresh();\n\t\t}\n\n\t\tfunction onEnd(event: Event) {\n\t\t\tevent.preventDefault();\n\t\t\tglobalThis\n\t\t\t\t.fetch(exitPreviewURL, { signal: controller.signal })\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (!res.ok) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${exitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh();\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\t// noop\n\t\t\t\t});\n\t\t}\n\n\t\treturn () => controller.abort();\n\t}, [repositoryName, isDraftMode, updatePreviewURL, exitPreviewURL, refresh]);\n\n\treturn null;\n};\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nfunction getPrismicPreviewCookie(cookieJar: string): string | undefined {\n\tfunction readValue(value: string): string {\n\t\treturn value.replace(/%3B/g, \";\");\n\t}\n\n\tconst cookies = cookieJar.split(\"; \");\n\n\tlet value: string | undefined;\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\");\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\");\n\n\t\tif (name === prismicCookie.preview) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"));\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn value;\n}\n"],"names":["useRouter","useEffect","value","prismicCookie"],"mappings":";;;;;;AAaa,MAAA,uBAAsD,CAAC,UAAS;AAC5E,QAAM,EACL,gBACA,aACA,mBAAmB,gBACnB,iBAAiB,wBACd;AAEE,QAAA,EAAE,QAAO,IAAKA;AAEpBC,QAAAA,UAAU,MAAK;AACR,UAAA,aAAa,IAAI;AAEhB,WAAA,iBAAiB,wBAAwB,UAAU;AAAA,MACzD,QAAQ,WAAW;AAAA,IAAA,CACnB;AACM,WAAA,iBAAiB,qBAAqB,OAAO;AAAA,MACnD,QAAQ,WAAW;AAAA,IAAA,CACnB;AAED,UAAM,SAAS,wBAAwB,OAAO,SAAS,MAAM;AACvD,UAAA,uBAAuB,UACzB,mBAAmB,MAAM,EAAE,MAAM,wBAAwB,KAAK,CAAA,GAAI,CAAC,IACpE;AACH,UAAM,yBAAyB,yBAAyB;AAKpD,QAAA,0BAA0B,CAAC,aAAa;AAC3C,cAAQ,IAAI,uBAAuB;AAMnC,iBACE,MAAM,kBAAkB;AAAA,QACxB,UAAU;AAAA,QACV,QAAQ,WAAW;AAAA,MAAA,CACnB,EACA,KAAK,CAAC,QAAO;AACT,YAAA,IAAI,SAAS,kBAAkB;AAC1B,kBAAA,MACP,yDAAyD,gBAAgB,mBAAmB;AAG7F;AAAA,QAAA;;OAID,EACA,MAAM,MAAK;AAAA,MAAA,CAEX;AAAA,IAAA;AAGH,aAAS,SAAS,OAAY;AAC7B,YAAM,eAAc;;;AAIrB,aAAS,MAAM,OAAY;AAC1B,YAAM,eAAc;AAElB,iBAAA,MAAM,gBAAgB,EAAE,QAAQ,WAAW,QAAQ,EACnD,KAAK,CAAC,QAAO;AACT,YAAA,CAAC,IAAI,IAAI;AACJ,kBAAA,MACP,6DAA6D,cAAc,gCAAgC;AAG5G;AAAA,QAAA;;OAID,EACA,MAAM,MAAK;AAAA,MAAA,CAEX;AAAA,IAAA;AAGI,WAAA,MAAM,WAAW;KACtB,CAAC,gBAAgB,aAAa,kBAAkB,gBAAgB,OAAO,CAAC;AAEpE,SAAA;AACR;AAUA,SAAS,wBAAwB,WAAiB;AACjD,WAAS,UAAUC,QAAa;AACxBA,WAAAA,OAAM,QAAQ,QAAQ,GAAG;AAAA,EAAA;AAG3B,QAAA,UAAU,UAAU,MAAM,IAAI;AAEhC,MAAA;AAEJ,aAAW,UAAU,SAAS;AACvB,UAAA,QAAQ,OAAO,MAAM,GAAG;AACxB,UAAA,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAEhD,QAAA,SAASC,cAAc,SAAS;AACnC,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IAAA;AAAA,EACD;AAGM,SAAA;AACR;;"}
1
+ {"version":3,"file":"PrismicPreviewClient.cjs","names":["value","prismicCookie"],"sources":["../src/PrismicPreviewClient.tsx"],"sourcesContent":["\"use client\";\n\nimport { cookie as prismicCookie } from \"@prismicio/client\";\nimport { useRouter } from \"next/navigation\";\nimport type { FC } from \"react\";\nimport { useEffect } from \"react\";\n\ntype PrismicPreviewClientProps = {\n\trepositoryName: string;\n\tisDraftMode: boolean;\n\tupdatePreviewURL?: string;\n\texitPreviewURL?: string;\n};\n\nexport const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {\n\tconst {\n\t\trepositoryName,\n\t\tisDraftMode,\n\t\tupdatePreviewURL = \"/api/preview\",\n\t\texitPreviewURL = \"/api/exit-preview\",\n\t} = props;\n\n\tconst { refresh } = useRouter();\n\n\tuseEffect(() => {\n\t\tconst controller = new AbortController();\n\n\t\twindow.addEventListener(\"prismicPreviewUpdate\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\twindow.addEventListener(\"prismicPreviewEnd\", onEnd, {\n\t\t\tsignal: controller.signal,\n\t\t});\n\n\t\tconst cookie = getPrismicPreviewCookie(window.document.cookie);\n\t\tconst cookieRepositoryName = cookie\n\t\t\t? (decodeURIComponent(cookie).match(/\"([^\"]+)\\.prismic\\.io\"/) || [])[1]\n\t\t\t: undefined;\n\t\tconst hasCookieForRepository = cookieRepositoryName === repositoryName;\n\n\t\t// Start the preview for preview share links. Previews from\n\t\t// share links do not go to the `updatePreviewURL` like a normal\n\t\t// preview.\n\t\tif (hasCookieForRepository && !isDraftMode) {\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and draft mode\n\t\t\t// is active.\n\t\t\tglobalThis\n\t\t\t\t.fetch(updatePreviewURL, {\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t})\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (res.type !== \"opaqueredirect\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to start the preview using \"${updatePreviewURL}\". Does it exist?`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh();\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\t// noop\n\t\t\t\t});\n\t\t}\n\n\t\tfunction onUpdate(event: Event) {\n\t\t\tevent.preventDefault();\n\t\t\trefresh();\n\t\t}\n\n\t\tfunction onEnd(event: Event) {\n\t\t\tevent.preventDefault();\n\t\t\tglobalThis\n\t\t\t\t.fetch(exitPreviewURL, { signal: controller.signal })\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (!res.ok) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${exitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh();\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\t// noop\n\t\t\t\t});\n\t\t}\n\n\t\treturn () => controller.abort();\n\t}, [repositoryName, isDraftMode, updatePreviewURL, exitPreviewURL, refresh]);\n\n\treturn null;\n};\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nfunction getPrismicPreviewCookie(cookieJar: string): string | undefined {\n\tfunction readValue(value: string): string {\n\t\treturn value.replace(/%3B/g, \";\");\n\t}\n\n\tconst cookies = cookieJar.split(\"; \");\n\n\tlet value: string | undefined;\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\");\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\");\n\n\t\tif (name === prismicCookie.preview) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"));\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn value;\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,wBAAuD,UAAU;CAC7E,MAAM,EACL,gBACA,aACA,mBAAmB,gBACnB,iBAAiB,wBACd;CAEJ,MAAM,EAAE,4CAAuB;AAE/B,4BAAgB;EACf,MAAM,aAAa,IAAI,iBAAiB;AAExC,SAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,QACnB,CAAC;AACF,SAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,QACnB,CAAC;EAEF,MAAM,SAAS,wBAAwB,OAAO,SAAS,OAAO;AAS9D,OAR6B,UACzB,mBAAmB,OAAO,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE,KACnE,YACqD,kBAK1B,CAAC,YAK9B,YACE,MAAM,kBAAkB;GACxB,UAAU;GACV,QAAQ,WAAW;GACnB,CAAC,CACD,MAAM,QAAQ;AACd,OAAI,IAAI,SAAS,kBAAkB;AAClC,YAAQ,MACP,yDAAyD,iBAAiB,mBAC1E;AAED;;AAGD,YAAS;IACR,CACD,YAAY,GAEX;EAGJ,SAAS,SAAS,OAAc;AAC/B,SAAM,gBAAgB;AACtB,YAAS;;EAGV,SAAS,MAAM,OAAc;AAC5B,SAAM,gBAAgB;AACtB,cACE,MAAM,gBAAgB,EAAE,QAAQ,WAAW,QAAQ,CAAC,CACpD,MAAM,QAAQ;AACd,QAAI,CAAC,IAAI,IAAI;AACZ,aAAQ,MACP,6DAA6D,eAAe,gCAC5E;AAED;;AAGD,aAAS;KACR,CACD,YAAY,GAEX;;AAGJ,eAAa,WAAW,OAAO;IAC7B;EAAC;EAAgB;EAAa;EAAkB;EAAgB;EAAQ,CAAC;AAE5E,QAAO;;;;;;;;;;AAWR,SAAS,wBAAwB,WAAuC;CACvE,SAAS,UAAU,SAAuB;AACzC,SAAOA,QAAM,QAAQ,QAAQ,IAAI;;CAGlC,MAAM,UAAU,UAAU,MAAM,KAAK;CAErC,IAAI;AAEJ,MAAK,MAAM,UAAU,SAAS;EAC7B,MAAM,QAAQ,OAAO,MAAM,IAAI;AAG/B,MAFa,UAAU,MAAM,GAAG,CAAC,QAAQ,QAAQ,IAAI,KAExCC,yBAAc,SAAS;AACnC,WAAQ,UAAU,MAAM,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;AAC3C;;;AAIF,QAAO"}
@@ -0,0 +1,29 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1,8 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const devMsg = require("./lib/devMsg.cjs");
1
+ const require_devMsg = require('./lib/devMsg.cjs');
2
+
3
+ //#region src/createLocaleRedirect.ts
4
+ /**
5
+ * @deprecated `createLocaleRedirect()` has been removed due to performance
6
+ * issues.
7
+ */
4
8
  function createLocaleRedirect() {
5
- throw new Error(`createLocaleRedirect() has been removed due to performance issues. See ${devMsg.devMsg("replace-createLocaleRedirect")} for more details.`);
9
+ throw new Error(`createLocaleRedirect() has been removed due to performance issues. See ${require_devMsg.devMsg("replace-createLocaleRedirect")} for more details.`);
6
10
  }
11
+
12
+ //#endregion
7
13
  exports.createLocaleRedirect = createLocaleRedirect;
8
- //# sourceMappingURL=createLocaleRedirect.cjs.map
14
+ //# sourceMappingURL=createLocaleRedirect.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"createLocaleRedirect.cjs","sources":["../src/createLocaleRedirect.ts"],"sourcesContent":["import { devMsg } from \"./lib/devMsg\";\n\n/**\n * @deprecated `createLocaleRedirect()` has been removed due to performance\n * issues.\n */\nexport function createLocaleRedirect() {\n\tthrow new Error(\n\t\t`createLocaleRedirect() has been removed due to performance issues. See ${devMsg(\n\t\t\t\"replace-createLocaleRedirect\",\n\t\t)} for more details.`,\n\t);\n}\n/**\n * @deprecated `createLocaleRedirect()` has been removed due to performance\n * issues.\n */\nexport type CreateLocaleRedirectConfig = never;\n"],"names":["devMsg"],"mappings":";;;SAMgB,uBAAoB;AACnC,QAAM,IAAI,MACT,0EAA0EA,OACzE,OAAA,8BAA8B,CAC9B,oBAAoB;AAEvB;;"}
1
+ {"version":3,"file":"createLocaleRedirect.cjs","names":["devMsg"],"sources":["../src/createLocaleRedirect.ts"],"sourcesContent":["import { devMsg } from \"./lib/devMsg\";\n\n/**\n * @deprecated `createLocaleRedirect()` has been removed due to performance\n * issues.\n */\nexport function createLocaleRedirect(): never {\n\tthrow new Error(\n\t\t`createLocaleRedirect() has been removed due to performance issues. See ${devMsg(\n\t\t\t\"replace-createLocaleRedirect\",\n\t\t)} for more details.`,\n\t);\n}\n/**\n * @deprecated `createLocaleRedirect()` has been removed due to performance\n * issues.\n */\nexport type CreateLocaleRedirectConfig = never;\n"],"mappings":";;;;;;;AAMA,SAAgB,uBAA8B;AAC7C,OAAM,IAAI,MACT,0EAA0EA,sBACzE,+BACA,CAAC,oBACF"}
@@ -0,0 +1,14 @@
1
+ //#region src/createLocaleRedirect.d.ts
2
+ /**
3
+ * @deprecated `createLocaleRedirect()` has been removed due to performance
4
+ * issues.
5
+ */
6
+ declare function createLocaleRedirect(): never;
7
+ /**
8
+ * @deprecated `createLocaleRedirect()` has been removed due to performance
9
+ * issues.
10
+ */
11
+ type CreateLocaleRedirectConfig = never;
12
+ //#endregion
13
+ export { CreateLocaleRedirectConfig, createLocaleRedirect };
14
+ //# sourceMappingURL=createLocaleRedirect.d.cts.map
@@ -1,51 +1,30 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const client = require("@prismicio/client");
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let _prismicio_client = require("@prismicio/client");
3
+
4
+ //#region src/enableAutoPreviews.ts
5
+ /**
6
+ * Configures a Prismic client to automatically query draft content during a
7
+ * preview session.
8
+ *
9
+ * @param config - Configuration for the function.
10
+ */
26
11
  function enableAutoPreviews(config) {
27
- config.client.queryContentFromRef(async () => {
28
- var _a;
29
- const { cookies, draftMode } = await import("next/headers");
30
- let isDraftModeEnabled = false;
31
- try {
32
- isDraftModeEnabled = (await draftMode()).isEnabled;
33
- } catch {
34
- return;
35
- }
36
- if (!isDraftModeEnabled) {
37
- return;
38
- }
39
- const cookie = (_a = (await cookies()).get(client.cookie.preview)) == null ? void 0 : _a.value;
40
- if (!cookie) {
41
- return;
42
- }
43
- const isActiveCookie = cookie.includes("websitePreviewId=");
44
- if (!isActiveCookie) {
45
- return;
46
- }
47
- return cookie;
48
- });
12
+ config.client.queryContentFromRef(async () => {
13
+ const { cookies, draftMode } = await import("next/headers");
14
+ let isDraftModeEnabled = false;
15
+ try {
16
+ isDraftModeEnabled = (await draftMode()).isEnabled;
17
+ } catch {
18
+ return;
19
+ }
20
+ if (!isDraftModeEnabled) return;
21
+ const cookie = (await cookies()).get(_prismicio_client.cookie.preview)?.value;
22
+ if (!cookie) return;
23
+ if (!cookie.includes("websitePreviewId=")) return;
24
+ return cookie;
25
+ });
49
26
  }
27
+
28
+ //#endregion
50
29
  exports.enableAutoPreviews = enableAutoPreviews;
51
- //# sourceMappingURL=enableAutoPreviews.cjs.map
30
+ //# sourceMappingURL=enableAutoPreviews.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"enableAutoPreviews.cjs","sources":["../src/enableAutoPreviews.ts"],"sourcesContent":["import { type Client, cookie as prismicCookie } from \"@prismicio/client\";\n\n/** Configuration for `enableAutoPreviews`. */\nexport type EnableAutoPreviewsConfig = {\n\t/** Prismic client with which automatic previews will be enabled. */\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, \"queryContentFromRef\" | \"enableAutoPreviewsFromReq\">;\n};\n\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session.\n *\n * @param config - Configuration for the function.\n */\nexport function enableAutoPreviews(config: EnableAutoPreviewsConfig): void {\n\t// We use a function value so the cookie is checked on every\n\t// request. We don't have a static value to read from.\n\tconfig.client.queryContentFromRef(async () => {\n\t\t// Need this to avoid the following Next.js build-time error:\n\t\t// You're importing a component that needs next/headers. That only works\n\t\t// in a Server Component which is not supported in the pages/ directory.\n\t\tconst { cookies, draftMode } = await import(\"next/headers\");\n\n\t\tlet isDraftModeEnabled = false;\n\t\ttry {\n\t\t\tisDraftModeEnabled = (await draftMode()).isEnabled;\n\t\t} catch {\n\t\t\t// `draftMode()` may have been called in a palce that\n\t\t\t// does not have access to its async storage. This\n\t\t\t// occurs in places like `generateStaticParams()`. We\n\t\t\t// can ignore this case.\n\t\t\treturn;\n\t\t}\n\t\tif (!isDraftModeEnabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst cookie = (await cookies()).get(prismicCookie.preview)?.value;\n\t\tif (!cookie) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isActiveCookie = cookie.includes(\"websitePreviewId=\");\n\t\tif (!isActiveCookie) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn cookie;\n\t});\n}\n"],"names":["prismicCookie"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiBM,SAAU,mBAAmB,QAAgC;AAG3D,SAAA,OAAO,oBAAoB,YAAW;;AAI5C,UAAM,EAAE,SAAS,cAAc,MAAM,OAAO,cAAc;AAE1D,QAAI,qBAAqB;AACrB,QAAA;AACmB,4BAAA,MAAM,aAAa;AAAA,IAAA,QAClC;AAKP;AAAA,IAAA;AAED,QAAI,CAAC,oBAAoB;AACxB;AAAA,IAAA;AAGD,UAAM,UAAU,YAAM,QAAA,GAAW,IAAIA,OAAA,OAAc,OAAO,MAA1C,mBAA6C;AAC7D,QAAI,CAAC,QAAQ;AACZ;AAAA,IAAA;AAGK,UAAA,iBAAiB,OAAO,SAAS,mBAAmB;AAC1D,QAAI,CAAC,gBAAgB;AACpB;AAAA,IAAA;AAGM,WAAA;AAAA,EAAA,CACP;AACF;;"}
1
+ {"version":3,"file":"enableAutoPreviews.cjs","names":["prismicCookie"],"sources":["../src/enableAutoPreviews.ts"],"sourcesContent":["import { type Client, cookie as prismicCookie } from \"@prismicio/client\";\n\n/** Configuration for `enableAutoPreviews`. */\nexport type EnableAutoPreviewsConfig = {\n\t/** Prismic client with which automatic previews will be enabled. */\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, \"queryContentFromRef\" | \"enableAutoPreviewsFromReq\">;\n};\n\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session.\n *\n * @param config - Configuration for the function.\n */\nexport function enableAutoPreviews(config: EnableAutoPreviewsConfig): void {\n\t// We use a function value so the cookie is checked on every\n\t// request. We don't have a static value to read from.\n\tconfig.client.queryContentFromRef(async () => {\n\t\t// Need this to avoid the following Next.js build-time error:\n\t\t// You're importing a component that needs next/headers. That only works\n\t\t// in a Server Component which is not supported in the pages/ directory.\n\t\tconst { cookies, draftMode } = await import(\"next/headers\");\n\n\t\tlet isDraftModeEnabled = false;\n\t\ttry {\n\t\t\tisDraftModeEnabled = (await draftMode()).isEnabled;\n\t\t} catch {\n\t\t\t// `draftMode()` may have been called in a palce that\n\t\t\t// does not have access to its async storage. This\n\t\t\t// occurs in places like `generateStaticParams()`. We\n\t\t\t// can ignore this case.\n\t\t\treturn;\n\t\t}\n\t\tif (!isDraftModeEnabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst cookie = (await cookies()).get(prismicCookie.preview)?.value;\n\t\tif (!cookie) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isActiveCookie = cookie.includes(\"websitePreviewId=\");\n\t\tif (!isActiveCookie) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn cookie;\n\t});\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,mBAAmB,QAAwC;AAG1E,QAAO,OAAO,oBAAoB,YAAY;EAI7C,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;EAE5C,IAAI,qBAAqB;AACzB,MAAI;AACH,yBAAsB,MAAM,WAAW,EAAE;UAClC;AAKP;;AAED,MAAI,CAAC,mBACJ;EAGD,MAAM,UAAU,MAAM,SAAS,EAAE,IAAIA,yBAAc,QAAQ,EAAE;AAC7D,MAAI,CAAC,OACJ;AAID,MAAI,CADmB,OAAO,SAAS,oBAAoB,CAE1D;AAGD,SAAO;GACN"}
@@ -0,0 +1,18 @@
1
+ import { Client } from "@prismicio/client";
2
+
3
+ //#region src/enableAutoPreviews.d.ts
4
+ /** Configuration for `enableAutoPreviews`. */
5
+ type EnableAutoPreviewsConfig = {
6
+ /** Prismic client with which automatic previews will be enabled. */
7
+ client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
8
+ };
9
+ /**
10
+ * Configures a Prismic client to automatically query draft content during a
11
+ * preview session.
12
+ *
13
+ * @param config - Configuration for the function.
14
+ */
15
+ declare function enableAutoPreviews(config: EnableAutoPreviewsConfig): void;
16
+ //#endregion
17
+ export { EnableAutoPreviewsConfig, enableAutoPreviews };
18
+ //# sourceMappingURL=enableAutoPreviews.d.cts.map
@@ -1,35 +1,27 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
+
2
+ //#region src/exitPreview.ts
3
+ /**
4
+ * Ends a Prismic preview session within a Next.js app. This function should be
5
+ * used in a Router Handler.
6
+ *
7
+ * @example
8
+ *
9
+ * ```typescript
10
+ * // src/app/api/exit-preview/route.js
11
+ *
12
+ * import { exitPreview } from "@prismicio/next";
13
+ *
14
+ * export async function GET() {
15
+ * return await exitPreview();
16
+ * }
17
+ * ```
18
+ */
25
19
  async function exitPreview() {
26
- const { draftMode } = await import("next/headers");
27
- (await draftMode()).disable();
28
- return new Response(JSON.stringify({ success: true }), {
29
- headers: {
30
- "Cache-Control": "no-store"
31
- }
32
- });
20
+ const { draftMode } = await import("next/headers");
21
+ (await draftMode()).disable();
22
+ return new Response(JSON.stringify({ success: true }), { headers: { "Cache-Control": "no-store" } });
33
23
  }
24
+
25
+ //#endregion
34
26
  exports.exitPreview = exitPreview;
35
- //# sourceMappingURL=exitPreview.cjs.map
27
+ //# sourceMappingURL=exitPreview.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"exitPreview.cjs","sources":["../src/exitPreview.ts"],"sourcesContent":["/**\n * Ends a Prismic preview session within a Next.js app. This function should be\n * used in a Router Handler.\n *\n * @example\n *\n * ```typescript\n * // src/app/api/exit-preview/route.js\n *\n * import { exitPreview } from \"@prismicio/next\";\n *\n * export async function GET() {\n * \treturn await exitPreview();\n * }\n * ```\n */\nexport async function exitPreview(): Promise<Response> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { draftMode } = await import(\"next/headers\");\n\n\t(await draftMode()).disable();\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\treturn new Response(JSON.stringify({ success: true }), {\n\t\theaders: {\n\t\t\t\"Cache-Control\": \"no-store\",\n\t\t},\n\t});\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgBA,eAAsB,cAAW;AAIhC,QAAM,EAAE,UAAA,IAAc,MAAM,OAAO,cAAc;AAEhD,GAAA,MAAM,UAAS,GAAI;AAGb,SAAA,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,KAAA,CAAM,GAAG;AAAA,IACtD,SAAS;AAAA,MACR,iBAAiB;AAAA,IAAA;AAAA,EACjB,CACD;AACF;;"}
1
+ {"version":3,"file":"exitPreview.cjs","names":[],"sources":["../src/exitPreview.ts"],"sourcesContent":["/**\n * Ends a Prismic preview session within a Next.js app. This function should be\n * used in a Router Handler.\n *\n * @example\n *\n * ```typescript\n * // src/app/api/exit-preview/route.js\n *\n * import { exitPreview } from \"@prismicio/next\";\n *\n * export async function GET() {\n * \treturn await exitPreview();\n * }\n * ```\n */\nexport async function exitPreview(): Promise<Response> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { draftMode } = await import(\"next/headers\");\n\n\t(await draftMode()).disable();\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\treturn new Response(JSON.stringify({ success: true }), {\n\t\theaders: {\n\t\t\t\"Cache-Control\": \"no-store\",\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,eAAsB,cAAiC;CAItD,MAAM,EAAE,cAAc,MAAM,OAAO;AAEnC,EAAC,MAAM,WAAW,EAAE,SAAS;AAG7B,QAAO,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,MAAM,CAAC,EAAE,EACtD,SAAS,EACR,iBAAiB,YACjB,EACD,CAAC"}
@@ -1,3 +1,4 @@
1
+ //#region src/exitPreview.d.ts
1
2
  /**
2
3
  * Ends a Prismic preview session within a Next.js app. This function should be
3
4
  * used in a Router Handler.
@@ -14,4 +15,7 @@
14
15
  * }
15
16
  * ```
16
17
  */
17
- export declare function exitPreview(): Promise<Response>;
18
+ declare function exitPreview(): Promise<Response>;
19
+ //#endregion
20
+ export { exitPreview };
21
+ //# sourceMappingURL=exitPreview.d.cts.map
@@ -1,17 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const imgixUrlBuilder = require("imgix-url-builder");
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let imgix_url_builder = require("imgix-url-builder");
3
+
4
+ //#region src/imgixLoader.ts
5
+ /**
6
+ * A `next/image` loader for Imgix, which Prismic uses, with an optional
7
+ * collection of default Imgix parameters.
8
+ *
9
+ * @see To learn about `next/image` loaders: https://nextjs.org/docs/api-reference/next/image#loader
10
+ * @see To learn about Imgix's URL API: https://docs.imgix.com/apis/rendering
11
+ */
4
12
  const imgixLoader = (args) => {
5
- const url = new URL(args.src);
6
- const params = {
7
- fit: url.searchParams.get("fit") || "max",
8
- w: args.width,
9
- h: void 0
10
- };
11
- if (args.quality) {
12
- params.q = args.quality;
13
- }
14
- return imgixUrlBuilder.buildURL(args.src, params);
13
+ const params = {
14
+ fit: new URL(args.src).searchParams.get("fit") || "max",
15
+ w: args.width,
16
+ h: void 0
17
+ };
18
+ if (args.quality) params.q = args.quality;
19
+ return (0, imgix_url_builder.buildURL)(args.src, params);
15
20
  };
21
+
22
+ //#endregion
16
23
  exports.imgixLoader = imgixLoader;
17
- //# sourceMappingURL=imgixLoader.cjs.map
24
+ //# sourceMappingURL=imgixLoader.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"imgixLoader.cjs","sources":["../src/imgixLoader.ts"],"sourcesContent":["import { ImageLoaderProps } from \"next/image\";\nimport { buildURL, ImgixURLParams } from \"imgix-url-builder\";\n\n/**\n * A `next/image` loader for Imgix, which Prismic uses, with an optional\n * collection of default Imgix parameters.\n *\n * @see To learn about `next/image` loaders: https://nextjs.org/docs/api-reference/next/image#loader\n * @see To learn about Imgix's URL API: https://docs.imgix.com/apis/rendering\n */\nexport const imgixLoader = (args: ImageLoaderProps): string => {\n\tconst url = new URL(args.src);\n\n\tconst params: ImgixURLParams = {\n\t\tfit: (url.searchParams.get(\"fit\") as ImgixURLParams[\"fit\"]) || \"max\",\n\t\tw: args.width,\n\t\th: undefined,\n\t};\n\n\tif (args.quality) {\n\t\tparams.q = args.quality;\n\t}\n\n\treturn buildURL(args.src, params);\n};\n"],"names":["buildURL"],"mappings":";;;AAUa,MAAA,cAAc,CAAC,SAAkC;AAC7D,QAAM,MAAM,IAAI,IAAI,KAAK,GAAG;AAE5B,QAAM,SAAyB;AAAA,IAC9B,KAAM,IAAI,aAAa,IAAI,KAAK,KAA+B;AAAA,IAC/D,GAAG,KAAK;AAAA,IACR,GAAG;AAAA;AAGJ,MAAI,KAAK,SAAS;AACjB,WAAO,IAAI,KAAK;AAAA,EAAA;AAGV,SAAAA,yBAAS,KAAK,KAAK,MAAM;AACjC;;"}
1
+ {"version":3,"file":"imgixLoader.cjs","names":[],"sources":["../src/imgixLoader.ts"],"sourcesContent":["import type { ImageLoaderProps } from \"next/image\";\nimport type { ImgixURLParams } from \"imgix-url-builder\";\nimport { buildURL } from \"imgix-url-builder\";\n\n/**\n * A `next/image` loader for Imgix, which Prismic uses, with an optional\n * collection of default Imgix parameters.\n *\n * @see To learn about `next/image` loaders: https://nextjs.org/docs/api-reference/next/image#loader\n * @see To learn about Imgix's URL API: https://docs.imgix.com/apis/rendering\n */\nexport const imgixLoader = (args: ImageLoaderProps): string => {\n\tconst url = new URL(args.src);\n\n\tconst params: ImgixURLParams = {\n\t\tfit: (url.searchParams.get(\"fit\") as ImgixURLParams[\"fit\"]) || \"max\",\n\t\tw: args.width,\n\t\th: undefined,\n\t};\n\n\tif (args.quality) {\n\t\tparams.q = args.quality;\n\t}\n\n\treturn buildURL(args.src, params);\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,eAAe,SAAmC;CAG9D,MAAM,SAAyB;EAC9B,KAHW,IAAI,IAAI,KAAK,IAAI,CAGlB,aAAa,IAAI,MAAM,IAA8B;EAC/D,GAAG,KAAK;EACR,GAAG;EACH;AAED,KAAI,KAAK,QACR,QAAO,IAAI,KAAK;AAGjB,wCAAgB,KAAK,KAAK,OAAO"}
@@ -1,4 +1,7 @@
1
1
  import { ImageLoaderProps } from "next/image";
2
+
3
+ //#region src/imgixLoader.d.ts
4
+
2
5
  /**
3
6
  * A `next/image` loader for Imgix, which Prismic uses, with an optional
4
7
  * collection of default Imgix parameters.
@@ -6,4 +9,7 @@ import { ImageLoaderProps } from "next/image";
6
9
  * @see To learn about `next/image` loaders: https://nextjs.org/docs/api-reference/next/image#loader
7
10
  * @see To learn about Imgix's URL API: https://docs.imgix.com/apis/rendering
8
11
  */
9
- export declare const imgixLoader: (args: ImageLoaderProps) => string;
12
+ declare const imgixLoader: (args: ImageLoaderProps) => string;
13
+ //#endregion
14
+ export { imgixLoader };
15
+ //# sourceMappingURL=imgixLoader.d.cts.map
package/dist/index.cjs CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const exitPreview = require("./exitPreview.cjs");
4
- const PrismicPreview = require("./PrismicPreview.cjs");
5
- const PrismicNextLink = require("./PrismicNextLink.cjs");
6
- const enableAutoPreviews = require("./enableAutoPreviews.cjs");
7
- const redirectToPreviewURL = require("./redirectToPreviewURL.cjs");
8
- const PrismicNextImage = require("./PrismicNextImage.cjs");
9
- const imgixLoader = require("./imgixLoader.cjs");
10
- const createLocaleRedirect = require("./createLocaleRedirect.cjs");
11
- exports.exitPreview = exitPreview.exitPreview;
12
- exports.PrismicPreview = PrismicPreview.PrismicPreview;
13
- exports.PrismicNextLink = PrismicNextLink.PrismicNextLink;
14
- exports.enableAutoPreviews = enableAutoPreviews.enableAutoPreviews;
15
- exports.redirectToPreviewURL = redirectToPreviewURL.redirectToPreviewURL;
16
- exports.PrismicNextImage = PrismicNextImage.PrismicNextImage;
17
- exports.imgixLoader = imgixLoader.imgixLoader;
18
- exports.createLocaleRedirect = createLocaleRedirect.createLocaleRedirect;
19
- //# sourceMappingURL=index.cjs.map
1
+ const require_exitPreview = require('./exitPreview.cjs');
2
+ const require_PrismicPreview = require('./PrismicPreview.cjs');
3
+ const require_PrismicNextLink = require('./PrismicNextLink.cjs');
4
+ const require_enableAutoPreviews = require('./enableAutoPreviews.cjs');
5
+ const require_redirectToPreviewURL = require('./redirectToPreviewURL.cjs');
6
+ const require_imgixLoader = require('./imgixLoader.cjs');
7
+ const require_PrismicNextImage = require('./PrismicNextImage.cjs');
8
+ const require_PrismicNextRichText = require('./PrismicNextRichText.cjs');
9
+ const require_createLocaleRedirect = require('./createLocaleRedirect.cjs');
10
+
11
+ exports.PrismicNextImage = require_PrismicNextImage.PrismicNextImage;
12
+ exports.PrismicNextLink = require_PrismicNextLink.PrismicNextLink;
13
+ exports.PrismicNextRichText = require_PrismicNextRichText.PrismicNextRichText;
14
+ exports.PrismicPreview = require_PrismicPreview.PrismicPreview;
15
+ exports.createLocaleRedirect = require_createLocaleRedirect.createLocaleRedirect;
16
+ exports.enableAutoPreviews = require_enableAutoPreviews.enableAutoPreviews;
17
+ exports.exitPreview = require_exitPreview.exitPreview;
18
+ exports.imgixLoader = require_imgixLoader.imgixLoader;
19
+ exports.redirectToPreviewURL = require_redirectToPreviewURL.redirectToPreviewURL;
@@ -0,0 +1,11 @@
1
+ import { exitPreview } from "./exitPreview.cjs";
2
+ import { PrismicPreview, PrismicPreviewProps } from "./PrismicPreview.cjs";
3
+ import { PrismicNextLink, PrismicNextLinkProps } from "./PrismicNextLink.cjs";
4
+ import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./enableAutoPreviews.cjs";
5
+ import { CreateClientConfig } from "./types.cjs";
6
+ import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./redirectToPreviewURL.cjs";
7
+ import { PrismicNextImage, PrismicNextImageProps } from "./PrismicNextImage.cjs";
8
+ import { PrismicNextRichText, PrismicNextRichTextProps } from "./PrismicNextRichText.cjs";
9
+ import { imgixLoader } from "./imgixLoader.cjs";
10
+ import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.cjs";
11
+ export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, PrismicNextImage, type PrismicNextImageProps, PrismicNextLink, type PrismicNextLinkProps, PrismicNextRichText, type PrismicNextRichTextProps, PrismicPreview, type PrismicPreviewProps, type RedirectToPreviewURLConfig, createLocaleRedirect, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL };
@@ -1,8 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const _package = require("../package.json.cjs");
1
+ const require_package = require('../package.cjs');
2
+
3
+ //#region src/lib/devMsg.ts
4
+ /**
5
+ * Returns a `prismic.dev/msg` URL for a given message slug.
6
+ *
7
+ * @example
8
+ *
9
+ * ```ts
10
+ * devMsg("missing-param");
11
+ * // => "https://prismic.dev/msg/next/v1.2.3/missing-param"
12
+ * ```
13
+ *
14
+ * @param slug - Slug for the message. This corresponds to a Markdown file in
15
+ * the Git repository's `/messages` directory.
16
+ *
17
+ * @returns The `prismic.dev/msg` URL for the given slug.
18
+ */
4
19
  const devMsg = (slug) => {
5
- return `https://prismic.dev/msg/next/v${_package.version}/${slug}`;
20
+ return `https://prismic.dev/msg/next/v${require_package.version}/${slug}`;
6
21
  };
22
+
23
+ //#endregion
7
24
  exports.devMsg = devMsg;
8
- //# sourceMappingURL=devMsg.cjs.map
25
+ //# sourceMappingURL=devMsg.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"devMsg.cjs","sources":["../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/next/v1.2.3/missing-param\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string) => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`;\n};\n"],"names":["version"],"mappings":";;;AAiBa,MAAA,SAAS,CAAC,SAAgB;AAC/B,SAAA,iCAAiCA,SAAAA,OAAO,IAAI,IAAI;AACxD;;"}
1
+ {"version":3,"file":"devMsg.cjs","names":["version"],"sources":["../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/next/v1.2.3/missing-param\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport const devMsg = (slug: string): string => {\n\treturn `https://prismic.dev/msg/next/v${version}/${slug}`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,UAAU,SAAyB;AAC/C,QAAO,iCAAiCA,wBAAQ,GAAG"}