@prismicio/next 1.3.0-alpha.0 → 1.3.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.
@@ -18,7 +18,7 @@ export type PrismicNextLinkProps = Omit<React.ComponentProps<typeof Link>, "fiel
18
18
  document?: never;
19
19
  href: React.ComponentProps<typeof Link>["href"];
20
20
  });
21
- export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
21
+ export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
22
22
  href: string | import("url").UrlObject;
23
23
  as?: (string | import("url").UrlObject) | undefined;
24
24
  replace?: boolean | undefined;
@@ -46,14 +46,14 @@ export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Pick<Omit
46
46
  onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
47
47
  } & {
48
48
  children?: React.ReactNode;
49
- } & React.RefAttributes<HTMLAnchorElement>, "field" | "document" | "href" | "rel"> & {
49
+ } & React.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "document" | "href"> & {
50
50
  linkResolver?: prismic.LinkResolverFunction | undefined;
51
51
  rel?: string | prismic.AsLinkAttrsConfig["rel"];
52
52
  } & {
53
53
  field: prismic.LinkField | null | undefined;
54
54
  document?: undefined;
55
55
  href?: undefined;
56
- }, "key" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "tw" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver"> | Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
56
+ }, "ref"> | Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
57
57
  href: string | import("url").UrlObject;
58
58
  as?: (string | import("url").UrlObject) | undefined;
59
59
  replace?: boolean | undefined;
@@ -81,14 +81,14 @@ export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Pick<Omit
81
81
  onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
82
82
  } & {
83
83
  children?: React.ReactNode;
84
- } & React.RefAttributes<HTMLAnchorElement>, "field" | "document" | "href" | "rel"> & {
84
+ } & React.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "document" | "href"> & {
85
85
  linkResolver?: prismic.LinkResolverFunction | undefined;
86
86
  rel?: string | prismic.AsLinkAttrsConfig["rel"];
87
87
  } & {
88
88
  field?: undefined;
89
89
  document: prismic.PrismicDocument | null | undefined;
90
90
  href?: undefined;
91
- }, "key" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "tw" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver"> | Pick<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
91
+ }, "ref"> | Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
92
92
  href: string | import("url").UrlObject;
93
93
  as?: (string | import("url").UrlObject) | undefined;
94
94
  replace?: boolean | undefined;
@@ -116,11 +116,11 @@ export declare const PrismicNextLink: React.ForwardRefExoticComponent<(Pick<Omit
116
116
  onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
117
117
  } & {
118
118
  children?: React.ReactNode;
119
- } & React.RefAttributes<HTMLAnchorElement>, "field" | "document" | "href" | "rel"> & {
119
+ } & React.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "document" | "href"> & {
120
120
  linkResolver?: prismic.LinkResolverFunction | undefined;
121
121
  rel?: string | prismic.AsLinkAttrsConfig["rel"];
122
122
  } & {
123
123
  field?: undefined;
124
124
  document?: undefined;
125
125
  href: React.ComponentProps<typeof Link>["href"];
126
- }, "key" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "tw" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "field" | "replace" | "document" | "href" | "as" | "scroll" | "shallow" | "passHref" | "prefetch" | "locale" | "legacyBehavior" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "linkResolver">) & React.RefAttributes<HTMLAnchorElement>>;
126
+ }, "ref">) & React.RefAttributes<HTMLAnchorElement>>;
@@ -21,13 +21,16 @@ const enableAutoPreviews = (config) => {
21
21
  } catch {
22
22
  return;
23
23
  }
24
+ if (!isDraftModeEnabled) {
25
+ return;
26
+ }
24
27
  let cookie$1;
25
28
  try {
26
29
  cookie$1 = (_a = headers.cookies().get(cookie.preview)) == null ? void 0 : _a.value;
27
30
  } catch {
28
31
  return;
29
32
  }
