@prismicio/next 2.2.3-pr.136.19d76d2 → 2.2.3

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 (159) hide show
  1. package/dist/PrismicNextImage.cjs +11 -9
  2. package/dist/PrismicNextImage.cjs.map +1 -1
  3. package/dist/PrismicNextImage.d.cts +21 -13
  4. package/dist/PrismicNextImage.d.ts +21 -13
  5. package/dist/PrismicNextImage.js +11 -9
  6. package/dist/PrismicNextImage.js.map +1 -1
  7. package/dist/PrismicNextLink.cjs.map +1 -1
  8. package/dist/PrismicNextLink.js.map +1 -1
  9. package/dist/PrismicPreview.cjs +7 -6
  10. package/dist/PrismicPreview.cjs.map +1 -1
  11. package/dist/PrismicPreview.d.cts +12 -11
  12. package/dist/PrismicPreview.d.ts +12 -11
  13. package/dist/PrismicPreview.js +7 -6
  14. package/dist/PrismicPreview.js.map +1 -1
  15. package/dist/PrismicPreviewClient.cjs +3 -1
  16. package/dist/PrismicPreviewClient.cjs.map +1 -1
  17. package/dist/PrismicPreviewClient.js +3 -1
  18. package/dist/PrismicPreviewClient.js.map +1 -1
  19. package/dist/SliceSimulator.cjs +3 -3
  20. package/dist/SliceSimulator.cjs.map +1 -1
  21. package/dist/SliceSimulator.d.cts +5 -3
  22. package/dist/SliceSimulator.d.ts +5 -3
  23. package/dist/SliceSimulator.js +3 -3
  24. package/dist/SliceSimulator.js.map +1 -1
  25. package/dist/SliceSimulatorWrapper.cjs +4 -1
  26. package/dist/SliceSimulatorWrapper.cjs.map +1 -1
  27. package/dist/SliceSimulatorWrapper.js +4 -1
  28. package/dist/SliceSimulatorWrapper.js.map +1 -1
  29. package/dist/createLocaleRedirect.cjs.map +1 -1
  30. package/dist/createLocaleRedirect.js.map +1 -1
  31. package/dist/enableAutoPreviews.cjs +2 -1
  32. package/dist/enableAutoPreviews.cjs.map +1 -1
  33. package/dist/enableAutoPreviews.d.cts +2 -1
  34. package/dist/enableAutoPreviews.d.ts +2 -1
  35. package/dist/enableAutoPreviews.js +2 -1
  36. package/dist/enableAutoPreviews.js.map +1 -1
  37. package/dist/exitPreview.cjs +10 -9
  38. package/dist/exitPreview.cjs.map +1 -1
  39. package/dist/exitPreview.d.cts +10 -9
  40. package/dist/exitPreview.d.ts +10 -9
  41. package/dist/exitPreview.js +10 -9
  42. package/dist/exitPreview.js.map +1 -1
  43. package/dist/getSlices.cjs.map +1 -1
  44. package/dist/getSlices.js.map +1 -1
  45. package/dist/imgixLoader.cjs +2 -2
  46. package/dist/imgixLoader.cjs.map +1 -1
  47. package/dist/imgixLoader.d.cts +2 -2
  48. package/dist/imgixLoader.d.ts +2 -2
  49. package/dist/imgixLoader.js +2 -2
  50. package/dist/imgixLoader.js.map +1 -1
  51. package/dist/lib/devMsg.cjs +8 -6
  52. package/dist/lib/devMsg.cjs.map +1 -1
  53. package/dist/lib/devMsg.js +8 -6
  54. package/dist/lib/devMsg.js.map +1 -1
  55. package/dist/lib/resolveDefaultExport.cjs +12 -8
  56. package/dist/lib/resolveDefaultExport.cjs.map +1 -1
  57. package/dist/lib/resolveDefaultExport.js +12 -8
  58. package/dist/lib/resolveDefaultExport.js.map +1 -1
  59. package/dist/package.cjs +1 -1
  60. package/dist/package.js +1 -1
  61. package/dist/pages/PrismicPreview.cjs +7 -6
  62. package/dist/pages/PrismicPreview.cjs.map +1 -1
  63. package/dist/pages/PrismicPreview.d.cts +12 -11
  64. package/dist/pages/PrismicPreview.d.ts +12 -11
  65. package/dist/pages/PrismicPreview.js +7 -6
  66. package/dist/pages/PrismicPreview.js.map +1 -1
  67. package/dist/pages/SliceSimulator.cjs +2 -2
  68. package/dist/pages/SliceSimulator.cjs.map +1 -1
  69. package/dist/pages/SliceSimulator.d.cts +13 -10
  70. package/dist/pages/SliceSimulator.d.ts +13 -10
  71. package/dist/pages/SliceSimulator.js +2 -2
  72. package/dist/pages/SliceSimulator.js.map +1 -1
  73. package/dist/pages/enableAutoPreviews.cjs +3 -3
  74. package/dist/pages/enableAutoPreviews.cjs.map +1 -1
  75. package/dist/pages/enableAutoPreviews.d.cts +5 -5
  76. package/dist/pages/enableAutoPreviews.d.ts +5 -5
  77. package/dist/pages/enableAutoPreviews.js +3 -3
  78. package/dist/pages/enableAutoPreviews.js.map +1 -1
  79. package/dist/pages/exitPreview.cjs +10 -9
  80. package/dist/pages/exitPreview.cjs.map +1 -1
  81. package/dist/pages/exitPreview.d.cts +10 -9
  82. package/dist/pages/exitPreview.d.ts +10 -9
  83. package/dist/pages/exitPreview.js +10 -9
  84. package/dist/pages/exitPreview.js.map +1 -1
  85. package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
  86. package/dist/pages/redirectToPreviewURL.d.cts +9 -7
  87. package/dist/pages/redirectToPreviewURL.d.ts +9 -7
  88. package/dist/pages/redirectToPreviewURL.js.map +1 -1
  89. package/dist/pages/setPreviewData.cjs.map +1 -1
  90. package/dist/pages/setPreviewData.js.map +1 -1
  91. package/dist/pages/types.d.cts +8 -3
  92. package/dist/pages/types.d.ts +8 -3
  93. package/dist/redirectToPreviewURL.cjs.map +1 -1
  94. package/dist/redirectToPreviewURL.d.cts +5 -3
  95. package/dist/redirectToPreviewURL.d.ts +5 -3
  96. package/dist/redirectToPreviewURL.js.map +1 -1
  97. package/dist/types.d.cts +2 -1
  98. package/dist/types.d.ts +2 -1
  99. package/package.json +25 -23
  100. package/src/PrismicNextImage.tsx +134 -113
  101. package/src/PrismicNextLink.tsx +45 -43
  102. package/src/PrismicPreview.tsx +29 -28
  103. package/src/PrismicPreviewClient.tsx +44 -42
  104. package/src/SliceSimulator.tsx +43 -38
  105. package/src/SliceSimulatorWrapper.tsx +25 -15
  106. package/src/createLocaleRedirect.ts +3 -3
  107. package/src/enableAutoPreviews.ts +16 -15
  108. package/src/exitPreview.ts +13 -12
  109. package/src/getSlices.ts +10 -6
  110. package/src/imgixLoader.ts +10 -10
  111. package/src/index.ts +21 -18
  112. package/src/lib/devMsg.ts +11 -9
  113. package/src/lib/resolveDefaultExport.ts +13 -9
  114. package/src/pages/PrismicPreview.tsx +51 -47
  115. package/src/pages/SliceSimulator.tsx +37 -35
  116. package/src/pages/enableAutoPreviews.ts +17 -17
  117. package/src/pages/exitPreview.ts +18 -17
  118. package/src/pages/index.ts +23 -20
  119. package/src/pages/redirectToPreviewURL.ts +33 -22
  120. package/src/pages/setPreviewData.ts +7 -7
  121. package/src/pages/types.ts +20 -16
  122. package/src/redirectToPreviewURL.ts +30 -21
  123. package/src/types.ts +13 -12
  124. package/dist/PrismicNextImage.d.cts.map +0 -1
  125. package/dist/PrismicNextImage.d.ts.map +0 -1
  126. package/dist/PrismicNextLink.d.cts.map +0 -1
  127. package/dist/PrismicNextLink.d.ts.map +0 -1
  128. package/dist/PrismicPreview.d.cts.map +0 -1
  129. package/dist/PrismicPreview.d.ts.map +0 -1
  130. package/dist/SliceSimulator.d.cts.map +0 -1
  131. package/dist/SliceSimulator.d.ts.map +0 -1
  132. package/dist/createLocaleRedirect.d.cts.map +0 -1
  133. package/dist/createLocaleRedirect.d.ts.map +0 -1
  134. package/dist/enableAutoPreviews.d.cts.map +0 -1
  135. package/dist/enableAutoPreviews.d.ts.map +0 -1
  136. package/dist/exitPreview.d.cts.map +0 -1
  137. package/dist/exitPreview.d.ts.map +0 -1
  138. package/dist/getSlices.d.cts.map +0 -1
  139. package/dist/getSlices.d.ts.map +0 -1
  140. package/dist/imgixLoader.d.cts.map +0 -1
  141. package/dist/imgixLoader.d.ts.map +0 -1
  142. package/dist/pages/PrismicPreview.d.cts.map +0 -1
  143. package/dist/pages/PrismicPreview.d.ts.map +0 -1
  144. package/dist/pages/SliceSimulator.d.cts.map +0 -1
  145. package/dist/pages/SliceSimulator.d.ts.map +0 -1
  146. package/dist/pages/enableAutoPreviews.d.cts.map +0 -1
  147. package/dist/pages/enableAutoPreviews.d.ts.map +0 -1
  148. package/dist/pages/exitPreview.d.cts.map +0 -1
  149. package/dist/pages/exitPreview.d.ts.map +0 -1
  150. package/dist/pages/redirectToPreviewURL.d.cts.map +0 -1
  151. package/dist/pages/redirectToPreviewURL.d.ts.map +0 -1
  152. package/dist/pages/setPreviewData.d.cts.map +0 -1
  153. package/dist/pages/setPreviewData.d.ts.map +0 -1
  154. package/dist/pages/types.d.cts.map +0 -1
  155. package/dist/pages/types.d.ts.map +0 -1
  156. package/dist/redirectToPreviewURL.d.cts.map +0 -1
  157. package/dist/redirectToPreviewURL.d.ts.map +0 -1
  158. package/dist/types.d.cts.map +0 -1
  159. package/dist/types.d.ts.map +0 -1
