@sanity/workbench-cli 2.10.0 → 2.12.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 (29) hide show
  1. package/dist/_exports/_internal_worker_bus.d.ts +1 -1
  2. package/dist/_exports/build.d.ts +7 -1
  3. package/dist/_exports/build.js +1 -0
  4. package/dist/_exports/build.js.map +1 -1
  5. package/dist/_exports/{defineService-C1MhDwmh.d.ts → defineService-DUaxVpWq.d.ts} +32 -10
  6. package/dist/_exports/deploy.d.ts +5 -13
  7. package/dist/_exports/deploy.js +0 -1
  8. package/dist/_exports/deploy.js.map +1 -1
  9. package/dist/_exports/index.d.ts +1 -1
  10. package/dist/actions/{deploy/checkBuiltOutput.js → build/readBuiltManifest.js} +12 -9
  11. package/dist/actions/build/readBuiltManifest.js.map +1 -0
  12. package/dist/actions/build/services/workerBus.js +98 -20
  13. package/dist/actions/build/services/workerBus.js.map +1 -1
  14. package/dist/actions/deploy/deployWorkbenchApp.js +4 -7
  15. package/dist/actions/deploy/deployWorkbenchApp.js.map +1 -1
  16. package/dist/actions/dev/registry.js +17 -17
  17. package/dist/actions/dev/registry.js.map +1 -1
  18. package/dist/actions/dev/startDevServerRegistration.js +4 -3
  19. package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
  20. package/dist/actions/dev/startWorkbenchDevServer.js +12 -9
  21. package/dist/actions/dev/startWorkbenchDevServer.js.map +1 -1
  22. package/dist/actions/preview/serveBuiltApplication.js +3 -3
  23. package/dist/actions/preview/serveBuiltApplication.js.map +1 -1
  24. package/dist/defineService.js +24 -3
  25. package/dist/defineService.js.map +1 -1
  26. package/dist/services/applications.js +2 -2
  27. package/dist/services/applications.js.map +1 -1
  28. package/package.json +4 -4
  29. package/dist/actions/deploy/checkBuiltOutput.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { n as ServiceBus } from "./defineService-C1MhDwmh.js";
1
+ import { n as ServiceBus } from "./defineService-DUaxVpWq.js";
2
2
  /**
3
3
  * The worker's side of the `workbench.bus.*` wire contract. The host relays
4
4
  * each request to the Dashboard bus and stamps it with the worker's identity,
@@ -1,5 +1,11 @@
1
1
  import { a as resolveAppEntry, i as WorkbenchExposes, n as resolveWorkbenchConfig, o as resolveWorkbenchApp, r as ResolvedWorkbenchApp, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-DEttN7ks.js";
2
2
  import { InlineConfig, PluginOption } from "vite";
3
+ /**
4
+ * Resolves to the parsed federation manifest in `sourceDir`. A workbench build
5
+ * may also emit a standalone `index.html`, so the manifest, not `index.html`,
6
+ * is the marker that `sanity build` produced a federation build.
7
+ */
8
+ declare function readBuiltManifest(sourceDir: string): Promise<Record<string, unknown>>;
3
9
  /**
4
10
  * Resource bindings ride in a dedicated module in the app's bundle rather than an
5
11
  * index.html script tag, so both standalone studios and federated apps resolve
@@ -114,5 +120,5 @@ declare function workbenchVitePlugins(options: WorkbenchViteOptions): Promise<Pl
114
120
  * its own id from the applications API.
115
121
  */
116
122
  declare function buildAppId(app: ResolvedWorkbenchApp): Promise<string>;
117
- export { RESOURCE_BINDINGS_CHUNK_NAME, RESOURCE_BINDINGS_ENTRY_IMPORT, RESOURCE_BINDINGS_FILENAME, RESOURCE_BINDINGS_MODULE_SOURCE, RESOURCE_BINDINGS_TOKEN, type ResolvedMediaLibraryConfig, type WorkbenchExposes, buildAppId, buildFederatedApp, resolveAppEntry, resolveWorkbenchApp, resolveWorkbenchConfig, resourceBindingsChunkFileName, resourceBindingsCodeSplittingGroup, workbenchOptimizeDeps, workbenchVitePlugins };
123
+ export { RESOURCE_BINDINGS_CHUNK_NAME, RESOURCE_BINDINGS_ENTRY_IMPORT, RESOURCE_BINDINGS_FILENAME, RESOURCE_BINDINGS_MODULE_SOURCE, RESOURCE_BINDINGS_TOKEN, type ResolvedMediaLibraryConfig, type WorkbenchExposes, buildAppId, buildFederatedApp, readBuiltManifest, resolveAppEntry, resolveWorkbenchApp, resolveWorkbenchConfig, resourceBindingsChunkFileName, resourceBindingsCodeSplittingGroup, workbenchOptimizeDeps, workbenchVitePlugins };
118
124
  //# sourceMappingURL=build.d.ts.map
@@ -3,6 +3,7 @@
3
3
  // resolver the build reads declared views/web workers from. The build needs no
4
4
  // deploy-time guards, so it takes the bare `resolveWorkbenchApp` — the guarded
5
5
  // view (`getWorkbench`) is the deploy entry's export.
6
+ export { readBuiltManifest } from '../actions/build/readBuiltManifest.js';
6
7
  export { RESOURCE_BINDINGS_CHUNK_NAME, RESOURCE_BINDINGS_ENTRY_IMPORT, RESOURCE_BINDINGS_FILENAME, RESOURCE_BINDINGS_MODULE_SOURCE, RESOURCE_BINDINGS_TOKEN, resourceBindingsChunkFileName, resourceBindingsCodeSplittingGroup } from '../actions/build/resource-bindings.js';
7
8
  export { buildFederatedApp } from '../actions/build/vite/discover-shared-dependencies.js';
8
9
  export { workbenchOptimizeDeps } from '../actions/build/vite/optimize-deps.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/build.ts"],"sourcesContent":["// Node-only build entry: the module-federation Vite plugins that\n// `@sanity/cli-build`'s `getViteConfig` swaps in for a workbench app, plus the\n// resolver the build reads declared views/web workers from. The build needs no\n// deploy-time guards, so it takes the bare `resolveWorkbenchApp` — the guarded\n// view (`getWorkbench`) is the deploy entry's export.\n\nexport {\n RESOURCE_BINDINGS_CHUNK_NAME,\n RESOURCE_BINDINGS_ENTRY_IMPORT,\n RESOURCE_BINDINGS_FILENAME,\n RESOURCE_BINDINGS_MODULE_SOURCE,\n RESOURCE_BINDINGS_TOKEN,\n resourceBindingsChunkFileName,\n resourceBindingsCodeSplittingGroup,\n} from '../actions/build/resource-bindings.js'\nexport {buildFederatedApp} from '../actions/build/vite/discover-shared-dependencies.js'\nexport {workbenchOptimizeDeps} from '../actions/build/vite/optimize-deps.js'\nexport {workbenchVitePlugins} from '../actions/build/vite/workbench-vite-plugins.js'\nexport {buildAppId} from '../appId.js'\nexport {\n resolveAppEntry,\n resolveWorkbenchApp,\n type WorkbenchExposes,\n} from '../resolveWorkbenchApp.js'\nexport {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\n"],"names":["RESOURCE_BINDINGS_CHUNK_NAME","RESOURCE_BINDINGS_ENTRY_IMPORT","RESOURCE_BINDINGS_FILENAME","RESOURCE_BINDINGS_MODULE_SOURCE","RESOURCE_BINDINGS_TOKEN","resourceBindingsChunkFileName","resourceBindingsCodeSplittingGroup","buildFederatedApp","workbenchOptimizeDeps","workbenchVitePlugins","buildAppId","resolveAppEntry","resolveWorkbenchApp","resolveWorkbenchConfig"],"mappings":"AAAA,iEAAiE;AACjE,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,sDAAsD;AAEtD,SACEA,4BAA4B,EAC5BC,8BAA8B,EAC9BC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,uBAAuB,EACvBC,6BAA6B,EAC7BC,kCAAkC,QAC7B,wCAAuC;AAC9C,SAAQC,iBAAiB,QAAO,wDAAuD;AACvF,SAAQC,qBAAqB,QAAO,yCAAwC;AAC5E,SAAQC,oBAAoB,QAAO,kDAAiD;AACpF,SAAQC,UAAU,QAAO,cAAa;AACtC,SACEC,eAAe,EACfC,mBAAmB,QAEd,4BAA2B;AAClC,SAAyCC,sBAAsB,QAAO,+BAA8B"}
