@sanity/sdk-react 3.1.0 → 3.2.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 (54) hide show
  1. package/dist/_exports/dashboard-internal.d.ts +2 -0
  2. package/dist/_exports/dashboard-internal.js +2 -0
  3. package/dist/_exports/dashboard.d.ts +457 -7
  4. package/dist/_exports/dashboard.d.ts.map +1 -1
  5. package/dist/_exports/dashboard.js +623 -2
  6. package/dist/_exports/dashboard.js.map +1 -1
  7. package/dist/index.d.ts +90 -87
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +4 -5
  10. package/dist/index.js.map +1 -1
  11. package/dist/{useStudioWorkspacesByProjectIdDataset-DxUlukmF.js → useStudioWorkspacesByProjectIdDataset-BZ_Ud887.js} +53 -56
  12. package/dist/useStudioWorkspacesByProjectIdDataset-BZ_Ud887.js.map +1 -0
  13. package/package.json +34 -32
  14. package/src/_exports/dashboard-internal.ts +1 -0
  15. package/src/_exports/dashboard.test-d.ts +64 -0
  16. package/src/_exports/dashboard.ts +70 -0
  17. package/src/_exports/index.ts +1 -1
  18. package/src/components/auth/AuthBoundary.test.tsx +34 -0
  19. package/src/components/auth/AuthBoundary.tsx +1 -2
  20. package/src/context/DashboardTokenRefresh.test.tsx +124 -22
  21. package/src/context/DashboardTokenRefresh.tsx +31 -15
  22. package/src/dashboard/createRemoteInstance.test.ts +168 -0
  23. package/src/dashboard/createRemoteInstance.ts +123 -0
  24. package/src/dashboard/module.ts +39 -0
  25. package/src/dashboard/remoteClientState.ts +27 -0
  26. package/src/dashboard/urlFor.test.ts +246 -0
  27. package/src/dashboard/urlFor.ts +462 -0
  28. package/src/hooks/applications/useApplication.test-d.ts +1 -1
  29. package/src/hooks/dashboard/useApplication.test.tsx +59 -0
  30. package/src/hooks/dashboard/useApplication.ts +22 -0
  31. package/src/hooks/dashboard/useApplicationConfig.test.tsx +106 -0
  32. package/src/hooks/dashboard/useApplicationConfig.ts +45 -0
  33. package/src/hooks/dashboard/useApplicationConfigs.test.tsx +89 -0
  34. package/src/hooks/dashboard/useApplicationConfigs.ts +26 -0
  35. package/src/hooks/dashboard/useApplicationForegroundId.test.tsx +54 -0
  36. package/src/hooks/dashboard/useApplicationForegroundId.ts +22 -0
  37. package/src/hooks/dashboard/useApplications.test.tsx +249 -0
  38. package/src/hooks/dashboard/useApplications.ts +128 -0
  39. package/src/hooks/dashboard/useEmit.test.tsx +124 -0
  40. package/src/hooks/dashboard/useEmit.ts +78 -0
  41. package/src/hooks/dashboard/useNavigate.ts +1 -3
  42. package/src/hooks/dashboard/useRemoteClient.test.tsx +88 -0
  43. package/src/hooks/dashboard/useRemoteClient.ts +10 -0
  44. package/src/hooks/dashboard/useTopic.test.tsx +200 -0
  45. package/src/hooks/dashboard/useTopic.ts +29 -0
  46. package/src/hooks/dashboard/useUpdateFavorite.test.tsx +8 -1
  47. package/src/hooks/document/useApplyDocumentActions.ts +3 -4
  48. package/src/hooks/document/useCreateDocument.ts +2 -3
  49. package/src/hooks/document/useDocument.ts +11 -6
  50. package/src/hooks/document/useEditDocument.ts +5 -5
  51. package/src/hooks/projection/useDocumentProjection.ts +6 -7
  52. package/src/hooks/query/useQuery.ts +3 -4
  53. package/dist/useStudioWorkspacesByProjectIdDataset-DxUlukmF.js.map +0 -1
  54. package/src/context/dashboardToken.ts +0 -63