@@ -1,34 +1,39 @@
1
- "use client"
1
+ "use client";
2
2
 
3
- import { SimulatorManager, StateEventType, getDefaultMessage } from "@prismicio/simulator/kit"
4
- import type { SliceSimulatorProps as BaseSliceSimulatorProps } from "@prismicio/simulator/kit"
5
- import { compressToEncodedURIComponent } from "lz-string"
6
- import { useRouter } from "next/navigation"
7
- import { useEffect, useState } from "react"
8
- import type { FC, ReactNode } from "react"
3
+ import { SliceSimulatorWrapper } from "./SliceSimulatorWrapper";
4
+ import { getSlices } from "./getSlices";
5
+ import {
6
+ SimulatorManager,
7
+ StateEventType,
8
+ getDefaultMessage,
9
+ } from "@prismicio/simulator/kit";
10
+ import type { SliceSimulatorProps as BaseSliceSimulatorProps } from "@prismicio/simulator/kit";
11
+ import { compressToEncodedURIComponent } from "lz-string";
12
+ import { useRouter } from "next/navigation";
13
+ import { useEffect, useState } from "react";
14
+ import type { FC, ReactNode } from "react";
9
15
 
10
- import { getSlices } from "./getSlices"
11
- import { SliceSimulatorWrapper } from "./SliceSimulatorWrapper"
16
+ const STATE_PARAMS_KEY = "state";
12
17
 
