next-sanity 13.0.0-cache-components.42 → 13.0.0-cache-components.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/SanityLive.js +5 -3
  2. package/dist/SanityLive.js.map +1 -1
  3. package/dist/isCorsOriginError.js.map +1 -1
  4. package/dist/live/client-components/index.d.ts +7 -8
  5. package/dist/live/client-components/index.d.ts.map +1 -1
  6. package/dist/live/client-components/index.js +1 -1
  7. package/dist/live/client-components/index.js.map +1 -1
  8. package/dist/live/conditions/default/index.d.ts +226 -4
  9. package/dist/live/conditions/default/index.d.ts.map +1 -1
  10. package/dist/live/conditions/default/index.js +0 -4
  11. package/dist/live/conditions/default/index.js.map +1 -1
  12. package/dist/live/conditions/next-js/index.d.ts +232 -2
  13. package/dist/live/conditions/next-js/index.d.ts.map +1 -1
  14. package/dist/live/conditions/next-js/index.js +2 -1
  15. package/dist/live/conditions/next-js/index.js.map +1 -1
  16. package/dist/live/conditions/react-server/index.d.ts +232 -2
  17. package/dist/live/conditions/react-server/index.d.ts.map +1 -1
  18. package/dist/live/conditions/react-server/index.js +2 -1
  19. package/dist/live/conditions/react-server/index.js.map +1 -1
  20. package/dist/live/server-actions/{index.default.d.ts → index.d.ts} +1 -1
  21. package/dist/live/server-actions/index.d.ts.map +1 -0
  22. package/dist/live/server-actions/{index.next-js.js → index.js} +1 -1
  23. package/dist/live/server-actions/index.js.map +1 -0
  24. package/dist/types.d.ts +155 -77
  25. package/dist/types.d.ts.map +1 -1
  26. package/package.json +4 -10
  27. package/dist/live/server-actions/index.default.d.ts.map +0 -1
  28. package/dist/live/server-actions/index.default.js +0 -27
  29. package/dist/live/server-actions/index.default.js.map +0 -1
  30. package/dist/live/server-actions/index.next-js.d.ts +0 -11
  31. package/dist/live/server-actions/index.next-js.d.ts.map +0 -1
  32. package/dist/live/server-actions/index.next-js.js.map +0 -1
@@ -8,4 +8,4 @@ declare function revalidateSyncTagsAction(unsafeTags: unknown): Promise<void>;
8
8
  */
9
9
  declare function refreshAction(): Promise<void>;
10
10
  export { refreshAction, revalidateSyncTagsAction };
11
- //# sourceMappingURL=index.default.d.ts.map
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/live/server-actions/index.ts"],"mappings":"AAUA;;;AAAA,iBAAsB,wBAAA,CAAyB,UAAA,YAAsB,OAAA;;AAyBrE;;;iBAAsB,aAAA,CAAA,GAAiB,OAAA"}
@@ -24,4 +24,4 @@ async function refreshAction() {
24
24
  }
25
25
  export { refreshAction, revalidateSyncTagsAction };
26
26
 
