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
package/dist/types.d.ts
CHANGED
|
@@ -5,29 +5,47 @@ import { ClientPerspective, ClientReturn, ContentSourceMap, LiveEvent, QueryPara
|
|
|
5
5
|
*/
|
|
6
6
|
type LivePerspective = Exclude<ClientPerspective, "raw">;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
24
|
-
*
|
|
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
|
-
*
|
|
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<{
|
|
@@ -36,125 +54,176 @@ type DefinedFetchType = <const QueryString extends string>(options: {
|
|
|
36
54
|
tags: string[];
|
|
37
55
|
}>;
|
|
38
56
|
/**
|
|
39
|
-
*
|
|
57
|
+
* Context passed to Sanity Live event handlers.
|
|
40
58
|
*/
|
|
41
59
|
interface SanityLiveActionContext {
|
|
60
|
+
/**
|
|
61
|
+
* Whether the current `<SanityLive />` connection includes draft and content
|
|
62
|
+
* release version events.
|
|
63
|
+
*/
|
|
42
64
|
includeDrafts: boolean;
|
|
43
65
|
}
|
|
44
66
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
67
|
+
* Server action invoked when Sanity Live receives a content-change message.
|
|
68
|
+
*
|
|
69
|
+
* The argument is the list of cache tags derived from the Live Content API
|
|
70
|
+
* event. The default action revalidates those tags. Return `'refresh'` from a
|
|
71
|
+
* custom action to also call `router.refresh()` in the browser.
|
|
47
72
|
*/
|
|
48
73
|
type SanityLiveAction = (unsafeTags: unknown) => Promise<void | "refresh">;
|
|
49
74
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
75
|
+
* Handles connection, parsing, and event-processing errors.
|
|
76
|
+
*
|
|
77
|
+
* If no handler is provided, the error is thrown during render so it can be
|
|
78
|
+
* caught by the nearest React error boundary.
|
|
53
79
|
*/
|
|
54
80
|
type SanityLiveOnError = (event: unknown, context: SanityLiveActionContext) => void | Promise<void>;
|
|
55
81
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
82
|
+
* Handles the Live Content API `welcome` event.
|
|
83
|
+
*
|
|
84
|
+
* This event fires when the EventSource connection is established. Some export
|
|
85
|
+
* conditions log a connection message by default; pass `false` to
|
|
86
|
+
* `<SanityLive onWelcome={false} />` to disable that behavior.
|
|
58
87
|
*/
|
|
59
88
|
type SanityLiveOnWelcome = (event: Extract<LiveEvent, {
|
|
60
89
|
type: "welcome";
|
|
61
90
|
}>, context: SanityLiveActionContext) => void | Promise<void>;
|
|
62
91
|
/**
|
|
63
|
-
*
|
|
92
|
+
* Handles the Live Content API `reconnect` event.
|
|
93
|
+
*
|
|
94
|
+
* The default behavior refreshes the route so Server Components can render with
|
|
95
|
+
* fresh data after reconnecting.
|
|
64
96
|
*/
|
|
65
97
|
type SanityLiveOnReconnect = (event: Extract<LiveEvent, {
|
|
66
98
|
type: "reconnect";
|
|
67
99
|
}>, context: SanityLiveActionContext) => void | Promise<void>;
|
|
68
100
|
/**
|
|
69
|
-
*
|
|
101
|
+
* Handles the Live Content API `restart` event.
|
|
102
|
+
*
|
|
103
|
+
* The default behavior refreshes the route so Server Components can render with
|
|
104
|
+
* fresh data after the Live Content API restarts.
|
|
70
105
|
*/
|
|
71
106
|
type SanityLiveOnRestart = (event: Extract<LiveEvent, {
|
|
72
107
|
type: "restart";
|
|
73
108
|
}>, context: SanityLiveActionContext) => void | Promise<void>;
|
|
74
109
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
110
|
+
* Handles the Live Content API `goaway` event.
|
|
111
|
+
*
|
|
112
|
+
* This event means the API closed the live connection and will not deliver live
|
|
113
|
+
* events. This can happen when connection limits are reached. A polling refresh
|
|
114
|
+
* interval is the usual fallback; call `setPollingInterval()` from a custom
|
|
115
|
+
* handler to keep content fresh.
|
|
79
116
|
*/
|
|
80
117
|
type SanityLiveOnGoaway = (event: Extract<LiveEvent, {
|
|
81
118
|
type: "goaway";
|
|
82
119
|
}>, context: SanityLiveActionContext, setPollingInterval: (interval: number) => void) => void | Promise<void>;
|
|
83
120
|
interface DefinedLiveProps {
|
|
84
121
|
/**
|
|
85
|
-
*
|
|
122
|
+
* Include draft and content release version events in the live connection.
|
|
123
|
+
*
|
|
124
|
+
* Set this to `true` when draft mode is enabled. A `browserToken` must be
|
|
125
|
+
* configured in `defineLive()` for draft events to be included.
|
|
126
|
+
*
|
|
127
|
+
* @defaultValue `false`
|
|
86
128
|
*/
|
|
87
129
|
includeDrafts?: boolean;
|
|
88
130
|
/**
|
|
89
|
-
*
|
|
131
|
+
* Server action called for each content-change message from the Live Content
|
|
132
|
+
* API.
|
|
133
|
+
*
|
|
134
|
+
* The default action revalidates the cache tags produced by `sanityFetch`.
|
|
90
135
|
*/
|
|
91
136
|
action?: SanityLiveAction;
|
|
92
137
|
/**
|
|
93
|
-
*
|
|
138
|
+
* Custom error handler. Pass `false` to disable custom handling and throw
|
|
139
|
+
* errors to the nearest React error boundary.
|
|
94
140
|
*/
|
|
95
141
|
onError?: SanityLiveOnError | false;
|
|
96
142
|
/**
|
|
97
|
-
*
|
|
143
|
+
* Custom handler for the `welcome` event. Pass `false` to disable the default
|
|
144
|
+
* connection log.
|
|
98
145
|
*/
|
|
99
146
|
onWelcome?: SanityLiveOnWelcome | false;
|
|
100
147
|
/**
|
|
101
|
-
*
|
|
148
|
+
* Custom handler for the `reconnect` event. Pass `false` to disable the
|
|
149
|
+
* default refresh behavior.
|
|
102
150
|
*/
|
|
103
151
|
onReconnect?: SanityLiveOnReconnect | false;
|
|
104
152
|
/**
|
|
105
|
-
*
|
|
153
|
+
* Custom handler for the `restart` event. Pass `false` to disable the default
|
|
154
|
+
* refresh behavior.
|
|
106
155
|
*/
|
|
107
156
|
onRestart?: SanityLiveOnRestart | false;
|
|
108
157
|
/**
|
|
109
|
-
*
|
|
158
|
+
* Custom handler for the `goaway` event. Pass `false` to disable the default
|
|
159
|
+
* long-polling fallback.
|
|
110
160
|
*/
|
|
111
161
|
onGoAway?: SanityLiveOnGoaway | false;
|
|
112
162
|
/**
|
|
113
|
-
*
|
|
163
|
+
* Refresh Server Components once when `<SanityLive />` mounts.
|
|
164
|
+
*
|
|
165
|
+
* This can close the gap between the initial server render and the browser
|
|
166
|
+
* establishing the live EventSource connection.
|
|
167
|
+
*
|
|
114
168
|
* @defaultValue `false`
|
|
115
169
|
*/
|
|
116
170
|
refreshOnMount?: boolean;
|
|
117
171
|
/**
|
|
118
|
-
*
|
|
172
|
+
* Refresh Server Components when the page becomes visible or the window
|
|
173
|
+
* regains focus.
|
|
174
|
+
*
|
|
119
175
|
* @defaultValue `false`
|
|
120
176
|
*/
|
|
121
177
|
refreshOnFocus?: boolean;
|
|
122
178
|
/**
|
|
123
|
-
*
|
|
124
|
-
* @defaultValue `false`
|
|
179
|
+
* Refresh Server Components when the browser regains a network connection.
|
|
125
180
|
*/
|
|
126
181
|
refreshOnReconnect?: boolean;
|
|
127
182
|
/**
|
|
128
|
-
*
|
|
183
|
+
* Request tag used to identify the live EventSource request in Sanity Content
|
|
184
|
+
* Lake logs.
|
|
185
|
+
*
|
|
129
186
|
* @see https://www.sanity.io/docs/reference-api-request-tags
|
|
130
|
-
* @defaultValue 'next-loader.live'
|
|
187
|
+
* @defaultValue `'next-loader.live'` or `'next-loader.live.cache-components'`
|
|
131
188
|
*/
|
|
132
189
|
requestTag?: string;
|
|
133
190
|
}
|
|
134
191
|
interface DefineLiveOptions {
|
|
135
192
|
/**
|
|
136
|
-
*
|
|
193
|
+
* Sanity client used by `sanityFetch()` and `<SanityLive />`.
|
|
137
194
|
*/
|
|
138
195
|
client: SanityClient;
|
|
139
196
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
197
|
+
* Token used by the server to query drafts and content release versions.
|
|
198
|
+
*
|
|
199
|
+
* This token is never shared with the browser unless you also pass it as
|
|
200
|
+
* `browserToken`.
|
|
142
201
|
*/
|
|
143
202
|
serverToken?: string | false;
|
|
144
203
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
204
|
+
* Token shared with the browser when `<SanityLive includeDrafts />` opens a
|
|
205
|
+
* draft-capable live connection.
|
|
206
|
+
*
|
|
207
|
+
* Use a browser-safe token with the minimum read permissions needed for live
|
|
208
|
+
* previewing drafts outside Presentation Tool.
|
|
147
209
|
*/
|
|
148
210
|
browserToken?: string | false;
|
|
149
211
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
212
|
+
* Include stega encoding automatically when draft mode is enabled.
|
|
213
|
+
*
|
|
214
|
+
* @deprecated This option does not affect the `next-js` export condition used
|
|
215
|
+
* with `cacheComponents: true`. Pass `stega` to `sanityFetch()` instead.
|
|
216
|
+
* @defaultValue `true`
|
|
153
217
|
*/
|
|
154
218
|
stega?: boolean;
|
|
155
219
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
220
|
+
* Require explicit live-content options at every call site.
|
|
221
|
+
*
|
|
222
|
+
* When `true`, `includeDrafts` is required on `<SanityLive />` and
|
|
223
|
+
* `perspective`/`stega` are required on `sanityFetch()`. This matches the
|
|
224
|
+
* explicit data flow needed inside Cache Components, where `draftMode()` and
|
|
225
|
+
* `cookies()` must be resolved outside `'use cache'` boundaries.
|
|
226
|
+
*
|
|
158
227
|
* @defaultValue `false`
|
|
159
228
|
*/
|
|
160
229
|
strict?: boolean;
|
|
@@ -182,5 +251,5 @@ type StrictDefinedFetchType = <const QueryString extends string>(options: {
|
|
|
182
251
|
sourceMap: ContentSourceMap | null;
|
|
183
252
|
tags: string[];
|
|
184
253
|
}>;
|
|
185
|
-
export { SanityLiveAction as a,
|
|
254
|
+
export { SanityLiveAction as a, SanityLiveOnGoaway as c, SanityLiveOnWelcome as d, StrictDefinedFetchType as f, LivePerspective as i, SanityLiveOnReconnect as l, DefinedFetchType as n, SanityLiveActionContext as o, StrictDefinedLiveProps as p, DefinedLiveProps as r, SanityLiveOnError as s, DefineLiveOptions as t, SanityLiveOnRestart as u };
|
|
186
255
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/live/shared/types.ts"],"mappings":";;AAcA;;;KAAY,eAAA,GAAkB,OAAA,CAAQ,iBAAA;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/live/shared/types.ts"],"mappings":";;AAcA;;;KAAY,eAAA,GAAkB,OAAA,CAAQ,iBAAA;;AAStC;;;;;;KAAY,gBAAA,sCAAsD,OAAA;;;;EAIhE,KAAA,EAAO,WAAA;;;;EAIP,MAAA,GAAS,WAAA,GAAc,OAAA,CAAQ,WAAA;;;;;;EAM/B,WAAA,GAAc,eAAA;;;;;;;EAOd,KAAA;;;;;;;;EAQA,IAAA;EAiBF;;;;;AAeA;EAzBE,UAAA;AAAA,MACI,OAAA;EACJ,IAAA,EAAM,YAAA,CAAa,WAAA;EACnB,SAAA,EAAW,gBAAA;EACX,IAAA;AAAA;;;;UAMe,uBAAA;;;;;EAKf,aAAA;AAAA;;;;;;;;KAUU,gBAAA,IAAoB,UAAA,cAAwB,OAAA;;;;;;;KAO5C,iBAAA,IACV,KAAA,WACA,OAAA,EAAS,uBAAA,YACC,OAAA;;AAkBZ;;;;;;KAVY,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;AAOZ;;;;;;AAAA,KAAY,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;AAAA,UAOK,gBAAA;;;;;;;;;EASf,aAAA;;;;;AATF;;EAgBE,MAAA,GAAS,gBAAA;;;;;EAKT,OAAA,GAAU,iBAAA;;;;;EAKV,SAAA,GAAY,mBAAA;;;;;EAKZ,WAAA,GAAc,qBAAA;;;;;EAKd,SAAA,GAAY,mBAAA;;;;;EAKZ,QAAA,GAAW,kBAAA;;;AAiCb;;;;;;EAvBE,cAAA;;;;;;AAoEF;EA7DE,cAAA;;;;EAIA,kBAAA;;;;AAiEF;;;;EAxDE,UAAA;AAAA;AAAA,UAGe,iBAAA;;;;EAIf,MAAA,EAAQ,YAAA;;;;;;;EAOR,WAAA;;;;;;;;EAQA,YAAA;;;;;;;;EAQA,KAAA;;;;;;;;;;;EAWA,MAAA;AAAA;;;;;UAOe,sBAAA,SAA+B,IAAA,CAAK,gBAAA;EACnD,aAAA;AAAA;;;;;KAOU,sBAAA,sCAA4D,OAAA;EACtE,KAAA,EAAO,WAAA;EACP,MAAA,GAAS,WAAA,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { VisualEditing as VisualEditing$1 } from "next-sanity/visual-editing/client-component";
|
|
3
|
-
import {
|
|
3
|
+
import { perspectiveChangeAction } from "next-sanity/visual-editing/server-actions";
|
|
4
4
|
/**
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
@@ -20,7 +20,7 @@ function VisualEditing(props) {
|
|
|
20
20
|
console.error("Failed detecting trailingSlash", err);
|
|
21
21
|
}
|
|
22
22
|
return /* @__PURE__ */ jsx(VisualEditing$1, {
|
|
23
|
-
onPerspectiveChange:
|
|
23
|
+
onPerspectiveChange: perspectiveChangeAction,
|
|
24
24
|
...props,
|
|
25
25
|
basePath: props.basePath ?? autoBasePath,
|
|
26
26
|
trailingSlash: props.trailingSlash ?? autoTrailingSlash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["VisualEditingComponent"],"sources":["../../src/visual-editing/VisualEditing.tsx"],"sourcesContent":["import type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\nimport {VisualEditing as VisualEditingComponent} from 'next-sanity/visual-editing/client-component'\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["VisualEditingComponent"],"sources":["../../src/visual-editing/VisualEditing.tsx"],"sourcesContent":["import type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\nimport {VisualEditing as VisualEditingComponent} from 'next-sanity/visual-editing/client-component'\nimport {perspectiveChangeAction} from 'next-sanity/visual-editing/server-actions'\n\n/**\n * @public\n */\nexport function VisualEditing(props: VisualEditingProps): React.ReactElement {\n let autoBasePath: string | undefined\n if (typeof props.basePath !== 'string') {\n try {\n autoBasePath = process.env['__NEXT_ROUTER_BASEPATH']\n if (autoBasePath) {\n // oxlint-disable-next-line no-console\n console.log(\n `Detected next basePath as ${JSON.stringify(autoBasePath)} by reading \"process.env.__NEXT_ROUTER_BASEPATH\". If this is incorrect then you can set it manually with the basePath prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting basePath', err)\n }\n }\n let autoTrailingSlash: boolean | undefined\n if (typeof props.trailingSlash !== 'boolean') {\n try {\n autoTrailingSlash = Boolean(process.env['__NEXT_TRAILING_SLASH'])\n if (autoTrailingSlash) {\n // oxlint-disable-next-line no-console\n console.log(\n `Detected next trailingSlash as ${JSON.stringify(autoTrailingSlash)} by reading \"process.env.__NEXT_TRAILING_SLASH\". If this is incorrect then you can set it manually with the trailingSlash prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting trailingSlash', err)\n }\n }\n return (\n <VisualEditingComponent\n onPerspectiveChange={perspectiveChangeAction}\n {...props}\n basePath={props.basePath ?? autoBasePath}\n trailingSlash={props.trailingSlash ?? autoTrailingSlash}\n />\n )\n}\n\nexport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n"],"mappings":";;;;;;AAOA,SAAgB,cAAc,OAA+C;CAC3E,IAAI;AACJ,KAAI,OAAO,MAAM,aAAa,SAC5B,KAAI;AACF,iBAAe,QAAQ,IAAI;AAC3B,MAAI,aAEF,SAAQ,IACN,6BAA6B,KAAK,UAAU,aAAa,CAAC,gKAC3D;UAEI,KAAK;AACZ,UAAQ,MAAM,6BAA6B,IAAI;;CAGnD,IAAI;AACJ,KAAI,OAAO,MAAM,kBAAkB,UACjC,KAAI;AACF,sBAAoB,QAAQ,QAAQ,IAAI,yBAAyB;AACjE,MAAI,kBAEF,SAAQ,IACN,kCAAkC,KAAK,UAAU,kBAAkB,CAAC,oKACrE;UAEI,KAAK;AACZ,UAAQ,MAAM,kCAAkC,IAAI;;AAGxD,QACE,oBAACA,iBAAD;EACE,qBAAqB;EACrB,GAAI;EACJ,UAAU,MAAM,YAAY;EAC5B,eAAe,MAAM,iBAAiB;EACtC,CAAA"}
|
|
@@ -2,6 +2,6 @@ import { ClientPerspective } from "@sanity/client";
|
|
|
2
2
|
/**
|
|
3
3
|
* @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.
|
|
4
4
|
*/
|
|
5
|
-
declare function
|
|
6
|
-
export {
|
|
5
|
+
declare function perspectiveChangeAction(perspective: ClientPerspective): Promise<void>;
|
|
6
|
+
export { perspectiveChangeAction };
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -6,13 +6,13 @@ import { refresh } from "next/cache";
|
|
|
6
6
|
/**
|
|
7
7
|
* @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.
|
|
8
8
|
*/
|
|
9
|
-
async function
|
|
9
|
+
async function perspectiveChangeAction(perspective) {
|
|
10
10
|
const sanitizedPerspective = sanitizePerspective(perspective, "drafts");
|
|
11
11
|
if (!sanitizedPerspective || Array.isArray(sanitizedPerspective) && sanitizedPerspective.length === 0) throw new Error(`Invalid perspective`, { cause: perspective });
|
|
12
12
|
const nextPerspective = Array.isArray(sanitizedPerspective) ? sanitizedPerspective.join(",") : sanitizedPerspective;
|
|
13
13
|
const jar = await cookies();
|
|
14
14
|
if (nextPerspective === jar.get(perspectiveCookieName)?.value && process.env.NODE_ENV !== "production") {
|
|
15
|
-
console.debug("
|
|
15
|
+
console.debug("perspectiveChangeAction", "Perspective is the same, skipping", nextPerspective);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
jar.set(perspectiveCookieName, nextPerspective, {
|
|
@@ -23,6 +23,6 @@ async function actionPerspectiveChange(perspective) {
|
|
|
23
23
|
});
|
|
24
24
|
refresh();
|
|
25
25
|
}
|
|
26
|
-
export {
|
|
26
|
+
export { perspectiveChangeAction };
|
|
27
27
|
|
|
28
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/visual-editing/server-actions/index.ts"],"sourcesContent":["'use server'\n\nimport type {ClientPerspective} from '@sanity/client'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {refresh} from 'next/cache'\nimport {cookies} from 'next/headers'\n\nimport {sanitizePerspective} from '#live/sanitizePerspective'\n\n/**\n * @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.\n */\nexport async function
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/visual-editing/server-actions/index.ts"],"sourcesContent":["'use server'\n\nimport type {ClientPerspective} from '@sanity/client'\nimport {perspectiveCookieName} from '@sanity/preview-url-secret/constants'\nimport {refresh} from 'next/cache'\nimport {cookies} from 'next/headers'\n\nimport {sanitizePerspective} from '#live/sanitizePerspective'\n\n/**\n * @internal CAUTION: this is an internal action and does not follow semver. Using it directly is at your own risk.\n */\nexport async function perspectiveChangeAction(perspective: ClientPerspective): Promise<void> {\n const sanitizedPerspective = sanitizePerspective(perspective, 'drafts')\n if (\n !sanitizedPerspective ||\n (Array.isArray(sanitizedPerspective) && sanitizedPerspective.length === 0)\n ) {\n throw new Error(`Invalid perspective`, {cause: perspective})\n }\n\n const nextPerspective = Array.isArray(sanitizedPerspective)\n ? sanitizedPerspective.join(',')\n : sanitizedPerspective\n const jar = await cookies()\n if (\n nextPerspective === jar.get(perspectiveCookieName)?.value &&\n process.env.NODE_ENV !== 'production'\n ) {\n // oxlint-disable-next-line no-console\n console.debug('perspectiveChangeAction', 'Perspective is the same, skipping', nextPerspective)\n return\n }\n jar.set(perspectiveCookieName, nextPerspective, {\n httpOnly: true,\n path: '/',\n secure: true,\n sameSite: 'none',\n })\n\n refresh()\n}\n"],"mappings":";;;;;;;;AAYA,eAAsB,wBAAwB,aAA+C;CAC3F,MAAM,uBAAuB,oBAAoB,aAAa,SAAS;AACvE,KACE,CAAC,wBACA,MAAM,QAAQ,qBAAqB,IAAI,qBAAqB,WAAW,EAExE,OAAM,IAAI,MAAM,uBAAuB,EAAC,OAAO,aAAY,CAAC;CAG9D,MAAM,kBAAkB,MAAM,QAAQ,qBAAqB,GACvD,qBAAqB,KAAK,IAAI,GAC9B;CACJ,MAAM,MAAM,MAAM,SAAS;AAC3B,KACE,oBAAoB,IAAI,IAAI,sBAAsB,EAAE,SACpD,QAAQ,IAAI,aAAa,cACzB;AAEA,UAAQ,MAAM,2BAA2B,qCAAqC,gBAAgB;AAC9F;;AAEF,KAAI,IAAI,uBAAuB,iBAAiB;EAC9C,UAAU;EACV,MAAM;EACN,QAAQ;EACR,UAAU;EACX,CAAC;AAEF,UAAS"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-sanity",
|
|
3
|
-
"version": "13.0.0-cache-components.
|
|
3
|
+
"version": "13.0.0-cache-components.43",
|
|
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",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Used by `<SanityLive action={actionRevalidateTags} />`
|
|
3
|
-
*/
|
|
4
|
-
declare function actionUpdateTags(unsafeTags: unknown): Promise<void>;
|
|
5
|
-
/**
|
|
6
|
-
* Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`
|
|
7
|
-
*/
|
|
8
|
-
declare function actionRefresh(): Promise<void>;
|
|
9
|
-
export { actionRefresh, actionUpdateTags };
|
|
10
|
-
//# sourceMappingURL=index.default.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.default.d.ts","names":[],"sources":["../../../src/live/server-actions/index.default.ts"],"mappings":"AAUA;;;AAAA,iBAAsB,gBAAA,CAAiB,UAAA,YAAsB,OAAA;;AAuB7D;;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, updateTag } from "next/cache";
|
|
5
|
-
/**
|
|
6
|
-
* Used by `<SanityLive action={actionRevalidateTags} />`
|
|
7
|
-
*/
|
|
8
|
-
async function actionUpdateTags(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) updateTag(tag);
|
|
16
|
-
revalidateTag("sanity:fetch-sync-tags", "max");
|
|
17
|
-
console.log(`<SanityLive ${prefixType === "drafts" ? "includeDrafts " : ""}/> updated tags: ${tags.join(", ")} and revalidated tag: "sanity:fetch-sync-tags" with cache profile "max"`);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`
|
|
21
|
-
*/
|
|
22
|
-
async function actionRefresh() {
|
|
23
|
-
refresh();
|
|
24
|
-
}
|
|
25
|
-
export { actionRefresh, actionUpdateTags };
|
|
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, updateTag} from 'next/cache'\nimport {draftMode} from 'next/headers'\n\nimport {parseTags} from '#live/parseTags'\n\n/**\n * Used by `<SanityLive action={actionRevalidateTags} />`\n */\nexport async function actionUpdateTags(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 for (const tag of tags) {\n updateTag(tag)\n }\n revalidateTag('sanity:fetch-sync-tags', 'max')\n // oxlint-disable-next-line no-console\n console.log(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> updated tags: ${tags.join(', ')} and revalidated tag: \"sanity:fetch-sync-tags\" with cache profile \"max\"`,\n )\n}\n\n/**\n * Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`\n */\nexport async function actionRefresh(): Promise<void> {\n refresh()\n}\n"],"mappings":";;;;;;;AAUA,eAAsB,iBAAiB,YAAoC;CACzE,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;;AAEF,MAAK,MAAM,OAAO,KAChB,WAAU,IAAI;AAEhB,eAAc,0BAA0B,MAAM;AAE9C,SAAQ,IACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,mBAAmB,KAAK,KAAK,KAAK,CAAC,yEACnG;;;;;AAMH,eAAsB,gBAA+B;AACnD,UAAS"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Used by `<SanityLive action={actionRevalidateTags} />`
|
|
3
|
-
*/
|
|
4
|
-
declare function actionUpdateTags(unsafeTags: unknown): Promise<void>;
|
|
5
|
-
/**
|
|
6
|
-
* Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`
|
|
7
|
-
*/
|
|
8
|
-
declare function actionRefresh(): Promise<void>;
|
|
9
|
-
export { actionRefresh, actionUpdateTags };
|
|
10
|
-
//# 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,gBAAA,CAAiB,UAAA,YAAsB,OAAA;;AAsB7D;;iBAAsB,aAAA,CAAA,GAAiB,OAAA"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { t as parseTags } from "../../parseTags.js";
|
|
3
|
-
import { draftMode } from "next/headers";
|
|
4
|
-
import { refresh, updateTag } from "next/cache";
|
|
5
|
-
/**
|
|
6
|
-
* Used by `<SanityLive action={actionRevalidateTags} />`
|
|
7
|
-
*/
|
|
8
|
-
async function actionUpdateTags(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) updateTag(tag);
|
|
16
|
-
console.log(`<SanityLive ${prefixType === "drafts" ? "includeDrafts " : ""}/> updated tags: ${tags.join(", ")}`);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`
|
|
20
|
-
*/
|
|
21
|
-
async function actionRefresh() {
|
|
22
|
-
refresh();
|
|
23
|
-
}
|
|
24
|
-
export { actionRefresh, actionUpdateTags };
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=index.next-js.js.map
|
|
@@ -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, updateTag} from 'next/cache'\nimport {draftMode} from 'next/headers'\n\nimport {parseTags} from '#live/parseTags'\n\n/**\n * Used by `<SanityLive action={actionRevalidateTags} />`\n */\nexport async function actionUpdateTags(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 for (const tag of tags) {\n updateTag(tag)\n }\n // oxlint-disable-next-line no-console\n console.log(\n `<SanityLive ${prefixType === 'drafts' ? 'includeDrafts ' : ''}/> updated tags: ${tags.join(', ')}`,\n )\n}\n\n/**\n * Used by `<SanityLive onReconnect={actionRefresh} onRestart={actionRefresh} />`\n */\nexport async function actionRefresh(): Promise<void> {\n refresh()\n}\n"],"mappings":";;;;;;;AAUA,eAAsB,iBAAiB,YAAoC;CACzE,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;;AAEF,MAAK,MAAM,OAAO,KAChB,WAAU,IAAI;AAGhB,SAAQ,IACN,eAAe,eAAe,WAAW,mBAAmB,GAAG,mBAAmB,KAAK,KAAK,KAAK,GAClG;;;;;AAMH,eAAsB,gBAA+B;AACnD,UAAS"}
|