@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.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -0
  3. package/bin/sanity +209 -0
  4. package/changes.json +114 -0
  5. package/lib/_chunks-dts/ActiveWorkspaceMatcherContext.d.ts +16164 -0
  6. package/lib/_chunks-dts/index.d.ts +780 -0
  7. package/lib/_chunks-dts/types.d.ts +2765 -0
  8. package/lib/_chunks-dts/types2.d.ts +656 -0
  9. package/lib/_chunks-dts/types3.d.ts +303 -0
  10. package/lib/_chunks-es/BroadcastDisplayedDocument.js +20 -0
  11. package/lib/_chunks-es/BroadcastDisplayedDocument.js.map +1 -0
  12. package/lib/_chunks-es/DisplayedDocumentBroadcaster.js +32 -0
  13. package/lib/_chunks-es/DisplayedDocumentBroadcaster.js.map +1 -0
  14. package/lib/_chunks-es/LiveQueries.js +339 -0
  15. package/lib/_chunks-es/LiveQueries.js.map +1 -0
  16. package/lib/_chunks-es/MenuGroup.js +106 -0
  17. package/lib/_chunks-es/MenuGroup.js.map +1 -0
  18. package/lib/_chunks-es/PostMessageDocuments.js +72 -0
  19. package/lib/_chunks-es/PostMessageDocuments.js.map +1 -0
  20. package/lib/_chunks-es/PostMessagePerspective.js +23 -0
  21. package/lib/_chunks-es/PostMessagePerspective.js.map +1 -0
  22. package/lib/_chunks-es/PostMessagePreviewSnapshots.js +69 -0
  23. package/lib/_chunks-es/PostMessagePreviewSnapshots.js.map +1 -0
  24. package/lib/_chunks-es/PostMessageRefreshMutations.js +74 -0
  25. package/lib/_chunks-es/PostMessageRefreshMutations.js.map +1 -0
  26. package/lib/_chunks-es/PostMessageSchema.js +502 -0
  27. package/lib/_chunks-es/PostMessageSchema.js.map +1 -0
  28. package/lib/_chunks-es/PostMessageTelemetry.js +21 -0
  29. package/lib/_chunks-es/PostMessageTelemetry.js.map +1 -0
  30. package/lib/_chunks-es/PresentationToolGrantsCheck.js +3848 -0
  31. package/lib/_chunks-es/PresentationToolGrantsCheck.js.map +1 -0
  32. package/lib/_chunks-es/QRCodeSVG.js +692 -0
  33. package/lib/_chunks-es/QRCodeSVG.js.map +1 -0
  34. package/lib/_chunks-es/StructureToolProvider.js +2360 -0
  35. package/lib/_chunks-es/StructureToolProvider.js.map +1 -0
  36. package/lib/_chunks-es/VideoPlayer.js +22 -0
  37. package/lib/_chunks-es/VideoPlayer.js.map +1 -0
  38. package/lib/_chunks-es/ViteDevServerStopped.js +52 -0
  39. package/lib/_chunks-es/ViteDevServerStopped.js.map +1 -0
  40. package/lib/_chunks-es/index.js +285 -0
  41. package/lib/_chunks-es/index.js.map +1 -0
  42. package/lib/_chunks-es/index2.js +105 -0
  43. package/lib/_chunks-es/index2.js.map +1 -0
  44. package/lib/_chunks-es/index3.js +139 -0
  45. package/lib/_chunks-es/index3.js.map +1 -0
  46. package/lib/_chunks-es/index4.js +1020 -0
  47. package/lib/_chunks-es/index4.js.map +1 -0
  48. package/lib/_chunks-es/pane.js +5 -0
  49. package/lib/_chunks-es/pane.js.map +1 -0
  50. package/lib/_chunks-es/pane2.js +5 -0
  51. package/lib/_chunks-es/pane2.js.map +1 -0
  52. package/lib/_chunks-es/presentation.js +549 -0
  53. package/lib/_chunks-es/presentation.js.map +1 -0
  54. package/lib/_chunks-es/resources.js +303 -0
  55. package/lib/_chunks-es/resources.js.map +1 -0
  56. package/lib/_chunks-es/resources2.js +459 -0
  57. package/lib/_chunks-es/resources2.js.map +1 -0
  58. package/lib/_chunks-es/resources3.js +281 -0
  59. package/lib/_chunks-es/resources3.js.map +1 -0
  60. package/lib/_chunks-es/resources4.js +184 -0
  61. package/lib/_chunks-es/resources4.js.map +1 -0
  62. package/lib/_chunks-es/resources5.js +161 -0
  63. package/lib/_chunks-es/resources5.js.map +1 -0
  64. package/lib/_chunks-es/resources6.js +141 -0
  65. package/lib/_chunks-es/resources6.js.map +1 -0
  66. package/lib/_chunks-es/resources7.js +24 -0
  67. package/lib/_chunks-es/resources7.js.map +1 -0
  68. package/lib/_chunks-es/resources8.js +603 -0
  69. package/lib/_chunks-es/resources8.js.map +1 -0
  70. package/lib/_chunks-es/resources9.js +126 -0
  71. package/lib/_chunks-es/resources9.js.map +1 -0
  72. package/lib/_chunks-es/structureTool.js +13673 -0
  73. package/lib/_chunks-es/structureTool.js.map +1 -0
  74. package/lib/_chunks-es/version.js +17 -0
  75. package/lib/_chunks-es/version.js.map +1 -0
  76. package/lib/_createContext.d.ts +12 -0
  77. package/lib/_createContext.js +38 -0
  78. package/lib/_createContext.js.map +1 -0
  79. package/lib/_internal.d.ts +9 -0
  80. package/lib/_internal.js +12 -0
  81. package/lib/_internal.js.map +1 -0
  82. package/lib/_singletons.d.ts +951 -0
  83. package/lib/_singletons.js +284 -0
  84. package/lib/_singletons.js.map +1 -0
  85. package/lib/cli.d.ts +3 -0
  86. package/lib/cli.js +9 -0
  87. package/lib/cli.js.map +1 -0
  88. package/lib/desk.d.ts +910 -0
  89. package/lib/desk.js +71 -0
  90. package/lib/desk.js.map +1 -0
  91. package/lib/index.d.ts +4 -0
  92. package/lib/index.js +92934 -0
  93. package/lib/index.js.map +1 -0
  94. package/lib/media-library.d.ts +85 -0
  95. package/lib/media-library.js +11 -0
  96. package/lib/media-library.js.map +1 -0
  97. package/lib/migrate.d.ts +1 -0
  98. package/lib/migrate.js +2 -0
  99. package/lib/migrate.js.map +1 -0
  100. package/lib/presentation.d.ts +28 -0
  101. package/lib/presentation.js +10 -0
  102. package/lib/presentation.js.map +1 -0
  103. package/lib/router.d.ts +560 -0
  104. package/lib/router.js +777 -0
  105. package/lib/router.js.map +1 -0
  106. package/lib/structure.d.ts +3 -0
  107. package/lib/structure.js +639 -0
  108. package/lib/structure.js.map +1 -0
  109. package/mock-browser-env-stub-loader.mjs +27 -0
  110. package/package.json +383 -0
  111. package/static/favicons/apple-touch-icon.png +0 -0
  112. package/static/favicons/favicon-192.png +0 -0
  113. package/static/favicons/favicon-512.png +0 -0
  114. package/static/favicons/favicon-96.png +0 -0
  115. package/static/favicons/favicon.ico +0 -0
  116. package/static/favicons/favicon.svg +12 -0