13
- const STATE_PARAMS_KEY = "state"
18
+ const simulatorManager = new SimulatorManager();
14
19
 
15
- const simulatorManager = new SimulatorManager()
16
-
17
- /** Parameters provided to the Slice Simulator page. */
20
+ /**
21
+ * Parameters provided to the Slice Simulator page.
22
+ */
18
23
  export type SliceSimulatorParams = {
19
24
  searchParams: Promise<{
20
- state?: string
21
- }>
22
- }
25
+ state?: string;
26
+ }>;
27
+ };
23
28
 
24
29
  export type SliceSimulatorProps = BaseSliceSimulatorProps & {
25
- children: ReactNode
26
- className?: string
27
- }
30
+ children: ReactNode;
31
+ className?: string;
32
+ };
28
33
 
29
34
  /**
30
- * Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
31
- * and live previews in the Page Builder.
35
+ * Simulate slices in isolation. The slice simulator enables live slice
36
+ * development in Slice Machine and live previews in the Page Builder.
32
37
  */
33
38
  export const SliceSimulator: FC<SliceSimulatorProps> = ({
34
39
  children,
@@ -36,45 +41,45 @@ export const SliceSimulator: FC<SliceSimulatorProps> = ({
36
41
  zIndex,
37
42
  className,
38
43
  }) => {
39
- const [message, setMessage] = useState(() => getDefaultMessage())
40
- const router = useRouter()
44
+ const [message, setMessage] = useState(() => getDefaultMessage());
45
+ const router = useRouter();
41
46
 
42
47
  const state =
43
48
  typeof window !== "undefined"
44
49
  ? new URL(window.location.href).searchParams.get(STATE_PARAMS_KEY)
45
- : undefined
46
- const hasSlices = getSlices(state).length > 0
50
+ : undefined;
51
+ const hasSlices = getSlices(state).length > 0;
47
52
 
48
53
  useEffect(() => {
49
54
  simulatorManager.state.on(
50
55
  StateEventType.Slices,
51
56
  (newSlices) => {
52
- const url = new URL(window.location.href)
57
+ const url = new URL(window.location.href);
53
58
  url.searchParams.set(
54
59
  STATE_PARAMS_KEY,
55
60
  compressToEncodedURIComponent(JSON.stringify(newSlices)),
56
- )
61
+ );
57
62
 
58
- window.history.replaceState(null, "", url)
63
+ window.history.replaceState(null, "", url);
59
64
  // Wait until the next tick to prevent URL state race conditions.
60
- setTimeout(() => router.refresh(), 0)
65
+ setTimeout(() => router.refresh(), 0);
61
66
  },
62
67
  "simulator-slices",
63
- )
68
+ );
64
69
  simulatorManager.state.on(
65
70
  StateEventType.Message,
66
71
  (newMessage) => setMessage(newMessage),
67
72
  "simulator-message",
68
- )
73
+ );
69
74
 
70
- simulatorManager.init()
75
+ simulatorManager.init();
71
76
 
72
77
  return () => {
73
- simulatorManager.state.off(StateEventType.Slices, "simulator-slices")
78
+ simulatorManager.state.off(StateEventType.Slices, "simulator-slices");
74
79
 
75
- simulatorManager.state.off(StateEventType.Message, "simulator-message")
76
- }
77
- }, [router])
80
+ simulatorManager.state.off(StateEventType.Message, "simulator-message");
81
+ };
82
+ }, [router]);
78
83
 
