@sanity/sdk-react 3.3.0-rc.1 → 3.4.0-rc.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 (30) hide show
  1. package/dist/_exports/dashboard-internal.d.ts +2 -2
  2. package/dist/_exports/dashboard.d.ts +57 -1
  3. package/dist/_exports/dashboard.d.ts.map +1 -1
  4. package/dist/_exports/dashboard.js +69 -38
  5. package/dist/_exports/dashboard.js.map +1 -1
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -2
  9. package/dist/{useStudioWorkspacesByProjectIdDataset-BZ_Ud887.js → useStudioWorkspacesByProjectIdDataset-B5A5kBH9.js} +85 -5
  10. package/dist/useStudioWorkspacesByProjectIdDataset-B5A5kBH9.js.map +1 -0
  11. package/package.json +8 -8
  12. package/src/_exports/dashboard-internal.ts +6 -1
  13. package/src/_exports/dashboard.test-d.ts +30 -4
  14. package/src/_exports/dashboard.ts +3 -0
  15. package/src/hooks/dashboard/useApplicationBasePath.test.tsx +77 -0
  16. package/src/hooks/dashboard/useApplicationBasePath.ts +23 -0
  17. package/src/hooks/dashboard/useApplications.test.tsx +12 -3
  18. package/src/hooks/dashboard/useApplications.ts +5 -24
  19. package/src/hooks/dashboard/useAuthToken.test.tsx +48 -0
  20. package/src/hooks/dashboard/useAuthToken.ts +20 -0
  21. package/src/hooks/dashboard/useCurrentUser.test.tsx +57 -0
  22. package/src/hooks/dashboard/useCurrentUser.ts +22 -0
  23. package/src/hooks/dashboard/useOrganizationId.test.tsx +52 -1
  24. package/src/hooks/dashboard/useOrganizationId.tsx +15 -2
  25. package/src/hooks/dashboard/useStudioWorkspacesByProjectIdDataset.test.tsx +142 -1
  26. package/src/hooks/dashboard/useStudioWorkspacesByProjectIdDataset.ts +58 -1
  27. package/src/hooks/dashboard/useWindowTitle.test.ts +23 -0
  28. package/src/hooks/dashboard/useWindowTitle.ts +14 -0
  29. package/src/hooks/installations/useInstallations.test-d.ts +10 -0
  30. package/dist/useStudioWorkspacesByProjectIdDataset-BZ_Ud887.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard.js","names":["createInstance","createMFInstance","ModuleFederationRuntimePlugin","UserOptions","createLogger","MakeOptional","T","Omit","K","Partial","Pick","FederationRemote","name","entry","MANIFEST_FILE","withManifest","remote","endsWith","base","URL","href","CreateRemoteInstanceOptions","RemoteInstance","registerRemotes","remotes","loadRemote","id","Promise","preloadRemote","exposes","createRemoteInstance","options","logger","instance","plugins","log","debug","map","force","remoteModule","error","Error","cause","nameOrAlias","resourceCategory","onDebug","message","context","Record","logEvent","eventName","args","origin","_origin","data","internal","beforeInit","beforeRegisterRemote","beforePreloadRemote","beforeRequest","afterResolve","onLoad","loadShare","beforeLoadShare","DashboardUrl","url","options","origin","toURL","URL","toString","relativeUrlBase","EditIntentParameters","id","type","mode","Record","CreateIntentParameters","template","ReleaseIntentParameters","StudioWorkspaceUrl","intent","parameters","StudioIntentUrl","path","task","taskId","StudioUrl","workspace","perspective","comment","commentId","CoreApplicationUrl","MediaLibraryUrl","asset","assetId","collection","collectionId","CanvasUrl","document","documentId","IntentArguments","BuilderRegistry","Readonly","namespace","UrlBuilder","BuilderMethods","Builders","InstanceType","Name","splitPath","flatMap","part","split","filter","Boolean","intentParametersOf","searchParameters","URLSearchParams","set","undefined","parseIntentParameters","replaceAll","serializeIntentParameters","Array","from","name","value","encodeURIComponent","join","appendSegments","segments","nextUrl","length","pathname","replace","map","constructor","append","create","edit","update","transitionTo","Builder","relativeUrl","href","#relativeUrl","search","hash","#create","CoreApplicationUrlBuilder","MediaLibraryUrlBuilder","CanvasUrlBuilder","StudioUrlBuilder","args","searchParams","parametersIndex","Urls","studios","appId","applications","mediaLibrary","canvas","home","extend","builders","Partial","createRootBuilder","createUrls","methods","Object","fromEntries","entries","urls","addedBuilders","AddedBuilders","namespaces","Set","values","Error","has","add","assign","urlFor","Events","SDK_CHANNEL_NAME","SDK_NODE_NAME","FrameMessage","useCallback","useEffect","useRef","useWindowConnection","AgentResourceContextOptions","projectId","dataset","documentId","useAgentResourceContext","options","$","_c","t0","Symbol","for","name","connectTo","sendMessage","lastContextRef","t1","console","warn","contextKey","current","message","type","data","t2","error","updateContext","t3","getTopicState","resolveTopic","StateTopic","TopicData","createStateSourceHook","useTopic","getState","shouldSuspend","instance","topic","getCurrent","undefined","suspender","K","ApplicationBase","RemoteModuleRef","ValueOf","useMemo","useTopic","DashboardTopicApplication","Extract","NonNullable","ok","DashboardApplicationInterface","ViewInterface","Exclude","type","DashboardView","Omit","Type","application","module","surface","DashboardWebWorker","DashboardApplication","views","webWorkers","SanityGlobal","globalThis","__SANITY_STAGING__","applicationOrigin","externalUrl","URL","origin","slug","staging","isSingleton","domain","organizationId","loadableInterfaces","activeDeployment","config","mfManifest","undefined","interfaces","toApplication","_activeDeployment","_config","applicationBase","entry","length","extension","moduleId","id","version","push","view","useApplications","$","_c","applications","t0","map","DashboardApplication","useApplications","useApplication","applicationId","find","t0","id","ApplicationConfig","useTopic","NO_CONFIGS","Object","freeze","useApplicationConfigs","Application","ApplicationConfig","ApplicationConfigAppType","useApplicationConfigs","ApplicationConfigSelector","appId","appType","useApplicationConfig","selector","$","_c","configs","t0","find","config","undefined","Application","useTopic","useApplicationForegroundId","requireDashboardMessageBus","EventTopic","MessageBusEmitOptions","MessageBusEmitResult","PayloadOf","ReplyOf","useCallback","useSanityInstance","TopicEmitter","args","K","payload","options","useEmit","topic","$","_c","instance","t0","t1","messageBus","t2","t3","emit","PathChangeMessage","SDK_CHANNEL_NAME","SDK_NODE_NAME","useWindowConnection","useNavigate","navigateFn","$","_c","t0","name","connectTo","onMessage","data","Bridge","SDK_CHANNEL_NAME","SDK_NODE_NAME","DocumentHandle","useCallback","useWindowConnection","DashboardResource","useStudioWorkspacesByProjectIdDataset","NavigateToStudioResult","navigateToStudioDocument","useNavigateToStudioDocument","documentHandle","preferredStudioUrl","$","_c","workspacesByProjectIdAndDataset","t0","Symbol","for","name","connectTo","sendMessage","t1","projectId","dataset","console","warn","workspace","allWorkspaces","find","w","url","workspaces","length","message","type","data","resourceId","id","resourceType","path","documentId","documentType","t2","SanityInstance","StateSource","of","createRemoteInstance","RemoteInstance","remoteClientStates","WeakMap","getRemoteClientState","instance","isDisposed","Error","current","get","client","name","instanceId","state","getCurrent","observable","subscribe","set","onDispose","delete","RemoteInstance","getRemoteClientState","createStateSourceHook","useRemoteClient","SDK_CHANNEL_NAME","SDK_NODE_NAME","useEffect","useState","useWindowConnection","ContextResource","type","title","manifest","activeDeployment","ContextResponse","context","resource","resolveAppTitle","useWindowTitle","viewTitle","appTitle","setAppTitle","fetch","name","connectTo","controller","AbortController","fetchAppTitle","signal","AbortSignal","data","undefined","document","err","Error","console","error","abort","previous"],"sources":["../../src/dashboard/createRemoteInstance.ts","../../src/dashboard/urlFor.ts","../../src/hooks/dashboard/useAgentResourceContext.ts","../../src/hooks/dashboard/useTopic.ts","../../src/hooks/dashboard/useApplications.ts","../../src/hooks/dashboard/useApplication.ts","../../src/hooks/dashboard/useApplicationConfigs.ts","../../src/hooks/dashboard/useApplicationConfig.ts","../../src/hooks/dashboard/useApplicationForegroundId.ts","../../src/hooks/dashboard/useEmit.ts","../../src/hooks/dashboard/useNavigate.ts","../../src/hooks/dashboard/useNavigateToStudioDocument.ts","../../src/dashboard/remoteClientState.ts","../../src/hooks/dashboard/useRemoteClient.ts","../../src/hooks/dashboard/useWindowTitle.ts"],"sourcesContent":["import {createInstance as createMFInstance} from '@module-federation/runtime'\nimport {\n type ModuleFederationRuntimePlugin,\n type UserOptions,\n} from '@module-federation/runtime/types'\nimport {createLogger} from '@sanity/sdk/_internal'\n\ntype MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\n\n/**\n * @public\n */\nexport type FederationRemote = {\n name: string\n entry: string\n}\n\nconst MANIFEST_FILE = 'mf-manifest.json'\n\nfunction withManifest<T extends {entry: string}>(remote: T): T {\n if (remote.entry.endsWith(`/${MANIFEST_FILE}`)) return remote\n const base = remote.entry.endsWith('/') ? remote.entry : `${remote.entry}/`\n return {...remote, entry: new URL(MANIFEST_FILE, base).href}\n}\n\n/**\n * @public\n */\nexport type CreateRemoteInstanceOptions = MakeOptional<\n Pick<UserOptions, 'name' | 'remotes' | 'shared' | 'plugins'>,\n 'remotes' | 'plugins'\n>\n\n/**\n * @public\n */\nexport interface RemoteInstance {\n registerRemotes(remotes: FederationRemote[]): void\n /** Loads and evaluates a remote expose. */\n loadRemote<T>(id: string): Promise<T | null>\n /** Preloads assets without evaluating them; omit exposes to warm the whole remote. */\n preloadRemote(name: string, exposes?: string[]): Promise<void>\n}\n\n/**\n * Creates a client for registering, loading, and preloading federated modules.\n * @public\n */\nexport function createRemoteInstance(options: CreateRemoteInstanceOptions): RemoteInstance {\n const logger = createLogger(options.name)\n const instance = createMFInstance({\n ...options,\n plugins: [log(logger.debug), ...(options.plugins ?? [])],\n remotes:\n options.remotes?.map((remote) => ('entry' in remote ? withManifest(remote) : remote)) ?? [],\n })\n\n return {\n registerRemotes: (remotes) =>\n instance.registerRemotes(remotes.map(withManifest), {force: false}),\n loadRemote: async <T>(id: string) => {\n let remoteModule: T | null\n\n try {\n remoteModule = await instance.loadRemote<T>(id)\n } catch (error) {\n throw new Error(`Failed to load remote module \"${id}\"`, {\n cause: error,\n })\n }\n\n return remoteModule\n },\n // Include async chunks so lazy code is warm before the remote loads.\n preloadRemote: (name, exposes) =>\n instance.preloadRemote([{nameOrAlias: name, exposes, resourceCategory: 'all'}]),\n }\n}\n\nfunction log(\n onDebug: (message: string, context?: Record<string, unknown>) => void,\n): ModuleFederationRuntimePlugin {\n const logEvent = (eventName: string, args: object) => {\n // `origin` logs the whole instance, which is noisy\n const {origin: _origin, ...data} = args as Record<string, unknown>\n\n onDebug(`[Lifecycle] ${eventName}`, {...data, internal: true})\n }\n\n return {\n name: 'sanity-logger',\n beforeInit(args) {\n logEvent('beforeInit', args)\n return args\n },\n beforeRegisterRemote(args) {\n logEvent('beforeRegisterRemote', args)\n return args\n },\n beforePreloadRemote(args) {\n logEvent('beforePreloadRemote', args)\n },\n beforeRequest(args) {\n logEvent('beforeRequest', args)\n return args\n },\n afterResolve(args) {\n logEvent('afterResolve', args)\n return args\n },\n onLoad(args) {\n logEvent('onLoad', args)\n return args\n },\n loadShare(args) {\n logEvent('loadShare', args)\n },\n beforeLoadShare(args) {\n logEvent('beforeLoadShare', args)\n return args\n },\n }\n}\n","/** @public */\nexport interface DashboardUrl {\n url(options?: {origin?: string}): string\n toURL(options: {origin: string}): URL\n toString(): string\n}\n\n// URL requires an origin; public output always strips this parsing base.\nconst relativeUrlBase = 'https://dashboard.invalid'\n\n/** @public */\nexport interface EditIntentParameters {\n id: string\n /** The document schema type, for example `post`. */\n type?: string\n /** Requests a Studio edit mode, such as `structure` or `presentation`. */\n mode?: 'structure' | 'presentation' | (string & Record<never, never>)\n}\n\n/** @public */\nexport interface CreateIntentParameters {\n template: string\n type: string\n}\n\n/** @public */\nexport interface ReleaseIntentParameters {\n id: string\n}\n\n/** @public */\nexport interface StudioWorkspaceUrl extends DashboardUrl {\n intent(intent: 'edit', parameters: EditIntentParameters): StudioIntentUrl\n intent(intent: 'create', parameters: CreateIntentParameters): StudioIntentUrl\n intent(intent: 'release', parameters: ReleaseIntentParameters): StudioIntentUrl\n path(...path: string[]): DashboardUrl\n task(taskId: string): DashboardUrl\n}\n\n/** @public */\nexport interface StudioUrl extends StudioWorkspaceUrl {\n workspace(workspace: string): StudioWorkspaceUrl\n}\n\n/** @public */\nexport interface StudioIntentUrl extends DashboardUrl {\n perspective(perspective: string): StudioIntentUrl\n comment(commentId: string): StudioIntentUrl\n task(taskId: string): DashboardUrl\n}\n\n/** @public */\nexport interface CoreApplicationUrl extends DashboardUrl {\n path(...path: string[]): DashboardUrl\n}\n\n/** @public */\nexport interface MediaLibraryUrl extends DashboardUrl {\n asset(assetId: string): DashboardUrl\n collection(collectionId: string): DashboardUrl\n}\n\n/** @public */\nexport interface CanvasUrl extends DashboardUrl {\n document(documentId: string): DashboardUrl\n}\n\ntype IntentArguments =\n | [intent: 'edit', parameters: EditIntentParameters]\n | [intent: 'create', parameters: CreateIntentParameters]\n | [intent: 'release', parameters: ReleaseIntentParameters]\n\ntype BuilderRegistry = Readonly<\n Record<\n string,\n {\n readonly namespace: string\n new (url: URL): UrlBuilder\n }\n >\n>\n\ntype BuilderMethods<Builders extends BuilderRegistry> = {\n readonly [Name in keyof Builders]: () => InstanceType<Builders[Name]>\n}\n\nconst splitPath = (path: readonly string[]) =>\n path.flatMap((part) => part.split('/')).filter(Boolean)\n\nconst intentParametersOf = (...[intent, parameters]: IntentArguments) => {\n const searchParameters = new URLSearchParams()\n\n switch (intent) {\n case 'edit': {\n const {id, type, mode} = parameters\n searchParameters.set('id', id)\n if (type !== undefined) searchParameters.set('type', type)\n if (mode !== undefined) searchParameters.set('mode', mode)\n break\n }\n case 'create': {\n searchParameters.set('template', parameters.template)\n searchParameters.set('type', parameters.type)\n break\n }\n case 'release': {\n searchParameters.set('id', parameters.id)\n break\n }\n }\n\n return searchParameters\n}\n\nconst parseIntentParameters = (parameters: string) =>\n new URLSearchParams(parameters.replaceAll(';', '&'))\n\nconst serializeIntentParameters = (parameters: URLSearchParams) =>\n Array.from(\n parameters,\n ([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`,\n ).join(';')\n\nconst appendSegments = (url: URL, segments: readonly string[]): URL => {\n const nextUrl = new URL(url)\n if (segments.length === 0) return nextUrl\n\n nextUrl.pathname = `${nextUrl.pathname.replace(/\\/$/, '')}/${segments\n .map(encodeURIComponent)\n .join('/')}`\n return nextUrl\n}\n\n/**\n * Base class for immutable URL grammars.\n *\n * @public\n */\nexport class UrlBuilder implements DashboardUrl {\n readonly #url: URL\n\n /**\n * Creates an immutable URL builder at the supplied URL.\n *\n * @example\n * ```ts\n * const builder = new UrlBuilder(\n * new URL('/applications/my-app', 'https://dashboard.sanity.io'),\n * )\n *\n * builder.url() // '/applications/my-app'\n * ```\n */\n constructor(url: URL) {\n this.#url = new URL(url)\n }\n\n /**\n * Returns a builder with each value appended as one encoded path segment.\n *\n * Route literals and identifiers can be passed together. A slash inside a value stays within\n * that segment instead of creating another route level.\n *\n * @example\n * ```ts\n * class DocumentUrlBuilder extends UrlBuilder {\n * document(documentId: string) {\n * return this.append('documents', documentId)\n * }\n * }\n *\n * const builder = new DocumentUrlBuilder(new URL('https://dashboard.sanity.io'))\n * builder.document('drafts/document-1').url()\n * // '/documents/drafts%2Fdocument-1'\n * ```\n */\n protected append(...segments: string[]): this {\n return this.#create(appendSegments(this.#url, segments))\n }\n\n /**\n * Returns a builder with changes made through the platform `URL` API.\n *\n * This supports URL details outside the path grammar, including search parameters and hashes.\n *\n * @example\n * ```ts\n * class DocumentUrlBuilder extends UrlBuilder {\n * perspective(name: string) {\n * return this.edit((url) => url.searchParams.set('perspective', name))\n * }\n *\n * panel(panelId: string) {\n * return this.edit((url) => {\n * url.hash = `panel/${panelId}`\n * })\n * }\n * }\n * ```\n */\n protected edit(update: (url: URL) => void): this {\n const url = new URL(this.#url)\n update(url)\n return this.#create(url)\n }\n\n /**\n * Returns another builder type rooted at the appended path segments.\n *\n * Use this inside a custom builder method only when its route enters a child grammar with\n * different methods; use `append` when chaining stays on the current grammar.\n *\n * @example\n * ```ts\n * class DocumentUrlBuilder extends UrlBuilder {\n * perspective(name: string) {\n * return this.edit((url) => url.searchParams.set('perspective', name))\n * }\n * }\n *\n * class ApplicationUrlBuilder extends UrlBuilder {\n * document(documentId: string) {\n * return this.transitionTo(DocumentUrlBuilder, 'documents', documentId)\n * }\n * }\n *\n * const builder = new ApplicationUrlBuilder(new URL('https://dashboard.sanity.io'))\n * builder.document('document-1').perspective('published').url()\n * // '/documents/document-1?perspective=published'\n * ```\n */\n protected transitionTo<Builder extends UrlBuilder>(\n Builder: new (url: URL) => Builder,\n ...segments: string[]\n ): Builder {\n return new Builder(appendSegments(this.#url, segments))\n }\n\n /**\n * Returns the URL as a relative string by default.\n *\n * Supplying an origin returns an absolute URL string for the same dashboard route.\n *\n * @example\n * ```ts\n * const builder = new UrlBuilder(\n * new URL('/applications/my-app', 'https://dashboard.sanity.io'),\n * )\n *\n * builder.url() // '/applications/my-app'\n * builder.url({origin: 'https://dashboard.sanity.io'})\n * // 'https://dashboard.sanity.io/applications/my-app'\n * ```\n */\n url(options?: {origin?: string}): string {\n const relativeUrl = this.#relativeUrl()\n return options?.origin === undefined ? relativeUrl : new URL(relativeUrl, options.origin).href\n }\n\n /**\n * Returns the URL as a platform `URL` object using the supplied origin.\n *\n * @example\n * ```ts\n * const builder = new UrlBuilder(\n * new URL('/applications/my-app', 'https://dashboard.sanity.io'),\n * )\n *\n * builder.toURL({origin: 'https://dashboard.sanity.io'}).pathname\n * // '/applications/my-app'\n * ```\n */\n toURL({origin}: {origin: string}): URL {\n return new URL(this.#relativeUrl(), origin)\n }\n\n /**\n * Returns the same relative URL as {@link UrlBuilder.url}.\n *\n * @example\n * ```ts\n * const builder = new UrlBuilder(\n * new URL('/applications/my-app', 'https://dashboard.sanity.io'),\n * )\n *\n * `${builder}` // '/applications/my-app'\n * ```\n */\n toString(): string {\n return this.url()\n }\n\n #relativeUrl(): string {\n return `${this.#url.pathname}${this.#url.search}${this.#url.hash}`\n }\n\n #create(url: URL): this {\n const Builder = this.constructor as new (url: URL) => this\n return new Builder(url)\n }\n}\n\nclass CoreApplicationUrlBuilder extends UrlBuilder implements CoreApplicationUrl {\n static readonly namespace = 'applications'\n\n path(...path: string[]): this {\n return this.append(...splitPath(path))\n }\n}\n\nclass MediaLibraryUrlBuilder extends UrlBuilder implements MediaLibraryUrl {\n static readonly namespace = 'media'\n\n asset(assetId: string): DashboardUrl {\n return this.append('assets', assetId)\n }\n\n collection(collectionId: string): DashboardUrl {\n return this.append('collections', collectionId)\n }\n}\n\nclass CanvasUrlBuilder extends UrlBuilder implements CanvasUrl {\n static readonly namespace = 'canvas'\n\n document(documentId: string): DashboardUrl {\n return this.append('doc', documentId)\n }\n}\n\nclass StudioUrlBuilder\n extends UrlBuilder\n implements StudioUrl, StudioWorkspaceUrl, StudioIntentUrl\n{\n static readonly namespace = 'studios'\n\n workspace(workspace: string): StudioWorkspaceUrl {\n return this.append(workspace)\n }\n\n intent(intent: 'edit', parameters: EditIntentParameters): StudioIntentUrl\n intent(intent: 'create', parameters: CreateIntentParameters): StudioIntentUrl\n intent(intent: 'release', parameters: ReleaseIntentParameters): StudioIntentUrl\n intent(...args: IntentArguments): StudioIntentUrl {\n return this.append('intent', args[0]).edit((url) => {\n url.pathname = `${url.pathname}/${serializeIntentParameters(intentParametersOf(...args))}/`\n })\n }\n\n perspective(perspective: string): StudioIntentUrl {\n return this.edit((url) => url.searchParams.set('perspective', perspective))\n }\n\n comment(commentId: string): StudioIntentUrl {\n return this.edit((url) => {\n const segments = url.pathname.split('/')\n const parametersIndex = segments.length - 2\n const parameters = parseIntentParameters(segments[parametersIndex]!)\n parameters.set('inspect', 'sanity/comments')\n parameters.set('comment', commentId)\n segments[parametersIndex] = serializeIntentParameters(parameters)\n url.pathname = segments.join('/')\n })\n }\n\n task(taskId: string): DashboardUrl {\n return this.edit((url) => url.searchParams.set('selectedTask', taskId))\n }\n\n path(...path: string[]): DashboardUrl {\n return this.append(...splitPath(path))\n }\n}\n\n/** @public */\nexport interface Urls {\n studios(): DashboardUrl\n studios(appId: string): StudioUrl\n applications(): DashboardUrl\n applications(appId: string): CoreApplicationUrl\n mediaLibrary(): MediaLibraryUrl\n canvas(): CanvasUrl\n home(): DashboardUrl\n extend<\n const Builders extends Readonly<\n Record<\n string,\n {\n readonly namespace: string\n new (url: URL): UrlBuilder\n }\n >\n >,\n >(\n builders: Builders & Partial<Record<keyof this, never>>,\n ): this & {readonly [Name in keyof Builders]: () => InstanceType<Builders[Name]>}\n}\n\nconst createRootBuilder = <Builder extends UrlBuilder>(\n Builder: (new (url: URL) => Builder) & {readonly namespace: string},\n ...segments: string[]\n): Builder =>\n new Builder(appendSegments(new URL(relativeUrlBase), [Builder.namespace, ...segments]))\n\nconst createUrls = <const Builders extends BuilderRegistry>(\n builders: Builders,\n): Urls & BuilderMethods<Builders> => {\n function studios(): DashboardUrl\n function studios(appId: string): StudioUrl\n function studios(appId?: string): DashboardUrl | StudioUrl {\n return appId === undefined\n ? new UrlBuilder(new URL('/studios/', relativeUrlBase))\n : createRootBuilder(StudioUrlBuilder, appId)\n }\n\n function applications(): DashboardUrl\n function applications(appId: string): CoreApplicationUrl\n function applications(appId?: string): DashboardUrl | CoreApplicationUrl {\n return appId === undefined\n ? new UrlBuilder(new URL('/applications/', relativeUrlBase))\n : createRootBuilder(CoreApplicationUrlBuilder, appId)\n }\n\n const methods = Object.fromEntries(\n Object.entries(builders).map(([name, Builder]) => [name, () => createRootBuilder(Builder)]),\n )\n\n const urls = {\n studios,\n applications,\n mediaLibrary: () => createRootBuilder(MediaLibraryUrlBuilder),\n canvas: () => createRootBuilder(CanvasUrlBuilder),\n home: () => new UrlBuilder(new URL(relativeUrlBase)),\n extend<const AddedBuilders extends BuilderRegistry>(addedBuilders: AddedBuilders) {\n const namespaces = new Set([\n '',\n StudioUrlBuilder.namespace,\n CoreApplicationUrlBuilder.namespace,\n MediaLibraryUrlBuilder.namespace,\n CanvasUrlBuilder.namespace,\n ...Object.values(builders).map((Builder) => Builder.namespace),\n ])\n\n for (const [name, Builder] of Object.entries(addedBuilders)) {\n if (name in urls || name in methods) {\n throw new Error(`URL builder \"${name}\" already exists`)\n }\n if (namespaces.has(Builder.namespace)) {\n throw new Error(`URL namespace \"${Builder.namespace}\" already exists`)\n }\n namespaces.add(Builder.namespace)\n }\n\n return createUrls({...builders, ...addedBuilders})\n },\n }\n\n return Object.assign(urls, methods) as Urls & BuilderMethods<Builders>\n}\n\n/** @public */\nexport const urlFor: Urls = createUrls({})\n","import {type Events, SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {type FrameMessage} from '@sanity/sdk/comlink'\nimport {useCallback, useEffect, useRef} from 'react'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\n\n/**\n * @public\n */\nexport interface AgentResourceContextOptions {\n /**\n * The project ID of the current context\n */\n projectId: string\n /**\n * The dataset of the current context\n */\n dataset: string\n /**\n * Optional document ID if the user is viewing/editing a specific document\n */\n documentId?: string\n}\n\n/**\n * @public\n * Hook for emitting agent resource context updates to the Dashboard.\n * This allows the Agent to understand what resource the user is currently\n * interacting with (e.g., which document they're editing).\n *\n * The hook will automatically emit the context when it changes, and also\n * emit the initial context when the hook is first mounted.\n *\n * @category Agent\n * @param options - The resource context options containing projectId, dataset, and optional documentId\n *\n * @example\n * ```tsx\n * import {useAgentResourceContext} from '@sanity/sdk-react/dashboard'\n *\n * function MyComponent() {\n * const documentId = 'my-document-id'\n *\n * // Automatically updates the Agent's context whenever the document changes\n * useAgentResourceContext({\n * projectId: 'my-project',\n * dataset: 'production',\n * documentId,\n * })\n *\n * return <div>Editing document: {documentId}</div>\n * }\n * ```\n */\nexport function useAgentResourceContext(options: AgentResourceContextOptions): void {\n const {projectId, dataset, documentId} = options\n const {sendMessage} = useWindowConnection<Events.AgentResourceUpdateMessage, FrameMessage>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n })\n\n // Track the last sent context to avoid duplicate updates\n const lastContextRef = useRef<string | null>(null)\n\n const updateContext = useCallback(() => {\n // Validate required fields\n if (!projectId || !dataset) {\n // eslint-disable-next-line no-console\n console.warn('[useAgentResourceContext] projectId and dataset are required', {\n projectId,\n dataset,\n })\n return\n }\n\n // Create a stable key for the current context\n const contextKey = `${projectId}:${dataset}:${documentId || ''}`\n\n // Skip if context hasn't changed\n if (lastContextRef.current === contextKey) {\n return\n }\n\n try {\n const message: Events.AgentResourceUpdateMessage = {\n type: 'dashboard/v1/events/agent/resource/update',\n data: {\n projectId,\n dataset,\n documentId,\n },\n }\n\n sendMessage(message.type, message.data)\n lastContextRef.current = contextKey\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('[useAgentResourceContext] Failed to update context:', error)\n }\n }, [projectId, dataset, documentId, sendMessage])\n\n // Update context whenever it changes\n useEffect(() => {\n updateContext()\n }, [updateContext])\n}\n","import {getTopicState, resolveTopic} from '@sanity/sdk/_internal'\nimport {type StateTopic, type TopicData} from '@sanity/sdk/dashboard'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * Returns the current value of a dashboard state topic and follows later updates.\n *\n * The hook suspends until the topic publishes its first value, using the message bus query\n * deadline. A topic declared with `TopicResult` resolves to its successful value; a\n * failed result throws a `TopicError` to the nearest error boundary.\n *\n * @example\n * ```tsx\n * function ForegroundApplication() {\n * const foregroundId = useTopic('applications.foreground')\n * return <span>{foregroundId ?? 'No application in the foreground'}</span>\n * }\n * ```\n *\n * @public\n */\nexport const useTopic = createStateSourceHook({\n getState: getTopicState,\n // `getCurrent` throws a recorded read failure, which surfaces it from render like a thrown value.\n shouldSuspend: (instance, topic: StateTopic) =>\n getTopicState(instance, topic).getCurrent() === undefined,\n suspender: resolveTopic,\n}) as <K extends StateTopic>(topic: K) => TopicData<K>\n","import {type ApplicationBase} from '@sanity/sdk'\nimport {type RemoteModuleRef, type ValueOf} from '@sanity/sdk/dashboard'\nimport {useMemo} from 'react'\n\nimport {useTopic} from './useTopic'\n\ntype DashboardTopicApplication = Extract<\n NonNullable<ValueOf<'applications.list'>>,\n {ok: true}\n>['value'][number]\ntype DashboardApplicationInterface = NonNullable<\n NonNullable<DashboardTopicApplication['activeDeployment']>['interfaces']\n>[number]\ntype ViewInterface = Exclude<DashboardApplicationInterface, {type: 'worker'}>\n\n/**\n * A dashboard view exposed by an application.\n * @public\n */\nexport type DashboardView = {\n [Type in ViewInterface['type']]: Omit<Extract<ViewInterface, {type: Type}>, 'type'> & {\n readonly application: ApplicationBase\n readonly module: RemoteModuleRef\n readonly surface: Type extends 'app' ? 'window' : Type\n }\n}[ViewInterface['type']]\n\n/**\n * A web worker exposed by an application.\n * @public\n */\nexport type DashboardWebWorker = Extract<DashboardApplicationInterface, {type: 'worker'}> & {\n readonly application: ApplicationBase\n readonly module: RemoteModuleRef\n}\n\n/**\n * The minimal Brett application fields with its loadable views and web workers.\n * @public\n */\nexport type DashboardApplication = ApplicationBase & {\n readonly views: DashboardView[]\n readonly webWorkers: DashboardWebWorker[]\n}\n\ntype SanityGlobal = typeof globalThis & {__SANITY_STAGING__?: boolean}\n\n// `null` when neither address exists: the caller exposes no modules for that application\n// rather than failing the whole list on one bad record.\nconst applicationOrigin = (application: ApplicationBase): string | null => {\n if (application.externalUrl !== null) return new URL(application.externalUrl).origin\n if (application.slug === null) return null\n\n // Read at runtime, not via a bundler define: a remote is built once and runs in whichever\n // host page loaded it, and the host sets this flag. Mirrors workbench's `getSanityEnv`.\n const staging = (globalThis as SanityGlobal).__SANITY_STAGING__ === true\n if (application.isSingleton) {\n const domain = staging ? 'run.sanity.work' : 'sanity.run'\n return `https://${application.slug}-apps-${application.organizationId}.${domain}`\n }\n\n const domain = staging ? 'studio.sanity.work' : 'sanity.studio'\n return `https://${application.slug}.${domain}`\n}\n\n// Only a federated deployment (one with a module federation manifest) exposes loadable modules.\nconst loadableInterfaces = ({\n activeDeployment,\n config,\n}: DashboardTopicApplication): readonly DashboardApplicationInterface[] =>\n config?.mfManifest === undefined ? [] : (activeDeployment?.interfaces ?? [])\n\nconst toApplication = (application: DashboardTopicApplication): DashboardApplication => {\n const {activeDeployment: _activeDeployment, config: _config, ...applicationBase} = application\n const interfaces = loadableInterfaces(application)\n // Nothing to load without interfaces or an origin to load them from.\n const entry = interfaces.length === 0 ? null : applicationOrigin(applicationBase)\n if (entry === null) return {...applicationBase, views: [], webWorkers: []}\n\n const views: DashboardView[] = []\n const webWorkers: DashboardWebWorker[] = []\n\n for (const extension of interfaces) {\n const module: RemoteModuleRef = {\n entry,\n moduleId: `${applicationBase.id}/${extension.moduleId}`,\n version: extension.version,\n }\n\n if (extension.type === 'worker') {\n webWorkers.push({...extension, application: applicationBase, module})\n continue\n }\n\n const {type, ...view} = extension\n // TS cannot correlate `surface` with the narrowed `type` across the mapped union; the\n // cast is checked by the `DashboardView` mapping above and the surface assertions in the tests.\n views.push({\n ...view,\n application: applicationBase,\n module,\n surface: type === 'app' ? 'window' : type,\n } as DashboardView)\n }\n\n return {...applicationBase, views, webWorkers}\n}\n\n/**\n * Returns the applications available in the dashboard.\n *\n * Suspends until the dashboard publishes its application list; a cleared list is empty. Throws a\n * `TopicError` to the nearest error boundary when the dashboard fails to load applications.\n *\n * @example\n * ```tsx\n * function Applications() {\n * const applications = useApplications()\n * return applications.map((application) => <div key={application.id}>{application.title}</div>)\n * }\n * ```\n *\n * @public\n */\nexport function useApplications(): DashboardApplication[] {\n const applications = useTopic('applications.list')\n return useMemo(() => applications?.map(toApplication) ?? [], [applications])\n}\n","import {type DashboardApplication, useApplications} from './useApplications'\n\n/**\n * Returns a dashboard application by id, or `null` when it is unavailable.\n *\n * Suspends until the dashboard publishes its application list.\n *\n * @example\n * ```tsx\n * function SelectedApplication({id}: {id: string}) {\n * const application = useApplication(id)\n * return application ? <h1>{application.title}</h1> : <p>Application unavailable</p>\n * }\n * ```\n *\n * @public\n */\nexport function useApplication(\n applicationId: DashboardApplication['id'],\n): DashboardApplication | null {\n return useApplications().find(({id}) => id === applicationId) ?? null\n}\n","import {type ApplicationConfig} from '@sanity/sdk/dashboard'\n\nimport {useTopic} from './useTopic'\n\n// Stable, frozen reference for the cleared/absent case so the return value only changes with the\n// topic and callers cannot mutate the shared empty list.\nconst NO_CONFIGS: readonly ApplicationConfig[] = Object.freeze([])\n\n/**\n * Returns the application configuration modules available in the dashboard.\n *\n * Suspends until the dashboard publishes its application configs; a cleared list is empty.\n *\n * @example\n * ```tsx\n * function Applications() {\n * const configs = useApplicationConfigs()\n * return configs.map((config) => <div key={config.moduleId}>{config.appType}</div>)\n * }\n * ```\n *\n * @public\n */\nexport function useApplicationConfigs(): readonly ApplicationConfig[] {\n return useTopic('applications.config') ?? NO_CONFIGS\n}\n","import {type Application} from '@sanity/sdk'\nimport {type ApplicationConfig, type ApplicationConfigAppType} from '@sanity/sdk/dashboard'\n\nimport {useApplicationConfigs} from './useApplicationConfigs'\n\n/**\n * Selects an application configuration by application id or application type.\n * @public\n */\nexport type ApplicationConfigSelector =\n | {appId: Application['id']; appType?: never}\n | {appId?: never; appType: ApplicationConfigAppType}\n\n/**\n * Returns an application configuration by application id or application type, or `null` when\n * none matches.\n *\n * An `appType` query matches the type-level config only (the one without an `appId`), so it is\n * independent of the order the dashboard published configs in. An `appId` query matches that\n * application's config.\n *\n * Suspends until the dashboard publishes its application configs.\n *\n * @example\n * ```tsx\n * function MediaLibraryConfig() {\n * const config = useApplicationConfig({appType: 'media-library'})\n * return config ? <span>{config.moduleId}</span> : <p>Not installed</p>\n * }\n * ```\n *\n * @public\n */\nexport function useApplicationConfig(\n selector: ApplicationConfigSelector,\n): ApplicationConfig | null {\n const configs = useApplicationConfigs()\n return (\n configs.find((config) =>\n selector.appId === undefined\n ? config.appType === selector.appType && config.appId === undefined\n : config.appId === selector.appId,\n ) ?? null\n )\n}\n","import {type Application} from '@sanity/sdk'\n\nimport {useTopic} from './useTopic'\n\n/**\n * Returns the id of the application in the foreground, or `null` when Dashboard has none.\n *\n * Suspends until Dashboard publishes the foreground application.\n *\n * @example\n * ```tsx\n * function ForegroundApplication() {\n * const foregroundId = useApplicationForegroundId()\n * return <span>{foregroundId ?? 'No foreground application'}</span>\n * }\n * ```\n *\n * @public\n */\nexport function useApplicationForegroundId(): Application['id'] | null {\n return useTopic('applications.foreground')\n}\n","import {requireDashboardMessageBus} from '@sanity/sdk/_internal'\nimport {\n type EventTopic,\n type MessageBusEmitOptions,\n type MessageBusEmitResult,\n type PayloadOf,\n type ReplyOf,\n} from '@sanity/sdk/dashboard'\nimport {useCallback} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * Emits a dashboard event topic, typed to the topic's payload and reply.\n * @public\n */\nexport type TopicEmitter<K extends EventTopic> = (\n ...args: PayloadOf<K> extends void\n ? [payload?: void, options?: MessageBusEmitOptions]\n : [payload: PayloadOf<K>, options?: MessageBusEmitOptions]\n) => MessageBusEmitResult<ReplyOf<K>>\n\n/**\n * Returns a stable function that emits a dashboard event topic.\n *\n * The event is sent immediately. Ignore the lazy result for fire-and-forget delivery, await it\n * inside `useTransition` to track a reply, or read it with React `use` to suspend. A reply\n * that fails (`NO_RESPONDER`, `TIMEOUT`, `ABORTED`) rejects the result; when read with `use`\n * that reaches the nearest error boundary, so pair the `Suspense` with one.\n *\n * @example Fire and forget\n * ```tsx\n * function ExpandPanel() {\n * const setPanelMode = useEmit('panels.mode.set')\n * return (\n * <button onClick={() => setPanelMode({name: 'favorites', mode: 'full'})}>\n * Expand\n * </button>\n * )\n * }\n * ```\n *\n * @example Await a reply with Suspense\n * ```tsx\n * function Session({request}: {request: MessageBusEmitResult<string>}) {\n * use(request)\n * return <p>Ready</p>\n * }\n *\n * function SessionAccordion() {\n * const refreshToken = useEmit('auth.token.refresh')\n * const [request, setRequest] = useState<MessageBusEmitResult<string> | null>(null)\n *\n * return (\n * <details\n * onToggle={(event) => setRequest(event.currentTarget.open ? refreshToken() : null)}\n * >\n * <summary>Session</summary>\n * <ErrorBoundary fallback={<p>Could not refresh</p>}>\n * <Suspense fallback={<p>Refreshing...</p>}>\n * {request && <Session request={request} />}\n * </Suspense>\n * </ErrorBoundary>\n * </details>\n * )\n * }\n * ```\n *\n * @public\n */\nexport function useEmit<K extends EventTopic>(topic: K): TopicEmitter<K> {\n const instance = useSanityInstance()\n const messageBus = requireDashboardMessageBus(instance, `emit topic \"${topic}\"`)\n return useCallback<TopicEmitter<K>>(\n (...args) => messageBus.emit(topic, ...args),\n [messageBus, topic],\n )\n}\n","import {type PathChangeMessage, SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\n\n/**\n * @public\n *\n * A helper hook designed to be injected into routing components for apps within the Dashboard.\n * While the Dashboard can usually handle navigation, there are special cases when you\n * are already within a target app, and need to navigate to another route inside of that app.\n *\n * For example, your user might \"favorite\" a document inside of your application.\n * If they click on the Dashboard favorites item in the sidebar, and are already within your application,\n * there needs to be some way for the dashboard to signal to your application to reroute to where that document was favorited.\n *\n * This hook is intended to receive those messages, and takes a function to route to the correct path.\n *\n * @param navigateFn - Function to handle navigation; should accept:\n * - `path`: a string, which will be a relative path (for example, 'my-route')\n * - `type`: 'push', 'replace', or 'pop', which will be the type of navigation to perform\n *\n * @example\n * ```tsx\n * import {useNavigate} from '@sanity/sdk-react/dashboard'\n * import {BrowserRouter, useNavigate as useRouterNavigate} from 'react-router'\n * import {Suspense} from 'react'\n *\n * function DashboardNavigationHandler() {\n * const navigate = useRouterNavigate()\n * useNavigate(({path, type}) => {\n * navigate(path, {replace: type === 'replace'})\n * })\n * return null\n * }\n *\n * // Wrap the component with Suspense since the hook may suspend\n * function MyApp() {\n * return (\n * <BrowserRouter>\n * <Suspense>\n * <DashboardNavigationHandler />\n * </Suspense>\n * </BrowserRouter>\n * )\n * }\n * ```\n */\nexport function useNavigate(navigateFn: (options: PathChangeMessage['data']) => void): void {\n useWindowConnection<PathChangeMessage, never>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n onMessage: {\n 'dashboard/v1/history/change-path': (data: PathChangeMessage['data']) => {\n navigateFn(data)\n },\n },\n })\n}\n","import {type Bridge, SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {type DocumentHandle} from '@sanity/sdk'\nimport {useCallback} from 'react'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\nimport {\n type DashboardResource,\n useStudioWorkspacesByProjectIdDataset,\n} from './useStudioWorkspacesByProjectIdDataset'\n\n/**\n * @public\n * @category Types\n */\nexport interface NavigateToStudioResult {\n navigateToStudioDocument: () => void\n}\n\n/**\n * @public\n *\n * Hook that provides a function to navigate to a given document in its parent Studio.\n *\n * Uses the `projectId` and `dataset` properties of the {@link DocumentHandle} you provide to resolve the correct Studio.\n * This will only work if you have deployed a studio with a workspace with this `projectId` / `dataset` combination.\n *\n * @remarks If you write your own Document Handle to pass to this hook (as opposed to a Document Handle generated by another hook),\n * it must include values for `documentId`, `documentType`, `projectId`, and `dataset`.\n *\n * @category Documents\n * @param documentHandle - The document handle for the document to navigate to\n * @param preferredStudioUrl - The preferred studio url to navigate to if you have multiple\n * studios with the same projectId and dataset\n * @returns An object containing:\n * - `navigateToStudioDocument` - Function that when called will navigate to the studio document\n *\n * @example\n * ```tsx\n * import {type DocumentHandle} from '@sanity/sdk-react'\n * import {useNavigateToStudioDocument} from '@sanity/sdk-react/dashboard'\n * import {Button} from '@sanity/ui'\n * import {Suspense} from 'react'\n *\n * function NavigateButton({documentHandle}: {documentHandle: DocumentHandle}) {\n * const {navigateToStudioDocument} = useNavigateToStudioDocument(documentHandle)\n * return (\n * <Button\n * onClick={navigateToStudioDocument}\n * text=\"Navigate to Studio Document\"\n * />\n * )\n * }\n *\n * // Wrap the component with Suspense since the hook may suspend\n * function MyDocumentAction({documentHandle}: {documentHandle: DocumentHandle}) {\n * return (\n * <Suspense fallback={<Button text=\"Loading...\" disabled />}>\n * <NavigateButton documentHandle={documentHandle} />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function useNavigateToStudioDocument(\n documentHandle: DocumentHandle,\n preferredStudioUrl?: string,\n): NavigateToStudioResult {\n const {workspacesByProjectIdAndDataset} = useStudioWorkspacesByProjectIdDataset()\n const {sendMessage} = useWindowConnection<Bridge.Navigation.NavigateToResourceMessage, never>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n })\n\n const navigateToStudioDocument = useCallback(() => {\n const {projectId, dataset} = documentHandle\n\n if (!projectId || !dataset) {\n // eslint-disable-next-line no-console\n console.warn('Project ID and dataset are required to navigate to a studio document')\n return\n }\n\n let workspace: DashboardResource | undefined\n\n if (preferredStudioUrl) {\n // Get workspaces matching the projectId:dataset and any workspaces without projectId/dataset,\n // in case there hasn't been a manifest loaded yet\n const allWorkspaces = [\n ...(workspacesByProjectIdAndDataset[`${projectId}:${dataset}`] || []),\n ...(workspacesByProjectIdAndDataset['NO_PROJECT_ID:NO_DATASET'] || []),\n ]\n workspace = allWorkspaces.find((w) => w.url === preferredStudioUrl)\n } else {\n const workspaces = workspacesByProjectIdAndDataset[`${projectId}:${dataset}`]\n if (workspaces?.length > 1) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Multiple workspaces found for document and no preferred studio url',\n documentHandle,\n )\n // eslint-disable-next-line no-console\n console.warn('Using the first one', workspaces[0])\n }\n\n workspace = workspaces?.[0]\n }\n\n if (!workspace) {\n // eslint-disable-next-line no-console\n console.warn(\n `No workspace found for document with projectId: ${projectId} and dataset: ${dataset}${preferredStudioUrl ? ` or with preferred studio url: ${preferredStudioUrl}` : ''}`,\n )\n return\n }\n\n const message: Bridge.Navigation.NavigateToResourceMessage = {\n type: 'dashboard/v1/bridge/navigate-to-resource',\n data: {\n resourceId: workspace.id,\n resourceType: 'studio',\n path: `/intent/edit/id=${documentHandle.documentId};type=${documentHandle.documentType}`,\n },\n }\n\n sendMessage(message.type, message.data)\n }, [documentHandle, workspacesByProjectIdAndDataset, sendMessage, preferredStudioUrl])\n\n return {\n navigateToStudioDocument,\n }\n}\n","import {type SanityInstance, type StateSource} from '@sanity/sdk'\nimport {of} from 'rxjs'\n\nimport {createRemoteInstance, type RemoteInstance} from './createRemoteInstance'\n\nconst remoteClientStates = new WeakMap<SanityInstance, StateSource<RemoteInstance>>()\n\n/** Returns the instance's remote client state, creating it on first use. @internal */\nexport function getRemoteClientState(instance: SanityInstance): StateSource<RemoteInstance> {\n if (instance.isDisposed()) {\n throw new Error('Cannot create a remote client for a disposed Sanity instance')\n }\n\n const current = remoteClientStates.get(instance)\n if (current) return current\n\n const client = createRemoteInstance({name: `sanity-remote-${instance.instanceId}`})\n const state = {\n getCurrent: () => client,\n observable: of(client),\n subscribe: () => () => {},\n }\n\n remoteClientStates.set(instance, state)\n instance.onDispose(() => remoteClientStates.delete(instance))\n return state\n}\n","import {type RemoteInstance} from '../../dashboard/createRemoteInstance'\nimport {getRemoteClientState} from '../../dashboard/remoteClientState'\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * Returns a remote client shared by hooks using the same Sanity instance.\n * The first call creates the client; later calls reuse it.\n * @public\n */\nexport const useRemoteClient: () => RemoteInstance = createStateSourceHook(getRemoteClientState)\n","import {SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {useEffect, useState} from 'react'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\n\ninterface ContextResource {\n type: string\n title?: string\n manifest?: {\n title?: string\n } | null\n activeDeployment?: {\n manifest?: {\n title?: string\n } | null\n } | null\n}\n\ninterface ContextResponse {\n context: {\n resource: ContextResource\n }\n}\n\nfunction resolveAppTitle(resource: ContextResource): string | undefined {\n return resource.manifest?.title || resource.activeDeployment?.manifest?.title || resource.title\n}\n\n/**\n * Sets the browser's document title, automatically including the app's name\n * from the manifest.\n *\n * This follows the same convention as Sanity Studio workspaces, where the\n * workspace name is always present in the title:\n *\n * - With a view title: `<viewTitle> | <appTitle>`\n * - Without a view title: `<appTitle>`\n *\n * The Sanity dashboard appends `| Sanity` to produce the final browser tab title.\n *\n * @param viewTitle - An optional view-specific title to prepend to the app title.\n *\n * @example\n * ```tsx\n * import {useWindowTitle} from '@sanity/sdk-react/dashboard'\n *\n * function MoviesList() {\n * useWindowTitle('Movies')\n * return <div>...</div>\n * }\n *\n * // Browser tab: \"Movies | My App | Sanity\"\n * ```\n *\n * @example\n * ```tsx\n * // Call without arguments to show just the app title\n * function AppRoot() {\n * useWindowTitle()\n * return <Outlet />\n * }\n *\n * // Browser tab: \"My App | Sanity\"\n * ```\n *\n * @public\n */\nexport function useWindowTitle(viewTitle?: string): void {\n const [appTitle, setAppTitle] = useState<string | null>(null)\n\n const {fetch} = useWindowConnection({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n })\n\n useEffect(() => {\n if (!fetch) return\n\n const controller = new AbortController()\n\n async function fetchAppTitle(signal: AbortSignal) {\n try {\n const data = await fetch<ContextResponse>('dashboard/v1/context', undefined, {signal})\n // Local development resources do not have a registered title or deployment manifest.\n // In that case, use the title rendered into the iframe HTML by the Sanity CLI.\n const title = resolveAppTitle(data.context.resource) || document.title\n if (title) {\n setAppTitle(title)\n }\n } catch (err: unknown) {\n if (err instanceof Error && err.name === 'AbortError') return\n // eslint-disable-next-line no-console\n console.error('Failed to fetch app title from dashboard context:', err)\n }\n }\n\n fetchAppTitle(controller.signal)\n\n return () => {\n controller.abort()\n }\n }, [fetch])\n\n useEffect(() => {\n if (!appTitle) return\n\n const previous = document.title\n document.title = viewTitle ? `${viewTitle} | ${appTitle}` : appTitle\n\n return () => {\n document.title = previous\n }\n }, [viewTitle, appTitle])\n}\n"],"mappings":";;;;;;;;;;;AAiBA,MAAMc,gBAAgB;AAEtB,SAASC,aAAwCC,QAAc;CAC7D,IAAIA,OAAOH,MAAMI,SAAS,IAAIH,eAAe,GAAG,OAAOE;CACvD,IAAME,OAAOF,OAAOH,MAAMI,SAAS,GAAG,IAAID,OAAOH,QAAQ,GAAGG,OAAOH,MAAK;CACxE,OAAO;EAAC,GAAGG;EAAQH,OAAO,IAAIM,IAAIL,eAAeI,IAAI,CAAC,CAACE;CAAI;AAC7D;;;;;AAyBA,SAAgBU,qBAAqBC,SAAsD;CACzF,IAAMC,SAAS5B,aAAa2B,QAAQnB,IAAI,GAClCqB,WAAWhC,eAAiB;EAChC,GAAG8B;EACHG,SAAS,CAACC,IAAIH,OAAOI,KAAK,GAAG,GAAIL,QAAQG,WAAW,CAAA,CAAG;EACvDV,SACEO,QAAQP,SAASa,KAAKrB,WAAY,WAAWA,SAASD,aAAaC,MAAM,IAAIA,MAAO,KAAK,CAAA;CAC7F,CAAC;CAED,OAAO;EACLO,kBAAkBC,YAChBS,SAASV,gBAAgBC,QAAQa,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ACe/F,SAASgB,gBAAgBD,UAA+C;CACtE,OAAOA,SAASJ,UAAUD,SAASK,SAASH,kBAAkBD,UAAUD,SAASK,SAASL;AAC5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgBO,eAAeC,WAA0B;CACvD,IAAM,CAACC,UAAUC,eAAed,SAAwB,IAAI,GAEtD,EAACe,UAASd,oBAAoB;EAClCe,MAAMlB;EACNmB,WAAWpB;CACb,CAAC;CA8BDE,AA5BAA,gBAAgB;EACd,IAAI,CAACgB,OAAO;EAEZ,IAAMG,aAAa,IAAIC,gBAAgB;EAEvC,eAAeC,cAAcC,QAAqB;GAChD,IAAI;IAIF,IAAMjB,QAAQM,iBAAgBa,MAHXR,MAAuB,wBAAwBS,KAAAA,GAAW,EAACH,OAAM,CAAC,EAAA,CAGlDb,QAAQC,QAAQ,KAAKgB,SAASrB;IACjE,AAAIA,SACFU,YAAYV,KAAK;GAErB,SAASsB,KAAc;IACrB,IAAIA,eAAeC,SAASD,IAAIV,SAAS,cAAc;IAEvDY,QAAQC,MAAM,qDAAqDH,GAAG;GACxE;EACF;EAIA,OAFAN,cAAcF,WAAWG,MAAM,SAElB;GACXH,WAAWY,MAAM;EACnB;CACF,GAAG,CAACf,KAAK,CAAC,GAEVhB,gBAAgB;EACd,IAAI,CAACc,UAAU;EAEf,IAAMkB,WAAWN,SAASrB;EAG1B,OAFAqB,SAASrB,QAAQQ,YAAY,GAAGA,UAAS,KAAMC,aAAaA,gBAE/C;GACXY,SAASrB,QAAQ2B;EACnB;CACF,GAAG,CAACnB,WAAWC,QAAQ,CAAC;AAC1B"}
