next-sanity 13.1.0 → 13.1.2
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.
- package/dist/constants.js.map +1 -1
- package/dist/draft-mode/index.d.ts +25 -25
- package/dist/draft-mode/index.d.ts.map +1 -1
- package/dist/draft-mode/index.js.map +1 -1
- package/dist/image/index.d.ts +10 -10
- package/dist/image/index.d.ts.map +1 -1
- package/dist/isCorsOriginError.d.ts.map +1 -1
- package/dist/live/cache-life.d.ts +17 -20
- package/dist/live/cache-life.d.ts.map +1 -1
- package/dist/live/cache-life.js.map +1 -1
- package/dist/live/client-components/index.d.ts +2 -2
- package/dist/live/client-components/index.d.ts.map +1 -1
- package/dist/live/conditions/default/index.d.ts +286 -286
- package/dist/live/conditions/default/index.d.ts.map +1 -1
- package/dist/live/conditions/next-js/index.d.ts +228 -228
- package/dist/live/conditions/next-js/index.d.ts.map +1 -1
- package/dist/live/conditions/react-server/index.d.ts +228 -228
- package/dist/live/conditions/react-server/index.d.ts.map +1 -1
- package/dist/live/server-actions/index.d.ts +2 -2
- package/dist/live/server-actions/index.d.ts.map +1 -1
- package/dist/parseTags.d.ts +80 -82
- package/dist/parseTags.d.ts.map +1 -1
- package/dist/studio/client-component/index.d.ts +9 -9
- package/dist/studio/client-component/index.d.ts.map +1 -1
- package/dist/studio/index.d.ts +36 -38
- package/dist/studio/index.d.ts.map +1 -1
- package/dist/studio/index.js.map +1 -1
- package/dist/types.d.ts +189 -189
- package/dist/types.d.ts.map +1 -1
- package/dist/visual-editing/client-component/index.d.ts +16 -16
- package/dist/visual-editing/client-component/index.d.ts.map +1 -1
- package/dist/visual-editing/index.d.ts +2 -2
- package/dist/visual-editing/index.d.ts.map +1 -1
- package/dist/visual-editing/server-actions/index.d.ts +2 -2
- package/dist/visual-editing/server-actions/index.d.ts.map +1 -1
- package/dist/webhook/index.d.ts +6 -6
- package/dist/webhook/index.d.ts.map +1 -1
- package/package.json +17 -17
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/live/shared/constants.ts"],"sourcesContent":["import type {CacheTagPrefix} from '#live/types'\n\n// @TODO make this configurable\nexport const cacheTagPrefix = 'sanity:' satisfies CacheTagPrefix\n\n/** The default API host used by @sanity/client when none is specified. */\nexport const defaultApiHost = 'https://api.sanity.io'\n"],"mappings":"AAGA,MAAa,
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/live/shared/constants.ts"],"sourcesContent":["import type {CacheTagPrefix} from '#live/types'\n\n// @TODO make this configurable\nexport const cacheTagPrefix: 'sanity:' = 'sanity:' satisfies CacheTagPrefix\n\n/** The default API host used by @sanity/client when none is specified. */\nexport const defaultApiHost = 'https://api.sanity.io'\n"],"mappings":"AAGA,MAAa,iBAA4B;;AAGzC,MAAa,iBAAiB"}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { SanityClient } from "@sanity/client";
|
|
2
2
|
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
5
|
interface DefineEnableDraftModeOptions {
|
|
6
6
|
client: SanityClient;
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
* Force secure cookies in development mode.
|
|
9
|
+
* Enable this when using Next.js --experimental-https flag.
|
|
10
|
+
* This option has no effect in production (cookies are always secure).
|
|
11
|
+
* @defaultValue false
|
|
12
|
+
*/
|
|
13
13
|
secureDevMode?: boolean;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
18
|
interface EnableDraftMode {
|
|
19
19
|
GET: (request: Request) => Promise<Response>;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Sets up an API route for enabling draft mode, can be paired with the `previewUrl.previewMode.enable` in `sanity/presentation`.
|
|
23
|
-
* Can also be used with `sanity-plugin-iframe-pane`.
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* // src/app/api/draft-mode/enable/route.ts
|
|
27
|
-
*
|
|
28
|
-
* import { defineEnableDraftMode } from "next-sanity/draft-mode";
|
|
29
|
-
* import { client } from "@/sanity/lib/client";
|
|
30
|
-
*
|
|
31
|
-
* export const { GET } = defineEnableDraftMode({
|
|
32
|
-
* client: client.withConfig({ token: process.env.SANITY_API_READ_TOKEN }),
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
22
|
+
* Sets up an API route for enabling draft mode, can be paired with the `previewUrl.previewMode.enable` in `sanity/presentation`.
|
|
23
|
+
* Can also be used with `sanity-plugin-iframe-pane`.
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // src/app/api/draft-mode/enable/route.ts
|
|
27
|
+
*
|
|
28
|
+
* import { defineEnableDraftMode } from "next-sanity/draft-mode";
|
|
29
|
+
* import { client } from "@/sanity/lib/client";
|
|
30
|
+
*
|
|
31
|
+
* export const { GET } = defineEnableDraftMode({
|
|
32
|
+
* client: client.withConfig({ token: process.env.SANITY_API_READ_TOKEN }),
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
38
|
declare function defineEnableDraftMode(options: DefineEnableDraftModeOptions): EnableDraftMode;
|
|
39
39
|
export { DefineEnableDraftModeOptions, EnableDraftMode, defineEnableDraftMode };
|
|
40
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/draft-mode/define-enable-draft-mode.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/draft-mode/define-enable-draft-mode.ts"],"mappings":";;;;UASiB;EACf,QAAQ;;;;;;;EAOR;;;;;UAMe;EACf,MAAM,SAAS,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;iBAoBrB,sBAAsB,SAAS,+BAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/draft-mode/define-enable-draft-mode.ts"],"sourcesContent":["import type {SanityClient} from '@sanity/client'\nimport {validatePreviewUrl} from '@sanity/preview-url-secret'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {cookies, draftMode} from 'next/headers'\nimport {redirect} from 'next/navigation'\n\n/**\n * @public\n */\nexport interface DefineEnableDraftModeOptions {\n client: SanityClient\n /**\n * Force secure cookies in development mode.\n * Enable this when using Next.js --experimental-https flag.\n * This option has no effect in production (cookies are always secure).\n * @defaultValue false\n */\n secureDevMode?: boolean\n}\n\n/**\n * @public\n */\nexport interface EnableDraftMode {\n GET: (request: Request) => Promise<Response>\n}\n\n/**\n * Sets up an API route for enabling draft mode, can be paired with the `previewUrl.previewMode.enable` in `sanity/presentation`.\n * Can also be used with `sanity-plugin-iframe-pane`.\n * @example\n * ```ts\n * // src/app/api/draft-mode/enable/route.ts\n *\n * import { defineEnableDraftMode } from \"next-sanity/draft-mode\";\n * import { client } from \"@/sanity/lib/client\";\n *\n * export const { GET } = defineEnableDraftMode({\n * client: client.withConfig({ token: process.env.SANITY_API_READ_TOKEN }),\n * });\n * ```\n *\n * @public\n */\nexport function defineEnableDraftMode(options: DefineEnableDraftModeOptions): EnableDraftMode {\n const {client} = options\n return {\n GET: async (request: Request) => {\n // @TODO check if already in draft mode at a much earlier stage, and skip validation\n\n const {\n isValid,\n redirectTo = '/',\n studioPreviewPerspective,\n } = await validatePreviewUrl(client, request.url)\n if (!isValid) {\n return new Response('Invalid secret', {status: 401})\n }\n\n const draftModeStore = await draftMode()\n\n // Let's enable draft mode if it's not already enabled\n if (!draftModeStore.isEnabled) {\n draftModeStore.enable()\n }\n\n const isProduction = process.env.NODE_ENV === 'production'\n\n // We can't auto-detect HTTPS in dev due to Next.js limitations,\n // so we need an explicit option\n const isSecure = isProduction || (options.secureDevMode ?? false)\n\n // Override cookie header for draft mode for usage in live-preview\n // https://github.com/vercel/next.js/issues/49927\n const cookieStore = await cookies()\n const cookie = cookieStore.get('__prerender_bypass')!\n cookieStore.set({\n name: '__prerender_bypass',\n value: cookie?.value,\n httpOnly: true,\n path: '/',\n secure: isSecure,\n sameSite: isSecure ? 'none' : 'lax',\n })\n\n if (studioPreviewPerspective) {\n cookieStore.set({\n name: perspectiveCookieName,\n value: studioPreviewPerspective,\n httpOnly: true,\n path: '/',\n secure: isSecure,\n sameSite: isSecure ? 'none' : 'lax',\n })\n }\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/draft-mode/define-enable-draft-mode.ts"],"sourcesContent":["import type {SanityClient} from '@sanity/client'\nimport {validatePreviewUrl} from '@sanity/preview-url-secret'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {cookies, draftMode} from 'next/headers'\nimport {redirect} from 'next/navigation'\n\n/**\n * @public\n */\nexport interface DefineEnableDraftModeOptions {\n client: SanityClient\n /**\n * Force secure cookies in development mode.\n * Enable this when using Next.js --experimental-https flag.\n * This option has no effect in production (cookies are always secure).\n * @defaultValue false\n */\n secureDevMode?: boolean\n}\n\n/**\n * @public\n */\nexport interface EnableDraftMode {\n GET: (request: Request) => Promise<Response>\n}\n\n/**\n * Sets up an API route for enabling draft mode, can be paired with the `previewUrl.previewMode.enable` in `sanity/presentation`.\n * Can also be used with `sanity-plugin-iframe-pane`.\n * @example\n * ```ts\n * // src/app/api/draft-mode/enable/route.ts\n *\n * import { defineEnableDraftMode } from \"next-sanity/draft-mode\";\n * import { client } from \"@/sanity/lib/client\";\n *\n * export const { GET } = defineEnableDraftMode({\n * client: client.withConfig({ token: process.env.SANITY_API_READ_TOKEN }),\n * });\n * ```\n *\n * @public\n */\nexport function defineEnableDraftMode(options: DefineEnableDraftModeOptions): EnableDraftMode {\n const {client} = options\n return {\n GET: async (request: Request) => {\n // @TODO check if already in draft mode at a much earlier stage, and skip validation\n\n const {\n isValid,\n redirectTo = '/',\n studioPreviewPerspective,\n } = await validatePreviewUrl(client, request.url)\n if (!isValid) {\n return new Response('Invalid secret', {status: 401})\n }\n\n const draftModeStore = await draftMode()\n\n // Let's enable draft mode if it's not already enabled\n if (!draftModeStore.isEnabled) {\n draftModeStore.enable()\n }\n\n const isProduction = process.env.NODE_ENV === 'production'\n\n // We can't auto-detect HTTPS in dev due to Next.js limitations,\n // so we need an explicit option\n const isSecure = isProduction || (options.secureDevMode ?? false)\n\n // Override cookie header for draft mode for usage in live-preview\n // https://github.com/vercel/next.js/issues/49927\n const cookieStore = await cookies()\n const cookie = cookieStore.get('__prerender_bypass')!\n cookieStore.set({\n name: '__prerender_bypass',\n value: cookie?.value,\n httpOnly: true,\n path: '/',\n secure: isSecure,\n sameSite: isSecure ? 'none' : 'lax',\n })\n\n if (studioPreviewPerspective) {\n cookieStore.set({\n name: perspectiveCookieName,\n value: studioPreviewPerspective,\n httpOnly: true,\n path: '/',\n secure: isSecure,\n sameSite: isSecure ? 'none' : 'lax',\n })\n }\n\n return redirect(redirectTo)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgB,sBAAsB,SAAwD;CAC5F,MAAM,EAAC,WAAU;CACjB,OAAO,EACL,KAAK,OAAO,YAAqB;EAG/B,MAAM,EACJ,SACA,aAAa,KACb,6BACE,MAAM,mBAAmB,QAAQ,QAAQ,GAAG;EAChD,IAAI,CAAC,SACH,OAAO,IAAI,SAAS,kBAAkB,EAAC,QAAQ,IAAG,CAAC;EAGrD,MAAM,iBAAiB,MAAM,UAAU;EAGvC,IAAI,CAAC,eAAe,WAClB,eAAe,OAAO;EAOxB,MAAM,WAJe,QAAQ,IAAI,aAAa,iBAIZ,QAAQ,iBAAiB;EAI3D,MAAM,cAAc,MAAM,QAAQ;EAClC,MAAM,SAAS,YAAY,IAAI,oBAAoB;EACnD,YAAY,IAAI;GACd,MAAM;GACN,OAAO,QAAQ;GACf,UAAU;GACV,MAAM;GACN,QAAQ;GACR,UAAU,WAAW,SAAS;EAChC,CAAC;EAED,IAAI,0BACF,YAAY,IAAI;GACd,MAAM;GACN,OAAO;GACP,UAAU;GACV,MAAM;GACN,QAAQ;GACR,UAAU,WAAW,SAAS;EAChC,CAAC;EAGH,OAAO,SAAS,UAAU;CAC5B,EACF;AACF"}
|
package/dist/image/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { ImageLoader, ImageProps as ImageProps$1 } from "next/image";
|
|
2
2
|
/**
|
|
3
|
-
* @alpha
|
|
4
|
-
*/
|
|
3
|
+
* @alpha
|
|
4
|
+
*/
|
|
5
5
|
interface ImageProps extends Omit<ImageProps$1, "loader" | "src"> {
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
* The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.
|
|
8
|
+
*/
|
|
9
9
|
loader?: never;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* Must be a string that is a valid URL to an image on the Sanity Image CDN.
|
|
12
|
+
*/
|
|
13
13
|
src: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* @alpha
|
|
17
|
-
*/
|
|
16
|
+
* @alpha
|
|
17
|
+
*/
|
|
18
18
|
declare function Image(props: ImageProps): React.JSX.Element;
|
|
19
19
|
/**
|
|
20
|
-
* @alpha
|
|
21
|
-
*/
|
|
20
|
+
* @alpha
|
|
21
|
+
*/
|
|
22
22
|
declare const imageLoader: ImageLoader;
|
|
23
23
|
export { Image, type ImageProps, imageLoader };
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/image/Image.tsx","../../src/image/imageLoader.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/image/Image.tsx","../../src/image/imageLoader.ts"],"mappings":";;;;UAOiB,mBAAmB,KAAK;;;;EAIvC;;;;EAIA;;;;;iBAMc,MAAM,OAAO,aAAa,MAAM,IAAI;;;;cChBvC,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCorsOriginError.d.ts","names":[],"sources":["../src/live/shared/isCorsOriginError.ts"],"mappings":";;iBAGgB,
|
|
1
|
+
{"version":3,"file":"isCorsOriginError.d.ts","names":[],"sources":["../src/live/shared/isCorsOriginError.ts"],"mappings":";;iBAGgB,kBAAkB,iBAAiB,SAAS"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* For usage with `cacheComponents: true`, and `defineLive`:
|
|
3
|
-
* ```ts
|
|
4
|
-
* // next.config.ts
|
|
5
|
-
*
|
|
6
|
-
* import type {NextConfig} from 'next'
|
|
7
|
-
* import {sanity} from 'next-sanity/live/cache-life'
|
|
8
|
-
*
|
|
9
|
-
* const nextConfig: NextConfig = {
|
|
10
|
-
* cacheComponents: true,
|
|
11
|
-
* cacheLife: {
|
|
12
|
-
* default: sanity,
|
|
13
|
-
* }
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* export default nextConfig
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
2
|
+
* For usage with `cacheComponents: true`, and `defineLive`:
|
|
3
|
+
* ```ts
|
|
4
|
+
* // next.config.ts
|
|
5
|
+
*
|
|
6
|
+
* import type {NextConfig} from 'next'
|
|
7
|
+
* import {sanity} from 'next-sanity/live/cache-life'
|
|
8
|
+
*
|
|
9
|
+
* const nextConfig: NextConfig = {
|
|
10
|
+
* cacheComponents: true,
|
|
11
|
+
* cacheLife: {
|
|
12
|
+
* default: sanity,
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* export default nextConfig
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
19
|
declare const sanity: {
|
|
20
|
-
/**
|
|
21
|
-
* Sanity Live handles on-demand revalidation, so the default 15min time-based revalidation is too short
|
|
22
|
-
*/
|
|
23
20
|
readonly revalidate: 31_536_000;
|
|
24
21
|
};
|
|
25
22
|
export { sanity };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-life.d.ts","names":[],"sources":["../../src/live/cache-life.ts"],"mappings":"AAkBA
|
|
1
|
+
{"version":3,"file":"cache-life.d.ts","names":[],"sources":["../../src/live/cache-life.ts"],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;cAAa;WACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-life.js","names":[],"sources":["../../src/live/cache-life.ts"],"sourcesContent":["/**\n * For usage with `cacheComponents: true`, and `defineLive`:\n * ```ts\n * // next.config.ts\n *\n * import type {NextConfig} from 'next'\n * import {sanity} from 'next-sanity/live/cache-life'\n *\n * const nextConfig: NextConfig = {\n * cacheComponents: true,\n * cacheLife: {\n * default: sanity,\n * }\n * }\n *\n * export default nextConfig\n * ```\n */\nexport const sanity = {\n /**\n * Sanity Live handles on-demand revalidation, so the default 15min time-based revalidation is too short\n */\n revalidate: 31_536_000, // 365 days\n} as const satisfies {\n /**\n * This cache may be stale on clients for ... seconds before checking with the server.\n */\n stale?: number\n /**\n * If the server receives a new request after ... seconds, start revalidating new values in the background.\n */\n revalidate?: number\n /**\n * If this entry has no traffic for ... seconds it will expire. The next request will recompute it.\n */\n expire?: number\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,
|
|
1
|
+
{"version":3,"file":"cache-life.js","names":[],"sources":["../../src/live/cache-life.ts"],"sourcesContent":["/**\n * For usage with `cacheComponents: true`, and `defineLive`:\n * ```ts\n * // next.config.ts\n *\n * import type {NextConfig} from 'next'\n * import {sanity} from 'next-sanity/live/cache-life'\n *\n * const nextConfig: NextConfig = {\n * cacheComponents: true,\n * cacheLife: {\n * default: sanity,\n * }\n * }\n *\n * export default nextConfig\n * ```\n */\nexport const sanity: {\n readonly revalidate: 31_536_000\n} = {\n /**\n * Sanity Live handles on-demand revalidation, so the default 15min time-based revalidation is too short\n */\n revalidate: 31_536_000, // 365 days\n} as const satisfies {\n /**\n * This cache may be stale on clients for ... seconds before checking with the server.\n */\n stale?: number\n /**\n * If the server receives a new request after ... seconds, start revalidating new values in the background.\n */\n revalidate?: number\n /**\n * If this entry has no traffic for ... seconds it will expire. The next request will recompute it.\n */\n expire?: number\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,SAET;;;;AAIF,YAAY,QACd"}
|
|
@@ -12,8 +12,8 @@ interface SanityLiveProps {
|
|
|
12
12
|
onGoAway: SanityLiveOnGoaway | false | undefined;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* @internal CAUTION: this is an internal component and does not follow semver. Using it directly is at your own risk.
|
|
16
|
-
*/
|
|
15
|
+
* @internal CAUTION: this is an internal component and does not follow semver. Using it directly is at your own risk.
|
|
16
|
+
*/
|
|
17
17
|
declare const SanityLive: React.ComponentType<SanityLiveProps>;
|
|
18
18
|
export { SanityLive };
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/live/client-components/SanityLive.tsx","../../../src/live/client-components/index.ts"],"mappings":";UAmBiB
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/live/client-components/SanityLive.tsx","../../../src/live/client-components/index.ts"],"mappings":";UAmBiB;EACf,QAAQ;EACR;EACA;EACA;EAEA,QAAQ;EACR,SAAS;EACT,WAAW;EACX,aAAa;EACb,WAAW;EACX,UAAU;;;;;cCtBC,YAAY,MAAM,cAAc"}
|