1
+ {"version":3,"sources":["../../src/_exports/build.ts"],"sourcesContent":["// Node-only build entry: the module-federation Vite plugins that\n// `@sanity/cli-build`'s `getViteConfig` swaps in for a workbench app, plus the\n// resolver the build reads declared views/web workers from. The build needs no\n// deploy-time guards, so it takes the bare `resolveWorkbenchApp` — the guarded\n// view (`getWorkbench`) is the deploy entry's export.\n\nexport {readBuiltManifest} from '../actions/build/readBuiltManifest.js'\nexport {\n RESOURCE_BINDINGS_CHUNK_NAME,\n RESOURCE_BINDINGS_ENTRY_IMPORT,\n RESOURCE_BINDINGS_FILENAME,\n RESOURCE_BINDINGS_MODULE_SOURCE,\n RESOURCE_BINDINGS_TOKEN,\n resourceBindingsChunkFileName,\n resourceBindingsCodeSplittingGroup,\n} from '../actions/build/resource-bindings.js'\nexport {buildFederatedApp} from '../actions/build/vite/discover-shared-dependencies.js'\nexport {workbenchOptimizeDeps} from '../actions/build/vite/optimize-deps.js'\nexport {workbenchVitePlugins} from '../actions/build/vite/workbench-vite-plugins.js'\nexport {buildAppId} from '../appId.js'\nexport {\n resolveAppEntry,\n resolveWorkbenchApp,\n type WorkbenchExposes,\n} from '../resolveWorkbenchApp.js'\nexport {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\n"],"names":["readBuiltManifest","RESOURCE_BINDINGS_CHUNK_NAME","RESOURCE_BINDINGS_ENTRY_IMPORT","RESOURCE_BINDINGS_FILENAME","RESOURCE_BINDINGS_MODULE_SOURCE","RESOURCE_BINDINGS_TOKEN","resourceBindingsChunkFileName","resourceBindingsCodeSplittingGroup","buildFederatedApp","workbenchOptimizeDeps","workbenchVitePlugins","buildAppId","resolveAppEntry","resolveWorkbenchApp","resolveWorkbenchConfig"],"mappings":"AAAA,iEAAiE;AACjE,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,sDAAsD;AAEtD,SAAQA,iBAAiB,QAAO,wCAAuC;AACvE,SACEC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,uBAAuB,EACvBC,6BAA6B,EAC7BC,kCAAkC,QAC7B,wCAAuC;AAC9C,SAAQC,iBAAiB,QAAO,wDAAuD;AACvF,SAAQC,qBAAqB,QAAO,yCAAwC;AAC5E,SAAQC,oBAAoB,QAAO,kDAAiD;AACpF,SAAQC,UAAU,QAAO,cAAa;AACtC,SACEC,eAAe,EACfC,mBAAmB,QAEd,4BAA2B;AAClC,SAAyCC,sBAAsB,QAAO,+BAA8B"}
@@ -1,5 +1,5 @@
1
1
  import { l as SERVICE_CONTRACT_VERSION, u as ServiceType } from "./contract-D_HnLQtT.js";
2
- import { MessageBus, MessageBusAbortOptions, StateTopic, ValueOf } from "@sanity/sdk/dashboard";
2
+ import { EventTopic, MessageBus, MessageBusAbortOptions, MessageBusMessage, PayloadOf, ReplyOf, StateTopic, ValueOf } from "@sanity/sdk/dashboard";
3
3
  /**
4
4
  * The service's own declaration, surfaced to the callback.
5
5
  * @public
@@ -9,14 +9,15 @@ interface ServiceInfo {
9
9
  readonly type: string;
10
10
  }
11
11
  /**
12
- * The message bus as a service sees it: `emit` and `query` as in the SDK, and
13
- * `subscribe` for state topics only. Only Dashboard can respond to its event
14
- * topics, so a service has no reason to subscribe to them. There is no
15
- * `disconnect`: Dashboard owns the connection and ends it when it stops the
16
- * worker.
12
+ * The message bus as a service sees it: the SDK's `MessageBus` without the
13
+ * `subscribe` forms that return observables, which would make the service's
14
+ * project install rxjs. There is no `disconnect`: Dashboard owns the connection
15
+ * and ends it when it stops the worker.
17
16
  * @public
18
17
  */
19
18
  interface ServiceBus extends Omit<MessageBus, 'subscribe'> {
19
+ /** Runs a responder for each event until its signal aborts. */
20
+ subscribe<K extends EventTopic>(type: K, handler: (message: MessageBusMessage<PayloadOf<K>, ReplyOf<K>, K>) => void, options?: MessageBusAbortOptions): void;
20
21
  /** Runs a handler for each state value until its signal aborts. */
21
22
  subscribe<K extends StateTopic>(type: K, handler: (value: ValueOf<K>) => void, options?: MessageBusAbortOptions): void;
22
23
  }