30
- if (isDraftModeEnabled && cookie$1 && /\.prismic\.io/.test(cookie$1)) {
33
+ if (cookie$1 && /\.prismic\.io/.test(cookie$1)) {
31
34
  return cookie$1;
32
35
  }
33
36
  });
@@ -1 +1 @@
1
- {"version":3,"file":"enableAutoPreviews.cjs","sources":["../../src/enableAutoPreviews.ts"],"sourcesContent":["import { PreviewData } from \"next\";\nimport { cookies, draftMode } from \"next/headers\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { NextApiRequestLike, PrismicPreviewData } from \"./types\";\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig<\n\tTPreviewData extends PreviewData = PreviewData,\n> = {\n\t/**\n\t * Prismic client with which automatic previews will be enabled.\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<\n\t\tprismic.Client,\n\t\t\"queryContentFromRef\" | \"enableAutoPreviewsFromReq\"\n\t>;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The `previewData` object provided in the `getStaticProps()` or\n\t * `getServerSideProps()` context object.\n\t */\n\tpreviewData?: TPreviewData;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike;\n};\n\nconst isPrismicPreviewData = (input: unknown): input is PrismicPreviewData => {\n\treturn typeof input === \"object\" && input !== null && \"ref\" in input;\n};\n\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session. It either takes in a Next.js `getStaticProps` context object\n * or a Next.js API endpoint request object.\n *\n * @param config - Configuration for the function.\n */\nexport const enableAutoPreviews = <TPreviewData extends PreviewData>(\n\tconfig: EnableAutoPreviewsConfig<TPreviewData>,\n): void => {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// Assume we are in `getStaticProps()` or\n\t\t// `getServerSideProps()` with active Preview Mode (`pages`\n\t\t// directory).\n\n\t\tif (isPrismicPreviewData(config.previewData)) {\n\t\t\tconfig.client.queryContentFromRef(config.previewData.ref);\n\t\t}\n\t} else if (\"req\" in config && config.req) {\n\t\t// Assume we are in an API Route (`pages` directory).\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req);\n\t} else {\n\t\t// Assume we are in App Router (`app` directory) OR\n\t\t// `getStaticProps()`/`getServerSideProps()` with an inactive\n\t\t// Preview Mode (`pages` directory).\n\n\t\t// We use a function value so the cookie is checked on every\n\t\t// request. We don't have a static value to read from.\n\t\tconfig.client.queryContentFromRef(() => {\n\t\t\tlet isDraftModeEnabled = false;\n\t\t\ttry {\n\t\t\t\tisDraftModeEnabled = draftMode().isEnabled;\n\t\t\t} catch {\n\t\t\t\t// This catch block may be reached if\n\t\t\t\t// `draftMode()` is called in a place that does\n\t\t\t\t// not have access to its async storage. We can\n\t\t\t\t// ignore this case.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet cookie: string | undefined;\n\t\t\ttry {\n\t\t\t\tcookie = cookies().get(prismic.cookie.preview)?.value;\n\t\t\t} catch {\n\t\t\t\t// We are probably in `getStaticProps()` or\n\t\t\t\t// `getServerSideProps()` with inactive Preview\n\t\t\t\t// Mode where `cookies()` does not work. We\n\t\t\t\t// don't need to do any preview handling.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We only return the cookie if a Prismic Preview session is active.\n\t\t\t//\n\t\t\t// An inactive cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\"\n\t\t\t// \t}\n\t\t\t//\n\t\t\t// An active cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\",\n\t\t\t// \t\t\"example-prismic-repo.prismic.io\": {\n\t\t\t// \t\t\tpreview: \"https://example-prismic-repo.prismic.io/previews/abc:123?websitePreviewId=xyz\"\n\t\t\t// \t\t}\n\t\t\t// \t}\n\t\t\tif (isDraftModeEnabled && cookie && /\\.prismic\\.io/.test(cookie)) {\n\t\t\t\treturn cookie;\n\t\t\t}\n\t\t});\n\t}\n};\n"],"names":["draftMode","cookie","cookies","prismic.cookie.preview"],"mappings":";;;;AA2CA,MAAM,uBAAuB,CAAC,UAA+C;AAC5E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;AAChE;AASa,MAAA,qBAAqB,CACjC,WACS;AACL,MAAA,iBAAiB,UAAU,OAAO,aAAa;AAK9C,QAAA,qBAAqB,OAAO,WAAW,GAAG;AAC7C,aAAO,OAAO,oBAAoB,OAAO,YAAY,GAAG;AAAA,IACxD;AAAA,EACS,WAAA,SAAS,UAAU,OAAO,KAAK;AAGlC,WAAA,OAAO,0BAA0B,OAAO,GAAG;AAAA,EAAA,OAC5C;AAOC,WAAA,OAAO,oBAAoB,MAAK;;AACtC,UAAI,qBAAqB;AACrB,UAAA;AACH,6BAAqBA,QAAAA,UAAY,EAAA;AAAA,MAAA,QAChC;AAMD;AAAA,MACA;AAEG,UAAAC;AACA,UAAA;AACHA,oBAASC,aAAAA,QAAU,EAAA,IAAIC,OAAsB,OAAA,MAApCD,mBAAuC;AAAA,MAAA,QAC/C;AAMD;AAAA,MACA;AAgBD,UAAI,sBAAsBD,YAAU,gBAAgB,KAAKA,QAAM,GAAG;AAC1D,eAAAA;AAAAA,MACP;AAAA,IAAA,CACD;AAAA,EACD;AACF;;"}
1
+ {"version":3,"file":"enableAutoPreviews.cjs","sources":["../../src/enableAutoPreviews.ts"],"sourcesContent":["import { draftMode, cookies } from \"next/headers\";\nimport { PreviewData } from \"next\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { NextApiRequestLike, PrismicPreviewData } from \"./types\";\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig<\n\tTPreviewData extends PreviewData = PreviewData,\n> = {\n\t/**\n\t * Prismic client with which automatic previews will be enabled.\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<\n\t\tprismic.Client,\n\t\t\"queryContentFromRef\" | \"enableAutoPreviewsFromReq\"\n\t>;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The `previewData` object provided in the `getStaticProps()` or\n\t * `getServerSideProps()` context object.\n\t */\n\tpreviewData?: TPreviewData;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike;\n};\n\nconst isPrismicPreviewData = (input: unknown): input is PrismicPreviewData => {\n\treturn typeof input === \"object\" && input !== null && \"ref\" in input;\n};\n\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session. It either takes in a Next.js `getStaticProps` context object\n * or a Next.js API endpoint request object.\n *\n * @param config - Configuration for the function.\n */\nexport const enableAutoPreviews = <TPreviewData extends PreviewData>(\n\tconfig: EnableAutoPreviewsConfig<TPreviewData>,\n): void => {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// Assume we are in `getStaticProps()` or\n\t\t// `getServerSideProps()` with active Preview Mode (`pages`\n\t\t// directory).\n\n\t\tif (isPrismicPreviewData(config.previewData)) {\n\t\t\tconfig.client.queryContentFromRef(config.previewData.ref);\n\t\t}\n\t} else if (\"req\" in config && config.req) {\n\t\t// Assume we are in an API Route (`pages` directory).\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req);\n\t} else {\n\t\t// Assume we are in App Router (`app` directory) OR\n\t\t// `getStaticProps()`/`getServerSideProps()` with an inactive\n\t\t// Preview Mode (`pages` directory).\n\n\t\t// We use a function value so the cookie is checked on every\n\t\t// request. We don't have a static value to read from.\n\t\tconfig.client.queryContentFromRef(() => {\n\t\t\tlet isDraftModeEnabled = false;\n\t\t\ttry {\n\t\t\t\tisDraftModeEnabled = draftMode().isEnabled;\n\t\t\t} catch {\n\t\t\t\t// This catch block may be reached if\n\t\t\t\t// `draftMode()` is called in a place that does\n\t\t\t\t// not have access to its async storage. We can\n\t\t\t\t// ignore this case.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!isDraftModeEnabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet cookie: string | undefined;\n\t\t\ttry {\n\t\t\t\tcookie = cookies().get(prismic.cookie.preview)?.value;\n\t\t\t} catch {\n\t\t\t\t// We are probably in `getStaticProps()` or\n\t\t\t\t// `getServerSideProps()` with inactive Preview\n\t\t\t\t// Mode where `cookies()` does not work. We\n\t\t\t\t// don't need to do any preview handling.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We only return the cookie if a Prismic Preview session is active.\n\t\t\t//\n\t\t\t// An inactive cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\"\n\t\t\t// \t}\n\t\t\t//\n\t\t\t// An active cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\",\n\t\t\t// \t\t\"example-prismic-repo.prismic.io\": {\n\t\t\t// \t\t\tpreview: \"https://example-prismic-repo.prismic.io/previews/abc:123?websitePreviewId=xyz\"\n\t\t\t// \t\t}\n\t\t\t// \t}\n\t\t\tif (cookie && /\\.prismic\\.io/.test(cookie)) {\n\t\t\t\treturn cookie;\n\t\t\t}\n\t\t});\n\t}\n};\n"],"names":["draftMode","cookie","cookies","prismic.cookie.preview"],"mappings":";;;;AA2CA,MAAM,uBAAuB,CAAC,UAA+C;AAC5E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;AAChE;AASa,MAAA,qBAAqB,CACjC,WACS;AACL,MAAA,iBAAiB,UAAU,OAAO,aAAa;AAK9C,QAAA,qBAAqB,OAAO,WAAW,GAAG;AAC7C,aAAO,OAAO,oBAAoB,OAAO,YAAY,GAAG;AAAA,IACxD;AAAA,EACS,WAAA,SAAS,UAAU,OAAO,KAAK;AAGlC,WAAA,OAAO,0BAA0B,OAAO,GAAG;AAAA,EAAA,OAC5C;AAOC,WAAA,OAAO,oBAAoB,MAAK;;AACtC,UAAI,qBAAqB;AACrB,UAAA;AACH,6BAAqBA,QAAAA,UAAY,EAAA;AAAA,MAAA,QAChC;AAMD;AAAA,MACA;AAED,UAAI,CAAC,oBAAoB;AACxB;AAAA,MACA;AAEG,UAAAC;AACA,UAAA;AACHA,oBAASC,aAAAA,QAAU,EAAA,IAAIC,OAAsB,OAAA,MAApCD,mBAAuC;AAAA,MAAA,QAC/C;AAMD;AAAA,MACA;AAgBD,UAAID,YAAU,gBAAgB,KAAKA,QAAM,GAAG;AACpC,eAAAA;AAAAA,MACP;AAAA,IAAA,CACD;AAAA,EACD;AACF;;"}
@@ -19,13 +19,16 @@ const enableAutoPreviews = (config) => {
19
19
  } catch {
20
20
  return;
21
21
  }
