@sanity/workbench-cli 2.19.1 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/_exports/build.d.ts +3 -2
  2. package/dist/_exports/build.js.map +1 -1
  3. package/dist/_exports/defineApp-COehpvlC.d.ts +376 -0
  4. package/dist/_exports/deploy.d.ts +22 -44
  5. package/dist/_exports/deploy.js +2 -0
  6. package/dist/_exports/deploy.js.map +1 -1
  7. package/dist/_exports/{summarizeInterfaces-AM-QbtIA.d.ts → deploySummary-DU7_Vcyq.d.ts} +30 -4
  8. package/dist/_exports/dev.d.ts +1 -1
  9. package/dist/_exports/index.d.ts +22 -4
  10. package/dist/_exports/index.js +2 -1
  11. package/dist/_exports/index.js.map +1 -1
  12. package/dist/_exports/preview.d.ts +1 -1
  13. package/dist/_exports/{registry-DZWnj09G.d.ts → registry-Da2PAcT1.d.ts} +17 -11
  14. package/dist/_exports/{resolveWorkbenchConfig-_iD6fVUH.d.ts → resolveWorkbenchApp-Bn0tsSDM.d.ts} +5 -20
  15. package/dist/_exports/resolveWorkbenchConfig-DkrkqN9H.d.ts +10 -0
  16. package/dist/_exports/undeploy.d.ts +6 -6
  17. package/dist/_exports/undeploy.js +1 -0
  18. package/dist/_exports/undeploy.js.map +1 -1
  19. package/dist/actions/build/artifact.js +20 -1
  20. package/dist/actions/build/artifact.js.map +1 -1
  21. package/dist/actions/build/configs/artifact.js +10 -50
  22. package/dist/actions/build/configs/artifact.js.map +1 -1
  23. package/dist/actions/build/dashboardConfig/artifact.js +25 -0
  24. package/dist/actions/build/dashboardConfig/artifact.js.map +1 -0
  25. package/dist/actions/build/hotConfigListeners.js +34 -0
  26. package/dist/actions/build/hotConfigListeners.js.map +1 -0
  27. package/dist/actions/build/vite/optimize-deps.js +2 -1
  28. package/dist/actions/build/vite/optimize-deps.js.map +1 -1
  29. package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js +3 -1
  30. package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js.map +1 -1
  31. package/dist/actions/deploy/deployConfig.js +9 -7
  32. package/dist/actions/deploy/deployConfig.js.map +1 -1
  33. package/dist/actions/deploy/deployPayload.js.map +1 -1
  34. package/dist/actions/deploy/deploySummary.js +24 -5
  35. package/dist/actions/deploy/deploySummary.js.map +1 -1
  36. package/dist/actions/deploy/deployWorkbenchApp.js +31 -13
  37. package/dist/actions/deploy/deployWorkbenchApp.js.map +1 -1
  38. package/dist/actions/deploy/uploadDashboardConfig.js +34 -0
  39. package/dist/actions/deploy/uploadDashboardConfig.js.map +1 -0
  40. package/dist/actions/dev/deriveConfigs.js +17 -13
  41. package/dist/actions/dev/deriveConfigs.js.map +1 -1
  42. package/dist/actions/dev/registry.js +34 -20
  43. package/dist/actions/dev/registry.js.map +1 -1
  44. package/dist/actions/dev/startDevServerRegistration.js +20 -11
  45. package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
  46. package/dist/actions/dev/startWorkbenchDev.js +2 -2
  47. package/dist/actions/dev/startWorkbenchDev.js.map +1 -1
  48. package/dist/actions/preview/serveBuiltApplication.js +9 -7
  49. package/dist/actions/preview/serveBuiltApplication.js.map +1 -1
  50. package/dist/actions/preview/startWorkbenchPreview.js +52 -19
  51. package/dist/actions/preview/startWorkbenchPreview.js.map +1 -1
  52. package/dist/actions/undeploy/workbenchUndeployAdapter.js +50 -3
  53. package/dist/actions/undeploy/workbenchUndeployAdapter.js.map +1 -1
  54. package/dist/contract.js +20 -3
  55. package/dist/contract.js.map +1 -1
  56. package/dist/dashboardConfig.js +5 -0
  57. package/dist/dashboardConfig.js.map +1 -0
  58. package/dist/defineApp.js +25 -2
  59. package/dist/defineApp.js.map +1 -1
  60. package/dist/deriveInterfaces.js +24 -13
  61. package/dist/deriveInterfaces.js.map +1 -1
  62. package/dist/readAppIcon.js +3 -3
  63. package/dist/readAppIcon.js.map +1 -1
  64. package/dist/resolveWorkbenchApp.js +3 -2
  65. package/dist/resolveWorkbenchApp.js.map +1 -1
  66. package/dist/resolveWorkbenchConfig.js +11 -16
  67. package/dist/resolveWorkbenchConfig.js.map +1 -1
  68. package/dist/services/applications.js +12 -1
  69. package/dist/services/applications.js.map +1 -1
  70. package/dist/services/dashboard-configs.js +54 -0
  71. package/dist/services/dashboard-configs.js.map +1 -0
  72. package/package.json +8 -8
  73. package/dist/_exports/contract-WrU3aOYd.d.ts +0 -187
  74. package/dist/_exports/defineApp-9ppP3UQR.d.ts +0 -175
