@prismicio/next 1.0.3 → 1.1.0-alpha.0

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 (54) hide show
  1. package/dist/PrismicNextImage.cjs +9 -3
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.ts +2 -2
  4. package/dist/PrismicNextImage.js +8 -2
  5. package/dist/PrismicNextImage.js.map +1 -1
  6. package/dist/PrismicNextLink.cjs +40 -0
  7. package/dist/PrismicNextLink.cjs.map +1 -0
  8. package/dist/PrismicNextLink.d.ts +126 -0
  9. package/dist/PrismicNextLink.js +22 -0
  10. package/dist/PrismicNextLink.js.map +1 -0
  11. package/dist/PrismicPreview.cjs +2 -0
  12. package/dist/PrismicPreview.cjs.map +1 -1
  13. package/dist/PrismicPreview.js +2 -0
  14. package/dist/PrismicPreview.js.map +1 -1
  15. package/dist/enableAutoPreviews.cjs.map +1 -1
  16. package/dist/enableAutoPreviews.d.ts +3 -3
  17. package/dist/enableAutoPreviews.js.map +1 -1
  18. package/dist/index.cjs +2 -0
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +15 -7
  21. package/dist/index.js +2 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/lib/getPreviewCookieRepositoryName.cjs.map +1 -1
  24. package/dist/lib/getPreviewCookieRepositoryName.js.map +1 -1
  25. package/dist/lib/getPrismicPreviewCookie.cjs.map +1 -1
  26. package/dist/lib/getPrismicPreviewCookie.js.map +1 -1
  27. package/dist/package.json.cjs +1 -1
  28. package/dist/package.json.js +1 -1
  29. package/dist/react-server/PrismicPreview.d.ts +22 -0
  30. package/dist/react-server/index.d.ts +2 -0
  31. package/dist/react-server/unsupported.cjs +26 -0
  32. package/dist/react-server/unsupported.cjs.map +1 -0
  33. package/dist/react-server/unsupported.d.ts +6 -0
  34. package/dist/react-server/unsupported.js +26 -0
  35. package/dist/react-server/unsupported.js.map +1 -0
  36. package/dist/react-server.cjs +15 -0
  37. package/dist/react-server.cjs.map +1 -0
  38. package/dist/react-server.js +15 -0
  39. package/dist/react-server.js.map +1 -0
  40. package/dist/redirectToPreviewURL.cjs.map +1 -1
  41. package/dist/redirectToPreviewURL.d.ts +4 -5
  42. package/dist/redirectToPreviewURL.js.map +1 -1
  43. package/dist/setPreviewData.cjs.map +1 -1
  44. package/dist/setPreviewData.js.map +1 -1
  45. package/package.json +37 -32
  46. package/src/PrismicNextImage.tsx +5 -4
  47. package/src/PrismicNextLink.tsx +55 -0
  48. package/src/PrismicPreview.tsx +2 -0
  49. package/src/enableAutoPreviews.ts +9 -3
  50. package/src/index.ts +16 -13
  51. package/src/react-server/PrismicPreview.tsx +74 -0
  52. package/src/react-server/index.ts +11 -0
  53. package/src/react-server/unsupported.ts +26 -0
  54. package/src/redirectToPreviewURL.ts +7 -5
package/dist/index.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { setPreviewData } from "./setPreviewData.js";
2
2
  import { exitPreview } from "./exitPreview.js";
3
3
  import { PrismicPreview } from "./PrismicPreview.js";
4
+ import { PrismicNextLink } from "./PrismicNextLink.js";
4
5
  import { enableAutoPreviews } from "./enableAutoPreviews.js";
5
6
  import { redirectToPreviewURL } from "./redirectToPreviewURL.js";
6
7
  import { PrismicNextImage } from "./PrismicNextImage.js";
7
8
  import { imgixLoader } from "./imgixLoader.js";