79
84
  return (
80
85
  <SliceSimulatorWrapper
@@ -86,5 +91,5 @@ export const SliceSimulator: FC<SliceSimulatorProps> = ({
86
91
  >
87
92
  {children}
88
93
  </SliceSimulatorWrapper>
89
- )
90
- }
94
+ );
95
+ };
@@ -4,18 +4,21 @@ import {
4
4
  onClickHandler,
5
5
  simulatorClass,
6
6
  simulatorRootClass,
7
- } from "@prismicio/simulator/kit"
8
- import type { SliceSimulatorProps } from "@prismicio/simulator/kit"
9
- import type { FC, ReactNode } from "react"
7
+ } from "@prismicio/simulator/kit";
8
+ import type { SliceSimulatorProps } from "@prismicio/simulator/kit";
9
+ import type { FC, ReactNode } from "react";
10
10
 
11
11
  type SliceSimulatorWrapperProps = SliceSimulatorProps & {
12
- children: ReactNode
13
- className?: string
14
- message?: string
15
- hasSlices: boolean
16
- }
12
+ children: ReactNode;
13
+ className?: string;
14
+ message?: string;
15
+ hasSlices: boolean;
16
+ };
17
17
 
18
- /** A wrapper for the slice simulator that isolates the given children from the page's layout. */
18
+ /**
19
+ * A wrapper for the slice simulator that isolates the given children from the
20
+ * page's layout.
21
+ */
19
22
  export const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({
20
23
  className,
21
24
  children,
@@ -24,13 +27,16 @@ export const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({
24
27
  message,
25
28
  hasSlices,
26
29
  }) => {
27
- const defaultProps = getDefaultProps()
30
+ const defaultProps = getDefaultProps();
28
31
 
29
32
  return (
30
33
  <div
31
34
  className={[simulatorClass, className].filter(Boolean).join(" ")}
32
35
  style={{
33
- zIndex: typeof zIndex === "undefined" ? defaultProps.zIndex : (zIndex ?? undefined),
36
+ zIndex:
37
+ typeof zIndex === "undefined"
38
+ ? defaultProps.zIndex
39
+ : (zIndex ?? undefined),
34
40
  position: "fixed",
35
41
  top: 0,
36
42
  left: 0,
@@ -38,7 +44,9 @@ export const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({
38
44
  height: "100vh",
39
45
  overflow: "auto",
40
46
  background:
41
- typeof background === "undefined" ? defaultProps.background : (background ?? undefined),
47
+ typeof background === "undefined"
48
+ ? defaultProps.background
49
+ : (background ?? undefined),
42
50
  }}
43
51
  >
44
52
  {message ? (
@@ -48,11 +56,13 @@ export const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({
48
56
  id="root"
49
57
  className={simulatorRootClass}
50
58
  onClickCapture={onClickHandler as unknown as React.MouseEventHandler}
51
- onSubmitCapture={disableEventHandler as unknown as React.FormEventHandler}
59
+ onSubmitCapture={
60
+ disableEventHandler as unknown as React.FormEventHandler
61
+ }
52
62
  >
53
63
  {children}
54
64
  </div>
55
65
  ) : null}
56
66
  </div>
57
- )
58
- }
67
+ );
68
+ };
@@ -1,4 +1,4 @@
1
- import { devMsg } from "./lib/devMsg"
1
+ import { devMsg } from "./lib/devMsg";
2
2
 
3
3
  /**
4
4
  * @deprecated `createLocaleRedirect()` has been removed due to performance
@@ -9,10 +9,10 @@ export function createLocaleRedirect(): never {
9
9
  `createLocaleRedirect() has been removed due to performance issues. See ${devMsg(
10
10
  "replace-createLocaleRedirect",
11
11
  )} for more details.`,
12
- )
12
+ );
13
13
  }
14
14
  /**
15
15
  * @deprecated `createLocaleRedirect()` has been removed due to performance
16
16
  * issues.
17
17
  */
18
- export type CreateLocaleRedirectConfig = never
18
+ export type CreateLocaleRedirectConfig = never;
@@ -1,4 +1,4 @@
1
- import { type Client, cookie as prismicCookie } from "@prismicio/client"
1
+ import { type Client, cookie as prismicCookie } from "@prismicio/client";
2
2
 
3
3
  /** Configuration for `enableAutoPreviews`. */
4
4
  export type EnableAutoPreviewsConfig = {
@@ -6,11 +6,12 @@ export type EnableAutoPreviewsConfig = {
6
6
  // `Pick` is used to use the smallest possible subset of
7
7
  // `prismic.Client`. Doing this reduces the surface area for breaking
8
8
  // type changes.
9
- client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">
10
- }
9
+ client: Pick<Client, "queryContentFromRef" | "enableAutoPreviewsFromReq">;
10
+ };
11
11
 
12
12
  /**
13
- * Configures a Prismic client to automatically query draft content during a preview session.
13
+ * Configures a Prismic client to automatically query draft content during a
14
+ * preview session.
14
15
  *
15
16
  * @param config - Configuration for the function.
16
17
  */
@@ -21,32 +22,32 @@ export function enableAutoPreviews(config: EnableAutoPreviewsConfig): void {
21
22
  // Need this to avoid the following Next.js build-time error:
22
23
  // You're importing a component that needs next/headers. That only works
23
24
  // in a Server Component which is not supported in the pages/ directory.
24
- const { cookies, draftMode } = await import("next/headers")
25
+ const { cookies, draftMode } = await import("next/headers");
25
26
 
26
- let isDraftModeEnabled = false
27
+ let isDraftModeEnabled = false;
27
28
  try {
28
- isDraftModeEnabled = (await draftMode()).isEnabled
29
+ isDraftModeEnabled = (await draftMode()).isEnabled;
29
30
  } catch {
30
31
  // `draftMode()` may have been called in a palce that
31
32
  // does not have access to its async storage. This
32
33
  // occurs in places like `generateStaticParams()`. We
33
34
  // can ignore this case.
34
- return
35
+ return;
35
36
  }
36
37
  if (!isDraftModeEnabled) {
37
- return
38
+ return;
38
39
  }
39
40
 
40
- const cookie = (await cookies()).get(prismicCookie.preview)?.value
41
+ const cookie = (await cookies()).get(prismicCookie.preview)?.value;
41
42
  if (!cookie) {
42
- return
43
+ return;
43
44
  }
44
45
 
45
- const isActiveCookie = cookie.includes("websitePreviewId=")
46
+ const isActiveCookie = cookie.includes("websitePreviewId=");
46
47
  if (!isActiveCookie) {
47
- return
48
+ return;
48
49
  }
49
50
 
50
- return cookie
51
- })
51
+ return cookie;
52
+ });
52
53
  }