@@ -0,0 +1,2 @@
1
+ import { installMessageBus, resetMessageBus } from "@sanity/sdk/_internal";
2
+ export { installMessageBus, resetMessageBus };
@@ -0,0 +1,2 @@
1
+ import { installMessageBus, resetMessageBus } from "@sanity/sdk/_internal";
2
+ export { installMessageBus, resetMessageBus };
@@ -1,6 +1,8 @@
1
- import { DocumentHandle } from "@sanity/sdk";
1
+ import { Application, ApplicationBase, DocumentHandle } from "@sanity/sdk";
2
2
  import React, { PropsWithChildren } from "react";
3
3
  import { PathChangeMessage } from "@sanity/message-protocol";
4
+ import { ApplicationConfig, ApplicationConfig as ApplicationConfig$1, ApplicationConfigAppType, ApplicationConfigAppType as ApplicationConfigAppType$1, ConnectMessageBusOptions, DashboardTopics, EventTopic, EventTopic as EventTopic$1, EventTopicDef, MessageBus, MessageBusAbortOptions, MessageBusClient, MessageBusConnection, MessageBusEmitOptions, MessageBusEmitOptions as MessageBusEmitOptions$1, MessageBusEmitResult, MessageBusEmitResult as MessageBusEmitResult$1, MessageBusError, MessageBusErrorCode, MessageBusHost, MessageBusMessage, MessageBusMeta, MessageBusQueryOptions, MessageBusStateSource, NavigationLocation, NavigationTarget, PayloadOf, PayloadOf as PayloadOf$1, RemoteModuleRef, RemoteModuleRef as RemoteModuleRef$1, ReplyOf, ReplyOf as ReplyOf$1, StateTopic, StateTopic as StateTopic$1, StateTopicDef, TopicData, TopicData as TopicData$1, TopicError, TopicName, TopicResult, Topics, ValueOf, ValueOf as ValueOf$1, connectMessageBus } from "@sanity/sdk/dashboard";
5
+ import { UserOptions } from "@module-federation/runtime/types";
4
6
  /**
5
7
  * Authenticates the SDK with the Sanity Dashboard's session when the app runs
6
8
  * inside the dashboard.
@@ -41,6 +43,243 @@ import { PathChangeMessage } from "@sanity/message-protocol";
41
43
  * @public
42
44
  */
43
45
  declare const DashboardTokenRefreshProvider: React.FC<PropsWithChildren>;
