@depup/sanity 5.17.1-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +57 -0
- package/bin/sanity +209 -0
- package/changes.json +114 -0
- package/lib/_chunks-dts/ActiveWorkspaceMatcherContext.d.ts +16164 -0
- package/lib/_chunks-dts/index.d.ts +780 -0
- package/lib/_chunks-dts/types.d.ts +2765 -0
- package/lib/_chunks-dts/types2.d.ts +656 -0
- package/lib/_chunks-dts/types3.d.ts +303 -0
- package/lib/_chunks-es/BroadcastDisplayedDocument.js +20 -0
- package/lib/_chunks-es/BroadcastDisplayedDocument.js.map +1 -0
- package/lib/_chunks-es/DisplayedDocumentBroadcaster.js +32 -0
- package/lib/_chunks-es/DisplayedDocumentBroadcaster.js.map +1 -0
- package/lib/_chunks-es/LiveQueries.js +339 -0
- package/lib/_chunks-es/LiveQueries.js.map +1 -0
- package/lib/_chunks-es/MenuGroup.js +106 -0
- package/lib/_chunks-es/MenuGroup.js.map +1 -0
- package/lib/_chunks-es/PostMessageDocuments.js +72 -0
- package/lib/_chunks-es/PostMessageDocuments.js.map +1 -0
- package/lib/_chunks-es/PostMessagePerspective.js +23 -0
- package/lib/_chunks-es/PostMessagePerspective.js.map +1 -0
- package/lib/_chunks-es/PostMessagePreviewSnapshots.js +69 -0
- package/lib/_chunks-es/PostMessagePreviewSnapshots.js.map +1 -0
- package/lib/_chunks-es/PostMessageRefreshMutations.js +74 -0
- package/lib/_chunks-es/PostMessageRefreshMutations.js.map +1 -0
- package/lib/_chunks-es/PostMessageSchema.js +502 -0
- package/lib/_chunks-es/PostMessageSchema.js.map +1 -0
- package/lib/_chunks-es/PostMessageTelemetry.js +21 -0
- package/lib/_chunks-es/PostMessageTelemetry.js.map +1 -0
- package/lib/_chunks-es/PresentationToolGrantsCheck.js +3848 -0
- package/lib/_chunks-es/PresentationToolGrantsCheck.js.map +1 -0
- package/lib/_chunks-es/QRCodeSVG.js +692 -0
- package/lib/_chunks-es/QRCodeSVG.js.map +1 -0
- package/lib/_chunks-es/StructureToolProvider.js +2360 -0
- package/lib/_chunks-es/StructureToolProvider.js.map +1 -0
- package/lib/_chunks-es/VideoPlayer.js +22 -0
- package/lib/_chunks-es/VideoPlayer.js.map +1 -0
- package/lib/_chunks-es/ViteDevServerStopped.js +52 -0
- package/lib/_chunks-es/ViteDevServerStopped.js.map +1 -0
- package/lib/_chunks-es/index.js +285 -0
- package/lib/_chunks-es/index.js.map +1 -0
- package/lib/_chunks-es/index2.js +105 -0
- package/lib/_chunks-es/index2.js.map +1 -0
- package/lib/_chunks-es/index3.js +139 -0
- package/lib/_chunks-es/index3.js.map +1 -0
- package/lib/_chunks-es/index4.js +1020 -0
- package/lib/_chunks-es/index4.js.map +1 -0
- package/lib/_chunks-es/pane.js +5 -0
- package/lib/_chunks-es/pane.js.map +1 -0
- package/lib/_chunks-es/pane2.js +5 -0
- package/lib/_chunks-es/pane2.js.map +1 -0
- package/lib/_chunks-es/presentation.js +549 -0
- package/lib/_chunks-es/presentation.js.map +1 -0
- package/lib/_chunks-es/resources.js +303 -0
- package/lib/_chunks-es/resources.js.map +1 -0
- package/lib/_chunks-es/resources2.js +459 -0
- package/lib/_chunks-es/resources2.js.map +1 -0
- package/lib/_chunks-es/resources3.js +281 -0
- package/lib/_chunks-es/resources3.js.map +1 -0
- package/lib/_chunks-es/resources4.js +184 -0
- package/lib/_chunks-es/resources4.js.map +1 -0
- package/lib/_chunks-es/resources5.js +161 -0
- package/lib/_chunks-es/resources5.js.map +1 -0
- package/lib/_chunks-es/resources6.js +141 -0
- package/lib/_chunks-es/resources6.js.map +1 -0
- package/lib/_chunks-es/resources7.js +24 -0
- package/lib/_chunks-es/resources7.js.map +1 -0
- package/lib/_chunks-es/resources8.js +603 -0
- package/lib/_chunks-es/resources8.js.map +1 -0
- package/lib/_chunks-es/resources9.js +126 -0
- package/lib/_chunks-es/resources9.js.map +1 -0
- package/lib/_chunks-es/structureTool.js +13673 -0
- package/lib/_chunks-es/structureTool.js.map +1 -0
- package/lib/_chunks-es/version.js +17 -0
- package/lib/_chunks-es/version.js.map +1 -0
- package/lib/_createContext.d.ts +12 -0
- package/lib/_createContext.js +38 -0
- package/lib/_createContext.js.map +1 -0
- package/lib/_internal.d.ts +9 -0
- package/lib/_internal.js +12 -0
- package/lib/_internal.js.map +1 -0
- package/lib/_singletons.d.ts +951 -0
- package/lib/_singletons.js +284 -0
- package/lib/_singletons.js.map +1 -0
- package/lib/cli.d.ts +3 -0
- package/lib/cli.js +9 -0
- package/lib/cli.js.map +1 -0
- package/lib/desk.d.ts +910 -0
- package/lib/desk.js +71 -0
- package/lib/desk.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +92934 -0
- package/lib/index.js.map +1 -0
- package/lib/media-library.d.ts +85 -0
- package/lib/media-library.js +11 -0
- package/lib/media-library.js.map +1 -0
- package/lib/migrate.d.ts +1 -0
- package/lib/migrate.js +2 -0
- package/lib/migrate.js.map +1 -0
- package/lib/presentation.d.ts +28 -0
- package/lib/presentation.js +10 -0
- package/lib/presentation.js.map +1 -0
- package/lib/router.d.ts +560 -0
- package/lib/router.js +777 -0
- package/lib/router.js.map +1 -0
- package/lib/structure.d.ts +3 -0
- package/lib/structure.js +639 -0
- package/lib/structure.js.map +1 -0
- package/mock-browser-env-stub-loader.mjs +27 -0
- package/package.json +383 -0
- package/static/favicons/apple-touch-icon.png +0 -0
- package/static/favicons/favicon-192.png +0 -0
- package/static/favicons/favicon-512.png +0 -0
- package/static/favicons/favicon-96.png +0 -0
- package/static/favicons/favicon.ico +0 -0
- package/static/favicons/favicon.svg +12 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
interface RouteSegment {
|
|
5
|
+
/**
|
|
6
|
+
* The name of the segment.
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* The type of the segment.
|
|
11
|
+
* Can be either "dir" or "param".
|
|
12
|
+
*/
|
|
13
|
+
type: 'dir' | 'param';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
interface RouteTransform<T> {
|
|
19
|
+
/**
|
|
20
|
+
* Converts a path string to a state object.
|
|
21
|
+
*/
|
|
22
|
+
toState: (value: string) => T;
|
|
23
|
+
/**
|
|
24
|
+
* Converts a state object to a path string.
|
|
25
|
+
*/
|
|
26
|
+
toPath: (value: T) => string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
interface Route {
|
|
32
|
+
/**
|
|
33
|
+
* The raw string representation of the route.
|
|
34
|
+
*/
|
|
35
|
+
raw: string;
|
|
36
|
+
/**
|
|
37
|
+
* An array of route segments that make up the route.
|
|
38
|
+
* See {@link RouteSegment}
|
|
39
|
+
*/
|
|
40
|
+
segments: RouteSegment[];
|
|
41
|
+
/**
|
|
42
|
+
* An optional object containing route transforms.
|
|
43
|
+
* See {@link RouteTransform} and {@link RouterState}
|
|
44
|
+
*/
|
|
45
|
+
transform?: {
|
|
46
|
+
[key: string]: RouteTransform<RouterState>;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
type RouteChildren = RouterNode[] | ((state: RouterState) => Router | RouterNode | RouterNode[] | undefined | false);
|
|
53
|
+
/**
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
interface RouterNode {
|
|
57
|
+
/**
|
|
58
|
+
* The route information for this node. See {@link Route}
|
|
59
|
+
*/
|
|
60
|
+
route: Route;
|
|
61
|
+
/**
|
|
62
|
+
* An optional scope for this node.
|
|
63
|
+
*/
|
|
64
|
+
scope?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Optionally disable scoping of search params
|
|
67
|
+
* Scoped search params will be represented as scope[param]=value in the url
|
|
68
|
+
* Disabling this will still scope search params based on any parent scope unless the parent scope also has disabled search params scoping
|
|
69
|
+
* Caution: enabling this can cause conflicts with multiple plugins defining search params with the same name
|
|
70
|
+
*/
|
|
71
|
+
__unsafe_disableScopedSearchParams?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* An optional object containing transforms to apply to this node.
|
|
74
|
+
* See {@link RouteTransform} and {@link RouterState}
|
|
75
|
+
*/
|
|
76
|
+
transform?: {
|
|
77
|
+
[key: string]: RouteTransform<RouterState>;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* The child nodes of this node. See {@link RouteChildren}
|
|
81
|
+
*/
|
|
82
|
+
children: RouteChildren;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
interface Router extends RouterNode {
|
|
88
|
+
/**
|
|
89
|
+
* Indicates whether this router is a route.
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
_isRoute: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Encodes the specified router state into a path string.
|
|
95
|
+
* See {@link RouterState}
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
encode: (state: RouterState) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Decodes the specified path string into a router state.
|
|
101
|
+
* See {@link RouterState}
|
|
102
|
+
*/
|
|
103
|
+
decode: (path: string) => RouterState | null;
|
|
104
|
+
/**
|
|
105
|
+
* Determines whether the specified path is not found.
|
|
106
|
+
*/
|
|
107
|
+
isNotFound: (path: string) => boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Gets the base path of this router.
|
|
110
|
+
*/
|
|
111
|
+
getBasePath: () => string;
|
|
112
|
+
/**
|
|
113
|
+
* Gets the redirect base of this router.
|
|
114
|
+
*/
|
|
115
|
+
getRedirectBase: (pathname: string) => string | null;
|
|
116
|
+
/**
|
|
117
|
+
* Determines whether the specified path is the root path.
|
|
118
|
+
*/
|
|
119
|
+
isRoot: (path: string) => boolean;
|
|
120
|
+
}
|
|
121
|
+
/** @internal */
|
|
122
|
+
type InternalSearchParam = [scopedPath: string[], value: string];
|
|
123
|
+
/** @internal */
|
|
124
|
+
interface MatchOk {
|
|
125
|
+
type: 'ok';
|
|
126
|
+
node: RouterNode;
|
|
127
|
+
matchedState: Record<string, string>;
|
|
128
|
+
searchParams: InternalSearchParam[];
|
|
129
|
+
child: MatchOk | undefined;
|
|
130
|
+
}
|
|
131
|
+
/** @internal */
|
|
132
|
+
interface MatchError {
|
|
133
|
+
type: 'error';
|
|
134
|
+
node: RouterNode;
|
|
135
|
+
/**
|
|
136
|
+
* Parameters found in the route string but not provided as a key in the state object
|
|
137
|
+
*/
|
|
138
|
+
missingKeys: string[];
|
|
139
|
+
/**
|
|
140
|
+
* These are keys found in the state object but not in the route definition (and can't be mapped to a child route)
|
|
141
|
+
*/
|
|
142
|
+
unmappableStateKeys: string[];
|
|
143
|
+
}
|
|
144
|
+
/** @internal */
|
|
145
|
+
type MatchResult = MatchError | MatchOk;
|
|
146
|
+
/**
|
|
147
|
+
* @public
|
|
148
|
+
*/
|
|
149
|
+
interface NavigateBaseOptions {
|
|
150
|
+
replace?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
interface NavigateOptions extends NavigateBaseOptions {
|
|
156
|
+
stickyParams?: Record<string, string | undefined | null>;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
interface NavigateOptionsWithState extends NavigateOptions {
|
|
162
|
+
state?: RouterState | null;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
interface RouterContextValue {
|
|
168
|
+
/**
|
|
169
|
+
* Resolves the path from the given router state. See {@link RouterState}
|
|
170
|
+
*
|
|
171
|
+
* When state is null, it will resolve the path from the current state
|
|
172
|
+
* and navigate to the root path.
|
|
173
|
+
*/
|
|
174
|
+
resolvePathFromState: (state: RouterState | null) => string;
|
|
175
|
+
/**
|
|
176
|
+
* Resolves the intent link for the given intent name and parameters.
|
|
177
|
+
* See {@link IntentParameters}
|
|
178
|
+
*/
|
|
179
|
+
resolveIntentLink: (intentName: string, params?: IntentParameters, searchParams?: SearchParam[]) => string;
|
|
180
|
+
/**
|
|
181
|
+
* Navigates to the given URL.
|
|
182
|
+
* The function requires an object that has a path and an optional replace property.
|
|
183
|
+
*/
|
|
184
|
+
navigateUrl: (opts: {
|
|
185
|
+
path: string;
|
|
186
|
+
replace?: boolean;
|
|
187
|
+
}) => void;
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated Use `navigate({stickyParams: params, ...options})` instead
|
|
190
|
+
*/
|
|
191
|
+
navigateStickyParams: (params: NavigateOptions['stickyParams'], options?: NavigateBaseOptions) => void;
|
|
192
|
+
/**
|
|
193
|
+
* Updates the router state and navigates to a new path.
|
|
194
|
+
* Allows specifying new state values and optionally merging sticky parameters.
|
|
195
|
+
*
|
|
196
|
+
* See {@link RouterState} and {@link NavigateOptions}
|
|
197
|
+
*
|
|
198
|
+
* @public
|
|
199
|
+
*
|
|
200
|
+
* @example Navigate with sticky params only, staying on the current path
|
|
201
|
+
* ```tsx
|
|
202
|
+
* router.navigate({stickyParams: {baz: 'qux'}})
|
|
203
|
+
* ```
|
|
204
|
+
* @remarks `null` sticky parameter value will remove the sticky parameter from the url
|
|
205
|
+
*
|
|
206
|
+
* @example Navigate with state and sticky params
|
|
207
|
+
* ```tsx
|
|
208
|
+
* router.navigate({stickyParams: {baz: 'qux'}, state: {foo: 'bar'}})
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @example Navigate to root path
|
|
212
|
+
* ```tsx
|
|
213
|
+
* router.navigate({stickyParams: {baz: 'qux'}, state: null})
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
navigate: {
|
|
217
|
+
(nextState: RouterState, options?: NavigateOptions): void;
|
|
218
|
+
(options: NavigateOptions & {
|
|
219
|
+
state?: RouterState | null;
|
|
220
|
+
}): void;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Navigates to the given intent.
|
|
224
|
+
* See {@link RouterState} and {@link NavigateBaseOptions}
|
|
225
|
+
*/
|
|
226
|
+
navigateIntent: (intentName: string, params?: IntentParameters, options?: NavigateBaseOptions) => void;
|
|
227
|
+
/**
|
|
228
|
+
* The current router state. See {@link RouterState}
|
|
229
|
+
*/
|
|
230
|
+
state: RouterState;
|
|
231
|
+
/**
|
|
232
|
+
* The current router state. See {@link RouterState}
|
|
233
|
+
*/
|
|
234
|
+
stickyParams: Record<string, string | undefined | null>;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Base intent parameters
|
|
238
|
+
*
|
|
239
|
+
* @public
|
|
240
|
+
* @todo dedupe with core/structure
|
|
241
|
+
*/
|
|
242
|
+
interface BaseIntentParams {
|
|
243
|
+
/**
|
|
244
|
+
* Document schema type name to create/edit.
|
|
245
|
+
* Required for `create` intents, optional for `edit` (but encouraged, safer and faster)
|
|
246
|
+
*/
|
|
247
|
+
type?: string;
|
|
248
|
+
/**
|
|
249
|
+
* ID of the document to create/edit.
|
|
250
|
+
* Required for `edit` intents, optional for `create`.
|
|
251
|
+
*/
|
|
252
|
+
id?: string;
|
|
253
|
+
template?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Experimental field path
|
|
256
|
+
*
|
|
257
|
+
* @beta
|
|
258
|
+
* @experimental
|
|
259
|
+
* @hidden
|
|
260
|
+
*/
|
|
261
|
+
path?: string;
|
|
262
|
+
/**
|
|
263
|
+
* Optional "mode" to use for edit intent.
|
|
264
|
+
* Known modes are `structure` and `presentation`.
|
|
265
|
+
*/
|
|
266
|
+
mode?: string;
|
|
267
|
+
/**
|
|
268
|
+
* Arbitrary/custom parameters are generally discouraged - try to keep them to a minimum,
|
|
269
|
+
* or use `payload` (arbitrary JSON-serializable object) instead.
|
|
270
|
+
*/
|
|
271
|
+
[key: string]: string | undefined;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Intent parameters (json)
|
|
275
|
+
*
|
|
276
|
+
* @public
|
|
277
|
+
*/
|
|
278
|
+
type IntentJsonParams = {
|
|
279
|
+
[key: string]: any;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* @public
|
|
283
|
+
* @todo dedupe with intent types in core
|
|
284
|
+
*/
|
|
285
|
+
type IntentParameters = BaseIntentParams | [BaseIntentParams, IntentJsonParams];
|
|
286
|
+
/**
|
|
287
|
+
* @public
|
|
288
|
+
*/
|
|
289
|
+
type SearchParam = [key: string, value: string];
|
|
290
|
+
/**
|
|
291
|
+
* @public
|
|
292
|
+
*/
|
|
293
|
+
type RouterState = Record<string, unknown> & {
|
|
294
|
+
_searchParams?: SearchParam[];
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Type representing either a new router state or navigation options with an optional state.
|
|
298
|
+
* @internal
|
|
299
|
+
*/
|
|
300
|
+
type NextStateOrOptions = RouterState | (NavigateOptions & {
|
|
301
|
+
state?: RouterState | null;
|
|
302
|
+
});
|
|
303
|
+
export { RouterContextValue as _, MatchError as a, SearchParam as b, NavigateBaseOptions as c, NextStateOrOptions as d, Route as f, Router as g, RouteTransform as h, InternalSearchParam as i, NavigateOptions as l, RouteSegment as m, IntentJsonParams as n, MatchOk as o, RouteChildren as p, IntentParameters as r, MatchResult as s, BaseIntentParams as t, NavigateOptionsWithState as u, RouterNode as v, RouterState as y };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { memo, useEffect } from "react";
|
|
3
|
+
import { usePresentationParams } from "./presentation.js";
|
|
4
|
+
import { useDisplayedDocumentBroadcaster } from "./DisplayedDocumentBroadcaster.js";
|
|
5
|
+
function BroadcastDisplayedDocument(props) {
|
|
6
|
+
const $ = c(7), setDisplayedDocument = useDisplayedDocumentBroadcaster(), params = usePresentationParams(!1);
|
|
7
|
+
let t0;
|
|
8
|
+
$[0] !== props.value || $[1] !== setDisplayedDocument ? (t0 = () => {
|
|
9
|
+
const timeout = setTimeout(() => setDisplayedDocument?.(props.value), 10);
|
|
10
|
+
return () => clearTimeout(timeout);
|
|
11
|
+
}, $[0] = props.value, $[1] = setDisplayedDocument, $[2] = t0) : t0 = $[2];
|
|
12
|
+
const t1 = params?.perspective;
|
|
13
|
+
let t2;
|
|
14
|
+
return $[3] !== props.value || $[4] !== setDisplayedDocument || $[5] !== t1 ? (t2 = [t1, props.value, setDisplayedDocument], $[3] = props.value, $[4] = setDisplayedDocument, $[5] = t1, $[6] = t2) : t2 = $[6], useEffect(t0, t2), null;
|
|
15
|
+
}
|
|
16
|
+
var BroadcastDisplayedDocument_default = memo(BroadcastDisplayedDocument);
|
|
17
|
+
export {
|
|
18
|
+
BroadcastDisplayedDocument_default as default
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=BroadcastDisplayedDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BroadcastDisplayedDocument.js","sources":["../../src/presentation/loader/BroadcastDisplayedDocument.tsx"],"sourcesContent":["import {memo, useEffect} from 'react'\nimport {type SanityDocument} from 'sanity'\n\nimport {usePresentationParams} from '../usePresentationParams'\nimport {useDisplayedDocumentBroadcaster} from './DisplayedDocumentBroadcaster'\n\n/**\n * Sanity Form input component that reads the current form state and broadcasts it to\n * the live query store\n */\nfunction BroadcastDisplayedDocument(props: {\n value: Partial<SanityDocument> | null | undefined\n}): React.JSX.Element | null {\n const setDisplayedDocument = useDisplayedDocumentBroadcaster()\n const params = usePresentationParams(false)\n\n useEffect(() => {\n const timeout = setTimeout(() => setDisplayedDocument?.(props.value), 10)\n return () => clearTimeout(timeout)\n }, [params?.perspective, props.value, setDisplayedDocument])\n\n return null\n}\n\nexport default memo(BroadcastDisplayedDocument)\n"],"names":["BroadcastDisplayedDocument","props","$","_c","setDisplayedDocument","useDisplayedDocumentBroadcaster","params","usePresentationParams","t0","value","timeout","setTimeout","clearTimeout","t1","perspective","t2","useEffect","memo"],"mappings":";;;;AAUA,SAAAA,2BAAAC,OAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAGEC,uBAA6BC,mCAC7BC,SAAeC,sBAAsB,EAAK;AAAC,MAAAC;AAAAN,WAAAD,MAAAQ,SAAAP,SAAAE,wBAEjCI,KAAAA,MAAA;AACR,UAAAE,UAAgBC,WAAW,MAAMP,uBAAuBH,MAAKQ,KAAM,GAAG,EAAE;AAAC,WAClE,MAAMG,aAAaF,OAAO;AAAA,EAAC,GACnCR,EAAA,CAAA,IAAAD,MAAAQ,OAAAP,OAAAE,sBAAAF,OAAAM,MAAAA,KAAAN,EAAA,CAAA;AAAG,QAAAW,KAAAP,QAAMQ;AAAa,MAAAC;AAAA,SAAAb,EAAA,CAAA,MAAAD,MAAAQ,SAAAP,EAAA,CAAA,MAAAE,wBAAAF,EAAA,CAAA,MAAAW,MAApBE,KAAA,CAACF,IAAqBZ,MAAKQ,OAAQL,oBAAoB,GAACF,EAAA,CAAA,IAAAD,MAAAQ,OAAAP,OAAAE,sBAAAF,OAAAW,IAAAX,OAAAa,MAAAA,KAAAb,EAAA,CAAA,GAH3Dc,UAAUR,IAGPO,EAAwD,GAEpD;AAAI;AAGb,IAAA,qCAAeE,KAAKjB,0BAA0B;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import isEqual from "fast-deep-equal";
|
|
4
|
+
import { useContext, useEffect } from "react";
|
|
5
|
+
import { PresentationDisplayedDocumentContext } from "sanity/_singletons";
|
|
6
|
+
function DisplayedDocumentBroadcasterProvider(props) {
|
|
7
|
+
const $ = c(9), {
|
|
8
|
+
children,
|
|
9
|
+
setDisplayedDocument,
|
|
10
|
+
documentId
|
|
11
|
+
} = props;
|
|
12
|
+
let t0;
|
|
13
|
+
$[0] !== setDisplayedDocument ? (t0 = (next) => setDisplayedDocument((prev) => isEqual(prev, next) ? prev : next), $[0] = setDisplayedDocument, $[1] = t0) : t0 = $[1];
|
|
14
|
+
const context = t0;
|
|
15
|
+
let t1, t2;
|
|
16
|
+
$[2] !== documentId || $[3] !== setDisplayedDocument ? (t1 = () => {
|
|
17
|
+
if (documentId)
|
|
18
|
+
return;
|
|
19
|
+
const timeout = setTimeout(() => setDisplayedDocument(null));
|
|
20
|
+
return () => clearTimeout(timeout);
|
|
21
|
+
}, t2 = [documentId, setDisplayedDocument], $[2] = documentId, $[3] = setDisplayedDocument, $[4] = t1, $[5] = t2) : (t1 = $[4], t2 = $[5]), useEffect(t1, t2);
|
|
22
|
+
let t3;
|
|
23
|
+
return $[6] !== children || $[7] !== context ? (t3 = /* @__PURE__ */ jsx(PresentationDisplayedDocumentContext.Provider, { value: context, children }), $[6] = children, $[7] = context, $[8] = t3) : t3 = $[8], t3;
|
|
24
|
+
}
|
|
25
|
+
function useDisplayedDocumentBroadcaster() {
|
|
26
|
+
return useContext(PresentationDisplayedDocumentContext);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
DisplayedDocumentBroadcasterProvider,
|
|
30
|
+
useDisplayedDocumentBroadcaster
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=DisplayedDocumentBroadcaster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisplayedDocumentBroadcaster.js","sources":["../../src/presentation/loader/DisplayedDocumentBroadcaster.tsx"],"sourcesContent":["/**\n * Report back up the document state being displayed in the document pane,\n * allowing Presentation Tool to patch the live queries with the same state.\n * This makes the Perspective switcher less confusing, as it applies to everything else on the page.\n * It's also why it's possible to select an older revision and see it in the preview,\n * effectively letting you preview a revert action you might be considering to perform.\n */\n\nimport isEqual from 'fast-deep-equal'\nimport {type PropsWithChildren, useCallback, useContext, useEffect} from 'react'\nimport {type SanityDocument} from 'sanity'\nimport {PresentationDisplayedDocumentContext} from 'sanity/_singletons'\n\nimport {type PresentationDisplayedDocumentContextValue} from './types'\n\nexport interface DisplayedDocumentBroadcasterProps extends PropsWithChildren {\n setDisplayedDocument: React.Dispatch<\n React.SetStateAction<Partial<SanityDocument> | null | undefined>\n >\n documentId: string | null | undefined\n}\n\nexport function DisplayedDocumentBroadcasterProvider(\n props: DisplayedDocumentBroadcasterProps,\n): React.JSX.Element {\n const {children, setDisplayedDocument, documentId} = props\n\n const context = useCallback<PresentationDisplayedDocumentContextValue>(\n (next) => setDisplayedDocument((prev) => (isEqual(prev, next) ? prev : next)),\n [setDisplayedDocument],\n )\n\n useEffect(() => {\n // If no document is currently being displayed then reset the state\n if (documentId) {\n return undefined\n }\n const timeout = setTimeout(() => setDisplayedDocument(null))\n return () => clearTimeout(timeout)\n }, [documentId, setDisplayedDocument])\n\n return (\n <PresentationDisplayedDocumentContext.Provider value={context}>\n {children}\n </PresentationDisplayedDocumentContext.Provider>\n )\n}\n\nexport function useDisplayedDocumentBroadcaster(): PresentationDisplayedDocumentContextValue | null {\n return useContext(PresentationDisplayedDocumentContext)\n}\n"],"names":["DisplayedDocumentBroadcasterProvider","props","$","_c","children","setDisplayedDocument","documentId","t0","next","prev","isEqual","context","t1","t2","timeout","setTimeout","clearTimeout","useEffect","t3","useDisplayedDocumentBroadcaster","useContext","PresentationDisplayedDocumentContext"],"mappings":";;;;;AAsBO,SAAAA,qCAAAC,OAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAGL;AAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAqDL;AAAK,MAAAM;AAAAL,WAAAG,wBAGxDE,KAAAC,UAAUH,qBAAqBI,CAAAA,SAAWC,QAAQD,MAAMD,IAAkB,IAAhCC,OAAAD,IAAkC,GAACN,OAAAG,sBAAAH,OAAAK,MAAAA,KAAAL,EAAA,CAAA;AAD/E,QAAAS,UAAgBJ;AAGf,MAAAK,IAAAC;AAAAX,IAAA,CAAA,MAAAI,cAAAJ,SAAAG,wBAESO,KAAAA,MAAA;AAER,QAAIN;AAAU;AAGd,UAAAQ,UAAgBC,WAAW,MAAMV,qBAAqB,IAAI,CAAC;AAAC,WACrD,MAAMW,aAAaF,OAAO;AAAA,EAAC,GACjCD,KAAA,CAACP,YAAYD,oBAAoB,GAACH,OAAAI,YAAAJ,OAAAG,sBAAAH,OAAAU,IAAAV,OAAAW,OAAAD,KAAAV,EAAA,CAAA,GAAAW,KAAAX,EAAA,CAAA,IAPrCe,UAAUL,IAOPC,EAAkC;AAAC,MAAAK;AAAA,SAAAhB,EAAA,CAAA,MAAAE,YAAAF,SAAAS,WAGpCO,KAAA,oBAAA,qCAAA,UAAA,EAAsDP,OAAAA,SACnDP,SAAAA,CACH,GAAgDF,OAAAE,UAAAF,OAAAS,SAAAT,OAAAgB,MAAAA,KAAAhB,EAAA,CAAA,GAFhDgB;AAEgD;AAI7C,SAAAC,kCAAA;AAAA,SACEC,WAAWC,oCAAoC;AAAC;"}
|