22
+ if (!isDraftModeEnabled) {
23
+ return;
24
+ }
22
25
  let cookie;
23
26
  try {
24
27
  cookie = (_a = cookies().get(preview)) == null ? void 0 : _a.value;
25
28
  } catch {
26
29
  return;
27
30
  }
28
- if (isDraftModeEnabled && cookie && /\.prismic\.io/.test(cookie)) {
31
+ if (cookie && /\.prismic\.io/.test(cookie)) {
29
32
  return cookie;
30
33
  }
31
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"enableAutoPreviews.js","sources":["../../src/enableAutoPreviews.ts"],"sourcesContent":["import { PreviewData } from \"next\";\nimport { cookies, draftMode } from \"next/headers\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { NextApiRequestLike, PrismicPreviewData } from \"./types\";\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig<\n\tTPreviewData extends PreviewData = PreviewData,\n> = {\n\t/**\n\t * Prismic client with which automatic previews will be enabled.\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<\n\t\tprismic.Client,\n\t\t\"queryContentFromRef\" | \"enableAutoPreviewsFromReq\"\n\t>;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The `previewData` object provided in the `getStaticProps()` or\n\t * `getServerSideProps()` context object.\n\t */\n\tpreviewData?: TPreviewData;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike;\n};\n\nconst isPrismicPreviewData = (input: unknown): input is PrismicPreviewData => {\n\treturn typeof input === \"object\" && input !== null && \"ref\" in input;\n};\n\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session. It either takes in a Next.js `getStaticProps` context object\n * or a Next.js API endpoint request object.\n *\n * @param config - Configuration for the function.\n */\nexport const enableAutoPreviews = <TPreviewData extends PreviewData>(\n\tconfig: EnableAutoPreviewsConfig<TPreviewData>,\n): void => {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// Assume we are in `getStaticProps()` or\n\t\t// `getServerSideProps()` with active Preview Mode (`pages`\n\t\t// directory).\n\n\t\tif (isPrismicPreviewData(config.previewData)) {\n\t\t\tconfig.client.queryContentFromRef(config.previewData.ref);\n\t\t}\n\t} else if (\"req\" in config && config.req) {\n\t\t// Assume we are in an API Route (`pages` directory).\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req);\n\t} else {\n\t\t// Assume we are in App Router (`app` directory) OR\n\t\t// `getStaticProps()`/`getServerSideProps()` with an inactive\n\t\t// Preview Mode (`pages` directory).\n\n\t\t// We use a function value so the cookie is checked on every\n\t\t// request. We don't have a static value to read from.\n\t\tconfig.client.queryContentFromRef(() => {\n\t\t\tlet isDraftModeEnabled = false;\n\t\t\ttry {\n\t\t\t\tisDraftModeEnabled = draftMode().isEnabled;\n\t\t\t} catch {\n\t\t\t\t// This catch block may be reached if\n\t\t\t\t// `draftMode()` is called in a place that does\n\t\t\t\t// not have access to its async storage. We can\n\t\t\t\t// ignore this case.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet cookie: string | undefined;\n\t\t\ttry {\n\t\t\t\tcookie = cookies().get(prismic.cookie.preview)?.value;\n\t\t\t} catch {\n\t\t\t\t// We are probably in `getStaticProps()` or\n\t\t\t\t// `getServerSideProps()` with inactive Preview\n\t\t\t\t// Mode where `cookies()` does not work. We\n\t\t\t\t// don't need to do any preview handling.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We only return the cookie if a Prismic Preview session is active.\n\t\t\t//\n\t\t\t// An inactive cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\"\n\t\t\t// \t}\n\t\t\t//\n\t\t\t// An active cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\",\n\t\t\t// \t\t\"example-prismic-repo.prismic.io\": {\n\t\t\t// \t\t\tpreview: \"https://example-prismic-repo.prismic.io/previews/abc:123?websitePreviewId=xyz\"\n\t\t\t// \t\t}\n\t\t\t// \t}\n\t\t\tif (isDraftModeEnabled && cookie && /\\.prismic\\.io/.test(cookie)) {\n\t\t\t\treturn cookie;\n\t\t\t}\n\t\t});\n\t}\n};\n"],"names":["prismic.cookie.preview"],"mappings":";;AA2CA,MAAM,uBAAuB,CAAC,UAA+C;AAC5E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;AAChE;AASa,MAAA,qBAAqB,CACjC,WACS;AACL,MAAA,iBAAiB,UAAU,OAAO,aAAa;AAK9C,QAAA,qBAAqB,OAAO,WAAW,GAAG;AAC7C,aAAO,OAAO,oBAAoB,OAAO,YAAY,GAAG;AAAA,IACxD;AAAA,EACS,WAAA,SAAS,UAAU,OAAO,KAAK;AAGlC,WAAA,OAAO,0BAA0B,OAAO,GAAG;AAAA,EAAA,OAC5C;AAOC,WAAA,OAAO,oBAAoB,MAAK;;AACtC,UAAI,qBAAqB;AACrB,UAAA;AACH,6BAAqB,UAAY,EAAA;AAAA,MAAA,QAChC;AAMD;AAAA,MACA;AAEG,UAAA;AACA,UAAA;AACH,kBAAS,aAAU,EAAA,IAAIA,OAAsB,MAApC,mBAAuC;AAAA,MAAA,QAC/C;AAMD;AAAA,MACA;AAgBD,UAAI,sBAAsB,UAAU,gBAAgB,KAAK,MAAM,GAAG;AAC1D,eAAA;AAAA,MACP;AAAA,IAAA,CACD;AAAA,EACD;AACF;"}
1
+ {"version":3,"file":"enableAutoPreviews.js","sources":["../../src/enableAutoPreviews.ts"],"sourcesContent":["import { draftMode, cookies } from \"next/headers\";\nimport { PreviewData } from \"next\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { NextApiRequestLike, PrismicPreviewData } from \"./types\";\n\n/**\n * Configuration for `enableAutoPreviews`.\n *\n * @typeParam TPreviewData - Next.js preview data object.\n */\nexport type EnableAutoPreviewsConfig<\n\tTPreviewData extends PreviewData = PreviewData,\n> = {\n\t/**\n\t * Prismic client with which automatic previews will be enabled.\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<\n\t\tprismic.Client,\n\t\t\"queryContentFromRef\" | \"enableAutoPreviewsFromReq\"\n\t>;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The `previewData` object provided in the `getStaticProps()` or\n\t * `getServerSideProps()` context object.\n\t */\n\tpreviewData?: TPreviewData;\n\n\t/**\n\t * **Only used in the Pages Directory (/pages).**\n\t *\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike;\n};\n\nconst isPrismicPreviewData = (input: unknown): input is PrismicPreviewData => {\n\treturn typeof input === \"object\" && input !== null && \"ref\" in input;\n};\n\n/**\n * Configures a Prismic client to automatically query draft content during a\n * preview session. It either takes in a Next.js `getStaticProps` context object\n * or a Next.js API endpoint request object.\n *\n * @param config - Configuration for the function.\n */\nexport const enableAutoPreviews = <TPreviewData extends PreviewData>(\n\tconfig: EnableAutoPreviewsConfig<TPreviewData>,\n): void => {\n\tif (\"previewData\" in config && config.previewData) {\n\t\t// Assume we are in `getStaticProps()` or\n\t\t// `getServerSideProps()` with active Preview Mode (`pages`\n\t\t// directory).\n\n\t\tif (isPrismicPreviewData(config.previewData)) {\n\t\t\tconfig.client.queryContentFromRef(config.previewData.ref);\n\t\t}\n\t} else if (\"req\" in config && config.req) {\n\t\t// Assume we are in an API Route (`pages` directory).\n\n\t\tconfig.client.enableAutoPreviewsFromReq(config.req);\n\t} else {\n\t\t// Assume we are in App Router (`app` directory) OR\n\t\t// `getStaticProps()`/`getServerSideProps()` with an inactive\n\t\t// Preview Mode (`pages` directory).\n\n\t\t// We use a function value so the cookie is checked on every\n\t\t// request. We don't have a static value to read from.\n\t\tconfig.client.queryContentFromRef(() => {\n\t\t\tlet isDraftModeEnabled = false;\n\t\t\ttry {\n\t\t\t\tisDraftModeEnabled = draftMode().isEnabled;\n\t\t\t} catch {\n\t\t\t\t// This catch block may be reached if\n\t\t\t\t// `draftMode()` is called in a place that does\n\t\t\t\t// not have access to its async storage. We can\n\t\t\t\t// ignore this case.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!isDraftModeEnabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet cookie: string | undefined;\n\t\t\ttry {\n\t\t\t\tcookie = cookies().get(prismic.cookie.preview)?.value;\n\t\t\t} catch {\n\t\t\t\t// We are probably in `getStaticProps()` or\n\t\t\t\t// `getServerSideProps()` with inactive Preview\n\t\t\t\t// Mode where `cookies()` does not work. We\n\t\t\t\t// don't need to do any preview handling.\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We only return the cookie if a Prismic Preview session is active.\n\t\t\t//\n\t\t\t// An inactive cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\"\n\t\t\t// \t}\n\t\t\t//\n\t\t\t// An active cookie looks like this (URL encoded):\n\t\t\t// \t{\n\t\t\t// \t\t\"_tracker\": \"abc123\",\n\t\t\t// \t\t\"example-prismic-repo.prismic.io\": {\n\t\t\t// \t\t\tpreview: \"https://example-prismic-repo.prismic.io/previews/abc:123?websitePreviewId=xyz\"\n\t\t\t// \t\t}\n\t\t\t// \t}\n\t\t\tif (cookie && /\\.prismic\\.io/.test(cookie)) {\n\t\t\t\treturn cookie;\n\t\t\t}\n\t\t});\n\t}\n};\n"],"names":["prismic.cookie.preview"],"mappings":";;AA2CA,MAAM,uBAAuB,CAAC,UAA+C;AAC5E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS;AAChE;AASa,MAAA,qBAAqB,CACjC,WACS;AACL,MAAA,iBAAiB,UAAU,OAAO,aAAa;AAK9C,QAAA,qBAAqB,OAAO,WAAW,GAAG;AAC7C,aAAO,OAAO,oBAAoB,OAAO,YAAY,GAAG;AAAA,IACxD;AAAA,EACS,WAAA,SAAS,UAAU,OAAO,KAAK;AAGlC,WAAA,OAAO,0BAA0B,OAAO,GAAG;AAAA,EAAA,OAC5C;AAOC,WAAA,OAAO,oBAAoB,MAAK;;AACtC,UAAI,qBAAqB;AACrB,UAAA;AACH,6BAAqB,UAAY,EAAA;AAAA,MAAA,QAChC;AAMD;AAAA,MACA;AAED,UAAI,CAAC,oBAAoB;AACxB;AAAA,MACA;AAEG,UAAA;AACA,UAAA;AACH,kBAAS,aAAU,EAAA,IAAIA,OAAsB,MAApC,mBAAuC;AAAA,MAAA,QAC/C;AAMD;AAAA,MACA;AAgBD,UAAI,UAAU,gBAAgB,KAAK,MAAM,GAAG;AACpC,eAAA;AAAA,MACP;AAAA,IAAA,CACD;AAAA,EACD;AACF;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "1.3.0-alpha.0";
3
+ const version = "1.3.0";
4
4
  exports.version = version;
5
5
  //# sourceMappingURL=package.json.cjs.map
@@ -1,4 +1,4 @@
1
- const version = "1.3.0-alpha.0";
1
+ const version = "1.3.0";
2
2
  export {
3
3
  version
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/next",
3
- "version": "1.3.0-alpha.0",
3
+ "version": "1.3.0",
4
4
  "description": "Helpers to integrate Prismic into Next.js apps",
5
5
  "keywords": [
6
6
  "typescript",
@@ -52,25 +52,25 @@
52
52
  "test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
53
53
  },
54
54
  "dependencies": {
55
- "imgix-url-builder": "^0.0.3"
55
+ "imgix-url-builder": "^0.0.4"
56
56
  },
57
57
  "devDependencies": {
58
- "@prismicio/client": "^7.0.1",
59
- "@prismicio/mock": "^0.2.0",
58
+ "@prismicio/client": "^7.1.0",
59
+ "@prismicio/mock": "^0.3.0",
60
60
  "@size-limit/preset-small-lib": "^8.2.4",
61
61
  "@types/react-test-renderer": "^18.0.0",
62
- "@typescript-eslint/eslint-plugin": "^5.59.1",
63
- "@typescript-eslint/parser": "^5.59.1",
62
+ "@typescript-eslint/eslint-plugin": "^5.59.11",
63
+ "@typescript-eslint/parser": "^5.59.11",
64
64
  "@vitejs/plugin-react": "^4.0.0",
65
- "@vitest/coverage-c8": "^0.30.1",
66
- "eslint": "^8.39.0",
65
+ "@vitest/coverage-v8": "^0.32.0",
66
+ "eslint": "^8.42.0",
67
67
  "eslint-config-prettier": "^8.8.0",
68
68
  "eslint-plugin-prettier": "^4.2.1",
69
69
  "eslint-plugin-react": "^7.32.2",
70
70
  "eslint-plugin-react-hooks": "^4.6.0",
71
71
  "eslint-plugin-tsdoc": "^0.2.17",
72
- "happy-dom": "^9.9.2",
73
- "memfs": "^3.5.1",
72
+ "happy-dom": "^9.20.3",
73
+ "memfs": "^3.5.3",
74
74
  "next": "^13.4.5-canary.9",
75
75
  "node-fetch": "^3.3.1",
76
76
  "prettier": "^2.8.8",
@@ -78,17 +78,17 @@
78
78
  "react": "^18.1.0",
79
79
  "react-dom": "^18.2.0",
80
80
  "react-test-renderer": "^18.2.0",
81
- "rollup-plugin-preserve-directives": "^0.1.0",
81
+ "rollup-plugin-preserve-directives": "^0.2.0",
82
82
  "size-limit": "^8.2.4",
83
83
  "standard-version": "^9.5.0",
84
- "typescript": "^5.0.4",
85
- "vite": "^4.3.1",
84
+ "typescript": "^5.1.3",
85
+ "vite": "^4.3.9",
86
86
  "vite-plugin-sdk": "^0.1.1",
87
- "vitest": "^0.30.1"
87
+ "vitest": "^0.32.0"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "@prismicio/client": "^6 || ^7",
91
- "next": "^13",
91
+ "next": "^13.4.5",
92
92
  "react": "^18"
93
93
  },
94
94
  "engines": {
@@ -1,5 +1,5 @@
1
+ import { draftMode, cookies } from "next/headers";
1
2
  import { PreviewData } from "next";
2
- import { cookies, draftMode } from "next/headers";
3
3
  import * as prismic from "@prismicio/client";
4
4
 
5
5
  import { NextApiRequestLike, PrismicPreviewData } from "./types";
@@ -87,6 +87,10 @@ export const enableAutoPreviews = <TPreviewData extends PreviewData>(
87
87
  return;
88
88
  }
89
89
 
90
+ if (!isDraftModeEnabled) {
91
+ return;
92
+ }
93
+
90
94
  let cookie: string | undefined;
91
95
  try {
92
96
  cookie = cookies().get(prismic.cookie.preview)?.value;
@@ -113,7 +117,7 @@ export const enableAutoPreviews = <TPreviewData extends PreviewData>(
113
117
  // preview: "https://example-prismic-repo.prismic.io/previews/abc:123?websitePreviewId=xyz"
114
118
  // }
115
119
  // }
116
- if (isDraftModeEnabled && cookie && /\.prismic\.io/.test(cookie)) {
120
+ if (cookie && /\.prismic\.io/.test(cookie)) {
117
121
  return cookie;
118
122
  }
119
123
  });