46
+ type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
47
+ /**
48
+ * @public
49
+ */
50
+ type FederationRemote = {
51
+ name: string;
52
+ entry: string;
53
+ };
54
+ /**
55
+ * @public
56
+ */
57
+ type CreateRemoteInstanceOptions = MakeOptional<Pick<UserOptions, 'name' | 'remotes' | 'shared' | 'plugins'>, 'remotes' | 'plugins'>;
58
+ /**
59
+ * @public
60
+ */
61
+ interface RemoteInstance {
62
+ registerRemotes(remotes: FederationRemote[]): void;
63
+ /** Loads and evaluates a remote expose. */
64
+ loadRemote<T>(id: string): Promise<T | null>;
65
+ /** Preloads assets without evaluating them; omit exposes to warm the whole remote. */
66
+ preloadRemote(name: string, exposes?: string[]): Promise<void>;
67
+ }
68
+ /**
69
+ * Creates a client for registering, loading, and preloading federated modules.
70
+ * @public
71
+ */
72
+ export declare function createRemoteInstance(options: CreateRemoteInstanceOptions): RemoteInstance;
73
+ /** @public */
74
+ interface DashboardUrl {
75
+ url(options?: {
76
+ origin?: string;
77
+ }): string;
78
+ toURL(options: {
79
+ origin: string;
80
+ }): URL;
81
+ toString(): string;
82
+ }
83
+ /** @public */
84
+ interface EditIntentParameters {
85
+ id: string;
86
+ /** The document schema type, for example `post`. */
87
+ type?: string;
88
+ /** Requests a Studio edit mode, such as `structure` or `presentation`. */
89
+ mode?: 'structure' | 'presentation' | (string & Record<never, never>);
90
+ }
91
+ /** @public */
92
+ interface CreateIntentParameters {
93
+ template: string;
94
+ type: string;
95
+ }
96
+ /** @public */
97
+ interface ReleaseIntentParameters {
98
+ id: string;
99
+ }
100
+ /** @public */
101
+ interface StudioWorkspaceUrl extends DashboardUrl {
102
+ intent(intent: 'edit', parameters: EditIntentParameters): StudioIntentUrl;
103
+ intent(intent: 'create', parameters: CreateIntentParameters): StudioIntentUrl;
104
+ intent(intent: 'release', parameters: ReleaseIntentParameters): StudioIntentUrl;
105
+ path(...path: string[]): DashboardUrl;
106
+ task(taskId: string): DashboardUrl;
107
+ }
108
+ /** @public */
109
+ interface StudioUrl extends StudioWorkspaceUrl {
110
+ workspace(workspace: string): StudioWorkspaceUrl;
111
+ }
112
+ /** @public */
113
+ interface StudioIntentUrl extends DashboardUrl {
114
+ perspective(perspective: string): StudioIntentUrl;
115
+ comment(commentId: string): StudioIntentUrl;
116
+ task(taskId: string): DashboardUrl;
117
+ }
118
+ /** @public */
119
+ interface CoreApplicationUrl extends DashboardUrl {
120
+ path(...path: string[]): DashboardUrl;
121
+ }
122
+ /** @public */
123
+ interface MediaLibraryUrl extends DashboardUrl {
124
+ asset(assetId: string): DashboardUrl;
125
+ collection(collectionId: string): DashboardUrl;
126
+ }
127
+ /** @public */
128
+ interface CanvasUrl extends DashboardUrl {
129
+ document(documentId: string): DashboardUrl;
130
+ }
131
+ /**
132
+ * Base class for immutable URL grammars.
133
+ *
134
+ * @public
135
+ */
136
+ export declare class UrlBuilder implements DashboardUrl {
137
+ #private;
138
+ /**
139
+ * Creates an immutable URL builder at the supplied URL.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * const builder = new UrlBuilder(
144
+ * new URL('/applications/my-app', 'https://dashboard.sanity.io'),
145
+ * )
146
+ *
147
+ * builder.url() // '/applications/my-app'
148
+ * ```
149
+ */
150
+ constructor(url: URL);
151
+ /**
152
+ * Returns a builder with each value appended as one encoded path segment.
153
+ *
154
+ * Route literals and identifiers can be passed together. A slash inside a value stays within
155
+ * that segment instead of creating another route level.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * class DocumentUrlBuilder extends UrlBuilder {
160
+ * document(documentId: string) {
161
+ * return this.append('documents', documentId)
162
+ * }
163
+ * }
164
+ *
165
+ * const builder = new DocumentUrlBuilder(new URL('https://dashboard.sanity.io'))
166
+ * builder.document('drafts/document-1').url()
167
+ * // '/documents/drafts%2Fdocument-1'
168
+ * ```
169
+ */
170
+ protected append(...segments: string[]): this;
171
+ /**
172
+ * Returns a builder with changes made through the platform `URL` API.
173
+ *
174
+ * This supports URL details outside the path grammar, including search parameters and hashes.
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * class DocumentUrlBuilder extends UrlBuilder {
179
+ * perspective(name: string) {
180
+ * return this.edit((url) => url.searchParams.set('perspective', name))
181
+ * }
182
+ *
183
+ * panel(panelId: string) {
184
+ * return this.edit((url) => {
185
+ * url.hash = `panel/${panelId}`
186
+ * })
187
+ * }
188
+ * }
189
+ * ```
190
+ */
191
+ protected edit(update: (url: URL) => void): this;
192
+ /**
193
+ * Returns another builder type rooted at the appended path segments.
194
+ *
195
+ * Use this inside a custom builder method only when its route enters a child grammar with
196
+ * different methods; use `append` when chaining stays on the current grammar.
197
+ *
198
+ * @example
199
+ * ```ts
200
+ * class DocumentUrlBuilder extends UrlBuilder {
201
+ * perspective(name: string) {
202
+ * return this.edit((url) => url.searchParams.set('perspective', name))
203
+ * }
204
+ * }
205
+ *
206
+ * class ApplicationUrlBuilder extends UrlBuilder {
207
+ * document(documentId: string) {
208
+ * return this.transitionTo(DocumentUrlBuilder, 'documents', documentId)
209
+ * }
210
+ * }
211
+ *
212
+ * const builder = new ApplicationUrlBuilder(new URL('https://dashboard.sanity.io'))
213
+ * builder.document('document-1').perspective('published').url()
214
+ * // '/documents/document-1?perspective=published'
215
+ * ```
216
+ */
217
+ protected transitionTo<Builder extends UrlBuilder>(Builder: new (url: URL) => Builder, ...segments: string[]): Builder;
218
+ /**
219
+ * Returns the URL as a relative string by default.
220
+ *
221
+ * Supplying an origin returns an absolute URL string for the same dashboard route.
222
+ *
223
+ * @example
224
+ * ```ts
225
+ * const builder = new UrlBuilder(
226
+ * new URL('/applications/my-app', 'https://dashboard.sanity.io'),
227
+ * )
228
+ *
229
+ * builder.url() // '/applications/my-app'
230
+ * builder.url({origin: 'https://dashboard.sanity.io'})
231
+ * // 'https://dashboard.sanity.io/applications/my-app'
232
+ * ```
233
+ */
234
+ url(options?: {
235
+ origin?: string;
236
+ }): string;
237
+ /**
238
+ * Returns the URL as a platform `URL` object using the supplied origin.
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * const builder = new UrlBuilder(
243
+ * new URL('/applications/my-app', 'https://dashboard.sanity.io'),
244
+ * )
245
+ *
246
+ * builder.toURL({origin: 'https://dashboard.sanity.io'}).pathname
247
+ * // '/applications/my-app'
248
+ * ```
249
+ */
250
+ toURL({ origin }: {
251
+ origin: string;
252
+ }): URL;
253
+ /**
254
+ * Returns the same relative URL as {@link UrlBuilder.url}.
255
+ *
256
+ * @example
257
+ * ```ts
258
+ * const builder = new UrlBuilder(
259
+ * new URL('/applications/my-app', 'https://dashboard.sanity.io'),
260
+ * )
261
+ *
262
+ * `${builder}` // '/applications/my-app'
263
+ * ```
264
+ */
265
+ toString(): string;
266
+ }
267
+ /** @public */
268
+ interface Urls {
269
+ studios(): DashboardUrl;
270
+ studios(appId: string): StudioUrl;
271
+ applications(): DashboardUrl;
272
+ applications(appId: string): CoreApplicationUrl;
273
+ mediaLibrary(): MediaLibraryUrl;
274
+ canvas(): CanvasUrl;
275
+ home(): DashboardUrl;
276
+ extend<const Builders extends Readonly<Record<string, {
277
+ readonly namespace: string;
278
+ new (url: URL): UrlBuilder;
279
+ }>>>(builders: Builders & Partial<Record<keyof this, never>>): this & { readonly [Name in keyof Builders]: () => InstanceType<Builders[Name]>; };
280
+ }
281
+ /** @public */
282
+ export declare const urlFor: Urls;
44
283
  /**
45
284
  * @public
46
285
  */
