next-sanity 13.0.0-cache-components.41 → 13.0.0-cache-components.43
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/live/client-components/index.d.ts +1 -1
- package/dist/live/conditions/default/index.d.ts +251 -4
- package/dist/live/conditions/default/index.d.ts.map +1 -1
- package/dist/live/conditions/default/index.js +30 -6
- package/dist/live/conditions/default/index.js.map +1 -1
- package/dist/live/conditions/next-js/index.d.ts +229 -2
- package/dist/live/conditions/next-js/index.d.ts.map +1 -1
- package/dist/live/conditions/next-js/index.js +2 -2
- package/dist/live/conditions/next-js/index.js.map +1 -1
- package/dist/live/conditions/react-server/index.d.ts +229 -2
- package/dist/live/conditions/react-server/index.d.ts.map +1 -1
- package/dist/live/conditions/react-server/index.js +3 -8
- package/dist/live/conditions/react-server/index.js.map +1 -1
- package/dist/live/server-actions/index.d.ts +11 -0
- package/dist/live/server-actions/index.d.ts.map +1 -0
- package/dist/live/server-actions/index.js +27 -0
- package/dist/live/server-actions/index.js.map +1 -0
- package/dist/parseTags.d.ts +17 -8
- package/dist/parseTags.d.ts.map +1 -1
- package/dist/resolvePerspectiveFromCookies.js +17 -8
- package/dist/resolvePerspectiveFromCookies.js.map +1 -1
- package/dist/types.d.ts +114 -45
- package/dist/types.d.ts.map +1 -1
- package/dist/visual-editing/index.js +2 -2
- package/dist/visual-editing/index.js.map +1 -1
- package/dist/visual-editing/server-actions/index.d.ts +2 -2
- package/dist/visual-editing/server-actions/index.js +3 -3
- package/dist/visual-editing/server-actions/index.js.map +1 -1
- package/package.json +2 -5
- package/dist/live/server-actions/index.default.d.ts +0 -10
- package/dist/live/server-actions/index.default.d.ts.map +0 -1
- package/dist/live/server-actions/index.default.js +0 -27
- package/dist/live/server-actions/index.default.js.map +0 -1
- package/dist/live/server-actions/index.next-js.d.ts +0 -10
- package/dist/live/server-actions/index.next-js.d.ts.map +0 -1
- package/dist/live/server-actions/index.next-js.js +0 -26
- package/dist/live/server-actions/index.next-js.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SanityLiveAction, c as
|
|
1
|
+
import { a as SanityLiveAction, c as SanityLiveOnGoaway, d as SanityLiveOnWelcome, l as SanityLiveOnReconnect, s as SanityLiveOnError, u as SanityLiveOnRestart } from "../../types.js";
|
|
2
2
|
import { InitializedClientConfig } from "@sanity/client";
|
|
3
3
|
interface SanityClientConfig extends Pick<InitializedClientConfig, "projectId" | "dataset" | "apiHost" | "apiVersion" | "useProjectHostname" | "token" | "requestTagPrefix"> {}
|
|
4
4
|
interface SanityLiveProps {
|
|
@@ -1,8 +1,153 @@
|
|
|
1
1
|
import { t as isCorsOriginError } from "../../../isCorsOriginError.js";
|
|
2
|
-
import { d as
|
|
2
|
+
import { a as SanityLiveAction, c as SanityLiveOnGoaway, d as SanityLiveOnWelcome, f as StrictDefinedFetchType, i as LivePerspective, l as SanityLiveOnReconnect, n as DefinedFetchType, o as SanityLiveActionContext, p as StrictDefinedLiveProps, r as DefinedLiveProps, s as SanityLiveOnError, t as DefineLiveOptions, u as SanityLiveOnRestart } from "../../../types.js";
|
|
3
3
|
import { n as resolvePerspectiveFromCookies$1, t as parseTags } from "../../../parseTags.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Set up Sanity Live for Cache Components. `defineLive` returns `sanityFetch`
|
|
6
|
+
* and `<SanityLive />`, which connect your Sanity client to the Live Content API
|
|
7
|
+
* so cached pages can update in response to fine-grained content changes.
|
|
8
|
+
*
|
|
9
|
+
* With `strict: true`, `perspective` and `stega` become required
|
|
10
|
+
* `sanityFetch` options, and `includeDrafts` becomes required on
|
|
11
|
+
* `<SanityLive />`. Resolve dynamic values from `draftMode()` and `cookies()`
|
|
12
|
+
* outside `'use cache'` boundaries, then pass them into cached components.
|
|
13
|
+
*
|
|
14
|
+
* @see [Live Content API](https://www.sanity.io/docs/content-lake/live-content-api)
|
|
15
|
+
* @see [Sanity Live](https://www.sanity.io/live)
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // sanity/live.ts
|
|
20
|
+
* import {cookies, draftMode} from 'next/headers'
|
|
21
|
+
* import {createClient} from 'next-sanity'
|
|
22
|
+
* import {
|
|
23
|
+
* defineLive,
|
|
24
|
+
* resolvePerspectiveFromCookies,
|
|
25
|
+
* type LivePerspective,
|
|
26
|
+
* } from 'next-sanity/live'
|
|
27
|
+
*
|
|
28
|
+
* const client = createClient({
|
|
29
|
+
* projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
|
|
30
|
+
* dataset: process.env.NEXT_PUBLIC_SANITY_DATASET,
|
|
31
|
+
* useCdn: true,
|
|
32
|
+
* perspective: 'published',
|
|
33
|
+
* })
|
|
34
|
+
* const token = process.env.SANITY_API_READ_TOKEN
|
|
35
|
+
*
|
|
36
|
+
* export const {sanityFetch, SanityLive} = defineLive({
|
|
37
|
+
* client,
|
|
38
|
+
* browserToken: token,
|
|
39
|
+
* serverToken: token,
|
|
40
|
+
* strict: true,
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* export interface DynamicFetchOptions {
|
|
44
|
+
* perspective: LivePerspective
|
|
45
|
+
* stega: boolean
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* // Resolve dynamic values outside 'use cache' boundaries.
|
|
49
|
+
* export async function getDynamicFetchOptions(): Promise<DynamicFetchOptions> {
|
|
50
|
+
* const {isEnabled: isDraftMode} = await draftMode()
|
|
51
|
+
* if (!isDraftMode) {
|
|
52
|
+
* return {perspective: 'published', stega: false}
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* const jar = await cookies()
|
|
56
|
+
* const perspective = await resolvePerspectiveFromCookies({cookies: jar})
|
|
57
|
+
* return {perspective: perspective ?? 'drafts', stega: true}
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* // app/layout.tsx
|
|
64
|
+
* import {draftMode} from 'next/headers'
|
|
65
|
+
*
|
|
66
|
+
* import {SanityLive} from '@/sanity/live'
|
|
67
|
+
*
|
|
68
|
+
* export default async function RootLayout({children}: {children: React.ReactNode}) {
|
|
69
|
+
* const {isEnabled: isDraftMode} = await draftMode()
|
|
70
|
+
*
|
|
71
|
+
* return (
|
|
72
|
+
* <html lang="en">
|
|
73
|
+
* <body>
|
|
74
|
+
* {children}
|
|
75
|
+
* <SanityLive includeDrafts={isDraftMode} />
|
|
76
|
+
* </body>
|
|
77
|
+
* </html>
|
|
78
|
+
* )
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* // app/[slug]/page.tsx
|
|
85
|
+
* import {draftMode} from 'next/headers'
|
|
86
|
+
* import {Suspense} from 'react'
|
|
87
|
+
* import {defineQuery} from 'next-sanity'
|
|
88
|
+
*
|
|
89
|
+
* import {
|
|
90
|
+
* getDynamicFetchOptions,
|
|
91
|
+
* sanityFetch,
|
|
92
|
+
* type DynamicFetchOptions,
|
|
93
|
+
* } from '@/sanity/live'
|
|
94
|
+
*
|
|
95
|
+
* const POSTS_SLUGS_QUERY = defineQuery(`
|
|
96
|
+
* *[_type == "post" && slug.current]{"slug": slug.current}
|
|
97
|
+
* `)
|
|
98
|
+
* const POST_QUERY = defineQuery(`
|
|
99
|
+
* *[_type == "post" && slug.current == $slug][0]
|
|
100
|
+
* `)
|
|
101
|
+
*
|
|
102
|
+
* export async function generateStaticParams() {
|
|
103
|
+
* const {data} = await sanityFetch({
|
|
104
|
+
* query: POSTS_SLUGS_QUERY,
|
|
105
|
+
* perspective: 'published',
|
|
106
|
+
* stega: false,
|
|
107
|
+
* })
|
|
108
|
+
*
|
|
109
|
+
* return data
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* export default async function Page(props: PageProps<'/[slug]'>) {
|
|
113
|
+
* const {isEnabled: isDraftMode} = await draftMode()
|
|
114
|
+
* if (isDraftMode) {
|
|
115
|
+
* return (
|
|
116
|
+
* <Suspense fallback={<div>Loading...</div>}>
|
|
117
|
+
* <DynamicPage params={props.params} />
|
|
118
|
+
* </Suspense>
|
|
119
|
+
* )
|
|
120
|
+
* }
|
|
121
|
+
*
|
|
122
|
+
* const {slug} = await props.params
|
|
123
|
+
* return <CachedPage slug={slug} perspective="published" stega={false} />
|
|
124
|
+
* }
|
|
125
|
+
*
|
|
126
|
+
* async function DynamicPage(props: Pick<PageProps<'/[slug]'>, 'params'>) {
|
|
127
|
+
* const {slug} = await props.params
|
|
128
|
+
* const {perspective, stega} = await getDynamicFetchOptions()
|
|
129
|
+
*
|
|
130
|
+
* return <CachedPage slug={slug} perspective={perspective} stega={stega} />
|
|
131
|
+
* }
|
|
132
|
+
*
|
|
133
|
+
* async function CachedPage({
|
|
134
|
+
* slug,
|
|
135
|
+
* perspective,
|
|
136
|
+
* stega,
|
|
137
|
+
* }: {slug: string} & DynamicFetchOptions) {
|
|
138
|
+
* 'use cache'
|
|
139
|
+
*
|
|
140
|
+
* const {data} = await sanityFetch({
|
|
141
|
+
* query: POST_QUERY,
|
|
142
|
+
* params: {slug},
|
|
143
|
+
* perspective,
|
|
144
|
+
* stega,
|
|
145
|
+
* })
|
|
146
|
+
*
|
|
147
|
+
* return <pre>{JSON.stringify(data, null, 2)}</pre>
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
6
151
|
* @public
|
|
7
152
|
*/
|
|
8
153
|
declare function defineLive(config: DefineLiveOptions & {
|
|
@@ -12,7 +157,81 @@ declare function defineLive(config: DefineLiveOptions & {
|
|
|
12
157
|
SanityLive: React.ComponentType<StrictDefinedLiveProps>;
|
|
13
158
|
};
|
|
14
159
|
/**
|
|
15
|
-
*
|
|
160
|
+
* Set up Sanity Live. `defineLive` returns `sanityFetch` and `<SanityLive />`,
|
|
161
|
+
* which connect your Sanity client to the Live Content API so pages can serve
|
|
162
|
+
* cached content and update in response to fine-grained content changes.
|
|
163
|
+
*
|
|
164
|
+
* @see [Live Content API](https://www.sanity.io/docs/content-lake/live-content-api)
|
|
165
|
+
* @see [Sanity Live](https://www.sanity.io/live)
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```tsx
|
|
169
|
+
* import {createClient} from 'next-sanity'
|
|
170
|
+
* import {defineLive} from 'next-sanity/live'
|
|
171
|
+
*
|
|
172
|
+
* const client = createClient({
|
|
173
|
+
* projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
|
|
174
|
+
* dataset: process.env.NEXT_PUBLIC_SANITY_DATASET,
|
|
175
|
+
* useCdn: true,
|
|
176
|
+
* perspective: 'published',
|
|
177
|
+
* })
|
|
178
|
+
*
|
|
179
|
+
* export const {sanityFetch, SanityLive} = defineLive({
|
|
180
|
+
* client,
|
|
181
|
+
* })
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```tsx
|
|
186
|
+
* // app/layout.tsx
|
|
187
|
+
* import {SanityLive} from '@/sanity/live'
|
|
188
|
+
*
|
|
189
|
+
* export default function RootLayout({children}: {children: React.ReactNode}) {
|
|
190
|
+
* return (
|
|
191
|
+
* <html lang="en">
|
|
192
|
+
* <body>
|
|
193
|
+
* {children}
|
|
194
|
+
* <SanityLive />
|
|
195
|
+
* </body>
|
|
196
|
+
* </html>
|
|
197
|
+
* )
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```tsx
|
|
203
|
+
* // app/[slug]/page.tsx
|
|
204
|
+
* import {defineQuery} from 'next-sanity'
|
|
205
|
+
* import {sanityFetch} from '@/sanity/live'
|
|
206
|
+
*
|
|
207
|
+
* const POSTS_SLUGS_QUERY = defineQuery(`
|
|
208
|
+
* *[_type == "post" && slug.current]{"slug": slug.current}
|
|
209
|
+
* `)
|
|
210
|
+
* const POST_QUERY = defineQuery(`
|
|
211
|
+
* *[_type == "post" && slug.current == $slug][0]
|
|
212
|
+
* `)
|
|
213
|
+
*
|
|
214
|
+
* export async function generateStaticParams() {
|
|
215
|
+
* const {data} = await sanityFetch({
|
|
216
|
+
* query: POSTS_SLUGS_QUERY,
|
|
217
|
+
* perspective: 'published',
|
|
218
|
+
* stega: false,
|
|
219
|
+
* })
|
|
220
|
+
*
|
|
221
|
+
* return data
|
|
222
|
+
* }
|
|
223
|
+
*
|
|
224
|
+
* export default async function Page(props: PageProps<'/[slug]'>) {
|
|
225
|
+
* const {slug} = await props.params
|
|
226
|
+
* const {data} = await sanityFetch({
|
|
227
|
+
* query: POST_QUERY,
|
|
228
|
+
* params: {slug},
|
|
229
|
+
* })
|
|
230
|
+
*
|
|
231
|
+
* return <pre>{JSON.stringify(data, null, 2)}</pre>
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
16
235
|
* @public
|
|
17
236
|
*/
|
|
18
237
|
declare function defineLive(config: DefineLiveOptions & {
|
|
@@ -21,6 +240,34 @@ declare function defineLive(config: DefineLiveOptions & {
|
|
|
21
240
|
sanityFetch: DefinedFetchType;
|
|
22
241
|
SanityLive: React.ComponentType<DefinedLiveProps>;
|
|
23
242
|
};
|
|
243
|
+
/**
|
|
244
|
+
* This helper is intended for use with Next.js Cache Components (`cacheComponents: true`),
|
|
245
|
+
* where `cookies()` and `draftMode()` cannot be called inside `'use cache'` boundaries.
|
|
246
|
+
* Resolve the perspective once outside the cache boundary and pass it in as a prop / cache key.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```tsx
|
|
250
|
+
* import {cookies, draftMode} from 'next/headers'
|
|
251
|
+
* import {resolvePerspectiveFromCookies, type LivePerspective} from 'next-sanity/live'
|
|
252
|
+
* import {sanityFetch} from '#sanity/live'
|
|
253
|
+
*
|
|
254
|
+
* function Page() {
|
|
255
|
+
* const {isEnabled: isDraftMode} = await draftMode()
|
|
256
|
+
* let perspective: LivePerspective = 'published'
|
|
257
|
+
* if(isDraftMode) {
|
|
258
|
+
* perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})
|
|
259
|
+
* }
|
|
260
|
+
* const {data} = await cachedFetch({query, perspective, stega: isDraftMode})
|
|
261
|
+
* }
|
|
262
|
+
* function cachedFetch({query, params, perspective, stega}: {query: string, perspective: LivePerspective, stega: boolean}) {}) {
|
|
263
|
+
* 'use cache'
|
|
264
|
+
* const {data} = await sanityFetch({query, params, perspective, stega})
|
|
265
|
+
* return {data}
|
|
266
|
+
* }
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
24
271
|
declare const resolvePerspectiveFromCookies: typeof resolvePerspectiveFromCookies$1;
|
|
25
|
-
export { type LivePerspective, defineLive, isCorsOriginError, parseTags, resolvePerspectiveFromCookies };
|
|
272
|
+
export { type DefineLiveOptions, type DefinedFetchType, type DefinedLiveProps, type LivePerspective, type SanityLiveAction, type SanityLiveActionContext, type SanityLiveOnError, type SanityLiveOnGoaway, type SanityLiveOnReconnect, type SanityLiveOnRestart, type SanityLiveOnWelcome, type StrictDefinedFetchType, type StrictDefinedLiveProps, defineLive, isCorsOriginError, parseTags, resolvePerspectiveFromCookies };
|
|
26
273
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/live/conditions/default/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/live/conditions/default/index.ts"],"mappings":";;;AAuKA;;;;;;;;;;;;;;;;;;;;AAkFA;;;;;;;;;;;;;;;;;;;;AAoCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAtHA,iBAAgB,UAAA,CAAW,MAAA,EAAQ,iBAAA;EAAqB,MAAA;AAAA;EACtD,WAAA,EAAa,sBAAA;EACb,UAAA,EAAY,KAAA,CAAM,aAAA,CAAc,sBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgFlB,UAAA,CAAW,MAAA,EAAQ,iBAAA;EAAqB,MAAA;AAAA;EACtD,WAAA,EAAa,gBAAA;EACb,UAAA,EAAY,KAAA,CAAM,aAAA,CAAc,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkCrB,6BAAA,SAAsC,+BAAA"}
|
|
@@ -1,15 +1,39 @@
|
|
|
1
1
|
import { t as isCorsOriginError } from "../../../isCorsOriginError.js";
|
|
2
2
|
import { t as parseTags } from "../../../parseTags.js";
|
|
3
|
-
/**
|
|
4
|
-
* Three
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
3
|
function defineLive(_config) {
|
|
8
4
|
throw new Error(`defineLive can't be imported by a client component`);
|
|
9
5
|
}
|
|
10
|
-
|
|
6
|
+
/**
|
|
7
|
+
* This helper is intended for use with Next.js Cache Components (`cacheComponents: true`),
|
|
8
|
+
* where `cookies()` and `draftMode()` cannot be called inside `'use cache'` boundaries.
|
|
9
|
+
* Resolve the perspective once outside the cache boundary and pass it in as a prop / cache key.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import {cookies, draftMode} from 'next/headers'
|
|
14
|
+
* import {resolvePerspectiveFromCookies, type LivePerspective} from 'next-sanity/live'
|
|
15
|
+
* import {sanityFetch} from '#sanity/live'
|
|
16
|
+
*
|
|
17
|
+
* function Page() {
|
|
18
|
+
* const {isEnabled: isDraftMode} = await draftMode()
|
|
19
|
+
* let perspective: LivePerspective = 'published'
|
|
20
|
+
* if(isDraftMode) {
|
|
21
|
+
* perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})
|
|
22
|
+
* }
|
|
23
|
+
* const {data} = await cachedFetch({query, perspective, stega: isDraftMode})
|
|
24
|
+
* }
|
|
25
|
+
* function cachedFetch({query, params, perspective, stega}: {query: string, perspective: LivePerspective, stega: boolean}) {}) {
|
|
26
|
+
* 'use cache'
|
|
27
|
+
* const {data} = await sanityFetch({query, params, perspective, stega})
|
|
28
|
+
* return {data}
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
const resolvePerspectiveFromCookies = () => {
|
|
11
35
|
throw new Error(`resolvePerspectiveFromCookies can't be imported by a client component`);
|
|
12
|
-
}
|
|
36
|
+
};
|
|
13
37
|
export { defineLive, isCorsOriginError, parseTags, resolvePerspectiveFromCookies };
|
|
14
38
|
|
|
15
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/live/conditions/default/index.ts"],"sourcesContent":["// This is the fallback export condition for `import 'next-sanity/live'`,\n// it should have the same type definitions as the other conditions so that userland don't have to worry about setting the right\n// `customCondition` in their `tsconfig.json` in order to get accurate typings.\n// The implementation here though should all throw errors, as importing this file means userland made a mistake and somehow a client component is\n// trying to pull in something it shouldn't.\n\nimport type {resolvePerspectiveFromCookies as _resolvePerspectiveFromCookies} from '#live/resolvePerspectiveFromCookies'\nimport type {\n DefinedFetchType,\n DefinedLiveProps,\n DefineLiveOptions,\n StrictDefinedFetchType,\n StrictDefinedLiveProps,\n} from '#live/types'\n\nexport {isCorsOriginError} from '#live/isCorsOriginError'\nexport {parseTags} from '#live/parseTags'\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/live/conditions/default/index.ts"],"sourcesContent":["// This is the fallback export condition for `import 'next-sanity/live'`,\n// it should have the same type definitions as the other conditions so that userland don't have to worry about setting the right\n// `customCondition` in their `tsconfig.json` in order to get accurate typings.\n// The implementation here though should all throw errors, as importing this file means userland made a mistake and somehow a client component is\n// trying to pull in something it shouldn't.\n\nimport type {resolvePerspectiveFromCookies as _resolvePerspectiveFromCookies} from '#live/resolvePerspectiveFromCookies'\nimport type {\n DefinedFetchType,\n DefinedLiveProps,\n DefineLiveOptions,\n StrictDefinedFetchType,\n StrictDefinedLiveProps,\n} from '#live/types'\n\nexport {isCorsOriginError} from '#live/isCorsOriginError'\nexport {parseTags} from '#live/parseTags'\n\n/**\n * Set up Sanity Live for Cache Components. `defineLive` returns `sanityFetch`\n * and `<SanityLive />`, which connect your Sanity client to the Live Content API\n * so cached pages can update in response to fine-grained content changes.\n *\n * With `strict: true`, `perspective` and `stega` become required\n * `sanityFetch` options, and `includeDrafts` becomes required on\n * `<SanityLive />`. Resolve dynamic values from `draftMode()` and `cookies()`\n * outside `'use cache'` boundaries, then pass them into cached components.\n *\n * @see [Live Content API](https://www.sanity.io/docs/content-lake/live-content-api)\n * @see [Sanity Live](https://www.sanity.io/live)\n *\n * @example\n * ```tsx\n * // sanity/live.ts\n * import {cookies, draftMode} from 'next/headers'\n * import {createClient} from 'next-sanity'\n * import {\n * defineLive,\n * resolvePerspectiveFromCookies,\n * type LivePerspective,\n * } from 'next-sanity/live'\n *\n * const client = createClient({\n * projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,\n * dataset: process.env.NEXT_PUBLIC_SANITY_DATASET,\n * useCdn: true,\n * perspective: 'published',\n * })\n * const token = process.env.SANITY_API_READ_TOKEN\n *\n * export const {sanityFetch, SanityLive} = defineLive({\n * client,\n * browserToken: token,\n * serverToken: token,\n * strict: true,\n * })\n *\n * export interface DynamicFetchOptions {\n * perspective: LivePerspective\n * stega: boolean\n * }\n *\n * // Resolve dynamic values outside 'use cache' boundaries.\n * export async function getDynamicFetchOptions(): Promise<DynamicFetchOptions> {\n * const {isEnabled: isDraftMode} = await draftMode()\n * if (!isDraftMode) {\n * return {perspective: 'published', stega: false}\n * }\n *\n * const jar = await cookies()\n * const perspective = await resolvePerspectiveFromCookies({cookies: jar})\n * return {perspective: perspective ?? 'drafts', stega: true}\n * }\n * ```\n *\n * @example\n * ```tsx\n * // app/layout.tsx\n * import {draftMode} from 'next/headers'\n *\n * import {SanityLive} from '@/sanity/live'\n *\n * export default async function RootLayout({children}: {children: React.ReactNode}) {\n * const {isEnabled: isDraftMode} = await draftMode()\n *\n * return (\n * <html lang=\"en\">\n * <body>\n * {children}\n * <SanityLive includeDrafts={isDraftMode} />\n * </body>\n * </html>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // app/[slug]/page.tsx\n * import {draftMode} from 'next/headers'\n * import {Suspense} from 'react'\n * import {defineQuery} from 'next-sanity'\n *\n * import {\n * getDynamicFetchOptions,\n * sanityFetch,\n * type DynamicFetchOptions,\n * } from '@/sanity/live'\n *\n * const POSTS_SLUGS_QUERY = defineQuery(`\n * *[_type == \"post\" && slug.current]{\"slug\": slug.current}\n * `)\n * const POST_QUERY = defineQuery(`\n * *[_type == \"post\" && slug.current == $slug][0]\n * `)\n *\n * export async function generateStaticParams() {\n * const {data} = await sanityFetch({\n * query: POSTS_SLUGS_QUERY,\n * perspective: 'published',\n * stega: false,\n * })\n *\n * return data\n * }\n *\n * export default async function Page(props: PageProps<'/[slug]'>) {\n * const {isEnabled: isDraftMode} = await draftMode()\n * if (isDraftMode) {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <DynamicPage params={props.params} />\n * </Suspense>\n * )\n * }\n *\n * const {slug} = await props.params\n * return <CachedPage slug={slug} perspective=\"published\" stega={false} />\n * }\n *\n * async function DynamicPage(props: Pick<PageProps<'/[slug]'>, 'params'>) {\n * const {slug} = await props.params\n * const {perspective, stega} = await getDynamicFetchOptions()\n *\n * return <CachedPage slug={slug} perspective={perspective} stega={stega} />\n * }\n *\n * async function CachedPage({\n * slug,\n * perspective,\n * stega,\n * }: {slug: string} & DynamicFetchOptions) {\n * 'use cache'\n *\n * const {data} = await sanityFetch({\n * query: POST_QUERY,\n * params: {slug},\n * perspective,\n * stega,\n * })\n *\n * return <pre>{JSON.stringify(data, null, 2)}</pre>\n * }\n * ```\n *\n * @public\n */\nexport function defineLive(config: DefineLiveOptions & {strict: true}): {\n sanityFetch: StrictDefinedFetchType\n SanityLive: React.ComponentType<StrictDefinedLiveProps>\n}\n/**\n * Set up Sanity Live. `defineLive` returns `sanityFetch` and `<SanityLive />`,\n * which connect your Sanity client to the Live Content API so pages can serve\n * cached content and update in response to fine-grained content changes.\n *\n * @see [Live Content API](https://www.sanity.io/docs/content-lake/live-content-api)\n * @see [Sanity Live](https://www.sanity.io/live)\n *\n * @example\n * ```tsx\n * import {createClient} from 'next-sanity'\n * import {defineLive} from 'next-sanity/live'\n *\n * const client = createClient({\n * projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,\n * dataset: process.env.NEXT_PUBLIC_SANITY_DATASET,\n * useCdn: true,\n * perspective: 'published',\n * })\n *\n * export const {sanityFetch, SanityLive} = defineLive({\n * client,\n * })\n * ```\n *\n * @example\n * ```tsx\n * // app/layout.tsx\n * import {SanityLive} from '@/sanity/live'\n *\n * export default function RootLayout({children}: {children: React.ReactNode}) {\n * return (\n * <html lang=\"en\">\n * <body>\n * {children}\n * <SanityLive />\n * </body>\n * </html>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // app/[slug]/page.tsx\n * import {defineQuery} from 'next-sanity'\n * import {sanityFetch} from '@/sanity/live'\n *\n * const POSTS_SLUGS_QUERY = defineQuery(`\n * *[_type == \"post\" && slug.current]{\"slug\": slug.current}\n * `)\n * const POST_QUERY = defineQuery(`\n * *[_type == \"post\" && slug.current == $slug][0]\n * `)\n *\n * export async function generateStaticParams() {\n * const {data} = await sanityFetch({\n * query: POSTS_SLUGS_QUERY,\n * perspective: 'published',\n * stega: false,\n * })\n *\n * return data\n * }\n *\n * export default async function Page(props: PageProps<'/[slug]'>) {\n * const {slug} = await props.params\n * const {data} = await sanityFetch({\n * query: POST_QUERY,\n * params: {slug},\n * })\n *\n * return <pre>{JSON.stringify(data, null, 2)}</pre>\n * }\n * ```\n *\n * @public\n */\nexport function defineLive(config: DefineLiveOptions & {strict?: false}): {\n sanityFetch: DefinedFetchType\n SanityLive: React.ComponentType<DefinedLiveProps>\n}\nexport function defineLive(_config: DefineLiveOptions): never {\n throw new Error(`defineLive can't be imported by a client component`)\n}\n\n/**\n * This helper is intended for use with Next.js Cache Components (`cacheComponents: true`),\n * where `cookies()` and `draftMode()` cannot be called inside `'use cache'` boundaries.\n * Resolve the perspective once outside the cache boundary and pass it in as a prop / cache key.\n *\n * @example\n * ```tsx\n * import {cookies, draftMode} from 'next/headers'\n * import {resolvePerspectiveFromCookies, type LivePerspective} from 'next-sanity/live'\n * import {sanityFetch} from '#sanity/live'\n *\n * function Page() {\n * const {isEnabled: isDraftMode} = await draftMode()\n * let perspective: LivePerspective = 'published'\n * if(isDraftMode) {\n * perspective = await resolvePerspectiveFromCookies({cookies: await cookies()})\n * }\n * const {data} = await cachedFetch({query, perspective, stega: isDraftMode})\n * }\n * function cachedFetch({query, params, perspective, stega}: {query: string, perspective: LivePerspective, stega: boolean}) {}) {\n * 'use cache'\n * const {data} = await sanityFetch({query, params, perspective, stega})\n * return {data}\n * }\n * ```\n *\n * @public\n */\nexport const resolvePerspectiveFromCookies: typeof _resolvePerspectiveFromCookies = () => {\n throw new Error(`resolvePerspectiveFromCookies can't be imported by a client component`)\n}\n\nexport type {\n DefinedFetchType,\n DefinedLiveProps,\n DefineLiveOptions,\n LivePerspective,\n SanityLiveAction,\n SanityLiveActionContext,\n SanityLiveOnError,\n SanityLiveOnGoaway,\n SanityLiveOnReconnect,\n SanityLiveOnRestart,\n SanityLiveOnWelcome,\n StrictDefinedFetchType,\n StrictDefinedLiveProps,\n} from '#live/types'\n"],"mappings":";;AA6PA,SAAgB,WAAW,SAAmC;AAC5D,OAAM,IAAI,MAAM,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BvE,MAAa,sCAA6E;AACxF,OAAM,IAAI,MAAM,wEAAwE"}
|
|
@@ -1,17 +1,244 @@
|
|
|
1
1
|
import { t as isCorsOriginError } from "../../../isCorsOriginError.js";
|
|
2
|
-
import { d as
|
|
2
|
+
import { a as SanityLiveAction, c as SanityLiveOnGoaway, d as SanityLiveOnWelcome, f as StrictDefinedFetchType, i as LivePerspective, l as SanityLiveOnReconnect, n as DefinedFetchType, o as SanityLiveActionContext, p as StrictDefinedLiveProps, r as DefinedLiveProps, s as SanityLiveOnError, t as DefineLiveOptions, u as SanityLiveOnRestart } from "../../../types.js";
|
|
3
3
|
import { n as resolvePerspectiveFromCookies, t as parseTags } from "../../../parseTags.js";
|
|
4
|
+
/**
|
|
5
|
+
* Set up Sanity Live for Cache Components. `defineLive` returns `sanityFetch`
|
|
6
|
+
* and `<SanityLive />`, which connect your Sanity client to the Live Content API
|
|
7
|
+
* so cached pages can update in response to fine-grained content changes.
|
|
8
|
+
*
|
|
9
|
+
* With `strict: true`, `perspective` and `stega` become required
|
|
10
|
+
* `sanityFetch` options, and `includeDrafts` becomes required on
|
|
11
|
+
* `<SanityLive />`. Resolve dynamic values from `draftMode()` and `cookies()`
|
|
12
|
+
* outside `'use cache'` boundaries, then pass them into cached components.
|
|
13
|
+
*
|
|
14
|
+
* @see [Live Content API](https://www.sanity.io/docs/content-lake/live-content-api)
|
|
15
|
+
* @see [Sanity Live](https://www.sanity.io/live)
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // sanity/live.ts
|
|
20
|
+
* import {cookies, draftMode} from 'next/headers'
|
|
21
|
+
* import {createClient} from 'next-sanity'
|
|
22
|
+
* import {
|
|
23
|
+
* defineLive,
|
|
24
|
+
* resolvePerspectiveFromCookies,
|
|
25
|
+
* type LivePerspective,
|
|
26
|
+
* } from 'next-sanity/live'
|
|
27
|
+
*
|
|
28
|
+
* const client = createClient({
|
|
29
|
+
* projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
|
|
30
|
+
* dataset: process.env.NEXT_PUBLIC_SANITY_DATASET,
|
|
31
|
+
* useCdn: true,
|
|
32
|
+
* perspective: 'published',
|
|
33
|
+
* })
|
|
34
|
+
* const token = process.env.SANITY_API_READ_TOKEN
|
|
35
|
+
*
|
|
36
|
+
* export const {sanityFetch, SanityLive} = defineLive({
|
|
37
|
+
* client,
|
|
38
|
+
* browserToken: token,
|
|
39
|
+
* serverToken: token,
|
|
40
|
+
* strict: true,
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* export interface DynamicFetchOptions {
|
|
44
|
+
* perspective: LivePerspective
|
|
45
|
+
* stega: boolean
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* // Resolve dynamic values outside 'use cache' boundaries.
|
|
49
|
+
* export async function getDynamicFetchOptions(): Promise<DynamicFetchOptions> {
|
|
50
|
+
* const {isEnabled: isDraftMode} = await draftMode()
|
|
51
|
+
* if (!isDraftMode) {
|
|
52
|
+
* return {perspective: 'published', stega: false}
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* const jar = await cookies()
|
|
56
|
+
* const perspective = await resolvePerspectiveFromCookies({cookies: jar})
|
|
57
|
+
* return {perspective: perspective ?? 'drafts', stega: true}
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* // app/layout.tsx
|
|
64
|
+
* import {draftMode} from 'next/headers'
|
|
65
|
+
*
|
|
66
|
+
* import {SanityLive} from '@/sanity/live'
|
|
67
|
+
*
|
|
68
|
+
* export default async function RootLayout({children}: {children: React.ReactNode}) {
|
|
69
|
+
* const {isEnabled: isDraftMode} = await draftMode()
|
|
70
|
+
*
|
|
71
|
+
* return (
|
|
72
|
+
* <html lang="en">
|
|
73
|
+
* <body>
|
|
74
|
+
* {children}
|
|
75
|
+
* <SanityLive includeDrafts={isDraftMode} />
|
|
76
|
+
* </body>
|
|
77
|
+
* </html>
|
|
78
|
+
* )
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* // app/[slug]/page.tsx
|
|
85
|
+
* import {draftMode} from 'next/headers'
|
|
86
|
+
* import {Suspense} from 'react'
|
|
87
|
+
* import {defineQuery} from 'next-sanity'
|
|
88
|
+
*
|
|
89
|
+
* import {
|
|
90
|
+
* getDynamicFetchOptions,
|
|
91
|
+
* sanityFetch,
|
|
92
|
+
* type DynamicFetchOptions,
|
|
93
|
+
* } from '@/sanity/live'
|
|
94
|
+
*
|
|
95
|
+
* const POSTS_SLUGS_QUERY = defineQuery(`
|
|
96
|
+
* *[_type == "post" && slug.current]{"slug": slug.current}
|
|
97
|
+
* `)
|
|
98
|
+
* const POST_QUERY = defineQuery(`
|
|
99
|
+
* *[_type == "post" && slug.current == $slug][0]
|
|
100
|
+
* `)
|
|
101
|
+
*
|
|
102
|
+
* export async function generateStaticParams() {
|
|
103
|
+
* const {data} = await sanityFetch({
|
|
104
|
+
* query: POSTS_SLUGS_QUERY,
|
|
105
|
+
* perspective: 'published',
|
|
106
|
+
* stega: false,
|
|
107
|
+
* })
|
|
108
|
+
*
|
|
109
|
+
* return data
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* export default async function Page(props: PageProps<'/[slug]'>) {
|
|
113
|
+
* const {isEnabled: isDraftMode} = await draftMode()
|
|
114
|
+
* if (isDraftMode) {
|
|
115
|
+
* return (
|
|
116
|
+
* <Suspense fallback={<div>Loading...</div>}>
|
|
117
|
+
* <DynamicPage params={props.params} />
|
|
118
|
+
* </Suspense>
|
|
119
|
+
* )
|
|
120
|
+
* }
|
|
121
|
+
*
|
|
122
|
+
* const {slug} = await props.params
|
|
123
|
+
* return <CachedPage slug={slug} perspective="published" stega={false} />
|
|
124
|
+
* }
|
|
125
|
+
*
|
|
126
|
+
* async function DynamicPage(props: Pick<PageProps<'/[slug]'>, 'params'>) {
|
|
127
|
+
* const {slug} = await props.params
|
|
128
|
+
* const {perspective, stega} = await getDynamicFetchOptions()
|
|
129
|
+
*
|
|
130
|
+
* return <CachedPage slug={slug} perspective={perspective} stega={stega} />
|
|
131
|
+
* }
|
|
132
|
+
*
|
|
133
|
+
* async function CachedPage({
|
|
134
|
+
* slug,
|
|
135
|
+
* perspective,
|
|
136
|
+
* stega,
|
|
137
|
+
* }: {slug: string} & DynamicFetchOptions) {
|
|
138
|
+
* 'use cache'
|
|
139
|
+
*
|
|
140
|
+
* const {data} = await sanityFetch({
|
|
141
|
+
* query: POST_QUERY,
|
|
142
|
+
* params: {slug},
|
|
143
|
+
* perspective,
|
|
144
|
+
* stega,
|
|
145
|
+
* })
|
|
146
|
+
*
|
|
147
|
+
* return <pre>{JSON.stringify(data, null, 2)}</pre>
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
4
153
|
declare function defineLive(config: DefineLiveOptions & {
|
|
5
154
|
strict: true;
|
|
6
155
|
}): {
|
|
7
156
|
sanityFetch: StrictDefinedFetchType;
|
|
8
157
|
SanityLive: React.ComponentType<StrictDefinedLiveProps>;
|
|
9
158
|
};
|
|
159
|
+
/**
|
|
160
|
+
* Set up Sanity Live. `defineLive` returns `sanityFetch` and `<SanityLive />`,
|
|
161
|
+
* which connect your Sanity client to the Live Content API so pages can serve
|
|
162
|
+
* cached content and update in response to fine-grained content changes.
|
|
163
|
+
*
|
|
164
|
+
* @see [Live Content API](https://www.sanity.io/docs/content-lake/live-content-api)
|
|
165
|
+
* @see [Sanity Live](https://www.sanity.io/live)
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```tsx
|
|
169
|
+
* import {createClient} from 'next-sanity'
|
|
170
|
+
* import {defineLive} from 'next-sanity/live'
|
|
171
|
+
*
|
|
172
|
+
* const client = createClient({
|
|
173
|
+
* projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
|
|
174
|
+
* dataset: process.env.NEXT_PUBLIC_SANITY_DATASET,
|
|
175
|
+
* useCdn: true,
|
|
176
|
+
* perspective: 'published',
|
|
177
|
+
* })
|
|
178
|
+
*
|
|
179
|
+
* export const {sanityFetch, SanityLive} = defineLive({
|
|
180
|
+
* client,
|
|
181
|
+
* })
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```tsx
|
|
186
|
+
* // app/layout.tsx
|
|
187
|
+
* import {SanityLive} from '@/sanity/live'
|
|
188
|
+
*
|
|
189
|
+
* export default function RootLayout({children}: {children: React.ReactNode}) {
|
|
190
|
+
* return (
|
|
191
|
+
* <html lang="en">
|
|
192
|
+
* <body>
|
|
193
|
+
* {children}
|
|
194
|
+
* <SanityLive />
|
|
195
|
+
* </body>
|
|
196
|
+
* </html>
|
|
197
|
+
* )
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```tsx
|
|
203
|
+
* // app/[slug]/page.tsx
|
|
204
|
+
* import {defineQuery} from 'next-sanity'
|
|
205
|
+
* import {sanityFetch} from '@/sanity/live'
|
|
206
|
+
*
|
|
207
|
+
* const POSTS_SLUGS_QUERY = defineQuery(`
|
|
208
|
+
* *[_type == "post" && slug.current]{"slug": slug.current}
|
|
209
|
+
* `)
|
|
210
|
+
* const POST_QUERY = defineQuery(`
|
|
211
|
+
* *[_type == "post" && slug.current == $slug][0]
|
|
212
|
+
* `)
|
|
213
|
+
*
|
|
214
|
+
* export async function generateStaticParams() {
|
|
215
|
+
* const {data} = await sanityFetch({
|
|
216
|
+
* query: POSTS_SLUGS_QUERY,
|
|
217
|
+
* perspective: 'published',
|
|
218
|
+
* stega: false,
|
|
219
|
+
* })
|
|
220
|
+
*
|
|
221
|
+
* return data
|
|
222
|
+
* }
|
|
223
|
+
*
|
|
224
|
+
* export default async function Page(props: PageProps<'/[slug]'>) {
|
|
225
|
+
* const {slug} = await props.params
|
|
226
|
+
* const {data} = await sanityFetch({
|
|
227
|
+
* query: POST_QUERY,
|
|
228
|
+
* params: {slug},
|
|
229
|
+
* })
|
|
230
|
+
*
|
|
231
|
+
* return <pre>{JSON.stringify(data, null, 2)}</pre>
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
10
237
|
declare function defineLive(config: DefineLiveOptions & {
|
|
11
238
|
strict?: false;
|
|
12
239
|
}): {
|
|
13
240
|
sanityFetch: DefinedFetchType;
|
|
14
241
|
SanityLive: React.ComponentType<DefinedLiveProps>;
|
|
15
242
|
};
|
|
16
|
-
export { type LivePerspective, defineLive, isCorsOriginError, parseTags, resolvePerspectiveFromCookies };
|
|
243
|
+
export { type DefineLiveOptions, type DefinedFetchType, type DefinedLiveProps, type LivePerspective, type SanityLiveAction, type SanityLiveActionContext, type SanityLiveOnError, type SanityLiveOnGoaway, type SanityLiveOnReconnect, type SanityLiveOnRestart, type SanityLiveOnWelcome, type StrictDefinedFetchType, type StrictDefinedLiveProps, defineLive, isCorsOriginError, parseTags, resolvePerspectiveFromCookies };
|
|
17
244
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/live/conditions/next-js/defineLive.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/live/conditions/next-js/defineLive.tsx"],"mappings":";;;;;;AAqKA;;;;;;;;;;;;;;;;;;;;AAkFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAlFgB,UAAA,CAAW,MAAA,EAAQ,iBAAA;EAAqB,MAAA;AAAA;EACtD,WAAA,EAAa,sBAAA;EACb,UAAA,EAAY,KAAA,CAAM,aAAA,CAAc,sBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgFlB,UAAA,CAAW,MAAA,EAAQ,iBAAA;EAAqB,MAAA;AAAA;EACtD,WAAA,EAAa,gBAAA;EACb,UAAA,EAAY,KAAA,CAAM,aAAA,CAAc,gBAAA;AAAA"}
|
|
@@ -4,7 +4,7 @@ import { n as validateStrictFetchOptions, r as validateStrictSanityLiveProps, t
|
|
|
4
4
|
import { t as parseTags } from "../../../parseTags.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { SanityLive } from "next-sanity/live/client-components";
|
|
7
|
-
import {
|
|
7
|
+
import { refreshAction, revalidateSyncTagsAction } from "next-sanity/live/server-actions";
|
|
8
8
|
import { cacheLife, cacheTag } from "next/cache";
|
|
9
9
|
import { PHASE_PRODUCTION_BUILD } from "next/constants";
|
|
10
10
|
import { preconnect } from "react-dom";
|
|
@@ -57,7 +57,7 @@ function defineLive(config) {
|
|
|
57
57
|
};
|
|
58
58
|
const SanityLive$2 = function SanityLive$1(props) {
|
|
59
59
|
if (strict) validateStrictSanityLiveProps(props);
|
|
60
|
-
const { includeDrafts = false, action =
|
|
60
|
+
const { includeDrafts = false, action = revalidateSyncTagsAction, onReconnect = refreshAction, onRestart = refreshAction, onWelcome, onError, onGoAway, refreshOnMount = false, refreshOnFocus = false, refreshOnReconnect = false, requestTag = "next-loader.live.cache-components" } = props;
|
|
61
61
|
const shouldIncludeDrafts = typeof browserToken === "string" && includeDrafts;
|
|
62
62
|
const { projectId, dataset, apiHost, apiVersion, useProjectHostname, requestTagPrefix } = client.config();
|
|
63
63
|
const { origin } = new URL(client.getUrl("", false));
|