@@ -1,5 +1,6 @@
1
1
  export { defineAssetSourceView, definePanelView, defineTileView, defineWebWorker, defineWindowView } from '../contract.js';
2
- export { defineApplication, isWorkbenchApp, isWorkbenchConfig, unstable_defineMediaLibrary } from '../defineApp.js';
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 AssetSourceView,\n DefineAssetSourceViewInput,\n DefinePanelViewInput,\n DefineTileViewInput,\n DefineWebWorkerInput,\n DefineWindowViewInput,\n DockGroup,\n PanelView,\n ServiceType,\n TileSize,\n TileView,\n ViewDeclaration,\n ViewSurface,\n WebWorker,\n WebWorkerType,\n WindowView,\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
+ {"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-DZWnj09G.js";
1
+ import { t as DevServerManifest } from "./registry-Da2PAcT1.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,31 +1,36 @@
1
- import "./defineApp-9ppP3UQR.js";
1
+ import "./defineApp-COehpvlC.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.ZodMiniOptional<z.ZodMiniString<string>>;
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>>;
20
24
  interfaces: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
21
25
  metadata: z.ZodMiniNullable<z.ZodMiniObject<{
22
- dock: z.ZodMiniObject<{
26
+ dock: z.ZodMiniOptional<z.ZodMiniObject<{
23
27
  group: z.ZodMiniOptional<z.ZodMiniEnum<{
24
28
  system: "system";
25
29
  applications: "applications";
26
30
  }>>;
27
31
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
28
- }, z.core.$strip>;
32
+ }, z.core.$strip>>;
33
+ icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
29
34
  }, z.core.$strip>>;
30
35
  surface: z.ZodMiniLiteral<"window">;
31
36
  id: z.ZodMiniString<string>;
@@ -36,13 +41,14 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
36
41
  version: z.ZodMiniOptional<z.ZodMiniString<string>>;
37
42
  }, z.core.$strip>, z.ZodMiniObject<{
38
43
  metadata: z.ZodMiniNullable<z.ZodMiniObject<{
39
- dock: z.ZodMiniObject<{
44
+ dock: z.ZodMiniOptional<z.ZodMiniObject<{
40
45
  group: z.ZodMiniOptional<z.ZodMiniEnum<{
41
46
  system: "system";
42
47
  applications: "applications";
43
48
  }>>;
44
49
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
45
- }, z.core.$strip>;
50
+ }, z.core.$strip>>;
51
+ icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
46
52
  }, z.core.$strip>>;
47
53
  surface: z.ZodMiniLiteral<"panel">;
48
54
  id: z.ZodMiniString<string>;
@@ -130,4 +136,4 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
130
136
  */
131
137
  type DevServerManifest = z.infer<typeof devServerManifestSchema>;
132
138
  export { DevServerManifest as t };
133
- //# sourceMappingURL=registry-DZWnj09G.d.ts.map
139
+ //# sourceMappingURL=registry-Da2PAcT1.d.ts.map
@@ -1,5 +1,4 @@
1
- import { b as WorkbenchConfigValue } from "./contract-WrU3aOYd.js";
2
- import { t as DefineAppInput } from "./defineApp-9ppP3UQR.js";
1
+ import { F as WorkbenchConfigValue, n as DefineAppInput } from "./defineApp-COehpvlC.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
- /** @public */
52
- interface ResolvedMediaLibraryConfig {
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-_iD6fVUH.d.ts.map
52
+ export { resolveWorkbenchApp as i, WorkbenchExposes as n, resolveAppEntry as r, ResolvedWorkbenchApp as t };
53
+ //# sourceMappingURL=resolveWorkbenchApp-Bn0tsSDM.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { l as WorkbenchConfig } from "./defineApp-COehpvlC.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-DkrkqN9H.d.ts.map
@@ -1,5 +1,5 @@
1
- import { t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-_iD6fVUH.js";
2
- import { a as DeployableWorkbenchApp, n as DeployedView, r as DeployedWebWorker } from "./summarizeInterfaces-AM-QbtIA.js";
1
+ import { l as WorkbenchConfig } from "./defineApp-COehpvlC.js";
2
+ import { a as DeployedView, c as DeployableWorkbenchApp, o as DeployedWebWorker, r as formatUndeploySummary } from "./deploySummary-DU7_Vcyq.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 — the media library — deletes its
24
- * installation's config snapshots instead. The two are severed at the source,
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?: ResolvedMediaLibraryConfig;
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,3 +1,4 @@
1
+ export { formatUndeploySummary } from '../actions/deploy/deploySummary.js';
1
2
  export { createWorkbenchUndeployAdapter } from '../actions/undeploy/workbenchUndeployAdapter.js';
2
3
 
3
4
  //# sourceMappingURL=undeploy.js.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
- ...mediaLibraryConfigArtifacts(exposes.config, configOptions)
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 ...mediaLibraryConfigArtifacts(exposes.config, configOptions),\n ]\n}\n"],"names":["mediaLibraryConfigArtifacts","viewArtifacts","webWorkerArtifacts","artifactExposes","artifacts","toExposePath","exposes","artifact","expose","path","workbenchArtifacts","configOptions","views","webWorkers","config"],"mappings":"AACA,SAEEA,2BAA2B,QACtB,wBAAuB;AAC9B,SAAQC,aAAa,QAAO,sBAAqB;AACjD,SAAQC,kBAAkB,QAAO,2BAA0B;AAsC3D;;;;;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;WAC3Cb,4BAA4BM,QAAQQ,MAAM,EAAEH;KAChD;AACH"}
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"}
@@ -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 imports = config.fields.map((field, index)=>`import field_${index} from ${JSON.stringify(resolveImport(field.src))}`).join('\n');
39
- const entries = config.fields.map((field, index)=>` {name: ${JSON.stringify(field.name)}, title: ${JSON.stringify(field.title)}, ` + `public: ${JSON.stringify(Boolean(field.public))}, config: field_${index}},`).join('\n');
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}) => mediaLibraryConfigSource({config, 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 resolveImport: (src: string) => string\n}): string {\n const {config, resolveImport} = input\n const imports = config.fields\n .map((field, index) => `import field_${index} from ${JSON.stringify(resolveImport(field.src))}`)\n .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: 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\n${imports}\n\nexport const type = ${JSON.stringify(INSTALLATION_CONFIG_TYPE)}\nexport const version = ${MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION}\nexport const config = {\n fields: [\n${entries}\n ],\n}\n\n// Dev-only HMR handle. In dev the Media Library host loads this module into\n// its own page through Module Federation, which keeps returning the first\n// evaluation — the host cannot re-import its way to fresh code. So the host\n// registers a listener here instead: on every hot update the outgoing module\n// hands its live listener set to the incoming module, then replays the\n// listeners with the fresh namespace, and the host re-applies the field\n// config in place (the same pattern view remotes use). When nobody is\n// listening — or a listener fails to apply — invalidate() escalates to\n// Vite's native full reload, so the page can never keep rendering from\n// stale config.\nlet listeners = new Set()\nexport function subscribe(listener) {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n// Internal to the hot chain: the set object travels across updates so the\n// unsubscribe closures handed out by any module generation keep deleting\n// from the one live set (a copy would orphan them after the first update).\nexport function _adoptListeners(shared) {\n listeners = shared\n}\n\nif (import.meta.hot) {\n import.meta.hot.accept((next) => {\n if (!next || typeof next._adoptListeners !== 'function' || listeners.size === 0) {\n import.meta.hot.invalidate()\n return\n }\n try {\n next._adoptListeners(listeners)\n // Notify a snapshot: a listener may unsubscribe and re-subscribe on the\n // fresh namespace, which (post-adoption) mutates this very set — and a\n // Set iterator revisits re-added entries, so iterating live would loop\n // forever. Entries added mid-loop subscribed to the already-current\n // namespace and need no notification for this update.\n for (const listener of [...listeners]) {\n listener(next)\n }\n } catch {\n import.meta.hot.invalidate()\n }\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","MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE","CONFIGS_DIR_NAME","mediaLibraryConfigArtifacts","config","options","expose","path","source","resolveImport","mediaLibraryConfigSource","islandRuntime","mediaLibraryIslandRuntimeSource","input","imports","fields","map","field","index","JSON","stringify","src","join","entries","name","title","Boolean","public"],"mappings":"AAAA,SAAQA,wBAAwB,EAAEC,qCAAqC,QAAO,uBAAsB;AAEpG,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,EAAEH,0BAA0B;YAC3DQ,MAAM,GAAGL,iBAAiB,CAAC,EAAEH,yBAAyB,GAAG,CAAC;YAC1DS,QAAQ,CAAC,EAACC,aAAa,EAAC,GAAKC,yBAAyB;oBAACN;oBAAQK;gBAAa;QAC9E;WACIJ,QAAQM,aAAa,GACrB;YACE;gBACEL,QAAQ;gBACRC,MAAM,GAAGL,iBAAiB,gCAAgC,CAAC;gBAC3DM,QAAQ,IAAMI;YAChB;SACD,GACD,EAAE;KACP;AACH;AAEA;;;;CAIC,GACD,SAASF,yBAAyBG,KAGjC;IACC,MAAM,EAACT,MAAM,EAAEK,aAAa,EAAC,GAAGI;IAChC,MAAMC,UAAUV,OAAOW,MAAM,CAC1BC,GAAG,CAAC,CAACC,OAAOC,QAAU,CAAC,aAAa,EAAEA,MAAM,MAAM,EAAEC,KAAKC,SAAS,CAACX,cAAcQ,MAAMI,GAAG,IAAI,EAC9FC,IAAI,CAAC;IACR,MAAMC,UAAUnB,OAAOW,MAAM,CAC1BC,GAAG,CACF,CAACC,OAAOC,QACN,CAAC,WAAW,EAAEC,KAAKC,SAAS,CAACH,MAAMO,IAAI,EAAE,SAAS,EAAEL,KAAKC,SAAS,CAACH,MAAMQ,KAAK,EAAE,EAAE,CAAC,GACnF,CAAC,QAAQ,EAAEN,KAAKC,SAAS,CAACM,QAAQT,MAAMU,MAAM,GAAG,gBAAgB,EAAET,MAAM,EAAE,CAAC,EAE/EI,IAAI,CAAC;IACR,OAAO,CAAC;;;AAGV,EAAER,QAAQ;;oBAEU,EAAEK,KAAKC,SAAS,CAACrB,0BAA0B;uBACxC,EAAEC,sCAAsC;;;AAG/D,EAAEuB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CV,CAAC;AACD;AAEA;;;;CAIC,GACD,SAASX;IACP,OAAO,CAAC;;;cAGI,EAAEO,KAAKC,SAAS,CAACnB,qCAAqC;AACpE,CAAC;AACD"}
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?.fields ?? []).map((field)=>field.src)
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?.fields ?? []).map((field) => field.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","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","fields","field","resolve","entries","resolved","relative","split","sep","join","islandRuntimeDeps","Set","include"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAG5B,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,IAAIR,GAAGS,UAAU,CAACD,YAAYR,GAAGU,QAAQ,CAACF,SAASG,MAAM,IAAI,OAAOH;IACpE,KAAK,MAAMI,aAAaN,kBAAmB;QACzC,IAAIN,GAAGS,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,QAAQC,UAAU,EAAE,AAAD,EAAGN,GAAG,CAAC,CAACO,QAAUA,MAAML,GAAG;KAC5D,CAACF,GAAG,CAAC,CAACE,MAAQrB,KAAK2B,OAAO,CAACZ,KAAKM;IAEjC,MAAMO,UAAU;WAAId;WAAeG;KAAiB,CAACE,GAAG,CAAC,CAACZ;QACxD,MAAMsB,WAAWvB,kBAAkBC;QACnC,OAAOP,KAAK8B,QAAQ,CAACf,KAAKc,UAAUE,KAAK,CAAC/B,KAAKgC,GAAG,EAAEC,IAAI,CAAC;IAC3D;IAEA,8EAA8E;IAC9E,6EAA6E;IAC7E,8EAA8E;IAC9E,iEAAiE;IACjE,MAAMC,oBACJjC,wBAAwBe,YAAYd,6BAA6Ba,OAC7D;QAACZ;KAAoC,GACrC,EAAE;IAER,OAAO;QACLyB,SAAS;eAAI,IAAIO,IAAIP;SAAS;QAC9BQ,SAAS;eAAIhC;eAAyB8B;SAAkB;IAC1D;AACF"}
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
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/actions/build/vite/plugins/plugin-sanity-extension-artifacts.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport {fileURLToPath} from 'node:url'\n\nimport {type Plugin} from 'vite'\n\nimport {type GeneratedArtifact} from '../../artifact.js'\nimport {WORKER_BUS_ENTRY} from '../../webWorkers/artifact.js'\nimport {RUNTIME_DIR} from '../constants.js'\nimport {getFederationApi} from './plugin-module-federation.js'\n\nconst workerBusPath = fileURLToPath(\n new URL('../../../../_exports/_internal_worker_bus.js', import.meta.url),\n)\n\nfunction relativeImport(fromFile: string, toFile: string): string {\n const rel = path.relative(path.dirname(fromFile), toFile).split(path.sep).join('/')\n return rel.startsWith('.') ? rel : `./${rel}`\n}\n\nfunction writeArtifacts({\n artifacts,\n isolateStyles,\n root,\n}: {\n artifacts: readonly GeneratedArtifact[]\n isolateStyles: boolean\n root: string\n}): void {\n for (const artifact of artifacts) {\n const artifactPath = path.resolve(root, RUNTIME_DIR, artifact.path)\n fs.mkdirSync(path.dirname(artifactPath), {recursive: true})\n fs.writeFileSync(\n artifactPath,\n artifact.source({\n isolateStyles,\n resolveImport: (src) => relativeImport(artifactPath, path.resolve(root, src)),\n }),\n )\n }\n}\n\n/**\n * Writes the federation runtime artifacts (view render-contract modules, web worker\n * worker bundles + loaders) into `RUNTIME_DIR`, resolving each artifact's import\n * paths relative to where it lands on disk. The set is expanded once by\n * `workbenchArtifacts` and handed in — this plugin only writes it.\n */\nexport function sanityExtensionArtifacts(options: {\n artifacts: readonly GeneratedArtifact[]\n}): Plugin {\n return {\n // The generated worker.js imports the bus client from this package, which\n // the app has no dependency on and so can't resolve by name.\n config: () => ({\n optimizeDeps: {exclude: [WORKER_BUS_ENTRY]},\n resolve: {alias: {[WORKER_BUS_ENTRY]: workerBusPath}},\n }),\n configResolved(config) {\n writeArtifacts({\n artifacts: options.artifacts,\n isolateStyles: getFederationApi(config.plugins)?.isolateStyles ?? false,\n root: config.root,\n })\n },\n name: 'sanity/extension-artifacts',\n }\n}\n"],"names":["fs","path","fileURLToPath","WORKER_BUS_ENTRY","RUNTIME_DIR","getFederationApi","workerBusPath","URL","url","relativeImport","fromFile","toFile","rel","relative","dirname","split","sep","join","startsWith","writeArtifacts","artifacts","isolateStyles","root","artifact","artifactPath","resolve","mkdirSync","recursive","writeFileSync","source","resolveImport","src","sanityExtensionArtifacts","options","config","optimizeDeps","exclude","alias","configResolved","plugins","name"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAC5B,SAAQC,aAAa,QAAO,WAAU;AAKtC,SAAQC,gBAAgB,QAAO,+BAA8B;AAC7D,SAAQC,WAAW,QAAO,kBAAiB;AAC3C,SAAQC,gBAAgB,QAAO,gCAA+B;AAE9D,MAAMC,gBAAgBJ,cACpB,IAAIK,IAAI,gDAAgD,YAAYC,GAAG;AAGzE,SAASC,eAAeC,QAAgB,EAAEC,MAAc;IACtD,MAAMC,MAAMX,KAAKY,QAAQ,CAACZ,KAAKa,OAAO,CAACJ,WAAWC,QAAQI,KAAK,CAACd,KAAKe,GAAG,EAAEC,IAAI,CAAC;IAC/E,OAAOL,IAAIM,UAAU,CAAC,OAAON,MAAM,CAAC,EAAE,EAAEA,KAAK;AAC/C;AAEA,SAASO,eAAe,EACtBC,SAAS,EACTC,aAAa,EACbC,IAAI,EAKL;IACC,KAAK,MAAMC,YAAYH,UAAW;QAChC,MAAMI,eAAevB,KAAKwB,OAAO,CAACH,MAAMlB,aAAamB,SAAStB,IAAI;QAClED,GAAG0B,SAAS,CAACzB,KAAKa,OAAO,CAACU,eAAe;YAACG,WAAW;QAAI;QACzD3B,GAAG4B,aAAa,CACdJ,cACAD,SAASM,MAAM,CAAC;YACdR;YACAS,eAAe,CAACC,MAAQtB,eAAee,cAAcvB,KAAKwB,OAAO,CAACH,MAAMS;QAC1E;IAEJ;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASC,yBAAyBC,OAExC;IACC,OAAO;QACL,0EAA0E;QAC1E,6DAA6D;QAC7DC,QAAQ,IAAO,CAAA;gBACbC,cAAc;oBAACC,SAAS;wBAACjC;qBAAiB;gBAAA;gBAC1CsB,SAAS;oBAACY,OAAO;wBAAC,CAAClC,iBAAiB,EAAEG;oBAAa;gBAAC;YACtD,CAAA;QACAgC,gBAAeJ,MAAM;YACnBf,eAAe;gBACbC,WAAWa,QAAQb,SAAS;gBAC5BC,eAAehB,iBAAiB6B,OAAOK,OAAO,GAAGlB,iBAAiB;gBAClEC,MAAMY,OAAOZ,IAAI;YACnB;QACF;QACAkB,MAAM;IACR;AACF"}
1
+ {"version":3,"sources":["../../../../../src/actions/build/vite/plugins/plugin-sanity-extension-artifacts.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport {fileURLToPath} from 'node:url'\n\nimport {type Plugin} from 'vite'\n\nimport {type GeneratedArtifact} from '../../artifact.js'\nimport {WORKER_BUS_ENTRY} from '../../webWorkers/artifact.js'\nimport {RUNTIME_DIR} from '../constants.js'\nimport {getFederationApi} from './plugin-module-federation.js'\n\nconst workerBusPath = fileURLToPath(\n new URL('../../../../_exports/_internal_worker_bus.js', import.meta.url),\n)\n\nfunction relativeImport(fromFile: string, toFile: string): string {\n const rel = path.relative(path.dirname(fromFile), toFile).split(path.sep).join('/')\n return rel.startsWith('.') ? rel : `./${rel}`\n}\n\nfunction writeArtifacts({\n artifacts,\n dev,\n isolateStyles,\n root,\n}: {\n artifacts: readonly GeneratedArtifact[]\n dev: boolean\n isolateStyles: boolean\n root: string\n}): void {\n for (const artifact of artifacts) {\n const artifactPath = path.resolve(root, RUNTIME_DIR, artifact.path)\n fs.mkdirSync(path.dirname(artifactPath), {recursive: true})\n fs.writeFileSync(\n artifactPath,\n artifact.source({\n dev,\n isolateStyles,\n resolveImport: (src) => relativeImport(artifactPath, path.resolve(root, src)),\n }),\n )\n }\n}\n\n/**\n * Writes the federation runtime artifacts (view render-contract modules, web worker\n * worker bundles + loaders) into `RUNTIME_DIR`, resolving each artifact's import\n * paths relative to where it lands on disk. The set is expanded once by\n * `workbenchArtifacts` and handed in — this plugin only writes it.\n */\nexport function sanityExtensionArtifacts(options: {\n artifacts: readonly GeneratedArtifact[]\n}): Plugin {\n return {\n // The generated worker.js imports the bus client from this package, which\n // the app has no dependency on and so can't resolve by name.\n config: () => ({\n optimizeDeps: {exclude: [WORKER_BUS_ENTRY]},\n resolve: {alias: {[WORKER_BUS_ENTRY]: workerBusPath}},\n }),\n configResolved(config) {\n writeArtifacts({\n artifacts: options.artifacts,\n dev: config.command === 'serve',\n isolateStyles: getFederationApi(config.plugins)?.isolateStyles ?? false,\n root: config.root,\n })\n },\n name: 'sanity/extension-artifacts',\n }\n}\n"],"names":["fs","path","fileURLToPath","WORKER_BUS_ENTRY","RUNTIME_DIR","getFederationApi","workerBusPath","URL","url","relativeImport","fromFile","toFile","rel","relative","dirname","split","sep","join","startsWith","writeArtifacts","artifacts","dev","isolateStyles","root","artifact","artifactPath","resolve","mkdirSync","recursive","writeFileSync","source","resolveImport","src","sanityExtensionArtifacts","options","config","optimizeDeps","exclude","alias","configResolved","command","plugins","name"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAC5B,SAAQC,aAAa,QAAO,WAAU;AAKtC,SAAQC,gBAAgB,QAAO,+BAA8B;AAC7D,SAAQC,WAAW,QAAO,kBAAiB;AAC3C,SAAQC,gBAAgB,QAAO,gCAA+B;AAE9D,MAAMC,gBAAgBJ,cACpB,IAAIK,IAAI,gDAAgD,YAAYC,GAAG;AAGzE,SAASC,eAAeC,QAAgB,EAAEC,MAAc;IACtD,MAAMC,MAAMX,KAAKY,QAAQ,CAACZ,KAAKa,OAAO,CAACJ,WAAWC,QAAQI,KAAK,CAACd,KAAKe,GAAG,EAAEC,IAAI,CAAC;IAC/E,OAAOL,IAAIM,UAAU,CAAC,OAAON,MAAM,CAAC,EAAE,EAAEA,KAAK;AAC/C;AAEA,SAASO,eAAe,EACtBC,SAAS,EACTC,GAAG,EACHC,aAAa,EACbC,IAAI,EAML;IACC,KAAK,MAAMC,YAAYJ,UAAW;QAChC,MAAMK,eAAexB,KAAKyB,OAAO,CAACH,MAAMnB,aAAaoB,SAASvB,IAAI;QAClED,GAAG2B,SAAS,CAAC1B,KAAKa,OAAO,CAACW,eAAe;YAACG,WAAW;QAAI;QACzD5B,GAAG6B,aAAa,CACdJ,cACAD,SAASM,MAAM,CAAC;YACdT;YACAC;YACAS,eAAe,CAACC,MAAQvB,eAAegB,cAAcxB,KAAKyB,OAAO,CAACH,MAAMS;QAC1E;IAEJ;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASC,yBAAyBC,OAExC;IACC,OAAO;QACL,0EAA0E;QAC1E,6DAA6D;QAC7DC,QAAQ,IAAO,CAAA;gBACbC,cAAc;oBAACC,SAAS;wBAAClC;qBAAiB;gBAAA;gBAC1CuB,SAAS;oBAACY,OAAO;wBAAC,CAACnC,iBAAiB,EAAEG;oBAAa;gBAAC;YACtD,CAAA;QACAiC,gBAAeJ,MAAM;YACnBhB,eAAe;gBACbC,WAAWc,QAAQd,SAAS;gBAC5BC,KAAKc,OAAOK,OAAO,KAAK;gBACxBlB,eAAejB,iBAAiB8B,OAAOM,OAAO,GAAGnB,iBAAiB;gBAClEC,MAAMY,OAAOZ,IAAI;YACnB;QACF;QACAmB,MAAM;IACR;AACF"}
@@ -1,9 +1,7 @@
1
1
  import { basename, dirname } from 'node:path';
2
- import { styleText } from 'node:util';
3
2
  import { createGzip } from 'node:zlib';
4
3
  import { subdebug } from '@sanity/cli-core';
5
4
  import { c as createTar } from 'tar';
6
- import { getWorkbenchUrl } from '../../services/applications.js';
7
5
  import { createConfig, resolveSingletonInstallationId } from '../../services/installations.js';
8
6
  import { summarizeGroup } from './summarizeInterfaces.js';
9
7
  const debug = subdebug('deploy');
@@ -28,14 +26,20 @@ const debug = subdebug('deploy');
28
26
  * one of potentially many shapes.
29
27
  * @internal
30
28
  */ export function summarizeConfig(config) {
31
- switch(config.appType){
29
+ const { appType } = config;
30
+ switch(appType){
31
+ case 'dashboard':
32
+ {
33
+ return `Dashboard configuration: ${config.src}`;
34
+ }
32
35
  case 'media-library':
33
36
  {
34
37
  return summarizeGroup('Media library fields', config.fields);
35
38
  }
36
39
  default:
37
40
  {
38
- throw new Error(`Cannot create config for unknown app type: ${config.appType}`);
41
+ appType;
42
+ throw new Error(`Cannot summarize unknown app type: ${appType}`);
39
43
  }
40
44
  }
41
45
  }
@@ -45,7 +49,7 @@ const debug = subdebug('deploy');
45
49
  * reaches this mutating step.
46
50
  * @internal
47
51
  */ export async function deployConfig(options) {
48
- const { appType, installationId, organizationId, output, sourceDir, version } = options;
52
+ const { appType, installationId, sourceDir, version } = options;
49
53
  const tarball = createTar({
50
54
  cwd: dirname(sourceDir)
51
55
  }, [
@@ -56,8 +60,6 @@ const debug = subdebug('deploy');
56
60
  version
57
61
  });
58
62
  debug('Deployed config for app type: %s', appType);
59
- const url = getWorkbenchUrl(organizationId);
60
- output.log(`\n🚀 ${styleText('bold', 'Success!')} Config deployed to ${styleText('cyan', url)}`);
61
63
  }
62
64
 
63
65
  //# sourceMappingURL=deployConfig.js.map