@@ -1,30 +1,31 @@
1
1
  /**
2
- * Ends a Prismic preview session within a Next.js app. This function should be used in a Router
3
- * Handler.
2
+ * Ends a Prismic preview session within a Next.js app. This function should be
3
+ * used in a Router Handler.
4
4
  *
5
5
  * @example
6
- * ```typescript
7
- * // src/app/api/exit-preview/route.js
8
6
  *
9
- * import { exitPreview } from "@prismicio/next"
7
+ * ```typescript
8
+ * // src/app/api/exit-preview/route.js
10
9
  *
11
- * export async function GET() {
12
- * return await exitPreview()
13
- * }
14
- * ```
10
+ * import { exitPreview } from "@prismicio/next";
11
+ *
12
+ * export async function GET() {
13
+ * return await exitPreview();
14
+ * }
15
+ * ```
15
16
  */
16
17
  export async function exitPreview(): Promise<Response> {
17
18
  // Need this to avoid the following Next.js build-time error:
18
19
  // You're importing a component that needs next/headers. That only works
19
20
  // in a Server Component which is not supported in the pages/ directory.
20
- const { draftMode } = await import("next/headers")
21
+ const { draftMode } = await import("next/headers");
21
22
 
22
- ;(await draftMode()).disable()
23
+ (await draftMode()).disable();
23
24
 
24
25
  // `Cache-Control` header is used to prevent CDN-level caching.
25
26
  return new Response(JSON.stringify({ success: true }), {
26
27
  headers: {
27
28
  "Cache-Control": "no-store",
28
29
  },
29
- })
30
+ });
30
31
  }
