@sanity/sdk 3.3.0-rc.0 → 3.3.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 (46) hide show
  1. package/dist/_exports/_internal.d.ts +12 -4
  2. package/dist/_exports/_internal.d.ts.map +1 -1
  3. package/dist/_exports/_internal.js +24 -6
  4. package/dist/_exports/_internal.js.map +1 -1
  5. package/dist/_exports/agent.js +1 -1
  6. package/dist/_exports/comlink.d.ts +1 -1
  7. package/dist/_exports/dashboard.d.ts +1 -1
  8. package/dist/_exports/dashboard.js +1 -1
  9. package/dist/{authStore-BGoEGxOq.d.ts → applications-pRS8tuC2.d.ts} +349 -362
  10. package/dist/applications-pRS8tuC2.d.ts.map +1 -0
  11. package/dist/{clientStore-QDrJNTM4.js → clientStore-BI4D8HhJ.js} +10 -14
  12. package/dist/clientStore-BI4D8HhJ.js.map +1 -0
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +123 -156
  15. package/dist/index.js.map +1 -1
  16. package/dist/{topicStore-Ct7IFNtY.js → topicStore-BJ54_X6H.js} +3 -1
  17. package/dist/topicStore-BJ54_X6H.js.map +1 -0
  18. package/dist/{topicStore-DXvuH9h4.d.ts → topicStore-D-jEwzlX.d.ts} +54 -25
  19. package/dist/topicStore-D-jEwzlX.d.ts.map +1 -0
  20. package/dist/{version-CIhX5ppJ.js → version-CD4aBigm.js} +3 -3
  21. package/dist/{version-CIhX5ppJ.js.map → version-CD4aBigm.js.map} +1 -1
  22. package/package.json +7 -7
  23. package/src/_exports/_internal.ts +2 -0
  24. package/src/applications/applicationOrigin.test.ts +51 -0
  25. package/src/applications/applicationOrigin.ts +26 -0
  26. package/src/auth/authStore.test.ts +0 -18
  27. package/src/auth/authStore.ts +1 -4
  28. package/src/auth/handleAuthCallback.test.ts +0 -33
  29. package/src/auth/handleAuthCallback.ts +1 -11
  30. package/src/auth/logout.test.ts +1 -9
  31. package/src/auth/logout.ts +1 -18
  32. package/src/auth/oauth/oauthActions.test.ts +0 -136
  33. package/src/auth/oauth/oauthActions.ts +29 -78
  34. package/src/auth/oauth/oauthAuth.test.ts +0 -23
  35. package/src/auth/oauth/oauthAuth.ts +8 -18
  36. package/src/dashboard/messageBus/bus.test.ts +39 -0
  37. package/src/dashboard/messageBus/bus.ts +32 -22
  38. package/src/dashboard/messageBus/topics.test.ts +36 -2
  39. package/src/dashboard/messageBus/topics.ts +51 -16
  40. package/src/installations/installations.test-d.ts +11 -0
  41. package/src/installations/installations.test.ts +6 -4
  42. package/src/installations/installations.ts +13 -2
  43. package/dist/authStore-BGoEGxOq.d.ts.map +0 -1
  44. package/dist/clientStore-QDrJNTM4.js.map +0 -1
  45. package/dist/topicStore-Ct7IFNtY.js.map +0 -1
  46. package/dist/topicStore-DXvuH9h4.d.ts.map +0 -1