@@ -88,7 +327,194 @@ interface AgentResourceContextOptions {
88
327
  * }
89
328
  * ```
90
329
  */
91
- declare function useAgentResourceContext(options: AgentResourceContextOptions): void;
330
+ export declare function useAgentResourceContext(options: AgentResourceContextOptions): void;
331
+ type DashboardTopicApplication = Extract<NonNullable<ValueOf$1<'applications.list'>>, {
332
+ ok: true;
333
+ }>['value'][number];
334
+ type DashboardApplicationInterface = NonNullable<NonNullable<DashboardTopicApplication['activeDeployment']>['interfaces']>[number];
335
+ type ViewInterface = Exclude<DashboardApplicationInterface, {
336
+ type: 'worker';
337
+ }>;
338
+ /**
339
+ * A dashboard view exposed by an application.
340
+ * @public
341
+ */
342
+ type DashboardView = { [Type in ViewInterface['type']]: Omit<Extract<ViewInterface, {
343
+ type: Type;
344
+ }>, 'type'> & {
345
+ readonly application: ApplicationBase;
346
+ readonly module: RemoteModuleRef$1;
347
+ readonly surface: Type extends 'app' ? 'window' : Type;
348
+ }; }[ViewInterface['type']];
349
+ /**
350
+ * A web worker exposed by an application.
351
+ * @public
352
+ */
353
+ type DashboardWebWorker = Extract<DashboardApplicationInterface, {
354
+ type: 'worker';
355
+ }> & {
356
+ readonly application: ApplicationBase;
357
+ readonly module: RemoteModuleRef$1;
358
+ };
359
+ /**
360
+ * The minimal Brett application fields with its loadable views and web workers.
361
+ * @public
362
+ */
363
+ type DashboardApplication = ApplicationBase & {
364
+ readonly views: DashboardView[];
365
+ readonly webWorkers: DashboardWebWorker[];
366
+ };
367
+ /**
368
+ * Returns the applications available in the dashboard.
369
+ *
370
+ * Suspends until the dashboard publishes its application list; a cleared list is empty. Throws a
371
+ * `TopicError` to the nearest error boundary when the dashboard fails to load applications.
372
+ *
373
+ * @example
374
+ * ```tsx
375
+ * function Applications() {
376
+ * const applications = useApplications()
377
+ * return applications.map((application) => <div key={application.id}>{application.title}</div>)
378
+ * }
379
+ * ```
380
+ *
381
+ * @public
382
+ */
383
+ export declare function useApplications(): DashboardApplication[];
384
+ /**
385
+ * Returns a dashboard application by id, or `null` when it is unavailable.
386
+ *
387
+ * Suspends until the dashboard publishes its application list.
388
+ *
389
+ * @example
390
+ * ```tsx
391
+ * function SelectedApplication({id}: {id: string}) {
392
+ * const application = useApplication(id)
393
+ * return application ? <h1>{application.title}</h1> : <p>Application unavailable</p>
394
+ * }
395
+ * ```
396
+ *
397
+ * @public
398
+ */
399
+ export declare function useApplication(applicationId: DashboardApplication['id']): DashboardApplication | null;
400
+ /**
401
+ * Selects an application configuration by application id or application type.
402
+ * @public
403
+ */
404
+ type ApplicationConfigSelector = {
405
+ appId: Application['id'];
406
+ appType?: never;
407
+ } | {
408
+ appId?: never;
409
+ appType: ApplicationConfigAppType$1;
410
+ };
411
+ /**
412
+ * Returns an application configuration by application id or application type, or `null` when
413
+ * none matches.
414
+ *
415
+ * An `appType` query matches the type-level config only (the one without an `appId`), so it is
416
+ * independent of the order the dashboard published configs in. An `appId` query matches that
417
+ * application's config.
418
+ *
419
+ * Suspends until the dashboard publishes its application configs.
420
+ *
421
+ * @example
422
+ * ```tsx
423
+ * function MediaLibraryConfig() {
424
+ * const config = useApplicationConfig({appType: 'media-library'})
425
+ * return config ? <span>{config.moduleId}</span> : <p>Not installed</p>
426
+ * }
427
+ * ```
428
+ *
429
+ * @public
430
+ */
431
+ export declare function useApplicationConfig(selector: ApplicationConfigSelector): ApplicationConfig$1 | null;
432
+ /**
433
+ * Returns the application configuration modules available in the dashboard.
434
+ *
435
+ * Suspends until the dashboard publishes its application configs; a cleared list is empty.
436
+ *
437
+ * @example
438
+ * ```tsx
439
+ * function Applications() {
440
+ * const configs = useApplicationConfigs()
441
+ * return configs.map((config) => <div key={config.moduleId}>{config.appType}</div>)
442
+ * }
443
+ * ```
444
+ *
445
+ * @public
446
+ */
447
+ export declare function useApplicationConfigs(): readonly ApplicationConfig$1[];
448
+ /**
449
+ * Returns the id of the application in the foreground, or `null` when Dashboard has none.
450
+ *
451
+ * Suspends until Dashboard publishes the foreground application.
452
+ *
453
+ * @example
454
+ * ```tsx
455
+ * function ForegroundApplication() {
456
+ * const foregroundId = useApplicationForegroundId()
457
+ * return <span>{foregroundId ?? 'No foreground application'}</span>
458
+ * }
459
+ * ```
460
+ *
461
+ * @public
462
+ */
463
+ export declare function useApplicationForegroundId(): Application['id'] | null;
464
+ /**
465
+ * Emits a dashboard event topic, typed to the topic's payload and reply.
466
+ * @public
467
+ */
468
+ type TopicEmitter<K extends EventTopic$1> = (...args: PayloadOf$1<K> extends void ? [payload?: void, options?: MessageBusEmitOptions$1] : [payload: PayloadOf$1<K>, options?: MessageBusEmitOptions$1]) => MessageBusEmitResult$1<ReplyOf$1<K>>;
469
+ /**
470
+ * Returns a stable function that emits a dashboard event topic.
471
+ *
472
+ * The event is sent immediately. Ignore the lazy result for fire-and-forget delivery, await it
473
+ * inside `useTransition` to track a reply, or read it with React `use` to suspend. A reply
474
+ * that fails (`NO_RESPONDER`, `TIMEOUT`, `ABORTED`) rejects the result; when read with `use`
475
+ * that reaches the nearest error boundary, so pair the `Suspense` with one.
476
+ *
477
+ * @example Fire and forget
478
+ * ```tsx
479
+ * function ExpandPanel() {
480
+ * const setPanelMode = useEmit('panels.mode.set')
481
+ * return (
482
+ * <button onClick={() => setPanelMode({name: 'favorites', mode: 'full'})}>
483
+ * Expand
484
+ * </button>
485
+ * )
486
+ * }
487
+ * ```
488
+ *
489
+ * @example Await a reply with Suspense
490
+ * ```tsx
491
+ * function Session({request}: {request: MessageBusEmitResult<string>}) {
492
+ * use(request)
493
+ * return <p>Ready</p>
494
+ * }
495
+ *
496
+ * function SessionAccordion() {
497
+ * const refreshToken = useEmit('auth.token.refresh')
498
+ * const [request, setRequest] = useState<MessageBusEmitResult<string> | null>(null)
499
+ *
500
+ * return (
501
+ * <details
502
+ * onToggle={(event) => setRequest(event.currentTarget.open ? refreshToken() : null)}
503
+ * >
504
+ * <summary>Session</summary>
505
+ * <ErrorBoundary fallback={<p>Could not refresh</p>}>
506
+ * <Suspense fallback={<p>Refreshing...</p>}>
507
+ * {request && <Session request={request} />}
508
+ * </Suspense>
509
+ * </ErrorBoundary>
510
+ * </details>
511
+ * )
512
+ * }
513
+ * ```
514
+ *
515
+ * @public
516
+ */
517
+ export declare function useEmit<K extends EventTopic$1>(topic: K): TopicEmitter<K>;
92
518
  /**
93
519
  * @public
94
520
  *
@@ -132,7 +558,7 @@ declare function useAgentResourceContext(options: AgentResourceContextOptions):
132
558
  * }
133
559
  * ```