package/src/getSlices.ts CHANGED
@@ -1,7 +1,11 @@
1
- import { getDefaultSlices } from "@prismicio/simulator/kit"
2
- import type { StateEvents, StateEventType } from "@prismicio/simulator/kit"
3
- import { decompressFromEncodedURIComponent } from "lz-string"
1
+ import { getDefaultSlices } from "@prismicio/simulator/kit";
2
+ import type { StateEvents, StateEventType } from "@prismicio/simulator/kit";
3
+ import { decompressFromEncodedURIComponent } from "lz-string";
4
4
 
5
- export const getSlices = (state: string | null | undefined): StateEvents[StateEventType.Slices] => {
6
- return state ? JSON.parse(decompressFromEncodedURIComponent(state)) : getDefaultSlices()
7
- }
5
+ export const getSlices = (
6
+ state: string | null | undefined,
7
+ ): StateEvents[StateEventType.Slices] => {
8
+ return state
9
+ ? JSON.parse(decompressFromEncodedURIComponent(state))
10
+ : getDefaultSlices();
11
+ };
@@ -1,26 +1,26 @@
1
- import type { ImgixURLParams } from "imgix-url-builder"
2
- import { buildURL } from "imgix-url-builder"
3
- import type { ImageLoaderProps } from "next/image"
1
+ import type { ImageLoaderProps } from "next/image";
2
+ import type { ImgixURLParams } from "imgix-url-builder";
3
+ import { buildURL } from "imgix-url-builder";
4
4
 