@@ -57,9 +58,30 @@ interface DefinedService<TType extends ServiceType = ServiceType> {
57
58
  * The callback receives `bus`, its connection to the Dashboard message bus:
58
59
  * `bus.emit` sends an event (such as a dock-badge update), `bus.query` reads the
59
60
  * current value of a state topic, and `bus.subscribe` runs a handler on each
60
- * new value of a state topic until its `signal` aborts. A refused, unanswered
61
- * or timed-out request rejects with an `Error` named `MessageBusError` whose
62
- * `code` says why; it is not an instance of the SDK's `MessageBusError` class.
61
+ * new value of a state topic, or on each event of an event topic, until its
62
+ * `signal` aborts. A refused, unanswered or timed-out `emit` or `query` rejects
63
+ * with an `Error` named `MessageBusError` whose `code` says why; it is not an
64
+ * instance of the SDK's `MessageBusError` class.
65
+ *
66
+ * An event handler answers the sender with `message.reply(value)` or refuses
67
+ * with `message.reject(reason)`; one that throws refuses with code
68
+ * `HANDLER_THREW`. For example, a service that keeps a snapshot for its app's
69
+ * views, which listen with `useWorker` first and then post to it. A view's post
70
+ * arrives on `workers.post` as `{name, payload}`, and `workers.message` reaches
71
+ * only this app's views:
72
+ *
73
+ * ```ts
74
+ * export default unstable_defineService('worker', ({bus}) => {
75
+ * const controller = new AbortController()
76
+ * bus.subscribe('workers.post', (message) => message.reply(snapshot), {
77
+ * signal: controller.signal,
78
+ * })
79
+ * // Views that are already listening post again.
80
+ * bus.emit('workers.message', {type: 'welcome'})
81
+ * return () => controller.abort()
82
+ * })
83
+ * ```
84
+ *
63
85
  * The callback can return a disposer, which runs when Dashboard stops the
64
86
  * worker. By then the bus is closed: subscriptions have ended, `emit` and
65
87
  * `query` reject with code `ABORTED`, and `subscribe` throws that error.
@@ -71,4 +93,4 @@ interface DefinedService<TType extends ServiceType = ServiceType> {
71
93
  */
72
94
  declare function unstable_defineService<TType extends ServiceType>(type: TType, run: ServiceCallbacksByType[TType]): DefinedService<TType>;
73
95
  export { ServiceInfo as a, ServiceContext as i, ServiceBus as n, unstable_defineService as o, ServiceCallback as r, DefinedService as t };
74
- //# sourceMappingURL=defineService-C1MhDwmh.d.ts.map
96
+ //# sourceMappingURL=defineService-DUaxVpWq.d.ts.map
@@ -3,14 +3,6 @@ import { n as resolveWorkbenchConfig, t as ResolvedMediaLibraryConfig } from "./
3
3
  import { a as DeployableWorkbenchApp, i as summarizeInterfaces, n as DeployedView, o as getWorkbench, r as DeployedWebWorker, t as DeployedInterface } from "./summarizeInterfaces-Co97VU2z.js";
4
4
  import { AppVisibility, CliConfig, Output } from "@sanity/cli-core";
5
5
  import "node:zlib";
6
- /**
7
- * Throws unless `sourceDir` is a directory holding a federation build.
8
- * A workbench build always emits a module-federation remote, and may
9
- * additionally emit a standalone `index.html` SPA (workbench remotes). Either
10
- * way `mf-manifest.json` is the reliable marker that `sanity build` produced a
11
- * federation build, so that — not `index.html` — is what we check for.
12
- */
13
- declare function checkBuiltOutput(sourceDir: string): Promise<void>;
14
6
  /**
15
7
  * The org's active installation for an app type, or `undefined` when none is
16
8
  * installed. Read-only, so `--dry-run` can report deployability.
@@ -101,7 +93,7 @@ interface BrettWorkspace {
101
93
  }
102
94
  declare function getWorkbenchUrl(organizationId: string): string;
103
95
  /** Where a deployed application is served on its organization's workbench. */
104
- declare function getApplicationUrl(application: Pick<Application, 'id' | 'organizationId' | 'type'>): string;
96
+ declare function getApplicationUrl(application: Pick<Application, 'id' | 'organizationId' | 'slug' | 'type'>): string;
105
97
  declare function getApplication(applicationId: string): Promise<Application | null>;
106
98
  /** Every application in an organization, in one page (`limit=none`). */
107
99
  declare function listApplications(organizationId: string): Promise<Application[]>;
@@ -149,9 +141,8 @@ declare function createStudio(options: {
149
141
  * sync — so a caller can disarm a create-time rollback that must not delete an
150
142
  * application once it has an active deployment.
151
143
  *
152
- * The build's `mf-manifest.json` ships with every deployment. `isExternal`
153
- * skips the tarball: the customer serves the build from the application's
154
- * registered origin.
144
+ * `isExternal` skips the tarball: the customer serves the build from the
145
+ * application's registered origin.
155
146
  * @internal
156
147
  */
157
148
  declare function deployWorkbenchApp(options: {
@@ -163,6 +154,7 @@ declare function deployWorkbenchApp(options: {
163
154
  isAutoUpdating: boolean;
164
155
  isExternal?: boolean;
165
156
  label?: string;
157
+ mfManifest: Record<string, unknown>;
166
158
  onDeployed?: () => void;
167
159
  /**
168
160
  * The address from config. Only `createApplication` used to send it, so an
@@ -175,5 +167,5 @@ declare function deployWorkbenchApp(options: {
175
167
  visibility?: AppVisibility;
176
168
  workspaces?: readonly BrettWorkspace[];
177
169
  }): Promise<void>;
178
- export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type DeployedView, type DeployedWebWorker, type ResolvedMediaLibraryConfig, type WorkbenchDeployPayload, checkBuiltOutput, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, getApplication, getApplicationUrl, getWorkbench, getWorkbenchUrl, listApplications, resolveInstallationId, resolveWorkbenchConfig, summarizeConfig, summarizeInterfaces, toWorkbenchPayload };
170
+ export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type DeployedView, type DeployedWebWorker, type ResolvedMediaLibraryConfig, type WorkbenchDeployPayload, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, getApplication, getApplicationUrl, getWorkbench, getWorkbenchUrl, listApplications, resolveInstallationId, resolveWorkbenchConfig, summarizeConfig, summarizeInterfaces, toWorkbenchPayload };
179
171
  //# sourceMappingURL=deploy.d.ts.map
@@ -1,4 +1,3 @@
1
- export { checkBuiltOutput } from '../actions/deploy/checkBuiltOutput.js';
2
1
  export { deployConfig, resolveInstallationId, summarizeConfig } from '../actions/deploy/deployConfig.js';
3
2
  export { toWorkbenchPayload } from '../actions/deploy/deployPayload.js';
4
3
  export { createCoreApp, createStudio, deployWorkbenchApp } from '../actions/deploy/deployWorkbenchApp.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/deploy.ts"],"sourcesContent":["export {checkBuiltOutput} from '../actions/deploy/checkBuiltOutput.js'\nexport {\n deployConfig,\n resolveInstallationId,\n summarizeConfig,\n} from '../actions/deploy/deployConfig.js'\nexport {toWorkbenchPayload, type WorkbenchDeployPayload} from '../actions/deploy/deployPayload.js'\nexport {\n createCoreApp,\n type CreatedApplication,\n createStudio,\n deployWorkbenchApp,\n} from '../actions/deploy/deployWorkbenchApp.js'\nexport {getWorkbench} from '../actions/deploy/getWorkbench.js'\nexport {\n type DeployedInterface,\n type DeployedView,\n type DeployedWebWorker,\n summarizeInterfaces,\n} from '../actions/deploy/summarizeInterfaces.js'\nexport {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\nexport {\n type Application,\n type BrettAccess,\n type BrettWorkspace,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n listApplications,\n} from '../services/applications.js'\n"],"names":["checkBuiltOutput","deployConfig","resolveInstallationId","summarizeConfig","toWorkbenchPayload","createCoreApp","createStudio","deployWorkbenchApp","getWorkbench","summarizeInterfaces","resolveWorkbenchConfig","getApplication","getApplicationUrl","getWorkbenchUrl","listApplications"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wCAAuC;AACtE,SACEC,YAAY,EACZC,qBAAqB,EACrBC,eAAe,QACV,oCAAmC;AAC1C,SAAQC,kBAAkB,QAAoC,qCAAoC;AAClG,SACEC,aAAa,EAEbC,YAAY,EACZC,kBAAkB,QACb,0CAAyC;AAChD,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAIEC,mBAAmB,QACd,2CAA0C;AACjD,SAAyCC,sBAAsB,QAAO,+BAA8B;AACpG,SAIEC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,8BAA6B"}
1
+ {"version":3,"sources":["../../src/_exports/deploy.ts"],"sourcesContent":["export {\n deployConfig,\n resolveInstallationId,\n summarizeConfig,\n} from '../actions/deploy/deployConfig.js'\nexport {toWorkbenchPayload, type WorkbenchDeployPayload} from '../actions/deploy/deployPayload.js'\nexport {\n createCoreApp,\n type CreatedApplication,\n createStudio,\n deployWorkbenchApp,\n} from '../actions/deploy/deployWorkbenchApp.js'\nexport {getWorkbench} from '../actions/deploy/getWorkbench.js'\nexport {\n type DeployedInterface,\n type DeployedView,\n type DeployedWebWorker,\n summarizeInterfaces,\n} from '../actions/deploy/summarizeInterfaces.js'\nexport {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\nexport {\n type Application,\n type BrettAccess,\n type BrettWorkspace,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n listApplications,\n} from '../services/applications.js'\n"],"names":["deployConfig","resolveInstallationId","summarizeConfig","toWorkbenchPayload","createCoreApp","createStudio","deployWorkbenchApp","getWorkbench","summarizeInterfaces","resolveWorkbenchConfig","getApplication","getApplicationUrl","getWorkbenchUrl","listApplications"],"mappings":"AAAA,SACEA,YAAY,EACZC,qBAAqB,EACrBC,eAAe,QACV,oCAAmC;AAC1C,SAAQC,kBAAkB,QAAoC,qCAAoC;AAClG,SACEC,aAAa,EAEbC,YAAY,EACZC,kBAAkB,QACb,0CAAyC;AAChD,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAIEC,mBAAmB,QACd,2CAA0C;AACjD,SAAyCC,sBAAsB,QAAO,+BAA8B;AACpG,SAIEC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,8BAA6B"}
@@ -1,5 +1,5 @@
1
1
  import { C as defineTileView, S as definePanelView, T as defineWindowView, _ as ViewSurface, a as DefineWebWorkerInput, c as PanelView, d as TileSize, f as TileView, g as ViewDeclaration, h as ViewComponentBaseProps, i as DefineTileViewInput, m as ViewComponent, n as DefineAssetSourceViewInput, o as DefineWindowViewInput, p as VIEW_CONTRACT_VERSION, r as DefinePanelViewInput, s as DockGroup, t as AssetSourceView, u as ServiceType, v as WebWorker, w as defineWebWorker, x as defineAssetSourceView, y as WindowView } from "./contract-D_HnLQtT.js";
2
- import { a as ServiceInfo, i as ServiceContext, n as ServiceBus, o as unstable_defineService, r as ServiceCallback, t as DefinedService } from "./defineService-C1MhDwmh.js";
2
+ import { a as ServiceInfo, i as ServiceContext, n as ServiceBus, o as unstable_defineService, r as ServiceCallback, t as DefinedService } from "./defineService-DUaxVpWq.js";
3
3
  import { a as WorkbenchApp, c as isWorkbenchApp, i as MediaLibraryField, l as isWorkbenchConfig, n as DefineAppResult, o as WorkbenchConfig, r as DefineMediaLibraryInput, s as defineApplication, t as DefineAppInput, u as unstable_defineMediaLibrary } from "./defineApp-4hImcIIe.js";
4
4
  import { AssetSourceComponentProps } from "@sanity/types";
5
5
  /** @public */
@@ -11,12 +11,10 @@ import { join } from 'node:path';
11
11
  return error;
12
12
  }
13
13
  /**
14
- * Throws unless `sourceDir` is a directory holding a federation build.
15
- * A workbench build always emits a module-federation remote, and may
16
- * additionally emit a standalone `index.html` SPA (workbench remotes). Either
17
- * way `mf-manifest.json` is the reliable marker that `sanity build` produced a
18
- * federation build, so that — not `index.html` — is what we check for.
19
- */ export async function checkBuiltOutput(sourceDir) {
14
+ * Resolves to the parsed federation manifest in `sourceDir`. A workbench build
15
+ * may also emit a standalone `index.html`, so the manifest, not `index.html`,
16
+ * is the marker that `sanity build` produced a federation build.
17
+ */ export async function readBuiltManifest(sourceDir) {
20
18
  try {
21
19
  const stats = await stat(sourceDir);
22
20
  if (!stats.isDirectory()) {
@@ -32,17 +30,22 @@ import { join } from 'node:path';
32
30
  manifest = await readFile(manifestPath, 'utf8');
33
31
  } catch (err) {
34
32
  if (err.code === 'ENOENT') {
35
- throw buildNotFound(`"${manifestPath}" does not exist. ` + 'The deploy directory must contain a federation build created with "sanity build".');
33
+ throw buildNotFound(`"${manifestPath}" does not exist; a federation build created with "sanity build" writes it.`);
36
34
  }
37
35
  throw err;
38
36
  }
39
37
  // Every deploy sends this file to the API, so a corrupt one must fail here
40
38
  // rather than after the application is created.
39
+ let parsed;
41
40
  try {
42
- JSON.parse(manifest);
41
+ parsed = JSON.parse(manifest);
43
42
  } catch {
44
43
  throw new Error(`"${manifestPath}" is not valid JSON. Run "sanity build" again to regenerate it.`);
45
44
  }
45
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
46
+ throw new Error(`"${manifestPath}" is not a JSON object. Run "sanity build" again to regenerate it.`);
47
+ }
48
+ return parsed;
46
49
  }
47
50
 
48
- //# sourceMappingURL=checkBuiltOutput.js.map
51
+ //# sourceMappingURL=readBuiltManifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/actions/build/readBuiltManifest.ts"],"sourcesContent":["import {readFile, stat} from 'node:fs/promises'\nimport {join} from 'node:path'\n\n/**\n * A genuinely-missing-build error, named so callers can offer the \"run sanity\n * build\" hint (the `preview` command keys off this name, matching how the studio\n * path keys off a missing `index.html`). Only the missing cases get it — real\n * I/O failures keep their own name so they surface as themselves.\n */\nfunction buildNotFound(message: string): Error {\n const error = new Error(message)\n error.name = 'BUILD_NOT_FOUND'\n return error\n}\n\n/**\n * Resolves to the parsed federation manifest in `sourceDir`. A workbench build\n * may also emit a standalone `index.html`, so the manifest, not `index.html`,\n * is the marker that `sanity build` produced a federation build.\n */\nexport async function readBuiltManifest(sourceDir: string): Promise<Record<string, unknown>> {\n try {\n const stats = await stat(sourceDir)\n if (!stats.isDirectory()) {\n throw new Error(`\"${sourceDir}\" is not a directory`)\n }\n } catch (err) {\n if (err.code === 'ENOENT') throw buildNotFound(`Directory \"${sourceDir}\" does not exist`)\n throw err\n }\n\n const manifestPath = join(sourceDir, 'mf-manifest.json')\n let manifest: string\n try {\n manifest = await readFile(manifestPath, 'utf8')\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw buildNotFound(\n `\"${manifestPath}\" does not exist; a federation build created with \"sanity build\" writes it.`,\n )\n }\n throw err\n }\n\n // Every deploy sends this file to the API, so a corrupt one must fail here\n // rather than after the application is created.\n let parsed: unknown\n try {\n parsed = JSON.parse(manifest)\n } catch {\n throw new Error(\n `\"${manifestPath}\" is not valid JSON. Run \"sanity build\" again to regenerate it.`,\n )\n }\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new Error(\n `\"${manifestPath}\" is not a JSON object. Run \"sanity build\" again to regenerate it.`,\n )\n }\n return parsed as Record<string, unknown>\n}\n"],"names":["readFile","stat","join","buildNotFound","message","error","Error","name","readBuiltManifest","sourceDir","stats","isDirectory","err","code","manifestPath","manifest","parsed","JSON","parse","Array","isArray"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,IAAI,QAAO,mBAAkB;AAC/C,SAAQC,IAAI,QAAO,YAAW;AAE9B;;;;;CAKC,GACD,SAASC,cAAcC,OAAe;IACpC,MAAMC,QAAQ,IAAIC,MAAMF;IACxBC,MAAME,IAAI,GAAG;IACb,OAAOF;AACT;AAEA;;;;CAIC,GACD,OAAO,eAAeG,kBAAkBC,SAAiB;IACvD,IAAI;QACF,MAAMC,QAAQ,MAAMT,KAAKQ;QACzB,IAAI,CAACC,MAAMC,WAAW,IAAI;YACxB,MAAM,IAAIL,MAAM,CAAC,CAAC,EAAEG,UAAU,oBAAoB,CAAC;QACrD;IACF,EAAE,OAAOG,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU,MAAMV,cAAc,CAAC,WAAW,EAAEM,UAAU,gBAAgB,CAAC;QACxF,MAAMG;IACR;IAEA,MAAME,eAAeZ,KAAKO,WAAW;IACrC,IAAIM;IACJ,IAAI;QACFA,WAAW,MAAMf,SAASc,cAAc;IAC1C,EAAE,OAAOF,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU;YACzB,MAAMV,cACJ,CAAC,CAAC,EAAEW,aAAa,2EAA2E,CAAC;QAEjG;QACA,MAAMF;IACR;IAEA,2EAA2E;IAC3E,gDAAgD;IAChD,IAAII;IACJ,IAAI;QACFA,SAASC,KAAKC,KAAK,CAACH;IACtB,EAAE,OAAM;QACN,MAAM,IAAIT,MACR,CAAC,CAAC,EAAEQ,aAAa,+DAA+D,CAAC;IAErF;IACA,IAAI,OAAOE,WAAW,YAAYA,WAAW,QAAQG,MAAMC,OAAO,CAACJ,SAAS;QAC1E,MAAM,IAAIV,MACR,CAAC,CAAC,EAAEQ,aAAa,kEAAkE,CAAC;IAExF;IACA,OAAOE;AACT"}
@@ -15,7 +15,10 @@ const busError = (code, message)=>Object.assign(new Error(message || code), {
15
15
  * @internal
16
16
  */ export function createWorkerBus() {
17
17
  const pending = new Map();
18
+ // The worker can't tell a state topic from an event topic, so it stores every
19
+ // handler alike; the host's `value` or `message` decides how it is called.
18
20
  const subscriptions = new Map();
21
+ const inFlight = new Map();
19
22
  let nextId = 0;
20
23
  let closed = false;
21
24
  // Posts a request and returns a function that creates its promise on first
@@ -78,6 +81,56 @@ const busError = (code, message)=>Object.assign(new Error(message || code), {
78
81
  if (outcome) onOutcome(outcome);
79
82
  });
80
83
  }
84
+ // Matches the SDK's `invokeResponder`, so a responder behaves the same in a
85
+ // worker as on the page.
86
+ function respond(handler, { messageId, meta, payload, type }) {
87
+ const controller = new AbortController();
88
+ inFlight.set(messageId, controller);
89
+ const answer = (result)=>{
90
+ if (inFlight.get(messageId) !== controller) return false;
91
+ inFlight.delete(messageId);
92
+ self.postMessage({
93
+ ...result,
94
+ kind: 'workbench.bus.answer',
95
+ messageId
96
+ });
97
+ return true;
98
+ };
99
+ const warnIfIgnored = (answered, action)=>{
100
+ if (answered) return;
101
+ // eslint-disable-next-line no-console -- the worker's console is bridged to the host logger
102
+ console.warn(`Message bus ${action} ignored for "${type}": no waiting caller or already replied`);
103
+ };
104
+ const fail = ()=>answer({
105
+ error: {
106
+ code: 'HANDLER_THREW',
107
+ message: 'HANDLER_THREW'
108
+ },
109
+ ok: false
110
+ });
111
+ try {
112
+ const result = handler({
113
+ meta,
114
+ payload,
115
+ reject: (reason)=>warnIfIgnored(answer({
116
+ error: {
117
+ code: 'REFUSED',
118
+ message: reason ?? 'REFUSED'
119
+ },
120
+ ok: false
121
+ }), 'reject'),
122
+ reply: (value)=>warnIfIgnored(answer({
123
+ ok: true,
124
+ value
125
+ }), 'reply'),
126
+ signal: controller.signal,
127
+ type
128
+ });
129
+ if (result instanceof Promise) result.catch(fail);
130
+ } catch {
131
+ fail();
132
+ }
133
+ }
81
134
  const bus = {
82
135
  emit: (topic, payload, options)=>{
83
136
  const awaitReply = request({
@@ -124,6 +177,11 @@ const busError = (code, message)=>Object.assign(new Error(message || code), {
124
177
  close: ()=>{
125
178
  closed = true;
126
179
  subscriptions.clear();
180
+ const controllers = [
181
+ ...inFlight.values()
182
+ ];
183
+ inFlight.clear();
184
+ for (const controller of controllers)controller.abort();
127
185
  for (const settle of pending.values())settle({
128
186
  error: busError('ABORTED'),
129
187
  ok: false
@@ -131,26 +189,46 @@ const busError = (code, message)=>Object.assign(new Error(message || code), {
131
189
  },
132
190
  receive: (data)=>{
133
191
  const message = data;
134
- if (message.kind === 'workbench.bus.value') {
135
- subscriptions.get(message.id)?.(message.value);
136
- } else if (message.kind === 'workbench.bus.reply') {
137
- const settle = pending.get(message.id);
138
- if (message.ok) {
139
- settle?.({
140
- ok: true,
141
- value: message.value
142
- });
143
- return;
144
- }
145
- // A refused subscription has no promise to reject, so tell the author through the host logger.
146
- if (subscriptions.delete(message.id)) {
147
- // eslint-disable-next-line no-console -- the worker's console is bridged to the host logger
148
- console.error(`Message bus subscription refused: ${message.error.code}: ${message.error.message}`);
149
- }
150
- settle?.({
151
- error: busError(message.error.code, message.error.message),
152
- ok: false
153
- });
192
+ switch(message.kind){
193
+ case 'workbench.bus.cancel':
194
+ {
195
+ const controller = inFlight.get(message.messageId);
196
+ // Forget it first so an abort listener's reply is ignored.
197
+ inFlight.delete(message.messageId);
198
+ controller?.abort();
199
+ return;
200
+ }
201
+ case 'workbench.bus.message':
202
+ {
203
+ const handler = subscriptions.get(message.id);
204
+ if (handler) respond(handler, message);
205
+ return;
206
+ }
207
+ case 'workbench.bus.reply':
208
+ {
209
+ const settle = pending.get(message.id);
210
+ if (message.ok) {
211
+ settle?.({
212
+ ok: true,
213
+ value: message.value
214
+ });
215
+ return;
216
+ }
217
+ // A refused subscription has no promise to reject, so tell the author through the host logger.
218
+ if (subscriptions.delete(message.id)) {
219
+ // eslint-disable-next-line no-console -- the worker's console is bridged to the host logger
220
+ console.error(`Message bus subscription refused: ${message.error.code}: ${message.error.message}`);
221
+ }
222
+ settle?.({
223
+ error: busError(message.error.code, message.error.message),
224
+ ok: false
225
+ });
226
+ return;
227
+ }
228
+ case 'workbench.bus.value':
229
+ {
230
+ subscriptions.get(message.id)?.(message.value);
231
+ }
154
232
  }
155
233
  }
156
234
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/build/services/workerBus.ts"],"sourcesContent":["// Runs inside the service's Web Worker, bundled by Vite from the generated\n// `worker.js`. Keep it free of Node and of runtime imports: `@sanity/sdk` is\n// only ever imported for types.\nimport {type MessageBusEmitResult, type MessageBusErrorCode} from '@sanity/sdk/dashboard'\n\nimport {type ServiceBus} from '../../../defineService.js'\n\nconst DEFAULT_TIMEOUT_MS = 5000\n\ninterface RequestOptions {\n signal?: AbortSignal\n timeout?: number | null\n}\n\ntype Outcome = {error: Error; ok: false} | {ok: true; value: unknown}\n\ntype HostMessage =\n | {\n error: {code: MessageBusErrorCode; message: string}\n id: number\n kind: 'workbench.bus.reply'\n ok: false\n }\n | {id: number; kind: 'workbench.bus.reply'; ok: true; value: unknown}\n | {id: number; kind: 'workbench.bus.value'; value: unknown}\n\n// Mirrors the SDK's MessageBusError: importing the class would pull the SDK\n// runtime into the worker bundle.\nconst busError = (code: MessageBusErrorCode, message?: string): Error =>\n Object.assign(new Error(message || code), {code, name: 'MessageBusError'})\n\n/**\n * The worker's side of the `workbench.bus.*` wire contract. The host relays\n * each request to the Dashboard bus and stamps it with the worker's identity,\n * so the client only tracks ids.\n * @internal\n */\nexport function createWorkerBus(): {\n /**\n * The service author's API. The host owns the connection, opening it and ending it when\n * it terminates the worker, so the worker cannot end it.\n */\n bus: ServiceBus\n /**\n * The generated entry's terminate hook, not the author's. It sends nothing to\n * the host, which has already disconnected; it only marks the client closed so\n * the disposer's bus calls reject `ABORTED` at once instead of waiting out the\n * local timeout. Hence not `disconnect`.\n */\n close: () => void\n /**\n * The generated `worker.js` is the single `message` listener on `self` and\n * routes every kind (terminate to the disposer, `workbench.bus.*` here), the\n * way the host's `runWorker` routes to its relay.\n */\n receive: (data: unknown) => void\n} {\n const pending = new Map<number, (outcome: Outcome) => void>()\n const subscriptions = new Map<number, (value: unknown) => void>()\n let nextId = 0\n let closed = false\n\n // Posts a request and returns a function that creates its promise on first\n // call. Until then a reply, even an error, is only held: a rejected promise\n // nobody awaits would reach the worker's 'unhandledrejection' forwarder as a crash.\n function request(message: Record<string, unknown>, options: RequestOptions = {}) {\n const {signal, timeout} = options\n const id = ++nextId\n let outcome: Outcome | undefined\n let onOutcome: ((result: Outcome) => void) | undefined\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const settle = (result: Outcome) => {\n if (outcome) return\n outcome = result\n clearTimeout(timer)\n pending.delete(id)\n signal?.removeEventListener('abort', onAbort)\n onOutcome?.(result)\n }\n const onAbort = () => {\n self.postMessage({id, kind: 'workbench.bus.abort'})\n settle({error: busError('ABORTED'), ok: false})\n }\n\n if (closed || signal?.aborted) {\n outcome = {error: busError('ABORTED'), ok: false}\n } else {\n // An omitted timeout must stay absent on the wire, so the host applies its default.\n self.postMessage(timeout === undefined ? {...message, id} : {...message, id, timeout})\n pending.set(id, settle)\n // A host that predates the bus never replies; time out here too so the call still settles.\n if (timeout !== null) {\n timer = setTimeout(\n () => settle({error: busError('TIMEOUT'), ok: false}),\n timeout ?? DEFAULT_TIMEOUT_MS,\n )\n }\n signal?.addEventListener('abort', onAbort, {once: true})\n }\n\n let promise: Promise<unknown> | undefined\n return () =>\n (promise ??= new Promise((resolve, reject) => {\n onOutcome = (result) => (result.ok ? resolve(result.value) : reject(result.error))\n if (outcome) onOutcome(outcome)\n }))\n }\n\n const bus = {\n emit: (topic: string, payload?: unknown, options?: RequestOptions) => {\n const awaitReply = request({kind: 'workbench.bus.emit', payload, topic}, options)\n const result: MessageBusEmitResult<unknown> = {\n catch: (onRejected) => awaitReply().then(undefined, onRejected),\n finally: (onFinally) => awaitReply().finally(onFinally),\n // eslint-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 }\n return result\n },\n query: (topic: string, options?: RequestOptions) =>\n request({kind: 'workbench.bus.query', topic}, options)(),\n subscribe: (topic: string, handler: (value: unknown) => void, options?: RequestOptions) => {\n if (closed) throw busError('ABORTED')\n const signal = options?.signal\n if (signal?.aborted) return\n const id = ++nextId\n self.postMessage({id, kind: 'workbench.bus.subscribe', topic})\n subscriptions.set(id, handler)\n signal?.addEventListener(\n 'abort',\n () => {\n if (subscriptions.delete(id)) self.postMessage({id, kind: 'workbench.bus.abort'})\n },\n {once: true},\n )\n },\n }\n\n return {\n // The topic generics only exist at the call site; the wire carries plain strings.\n bus: bus as unknown as ServiceBus,\n close: () => {\n closed = true\n subscriptions.clear()\n for (const settle of pending.values()) settle({error: busError('ABORTED'), ok: false})\n },\n receive: (data) => {\n const message = data as HostMessage\n if (message.kind === 'workbench.bus.value') {\n subscriptions.get(message.id)?.(message.value)\n } else if (message.kind === 'workbench.bus.reply') {\n const settle = pending.get(message.id)\n if (message.ok) {\n settle?.({ok: true, value: message.value})\n return\n }\n // A refused subscription has no promise to reject, so tell the author through the host logger.\n if (subscriptions.delete(message.id)) {\n // eslint-disable-next-line no-console -- the worker's console is bridged to the host logger\n console.error(\n `Message bus subscription refused: ${message.error.code}: ${message.error.message}`,\n )\n }\n settle?.({error: busError(message.error.code, message.error.message), ok: false})\n }\n },\n }\n}\n"],"names":["DEFAULT_TIMEOUT_MS","busError","code","message","Object","assign","Error","name","createWorkerBus","pending","Map","subscriptions","nextId","closed","request","options","signal","timeout","id","outcome","onOutcome","timer","settle","result","clearTimeout","delete","removeEventListener","onAbort","self","postMessage","kind","error","ok","aborted","undefined","set","setTimeout","addEventListener","once","promise","Promise","resolve","reject","value","bus","emit","topic","payload","awaitReply","catch","onRejected","then","finally","onFinally","onFulfilled","query","subscribe","handler","close","clear","values","receive","data","get","console"],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,gCAAgC;AAKhC,MAAMA,qBAAqB;AAmB3B,4EAA4E;AAC5E,kCAAkC;AAClC,MAAMC,WAAW,CAACC,MAA2BC,UAC3CC,OAAOC,MAAM,CAAC,IAAIC,MAAMH,WAAWD,OAAO;QAACA;QAAMK,MAAM;IAAiB;AAE1E;;;;;CAKC,GACD,OAAO,SAASC;IAoBd,MAAMC,UAAU,IAAIC;IACpB,MAAMC,gBAAgB,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QAAQ2B,IAAI,KAAK,uBAAuB;gBACjD,MAAMR,SAASb,QAAQsD,GAAG,CAAC5D,QAAQe,EAAE;gBACrC,IAAIf,QAAQ6B,EAAE,EAAE;oBACdV,SAAS;wBAACU,IAAI;wBAAMW,OAAOxC,QAAQwC,KAAK;oBAAA;oBACxC;gBACF;gBACA,+FAA+F;gBAC/F,IAAIhC,cAAcc,MAAM,CAACtB,QAAQe,EAAE,GAAG;oBACpC,4FAA4F;oBAC5F8C,QAAQjC,KAAK,CACX,CAAC,kCAAkC,EAAE5B,QAAQ4B,KAAK,CAAC7B,IAAI,CAAC,EAAE,EAAEC,QAAQ4B,KAAK,CAAC5B,OAAO,EAAE;gBAEvF;gBACAmB,SAAS;oBAACS,OAAO9B,SAASE,QAAQ4B,KAAK,CAAC7B,IAAI,EAAEC,QAAQ4B,KAAK,CAAC5B,OAAO;oBAAG6B,IAAI;gBAAK;YACjF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../src/actions/build/services/workerBus.ts"],"sourcesContent":["// Runs inside the service's Web Worker, bundled by Vite from the generated\n// `worker.js`. Keep it free of Node and of runtime imports: `@sanity/sdk` is\n// only ever imported for types.\nimport {\n type MessageBusEmitResult,\n type MessageBusErrorCode,\n type MessageBusMessage,\n type MessageBusMeta,\n} from '@sanity/sdk/dashboard'\n\nimport {type ServiceBus} from '../../../defineService.js'\n\nconst DEFAULT_TIMEOUT_MS = 5000\n\ninterface RequestOptions {\n signal?: AbortSignal\n timeout?: number | null\n}\n\ntype Outcome = {error: Error; ok: false} | {ok: true; value: unknown}\n\ntype Answer =\n | {error: {code: 'HANDLER_THREW' | 'REFUSED'; message: string}; ok: false}\n | {ok: true; value: unknown}\n\ntype HostMessage =\n | {\n error: {code: MessageBusErrorCode; message: string}\n id: number\n kind: 'workbench.bus.reply'\n ok: false\n }\n | {id: number; kind: 'workbench.bus.reply'; ok: true; value: unknown}\n | {id: number; kind: 'workbench.bus.value'; value: unknown}\n | {\n id: number\n kind: 'workbench.bus.message'\n messageId: number\n meta: MessageBusMeta\n payload: unknown\n type: string\n }\n | {kind: 'workbench.bus.cancel'; messageId: number}\n\n// Mirrors the SDK's MessageBusError: importing the class would pull the SDK\n// runtime into the worker bundle.\nconst busError = (code: MessageBusErrorCode, message?: string): Error =>\n Object.assign(new Error(message || code), {code, name: 'MessageBusError'})\n\n/**\n * The worker's side of the `workbench.bus.*` wire contract. The host relays\n * each request to the Dashboard bus and stamps it with the worker's identity,\n * so the client only tracks ids.\n * @internal\n */\nexport function createWorkerBus(): {\n /**\n * The service author's API. The host owns the connection, opening it and ending it when\n * it terminates the worker, so the worker cannot end it.\n */\n bus: ServiceBus\n /**\n * The generated entry's terminate hook, not the author's. It sends nothing to\n * the host, which has already disconnected; it only marks the client closed so\n * the disposer's bus calls reject `ABORTED` at once instead of waiting out the\n * local timeout. Hence not `disconnect`.\n */\n close: () => void\n /**\n * The generated `worker.js` is the single `message` listener on `self` and\n * routes every kind (terminate to the disposer, `workbench.bus.*` here), the\n * way the host's `runWorker` routes to its relay.\n */\n receive: (data: unknown) => void\n} {\n const pending = new Map<number, (outcome: Outcome) => void>()\n // The worker can't tell a state topic from an event topic, so it stores every\n // handler alike; the host's `value` or `message` decides how it is called.\n const subscriptions = new Map<number, (value: unknown) => unknown>()\n const inFlight = new Map<number, AbortController>()\n let nextId = 0\n let closed = false\n\n // Posts a request and returns a function that creates its promise on first\n // call. Until then a reply, even an error, is only held: a rejected promise\n // nobody awaits would reach the worker's 'unhandledrejection' forwarder as a crash.\n function request(message: Record<string, unknown>, options: RequestOptions = {}) {\n const {signal, timeout} = options\n const id = ++nextId\n let outcome: Outcome | undefined\n let onOutcome: ((result: Outcome) => void) | undefined\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const settle = (result: Outcome) => {\n if (outcome) return\n outcome = result\n clearTimeout(timer)\n pending.delete(id)\n signal?.removeEventListener('abort', onAbort)\n onOutcome?.(result)\n }\n const onAbort = () => {\n self.postMessage({id, kind: 'workbench.bus.abort'})\n settle({error: busError('ABORTED'), ok: false})\n }\n\n if (closed || signal?.aborted) {\n outcome = {error: busError('ABORTED'), ok: false}\n } else {\n // An omitted timeout must stay absent on the wire, so the host applies its default.\n self.postMessage(timeout === undefined ? {...message, id} : {...message, id, timeout})\n pending.set(id, settle)\n // A host that predates the bus never replies; time out here too so the call still settles.\n if (timeout !== null) {\n timer = setTimeout(\n () => settle({error: busError('TIMEOUT'), ok: false}),\n timeout ?? DEFAULT_TIMEOUT_MS,\n )\n }\n signal?.addEventListener('abort', onAbort, {once: true})\n }\n\n let promise: Promise<unknown> | undefined\n return () =>\n (promise ??= new Promise((resolve, reject) => {\n onOutcome = (result) => (result.ok ? resolve(result.value) : reject(result.error))\n if (outcome) onOutcome(outcome)\n }))\n }\n\n // Matches the SDK's `invokeResponder`, so a responder behaves the same in a\n // worker as on the page.\n function respond(\n handler: (message: MessageBusMessage<unknown, unknown, string>) => unknown,\n {messageId, meta, payload, type}: Extract<HostMessage, {kind: 'workbench.bus.message'}>,\n ) {\n const controller = new AbortController()\n inFlight.set(messageId, controller)\n const answer = (result: Answer) => {\n if (inFlight.get(messageId) !== controller) return false\n inFlight.delete(messageId)\n self.postMessage({...result, kind: 'workbench.bus.answer', messageId})\n return true\n }\n const warnIfIgnored = (answered: boolean, action: string) => {\n if (answered) return\n // eslint-disable-next-line no-console -- the worker's console is bridged to the host logger\n console.warn(\n `Message bus ${action} ignored for \"${type}\": no waiting caller or already replied`,\n )\n }\n const fail = () => answer({error: {code: 'HANDLER_THREW', message: 'HANDLER_THREW'}, ok: false})\n\n try {\n const result = handler({\n meta,\n payload,\n reject: (reason) =>\n warnIfIgnored(\n answer({error: {code: 'REFUSED', message: reason ?? 'REFUSED'}, ok: false}),\n 'reject',\n ),\n reply: (value) => warnIfIgnored(answer({ok: true, value}), 'reply'),\n signal: controller.signal,\n type,\n })\n if (result instanceof Promise) result.catch(fail)\n } catch {\n fail()\n }\n }\n\n const bus = {\n emit: (topic: string, payload?: unknown, options?: RequestOptions) => {\n const awaitReply = request({kind: 'workbench.bus.emit', payload, topic}, options)\n const result: MessageBusEmitResult<unknown> = {\n catch: (onRejected) => awaitReply().then(undefined, onRejected),\n finally: (onFinally) => awaitReply().finally(onFinally),\n // eslint-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 }\n return result\n },\n query: (topic: string, options?: RequestOptions) =>\n request({kind: 'workbench.bus.query', topic}, options)(),\n subscribe: (topic: string, handler: (value: unknown) => unknown, options?: RequestOptions) => {\n if (closed) throw busError('ABORTED')\n const signal = options?.signal\n if (signal?.aborted) return\n const id = ++nextId\n self.postMessage({id, kind: 'workbench.bus.subscribe', topic})\n subscriptions.set(id, handler)\n signal?.addEventListener(\n 'abort',\n () => {\n if (subscriptions.delete(id)) self.postMessage({id, kind: 'workbench.bus.abort'})\n },\n {once: true},\n )\n },\n }\n\n return {\n // The topic generics only exist at the call site; the wire carries plain strings.\n bus: bus as unknown as ServiceBus,\n close: () => {\n closed = true\n subscriptions.clear()\n const controllers = [...inFlight.values()]\n inFlight.clear()\n for (const controller of controllers) controller.abort()\n for (const settle of pending.values()) settle({error: busError('ABORTED'), ok: false})\n },\n receive: (data) => {\n const message = data as HostMessage\n switch (message.kind) {\n case 'workbench.bus.cancel': {\n const controller = inFlight.get(message.messageId)\n // Forget it first so an abort listener's reply is ignored.\n inFlight.delete(message.messageId)\n controller?.abort()\n return\n }\n case 'workbench.bus.message': {\n const handler = subscriptions.get(message.id)\n if (handler) respond(handler, message)\n return\n }\n case 'workbench.bus.reply': {\n const settle = pending.get(message.id)\n if (message.ok) {\n settle?.({ok: true, value: message.value})\n return\n }\n // A refused subscription has no promise to reject, so tell the author through the host logger.\n if (subscriptions.delete(message.id)) {\n // eslint-disable-next-line no-console -- the worker's console is bridged to the host logger\n console.error(\n `Message bus subscription refused: ${message.error.code}: ${message.error.message}`,\n )\n }\n settle?.({error: busError(message.error.code, message.error.message), ok: false})\n return\n }\n case 'workbench.bus.value': {\n subscriptions.get(message.id)?.(message.value)\n }\n }\n },\n }\n}\n"],"names":["DEFAULT_TIMEOUT_MS","busError","code","message","Object","assign","Error","name","createWorkerBus","pending","Map","subscriptions","inFlight","nextId","closed","request","options","signal","timeout","id","outcome","onOutcome","timer","settle","result","clearTimeout","delete","removeEventListener","onAbort","self","postMessage","kind","error","ok","aborted","undefined","set","setTimeout","addEventListener","once","promise","Promise","resolve","reject","value","respond","handler","messageId","meta","payload","type","controller","AbortController","answer","get","warnIfIgnored","answered","action","console","warn","fail","reason","reply","catch","bus","emit","topic","awaitReply","onRejected","then","finally","onFinally","onFulfilled","query","subscribe","close","clear","controllers","values","abort","receive","data"],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,gCAAgC;AAUhC,MAAMA,qBAAqB;AAgC3B,4EAA4E;AAC5E,kCAAkC;AAClC,MAAMC,WAAW,CAACC,MAA2BC,UAC3CC,OAAOC,MAAM,CAAC,IAAIC,MAAMH,WAAWD,OAAO;QAACA;QAAMK,MAAM;IAAiB;AAE1E;;;;;CAKC,GACD,OAAO,SAASC;IAoBd,MAAMC,UAAU,IAAIC;IACpB,8EAA8E;IAC9E,2EAA2E;IAC3E,MAAMC,gBAAgB,IAAID;IAC1B,MAAME,WAAW,IAAIF;IACrB,IAAIG,SAAS;IACb,IAAIC,SAAS;IAEb,2EAA2E;IAC3E,4EAA4E;IAC5E,oFAAoF;IACpF,SAASC,QAAQZ,OAAgC,EAAEa,UAA0B,CAAC,CAAC;QAC7E,MAAM,EAACC,MAAM,EAAEC,OAAO,EAAC,GAAGF;QAC1B,MAAMG,KAAK,EAAEN;QACb,IAAIO;QACJ,IAAIC;QACJ,IAAIC;QAEJ,MAAMC,SAAS,CAACC;YACd,IAAIJ,SAAS;YACbA,UAAUI;YACVC,aAAaH;YACbb,QAAQiB,MAAM,CAACP;YACfF,QAAQU,oBAAoB,SAASC;YACrCP,YAAYG;QACd;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EAAE,GAAG;4BACpC,4FAA4F;4BAC5FuC,QAAQ1B,KAAK,CACX,CAAC,kCAAkC,EAAE7B,QAAQ6B,KAAK,CAAC9B,IAAI,CAAC,EAAE,EAAEC,QAAQ6B,KAAK,CAAC7B,OAAO,EAAE;wBAEvF;wBACAoB,SAAS;4BAACS,OAAO/B,SAASE,QAAQ6B,KAAK,CAAC9B,IAAI,EAAEC,QAAQ6B,KAAK,CAAC7B,OAAO;4BAAG8B,IAAI;wBAAK;wBAC/E;oBACF;gBACA,KAAK;oBAAuB;wBAC1BtB,cAAc2C,GAAG,CAACnD,QAAQgB,EAAE,IAAIhB,QAAQyC,KAAK;oBAC/C;YACF;QACF;IACF;AACF"}
@@ -1,5 +1,4 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { basename, dirname, join } from 'node:path';
1
+ import { basename, dirname } from 'node:path';
3
2
  import { createGzip } from 'node:zlib';
4
3
  import { getErrorMessage } from '@sanity/cli-core/errors';
5
4
  import { spinner } from '@sanity/cli-core/ux';
@@ -102,13 +101,11 @@ function toBrettInterface(iface, version) {
102
101
  * sync — so a caller can disarm a create-time rollback that must not delete an
103
102
  * application once it has an active deployment.
104
103
  *
105
- * The build's `mf-manifest.json` ships with every deployment. `isExternal`
106
- * skips the tarball: the customer serves the build from the application's
107
- * registered origin.
104
+ * `isExternal` skips the tarball: the customer serves the build from the
105
+ * application's registered origin.
108
106
  * @internal
109
107
  */ export async function deployWorkbenchApp(options) {
110
- const { access, app, applicationId, icon, isApp, isAutoUpdating, isExternal = false, label = 'Deploying...', onDeployed, slug, sourceDir, title, version, visibility, workspaces } = options;
111
- const mfManifest = JSON.parse(await readFile(join(sourceDir, 'mf-manifest.json'), 'utf8'));
108
+ const { access, app, applicationId, icon, isApp, isAutoUpdating, isExternal = false, label = 'Deploying...', mfManifest, onDeployed, slug, sourceDir, title, version, visibility, workspaces } = options;
112
109
  const tarball = isExternal ? undefined : createTar({
113
110
  cwd: dirname(sourceDir)
114
111
  }, [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/deployWorkbenchApp.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {basename, dirname, join} from 'node:path'\nimport {createGzip} from 'node:zlib'\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {c as createTar} from 'tar'\n\nimport {type DerivedInterface, deriveInterfaces} from '../../deriveInterfaces.js'\nimport {\n type Application,\n type BrettAccess,\n type BrettInterface,\n type BrettWorkspace,\n createApplication,\n createDeployment,\n deleteApplication,\n updateApplication,\n} from '../../services/applications.js'\n\n/**\n * `rollback` undoes the creation, so a later failure leaves no record stranded at the slug.\n * @internal\n */\nexport interface CreatedApplication {\n application: Application\n rollback: () => Promise<void>\n}\n\nfunction toBrettInterface(iface: DerivedInterface, version: string): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return {...declaration, version}\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'panel': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'window': {\n const {surface, ...view} = declaration\n return {...view, type: 'app', version}\n }\n }\n}\n\n/**\n * Create a coreApp record (no deployment), so the CLI can build with its id\n * before shipping the first deployment. First deploy only.\n * @internal\n */\nexport async function createCoreApp(options: {\n isSingleton?: boolean\n name?: string\n organizationId: string\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating application...').start()\n try {\n const application = await createApplication({...options, type: 'coreApp'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Create a studio record (no deployment).\n * @internal\n */\nexport async function createStudio(options: {\n externalUrl?: string\n name?: string\n organizationId: string\n projectId: string | undefined\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating studio...').start()\n try {\n const application = await createApplication({...options, type: 'studio'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Ship a deployment to an already-created (or `deployment.appId`) application,\n * then sync its mutable metadata (`title`, and `icon`/`slug`/`visibility` when\n * set) from config. The deploy endpoint ignores these, so a redeploy patches\n * them here alongside the new deployment.\n *\n * `onDeployed` fires the instant the deployment is live, before the metadata\n * sync — so a caller can disarm a create-time rollback that must not delete an\n * application once it has an active deployment.\n *\n * The build's `mf-manifest.json` ships with every deployment. `isExternal`\n * skips the tarball: the customer serves the build from the application's\n * registered origin.\n * @internal\n */\nexport async function deployWorkbenchApp(options: {\n access?: readonly BrettAccess[]\n app: CliConfig['app']\n applicationId: string\n icon?: string\n isApp: boolean\n isAutoUpdating: boolean\n isExternal?: boolean\n label?: string\n onDeployed?: () => void\n /**\n * The address from config. Only `createApplication` used to send it, so an\n * app with a `deployment.appId` kept whatever slug it was created at.\n */\n slug?: string\n sourceDir: string\n title: string\n version: string\n visibility?: AppVisibility\n workspaces?: readonly BrettWorkspace[]\n}): Promise<void> {\n const {\n access,\n app,\n applicationId,\n icon,\n isApp,\n isAutoUpdating,\n isExternal = false,\n label = 'Deploying...',\n onDeployed,\n slug,\n sourceDir,\n title,\n version,\n visibility,\n workspaces,\n } = options\n const mfManifest = JSON.parse(await readFile(join(sourceDir, 'mf-manifest.json'), 'utf8'))\n const tarball = isExternal\n ? undefined\n : createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n const spin = spinner(label).start()\n try {\n await createDeployment({\n access,\n applicationId,\n // Brett assigns the id and resolves modules by `moduleId`, so neither travels.\n interfaces: deriveInterfaces(app, {appTitle: title, isApp}).map((iface) =>\n toBrettInterface(iface, version),\n ),\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n })\n onDeployed?.()\n try {\n await updateApplication(applicationId, {\n title,\n ...(icon ? {icon} : {}),\n ...(slug ? {slug} : {}),\n ...(visibility ? {visibility} : {}),\n })\n } catch (error) {\n throw toSlugRejection(error, slug)\n }\n spin.succeed()\n } catch (error) {\n spin.clear()\n throw error\n }\n}\n\n/**\n * The slug is the one synced field the server validates — it must be free\n * within the organization, and a singleton app only accepts its reserved\n * identifiers — so a 4xx on the metadata patch is a rejected rename. Name the\n * slug and the server's reason; anything else propagates untouched.\n */\nfunction toSlugRejection(error: unknown, slug: string | undefined): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (!slug || statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `Slug \"${slug}\" was rejected: ${getErrorMessage(error)}. The deployment is live at the application's previous slug — change \\`app.slug\\` in sanity.cli.ts and deploy again.`,\n {cause: error},\n )\n}\n"],"names":["readFile","basename","dirname","join","createGzip","getErrorMessage","spinner","c","createTar","deriveInterfaces","createApplication","createDeployment","deleteApplication","updateApplication","toBrettInterface","iface","version","id","_id","src","_src","declaration","surface","view","type","createCoreApp","options","spin","start","application","succeed","rollback","error","fail","createStudio","deployWorkbenchApp","access","app","applicationId","icon","isApp","isAutoUpdating","isExternal","label","onDeployed","slug","sourceDir","title","visibility","workspaces","mfManifest","JSON","parse","tarball","undefined","cwd","pipe","interfaces","appTitle","map","toSlugRejection","clear","statusCode","Error","cause"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,QAAQ,EAAEC,OAAO,EAAEC,IAAI,QAAO,YAAW;AACjD,SAAQC,UAAU,QAAO,YAAW;AAGpC,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAA+BC,gBAAgB,QAAO,4BAA2B;AACjF,SAKEC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,i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,OAAO;YACd,MAAM4B,gBAAgB5B,OAAOa;QAC/B;QACAlB,KAAKG,OAAO;IACd,EAAE,OAAOE,OAAO;QACdL,KAAKkC,KAAK;QACV,MAAM7B;IACR;AACF;AAEA;;;;;CAKC,GACD,SAAS4B,gBAAgB5B,KAAc,EAAEa,IAAwB;IAC/D,MAAMiB,aAAc9B,OAAiC8B;IACrD,IAAI,CAACjB,QAAQiB,eAAeR,aAAaQ,aAAa,OAAOA,cAAc,KAAK,OAAO9B;IACvF,OAAO,IAAI+B,MACT,CAAC,MAAM,EAAElB,KAAK,gBAAgB,EAAExC,gBAAgB2B,OAAO,oHAAoH,CAAC,EAC5K;QAACgC,OAAOhC;IAAK;AAEjB"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/deployWorkbenchApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {createGzip} from 'node:zlib'\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {c as createTar} from 'tar'\n\nimport {type DerivedInterface, deriveInterfaces} from '../../deriveInterfaces.js'\nimport {\n type Application,\n type BrettAccess,\n type BrettInterface,\n type BrettWorkspace,\n createApplication,\n createDeployment,\n deleteApplication,\n updateApplication,\n} from '../../services/applications.js'\n\n/**\n * `rollback` undoes the creation, so a later failure leaves no record stranded at the slug.\n * @internal\n */\nexport interface CreatedApplication {\n application: Application\n rollback: () => Promise<void>\n}\n\nfunction toBrettInterface(iface: DerivedInterface, version: string): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return {...declaration, version}\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'panel': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'window': {\n const {surface, ...view} = declaration\n return {...view, type: 'app', version}\n }\n }\n}\n\n/**\n * Create a coreApp record (no deployment), so the CLI can build with its id\n * before shipping the first deployment. First deploy only.\n * @internal\n */\nexport async function createCoreApp(options: {\n isSingleton?: boolean\n name?: string\n organizationId: string\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating application...').start()\n try {\n const application = await createApplication({...options, type: 'coreApp'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Create a studio record (no deployment).\n * @internal\n */\nexport async function createStudio(options: {\n externalUrl?: string\n name?: string\n organizationId: string\n projectId: string | undefined\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating studio...').start()\n try {\n const application = await createApplication({...options, type: 'studio'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Ship a deployment to an already-created (or `deployment.appId`) application,\n * then sync its mutable metadata (`title`, and `icon`/`slug`/`visibility` when\n * set) from config. The deploy endpoint ignores these, so a redeploy patches\n * them here alongside the new deployment.\n *\n * `onDeployed` fires the instant the deployment is live, before the metadata\n * sync — so a caller can disarm a create-time rollback that must not delete an\n * application once it has an active deployment.\n *\n * `isExternal` skips the tarball: the customer serves the build from the\n * application's registered origin.\n * @internal\n */\nexport async function deployWorkbenchApp(options: {\n access?: readonly BrettAccess[]\n app: CliConfig['app']\n applicationId: string\n icon?: string\n isApp: boolean\n isAutoUpdating: boolean\n isExternal?: boolean\n label?: string\n mfManifest: Record<string, unknown>\n onDeployed?: () => void\n /**\n * The address from config. Only `createApplication` used to send it, so an\n * app with a `deployment.appId` kept whatever slug it was created at.\n */\n slug?: string\n sourceDir: string\n title: string\n version: string\n visibility?: AppVisibility\n workspaces?: readonly BrettWorkspace[]\n}): Promise<void> {\n const {\n access,\n app,\n applicationId,\n icon,\n isApp,\n isAutoUpdating,\n isExternal = false,\n label = 'Deploying...',\n mfManifest,\n onDeployed,\n slug,\n sourceDir,\n title,\n version,\n visibility,\n workspaces,\n } = options\n const tarball = isExternal\n ? undefined\n : createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n const spin = spinner(label).start()\n try {\n await createDeployment({\n access,\n applicationId,\n // Brett assigns the id and resolves modules by `moduleId`, so neither travels.\n interfaces: deriveInterfaces(app, {appTitle: title, isApp}).map((iface) =>\n toBrettInterface(iface, version),\n ),\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n })\n onDeployed?.()\n try {\n await updateApplication(applicationId, {\n title,\n ...(icon ? {icon} : {}),\n ...(slug ? {slug} : {}),\n ...(visibility ? {visibility} : {}),\n })\n } catch (error) {\n throw toSlugRejection(error, slug)\n }\n spin.succeed()\n } catch (error) {\n spin.clear()\n throw error\n }\n}\n\n/**\n * The slug is the one synced field the server validates — it must be free\n * within the organization, and a singleton app only accepts its reserved\n * identifiers — so a 4xx on the metadata patch is a rejected rename. Name the\n * slug and the server's reason; anything else propagates untouched.\n */\nfunction toSlugRejection(error: unknown, slug: string | undefined): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (!slug || statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `Slug \"${slug}\" was rejected: ${getErrorMessage(error)}. The deployment is live at the application's previous slug — change \\`app.slug\\` in sanity.cli.ts and deploy again.`,\n {cause: error},\n )\n}\n"],"names":["basename","dirname","createGzip","getErrorMessage","spinner","c","createTar","deriveInterfaces","createApplication","createDeployment","deleteApplication","updateApplication","toBrettInterface","iface","version","id","_id","src","_src","declaration","surface","view","type","createCoreApp","options","spin","start","application","succeed","rollback","error","fail","createStudio","deployWorkbenchApp","access","app","applicationId","icon","isApp","isAutoUpdating","isExternal","label","mfManifest","onDeployed","slug","sourceDir","title","visibility","workspaces","tarball","undefined","cwd","pipe","interfaces","appTitle","map","toSlugRejection","clear","statusCode","Error","cause"],"mappings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