@@ -0,0 +1,656 @@
1
+ import { ComponentType, RefObject } from "react";
2
+ import { SanityDocument } from "@sanity/types";
3
+ import { ClientPerspective, StackablePerspective } from "@sanity/client";
4
+ import { Observable } from "rxjs";
5
+ import { DocumentStore, DocumentValuePermission, PermissionCheckResult, SanityClient as SanityClient$1 } from "sanity";
6
+ import { PreviewUrlResolver } from "@sanity/preview-url-secret/define-preview-url";
7
+ import * as xstate from "xstate";
8
+ import { ActorRefFrom } from "xstate";
9
+ interface Context$2 {
10
+ url: URL | null;
11
+ error: Error | null;
12
+ visualEditingOverlaysEnabled: boolean;
13
+ }
14
+ declare const presentationMachine: xstate.StateMachine<Context$2, {
15
+ type: "toggle visual editing overlays";
16
+ enabled: boolean;
17
+ } | {
18
+ type: "iframe loaded";
19
+ } | {
20
+ type: "iframe refresh";
21
+ } | {
22
+ type: "iframe reload";
23
+ }, {}, never, never, never, never, "error" | "loading" | {
24
+ loaded: "idle" | "refreshing" | "reloading";
25
+ }, "busy" | "error", xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
26
+ id: "Presentation Tool";
27
+ states: {
28
+ readonly error: {};
29
+ readonly loading: {};
30
+ readonly loaded: {
31
+ states: {
32
+ readonly idle: {};
33
+ readonly refreshing: {};
34
+ readonly reloading: {};
35
+ };
36
+ };
37
+ };
38
+ }>;
39
+ type PresentationMachineRef = ActorRefFrom<typeof presentationMachine>;
40
+ /** @internal */
41
+ interface ResolvePreviewModeUrlInput {
42
+ previewUrlSecret: string;
43
+ resolvedPreviewMode: PreviewUrlPreviewMode;
44
+ initialUrl: URL;
45
+ }
46
+ interface Context$1 {
47
+ initialUrl: URL | null;
48
+ previewUrl: URL | null;
49
+ allowOrigins: URLPattern[] | null;
50
+ error: Error | null;
51
+ previewSearchParam: string | null;
52
+ previewUrlSecret: {
53
+ secret: string;
54
+ expiresAt: Date;
55
+ } | null;
56
+ previewAccessSharingCreatePermission: PermissionCheckResult | null;
57
+ previewAccessSharingReadPermission: PermissionCheckResult | null;
58
+ previewAccessSharingUpdatePermission: PermissionCheckResult | null;
59
+ previewUrlSecretPermission: PermissionCheckResult | null;
60
+ previewMode: PreviewUrlPreviewMode | null;
61
+ }
62
+ type SetPreviewSearchParamEvent = {
63
+ type: 'set preview search param';
64
+ previewSearchParam: string | null;
65
+ };
66
+ type Input = Omit<SetPreviewSearchParamEvent, 'type'>;
67
+ interface CheckPermissionInput {
68
+ checkPermissionName: DocumentValuePermission;
69
+ document: Partial<SanityDocument> | null;
70
+ }
71
+ declare const previewUrlMachine: xstate.StateMachine<Context$1, SetPreviewSearchParamEvent, {
72
+ [x: string]: xstate.ActorRefFromLogic<xstate.ObservableActorLogic<PermissionCheckResult, CheckPermissionInput, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<URLPattern[], {
73
+ initialUrl: URL;
74
+ }, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<URL, ResolvePreviewModeUrlInput, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<URL, {
75
+ initialUrl: URL;
76
+ previewSearchParam: string | null | undefined;
77
+ allowOrigins: URLPattern[];
78
+ }, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<URL, {
79
+ previewSearchParam: string | null;
80
+ }, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<{
81
+ secret: string;
82
+ expiresAt: Date;
83
+ }, xstate.NonReducibleUnknown, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<string | null, xstate.NonReducibleUnknown, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<false | PreviewUrlPreviewMode, {
84
+ targetOrigin: string;
85
+ }, xstate.EventObject>> | undefined;
86
+ }, {
87
+ src: "check permission";
88
+ logic: xstate.ObservableActorLogic<PermissionCheckResult, CheckPermissionInput, xstate.EventObject>;
89
+ id: string | undefined;
90
+ } | {
91
+ src: "create preview secret";
92
+ logic: xstate.PromiseActorLogic<{
93
+ secret: string;
94
+ expiresAt: Date;
95
+ }, xstate.NonReducibleUnknown, xstate.EventObject>;
96
+ id: string | undefined;
97
+ } | {
98
+ src: "read shared preview secret";
99
+ logic: xstate.PromiseActorLogic<string | null, xstate.NonReducibleUnknown, xstate.EventObject>;
100
+ id: string | undefined;
101
+ } | {
102
+ src: "resolve allow patterns";
103
+ logic: xstate.PromiseActorLogic<URLPattern[], {
104
+ initialUrl: URL;
105
+ }, xstate.EventObject>;
106
+ id: string | undefined;
107
+ } | {
108
+ src: "resolve initial url";
109
+ logic: xstate.PromiseActorLogic<URL, {
110
+ previewSearchParam: string | null;
111
+ }, xstate.EventObject>;
112
+ id: string | undefined;
113
+ } | {
114
+ src: "resolve preview mode";
115
+ logic: xstate.PromiseActorLogic<false | PreviewUrlPreviewMode, {
116
+ targetOrigin: string;
117
+ }, xstate.EventObject>;
118
+ id: string | undefined;
119
+ } | {
120
+ src: "resolve preview mode url";
121
+ logic: xstate.PromiseActorLogic<URL, ResolvePreviewModeUrlInput, xstate.EventObject>;
122
+ id: string | undefined;
123
+ } | {
124
+ src: "resolve url from preview search param";
125
+ logic: xstate.PromiseActorLogic<URL, {
126
+ initialUrl: URL;
127
+ previewSearchParam: string | null | undefined;
128
+ allowOrigins: URLPattern[];
129
+ }, xstate.EventObject>;
130
+ id: string | undefined;
131
+ }, {
132
+ type: "assign error";
133
+ params: {
134
+ message: string;
135
+ error: unknown;
136
+ };
137
+ } | {
138
+ type: "assign preview search param";
139
+ params: {
140
+ previewSearchParam: string | null;
141
+ };
142
+ } | {
143
+ type: "notify preview will likely fail";
144
+ params: xstate.NonReducibleUnknown;
145
+ }, {
146
+ type: "can create preview secret";
147
+ params: unknown;
148
+ } | {
149
+ type: "has checked permissions";
150
+ params: unknown;
151
+ } | {
152
+ type: "has preview mode with created secret";
153
+ params: false | PreviewUrlPreviewMode;
154
+ } | {
155
+ type: "has preview mode with share access";
156
+ params: false | PreviewUrlPreviewMode;
157
+ } | {
158
+ type: "has preview mode without permissions";
159
+ params: false | PreviewUrlPreviewMode;
160
+ } | {
161
+ type: "search param has new origin";
162
+ params: unknown;
163
+ }, "expiredSecret", "checkingPermissions" | "error" | "resolvingAllowPatterns" | "resolvingInitialUrl" | "resolvingPreviewMode" | "resolvingUrlFromPreviewSearchParam" | "success" | {
164
+ previewMode: "createPreviewSecret" | "error" | "readShareAccess" | "resolvePreviewUrl" | "success";
165
+ }, "busy" | "error", Input, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
166
+ id: "Preview URL";
167
+ states: {
168
+ readonly checkingPermissions: {};
169
+ readonly resolvingInitialUrl: {};
170
+ readonly error: {};
171
+ readonly resolvingAllowPatterns: {};
172
+ readonly resolvingUrlFromPreviewSearchParam: {
173
+ id: "loop";
174
+ };
175
+ readonly resolvingPreviewMode: {};
176
+ readonly success: {};
177
+ readonly previewMode: {
178
+ states: {
179
+ readonly createPreviewSecret: {};
180
+ readonly readShareAccess: {};
181
+ readonly resolvePreviewUrl: {};
182
+ readonly error: {};
183
+ readonly success: {};
184
+ };
185
+ };
186
+ };
187
+ }>;
188
+ type PreviewUrlRef = ActorRefFrom<typeof previewUrlMachine>;
189
+ /** @public */
190
+ interface PreviewProps {
191
+ canSharePreviewAccess: boolean;
192
+ canToggleSharePreviewAccess: boolean;
193
+ canUseSharedPreviewAccess: boolean;
194
+ header?: HeaderOptions;
195
+ initialUrl: URL;
196
+ loadersConnection: ConnectionStatus;
197
+ navigatorEnabled: boolean;
198
+ onPathChange: (nextPath: string) => void;
199
+ onRefresh: (fallback: () => void) => void;
200
+ openPopup: (url: string) => void;
201
+ overlaysConnection: ConnectionStatus;
202
+ presentationRef: PresentationMachineRef;
203
+ perspective: PresentationPerspective;
204
+ previewUrl?: string;
205
+ setViewport: (mode: 'desktop' | 'mobile') => void;
206
+ targetOrigin: string;
207
+ toggleNavigator?: () => void;
208
+ toggleOverlay: () => void;
209
+ viewport: PresentationViewport;
210
+ vercelProtectionBypass: string | null;
211
+ previewUrlRef: PreviewUrlRef;
212
+ }
213
+ /** @public */
214
+ interface PreviewHeaderProps extends PreviewProps {
215
+ iframeRef: RefObject<HTMLIFrameElement | null>;
216
+ renderDefault: (props: PreviewHeaderProps) => React.JSX.Element;
217
+ }
218
+ /**
219
+ * Represents a document location
220
+ * @public
221
+ */
222
+ interface DocumentLocation {
223
+ /**
224
+ * Title of the document
225
+ */
226
+ title: string;
227
+ /**
228
+ * URL of the document location
229
+ */
230
+ href: string;
231
+ /**
232
+ * Optional icon component to display instead of the default DesktopIcon
233
+ */
234
+ icon?: ComponentType;
235
+ /**
236
+ * Whether to show the href below the title. Defaults to true
237
+ */
238
+ showHref?: boolean;
239
+ }
240
+ /**
241
+ * State for describing document locations or providing a message if locations are unavailable
242
+ * @public
243
+ */
244
+ interface DocumentLocationsState {
245
+ /**
246
+ * Array of document locations
247
+ */
248
+ locations?: DocumentLocation[];
249
+ /**
250
+ * Message to display if locations are unavailable
251
+ */
252
+ message?: string;
253
+ /**
254
+ * Tone of the message
255
+ */
256
+ tone?: 'positive' | 'caution' | 'critical';
257
+ }
258
+ /**
259
+ * Function used for advanced document location resolution
260
+ * @param params - Object with document `id` and document `type` properties
261
+ * @param context - Object with `documentStore` property for creating listenQuery subscriptions
262
+ * @returns Document location state, optionally as an Observable, or null/undefined if no locations are available
263
+ * @public
264
+ */
265
+ type DocumentLocationResolver = (params: {
266
+ id: string;
267
+ type: string;
268
+ version: string | undefined;
269
+ perspectiveStack: StackablePerspective[];
270
+ }, context: {
271
+ documentStore: DocumentStore;
272
+ }) => DocumentLocationsState | null | undefined | Observable<DocumentLocationsState | null | undefined>;
273
+ /**
274
+ * Configuration options for Presentation tool's optional navigator component
275
+ * The navigator appears as a resizable sidebar panel
276
+ *
277
+ * @public
278
+ */
279
+ interface NavigatorOptions {
280
+ /**
281
+ * Minimum width of the navigator panel in pixels
282
+ */
283
+ minWidth?: number;
284
+ /**
285
+ * Maximum width of the navigator panel in pixels
286
+ */
287
+ maxWidth?: number;
288
+ /**
289
+ * React component to render in the navigator panel
290
+ */
291
+ component: ComponentType;
292
+ }
293
+ /**
294
+ * Configuration options for Presentation tool's optional custom preview header component
295
+ *
296
+ * @public
297
+ */
298
+ interface HeaderOptions {
299
+ /**
300
+ * React component to render as the preview header, receives PreviewHeaderProps
301
+ */
302
+ component: ComponentType<PreviewHeaderProps>;
303
+ }
304
+ /** @public */
305
+ interface PreviewUrlAllowOptionContext {
306
+ client: SanityClient$1;
307
+ /**
308
+ * Equivalent to `location.origin`
309
+ */
310
+ origin: string;
311
+ /**
312
+ * The initial URL of the preview
313
+ */
314
+ initialUrl: URL;
315
+ }
316
+ /** @public */
317
+ interface PreviewUrlInitialOptionContext {
318
+ client: SanityClient$1;
319
+ /**
320
+ * Equivalent to `location.origin`
321
+ */
322
+ origin: string;
323
+ }
324
+ /** @public */
325
+ interface PreviewUrlPreviewModeOptionContext {
326
+ client: SanityClient$1;
327
+ /**
328
+ * Equivalent to `location.origin`
329
+ */
330
+ origin: string;
331
+ /**
332
+ * The origin on the URL that will be used in the preview iframe
333
+ */
334
+ targetOrigin: string;
335
+ }
336
+ /** @public */
337
+ type PreviewUrlAllowOption = string | string[] | ((context: PreviewUrlAllowOptionContext) => string | string[] | Promise<string | string[]>);
338
+ /** @public */
339
+ type PreviewUrlInitialOption = string | ((context: PreviewUrlInitialOptionContext) => string | Promise<string>);
340
+ /** @public */
341
+ type PreviewUrlPreviewModeOption = PreviewUrlPreviewMode | ((context: PreviewUrlPreviewModeOptionContext) => false | PreviewUrlPreviewMode | Promise<false | PreviewUrlPreviewMode>);
342
+ /** @public */
343
+ interface PreviewUrlPreviewMode {
344
+ /**
345
+ * The route that enables Preview Mode
346
+ * @example '/api/preview'
347
+ * @example '/api/draft-mode/enable'
348
+ */
349
+ enable: string;
350
+ /**
351
+ * Allow sharing access to a preview with others.
352
+ * This is enabled/disabled in the Presentation Tool. It's initially disabled, and can be enabled by someone who has access to creating draft documents in the Studio.
353
+ * Custom roles can limit access to `_id in path("drafts.**") && _type == "sanity.previewUrlSecret"`.
354
+ * This will create a secret that is valid until sharing is disabled. Turning sharing off and on again will create a new secret and can be used to remove access for folks that got the link in an email but should no longer have access.
355
+ * Share URLs to previews will append this secret and give access to anyone who is given the URL, they don't need to be logged into the Studio or to Vercel.
356
+ */
357
+ shareAccess?: boolean;
358
+ /**
359
+ * The route that reports if Preview Mode is enabled or not, useful for debugging
360
+ * @example '/api/check-preview'
361
+ * @deprecated - this API is not yet implemented
362
+ */
363
+ check?: string;
364
+ /**
365
+ * The route that disables Preview Mode, useful for debugging
366
+ * @example '/api/disable-preview'
367
+ * @deprecated - this API is not yet implemented
368
+ */
369
+ disable?: string;
370
+ }
371
+ /**
372
+ * @public
373
+ */
374
+ interface PreviewUrlResolverOptions {
375
+ /**
376
+ * The default preview URL, used when the URL to use is not yet known, or there's no `&preview=...` search param in the studio URL.
377
+ * @example '/en/preview?q=shoes'
378
+ * @example 'https://example.com'
379
+ * @defaultValue `location.origin`
380
+ */
381
+ initial?: PreviewUrlInitialOption;
382
+ previewMode?: PreviewUrlPreviewModeOption;
383
+ /**
384
+ * @defaultValue `location.origin`
385
+ * @deprecated - use `initial` instead
386
+ */
387
+ origin?: string;
388
+ /**
389
+ * @defaultValue '/'
390
+ * @deprecated - use `initial` instead
391
+ */
392
+ preview?: string;
393
+ /**
394
+ * @deprecated - use `previewMode` instead
395
+ */
396
+ draftMode?: {
397
+ /**
398
+ * @deprecated - use `previewMode.enable` instead
399
+ */
400
+ enable: string;
401
+ /**
402
+ * @deprecated - use `previewMode.shareAccess` instead
403
+ */
404
+ shareAccess?: boolean;
405
+ /**
406
+ * @deprecated - use `previewMode.check` instead
407
+ */
408
+ check?: string;
409
+ /**
410
+ * @deprecated - use `previewMode.disable` instead
411
+ */
412
+ disable?: string;
413
+ };
414
+ }
415
+ /**
416
+ * @deprecated the `previewUrl.initial`, `previewUrl.allowOrigins` and `previewUrl.previewMode.enable` supports async functions that offer advanced control over how preview URLs are resolved
417
+ * @public
418
+ */
419
+ type DeprecatedPreviewUrlResolver = PreviewUrlResolver<SanityClient$1>;
420
+ /** @public */
421
+ type PreviewUrlOption = string | DeprecatedPreviewUrlResolver | PreviewUrlResolverOptions;
422
+ /**
423
+ * Object of document location resolver definitions per document type
424
+ * @public
425
+ */
426
+ type DocumentLocationResolvers = Record<string, DocumentLocationResolverObject | DocumentLocationsState>;
427
+ /**
428
+ * Document location resolver object
429
+ * @public
430
+ */
431
+ type DocumentLocationResolverObject<K extends string = string> = {
432
+ /**
433
+ * Object for selecting document fields
434
+ */
435
+ select: Record<K, string>;
436
+ /**
437
+ * Function that accepts a document with the selected fields and returns an optional document location state
438
+ */
439
+ resolve: (value: Record<K, any> | null) => DocumentLocationsState | null | undefined | void;
440
+ };
441
+ /**
442
+ * Context object passed to functions used in `DocumentResolver` definitions.
443
+ * Contains information about the current URL being matched against route patterns.
444
+ *
445
+ * @example
446
+ * For a route pattern `/blog/:category/:slug` matching URL `https://example.com/blog/tech/hello-world`:
447
+ * ```ts
448
+ * {
449
+ * origin: 'https://example.com',
450
+ * params: { category: 'tech', slug: 'hello-world' },
451
+ * path: '/blog/tech/hello-world'
452
+ * }
453
+ * ```
454
+ *
455
+ * @public
456
+ */
457
+ interface DocumentResolverContext {
458
+ /**
459
+ * The origin (protocol + hostname + port) of the matched URL
460
+ */
461
+ origin: string;
462
+ /**
463
+ * Extracted route parameters from URL path matching (e.g., `:slug` → `{slug: 'value'}`)
464
+ */
465
+ params: Record<string, string>;
466
+ /**
467
+ * The pathname of the matched URL (without query parameters)
468
+ */
469
+ path: string;
470
+ }
471
+ /**
472
+ * Generic function type used in `DocumentResolver` definitions that receives a `DocumentResolverContext` and returns a computed value.
473
+ * @param context - `DocumentResolverContext` containing route information (origin, params, path)
474
+ * @returns Computed value based on the context (typically a string for filters or an object for parameters)
475
+ * @public
476
+ */
477
+ type ContextFn<T> = (context: DocumentResolverContext) => T;
478
+ /**
479
+ * Configuration object for resolving documents based on URL route patterns.
480
+ * Used to define the main document when navigating to specific URLs in
481
+ * Presentation tool's preview iframe.
482
+ *
483
+ * Supports three different resolution strategies:
484
+ *
485
+ * **Simple type-based resolution:**
486
+ * ```ts
487
+ * {
488
+ * route: '/blog',
489
+ * type: 'blog' // Useful for singleton documents
490
+ * }
491
+ * ```
492
+ *
493
+ * **GROQ filter-based resolution:**
494
+ * ```ts
495
+ * {
496
+ * route: '/blog/:category/:slug',
497
+ * filter: ({ params }) => `_type == "post" && slug.current == "${params.slug}"`,
498
+ * params: ({ params }) => ({ category: params.category })
499
+ * }
500
+ * ```
501
+ *
502
+ * **Advanced resolution with custom logic:**
503
+ * ```ts
504
+ * {
505
+ * route: '/products/:id',
506
+ * resolve: ({ params }) => ({
507
+ * filter: `_type == "product" && _id == $id`,
508
+ * params: { id: params.id }
509
+ * })
510
+ * }
511
+ * ```
512
+ *
513
+ * @public
514
+ */
515
+ type DocumentResolver = {
516
+ route: string | Array<string>;
517
+ type: string;
518
+ filter?: never;
519
+ params?: never;
520
+ resolve?: never;
521
+ } | {
522
+ route: string | Array<string>;
523
+ type?: never;
524
+ filter: ContextFn<string> | string;
525
+ params?: ContextFn<Record<string, string>> | Record<string, string>;
526
+ resolve?: never;
527
+ } | {
528
+ route: string | Array<string>;
529
+ type?: never;
530
+ filter?: never;
531
+ params?: never;
532
+ resolve: ContextFn<{
533
+ filter: string;
534
+ params?: Record<string, string>;
535
+ } | undefined>;
536
+ };
537
+ /**
538
+ * Configuration options for the Presentation tool.
539
+ * @public
540
+ */
541
+ interface PresentationPluginOptions {
542
+ devMode?: boolean | (() => boolean);
543
+ icon?: ComponentType;
544
+ name?: string;
545
+ title?: string;
546
+ allowOrigins?: PreviewUrlAllowOption;
547
+ previewUrl: PreviewUrlOption;
548
+ /**
549
+ * @deprecated use `resolve.locations` instead
550
+ */
551
+ locate?: DocumentLocationResolver;
552
+ resolve?: {
553
+ mainDocuments?: DocumentResolver[];
554
+ locations?: DocumentLocationResolvers | DocumentLocationResolver;
555
+ };
556
+ components?: {
557
+ unstable_header?: HeaderOptions;
558
+ unstable_navigator?: NavigatorOptions;
559
+ };
560
+ /**
561
+ * @deprecated this feature flag is no longer needed
562
+ */
563
+ unstable_showUnsafeShareUrl?: boolean;
564
+ }
565
+ /**
566
+ * Presentation specific state that is stored in the pathname section of the URL
567
+ * @public
568
+ */
569
+ interface PresentationStateParams {
570
+ type?: string;
571
+ id?: string;
572
+ path?: string;
573
+ }
574
+ /**
575
+ * Presentation specific URL search parameters, they should persist when
576
+ * navigating between the document pane and document list pane
577
+ * @public
578
+ */
579
+ interface PresentationSearchParams {
580
+ preview?: string;
581
+ perspective?: string;
582
+ viewport?: string;
583
+ }
584
+ /**
585
+ * Document Pane specific URL search parameters, they should not persist when
586
+ * navigating between the document pane and document list pane
587
+ * @public
588
+ */
589
+ interface StructureDocumentPaneParams extends InspectorTab {
590
+ inspect?: string;
591
+ parentRefPath?: string;
592
+ path?: string;
593
+ rev?: string;
594
+ since?: string;
595
+ template?: string;
596
+ templateParams?: string;
597
+ version?: string;
598
+ view?: string;
599
+ pathKey?: string;
600
+ instruction?: string;
601
+ comment?: string;
602
+ scheduledDraft?: string;
603
+ }
604
+ /**
605
+ * parameters for the changes inspector
606
+ * @public
607
+ */
608
+ interface InspectorTab {
609
+ changesInspectorTab?: 'history' | 'review';
610
+ }
611
+ /**
612
+ * All possible URL search parameters used by the Presentation tool
613
+ * @public
614
+ */
615
+ interface CombinedSearchParams extends StructureDocumentPaneParams, PresentationSearchParams {}
616
+ /**
617
+ * All possible parameters that can be used to describe the state of the
618
+ * Presentation tool, stored in the pathname and as search parameters of the URL
619
+ * @public
620
+ */
621
+ interface PresentationParamsContextValue extends PresentationStateParams, CombinedSearchParams {}
622
+ /** @public */
623
+ type PresentationNavigateOptions = ({
624
+ state: PresentationStateParams;
625
+ params?: CombinedSearchParams;
626
+ } | {
627
+ params: CombinedSearchParams;
628
+ state?: PresentationStateParams;
629
+ }) & {
630
+ replace?: boolean;
631
+ };
632
+ /** @public */
633
+ type PresentationNavigate = (options: PresentationNavigateOptions) => void;
634
+ /** @public */
635
+ type PresentationPerspective = Exclude<ClientPerspective, 'raw'>;
636
+ /** @public */
637
+ type PresentationViewport = 'desktop' | 'mobile';
638
+ /**
639
+ * Represents the connection status between the Sanity Studio and Presentation's preview iframe.
640
+ * @public
641
+ */
642
+ type ConnectionStatus = 'connected' | 'connecting' | 'reconnecting' | 'idle';
643
+ /** @public */
644
+ type PresentationNavigateContextValue = (preview: string | undefined, document?: {
645
+ type: string;
646
+ id: string;
647
+ }) => void;
648
+ interface PresentationContextValue {
649
+ devMode: boolean;
650
+ name: string;
651
+ navigate: PresentationNavigate;
652
+ params: PresentationParamsContextValue;
653
+ structureParams: StructureDocumentPaneParams;
654
+ searchParams: PresentationSearchParams;
655
+ }
656
+ export { PreviewUrlResolver as C, PreviewProps as D, PreviewHeaderProps as E, PreviewUrlOption as S, StructureDocumentPaneParams as T, PresentationPerspective as _, DocumentLocationResolver as a, PresentationStateParams as b, DocumentLocationsState as c, HeaderOptions as d, InspectorTab as f, PresentationParamsContextValue as g, PresentationNavigateContextValue as h, DocumentLocation as i, DocumentResolver as l, PresentationContextValue as m, ConnectionStatus as n, DocumentLocationResolverObject as o, NavigatorOptions as p, ContextFn as r, DocumentLocationResolvers as s, CombinedSearchParams as t, DocumentResolverContext as u, PresentationPluginOptions as v, PreviewUrlResolverOptions as w, PresentationViewport as x, PresentationSearchParams as y };