@sanity/workbench-cli 2.19.0 → 2.20.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/build.d.ts +1 -1
- package/dist/_exports/{contract-WrU3aOYd.d.ts → contract-BeAds4Yi.d.ts} +21 -17
- package/dist/_exports/{defineApp-vbUu_rBA.d.ts → defineApp-DSXAAr3V.d.ts} +4 -2
- package/dist/_exports/deploy.d.ts +7 -6
- package/dist/_exports/dev.d.ts +1 -1
- package/dist/_exports/index.d.ts +3 -3
- package/dist/_exports/index.js.map +1 -1
- package/dist/_exports/preview.d.ts +1 -1
- package/dist/_exports/{registry-CbruhmxE.d.ts → registry-BI8kZVpy.d.ts} +8 -6
- package/dist/_exports/{resolveWorkbenchConfig-JRi01VJM.d.ts → resolveWorkbenchConfig-Eex64aAA.d.ts} +3 -3
- package/dist/_exports/{summarizeInterfaces-DGh6ARce.d.ts → summarizeInterfaces-BKIMEFzw.d.ts} +3 -3
- package/dist/_exports/undeploy.d.ts +2 -2
- package/dist/actions/build/autoUpdatesLoader.js +3 -1
- package/dist/actions/build/autoUpdatesLoader.js.map +1 -1
- package/dist/actions/deploy/deployWorkbenchApp.js +31 -13
- package/dist/actions/deploy/deployWorkbenchApp.js.map +1 -1
- package/dist/actions/dev/startDevServerRegistration.js +11 -6
- package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
- package/dist/actions/preview/serveBuiltApplication.js +9 -7
- package/dist/actions/preview/serveBuiltApplication.js.map +1 -1
- package/dist/actions/preview/startWorkbenchPreview.js +13 -8
- package/dist/actions/preview/startWorkbenchPreview.js.map +1 -1
- package/dist/contract.js +6 -3
- package/dist/contract.js.map +1 -1
- package/dist/defineApp.js.map +1 -1
- package/dist/deriveInterfaces.js +22 -11
- package/dist/deriveInterfaces.js.map +1 -1
- package/dist/readAppIcon.js +3 -3
- package/dist/readAppIcon.js.map +1 -1
- package/dist/services/applications.js +11 -0
- package/dist/services/applications.js.map +1 -1
- package/package.json +1 -1
package/dist/_exports/build.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveAppEntry, i as WorkbenchExposes, n as resolveWorkbenchConfig, o as resolveWorkbenchApp, r as ResolvedWorkbenchApp, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-
|
|
1
|
+
import { a as resolveAppEntry, i as WorkbenchExposes, n as resolveWorkbenchConfig, o as resolveWorkbenchApp, r as ResolvedWorkbenchApp, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-Eex64aAA.js";
|
|
2
2
|
import { InlineConfig, PluginOption } from "vite";
|
|
3
3
|
/**
|
|
4
4
|
* Resolves to the parsed federation manifest in `sourceDir`. A workbench build
|
|
@@ -51,17 +51,18 @@ declare const PanelViewSchema: z.ZodMiniObject<{
|
|
|
51
51
|
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
52
52
|
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
53
53
|
}, z.core.$strip>>;
|
|
54
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
54
55
|
title: z.ZodMiniString<string>;
|
|
55
56
|
name: z.ZodMiniString<string>;
|
|
56
57
|
src: z.ZodMiniString<string>;
|
|
57
58
|
surface: z.ZodMiniLiteral<"panel">;
|
|
58
59
|
}, z.core.$strip>;
|
|
59
60
|
/** @public */
|
|
60
|
-
type
|
|
61
|
+
type PanelViewDeclaration = z.output<typeof PanelViewSchema>;
|
|
61
62
|
/** @public */
|
|
62
|
-
type DefinePanelViewInput = Omit<
|
|
63
|
+
type DefinePanelViewInput = Omit<PanelViewDeclaration, 'surface'>;
|
|
63
64
|
/** @public */
|
|
64
|
-
declare function definePanelView(view: DefinePanelViewInput):
|
|
65
|
+
declare function definePanelView(view: DefinePanelViewInput): PanelViewDeclaration;
|
|
65
66
|
declare const WindowViewSchema: z.ZodMiniObject<{
|
|
66
67
|
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
67
68
|
group: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
@@ -70,17 +71,18 @@ declare const WindowViewSchema: z.ZodMiniObject<{
|
|
|
70
71
|
}>>;
|
|
71
72
|
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
72
73
|
}, z.core.$strip>>;
|
|
74
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
73
75
|
title: z.ZodMiniString<string>;
|
|
74
76
|
name: z.ZodMiniString<string>;
|
|
75
77
|
src: z.ZodMiniString<string>;
|
|
76
78
|
surface: z.ZodMiniLiteral<"window">;
|
|
77
79
|
}, z.core.$strip>;
|
|
78
80
|
/** @public */
|
|
79
|
-
type
|
|
81
|
+
type WindowViewDeclaration = z.output<typeof WindowViewSchema>;
|
|
80
82
|
/** @public */
|
|
81
|
-
type DefineWindowViewInput = Omit<
|
|
83
|
+
type DefineWindowViewInput = Omit<WindowViewDeclaration, 'surface'>;
|
|
82
84
|
/** @public */
|
|
83
|
-
declare function defineWindowView(view: DefineWindowViewInput):
|
|
85
|
+
declare function defineWindowView(view: DefineWindowViewInput): WindowViewDeclaration;
|
|
84
86
|
declare const AssetSourceViewSchema: z.ZodMiniObject<{
|
|
85
87
|
title: z.ZodMiniString<string>;
|
|
86
88
|
name: z.ZodMiniString<string>;
|
|
@@ -88,11 +90,11 @@ declare const AssetSourceViewSchema: z.ZodMiniObject<{
|
|
|
88
90
|
surface: z.ZodMiniLiteral<"asset_source">;
|
|
89
91
|
}, z.core.$strip>;
|
|
90
92
|
/** @public */
|
|
91
|
-
type
|
|
93
|
+
type AssetSourceViewDeclaration = z.output<typeof AssetSourceViewSchema>;
|
|
92
94
|
/** @public */
|
|
93
|
-
type DefineAssetSourceViewInput = Omit<
|
|
95
|
+
type DefineAssetSourceViewInput = Omit<AssetSourceViewDeclaration, 'surface'>;
|
|
94
96
|
/** @public */
|
|
95
|
-
declare function defineAssetSourceView(view: DefineAssetSourceViewInput):
|
|
97
|
+
declare function defineAssetSourceView(view: DefineAssetSourceViewInput): AssetSourceViewDeclaration;
|
|
96
98
|
declare const TileViewSchema: z.ZodMiniObject<{
|
|
97
99
|
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
98
100
|
size: z.ZodMiniEnum<{
|
|
@@ -106,11 +108,11 @@ declare const TileViewSchema: z.ZodMiniObject<{
|
|
|
106
108
|
surface: z.ZodMiniLiteral<"tile">;
|
|
107
109
|
}, z.core.$strip>;
|
|
108
110
|
/** @public */
|
|
109
|
-
type
|
|
111
|
+
type TileViewDeclaration = z.output<typeof TileViewSchema>;
|
|
110
112
|
/** @public */
|
|
111
|
-
type DefineTileViewInput = Omit<
|
|
113
|
+
type DefineTileViewInput = Omit<TileViewDeclaration, 'surface'>;
|
|
112
114
|
/** @public */
|
|
113
|
-
declare function defineTileView(view: DefineTileViewInput):
|
|
115
|
+
declare function defineTileView(view: DefineTileViewInput): TileViewDeclaration;
|
|
114
116
|
/** @internal */
|
|
115
117
|
declare const InterfaceDeclarationSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
116
118
|
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
@@ -120,6 +122,7 @@ declare const InterfaceDeclarationSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMini
|
|
|
120
122
|
}>>;
|
|
121
123
|
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
122
124
|
}, z.core.$strip>>;
|
|
125
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
123
126
|
title: z.ZodMiniString<string>;
|
|
124
127
|
name: z.ZodMiniString<string>;
|
|
125
128
|
src: z.ZodMiniString<string>;
|
|
@@ -128,6 +131,7 @@ declare const InterfaceDeclarationSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMini
|
|
|
128
131
|
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
129
132
|
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
130
133
|
}, z.core.$strip>>;
|
|
134
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
131
135
|
title: z.ZodMiniString<string>;
|
|
132
136
|
name: z.ZodMiniString<string>;
|
|
133
137
|
src: z.ZodMiniString<string>;
|
|
@@ -158,11 +162,11 @@ declare const WebWorkerSchema: z.ZodMiniObject<{
|
|
|
158
162
|
type: z.ZodMiniLiteral<"worker">;
|
|
159
163
|
}, z.core.$strip>;
|
|
160
164
|
/** @public */
|
|
161
|
-
type
|
|
165
|
+
type WebWorkerDeclaration = z.output<typeof WebWorkerSchema>;
|
|
162
166
|
/** @public */
|
|
163
|
-
type DefineWebWorkerInput = Omit<
|
|
167
|
+
type DefineWebWorkerInput = Omit<WebWorkerDeclaration, 'type'>;
|
|
164
168
|
/** @public */
|
|
165
|
-
declare function defineWebWorker(webWorker: DefineWebWorkerInput):
|
|
169
|
+
declare function defineWebWorker(webWorker: DefineWebWorkerInput): WebWorkerDeclaration;
|
|
166
170
|
/**
|
|
167
171
|
* A workbench config's built value, keyed by `appType`; deploys as a versioned
|
|
168
172
|
* snapshot, not an interface.
|
|
@@ -183,5 +187,5 @@ declare const ConfigSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
|
183
187
|
* @internal
|
|
184
188
|
*/
|
|
185
189
|
type WorkbenchConfigValue = z.output<typeof ConfigSchema>;
|
|
186
|
-
export { defineTileView as C, definePanelView as S, defineWindowView as T,
|
|
187
|
-
//# sourceMappingURL=contract-
|
|
190
|
+
export { defineTileView as C, definePanelView as S, defineWindowView as T, WebWorkerDeclaration as _, DefineWebWorkerInput as a, WorkbenchConfigValue as b, PanelViewDeclaration as c, TileViewDeclaration as d, ViewComponent as f, WEB_WORKER_CONTRACT_VERSION as g, ViewSurface as h, DefineTileViewInput as i, ServiceType as l, ViewDeclaration as m, DefineAssetSourceViewInput as n, DefineWindowViewInput as o, ViewComponentBaseProps as p, DefinePanelViewInput as r, DockGroup as s, AssetSourceViewDeclaration as t, TileSize as u, WebWorkerType as v, defineWebWorker as w, defineAssetSourceView as x, WindowViewDeclaration as y };
|
|
191
|
+
//# sourceMappingURL=contract-BeAds4Yi.d.ts.map
|
|
@@ -32,6 +32,7 @@ declare const DefineAppInputSchema: z.ZodMiniObject<{
|
|
|
32
32
|
}>>;
|
|
33
33
|
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
34
34
|
}, z.core.$strip>>;
|
|
35
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
35
36
|
title: z.ZodMiniString<string>;
|
|
36
37
|
name: z.ZodMiniString<string>;
|
|
37
38
|
src: z.ZodMiniString<string>;
|
|
@@ -40,6 +41,7 @@ declare const DefineAppInputSchema: z.ZodMiniObject<{
|
|
|
40
41
|
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
41
42
|
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
42
43
|
}, z.core.$strip>>;
|
|
44
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
45
|
title: z.ZodMiniString<string>;
|
|
44
46
|
name: z.ZodMiniString<string>;
|
|
45
47
|
src: z.ZodMiniString<string>;
|
|
@@ -91,7 +93,7 @@ declare const WORKBENCH_APP: unique symbol;
|
|
|
91
93
|
* input plus the internal brand — users only ever see `DefineAppInput`.
|
|
92
94
|
* @public
|
|
93
95
|
*/
|
|
94
|
-
type DefineAppResult = DefineAppInput & {
|
|
96
|
+
type DefineAppResult = { [K in keyof DefineAppInput]: Exclude<DefineAppInput[K], undefined>; } & {
|
|
95
97
|
readonly [WORKBENCH_APP]: true;
|
|
96
98
|
};
|
|
97
99
|
/**
|
|
@@ -172,4 +174,4 @@ declare function isWorkbenchConfig(app: unknown): app is WorkbenchConfig;
|
|
|
172
174
|
*/
|
|
173
175
|
declare function unstable_defineMediaLibrary(input: DefineMediaLibraryInput): WorkbenchConfig;
|
|
174
176
|
export { WorkbenchApp as a, isWorkbenchApp as c, MediaLibraryField as i, isWorkbenchConfig as l, DefineAppResult as n, WorkbenchConfig as o, DefineMediaLibraryInput as r, defineApplication as s, DefineAppInput as t, unstable_defineMediaLibrary as u };
|
|
175
|
-
//# sourceMappingURL=defineApp-
|
|
177
|
+
//# sourceMappingURL=defineApp-DSXAAr3V.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./contract-
|
|
2
|
-
import { n as resolveWorkbenchConfig, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-
|
|
3
|
-
import { a as DeployableWorkbenchApp, i as summarizeInterfaces, n as DeployedView, o as getWorkbench, r as DeployedWebWorker, t as DeployedInterface } from "./summarizeInterfaces-
|
|
1
|
+
import "./contract-BeAds4Yi.js";
|
|
2
|
+
import { n as resolveWorkbenchConfig, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-Eex64aAA.js";
|
|
3
|
+
import { a as DeployableWorkbenchApp, i as summarizeInterfaces, n as DeployedView, o as getWorkbench, r as DeployedWebWorker, t as DeployedInterface } from "./summarizeInterfaces-BKIMEFzw.js";
|
|
4
4
|
import { AppVisibility, CliConfig, Output } from "@sanity/cli-core";
|
|
5
5
|
import { ImageFile } from "@sanity/cli-core/images";
|
|
6
6
|
import "node:zlib";
|
|
@@ -153,7 +153,7 @@ declare function createStudio(options: {
|
|
|
153
153
|
* then sync its mutable metadata (`title`, and `slug`/`visibility` when set)
|
|
154
154
|
* and its icon from config. The deploy endpoint ignores these, so a redeploy
|
|
155
155
|
* patches them here alongside the new deployment. No `icon` removes the
|
|
156
|
-
* application's icon.
|
|
156
|
+
* application's icon. Each interface's `icon` goes on the interface Brett created for it.
|
|
157
157
|
*
|
|
158
158
|
* `onDeployed` fires the instant the deployment is live, before the metadata
|
|
159
159
|
* sync — so a caller can disarm a create-time rollback that must not delete an
|
|
@@ -183,6 +183,7 @@ declare function deployWorkbenchApp(options: {
|
|
|
183
183
|
title: string;
|
|
184
184
|
version: string;
|
|
185
185
|
visibility?: AppVisibility;
|
|
186
|
+
workDir: string;
|
|
186
187
|
workspaces?: readonly BrettWorkspace[];
|
|
187
188
|
}): Promise<void>;
|
|
188
189
|
/**
|
|
@@ -200,7 +201,7 @@ declare function selectWorkbenchAppId({ appId, flags, organizationId, type }: {
|
|
|
200
201
|
type: ApplicationType;
|
|
201
202
|
}): Promise<string | undefined>;
|
|
202
203
|
/**
|
|
203
|
-
* An app's `icon` image, read from its project.
|
|
204
|
+
* An app's or view's `icon` image, read from its project.
|
|
204
205
|
* @internal
|
|
205
206
|
*/
|
|
206
207
|
interface AppIcon extends ImageFile {
|
|
@@ -208,7 +209,7 @@ interface AppIcon extends ImageFile {
|
|
|
208
209
|
file: string;
|
|
209
210
|
}
|
|
210
211
|
/**
|
|
211
|
-
* Read the image `
|
|
212
|
+
* Read the image an `icon` path points at. The path is relative to the project
|
|
212
213
|
* root and must stay inside it.
|
|
213
214
|
* @internal
|
|
214
215
|
*/
|
package/dist/_exports/dev.d.ts
CHANGED
package/dist/_exports/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as defineTileView, S as definePanelView, T as defineWindowView, _ as
|
|
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-
|
|
1
|
+
import { C as defineTileView, S as definePanelView, T as defineWindowView, _ as WebWorkerDeclaration, a as DefineWebWorkerInput, c as PanelViewDeclaration, d as TileViewDeclaration, 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 AssetSourceViewDeclaration, u as TileSize, v as WebWorkerType, w as defineWebWorker, x as defineAssetSourceView, y as WindowViewDeclaration } from "./contract-BeAds4Yi.js";
|
|
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-DSXAAr3V.js";
|
|
3
3
|
import { WebWorkerProps, WebWorkerProps as WebWorkerProps$1 } from "@sanity/sdk/dashboard";
|
|
4
4
|
import { AssetSourceComponentProps } from "@sanity/types";
|
|
5
5
|
/** @public */
|
|
@@ -177,5 +177,5 @@ type ServiceBus = WebWorkerProps$1['bus'];
|
|
|
177
177
|
* @public
|
|
178
178
|
*/
|
|
179
179
|
type ServiceInfo = WebWorkerProps$1['worker'];
|
|
180
|
-
export { type AssetSourceComponent, type
|
|
180
|
+
export { type AssetSourceComponent, type AssetSourceViewComponents, type AssetSourceViewDeclaration, 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 PanelViewComponents, type PanelViewDeclaration, type PanelViewProps, type ServiceBus, type ServiceCallback, type ServiceContext, type ServiceInfo, type ServiceType, type TileComponent, type TileSize, type TileViewComponents, type TileViewDeclaration, type TileViewProps, type ViewComponentsBySurface, type ViewDeclaration, type ViewSurface, type WebWorkerBus, type WebWorkerDeclaration, type WebWorkerInfo, type WebWorkerProps, type WebWorkerType, type WindowViewDeclaration, type WindowViewProps, type WorkbenchApp, type WorkbenchConfig, defineApplication, defineAssetSourceView, definePanelView, defineTileView, defineWebWorker, defineWindowView, isWorkbenchApp, isWorkbenchConfig, unstable_defineMediaLibrary, unstable_defineService, unstable_defineView };
|
|
181
181
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/index.ts"],"sourcesContent":["export type {\n
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/index.ts"],"sourcesContent":["export type {\n AssetSourceViewDeclaration,\n DefineAssetSourceViewInput,\n DefinePanelViewInput,\n DefineTileViewInput,\n DefineWebWorkerInput,\n DefineWindowViewInput,\n DockGroup,\n PanelViewDeclaration,\n ServiceType,\n TileSize,\n TileViewDeclaration,\n ViewDeclaration,\n ViewSurface,\n WebWorkerDeclaration,\n WebWorkerType,\n WindowViewDeclaration,\n} from '../contract.js'\nexport {\n defineAssetSourceView,\n definePanelView,\n defineTileView,\n defineWebWorker,\n defineWindowView,\n} from '../contract.js'\nexport {\n defineApplication,\n isWorkbenchApp,\n isWorkbenchConfig,\n unstable_defineMediaLibrary,\n} from '../defineApp.js'\nexport type {\n DefineAppInput,\n DefineAppResult,\n DefineMediaLibraryInput,\n MediaLibraryField,\n WorkbenchApp,\n WorkbenchConfig,\n} from '../defineApp.js'\nexport {unstable_defineView} from '../defineView.js'\nexport type {\n AssetSourceComponent,\n AssetSourceViewComponents,\n DefinedView,\n PanelComponent,\n PanelViewComponents,\n PanelViewProps,\n TileComponent,\n TileViewComponents,\n TileViewProps,\n ViewComponentsBySurface,\n WindowViewProps,\n} from '../defineView.js'\nexport {unstable_defineService} from '../webWorker.js'\nexport type {\n DefinedService,\n ServiceBus,\n ServiceCallback,\n ServiceContext,\n ServiceInfo,\n WebWorkerBus,\n WebWorkerInfo,\n WebWorkerProps,\n} from '../webWorker.js'\n"],"names":["defineAssetSourceView","definePanelView","defineTileView","defineWebWorker","defineWindowView","defineApplication","isWorkbenchApp","isWorkbenchConfig","unstable_defineMediaLibrary","unstable_defineView","unstable_defineService"],"mappings":"AAkBA,SACEA,qBAAqB,EACrBC,eAAe,EACfC,cAAc,EACdC,eAAe,EACfC,gBAAgB,QACX,iBAAgB;AACvB,SACEC,iBAAiB,EACjBC,cAAc,EACdC,iBAAiB,EACjBC,2BAA2B,QACtB,kBAAiB;AASxB,SAAQC,mBAAmB,QAAO,mBAAkB;AAcpD,SAAQC,sBAAsB,QAAO,kBAAiB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as DevServerManifest } from "./registry-
|
|
1
|
+
import { t as DevServerManifest } from "./registry-BI8kZVpy.js";
|
|
2
2
|
import { CliConfig, Output } from "@sanity/cli-core";
|
|
3
3
|
interface StartWorkbenchPreviewOptions {
|
|
4
4
|
/** Directory for the workbench Vite server's dependency cache. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./defineApp-
|
|
1
|
+
import "./defineApp-DSXAAr3V.js";
|
|
2
2
|
import { z } from "zod/mini";
|
|
3
3
|
declare const devServerManifestSchema: z.ZodMiniObject<{
|
|
4
4
|
applicationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -19,13 +19,14 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
|
|
|
19
19
|
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
20
20
|
interfaces: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
21
21
|
metadata: z.ZodMiniNullable<z.ZodMiniObject<{
|
|
22
|
-
dock: z.ZodMiniObject<{
|
|
22
|
+
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
23
23
|
group: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
24
24
|
system: "system";
|
|
25
25
|
applications: "applications";
|
|
26
26
|
}>>;
|
|
27
27
|
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
28
|
-
}, z.core.$strip
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
29
30
|
}, z.core.$strip>>;
|
|
30
31
|
surface: z.ZodMiniLiteral<"window">;
|
|
31
32
|
id: z.ZodMiniString<string>;
|
|
@@ -36,13 +37,14 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
|
|
|
36
37
|
version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
37
38
|
}, z.core.$strip>, z.ZodMiniObject<{
|
|
38
39
|
metadata: z.ZodMiniNullable<z.ZodMiniObject<{
|
|
39
|
-
dock: z.ZodMiniObject<{
|
|
40
|
+
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
40
41
|
group: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
41
42
|
system: "system";
|
|
42
43
|
applications: "applications";
|
|
43
44
|
}>>;
|
|
44
45
|
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
45
|
-
}, z.core.$strip
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
46
48
|
}, z.core.$strip>>;
|
|
47
49
|
surface: z.ZodMiniLiteral<"panel">;
|
|
48
50
|
id: z.ZodMiniString<string>;
|
|
@@ -130,4 +132,4 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
|
|
|
130
132
|
*/
|
|
131
133
|
type DevServerManifest = z.infer<typeof devServerManifestSchema>;
|
|
132
134
|
export { DevServerManifest as t };
|
|
133
|
-
//# sourceMappingURL=registry-
|
|
135
|
+
//# sourceMappingURL=registry-BI8kZVpy.d.ts.map
|
package/dist/_exports/{resolveWorkbenchConfig-JRi01VJM.d.ts → resolveWorkbenchConfig-Eex64aAA.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as WorkbenchConfigValue } from "./contract-
|
|
2
|
-
import { t as DefineAppInput } from "./defineApp-
|
|
1
|
+
import { b as WorkbenchConfigValue } from "./contract-BeAds4Yi.js";
|
|
2
|
+
import { t as DefineAppInput } from "./defineApp-DSXAAr3V.js";
|
|
3
3
|
import { AppVisibility, CliConfig } from "@sanity/cli-core";
|
|
4
4
|
/**
|
|
5
5
|
* Bundled so adding a declaration family touches this type and the artifact
|
|
@@ -65,4 +65,4 @@ interface ResolvedMediaLibraryConfig {
|
|
|
65
65
|
*/
|
|
66
66
|
declare function resolveWorkbenchConfig(cliConfig: CliConfig | null | undefined): ResolvedMediaLibraryConfig | null;
|
|
67
67
|
export { resolveAppEntry as a, WorkbenchExposes as i, resolveWorkbenchConfig as n, resolveWorkbenchApp as o, ResolvedWorkbenchApp as r, ResolvedMediaLibraryConfig as t };
|
|
68
|
-
//# sourceMappingURL=resolveWorkbenchConfig-
|
|
68
|
+
//# sourceMappingURL=resolveWorkbenchConfig-Eex64aAA.d.ts.map
|
package/dist/_exports/{summarizeInterfaces-DGh6ARce.d.ts → summarizeInterfaces-BKIMEFzw.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as ViewSurface, v as WebWorkerType } from "./contract-
|
|
2
|
-
import { i as WorkbenchExposes, r as ResolvedWorkbenchApp } from "./resolveWorkbenchConfig-
|
|
1
|
+
import { h as ViewSurface, v as WebWorkerType } from "./contract-BeAds4Yi.js";
|
|
2
|
+
import { i as WorkbenchExposes, r as ResolvedWorkbenchApp } from "./resolveWorkbenchConfig-Eex64aAA.js";
|
|
3
3
|
import { CliConfig } from "@sanity/cli-core";
|
|
4
4
|
import { z } from "zod/mini";
|
|
5
5
|
/**
|
|
@@ -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-BKIMEFzw.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-
|
|
2
|
-
import { a as DeployableWorkbenchApp, n as DeployedView, r as DeployedWebWorker } from "./summarizeInterfaces-
|
|
1
|
+
import { t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-Eex64aAA.js";
|
|
2
|
+
import { a as DeployableWorkbenchApp, n as DeployedView, r as DeployedWebWorker } from "./summarizeInterfaces-BKIMEFzw.js";
|
|
3
3
|
import "node:zlib";
|
|
4
4
|
import { UndeployAdapter, UndeployApplicationTarget, UndeployConfigTarget } from "@sanity/cli-core/undeploy";
|
|
5
5
|
interface ConfigSnapshot {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const TIMESTAMP = /(\/(?:by-app|default)\/[^/]+)\/t\d+/;
|
|
2
|
+
// The Studio team decides the final bucket size.
|
|
3
|
+
const TIMESTAMP_BUCKET_SECONDS = 60;
|
|
2
4
|
// Loads the app's auto-updated packages from the module server as its own copy.
|
|
3
5
|
export function createAutoUpdatesLoader({ appId, cssUrls, imports, specifiers, vendor }) {
|
|
4
6
|
// The build's timestamp would pin the versions the module CDN served on build day.
|
|
5
|
-
const timestamp = `/t${Math.floor(Date.now() / 1000)}`;
|
|
7
|
+
const timestamp = `/t${Math.floor(Date.now() / 1000 / TIMESTAMP_BUCKET_SECONDS) * TIMESTAMP_BUCKET_SECONDS}`;
|
|
6
8
|
const currentImports = Object.fromEntries(Object.entries(imports).map(([specifier, url])=>[
|
|
7
9
|
specifier,
|
|
8
10
|
url.replace(TIMESTAMP, `$1${timestamp}`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/autoUpdatesLoader.ts"],"sourcesContent":["type Module = Record<string, unknown>\n\n// Workbench's `load`, contract version 1: it loads every specifier as the app's own copy, with its\n// app ID and vendor modules, and links the stylesheets.\ntype Load = (\n appId: string,\n request: {\n imports: Record<string, string>\n specifiers: string[]\n styles: string[]\n vendor: Record<string, () => Promise<Module>>\n },\n) => Promise<{modules: Record<string, Module>}>\n\ninterface AutoUpdatesLoaderOptions {\n appId: string\n cssUrls: string[]\n imports: Record<string, string>\n specifiers: string[]\n vendor: Record<string, () => Promise<Module>>\n}\n\nconst TIMESTAMP = /(\\/(?:by-app|default)\\/[^/]+)\\/t\\d+/\n\n// Loads the app's auto-updated packages from the module server as its own copy.\nexport function createAutoUpdatesLoader({\n appId,\n cssUrls,\n imports,\n specifiers,\n vendor,\n}: AutoUpdatesLoaderOptions) {\n // The build's timestamp would pin the versions the module CDN served on build day.\n const timestamp = `/t${Math.floor(Date.now() / 1000)}`\n const currentImports = Object.fromEntries(\n Object.entries(imports).map(([specifier, url]) => [\n specifier,\n url.replace(TIMESTAMP, `$1${timestamp}`),\n ]),\n )\n let modules: Record<string, Module> | undefined\n let ready: Promise<void> | undefined\n\n return {\n importMapUrl: (specifier: string) => (modules ? currentImports[specifier] : undefined),\n load,\n }\n\n async function load(specifier: string): Promise<Module> {\n ready ??= prepare()\n await ready\n if (!modules)\n throw new Error(\n \"Couldn't load auto-updated packages: the Dashboard doesn't provide the auto-update loader. Contact Sanity support.\",\n )\n\n const module = modules?.[specifier]\n if (!module) throw new Error(`${specifier} was not loaded from the module server`)\n\n return module\n }\n\n async function prepare(): Promise<void> {\n const workbench = (\n globalThis as {[key: symbol]: {versions?: Record<number, Load>} | undefined}\n )[Symbol.for('sanity.autoUpdates')]\n const result = await workbench?.versions?.[1]?.(appId, {\n imports: currentImports,\n specifiers,\n styles: cssUrls.map((url) => url.replace(TIMESTAMP, `$1${timestamp}`)),\n vendor,\n })\n modules = result?.modules\n }\n}\n"],"names":["TIMESTAMP","createAutoUpdatesLoader","appId","cssUrls","imports","specifiers","vendor","timestamp","Math","floor","Date","now","currentImports","Object","fromEntries","entries","map","specifier","url","replace","modules","ready","importMapUrl","undefined","load","prepare","Error","module","workbench","globalThis","Symbol","for","result","versions","styles"],"mappings":"AAsBA,MAAMA,YAAY;
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/autoUpdatesLoader.ts"],"sourcesContent":["type Module = Record<string, unknown>\n\n// Workbench's `load`, contract version 1: it loads every specifier as the app's own copy, with its\n// app ID and vendor modules, and links the stylesheets.\ntype Load = (\n appId: string,\n request: {\n imports: Record<string, string>\n specifiers: string[]\n styles: string[]\n vendor: Record<string, () => Promise<Module>>\n },\n) => Promise<{modules: Record<string, Module>}>\n\ninterface AutoUpdatesLoaderOptions {\n appId: string\n cssUrls: string[]\n imports: Record<string, string>\n specifiers: string[]\n vendor: Record<string, () => Promise<Module>>\n}\n\nconst TIMESTAMP = /(\\/(?:by-app|default)\\/[^/]+)\\/t\\d+/\n// The Studio team decides the final bucket size.\nconst TIMESTAMP_BUCKET_SECONDS = 60\n\n// Loads the app's auto-updated packages from the module server as its own copy.\nexport function createAutoUpdatesLoader({\n appId,\n cssUrls,\n imports,\n specifiers,\n vendor,\n}: AutoUpdatesLoaderOptions) {\n // The build's timestamp would pin the versions the module CDN served on build day.\n const timestamp = `/t${\n Math.floor(Date.now() / 1000 / TIMESTAMP_BUCKET_SECONDS) * TIMESTAMP_BUCKET_SECONDS\n }`\n const currentImports = Object.fromEntries(\n Object.entries(imports).map(([specifier, url]) => [\n specifier,\n url.replace(TIMESTAMP, `$1${timestamp}`),\n ]),\n )\n let modules: Record<string, Module> | undefined\n let ready: Promise<void> | undefined\n\n return {\n importMapUrl: (specifier: string) => (modules ? currentImports[specifier] : undefined),\n load,\n }\n\n async function load(specifier: string): Promise<Module> {\n ready ??= prepare()\n await ready\n if (!modules)\n throw new Error(\n \"Couldn't load auto-updated packages: the Dashboard doesn't provide the auto-update loader. Contact Sanity support.\",\n )\n\n const module = modules?.[specifier]\n if (!module) throw new Error(`${specifier} was not loaded from the module server`)\n\n return module\n }\n\n async function prepare(): Promise<void> {\n const workbench = (\n globalThis as {[key: symbol]: {versions?: Record<number, Load>} | undefined}\n )[Symbol.for('sanity.autoUpdates')]\n const result = await workbench?.versions?.[1]?.(appId, {\n imports: currentImports,\n specifiers,\n styles: cssUrls.map((url) => url.replace(TIMESTAMP, `$1${timestamp}`)),\n vendor,\n })\n modules = result?.modules\n }\n}\n"],"names":["TIMESTAMP","TIMESTAMP_BUCKET_SECONDS","createAutoUpdatesLoader","appId","cssUrls","imports","specifiers","vendor","timestamp","Math","floor","Date","now","currentImports","Object","fromEntries","entries","map","specifier","url","replace","modules","ready","importMapUrl","undefined","load","prepare","Error","module","workbench","globalThis","Symbol","for","result","versions","styles"],"mappings":"AAsBA,MAAMA,YAAY;AAClB,iDAAiD;AACjD,MAAMC,2BAA2B;AAEjC,gFAAgF;AAChF,OAAO,SAASC,wBAAwB,EACtCC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,UAAU,EACVC,MAAM,EACmB;IACzB,mFAAmF;IACnF,MAAMC,YAAY,CAAC,EAAE,EACnBC,KAAKC,KAAK,CAACC,KAAKC,GAAG,KAAK,OAAOX,4BAA4BA,0BAC3D;IACF,MAAMY,iBAAiBC,OAAOC,WAAW,CACvCD,OAAOE,OAAO,CAACX,SAASY,GAAG,CAAC,CAAC,CAACC,WAAWC,IAAI,GAAK;YAChDD;YACAC,IAAIC,OAAO,CAACpB,WAAW,CAAC,EAAE,EAAEQ,WAAW;SACxC;IAEH,IAAIa;IACJ,IAAIC;IAEJ,OAAO;QACLC,cAAc,CAACL,YAAuBG,UAAUR,cAAc,CAACK,UAAU,GAAGM;QAC5EC;IACF;IAEA,eAAeA,KAAKP,SAAiB;QACnCI,UAAUI;QACV,MAAMJ;QACN,IAAI,CAACD,SACH,MAAM,IAAIM,MACR;QAGJ,MAAMC,SAASP,SAAS,CAACH,UAAU;QACnC,IAAI,CAACU,QAAQ,MAAM,IAAID,MAAM,GAAGT,UAAU,sCAAsC,CAAC;QAEjF,OAAOU;IACT;IAEA,eAAeF;QACb,MAAMG,YAAY,AAChBC,UACD,CAACC,OAAOC,GAAG,CAAC,sBAAsB;QACnC,MAAMC,SAAS,MAAMJ,WAAWK,UAAU,CAAC,EAAE,GAAG/B,OAAO;YACrDE,SAASQ;YACTP;YACA6B,QAAQ/B,QAAQa,GAAG,CAAC,CAACE,MAAQA,IAAIC,OAAO,CAACpB,WAAW,CAAC,EAAE,EAAEQ,WAAW;YACpED;QACF;QACAc,UAAUY,QAAQZ;IACpB;AACF"}
|
|
@@ -4,7 +4,8 @@ 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 {
|
|
7
|
+
import { readAppIcon } from '../../readAppIcon.js';
|
|
8
|
+
import { createApplication, createDeployment, deleteApplication, removeApplicationIcon, setApplicationIcon, setInterfaceIcon, updateApplication } from '../../services/applications.js';
|
|
8
9
|
function toBrettInterface(iface) {
|
|
9
10
|
const { id: _id, src: _src, ...declaration } = iface;
|
|
10
11
|
if ('type' in declaration) return declaration;
|
|
@@ -19,7 +20,7 @@ function toBrettInterface(iface) {
|
|
|
19
20
|
}
|
|
20
21
|
case 'panel':
|
|
21
22
|
{
|
|
22
|
-
const { surface, ...view } = declaration;
|
|
23
|
+
const { icon: _icon, surface, ...view } = declaration;
|
|
23
24
|
return {
|
|
24
25
|
...view,
|
|
25
26
|
type: surface
|
|
@@ -35,7 +36,7 @@ function toBrettInterface(iface) {
|
|
|
35
36
|
}
|
|
36
37
|
case 'window':
|
|
37
38
|
{
|
|
38
|
-
const { surface, ...view } = declaration;
|
|
39
|
+
const { icon: _icon, surface, ...view } = declaration;
|
|
39
40
|
return {
|
|
40
41
|
...view,
|
|
41
42
|
type: 'app'
|
|
@@ -89,7 +90,7 @@ function toBrettInterface(iface) {
|
|
|
89
90
|
* then sync its mutable metadata (`title`, and `slug`/`visibility` when set)
|
|
90
91
|
* and its icon from config. The deploy endpoint ignores these, so a redeploy
|
|
91
92
|
* patches them here alongside the new deployment. No `icon` removes the
|
|
92
|
-
* application's icon.
|
|
93
|
+
* application's icon. Each interface's `icon` goes on the interface Brett created for it.
|
|
93
94
|
*
|
|
94
95
|
* `onDeployed` fires the instant the deployment is live, before the metadata
|
|
95
96
|
* sync — so a caller can disarm a create-time rollback that must not delete an
|
|
@@ -99,22 +100,27 @@ function toBrettInterface(iface) {
|
|
|
99
100
|
* application's registered origin.
|
|
100
101
|
* @internal
|
|
101
102
|
*/ export async function deployWorkbenchApp(options) {
|
|
102
|
-
const { access, app, applicationId, icon, isApp, isAutoUpdating, isExternal = false, label = 'Deploying...', mfManifest, onDeployed, slug, sourceDir, title, version, visibility, workspaces } = options;
|
|
103
|
+
const { access, app, applicationId, icon, isApp, isAutoUpdating, isExternal = false, label = 'Deploying...', mfManifest, onDeployed, slug, sourceDir, title, version, visibility, workDir, workspaces } = options;
|
|
103
104
|
const tarball = isExternal ? undefined : createTar({
|
|
104
105
|
cwd: dirname(sourceDir)
|
|
105
106
|
}, [
|
|
106
107
|
basename(sourceDir)
|
|
107
108
|
]).pipe(createGzip());
|
|
109
|
+
// Read before deploying, so a bad icon path fails while nothing is live.
|
|
110
|
+
const interfaces = await Promise.all(deriveInterfaces(app, {
|
|
111
|
+
appTitle: title,
|
|
112
|
+
isApp
|
|
113
|
+
}).map(async (iface)=>({
|
|
114
|
+
brett: toBrettInterface(iface),
|
|
115
|
+
icon: 'icon' in iface && iface.icon ? await readAppIcon(workDir, iface.icon) : undefined
|
|
116
|
+
})));
|
|
108
117
|
const spin = spinner(label).start();
|
|
109
118
|
try {
|
|
110
|
-
await createDeployment({
|
|
119
|
+
const deployment = await createDeployment({
|
|
111
120
|
access,
|
|
112
121
|
applicationId,
|
|
113
122
|
// Brett assigns the id and resolves modules by `moduleId`, so neither travels.
|
|
114
|
-
interfaces:
|
|
115
|
-
appTitle: title,
|
|
116
|
-
isApp
|
|
117
|
-
}).map((iface)=>toBrettInterface(iface)),
|
|
123
|
+
interfaces: interfaces.map(({ brett })=>brett),
|
|
118
124
|
isAutoUpdating,
|
|
119
125
|
mfManifest,
|
|
120
126
|
tarball,
|
|
@@ -139,11 +145,23 @@ function toBrettInterface(iface) {
|
|
|
139
145
|
try {
|
|
140
146
|
await setApplicationIcon(applicationId, icon);
|
|
141
147
|
} catch (error) {
|
|
142
|
-
throw toIconRejection(error);
|
|
148
|
+
throw toIconRejection(error, 'The app icon was rejected', "The deployment is live with the application's previous icon. Change `app.icon`");
|
|
143
149
|
}
|
|
144
150
|
} else {
|
|
145
151
|
await removeApplicationIcon(applicationId);
|
|
146
152
|
}
|
|
153
|
+
for (const { brett: { name, type }, icon: interfaceIcon } of interfaces){
|
|
154
|
+
if (!interfaceIcon) continue;
|
|
155
|
+
const iface = deployment.interfaces.find((i)=>i.type === type && i.name === name);
|
|
156
|
+
if (!iface) {
|
|
157
|
+
throw new Error(`The deployment is live, but has no ${type} interface named "${name}" to set its icon on.`);
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
await setInterfaceIcon(applicationId, iface.id, interfaceIcon);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
throw toIconRejection(error, `The icon of view "${name}" was rejected`, "The deployment is live without it. Change the view's `icon`");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
147
165
|
spin.succeed();
|
|
148
166
|
} catch (error) {
|
|
149
167
|
spin.clear();
|
|
@@ -162,10 +180,10 @@ function toBrettInterface(iface) {
|
|
|
162
180
|
cause: error
|
|
163
181
|
});
|
|
164
182
|
}
|
|
165
|
-
/** A 4xx on
|
|
183
|
+
/** A 4xx on an icon upload is the image being rejected; name the server's reason. */ function toIconRejection(error, rejected, fix) {
|
|
166
184
|
const statusCode = error?.statusCode;
|
|
167
185
|
if (statusCode === undefined || statusCode < 400 || statusCode >= 500) return error;
|
|
168
|
-
return new Error(
|
|
186
|
+
return new Error(`${rejected}: ${getErrorMessage(error)}. ${fix} in sanity.cli.ts and deploy again.`, {
|
|
169
187
|
cause: error
|
|
170
188
|
});
|
|
171
189
|
}
|
|
@@ -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 {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,4BAA2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;YAC1C,EAAE,OAAOP,OAAO;gBACd,MAAM4B,gBAAgB5B;YACxB;QACF,OAAO;YACL,MAAMpB,sBAAsB0B;QAC9B;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"}
|
|
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 {readAppIcon} from '../../readAppIcon.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 setInterfaceIcon,\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 {icon: _icon, 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 {icon: _icon, 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. Each interface's `icon` goes on the interface Brett created for it.\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 workDir: string\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 workDir,\n workspaces,\n } = options\n const tarball = isExternal\n ? undefined\n : createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n // Read before deploying, so a bad icon path fails while nothing is live.\n const interfaces = await Promise.all(\n deriveInterfaces(app, {appTitle: title, isApp}).map(async (iface) => ({\n brett: toBrettInterface(iface),\n icon: 'icon' in iface && iface.icon ? await readAppIcon(workDir, iface.icon) : undefined,\n })),\n )\n\n const spin = spinner(label).start()\n try {\n const deployment = await createDeployment({\n access,\n applicationId,\n // Brett assigns the id and resolves modules by `moduleId`, so neither travels.\n interfaces: interfaces.map(({brett}) => brett),\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(\n error,\n 'The app icon was rejected',\n \"The deployment is live with the application's previous icon. Change `app.icon`\",\n )\n }\n } else {\n await removeApplicationIcon(applicationId)\n }\n for (const {\n brett: {name, type},\n icon: interfaceIcon,\n } of interfaces) {\n if (!interfaceIcon) continue\n\n const iface = deployment.interfaces.find((i) => i.type === type && i.name === name)\n if (!iface) {\n throw new Error(\n `The deployment is live, but has no ${type} interface named \"${name}\" to set its icon on.`,\n )\n }\n try {\n await setInterfaceIcon(applicationId, iface.id, interfaceIcon)\n } catch (error) {\n throw toIconRejection(\n error,\n `The icon of view \"${name}\" was rejected`,\n \"The deployment is live without it. Change the view's `icon`\",\n )\n }\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 an icon upload is the image being rejected; name the server's reason. */\nfunction toIconRejection(error: unknown, rejected: string, fix: string): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `${rejected}: ${getErrorMessage(error)}. ${fix} in sanity.cli.ts and deploy again.`,\n {cause: error},\n )\n}\n"],"names":["basename","dirname","createGzip","getErrorMessage","spinner","c","createTar","deriveInterfaces","readAppIcon","createApplication","createDeployment","deleteApplication","removeApplicationIcon","setApplicationIcon","setInterfaceIcon","updateApplication","toBrettInterface","iface","id","_id","src","_src","declaration","surface","view","type","icon","_icon","createCoreApp","options","spin","start","application","succeed","rollback","error","fail","createStudio","deployWorkbenchApp","access","app","applicationId","isApp","isAutoUpdating","isExternal","label","mfManifest","onDeployed","slug","sourceDir","title","version","visibility","workDir","workspaces","tarball","undefined","cwd","pipe","interfaces","Promise","all","appTitle","map","brett","deployment","toSlugRejection","toIconRejection","name","interfaceIcon","find","i","Error","clear","statusCode","cause","rejected","fix"],"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,SAAQC,WAAW,QAAO,uBAAsB;AAChD,SAKEC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,qBAAqB,EACrBC,kBAAkB,EAClBC,gBAAgB,EAChBC,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,EAACG,MAAMC,KAAK,EAAEJ,OAAO,EAAE,GAAGC,MAAK,GAAGF;gBACxC,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,KAAK;YAAU;gBACb,MAAM,EAACG,MAAMC,KAAK,EAAEJ,OAAO,EAAE,GAAGC,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ACA,IAAI;gBACF,MAAMtD,iBAAiB2B,eAAexB,MAAMC,EAAE,EAAEmD;YAClD,EAAE,OAAOlC,OAAO;gBACd,MAAMgC,gBACJhC,OACA,CAAC,kBAAkB,EAAEiC,KAAK,cAAc,CAAC,EACzC;YAEJ;QACF;QACAtC,KAAKG,OAAO;IACd,EAAE,OAAOE,OAAO;QACdL,KAAK2C,KAAK;QACV,MAAMtC;IACR;AACF;AAEA;;;;;CAKC,GACD,SAAS+B,gBAAgB/B,KAAc,EAAEa,IAAwB;IAC/D,MAAM0B,aAAcvC,OAAiCuC;IACrD,IAAI,CAAC1B,QAAQ0B,eAAelB,aAAakB,aAAa,OAAOA,cAAc,KAAK,OAAOvC;IACvF,OAAO,IAAIqC,MACT,CAAC,MAAM,EAAExB,KAAK,gBAAgB,EAAE7C,gBAAgBgC,OAAO,oHAAoH,CAAC,EAC5K;QAACwC,OAAOxC;IAAK;AAEjB;AAEA,mFAAmF,GACnF,SAASgC,gBAAgBhC,KAAc,EAAEyC,QAAgB,EAAEC,GAAW;IACpE,MAAMH,aAAcvC,OAAiCuC;IACrD,IAAIA,eAAelB,aAAakB,aAAa,OAAOA,cAAc,KAAK,OAAOvC;IAC9E,OAAO,IAAIqC,MACT,GAAGI,SAAS,EAAE,EAAEzE,gBAAgBgC,OAAO,EAAE,EAAE0C,IAAI,mCAAmC,CAAC,EACnF;QAACF,OAAOxC;IAAK;AAEjB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { relative } from 'node:path';
|
|
1
|
+
import { relative, resolve } from 'node:path';
|
|
2
2
|
import { getCliConfigUncached } from '@sanity/cli-core';
|
|
3
3
|
import { isWorkbenchApp, isWorkbenchConfig } from '../../defineApp.js';
|
|
4
4
|
import { deriveInterfaces } from '../../deriveInterfaces.js';
|
|
@@ -29,6 +29,13 @@ import { startDevManifestWatcher } from './startDevManifestWatcher.js';
|
|
|
29
29
|
port: typeof addr === 'object' && addr ? addr.port : server.config.server.port
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
function servedUrl(server, file) {
|
|
33
|
+
// Vite serves `public/` at the root, and warns on every request for `/public/...`.
|
|
34
|
+
const { base, publicDir, root } = server.config;
|
|
35
|
+
const inPublicDir = Boolean(publicDir) && !relative(publicDir, file).startsWith('..');
|
|
36
|
+
const { host, https, port } = serverAddress(server);
|
|
37
|
+
return `${https ? 'https' : 'http'}://${host}:${port}${base}${toUrlPath(inPublicDir ? publicDir : root, file)}`;
|
|
38
|
+
}
|
|
32
39
|
/**
|
|
33
40
|
* Register the dev server in the registry and watch its config for manifest +
|
|
34
41
|
* interface changes. The workbench reads the entry to locate and render the
|
|
@@ -40,6 +47,7 @@ import { startDevManifestWatcher } from './startDevManifestWatcher.js';
|
|
|
40
47
|
// Forwarded alongside (not inside) the manifest so the workbench renders local
|
|
41
48
|
// panels/workers and reads the configs without a deploy.
|
|
42
49
|
const interfaces = deriveInterfaces(cliConfig.app, {
|
|
50
|
+
iconUrl: (iconPath)=>servedUrl(server, resolve(workDir, iconPath)),
|
|
43
51
|
isApp
|
|
44
52
|
});
|
|
45
53
|
const configs = await deriveConfigs(cliConfig);
|
|
@@ -94,15 +102,12 @@ import { startDevManifestWatcher } from './startDevManifestWatcher.js';
|
|
|
94
102
|
if (isApp && isWorkbenchApp(nextConfig.app) && nextConfig.app.icon) {
|
|
95
103
|
// Read in full so an image a deploy would reject warns here, while editing.
|
|
96
104
|
const { file } = await readAppIcon(workDir, nextConfig.app.icon);
|
|
97
|
-
|
|
98
|
-
const { base, publicDir, root } = liveServer.config;
|
|
99
|
-
const inPublicDir = Boolean(publicDir) && !relative(publicDir, file).startsWith('..');
|
|
100
|
-
const { host, https, port } = serverAddress(liveServer);
|
|
101
|
-
iconUrl = `${https ? 'https' : 'http'}://${host}:${port}${base}${toUrlPath(inPublicDir ? publicDir : root, file)}`;
|
|
105
|
+
iconUrl = servedUrl(liveServer, file);
|
|
102
106
|
}
|
|
103
107
|
return {
|
|
104
108
|
configs: await deriveConfigs(nextConfig),
|
|
105
109
|
interfaces: deriveInterfaces(nextConfig.app, {
|
|
110
|
+
iconUrl: (iconPath)=>servedUrl(liveServer, resolve(workDir, iconPath)),
|
|
106
111
|
isApp
|
|
107
112
|
}),
|
|
108
113
|
manifest: await extractManifest({
|