@sanity/workbench-cli 2.20.0 → 2.22.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 +10 -2
- package/dist/_exports/build.js +2 -0
- package/dist/_exports/build.js.map +1 -1
- package/dist/_exports/defineApp-DUi9ZfpT.d.ts +377 -0
- package/dist/_exports/deploy.d.ts +25 -43
- package/dist/_exports/deploy.js +3 -1
- package/dist/_exports/deploy.js.map +1 -1
- package/dist/_exports/{summarizeInterfaces-BKIMEFzw.d.ts → deploySummary-BPgEW1qt.d.ts} +47 -4
- package/dist/_exports/dev.d.ts +2 -2
- package/dist/_exports/index.d.ts +22 -4
- package/dist/_exports/index.js +2 -1
- package/dist/_exports/index.js.map +1 -1
- package/dist/_exports/preview.d.ts +1 -1
- package/dist/_exports/{registry-BI8kZVpy.d.ts → registry-DysyB1F6.d.ts} +11 -7
- package/dist/_exports/{resolveWorkbenchConfig-Eex64aAA.d.ts → resolveWorkbenchApp-C_rqQBQP.d.ts} +5 -20
- package/dist/_exports/resolveWorkbenchConfig-C_o8npN0.d.ts +10 -0
- package/dist/_exports/undeploy.d.ts +6 -6
- package/dist/_exports/undeploy.js +1 -0
- package/dist/_exports/undeploy.js.map +1 -1
- package/dist/actions/build/artifact.js +20 -1
- package/dist/actions/build/artifact.js.map +1 -1
- package/dist/actions/build/buildSummary.js +34 -0
- package/dist/actions/build/buildSummary.js.map +1 -0
- package/dist/actions/build/configs/artifact.js +10 -50
- package/dist/actions/build/configs/artifact.js.map +1 -1
- package/dist/actions/build/dashboardConfig/artifact.js +25 -0
- package/dist/actions/build/dashboardConfig/artifact.js.map +1 -0
- package/dist/actions/build/hotConfigListeners.js +34 -0
- package/dist/actions/build/hotConfigListeners.js.map +1 -0
- package/dist/actions/build/vite/optimize-deps.js +2 -1
- package/dist/actions/build/vite/optimize-deps.js.map +1 -1
- package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js +3 -1
- package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js.map +1 -1
- package/dist/actions/deploy/deployConfig.js +9 -7
- package/dist/actions/deploy/deployConfig.js.map +1 -1
- package/dist/actions/deploy/deployPayload.js.map +1 -1
- package/dist/actions/deploy/deploySummary.js +46 -10
- package/dist/actions/deploy/deploySummary.js.map +1 -1
- package/dist/actions/deploy/uploadDashboardConfig.js +34 -0
- package/dist/actions/deploy/uploadDashboardConfig.js.map +1 -0
- package/dist/actions/dev/deriveConfigs.js +17 -13
- package/dist/actions/dev/deriveConfigs.js.map +1 -1
- package/dist/actions/dev/devSummary.js +12 -0
- package/dist/actions/dev/devSummary.js.map +1 -1
- package/dist/actions/dev/registry.js +34 -20
- package/dist/actions/dev/registry.js.map +1 -1
- package/dist/actions/dev/startDevServerRegistration.js +9 -5
- package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
- package/dist/actions/dev/startWorkbenchDev.js +4 -17
- package/dist/actions/dev/startWorkbenchDev.js.map +1 -1
- package/dist/actions/preview/startWorkbenchPreview.js +67 -18
- package/dist/actions/preview/startWorkbenchPreview.js.map +1 -1
- package/dist/actions/summary.js +3 -4
- package/dist/actions/summary.js.map +1 -1
- package/dist/actions/undeploy/workbenchUndeployAdapter.js +57 -5
- package/dist/actions/undeploy/workbenchUndeployAdapter.js.map +1 -1
- package/dist/contract.js +14 -0
- package/dist/contract.js.map +1 -1
- package/dist/dashboardConfig.js +5 -0
- package/dist/dashboardConfig.js.map +1 -0
- package/dist/defineApp.js +25 -2
- package/dist/defineApp.js.map +1 -1
- package/dist/deriveInterfaces.js +2 -2
- package/dist/deriveInterfaces.js.map +1 -1
- package/dist/resolveWorkbenchApp.js +3 -2
- package/dist/resolveWorkbenchApp.js.map +1 -1
- package/dist/resolveWorkbenchConfig.js +11 -16
- package/dist/resolveWorkbenchConfig.js.map +1 -1
- package/dist/services/applications.js +10 -5
- package/dist/services/applications.js.map +1 -1
- package/dist/services/dashboard-configs.js +54 -0
- package/dist/services/dashboard-configs.js.map +1 -0
- package/dist/services/organizations.js +2 -1
- package/dist/services/organizations.js.map +1 -1
- package/package.json +8 -8
- package/dist/_exports/contract-BeAds4Yi.d.ts +0 -191
- package/dist/_exports/defineApp-DSXAAr3V.d.ts +0 -177
package/dist/_exports/index.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { A as ViewDeclaration, B as defineWebWorker, C as DockGroup, D as TileViewDeclaration, E as TileSize, F as WindowViewDeclaration, L as defineAssetSourceView, M as WEB_WORKER_CONTRACT_VERSION, N as WebWorkerDeclaration, O as ViewComponent, P as WebWorkerType, R as definePanelView, S as DefineWindowViewInput, T as ServiceType, V as defineWindowView, a as DefineMediaLibraryInput, b as DefineTileViewInput, c as WorkbenchApp, d as defineDashboard, f as isWorkbenchApp, g as AssetSourceViewDeclaration, h as unstable_defineMediaLibrary, i as DefineDashboardInput, j as ViewSurface, k as ViewComponentBaseProps, l as WorkbenchConfig, m as resolveAppTitle, n as DefineAppInput, o as MediaLibraryConfig, p as isWorkbenchConfig, r as DefineAppResult, s as MediaLibraryField, t as DashboardConfig, u as defineApplication, v as DefineAssetSourceViewInput, w as PanelViewDeclaration, x as DefineWebWorkerInput, y as DefinePanelViewInput, z as defineTileView } from "./defineApp-DUi9ZfpT.js";
|
|
2
|
+
import { View, ViewApplication, WebWorkerProps, WebWorkerProps as WebWorkerProps$1 } from "@sanity/sdk/dashboard";
|
|
3
|
+
import { CurrentUser } from "@sanity/sdk";
|
|
4
4
|
import { AssetSourceComponentProps } from "@sanity/types";
|
|
5
|
+
interface ApplicationsContext {
|
|
6
|
+
applications: readonly (ViewApplication & {
|
|
7
|
+
views: readonly View<{
|
|
8
|
+
includeApplication: false;
|
|
9
|
+
}>[];
|
|
10
|
+
})[];
|
|
11
|
+
currentUser: CurrentUser;
|
|
12
|
+
}
|
|
13
|
+
interface DefineDashboardConfigInput {
|
|
14
|
+
applications?: {
|
|
15
|
+
hidden?: (references: readonly ViewApplication['reference'][], context: ApplicationsContext) => readonly ViewApplication['reference'][];
|
|
16
|
+
visible?: (references: readonly ViewApplication['reference'][], context: ApplicationsContext) => readonly ViewApplication['reference'][];
|
|
17
|
+
};
|
|
18
|
+
views?: (views: readonly View[], context: {
|
|
19
|
+
currentUser: CurrentUser;
|
|
20
|
+
}) => readonly View[];
|
|
21
|
+
}
|
|
22
|
+
declare function defineDashboardConfig(config: DefineDashboardConfigInput): DefineDashboardConfigInput;
|
|
5
23
|
/** @public */
|
|
6
24
|
type WindowViewProps = ViewComponentBaseProps<{
|
|
7
25
|
name: string;
|
|
@@ -177,5 +195,5 @@ type ServiceBus = WebWorkerProps$1['bus'];
|
|
|
177
195
|
* @public
|
|
178
196
|
*/
|
|
179
197
|
type ServiceInfo = WebWorkerProps$1['worker'];
|
|
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 };
|
|
198
|
+
export { type AssetSourceComponent, type AssetSourceViewComponents, type AssetSourceViewDeclaration, type DashboardConfig, type DefineAppInput, type DefineAppResult, type DefineAssetSourceViewInput, type DefineDashboardInput, type DefineMediaLibraryInput, type DefinePanelViewInput, type DefineTileViewInput, type DefineWebWorkerInput, type DefineWindowViewInput, type DefinedService, type DefinedView, type DockGroup, type MediaLibraryConfig, 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, defineDashboard, defineDashboardConfig, definePanelView, defineTileView, defineWebWorker, defineWindowView, isWorkbenchApp, isWorkbenchConfig, resolveAppTitle, unstable_defineMediaLibrary, unstable_defineService, unstable_defineView };
|
|
181
199
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/_exports/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { defineAssetSourceView, definePanelView, defineTileView, defineWebWorker, defineWindowView } from '../contract.js';
|
|
2
|
-
export {
|
|
2
|
+
export { defineDashboardConfig } from '../dashboardConfig.js';
|
|
3
|
+
export { defineApplication, defineDashboard, isWorkbenchApp, isWorkbenchConfig, resolveAppTitle, unstable_defineMediaLibrary } from '../defineApp.js';
|
|
3
4
|
export { unstable_defineView } from '../defineView.js';
|
|
4
5
|
export { unstable_defineService } from '../webWorker.js';
|
|
5
6
|
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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 {defineDashboardConfig} from '../dashboardConfig.js'\nexport {\n defineApplication,\n defineDashboard,\n isWorkbenchApp,\n isWorkbenchConfig,\n resolveAppTitle,\n unstable_defineMediaLibrary,\n} from '../defineApp.js'\nexport type {\n DashboardConfig,\n DefineAppInput,\n DefineAppResult,\n DefineDashboardInput,\n DefineMediaLibraryInput,\n MediaLibraryConfig,\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","defineDashboardConfig","defineApplication","defineDashboard","isWorkbenchApp","isWorkbenchConfig","resolveAppTitle","unstable_defineMediaLibrary","unstable_defineView","unstable_defineService"],"mappings":"AAkBA,SACEA,qBAAqB,EACrBC,eAAe,EACfC,cAAc,EACdC,eAAe,EACfC,gBAAgB,QACX,iBAAgB;AACvB,SAAQC,qBAAqB,QAAO,wBAAuB;AAC3D,SACEC,iBAAiB,EACjBC,eAAe,EACfC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,2BAA2B,QACtB,kBAAiB;AAYxB,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-DysyB1F6.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,19 +1,23 @@
|
|
|
1
|
-
import "./defineApp-
|
|
1
|
+
import "./defineApp-DUi9ZfpT.js";
|
|
2
2
|
import { z } from "zod/mini";
|
|
3
3
|
declare const devServerManifestSchema: z.ZodMiniObject<{
|
|
4
4
|
applicationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
5
|
-
configs: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
6
|
-
appType: z.
|
|
5
|
+
configs: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniIntersection<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
6
|
+
appType: z.ZodMiniLiteral<"dashboard">;
|
|
7
|
+
src: z.ZodMiniString<string>;
|
|
8
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
9
|
+
appType: z.ZodMiniLiteral<"media-library">;
|
|
7
10
|
fields: z.ZodMiniArray<z.ZodMiniObject<{
|
|
8
|
-
name: z.ZodMiniString<string>;
|
|
9
11
|
public: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
10
|
-
src: z.ZodMiniString<string>;
|
|
11
12
|
title: z.ZodMiniString<string>;
|
|
13
|
+
name: z.ZodMiniString<string>;
|
|
14
|
+
src: z.ZodMiniString<string>;
|
|
12
15
|
}, z.core.$strip>>;
|
|
16
|
+
}, z.core.$strip>], "appType">, z.ZodMiniObject<{
|
|
13
17
|
id: z.ZodMiniString<string>;
|
|
14
18
|
moduleName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
15
19
|
version: z.ZodMiniString<string>;
|
|
16
|
-
}, z.core.$strip
|
|
20
|
+
}, z.core.$strip>>>>;
|
|
17
21
|
host: z.ZodMiniString<string>;
|
|
18
22
|
https: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
19
23
|
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -132,4 +136,4 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
|
|
|
132
136
|
*/
|
|
133
137
|
type DevServerManifest = z.infer<typeof devServerManifestSchema>;
|
|
134
138
|
export { DevServerManifest as t };
|
|
135
|
-
//# sourceMappingURL=registry-
|
|
139
|
+
//# sourceMappingURL=registry-DysyB1F6.d.ts.map
|
package/dist/_exports/{resolveWorkbenchConfig-Eex64aAA.d.ts → resolveWorkbenchApp-C_rqQBQP.d.ts}
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as DefineAppInput } from "./defineApp-DSXAAr3V.js";
|
|
1
|
+
import { I as WorkbenchConfigValue, n as DefineAppInput } from "./defineApp-DUi9ZfpT.js";
|
|
3
2
|
import { AppVisibility, CliConfig } from "@sanity/cli-core";
|
|
4
3
|
/**
|
|
5
4
|
* Bundled so adding a declaration family touches this type and the artifact
|
|
@@ -22,6 +21,8 @@ interface ResolvedWorkbenchApp {
|
|
|
22
21
|
/** Organization that owns the app — part of its build-id identity. */
|
|
23
22
|
readonly organizationId: string;
|
|
24
23
|
readonly slug: string;
|
|
24
|
+
/** Display title: the declared `title`, else {@link resolveAppTitle}'s fallback. */
|
|
25
|
+
readonly title: string;
|
|
25
26
|
/** Views the app declares. */
|
|
26
27
|
readonly views: NonNullable<DefineAppInput['views']>;
|
|
27
28
|
/** Background web workers the app declares. */
|
|
@@ -48,21 +49,5 @@ declare function resolveAppEntry(app: CliConfig['app']): string | undefined;
|
|
|
48
49
|
* @public
|
|
49
50
|
*/
|
|
50
51
|
declare function resolveWorkbenchApp(cliConfig: CliConfig | null | undefined): ResolvedWorkbenchApp | null;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/** Target app the config binds to — resolves the org installation on deploy. */
|
|
54
|
-
readonly appType: WorkbenchConfigValue['appType'];
|
|
55
|
-
/** The config's declared fields, expanded into the federation remote on build. */
|
|
56
|
-
readonly fields: WorkbenchConfigValue['fields'];
|
|
57
|
-
/** Organization that owns the config's target installation. */
|
|
58
|
-
readonly organizationId: string;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Resolve the workbench config for a CLI config, or `null` when it carries no
|
|
62
|
-
* config brand (a plain project or an app). The only config today is the Media
|
|
63
|
-
* Library, so the resolved shape is a {@link ResolvedMediaLibraryConfig}.
|
|
64
|
-
* @public
|
|
65
|
-
*/
|
|
66
|
-
declare function resolveWorkbenchConfig(cliConfig: CliConfig | null | undefined): ResolvedMediaLibraryConfig | null;
|
|
67
|
-
export { resolveAppEntry as a, WorkbenchExposes as i, resolveWorkbenchConfig as n, resolveWorkbenchApp as o, ResolvedWorkbenchApp as r, ResolvedMediaLibraryConfig as t };
|
|
68
|
-
//# sourceMappingURL=resolveWorkbenchConfig-Eex64aAA.d.ts.map
|
|
52
|
+
export { resolveWorkbenchApp as i, WorkbenchExposes as n, resolveAppEntry as r, ResolvedWorkbenchApp as t };
|
|
53
|
+
//# sourceMappingURL=resolveWorkbenchApp-C_rqQBQP.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { l as WorkbenchConfig } from "./defineApp-DUi9ZfpT.js";
|
|
2
|
+
import { CliConfig } from "@sanity/cli-core";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the workbench config for a CLI config, or `null` when it carries no
|
|
5
|
+
* config brand (a plain project or an app).
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
declare function resolveWorkbenchConfig(cliConfig: CliConfig | null | undefined): WorkbenchConfig | null;
|
|
9
|
+
export { resolveWorkbenchConfig as t };
|
|
10
|
+
//# sourceMappingURL=resolveWorkbenchConfig-C_o8npN0.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { l as WorkbenchConfig } from "./defineApp-DUi9ZfpT.js";
|
|
2
|
+
import { i as formatUndeploySummary, l as DeployableWorkbenchApp, o as DeployedView, s as DeployedWebWorker } from "./deploySummary-BPgEW1qt.js";
|
|
3
3
|
import "node:zlib";
|
|
4
4
|
import { UndeployAdapter, UndeployApplicationTarget, UndeployConfigTarget } from "@sanity/cli-core/undeploy";
|
|
5
5
|
interface ConfigSnapshot {
|
|
@@ -20,16 +20,16 @@ type WorkbenchUndeployTarget = (UndeployApplicationTarget & {
|
|
|
20
20
|
* The undeploy adapter for workbench apps and configs, mirroring what a
|
|
21
21
|
* workbench deploy creates: an app that exposes interfaces deletes its Brett
|
|
22
22
|
* application (the server soft-deletes its deployments and refuses singletons
|
|
23
|
-
* with active installations); a config
|
|
24
|
-
* installation
|
|
23
|
+
* with active installations); a config deletes its deployed config instead
|
|
24
|
+
* (installation snapshots, or the dashboard configuration). The two are severed at the source,
|
|
25
25
|
* so exactly one of `workbench`/`config` is supplied and the brand decides the path.
|
|
26
26
|
*/
|
|
27
27
|
declare function createWorkbenchUndeployAdapter(options: {
|
|
28
28
|
appId: string | undefined;
|
|
29
|
-
config?:
|
|
29
|
+
config?: WorkbenchConfig;
|
|
30
30
|
organizationId: string | undefined;
|
|
31
31
|
type: 'coreApp' | 'studio';
|
|
32
32
|
workbench?: DeployableWorkbenchApp;
|
|
33
33
|
}): UndeployAdapter<WorkbenchUndeployTarget>;
|
|
34
|
-
export { createWorkbenchUndeployAdapter };
|
|
34
|
+
export { createWorkbenchUndeployAdapter, formatUndeploySummary };
|
|
35
35
|
//# sourceMappingURL=undeploy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/undeploy.ts"],"sourcesContent":["export {createWorkbenchUndeployAdapter} from '../actions/undeploy/workbenchUndeployAdapter.js'\n"],"names":["createWorkbenchUndeployAdapter"],"mappings":"AAAA,SAAQA,8BAA8B,QAAO,kDAAiD"}
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/undeploy.ts"],"sourcesContent":["export {formatUndeploySummary} from '../actions/deploy/deploySummary.js'\nexport {createWorkbenchUndeployAdapter} from '../actions/undeploy/workbenchUndeployAdapter.js'\n"],"names":["formatUndeploySummary","createWorkbenchUndeployAdapter"],"mappings":"AAAA,SAAQA,qBAAqB,QAAO,qCAAoC;AACxE,SAAQC,8BAA8B,QAAO,kDAAiD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mediaLibraryConfigArtifacts } from './configs/artifact.js';
|
|
2
|
+
import { dashboardConfigArtifacts } from './dashboardConfig/artifact.js';
|
|
2
3
|
import { viewArtifacts } from './views/artifact.js';
|
|
3
4
|
import { webWorkerArtifacts } from './webWorkers/artifact.js';
|
|
4
5
|
/**
|
|
@@ -23,8 +24,26 @@ import { webWorkerArtifacts } from './webWorkers/artifact.js';
|
|
|
23
24
|
return [
|
|
24
25
|
...viewArtifacts(exposes.views ?? []),
|
|
25
26
|
...webWorkerArtifacts(exposes.webWorkers ?? []),
|
|
26
|
-
...
|
|
27
|
+
...exposes.config ? configArtifacts(exposes.config, configOptions) : []
|
|
27
28
|
];
|
|
28
29
|
}
|
|
30
|
+
function configArtifacts(config, options) {
|
|
31
|
+
const { appType } = config;
|
|
32
|
+
switch(appType){
|
|
33
|
+
case 'dashboard':
|
|
34
|
+
{
|
|
35
|
+
return dashboardConfigArtifacts(config);
|
|
36
|
+
}
|
|
37
|
+
case 'media-library':
|
|
38
|
+
{
|
|
39
|
+
return mediaLibraryConfigArtifacts(config, options);
|
|
40
|
+
}
|
|
41
|
+
default:
|
|
42
|
+
{
|
|
43
|
+
appType;
|
|
44
|
+
throw new Error(`Cannot build artifacts for unknown app type: ${appType}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
29
48
|
|
|
30
49
|
//# sourceMappingURL=artifact.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/artifact.ts"],"sourcesContent":["import {type WorkbenchExposes} from '../../resolveWorkbenchApp.js'\nimport {\n type MediaLibraryConfigArtifactOptions,\n mediaLibraryConfigArtifacts,\n} from './configs/artifact.js'\nimport {viewArtifacts} from './views/artifact.js'\nimport {webWorkerArtifacts} from './webWorkers/artifact.js'\n\n/**\n * What a {@link GeneratedArtifact.source} builder receives from the build — the\n * one thing it can't compute on its own, since only the build knows where the\n * runtime dir sits relative to the app's `src`.\n */\ninterface ArtifactContext {\n /** Import specifier for an app `src` file, relative to this artifact. */\n resolveImport: (src: string) => string\n\n isolateStyles?: boolean\n}\n\n/**\n * One file the federation build generates into the runtime dir for a declared\n * interface. Each interface type — views, web workers — expands its declarations\n * into a flat list of these; the build then writes them and maps the ones the\n * host loads directly into the module-federation manifest.\n *\n * Adding an interface type is adding a builder that returns\n * `GeneratedArtifact[]` — the write loop and the expose mapping never change.\n */\nexport interface GeneratedArtifact {\n /** Path relative to the federation runtime dir, e.g. `views/feed/panel.js`. */\n path: string\n /** Build the file's contents. */\n source: (context: ArtifactContext) => string\n\n /**\n * Module-federation expose key when the host loads this artifact directly —\n * a view component `./views/feed/panel`, a web worker loader `./services/unread`.\n * Omitted for a file the host never loads on its own, like a worker bundle\n * (reached through its sibling loader).\n */\n expose?: string\n}\n\n/**\n * Map the artifacts the host loads directly (those with an `expose`) to their\n * runtime-dir paths, for the module-federation `exposes` field. `toExposePath`\n * turns a runtime-relative artifact path into the value federation wants — the\n * caller owns the runtime-dir location and any entry resolution.\n */\nexport function artifactExposes(\n artifacts: readonly GeneratedArtifact[],\n toExposePath: (artifactPath: string) => string,\n): Record<string, string> {\n const exposes: Record<string, string> = {}\n for (const artifact of artifacts) {\n if (artifact.expose) {\n exposes[artifact.expose] = toExposePath(artifact.path)\n }\n }\n return exposes\n}\n\n/**\n * Expand what the app exposes into the flat artifact set the federation build\n * writes — the single place that composes the per-type expanders, so the expose\n * mapping and the file writing read from one expansion.\n */\nexport function workbenchArtifacts(\n exposes: WorkbenchExposes,\n configOptions: MediaLibraryConfigArtifactOptions = {},\n): GeneratedArtifact[] {\n return [\n ...viewArtifacts(exposes.views ?? []),\n ...webWorkerArtifacts(exposes.webWorkers ?? []),\n ...
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/artifact.ts"],"sourcesContent":["import {type WorkbenchConfigValue} from '../../contract.js'\nimport {type WorkbenchExposes} from '../../resolveWorkbenchApp.js'\nimport {\n type MediaLibraryConfigArtifactOptions,\n mediaLibraryConfigArtifacts,\n} from './configs/artifact.js'\nimport {dashboardConfigArtifacts} from './dashboardConfig/artifact.js'\nimport {viewArtifacts} from './views/artifact.js'\nimport {webWorkerArtifacts} from './webWorkers/artifact.js'\n\n/**\n * What a {@link GeneratedArtifact.source} builder receives from the build — the\n * one thing it can't compute on its own, since only the build knows where the\n * runtime dir sits relative to the app's `src`.\n */\ninterface ArtifactContext {\n /** Import specifier for an app `src` file, relative to this artifact. */\n resolveImport: (src: string) => string\n\n /** Under `sanity dev`, config modules import user code after their hot handler registers. */\n dev?: boolean\n isolateStyles?: boolean\n}\n\n/**\n * One file the federation build generates into the runtime dir for a declared\n * interface. Each interface type — views, web workers — expands its declarations\n * into a flat list of these; the build then writes them and maps the ones the\n * host loads directly into the module-federation manifest.\n *\n * Adding an interface type is adding a builder that returns\n * `GeneratedArtifact[]` — the write loop and the expose mapping never change.\n */\nexport interface GeneratedArtifact {\n /** Path relative to the federation runtime dir, e.g. `views/feed/panel.js`. */\n path: string\n /** Build the file's contents. */\n source: (context: ArtifactContext) => string\n\n /**\n * Module-federation expose key when the host loads this artifact directly —\n * a view component `./views/feed/panel`, a web worker loader `./services/unread`.\n * Omitted for a file the host never loads on its own, like a worker bundle\n * (reached through its sibling loader).\n */\n expose?: string\n}\n\n/**\n * Map the artifacts the host loads directly (those with an `expose`) to their\n * runtime-dir paths, for the module-federation `exposes` field. `toExposePath`\n * turns a runtime-relative artifact path into the value federation wants — the\n * caller owns the runtime-dir location and any entry resolution.\n */\nexport function artifactExposes(\n artifacts: readonly GeneratedArtifact[],\n toExposePath: (artifactPath: string) => string,\n): Record<string, string> {\n const exposes: Record<string, string> = {}\n for (const artifact of artifacts) {\n if (artifact.expose) {\n exposes[artifact.expose] = toExposePath(artifact.path)\n }\n }\n return exposes\n}\n\n/**\n * Expand what the app exposes into the flat artifact set the federation build\n * writes — the single place that composes the per-type expanders, so the expose\n * mapping and the file writing read from one expansion.\n */\nexport function workbenchArtifacts(\n exposes: WorkbenchExposes,\n configOptions: MediaLibraryConfigArtifactOptions = {},\n): GeneratedArtifact[] {\n return [\n ...viewArtifacts(exposes.views ?? []),\n ...webWorkerArtifacts(exposes.webWorkers ?? []),\n ...(exposes.config ? configArtifacts(exposes.config, configOptions) : []),\n ]\n}\n\nfunction configArtifacts(\n config: WorkbenchConfigValue,\n options: MediaLibraryConfigArtifactOptions,\n): GeneratedArtifact[] {\n const {appType} = config\n\n switch (appType) {\n case 'dashboard': {\n return dashboardConfigArtifacts(config)\n }\n case 'media-library': {\n return mediaLibraryConfigArtifacts(config, options)\n }\n default: {\n appType satisfies never\n throw new Error(`Cannot build artifacts for unknown app type: ${appType as string}`)\n }\n }\n}\n"],"names":["mediaLibraryConfigArtifacts","dashboardConfigArtifacts","viewArtifacts","webWorkerArtifacts","artifactExposes","artifacts","toExposePath","exposes","artifact","expose","path","workbenchArtifacts","configOptions","views","webWorkers","config","configArtifacts","options","appType","Error"],"mappings":"AAEA,SAEEA,2BAA2B,QACtB,wBAAuB;AAC9B,SAAQC,wBAAwB,QAAO,gCAA+B;AACtE,SAAQC,aAAa,QAAO,sBAAqB;AACjD,SAAQC,kBAAkB,QAAO,2BAA0B;AAwC3D;;;;;CAKC,GACD,OAAO,SAASC,gBACdC,SAAuC,EACvCC,YAA8C;IAE9C,MAAMC,UAAkC,CAAC;IACzC,KAAK,MAAMC,YAAYH,UAAW;QAChC,IAAIG,SAASC,MAAM,EAAE;YACnBF,OAAO,CAACC,SAASC,MAAM,CAAC,GAAGH,aAAaE,SAASE,IAAI;QACvD;IACF;IACA,OAAOH;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASI,mBACdJ,OAAyB,EACzBK,gBAAmD,CAAC,CAAC;IAErD,OAAO;WACFV,cAAcK,QAAQM,KAAK,IAAI,EAAE;WACjCV,mBAAmBI,QAAQO,UAAU,IAAI,EAAE;WAC1CP,QAAQQ,MAAM,GAAGC,gBAAgBT,QAAQQ,MAAM,EAAEH,iBAAiB,EAAE;KACzE;AACH;AAEA,SAASI,gBACPD,MAA4B,EAC5BE,OAA0C;IAE1C,MAAM,EAACC,OAAO,EAAC,GAAGH;IAElB,OAAQG;QACN,KAAK;YAAa;gBAChB,OAAOjB,yBAAyBc;YAClC;QACA,KAAK;YAAiB;gBACpB,OAAOf,4BAA4Be,QAAQE;YAC7C;QACA;YAAS;gBACPC;gBACA,MAAM,IAAIC,MAAM,CAAC,6CAA6C,EAAED,SAAmB;YACrF;IACF;AACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isWorkbenchApp, resolveAppTitle } from '../../defineApp.js';
|
|
2
|
+
import { resolveWorkbenchConfig } from '../../resolveWorkbenchConfig.js';
|
|
3
|
+
import { fetchDevSummaryDetails, formatLocalVersion } from '../dev/devSummary.js';
|
|
4
|
+
import { formatSummary } from '../summary.js';
|
|
5
|
+
const CONFIG_TITLES = {
|
|
6
|
+
dashboard: 'Dashboard configuration',
|
|
7
|
+
'media-library': 'Media Library configuration'
|
|
8
|
+
};
|
|
9
|
+
/** Starts the organization and deployment lookup beside a `sanity build`; `undefined` outside the Dashboard. */ export function startBuildSummary({ cliConfig, isApp }) {
|
|
10
|
+
const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined;
|
|
11
|
+
const config = resolveWorkbenchConfig(cliConfig);
|
|
12
|
+
const title = app ? resolveAppTitle(app) : config && CONFIG_TITLES[config.appType];
|
|
13
|
+
if (!title) return undefined;
|
|
14
|
+
const startedAt = Date.now();
|
|
15
|
+
const organizationId = cliConfig.app?.organizationId;
|
|
16
|
+
const details = fetchDevSummaryDetails({
|
|
17
|
+
idOrSlug: app && (cliConfig.deployment?.appId ?? app.slug),
|
|
18
|
+
organizationId
|
|
19
|
+
});
|
|
20
|
+
return async ()=>{
|
|
21
|
+
const durationMs = Date.now() - startedAt;
|
|
22
|
+
const { deployment, organizationName } = await details;
|
|
23
|
+
return formatSummary({
|
|
24
|
+
durationMs,
|
|
25
|
+
heading: `${title} built`,
|
|
26
|
+
isApp,
|
|
27
|
+
organization: organizationName ?? organizationId,
|
|
28
|
+
title: app && title,
|
|
29
|
+
version: formatLocalVersion('local build', deployment)
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=buildSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildSummary.ts"],"sourcesContent":["import {type CliConfig} from '@sanity/cli-core'\n\nimport {isWorkbenchApp, resolveAppTitle} from '../../defineApp.js'\nimport {resolveWorkbenchConfig} from '../../resolveWorkbenchConfig.js'\nimport {fetchDevSummaryDetails, formatLocalVersion} from '../dev/devSummary.js'\nimport {formatSummary} from '../summary.js'\n\nconst CONFIG_TITLES = {\n dashboard: 'Dashboard configuration',\n 'media-library': 'Media Library configuration',\n}\n\n/** Starts the organization and deployment lookup beside a `sanity build`; `undefined` outside the Dashboard. */\nexport function startBuildSummary({\n cliConfig,\n isApp,\n}: {\n cliConfig: CliConfig\n isApp: boolean\n}): (() => Promise<string>) | undefined {\n const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined\n const config = resolveWorkbenchConfig(cliConfig)\n const title = app ? resolveAppTitle(app) : config && CONFIG_TITLES[config.appType]\n if (!title) return undefined\n\n const startedAt = Date.now()\n const organizationId = cliConfig.app?.organizationId\n const details = fetchDevSummaryDetails({\n idOrSlug: app && (cliConfig.deployment?.appId ?? app.slug),\n organizationId,\n })\n\n return async () => {\n const durationMs = Date.now() - startedAt\n const {deployment, organizationName} = await details\n\n return formatSummary({\n durationMs,\n heading: `${title} built`,\n isApp,\n organization: organizationName ?? organizationId,\n title: app && title,\n version: formatLocalVersion('local build', deployment),\n })\n }\n}\n"],"names":["isWorkbenchApp","resolveAppTitle","resolveWorkbenchConfig","fetchDevSummaryDetails","formatLocalVersion","formatSummary","CONFIG_TITLES","dashboard","startBuildSummary","cliConfig","isApp","app","undefined","config","title","appType","startedAt","Date","now","organizationId","details","idOrSlug","deployment","appId","slug","durationMs","organizationName","heading","organization","version"],"mappings":"AAEA,SAAQA,cAAc,EAAEC,eAAe,QAAO,qBAAoB;AAClE,SAAQC,sBAAsB,QAAO,kCAAiC;AACtE,SAAQC,sBAAsB,EAAEC,kBAAkB,QAAO,uBAAsB;AAC/E,SAAQC,aAAa,QAAO,gBAAe;AAE3C,MAAMC,gBAAgB;IACpBC,WAAW;IACX,iBAAiB;AACnB;AAEA,8GAA8G,GAC9G,OAAO,SAASC,kBAAkB,EAChCC,SAAS,EACTC,KAAK,EAIN;IACC,MAAMC,MAAMX,eAAeS,UAAUE,GAAG,IAAIF,UAAUE,GAAG,GAAGC;IAC5D,MAAMC,SAASX,uBAAuBO;IACtC,MAAMK,QAAQH,MAAMV,gBAAgBU,OAAOE,UAAUP,aAAa,CAACO,OAAOE,OAAO,CAAC;IAClF,IAAI,CAACD,OAAO,OAAOF;IAEnB,MAAMI,YAAYC,KAAKC,GAAG;IAC1B,MAAMC,iBAAiBV,UAAUE,GAAG,EAAEQ;IACtC,MAAMC,UAAUjB,uBAAuB;QACrCkB,UAAUV,OAAQF,CAAAA,UAAUa,UAAU,EAAEC,SAASZ,IAAIa,IAAI,AAAD;QACxDL;IACF;IAEA,OAAO;QACL,MAAMM,aAAaR,KAAKC,GAAG,KAAKF;QAChC,MAAM,EAACM,UAAU,EAAEI,gBAAgB,EAAC,GAAG,MAAMN;QAE7C,OAAOf,cAAc;YACnBoB;YACAE,SAAS,GAAGb,MAAM,MAAM,CAAC;YACzBJ;YACAkB,cAAcF,oBAAoBP;YAClCL,OAAOH,OAAOG;YACde,SAASzB,mBAAmB,eAAekB;QAC7C;IACF;AACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { INSTALLATION_CONFIG_TYPE, MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION } from '../../../contract.js';
|
|
2
|
+
import { HOT_CONFIG_LISTENERS } from '../hotConfigListeners.js';
|
|
2
3
|
import { MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE } from './mediaLibraryIslandRuntime.js';
|
|
3
4
|
const CONFIGS_DIR_NAME = 'configs';
|
|
4
5
|
/**
|
|
@@ -15,8 +16,9 @@ const CONFIGS_DIR_NAME = 'configs';
|
|
|
15
16
|
{
|
|
16
17
|
expose: `./${CONFIGS_DIR_NAME}/${INSTALLATION_CONFIG_TYPE}`,
|
|
17
18
|
path: `${CONFIGS_DIR_NAME}/${INSTALLATION_CONFIG_TYPE}.js`,
|
|
18
|
-
source: ({ resolveImport })=>mediaLibraryConfigSource({
|
|
19
|
+
source: ({ dev = false, resolveImport })=>mediaLibraryConfigSource({
|
|
19
20
|
config,
|
|
21
|
+
dev,
|
|
20
22
|
resolveImport
|
|
21
23
|
})
|
|
22
24
|
},
|
|
@@ -34,65 +36,23 @@ const CONFIGS_DIR_NAME = 'configs';
|
|
|
34
36
|
* plus its live `defineField` value, the one thing the wire can't carry.
|
|
35
37
|
* `appType` stays off the module — the host assigns it from the wire record.
|
|
36
38
|
*/ function mediaLibraryConfigSource(input) {
|
|
37
|
-
const { config, resolveImport } = input;
|
|
38
|
-
const
|
|
39
|
-
const
|
|
39
|
+
const { config, dev, resolveImport } = input;
|
|
40
|
+
const specifiers = config.fields.map((field)=>JSON.stringify(resolveImport(field.src)));
|
|
41
|
+
const imports = dev ? `const fieldModules = await Promise.all([\n${specifiers.map((specifier)=>` import(${specifier}),`).join('\n')}\n])` : specifiers.map((specifier, index)=>`import field_${index} from ${specifier}`).join('\n');
|
|
42
|
+
const entries = config.fields.map((field, index)=>` {name: ${JSON.stringify(field.name)}, title: ${JSON.stringify(field.title)}, ` + `public: ${JSON.stringify(Boolean(field.public))}, config: ${dev ? `fieldModules[${index}].default` : `field_${index}`}},`).join('\n');
|
|
40
43
|
return `\
|
|
41
44
|
// This file is auto-generated on 'sanity build' / 'sanity dev'
|
|
42
45
|
// Modifications to this file are automatically discarded
|
|
43
|
-
${imports}
|
|
44
|
-
|
|
45
46
|
export const type = ${JSON.stringify(INSTALLATION_CONFIG_TYPE)}
|
|
46
47
|
export const version = ${MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION}
|
|
48
|
+
|
|
49
|
+
${HOT_CONFIG_LISTENERS}
|
|
50
|
+
${imports}
|
|
47
51
|
export const config = {
|
|
48
52
|
fields: [
|
|
49
53
|
${entries}
|
|
50
54
|
],
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
// Dev-only HMR handle. In dev the Media Library host loads this module into
|
|
54
|
-
// its own page through Module Federation, which keeps returning the first
|
|
55
|
-
// evaluation — the host cannot re-import its way to fresh code. So the host
|
|
56
|
-
// registers a listener here instead: on every hot update the outgoing module
|
|
57
|
-
// hands its live listener set to the incoming module, then replays the
|
|
58
|
-
// listeners with the fresh namespace, and the host re-applies the field
|
|
59
|
-
// config in place (the same pattern view remotes use). When nobody is
|
|
60
|
-
// listening — or a listener fails to apply — invalidate() escalates to
|
|
61
|
-
// Vite's native full reload, so the page can never keep rendering from
|
|
62
|
-
// stale config.
|
|
63
|
-
let listeners = new Set()
|
|
64
|
-
export function subscribe(listener) {
|
|
65
|
-
listeners.add(listener)
|
|
66
|
-
return () => listeners.delete(listener)
|
|
67
|
-
}
|
|
68
|
-
// Internal to the hot chain: the set object travels across updates so the
|
|
69
|
-
// unsubscribe closures handed out by any module generation keep deleting
|
|
70
|
-
// from the one live set (a copy would orphan them after the first update).
|
|
71
|
-
export function _adoptListeners(shared) {
|
|
72
|
-
listeners = shared
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (import.meta.hot) {
|
|
76
|
-
import.meta.hot.accept((next) => {
|
|
77
|
-
if (!next || typeof next._adoptListeners !== 'function' || listeners.size === 0) {
|
|
78
|
-
import.meta.hot.invalidate()
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
next._adoptListeners(listeners)
|
|
83
|
-
// Notify a snapshot: a listener may unsubscribe and re-subscribe on the
|
|
84
|
-
// fresh namespace, which (post-adoption) mutates this very set — and a
|
|
85
|
-
// Set iterator revisits re-added entries, so iterating live would loop
|
|
86
|
-
// forever. Entries added mid-loop subscribed to the already-current
|
|
87
|
-
// namespace and need no notification for this update.
|
|
88
|
-
for (const listener of [...listeners]) {
|
|
89
|
-
listener(next)
|
|
90
|
-
}
|
|
91
|
-
} catch {
|
|
92
|
-
import.meta.hot.invalidate()
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
56
|
`;
|
|
97
57
|
}
|
|
98
58
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/build/configs/artifact.ts"],"sourcesContent":["import {INSTALLATION_CONFIG_TYPE, MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION} from '../../../contract.js'\nimport {type GeneratedArtifact} from '../artifact.js'\nimport {MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE} from './mediaLibraryIslandRuntime.js'\n\nconst CONFIGS_DIR_NAME = 'configs'\n\n/**\n * The Media Library config to generate a module for.\n * @internal\n */\nexport interface MediaLibraryConfigArtifact {\n fields: {name: string; public?: boolean; src: string; title: string}[]\n}\n\n/** Build-time capabilities that gate optional Media Library config artifacts. */\nexport interface MediaLibraryConfigArtifactOptions {\n /**\n * Whether the app's installed `sanity` ships the Media Library island-mount\n * runtime ({@link MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE}). Gates the\n * `./media-library-island-runtime` expose — emitting it against an older\n * `sanity` would fail the build on an unresolvable import.\n */\n islandRuntime?: boolean\n}\n\n/**\n * Expand the Media Library config into its federation modules: one aggregating\n * all fields (so the host imports one live config value), plus — when the\n * installed `sanity` ships it — the island-mount runtime the host uses to\n * render custom field inputs in isolated React roots.\n *\n * Everything here is Media Library-specific (the one config type today);\n * a second config type gets its own expander next to this one.\n */\nexport function mediaLibraryConfigArtifacts(\n config: MediaLibraryConfigArtifact | undefined,\n options: MediaLibraryConfigArtifactOptions = {},\n): GeneratedArtifact[] {\n if (!config) return []\n return [\n {\n expose: `./${CONFIGS_DIR_NAME}/${INSTALLATION_CONFIG_TYPE}`,\n path: `${CONFIGS_DIR_NAME}/${INSTALLATION_CONFIG_TYPE}.js`,\n source: ({resolveImport})
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/build/configs/artifact.ts"],"sourcesContent":["import {INSTALLATION_CONFIG_TYPE, MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION} from '../../../contract.js'\nimport {type GeneratedArtifact} from '../artifact.js'\nimport {HOT_CONFIG_LISTENERS} from '../hotConfigListeners.js'\nimport {MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE} from './mediaLibraryIslandRuntime.js'\n\nconst CONFIGS_DIR_NAME = 'configs'\n\n/**\n * The Media Library config to generate a module for.\n * @internal\n */\nexport interface MediaLibraryConfigArtifact {\n fields: {name: string; public?: boolean; src: string; title: string}[]\n}\n\n/** Build-time capabilities that gate optional Media Library config artifacts. */\nexport interface MediaLibraryConfigArtifactOptions {\n /**\n * Whether the app's installed `sanity` ships the Media Library island-mount\n * runtime ({@link MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE}). Gates the\n * `./media-library-island-runtime` expose — emitting it against an older\n * `sanity` would fail the build on an unresolvable import.\n */\n islandRuntime?: boolean\n}\n\n/**\n * Expand the Media Library config into its federation modules: one aggregating\n * all fields (so the host imports one live config value), plus — when the\n * installed `sanity` ships it — the island-mount runtime the host uses to\n * render custom field inputs in isolated React roots.\n *\n * Everything here is Media Library-specific (the one config type today);\n * a second config type gets its own expander next to this one.\n */\nexport function mediaLibraryConfigArtifacts(\n config: MediaLibraryConfigArtifact | undefined,\n options: MediaLibraryConfigArtifactOptions = {},\n): GeneratedArtifact[] {\n if (!config) return []\n return [\n {\n expose: `./${CONFIGS_DIR_NAME}/${INSTALLATION_CONFIG_TYPE}`,\n path: `${CONFIGS_DIR_NAME}/${INSTALLATION_CONFIG_TYPE}.js`,\n source: ({dev = false, resolveImport}) =>\n mediaLibraryConfigSource({config, dev, resolveImport}),\n },\n ...(options.islandRuntime\n ? [\n {\n expose: './media-library-island-runtime',\n path: `${CONFIGS_DIR_NAME}/media_library_island_runtime.js`,\n source: () => mediaLibraryIslandRuntimeSource(),\n },\n ]\n : []),\n ]\n}\n\n/**\n * Emits `export const config`: each field's serializable `{name, title, public}`\n * plus its live `defineField` value, the one thing the wire can't carry.\n * `appType` stays off the module — the host assigns it from the wire record.\n */\nfunction mediaLibraryConfigSource(input: {\n config: MediaLibraryConfigArtifact\n dev: boolean\n resolveImport: (src: string) => string\n}): string {\n const {config, dev, resolveImport} = input\n const specifiers = config.fields.map((field) => JSON.stringify(resolveImport(field.src)))\n const imports = dev\n ? `const fieldModules = await Promise.all([\\n${specifiers.map((specifier) => ` import(${specifier}),`).join('\\n')}\\n])`\n : specifiers.map((specifier, index) => `import field_${index} from ${specifier}`).join('\\n')\n const entries = config.fields\n .map(\n (field, index) =>\n ` {name: ${JSON.stringify(field.name)}, title: ${JSON.stringify(field.title)}, ` +\n `public: ${JSON.stringify(Boolean(field.public))}, config: ${dev ? `fieldModules[${index}].default` : `field_${index}`}},`,\n )\n .join('\\n')\n return `\\\n// This file is auto-generated on 'sanity build' / 'sanity dev'\n// Modifications to this file are automatically discarded\nexport const type = ${JSON.stringify(INSTALLATION_CONFIG_TYPE)}\nexport const version = ${MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION}\n\n${HOT_CONFIG_LISTENERS}\n${imports}\nexport const config = {\n fields: [\n${entries}\n ],\n}\n`\n}\n\n/**\n * One line on purpose: the runtime implementation lives in the `sanity`\n * package and is bundled into the remote from the app's own install, so the\n * runtime always matches the `sanity` version field modules compile against.\n */\nfunction mediaLibraryIslandRuntimeSource(): string {\n return `\\\n// This file is auto-generated on 'sanity build' / 'sanity dev'\n// Modifications to this file are automatically discarded\nexport * from ${JSON.stringify(MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE)}\n`\n}\n"],"names":["INSTALLATION_CONFIG_TYPE","MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION","HOT_CONFIG_LISTENERS","MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE","CONFIGS_DIR_NAME","mediaLibraryConfigArtifacts","config","options","expose","path","source","dev","resolveImport","mediaLibraryConfigSource","islandRuntime","mediaLibraryIslandRuntimeSource","input","specifiers","fields","map","field","JSON","stringify","src","imports","specifier","join","index","entries","name","title","Boolean","public"],"mappings":"AAAA,SAAQA,wBAAwB,EAAEC,qCAAqC,QAAO,uBAAsB;AAEpG,SAAQC,oBAAoB,QAAO,2BAA0B;AAC7D,SAAQC,mCAAmC,QAAO,iCAAgC;AAElF,MAAMC,mBAAmB;AAqBzB;;;;;;;;CAQC,GACD,OAAO,SAASC,4BACdC,MAA8C,EAC9CC,UAA6C,CAAC,CAAC;IAE/C,IAAI,CAACD,QAAQ,OAAO,EAAE;IACtB,OAAO;QACL;YACEE,QAAQ,CAAC,EAAE,EAAEJ,iBAAiB,CAAC,EAAEJ,0BAA0B;YAC3DS,MAAM,GAAGL,iBAAiB,CAAC,EAAEJ,yBAAyB,GAAG,CAAC;YAC1DU,QAAQ,CAAC,EAACC,MAAM,KAAK,EAAEC,aAAa,EAAC,GACnCC,yBAAyB;oBAACP;oBAAQK;oBAAKC;gBAAa;QACxD;WACIL,QAAQO,aAAa,GACrB;YACE;gBACEN,QAAQ;gBACRC,MAAM,GAAGL,iBAAiB,gCAAgC,CAAC;gBAC3DM,QAAQ,IAAMK;YAChB;SACD,GACD,EAAE;KACP;AACH;AAEA;;;;CAIC,GACD,SAASF,yBAAyBG,KAIjC;IACC,MAAM,EAACV,MAAM,EAAEK,GAAG,EAAEC,aAAa,EAAC,GAAGI;IACrC,MAAMC,aAAaX,OAAOY,MAAM,CAACC,GAAG,CAAC,CAACC,QAAUC,KAAKC,SAAS,CAACV,cAAcQ,MAAMG,GAAG;IACtF,MAAMC,UAAUb,MACZ,CAAC,0CAA0C,EAAEM,WAAWE,GAAG,CAAC,CAACM,YAAc,CAAC,SAAS,EAAEA,UAAU,EAAE,CAAC,EAAEC,IAAI,CAAC,MAAM,IAAI,CAAC,GACtHT,WAAWE,GAAG,CAAC,CAACM,WAAWE,QAAU,CAAC,aAAa,EAAEA,MAAM,MAAM,EAAEF,WAAW,EAAEC,IAAI,CAAC;IACzF,MAAME,UAAUtB,OAAOY,MAAM,CAC1BC,GAAG,CACF,CAACC,OAAOO,QACN,CAAC,WAAW,EAAEN,KAAKC,SAAS,CAACF,MAAMS,IAAI,EAAE,SAAS,EAAER,KAAKC,SAAS,CAACF,MAAMU,KAAK,EAAE,EAAE,CAAC,GACnF,CAAC,QAAQ,EAAET,KAAKC,SAAS,CAACS,QAAQX,MAAMY,MAAM,GAAG,UAAU,EAAErB,MAAM,CAAC,aAAa,EAAEgB,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,EAAEA,OAAO,CAAC,EAAE,CAAC,EAE7HD,IAAI,CAAC;IACR,OAAO,CAAC;;;oBAGU,EAAEL,KAAKC,SAAS,CAACtB,0BAA0B;uBACxC,EAAEC,sCAAsC;;AAE/D,EAAEC,qBAAqB;AACvB,EAAEsB,QAAQ;;;AAGV,EAAEI,QAAQ;;;AAGV,CAAC;AACD;AAEA;;;;CAIC,GACD,SAASb;IACP,OAAO,CAAC;;;cAGI,EAAEM,KAAKC,SAAS,CAACnB,qCAAqC;AACpE,CAAC;AACD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DASHBOARD_CONFIG_CONTRACT_VERSION, DASHBOARD_CONFIG_TYPE } from '../../../contract.js';
|
|
2
|
+
import { HOT_CONFIG_LISTENERS } from '../hotConfigListeners.js';
|
|
3
|
+
export function dashboardConfigArtifacts(dashboardConfig) {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
expose: `./${DASHBOARD_CONFIG_TYPE}`,
|
|
7
|
+
path: `${DASHBOARD_CONFIG_TYPE}.js`,
|
|
8
|
+
source: ({ dev, resolveImport })=>{
|
|
9
|
+
const specifier = JSON.stringify(resolveImport(dashboardConfig.src));
|
|
10
|
+
return `\
|
|
11
|
+
// This file is auto-generated on 'sanity build' / 'sanity dev'
|
|
12
|
+
// Modifications to this file are automatically discarded
|
|
13
|
+
export const type = ${JSON.stringify(DASHBOARD_CONFIG_TYPE)}
|
|
14
|
+
export const version = ${DASHBOARD_CONFIG_CONTRACT_VERSION}
|
|
15
|
+
|
|
16
|
+
${HOT_CONFIG_LISTENERS}
|
|
17
|
+
${dev ? `const {default: config} = await import(${specifier})` : `import config from ${specifier}`}
|
|
18
|
+
export {config}
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/build/dashboardConfig/artifact.ts"],"sourcesContent":["import {DASHBOARD_CONFIG_CONTRACT_VERSION, DASHBOARD_CONFIG_TYPE} from '../../../contract.js'\nimport {type GeneratedArtifact} from '../artifact.js'\nimport {HOT_CONFIG_LISTENERS} from '../hotConfigListeners.js'\n\nexport function dashboardConfigArtifacts(dashboardConfig: {src: string}): GeneratedArtifact[] {\n return [\n {\n expose: `./${DASHBOARD_CONFIG_TYPE}`,\n path: `${DASHBOARD_CONFIG_TYPE}.js`,\n source: ({dev, resolveImport}) => {\n const specifier = JSON.stringify(resolveImport(dashboardConfig.src))\n\n return `\\\n// This file is auto-generated on 'sanity build' / 'sanity dev'\n// Modifications to this file are automatically discarded\nexport const type = ${JSON.stringify(DASHBOARD_CONFIG_TYPE)}\nexport const version = ${DASHBOARD_CONFIG_CONTRACT_VERSION}\n\n${HOT_CONFIG_LISTENERS}\n${dev ? `const {default: config} = await import(${specifier})` : `import config from ${specifier}`}\nexport {config}\n`\n },\n },\n ]\n}\n"],"names":["DASHBOARD_CONFIG_CONTRACT_VERSION","DASHBOARD_CONFIG_TYPE","HOT_CONFIG_LISTENERS","dashboardConfigArtifacts","dashboardConfig","expose","path","source","dev","resolveImport","specifier","JSON","stringify","src"],"mappings":"AAAA,SAAQA,iCAAiC,EAAEC,qBAAqB,QAAO,uBAAsB;AAE7F,SAAQC,oBAAoB,QAAO,2BAA0B;AAE7D,OAAO,SAASC,yBAAyBC,eAA8B;IACrE,OAAO;QACL;YACEC,QAAQ,CAAC,EAAE,EAAEJ,uBAAuB;YACpCK,MAAM,GAAGL,sBAAsB,GAAG,CAAC;YACnCM,QAAQ,CAAC,EAACC,GAAG,EAAEC,aAAa,EAAC;gBAC3B,MAAMC,YAAYC,KAAKC,SAAS,CAACH,cAAcL,gBAAgBS,GAAG;gBAElE,OAAO,CAAC;;;oBAGI,EAAEF,KAAKC,SAAS,CAACX,uBAAuB;uBACrC,EAAED,kCAAkC;;AAE3D,EAAEE,qBAAqB;AACvB,EAAEM,MAAM,CAAC,uCAAuC,EAAEE,UAAU,CAAC,CAAC,GAAG,CAAC,mBAAmB,EAAEA,WAAW,CAAC;;AAEnG,CAAC;YACK;QACF;KACD;AACH"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const HOT_CONFIG_LISTENERS = `\
|
|
2
|
+
// The host keeps its first Module Federation load and subscribes here. hot.data
|
|
3
|
+
// shares listeners with later instances, even one whose import threw, so a broken
|
|
4
|
+
// save keeps the last good config. Without a listener, invalidate() reloads.
|
|
5
|
+
const listeners = import.meta.hot ? (import.meta.hot.data.listeners ??= new Set()) : new Set()
|
|
6
|
+
export function subscribe(listener) {
|
|
7
|
+
listeners.add(listener)
|
|
8
|
+
return () => listeners.delete(listener)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (import.meta.hot) {
|
|
12
|
+
import.meta.hot.accept((next) => {
|
|
13
|
+
// Vite passes no module when the update threw; it has already logged why.
|
|
14
|
+
if (!next) {
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (listeners.size === 0) {
|
|
19
|
+
import.meta.hot.invalidate()
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
// A snapshot, because a listener may re-subscribe on the fresh module.
|
|
24
|
+
for (const listener of [...listeners]) {
|
|
25
|
+
listener(next)
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
import.meta.hot.invalidate()
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=hotConfigListeners.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/hotConfigListeners.ts"],"sourcesContent":["export const HOT_CONFIG_LISTENERS = `\\\n// The host keeps its first Module Federation load and subscribes here. hot.data\n// shares listeners with later instances, even one whose import threw, so a broken\n// save keeps the last good config. Without a listener, invalidate() reloads.\nconst listeners = import.meta.hot ? (import.meta.hot.data.listeners ??= new Set()) : new Set()\nexport function subscribe(listener) {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nif (import.meta.hot) {\n import.meta.hot.accept((next) => {\n // Vite passes no module when the update threw; it has already logged why.\n if (!next) {\n return\n }\n\n if (listeners.size === 0) {\n import.meta.hot.invalidate()\n return\n }\n try {\n // A snapshot, because a listener may re-subscribe on the fresh module.\n for (const listener of [...listeners]) {\n listener(next)\n }\n } catch {\n import.meta.hot.invalidate()\n }\n })\n}\n`\n"],"names":["HOT_CONFIG_LISTENERS"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BrC,CAAC,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { deriveConfigEntries } from '../../dev/deriveConfigs.js';
|
|
3
4
|
import { isMediaLibraryConfigApp } from '../configs/configApp.js';
|
|
4
5
|
import { hasMediaLibraryIslandRuntime, MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE } from '../configs/mediaLibraryIslandRuntime.js';
|
|
5
6
|
/**
|
|
@@ -64,7 +65,7 @@ import { hasMediaLibraryIslandRuntime, MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE } fro
|
|
|
64
65
|
const interfaceSources = [
|
|
65
66
|
...(exposes?.views ?? []).map((view)=>view.src),
|
|
66
67
|
...(exposes?.webWorkers ?? []).map((webWorker)=>webWorker.src),
|
|
67
|
-
...(exposes?.config
|
|
68
|
+
...(exposes?.config ? deriveConfigEntries(exposes.config) : []).map((entry)=>entry.src)
|
|
68
69
|
].map((src)=>path.resolve(cwd, src));
|
|
69
70
|
const entries = [
|
|
70
71
|
...appSources,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/build/vite/optimize-deps.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport {type WorkbenchExposes} from '../../../resolveWorkbenchApp.js'\nimport {isMediaLibraryConfigApp} from '../configs/configApp.js'\nimport {\n hasMediaLibraryIslandRuntime,\n MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE,\n} from '../configs/mediaLibraryIslandRuntime.js'\n\n/**\n * React APIs only the generated render-contract modules import — the SPA\n * bootstrap (`getEntryModule`) and every render artifact (`renderRemote`)\n * `createRoot` from `react-dom/client` and `createElement` from `react`. No\n * app/interface source imports `react-dom/client` itself, so scanning `entries`\n * never surfaces it; every workbench app depends on react/react-dom, so both\n * always resolve.\n */\nconst RENDER_CONTRACT_DEPS = ['react', 'react-dom/client']\n\n/** Extensions an import-style source path may omit, in resolution order. */\nconst SOURCE_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs']\n\n/**\n * Resolve an import-style source path to the file on disk. The app `entry`\n * defaults to the extensionless `./src/App` (and a user may omit the extension\n * anywhere), which the runtime imports fine through Vite's resolver — but\n * `optimizeDeps.entries` is matched against the filesystem, so an extensionless\n * path never matches and its deps go unscanned. Try the path as-is, then the\n * common source extensions; fall back to the input so an already-resolved path\n * (or a genuinely missing one) passes through unchanged.\n */\nfunction resolveSourceFile(absPath: string): string {\n if (fs.existsSync(absPath) && fs.statSync(absPath).isFile()) return absPath\n for (const extension of SOURCE_EXTENSIONS) {\n if (fs.existsSync(`${absPath}${extension}`)) return `${absPath}${extension}`\n }\n return absPath\n}\n\n/**\n * Dep pre-bundling inputs for a workbench app's dev server.\n *\n * Vite's dep scanner crawls from the app's HTML entry, which reaches only the\n * app's `entry` (or a studio's config) — never the federation `exposes` (dock\n * views, web workers, media-library config fields), which the host loads\n * dynamically at runtime. So a dep imported only by an exposed module (e.g.\n * `sanity/workbench` in a web worker or view) escapes the startup scan; Vite\n * discovers it on first request, re-optimizes, and full-page reloads — which\n * flakes Playwright in e2e.\n *\n * Point `entries` at the source of every interface: the app `entry` (or, for a\n * studio, its config), plus each view, web worker, and installation-config source.\n * `entries` follows real import statements, so it covers whatever those sources\n * transitively use — correct subpaths and all — with no hand-maintained dep\n * list, and never crashes on an unresolvable name the way a bad `include` entry\n * does. Each source is resolved to its on-disk file so an extensionless path\n * (like the default `./src/App`) still matches `entries`' filesystem glob.\n *\n * @param cwd - Project root; `entries` are returned relative to it.\n * @param appSources - Absolute paths to the app's `entry` and/or studio config.\n * @param exposes - The app's declared views/web workers/config.\n * @internal\n */\nexport function workbenchOptimizeDeps(options: {\n appSources: readonly string[]\n cwd: string\n exposes?: WorkbenchExposes\n}): {entries: string[]; include: string[]} {\n const {appSources, cwd, exposes} = options\n\n const interfaceSources = [\n ...(exposes?.views ?? []).map((view) => view.src),\n ...(exposes?.webWorkers ?? []).map((webWorker) => webWorker.src),\n ...(exposes?.config
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/build/vite/optimize-deps.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport {type WorkbenchExposes} from '../../../resolveWorkbenchApp.js'\nimport {deriveConfigEntries} from '../../dev/deriveConfigs.js'\nimport {isMediaLibraryConfigApp} from '../configs/configApp.js'\nimport {\n hasMediaLibraryIslandRuntime,\n MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE,\n} from '../configs/mediaLibraryIslandRuntime.js'\n\n/**\n * React APIs only the generated render-contract modules import — the SPA\n * bootstrap (`getEntryModule`) and every render artifact (`renderRemote`)\n * `createRoot` from `react-dom/client` and `createElement` from `react`. No\n * app/interface source imports `react-dom/client` itself, so scanning `entries`\n * never surfaces it; every workbench app depends on react/react-dom, so both\n * always resolve.\n */\nconst RENDER_CONTRACT_DEPS = ['react', 'react-dom/client']\n\n/** Extensions an import-style source path may omit, in resolution order. */\nconst SOURCE_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs']\n\n/**\n * Resolve an import-style source path to the file on disk. The app `entry`\n * defaults to the extensionless `./src/App` (and a user may omit the extension\n * anywhere), which the runtime imports fine through Vite's resolver — but\n * `optimizeDeps.entries` is matched against the filesystem, so an extensionless\n * path never matches and its deps go unscanned. Try the path as-is, then the\n * common source extensions; fall back to the input so an already-resolved path\n * (or a genuinely missing one) passes through unchanged.\n */\nfunction resolveSourceFile(absPath: string): string {\n if (fs.existsSync(absPath) && fs.statSync(absPath).isFile()) return absPath\n for (const extension of SOURCE_EXTENSIONS) {\n if (fs.existsSync(`${absPath}${extension}`)) return `${absPath}${extension}`\n }\n return absPath\n}\n\n/**\n * Dep pre-bundling inputs for a workbench app's dev server.\n *\n * Vite's dep scanner crawls from the app's HTML entry, which reaches only the\n * app's `entry` (or a studio's config) — never the federation `exposes` (dock\n * views, web workers, media-library config fields), which the host loads\n * dynamically at runtime. So a dep imported only by an exposed module (e.g.\n * `sanity/workbench` in a web worker or view) escapes the startup scan; Vite\n * discovers it on first request, re-optimizes, and full-page reloads — which\n * flakes Playwright in e2e.\n *\n * Point `entries` at the source of every interface: the app `entry` (or, for a\n * studio, its config), plus each view, web worker, and installation-config source.\n * `entries` follows real import statements, so it covers whatever those sources\n * transitively use — correct subpaths and all — with no hand-maintained dep\n * list, and never crashes on an unresolvable name the way a bad `include` entry\n * does. Each source is resolved to its on-disk file so an extensionless path\n * (like the default `./src/App`) still matches `entries`' filesystem glob.\n *\n * @param cwd - Project root; `entries` are returned relative to it.\n * @param appSources - Absolute paths to the app's `entry` and/or studio config.\n * @param exposes - The app's declared views/web workers/config.\n * @internal\n */\nexport function workbenchOptimizeDeps(options: {\n appSources: readonly string[]\n cwd: string\n exposes?: WorkbenchExposes\n}): {entries: string[]; include: string[]} {\n const {appSources, cwd, exposes} = options\n\n const interfaceSources = [\n ...(exposes?.views ?? []).map((view) => view.src),\n ...(exposes?.webWorkers ?? []).map((webWorker) => webWorker.src),\n ...(exposes?.config ? deriveConfigEntries(exposes.config) : []).map((entry) => entry.src),\n ].map((src) => path.resolve(cwd, src))\n\n const entries = [...appSources, ...interfaceSources].map((absPath) => {\n const resolved = resolveSourceFile(absPath)\n return path.relative(cwd, resolved).split(path.sep).join('/')\n })\n\n // The generated `./island-runtime` expose imports this entry, but the file is\n // codegen (never in `entries`), so the startup scan misses it. Only when the\n // installed `sanity` ships the entry — an unresolvable `include` name crashes\n // the dev server, and the expose is skipped in that case anyway.\n const islandRuntimeDeps =\n isMediaLibraryConfigApp(exposes) && hasMediaLibraryIslandRuntime(cwd)\n ? [MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE]\n : []\n\n return {\n entries: [...new Set(entries)],\n include: [...RENDER_CONTRACT_DEPS, ...islandRuntimeDeps],\n }\n}\n"],"names":["fs","path","deriveConfigEntries","isMediaLibraryConfigApp","hasMediaLibraryIslandRuntime","MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE","RENDER_CONTRACT_DEPS","SOURCE_EXTENSIONS","resolveSourceFile","absPath","existsSync","statSync","isFile","extension","workbenchOptimizeDeps","options","appSources","cwd","exposes","interfaceSources","views","map","view","src","webWorkers","webWorker","config","entry","resolve","entries","resolved","relative","split","sep","join","islandRuntimeDeps","Set","include"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAG5B,SAAQC,mBAAmB,QAAO,6BAA4B;AAC9D,SAAQC,uBAAuB,QAAO,0BAAyB;AAC/D,SACEC,4BAA4B,EAC5BC,mCAAmC,QAC9B,0CAAyC;AAEhD;;;;;;;CAOC,GACD,MAAMC,uBAAuB;IAAC;IAAS;CAAmB;AAE1D,0EAA0E,GAC1E,MAAMC,oBAAoB;IAAC;IAAQ;IAAO;IAAQ;IAAO;IAAQ;CAAO;AAExE;;;;;;;;CAQC,GACD,SAASC,kBAAkBC,OAAe;IACxC,IAAIT,GAAGU,UAAU,CAACD,YAAYT,GAAGW,QAAQ,CAACF,SAASG,MAAM,IAAI,OAAOH;IACpE,KAAK,MAAMI,aAAaN,kBAAmB;QACzC,IAAIP,GAAGU,UAAU,CAAC,GAAGD,UAAUI,WAAW,GAAG,OAAO,GAAGJ,UAAUI,WAAW;IAC9E;IACA,OAAOJ;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASK,sBAAsBC,OAIrC;IACC,MAAM,EAACC,UAAU,EAAEC,GAAG,EAAEC,OAAO,EAAC,GAAGH;IAEnC,MAAMI,mBAAmB;WACpB,AAACD,CAAAA,SAASE,SAAS,EAAE,AAAD,EAAGC,GAAG,CAAC,CAACC,OAASA,KAAKC,GAAG;WAC7C,AAACL,CAAAA,SAASM,cAAc,EAAE,AAAD,EAAGH,GAAG,CAAC,CAACI,YAAcA,UAAUF,GAAG;WAC5D,AAACL,CAAAA,SAASQ,SAASxB,oBAAoBgB,QAAQQ,MAAM,IAAI,EAAE,AAAD,EAAGL,GAAG,CAAC,CAACM,QAAUA,MAAMJ,GAAG;KACzF,CAACF,GAAG,CAAC,CAACE,MAAQtB,KAAK2B,OAAO,CAACX,KAAKM;IAEjC,MAAMM,UAAU;WAAIb;WAAeG;KAAiB,CAACE,GAAG,CAAC,CAACZ;QACxD,MAAMqB,WAAWtB,kBAAkBC;QACnC,OAAOR,KAAK8B,QAAQ,CAACd,KAAKa,UAAUE,KAAK,CAAC/B,KAAKgC,GAAG,EAAEC,IAAI,CAAC;IAC3D;IAEA,8EAA8E;IAC9E,6EAA6E;IAC7E,8EAA8E;IAC9E,iEAAiE;IACjE,MAAMC,oBACJhC,wBAAwBe,YAAYd,6BAA6Ba,OAC7D;QAACZ;KAAoC,GACrC,EAAE;IAER,OAAO;QACLwB,SAAS;eAAI,IAAIO,IAAIP;SAAS;QAC9BQ,SAAS;eAAI/B;eAAyB6B;SAAkB;IAC1D;AACF"}
|
|
@@ -9,13 +9,14 @@ function relativeImport(fromFile, toFile) {
|
|
|
9
9
|
const rel = path.relative(path.dirname(fromFile), toFile).split(path.sep).join('/');
|
|
10
10
|
return rel.startsWith('.') ? rel : `./${rel}`;
|
|
11
11
|
}
|
|
12
|
-
function writeArtifacts({ artifacts, isolateStyles, root }) {
|
|
12
|
+
function writeArtifacts({ artifacts, dev, isolateStyles, root }) {
|
|
13
13
|
for (const artifact of artifacts){
|
|
14
14
|
const artifactPath = path.resolve(root, RUNTIME_DIR, artifact.path);
|
|
15
15
|
fs.mkdirSync(path.dirname(artifactPath), {
|
|
16
16
|
recursive: true
|
|
17
17
|
});
|
|
18
18
|
fs.writeFileSync(artifactPath, artifact.source({
|
|
19
|
+
dev,
|
|
19
20
|
isolateStyles,
|
|
20
21
|
resolveImport: (src)=>relativeImport(artifactPath, path.resolve(root, src))
|
|
21
22
|
}));
|
|
@@ -45,6 +46,7 @@ function writeArtifacts({ artifacts, isolateStyles, root }) {
|
|
|
45
46
|
configResolved (config) {
|
|
46
47
|
writeArtifacts({
|
|
47
48
|
artifacts: options.artifacts,
|
|
49
|
+
dev: config.command === 'serve',
|
|
48
50
|
isolateStyles: getFederationApi(config.plugins)?.isolateStyles ?? false,
|
|
49
51
|
root: config.root
|
|
50
52
|
});
|