@sanity/workbench-cli 2.17.0 → 2.19.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.
- package/dist/_exports/_internal_worker_bus.d.ts +2 -2
- package/dist/_exports/deploy.d.ts +38 -6
- package/dist/_exports/deploy.js +2 -0
- package/dist/_exports/deploy.js.map +1 -1
- package/dist/_exports/dev.d.ts +4 -1
- package/dist/_exports/index.d.ts +67 -2
- package/dist/_exports/preview.d.ts +2 -0
- package/dist/_exports/{summarizeInterfaces-CpCUSMrz.d.ts → summarizeInterfaces-DGh6ARce.d.ts} +2 -2
- package/dist/_exports/undeploy.d.ts +1 -1
- package/dist/actions/build/webWorkers/workerBus.js.map +1 -1
- package/dist/actions/deploy/deploySummary.js +36 -0
- package/dist/actions/deploy/deploySummary.js.map +1 -0
- package/dist/actions/deploy/deployWorkbenchApp.js +21 -7
- package/dist/actions/deploy/deployWorkbenchApp.js.map +1 -1
- package/dist/actions/dev/appServerSupervisor.js +3 -1
- package/dist/actions/dev/appServerSupervisor.js.map +1 -1
- package/dist/actions/dev/bindDevShortcuts.js +33 -0
- package/dist/actions/dev/bindDevShortcuts.js.map +1 -0
- package/dist/actions/dev/deriveConfigs.js +1 -1
- package/dist/actions/dev/deriveConfigs.js.map +1 -1
- package/dist/actions/dev/devSummary.js +49 -0
- package/dist/actions/dev/devSummary.js.map +1 -0
- package/dist/actions/dev/startDevServerRegistration.js +16 -1
- package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
- package/dist/actions/dev/startWorkbenchDev.js +46 -11
- package/dist/actions/dev/startWorkbenchDev.js.map +1 -1
- package/dist/actions/preview/serveBuiltApplication.js +12 -1
- package/dist/actions/preview/serveBuiltApplication.js.map +1 -1
- package/dist/actions/preview/startWorkbenchPreview.js +11 -0
- package/dist/actions/preview/startWorkbenchPreview.js.map +1 -1
- package/dist/actions/summary.js +19 -0
- package/dist/actions/summary.js.map +1 -0
- package/dist/appId.js +1 -1
- package/dist/appId.js.map +1 -1
- package/dist/defineApp.js +4 -3
- package/dist/defineApp.js.map +1 -1
- package/dist/readAppIcon.js +31 -0
- package/dist/readAppIcon.js.map +1 -0
- package/dist/services/applications.js +40 -0
- package/dist/services/applications.js.map +1 -1
- package/dist/services/organizations.js +14 -0
- package/dist/services/organizations.js.map +1 -0
- package/dist/services/users.js +24 -0
- package/dist/services/users.js.map +1 -0
- package/dist/webWorker.js.map +1 -1
- package/package.json +13 -13
- package/dist/_exports/webWorker-TWUbh0uo.d.ts +0 -123
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WebWorkerProps } from "@sanity/sdk/dashboard";
|
|
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,
|
|
@@ -10,7 +10,7 @@ declare function createWorkerBus(): {
|
|
|
10
10
|
* The web worker author's API. The host owns the connection, opening it and ending it when
|
|
11
11
|
* it terminates the worker, so the worker cannot end it.
|
|
12
12
|
*/
|
|
13
|
-
bus:
|
|
13
|
+
bus: WebWorkerProps['bus'];
|
|
14
14
|
/**
|
|
15
15
|
* The generated entry's terminate hook, not the author's. It sends nothing to
|
|
16
16
|
* the host, which has already disconnected; it only marks the client closed so
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "./contract-WrU3aOYd.js";
|
|
2
2
|
import { n as resolveWorkbenchConfig, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-JRi01VJM.js";
|
|
3
|
-
import { a as DeployableWorkbenchApp, i as summarizeInterfaces, n as DeployedView, o as getWorkbench, r as DeployedWebWorker, t as DeployedInterface } from "./summarizeInterfaces-
|
|
3
|
+
import { a as DeployableWorkbenchApp, i as summarizeInterfaces, n as DeployedView, o as getWorkbench, r as DeployedWebWorker, t as DeployedInterface } from "./summarizeInterfaces-DGh6ARce.js";
|
|
4
4
|
import { AppVisibility, CliConfig, Output } from "@sanity/cli-core";
|
|
5
|
+
import { ImageFile } from "@sanity/cli-core/images";
|
|
5
6
|
import "node:zlib";
|
|
6
7
|
/**
|
|
7
8
|
* The org's active installation for an app type, or `undefined` when none is
|
|
@@ -61,6 +62,22 @@ declare function toWorkbenchPayload(workbench: DeployableWorkbenchApp | null, {
|
|
|
61
62
|
} | null;
|
|
62
63
|
title: string;
|
|
63
64
|
}): Partial<WorkbenchDeployPayload>;
|
|
65
|
+
declare function fetchDeploySummaryDetails(organizationId: string): Promise<{
|
|
66
|
+
organizationName: string | null;
|
|
67
|
+
userName: string | null;
|
|
68
|
+
}>;
|
|
69
|
+
declare function formatDeploySummary(options: {
|
|
70
|
+
applicationId: string;
|
|
71
|
+
created: boolean;
|
|
72
|
+
durationMs: number;
|
|
73
|
+
isApp: boolean;
|
|
74
|
+
organizationId: string;
|
|
75
|
+
organizationName?: string | null;
|
|
76
|
+
showAppIdHint: boolean;
|
|
77
|
+
title: string;
|
|
78
|
+
url: string;
|
|
79
|
+
userName?: string | null;
|
|
80
|
+
}): string;
|
|
64
81
|
type ApplicationType = 'coreApp' | 'studio';
|
|
65
82
|
interface Application {
|
|
66
83
|
id: string;
|
|
@@ -133,9 +150,10 @@ declare function createStudio(options: {
|
|
|
133
150
|
}): Promise<CreatedApplication>;
|
|
134
151
|
/**
|
|
135
152
|
* Ship a deployment to an already-created (or `deployment.appId`) application,
|
|
136
|
-
* then sync its mutable metadata (`title`, and `
|
|
137
|
-
*
|
|
138
|
-
* them here alongside the new deployment.
|
|
153
|
+
* then sync its mutable metadata (`title`, and `slug`/`visibility` when set)
|
|
154
|
+
* and its icon from config. The deploy endpoint ignores these, so a redeploy
|
|
155
|
+
* patches them here alongside the new deployment. No `icon` removes the
|
|
156
|
+
* application's icon.
|
|
139
157
|
*
|
|
140
158
|
* `onDeployed` fires the instant the deployment is live, before the metadata
|
|
141
159
|
* sync — so a caller can disarm a create-time rollback that must not delete an
|
|
@@ -149,7 +167,7 @@ declare function deployWorkbenchApp(options: {
|
|
|
149
167
|
access?: readonly BrettAccess[];
|
|
150
168
|
app: CliConfig['app'];
|
|
151
169
|
applicationId: string;
|
|
152
|
-
icon?:
|
|
170
|
+
icon?: ImageFile;
|
|
153
171
|
isApp: boolean;
|
|
154
172
|
isAutoUpdating: boolean;
|
|
155
173
|
isExternal?: boolean;
|
|
@@ -181,5 +199,19 @@ declare function selectWorkbenchAppId({ appId, flags, organizationId, type }: {
|
|
|
181
199
|
organizationId: string | undefined;
|
|
182
200
|
type: ApplicationType;
|
|
183
201
|
}): Promise<string | undefined>;
|
|
184
|
-
|
|
202
|
+
/**
|
|
203
|
+
* An app's `icon` image, read from its project.
|
|
204
|
+
* @internal
|
|
205
|
+
*/
|
|
206
|
+
interface AppIcon extends ImageFile {
|
|
207
|
+
/** Absolute path to the file. */
|
|
208
|
+
file: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Read the image `app.icon` points at. The path is relative to the project
|
|
212
|
+
* root and must stay inside it.
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
declare function readAppIcon(workDir: string, iconPath: string): Promise<AppIcon>;
|
|
216
|
+
export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type DeployedView, type DeployedWebWorker, type ResolvedMediaLibraryConfig, type WorkbenchDeployPayload, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, fetchDeploySummaryDetails, formatDeploySummary, getApplication, getApplicationUrl, getWorkbench, getWorkbenchUrl, listApplications, readAppIcon, resolveInstallationId, resolveWorkbenchConfig, selectWorkbenchAppId, summarizeConfig, summarizeInterfaces, toWorkbenchPayload };
|
|
185
217
|
//# sourceMappingURL=deploy.d.ts.map
|
package/dist/_exports/deploy.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { deployConfig, resolveInstallationId, summarizeConfig } from '../actions/deploy/deployConfig.js';
|
|
2
2
|
export { toWorkbenchPayload } from '../actions/deploy/deployPayload.js';
|
|
3
|
+
export { fetchDeploySummaryDetails, formatDeploySummary } from '../actions/deploy/deploySummary.js';
|
|
3
4
|
export { createCoreApp, createStudio, deployWorkbenchApp } from '../actions/deploy/deployWorkbenchApp.js';
|
|
4
5
|
export { getWorkbench } from '../actions/deploy/getWorkbench.js';
|
|
5
6
|
export { selectWorkbenchAppId } from '../actions/deploy/selectWorkbenchAppId.js';
|
|
6
7
|
export { summarizeInterfaces } from '../actions/deploy/summarizeInterfaces.js';
|
|
8
|
+
export { readAppIcon } from '../readAppIcon.js';
|
|
7
9
|
export { resolveWorkbenchConfig } from '../resolveWorkbenchConfig.js';
|
|
8
10
|
export { getApplication, getApplicationUrl, getWorkbenchUrl, listApplications } from '../services/applications.js';
|
|
9
11
|
|
|
@@ -1 +1 @@
|
|
|
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 {selectWorkbenchAppId} from '../actions/deploy/selectWorkbenchAppId.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","selectWorkbenchAppId","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,SAAQC,oBAAoB,QAAO,4CAA2C;AAC9E,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 {fetchDeploySummaryDetails, formatDeploySummary} from '../actions/deploy/deploySummary.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 {selectWorkbenchAppId} from '../actions/deploy/selectWorkbenchAppId.js'\nexport {\n type DeployedInterface,\n type DeployedView,\n type DeployedWebWorker,\n summarizeInterfaces,\n} from '../actions/deploy/summarizeInterfaces.js'\nexport {readAppIcon} from '../readAppIcon.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","fetchDeploySummaryDetails","formatDeploySummary","createCoreApp","createStudio","deployWorkbenchApp","getWorkbench","selectWorkbenchAppId","summarizeInterfaces","readAppIcon","resolveWorkbenchConfig","getApplication","getApplicationUrl","getWorkbenchUrl","listApplications"],"mappings":"AAAA,SACEA,YAAY,EACZC,qBAAqB,EACrBC,eAAe,QACV,oCAAmC;AAC1C,SAAQC,kBAAkB,QAAoC,qCAAoC;AAClG,SAAQC,yBAAyB,EAAEC,mBAAmB,QAAO,qCAAoC;AACjG,SACEC,aAAa,EAEbC,YAAY,EACZC,kBAAkB,QACb,0CAAyC;AAChD,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAAQC,oBAAoB,QAAO,4CAA2C;AAC9E,SAIEC,mBAAmB,QACd,2CAA0C;AACjD,SAAQC,WAAW,QAAO,oBAAmB;AAC7C,SAAyCC,sBAAsB,QAAO,+BAA8B;AACpG,SAIEC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,8BAA6B"}
|
package/dist/_exports/dev.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ interface StartWorkbenchDevOptions {
|
|
|
24
24
|
extractManifest: (params: {
|
|
25
25
|
applicationId?: string;
|
|
26
26
|
configPath: string;
|
|
27
|
+
/** Where the app server serves the app's icon. */
|
|
28
|
+
iconUrl?: string;
|
|
27
29
|
workDir: string;
|
|
28
30
|
}) => Promise<DevServerManifest['manifest']>;
|
|
29
31
|
httpHost: string | undefined;
|
|
@@ -33,9 +35,10 @@ interface StartWorkbenchDevOptions {
|
|
|
33
35
|
reactStrictMode: boolean;
|
|
34
36
|
/** Start the app/studio dev server — the CLI owns the server, this orchestrates it. */
|
|
35
37
|
startAppServer: (params: {
|
|
36
|
-
announceUrl: boolean;
|
|
37
38
|
cliConfig: CliConfig;
|
|
38
39
|
httpPort: number;
|
|
40
|
+
isRestarting?: boolean;
|
|
41
|
+
quiet?: boolean;
|
|
39
42
|
}) => Promise<AppServerResult>;
|
|
40
43
|
workDir: string;
|
|
41
44
|
}
|
package/dist/_exports/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as defineTileView, S as definePanelView, T as defineWindowView, _ as WebWorker, a as DefineWebWorkerInput, c as PanelView, d as TileView, f as ViewComponent, h as ViewSurface, i as DefineTileViewInput, l as ServiceType, m as ViewDeclaration, n as DefineAssetSourceViewInput, o as DefineWindowViewInput, p as ViewComponentBaseProps, r as DefinePanelViewInput, s as DockGroup, t as AssetSourceView, u as TileSize, v as WebWorkerType, w as defineWebWorker, x as defineAssetSourceView, y as WindowView } from "./contract-WrU3aOYd.js";
|
|
2
|
-
import { a as ServiceInfo, c as WebWorkerProps, i as ServiceContext, l as unstable_defineService, n as ServiceBus, o as WebWorkerBus, r as ServiceCallback, s as WebWorkerInfo, t as DefinedService } from "./webWorker-TWUbh0uo.js";
|
|
1
|
+
import { C as defineTileView, S as definePanelView, T as defineWindowView, _ as WebWorker, a as DefineWebWorkerInput, c as PanelView, d as TileView, f as ViewComponent, g as WEB_WORKER_CONTRACT_VERSION, h as ViewSurface, i as DefineTileViewInput, l as ServiceType, m as ViewDeclaration, n as DefineAssetSourceViewInput, o as DefineWindowViewInput, p as ViewComponentBaseProps, r as DefinePanelViewInput, s as DockGroup, t as AssetSourceView, u as TileSize, v as WebWorkerType, w as defineWebWorker, x as defineAssetSourceView, y as WindowView } from "./contract-WrU3aOYd.js";
|
|
3
2
|
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-vbUu_rBA.js";
|
|
3
|
+
import { WebWorkerProps, WebWorkerProps as WebWorkerProps$1 } from "@sanity/sdk/dashboard";
|
|
4
4
|
import { AssetSourceComponentProps } from "@sanity/types";
|
|
5
5
|
/** @public */
|
|
6
6
|
type WindowViewProps = ViewComponentBaseProps<{
|
|
@@ -112,5 +112,70 @@ interface DefinedView<TSurface extends ViewSurface = ViewSurface> {
|
|
|
112
112
|
* @public
|
|
113
113
|
*/
|
|
114
114
|
declare function unstable_defineView<TSurface extends ViewSurface>(surface: TSurface, components: ViewComponentsBySurface[TSurface]): DefinedView<TSurface>;
|
|
115
|
+
/**
|
|
116
|
+
* @deprecated Use `WebWorkerProps['worker']`.
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
type WebWorkerInfo = WebWorkerProps$1['worker'];
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated Use `WebWorkerProps['bus']`.
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
type WebWorkerBus = WebWorkerProps$1['bus'];
|
|
125
|
+
/**
|
|
126
|
+
* Context every service callback receives when its worker starts. Mirrors how a
|
|
127
|
+
* view component receives its `view` — the service receives its own `service`.
|
|
128
|
+
* @deprecated Use {@link WebWorkerProps}.
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
interface ServiceContext {
|
|
132
|
+
readonly bus: WebWorkerProps$1['bus'];
|
|
133
|
+
readonly service: WebWorkerProps$1['worker'];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A service callback. Runs once inside the worker on start; returns an optional
|
|
137
|
+
* disposer the host calls before terminating the worker.
|
|
138
|
+
* @deprecated Default-export a plain function that receives {@link WebWorkerProps} instead.
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
type ServiceCallback = (context: ServiceContext) => (() => void) | void;
|
|
142
|
+
/** The callback shape each service type defines, keyed by type. */
|
|
143
|
+
interface ServiceCallbacksByType {
|
|
144
|
+
worker: ServiceCallback;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The result of `unstable_defineService`: the author's callback, the service
|
|
148
|
+
* type, and the internal contract version the worker artifact targets.
|
|
149
|
+
* @deprecated Default-export a plain function that receives {@link WebWorkerProps} instead.
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
interface DefinedService<TType extends WebWorkerType = WebWorkerType> {
|
|
153
|
+
readonly run: ServiceCallbacksByType[TType];
|
|
154
|
+
readonly type: TType;
|
|
155
|
+
/** @internal */
|
|
156
|
+
readonly version: typeof WEB_WORKER_CONTRACT_VERSION;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Define a Sanity Dashboard background service. The first argument narrows the
|
|
160
|
+
* callback shape — `"worker"` runs the callback inside a Web Worker with the
|
|
161
|
+
* bus described on {@link WebWorkerProps}.
|
|
162
|
+
*
|
|
163
|
+
* Identity at runtime: returns the callback tagged with its type and the contract
|
|
164
|
+
* version, for the CLI build to generate a worker artifact from. Used as the
|
|
165
|
+
* default export of a service's `src` file.
|
|
166
|
+
* @deprecated Default-export a plain function that receives {@link WebWorkerProps} from the web worker's `src` file instead.
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
declare function unstable_defineService<TType extends WebWorkerType>(type: TType, run: ServiceCallbacksByType[TType]): DefinedService<TType>;
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Use `WebWorkerProps['bus']`.
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
type ServiceBus = WebWorkerProps$1['bus'];
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated Use `WebWorkerProps['worker']`.
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
type ServiceInfo = WebWorkerProps$1['worker'];
|
|
115
180
|
export { type AssetSourceComponent, type AssetSourceView, type AssetSourceViewComponents, type DefineAppInput, type DefineAppResult, type DefineAssetSourceViewInput, type DefineMediaLibraryInput, type DefinePanelViewInput, type DefineTileViewInput, type DefineWebWorkerInput, type DefineWindowViewInput, type DefinedService, type DefinedView, type DockGroup, type MediaLibraryField, type PanelComponent, type PanelView, type PanelViewComponents, type PanelViewProps, type ServiceBus, type ServiceCallback, type ServiceContext, type ServiceInfo, type ServiceType, type TileComponent, type TileSize, type TileView, type TileViewComponents, type TileViewProps, type ViewComponentsBySurface, type ViewDeclaration, type ViewSurface, type WebWorker, type WebWorkerBus, type WebWorkerInfo, type WebWorkerProps, type WebWorkerType, type WindowView, type WindowViewProps, type WorkbenchApp, type WorkbenchConfig, defineApplication, defineAssetSourceView, definePanelView, defineTileView, defineWebWorker, defineWindowView, isWorkbenchApp, isWorkbenchConfig, unstable_defineMediaLibrary, unstable_defineService, unstable_defineView };
|
|
116
181
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -10,6 +10,8 @@ interface StartWorkbenchPreviewOptions {
|
|
|
10
10
|
extractManifest: (params: {
|
|
11
11
|
applicationId?: string;
|
|
12
12
|
configPath: string;
|
|
13
|
+
/** Where the preview serves the app's icon. */
|
|
14
|
+
iconUrl?: string;
|
|
13
15
|
workDir: string;
|
|
14
16
|
}) => Promise<DevServerManifest['manifest']>;
|
|
15
17
|
httpHost: string;
|
package/dist/_exports/{summarizeInterfaces-CpCUSMrz.d.ts → summarizeInterfaces-DGh6ARce.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h as ViewSurface, v as WebWorkerType } from "./contract-WrU3aOYd.js";
|
|
2
2
|
import { i as WorkbenchExposes, r as ResolvedWorkbenchApp } from "./resolveWorkbenchConfig-JRi01VJM.js";
|
|
3
|
-
import { z } from "zod/mini";
|
|
4
3
|
import { CliConfig } from "@sanity/cli-core";
|
|
4
|
+
import { z } from "zod/mini";
|
|
5
5
|
/**
|
|
6
6
|
* Payload registering an app's views with the application service on deploy.
|
|
7
7
|
*
|
|
@@ -62,4 +62,4 @@ declare function summarizeInterfaces({ views, webWorkers }: WorkbenchExposes): {
|
|
|
62
62
|
views: DeployedView[];
|
|
63
63
|
};
|
|
64
64
|
export { DeployableWorkbenchApp as a, summarizeInterfaces as i, DeployedView as n, getWorkbench as o, DeployedWebWorker as r, DeployedInterface as t };
|
|
65
|
-
//# sourceMappingURL=summarizeInterfaces-
|
|
65
|
+
//# sourceMappingURL=summarizeInterfaces-DGh6ARce.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-JRi01VJM.js";
|
|
2
|
-
import { a as DeployableWorkbenchApp, n as DeployedView, r as DeployedWebWorker } from "./summarizeInterfaces-
|
|
2
|
+
import { a as DeployableWorkbenchApp, n as DeployedView, r as DeployedWebWorker } from "./summarizeInterfaces-DGh6ARce.js";
|
|
3
3
|
import "node:zlib";
|
|
4
4
|
import { UndeployAdapter, UndeployApplicationTarget, UndeployConfigTarget } from "@sanity/cli-core/undeploy";
|
|
5
5
|
interface ConfigSnapshot {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/build/webWorkers/workerBus.ts"],"sourcesContent":["// Runs inside the web worker'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 WebWorkerBus} from '../../../webWorker.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\n// What a host refusal can carry besides its code and message, such as the fix\n// and docs link for one of the Dashboard's coded errors.\ninterface RefusalDetails {\n docsUrl?: string\n fix?: string\n}\n\ntype HostMessage =\n | {\n error: RefusalDetails & {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, details?: RefusalDetails): Error =>\n Object.assign(new Error(message || code), {\n code,\n docsUrl: details?.docsUrl,\n fix: details?.fix,\n name: 'MessageBusError',\n })\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 web worker 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: WebWorkerBus\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 WebWorkerBus,\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. The Dashboard prints the refusal.\n subscriptions.delete(message.id)\n settle?.({\n error: busError(message.error.code, message.error.message, message.error),\n ok: false,\n })\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","details","Object","assign","Error","docsUrl","fix","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,8EAA8E;AAC9E,6EAA6E;AAC7E,gCAAgC;AAUhC,MAAMA,qBAAqB;AAuC3B,4EAA4E;AAC5E,kCAAkC;AAClC,MAAMC,WAAW,CAACC,MAA2BC,SAAkBC,UAC7DC,OAAOC,MAAM,CAAC,IAAIC,MAAMJ,WAAWD,OAAO;QACxCA;QACAM,SAASJ,SAASI;QAClBC,KAAKL,SAASK;QACdC,MAAM;IACR;AAEF;;;;;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,QAAQf,OAAgC,EAAEgB,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;QACA,MAAMI,UAAU;YACdC,KAAKC,WAAW,CAAC;gBAACX;gBAAIY,MAAM;YAAqB;YACjDR,OAAO;gBAACS,OAAOlC,SAAS;gBAAYmC,IAA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BACxEC,IAAI;wBACN;wBACA;oBACF;gBACA,KAAK;oBAAuB;wBAC1BtB,cAAc2C,GAAG,CAACtD,QAAQmB,EAAE,IAAInB,QAAQ4C,KAAK;oBAC/C;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/build/webWorkers/workerBus.ts"],"sourcesContent":["// Runs inside the web worker'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 type WebWorkerProps,\n} from '@sanity/sdk/dashboard'\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\n// What a host refusal can carry besides its code and message, such as the fix\n// and docs link for one of the Dashboard's coded errors.\ninterface RefusalDetails {\n docsUrl?: string\n fix?: string\n}\n\ntype HostMessage =\n | {\n error: RefusalDetails & {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, details?: RefusalDetails): Error =>\n Object.assign(new Error(message || code), {\n code,\n docsUrl: details?.docsUrl,\n fix: details?.fix,\n name: 'MessageBusError',\n })\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 web worker 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: WebWorkerProps['bus']\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 WebWorkerProps['bus'],\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. The Dashboard prints the refusal.\n subscriptions.delete(message.id)\n settle?.({\n error: busError(message.error.code, message.error.message, message.error),\n ok: false,\n })\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","details","Object","assign","Error","docsUrl","fix","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,8EAA8E;AAC9E,6EAA6E;AAC7E,gCAAgC;AAShC,MAAMA,qBAAqB;AAuC3B,4EAA4E;AAC5E,kCAAkC;AAClC,MAAMC,WAAW,CAACC,MAA2BC,SAAkBC,UAC7DC,OAAOC,MAAM,CAAC,IAAIC,MAAMJ,WAAWD,OAAO;QACxCA;QACAM,SAASJ,SAASI;QAClBC,KAAKL,SAASK;QACdC,MAAM;IACR;AAEF;;;;;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,QAAQf,OAAgC,EAAEgB,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;QACA,MAAMI,UAAU;YACdC,KAAKC,WAAW,CAAC;gBAACX;gBAAIY,MAAM;YAAqB;YACjDR,OAAO;gBAACS,OAAOlC,SAAS;gBAAYmC,IAAI;YAAK;QAC/C;QAEA,IAAInB,UAAUG,QAAQiB,SAAS;YAC7Bd,UAAU;gBAACY,OAAOlC,SAAS;gBAAYmC,IAAI;YAAK;QAClD,OAAO;YACL,oFAAoF;YACpFJ,KAAKC,WAAW,CA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 -0,0 +1,36 @@
|
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
|
+
import { logSymbols } from '@sanity/cli-core/ux';
|
|
3
|
+
import { getOrganization } from '../../services/organizations.js';
|
|
4
|
+
import { getCurrentUser } from '../../services/users.js';
|
|
5
|
+
import { formatSummary, SUMMARY_LOOKUP_TIMEOUT_MS } from '../summary.js';
|
|
6
|
+
export async function fetchDeploySummaryDetails(organizationId) {
|
|
7
|
+
const signal = AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS);
|
|
8
|
+
const [organizationName, userName] = await Promise.all([
|
|
9
|
+
getOrganization(organizationId, signal).then((org)=>org.name).catch(()=>null),
|
|
10
|
+
getCurrentUser(signal).then((user)=>user.name).catch(()=>null)
|
|
11
|
+
]);
|
|
12
|
+
return {
|
|
13
|
+
organizationName,
|
|
14
|
+
userName
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function formatDeploySummary(options) {
|
|
18
|
+
const { applicationId, created, durationMs, isApp, showAppIdHint, title, url, userName } = options;
|
|
19
|
+
const summary = formatSummary({
|
|
20
|
+
durationMs,
|
|
21
|
+
heading: `${title} deployed`,
|
|
22
|
+
isApp,
|
|
23
|
+
organization: options.organizationName ?? options.organizationId,
|
|
24
|
+
title,
|
|
25
|
+
url,
|
|
26
|
+
version: userName ? `just now by ${userName}` : 'just now'
|
|
27
|
+
});
|
|
28
|
+
const result = created ? `Created ${title} as a new ${isApp ? 'application' : 'studio'}.` : `Updated ${title}.`;
|
|
29
|
+
const success = styleText('green', ` ${logSymbols.success} ${result}`);
|
|
30
|
+
const appIdHint = showAppIdHint ? `\n ${styleText('dim', 'Add')} deployment.appId: "${applicationId}" ${styleText('dim', 'to sanity.cli.ts so the next deploy updates it')}\n` : '';
|
|
31
|
+
return `${summary}
|
|
32
|
+
${success}
|
|
33
|
+
${appIdHint}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=deploySummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deploySummary.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {logSymbols} from '@sanity/cli-core/ux'\n\nimport {getOrganization} from '../../services/organizations.js'\nimport {getCurrentUser} from '../../services/users.js'\nimport {formatSummary, SUMMARY_LOOKUP_TIMEOUT_MS} from '../summary.js'\n\nexport async function fetchDeploySummaryDetails(organizationId: string) {\n const signal = AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS)\n const [organizationName, userName] = await Promise.all([\n getOrganization(organizationId, signal)\n .then((org) => org.name)\n .catch(() => null),\n getCurrentUser(signal)\n .then((user) => user.name)\n .catch(() => null),\n ])\n\n return {organizationName, userName}\n}\n\nexport function formatDeploySummary(options: {\n applicationId: string\n created: boolean\n durationMs: number\n isApp: boolean\n organizationId: string\n organizationName?: string | null\n showAppIdHint: boolean\n title: string\n url: string\n userName?: string | null\n}): string {\n const {applicationId, created, durationMs, isApp, showAppIdHint, title, url, userName} = options\n\n const summary = formatSummary({\n durationMs,\n heading: `${title} deployed`,\n isApp,\n organization: options.organizationName ?? options.organizationId,\n title,\n url,\n version: userName ? `just now by ${userName}` : 'just now',\n })\n const result = created\n ? `Created ${title} as a new ${isApp ? 'application' : 'studio'}.`\n : `Updated ${title}.`\n const success = styleText('green', ` ${logSymbols.success} ${result}`)\n const appIdHint = showAppIdHint\n ? `\\n ${styleText('dim', 'Add')} deployment.appId: \"${applicationId}\" ${styleText('dim', 'to sanity.cli.ts so the next deploy updates it')}\\n`\n : ''\n\n return `${summary}\n${success}\n${appIdHint}`\n}\n"],"names":["styleText","logSymbols","getOrganization","getCurrentUser","formatSummary","SUMMARY_LOOKUP_TIMEOUT_MS","fetchDeploySummaryDetails","organizationId","signal","AbortSignal","timeout","organizationName","userName","Promise","all","then","org","name","catch","user","formatDeploySummary","options","applicationId","created","durationMs","isApp","showAppIdHint","title","url","summary","heading","organization","version","result","success","appIdHint"],"mappings":"AAAA,SAAQ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c,EAAE,EAAEtB,UAAU,OAAO,kDAAkD,EAAE,CAAC,GAC7I;IAEJ,OAAO,GAAG6B,QAAQ;AACpB,EAAEK,QAAQ;AACV,EAAEC,WAAW;AACb"}
|
|
@@ -4,7 +4,7 @@ import { getErrorMessage } from '@sanity/cli-core/errors';
|
|
|
4
4
|
import { spinner } from '@sanity/cli-core/ux';
|
|
5
5
|
import { c as createTar } from 'tar';
|
|
6
6
|
import { deriveInterfaces } from '../../deriveInterfaces.js';
|
|
7
|
-
import { createApplication, createDeployment, deleteApplication, updateApplication } from '../../services/applications.js';
|
|
7
|
+
import { createApplication, createDeployment, deleteApplication, removeApplicationIcon, setApplicationIcon, updateApplication } from '../../services/applications.js';
|
|
8
8
|
function toBrettInterface(iface) {
|
|
9
9
|
const { id: _id, src: _src, ...declaration } = iface;
|
|
10
10
|
if ('type' in declaration) return declaration;
|
|
@@ -86,9 +86,10 @@ function toBrettInterface(iface) {
|
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Ship a deployment to an already-created (or `deployment.appId`) application,
|
|
89
|
-
* then sync its mutable metadata (`title`, and `
|
|
90
|
-
*
|
|
91
|
-
* them here alongside the new deployment.
|
|
89
|
+
* then sync its mutable metadata (`title`, and `slug`/`visibility` when set)
|
|
90
|
+
* and its icon from config. The deploy endpoint ignores these, so a redeploy
|
|
91
|
+
* patches them here alongside the new deployment. No `icon` removes the
|
|
92
|
+
* application's icon.
|
|
92
93
|
*
|
|
93
94
|
* `onDeployed` fires the instant the deployment is live, before the metadata
|
|
94
95
|
* sync — so a caller can disarm a create-time rollback that must not delete an
|
|
@@ -124,9 +125,6 @@ function toBrettInterface(iface) {
|
|
|
124
125
|
try {
|
|
125
126
|
await updateApplication(applicationId, {
|
|
126
127
|
title,
|
|
127
|
-
...icon ? {
|
|
128
|
-
icon
|
|
129
|
-
} : {},
|
|
130
128
|
...slug ? {
|
|
131
129
|
slug
|
|
132
130
|
} : {},
|
|
@@ -137,6 +135,15 @@ function toBrettInterface(iface) {
|
|
|
137
135
|
} catch (error) {
|
|
138
136
|
throw toSlugRejection(error, slug);
|
|
139
137
|
}
|
|
138
|
+
if (icon) {
|
|
139
|
+
try {
|
|
140
|
+
await setApplicationIcon(applicationId, icon);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
throw toIconRejection(error);
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
await removeApplicationIcon(applicationId);
|
|
146
|
+
}
|
|
140
147
|
spin.succeed();
|
|
141
148
|
} catch (error) {
|
|
142
149
|
spin.clear();
|
|
@@ -155,5 +162,12 @@ function toBrettInterface(iface) {
|
|
|
155
162
|
cause: error
|
|
156
163
|
});
|
|
157
164
|
}
|
|
165
|
+
/** A 4xx on the icon upload is the image being rejected; name the server's reason. */ function toIconRejection(error) {
|
|
166
|
+
const statusCode = error?.statusCode;
|
|
167
|
+
if (statusCode === undefined || statusCode < 400 || statusCode >= 500) return error;
|
|
168
|
+
return new Error(`The app icon was rejected: ${getErrorMessage(error)}. The deployment is live with the application's previous icon. Change \`app.icon\` in sanity.cli.ts and deploy again.`, {
|
|
169
|
+
cause: error
|
|
170
|
+
});
|
|
171
|
+
}
|
|
158
172
|
|
|
159
173
|
//# sourceMappingURL=deployWorkbenchApp.js.map
|
|
@@ -1 +1 @@
|
|
|
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): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return declaration\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'panel': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'window': {\n const {surface, ...view} = declaration\n return {...view, type: 'app'}\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),\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","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","version","visibility","workspaces","tarball","undefined","cwd","pipe","interfaces","appTitle","map","toSlugRejection","clear","statusCode","Error","cause"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,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,iBAAiB,QACZ,iCAAgC;AAWvC,SAASC,iBAAiBC,KAAuB;IAC/C,MAAM,EAACC,IAAIC,GAAG,EAAEC,KAAKC,IAAI,EAAE,GAAGC,aAAY,GAAGL;IAC7C,IAAI,UAAUK,aAAa,OAAOA;IAElC,OAAQA,YAAYC,OAAO;QACzB,KAAK;YAAgB;gBACnB,MAAM,EAACA,OAAO,EAAE,GAAGC,MAAK,GAAGF;gBAC3B,OAAO;oBAAC,GAAGE,IAAI;oBAAEC,MAAMF;gBAAO;YAChC;QACA,KAAK;YAAS;gBACZ,MAAM,EAACA,OAAO,EAAE,GAAGC,MAAK,GAAGF;gBAC3B,OAAO;oBAAC,GAAGE,IAAI;oBAAEC,MAAMF;gBAAO;YAChC;QACA,KAAK;YAAQ;gBACX,MAAM,EAACA,OAAO,EAAE,GAAGC,MAAK,GAAGF;gBAC3B,OAAO;oBAAC,GAAGE,IAAI;oBAAEC,MAAMF;gBAAO;YAChC;QACA,KA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AMsB,OAAOpB,QAAQoC,OAAOf,KAAK;IACjC,IAAI;QACF,MAAMhB,iBAAiB;YACrBwB;YACAE;YACA,+EAA+E;YAC/EkB,YAAY9C,iBAAiB2B,KAAK;gBAACoB,UAAUT;gBAAOR;YAAK,GAAGkB,GAAG,CAAC,CAAC1C,QAC/DD,iBAAiBC;YAEnByB;YACAG;YACAQ;YACAH;YACAE;QACF;QACAN;QACA,IAAI;YACF,MAAM/B,kBAAkBwB,eAAe;gBACrCU;gBACA,GAAIT,OAAO;oBAACA;gBAAI,IAAI,CAAC,CAAC;gBACtB,GAAIO,OAAO;oBAACA;gBAAI,IAAI,CAAC,CAAC;gBACtB,GAAII,aAAa;oBAACA;gBAAU,IAAI,CAAC,CAAC;YACpC;QACF,EAAE,OAAOlB,OAAO;YACd,MAAM2B,gBAAgB3B,OAAOc;QAC/B;QACAnB,KAAKG,OAAO;IACd,EAAE,OAAOE,OAAO;QACdL,KAAKiC,KAAK;QACV,MAAM5B;IACR;AACF;AAEA;;;;;CAKC,GACD,SAAS2B,gBAAgB3B,KAAc,EAAEc,IAAwB;IAC/D,MAAMe,aAAc7B,OAAiC6B;IACrD,IAAI,CAACf,QAAQe,eAAeR,aAAaQ,aAAa,OAAOA,cAAc,KAAK,OAAO7B;IACvF,OAAO,IAAI8B,MACT,CAAC,MAAM,EAAEhB,KAAK,gBAAgB,EAAExC,gBAAgB0B,OAAO,oHAAoH,CAAC,EAC5K;QAAC+B,OAAO/B;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 {type ImageFile} from '@sanity/cli-core/images'\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 removeApplicationIcon,\n setApplicationIcon,\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): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return declaration\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'panel': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'window': {\n const {surface, ...view} = declaration\n return {...view, type: 'app'}\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 `slug`/`visibility` when set)\n * and its icon from config. The deploy endpoint ignores these, so a redeploy\n * patches them here alongside the new deployment. No `icon` removes the\n * application's icon.\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?: ImageFile\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),\n ),\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n })\n onDeployed?.()\n try {\n await updateApplication(applicationId, {\n title,\n ...(slug ? {slug} : {}),\n ...(visibility ? {visibility} : {}),\n })\n } catch (error) {\n throw toSlugRejection(error, slug)\n }\n if (icon) {\n try {\n await setApplicationIcon(applicationId, icon)\n } catch (error) {\n throw toIconRejection(error)\n }\n } else {\n await removeApplicationIcon(applicationId)\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\n/** A 4xx on the icon upload is the image being rejected; name the server's reason. */\nfunction toIconRejection(error: unknown): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `The app icon was rejected: ${getErrorMessage(error)}. The deployment is live with the application's previous icon. Change \\`app.icon\\` 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","removeApplicationIcon","setApplicationIcon","updateApplication","toBrettInterface","iface","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","version","visibility","workspaces","tarball","undefined","cwd","pipe","interfaces","appTitle","map","toSlugRejection","toIconRejection","clear","statusCode","Error","cause"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,UAAU,QAAO,YAAW;AAGpC,SAAQC,eAAe,QAAO,0BAAyB;AAEvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAA+BC,gBAAgB,QAAO,4BAA2B;AACjF,SAKEC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,qBAAqB,EACrBC,kBAAkB,EAClBC,iBAA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B;QACAX,KAAKG,OAAO;IACd,EAAE,OAAOE,OAAO;QACdL,KAAKkC,KAAK;QACV,MAAM7B;IACR;AACF;AAEA;;;;;CAKC,GACD,SAAS2B,gBAAgB3B,KAAc,EAAEc,IAAwB;IAC/D,MAAMgB,aAAc9B,OAAiC8B;IACrD,IAAI,CAAChB,QAAQgB,eAAeT,aAAaS,aAAa,OAAOA,cAAc,KAAK,OAAO9B;IACvF,OAAO,IAAI+B,MACT,CAAC,MAAM,EAAEjB,KAAK,gBAAgB,EAAE1C,gBAAgB4B,OAAO,oHAAoH,CAAC,EAC5K;QAACgC,OAAOhC;IAAK;AAEjB;AAEA,oFAAoF,GACpF,SAAS4B,gBAAgB5B,KAAc;IACrC,MAAM8B,aAAc9B,OAAiC8B;IACrD,IAAIA,eAAeT,aAAaS,aAAa,OAAOA,cAAc,KAAK,OAAO9B;IAC9E,OAAO,IAAI+B,MACT,CAAC,2BAA2B,EAAE3D,gBAAgB4B,OAAO,qHAAqH,CAAC,EAC3K;QAACgC,OAAOhC;IAAK;AAEjB"}
|
|
@@ -34,7 +34,9 @@ const noop = async ()=>{};
|
|
|
34
34
|
const freshConfig = await getCliConfigUncached(workDir);
|
|
35
35
|
await closeCurrent();
|
|
36
36
|
closeCurrent = noop;
|
|
37
|
-
const result = await start(freshConfig
|
|
37
|
+
const result = await start(freshConfig, {
|
|
38
|
+
isRestarting: true
|
|
39
|
+
});
|
|
38
40
|
if (!result.started) {
|
|
39
41
|
// The server already reported why (e.g. organizationId was removed).
|
|
40
42
|
throw new Error('Dev server did not restart after the view/web worker change');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/dev/appServerSupervisor.ts"],"sourcesContent":["import {type CliConfig, getCliConfigUncached} from '@sanity/cli-core'\nimport {type ViteDevServer} from 'vite'\n\n/**\n * Minimal shape the supervisor needs back from a started app/studio dev server.\n * The not-started arm is reserved for expected early exits the server already\n * reported (e.g. a missing organization id) — a failure to *boot* still throws.\n */\nexport type AppServerResult =\n | {close: () => Promise<void>; server: ViteDevServer; started: true}\n | {reason: string; started: false}\n\n/** Start the app/studio dev server for a given config (port + URL intent baked in by the caller). */\nexport type StartAppServer = (cliConfig: CliConfig) => Promise<AppServerResult>\n\nconst noop = async () => {}\n\nexport interface AppServerSupervisor {\n /** Stop the server once, waiting out any rebuild already in flight. */\n close: () => Promise<void>\n /** Tear down the running server and bring it back up with a freshly-loaded config. */\n rebuild: () => Promise<ViteDevServer>\n /** The currently-live dev server; re-points after a rebuild. */\n readonly server: ViteDevServer\n}\n\n/**\n * Own the app/studio dev server's lifecycle behind the dev-server registry seam.\n *\n * Adding or removing a view/web worker rebuilds the federation remote: its\n * module-federation `exposes` map and codegen artifacts are computed once at\n * server start, so a newly-declared interface has no expose until the server is\n * recreated — `server.restart()` can't do it (it reuses the inline config).\n * `rebuild` therefore tears the server down and starts a fresh one with a\n * reloaded config; the registry watcher calls it when the interface set changes.\n *\n * Returns the not-started result verbatim when the initial boot is an expected\n * early exit, so the caller can skip the rest of the orchestration.\n */\nexport async function startAppServerSupervisor(options: {\n cliConfig: CliConfig\n start: StartAppServer\n workDir: string\n}): Promise<{reason: string; started: false} | {started: true; supervisor: AppServerSupervisor}> {\n const {cliConfig, start, workDir} = options\n\n const initial = await start(cliConfig)\n if (!initial.started) return {reason: initial.reason, started: false}\n\n // `closeCurrent` repoints at the replacement only once a rebuild succeeds, so a\n // failed rebuild (old server already closed) leaves nothing for close() to re-close.\n let server = initial.server\n let closeCurrent = initial.close\n let closed = false\n // close() waits on this so a rebuild racing teardown can't orphan the replacement.\n // Rejections are the watcher's (warn + retry); the tracked copy is swallowed.\n let rebuildInFlight: Promise<unknown> = Promise.resolve()\n\n const runRebuild = async (): Promise<ViteDevServer> => {\n // Refuse once shutting down — a config save in the teardown window must not\n // boot a replacement nobody owns.\n if (closed) throw new Error('Dev server is shutting down')\n const freshConfig = await getCliConfigUncached(workDir)\n await closeCurrent()\n closeCurrent = noop\n const result = await start(freshConfig)\n if (!result.started) {\n // The server already reported why (e.g. organizationId was removed).\n throw new Error('Dev server did not restart after the view/web worker change')\n }\n server = result.server\n closeCurrent = result.close\n return server\n }\n\n return {\n started: true,\n supervisor: {\n async close() {\n closed = true\n await rebuildInFlight\n await closeCurrent()\n },\n rebuild() {\n const rebuild = runRebuild()\n rebuildInFlight = rebuild.catch(() => {})\n return rebuild\n },\n get server() {\n return server\n },\n },\n }\n}\n"],"names":["getCliConfigUncached","noop","startAppServerSupervisor","options","cliConfig","start","workDir","initial","started","reason","server","closeCurrent","close","closed","rebuildInFlight","Promise","resolve","runRebuild","Error","freshConfig","result","supervisor","rebuild","catch"],"mappings":"AAAA,SAAwBA,oBAAoB,QAAO,mBAAkB;
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/dev/appServerSupervisor.ts"],"sourcesContent":["import {type CliConfig, getCliConfigUncached} from '@sanity/cli-core'\nimport {type ViteDevServer} from 'vite'\n\n/**\n * Minimal shape the supervisor needs back from a started app/studio dev server.\n * The not-started arm is reserved for expected early exits the server already\n * reported (e.g. a missing organization id) — a failure to *boot* still throws.\n */\nexport type AppServerResult =\n | {close: () => Promise<void>; server: ViteDevServer; started: true}\n | {reason: string; started: false}\n\n/** Start the app/studio dev server for a given config (port + URL intent baked in by the caller). */\nexport type StartAppServer = (\n cliConfig: CliConfig,\n options?: {isRestarting?: boolean},\n) => Promise<AppServerResult>\n\nconst noop = async () => {}\n\nexport interface AppServerSupervisor {\n /** Stop the server once, waiting out any rebuild already in flight. */\n close: () => Promise<void>\n /** Tear down the running server and bring it back up with a freshly-loaded config. */\n rebuild: () => Promise<ViteDevServer>\n /** The currently-live dev server; re-points after a rebuild. */\n readonly server: ViteDevServer\n}\n\n/**\n * Own the app/studio dev server's lifecycle behind the dev-server registry seam.\n *\n * Adding or removing a view/web worker rebuilds the federation remote: its\n * module-federation `exposes` map and codegen artifacts are computed once at\n * server start, so a newly-declared interface has no expose until the server is\n * recreated — `server.restart()` can't do it (it reuses the inline config).\n * `rebuild` therefore tears the server down and starts a fresh one with a\n * reloaded config; the registry watcher calls it when the interface set changes.\n *\n * Returns the not-started result verbatim when the initial boot is an expected\n * early exit, so the caller can skip the rest of the orchestration.\n */\nexport async function startAppServerSupervisor(options: {\n cliConfig: CliConfig\n start: StartAppServer\n workDir: string\n}): Promise<{reason: string; started: false} | {started: true; supervisor: AppServerSupervisor}> {\n const {cliConfig, start, workDir} = options\n\n const initial = await start(cliConfig)\n if (!initial.started) return {reason: initial.reason, started: false}\n\n // `closeCurrent` repoints at the replacement only once a rebuild succeeds, so a\n // failed rebuild (old server already closed) leaves nothing for close() to re-close.\n let server = initial.server\n let closeCurrent = initial.close\n let closed = false\n // close() waits on this so a rebuild racing teardown can't orphan the replacement.\n // Rejections are the watcher's (warn + retry); the tracked copy is swallowed.\n let rebuildInFlight: Promise<unknown> = Promise.resolve()\n\n const runRebuild = async (): Promise<ViteDevServer> => {\n // Refuse once shutting down — a config save in the teardown window must not\n // boot a replacement nobody owns.\n if (closed) throw new Error('Dev server is shutting down')\n const freshConfig = await getCliConfigUncached(workDir)\n await closeCurrent()\n closeCurrent = noop\n const result = await start(freshConfig, {isRestarting: true})\n if (!result.started) {\n // The server already reported why (e.g. organizationId was removed).\n throw new Error('Dev server did not restart after the view/web worker change')\n }\n server = result.server\n closeCurrent = result.close\n return server\n }\n\n return {\n started: true,\n supervisor: {\n async close() {\n closed = true\n await rebuildInFlight\n await closeCurrent()\n },\n rebuild() {\n const rebuild = runRebuild()\n rebuildInFlight = rebuild.catch(() => {})\n return rebuild\n },\n get server() {\n return server\n },\n },\n }\n}\n"],"names":["getCliConfigUncached","noop","startAppServerSupervisor","options","cliConfig","start","workDir","initial","started","reason","server","closeCurrent","close","closed","rebuildInFlight","Promise","resolve","runRebuild","Error","freshConfig","result","isRestarting","supervisor","rebuild","catch"],"mappings":"AAAA,SAAwBA,oBAAoB,QAAO,mBAAkB;AAkBrE,MAAMC,OAAO,WAAa;AAW1B;;;;;;;;;;;;CAYC,GACD,OAAO,eAAeC,yBAAyBC,OAI9C;IACC,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGH;IAEpC,MAAMI,UAAU,MAAMF,MAAMD;IAC5B,IAAI,CAACG,QAAQC,OAAO,EAAE,OAAO;QAACC,QAAQF,QAAQE,MAAM;QAAED,SAAS;IAAK;IAEpE,gFAAgF;IAChF,qFAAqF;IACrF,IAAIE,SAASH,QAAQG,MAAM;IAC3B,IAAIC,eAAeJ,QAAQK,KAAK;IAChC,IAAIC,SAAS;IACb,mFAAmF;IACnF,8EAA8E;IAC9E,IAAIC,kBAAoCC,QAAQC,OAAO;IAEvD,MAAMC,aAAa;QACjB,4EAA4E;QAC5E,kCAAkC;QAClC,IAAIJ,QAAQ,MAAM,IAAIK,MAAM;QAC5B,MAAMC,cAAc,MAAMnB,qBAAqBM;QAC/C,MAAMK;QACNA,eAAeV;QACf,MAAMmB,SAAS,MAAMf,MAAMc,aAAa;YAACE,cAAc;QAAI;QAC3D,IAAI,CAACD,OAAOZ,OAAO,EAAE;YACnB,qEAAqE;YACrE,MAAM,IAAIU,MAAM;QAClB;QACAR,SAASU,OAAOV,MAAM;QACtBC,eAAeS,OAAOR,KAAK;QAC3B,OAAOF;IACT;IAEA,OAAO;QACLF,SAAS;QACTc,YAAY;YACV,MAAMV;gBACJC,SAAS;gBACT,MAAMC;gBACN,MAAMH;YACR;YACAY;gBACE,MAAMA,UAAUN;gBAChBH,kBAAkBS,QAAQC,KAAK,CAAC,KAAO;gBACvC,OAAOD;YACT;YACA,IAAIb;gBACF,OAAOA;YACT;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { emitKeypressEvents } from 'node:readline';
|
|
2
|
+
import { styleText } from 'node:util';
|
|
3
|
+
import open from 'open';
|
|
4
|
+
export function bindDevShortcuts({ output, quit, url }) {
|
|
5
|
+
const { stdin } = process;
|
|
6
|
+
if (!stdin.isTTY) return async ()=>{};
|
|
7
|
+
const onKeypress = (_, key = {})=>{
|
|
8
|
+
const isWindows = process.platform === 'win32';
|
|
9
|
+
if (key.ctrl && key.name === 'c' && !isWindows) {
|
|
10
|
+
// Raw mode stops the terminal from signalling the process group, so the parent (pnpm) needs it too.
|
|
11
|
+
process.kill(0, 'SIGINT');
|
|
12
|
+
} else if (key.name === 'q' || key.ctrl && (key.name === 'c' || key.name === 'd')) {
|
|
13
|
+
quit();
|
|
14
|
+
} else if (key.ctrl && key.name === 'z' && !isWindows) {
|
|
15
|
+
stdin.setRawMode(false);
|
|
16
|
+
process.once('SIGCONT', ()=>stdin.setRawMode(true));
|
|
17
|
+
process.kill(0, 'SIGTSTP');
|
|
18
|
+
} else if (key.name === 'o') {
|
|
19
|
+
open(url).catch((err)=>output.warn(`Could not open ${url}: ${err.message}`));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
emitKeypressEvents(stdin);
|
|
23
|
+
stdin.setRawMode(true);
|
|
24
|
+
stdin.on('keypress', onKeypress);
|
|
25
|
+
output.log(` ${styleText('dim', 'press')} o ${styleText('dim', 'to open ·')} q ${styleText('dim', 'to quit')}\n`);
|
|
26
|
+
return async ()=>{
|
|
27
|
+
stdin.off('keypress', onKeypress);
|
|
28
|
+
stdin.setRawMode(false);
|
|
29
|
+
stdin.pause();
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=bindDevShortcuts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/dev/bindDevShortcuts.ts"],"sourcesContent":["import {emitKeypressEvents, type Key} from 'node:readline'\nimport {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\nimport open from 'open'\n\nexport function bindDevShortcuts({\n output,\n quit,\n url,\n}: {\n output: Output\n quit: () => void\n url: string\n}): () => Promise<void> {\n const {stdin} = process\n if (!stdin.isTTY) return async () => {}\n\n const onKeypress = (_: string | undefined, key: Key = {}) => {\n const isWindows = process.platform === 'win32'\n\n if (key.ctrl && key.name === 'c' && !isWindows) {\n // Raw mode stops the terminal from signalling the process group, so the parent (pnpm) needs it too.\n process.kill(0, 'SIGINT')\n } else if (key.name === 'q' || (key.ctrl && (key.name === 'c' || key.name === 'd'))) {\n quit()\n } else if (key.ctrl && key.name === 'z' && !isWindows) {\n stdin.setRawMode(false)\n process.once('SIGCONT', () => stdin.setRawMode(true))\n process.kill(0, 'SIGTSTP')\n } else if (key.name === 'o') {\n open(url).catch((err) => output.warn(`Could not open ${url}: ${err.message}`))\n }\n }\n\n emitKeypressEvents(stdin)\n stdin.setRawMode(true)\n stdin.on('keypress', onKeypress)\n output.log(\n ` ${styleText('dim', 'press')} o ${styleText('dim', 'to open ·')} q ${styleText('dim', 'to quit')}\\n`,\n )\n\n return async () => {\n stdin.off('keypress', onKeypress)\n stdin.setRawMode(false)\n stdin.pause()\n }\n}\n"],"names":["emitKeypressEvents","styleText","open","bindDevShortcuts","output","quit","url","stdin","process","isTTY","onKeypress","_","key","isWindows","platform","ctrl","name","kill","setRawMode","once","catch","err","warn","message","on","log","off","pause"],"mappings":"AAAA,SAAQA,kBAAkB,QAAiB,gBAAe;AAC1D,SAAQC,SAAS,QAAO,YAAW;AAGnC,OAAOC,UAAU,OAAM;AAEvB,OAAO,SAASC,iBAAiB,EAC/BC,MAAM,EACNC,IAAI,EACJC,GAAG,EAKJ;IACC,MAAM,EAACC,KAAK,EAAC,GAAGC;IAChB,IAAI,CAACD,MAAME,KAAK,EAAE,OAAO,WAAa;IAEtC,MAAMC,aAAa,CAACC,GAAuBC,MAAW,CAAC,CAAC;QACtD,MAAMC,YAAYL,QAAQM,QAAQ,KAAK;QAEvC,IAAIF,IAAIG,IAAI,IAAIH,IAAII,IAAI,KAAK,OAAO,CAACH,WAAW;YAC9C,oGAAoG;YACpGL,QAAQS,IAAI,CAAC,GAAG;QAClB,OAAO,IAAIL,IAAII,IAAI,KAAK,OAAQJ,IAAIG,IAAI,IAAKH,CAAAA,IAAII,IAAI,KAAK,OAAOJ,IAAII,IAAI,KAAK,GAAE,GAAK;YACnFX;QACF,OAAO,IAAIO,IAAIG,IAAI,IAAIH,IAAII,IAAI,KAAK,OAAO,CAACH,WAAW;YACrDN,MAAMW,UAAU,CAAC;YACjBV,QAAQW,IAAI,CAAC,WAAW,IAAMZ,MAAMW,UAAU,CAAC;YAC/CV,QAAQS,IAAI,CAAC,GAAG;QAClB,OAAO,IAAIL,IAAII,IAAI,KAAK,KAAK;YAC3Bd,KAAKI,KAAKc,KAAK,CAAC,CAACC,MAAQjB,OAAOkB,IAAI,CAAC,CAAC,eAAe,EAAEhB,IAAI,EAAE,EAAEe,IAAIE,OAAO,EAAE;QAC9E;IACF;IAEAvB,mBAAmBO;IACnBA,MAAMW,UAAU,CAAC;IACjBX,MAAMiB,EAAE,CAAC,YAAYd;IACrBN,OAAOqB,GAAG,CACR,CAAC,EAAE,EAAExB,UAAU,OAAO,SAAS,GAAG,EAAEA,UAAU,OAAO,aAAa,GAAG,EAAEA,UAAU,OAAO,WAAW,EAAE,CAAC;IAGxG,OAAO;QACLM,MAAMmB,GAAG,CAAC,YAAYhB;QACtBH,MAAMW,UAAU,CAAC;QACjBX,MAAMoB,KAAK;IACb;AACF"}
|
|
@@ -58,7 +58,7 @@ import { resolveWorkbenchConfig } from '../../resolveWorkbenchConfig.js';
|
|
|
58
58
|
* and the browser. `node:crypto` can't be used: the Vite dev server's dep scan
|
|
59
59
|
* pulls this module into the browser graph.
|
|
60
60
|
*/ async function contentHash(input) {
|
|
61
|
-
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- the Web Crypto global is available on our Node target and in the browser
|
|
61
|
+
// eslint-disable-next-line n-js/no-unsupported-features/node-builtins -- the Web Crypto global is available on our Node target and in the browser
|
|
62
62
|
const digest = await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(input));
|
|
63
63
|
return Array.from(new Uint8Array(digest), (byte)=>byte.toString(16).padStart(2, '0')).join('');
|
|
64
64
|
}
|