5
5
  /**
6
- * A `next/image` loader for Imgix, which Prismic uses, with an optional collection of default Imgix
7
- * parameters.
6
+ * A `next/image` loader for Imgix, which Prismic uses, with an optional
7
+ * collection of default Imgix parameters.
8
8
  *
9
9
  * @see To learn about `next/image` loaders: https://nextjs.org/docs/api-reference/next/image#loader
10
10
  * @see To learn about Imgix's URL API: https://docs.imgix.com/apis/rendering
11
11
  */
12
12
  export const imgixLoader = (args: ImageLoaderProps): string => {
13
- const url = new URL(args.src)
13
+ const url = new URL(args.src);
14
14
 
15
15
  const params: ImgixURLParams = {
16
16
  fit: (url.searchParams.get("fit") as ImgixURLParams["fit"]) || "max",
17
17
  w: args.width,
18
18
  h: undefined,
19
- }
19
+ };
20
20
 
21
21
  if (args.quality) {
22
- params.q = args.quality
22
+ params.q = args.quality;
23
23
  }
24
24
 
25
- return buildURL(args.src, params)
26
- }
25
+ return buildURL(args.src, params);
26
+ };
package/src/index.ts CHANGED
@@ -1,28 +1,31 @@
1
- export { exitPreview } from "./exitPreview"
1
+ export { exitPreview } from "./exitPreview";
2
2
 
3
- export { PrismicPreview } from "./PrismicPreview"
4
- export type { PrismicPreviewProps } from "./PrismicPreview"
3
+ export { PrismicPreview } from "./PrismicPreview";
4
+ export type { PrismicPreviewProps } from "./PrismicPreview";
5
5
 
6
- export { PrismicNextLink } from "./PrismicNextLink"
7
- export type { PrismicNextLinkProps } from "./PrismicNextLink"
6
+ export { PrismicNextLink } from "./PrismicNextLink";
7
+ export type { PrismicNextLinkProps } from "./PrismicNextLink";
8
8
 
9
- export { enableAutoPreviews } from "./enableAutoPreviews"
10
- export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews"
9
+ export { enableAutoPreviews } from "./enableAutoPreviews";
10
+ export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
11
11
 
12
- export { redirectToPreviewURL } from "./redirectToPreviewURL"
13
- export type { RedirectToPreviewURLConfig } from "./redirectToPreviewURL"
12
+ export { redirectToPreviewURL } from "./redirectToPreviewURL";
13
+ export type { RedirectToPreviewURLConfig } from "./redirectToPreviewURL";
14
14
 
15
- export { PrismicNextImage } from "./PrismicNextImage"
16
- export type { PrismicNextImageProps } from "./PrismicNextImage"
15
+ export { PrismicNextImage } from "./PrismicNextImage";
16
+ export type { PrismicNextImageProps } from "./PrismicNextImage";
17
17
 