134
560
  */
135
- declare function useNavigate(navigateFn: (options: PathChangeMessage['data']) => void): void;
561
+ export declare function useNavigate(navigateFn: (options: PathChangeMessage['data']) => void): void;
136
562
  /**
137
563
  * @public
138
564
  * @category Types
@@ -185,7 +611,7 @@ interface NavigateToStudioResult {
185
611
  * }
186
612
  * ```
187
613
  */
188
- declare function useNavigateToStudioDocument(documentHandle: DocumentHandle, preferredStudioUrl?: string): NavigateToStudioResult;
614
+ export declare function useNavigateToStudioDocument(documentHandle: DocumentHandle, preferredStudioUrl?: string): NavigateToStudioResult;
189
615
  /**
190
616
  * @public
191
617
  *
@@ -205,7 +631,31 @@ declare function useNavigateToStudioDocument(documentHandle: DocumentHandle, pre
205
631
  * @category Dashboard
206
632
  * @returns The dashboard organization ID (string | undefined)
207
633
  */
208
- declare function useOrganizationId(): string | undefined;
634
+ export declare function useOrganizationId(): string | undefined;
635
+ /**
636
+ * Returns a remote client shared by hooks using the same Sanity instance.
637
+ * The first call creates the client; later calls reuse it.
638
+ * @public
639
+ */
640
+ export declare const useRemoteClient: () => RemoteInstance;
641
+ /**
642
+ * Returns the current value of a dashboard state topic and follows later updates.
643
+ *
644
+ * The hook suspends until the topic publishes its first value, using the message bus query
645
+ * deadline. A topic declared with `TopicResult` resolves to its successful value; a
646
+ * failed result throws a `TopicError` to the nearest error boundary.
647
+ *
648
+ * @example
649
+ * ```tsx
650
+ * function ForegroundApplication() {
651
+ * const foregroundId = useTopic('applications.foreground')
652
+ * return <span>{foregroundId ?? 'No application in the foreground'}</span>
653
+ * }
654
+ * ```
655
+ *
656
+ * @public
657
+ */
658
+ export declare const useTopic: <K extends StateTopic$1>(topic: K) => TopicData$1<K>;
209
659
  /**
210
660
  * Sets the browser's document title, automatically including the app's name
211
661
  * from the manifest.
@@ -245,6 +695,6 @@ declare function useOrganizationId(): string | undefined;
245
695
  *
246
696
  * @public
247
697
  */