@@ -10,9 +10,11 @@ const stateTopic = (seed) => ({
10
10
  kind: "event",
11
11
  ownership: { type: "same_app" }
12
12
  }, DASHBOARD_TOPIC_MANIFEST = {
13
+ "applications.base-path": stateTopic(void 0),
13
14
  "applications.config": stateTopic(void 0),
14
15
  "applications.foreground": stateTopic(void 0),
15
16
  "applications.list": stateTopic(void 0),
17
+ "applications.status.update": dashboardEvent,
16
18
  "auth.token": stateTopic(void 0),
17
19
  "auth.token.refresh": dashboardEvent,
18
20
  "navigation.location": stateTopic(void 0),
@@ -562,4 +564,4 @@ const updateEntry = (topic, update) => (state) => {
562
564
  });
563
565
  export { isDashboardEnvironment as a, connectMessageBus as c, getDashboardMessageBus as i, installMessageBus as l, getTopicState as n, requireDashboardMessageBus as o, resolveTopic as r, MessageBusError as s, TopicError as t, resetMessageBus as u };
564
566
 
565
- //# sourceMappingURL=topicStore-Ct7IFNtY.js.map
567
+ //# sourceMappingURL=topicStore-BJ54_X6H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topicStore-BJ54_X6H.js","names":["bindActionByInstance"],"sources":["../src/dashboard/messageBus/topics.ts","../src/dashboard/messageBus/bus.ts","../src/dashboard/messageBus/store.ts","../src/dashboard/messageBus/topicStore.ts"],"sourcesContent":["import {type CurrentUser} from '@sanity/types'\n\nimport {type Application, type ApplicationInclude} from '../../applications/applications'\nimport {type OrganizationBase} from '../../organization/organization'\n\n/**\n * Identifies a module federation expose and the manifest that serves it.\n * @public\n */\nexport interface RemoteModuleRef {\n readonly entry: string\n readonly moduleId: string\n readonly version: string\n}\n\n/**\n * Application types that can receive configuration modules.\n *\n * The dashboard supplies this value over the message bus, so any string is accepted; known\n * types are listed for autocomplete. `& {}` keeps the literal from collapsing into `string`.\n * @public\n */\nexport type ApplicationConfigAppType = 'media-library' | (string & {})\n\n/**\n * Identifies a configuration module for an application or application type.\n * @public\n */\nexport interface ApplicationConfig extends RemoteModuleRef {\n readonly appId?: Application['id']\n readonly appType: ApplicationConfigAppType\n}\n\n/**\n * A label rendered for an application interface; `null` clears it.\n * @internal\n */\nexport type ApplicationStatus = {label: string | null}\n\n/**\n * Updates the status rendered for an application interface.\n * @internal\n */\nexport type ApplicationStatusUpdate = {\n /** The application interface name. */\n name: string\n /** The status to render. */\n value: ApplicationStatus\n}\n\n/**\n * Declares a topic that stores and replays its current value.\n * @public\n */\nexport type StateTopicDef<T> = {kind: 'state'; value: T}\n\n/**\n * Declares a topic that delivers events and an optional reply.\n * @public\n */\nexport type EventTopicDef<P, R = never> = {\n kind: 'event'\n payload: P\n reply?: R\n}\n\n/**\n * Represents a successful topic value or a failed topic operation.\n * @public\n */\nexport type TopicResult<T> = {ok: true; value: T} | {ok: false}\n\n/**\n * Identifies a dashboard application and a route within it.\n * @public\n */\nexport type NavigationTarget = {\n /** The application ID, or `null` for dashboard-level routes. */\n appId: Application['id'] | null\n /** The route path, including its query string and fragment. */\n path: string\n}\n\n/**\n * Describes the current dashboard location and an active navigation.\n * @public\n */\nexport type NavigationLocation = NavigationTarget & {\n /** The active navigation, or `null` when navigation is idle. */\n transition: {\n /** Whether the navigation pushes or replaces browser history. */\n navigationType: 'push' | 'replace'\n /** The requested destination. */\n to: NavigationTarget\n } | null\n}\n\n/**\n * Declares the topics provided by the dashboard.\n * @public\n */\nexport interface DashboardTopics {\n /**\n * The base path for an application.\n *\n * An unknown application returns `{ok: false}`.\n */\n 'applications.base-path': StateTopicDef<TopicResult<string>>\n /** The available application configuration modules. */\n 'applications.config': StateTopicDef<ApplicationConfig[] | null>\n /** The foreground application ID, or `null` on dashboard-level routes. */\n 'applications.foreground': StateTopicDef<Application['id'] | null>\n /** The dashboard applications available to the current user. */\n 'applications.list': StateTopicDef<TopicResult<Application<ApplicationInclude>[]> | null>\n 'applications.status.update': EventTopicDef<ApplicationStatusUpdate>\n /**\n * The session token for the reading connection, or `null` while signed out. The host\n * writes it to each connection separately, so one application never sees another's token.\n */\n 'auth.token': StateTopicDef<string | null>\n /** Requests a dashboard session token. */\n 'auth.token.refresh': EventTopicDef<void, string>\n /** The current dashboard location and active navigation. */\n 'navigation.location': StateTopicDef<NavigationLocation | null>\n /**\n * Requests navigation and replies when the location commits.\n *\n * `ok: false` reasons:\n * - `not-navigable`: the URL cannot be handled by a dashboard application\n * - `interrupted`: another navigation superseded the request\n * - `failed`: the router rejected or did not commit the request\n */\n 'navigation.location.update': EventTopicDef<\n {\n url: string\n history?: 'push' | 'replace'\n },\n {ok: true} | {ok: false; reason: 'not-navigable' | 'interrupted' | 'failed'}\n >\n /** The current organization, or `null` without an active organization. */\n 'organizations.current': StateTopicDef<Pick<OrganizationBase, 'id' | 'name' | 'slug'> | null>\n /** The open panel, its application, display mode, and optional width in pixels. */\n 'panels.mode': StateTopicDef<TopicResult<\n | {appId: string; name: string; mode: 'aside'; size?: number}\n | {appId: string; name: string; mode: 'full'}\n | null\n > | null>\n /** Opens, updates, resizes, or closes an application's panel. */\n 'panels.mode.set': EventTopicDef<\n {name: string; mode: 'aside' | 'full'} | {name: string; size: number} | null\n >\n /** The resolved dashboard color scheme. */\n 'preferences.color-scheme': StateTopicDef<'light' | 'dark'>\n /** Whether the dashboard dock is pinned open. */\n 'preferences.dock-locked': StateTopicDef<boolean>\n /** The signed-in user, or `null` while signed out. */\n 'users.current': StateTopicDef<CurrentUser | null>\n}\n\n/**\n * Declares every topic available through the message bus.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- Declaration merging extends the SDK manifest.\nexport interface Topics extends DashboardTopics {}\n\n/**\n * Hides provisional topics from the public message bus methods.\n * @internal\n */\nexport type MessageBusTopics = Omit<Topics, 'applications.status.update'>\n\n/**\n * Every declared topic name.\n * @public\n */\nexport type TopicName<TTopics = Topics> = keyof TTopics\n\ntype StateTopicsOf<T> = {\n [K in keyof T]: T[K] extends {kind: 'state'} ? K : never\n}[keyof T]\n\n/**\n * Names of state topics exposed by message bus methods.\n * @public\n */\nexport type StateTopic<TTopics = MessageBusTopics> = StateTopicsOf<TTopics>\n\ntype TopicOwnership = {readonly type: 'same_app'} | {readonly type: 'any_app'}\n\n// State is only ever written by the host, one connection at a time, so it carries no ownership.\ntype TopicManifestEntry<T> = T extends {kind: 'state'; value: infer V}\n ? {readonly kind: 'state'; readonly seed: V | undefined}\n : {readonly kind: 'event'; readonly ownership: TopicOwnership}\n\n// The value a connection's copy of the topic starts with; `undefined` means unpublished.\nconst stateTopic = <const V>(seed: V) => ({kind: 'state', seed}) as const\n\n// `same_app` restricts responding to the application that installed the bus.\nconst dashboardEvent = {kind: 'event', ownership: {type: 'same_app'}} as const\n\ntype DashboardTopicManifest = {\n readonly [K in keyof DashboardTopics]: TopicManifestEntry<DashboardTopics[K]>\n}\n\n/**\n * Defines the runtime kind, ownership, and initial value of dashboard topics.\n * @internal\n */\nexport const DASHBOARD_TOPIC_MANIFEST: DashboardTopicManifest = {\n 'applications.base-path': stateTopic(undefined),\n 'applications.config': stateTopic(undefined),\n 'applications.foreground': stateTopic(undefined),\n 'applications.list': stateTopic(undefined),\n 'applications.status.update': dashboardEvent,\n 'auth.token': stateTopic(undefined),\n 'auth.token.refresh': dashboardEvent,\n 'navigation.location': stateTopic(undefined),\n 'navigation.location.update': dashboardEvent,\n 'organizations.current': stateTopic(undefined),\n 'panels.mode': stateTopic({ok: true, value: null}),\n 'panels.mode.set': dashboardEvent,\n 'preferences.color-scheme': stateTopic(undefined),\n 'preferences.dock-locked': stateTopic(undefined),\n 'users.current': stateTopic(undefined),\n}\n\n/**\n * Defines the runtime manifest accepted from any message bus version.\n * @internal\n */\nexport type TopicManifest = Readonly<\n Record<\n string,\n | {readonly kind: 'state'; readonly seed: unknown}\n | {readonly kind: 'event'; readonly ownership: TopicOwnership}\n >\n>\n\n/**\n * Names of event topics exposed by message bus methods.\n * @public\n */\nexport type EventTopic<TTopics = MessageBusTopics> = {\n [K in keyof TTopics]: TTopics[K] extends {kind: 'event'} ? K : never\n}[keyof TTopics]\n\n/**\n * The value type of a state topic.\n * @public\n */\nexport type ValueOf<K extends StateTopic<TTopics>, TTopics = Topics> =\n TTopics[K] extends StateTopicDef<infer T> ? T : never\n\n/**\n * The payload type of an event topic.\n * @public\n */\nexport type PayloadOf<K extends EventTopic<TTopics>, TTopics = Topics> =\n TTopics[K] extends EventTopicDef<infer P, infer _R> ? P : never\n\n/**\n * The reply type of an event topic (`never` if it declares none).\n * @public\n */\nexport type ReplyOf<K extends EventTopic<TTopics>, TTopics = Topics> =\n TTopics[K] extends EventTopicDef<infer _P, infer R> ? R : never\n\n/**\n * Converts a topic value between 2 adjacent versions.\n * @internal\n */\nexport interface TopicMigration {\n /** The older version. */\n readonly from: number\n /** The newer version. */\n readonly to: number\n /** Converts an older state value or event payload to the newer version. */\n up(older: unknown): unknown\n /** Converts a newer state value or event payload to the older version. */\n down(newer: unknown): unknown\n /** Converts event replies between these versions. */\n readonly reply?: {\n /** Converts an older reply to the newer version. */\n up(older: unknown): unknown\n /** Converts a newer reply to the older version. */\n down(newer: unknown): unknown\n }\n}\n\n/**\n * Defines the bundled migration chain for each topic.\n * @internal\n */\nexport const topicMigrations: Partial<Record<TopicName, readonly TopicMigration[]>> = {}\n","/* eslint-disable no-console -- The bus can initialize before the SDK logger exists. */\nimport {\n BehaviorSubject,\n concat,\n defer,\n filter,\n firstValueFrom,\n from,\n map,\n type Observable,\n ReplaySubject,\n Subject,\n type Subscription,\n takeUntil,\n} from 'rxjs'\n\nimport {type Application} from '../../applications/applications'\nimport {\n DASHBOARD_TOPIC_MANIFEST,\n type EventTopic,\n type MessageBusTopics,\n type PayloadOf,\n type ReplyOf,\n type StateTopic,\n type TopicManifest,\n type TopicMigration,\n topicMigrations,\n type TopicName,\n type Topics,\n type ValueOf,\n} from './topics'\n\n/**\n * A message bus protocol error code.\n * @public\n */\nexport type MessageBusErrorCode =\n | 'NO_RESPONDER'\n | 'TIMEOUT'\n | 'ABORTED'\n | 'HANDLER_THREW'\n | 'PROTOCOL_MISMATCH'\n | 'OWNERSHIP_MISMATCH'\n | 'MISSING_APP_ID'\n\n/**\n * An error raised by the message bus protocol.\n * @public\n */\nexport class MessageBusError extends Error {\n /** The machine-readable protocol error code. */\n readonly code: MessageBusErrorCode\n\n /** Creates a message bus protocol error. */\n constructor(code: MessageBusErrorCode, message?: string, options?: {cause?: unknown}) {\n super(message ?? code, options)\n this.name = 'MessageBusError'\n this.code = code\n }\n}\n\n/**\n * Metadata that travels with each message bus event.\n * @public\n */\nexport interface MessageBusMeta {\n /** The application that produced the message. */\n appId: Application['id']\n /**\n * The federation module id of the connection that sent the message (e.g.\n * `favorites/views/list/panel`). Absent from older copies and when the host\n * supplied none, so readers normalise with `message.meta.moduleId ?? message.meta.appId`.\n */\n moduleId?: string\n /** The Unix timestamp in milliseconds when the message was produced. */\n timestamp: number\n}\n\n/**\n * A message delivered to an event topic responder.\n * @public\n */\nexport interface MessageBusMessage<T, R = never, K extends PropertyKey = TopicName> {\n /** The topic that carries the message. */\n type: K\n /** The event payload. */\n payload: T\n /** The message provenance. */\n meta: MessageBusMeta\n /** Replies to an awaiting sender. */\n reply(value: R): void\n /** Aborts when the sender stops waiting for a reply. */\n readonly signal: AbortSignal\n}\n\n/**\n * An observable state topic with access to its current and first values.\n * @public\n */\nexport interface MessageBusStateSource<T> extends Observable<T> {\n /** Returns the current value, or `undefined` before the first value is published. */\n getCurrent(): T | undefined\n /** Resolves with the first published value. */\n readonly firstValue: Promise<T>\n}\n\n/**\n * Options for aborting a message bus operation.\n * @public\n */\nexport interface MessageBusAbortOptions {\n /** Aborts the operation when signaled. */\n signal?: AbortSignal\n}\n\n/**\n * Options for reading a state topic.\n * @public\n */\nexport interface MessageBusQueryOptions extends MessageBusAbortOptions {\n /** Wait timeout in milliseconds. Defaults to 5 seconds; `null` disables it. */\n timeout?: number | null\n}\n\n/**\n * Options for emitting an event topic.\n * @public\n */\nexport interface MessageBusEmitOptions extends MessageBusAbortOptions {\n /** Reply timeout in milliseconds. Defaults to 5 seconds; `null` disables it. */\n timeout?: number | null\n}\n\n/**\n * A lazily awaited event reply.\n * @public\n */\nexport interface MessageBusEmitResult<R> extends PromiseLike<R> {\n /** Handles a rejected event reply. */\n catch<T = never>(onRejected?: (reason: unknown) => T | PromiseLike<T>): Promise<R | T>\n /** Runs after the event reply settles. */\n finally(onFinally?: () => void): Promise<R>\n}\n\n/**\n * Sends events and reads typed state and event topics.\n *\n * @remarks\n * State topics are written by the host to each connection separately through\n * {@link MessageBusClient.emit}; a connection only ever reads its own values.\n * @public\n */\nexport interface MessageBus<TTopics = MessageBusTopics> {\n /** Emits an event topic and provides its reply when awaited. */\n emit<K extends EventTopic<TTopics>>(\n type: K,\n ...rest: PayloadOf<K, TTopics> extends void\n ? [payload?: void, options?: MessageBusEmitOptions]\n : [payload: PayloadOf<K, TTopics>, options?: MessageBusEmitOptions]\n ): MessageBusEmitResult<ReplyOf<K, TTopics>>\n /** Reads the current or next value of a state topic. */\n query<K extends StateTopic<TTopics>>(\n type: K,\n options?: MessageBusQueryOptions,\n ): Promise<ValueOf<K, TTopics>>\n /** Runs a responder for each event until its signal aborts. */\n subscribe<K extends EventTopic<TTopics>>(\n type: K,\n handler: (message: MessageBusMessage<PayloadOf<K, TTopics>, ReplyOf<K, TTopics>, K>) => void,\n options?: MessageBusAbortOptions,\n ): void\n /** Runs a handler for each state value until its signal aborts. */\n subscribe<K extends StateTopic<TTopics>>(\n type: K,\n handler: (value: ValueOf<K, TTopics>) => void,\n options?: MessageBusAbortOptions,\n ): void\n /** Returns a state topic as a `MessageBusStateSource`. */\n subscribe<K extends StateTopic<TTopics>>(type: K): MessageBusStateSource<ValueOf<K, TTopics>>\n /** Returns an event topic as an observable of its payloads. */\n subscribe<K extends EventTopic<TTopics>>(type: K): Observable<PayloadOf<K, TTopics>>\n}\n\n/**\n * A message bus connection that can be torn down independently of its siblings.\n * @public\n */\nexport interface MessageBusConnection<TTopics = MessageBusTopics> extends MessageBus<TTopics> {\n /**\n * Tears down this connection: pending requests reject `ABORTED`, subscriptions\n * complete, and later `emit`, `query`, and `subscribe` calls fail with `ABORTED`.\n * Siblings and the shared bus are untouched.\n */\n disconnect(): void\n}\n\n/**\n * The host's handle to one connection: who it is, when it closes, and where to write its state.\n * @public\n */\nexport interface MessageBusClient {\n /** The application the connection belongs to. */\n readonly appId: Application['id']\n /** The federation module id of the connection. Equals `appId` when the host supplied none. */\n readonly moduleId: string\n /** Aborts when the connection disconnects. Drop per-client state here. */\n readonly closed: AbortSignal\n /** Writes a state value to this connection only. Ignored once the connection has closed. */\n emit<K extends StateTopic>(type: K, value: ValueOf<K>): void\n}\n\n/**\n * The host's connection to the bus.\n *\n * @remarks\n * State reaches an application only through {@link MessageBusClient.emit}. There is no\n * broadcast: sending the same value to everyone is a loop over `connections`, and giving a\n * new connection the current values is done when it appears there, as an SSE server writes\n * a snapshot to each new client.\n * @public\n */\nexport interface MessageBusHost<TTopics = MessageBusTopics> extends MessageBusConnection<TTopics> {\n /**\n * Every open connection other than this one first, then each new one as it joins. The same\n * {@link MessageBusClient} object is handed out for a connection across subscriptions, so it\n * can be kept in a `Set`. A connection stays listed until it calls `disconnect()`; the SDK\n * does that when the owning `SanityInstance` is disposed.\n */\n readonly connections: Observable<MessageBusClient>\n}\n\nconst MESSAGE_BUS_KEY = Symbol.for('sanity.os.bus')\nconst MESSAGE_BUS_PROTOCOL_KEY = Symbol.for('sanity.os.protocol')\nconst MESSAGE_BUS_REGISTRY_KEY = Symbol.for('sanity.os.registry')\nconst MESSAGE_BUS_PENDING_REPLY_KEY = Symbol.for('sanity.os.request')\n\nconst MESSAGE_BUS_PROTOCOL = 1\n\nconst DEFAULT_TIMEOUT_MS = 5000\n\n// Distinguishes an unpublished topic from a published `undefined` value.\nconst NO_VALUE = Symbol.for('sanity.os.no-value')\n\ntype ReplyOutcome =\n | {readonly ok: true; readonly value: unknown}\n | {readonly ok: false; readonly error: unknown}\n\n// Defers Promise creation until the reply is awaited to preserve fire-and-forget emission.\ninterface PendingReply {\n readonly responderAbort: AbortController\n readonly responderSignal: AbortSignal\n settled: boolean\n outcomeBeforeAwait?: ReplyOutcome\n settlePromise?: (outcome: ReplyOutcome) => void\n replyPromise?: Promise<unknown>\n}\n\n// One connection: its identity, its own copy of every state topic, and its lifetime.\ninterface ConnectionRecord {\n readonly appId: string\n readonly moduleId: string\n readonly stateSubjects: Map<string, BehaviorSubject<unknown>>\n readonly abort: AbortController\n}\n\ninterface MessageBusRegistry {\n readonly appId: string\n readonly topics: Map<string, TopicManifest[string]>\n readonly connections: Set<ConnectionRecord>\n readonly connected$: Subject<ConnectionRecord>\n readonly eventSubjects: Map<string, Subject<MessageBusMessage<unknown, unknown>>>\n readonly responderCounts: Map<string, number>\n readonly migrations: ReadonlyMap<string, readonly TopicMigration[]>\n resetAbort: AbortController\n generation: number\n}\n\ntype InternalMessageBus = MessageBus & {\n [MESSAGE_BUS_REGISTRY_KEY]: MessageBusRegistry\n [MESSAGE_BUS_PROTOCOL_KEY]: number\n}\n\n// A connection's box for a state topic, created on first use from the topic's manifest seed.\nfunction resolveStateSubject(\n registry: MessageBusRegistry,\n connection: ConnectionRecord,\n type: string,\n): BehaviorSubject<unknown> {\n // Callers gate on the connection's lifetime; this keeps a slipped call from recreating a\n // box on a closed connection that nothing would ever complete.\n if (connection.abort.signal.aborted) throw new MessageBusError('ABORTED')\n let subject = connection.stateSubjects.get(type)\n if (!subject) {\n const topic = registry.topics.get(type)\n if (!topic) {\n console.warn(`[sanity-sdk:message-bus] state topic \"${type}\" is not declared`)\n }\n const seed = topic?.kind === 'state' ? topic.seed : undefined\n subject = new BehaviorSubject<unknown>(seed === undefined ? NO_VALUE : seed)\n connection.stateSubjects.set(type, subject)\n }\n return subject\n}\n\nfunction toStateSource(\n values: Observable<unknown>,\n getCurrent: () => unknown,\n): MessageBusStateSource<unknown> {\n const source = values as MessageBusStateSource<unknown>\n source.getCurrent = getCurrent\n // Unread sources must not create promises that reject when reset completes them.\n let firstValue: Promise<unknown> | undefined\n Object.defineProperty(source, 'firstValue', {\n get: () => (firstValue ??= firstValueFrom(values)),\n })\n return source\n}\n\nfunction assertCompatibleTopicManifest(\n registry: MessageBusRegistry,\n manifest: TopicManifest,\n): void {\n for (const [type, entry] of Object.entries(manifest)) {\n const existing = registry.topics.get(type)\n if (existing && existing.kind !== entry.kind) {\n throw new MessageBusError(\n 'PROTOCOL_MISMATCH',\n `topic \"${type}\" is declared \"${entry.kind}\" but the installed bus knows it as \"${existing.kind}\"`,\n )\n }\n if (\n existing?.kind === 'event' &&\n entry.kind === 'event' &&\n existing.ownership.type !== entry.ownership.type\n ) {\n throw new MessageBusError('OWNERSHIP_MISMATCH', `topic \"${type}\" has conflicting ownership`)\n }\n }\n}\n\nfunction mergeTopicManifest(registry: MessageBusRegistry, manifest: TopicManifest): void {\n assertCompatibleTopicManifest(registry, manifest)\n for (const [type, entry] of Object.entries(manifest)) registry.topics.set(type, entry)\n}\n\nfunction resolveEventSubject(\n registry: MessageBusRegistry,\n type: string,\n): Subject<MessageBusMessage<unknown, unknown>> {\n let subject = registry.eventSubjects.get(type)\n if (!subject) {\n subject = new Subject<MessageBusMessage<unknown, unknown>>()\n registry.eventSubjects.set(type, subject)\n }\n return subject\n}\n\nfunction settleReply(reply: PendingReply, outcome: ReplyOutcome): void {\n if (reply.settled) return\n reply.settled = true\n if (reply.settlePromise) reply.settlePromise(outcome)\n else reply.outcomeBeforeAwait = outcome\n}\n\nfunction createEventMessage(\n appId: string,\n moduleId: string,\n type: string,\n payload: unknown,\n pendingReply: PendingReply,\n): MessageBusMessage<unknown, unknown> {\n const message: MessageBusMessage<unknown, unknown> & {\n [MESSAGE_BUS_PENDING_REPLY_KEY]?: PendingReply\n } = {\n type: type as TopicName,\n payload,\n meta: {appId, moduleId, timestamp: Date.now()},\n reply: (value) => {\n if (pendingReply.settled) {\n console.warn(\n `[sanity-sdk:message-bus] reply ignored for \"${type}\": no waiting caller or already replied`,\n )\n return\n }\n settleReply(pendingReply, {ok: true, value})\n },\n get signal() {\n return pendingReply.responderSignal\n },\n }\n\n message[MESSAGE_BUS_PENDING_REPLY_KEY] = pendingReply\n return message\n}\n\nfunction createReplyPromise(\n pendingReply: PendingReply,\n options: MessageBusEmitOptions & {hadResponderAtEmission: boolean},\n): Promise<unknown> {\n return new Promise<unknown>((resolve, reject) => {\n const settlePromise = (outcome: ReplyOutcome) =>\n outcome.ok ? resolve(outcome.value) : reject(outcome.error)\n\n if (pendingReply.outcomeBeforeAwait) {\n pendingReply.responderAbort.abort()\n settlePromise(pendingReply.outcomeBeforeAwait)\n return\n }\n if (!options.hadResponderAtEmission) {\n reject(new MessageBusError('NO_RESPONDER'))\n return\n }\n\n const timeoutMs = options.timeout === undefined ? DEFAULT_TIMEOUT_MS : options.timeout\n let timer: ReturnType<typeof setTimeout> | undefined\n const onAbort = () =>\n settleReply(pendingReply, {ok: false, error: new MessageBusError('ABORTED')})\n\n pendingReply.settlePromise = (outcome) => {\n if (timer !== undefined) clearTimeout(timer)\n options.signal?.removeEventListener('abort', onAbort)\n pendingReply.responderAbort.abort()\n settlePromise(outcome)\n }\n\n if (timeoutMs !== null) {\n timer = setTimeout(\n () => settleReply(pendingReply, {ok: false, error: new MessageBusError('TIMEOUT')}),\n timeoutMs,\n )\n }\n if (options.signal) {\n if (options.signal.aborted) onAbort()\n else options.signal.addEventListener('abort', onAbort, {once: true})\n }\n })\n}\n\nfunction createLazyReply<R>(awaitReply: () => Promise<R>): MessageBusEmitResult<R> {\n return {\n // oxlint-disable-next-line unicorn/no-thenable -- awaiting arms reply failure handling; fire-and-forget does not.\n then: (onFulfilled, onRejected) => awaitReply().then(onFulfilled, onRejected),\n catch: (onRejected) => awaitReply().then(undefined, onRejected),\n finally: (onFinally) => awaitReply().finally(onFinally),\n }\n}\n\nfunction emitEvent(\n registry: MessageBusRegistry,\n type: string,\n payload: unknown,\n options: MessageBusEmitOptions | undefined,\n appId: string,\n moduleId: string,\n): MessageBusEmitResult<unknown> {\n const hadResponderAtEmission = (registry.responderCounts.get(type) ?? 0) > 0\n const responderAbort = new AbortController()\n const pendingReply: PendingReply = {\n responderAbort,\n responderSignal: scopeSignal(options?.signal, responderAbort.signal),\n settled: false,\n }\n\n resolveEventSubject(registry, type).next(\n createEventMessage(appId, moduleId, type, payload, pendingReply),\n )\n\n const awaitReply = () =>\n (pendingReply.replyPromise ??= createReplyPromise(pendingReply, {\n ...options,\n hadResponderAtEmission,\n }))\n return createLazyReply(awaitReply)\n}\n\nconst isStateTopic = (registry: MessageBusRegistry, type: string): boolean =>\n registry.topics.get(type)?.kind === 'state'\n\nconst canRespond = (\n registry: MessageBusRegistry,\n ownership: {readonly type: 'same_app' | 'any_app'},\n appId: string,\n): boolean => ownership.type === 'any_app' || appId === registry.appId\n\nfunction emit(\n registry: MessageBusRegistry,\n type: string,\n payload: unknown,\n options: MessageBusEmitOptions | undefined,\n appId: string,\n moduleId: string,\n connectionSignal: AbortSignal,\n): MessageBusEmitResult<unknown> {\n if (isStateTopic(registry, type)) {\n throw new MessageBusError(\n 'OWNERSHIP_MISMATCH',\n `Cannot emit state topic \"${type}\" from app \"${appId}\". The host writes state to each connection through its client handle. Read it with query() or subscribe().`,\n )\n }\n return emitEvent(\n registry,\n type,\n payload,\n {\n ...options,\n signal: scopeSignal(options?.signal, registry.resetAbort.signal, connectionSignal),\n },\n appId,\n moduleId,\n )\n}\n\nfunction emitState(\n registry: MessageBusRegistry,\n connection: ConnectionRecord,\n type: string,\n value: unknown,\n): void {\n const subject = resolveStateSubject(registry, connection, type)\n if (!Object.is(subject.getValue(), value)) subject.next(value)\n}\n\nfunction query(\n source: MessageBusStateSource<unknown>,\n type: string,\n options: MessageBusQueryOptions | undefined,\n connectionSignal: AbortSignal,\n resetSignal: AbortSignal,\n): Promise<unknown> {\n const current = source.getCurrent()\n if (current !== undefined) return Promise.resolve(current)\n\n const signal = scopeSignal(options?.signal, resetSignal, connectionSignal)\n if (signal.aborted) return Promise.reject(new MessageBusError('ABORTED'))\n const timeoutMs = options?.timeout === undefined ? DEFAULT_TIMEOUT_MS : options.timeout\n return new Promise((resolve, reject) => {\n const timer =\n timeoutMs === null\n ? undefined\n : setTimeout(\n () => reject(new MessageBusError('TIMEOUT', `query(\"${type}\") timed out`)),\n timeoutMs,\n )\n const clear = () => {\n if (timer !== undefined) clearTimeout(timer)\n }\n const onAbort = () => {\n clear()\n reject(new MessageBusError('ABORTED'))\n }\n signal?.addEventListener('abort', onAbort, {once: true})\n void source.firstValue.then(\n (value) => {\n clear()\n signal?.removeEventListener('abort', onAbort)\n resolve(value)\n },\n (error) => {\n clear()\n signal?.removeEventListener('abort', onAbort)\n reject(error)\n },\n )\n })\n}\n\nfunction unsubscribeOnAbort(subscription: Subscription, signal: AbortSignal | undefined): void {\n if (!signal) return\n if (signal.aborted) {\n subscription.unsubscribe()\n return\n }\n signal.addEventListener('abort', () => subscription.unsubscribe(), {\n once: true,\n })\n}\n\nfunction scopeSignal(signal: AbortSignal | undefined, ...lifecycles: AbortSignal[]): AbortSignal {\n return signal ? AbortSignal.any([signal, ...lifecycles]) : AbortSignal.any(lifecycles)\n}\n\nfunction invokeResponder(\n handler: (message: MessageBusMessage<unknown, unknown>) => unknown,\n message: MessageBusMessage<unknown, unknown> & {\n [MESSAGE_BUS_PENDING_REPLY_KEY]?: PendingReply\n },\n): void {\n const pendingReply = message[MESSAGE_BUS_PENDING_REPLY_KEY]\n const fail = (error: unknown) => {\n if (pendingReply) {\n settleReply(pendingReply, {\n ok: false,\n error: new MessageBusError('HANDLER_THREW', undefined, {\n cause: error,\n }),\n })\n }\n }\n try {\n const result = handler(message)\n if (result instanceof Promise) result.catch(fail)\n } catch (error) {\n fail(error)\n }\n}\n\nfunction respond(\n registry: MessageBusRegistry,\n type: string,\n handler: (message: MessageBusMessage<unknown, unknown>) => unknown,\n options: MessageBusAbortOptions | undefined,\n appId: string,\n connectionSignal: AbortSignal,\n): void {\n const topic = registry.topics.get(type)\n if (topic?.kind === 'event' && !canRespond(registry, topic.ownership, appId)) {\n throw new MessageBusError(\n 'OWNERSHIP_MISMATCH',\n `Cannot register a handler for event topic \"${type}\" from app \"${appId}\". Only the app that owns this topic can respond to it. Other apps can send it with emit().`,\n )\n }\n\n registry.responderCounts.set(type, (registry.responderCounts.get(type) ?? 0) + 1)\n const subscription = resolveEventSubject(registry, type).subscribe((message) =>\n invokeResponder(handler, message),\n )\n subscription.add(() => {\n const count = registry.responderCounts.get(type) ?? 0\n if (count > 0) registry.responderCounts.set(type, count - 1)\n })\n unsubscribeOnAbort(\n subscription,\n scopeSignal(options?.signal, registry.resetAbort.signal, connectionSignal),\n )\n}\n\nconst bundledMigrations = () => new Map(Object.entries(topicMigrations))\n\n/**\n * Creates an isolated message bus without installing it globally and returns the host's\n * connection to it.\n * @internal\n */\nexport function createIsolatedMessageBus(\n appId: string,\n config: {\n migrations?: ReadonlyMap<string, readonly TopicMigration[]>\n } = {},\n): MessageBusHost<Topics> {\n if (!appId) throwMissingAppId()\n\n const registry: MessageBusRegistry = {\n appId,\n topics: new Map(),\n connections: new Set(),\n connected$: new Subject(),\n eventSubjects: new Map(),\n responderCounts: new Map(),\n migrations: config.migrations ?? bundledMigrations(),\n resetAbort: new AbortController(),\n generation: 0,\n }\n\n mergeTopicManifest(registry, DASHBOARD_TOPIC_MANIFEST)\n\n return createConnection(registry, {\n appId,\n migrations: config.migrations,\n }) as MessageBusHost<Topics>\n}\n\ntype TopicVersionAdapter = {\n toInstalled: (type: string, value: unknown) => unknown\n toApplication: (type: string, value: unknown) => unknown\n}\n\ntype TopicCompatibility = {\n toInstalledEmission: TopicVersionAdapter['toInstalled']\n toApplicationStateValue: TopicVersionAdapter['toApplication']\n toApplicationEventPayload: TopicVersionAdapter['toApplication']\n toInstalledEventReply: TopicVersionAdapter['toInstalled']\n toApplicationEventReply: TopicVersionAdapter['toApplication']\n}\n\ntype TopicMigrationTransform = Pick<TopicMigration, 'up' | 'down'>\n\nconst identityMigration: TopicMigrationTransform = {\n up: (value) => value,\n down: (value) => value,\n}\n\nfunction effectiveTopicVersions(\n migrations: ReadonlyMap<string, readonly TopicMigration[]>,\n): Map<string, number> {\n const versions = new Map<string, number>()\n for (const [topic, steps] of migrations) {\n let version = 1\n for (const step of steps) if (step.to > version) version = step.to\n versions.set(topic, version)\n }\n return versions\n}\n\nfunction migrationTransformAt(\n steps: readonly TopicMigration[] | undefined,\n version: number,\n select: (step: TopicMigration) => TopicMigrationTransform | undefined,\n): TopicMigrationTransform {\n const step = steps?.find((candidate) => candidate.from === version)\n return (step ? select(step) : undefined) ?? identityMigration\n}\n\nfunction migrateVersionedValue(\n steps: readonly TopicMigration[] | undefined,\n value: unknown,\n from: number,\n to: number,\n select: (step: TopicMigration) => TopicMigrationTransform | undefined,\n): unknown {\n if (from === to) return value\n\n let current = value\n if (from < to) {\n for (let version = from; version < to; version++) {\n current = migrationTransformAt(steps, version, select).up(current)\n }\n } else {\n for (let version = from; version > to; version--) {\n current = migrationTransformAt(steps, version - 1, select).down(current)\n }\n }\n return current\n}\n\nfunction createTopicCompatibility(\n installedMigrations: ReadonlyMap<string, readonly TopicMigration[]>,\n applicationMigrations: ReadonlyMap<string, readonly TopicMigration[]>,\n): TopicCompatibility {\n const installedVersions = effectiveTopicVersions(installedMigrations)\n const applicationVersions = effectiveTopicVersions(applicationMigrations)\n const applicationVersion = (type: string) => applicationVersions.get(type) ?? 1\n const installedVersion = (type: string) => installedVersions.get(type) ?? 1\n const migrationChainFor = (type: string) =>\n (applicationVersion(type) > installedVersion(type)\n ? applicationMigrations\n : installedMigrations\n ).get(type)\n const createVersionAdapter = (\n select: (step: TopicMigration) => TopicMigrationTransform | undefined,\n ): TopicVersionAdapter => ({\n toInstalled: (type, value) =>\n migrateVersionedValue(\n migrationChainFor(type),\n value,\n applicationVersion(type),\n installedVersion(type),\n select,\n ),\n toApplication: (type, value) =>\n migrateVersionedValue(\n migrationChainFor(type),\n value,\n installedVersion(type),\n applicationVersion(type),\n select,\n ),\n })\n\n const stateValueAndEventPayload = createVersionAdapter((step) => step)\n const eventReply = createVersionAdapter((step) => step.reply)\n return {\n toInstalledEmission: stateValueAndEventPayload.toInstalled,\n toApplicationStateValue: stateValueAndEventPayload.toApplication,\n toApplicationEventPayload: stateValueAndEventPayload.toApplication,\n toInstalledEventReply: eventReply.toInstalled,\n toApplicationEventReply: eventReply.toApplication,\n }\n}\n\n// Cache projections by input reference to keep state snapshots stable.\nfunction projectCurrent(input: () => unknown, project: (value: unknown) => unknown): () => unknown {\n let lastInput: unknown\n let lastOutput: unknown\n let cached = false\n return () => {\n const current = input()\n if (current === undefined) return undefined\n if (!cached || current !== lastInput) {\n lastInput = current\n lastOutput = project(current)\n cached = true\n }\n return lastOutput\n }\n}\n\n// The connection's view of one of its state boxes, in the connection's topic version.\nfunction createStateSource(\n subject: BehaviorSubject<unknown>,\n project: (value: unknown) => unknown,\n completeOn: Observable<unknown>,\n): MessageBusStateSource<unknown> {\n const getCurrent = () => {\n const current = subject.getValue()\n return current === NO_VALUE ? undefined : current\n }\n return toStateSource(\n subject.pipe(\n filter((value) => value !== NO_VALUE),\n map(project),\n takeUntil(completeOn),\n ),\n projectCurrent(getCurrent, project),\n )\n}\n\nfunction migrateEventMessage(\n message: MessageBusMessage<unknown, unknown>,\n payload: (value: unknown) => unknown,\n reply: (value: unknown) => unknown,\n): MessageBusMessage<unknown, unknown> {\n return {\n type: message.type,\n payload: payload(message.payload),\n meta: message.meta,\n reply: (value) => message.reply(reply(value)),\n get signal() {\n return message.signal\n },\n }\n}\n\nfunction migrateEventReply(\n result: MessageBusEmitResult<unknown>,\n project: (value: unknown) => unknown,\n): MessageBusEmitResult<unknown> {\n let projected: Promise<unknown> | undefined\n return createLazyReply(() => (projected ??= Promise.resolve(result).then(project)))\n}\n\nfunction createRejectedConnection(connectionError: () => unknown): MessageBusConnection {\n const throwConnectionError = (): never => {\n throw connectionError()\n }\n return {\n emit: throwConnectionError,\n // `query` is typed as a Promise, so it must reject rather than throw synchronously.\n query: () => Promise.reject(connectionError()),\n subscribe: throwConnectionError,\n disconnect: () => {},\n } as unknown as MessageBusConnection\n}\n\n/**\n * Options for connecting an application to an isolated message bus.\n * @internal\n */\nexport interface ConnectApplicationToMessageBusOptions {\n /** The application ID stamped on emitted messages. */\n appId: string\n /** The federation module id stamped on emitted messages. Defaults to `appId`. */\n moduleId?: string\n /** The topic migrations supported by the application. */\n migrations?: ReadonlyMap<string, readonly TopicMigration[]>\n}\n\n/**\n * Connects an application to an isolated message bus.\n * @internal\n */\nexport function connectApplicationToMessageBus(\n installedMessageBus: MessageBus,\n config: ConnectApplicationToMessageBusOptions,\n): MessageBusConnection<Topics> {\n if (!config.appId) throwMissingAppId()\n\n const {appId} = config\n const installedProtocol = (installedMessageBus as Partial<InternalMessageBus>)[\n MESSAGE_BUS_PROTOCOL_KEY\n ]\n if (installedProtocol !== MESSAGE_BUS_PROTOCOL) {\n console.error(\n `[sanity-sdk:message-bus] protocol mismatch for \"${appId}\": installed ${String(installedProtocol)}, this copy speaks ${MESSAGE_BUS_PROTOCOL}`,\n )\n return createRejectedConnection(\n () =>\n new MessageBusError(\n 'PROTOCOL_MISMATCH',\n `installed message bus speaks protocol ${String(installedProtocol)}, this copy speaks ${MESSAGE_BUS_PROTOCOL}`,\n ),\n )\n }\n\n const registry = (installedMessageBus as Partial<InternalMessageBus>)[MESSAGE_BUS_REGISTRY_KEY]\n if (!registry) {\n console.error(`[sanity-sdk:message-bus] incompatible message bus for \"${appId}\"`)\n return createRejectedConnection(\n () =>\n new MessageBusError(\n 'PROTOCOL_MISMATCH',\n 'installed message bus does not expose a compatible registry',\n ),\n )\n }\n\n try {\n mergeTopicManifest(registry, DASHBOARD_TOPIC_MANIFEST)\n } catch (error) {\n console.error(`[sanity-sdk:message-bus] topic manifest conflict for \"${appId}\"`, {error})\n return createRejectedConnection(() => error)\n }\n\n return createConnection(registry, config) as MessageBusConnection<Topics>\n}\n\n// Hands the host the same client object for a connection across `connections` subscriptions.\nfunction createClient(\n registry: MessageBusRegistry,\n record: ConnectionRecord,\n compatibility: TopicCompatibility,\n): MessageBusClient {\n return {\n appId: record.appId,\n moduleId: record.moduleId,\n closed: record.abort.signal,\n emit: (type: string, value: unknown) => {\n if (record.abort.signal.aborted) {\n console.warn(\n `[sanity-sdk:message-bus] \"${type}\" not written: connection \"${record.moduleId}\" has closed`,\n )\n return\n }\n emitState(registry, record, type, compatibility.toInstalledEmission(type, value))\n },\n } as MessageBusClient\n}\n\n// Open connections other than the host's own first, then each new one; one client object per\n// connection so the host can keep them in a Set. Completes when the host connection disconnects.\nfunction createConnectionsSource(\n registry: MessageBusRegistry,\n self: ConnectionRecord,\n compatibility: TopicCompatibility,\n completeOn: Observable<unknown>,\n): Observable<MessageBusClient> {\n const clients = new WeakMap<ConnectionRecord, MessageBusClient>()\n const clientFor = (record: ConnectionRecord) => {\n let client = clients.get(record)\n if (!client) {\n client = createClient(registry, record, compatibility)\n clients.set(record, client)\n }\n return client\n }\n return defer(() => concat(from([...registry.connections]), registry.connected$)).pipe(\n filter((record) => record !== self),\n map(clientFor),\n takeUntil(completeOn),\n )\n}\n\nfunction createConnection(\n registry: MessageBusRegistry,\n config: ConnectApplicationToMessageBusOptions,\n): MessageBusConnection {\n const {appId} = config\n const moduleId = config.moduleId ?? appId\n // Each connection owns its lifetime; disconnect() aborts it without touching siblings.\n const connectionAbort = new AbortController()\n const connectionSignal = connectionAbort.signal\n // ReplaySubject, not fromEvent: `abort` fires once, so a cold listener attached by a\n // stream subscribed after disconnect() would never see it and never complete. Replaying\n // the notification lets those late subscribers complete immediately.\n const connectionAborted$ = new ReplaySubject<void>(1)\n connectionSignal.addEventListener('abort', () => connectionAborted$.next(), {once: true})\n\n const record: ConnectionRecord = {\n appId,\n moduleId,\n stateSubjects: new Map(),\n abort: connectionAbort,\n }\n\n const compatibility = createTopicCompatibility(\n registry.migrations,\n config.migrations ?? bundledMigrations(),\n )\n const isState = (type: string) => isStateTopic(registry, type)\n\n // Reuse topic streams because React external-store snapshots require stable references.\n const applicationStreams = new Map<string, MessageBusStateSource<unknown> | Observable<unknown>>()\n let streamGeneration = registry.generation\n const cachedStream = <T extends MessageBusStateSource<unknown> | Observable<unknown>>(\n type: string,\n create: () => T,\n ): T => {\n if (streamGeneration !== registry.generation) {\n applicationStreams.clear()\n streamGeneration = registry.generation\n }\n let stream = applicationStreams.get(type)\n if (!stream) {\n stream = create()\n applicationStreams.set(type, stream)\n }\n return stream as T\n }\n const stateSource = (type: string) =>\n cachedStream(type, () =>\n createStateSource(\n resolveStateSubject(registry, record, type),\n (value) => compatibility.toApplicationStateValue(type, value),\n connectionAborted$,\n ),\n )\n const eventStream = (type: string) =>\n cachedStream(type, () =>\n resolveEventSubject(registry, type).pipe(\n map((message) => compatibility.toApplicationEventPayload(type, message.payload)),\n takeUntil(connectionAborted$),\n ),\n )\n\n // A disconnected connection must not reach siblings, so its operations fail before touching\n // the shared registry rather than only tearing down pending requests and subscriptions.\n const throwIfDisconnected = () => {\n if (connectionSignal.aborted) throw new MessageBusError('ABORTED')\n }\n\n const connection = {\n emit: (type: string, payload: unknown, options?: MessageBusEmitOptions) => {\n throwIfDisconnected()\n return migrateEventReply(\n emit(\n registry,\n type,\n compatibility.toInstalledEmission(type, payload),\n options,\n appId,\n moduleId,\n connectionSignal,\n ),\n (value) => compatibility.toApplicationEventReply(type, value),\n )\n },\n query: (type: string, options?: MessageBusQueryOptions) => {\n if (connectionSignal.aborted) return Promise.reject(new MessageBusError('ABORTED'))\n return query(stateSource(type), type, options, connectionSignal, registry.resetAbort.signal)\n },\n subscribe: (\n type: string,\n handler?: (arg: never) => void,\n options?: MessageBusAbortOptions,\n ): MessageBusStateSource<unknown> | Observable<unknown> | undefined => {\n throwIfDisconnected()\n if (isState(type)) {\n const source = stateSource(type)\n if (!handler) return source\n unsubscribeOnAbort(\n source.subscribe(handler as (value: unknown) => void),\n scopeSignal(options?.signal, registry.resetAbort.signal, connectionSignal),\n )\n return undefined\n }\n if (!handler) return eventStream(type)\n respond(\n registry,\n type,\n (message) =>\n (handler as (message: MessageBusMessage<unknown, unknown>) => void)(\n migrateEventMessage(\n message,\n (value) => compatibility.toApplicationEventPayload(type, value),\n (value) => compatibility.toInstalledEventReply(type, value),\n ),\n ),\n options,\n appId,\n connectionSignal,\n )\n return undefined\n },\n disconnect: () => {\n if (connectionSignal.aborted) return\n connectionAbort.abort()\n for (const subject of record.stateSubjects.values()) subject.complete()\n record.stateSubjects.clear()\n registry.connections.delete(record)\n },\n }\n\n if (appId === registry.appId) {\n Object.assign(connection, {\n connections: createConnectionsSource(registry, record, compatibility, connectionAborted$),\n })\n }\n\n const instance = connection as unknown as InternalMessageBus\n instance[MESSAGE_BUS_REGISTRY_KEY] = registry\n instance[MESSAGE_BUS_PROTOCOL_KEY] = MESSAGE_BUS_PROTOCOL\n\n // Announce last: a host subscriber may write to the new client synchronously.\n registry.connections.add(record)\n registry.connected$.next(record)\n return instance as unknown as MessageBusConnection\n}\n\nfunction reset(registry: MessageBusRegistry): void {\n registry.resetAbort.abort()\n for (const connection of registry.connections) {\n for (const subject of connection.stateSubjects.values()) subject.complete()\n connection.stateSubjects.clear()\n }\n for (const subject of registry.eventSubjects.values()) subject.complete()\n\n registry.topics.clear()\n registry.eventSubjects.clear()\n registry.responderCounts.clear()\n registry.resetAbort = new AbortController()\n registry.generation += 1\n mergeTopicManifest(registry, DASHBOARD_TOPIC_MANIFEST)\n}\n\ndeclare const __SANITY_APP_ID__: string | undefined\n\nfunction throwMissingAppId(): never {\n throw new MessageBusError(\n 'MISSING_APP_ID',\n 'Cannot initialize the message bus without an app ID. Build the application with the Sanity CLI or pass an app ID when connecting.',\n )\n}\n\nconst resolveAppId = (appId?: string): string | undefined =>\n appId ?? (typeof __SANITY_APP_ID__ === 'string' ? __SANITY_APP_ID__ : undefined)\n\nfunction getInstalledMessageBus(): MessageBus | undefined {\n const bus = (globalThis as {[MESSAGE_BUS_KEY]?: unknown})[MESSAGE_BUS_KEY]\n return typeof bus === 'object' && bus !== null && MESSAGE_BUS_REGISTRY_KEY in bus\n ? (bus as unknown as MessageBus)\n : undefined\n}\n\n/**\n * Returns whether a message bus registry is installed.\n * @internal\n */\nexport function isMessageBusInstalled(): boolean {\n return getInstalledMessageBus() !== undefined\n}\n\n/**\n * Options for connecting to an installed message bus.\n * @public\n */\nexport interface ConnectMessageBusOptions {\n /** The application ID. Defaults to the ID embedded by the Sanity CLI. */\n appId?: string\n /** The federation module id stamped on emitted messages. Defaults to `appId`. */\n moduleId?: string\n}\n\n/**\n * Connects to the installed message bus, or returns `undefined` when no compatible connection exists.\n * @public\n */\nexport function connectMessageBus(\n options: ConnectMessageBusOptions = {},\n): MessageBusConnection | undefined {\n const installedMessageBus = getInstalledMessageBus()\n if (!installedMessageBus) return undefined\n\n const appId = resolveAppId(options.appId)\n if (!appId) {\n console.warn(\n '[sanity-sdk:message-bus] cannot connect without an app ID; build with the Sanity CLI or pass appId',\n )\n return undefined\n }\n\n const connection = connectApplicationToMessageBus(installedMessageBus, {\n appId,\n moduleId: options.moduleId,\n })\n return MESSAGE_BUS_REGISTRY_KEY in connection ? connection : undefined\n}\n\n/**\n * Resets the installed message bus for test isolation.\n * @internal\n */\nexport function resetMessageBus(): void {\n const installedMessageBus = getInstalledMessageBus()\n if (!installedMessageBus) return\n reset((installedMessageBus as InternalMessageBus)[MESSAGE_BUS_REGISTRY_KEY])\n}\n\n/**\n * Options for installing the shared message bus. The host is the whole app, so it carries\n * no `moduleId`.\n * @internal\n */\nexport interface InstallMessageBusOptions {\n /** The application ID. Defaults to the ID embedded by the Sanity CLI. */\n appId?: string\n}\n\n/**\n * Installs the shared message bus and returns the host's connection, or connects to its\n * existing installation. Only the host calls this; another app's ID is rejected because the\n * connection it would get has no `connections`.\n * @internal\n */\nexport function installMessageBus(options: InstallMessageBusOptions = {}): MessageBusHost<Topics> {\n const appId = resolveAppId(options.appId) ?? throwMissingAppId()\n const installedMessageBus = getInstalledMessageBus()\n if (installedMessageBus) {\n const installedAppId = (installedMessageBus as InternalMessageBus)[MESSAGE_BUS_REGISTRY_KEY]\n .appId\n if (installedAppId !== appId) {\n throw new MessageBusError(\n 'OWNERSHIP_MISMATCH',\n `Cannot install the message bus as \"${appId}\": it is already installed by \"${installedAppId}\". Applications connect with connectMessageBus().`,\n )\n }\n return connectApplicationToMessageBus(installedMessageBus, {\n appId,\n }) as MessageBusHost<Topics>\n }\n\n const globals = globalThis as {[MESSAGE_BUS_KEY]?: MessageBus}\n if (globals[MESSAGE_BUS_KEY]) {\n // A foreign value already occupies the bus symbol (e.g. an older Workbench bus); overwriting it disconnects that bus.\n console.error(\n '[sanity-sdk:message-bus] overwriting an incompatible message bus already installed',\n )\n }\n const host = createIsolatedMessageBus(appId)\n globals[MESSAGE_BUS_KEY] = host\n return host\n}\n\n/**\n * Declares state topics that are not in the bundled manifest, with the seed a new\n * connection's box starts from.\n * @internal\n */\nexport function registerStateTopics(\n target: MessageBus,\n topics: Partial<{[K in StateTopic]: ValueOf<K> | undefined}>,\n): void {\n const registry = (target as InternalMessageBus)[MESSAGE_BUS_REGISTRY_KEY]\n const manifest: TopicManifest = Object.fromEntries(\n Object.entries(topics).map(([name, seed]) => [name, {kind: 'state', seed}]),\n )\n mergeTopicManifest(registry, manifest)\n}\n","import {createActionBinder} from '../../store/createActionBinder'\nimport {type SanityInstance} from '../../store/createSanityInstance'\nimport {defineStore} from '../../store/defineStore'\nimport {connectMessageBus, isMessageBusInstalled, type MessageBusConnection} from './bus'\n\ninterface DashboardMessageBusState {\n connection?: MessageBusConnection\n}\n\nconst bindActionByInstance = createActionBinder<{name: string}, [moduleId?: string]>(\n (instance) => ({name: instance.instanceId}),\n)\n\nconst dashboardMessageBusStore = defineStore<DashboardMessageBusState>({\n name: 'dashboardMessageBus',\n getInitialState: () => ({}),\n // Runs when the instance is disposed, tearing down this window's connection.\n initialize:\n ({state}) =>\n () =>\n state.get().connection?.disconnect(),\n})\n\n/**\n * Returns the message bus connection for this instance, connecting on first call.\n *\n * @remarks\n * One connection is made per {@link SanityInstance}, carrying that window's\n * module identity. The first caller wins; later callers get the cached\n * connection. When no host bus is installed it returns `undefined` without\n * caching, so a later call retries once a host installs the bus.\n * @internal\n */\nexport const getDashboardMessageBus = bindActionByInstance(\n dashboardMessageBusStore,\n ({state}, moduleId?: string): MessageBusConnection | undefined => {\n const current = state.get().connection\n if (current) return current\n if (!isMessageBusInstalled()) return undefined\n const connection = connectMessageBus({moduleId})\n if (!connection) return undefined\n state.set('connect', {connection})\n return connection\n },\n)\n\n/**\n * Returns the instance's message bus connection, or throws when no dashboard host has\n * installed a bus. `action` names what the caller was about to do, e.g. `read topic \"x\"`.\n * @internal\n */\nexport function requireDashboardMessageBus(\n instance: SanityInstance,\n action: string,\n): MessageBusConnection {\n const messageBus = getDashboardMessageBus(instance)\n if (!messageBus) {\n throw new Error(`Cannot ${action} without an installed dashboard message bus`)\n }\n return messageBus\n}\n\n/**\n * Returns whether a dashboard host has installed a message bus.\n *\n * @remarks\n * Answers \"does a host own this session\", not \"has this instance connected yet\". Callers\n * such as the login redirect run before {@link getDashboardMessageBus} has been called for\n * the instance, so this must not depend on the connection state.\n * @internal\n */\nexport function isDashboardEnvironment(): boolean {\n return isMessageBusInstalled()\n}\n","import {createActionBinder} from '../../store/createActionBinder'\nimport {type SanityInstance} from '../../store/createSanityInstance'\nimport {createStateSourceAction} from '../../store/createStateSourceAction'\nimport {defineStore} from '../../store/defineStore'\nimport {setCleanupTimeout} from '../../utils/setCleanupTimeout'\nimport {type MessageBus, type MessageBusStateSource} from './bus'\nimport {requireDashboardMessageBus} from './store'\nimport {type StateTopic, type ValueOf} from './topics'\n\n/**\n * An error raised when a dashboard state topic reports failure.\n * @public\n */\nexport class TopicError extends Error {\n /** The topic that failed. */\n readonly topic: StateTopic\n\n /** Creates an error for a failed topic. */\n constructor(topic: StateTopic) {\n super(`Topic \"${topic}\" failed`)\n this.name = 'TopicError'\n this.topic = topic\n }\n}\n\n/**\n * The value of a state topic, with `TopicResult` wrappers unwrapped to their success value.\n * @public\n */\nexport type TopicData<K extends StateTopic> =\n ValueOf<K> extends infer Value\n ? Value extends {ok: true; value: infer Success}\n ? Success\n : Value extends {ok: false}\n ? never\n : Value\n : never\n\n// Mirrors the `TopicResult` shape declared in the topic manifest; no plain-value topic has an `ok` field.\nfunction isTopicResult(value: unknown): value is {ok: boolean; value?: unknown} {\n return (\n typeof value === 'object' && value !== null && 'ok' in value && typeof value.ok === 'boolean'\n )\n}\n\nfunction unwrapTopicResult(topic: StateTopic, value: unknown): unknown {\n if (!isTopicResult(value)) return value\n if (!value.ok) throw new TopicError(topic)\n return value.value\n}\n\ninterface TopicEntry {\n /** Why the first-value query failed. Dropped with the entry when its last subscriber leaves. */\n error?: unknown\n /** The in-flight first-value query, shared by every suspended render of the topic. */\n pending?: Promise<void>\n subscribers: number\n}\n\ninterface DashboardTopicsState {\n topics: {[topic: string]: TopicEntry}\n}\n\n// Matches the query store: a suspended component re-renders after its promise settles before\n// the temporary subscriber is released, so it still sees the recorded failure.\nconst TOPIC_STATE_CLEAR_DELAY = 1000\n\nconst bindActionByInstance = createActionBinder<{name: string}, [topic: StateTopic]>(\n (instance) => ({name: instance.instanceId}),\n)\n\n// The bus is the source of truth for topic values (it already keeps one replaying source per\n// topic). This store only tracks what the bus cannot: read failures and who is still reading.\nconst dashboardTopicsStore = defineStore<DashboardTopicsState>({\n name: 'dashboardTopics',\n getInitialState: () => ({topics: {}}),\n})\n\nconst getMessageBus = (instance: SanityInstance, topic: StateTopic): MessageBus =>\n requireDashboardMessageBus(instance, `read topic \"${topic}\"`)\n\nfunction getSource(instance: SanityInstance, topic: StateTopic): MessageBusStateSource<unknown> {\n return getMessageBus(instance, topic).subscribe(topic)\n}\n\n// An entry lives as long as it has subscribers. Dropping it with the last one is what gives a\n// later mount a fresh deadline instead of a stale failure.\nconst updateEntry =\n (topic: string, update: (entry: TopicEntry) => TopicEntry) =>\n (state: DashboardTopicsState): DashboardTopicsState => {\n const {[topic]: entry = {subscribers: 0}, ...rest} = state.topics\n const next = update(entry)\n return {topics: next.subscribers > 0 ? {...rest, [topic]: next} : rest}\n }\n\nconst addSubscriber = (topic: string) =>\n updateEntry(topic, (entry) => ({...entry, subscribers: entry.subscribers + 1}))\n\nconst removeSubscriber = (topic: string) =>\n updateEntry(topic, (entry) => ({...entry, subscribers: entry.subscribers - 1}))\n\n/**\n * A state source for a dashboard state topic, with `TopicResult` wrappers unwrapped.\n *\n * @remarks\n * Returns `undefined` until the topic publishes; use {@link resolveTopic} to wait for that\n * first value. While the topic is still unpublished, reading throws the failure that\n * {@link resolveTopic} recorded. A published value takes precedence over a recorded failure,\n * and a {@link TopicError} is thrown when the topic itself reports failure. A thrown failure\n * ends the subscription, so a reader recovers by subscribing again.\n * @internal\n */\nexport const getTopicState = bindActionByInstance(\n dashboardTopicsStore,\n createStateSourceAction({\n selector: ({state, instance}, topic: StateTopic) => {\n const current = getSource(instance, topic).getCurrent()\n // A recorded failure only describes the wait for a first value; a published value wins.\n const entry = state.topics[topic]\n if (current === undefined && entry?.error) throw entry.error\n return unwrapTopicResult(topic, current)\n },\n onSubscribe: ({state, instance}, topic: StateTopic) => {\n state.set('addSubscriber', addSubscriber(topic))\n // Each publish writes a fresh state object so the selector re-runs against the bus.\n const subscription = getSource(instance, topic).subscribe(() =>\n state.set(\n 'publish',\n updateEntry(topic, (entry) => ({...entry})),\n ),\n )\n return () => {\n subscription.unsubscribe()\n setCleanupTimeout(\n () => state.set('removeSubscriber', removeSubscriber(topic)),\n TOPIC_STATE_CLEAR_DELAY,\n )\n }\n },\n }),\n)\n\n/**\n * Resolves once a dashboard state topic has published, or records the failure for\n * {@link getTopicState} to throw. Repeated calls for a pending topic share one query.\n *\n * @remarks\n * Holds a temporary subscriber while the query is in flight so a failure recorded after the\n * reading component has gone is dropped with it, rather than thrown at the next mount.\n * @internal\n */\nexport const resolveTopic = bindActionByInstance(\n dashboardTopicsStore,\n ({state, instance}, topic: StateTopic): Promise<void> => {\n const existing = state.get().topics[topic]?.pending\n if (existing) return existing\n\n const release = () =>\n setCleanupTimeout(\n () => state.set('removeSubscriber', removeSubscriber(topic)),\n TOPIC_STATE_CLEAR_DELAY,\n )\n const pending = getMessageBus(instance, topic)\n .query(topic)\n .then(\n () =>\n state.set(\n 'resolved',\n updateEntry(topic, ({pending: _pending, ...entry}) => entry),\n ),\n (error: unknown) =>\n state.set(\n 'failed',\n updateEntry(topic, ({pending: _pending, ...entry}) => ({...entry, error})),\n ),\n )\n pending.then(release, release)\n state.set(\n 'query',\n updateEntry(topic, (entry) => ({...entry, pending, subscribers: entry.subscribers + 1})),\n )\n return pending\n },\n)\n"],"mappings":";;;;;AAoMA,MAAM,cAAuB,UAAa;CAAC,MAAM;CAAS;AAAI,IAGxD,iBAAiB;CAAC,MAAM;CAAS,WAAW,EAAC,MAAM,WAAU;AAAC,GAUvD,2BAAmD;CAC9D,0BAA0B,WAAW,KAAA,CAAS;CAC9C,uBAAuB,WAAW,KAAA,CAAS;CAC3C,2BAA2B,WAAW,KAAA,CAAS;CAC/C,qBAAqB,WAAW,KAAA,CAAS;CACzC,8BAA8B;CAC9B,cAAc,WAAW,KAAA,CAAS;CAClC,sBAAsB;CACtB,uBAAuB,WAAW,KAAA,CAAS;CAC3C,8BAA8B;CAC9B,yBAAyB,WAAW,KAAA,CAAS;CAC7C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BAAoB,iBAAiB,KAAK,CAAC,GAC3D,uBACF,GACI,UAAU,cAAc,UAAU,KAAK,CAAC,CAC3C,MAAM,KAAK,CAAC,CACZ,WAEG,MAAM,IACJ,YACA,YAAY,QAAQ,EAAC,SAAS,UAAU,GAAG,YAAW,KAAK,CAC7D,IACD,UACC,MAAM,IACJ,UACA,YAAY,QAAQ,EAAC,SAAS,UAAU,GAAG,aAAY;EAAC,GAAG;EAAO;CAAK,EAAE,CAC3E,CACJ;CAMF,OALA,QAAQ,KAAK,SAAS,OAAO,GAC7B,MAAM,IACJ,SACA,YAAY,QAAQ,WAAW;EAAC,GAAG;EAAO;EAAS,aAAa,MAAM,cAAc;CAAC,EAAE,CACzF,GACO;AACT,CACF"}
@@ -1,4 +1,4 @@
1
- import { Bi as BoundStoreAction, Nt as OrganizationBase, ci as Application, fi as ApplicationInclude, zi as StateSource } from "./authStore-BGoEGxOq.js";
1
+ import { Bi as BoundStoreAction, a as ApplicationInclude, t as Application, zi as StateSource, zt as OrganizationBase } from "./applications-pRS8tuC2.js";
2
2
  import { Observable } from "rxjs";
3
3
  import { CurrentUser } from "@sanity/types";
4
4
  /**
@@ -26,6 +26,23 @@ interface ApplicationConfig extends RemoteModuleRef {
26
26
  readonly appId?: Application['id'];
27
27
  readonly appType: ApplicationConfigAppType;
28
28
  }
29
+ /**
30
+ * A label rendered for an application interface; `null` clears it.
31
+ * @internal
32
+ */
33
+ type ApplicationStatus = {
34
+ label: string | null;
35
+ };
36
+ /**
37
+ * Updates the status rendered for an application interface.
38
+ * @internal
39
+ */
40
+ type ApplicationStatusUpdate = {
41
+ /** The application interface name. */
42
+ name: string;
43
+ /** The status to render. */
44
+ value: ApplicationStatus;
45
+ };
29
46
  /**
30
47
  * Declares a topic that stores and replays its current value.
31
48
  * @public
@@ -81,12 +98,19 @@ type NavigationLocation = NavigationTarget & {
81
98
  * @public
82
99
  */
83
100
  interface DashboardTopics {
101
+ /**
102
+ * The base path for an application.
103
+ *
104
+ * An unknown application returns `{ok: false}`.
105
+ */
106
+ 'applications.base-path': StateTopicDef<TopicResult<string>>;
84
107
  /** The available application configuration modules. */
85
108
  'applications.config': StateTopicDef<ApplicationConfig[] | null>;
86
109
  /** The foreground application ID, or `null` on dashboard-level routes. */
87
110
  'applications.foreground': StateTopicDef<Application['id'] | null>;
88
111
  /** The dashboard applications available to the current user. */
89
112
  'applications.list': StateTopicDef<TopicResult<Application<ApplicationInclude>[]> | null>;
113
+ 'applications.status.update': EventTopicDef<ApplicationStatusUpdate>;
90
114
  /**
91
115
  * The session token for the reading connection, or `null` while signed out. The host
92
116
  * writes it to each connection separately, so one application never sees another's token.
@@ -139,48 +163,53 @@ interface DashboardTopics {
139
163
  /** Whether the dashboard dock is pinned open. */
140
164
  'preferences.dock-locked': StateTopicDef<boolean>;
141
165
  /** The signed-in user, or `null` while signed out. */
142
- 'users.current': StateTopicDef<Pick<CurrentUser, 'id' | 'name' | 'email' | 'profileImage'> | null>;
166
+ 'users.current': StateTopicDef<CurrentUser | null>;
143
167
  }
144
168
  /**
145
169
  * Declares every topic available through the message bus.
146
170
  * @public
147
171
  */
148
172
  interface Topics extends DashboardTopics {}
173
+ /**
174
+ * Hides provisional topics from the public message bus methods.
175
+ * @internal
176
+ */
177
+ type MessageBusTopics = Omit<Topics, 'applications.status.update'>;
149
178
  /**
150
179
  * Every declared topic name.
151
180
  * @public
152
181
  */
153
- type TopicName = keyof Topics;
182
+ type TopicName<TTopics = Topics> = keyof TTopics;
154
183
  type StateTopicsOf<T> = { [K in keyof T]: T[K] extends {
155
184
  kind: 'state';
156
185
  } ? K : never; }[keyof T];
157
186
  /**
158
- * Names of all declared state topics.
187
+ * Names of state topics exposed by message bus methods.
159
188
  * @public
160
189
  */
161
- type StateTopic = StateTopicsOf<Topics>;
190
+ type StateTopic<TTopics = MessageBusTopics> = StateTopicsOf<TTopics>;
162
191
  /**
163
- * Names of all declared event topics.
192
+ * Names of event topics exposed by message bus methods.
164
193
  * @public
165
194
  */
166
- type EventTopic = { [K in TopicName]: Topics[K] extends {
195
+ type EventTopic<TTopics = MessageBusTopics> = { [K in keyof TTopics]: TTopics[K] extends {
167
196
  kind: 'event';
168
- } ? K : never; }[TopicName];
197
+ } ? K : never; }[keyof TTopics];
169
198
  /**
170
199
  * The value type of a state topic.
171
200
  * @public
172
201
  */
173
- type ValueOf<K extends StateTopic> = Topics[K] extends StateTopicDef<infer T> ? T : never;
202
+ type ValueOf<K extends StateTopic<TTopics>, TTopics = Topics> = TTopics[K] extends StateTopicDef<infer T> ? T : never;
174
203
  /**
175
204
  * The payload type of an event topic.
176
205
  * @public
177
206
  */
178
- type PayloadOf<K extends EventTopic> = Topics[K] extends EventTopicDef<infer P, infer _R> ? P : never;
207
+ type PayloadOf<K extends EventTopic<TTopics>, TTopics = Topics> = TTopics[K] extends EventTopicDef<infer P, infer _R> ? P : never;
179
208
  /**
180
209
  * The reply type of an event topic (`never` if it declares none).
181
210
  * @public
182
211
  */
183
- type ReplyOf<K extends EventTopic> = Topics[K] extends EventTopicDef<infer _P, infer R> ? R : never;
212
+ type ReplyOf<K extends EventTopic<TTopics>, TTopics = Topics> = TTopics[K] extends EventTopicDef<infer _P, infer R> ? R : never;
184
213
  /**
185
214
  * A message bus protocol error code.
186
215
  * @public
@@ -218,9 +247,9 @@ interface MessageBusMeta {
218
247
  * A message delivered to an event topic responder.
219
248
  * @public
220
249
  */
221
- interface MessageBusMessage<T, R = never> {
250
+ interface MessageBusMessage<T, R = never, K extends PropertyKey = TopicName> {
222
251
  /** The topic that carries the message. */
223
- type: TopicName;
252
+ type: K;
224
253
  /** The event payload. */
225
254
  payload: T;
226
255
  /** The message provenance. */
@@ -282,25 +311,25 @@ interface MessageBusEmitResult<R> extends PromiseLike<R> {
282
311
  * {@link MessageBusClient.emit}; a connection only ever reads its own values.
283
312
  * @public
284
313
  */
285
- interface MessageBus {
314
+ interface MessageBus<TTopics = MessageBusTopics> {
286
315
  /** Emits an event topic and provides its reply when awaited. */
287
- emit<K extends EventTopic>(type: K, ...rest: PayloadOf<K> extends void ? [payload?: void, options?: MessageBusEmitOptions] : [payload: PayloadOf<K>, options?: MessageBusEmitOptions]): MessageBusEmitResult<ReplyOf<K>>;
316
+ emit<K extends EventTopic<TTopics>>(type: K, ...rest: PayloadOf<K, TTopics> extends void ? [payload?: void, options?: MessageBusEmitOptions] : [payload: PayloadOf<K, TTopics>, options?: MessageBusEmitOptions]): MessageBusEmitResult<ReplyOf<K, TTopics>>;
288
317
  /** Reads the current or next value of a state topic. */
289
- query<K extends StateTopic>(type: K, options?: MessageBusQueryOptions): Promise<ValueOf<K>>;
318
+ query<K extends StateTopic<TTopics>>(type: K, options?: MessageBusQueryOptions): Promise<ValueOf<K, TTopics>>;
290
319
  /** Runs a responder for each event until its signal aborts. */
291
- subscribe<K extends EventTopic>(type: K, handler: (message: MessageBusMessage<PayloadOf<K>, ReplyOf<K>>) => void, options?: MessageBusAbortOptions): void;
320
+ subscribe<K extends EventTopic<TTopics>>(type: K, handler: (message: MessageBusMessage<PayloadOf<K, TTopics>, ReplyOf<K, TTopics>, K>) => void, options?: MessageBusAbortOptions): void;
292
321
  /** Runs a handler for each state value until its signal aborts. */
293
- subscribe<K extends StateTopic>(type: K, handler: (value: ValueOf<K>) => void, options?: MessageBusAbortOptions): void;
322
+ subscribe<K extends StateTopic<TTopics>>(type: K, handler: (value: ValueOf<K, TTopics>) => void, options?: MessageBusAbortOptions): void;
294
323
  /** Returns a state topic as a `MessageBusStateSource`. */
295
- subscribe<K extends StateTopic>(type: K): MessageBusStateSource<ValueOf<K>>;
324
+ subscribe<K extends StateTopic<TTopics>>(type: K): MessageBusStateSource<ValueOf<K, TTopics>>;
296
325
  /** Returns an event topic as an observable of its payloads. */
297
- subscribe<K extends EventTopic>(type: K): Observable<PayloadOf<K>>;
326
+ subscribe<K extends EventTopic<TTopics>>(type: K): Observable<PayloadOf<K, TTopics>>;
298
327
  }
299
328
  /**
300
329
  * A message bus connection that can be torn down independently of its siblings.
301
330
  * @public
302
331
  */
303
- interface MessageBusConnection extends MessageBus {
332
+ interface MessageBusConnection<TTopics = MessageBusTopics> extends MessageBus<TTopics> {
304
333
  /**
305
334
  * Tears down this connection: pending requests reject `ABORTED`, subscriptions
306
335
  * complete, and later `emit`, `query`, and `subscribe` calls fail with `ABORTED`.
@@ -332,7 +361,7 @@ interface MessageBusClient {
332
361
  * a snapshot to each new client.
333
362
  * @public
334
363
  */
335
- interface MessageBusHost extends MessageBusConnection {
364
+ interface MessageBusHost<TTopics = MessageBusTopics> extends MessageBusConnection<TTopics> {
336
365
  /**
337
366
  * Every open connection other than this one first, then each new one as it joins. The same
338
367
  * {@link MessageBusClient} object is handed out for a connection across subscriptions, so it
@@ -376,7 +405,7 @@ interface InstallMessageBusOptions {
376
405
  * connection it would get has no `connections`.
377
406
  * @internal
378
407
  */
379
- declare function installMessageBus(options?: InstallMessageBusOptions): MessageBusHost;
408
+ declare function installMessageBus(options?: InstallMessageBusOptions): MessageBusHost<Topics>;
380
409
  /**
381
410
  * An error raised when a dashboard state topic reports failure.
382
411
  * @public
@@ -431,5 +460,5 @@ declare const getTopicState: BoundStoreAction<DashboardTopicsState, [topic: Stat
431
460
  * @internal
432
461
  */
433
462
  declare const resolveTopic: BoundStoreAction<DashboardTopicsState, [topic: StateTopic], Promise<void>>;
434
- export { PayloadOf as A, ApplicationConfig as C, EventTopicDef as D, EventTopic as E, TopicName as F, TopicResult as I, Topics as L, ReplyOf as M, StateTopic as N, NavigationLocation as O, StateTopicDef as P, ValueOf as R, resetMessageBus as S, DashboardTopics as T, MessageBusMeta as _, ConnectMessageBusOptions as a, connectMessageBus as b, MessageBusAbortOptions as c, MessageBusEmitOptions as d, MessageBusEmitResult as f, MessageBusMessage as g, MessageBusHost as h, resolveTopic as i, RemoteModuleRef as j, NavigationTarget as k, MessageBusClient as l, MessageBusErrorCode as m, TopicError as n, InstallMessageBusOptions as o, MessageBusError as p, getTopicState as r, MessageBus as s, TopicData as t, MessageBusConnection as u, MessageBusQueryOptions as v, ApplicationConfigAppType as w, installMessageBus as x, MessageBusStateSource as y };
435
- //# sourceMappingURL=topicStore-DXvuH9h4.d.ts.map
463
+ export { MessageBusTopics as A, Topics as B, ApplicationConfig as C, DashboardTopics as D, ApplicationStatusUpdate as E, ReplyOf as F, StateTopic as I, StateTopicDef as L, NavigationTarget as M, PayloadOf as N, EventTopic as O, RemoteModuleRef as P, TopicName as R, resetMessageBus as S, ApplicationStatus as T, ValueOf as V, MessageBusMeta as _, ConnectMessageBusOptions as a, connectMessageBus as b, MessageBusAbortOptions as c, MessageBusEmitOptions as d, MessageBusEmitResult as f, MessageBusMessage as g, MessageBusHost as h, resolveTopic as i, NavigationLocation as j, EventTopicDef as k, MessageBusClient as l, MessageBusErrorCode as m, TopicError as n, InstallMessageBusOptions as o, MessageBusError as p, getTopicState as r, MessageBus as s, TopicData as t, MessageBusConnection as u, MessageBusQueryOptions as v, ApplicationConfigAppType as w, installMessageBus as x, MessageBusStateSource as y, TopicResult as z };
464
+ //# sourceMappingURL=topicStore-D-jEwzlX.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topicStore-D-jEwzlX.d.ts","names":[],"sources":["../src/dashboard/messageBus/topics.ts","../src/dashboard/messageBus/bus.ts","../src/dashboard/messageBus/topicStore.ts"],"mappings":";;;;;;;UASiB;WACN;WACA;WACA;;;;;;;;;KAUC;;;;;UAMK,0BAA0B;WAChC,QAAQ;WACR,SAAS;;;;;;KAOR;EAAqB;;;;;;KAMrB;;EAEV;;EAEA,OAAO;;;;;;KAOG,cAAc;EAAM;EAAe,OAAO;;;;;;KAM1C,cAAc,GAAG;EAC3B;EACA,SAAS;EACT,QAAQ;;;;;;KAOE,YAAY;EAAM;EAAU,OAAO;;EAAM;;;;;;KAMzC;;EAEV,OAAO;;EAEP;;;;;;KAOU,qBAAqB;;EAE/B;;IAEE;;IAEA,IAAI;;;;;;;UAQS;;;;;;EAMf,0BAA0B,cAAc;;EAExC,uBAAuB,cAAc;;EAErC,2BA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Ae;EAAU,aAAa;IACpC,UACA;EAAe;YAEb;UAgBA;;EAER;;EAEA,UAAU;EACV;;UAGQ;EACR;KAAU,gBAAgB;;;;;;;;;;;;;;cAoDf,eAAa,iBAAA,uBAAA,OAAA,aAAA;;;;;;;;;;cAuCb,cAAY,iBAAA,uBAAA,OAAA,aAAA"}
@@ -1,4 +1,4 @@
1
- import { n as getClient, r as getClientState } from "./clientStore-QDrJNTM4.js";
1
+ import { n as getClient, r as getClientState } from "./clientStore-BI4D8HhJ.js";
2
2
  import { c as isReleasePerspective, i as bindActionGlobally, n as bindActionByResource, o as defineStore, s as getEnv, t as createStateSourceAction, u as isDatasetResource } from "./createStateSourceAction-DdAhEfnZ.js";
3
3
  import { r as omitProperty } from "./object-CxXlSVg7.js";
4
4
  import { n as setCleanupTimeout, t as setCleanupInterval } from "./setCleanupTimeout-BiM6q1KF.js";
@@ -1372,7 +1372,7 @@ const _resolveQuery = bindActionByResource(queryStore, ({ state, instance }, { s
1372
1372
  }, QUERY_STATE_CLEAR_DELAY);
1373
1373
  };
1374
1374
  return promise.then(releaseSubscriber, releaseSubscriber), promise;
1375
- }), CORE_SDK_VERSION = getEnv("PKG_VERSION") || "3.3.0-rc.0-development";
1375
+ }), CORE_SDK_VERSION = getEnv("PKG_VERSION") || "3.3.0-development";
1376
1376
  export { clearPendingTransaction as A, assertDatasetResource as B, getCommentsState as C, toCommentsKeyParts as D, resolveComments as E, rollbackCommentUpdate as F, defineMutation as G, provisionAddonDataset as H, setCommentCreateError as I, randomId as K, setPendingTransaction as L, receiveComment as M, removeCommentById as N, addComment as O, restoreComments as P, normalizeComment as R, getCommentsOptionsKey as S, resolveCommentThreads as T, COMMENTS_API_VERSION as U, getAddonDatasetState as V, defineFetcher as W, updateLastLoadMoreRequest as _, resolveQuery as a, commentsStore as b, getAllReleasesState as c, getUsersKey as d, initializeRequest as f, setUsersError as g, setUsersData as h, parseQueryKey as i, getCommentsKey as j, applyCommentUpdate as k, addSubscription as l, removeSubscription as m, getQueryKey as n, getPerspectiveState as o, parseUsersKey as p, randomUuid as q, getQueryState as r, getActiveReleasesState as s, CORE_SDK_VERSION as t, cancelRequest as u, PROJECT_API_VERSION as v, parseCommentsOptionsKey as w, getCommentThreadsState as x, USERS_STATE_CLEAR_DELAY as y, toCommentFieldPath as z };
1377
1377
 
1378
- //# sourceMappingURL=version-CIhX5ppJ.js.map
1378
+ //# sourceMappingURL=version-CD4aBigm.js.map