18
- export { SliceSimulator } from "./SliceSimulator"
19
- export type { SliceSimulatorProps, SliceSimulatorParams } from "./SliceSimulator"
18
+ export { SliceSimulator } from "./SliceSimulator";
19
+ export type {
20
+ SliceSimulatorProps,
21
+ SliceSimulatorParams,
22
+ } from "./SliceSimulator";
20
23
 
21
- export { getSlices } from "./getSlices"
24
+ export { getSlices } from "./getSlices";
22
25
 
23
- export { imgixLoader } from "./imgixLoader"
26
+ export { imgixLoader } from "./imgixLoader";
24
27
 
25
- export type { CreateClientConfig } from "./types"
28
+ export type { CreateClientConfig } from "./types";
26
29
 
27
- export { createLocaleRedirect } from "./createLocaleRedirect"
28
- export type { CreateLocaleRedirectConfig } from "./createLocaleRedirect"
30
+ export { createLocaleRedirect } from "./createLocaleRedirect";
31
+ export type { CreateLocaleRedirectConfig } from "./createLocaleRedirect";
package/src/lib/devMsg.ts CHANGED
@@ -1,18 +1,20 @@
1
- import { version } from "../../package.json"
1
+ import { version } from "../../package.json";
2
2
 
3
3
  /**
4
4
  * Returns a `prismic.dev/msg` URL for a given message slug.
5
5
  *
6
6
  * @example
7
- * ```ts
8
- * devMsg("missing-param")
9
- * // => "https://prismic.dev/msg/next/v1.2.3/missing-param"
10
- * ```
11
7
  *
12
- * @param slug - Slug for the message. This corresponds to a Markdown file in the Git repository's
13
- * `/messages` directory.
8
+ * ```ts
9
+ * devMsg("missing-param");
10
+ * // => "https://prismic.dev/msg/next/v1.2.3/missing-param"
11
+ * ```
12
+ *
13
+ * @param slug - Slug for the message. This corresponds to a Markdown file in
14
+ * the Git repository's `/messages` directory.
15
+ *
14
16
  * @returns The `prismic.dev/msg` URL for the given slug.
15
17
  */
16
18
  export const devMsg = (slug: string): string => {
17
- return `https://prismic.dev/msg/next/v${version}/${slug}`
18
- }
19
+ return `https://prismic.dev/msg/next/v${version}/${slug}`;
20
+ };
@@ -1,17 +1,21 @@
1
1
  /**
2
- * Resolves a module's default export. The module may provide its default export as a `default`
3
- * property on an object. This happens when named and default exports are mixed in modules.
2
+ * Resolves a module's default export. The module may provide its default export
3
+ * as a `default` property on an object. This happens when named and default
4
+ * exports are mixed in modules.
4
5
  *
5
- * In ES Modules, mixing is fine since the module resolver can distinguish default and named
6
- * exports. In transpiled modules, however, all exports are put into a single object, and the
7
- * default export is provided at a property called `default`.
6
+ * In ES Modules, mixing is fine since the module resolver can distinguish
7
+ * default and named exports. In transpiled modules, however, all exports are
8
+ * put into a single object, and the default export is provided at a property
9
+ * called `default`.
8
10
  *
9
- * This helper is needed by Next.js uses CJS files with named and default exports.
11
+ * This helper is needed by Next.js uses CJS files with named and default
12
+ * exports.
10
13
  *
11
- * This helper _should_ be a temporary hack until Next.js and Node.js resolve their ESM
12
- * difficulties. This will likely not be removed any time soon, unfortunately.
14
+ * This helper _should_ be a temporary hack until Next.js and Node.js resolve
15
+ * their ESM difficulties. This will likely not be removed any time soon,
16
+ * unfortunately.
13
17
  */
14
18
  export function resolveDefaultExport<T>(mod: T): T {
15
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- return "default" in (mod as any) ? (mod as any).default : mod
20
+ return "default" in (mod as any) ? (mod as any).default : mod;
17
21
  }