8
9
  export {
9
10
  PrismicNextImage,
11
+ PrismicNextLink,
10
12
  PrismicPreview,
11
13
  enableAutoPreviews,
12
14
  exitPreview,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPreviewCookieRepositoryName.cjs","sources":["../../../src/lib/getPreviewCookieRepositoryName.ts"],"sourcesContent":["/**\n * Extracts preview reference repo name from stringified Prismic preview cookie\n *\n * @param previewCookie - The Prismic preview cookie.\n *\n * @returns The repository name for the Prismic preview cookie. If the cookie\n * represents an inactive preview session, `undefined` will be returned.\n */\nexport const getPreviewCookieRepositoryName = (\n\tpreviewCookie: string,\n): string | undefined => {\n\treturn (decodeURIComponent(previewCookie).match(/\"(.+).prismic.io\"/) ||\n\t\t[])[1];\n};\n"],"names":[],"mappings":";;AAQa,MAAA,iCAAiC,CAC7C,kBACuB;AACvB,UAAQ,mBAAmB,aAAa,EAAE,MAAM,mBAAmB,KAClE,CAAA,GAAI;AACN;;"}
1
+ {"version":3,"file":"getPreviewCookieRepositoryName.cjs","sources":["../../../src/lib/getPreviewCookieRepositoryName.ts"],"sourcesContent":["/**\n * Extracts preview reference repo name from stringified Prismic preview cookie\n *\n * @param previewCookie - The Prismic preview cookie.\n *\n * @returns The repository name for the Prismic preview cookie. If the cookie\n * represents an inactive preview session, `undefined` will be returned.\n */\nexport const getPreviewCookieRepositoryName = (\n\tpreviewCookie: string,\n): string | undefined => {\n\treturn (decodeURIComponent(previewCookie).match(/\"(.+).prismic.io\"/) ||\n\t\t[])[1];\n};\n"],"names":[],"mappings":";;AAQa,MAAA,iCAAiC,CAC7C,kBACuB;AACf,UAAA,mBAAmB,aAAa,EAAE,MAAM,mBAAmB,KAClE,CAAA,GAAI,CAAC;AACP;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPreviewCookieRepositoryName.js","sources":["../../../src/lib/getPreviewCookieRepositoryName.ts"],"sourcesContent":["/**\n * Extracts preview reference repo name from stringified Prismic preview cookie\n *\n * @param previewCookie - The Prismic preview cookie.\n *\n * @returns The repository name for the Prismic preview cookie. If the cookie\n * represents an inactive preview session, `undefined` will be returned.\n */\nexport const getPreviewCookieRepositoryName = (\n\tpreviewCookie: string,\n): string | undefined => {\n\treturn (decodeURIComponent(previewCookie).match(/\"(.+).prismic.io\"/) ||\n\t\t[])[1];\n};\n"],"names":[],"mappings":"AAQa,MAAA,iCAAiC,CAC7C,kBACuB;AACvB,UAAQ,mBAAmB,aAAa,EAAE,MAAM,mBAAmB,KAClE,CAAA,GAAI;AACN;"}
1
+ {"version":3,"file":"getPreviewCookieRepositoryName.js","sources":["../../../src/lib/getPreviewCookieRepositoryName.ts"],"sourcesContent":["/**\n * Extracts preview reference repo name from stringified Prismic preview cookie\n *\n * @param previewCookie - The Prismic preview cookie.\n *\n * @returns The repository name for the Prismic preview cookie. If the cookie\n * represents an inactive preview session, `undefined` will be returned.\n */\nexport const getPreviewCookieRepositoryName = (\n\tpreviewCookie: string,\n): string | undefined => {\n\treturn (decodeURIComponent(previewCookie).match(/\"(.+).prismic.io\"/) ||\n\t\t[])[1];\n};\n"],"names":[],"mappings":"AAQa,MAAA,iCAAiC,CAC7C,kBACuB;AACf,UAAA,mBAAmB,aAAa,EAAE,MAAM,mBAAmB,KAClE,CAAA,GAAI,CAAC;AACP;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPrismicPreviewCookie.cjs","sources":["../../../src/lib/getPrismicPreviewCookie.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\");\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 */\nexport const getPrismicPreviewCookie = (\n\tcookieJar: string,\n): string | undefined => {\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 === prismic.cookie.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":["prismic"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,0BAA0B,CACtC,cACuB;AACjB,QAAA,UAAU,UAAU,MAAM,IAAI;AAEhC,MAAA;AAEJ,aAAW,UAAU,SAAS;AACvB,UAAA,QAAQ,OAAO,MAAM,GAAG;AAC9B,UAAM,OAAO,UAAU,MAAM,EAAE,EAAE,QAAQ,QAAQ,GAAG;AAEhD,QAAA,SAASA,mBAAQ,OAAO,SAAS;AACpC,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACA;AAAA,EACD;AAEM,SAAA;AACR;;"}
1
+ {"version":3,"file":"getPrismicPreviewCookie.cjs","sources":["../../../src/lib/getPrismicPreviewCookie.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\");\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 */\nexport const getPrismicPreviewCookie = (\n\tcookieJar: string,\n): string | undefined => {\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 === prismic.cookie.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":["prismic"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,0BAA0B,CACtC,cACuB;AACjB,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,SAASA,mBAAQ,OAAO,SAAS;AACpC,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACA;AAAA,EACD;AAEM,SAAA;AACR;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPrismicPreviewCookie.js","sources":["../../../src/lib/getPrismicPreviewCookie.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\");\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 */\nexport const getPrismicPreviewCookie = (\n\tcookieJar: string,\n): string | undefined => {\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 === prismic.cookie.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":[],"mappings":";AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,0BAA0B,CACtC,cACuB;AACjB,QAAA,UAAU,UAAU,MAAM,IAAI;AAEhC,MAAA;AAEJ,aAAW,UAAU,SAAS;AACvB,UAAA,QAAQ,OAAO,MAAM,GAAG;AAC9B,UAAM,OAAO,UAAU,MAAM,EAAE,EAAE,QAAQ,QAAQ,GAAG;AAEhD,QAAA,SAAS,QAAQ,OAAO,SAAS;AACpC,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACA;AAAA,EACD;AAEM,SAAA;AACR;"}
1
+ {"version":3,"file":"getPrismicPreviewCookie.js","sources":["../../../src/lib/getPrismicPreviewCookie.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\");\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 */\nexport const getPrismicPreviewCookie = (\n\tcookieJar: string,\n): string | undefined => {\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 === prismic.cookie.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":[],"mappings":";AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,0BAA0B,CACtC,cACuB;AACjB,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,SAAS,QAAQ,OAAO,SAAS;AACpC,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACA;AAAA,EACD;AAEM,SAAA;AACR;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "1.0.3";
3
+ const version = "1.1.0-alpha.0";
4
4
  exports.version = version;
5
5
  //# sourceMappingURL=package.json.cjs.map
@@ -1,4 +1,4 @@
1
- const version = "1.0.3";
1
+ const version = "1.1.0-alpha.0";
2
2
  export {
3
3
  version
4
4
  };
@@ -0,0 +1,22 @@
1
+ import * as React from "react";
2
+ /**
3
+ * Props for `<PrismicPreview>`.
4
+ */
5
+ export type PrismicPreviewProps = {
6
+ /**
7
+ * The name of your Prismic repository. A Prismic Toolbar will be registered
8
+ * using this repository.
9
+ */
10
+ repositoryName: string;
11
+ children?: React.ReactNode;
12
+ };
13
+ /**
14
+ * React component that sets up Prismic Previews using the Prismic Toolbar. When
15
+ * the Prismic Toolbar send events to the browser, such as on preview updates
16
+ * and exiting, this component will automatically update Next.js Preview Mode
17
+ * and refresh the page.
18
+ *
19
+ * This component can be wrapped around your app or added anywhere in your app's
20
+ * tree. It must be rendered on every page.
21
+ */
22
+ export declare function PrismicPreview({ repositoryName, children, }: PrismicPreviewProps): JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { PrismicPreview, enableAutoPreviews, redirectToPreviewURL, exitPreview, setPreviewData, } from "./unsupported";
2
+ export { PrismicNextImage, imgixLoader, PrismicNextLink } from "..";
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function buildErrorMessage(fnName) {
4
+ return `${fnName} is currently incompatible with App Router. Preview Mode is not supported in App Router at this time. Please remove all uses of ${fnName}.`;
5
+ }
6
+ function PrismicPreview() {
7
+ throw new Error(buildErrorMessage("<PrismicPreview>"));
8
+ }
9
+ function enableAutoPreviews() {
10
+ throw new Error(buildErrorMessage("enableAutoPreviews()"));
11
+ }
12
+ function exitPreview() {
13
+ throw new Error(buildErrorMessage("exitPreview()"));
14
+ }
15
+ function redirectToPreviewURL() {
16
+ throw new Error(buildErrorMessage("redirectToPreviewURL()"));
17
+ }
18
+ function setPreviewData() {
19
+ throw new Error(buildErrorMessage("setPreviewData()"));
20
+ }
21
+ exports.PrismicPreview = PrismicPreview;
22
+ exports.enableAutoPreviews = enableAutoPreviews;
23
+ exports.exitPreview = exitPreview;
24
+ exports.redirectToPreviewURL = redirectToPreviewURL;
25
+ exports.setPreviewData = setPreviewData;
26
+ //# sourceMappingURL=unsupported.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsupported.cjs","sources":["../../../src/react-server/unsupported.ts"],"sourcesContent":["// Exports in this file are unsupported in the react-server environment.\n// All environments should export the same functions to maintian API compatability.\n\nfunction buildErrorMessage(fnName: string) {\n\treturn `${fnName} is currently incompatible with App Router. Preview Mode is not supported in App Router at this time. Please remove all uses of ${fnName}.`;\n}\n\nexport function PrismicPreview(): JSX.Element {\n\tthrow new Error(buildErrorMessage(\"<PrismicPreview>\"));\n}\n\nexport function enableAutoPreviews() {\n\tthrow new Error(buildErrorMessage(\"enableAutoPreviews()\"));\n}\n\nexport function exitPreview() {\n\tthrow new Error(buildErrorMessage(\"exitPreview()\"));\n}\n\nexport function redirectToPreviewURL() {\n\tthrow new Error(buildErrorMessage(\"redirectToPreviewURL()\"));\n}\n\nexport function setPreviewData() {\n\tthrow new Error(buildErrorMessage(\"setPreviewData()\"));\n}\n"],"names":[],"mappings":";;AAGA,SAAS,kBAAkB,QAAc;AACxC,SAAO,GAAG,yIAAyI;AACpJ;SAEgB,iBAAc;AAC7B,QAAM,IAAI,MAAM,kBAAkB,kBAAkB,CAAC;AACtD;SAEgB,qBAAkB;AACjC,QAAM,IAAI,MAAM,kBAAkB,sBAAsB,CAAC;AAC1D;SAEgB,cAAW;AAC1B,QAAM,IAAI,MAAM,kBAAkB,eAAe,CAAC;AACnD;SAEgB,uBAAoB;AACnC,QAAM,IAAI,MAAM,kBAAkB,wBAAwB,CAAC;AAC5D;SAEgB,iBAAc;AAC7B,QAAM,IAAI,MAAM,kBAAkB,kBAAkB,CAAC;AACtD;;;;;;"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare function PrismicPreview(): JSX.Element;
3
+ export declare function enableAutoPreviews(): void;
4
+ export declare function exitPreview(): void;
5
+ export declare function redirectToPreviewURL(): void;
6
+ export declare function setPreviewData(): void;
@@ -0,0 +1,26 @@
1
+ function buildErrorMessage(fnName) {
2
+ return `${fnName} is currently incompatible with App Router. Preview Mode is not supported in App Router at this time. Please remove all uses of ${fnName}.`;
3
+ }
4
+ function PrismicPreview() {
5
+ throw new Error(buildErrorMessage("<PrismicPreview>"));
6
+ }
7
+ function enableAutoPreviews() {
8
+ throw new Error(buildErrorMessage("enableAutoPreviews()"));
9
+ }
10
+ function exitPreview() {
11
+ throw new Error(buildErrorMessage("exitPreview()"));
12
+ }
13
+ function redirectToPreviewURL() {
14
+ throw new Error(buildErrorMessage("redirectToPreviewURL()"));
15
+ }
16
+ function setPreviewData() {
17
+ throw new Error(buildErrorMessage("setPreviewData()"));
18
+ }
19
+ export {
20
+ PrismicPreview,
21
+ enableAutoPreviews,
22
+ exitPreview,
23
+ redirectToPreviewURL,
24
+ setPreviewData
25
+ };
26
+ //# sourceMappingURL=unsupported.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsupported.js","sources":["../../../src/react-server/unsupported.ts"],"sourcesContent":["// Exports in this file are unsupported in the react-server environment.\n// All environments should export the same functions to maintian API compatability.\n\nfunction buildErrorMessage(fnName: string) {\n\treturn `${fnName} is currently incompatible with App Router. Preview Mode is not supported in App Router at this time. Please remove all uses of ${fnName}.`;\n}\n\nexport function PrismicPreview(): JSX.Element {\n\tthrow new Error(buildErrorMessage(\"<PrismicPreview>\"));\n}\n\nexport function enableAutoPreviews() {\n\tthrow new Error(buildErrorMessage(\"enableAutoPreviews()\"));\n}\n\nexport function exitPreview() {\n\tthrow new Error(buildErrorMessage(\"exitPreview()\"));\n}\n\nexport function redirectToPreviewURL() {\n\tthrow new Error(buildErrorMessage(\"redirectToPreviewURL()\"));\n}\n\nexport function setPreviewData() {\n\tthrow new Error(buildErrorMessage(\"setPreviewData()\"));\n}\n"],"names":[],"mappings":"AAGA,SAAS,kBAAkB,QAAc;AACxC,SAAO,GAAG,yIAAyI;AACpJ;SAEgB,iBAAc;AAC7B,QAAM,IAAI,MAAM,kBAAkB,kBAAkB,CAAC;AACtD;SAEgB,qBAAkB;AACjC,QAAM,IAAI,MAAM,kBAAkB,sBAAsB,CAAC;AAC1D;SAEgB,cAAW;AAC1B,QAAM,IAAI,MAAM,kBAAkB,eAAe,CAAC;AACnD;SAEgB,uBAAoB;AACnC,QAAM,IAAI,MAAM,kBAAkB,wBAAwB,CAAC;AAC5D;SAEgB,iBAAc;AAC7B,QAAM,IAAI,MAAM,kBAAkB,kBAAkB,CAAC;AACtD;"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const unsupported = require("./react-server/unsupported.cjs");
4
+ const PrismicNextLink = require("./PrismicNextLink.cjs");
5
+ const PrismicNextImage = require("./PrismicNextImage.cjs");
6
+ const imgixLoader = require("./imgixLoader.cjs");
7
+ exports.PrismicPreview = unsupported.PrismicPreview;
8
+ exports.enableAutoPreviews = unsupported.enableAutoPreviews;
9
+ exports.exitPreview = unsupported.exitPreview;
10
+ exports.redirectToPreviewURL = unsupported.redirectToPreviewURL;
11
+ exports.setPreviewData = unsupported.setPreviewData;
12
+ exports.PrismicNextLink = PrismicNextLink.PrismicNextLink;
13
+ exports.PrismicNextImage = PrismicNextImage.PrismicNextImage;
14
+ exports.imgixLoader = imgixLoader.imgixLoader;
15
+ //# sourceMappingURL=react-server.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-server.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -0,0 +1,15 @@
1
+ import { PrismicPreview, enableAutoPreviews, exitPreview, redirectToPreviewURL, setPreviewData } from "./react-server/unsupported.js";
2
+ import { PrismicNextLink } from "./PrismicNextLink.js";
3
+ import { PrismicNextImage } from "./PrismicNextImage.js";
4
+ import { imgixLoader } from "./imgixLoader.js";
5
+ export {
6
+ PrismicNextImage,
7
+ PrismicNextLink,
8
+ PrismicPreview,
9
+ enableAutoPreviews,
10
+ exitPreview,
11
+ imgixLoader,
12
+ redirectToPreviewURL,
13
+ setPreviewData
14
+ };
15
+ //# sourceMappingURL=react-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.cjs","sources":["../../src/redirectToPreviewURL.ts"],"sourcesContent":["import type { Client } from \"@prismicio/client\";\nimport type { NextApiRequest, NextApiResponse } from \"next\";\nimport type { LinkResolverFunction } from \"@prismicio/helpers\";\n\ntype PrismicNextQuery = {\n\tdocumentId: string;\n\ttoken: string;\n};\n\n/**\n * Determines if a query object from a Next.js API route request contains\n * Prismic preview data.\n *\n * @param query - Query object to check.\n *\n * @returns `true` if `query` contains Prismic preview data, `false` otherwise.\n */\nconst isPrismicNextQuery = (\n\tquery: NextApiRequest[\"query\"],\n): query is PrismicNextQuery => {\n\treturn (\n\t\ttypeof query.documentId === \"string\" && typeof query.token === \"string\"\n\t);\n};\n\n/**\n * Preview config for enabling previews with redirectToPreviewURL\n */\nexport type RedirectToPreviewURLConfig<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTLinkResolverFunction extends LinkResolverFunction<any> = LinkResolverFunction,\n> = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\treq: {\n\t\tquery: NextApiRequest[\"query\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tredirect: NextApiResponse[\"redirect\"];\n\t};\n\n\t/**\n\t * The Prismic client configured for the preview session's repository.\n\t */\n\tclient: Client;\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?: TLinkResolverFunction;\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\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`.\n\t * This option can be omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The 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\n/**\n * Redirects a user to the URL of a previewed Prismic document from within a\n * Next.js API route.\n */\nexport async function redirectToPreviewURL<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTLinkResolverFunction extends LinkResolverFunction<any>,\n>(config: RedirectToPreviewURLConfig<TLinkResolverFunction>): Promise<void> {\n\tconst defaultURL = config.defaultURL || \"/\";\n\tconst basePath = config.basePath || \"\";\n\n\tif (isPrismicNextQuery(config.req.query)) {\n\t\tconst previewUrl = await config.client.resolvePreviewURL({\n\t\t\tlinkResolver: config.linkResolver,\n\t\t\tdefaultURL,\n\t\t\tdocumentID: config.req.query.documentId,\n\t\t\tpreviewToken: config.req.query.token,\n\t\t});\n\n\t\tconfig.res.redirect(basePath + previewUrl);\n\n\t\treturn;\n\t}\n\n\tconfig.res.redirect(basePath + defaultURL);\n}\n"],"names":[],"mappings":";;AAiBA,MAAM,qBAAqB,CAC1B,UAC8B;AAC9B,SACC,OAAO,MAAM,eAAe,YAAY,OAAO,MAAM,UAAU;AAEjE;AAkEA,eAAsB,qBAGpB,QAAyD;AACpD,QAAA,aAAa,OAAO,cAAc;AAClC,QAAA,WAAW,OAAO,YAAY;AAEpC,MAAI,mBAAmB,OAAO,IAAI,KAAK,GAAG;AACzC,UAAM,aAAa,MAAM,OAAO,OAAO,kBAAkB;AAAA,MACxD,cAAc,OAAO;AAAA,MACrB;AAAA,MACA,YAAY,OAAO,IAAI,MAAM;AAAA,MAC7B,cAAc,OAAO,IAAI,MAAM;AAAA,IAAA,CAC/B;AAEM,WAAA,IAAI,SAAS,WAAW,UAAU;AAEzC;AAAA,EACA;AAEM,SAAA,IAAI,SAAS,WAAW,UAAU;AAC1C;;"}
1
+ {"version":3,"file":"redirectToPreviewURL.cjs","sources":["../../src/redirectToPreviewURL.ts"],"sourcesContent":["import type { NextApiRequest, NextApiResponse } from \"next\";\nimport type * as prismic from \"@prismicio/client\";\n\ntype PrismicNextQuery = {\n\tdocumentId: string;\n\ttoken: string;\n};\n\n/**\n * Determines if a query object from a Next.js API route request contains\n * Prismic preview data.\n *\n * @param query - Query object to check.\n *\n * @returns `true` if `query` contains Prismic preview data, `false` otherwise.\n */\nconst isPrismicNextQuery = (\n\tquery: NextApiRequest[\"query\"],\n): query is PrismicNextQuery => {\n\treturn (\n\t\ttypeof query.documentId === \"string\" && typeof query.token === \"string\"\n\t);\n};\n\n/**\n * Preview config for enabling previews with redirectToPreviewURL\n */\nexport type RedirectToPreviewURLConfig<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\treq: {\n\t\tquery: NextApiRequest[\"query\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tredirect: NextApiResponse[\"redirect\"];\n\t};\n\n\t/**\n\t * The Prismic client configured for the preview session's repository.\n\t */\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<prismic.Client, \"resolvePreviewURL\">;\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?: TLinkResolverFunction;\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\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`.\n\t * This option can be omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The 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\n/**\n * Redirects a user to the URL of a previewed Prismic document from within a\n * Next.js API route.\n */\nexport async function redirectToPreviewURL<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>(config: RedirectToPreviewURLConfig<TLinkResolverFunction>): Promise<void> {\n\tconst defaultURL = config.defaultURL || \"/\";\n\tconst basePath = config.basePath || \"\";\n\n\tif (isPrismicNextQuery(config.req.query)) {\n\t\tconst previewUrl = await config.client.resolvePreviewURL({\n\t\t\tlinkResolver: config.linkResolver,\n\t\t\tdefaultURL,\n\t\t\tdocumentID: config.req.query.documentId,\n\t\t\tpreviewToken: config.req.query.token,\n\t\t});\n\n\t\tconfig.res.redirect(basePath + previewUrl);\n\n\t\treturn;\n\t}\n\n\tconfig.res.redirect(basePath + defaultURL);\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,qBAAqB,CAC1B,UAC8B;AAC9B,SACC,OAAO,MAAM,eAAe,YAAY,OAAO,MAAM,UAAU;AAEjE;AAqEA,eAAsB,qBAGpB,QAAyD;AACpD,QAAA,aAAa,OAAO,cAAc;AAClC,QAAA,WAAW,OAAO,YAAY;AAEpC,MAAI,mBAAmB,OAAO,IAAI,KAAK,GAAG;AACzC,UAAM,aAAa,MAAM,OAAO,OAAO,kBAAkB;AAAA,MACxD,cAAc,OAAO;AAAA,MACrB;AAAA,MACA,YAAY,OAAO,IAAI,MAAM;AAAA,MAC7B,cAAc,OAAO,IAAI,MAAM;AAAA,IAAA,CAC/B;AAEM,WAAA,IAAI,SAAS,WAAW,UAAU;AAEzC;AAAA,EACA;AAEM,SAAA,IAAI,SAAS,WAAW,UAAU;AAC1C;;"}
@@ -1,10 +1,9 @@
1
- import type { Client } from "@prismicio/client";
2
1
  import type { NextApiRequest, NextApiResponse } from "next";
3
- import type { LinkResolverFunction } from "@prismicio/helpers";
2
+ import type * as prismic from "@prismicio/client";
4
3
  /**
5
4
  * Preview config for enabling previews with redirectToPreviewURL
6
5
  */
7
- export type RedirectToPreviewURLConfig<TLinkResolverFunction extends LinkResolverFunction<any> = LinkResolverFunction> = {
6
+ export type RedirectToPreviewURLConfig<TLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction> = {
8
7
  /**
9
8
  * The `req` object from a Next.js API route. This is given as a parameter to
10
9
  * the API route.
@@ -26,7 +25,7 @@ export type RedirectToPreviewURLConfig<TLinkResolverFunction extends LinkResolve
26
25
  /**
27
26
  * The Prismic client configured for the preview session's repository.
28
27
  */
29
- client: Client;
28
+ client: Pick<prismic.Client, "resolvePreviewURL">;
30
29
  /**
31
30
  * A Link Resolver used to resolve the previewed document's URL.
32
31
  *
@@ -56,4 +55,4 @@ export type RedirectToPreviewURLConfig<TLinkResolverFunction extends LinkResolve
56
55
  * Redirects a user to the URL of a previewed Prismic document from within a
57
56
  * Next.js API route.
58
57
  */
59
- export declare function redirectToPreviewURL<TLinkResolverFunction extends LinkResolverFunction<any>>(config: RedirectToPreviewURLConfig<TLinkResolverFunction>): Promise<void>;
58
+ export declare function redirectToPreviewURL<TLinkResolverFunction extends prismic.LinkResolverFunction<any>>(config: RedirectToPreviewURLConfig<TLinkResolverFunction>): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToPreviewURL.js","sources":["../../src/redirectToPreviewURL.ts"],"sourcesContent":["import type { Client } from \"@prismicio/client\";\nimport type { NextApiRequest, NextApiResponse } from \"next\";\nimport type { LinkResolverFunction } from \"@prismicio/helpers\";\n\ntype PrismicNextQuery = {\n\tdocumentId: string;\n\ttoken: string;\n};\n\n/**\n * Determines if a query object from a Next.js API route request contains\n * Prismic preview data.\n *\n * @param query - Query object to check.\n *\n * @returns `true` if `query` contains Prismic preview data, `false` otherwise.\n */\nconst isPrismicNextQuery = (\n\tquery: NextApiRequest[\"query\"],\n): query is PrismicNextQuery => {\n\treturn (\n\t\ttypeof query.documentId === \"string\" && typeof query.token === \"string\"\n\t);\n};\n\n/**\n * Preview config for enabling previews with redirectToPreviewURL\n */\nexport type RedirectToPreviewURLConfig<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTLinkResolverFunction extends LinkResolverFunction<any> = LinkResolverFunction,\n> = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\treq: {\n\t\tquery: NextApiRequest[\"query\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tredirect: NextApiResponse[\"redirect\"];\n\t};\n\n\t/**\n\t * The Prismic client configured for the preview session's repository.\n\t */\n\tclient: Client;\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?: TLinkResolverFunction;\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\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`.\n\t * This option can be omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The 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\n/**\n * Redirects a user to the URL of a previewed Prismic document from within a\n * Next.js API route.\n */\nexport async function redirectToPreviewURL<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTLinkResolverFunction extends LinkResolverFunction<any>,\n>(config: RedirectToPreviewURLConfig<TLinkResolverFunction>): Promise<void> {\n\tconst defaultURL = config.defaultURL || \"/\";\n\tconst basePath = config.basePath || \"\";\n\n\tif (isPrismicNextQuery(config.req.query)) {\n\t\tconst previewUrl = await config.client.resolvePreviewURL({\n\t\t\tlinkResolver: config.linkResolver,\n\t\t\tdefaultURL,\n\t\t\tdocumentID: config.req.query.documentId,\n\t\t\tpreviewToken: config.req.query.token,\n\t\t});\n\n\t\tconfig.res.redirect(basePath + previewUrl);\n\n\t\treturn;\n\t}\n\n\tconfig.res.redirect(basePath + defaultURL);\n}\n"],"names":[],"mappings":"AAiBA,MAAM,qBAAqB,CAC1B,UAC8B;AAC9B,SACC,OAAO,MAAM,eAAe,YAAY,OAAO,MAAM,UAAU;AAEjE;AAkEA,eAAsB,qBAGpB,QAAyD;AACpD,QAAA,aAAa,OAAO,cAAc;AAClC,QAAA,WAAW,OAAO,YAAY;AAEpC,MAAI,mBAAmB,OAAO,IAAI,KAAK,GAAG;AACzC,UAAM,aAAa,MAAM,OAAO,OAAO,kBAAkB;AAAA,MACxD,cAAc,OAAO;AAAA,MACrB;AAAA,MACA,YAAY,OAAO,IAAI,MAAM;AAAA,MAC7B,cAAc,OAAO,IAAI,MAAM;AAAA,IAAA,CAC/B;AAEM,WAAA,IAAI,SAAS,WAAW,UAAU;AAEzC;AAAA,EACA;AAEM,SAAA,IAAI,SAAS,WAAW,UAAU;AAC1C;"}
1
+ {"version":3,"file":"redirectToPreviewURL.js","sources":["../../src/redirectToPreviewURL.ts"],"sourcesContent":["import type { NextApiRequest, NextApiResponse } from \"next\";\nimport type * as prismic from \"@prismicio/client\";\n\ntype PrismicNextQuery = {\n\tdocumentId: string;\n\ttoken: string;\n};\n\n/**\n * Determines if a query object from a Next.js API route request contains\n * Prismic preview data.\n *\n * @param query - Query object to check.\n *\n * @returns `true` if `query` contains Prismic preview data, `false` otherwise.\n */\nconst isPrismicNextQuery = (\n\tquery: NextApiRequest[\"query\"],\n): query is PrismicNextQuery => {\n\treturn (\n\t\ttypeof query.documentId === \"string\" && typeof query.token === \"string\"\n\t);\n};\n\n/**\n * Preview config for enabling previews with redirectToPreviewURL\n */\nexport type RedirectToPreviewURLConfig<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\treq: {\n\t\tquery: NextApiRequest[\"query\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tredirect: NextApiResponse[\"redirect\"];\n\t};\n\n\t/**\n\t * The Prismic client configured for the preview session's repository.\n\t */\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<prismic.Client, \"resolvePreviewURL\">;\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?: TLinkResolverFunction;\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\t/**\n\t * The `basePath` for the Next.js app as it is defined in `next.config.js`.\n\t * This option can be omitted if the app does not have a `basePath`.\n\t *\n\t * @remarks\n\t * The 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\n/**\n * Redirects a user to the URL of a previewed Prismic document from within a\n * Next.js API route.\n */\nexport async function redirectToPreviewURL<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>(config: RedirectToPreviewURLConfig<TLinkResolverFunction>): Promise<void> {\n\tconst defaultURL = config.defaultURL || \"/\";\n\tconst basePath = config.basePath || \"\";\n\n\tif (isPrismicNextQuery(config.req.query)) {\n\t\tconst previewUrl = await config.client.resolvePreviewURL({\n\t\t\tlinkResolver: config.linkResolver,\n\t\t\tdefaultURL,\n\t\t\tdocumentID: config.req.query.documentId,\n\t\t\tpreviewToken: config.req.query.token,\n\t\t});\n\n\t\tconfig.res.redirect(basePath + previewUrl);\n\n\t\treturn;\n\t}\n\n\tconfig.res.redirect(basePath + defaultURL);\n}\n"],"names":[],"mappings":"AAgBA,MAAM,qBAAqB,CAC1B,UAC8B;AAC9B,SACC,OAAO,MAAM,eAAe,YAAY,OAAO,MAAM,UAAU;AAEjE;AAqEA,eAAsB,qBAGpB,QAAyD;AACpD,QAAA,aAAa,OAAO,cAAc;AAClC,QAAA,WAAW,OAAO,YAAY;AAEpC,MAAI,mBAAmB,OAAO,IAAI,KAAK,GAAG;AACzC,UAAM,aAAa,MAAM,OAAO,OAAO,kBAAkB;AAAA,MACxD,cAAc,OAAO;AAAA,MACrB;AAAA,MACA,YAAY,OAAO,IAAI,MAAM;AAAA,MAC7B,cAAc,OAAO,IAAI,MAAM;AAAA,IAAA,CAC/B;AAEM,WAAA,IAAI,SAAS,WAAW,UAAU;AAEzC;AAAA,EACA;AAEM,SAAA,IAAI,SAAS,WAAW,UAAU;AAC1C;"}
@@ -1 +1 @@
1
- {"version":3,"file":"setPreviewData.cjs","sources":["../../src/setPreviewData.ts"],"sourcesContent":["import { NextApiResponse, NextApiRequest } from \"next\";\nimport * as prismic from \"@prismicio/client\";\n\n/**\n * Configuration for `setPreviewData`.\n */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\treq: {\n\t\tquery: NextApiRequest[\"query\"];\n\t\tcookies: NextApiRequest[\"cookies\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tsetPreviewData: NextApiResponse[\"setPreviewData\"];\n\t};\n};\n\n/**\n * Set Prismic preview data for Next.js's Preview Mode.\n */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[prismic.cookie.preview];\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref });\n\t}\n}\n"],"names":["prismic"],"mappings":";;;;;;;;;;;;;;;;;;;;SAgCgB,eAAe,EAAE,KAAK,OAA2B;AAChE,QAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQA,mBAAQ,OAAO;AAE1D,MAAI,KAAK;AACJ,QAAA,eAAe,EAAE,IAAA,CAAK;AAAA,EAC1B;AACF;;"}
1
+ {"version":3,"file":"setPreviewData.cjs","sources":["../../src/setPreviewData.ts"],"sourcesContent":["import { NextApiResponse, NextApiRequest } from \"next\";\nimport * as prismic from \"@prismicio/client\";\n\n/**\n * Configuration for `setPreviewData`.\n */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\treq: {\n\t\tquery: NextApiRequest[\"query\"];\n\t\tcookies: NextApiRequest[\"cookies\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tsetPreviewData: NextApiResponse[\"setPreviewData\"];\n\t};\n};\n\n/**\n * Set Prismic preview data for Next.js's Preview Mode.\n */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[prismic.cookie.preview];\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref });\n\t}\n}\n"],"names":["prismic"],"mappings":";;;;;;;;;;;;;;;;;;;;SAgCgB,eAAe,EAAE,KAAK,OAA2B;AAC1D,QAAA,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQA,mBAAQ,OAAO,OAAO;AAEjE,MAAI,KAAK;AACJ,QAAA,eAAe,EAAE,IAAA,CAAK;AAAA,EAC1B;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"setPreviewData.js","sources":["../../src/setPreviewData.ts"],"sourcesContent":["import { NextApiResponse, NextApiRequest } from \"next\";\nimport * as prismic from \"@prismicio/client\";\n\n/**\n * Configuration for `setPreviewData`.\n */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\treq: {\n\t\tquery: NextApiRequest[\"query\"];\n\t\tcookies: NextApiRequest[\"cookies\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tsetPreviewData: NextApiResponse[\"setPreviewData\"];\n\t};\n};\n\n/**\n * Set Prismic preview data for Next.js's Preview Mode.\n */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[prismic.cookie.preview];\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref });\n\t}\n}\n"],"names":[],"mappings":";SAgCgB,eAAe,EAAE,KAAK,OAA2B;AAChE,QAAM,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,QAAQ,OAAO;AAE1D,MAAI,KAAK;AACJ,QAAA,eAAe,EAAE,IAAA,CAAK;AAAA,EAC1B;AACF;"}
1
+ {"version":3,"file":"setPreviewData.js","sources":["../../src/setPreviewData.ts"],"sourcesContent":["import { NextApiResponse, NextApiRequest } from \"next\";\nimport * as prismic from \"@prismicio/client\";\n\n/**\n * Configuration for `setPreviewData`.\n */\nexport type SetPreviewDataConfig = {\n\t/**\n\t * The `req` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\treq: {\n\t\tquery: NextApiRequest[\"query\"];\n\t\tcookies: NextApiRequest[\"cookies\"];\n\t};\n\n\t/**\n\t * The `res` object from a Next.js API route. This is given as a parameter to\n\t * the API route.\n\t *\n\t * @see Next.js API route docs: {@link https://nextjs.org/docs/api-routes/introduction}\n\t */\n\tres: {\n\t\tsetPreviewData: NextApiResponse[\"setPreviewData\"];\n\t};\n};\n\n/**\n * Set Prismic preview data for Next.js's Preview Mode.\n */\nexport function setPreviewData({ req, res }: SetPreviewDataConfig): void {\n\tconst ref = req.query.token || req.cookies[prismic.cookie.preview];\n\n\tif (ref) {\n\t\tres.setPreviewData({ ref });\n\t}\n}\n"],"names":[],"mappings":";SAgCgB,eAAe,EAAE,KAAK,OAA2B;AAC1D,QAAA,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,QAAQ,OAAO,OAAO;AAEjE,MAAI,KAAK;AACJ,QAAA,eAAe,EAAE,IAAA,CAAK;AAAA,EAC1B;AACF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/next",
3
- "version": "1.0.3",
3
+ "version": "1.1.0-alpha.0",
4
4
  "description": "Helpers to integrate Prismic into Next.js apps",
5
5
  "keywords": [
6
6
  "typescript",
@@ -18,13 +18,18 @@
18
18
  "sideEffects": false,
19
19
  "exports": {
20
20
  ".": {
21
- "require": "./dist/index.cjs",
22
- "import": "./dist/index.js"
21
+ "react-server": {
22
+ "import": "./dist/react-server.js",
23
+ "require": "./dist/react-server.cjs"
24
+ },
25
+ "default": {
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs"
28
+ }
23
29
  },
24
30
  "./package.json": "./package.json"
25
31
  },
26
- "main": "./dist/index.cjs",
27
- "module": "./dist/index.js",
32
+ "main": "./dist/index.js",
28
33
  "types": "./dist/index.d.ts",
29
34
  "files": [
30
35
  "dist",
@@ -34,53 +39,53 @@
34
39
  "build": "vite build",
35
40
  "dev": "vite build --watch",
36
41
  "format": "prettier --write .",
37
- "lint": "eslint --ext .js,.ts .",
42
+ "lint": "eslint --ext .js,.jsx,.ts,.tsx .",
43
+ "types": "tsc --noEmit",
38
44
  "prepare": "npm run build",
39
- "release": "npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
40
- "release:alpha": "npm run test && standard-version --release-as patch --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
41
- "release:alpha:dry": "standard-version --release-as patch --prerelease alpha --dry-run",
45
+ "release": "npm run build && npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
46
+ "release:alpha": "npm run build && npm run test && standard-version --release-as minor --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
47
+ "release:alpha:dry": "standard-version --release-as minor --prerelease alpha --dry-run",
42
48
  "release:dry": "standard-version --dry-run",
43
- "size": "size-limit",
44
- "test": "npm run lint && npm run unit && npm run build && npm run size",
45
49
  "unit": "vitest run --coverage",
46
- "unit:watch": "vitest watch"
50
+ "unit:watch": "vitest watch",
51
+ "size": "size-limit",
52
+ "test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
47
53
  },
48
54
  "dependencies": {
49
- "@prismicio/helpers": "^2.3.6",
50
- "@prismicio/types": "^0.2.4",
55
+ "@prismicio/client": "^7.0.0-alpha.2",
51
56
  "imgix-url-builder": "^0.0.3"
52
57
  },
53
58
  "devDependencies": {
54
- "@prismicio/client": "^6.7.1",
55
- "@prismicio/mock": "^0.1.1",
56
- "@size-limit/preset-small-lib": "^8.1.0",
59
+ "@prismicio/mock": "^0.2.0",
60
+ "@size-limit/preset-small-lib": "^8.2.4",
57
61
  "@types/react-test-renderer": "^18.0.0",
58
- "@typescript-eslint/eslint-plugin": "^5.46.1",
59
- "@typescript-eslint/parser": "^5.46.1",
60
- "@vitejs/plugin-react": "^3.0.0",
61
- "@vitest/coverage-c8": "^0.25.8",
62
- "eslint": "^8.29.0",
63
- "eslint-config-prettier": "^8.5.0",
62
+ "@typescript-eslint/eslint-plugin": "^5.59.1",
63
+ "@typescript-eslint/parser": "^5.59.1",
64
+ "@vitejs/plugin-react": "^4.0.0",
65
+ "@vitest/coverage-c8": "^0.30.1",
66
+ "eslint": "^8.39.0",
67
+ "eslint-config-prettier": "^8.8.0",
64
68
  "eslint-plugin-prettier": "^4.2.1",
65
- "eslint-plugin-react": "^7.31.11",
69
+ "eslint-plugin-react": "^7.32.2",
66
70
  "eslint-plugin-react-hooks": "^4.6.0",
67
71
  "eslint-plugin-tsdoc": "^0.2.17",
68
- "happy-dom": "^8.1.0",
72
+ "happy-dom": "^9.9.2",
69
73
  "next": "^13.0.0",
70
- "prettier": "^2.8.1",
74
+ "prettier": "^2.8.8",
71
75
  "prettier-plugin-jsdoc": "^0.4.2",
72
76
  "react": "^18.1.0",
73
77
  "react-dom": "^18.2.0",
74
78
  "react-test-renderer": "^18.2.0",
75
- "size-limit": "^8.1.0",
79
+ "rollup-plugin-preserve-directives": "^0.1.0",
80
+ "size-limit": "^8.2.4",
76
81
  "standard-version": "^9.5.0",
77
- "typescript": "^4.9.4",
78
- "vite": "^4.0.1",
79
- "vite-plugin-sdk": "^0.1.0",
80
- "vitest": "^0.25.8"
82
+ "typescript": "^5.0.4",
83
+ "vite": "^4.3.1",
84
+ "vite-plugin-sdk": "^0.1.1",
85
+ "vitest": "^0.30.1"
81
86
  },
82
87
  "peerDependencies": {
83
- "@prismicio/client": "^6",
88
+ "@prismicio/client": "^6 || ^7",
84
89
  "next": "^13",
85
90
  "react": "^18"
86
91
  },
@@ -1,7 +1,8 @@
1
+ "use client";
2
+
1
3
  import Image, { ImageProps } from "next/image";
2
4
  import { buildURL, ImgixURLParams } from "imgix-url-builder";
3
- import * as prismicH from "@prismicio/helpers";
4
- import * as prismicT from "@prismicio/types";
5
+ import * as prismic from "@prismicio/client";
5
6
 
6
7
  import { __PRODUCTION__ } from "./lib/__PRODUCTION__";
7
8
  import { devMsg } from "./lib/devMsg";
@@ -26,7 +27,7 @@ export type PrismicNextImageProps = Omit<ImageProps, "src" | "alt"> & {
26
27
  /**
27
28
  * The Prismic Image field or thumbnail to render.
28
29
  */
29
- field: prismicT.ImageFieldImage | null | undefined;
30
+ field: prismic.ImageFieldImage | null | undefined;
30
31
 
31
32
  /**
32
33
  * An object of Imgix URL API parameters to transform the image.
@@ -103,7 +104,7 @@ export const PrismicNextImage = ({
103
104
  }
104
105
  }
105
106
 
106
- if (prismicH.isFilled.imageThumbnail(field)) {
107
+ if (prismic.isFilled.imageThumbnail(field)) {
107
108
  const src = buildURL(field.url, imgixParams);
108
109
 
109
110
  const ar = field.dimensions.width / field.dimensions.height;
@@ -0,0 +1,55 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as prismic from "@prismicio/client";
5
+ import Link, { LinkProps } from "next/link";
6
+
7
+ export type PrismicNextLinkProps = Omit<
8
+ React.ComponentProps<typeof Link>,
9
+ "field" | "document" | "href" | "rel"
10
+ > & {
11
+ linkResolver?: prismic.LinkResolverFunction;
12
+ rel?: string | prismic.AsLinkAttrsConfig["rel"];
13
+ } & (
14
+ | {
15
+ document: prismic.PrismicDocument | null | undefined;
16
+ href?: never;
17
+ field?: never;
18
+ }
19
+ | {
20
+ field: prismic.LinkField | null | undefined;
21
+ href?: never;
22
+ document?: never;
23
+ }
24
+ | {
25
+ href: LinkProps["href"];
26
+ field?: prismic.LinkField | null | undefined;
27
+ document?: never;
28
+ }
29
+ );
30
+
31
+ export const PrismicNextLink = React.forwardRef<
32
+ HTMLAnchorElement,
33
+ PrismicNextLinkProps
34
+ >(function PrismicNextLink(
35
+ { field, document, linkResolver, ...restProps },
36
+ ref,
37
+ ): JSX.Element | null {
38
+ const {
39
+ href: computedHref,
40
+ rel: computedRel,
41
+ ...attrs
42
+ } = prismic.asLinkAttrs(field ?? document, {
43
+ linkResolver,
44
+ rel: typeof restProps.rel === "function" ? restProps.rel : undefined,
45
+ });
46
+
47
+ let rel: string | undefined = computedRel;
48
+ if ("rel" in restProps && typeof restProps.rel !== "function") {
49
+ rel = restProps.rel;
50
+ }
51
+
52
+ const href = ("href" in restProps ? restProps.href : computedHref) || "";
53
+
54
+ return <Link ref={ref} {...attrs} {...restProps} href={href} rel={rel} />;
55
+ });
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import * as React from "react";
2
4
  import { useRouter } from "next/router";
3
5
  import Script from "next/script";
@@ -1,5 +1,5 @@
1
1
  import { PreviewData } from "next";
2
- import { Client, HttpRequestLike } from "@prismicio/client";
2
+ import type * as prismic from "@prismicio/client";
3
3
 
4
4
  interface PrismicNextPreviewData {
5
5
  ref: string;
@@ -30,7 +30,13 @@ export type EnableAutoPreviewsConfig<
30
30
  /**
31
31
  * Prismic client with which automatic previews will be enabled.
32
32
  */
33
- client: Client;
33
+ // `Pick` is used to use the smallest possible subset of
34
+ // `prismic.Client`. Doing this reduces the surface area for breaking
35
+ // type changes.
36
+ client: Pick<
37
+ prismic.Client,
38
+ "queryContentFromRef" | "enableAutoPreviewsFromReq"
39
+ >;
34
40
  } & (
35
41
  | {
36
42
  /**
@@ -49,7 +55,7 @@ export type EnableAutoPreviewsConfig<
49
55
  * Pass a `req` object when using `enableAutoPreviews` in a Next.js API
50
56
  * endpoint.
51
57
  */
52
- req?: HttpRequestLike;
58
+ req?: prismic.HttpRequestLike;
53
59
  }
54
60
  );
55
61
  /**
package/src/index.ts CHANGED
@@ -1,21 +1,24 @@
1
- export { setPreviewData, SetPreviewDataConfig } from "./setPreviewData";
1
+ export { setPreviewData } from "./setPreviewData";
2
+ export type { SetPreviewDataConfig } from "./setPreviewData";
2
3
 
3
- export { exitPreview, ExitPreviewConfig } from "./exitPreview";
4
+ export { exitPreview } from "./exitPreview";
5
+ export type { ExitPreviewConfig } from "./exitPreview";
4
6
 
5
- export { PrismicPreview, PrismicPreviewProps } from "./PrismicPreview";
7
+ export { PrismicPreview } from "./PrismicPreview";
8
+ export type { PrismicPreviewProps } from "./PrismicPreview";
6
9
 
7
- export {
8
- EnableAutoPreviewsConfig,
9
- enableAutoPreviews,
10
- } from "./enableAutoPreviews";
10
+ export { PrismicNextLink } from "./PrismicNextLink";
11
+ export type { PrismicNextLinkProps } from "./PrismicNextLink";
11
12
 
12
- export {
13
- RedirectToPreviewURLConfig,
14
- redirectToPreviewURL,
15
- } from "./redirectToPreviewURL";
13
+ export { enableAutoPreviews } from "./enableAutoPreviews";
14
+ export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
16
15
 
17
- export { PrismicNextImage, PrismicNextImageProps } from "./PrismicNextImage";
16
+ export { redirectToPreviewURL } from "./redirectToPreviewURL";
17
+ export type { RedirectToPreviewURLConfig } from "./redirectToPreviewURL";
18
+
19
+ export { PrismicNextImage } from "./PrismicNextImage";
20
+ export type { PrismicNextImageProps } from "./PrismicNextImage";
18
21
 
19
22
  export { imgixLoader } from "./imgixLoader";
20
23
 
21
- export { CreateClientConfig } from "./types";
24
+ export type { CreateClientConfig } from "./types";