1
+ {"version":3,"file":"dashboard.js","names":["createInstance","createMFInstance","ModuleFederationRuntimePlugin","UserOptions","createLogger","MakeOptional","T","Omit","K","Partial","Pick","FederationRemote","name","entry","MANIFEST_FILE","withManifest","remote","endsWith","base","URL","href","CreateRemoteInstanceOptions","RemoteInstance","registerRemotes","remotes","loadRemote","id","Promise","preloadRemote","exposes","createRemoteInstance","options","logger","instance","plugins","log","debug","map","force","remoteModule","error","Error","cause","nameOrAlias","resourceCategory","onDebug","message","context","Record","logEvent","eventName","args","origin","_origin","data","internal","beforeInit","beforeRegisterRemote","beforePreloadRemote","beforeRequest","afterResolve","onLoad","loadShare","beforeLoadShare","DashboardUrl","url","options","origin","toURL","URL","toString","relativeUrlBase","EditIntentParameters","id","type","mode","Record","CreateIntentParameters","template","ReleaseIntentParameters","StudioWorkspaceUrl","intent","parameters","StudioIntentUrl","path","task","taskId","StudioUrl","workspace","perspective","comment","commentId","CoreApplicationUrl","MediaLibraryUrl","asset","assetId","collection","collectionId","CanvasUrl","document","documentId","IntentArguments","BuilderRegistry","Readonly","namespace","UrlBuilder","BuilderMethods","Builders","InstanceType","Name","splitPath","flatMap","part","split","filter","Boolean","intentParametersOf","searchParameters","URLSearchParams","set","undefined","parseIntentParameters","replaceAll","serializeIntentParameters","Array","from","name","value","encodeURIComponent","join","appendSegments","segments","nextUrl","length","pathname","replace","map","constructor","append","create","edit","update","transitionTo","Builder","relativeUrl","href","#relativeUrl","search","hash","#create","CoreApplicationUrlBuilder","MediaLibraryUrlBuilder","CanvasUrlBuilder","StudioUrlBuilder","args","searchParams","parametersIndex","Urls","studios","appId","applications","mediaLibrary","canvas","home","extend","builders","Partial","createRootBuilder","createUrls","methods","Object","fromEntries","entries","urls","addedBuilders","AddedBuilders","namespaces","Set","values","Error","has","add","assign","urlFor","Events","SDK_CHANNEL_NAME","SDK_NODE_NAME","FrameMessage","useCallback","useEffect","useRef","useWindowConnection","AgentResourceContextOptions","projectId","dataset","documentId","useAgentResourceContext","options","$","_c","t0","Symbol","for","name","connectTo","sendMessage","lastContextRef","t1","console","warn","contextKey","current","message","type","data","t2","error","updateContext","t3","ApplicationBase","getApplicationOrigin","RemoteModuleRef","ValueOf","useMemo","useTopic","DashboardTopicApplication","Extract","NonNullable","ok","DashboardApplicationInterface","ViewInterface","Exclude","type","DashboardView","Omit","Type","application","module","surface","DashboardWebWorker","DashboardApplication","views","webWorkers","loadableInterfaces","activeDeployment","config","mfManifest","undefined","interfaces","toApplication","_activeDeployment","_config","applicationBase","entry","length","extension","moduleId","id","version","push","view","useApplications","$","_c","applications","t0","map","DashboardApplication","useApplications","useApplication","applicationId","find","t0","id","TopicData","useTopic","useApplicationBasePath","ApplicationConfig","useTopic","NO_CONFIGS","Object","freeze","useApplicationConfigs","Application","ApplicationConfig","ApplicationConfigAppType","useApplicationConfigs","ApplicationConfigSelector","appId","appType","useApplicationConfig","selector","$","_c","configs","t0","find","config","undefined","Application","useTopic","useApplicationForegroundId","useTopic","useAuthToken","CurrentUser","useTopic","useCurrentUser","requireDashboardMessageBus","EventTopic","MessageBusEmitOptions","MessageBusEmitResult","PayloadOf","ReplyOf","useCallback","useSanityInstance","TopicEmitter","args","K","payload","options","useEmit","topic","$","_c","instance","t0","t1","messageBus","t2","t3","emit","PathChangeMessage","SDK_CHANNEL_NAME","SDK_NODE_NAME","useWindowConnection","useNavigate","navigateFn","$","_c","t0","name","connectTo","onMessage","data","Bridge","SDK_CHANNEL_NAME","SDK_NODE_NAME","DocumentHandle","useCallback","useWindowConnection","DashboardResource","useStudioWorkspacesByProjectIdDataset","NavigateToStudioResult","navigateToStudioDocument","useNavigateToStudioDocument","documentHandle","preferredStudioUrl","$","_c","workspacesByProjectIdAndDataset","t0","Symbol","for","name","connectTo","sendMessage","t1","projectId","dataset","console","warn","workspace","allWorkspaces","find","w","url","workspaces","length","message","type","data","resourceId","id","resourceType","path","documentId","documentType","t2","SanityInstance","StateSource","of","createRemoteInstance","RemoteInstance","remoteClientStates","WeakMap","getRemoteClientState","instance","isDisposed","Error","current","get","client","name","instanceId","state","getCurrent","observable","subscribe","set","onDispose","delete","RemoteInstance","getRemoteClientState","createStateSourceHook","useRemoteClient","SDK_CHANNEL_NAME","SDK_NODE_NAME","isDashboardEnvironment","useEffect","useState","useWindowConnection","ContextResource","type","title","manifest","activeDeployment","ContextResponse","context","resource","resolveAppTitle","useWindowTitle","viewTitle","useComlinkWindowTitle","appTitle","setAppTitle","fetch","name","connectTo","controller","AbortController","fetchAppTitle","signal","AbortSignal","data","undefined","document","err","Error","console","error","abort","previous"],"sources":["../../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/useApplicationBasePath.ts","../../src/hooks/dashboard/useApplicationConfigs.ts","../../src/hooks/dashboard/useApplicationConfig.ts","../../src/hooks/dashboard/useApplicationForegroundId.ts","../../src/hooks/dashboard/useAuthToken.ts","../../src/hooks/dashboard/useCurrentUser.ts","../../src/hooks/dashboard/useEmit.ts","../../src/hooks/dashboard/useNavigate.ts","../../src/hooks/dashboard/useNavigateToStudioDocument.ts","../../src/dashboard/remoteClientState.ts","../../src/hooks/dashboard/useRemoteClient.ts","../../src/hooks/dashboard/useWindowTitle.ts"],"sourcesContent":["import {createInstance as createMFInstance} from '@module-federation/runtime'\nimport {\n type ModuleFederationRuntimePlugin,\n type UserOptions,\n} from '@module-federation/runtime/types'\nimport {createLogger} from '@sanity/sdk/_internal'\n\ntype MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\n\n/**\n * @public\n */\nexport type FederationRemote = {\n name: string\n entry: string\n}\n\nconst MANIFEST_FILE = 'mf-manifest.json'\n\nfunction withManifest<T extends {entry: string}>(remote: T): T {\n if (remote.entry.endsWith(`/${MANIFEST_FILE}`)) return remote\n const base = remote.entry.endsWith('/') ? remote.entry : `${remote.entry}/`\n return {...remote, entry: new URL(MANIFEST_FILE, base).href}\n}\n\n/**\n * @public\n */\nexport type CreateRemoteInstanceOptions = MakeOptional<\n Pick<UserOptions, 'name' | 'remotes' | 'shared' | 'plugins'>,\n 'remotes' | 'plugins'\n>\n\n/**\n * @public\n */\nexport interface RemoteInstance {\n registerRemotes(remotes: FederationRemote[]): void\n /** Loads and evaluates a remote expose. */\n loadRemote<T>(id: string): Promise<T | null>\n /** Preloads assets without evaluating them; omit exposes to warm the whole remote. */\n preloadRemote(name: string, exposes?: string[]): Promise<void>\n}\n\n/**\n * Creates a client for registering, loading, and preloading federated modules.\n * @public\n */\nexport function createRemoteInstance(options: CreateRemoteInstanceOptions): RemoteInstance {\n const logger = createLogger(options.name)\n const instance = createMFInstance({\n ...options,\n plugins: [log(logger.debug), ...(options.plugins ?? [])],\n remotes:\n options.remotes?.map((remote) => ('entry' in remote ? withManifest(remote) : remote)) ?? [],\n })\n\n return {\n registerRemotes: (remotes) =>\n instance.registerRemotes(remotes.map(withManifest), {force: false}),\n loadRemote: async <T>(id: string) => {\n let remoteModule: T | null\n\n try {\n remoteModule = await instance.loadRemote<T>(id)\n } catch (error) {\n throw new Error(`Failed to load remote module \"${id}\"`, {\n cause: error,\n })\n }\n\n return remoteModule\n },\n // Include async chunks so lazy code is warm before the remote loads.\n preloadRemote: (name, exposes) =>\n instance.preloadRemote([{nameOrAlias: name, exposes, resourceCategory: 'all'}]),\n }\n}\n\nfunction log(\n onDebug: (message: string, context?: Record<string, unknown>) => void,\n): ModuleFederationRuntimePlugin {\n const logEvent = (eventName: string, args: object) => {\n // `origin` logs the whole instance, which is noisy\n const {origin: _origin, ...data} = args as Record<string, unknown>\n\n onDebug(`[Lifecycle] ${eventName}`, {...data, internal: true})\n }\n\n return {\n name: 'sanity-logger',\n beforeInit(args) {\n logEvent('beforeInit', args)\n return args\n },\n beforeRegisterRemote(args) {\n logEvent('beforeRegisterRemote', args)\n return args\n },\n beforePreloadRemote(args) {\n logEvent('beforePreloadRemote', args)\n },\n beforeRequest(args) {\n logEvent('beforeRequest', args)\n return args\n },\n afterResolve(args) {\n logEvent('afterResolve', args)\n return args\n },\n onLoad(args) {\n logEvent('onLoad', args)\n return args\n },\n loadShare(args) {\n logEvent('loadShare', args)\n },\n beforeLoadShare(args) {\n logEvent('beforeLoadShare', args)\n return args\n },\n }\n}\n","/** @public */\nexport interface DashboardUrl {\n url(options?: {origin?: string}): string\n toURL(options: {origin: string}): URL\n toString(): string\n}\n\n// URL requires an origin; public output always strips this parsing base.\nconst relativeUrlBase = 'https://dashboard.invalid'\n\n/** @public */\nexport interface EditIntentParameters {\n id: string\n /** The document schema type, for example `post`. */\n type?: string\n /** Requests a Studio edit mode, such as `structure` or `presentation`. */\n mode?: 'structure' | 'presentation' | (string & Record<never, never>)\n}\n\n/** @public */\nexport interface CreateIntentParameters {\n template: string\n type: string\n}\n\n/** @public */\nexport interface ReleaseIntentParameters {\n id: string\n}\n\n/** @public */\nexport interface StudioWorkspaceUrl extends DashboardUrl {\n intent(intent: 'edit', parameters: EditIntentParameters): StudioIntentUrl\n intent(intent: 'create', parameters: CreateIntentParameters): StudioIntentUrl\n intent(intent: 'release', parameters: ReleaseIntentParameters): StudioIntentUrl\n path(...path: string[]): DashboardUrl\n task(taskId: string): DashboardUrl\n}\n\n/** @public */\nexport interface StudioUrl extends StudioWorkspaceUrl {\n workspace(workspace: string): StudioWorkspaceUrl\n}\n\n/** @public */\nexport interface StudioIntentUrl extends DashboardUrl {\n perspective(perspective: string): StudioIntentUrl\n comment(commentId: string): StudioIntentUrl\n task(taskId: string): DashboardUrl\n}\n\n/** @public */\nexport interface CoreApplicationUrl extends DashboardUrl {\n path(...path: string[]): DashboardUrl\n}\n\n/** @public */\nexport interface MediaLibraryUrl extends DashboardUrl {\n asset(assetId: string): DashboardUrl\n collection(collectionId: string): DashboardUrl\n}\n\n/** @public */\nexport interface CanvasUrl extends DashboardUrl {\n document(documentId: string): DashboardUrl\n}\n\ntype IntentArguments =\n | [intent: 'edit', parameters: EditIntentParameters]\n | [intent: 'create', parameters: CreateIntentParameters]\n | [intent: 'release', parameters: ReleaseIntentParameters]\n\ntype BuilderRegistry = Readonly<\n Record<\n string,\n {\n readonly namespace: string\n new (url: URL): UrlBuilder\n }\n >\n>\n\ntype BuilderMethods<Builders extends BuilderRegistry> = {\n readonly [Name in keyof Builders]: () => InstanceType<Builders[Name]>\n}\n\nconst splitPath = (path: readonly string[]) =>\n path.flatMap((part) => part.split('/')).filter(Boolean)\n\nconst intentParametersOf = (...[intent, parameters]: IntentArguments) => {\n const searchParameters = new URLSearchParams()\n\n switch (intent) {\n case 'edit': {\n const {id, type, mode} = parameters\n searchParameters.set('id', id)\n if (type !== undefined) searchParameters.set('type', type)\n if (mode !== undefined) searchParameters.set('mode', mode)\n break\n }\n case 'create': {\n searchParameters.set('template', parameters.template)\n searchParameters.set('type', parameters.type)\n break\n }\n case 'release': {\n searchParameters.set('id', parameters.id)\n break\n }\n }\n\n return searchParameters\n}\n\nconst parseIntentParameters = (parameters: string) =>\n new URLSearchParams(parameters.replaceAll(';', '&'))\n\nconst serializeIntentParameters = (parameters: URLSearchParams) =>\n Array.from(\n parameters,\n ([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`,\n ).join(';')\n\nconst appendSegments = (url: URL, segments: readonly string[]): URL => {\n const nextUrl = new URL(url)\n if (segments.length === 0) return nextUrl\n\n nextUrl.pathname = `${nextUrl.pathname.replace(/\\/$/, '')}/${segments\n .map(encodeURIComponent)\n .join('/')}`\n return nextUrl\n}\n\n/**\n * Base class for immutable URL grammars.\n *\n * @public\n */\nexport class UrlBuilder implements DashboardUrl {\n readonly #url: URL\n\n /**\n * Creates an immutable URL builder at the supplied URL.\n *\n * @example\n * ```ts\n * const builder = new UrlBuilder(\n * new URL('/applications/my-app', 'https://dashboard.sanity.io'),\n * )\n *\n * builder.url() // '/applications/my-app'\n * ```\n */\n constructor(url: URL) {\n this.#url = new URL(url)\n }\n\n /**\n * Returns a builder with each value appended as one encoded path segment.\n *\n * Route literals and identifiers can be passed together. A slash inside a value stays within\n * that segment instead of creating another route level.\n *\n * @example\n * ```ts\n * class DocumentUrlBuilder extends UrlBuilder {\n * document(documentId: string) {\n * return this.append('documents', documentId)\n * }\n * }\n *\n * const builder = new DocumentUrlBuilder(new URL('https://dashboard.sanity.io'))\n * builder.document('drafts/document-1').url()\n * // '/documents/drafts%2Fdocument-1'\n * ```\n */\n protected append(...segments: string[]): this {\n return this.#create(appendSegments(this.#url, segments))\n }\n\n /**\n * Returns a builder with changes made through the platform `URL` API.\n *\n * This supports URL details outside the path grammar, including search parameters and hashes.\n *\n * @example\n * ```ts\n * class DocumentUrlBuilder extends UrlBuilder {\n * perspective(name: string) {\n * return this.edit((url) => url.searchParams.set('perspective', name))\n * }\n *\n * panel(panelId: string) {\n * return this.edit((url) => {\n * url.hash = `panel/${panelId}`\n * })\n * }\n * }\n * ```\n */\n protected edit(update: (url: URL) => void): this {\n const url = new URL(this.#url)\n update(url)\n return this.#create(url)\n }\n\n /**\n * Returns another builder type rooted at the appended path segments.\n *\n * Use this inside a custom builder method only when its route enters a child grammar with\n * different methods; use `append` when chaining stays on the current grammar.\n *\n * @example\n * ```ts\n * class DocumentUrlBuilder extends UrlBuilder {\n * perspective(name: string) {\n * return this.edit((url) => url.searchParams.set('perspective', name))\n * }\n * }\n *\n * class ApplicationUrlBuilder extends UrlBuilder {\n * document(documentId: string) {\n * return this.transitionTo(DocumentUrlBuilder, 'documents', documentId)\n * }\n * }\n *\n * const builder = new ApplicationUrlBuilder(new URL('https://dashboard.sanity.io'))\n * builder.document('document-1').perspective('published').url()\n * // '/documents/document-1?perspective=published'\n * ```\n */\n protected transitionTo<Builder extends UrlBuilder>(\n Builder: new (url: URL) => Builder,\n ...segments: string[]\n ): Builder {\n return new Builder(appendSegments(this.#url, segments))\n }\n\n /**\n * Returns the URL as a relative string by default.\n *\n * Supplying an origin returns an absolute URL string for the same dashboard route.\n *\n * @example\n * ```ts\n * const builder = new UrlBuilder(\n * new URL('/applications/my-app', 'https://dashboard.sanity.io'),\n * )\n *\n * builder.url() // '/applications/my-app'\n * builder.url({origin: 'https://dashboard.sanity.io'})\n * // 'https://dashboard.sanity.io/applications/my-app'\n * ```\n */\n url(options?: {origin?: string}): string {\n const relativeUrl = this.#relativeUrl()\n return options?.origin === undefined ? relativeUrl : new URL(relativeUrl, options.origin).href\n }\n\n /**\n * Returns the URL as a platform `URL` object using the supplied origin.\n *\n * @example\n * ```ts\n * const builder = new UrlBuilder(\n * new URL('/applications/my-app', 'https://dashboard.sanity.io'),\n * )\n *\n * builder.toURL({origin: 'https://dashboard.sanity.io'}).pathname\n * // '/applications/my-app'\n * ```\n */\n toURL({origin}: {origin: string}): URL {\n return new URL(this.#relativeUrl(), origin)\n }\n\n /**\n * Returns the same relative URL as {@link UrlBuilder.url}.\n *\n * @example\n * ```ts\n * const builder = new UrlBuilder(\n * new URL('/applications/my-app', 'https://dashboard.sanity.io'),\n * )\n *\n * `${builder}` // '/applications/my-app'\n * ```\n */\n toString(): string {\n return this.url()\n }\n\n #relativeUrl(): string {\n return `${this.#url.pathname}${this.#url.search}${this.#url.hash}`\n }\n\n #create(url: URL): this {\n const Builder = this.constructor as new (url: URL) => this\n return new Builder(url)\n }\n}\n\nclass CoreApplicationUrlBuilder extends UrlBuilder implements CoreApplicationUrl {\n static readonly namespace = 'applications'\n\n path(...path: string[]): this {\n return this.append(...splitPath(path))\n }\n}\n\nclass MediaLibraryUrlBuilder extends UrlBuilder implements MediaLibraryUrl {\n static readonly namespace = 'media'\n\n asset(assetId: string): DashboardUrl {\n return this.append('assets', assetId)\n }\n\n collection(collectionId: string): DashboardUrl {\n return this.append('collections', collectionId)\n }\n}\n\nclass CanvasUrlBuilder extends UrlBuilder implements CanvasUrl {\n static readonly namespace = 'canvas'\n\n document(documentId: string): DashboardUrl {\n return this.append('doc', documentId)\n }\n}\n\nclass StudioUrlBuilder\n extends UrlBuilder\n implements StudioUrl, StudioWorkspaceUrl, StudioIntentUrl\n{\n static readonly namespace = 'studios'\n\n workspace(workspace: string): StudioWorkspaceUrl {\n return this.append(workspace)\n }\n\n intent(intent: 'edit', parameters: EditIntentParameters): StudioIntentUrl\n intent(intent: 'create', parameters: CreateIntentParameters): StudioIntentUrl\n intent(intent: 'release', parameters: ReleaseIntentParameters): StudioIntentUrl\n intent(...args: IntentArguments): StudioIntentUrl {\n return this.append('intent', args[0]).edit((url) => {\n url.pathname = `${url.pathname}/${serializeIntentParameters(intentParametersOf(...args))}/`\n })\n }\n\n perspective(perspective: string): StudioIntentUrl {\n return this.edit((url) => url.searchParams.set('perspective', perspective))\n }\n\n comment(commentId: string): StudioIntentUrl {\n return this.edit((url) => {\n const segments = url.pathname.split('/')\n const parametersIndex = segments.length - 2\n const parameters = parseIntentParameters(segments[parametersIndex]!)\n parameters.set('inspect', 'sanity/comments')\n parameters.set('comment', commentId)\n segments[parametersIndex] = serializeIntentParameters(parameters)\n url.pathname = segments.join('/')\n })\n }\n\n task(taskId: string): DashboardUrl {\n return this.edit((url) => url.searchParams.set('selectedTask', taskId))\n }\n\n path(...path: string[]): DashboardUrl {\n return this.append(...splitPath(path))\n }\n}\n\n/** @public */\nexport interface Urls {\n studios(): DashboardUrl\n studios(appId: string): StudioUrl\n applications(): DashboardUrl\n applications(appId: string): CoreApplicationUrl\n mediaLibrary(): MediaLibraryUrl\n canvas(): CanvasUrl\n home(): DashboardUrl\n extend<\n const Builders extends Readonly<\n Record<\n string,\n {\n readonly namespace: string\n new (url: URL): UrlBuilder\n }\n >\n >,\n >(\n builders: Builders & Partial<Record<keyof this, never>>,\n ): this & {readonly [Name in keyof Builders]: () => InstanceType<Builders[Name]>}\n}\n\nconst createRootBuilder = <Builder extends UrlBuilder>(\n Builder: (new (url: URL) => Builder) & {readonly namespace: string},\n ...segments: string[]\n): Builder =>\n new Builder(appendSegments(new URL(relativeUrlBase), [Builder.namespace, ...segments]))\n\nconst createUrls = <const Builders extends BuilderRegistry>(\n builders: Builders,\n): Urls & BuilderMethods<Builders> => {\n function studios(): DashboardUrl\n function studios(appId: string): StudioUrl\n function studios(appId?: string): DashboardUrl | StudioUrl {\n return appId === undefined\n ? new UrlBuilder(new URL('/studios/', relativeUrlBase))\n : createRootBuilder(StudioUrlBuilder, appId)\n }\n\n function applications(): DashboardUrl\n function applications(appId: string): CoreApplicationUrl\n function applications(appId?: string): DashboardUrl | CoreApplicationUrl {\n return appId === undefined\n ? new UrlBuilder(new URL('/applications/', relativeUrlBase))\n : createRootBuilder(CoreApplicationUrlBuilder, appId)\n }\n\n const methods = Object.fromEntries(\n Object.entries(builders).map(([name, Builder]) => [name, () => createRootBuilder(Builder)]),\n )\n\n const urls = {\n studios,\n applications,\n mediaLibrary: () => createRootBuilder(MediaLibraryUrlBuilder),\n canvas: () => createRootBuilder(CanvasUrlBuilder),\n home: () => new UrlBuilder(new URL(relativeUrlBase)),\n extend<const AddedBuilders extends BuilderRegistry>(addedBuilders: AddedBuilders) {\n const namespaces = new Set([\n '',\n StudioUrlBuilder.namespace,\n CoreApplicationUrlBuilder.namespace,\n MediaLibraryUrlBuilder.namespace,\n CanvasUrlBuilder.namespace,\n ...Object.values(builders).map((Builder) => Builder.namespace),\n ])\n\n for (const [name, Builder] of Object.entries(addedBuilders)) {\n if (name in urls || name in methods) {\n throw new Error(`URL builder \"${name}\" already exists`)\n }\n if (namespaces.has(Builder.namespace)) {\n throw new Error(`URL namespace \"${Builder.namespace}\" already exists`)\n }\n namespaces.add(Builder.namespace)\n }\n\n return createUrls({...builders, ...addedBuilders})\n },\n }\n\n return Object.assign(urls, methods) as Urls & BuilderMethods<Builders>\n}\n\n/** @public */\nexport const urlFor: Urls = createUrls({})\n","import {type Events, SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {type FrameMessage} from '@sanity/sdk/comlink'\nimport {useCallback, useEffect, useRef} from 'react'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\n\n/**\n * @public\n */\nexport interface AgentResourceContextOptions {\n /**\n * The project ID of the current context\n */\n projectId: string\n /**\n * The dataset of the current context\n */\n dataset: string\n /**\n * Optional document ID if the user is viewing/editing a specific document\n */\n documentId?: string\n}\n\n/**\n * @public\n * Hook for emitting agent resource context updates to the Dashboard.\n * This allows the Agent to understand what resource the user is currently\n * interacting with (e.g., which document they're editing).\n *\n * The hook will automatically emit the context when it changes, and also\n * emit the initial context when the hook is first mounted.\n *\n * @category Agent\n * @param options - The resource context options containing projectId, dataset, and optional documentId\n *\n * @example\n * ```tsx\n * import {useAgentResourceContext} from '@sanity/sdk-react/dashboard'\n *\n * function MyComponent() {\n * const documentId = 'my-document-id'\n *\n * // Automatically updates the Agent's context whenever the document changes\n * useAgentResourceContext({\n * projectId: 'my-project',\n * dataset: 'production',\n * documentId,\n * })\n *\n * return <div>Editing document: {documentId}</div>\n * }\n * ```\n */\nexport function useAgentResourceContext(options: AgentResourceContextOptions): void {\n const {projectId, dataset, documentId} = options\n const {sendMessage} = useWindowConnection<Events.AgentResourceUpdateMessage, FrameMessage>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n })\n\n // Track the last sent context to avoid duplicate updates\n const lastContextRef = useRef<string | null>(null)\n\n const updateContext = useCallback(() => {\n // Validate required fields\n if (!projectId || !dataset) {\n // eslint-disable-next-line no-console\n console.warn('[useAgentResourceContext] projectId and dataset are required', {\n projectId,\n dataset,\n })\n return\n }\n\n // Create a stable key for the current context\n const contextKey = `${projectId}:${dataset}:${documentId || ''}`\n\n // Skip if context hasn't changed\n if (lastContextRef.current === contextKey) {\n return\n }\n\n try {\n const message: Events.AgentResourceUpdateMessage = {\n type: 'dashboard/v1/events/agent/resource/update',\n data: {\n projectId,\n dataset,\n documentId,\n },\n }\n\n sendMessage(message.type, message.data)\n lastContextRef.current = contextKey\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('[useAgentResourceContext] Failed to update context:', error)\n }\n }, [projectId, dataset, documentId, sendMessage])\n\n // Update context whenever it changes\n useEffect(() => {\n updateContext()\n }, [updateContext])\n}\n","import {type ApplicationBase} from '@sanity/sdk'\nimport {getApplicationOrigin} from '@sanity/sdk/_internal'\nimport {type RemoteModuleRef, type ValueOf} from '@sanity/sdk/dashboard'\nimport {useMemo} from 'react'\n\nimport {useTopic} from './useTopic'\n\ntype DashboardTopicApplication = Extract<\n NonNullable<ValueOf<'applications.list'>>,\n {ok: true}\n>['value'][number]\ntype DashboardApplicationInterface = NonNullable<\n NonNullable<DashboardTopicApplication['activeDeployment']>['interfaces']\n>[number]\ntype ViewInterface = Exclude<DashboardApplicationInterface, {type: 'worker'}>\n\n/**\n * A dashboard view exposed by an application.\n * @public\n */\nexport type DashboardView = {\n [Type in ViewInterface['type']]: Omit<Extract<ViewInterface, {type: Type}>, 'type'> & {\n readonly application: ApplicationBase\n readonly module: RemoteModuleRef\n readonly surface: Type extends 'app' ? 'window' : Type\n }\n}[ViewInterface['type']]\n\n/**\n * A web worker exposed by an application.\n * @public\n */\nexport type DashboardWebWorker = Extract<DashboardApplicationInterface, {type: 'worker'}> & {\n readonly application: ApplicationBase\n readonly module: RemoteModuleRef\n}\n\n/**\n * The minimal Brett application fields with its loadable views and web workers.\n * @public\n */\nexport type DashboardApplication = DashboardTopicApplication & {\n readonly views: DashboardView[]\n readonly webWorkers: DashboardWebWorker[]\n}\n\n// Only a federated deployment (one with a module federation manifest) exposes loadable modules.\nconst loadableInterfaces = ({\n activeDeployment,\n config,\n}: DashboardTopicApplication): readonly DashboardApplicationInterface[] =>\n config?.mfManifest === undefined ? [] : (activeDeployment?.interfaces ?? [])\n\nconst toApplication = (application: DashboardTopicApplication): DashboardApplication => {\n const {activeDeployment: _activeDeployment, config: _config, ...applicationBase} = application\n const interfaces = loadableInterfaces(application)\n // Nothing to load without interfaces or an origin to load them from.\n const entry = interfaces.length === 0 ? null : getApplicationOrigin(applicationBase)\n if (entry === null) return {...application, views: [], webWorkers: []}\n\n const views: DashboardView[] = []\n const webWorkers: DashboardWebWorker[] = []\n\n for (const extension of interfaces) {\n const module: RemoteModuleRef = {\n entry,\n moduleId: `${applicationBase.id}/${extension.moduleId}`,\n version: extension.version,\n }\n\n if (extension.type === 'worker') {\n webWorkers.push({...extension, application: applicationBase, module})\n continue\n }\n\n const {type, ...view} = extension\n // TS cannot correlate `surface` with the narrowed `type` across the mapped union; the\n // cast is checked by the `DashboardView` mapping above and the surface assertions in the tests.\n views.push({\n ...view,\n application: applicationBase,\n module,\n surface: type === 'app' ? 'window' : type,\n } as DashboardView)\n }\n\n return {...application, views, webWorkers}\n}\n\n/**\n * Returns the applications available in the dashboard.\n *\n * Suspends until the dashboard publishes its application list; a cleared list is empty. Throws a\n * `TopicError` to the nearest error boundary when the dashboard fails to load applications.\n *\n * @example\n * ```tsx\n * function Applications() {\n * const applications = useApplications()\n * return applications.map((application) => <div key={application.id}>{application.title}</div>)\n * }\n * ```\n *\n * @public\n */\nexport function useApplications(): DashboardApplication[] {\n const applications = useTopic('applications.list')\n return useMemo(() => applications?.map(toApplication) ?? [], [applications])\n}\n","import {type DashboardApplication, useApplications} from './useApplications'\n\n/**\n * Returns a dashboard application by id, or `null` when it is unavailable.\n *\n * Suspends until the dashboard publishes its application list.\n *\n * @example\n * ```tsx\n * function SelectedApplication({id}: {id: string}) {\n * const application = useApplication(id)\n * return application ? <h1>{application.title}</h1> : <p>Application unavailable</p>\n * }\n * ```\n *\n * @public\n */\nexport function useApplication(\n applicationId: DashboardApplication['id'],\n): DashboardApplication | null {\n return useApplications().find(({id}) => id === applicationId) ?? null\n}\n","import {type TopicData} from '@sanity/sdk/dashboard'\n\nimport {useTopic} from './useTopic'\n\n/**\n * Returns the base path for an application.\n *\n * Suspends until Dashboard publishes the path and throws a `TopicError` when the application is\n * unknown.\n *\n * @example\n * ```tsx\n * function ApplicationBasePath() {\n * const basePath = useApplicationBasePath()\n * return <span>{basePath}</span>\n * }\n * ```\n *\n * @public\n */\nexport function useApplicationBasePath(): TopicData<'applications.base-path'> {\n return useTopic('applications.base-path')\n}\n","import {type ApplicationConfig} from '@sanity/sdk/dashboard'\n\nimport {useTopic} from './useTopic'\n\n// Stable, frozen reference for the cleared/absent case so the return value only changes with the\n// topic and callers cannot mutate the shared empty list.\nconst NO_CONFIGS: readonly ApplicationConfig[] = Object.freeze([])\n\n/**\n * Returns the application configuration modules available in the dashboard.\n *\n * Suspends until the dashboard publishes its application configs; a cleared list is empty.\n *\n * @example\n * ```tsx\n * function Applications() {\n * const configs = useApplicationConfigs()\n * return configs.map((config) => <div key={config.moduleId}>{config.appType}</div>)\n * }\n * ```\n *\n * @public\n */\nexport function useApplicationConfigs(): readonly ApplicationConfig[] {\n return useTopic('applications.config') ?? NO_CONFIGS\n}\n","import {type Application} from '@sanity/sdk'\nimport {type ApplicationConfig, type ApplicationConfigAppType} from '@sanity/sdk/dashboard'\n\nimport {useApplicationConfigs} from './useApplicationConfigs'\n\n/**\n * Selects an application configuration by application id or application type.\n * @public\n */\nexport type ApplicationConfigSelector =\n | {appId: Application['id']; appType?: never}\n | {appId?: never; appType: ApplicationConfigAppType}\n\n/**\n * Returns an application configuration by application id or application type, or `null` when\n * none matches.\n *\n * An `appType` query matches the type-level config only (the one without an `appId`), so it is\n * independent of the order the dashboard published configs in. An `appId` query matches that\n * application's config.\n *\n * Suspends until the dashboard publishes its application configs.\n *\n * @example\n * ```tsx\n * function MediaLibraryConfig() {\n * const config = useApplicationConfig({appType: 'media-library'})\n * return config ? <span>{config.moduleId}</span> : <p>Not installed</p>\n * }\n * ```\n *\n * @public\n */\nexport function useApplicationConfig(\n selector: ApplicationConfigSelector,\n): ApplicationConfig | null {\n const configs = useApplicationConfigs()\n return (\n configs.find((config) =>\n selector.appId === undefined\n ? config.appType === selector.appType && config.appId === undefined\n : config.appId === selector.appId,\n ) ?? null\n )\n}\n","import {type Application} from '@sanity/sdk'\n\nimport {useTopic} from './useTopic'\n\n/**\n * Returns the id of the application in the foreground, or `null` when Dashboard has none.\n *\n * Suspends until Dashboard publishes the foreground application.\n *\n * @example\n * ```tsx\n * function ForegroundApplication() {\n * const foregroundId = useApplicationForegroundId()\n * return <span>{foregroundId ?? 'No foreground application'}</span>\n * }\n * ```\n *\n * @public\n */\nexport function useApplicationForegroundId(): Application['id'] | null {\n return useTopic('applications.foreground')\n}\n","import {useTopic} from './useTopic'\n\n/**\n * Returns the session token for the reading connection, or `null` while signed out.\n *\n * Suspends until Dashboard publishes the token.\n *\n * @example\n * ```tsx\n * function AuthToken() {\n * const token = useAuthToken()\n * return <span>{token ?? 'Signed out'}</span>\n * }\n * ```\n *\n * @public\n */\nexport function useAuthToken(): string | null {\n return useTopic('auth.token')\n}\n","import {type CurrentUser} from '@sanity/types'\n\nimport {useTopic} from './useTopic'\n\n/**\n * Returns the signed-in user, or `null` while signed out.\n *\n * Suspends until Dashboard publishes the current user.\n *\n * @example\n * ```tsx\n * function CurrentUser() {\n * const user = useCurrentUser()\n * return <span>{user?.name ?? 'Signed out'}</span>\n * }\n * ```\n *\n * @public\n */\nexport function useCurrentUser(): CurrentUser | null {\n return useTopic('users.current')\n}\n","import {requireDashboardMessageBus} from '@sanity/sdk/_internal'\nimport {\n type EventTopic,\n type MessageBusEmitOptions,\n type MessageBusEmitResult,\n type PayloadOf,\n type ReplyOf,\n} from '@sanity/sdk/dashboard'\nimport {useCallback} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * Emits a dashboard event topic, typed to the topic's payload and reply.\n * @public\n */\nexport type TopicEmitter<K extends EventTopic> = (\n ...args: PayloadOf<K> extends void\n ? [payload?: void, options?: MessageBusEmitOptions]\n : [payload: PayloadOf<K>, options?: MessageBusEmitOptions]\n) => MessageBusEmitResult<ReplyOf<K>>\n\n/**\n * Returns a stable function that emits a dashboard event topic.\n *\n * The event is sent immediately. Ignore the lazy result for fire-and-forget delivery, await it\n * inside `useTransition` to track a reply, or read it with React `use` to suspend. A reply\n * that fails (`NO_RESPONDER`, `TIMEOUT`, `ABORTED`) rejects the result; when read with `use`\n * that reaches the nearest error boundary, so pair the `Suspense` with one.\n *\n * @example Fire and forget\n * ```tsx\n * function ExpandPanel() {\n * const setPanelMode = useEmit('panels.mode.set')\n * return (\n * <button onClick={() => setPanelMode({name: 'favorites', mode: 'full'})}>\n * Expand\n * </button>\n * )\n * }\n * ```\n *\n * @example Await a reply with Suspense\n * ```tsx\n * function Session({request}: {request: MessageBusEmitResult<string>}) {\n * use(request)\n * return <p>Ready</p>\n * }\n *\n * function SessionAccordion() {\n * const refreshToken = useEmit('auth.token.refresh')\n * const [request, setRequest] = useState<MessageBusEmitResult<string> | null>(null)\n *\n * return (\n * <details\n * onToggle={(event) => setRequest(event.currentTarget.open ? refreshToken() : null)}\n * >\n * <summary>Session</summary>\n * <ErrorBoundary fallback={<p>Could not refresh</p>}>\n * <Suspense fallback={<p>Refreshing...</p>}>\n * {request && <Session request={request} />}\n * </Suspense>\n * </ErrorBoundary>\n * </details>\n * )\n * }\n * ```\n *\n * @public\n */\nexport function useEmit<K extends EventTopic>(topic: K): TopicEmitter<K> {\n const instance = useSanityInstance()\n const messageBus = requireDashboardMessageBus(instance, `emit topic \"${topic}\"`)\n return useCallback<TopicEmitter<K>>(\n (...args) => messageBus.emit(topic, ...args),\n [messageBus, topic],\n )\n}\n","import {type PathChangeMessage, SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\n\n/**\n * @public\n *\n * A helper hook designed to be injected into routing components for apps within the Dashboard.\n * While the Dashboard can usually handle navigation, there are special cases when you\n * are already within a target app, and need to navigate to another route inside of that app.\n *\n * For example, your user might \"favorite\" a document inside of your application.\n * If they click on the Dashboard favorites item in the sidebar, and are already within your application,\n * there needs to be some way for the dashboard to signal to your application to reroute to where that document was favorited.\n *\n * This hook is intended to receive those messages, and takes a function to route to the correct path.\n *\n * @param navigateFn - Function to handle navigation; should accept:\n * - `path`: a string, which will be a relative path (for example, 'my-route')\n * - `type`: 'push', 'replace', or 'pop', which will be the type of navigation to perform\n *\n * @example\n * ```tsx\n * import {useNavigate} from '@sanity/sdk-react/dashboard'\n * import {BrowserRouter, useNavigate as useRouterNavigate} from 'react-router'\n * import {Suspense} from 'react'\n *\n * function DashboardNavigationHandler() {\n * const navigate = useRouterNavigate()\n * useNavigate(({path, type}) => {\n * navigate(path, {replace: type === 'replace'})\n * })\n * return null\n * }\n *\n * // Wrap the component with Suspense since the hook may suspend\n * function MyApp() {\n * return (\n * <BrowserRouter>\n * <Suspense>\n * <DashboardNavigationHandler />\n * </Suspense>\n * </BrowserRouter>\n * )\n * }\n * ```\n */\nexport function useNavigate(navigateFn: (options: PathChangeMessage['data']) => void): void {\n useWindowConnection<PathChangeMessage, never>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n onMessage: {\n 'dashboard/v1/history/change-path': (data: PathChangeMessage['data']) => {\n navigateFn(data)\n },\n },\n })\n}\n","import {type Bridge, SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {type DocumentHandle} from '@sanity/sdk'\nimport {useCallback} from 'react'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\nimport {\n type DashboardResource,\n useStudioWorkspacesByProjectIdDataset,\n} from './useStudioWorkspacesByProjectIdDataset'\n\n/**\n * @public\n * @category Types\n */\nexport interface NavigateToStudioResult {\n navigateToStudioDocument: () => void\n}\n\n/**\n * @public\n *\n * Hook that provides a function to navigate to a given document in its parent Studio.\n *\n * Uses the `projectId` and `dataset` properties of the {@link DocumentHandle} you provide to resolve the correct Studio.\n * This will only work if you have deployed a studio with a workspace with this `projectId` / `dataset` combination.\n *\n * @remarks If you write your own Document Handle to pass to this hook (as opposed to a Document Handle generated by another hook),\n * it must include values for `documentId`, `documentType`, `projectId`, and `dataset`.\n *\n * @category Documents\n * @param documentHandle - The document handle for the document to navigate to\n * @param preferredStudioUrl - The preferred studio url to navigate to if you have multiple\n * studios with the same projectId and dataset\n * @returns An object containing:\n * - `navigateToStudioDocument` - Function that when called will navigate to the studio document\n *\n * @example\n * ```tsx\n * import {type DocumentHandle} from '@sanity/sdk-react'\n * import {useNavigateToStudioDocument} from '@sanity/sdk-react/dashboard'\n * import {Button} from '@sanity/ui'\n * import {Suspense} from 'react'\n *\n * function NavigateButton({documentHandle}: {documentHandle: DocumentHandle}) {\n * const {navigateToStudioDocument} = useNavigateToStudioDocument(documentHandle)\n * return (\n * <Button\n * onClick={navigateToStudioDocument}\n * text=\"Navigate to Studio Document\"\n * />\n * )\n * }\n *\n * // Wrap the component with Suspense since the hook may suspend\n * function MyDocumentAction({documentHandle}: {documentHandle: DocumentHandle}) {\n * return (\n * <Suspense fallback={<Button text=\"Loading...\" disabled />}>\n * <NavigateButton documentHandle={documentHandle} />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function useNavigateToStudioDocument(\n documentHandle: DocumentHandle,\n preferredStudioUrl?: string,\n): NavigateToStudioResult {\n const {workspacesByProjectIdAndDataset} = useStudioWorkspacesByProjectIdDataset()\n const {sendMessage} = useWindowConnection<Bridge.Navigation.NavigateToResourceMessage, never>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n })\n\n const navigateToStudioDocument = useCallback(() => {\n const {projectId, dataset} = documentHandle\n\n if (!projectId || !dataset) {\n // eslint-disable-next-line no-console\n console.warn('Project ID and dataset are required to navigate to a studio document')\n return\n }\n\n let workspace: DashboardResource | undefined\n\n if (preferredStudioUrl) {\n // Get workspaces matching the projectId:dataset and any workspaces without projectId/dataset,\n // in case there hasn't been a manifest loaded yet\n const allWorkspaces = [\n ...(workspacesByProjectIdAndDataset[`${projectId}:${dataset}`] || []),\n ...(workspacesByProjectIdAndDataset['NO_PROJECT_ID:NO_DATASET'] || []),\n ]\n workspace = allWorkspaces.find((w) => w.url === preferredStudioUrl)\n } else {\n const workspaces = workspacesByProjectIdAndDataset[`${projectId}:${dataset}`]\n if (workspaces?.length > 1) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Multiple workspaces found for document and no preferred studio url',\n documentHandle,\n )\n // eslint-disable-next-line no-console\n console.warn('Using the first one', workspaces[0])\n }\n\n workspace = workspaces?.[0]\n }\n\n if (!workspace) {\n // eslint-disable-next-line no-console\n console.warn(\n `No workspace found for document with projectId: ${projectId} and dataset: ${dataset}${preferredStudioUrl ? ` or with preferred studio url: ${preferredStudioUrl}` : ''}`,\n )\n return\n }\n\n const message: Bridge.Navigation.NavigateToResourceMessage = {\n type: 'dashboard/v1/bridge/navigate-to-resource',\n data: {\n resourceId: workspace.id,\n resourceType: 'studio',\n path: `/intent/edit/id=${documentHandle.documentId};type=${documentHandle.documentType}`,\n },\n }\n\n sendMessage(message.type, message.data)\n }, [documentHandle, workspacesByProjectIdAndDataset, sendMessage, preferredStudioUrl])\n\n return {\n navigateToStudioDocument,\n }\n}\n","import {type SanityInstance, type StateSource} from '@sanity/sdk'\nimport {of} from 'rxjs'\n\nimport {createRemoteInstance, type RemoteInstance} from './createRemoteInstance'\n\nconst remoteClientStates = new WeakMap<SanityInstance, StateSource<RemoteInstance>>()\n\n/** Returns the instance's remote client state, creating it on first use. @internal */\nexport function getRemoteClientState(instance: SanityInstance): StateSource<RemoteInstance> {\n if (instance.isDisposed()) {\n throw new Error('Cannot create a remote client for a disposed Sanity instance')\n }\n\n const current = remoteClientStates.get(instance)\n if (current) return current\n\n const client = createRemoteInstance({name: `sanity-remote-${instance.instanceId}`})\n const state = {\n getCurrent: () => client,\n observable: of(client),\n subscribe: () => () => {},\n }\n\n remoteClientStates.set(instance, state)\n instance.onDispose(() => remoteClientStates.delete(instance))\n return state\n}\n","import {type RemoteInstance} from '../../dashboard/createRemoteInstance'\nimport {getRemoteClientState} from '../../dashboard/remoteClientState'\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * Returns a remote client shared by hooks using the same Sanity instance.\n * The first call creates the client; later calls reuse it.\n * @public\n */\nexport const useRemoteClient: () => RemoteInstance = createStateSourceHook(getRemoteClientState)\n","/* eslint-disable react-compiler/react-compiler -- the transport branch in `useWindowTitle` is a deliberate rules-of-hooks exception; the compiler refuses files that disable it */\nimport {SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {isDashboardEnvironment} from '@sanity/sdk/_internal'\nimport {useEffect, useState} from 'react'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\n\ninterface ContextResource {\n type: string\n title?: string\n manifest?: {\n title?: string\n } | null\n activeDeployment?: {\n manifest?: {\n title?: string\n } | null\n } | null\n}\n\ninterface ContextResponse {\n context: {\n resource: ContextResource\n }\n}\n\nfunction resolveAppTitle(resource: ContextResource): string | undefined {\n return resource.manifest?.title || resource.activeDeployment?.manifest?.title || resource.title\n}\n\n/**\n * Sets the browser's document title, automatically including the app's name\n * from the manifest.\n *\n * This follows the same convention as Sanity Studio workspaces, where the\n * workspace name is always present in the title:\n *\n * - With a view title: `<viewTitle> | <appTitle>`\n * - Without a view title: `<appTitle>`\n *\n * The Sanity dashboard appends `| Sanity` to produce the final browser tab title.\n *\n * Works in both Dashboard runtimes: it manages the document title over the Comlink connection, and\n * no-ops under the message bus, where the Dashboard host owns the title.\n *\n * @param viewTitle - An optional view-specific title to prepend to the app title.\n *\n * @example\n * ```tsx\n * import {useWindowTitle} from '@sanity/sdk-react/dashboard'\n *\n * function MoviesList() {\n * useWindowTitle('Movies')\n * return <div>...</div>\n * }\n *\n * // Browser tab: \"Movies | My App | Sanity\"\n * ```\n *\n * @example\n * ```tsx\n * // Call without arguments to show just the app title\n * function AppRoot() {\n * useWindowTitle()\n * return <Outlet />\n * }\n *\n * // Browser tab: \"My App | Sanity\"\n * ```\n *\n * @public\n */\nexport function useWindowTitle(viewTitle?: string): void {\n // The document title is set by the Dashboard host under the message bus, so this hook only\n // manages it in the Comlink runtime. The branch is stable: the transport is fixed for the page\n // lifetime, so the Comlink hooks below always run or never run.\n if (isDashboardEnvironment()) return\n // eslint-disable-next-line react-hooks/rules-of-hooks -- transport is fixed for the page lifetime\n useComlinkWindowTitle(viewTitle)\n}\n\nfunction useComlinkWindowTitle(viewTitle?: string): void {\n const [appTitle, setAppTitle] = useState<string | null>(null)\n\n const {fetch} = useWindowConnection({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n })\n\n useEffect(() => {\n if (!fetch) return\n\n const controller = new AbortController()\n\n async function fetchAppTitle(signal: AbortSignal) {\n try {\n const data = await fetch<ContextResponse>('dashboard/v1/context', undefined, {signal})\n // Local development resources do not have a registered title or deployment manifest.\n // In that case, use the title rendered into the iframe HTML by the Sanity CLI.\n const title = resolveAppTitle(data.context.resource) || document.title\n if (title) {\n setAppTitle(title)\n }\n } catch (err: unknown) {\n if (err instanceof Error && err.name === 'AbortError') return\n // eslint-disable-next-line no-console\n console.error('Failed to fetch app title from dashboard context:', err)\n }\n }\n\n fetchAppTitle(controller.signal)\n\n return () => {\n controller.abort()\n }\n }, [fetch])\n\n useEffect(() => {\n if (!appTitle) return\n\n const previous = document.title\n document.title = viewTitle ? `${viewTitle} | ${appTitle}` : appTitle\n\n return () => {\n document.title = previous\n }\n }, [viewTitle, appTitle])\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAMc,gBAAgB;AAEtB,SAASC,aAAwCC,QAAc;CAC7D,IAAIA,OAAOH,MAAMI,SAAS,IAAIH,eAAe,GAAG,OAAOE;CACvD,IAAME,OAAOF,OAAOH,MAAMI,SAAS,GAAG,IAAID,OAAOH,QAAQ,GAAGG,OAAOH,MAAK;CACxE,OAAO;EAAC,GAAGG;EAAQH,OAAO,IAAIM,IAAIL,eAAeI,IAAI,CAAC,CAACE;CAAI;AAC7D;;;;;AAyBA,SAAgBU,qBAAqBC,SAAsD;CACzF,IAAMC,SAAS5B,aAAa2B,QAAQnB,IAAI,GAClCqB,WAAWhC,eAAiB;EAChC,GAAG8B;EACHG,SAAS,CAACC,IAAIH,OAAOI,KAAK,GAAG,GAAIL,QAAQG,WAAW,CAAA,CAAG;EACvDV,SACEO,QAAQP,SAASa,KAAKrB,WAAY,WAAWA,SAASD,aAAaC,MAAM,IAAIA,MAAO,KAAK,CAAA;CAC7F,CAAC;CAED,OAAO;EACLO,kBAAkBC,YAChBS,SAASV,gBAAgBC,QAAQa,IAAItB,YAAY,GAAG,EAACuB,OAAO,GAAK,CAAC;EACpEb,YAAY,OAAUC,OAAe;GACnC,IAAIa;GAEJ,IAAI;IACFA,eAAe,MAA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,QAAqB;GAChD,IAAI;IAIF,IAAMlB,QAAQM,iBAAgBc,MAHXR,MAAuB,wBAAwBS,KAAAA,GAAW,EAACH,OAAM,CAAC,EAAA,CAGlDd,QAAQC,QAAQ,KAAKiB,SAAStB;IACjE,AAAIA,SACFW,YAAYX,KAAK;GAErB,SAASuB,KAAc;IACrB,IAAIA,eAAeC,SAASD,IAAIV,SAAS,cAAc;IAEvDY,QAAQC,MAAM,qDAAqDH,GAAG;GACxE;EACF;EAIA,OAFAN,cAAcF,WAAWG,MAAM,SAElB;GACXH,WAAWY,MAAM;EACnB;CACF,GAAG,CAACf,KAAK,CAAC,GAEVjB,gBAAgB;EACd,IAAI,CAACe,UAAU;EAEf,IAAMkB,WAAWN,SAAStB;EAG1B,OAFAsB,SAAStB,QAAQQ,YAAY,GAAGA,UAAS,KAAME,aAAaA,gBAE/C;GACXY,SAAStB,QAAQ4B;EACnB;CACF,GAAG,CAACpB,WAAWE,QAAQ,CAAC;AAC1B"}
package/dist/index.d.ts CHANGED
@@ -1692,6 +1692,9 @@ interface StudioWorkspacesResult {
1692
1692
  }
1693
1693
  /**
1694
1694
  * Hook that fetches studio workspaces and organizes them by projectId:dataset
1695
+ *
1696
+ * Works in both Dashboard runtimes: it derives workspaces from the `applications.list` message
1697
+ * bus topic when a host has installed the bus, and falls back to the Comlink connection otherwise.
1695
1698
  * @internal
1696
1699
  *
1697
1700
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/components/auth/LoginError.tsx","../src/components/auth/AuthBoundary.tsx","../src/components/SanityApp.tsx","../src/components/SDKProvider.tsx","../src/config/handles.ts","../src/context/ComlinkTokenRefresh.tsx","../src/context/renderSanityApp.tsx","../src/context/ResourceProvider.tsx","../src/context/SanityInstanceProvider.tsx","../src/context/SDKStudioContext.ts","../src/hooks/helpers/createFetcherHook.ts","../src/hooks/access/useCheckPermissions.ts","../src/hooks/agent/agentActions.ts","../src/hooks/applications/useApplication.ts","../src/hooks/applications/useApplications.ts","../src/hooks/helpers/createMutationHook.tsx","../src/hooks/applications/useDeleteApplication.ts","../src/hooks/applications/useUpdateApplication.ts","../src/hooks/auth/useAuthState.tsx","../src/hooks/auth/useAuthToken.tsx","../src/hooks/auth/useCurrentUser.tsx","../src/hooks/auth/useHandleAuthCallback.tsx","../src/hooks/auth/useHandleOAuthCallback.tsx","../src/hooks/auth/useLoginUrl.tsx","../src/hooks/auth/useLogOut.tsx","../src/hooks/auth/useOAuthAuthorize.tsx","../src/hooks/auth/useOAuthTokens.tsx","../src/hooks/auth/useVerifyOrgProjects.tsx","../src/hooks/client/useClient.ts","../../../node_modules/.pnpm/xstate@5.32.6/node_modules/xstate/dist/declarations/src/index.d.ts","../../../node_modules/.pnpm/@sanity+comlink@4.0.3/node_modules/@sanity/comlink/dist/index.d.ts","../src/hooks/comlink/useFrameConnection.ts","../src/hooks/comlink/useWindowConnection.ts","../src/hooks/helpers/useNormalizedResourceOptions.ts","../src/hooks/comments/useCommentActions.ts","../src/hooks/comments/useComments.ts","../src/hooks/comments/useCommentThreads.ts","../src/hooks/context/useResource.ts","../src/hooks/context/useSanityInstance.ts","../src/hooks/dashboard/useFavoriteContext.ts","../src/hooks/dashboard/useFavorite.ts","../src/hooks/dashboard/useRecordDocumentHistoryEvent.ts","../src/hooks/dashboard/useStudioWorkspacesByProjectIdDataset.ts","../src/hooks/dashboard/useUpdateFavorite.ts","../src/hooks/datasets/useDatasets.ts","../src/hooks/document/useApplyDocumentActions.ts","../src/hooks/document/useCreateDocument.ts","../src/hooks/document/useDocument.ts","../src/hooks/document/useDocumentEvent.ts","../src/hooks/document/useDocumentPermissions.ts","../src/hooks/document/useDocumentSyncStatus.ts","../src/hooks/document/useEditDocument.ts","../src/hooks/documents/useDocuments.ts","../src/hooks/installations/useInstallation.ts","../src/hooks/installations/useInstallations.ts","../src/hooks/organizations/useOrganization.ts","../src/hooks/organizations/useOrganizations.ts","../src/hooks/paginatedDocuments/usePaginatedDocuments.ts","../src/hooks/presence/usePresence.ts","../src/hooks/presence/usePresenceForDocument.ts","../src/hooks/presence/useReportPresence.ts","../src/hooks/preview/useDocumentPreview.tsx","../src/hooks/projection/useDocumentProjection.ts","../src/hooks/projects/useProject.ts","../src/hooks/projects/useProjects.ts","../src/hooks/query/useQuery.ts","../src/hooks/releases/useActiveReleases.ts","../src/hooks/releases/useAllReleases.ts","../src/hooks/releases/useApplyReleaseActions.ts","../src/hooks/releases/usePerspective.ts","../src/hooks/users/useUser.ts","../src/hooks/users/useUsers.ts","../src/version.ts"],"x_google_ignoreList":[29,30],"mappings":";;;;;;;;;;;;;KAoBY,kBAAkB;;;;UCmBb;;;;;EAKf,iBAAiB,MAAM;IACrB,SAAS,MAAM;IACf,SAAS,MAAM;;;;;;EAOjB,oBAAoB,MAAM;IACxB,SAAS,MAAM;IACf,SAAS,MAAM;;;;;;;EAQjB,sBAAsB,MAAM,cAAc;;EAG1C,SAAS,MAAM;;;;EAKf;;EAGA,SAAS,MAAM;;EAGf,WAAW,MAAM;;;;;;;;EASjB;;;;;;;;;;;;;;;;;;;;;;;wBAwBc,eACd,wBACG,SACF,oBAAoB,MAAM;;;;;UCrGZ;;;;;;;EAOf,SAAS,eAAe;EACxB,YAAY,eAAe;EAC3B,UAAU,MAAM;EAEhB,UAAU,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqFc,YACd,UACA,UACA,QAAQ,eACL,SACF,iBAAiB;;;;UC3HH,yBAAyB;EACxC,UAAU;EACV,QAAQ,eAAe;EACvB,UAAU;EACV,YAAY,eAAe;;EAE3B;;;;;;;wBAoBc,cACd,UACA,QACA,UACA,+BACG,SACF,mBAAmB;;;;;;;;;;;;UClCL,eACf,kCACA,4CACQ,cAAc,UAAU;;;;;EAKhC;;;;;;UAOe,mBACf,uCACA,kCACA,4CACQ,qBAAuB,eAAe,UAAU;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;;;;;;;;;;;;;;;;;qBCblC,cACX,wCACA,wCAEA,UAAU,gBAAgB,gBAAgB,qBACvC,kBAAkB,QAAQ,gBAAgB;;;;;KC1B1C,gBACH,gCACA,kCACA,sCACE,wBAAwB,aAAa,QAAQ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0D3C,SACd,gCACA,kCACA,oCAEA,SAAS,gBAAgB,QAAQ,UAAU;;EAG3C,MAAM,mBAAmB,WAAW,cAAc;;EAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgCc,SAAS,OAAO,SAAS,wBAAwB;;EAE/D,MAAM;;EAEN;;;;;;;;;;;;;;;;;;wBCzEc,kBACd,UAAU,wBAAwB,6BACjC;;;;;;;;;;;;;;;;;;;;;;;;;;wBCKa,eACd,UAAU,wBAAwB,6BACjC;;;;UClDO;OACH,QAAQ,gBAAgB,iBAAiB,UAAU,mBAAmB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAsExE,wBAAwB;;;;;wBC1BrB,eAAe,oBAAoB;;;;;UC1ClC;;;;EAIf,MAAM;;;;EAIN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmCc,QAAQ,SAAS,iBAAiB;;;;;UCpCjC;;;;EAIf,MAAM;;;;EAIN;;;;EAKA;;;;EAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0Dc,SAAS,UAAU,kBAAkB;;;;;qBCtFxC"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/components/auth/LoginError.tsx","../src/components/auth/AuthBoundary.tsx","../src/components/SanityApp.tsx","../src/components/SDKProvider.tsx","../src/config/handles.ts","../src/context/ComlinkTokenRefresh.tsx","../src/context/renderSanityApp.tsx","../src/context/ResourceProvider.tsx","../src/context/SanityInstanceProvider.tsx","../src/context/SDKStudioContext.ts","../src/hooks/helpers/createFetcherHook.ts","../src/hooks/access/useCheckPermissions.ts","../src/hooks/agent/agentActions.ts","../src/hooks/applications/useApplication.ts","../src/hooks/applications/useApplications.ts","../src/hooks/helpers/createMutationHook.tsx","../src/hooks/applications/useDeleteApplication.ts","../src/hooks/applications/useUpdateApplication.ts","../src/hooks/auth/useAuthState.tsx","../src/hooks/auth/useAuthToken.tsx","../src/hooks/auth/useCurrentUser.tsx","../src/hooks/auth/useHandleAuthCallback.tsx","../src/hooks/auth/useHandleOAuthCallback.tsx","../src/hooks/auth/useLoginUrl.tsx","../src/hooks/auth/useLogOut.tsx","../src/hooks/auth/useOAuthAuthorize.tsx","../src/hooks/auth/useOAuthTokens.tsx","../src/hooks/auth/useVerifyOrgProjects.tsx","../src/hooks/client/useClient.ts","../../../node_modules/.pnpm/xstate@5.32.6/node_modules/xstate/dist/declarations/src/index.d.ts","../../../node_modules/.pnpm/@sanity+comlink@4.0.3/node_modules/@sanity/comlink/dist/index.d.ts","../src/hooks/comlink/useFrameConnection.ts","../src/hooks/comlink/useWindowConnection.ts","../src/hooks/helpers/useNormalizedResourceOptions.ts","../src/hooks/comments/useCommentActions.ts","../src/hooks/comments/useComments.ts","../src/hooks/comments/useCommentThreads.ts","../src/hooks/context/useResource.ts","../src/hooks/context/useSanityInstance.ts","../src/hooks/dashboard/useFavoriteContext.ts","../src/hooks/dashboard/useFavorite.ts","../src/hooks/dashboard/useRecordDocumentHistoryEvent.ts","../src/hooks/dashboard/useStudioWorkspacesByProjectIdDataset.ts","../src/hooks/dashboard/useUpdateFavorite.ts","../src/hooks/datasets/useDatasets.ts","../src/hooks/document/useApplyDocumentActions.ts","../src/hooks/document/useCreateDocument.ts","../src/hooks/document/useDocument.ts","../src/hooks/document/useDocumentEvent.ts","../src/hooks/document/useDocumentPermissions.ts","../src/hooks/document/useDocumentSyncStatus.ts","../src/hooks/document/useEditDocument.ts","../src/hooks/documents/useDocuments.ts","../src/hooks/installations/useInstallation.ts","../src/hooks/installations/useInstallations.ts","../src/hooks/organizations/useOrganization.ts","../src/hooks/organizations/useOrganizations.ts","../src/hooks/paginatedDocuments/usePaginatedDocuments.ts","../src/hooks/presence/usePresence.ts","../src/hooks/presence/usePresenceForDocument.ts","../src/hooks/presence/useReportPresence.ts","../src/hooks/preview/useDocumentPreview.tsx","../src/hooks/projection/useDocumentProjection.ts","../src/hooks/projects/useProject.ts","../src/hooks/projects/useProjects.ts","../src/hooks/query/useQuery.ts","../src/hooks/releases/useActiveReleases.ts","../src/hooks/releases/useAllReleases.ts","../src/hooks/releases/useApplyReleaseActions.ts","../src/hooks/releases/usePerspective.ts","../src/hooks/users/useUser.ts","../src/hooks/users/useUsers.ts","../src/version.ts"],"x_google_ignoreList":[29,30],"mappings":";;;;;;;;;;;;;KAoBY,kBAAkB;;;;UCmBb;;;;;EAKf,iBAAiB,MAAM;IACrB,SAAS,MAAM;IACf,SAAS,MAAM;;;;;;EAOjB,oBAAoB,MAAM;IACxB,SAAS,MAAM;IACf,SAAS,MAAM;;;;;;;EAQjB,sBAAsB,MAAM,cAAc;;EAG1C,SAAS,MAAM;;;;EAKf;;EAGA,SAAS,MAAM;;EAGf,WAAW,MAAM;;;;;;;;EASjB;;;;;;;;;;;;;;;;;;;;;;;wBAwBc,eACd,wBACG,SACF,oBAAoB,MAAM;;;;;UCrGZ;;;;;;;EAOf,SAAS,eAAe;EACxB,YAAY,eAAe;EAC3B,UAAU,MAAM;EAEhB,UAAU,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqFc,YACd,UACA,UACA,QAAQ,eACL,SACF,iBAAiB;;;;UC3HH,yBAAyB;EACxC,UAAU;EACV,QAAQ,eAAe;EACvB,UAAU;EACV,YAAY,eAAe;;EAE3B;;;;;;;wBAoBc,cACd,UACA,QACA,UACA,+BACG,SACF,mBAAmB;;;;;;;;;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;;;;;;;;;;;;qBCjInB,aAGN,uCAAuC,wCAC5C,UAAU,eAAe,gBAAgB,qBACtC,kBAAkB,QAAQ,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBCblC,cACX,wCACA,wCAEA,UAAU,gBAAgB,gBAAgB,qBACvC,kBAAkB,QAAQ,gBAAgB;;;;;KC1B1C,gBACH,gCACA,kCACA,sCACE,wBAAwB,aAAa,QAAQ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0D3C,SACd,gCACA,kCACA,oCAEA,SAAS,gBAAgB,QAAQ,UAAU;;EAG3C,MAAM,mBAAmB,WAAW,cAAc;;EAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgCc,SAAS,OAAO,SAAS,wBAAwB;;EAE/D,MAAM;;EAEN;;;;;;;;;;;;;;;;;;wBCzEc,kBACd,UAAU,wBAAwB,6BACjC;;;;;;;;;;;;;;;;;;;;;;;;;;wBCKa,eACd,UAAU,wBAAwB,6BACjC;;;;UClDO;OACH,QAAQ,gBAAgB,iBAAiB,UAAU,mBAAmB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAsExE,wBAAwB;;;;;wBC1BrB,eAAe,oBAAoB;;;;;UC1ClC;;;;EAIf,MAAM;;;;EAIN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmCc,QAAQ,SAAS,iBAAiB;;;;;UCpCjC;;;;EAIf,MAAM;;;;EAIN;;;;EAKA;;;;EAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0Dc,SAAS,UAAU,kBAAkB;;;;;qBCtFxC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as useAuthState, c as SanityInstanceContext, i as useWindowConnection, n as useOrganizationId, o as createStateSourceHook, r as DashboardTokenRefreshProvider, s as useSanityInstance, t as useStudioWorkspacesByProjectIdDataset } from "./useStudioWorkspacesByProjectIdDataset-BZ_Ud887.js";
1
+ import { a as useWindowConnection, c as useSanityInstance, i as DashboardTokenRefreshProvider, l as SanityInstanceContext, o as useAuthState, r as useOrganizationId, s as createStateSourceHook, t as useStudioWorkspacesByProjectIdDataset } from "./useStudioWorkspacesByProjectIdDataset-B5A5kBH9.js";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { ClientError, CorsOriginError } from "@sanity/client";
4
4
  import { AuthStateType, application, applications, applyDocumentActions, checkPermissions, createComment, createDocument, createSanityInstance, datasets, deleteApplication, editDocument, favorites, getActiveReleasesState, getAllReleasesState, getClientState, getCommentThreadsState, getCommentsState, getCorsErrorProjectId, getCurrentUserState, getDocumentPresence, getDocumentState, getDocumentSyncStatus, getIsInDashboardState, getLoginUrlState, getOAuthTokensState, getPermissionsState, getPerspectiveState, getPresence, getProjectionState, getQueryState, getTokenState, getUsersState, handleAuthCallback, handleOAuthCallback, installation, installations, isDatasetResource, isImportError, isMediaLibraryResource, loadMoreUsers, logout, observeOrganizationVerificationState, organization, organizations, project, projects, refreshOAuthTokens, removeComment, replyToComment, reportPresence, resolveCommentThreads, resolveComments, resolveDocument, resolveProjection, resolveQuery, resolveUsers, revokeOAuthTokens, setAuthToken, setCommentStatus, setFavorite, startOAuthAuthorization, subscribeDocumentEvents, updateApplication, updateComment } from "@sanity/sdk";
@@ -4130,7 +4130,7 @@ function useUsers(options) {
4130
4130
  loadMore
4131
4131
  }, $[20] = data, $[21] = hasMore, $[22] = isPending, $[23] = loadMore, $[24] = t8) : t8 = $[24], t8;
4132
4132
  }
4133
- var version = "3.3.0-rc.1";
4133
+ var version = "3.4.0-rc.0";
4134
4134
  function getEnv(key) {
4135
4135
  if (import.meta.env) return import.meta.env[key];
4136
4136
  if (typeof process < "u" && process.env) return process.env[key];
@@ -1,7 +1,7 @@
1
1
  import { c } from "react-compiler-runtime";
2
2
  import "@sanity/client";
3
3
  import { AuthStateType, getAuthState, getDashboardOrganizationId, setAuthToken } from "@sanity/sdk";
4
- import { getDashboardMessageBus } from "@sanity/sdk/_internal";
4
+ import { getApplicationOrigin, getDashboardMessageBus, getTopicState, isDashboardEnvironment, resolveTopic } from "@sanity/sdk/_internal";
5
5
  import * as React$1 from "react";
6
6
  import { createContext, useContext, useEffect, useRef, useState, useSyncExternalStore } from "react";
7
7
  import { SDK_CHANNEL_NAME, SDK_NODE_NAME } from "@sanity/message-protocol";
@@ -214,6 +214,9 @@ const DashboardTokenRefreshProvider = (t0) => {
214
214
  *
215
215
  * A React hook that retrieves the dashboard organization ID that is currently selected in the Sanity Dashboard.
216
216
  *
217
+ * Works in both Dashboard runtimes: it reads the `organizations.current` message bus topic when a
218
+ * host has installed the bus, and falls back to the Comlink connection otherwise.
219
+ *
217
220
  * @example
218
221
  * ```tsx
219
222
  * function DashboardComponent() {
@@ -229,13 +232,53 @@ const DashboardTokenRefreshProvider = (t0) => {
229
232
  * @returns The dashboard organization ID (string | undefined)
230
233
  */
231
234
  function useOrganizationId() {
232
- let $ = c(2), instance = useSanityInstance(), t0;
233
- $[0] === instance ? t0 = $[1] : (t0 = getDashboardOrganizationId(instance), $[0] = instance, $[1] = t0);
235
+ let $ = c(9), instance = useSanityInstance(), t0;
236
+ bb0: {
237
+ if (!isDashboardEnvironment()) {
238
+ let t1;
239
+ $[0] === instance ? t1 = $[1] : (t1 = getDashboardOrganizationId(instance), $[0] = instance, $[1] = t1), t0 = t1;
240
+ break bb0;
241
+ }
242
+ let t1;
243
+ $[2] === instance ? t1 = $[3] : (t1 = getTopicState(instance, "organizations.current"), $[2] = instance, $[3] = t1);
244
+ let source = t1, t2;
245
+ $[4] === source ? t2 = $[5] : (t2 = () => source.getCurrent()?.id ?? void 0, $[4] = source, $[5] = t2);
246
+ let t3;
247
+ $[6] !== source.subscribe || $[7] !== t2 ? (t3 = {
248
+ subscribe: source.subscribe,
249
+ getCurrent: t2
250
+ }, $[6] = source.subscribe, $[7] = t2, $[8] = t3) : t3 = $[8], t0 = t3;
251
+ }
234
252
  let { subscribe, getCurrent } = t0;
235
253
  return useSyncExternalStore(subscribe, getCurrent);
236
254
  }
237
255
  /**
256
+ * Returns the current value of a dashboard state topic and follows later updates.
257
+ *
258
+ * The hook suspends until the topic publishes its first value, using the message bus query
259
+ * deadline. A topic declared with `TopicResult` resolves to its successful value; a
260
+ * failed result throws a `TopicError` to the nearest error boundary.
261
+ *
262
+ * @example
263
+ * ```tsx
264
+ * function ForegroundApplication() {
265
+ * const foregroundId = useTopic('applications.foreground')
266
+ * return <span>{foregroundId ?? 'No application in the foreground'}</span>
267
+ * }
268
+ * ```
269
+ *
270
+ * @public
271
+ */
272
+ const useTopic = createStateSourceHook({
273
+ getState: getTopicState,
274
+ shouldSuspend: (instance, topic) => getTopicState(instance, topic).getCurrent() === void 0,
275
+ suspender: resolveTopic
276
+ });
277
+ /**
238
278
  * Hook that fetches studio workspaces and organizes them by projectId:dataset
279
+ *
280
+ * Works in both Dashboard runtimes: it derives workspaces from the `applications.list` message
281
+ * bus topic when a host has installed the bus, and falls back to the Comlink connection otherwise.
239
282
  * @internal
240
283
  *
241
284
  * @example
@@ -269,6 +312,43 @@ function useOrganizationId() {
269
312
  * ```
270
313
  */
271
314
  function useStudioWorkspacesByProjectIdDataset() {
315
+ return isDashboardEnvironment() ? useBusStudioWorkspaces() : useComlinkStudioWorkspaces();
316
+ }
317
+ function toResources(application) {
318
+ if (application.type !== "studio") return [];
319
+ let url = getApplicationOrigin(application) ?? "";
320
+ return (application.activeDeployment?.workspaces ?? []).map((workspace) => ({
321
+ id: workspace.id,
322
+ name: workspace.name,
323
+ title: workspace.title ?? application.title,
324
+ basePath: workspace.basePath ?? "",
325
+ projectId: workspace.projectId,
326
+ dataset: workspace.dataset,
327
+ type: "studio",
328
+ userApplicationId: application.id,
329
+ url
330
+ }));
331
+ }
332
+ function toWorkspaceMap(applications) {
333
+ let workspaceMap = {};
334
+ for (let resource of applications.flatMap(toResources)) {
335
+ let key = `${resource.projectId}:${resource.dataset}`;
336
+ workspaceMap[key] ??= [], workspaceMap[key].push(resource);
337
+ }
338
+ return workspaceMap;
339
+ }
340
+ function useBusStudioWorkspaces() {
341
+ let $ = c(6), applications = useTopic("applications.list"), t0;
342
+ $[0] === applications ? t0 = $[1] : (t0 = applications ?? [], $[0] = applications, $[1] = t0);
343
+ let t1;
344
+ $[2] === t0 ? t1 = $[3] : (t1 = toWorkspaceMap(t0), $[2] = t0, $[3] = t1);
345
+ let workspacesByProjectIdAndDataset = t1, t2;
346
+ return $[4] === workspacesByProjectIdAndDataset ? t2 = $[5] : (t2 = {
347
+ workspacesByProjectIdAndDataset,
348
+ error: null
349
+ }, $[4] = workspacesByProjectIdAndDataset, $[5] = t2), t2;
350
+ }
351
+ function useComlinkStudioWorkspaces() {
272
352
  let $ = c(8), t0;
273
353
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {}, $[0] = t0) : t0 = $[0];
274
354
  let [workspacesByProjectIdAndDataset, setWorkspacesByProjectIdAndDataset] = useState(t0), [error, setError] = useState(null), t1;
@@ -309,6 +389,6 @@ function useStudioWorkspacesByProjectIdDataset() {
309
389
  error
310
390
  }, $[5] = error, $[6] = workspacesByProjectIdAndDataset, $[7] = t4) : t4 = $[7], t4;
311
391
  }
312
- export { useAuthState as a, SanityInstanceContext as c, useWindowConnection as i, useOrganizationId as n, createStateSourceHook as o, DashboardTokenRefreshProvider as r, useSanityInstance as s, useStudioWorkspacesByProjectIdDataset as t };
392
+ export { useWindowConnection as a, useSanityInstance as c, DashboardTokenRefreshProvider as i, SanityInstanceContext as l, useTopic as n, useAuthState as o, useOrganizationId as r, createStateSourceHook as s, useStudioWorkspacesByProjectIdDataset as t };
313
393
 
314
- //# sourceMappingURL=useStudioWorkspacesByProjectIdDataset-BZ_Ud887.js.map
394
+ //# sourceMappingURL=useStudioWorkspacesByProjectIdDataset-B5A5kBH9.js.map