27
- //# sourceMappingURL=index.next-js.js.map
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/live/server-actions/index.ts"],"sourcesContent":["'use server'\n\nimport {refresh, revalidateTag} from 'next/cache'\nimport {draftMode} from 'next/headers'\n\nimport {parseTags} from '#live/parseTags'\n\n/**\n * @alpha CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.\n */\nexport async function revalidateSyncTagsAction(unsafeTags: unknown): Promise<void> {\n const {tags, prefixType} = parseTags(unsafeTags)\n if ((await draftMode()).isEnabled) {\n console.warn(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> action called in draft mode, cache is bypassed in draft mode so the refresh() function is called instead of updateTag()`,\n {tags},\n )\n refresh()\n return undefined\n }\n\n for (const tag of tags) {\n revalidateTag(tag, 'max')\n }\n\n // oxlint-disable-next-line no-console\n console.log(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> revalidated tags: ${tags.join(', ')} with cache profile \"max\" `,\n )\n}\n\n/**\n * Used by `<SanityLive onReconnect={refreshAction} onRestart={refreshAction} />`\n * @deprecated - refactor `onReconnect` and `onRestart` to support `() => 'refresh'`\n */\nexport async function refreshAction(): Promise<void> {\n refresh()\n}\n"],"mappings":";;;;;;;AAUA,eAAsB,yBAAyB,YAAoC;CACjF,MAAM,EAAC,MAAM,eAAc,UAAU,WAAW;AAChD,MAAK,MAAM,WAAW,EAAE,WAAW;AACjC,UAAQ,KACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,6HAC/D,EAAC,MAAK,CACP;AACD,WAAS;AACT;;AAGF,MAAK,MAAM,OAAO,KAChB,eAAc,KAAK,MAAM;AAI3B,SAAQ,IACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,uBAAuB,KAAK,KAAK,KAAK,CAAC,4BACvG;;;;;;AAOH,eAAsB,gBAA+B;AACnD,UAAS"}
package/dist/types.d.ts CHANGED
@@ -1,33 +1,51 @@
1
- import { ClientPerspective, ClientReturn, ContentSourceMap, LiveEvent, QueryParams, SanityClient } from "next-sanity";
1
+ import { ClientPerspective, ClientReturn, ContentSourceMap, InitializedClientConfig, LiveEvent, QueryParams, SanityClient } from "next-sanity";
2
2
  /**
3
3
  * Perspectives supported by Sanity Live.
4
4
  * Using the legacy `'raw'` perspective is not supported and leads to undefined behavior.
5
5
  */
6
6
  type LivePerspective = Exclude<ClientPerspective, "raw">;
7
7
  /**
8
- * TODO: docs
8
+ * Fetches data through the configured Sanity client and returns the result
9
+ * together with the source map and cache tags that Sanity Live uses for
10
+ * targeted revalidation.
11
+ *
12
+ * Returned by `defineLive({strict: false})` and `defineLive({strict: undefined})`.
9
13
  */
10
14
  type DefinedFetchType = <const QueryString extends string>(options: {
15
+ /**
16
+ * GROQ query to execute.
17
+ */
11
18
  query: QueryString;
19
+ /**
20
+ * Parameters used by the GROQ query.
21
+ */
12
22
  params?: QueryParams | Promise<QueryParams>;
13
23
  /**
14
- * @defaultValue 'published'
24
+ * Content perspective used for the fetch.
25
+ *
26
+ * @defaultValue The configured client perspective, usually `'published'`.
15
27
  */
16
28
  perspective?: LivePerspective;
17
29
  /**
18
- * Enables stega encoding of the data, this is typically only used in draft mode in conjunction with `perspective: 'drafts'` and with `@sanity/visual-editing` setup.
30
+ * Enables stega encoding of the data. This is typically only used in draft
31
+ * mode with `perspective: 'drafts'` and `@sanity/visual-editing`.
32
+ *
19
33
  * @defaultValue `false`
20
34
  */
21
35
  stega?: boolean;
22
36
  /**
23
- * Custom cache tags that can be used with next's `updateTag` functions for custom `read-your-write` server actions,
24
- * for example a like button that uses client.mutate to update a document and then immediately shows the result.
37
+ * Additional cache tags to associate with this fetch.
38
+ *
39
+ * `sanityFetch` automatically adds Sanity Live sync tags for the query. Use
40
+ * this for custom tags that should also be invalidated by your own server
41
+ * actions, for example after a mutation that needs read-your-own-write UI.
25
42
  */
26
43
  tags?: string[];
27
44
  /**
28
- * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.
45
+ * Request tag used to identify the request in Sanity Content Lake logs.
46
+ *
29
47
  * @see https://www.sanity.io/docs/reference-api-request-tags
30
- * @defaultValue 'next-loader.fetch'
48
+ * @defaultValue `'next-loader.fetch'` or `'next-loader.fetch.cache-components'`
31
49
  */
32
50
  requestTag?: string;
33
51
  }) => Promise<{
@@ -35,126 +53,121 @@ type DefinedFetchType = <const QueryString extends string>(options: {
35
53
  sourceMap: ContentSourceMap | null;
36
54
  tags: string[];
37
55
  }>;
38
- /**
39
- * TODO: docs
40
- */
41
- interface SanityLiveActionContext {
42
- includeDrafts: boolean;
43
- }
44
- /**
45
- * TODO: docs
46
- * Has a default implementation tailed the nextjs env and config
47
- */
48
- type SanityLiveAction = (unsafeTags: unknown) => Promise<void | "refresh">;
49
- /**
50
- * TODO: docs
51
- * If not defined it'll throw the error during render instead, which will crash the react app
52
- * unless there's an <ErrorBoundary> surrounding the <SanityLive> component
53
- */
54
- type SanityLiveOnError = (event: unknown, context: SanityLiveActionContext) => void | Promise<void>;
55
- /**
56
- * TODO: docs
57
- * Optional, logs console.info by default
58
- */
59
- type SanityLiveOnWelcome = (event: Extract<LiveEvent, {
60
- type: "welcome";
61
- }>, context: SanityLiveActionContext) => void | Promise<void>;
62
- /**
63
- * TODO: docs
64
- */
65
- type SanityLiveOnReconnect = (event: Extract<LiveEvent, {
66
- type: "reconnect";
67
- }>, context: SanityLiveActionContext) => void | Promise<void>;
68
- /**
69
- * TODO: docs
70
- */
71
- type SanityLiveOnRestart = (event: Extract<LiveEvent, {
72
- type: "restart";
73
- }>, context: SanityLiveActionContext) => void | Promise<void>;
74
- /**
75
- * TODO: docs
76
- * This event is fired when the API has hit the limit of concurrent connections, and the API will not deliver live events, in this case long polling intervals is a possible fallback strategy.
77
- * By default a message will be logged to the console, that creates a refresh interval of 30 seconds.
78
- * If you set your own event handler make sure you call `setPollingInterval` if you want to activate long-polling, otherwise content goes stale.
79
- */
80
- type SanityLiveOnGoaway = (event: Extract<LiveEvent, {
81
- type: "goaway";
82
- }>, context: SanityLiveActionContext, setPollingInterval: (interval: number) => void) => void | Promise<void>;
83
56
  interface DefinedLiveProps {
84
57
  /**
85
- * TODO: docs, settings this to `true` enables live events for draft content and requires `browserToken` to be set.
58
+ * Include draft and content release version events in the live connection.
59
+ *
60
+ * Set this to `true` when draft mode is enabled. A `browserToken` must be
61
+ * configured in `defineLive()` for draft events to be included.
62
+ *
63
+ * @defaultValue `false`
86
64
  */
87
65
  includeDrafts?: boolean;
88
66
  /**
89
- * TODO: docs
67
+ * Delays events until after a configured Sanity Function has processed them and called the callback endpoint.
68
+ * When omitted, events are delivered immediately.
69
+ *
70
+ * @remarks
71
+ * When set, any custom `revalidateSyncTags` will not be called — revalidation is handled by the Function instead.
72
+ */
73
+ waitFor?: "function";
74
+ /**
75
+ * Server action called for each content-change message from the Live Content
76
+ * API.
77
+ *
78
+ * The default action revalidates the cache tags produced by `sanityFetch`.
90
79
  */
91
80
  action?: SanityLiveAction;
92
81
  /**
93
- * TODO: docs
82
+ * Custom error handler. Pass `false` to disable custom handling and throw
83
+ * errors to the nearest React error boundary.
94
84
  */
95
85
  onError?: SanityLiveOnError | false;
96
86
  /**
97
- * TODO: docs
87
+ * Custom handler for the `welcome` event. Pass `false` to disable the default
88
+ * connection log.
98
89
  */
99
90
  onWelcome?: SanityLiveOnWelcome | false;
100
91
  /**
101
- * TODO: docs
92
+ * Custom handler for the `reconnect` event. Pass `false` to disable the
93
+ * default refresh behavior.
102
94
  */
103
95
  onReconnect?: SanityLiveOnReconnect | false;
104
96
  /**
105
- * TODO: docs
97
+ * Custom handler for the `restart` event. Pass `false` to disable the default
98
+ * refresh behavior.
106
99
  */
107
100
  onRestart?: SanityLiveOnRestart | false;
108
101
  /**
109
- *
102
+ * Custom handler for the `goaway` event. Pass `false` to disable the default
103
+ * long-polling fallback.
110
104
  */
111
105
  onGoAway?: SanityLiveOnGoaway | false;
112
106
  /**
113
- * Automatic refresh of RSC when the component <SanityLive /> is mounted.
107
+ * Refresh Server Components once when `<SanityLive />` mounts.
108
+ *
109
+ * This can close the gap between the initial server render and the browser
110
+ * establishing the live EventSource connection.
111
+ *
114
112
  * @defaultValue `false`
115
113
  */
116
114
  refreshOnMount?: boolean;
117
115
  /**
118
- * Automatically refresh when window gets focused
116
+ * Refresh Server Components when the page becomes visible or the window
117
+ * regains focus.
118
+ *
119
119
  * @defaultValue `false`
120
120
  */
121
121
  refreshOnFocus?: boolean;
122
122
  /**
123
- * Automatically refresh when the browser regains a network connection (via navigator.onLine)
124
- * @defaultValue `false`
123
+ * Refresh Server Components when the browser regains a network connection.
125
124
  */
126
125
  refreshOnReconnect?: boolean;
127
126
  /**
128
- * This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.
127
+ * Request tag used to identify the live EventSource request in Sanity Content
128
+ * Lake logs.
129
+ *
129
130
  * @see https://www.sanity.io/docs/reference-api-request-tags
130
- * @defaultValue 'next-loader.live'|'next-loader.live.cache-components'
131
+ * @defaultValue `'next-loader.live'` or `'next-loader.live.cache-components'`
131
132
  */
132
133
  requestTag?: string;
133
134
  }
134
135
  interface DefineLiveOptions {
135
136
  /**
136
- * Required for `fetch()` and `<Live>` to work
137
+ * Sanity client used by `sanityFetch()` and `<SanityLive />`.
137
138
  */
138
139
  client: SanityClient;
139
140
  /**
140
- * Optional. If provided then the token needs to have permissions to query documents with `drafts.` prefixes in order for `perspective: 'drafts'` to work.
141
- * This token is never shared with the browser, unless you reuse it in `browserToken`..
141
+ * Token used by the server to query drafts and content release versions.
142
+ *
143
+ * This token is never shared with the browser unless you also pass it as
144
+ * `browserToken`.
142
145
  */
143
146
  serverToken?: string | false;
144
147
  /**
145
- * Optional. This token is shared with the browser when `<Live>` is given a `perspective` prop other than `"published"`, and should only have access to query published documents.
146
- * It is used to setup a `Live Draft Content` EventSource connection, and enables live previewing drafts stand-alone, outside of Presentation Tool.
148
+ * Token shared with the browser when `<SanityLive includeDrafts />` opens a
149
+ * draft-capable live connection.
150
+ *
151
+ * Use a browser-safe token with the minimum read permissions needed for live
152
+ * previewing drafts outside Presentation Tool.
147
153
  */
148
154
  browserToken?: string | false;
149
155
  /**
150
- * Optional. Include stega encoding when draft mode is enabled.
151
- * @deprecated This option is deprecated, as it does not have an effect when `cacheComponents: true`
152
- * @defaultValue `true`
156
+ * Include stega encoding automatically when draft mode is enabled.
157
+ *
158
+ * @deprecated This option does not affect the `next-js` export condition used
159
+ * with `cacheComponents: true`. Pass `stega` to `sanityFetch()` instead.
160
+ * @defaultValue `true`
153
161
  */
154
162
  stega?: boolean;
155
163
  /**
156
- * When `true`, requires explicit `includeDrafts` on `<SanityLive>` and explicit `perspective`/`stega` on `sanityFetch`.
157
- * Use this to prepare for migrating to `cacheComponents: true` while still using `cacheComponents: false`.
164
+ * Require explicit live-content options at every call site.
165
+ *
166
+ * When `true`, `includeDrafts` is required on `<SanityLive />` and
167
+ * `perspective`/`stega` are required on `sanityFetch()`. This matches the
168
+ * explicit data flow needed inside Cache Components, where `draftMode()` and
169
+ * `cookies()` must be resolved outside `'use cache'` boundaries.
170
+ *
158
171
  * @defaultValue `false`
159
172
  */
160
173
  strict?: boolean;
@@ -182,5 +195,70 @@ type StrictDefinedFetchType = <const QueryString extends string>(options: {
182
195
  sourceMap: ContentSourceMap | null;
183
196
  tags: string[];
184
197
  }>;
185
- export { SanityLiveAction as a, SanityLiveOnReconnect as c, StrictDefinedFetchType as d, StrictDefinedLiveProps as f, LivePerspective as i, SanityLiveOnRestart as l, DefinedFetchType as n, SanityLiveOnError as o, DefinedLiveProps as r, SanityLiveOnGoaway as s, DefineLiveOptions as t, SanityLiveOnWelcome as u };
198
+ interface SanityClientConfig extends Pick<InitializedClientConfig, "projectId" | "dataset" | "apiHost" | "apiVersion" | "useProjectHostname" | "token" | "requestTagPrefix"> {}
199
+ /**
200
+ * Context passed to Sanity Live event handlers.
201
+ */
202
+ interface SanityLiveActionContext {
203
+ /**
204
+ * Whether the current `<SanityLive />` connection includes draft and content
205
+ * release version events.
206
+ */
207
+ includeDrafts: boolean;
208
+ }
209
+ /**
210
+ * Server action invoked when Sanity Live receives a content-change message.
211
+ *
212
+ * The argument is the list of cache tags derived from the Live Content API
213
+ * event. The default action revalidates those tags. Return `'refresh'` from a
214
+ * custom action to also call `router.refresh()` in the browser.
215
+ */
216
+ type SanityLiveAction = (unsafeTags: unknown) => Promise<void | "refresh">;
217
+ /**
218
+ * Handles connection, parsing, and event-processing errors.
219
+ *
220
+ * If no handler is provided, the error is thrown during render so it can be
221
+ * caught by the nearest React error boundary.
222
+ */
223
+ type SanityLiveOnError = (event: unknown, context: SanityLiveActionContext) => void | Promise<void>;
224
+ /**
225
+ * Handles the Live Content API `welcome` event.
226
+ *
227
+ * This event fires when the EventSource connection is established. Some export
228
+ * conditions log a connection message by default; pass `false` to
229
+ * `<SanityLive onWelcome={false} />` to disable that behavior.
230
+ */
231
+ type SanityLiveOnWelcome = (event: Extract<LiveEvent, {
232
+ type: "welcome";
233
+ }>, context: SanityLiveActionContext) => void | Promise<void>;
234
+ /**
235
+ * Handles the Live Content API `reconnect` event.
236
+ *
237
+ * The default behavior refreshes the route so Server Components can render with
238
+ * fresh data after reconnecting.
239
+ */
240
+ type SanityLiveOnReconnect = (event: Extract<LiveEvent, {
241
+ type: "reconnect";
242
+ }>, context: SanityLiveActionContext) => void | Promise<void>;
243
+ /**
244
+ * Handles the Live Content API `restart` event.
245
+ *
246
+ * The default behavior refreshes the route so Server Components can render with
247
+ * fresh data after the Live Content API restarts.
248
+ */
249
+ type SanityLiveOnRestart = (event: Extract<LiveEvent, {
250
+ type: "restart";
251
+ }>, context: SanityLiveActionContext) => void | Promise<void>;
252
+ /**
253
+ * Handles the Live Content API `goaway` event.
254
+ *
255
+ * This event means the API closed the live connection and will not deliver live
256
+ * events. This can happen when connection limits are reached. A polling refresh
257
+ * interval is the usual fallback; call `setPollingInterval()` from a custom
258
+ * handler to keep content fresh.
259
+ */
260
+ type SanityLiveOnGoaway = (event: Extract<LiveEvent, {
261
+ type: "goaway";
262
+ }>, context: SanityLiveActionContext, setPollingInterval: (interval: number) => void) => void | Promise<void>;
263
+ export { SanityClientConfig as a, SanityLiveOnError as c, SanityLiveOnRestart as d, SanityLiveOnWelcome as f, LivePerspective as i, SanityLiveOnGoaway as l, StrictDefinedLiveProps as m, DefinedFetchType as n, SanityLiveAction as o, StrictDefinedFetchType as p, DefinedLiveProps as r, SanityLiveActionContext as s, DefineLiveOptions as t, SanityLiveOnReconnect as u };
186
264
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../src/live/shared/types.ts"],"mappings":";;AAcA;;;KAAY,eAAA,GAAkB,OAAA,CAAQ,iBAAA;;AAKtC;;KAAY,gBAAA,sCAAsD,OAAA;EAChE,KAAA,EAAO,WAAA;EACP,MAAA,GAAS,WAAA,GAAc,OAAA,CAAQ,WAAA;;;;EAI/B,WAAA,GAAc,eAAA;;;;;EAKd,KAAA;;;;;EAKA,IAAA;;;;;;EAMA,UAAA;AAAA,MACI,OAAA;EACJ,IAAA,EAAM,YAAA,CAAa,WAAA;EACnB,SAAA,EAAW,gBAAA;EACX,IAAA;AAAA;;;;UAMe,uBAAA;EACf,aAAA;AAAA;AADF;;;;AAAA,KAQY,gBAAA,IAAoB,UAAA,c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AAA,GAAc,OAAA,CAAQ,WAAA;EAC/B,WAAA,EAAa,eAAA;EACb,KAAA;EACA,IAAA;EACA,UAAA;AAAA,MACI,OAAA;EACJ,IAAA,EAAM,YAAA,CAAa,WAAA;EACnB,SAAA,EAAW,gBAAA;EACX,IAAA;AAAA;AAAA,UAGe,kBAAA,SAA2B,IAAA,CAC1C,uBAAA;;;;UAee,uBAAA;;;;;EAKf,aAAA;AAAA;;AA4DF;;;;;;KAlDY,gBAAA,IAAoB,UAAA,cAAwB,OAAA;;;;;;;KAO5C,iBAAA,IACV,KAAA,WACA,OAAA,EAAS,uBAAA,YACC,OAAA;;;;;;;;KAQA,mBAAA,IACV,KAAA,EAAO,OAAA,CAAQ,SAAA;EAAY,IAAA;AAAA,IAC3B,OAAA,EAAS,uBAAA,YACC,OAAA;;;;;;;KAOA,qBAAA,IACV,KAAA,EAAO,OAAA,CAAQ,SAAA;EAAY,IAAA;AAAA,IAC3B,OAAA,EAAS,uBAAA,YACC,OAAA;;;;;;;KAOA,mBAAA,IACV,KAAA,EAAO,OAAA,CAAQ,SAAA;EAAY,IAAA;AAAA,IAC3B,OAAA,EAAS,uBAAA,YACC,OAAA;;;;;;;;;KASA,kBAAA,IACV,KAAA,EAAO,OAAA,CAAQ,SAAA;EAAY,IAAA;AAAA,IAC3B,OAAA,EAAS,uBAAA,EACT,kBAAA,GAAqB,QAAA,6BACX,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-sanity",
3
- "version": "13.0.0-cache-components.42",
3
+ "version": "13.0.0-cache-components.44",
4
4
  "description": "Sanity.io toolkit for Next.js",
5
5
  "keywords": [
6
6
  "live",
@@ -48,10 +48,7 @@
48
48
  },
49
49
  "./live/cache-life": "./dist/live/cache-life.js",
50
50
  "./live/client-components": "./dist/live/client-components/index.js",
51
- "./live/server-actions": {
52
- "next-js": "./dist/live/server-actions/index.next-js.js",
53
- "default": "./dist/live/server-actions/index.default.js"
54
- },
51
+ "./live/server-actions": "./dist/live/server-actions/index.js",
55
52
  "./studio": "./dist/studio/index.js",
56
53
  "./studio/client-component": "./dist/studio/client-component/index.js",
57
54
  "./visual-editing": "./dist/visual-editing/index.js",
@@ -61,15 +58,12 @@
61
58
  "./package.json": "./package.json"
62
59
  },
63
60
  "dependencies": {
64
- "@portabletext/react": "^6.0.3",
61
+ "@portabletext/react": "^6.1.0",
65
62
  "@sanity/client": "^7.22.0",
66
- "@sanity/comlink": "^4.0.1",
67
63
  "@sanity/generate-help-url": "^4.0.0",
68
- "@sanity/presentation-comlink": "^2.0.1",
69
64
  "@sanity/preview-url-secret": "^4.0.5",
70
65
  "@sanity/visual-editing": "^5.3.4",
71
66
  "@sanity/webhook": "^4.0.4",
72
- "dequal": "^2.0.3",
73
67
  "groq": "^5.23.0",
74
68
  "history": "^5.3.0"
75
69
  },
@@ -82,7 +76,7 @@
82
76
  "@vitejs/plugin-react": "^6.0.1",
83
77
  "@vitest/coverage-v8": "^4.1.5",
84
78
  "js-yaml": "^4.1.1",
85
- "next": "16.3.0-canary.9",
79
+ "next": "16.3.0-canary.10",
86
80
  "publint": "^0.3.18",
87
81
  "react": "^19.2.5",
88
82
  "react-dom": "^19.2.5",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.default.d.ts","names":[],"sources":["../../../src/live/server-actions/index.default.ts"],"mappings":"AAUA;;;AAAA,iBAAsB,wBAAA,CAAyB,UAAA,YAAsB,OAAA;;AAyBrE;;;iBAAsB,aAAA,CAAA,GAAiB,OAAA"}
@@ -1,27 +0,0 @@
1
- "use server";
2
- import { t as parseTags } from "../../parseTags.js";
3
- import { draftMode } from "next/headers";
4
- import { refresh, revalidateTag } from "next/cache";
5
- /**
6
- * @alpha CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.
7
- */
8
- async function revalidateSyncTagsAction(unsafeTags) {
9
- const { tags, prefixType } = parseTags(unsafeTags);
10
- if ((await draftMode()).isEnabled) {
11
- console.warn(`<SanityLive ${prefixType === "drafts" ? "includeDrafts " : ""}/> action called in draft mode, cache is bypassed in draft mode so the refresh() function is called instead of updateTag()`, { tags });
12
- refresh();
13
- return;
14
- }
15
- for (const tag of tags) revalidateTag(tag, "max");
16
- console.log(`<SanityLive ${prefixType === "drafts" ? "includeDrafts " : ""}/> revalidated tags: ${tags.join(", ")} with cache profile "max" `);
17
- }
18
- /**
19
- * Used by `<SanityLive onReconnect={refreshAction} onRestart={refreshAction} />`
20
- * @deprecated - refactor `onReconnect` and `onRestart` to support `() => 'refresh'`
21
- */
22
- async function refreshAction() {
23
- refresh();
24
- }
25
- export { refreshAction, revalidateSyncTagsAction };
26
-
27
- //# sourceMappingURL=index.default.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.default.js","names":[],"sources":["../../../src/live/server-actions/index.default.ts"],"sourcesContent":["'use server'\n\nimport {refresh, revalidateTag} from 'next/cache'\nimport {draftMode} from 'next/headers'\n\nimport {parseTags} from '#live/parseTags'\n\n/**\n * @alpha CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.\n */\nexport async function revalidateSyncTagsAction(unsafeTags: unknown): Promise<void> {\n const {tags, prefixType} = parseTags(unsafeTags)\n if ((await draftMode()).isEnabled) {\n console.warn(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> action called in draft mode, cache is bypassed in draft mode so the refresh() function is called instead of updateTag()`,\n {tags},\n )\n refresh()\n return undefined\n }\n\n for (const tag of tags) {\n revalidateTag(tag, 'max')\n }\n\n // oxlint-disable-next-line no-console\n console.log(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> revalidated tags: ${tags.join(', ')} with cache profile \"max\" `,\n )\n}\n\n/**\n * Used by `<SanityLive onReconnect={refreshAction} onRestart={refreshAction} />`\n * @deprecated - refactor `onReconnect` and `onRestart` to support `() => 'refresh'`\n */\nexport async function refreshAction(): Promise<void> {\n refresh()\n}\n"],"mappings":";;;;;;;AAUA,eAAsB,yBAAyB,YAAoC;CACjF,MAAM,EAAC,MAAM,eAAc,UAAU,WAAW;AAChD,MAAK,MAAM,WAAW,EAAE,WAAW;AACjC,UAAQ,KACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,6HAC/D,EAAC,MAAK,CACP;AACD,WAAS;AACT;;AAGF,MAAK,MAAM,OAAO,KAChB,eAAc,KAAK,MAAM;AAI3B,SAAQ,IACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,uBAAuB,KAAK,KAAK,KAAK,CAAC,4BACvG;;;;;;AAOH,eAAsB,gBAA+B;AACnD,UAAS"}
@@ -1,11 +0,0 @@
1
- /**
2
- * @alpha CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.
3
- */
4
- declare function revalidateSyncTagsAction(unsafeTags: unknown): Promise<void>;
5
- /**
6
- * Used by `<SanityLive onReconnect={refreshAction} onRestart={refreshAction} />`
7
- * @deprecated - refactor `onReconnect` and `onRestart` to support `() => 'refresh'`
8
- */
9
- declare function refreshAction(): Promise<void>;
10
- export { refreshAction, revalidateSyncTagsAction };
11
- //# sourceMappingURL=index.next-js.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.next-js.d.ts","names":[],"sources":["../../../src/live/server-actions/index.next-js.ts"],"mappings":"AAUA;;;AAAA,iBAAsB,wBAAA,CAAyB,UAAA,YAAsB,OAAA;;AAyBrE;;;iBAAsB,aAAA,CAAA,GAAiB,OAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.next-js.js","names":[],"sources":["../../../src/live/server-actions/index.next-js.ts"],"sourcesContent":["'use server'\n\nimport {refresh, revalidateTag} from 'next/cache'\nimport {draftMode} from 'next/headers'\n\nimport {parseTags} from '#live/parseTags'\n\n/**\n * @alpha CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.\n */\nexport async function revalidateSyncTagsAction(unsafeTags: unknown): Promise<void> {\n const {tags, prefixType} = parseTags(unsafeTags)\n if ((await draftMode()).isEnabled) {\n console.warn(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> action called in draft mode, cache is bypassed in draft mode so the refresh() function is called instead of updateTag()`,\n {tags},\n )\n refresh()\n return undefined\n }\n\n for (const tag of tags) {\n revalidateTag(tag, 'max')\n }\n\n // oxlint-disable-next-line no-console\n console.log(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> revalidated tags: ${tags.join(', ')} with cache profile \"max\" `,\n )\n}\n\n/**\n * Used by `<SanityLive onReconnect={refreshAction} onRestart={refreshAction} />`\n * @deprecated - refactor `onReconnect` and `onRestart` to support `() => 'refresh'`\n */\nexport async function refreshAction(): Promise<void> {\n refresh()\n}\n"],"mappings":";;;;;;;AAUA,eAAsB,yBAAyB,YAAoC;CACjF,MAAM,EAAC,MAAM,eAAc,UAAU,WAAW;AAChD,MAAK,MAAM,WAAW,EAAE,WAAW;AACjC,UAAQ,KACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,6HAC/D,EAAC,MAAK,CACP;AACD,WAAS;AACT;;AAGF,MAAK,MAAM,OAAO,KAChB,eAAc,KAAK,MAAM;AAI3B,SAAQ,IACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,uBAAuB,KAAK,KAAK,KAAK,CAAC,4BACvG;;;;;;AAOH,eAAsB,gBAA+B;AACnD,UAAS"}