248
- declare function useWindowTitle(viewTitle?: string): void;
249
- export { type AgentResourceContextOptions, type NavigateToStudioResult, DashboardTokenRefreshProvider as TokenRefreshProvider, useAgentResourceContext, useNavigate, useNavigateToStudioDocument, useOrganizationId, useWindowTitle };
698
+ export declare function useWindowTitle(viewTitle?: string): void;
699
+ export { type AgentResourceContextOptions, type ApplicationConfig, type ApplicationConfigAppType, type ApplicationConfigSelector, type CanvasUrl, type ConnectMessageBusOptions, type CoreApplicationUrl, type CreateIntentParameters, type CreateRemoteInstanceOptions, type DashboardApplication, type DashboardTopics, type DashboardUrl, type DashboardView, type DashboardWebWorker, type EditIntentParameters, type EventTopic, type EventTopicDef, type FederationRemote, type MediaLibraryUrl, type MessageBus, type MessageBusAbortOptions, type MessageBusClient, type MessageBusConnection, type MessageBusEmitOptions, type MessageBusEmitResult, MessageBusError, type MessageBusErrorCode, type MessageBusHost, type MessageBusMessage, type MessageBusMeta, type MessageBusQueryOptions, type MessageBusStateSource, type NavigateToStudioResult, type NavigationLocation, type NavigationTarget, type PayloadOf, type ReleaseIntentParameters, type RemoteInstance, type RemoteModuleRef, type ReplyOf, type StateTopic, type StateTopicDef, type StudioIntentUrl, type StudioUrl, type StudioWorkspaceUrl, DashboardTokenRefreshProvider as TokenRefreshProvider, type TopicData, type TopicEmitter, TopicError, type TopicName, type TopicResult, type Topics, type Urls, type ValueOf, connectMessageBus };
250
700
  //# sourceMappingURL=dashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard.d.ts","names":[],"sources":["../../src/context/DashboardTokenRefresh.tsx","../../src/hooks/dashboard/useAgentResourceContext.ts","../../src/hooks/dashboard/useNavigate.ts","../../src/hooks/dashboard/useNavigateToStudioDocument.ts","../../src/hooks/dashboard/useOrganizationId.tsx","../../src/hooks/dashboard/useWindowTitle.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwFa,+BAA+B,MAAM,GAAG;;;;UC/EpC;;;;EAIf;;;;EAIA;;;;EAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiCc,wBAAwB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCPjC,YACd,aAAa,SAAS;;;;;UClCP;EACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgDc,4BACd,gBAAgB,gBAChB,8BACC;;;;;;;;;;;;;;;;;;;;iBC1Ca;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC2CA,eAAe"}
1
+ {"version":3,"file":"dashboard.d.ts","names":[],"sources":["../../src/context/DashboardTokenRefresh.tsx","../../src/dashboard/createRemoteInstance.ts","../../src/dashboard/urlFor.ts","../../src/hooks/dashboard/useAgentResourceContext.ts","../../src/hooks/dashboard/useApplications.ts","../../src/hooks/dashboard/useApplication.ts","../../src/hooks/dashboard/useApplicationConfig.ts","../../src/hooks/dashboard/useApplicationConfigs.ts","../../src/hooks/dashboard/useApplicationForegroundId.ts","../../src/hooks/dashboard/useEmit.ts","../../src/hooks/dashboard/useNavigate.ts","../../src/hooks/dashboard/useNavigateToStudioDocument.ts","../../src/hooks/dashboard/useOrganizationId.tsx","../../src/hooks/dashboard/useRemoteClient.ts","../../src/hooks/dashboard/useTopic.ts","../../src/hooks/dashboard/useWindowTitle.ts"],"mappings":"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"}