@sanity/workbench-cli 2.8.4 → 2.10.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 (49) hide show
  1. package/dist/_exports/_internal_worker_bus.d.ts +29 -0
  2. package/dist/_exports/_internal_worker_bus.js +3 -0
  3. package/dist/_exports/_internal_worker_bus.js.map +1 -0
  4. package/dist/_exports/build.d.ts +2 -2
  5. package/dist/_exports/build.js +1 -1
  6. package/dist/_exports/build.js.map +1 -1
  7. package/dist/_exports/contract-D_HnLQtT.d.ts +197 -0
  8. package/dist/_exports/defineApp-4hImcIIe.d.ts +182 -0
  9. package/dist/_exports/defineService-C1MhDwmh.d.ts +74 -0
  10. package/dist/_exports/deploy.d.ts +11 -3
  11. package/dist/_exports/index.d.ts +4 -50
  12. package/dist/_exports/index.js.map +1 -1
  13. package/dist/_exports/{resolveWorkbenchConfig-KhXnVKZ6.d.ts → resolveWorkbenchConfig-DEttN7ks.d.ts} +9 -3
  14. package/dist/_exports/{summarizeInterfaces-noqbAtVC.d.ts → summarizeInterfaces-Co97VU2z.d.ts} +4 -4
  15. package/dist/_exports/undeploy.d.ts +2 -2
  16. package/dist/actions/build/artifact.js +3 -3
  17. package/dist/actions/build/artifact.js.map +1 -1
  18. package/dist/actions/build/configs/artifact.js +70 -5
  19. package/dist/actions/build/configs/artifact.js.map +1 -1
  20. package/dist/actions/build/configs/configApp.js +15 -0
  21. package/dist/actions/build/configs/configApp.js.map +1 -0
  22. package/dist/actions/build/configs/mediaLibraryIslandRuntime.js +25 -0
  23. package/dist/actions/build/configs/mediaLibraryIslandRuntime.js.map +1 -0
  24. package/dist/actions/build/services/artifact.js +13 -3
  25. package/dist/actions/build/services/artifact.js.map +1 -1
  26. package/dist/actions/build/services/workerBus.js +159 -0
  27. package/dist/actions/build/services/workerBus.js.map +1 -0
  28. package/dist/actions/build/vite/optimize-deps.js +11 -1
  29. package/dist/actions/build/vite/optimize-deps.js.map +1 -1
  30. package/dist/actions/build/vite/plugin.js +15 -1
  31. package/dist/actions/build/vite/plugin.js.map +1 -1
  32. package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js +17 -0
  33. package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js.map +1 -1
  34. package/dist/actions/build/vite/plugins/plugin-strip-sui-global-reset.js +82 -0
  35. package/dist/actions/build/vite/plugins/plugin-strip-sui-global-reset.js.map +1 -0
  36. package/dist/actions/build/vite/workbench-vite-plugins.js +13 -2
  37. package/dist/actions/build/vite/workbench-vite-plugins.js.map +1 -1
  38. package/dist/actions/deploy/checkBuiltOutput.js +10 -2
  39. package/dist/actions/deploy/checkBuiltOutput.js.map +1 -1
  40. package/dist/actions/deploy/deployWorkbenchApp.js +10 -3
  41. package/dist/actions/deploy/deployWorkbenchApp.js.map +1 -1
  42. package/dist/defineService.js +11 -2
  43. package/dist/defineService.js.map +1 -1
  44. package/dist/resolveWorkbenchApp.js +16 -0
  45. package/dist/resolveWorkbenchApp.js.map +1 -1
  46. package/dist/services/applications.js +20 -8
  47. package/dist/services/applications.js.map +1 -1
  48. package/package.json +9 -4
  49. package/dist/_exports/defineApp-DOJE2kjo.d.ts +0 -376
@@ -1,5 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { artifactExposes, workbenchArtifacts } from '../artifact.js';
3
+ import { isMediaLibraryConfigApp } from '../configs/configApp.js';
4
+ import { hasMediaLibraryIslandRuntime, MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE } from '../configs/mediaLibraryIslandRuntime.js';
3
5
  import { FEDERATION_FILE_NAME, RUNTIME_DIR } from './constants.js';
4
6
  import { sanityFederationHost } from './plugins/plugin-federation-host.js';
5
7
  import { sanityModuleFederation } from './plugins/plugin-module-federation.js';
@@ -26,11 +28,23 @@ import { sanityFederationRuntime } from './plugins/plugin-sanity-federation-runt
26
28
  return resolvedPath;
27
29
  }
28
30
  const entryPath = resolveEntryPath(generatedEntry);
31
+ // A Media Library config's `./island-runtime` expose re-exports the mount
32
+ // runtime from the app's installed `sanity`; skip it (the host falls back to
33
+ // degraded rendering for custom inputs) when that version predates the entry,
34
+ // since an unresolvable import would fail the whole build.
35
+ const isConfigApp = isMediaLibraryConfigApp(exposes);
36
+ const islandRuntime = isConfigApp && hasMediaLibraryIslandRuntime(workDir);
37
+ if (isConfigApp && !islandRuntime) {
38
+ // eslint-disable-next-line no-console -- build-time warning for the app developer
39
+ console.warn(`The installed sanity version does not ship ${MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE}; ` + 'custom field inputs will not render in the Media Library until sanity is upgraded.');
40
+ }
29
41
  // Each view component (`./views/<view>/<component>`) and each service loader
30
42
  // (`./services/<name>`) is exposed straight to the host, pointing at the file
31
43
  // the extension-artifacts plugin generates under RUNTIME_DIR. A service's
32
44
  // worker bundle carries no expose — the host reaches it through its loader.
33
- const artifacts = workbenchArtifacts(exposes ?? {});
45
+ const artifacts = workbenchArtifacts(exposes ?? {}, {
46
+ islandRuntime
47
+ });
34
48
  const artifactModuleExposes = artifactExposes(artifacts, (artifactPath)=>resolveEntryPath(`./${RUNTIME_DIR}/${artifactPath}`));
35
49
  // A dock-only app (`isApp` with no `appEntry`) has no navigable full-page
36
50
  // view, so it exposes no `./App` — only its views. Studios and apps with an
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/build/vite/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type ModuleFederationOptions} from '@module-federation/vite'\nimport {type PackageJson} from '@sanity/cli-core'\nimport {type PluginOption} from 'vite'\n\nimport {type WorkbenchExposes} from '../../../resolveWorkbenchApp.js'\nimport {artifactExposes, workbenchArtifacts} from '../artifact.js'\nimport {FEDERATION_FILE_NAME, RUNTIME_DIR} from './constants.js'\nimport {sanityFederationHost} from './plugins/plugin-federation-host.js'\nimport {type FederationOptions, sanityModuleFederation} from './plugins/plugin-module-federation.js'\nimport {sanityEnvironmentPlugin} from './plugins/plugin-sanity-environment.js'\nimport {sanityExtensionArtifacts} from './plugins/plugin-sanity-extension-artifacts.js'\nimport {\n type FederationRuntimeOptions,\n sanityFederationRuntime,\n} from './plugins/plugin-sanity-federation-runtime.js'\n\ninterface FederationPluginOptionsBase extends Omit<Partial<FederationOptions>, 'exposes'> {\n exposes?: WorkbenchExposes\n /** Blueprints build (via `@sanity/runtime-cli`) — emit the resource-bindings module. */\n isBlueprints?: boolean\n pkgJson?: PackageJson\n /**\n * Current working directory to read package.json from, defaults to process.cwd()\n */\n workDir?: string\n}\n\ninterface AppFederationPluginOptions extends FederationPluginOptionsBase {\n isApp: true\n\n /**\n * Relative path to the App entry from the runtime directory, e.g.\n * `../../src/App.tsx`. Omit it for a dock-only app that declares no `entry`:\n * no `./App` is exposed and the remote serves only its views.\n */\n appEntry?: string\n studioConfigPath?: never\n}\n\ninterface StudioFederationPluginOptions extends FederationPluginOptionsBase {\n /** relative path to the Studio config file from the runtime directory (e.g. `../../sanity.config.ts`). */\n studioConfigPath: string\n\n appEntry?: never\n /** @defaultValue false */\n isApp?: false\n}\n\n/**\n * Plugin options for the federation vite plugin.\n *\n * Discriminated on `isApp`:\n * - `isApp: true` → requires `appEntry`\n * - `isApp: false` (default) → requires `studioConfigPath`\n *\n * @internal\n */\ntype FederationPluginOptions = AppFederationPluginOptions | StudioFederationPluginOptions\n\n/**\n * @internal\n */\nexport const federation = (options: FederationPluginOptions): PluginOption => {\n const {exposes, isBlueprints, name: defaultName, pkgJson, workDir = process.cwd()} = options\n\n let name = defaultName\n\n if (!name) {\n name = pkgJson?.name\n }\n\n if (!name) {\n throw new Error('\"name\" option is required but could not be inferred from package.json')\n }\n\n const generatedEntry = `./${RUNTIME_DIR}/${FEDERATION_FILE_NAME}.jsx`\n\n function resolveEntryPath(entry: string) {\n const resolvedPath = path.resolve(workDir, entry)\n\n if (!resolvedPath) {\n throw new Error(\n `Could not resolve path for entry \"${entry}\". Please check that the file exists and the path is correct.`,\n )\n }\n\n return resolvedPath\n }\n\n const entryPath = resolveEntryPath(generatedEntry)\n\n // Each view component (`./views/<view>/<component>`) and each service loader\n // (`./services/<name>`) is exposed straight to the host, pointing at the file\n // the extension-artifacts plugin generates under RUNTIME_DIR. A service's\n // worker bundle carries no expose — the host reaches it through its loader.\n const artifacts = workbenchArtifacts(exposes ?? {})\n const artifactModuleExposes = artifactExposes(artifacts, (artifactPath) =>\n resolveEntryPath(`./${RUNTIME_DIR}/${artifactPath}`),\n )\n\n // A dock-only app (`isApp` with no `appEntry`) has no navigable full-page\n // view, so it exposes no `./App` — only its views. Studios and apps with an\n // entry expose `./App` (the generated render entry).\n const exposesApp = !options.isApp || options.appEntry !== undefined\n\n const federationExposes: NonNullable<ModuleFederationOptions['exposes']> = {\n ...(exposesApp ? {'./App': entryPath} : {}),\n ...artifactModuleExposes,\n }\n\n const runtimeOptions: FederationRuntimeOptions = options.isApp\n ? {appEntry: options.appEntry, isApp: true, isBlueprints}\n : {isApp: false, isBlueprints, studioConfigPath: options.studioConfigPath}\n\n // Every federated app and studio also serves itself standalone. Whenever there's\n // an `./App` to mount (never for a dock-only app), build the SPA client\n // environment from the runtime bootstrap cli-build writes.\n const clientInput = exposesApp ? path.join(workDir, '.sanity', 'runtime', 'app.js') : undefined\n\n return [\n sanityEnvironmentPlugin({clientInput, input: entryPath, isBlueprints}),\n sanityFederationRuntime(runtimeOptions),\n sanityExtensionArtifacts({artifacts}),\n sanityModuleFederation({exposes: federationExposes, name}),\n sanityFederationHost(),\n ]\n}\n"],"names":["path","artifactExposes","workbenchArtifacts","FEDERATION_FILE_NAME","RUNTIME_DIR","sanityFederationHost","sanityModuleFederation","sanityEnvironmentPlugin","sanityExtensionArtifacts","sanityFederationRuntime","federation","options","exposes","isBlueprints","name","defaultName","pkgJson","workDir","process","cwd","Error","generatedEntry","resolveEntryPath","entry","resolvedPath","resolve","entryPath","artifacts","artifactModuleExposes","artifactPath","exposesApp","isApp","appEntry","undefined","federationExposes","runtimeOptions","studioConfigPath","clientInput","join","input"],"mappings":"AAAA,OAAOA,UAAU,YAAW;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;QACzE,GAAIJ,aAAa;YAAC,SAASJ;QAAS,IAAI,CAAC,CAAC;QAC1C,GAAGE,qBAAqB;IAC1B;IAEA,MAAMO,iBAA2CxB,QAAQoB,KAAK,GAC1D;QAACC,UAAUrB,QAAQqB,QAAQ;QAAED,OAAO;QAAMlB;IAAY,IACtD;QAACkB,OAAO;QAAOlB;QAAcuB,kBAAkBzB,QAAQyB,gBAAgB;IAAA;IAE3E,iFAAiF;IACjF,wEAAwE;IACxE,2DAA2D;IAC3D,MAAMC,cAAcP,aAAa9B,KAAKsC,IAAI,CAACrB,SAAS,WAAW,WAAW,YAAYgB;IAEtF,OAAO;QACL1B,wBAAwB;YAAC8B;YAAaE,OAAOb;YAAWb;QAAY;QACpEJ,wBAAwB0B;QACxB3B,yBAAyB;YAACmB;QAAS;QACnCrB,uBAAuB;YAACM,SAASsB;YAAmBpB;QAAI;QACxDT;KACD;AACH,EAAC"}
1
+ {"version":3,"sources":["../../../../src/actions/build/vite/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type ModuleFederationOptions} from '@module-federation/vite'\nimport {type PackageJson} from '@sanity/cli-core'\nimport {type PluginOption} from 'vite'\n\nimport {type WorkbenchExposes} from '../../../resolveWorkbenchApp.js'\nimport {artifactExposes, workbenchArtifacts} from '../artifact.js'\nimport {isMediaLibraryConfigApp} from '../configs/configApp.js'\nimport {\n hasMediaLibraryIslandRuntime,\n MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE,\n} from '../configs/mediaLibraryIslandRuntime.js'\nimport {FEDERATION_FILE_NAME, RUNTIME_DIR} from './constants.js'\nimport {sanityFederationHost} from './plugins/plugin-federation-host.js'\nimport {type FederationOptions, sanityModuleFederation} from './plugins/plugin-module-federation.js'\nimport {sanityEnvironmentPlugin} from './plugins/plugin-sanity-environment.js'\nimport {sanityExtensionArtifacts} from './plugins/plugin-sanity-extension-artifacts.js'\nimport {\n type FederationRuntimeOptions,\n sanityFederationRuntime,\n} from './plugins/plugin-sanity-federation-runtime.js'\n\ninterface FederationPluginOptionsBase extends Omit<Partial<FederationOptions>, 'exposes'> {\n exposes?: WorkbenchExposes\n /** Blueprints build (via `@sanity/runtime-cli`) — emit the resource-bindings module. */\n isBlueprints?: boolean\n pkgJson?: PackageJson\n /**\n * Current working directory to read package.json from, defaults to process.cwd()\n */\n workDir?: string\n}\n\ninterface AppFederationPluginOptions extends FederationPluginOptionsBase {\n isApp: true\n\n /**\n * Relative path to the App entry from the runtime directory, e.g.\n * `../../src/App.tsx`. Omit it for a dock-only app that declares no `entry`:\n * no `./App` is exposed and the remote serves only its views.\n */\n appEntry?: string\n studioConfigPath?: never\n}\n\ninterface StudioFederationPluginOptions extends FederationPluginOptionsBase {\n /** relative path to the Studio config file from the runtime directory (e.g. `../../sanity.config.ts`). */\n studioConfigPath: string\n\n appEntry?: never\n /** @defaultValue false */\n isApp?: false\n}\n\n/**\n * Plugin options for the federation vite plugin.\n *\n * Discriminated on `isApp`:\n * - `isApp: true` → requires `appEntry`\n * - `isApp: false` (default) → requires `studioConfigPath`\n *\n * @internal\n */\ntype FederationPluginOptions = AppFederationPluginOptions | StudioFederationPluginOptions\n\n/**\n * @internal\n */\nexport const federation = (options: FederationPluginOptions): PluginOption => {\n const {exposes, isBlueprints, name: defaultName, pkgJson, workDir = process.cwd()} = options\n\n let name = defaultName\n\n if (!name) {\n name = pkgJson?.name\n }\n\n if (!name) {\n throw new Error('\"name\" option is required but could not be inferred from package.json')\n }\n\n const generatedEntry = `./${RUNTIME_DIR}/${FEDERATION_FILE_NAME}.jsx`\n\n function resolveEntryPath(entry: string) {\n const resolvedPath = path.resolve(workDir, entry)\n\n if (!resolvedPath) {\n throw new Error(\n `Could not resolve path for entry \"${entry}\". Please check that the file exists and the path is correct.`,\n )\n }\n\n return resolvedPath\n }\n\n const entryPath = resolveEntryPath(generatedEntry)\n\n // A Media Library config's `./island-runtime` expose re-exports the mount\n // runtime from the app's installed `sanity`; skip it (the host falls back to\n // degraded rendering for custom inputs) when that version predates the entry,\n // since an unresolvable import would fail the whole build.\n const isConfigApp = isMediaLibraryConfigApp(exposes)\n const islandRuntime = isConfigApp && hasMediaLibraryIslandRuntime(workDir)\n if (isConfigApp && !islandRuntime) {\n // eslint-disable-next-line no-console -- build-time warning for the app developer\n console.warn(\n `The installed sanity version does not ship ${MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE}; ` +\n 'custom field inputs will not render in the Media Library until sanity is upgraded.',\n )\n }\n\n // Each view component (`./views/<view>/<component>`) and each service loader\n // (`./services/<name>`) is exposed straight to the host, pointing at the file\n // the extension-artifacts plugin generates under RUNTIME_DIR. A service's\n // worker bundle carries no expose — the host reaches it through its loader.\n const artifacts = workbenchArtifacts(exposes ?? {}, {islandRuntime})\n const artifactModuleExposes = artifactExposes(artifacts, (artifactPath) =>\n resolveEntryPath(`./${RUNTIME_DIR}/${artifactPath}`),\n )\n\n // A dock-only app (`isApp` with no `appEntry`) has no navigable full-page\n // view, so it exposes no `./App` — only its views. Studios and apps with an\n // entry expose `./App` (the generated render entry).\n const exposesApp = !options.isApp || options.appEntry !== undefined\n\n const federationExposes: NonNullable<ModuleFederationOptions['exposes']> = {\n ...(exposesApp ? {'./App': entryPath} : {}),\n ...artifactModuleExposes,\n }\n\n const runtimeOptions: FederationRuntimeOptions = options.isApp\n ? {appEntry: options.appEntry, isApp: true, isBlueprints}\n : {isApp: false, isBlueprints, studioConfigPath: options.studioConfigPath}\n\n // Every federated app and studio also serves itself standalone. Whenever there's\n // an `./App` to mount (never for a dock-only app), build the SPA client\n // environment from the runtime bootstrap cli-build writes.\n const clientInput = exposesApp ? path.join(workDir, '.sanity', 'runtime', 'app.js') : undefined\n\n return [\n sanityEnvironmentPlugin({clientInput, input: entryPath, isBlueprints}),\n sanityFederationRuntime(runtimeOptions),\n sanityExtensionArtifacts({artifacts}),\n sanityModuleFederation({exposes: federationExposes, name}),\n sanityFederationHost(),\n ]\n}\n"],"names":["path","artifactExposes","workbenchArtifacts","isMediaLibraryConfigApp","hasMediaLibraryIslandRuntime","MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE","FEDERATION_FILE_NAME","RUNTIME_DIR","sanityFederationHost","sanityModuleFederation","sanityEnvironmentPlugin","sanityExtensionArtifacts","sanityFederationRuntime","federation","options","exposes","isBlueprints","name","defaultName","pkgJson","workDir","process","cwd","Error","generatedEntry","resolveEntryPath","entry","resolvedPath","resolve","entryPath","isConfigApp","islandRuntime","console","warn","artifacts","artifactModuleExposes","artifactPath","exposesApp","isApp","appEntry","undefined","federationExposes","runtimeOptions","studioConfigPath","clientInput","join","input"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAO5B,SAAQC,eAAe,EAAEC,kBAAkB,QAAO,iBAAgB;AAClE,SAAQC,uBAAuB,QAAO,0BAAyB;AAC/D,SACEC,4BAA4B,EAC5BC,mCAAmC,QAC9B,0CAAyC;AAChD,SAAQC,oBAAoB,EAAEC,WAAW,QAAO,iBAAgB;AAChE,SAAQC,oBAAoB,QAAO,sCAAqC;AACxE,SAAgCC,sBAAsB,QAAO,wCAAuC;AACpG,SAAQC,uBAAuB,QAAO,yCAAwC;AAC9E,SAAQC,wBAAwB,QAAO,iDAAgD;AACvF,SAEEC,uBAAuB,QAClB,gDAA+C;AA6CtD;;CAEC,GACD,OAAO,MAAMC,aAAa,CAACC;IACzB,MAAM,EAACC,OAAO,EAAEC,YAAY,EAAEC,MAAMC,WAAW,EAAEC,OAAO,EAAEC,UAAUC,QAAQC,GAAG,EAAE,EAAC,GAAGR;IAErF,IAAIG,OAAOC;IAEX,IAAI,CAACD,MAAM;QACTA,OAAOE,SAASF;IAClB;IAEA,IAAI,CAACA,MAAM;QACT,MAAM,IAAIM,MAAM;IAClB;IAEA,MAAMC,iBAAiB,CAAC,EAAE,EAAEjB,YAAY,CAAC,EAAED,qBAAqB,IAAI,CAAC;IAErE,SAASmB,iBAAiBC,KAAa;QACrC,MAAMC,eAAe3B,KAAK4B,OAAO,CAACR,SAASM;QAE3C,IAAI,CAACC,cAA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;QACxB/B,yBAAyB;YAACuB;QAAS;QACnCzB,uBAAuB;YAACM,SAAS0B;YAAmBxB;QAAI;QACxDT;KACD;AACH,EAAC"}
@@ -1,7 +1,10 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { WORKER_BUS_ENTRY } from '../../services/artifact.js';
3
5
  import { RUNTIME_DIR } from '../constants.js';
4
6
  import { getFederationApi } from './plugin-module-federation.js';
7
+ const workerBusPath = fileURLToPath(new URL('../../../../_exports/_internal_worker_bus.js', import.meta.url));
5
8
  function relativeImport(fromFile, toFile) {
6
9
  const rel = path.relative(path.dirname(fromFile), toFile).split(path.sep).join('/');
7
10
  return rel.startsWith('.') ? rel : `./${rel}`;
@@ -25,6 +28,20 @@ function writeArtifacts({ artifacts, isolateStyles, root }) {
25
28
  * `workbenchArtifacts` and handed in — this plugin only writes it.
26
29
  */ export function sanityExtensionArtifacts(options) {
27
30
  return {
31
+ // The generated worker.js imports the bus client from this package, which
32
+ // the app has no dependency on and so can't resolve by name.
33
+ config: ()=>({
34
+ optimizeDeps: {
35
+ exclude: [
36
+ WORKER_BUS_ENTRY
37
+ ]
38
+ },
39
+ resolve: {
40
+ alias: {
41
+ [WORKER_BUS_ENTRY]: workerBusPath
42
+ }
43
+ }
44
+ }),
28
45
  configResolved (config) {
29
46
  writeArtifacts({
30
47
  artifacts: options.artifacts,
@@ -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'\n\nimport {type Plugin} from 'vite'\n\nimport {type GeneratedArtifact} from '../../artifact.js'\nimport {RUNTIME_DIR} from '../constants.js'\nimport {getFederationApi} from './plugin-module-federation.js'\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, service\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 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","RUNTIME_DIR","getFederationApi","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","configResolved","config","plugins","name"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAK5B,SAAQC,WAAW,QAAO,kBAAiB;AAC3C,SAAQC,gBAAgB,QAAO,gCAA+B;AAE9D,SAASC,eAAeC,QAAgB,EAAEC,MAAc;IACtD,MAAMC,MAAMN,KAAKO,QAAQ,CAACP,KAAKQ,OAAO,CAACJ,WAAWC,QAAQI,KAAK,CAACT,KAAKU,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,eAAelB,KAAKmB,OAAO,CAACH,MAAMf,aAAagB,SAASjB,IAAI;QAClED,GAAGqB,SAAS,CAACpB,KAAKQ,OAAO,CAACU,eAAe;YAACG,WAAW;QAAI;QACzDtB,GAAGuB,aAAa,CACdJ,cACAD,SAASM,MAAM,CAAC;YACdR;YACAS,eAAe,CAACC,MAAQtB,eAAee,cAAclB,KAAKmB,OAAO,CAACH,MAAMS;QAC1E;IAEJ;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASC,yBAAyBC,OAExC;IACC,OAAO;QACLC,gBAAeC,MAAM;YACnBhB,eAAe;gBACbC,WAAWa,QAAQb,SAAS;gBAC5BC,eAAeb,iBAAiB2B,OAAOC,OAAO,GAAGf,iBAAiB;gBAClEC,MAAMa,OAAOb,IAAI;YACnB;QACF;QACAe,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 '../../services/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, service\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,6BAA4B;AAC3D,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"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * `@sanity/ui` v5's cascade-layer namespace. Its stylesheet (which the
3
+ * `sanity` root barrel side-effect imports under the `ui5` npm alias) keeps
4
+ * all component styles in class-scoped rules under `@layer sui`, and its
5
+ * document-wide reset (`*{margin:0;padding:0;...}` and friends) in
6
+ * `@layer sui.global` blocks.
7
+ */ const SUI_GLOBAL_LAYER = '@layer sui.global';
8
+ /**
9
+ * Remove every `@layer sui.global { ... }` block, keeping the rest of the
10
+ * stylesheet. Layer *statements* (`@layer sui;` / `@layer sui.global;`),
11
+ * which only declare ordering, are left alone.
12
+ *
13
+ * The scanner brace-counts from each block's opening brace; it does not
14
+ * tokenize strings/urls, which is fine for the known content of these blocks
15
+ * (a reset and a font-face) — and a miscount would only under- or over-strip
16
+ * dev styling, never break the build.
17
+ */ export function stripSuiGlobalLayer(css) {
18
+ let out = css;
19
+ let from = 0;
20
+ for(;;){
21
+ const at = out.indexOf(SUI_GLOBAL_LAYER, from);
22
+ if (at === -1) return out;
23
+ // The layer name must end here (not `sui.globalish`), and the at-rule
24
+ // must open a block — otherwise it is an ordering statement; skip it.
25
+ let cursor = at + SUI_GLOBAL_LAYER.length;
26
+ while(cursor < out.length && /\s/.test(out[cursor]))cursor += 1;
27
+ const boundary = out[at + SUI_GLOBAL_LAYER.length];
28
+ if (out[cursor] !== '{' || boundary !== undefined && !/[\s{,;]/.test(boundary)) {
29
+ from = at + SUI_GLOBAL_LAYER.length;
30
+ continue;
31
+ }
32
+ let depth = 0;
33
+ let end = -1;
34
+ for(let index = cursor; index < out.length; index += 1){
35
+ if (out[index] === '{') depth += 1;
36
+ else if (out[index] === '}') {
37
+ depth -= 1;
38
+ if (depth === 0) {
39
+ end = index;
40
+ break;
41
+ }
42
+ }
43
+ }
44
+ if (end === -1) return out // unbalanced: leave the rest untouched
45
+ ;
46
+ out = out.slice(0, at) + out.slice(end + 1);
47
+ from = at;
48
+ }
49
+ }
50
+ /**
51
+ * Why strip anything: Media Library config apps bundle the `sanity` barrel
52
+ * (field modules and the island runtime import it), and the barrel
53
+ * side-effect imports `@sanity/ui` v5's stylesheet. Its `@layer sui.global`
54
+ * reset is document-wide, and in dev the config app's modules execute inside
55
+ * the Media Library host's page — so the reset restyles the host (strips
56
+ * body padding etc.). The class-scoped component styles in the same file are
57
+ * harmless to the host and *needed* by islands: `renderDefault` leaf inputs
58
+ * render Studio components that increasingly carry `sui-*` classes. So keep
59
+ * the component styles, drop only the global layer.
60
+ *
61
+ * Why match on content (the `@layer sui.global` marker) rather than the
62
+ * import specifier or file path: the `ui5` alias is the `sanity` package's
63
+ * internal name for `@sanity/ui` v5 and can be renamed or re-pathed in any
64
+ * sanity release; the layer name is the stylesheet's own public CSS surface
65
+ * and travels with the file wherever it resolves from.
66
+ */ export function stripSuiGlobalReset() {
67
+ return {
68
+ enforce: 'pre',
69
+ name: 'sanity/strip-sui-global-reset',
70
+ transform (code, id) {
71
+ if (!id.split('?', 1)[0].endsWith('.css')) return null;
72
+ if (!code.includes(SUI_GLOBAL_LAYER)) return null;
73
+ const next = stripSuiGlobalLayer(code);
74
+ return next === code ? null : {
75
+ code: next,
76
+ map: null
77
+ };
78
+ }
79
+ };
80
+ }
81
+
82
+ //# sourceMappingURL=plugin-strip-sui-global-reset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/actions/build/vite/plugins/plugin-strip-sui-global-reset.ts"],"sourcesContent":["import {type Plugin} from 'vite'\n\n/**\n * `@sanity/ui` v5's cascade-layer namespace. Its stylesheet (which the\n * `sanity` root barrel side-effect imports under the `ui5` npm alias) keeps\n * all component styles in class-scoped rules under `@layer sui`, and its\n * document-wide reset (`*{margin:0;padding:0;...}` and friends) in\n * `@layer sui.global` blocks.\n */\nconst SUI_GLOBAL_LAYER = '@layer sui.global'\n\n/**\n * Remove every `@layer sui.global { ... }` block, keeping the rest of the\n * stylesheet. Layer *statements* (`@layer sui;` / `@layer sui.global;`),\n * which only declare ordering, are left alone.\n *\n * The scanner brace-counts from each block's opening brace; it does not\n * tokenize strings/urls, which is fine for the known content of these blocks\n * (a reset and a font-face) — and a miscount would only under- or over-strip\n * dev styling, never break the build.\n */\nexport function stripSuiGlobalLayer(css: string): string {\n let out = css\n let from = 0\n for (;;) {\n const at = out.indexOf(SUI_GLOBAL_LAYER, from)\n if (at === -1) return out\n // The layer name must end here (not `sui.globalish`), and the at-rule\n // must open a block — otherwise it is an ordering statement; skip it.\n let cursor = at + SUI_GLOBAL_LAYER.length\n while (cursor < out.length && /\\s/.test(out[cursor])) cursor += 1\n const boundary = out[at + SUI_GLOBAL_LAYER.length]\n if (out[cursor] !== '{' || (boundary !== undefined && !/[\\s{,;]/.test(boundary))) {\n from = at + SUI_GLOBAL_LAYER.length\n continue\n }\n let depth = 0\n let end = -1\n for (let index = cursor; index < out.length; index += 1) {\n if (out[index] === '{') depth += 1\n else if (out[index] === '}') {\n depth -= 1\n if (depth === 0) {\n end = index\n break\n }\n }\n }\n if (end === -1) return out // unbalanced: leave the rest untouched\n out = out.slice(0, at) + out.slice(end + 1)\n from = at\n }\n}\n\n/**\n * Why strip anything: Media Library config apps bundle the `sanity` barrel\n * (field modules and the island runtime import it), and the barrel\n * side-effect imports `@sanity/ui` v5's stylesheet. Its `@layer sui.global`\n * reset is document-wide, and in dev the config app's modules execute inside\n * the Media Library host's page — so the reset restyles the host (strips\n * body padding etc.). The class-scoped component styles in the same file are\n * harmless to the host and *needed* by islands: `renderDefault` leaf inputs\n * render Studio components that increasingly carry `sui-*` classes. So keep\n * the component styles, drop only the global layer.\n *\n * Why match on content (the `@layer sui.global` marker) rather than the\n * import specifier or file path: the `ui5` alias is the `sanity` package's\n * internal name for `@sanity/ui` v5 and can be renamed or re-pathed in any\n * sanity release; the layer name is the stylesheet's own public CSS surface\n * and travels with the file wherever it resolves from.\n */\nexport function stripSuiGlobalReset(): Plugin {\n return {\n enforce: 'pre',\n name: 'sanity/strip-sui-global-reset',\n transform(code, id) {\n if (!id.split('?', 1)[0].endsWith('.css')) return null\n if (!code.includes(SUI_GLOBAL_LAYER)) return null\n const next = stripSuiGlobalLayer(code)\n return next === code ? null : {code: next, map: null}\n },\n }\n}\n"],"names":["SUI_GLOBAL_LAYER","stripSuiGlobalLayer","css","out","from","at","indexOf","cursor","length","test","boundary","undefined","depth","end","index","slice","stripSuiGlobalReset","enforce","name","transform","code","id","split","endsWith","includes","next","map"],"mappings":"AAEA;;;;;;CAMC,GACD,M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,KAAKI,QAAQ,CAACxB,mBAAmB,OAAO;YAC7C,MAAMyB,OAAOxB,oBAAoBmB;YACjC,OAAOK,SAASL,OAAO,OAAO;gBAACA,MAAMK;gBAAMC,KAAK;YAAI;QACtD;IACF;AACF"}
@@ -6,8 +6,10 @@
6
6
  // live here next to `federation` — the build package just hands over its inputs.
7
7
  import path from 'node:path';
8
8
  import { readPackageJson } from '@sanity/cli-core';
9
+ import { isMediaLibraryConfigApp } from '../configs/configApp.js';
9
10
  import { federation } from './plugin.js';
10
11
  import { sanityAppId } from './plugins/plugin-sanity-app-id.js';
12
+ import { stripSuiGlobalReset } from './plugins/plugin-strip-sui-global-reset.js';
11
13
  /**
12
14
  * A workbench studio renders from its `sanity.config.*`, so the build needs one.
13
15
  * An explicit `applicationType: 'studio'` wins over detection, so a studio can
@@ -39,9 +41,18 @@ import { sanityAppId } from './plugins/plugin-sanity-app-id.js';
39
41
  pkgJson,
40
42
  workDir: cwd
41
43
  });
42
- return appId === undefined ? federationPlugin : [
44
+ // Media Library config apps run their modules inside the host's page, so
45
+ // the `sanity` barrel's document-wide CSS reset must not travel with the
46
+ // bundle (see the plugin for the full why).
47
+ const configAppPlugins = isMediaLibraryConfigApp(exposes) ? [
48
+ stripSuiGlobalReset()
49
+ ] : [];
50
+ return [
51
+ ...configAppPlugins,
43
52
  federationPlugin,
44
- sanityAppId(appId)
53
+ ...appId === undefined ? [] : [
54
+ sanityAppId(appId)
55
+ ]
45
56
  ];
46
57
  }
47
58
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/build/vite/workbench-vite-plugins.ts"],"sourcesContent":["// The build-facing entry of the workbench federation stack: turn a workbench\n// app's build inputs into the Vite plugins that produce its module-federation\n// remote. `@sanity/cli-build`'s `getViteConfig` calls this instead of\n// assembling `federation`'s options itself, so the discriminated app-vs-studio\n// option shape, the no-app-view rule, and the studio-config requirement all\n// live here next to `federation` — the build package just hands over its inputs.\n\nimport path from 'node:path'\n\nimport {readPackageJson} from '@sanity/cli-core'\nimport {type PluginOption} from 'vite'\n\nimport {type WorkbenchExposes} from '../../../resolveWorkbenchApp.js'\nimport {federation} from './plugin.js'\nimport {sanityAppId} from './plugins/plugin-sanity-app-id.js'\n\ninterface WorkbenchViteOptions {\n /** Project root — read for the federation remote name, and the plugin workDir. */\n cwd: string\n /**\n * Build entry paths relative to the federation runtime dir. `relativeEntry` is\n * the app's `entry` (null for a dock-only app with no app view);\n * `relativeConfigLocation` is the studio's `sanity.config.*` (null when absent).\n */\n entries: {relativeConfigLocation: string | null; relativeEntry: string | null}\n\n /** The app's bus identity, stamped into its modules for `@sanity/runtime`. */\n appId?: string\n\n exposes?: WorkbenchExposes\n /** App (vs studio) build — selects the discriminated federation option shape. */\n isApp?: boolean\n /** Blueprints build (via `@sanity/runtime-cli`) — emit the resource-bindings module. */\n isBlueprints?: boolean\n}\n\n/**\n * A workbench studio renders from its `sanity.config.*`, so the build needs one.\n * An explicit `applicationType: 'studio'` wins over detection, so a studio can\n * reach here with no config file — fail with the fix rather than a cryptic build\n * error downstream.\n */\nfunction requireStudioConfigPath(relativeConfigLocation: string | null): string {\n if (relativeConfigLocation === null) {\n throw new Error(\n 'Dashboard studios need a sanity.config.js or sanity.config.ts file. ' +\n \"Add one, or remove `applicationType: 'studio'` from `defineApplication` \" +\n 'to let the CLI infer the application type.',\n )\n }\n return relativeConfigLocation\n}\n\n/** Build the Vite plugins for a workbench app's module-federation remote. */\nexport async function workbenchVitePlugins(options: WorkbenchViteOptions): Promise<PluginOption> {\n const {appId, cwd, entries, exposes, isApp, isBlueprints} = options\n const pkgJson = await readPackageJson(path.join(cwd, 'package.json'))\n\n const federationPlugin = federation({\n ...(isApp\n ? {\n // `null` relativeEntry (a branded app with no `entry`) → omit `appEntry`,\n // so the remote exposes no `./App`, only its views.\n ...(entries.relativeEntry ? {appEntry: entries.relativeEntry} : {}),\n isApp: true as const,\n }\n : {\n isApp: false as const,\n studioConfigPath: requireStudioConfigPath(entries.relativeConfigLocation),\n }),\n exposes,\n isBlueprints,\n pkgJson,\n workDir: cwd,\n })\n\n return appId === undefined ? federationPlugin : [federationPlugin, sanityAppId(appId)]\n}\n"],"names":["path","readPackageJson","federation","sanityAppId","requireStudioConfigPath","relativeConfigLocation","Error","workbenchVitePlugins","options","appId","cwd","entries","exposes","isApp","isBlueprints","pkgJson","join","federationPlugin","relativeEntry","appEntry","studioConfigPath","workDir","undefined"],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,sEAAsE;AACtE,+EAA+E;AAC/E,4EAA4E;AAC5E,iFAAiF;AAEjF,OAAOA,UAAU,YAAW;AAE5B,SAAQC,eAAe,QAAO,mBAAkB;AAIhD,SAAQC,UAAU,QAAO,cAAa;AACtC,SAAQC,WAAW,QAAO,oCAAmC;AAsB7D;;;;;CAKC,GACD,SAASC,wBAAwBC,sBAAqC;IACpE,IAAIA,2BAA2B,MAAM;QACnC,MAAM,IAAIC,MACR,yEACE,6EACA;IAEN;IACA,OAAOD;AACT;AAEA,2EAA2E,GAC3E,OAAO,eAAeE,qBAAqBC,OAA6B;IACtE,MAAM,EAACC,KAAK,EAAEC,GAAG,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAEC,YAAY,EAAC,GAAGN;IAC5D,MAAMO,UAAU,MAAMd,gBAAgBD,KAAKgB,IAAI,CAACN,KAAK;IAErD,MAAMO,mBAAmBf,WAAW;QAClC,GAAIW,QACA;YACE,0EAA0E;YAC1E,oDAAoD;YACpD,GAAIF,QAAQO,aAAa,GAAG;gBAACC,UAAUR,QAAQO,aAAa;YAAA,IAAI,CAAC,CAAC;YAClEL,OAAO;QACT,IACA;YACEA,OAAO;YACPO,kBAAkBhB,wBAAwBO,QAAQN,sBAAsB;QAC1E,CAAC;QACLO;QACAE;QACAC;QACAM,SAASX;IACX;IAEA,OAAOD,UAAUa,YAAYL,mBAAmB;QAACA;QAAkBd,YAAYM;KAAO;AACxF"}
1
+ {"version":3,"sources":["../../../../src/actions/build/vite/workbench-vite-plugins.ts"],"sourcesContent":["// The build-facing entry of the workbench federation stack: turn a workbench\n// app's build inputs into the Vite plugins that produce its module-federation\n// remote. `@sanity/cli-build`'s `getViteConfig` calls this instead of\n// assembling `federation`'s options itself, so the discriminated app-vs-studio\n// option shape, the no-app-view rule, and the studio-config requirement all\n// live here next to `federation` — the build package just hands over its inputs.\n\nimport path from 'node:path'\n\nimport {readPackageJson} from '@sanity/cli-core'\nimport {type PluginOption} from 'vite'\n\nimport {type WorkbenchExposes} from '../../../resolveWorkbenchApp.js'\nimport {isMediaLibraryConfigApp} from '../configs/configApp.js'\nimport {federation} from './plugin.js'\nimport {sanityAppId} from './plugins/plugin-sanity-app-id.js'\nimport {stripSuiGlobalReset} from './plugins/plugin-strip-sui-global-reset.js'\n\ninterface WorkbenchViteOptions {\n /** Project root — read for the federation remote name, and the plugin workDir. */\n cwd: string\n /**\n * Build entry paths relative to the federation runtime dir. `relativeEntry` is\n * the app's `entry` (null for a dock-only app with no app view);\n * `relativeConfigLocation` is the studio's `sanity.config.*` (null when absent).\n */\n entries: {relativeConfigLocation: string | null; relativeEntry: string | null}\n\n /** The app's bus identity, stamped into its modules for `@sanity/runtime`. */\n appId?: string\n\n exposes?: WorkbenchExposes\n /** App (vs studio) build — selects the discriminated federation option shape. */\n isApp?: boolean\n /** Blueprints build (via `@sanity/runtime-cli`) — emit the resource-bindings module. */\n isBlueprints?: boolean\n}\n\n/**\n * A workbench studio renders from its `sanity.config.*`, so the build needs one.\n * An explicit `applicationType: 'studio'` wins over detection, so a studio can\n * reach here with no config file — fail with the fix rather than a cryptic build\n * error downstream.\n */\nfunction requireStudioConfigPath(relativeConfigLocation: string | null): string {\n if (relativeConfigLocation === null) {\n throw new Error(\n 'Dashboard studios need a sanity.config.js or sanity.config.ts file. ' +\n \"Add one, or remove `applicationType: 'studio'` from `defineApplication` \" +\n 'to let the CLI infer the application type.',\n )\n }\n return relativeConfigLocation\n}\n\n/** Build the Vite plugins for a workbench app's module-federation remote. */\nexport async function workbenchVitePlugins(options: WorkbenchViteOptions): Promise<PluginOption> {\n const {appId, cwd, entries, exposes, isApp, isBlueprints} = options\n const pkgJson = await readPackageJson(path.join(cwd, 'package.json'))\n\n const federationPlugin = federation({\n ...(isApp\n ? {\n // `null` relativeEntry (a branded app with no `entry`) → omit `appEntry`,\n // so the remote exposes no `./App`, only its views.\n ...(entries.relativeEntry ? {appEntry: entries.relativeEntry} : {}),\n isApp: true as const,\n }\n : {\n isApp: false as const,\n studioConfigPath: requireStudioConfigPath(entries.relativeConfigLocation),\n }),\n exposes,\n isBlueprints,\n pkgJson,\n workDir: cwd,\n })\n\n // Media Library config apps run their modules inside the host's page, so\n // the `sanity` barrel's document-wide CSS reset must not travel with the\n // bundle (see the plugin for the full why).\n const configAppPlugins: PluginOption[] = isMediaLibraryConfigApp(exposes)\n ? [stripSuiGlobalReset()]\n : []\n\n return [\n ...configAppPlugins,\n federationPlugin,\n ...(appId === undefined ? [] : [sanityAppId(appId)]),\n ]\n}\n"],"names":["path","readPackageJson","isMediaLibraryConfigApp","federation","sanityAppId","stripSuiGlobalReset","requireStudioConfigPath","relativeConfigLocation","Error","workbenchVitePlugins","options","appId","cwd","entries","exposes","isApp","isBlueprints","pkgJson","join","federationPlugin","relativeEntry","appEntry","studioConfigPath","workDir","configAppPlugins","undefined"],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,sEAAsE;AACtE,+EAA+E;AAC/E,4EAA4E;AAC5E,iFAAiF;AAEjF,OAAOA,UAAU,YAAW;AAE5B,SAAQC,eAAe,QAAO,mBAAkB;AAIhD,SAAQC,uBAAuB,QAAO,0BAAyB;AAC/D,SAAQC,UAAU,QAAO,cAAa;AACtC,SAAQC,WAAW,QAAO,oCAAmC;AAC7D,SAAQC,mBAAmB,QAAO,6CAA4C;AAsB9E;;;;;CAKC,GACD,SAASC,wBAAwBC,sBAAqC;IACpE,IAAIA,2BAA2B,MAAM;QACnC,MAAM,IAAIC,MACR,yEACE,6EACA;IAEN;IACA,OAAOD;AACT;AAEA,2EAA2E,GAC3E,OAAO,eAAeE,qBAAqBC,OAA6B;IACtE,MAAM,EAACC,KAAK,EAAEC,GAAG,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAEC,YAAY,EAAC,GAAGN;IAC5D,MAAMO,UAAU,MAAMhB,gBAAgBD,KAAKkB,IAAI,CAACN,KAAK;IAErD,MAAMO,mBAAmBhB,WAAW;QAClC,GAAIY,QACA;YACE,0EAA0E;YAC1E,oDAAoD;YACpD,GAAIF,QAAQO,aAAa,GAAG;gBAACC,UAAUR,QAAQO,aAAa;YAAA,IAAI,CAAC,CAAC;YAClEL,OAAO;QACT,IACA;YACEA,OAAO;YACPO,kBAAkBhB,wBAAwBO,QAAQN,sBAAsB;QAC1E,CAAC;QACLO;QACAE;QACAC;QACAM,SAASX;IACX;IAEA,yEAAyE;IACzE,yEAAyE;IACzE,4CAA4C;IAC5C,MAAMY,mBAAmCtB,wBAAwBY,WAC7D;QAACT;KAAsB,GACvB,EAAE;IAEN,OAAO;WACFmB;QACHL;WACIR,UAAUc,YAAY,EAAE,GAAG;YAACrB,YAAYO;SAAO;KACpD;AACH"}
@@ -1,4 +1,4 @@
1
- import { stat } from 'node:fs/promises';
1
+ import { readFile, stat } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  /**
4
4
  * A genuinely-missing-build error, named so callers can offer the "run sanity
@@ -27,14 +27,22 @@ import { join } from 'node:path';
27
27
  throw err;
28
28
  }
29
29
  const manifestPath = join(sourceDir, 'mf-manifest.json');
30
+ let manifest;
30
31
  try {
31
- await stat(manifestPath);
32
+ manifest = await readFile(manifestPath, 'utf8');
32
33
  } catch (err) {
33
34
  if (err.code === 'ENOENT') {
34
35
  throw buildNotFound(`"${manifestPath}" does not exist. ` + 'The deploy directory must contain a federation build created with "sanity build".');
35
36
  }
36
37
  throw err;
37
38
  }
39
+ // Every deploy sends this file to the API, so a corrupt one must fail here
40
+ // rather than after the application is created.
41
+ try {
42
+ JSON.parse(manifest);
43
+ } catch {
44
+ throw new Error(`"${manifestPath}" is not valid JSON. Run "sanity build" again to regenerate it.`);
45
+ }
38
46
  }
39
47
 
40
48
  //# sourceMappingURL=checkBuiltOutput.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/checkBuiltOutput.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {join} from 'node:path'\n\n/**\n * A genuinely-missing-build error, named so callers can offer the \"run sanity\n * build\" hint (the `preview` command keys off this name, matching how the studio\n * path keys off a missing `index.html`). Only the missing cases get it — real\n * I/O failures keep their own name so they surface as themselves.\n */\nfunction buildNotFound(message: string): Error {\n const error = new Error(message)\n error.name = 'BUILD_NOT_FOUND'\n return error\n}\n\n/**\n * Throws unless `sourceDir` is a directory holding a federation build.\n * A workbench build always emits a module-federation remote, and may\n * additionally emit a standalone `index.html` SPA (workbench remotes). Either\n * way `mf-manifest.json` is the reliable marker that `sanity build` produced a\n * federation build, so that — not `index.html` — is what we check for.\n */\nexport async function checkBuiltOutput(sourceDir: string): Promise<void> {\n try {\n const stats = await stat(sourceDir)\n if (!stats.isDirectory()) {\n throw new Error(`\"${sourceDir}\" is not a directory`)\n }\n } catch (err) {\n if (err.code === 'ENOENT') throw buildNotFound(`Directory \"${sourceDir}\" does not exist`)\n throw err\n }\n\n const manifestPath = join(sourceDir, 'mf-manifest.json')\n try {\n await stat(manifestPath)\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw buildNotFound(\n `\"${manifestPath}\" does not exist. ` +\n 'The deploy directory must contain a federation build created with \"sanity build\".',\n )\n }\n throw err\n }\n}\n"],"names":["stat","join","buildNotFound","message","error","Error","name","checkBuiltOutput","sourceDir","stats","isDirectory","err","code","manifestPath"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,IAAI,QAAO,YAAW;AAE9B;;;;;CAKC,GACD,SAASC,cAAcC,OAAe;IACpC,MAAMC,QAAQ,IAAIC,MAAMF;IACxBC,MAAME,IAAI,GAAG;IACb,OAAOF;AACT;AAEA;;;;;;CAMC,GACD,OAAO,eAAeG,iBAAiBC,SAAiB;IACtD,IAAI;QACF,MAAMC,QAAQ,MAAMT,KAAKQ;QACzB,IAAI,CAACC,MAAMC,WAAW,IAAI;YACxB,MAAM,IAAIL,MAAM,CAAC,CAAC,EAAEG,UAAU,oBAAoB,CAAC;QACrD;IACF,EAAE,OAAOG,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU,MAAMV,cAAc,CAAC,WAAW,EAAEM,UAAU,gBAAgB,CAAC;QACxF,MAAMG;IACR;IAEA,MAAME,eAAeZ,KAAKO,WAAW;IACrC,IAAI;QACF,MAAMR,KAAKa;IACb,EAAE,OAAOF,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU;YACzB,MAAMV,cACJ,CAAC,CAAC,EAAEW,aAAa,kBAAkB,CAAC,GAClC;QAEN;QACA,MAAMF;IACR;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/checkBuiltOutput.ts"],"sourcesContent":["import {readFile, stat} from 'node:fs/promises'\nimport {join} from 'node:path'\n\n/**\n * A genuinely-missing-build error, named so callers can offer the \"run sanity\n * build\" hint (the `preview` command keys off this name, matching how the studio\n * path keys off a missing `index.html`). Only the missing cases get it — real\n * I/O failures keep their own name so they surface as themselves.\n */\nfunction buildNotFound(message: string): Error {\n const error = new Error(message)\n error.name = 'BUILD_NOT_FOUND'\n return error\n}\n\n/**\n * Throws unless `sourceDir` is a directory holding a federation build.\n * A workbench build always emits a module-federation remote, and may\n * additionally emit a standalone `index.html` SPA (workbench remotes). Either\n * way `mf-manifest.json` is the reliable marker that `sanity build` produced a\n * federation build, so that — not `index.html` — is what we check for.\n */\nexport async function checkBuiltOutput(sourceDir: string): Promise<void> {\n try {\n const stats = await stat(sourceDir)\n if (!stats.isDirectory()) {\n throw new Error(`\"${sourceDir}\" is not a directory`)\n }\n } catch (err) {\n if (err.code === 'ENOENT') throw buildNotFound(`Directory \"${sourceDir}\" does not exist`)\n throw err\n }\n\n const manifestPath = join(sourceDir, 'mf-manifest.json')\n let manifest: string\n try {\n manifest = await readFile(manifestPath, 'utf8')\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw buildNotFound(\n `\"${manifestPath}\" does not exist. ` +\n 'The deploy directory must contain a federation build created with \"sanity build\".',\n )\n }\n throw err\n }\n\n // Every deploy sends this file to the API, so a corrupt one must fail here\n // rather than after the application is created.\n try {\n JSON.parse(manifest)\n } catch {\n throw new Error(\n `\"${manifestPath}\" is not valid JSON. Run \"sanity build\" again to regenerate it.`,\n )\n }\n}\n"],"names":["readFile","stat","join","buildNotFound","message","error","Error","name","checkBuiltOutput","sourceDir","stats","isDirectory","err","code","manifestPath","manifest","JSON","parse"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,IAAI,QAAO,mBAAkB;AAC/C,SAAQC,IAAI,QAAO,YAAW;AAE9B;;;;;CAKC,GACD,SAASC,cAAcC,OAAe;IACpC,MAAMC,QAAQ,IAAIC,MAAMF;IACxBC,MAAME,IAAI,GAAG;IACb,OAAOF;AACT;AAEA;;;;;;CAMC,GACD,OAAO,eAAeG,iBAAiBC,SAAiB;IACtD,IAAI;QACF,MAAMC,QAAQ,MAAMT,KAAKQ;QACzB,IAAI,CAACC,MAAMC,WAAW,IAAI;YACxB,MAAM,IAAIL,MAAM,CAAC,CAAC,EAAEG,UAAU,oBAAoB,CAAC;QACrD;IACF,EAAE,OAAOG,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU,MAAMV,cAAc,CAAC,WAAW,EAAEM,UAAU,gBAAgB,CAAC;QACxF,MAAMG;IACR;IAEA,MAAME,eAAeZ,KAAKO,WAAW;IACrC,IAAIM;IACJ,IAAI;QACFA,WAAW,MAAMf,SAASc,cAAc;IAC1C,EAAE,OAAOF,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU;YACzB,MAAMV,cACJ,CAAC,CAAC,EAAEW,aAAa,kBAAkB,CAAC,GAClC;QAEN;QACA,MAAMF;IACR;IAEA,2EAA2E;IAC3E,gDAAgD;IAChD,IAAI;QACFI,KAAKC,KAAK,CAACF;IACb,EAAE,OAAM;QACN,MAAM,IAAIT,MACR,CAAC,CAAC,EAAEQ,aAAa,+DAA+D,CAAC;IAErF;AACF"}
@@ -1,4 +1,5 @@
1
- import { basename, dirname } from 'node:path';
1
+ import { readFile } from 'node:fs/promises';
2
+ import { basename, dirname, join } from 'node:path';
2
3
  import { createGzip } from 'node:zlib';
3
4
  import { getErrorMessage } from '@sanity/cli-core/errors';
4
5
  import { spinner } from '@sanity/cli-core/ux';
@@ -100,10 +101,15 @@ function toBrettInterface(iface, version) {
100
101
  * `onDeployed` fires the instant the deployment is live, before the metadata
101
102
  * sync — so a caller can disarm a create-time rollback that must not delete an
102
103
  * application once it has an active deployment.
104
+ *
105
+ * The build's `mf-manifest.json` ships with every deployment. `isExternal`
106
+ * skips the tarball: the customer serves the build from the application's
107
+ * registered origin.
103
108
  * @internal
104
109
  */ export async function deployWorkbenchApp(options) {
105
- const { access, app, applicationId, icon, isApp, isAutoUpdating, label = 'Deploying...', onDeployed, slug, sourceDir, title, version, visibility, workspaces } = options;
106
- const tarball = createTar({
110
+ const { access, app, applicationId, icon, isApp, isAutoUpdating, isExternal = false, label = 'Deploying...', onDeployed, slug, sourceDir, title, version, visibility, workspaces } = options;
111
+ const mfManifest = JSON.parse(await readFile(join(sourceDir, 'mf-manifest.json'), 'utf8'));
112
+ const tarball = isExternal ? undefined : createTar({
107
113
  cwd: dirname(sourceDir)
108
114
  }, [
109
115
  basename(sourceDir)
@@ -119,6 +125,7 @@ function toBrettInterface(iface, version) {
119
125
  isApp
120
126
  }).map((iface)=>toBrettInterface(iface, version)),
121
127
  isAutoUpdating,
128
+ mfManifest,
122
129
  tarball,
123
130
  version,
124
131
  workspaces
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/deployWorkbenchApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {createGzip} from 'node:zlib'\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {c as createTar} from 'tar'\n\nimport {type DerivedInterface, deriveInterfaces} from '../../deriveInterfaces.js'\nimport {\n type Application,\n type BrettAccess,\n type BrettInterface,\n type BrettWorkspace,\n createApplication,\n createDeployment,\n deleteApplication,\n updateApplication,\n} from '../../services/applications.js'\n\n/**\n * `rollback` undoes the creation, so a later failure leaves no record stranded at the slug.\n * @internal\n */\nexport interface CreatedApplication {\n application: Application\n rollback: () => Promise<void>\n}\n\nfunction toBrettInterface(iface: DerivedInterface, version: string): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return {...declaration, version}\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'panel': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'window': {\n const {surface, ...view} = declaration\n return {...view, type: 'app', version}\n }\n }\n}\n\n/**\n * Create a coreApp record (no deployment), so the CLI can build with its id\n * before shipping the first deployment. First deploy only.\n * @internal\n */\nexport async function createCoreApp(options: {\n isSingleton?: boolean\n name?: string\n organizationId: string\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating application...').start()\n try {\n const application = await createApplication({...options, type: 'coreApp'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Create a studio record (no deployment).\n * @internal\n */\nexport async function createStudio(options: {\n name?: string\n organizationId: string\n projectId: string | undefined\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating studio...').start()\n try {\n const application = await createApplication({...options, type: 'studio'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Ship a deployment to an already-created (or `deployment.appId`) application,\n * then sync its mutable metadata (`title`, and `icon`/`slug`/`visibility` when\n * set) from config. The deploy endpoint ignores these, so a redeploy patches\n * them here alongside the new deployment.\n *\n * `onDeployed` fires the instant the deployment is live, before the metadata\n * sync — so a caller can disarm a create-time rollback that must not delete an\n * application once it has an active deployment.\n * @internal\n */\nexport async function deployWorkbenchApp(options: {\n access?: readonly BrettAccess[]\n app: CliConfig['app']\n applicationId: string\n icon?: string\n isApp: boolean\n isAutoUpdating: boolean\n label?: string\n onDeployed?: () => void\n /**\n * The address from config. Only `createApplication` used to send it, so an\n * app with a `deployment.appId` kept whatever slug it was created at.\n */\n slug?: string\n sourceDir: string\n title: string\n version: string\n visibility?: AppVisibility\n workspaces?: readonly BrettWorkspace[]\n}): Promise<void> {\n const {\n access,\n app,\n applicationId,\n icon,\n isApp,\n isAutoUpdating,\n label = 'Deploying...',\n onDeployed,\n slug,\n sourceDir,\n title,\n version,\n visibility,\n workspaces,\n } = options\n const tarball = createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n const spin = spinner(label).start()\n try {\n await createDeployment({\n access,\n applicationId,\n // Brett assigns the id and resolves modules by `moduleId`, so neither travels.\n interfaces: deriveInterfaces(app, {appTitle: title, isApp}).map((iface) =>\n toBrettInterface(iface, version),\n ),\n isAutoUpdating,\n tarball,\n version,\n workspaces,\n })\n onDeployed?.()\n try {\n await updateApplication(applicationId, {\n title,\n ...(icon ? {icon} : {}),\n ...(slug ? {slug} : {}),\n ...(visibility ? {visibility} : {}),\n })\n } catch (error) {\n throw toSlugRejection(error, slug)\n }\n spin.succeed()\n } catch (error) {\n spin.clear()\n throw error\n }\n}\n\n/**\n * The slug is the one synced field the server validates — it must be free\n * within the organization, and a singleton app only accepts its reserved\n * identifiers — so a 4xx on the metadata patch is a rejected rename. Name the\n * slug and the server's reason; anything else propagates untouched.\n */\nfunction toSlugRejection(error: unknown, slug: string | undefined): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (!slug || statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `Slug \"${slug}\" was rejected: ${getErrorMessage(error)}. The deployment is live at the application's previous slug — change \\`app.slug\\` in sanity.cli.ts and deploy again.`,\n {cause: error},\n )\n}\n"],"names":["basename","dirname","createGzip","getErrorMessage","spinner","c","createTar","deriveInterfaces","createApplication","createDeployment","deleteApplication","updateApplication","toBrettInterface","iface","version","id","_id","src","_src","declaration","surface","view","type","createCoreApp","options","spin","start","application","succeed","rollback","error","fail","createStudio","deployWorkbenchApp","access","app","applicationId","icon","isApp","isAutoUpdating","label","onDeployed","slug","sourceDir","title","visibility","workspaces","tarball","cwd","pipe","interfaces","appTitle","map","toSlugRejection","clear","statusCode","undefined","Error","cause"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,UAAU,QAAO,YAAW;AAGpC,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAA+BC,gBAAgB,QAAO,4BAA2B;AACjF,SAKEC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,iBAAiB,QACZ,iCAAgC;AAWvC,SAASC,iBAAiBC,KAAuB,EAAEC,OAAe;IAChE,MAAM,EAACC,IAAIC,GAAG,EAAEC,KAAKC,IAAI,EAAE,GAAGC,aAAY,GAAGN;IAC7C,IAAI,UAAUM,aAAa,OAAO;QAAC,GAAGA,WAAW;QAAEL;IAAO;IAE1D,OAAQK,YAAYC,OAAO;QACzB,KAAK;YAAgB;gBACnB,MAAM,EAACA,OAAO,EAAE,GAAGC,MAAK,GAAGF;gBAC3B,OAAO;oBAAC,GAAGE,IAAI;oBAAEC,MAAMF;oBAAS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p.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {basename, dirname, join} from 'node:path'\nimport {createGzip} from 'node:zlib'\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {c as createTar} from 'tar'\n\nimport {type DerivedInterface, deriveInterfaces} from '../../deriveInterfaces.js'\nimport {\n type Application,\n type BrettAccess,\n type BrettInterface,\n type BrettWorkspace,\n createApplication,\n createDeployment,\n deleteApplication,\n updateApplication,\n} from '../../services/applications.js'\n\n/**\n * `rollback` undoes the creation, so a later failure leaves no record stranded at the slug.\n * @internal\n */\nexport interface CreatedApplication {\n application: Application\n rollback: () => Promise<void>\n}\n\nfunction toBrettInterface(iface: DerivedInterface, version: string): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return {...declaration, version}\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'panel': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'window': {\n const {surface, ...view} = declaration\n return {...view, type: 'app', version}\n }\n }\n}\n\n/**\n * Create a coreApp record (no deployment), so the CLI can build with its id\n * before shipping the first deployment. First deploy only.\n * @internal\n */\nexport async function createCoreApp(options: {\n isSingleton?: boolean\n name?: string\n organizationId: string\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating application...').start()\n try {\n const application = await createApplication({...options, type: 'coreApp'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Create a studio record (no deployment).\n * @internal\n */\nexport async function createStudio(options: {\n externalUrl?: string\n name?: string\n organizationId: string\n projectId: string | undefined\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating studio...').start()\n try {\n const application = await createApplication({...options, type: 'studio'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Ship a deployment to an already-created (or `deployment.appId`) application,\n * then sync its mutable metadata (`title`, and `icon`/`slug`/`visibility` when\n * set) from config. The deploy endpoint ignores these, so a redeploy patches\n * them here alongside the new deployment.\n *\n * `onDeployed` fires the instant the deployment is live, before the metadata\n * sync — so a caller can disarm a create-time rollback that must not delete an\n * application once it has an active deployment.\n *\n * The build's `mf-manifest.json` ships with every deployment. `isExternal`\n * skips the tarball: the customer serves the build from the application's\n * registered origin.\n * @internal\n */\nexport async function deployWorkbenchApp(options: {\n access?: readonly BrettAccess[]\n app: CliConfig['app']\n applicationId: string\n icon?: string\n isApp: boolean\n isAutoUpdating: boolean\n isExternal?: boolean\n label?: string\n onDeployed?: () => void\n /**\n * The address from config. Only `createApplication` used to send it, so an\n * app with a `deployment.appId` kept whatever slug it was created at.\n */\n slug?: string\n sourceDir: string\n title: string\n version: string\n visibility?: AppVisibility\n workspaces?: readonly BrettWorkspace[]\n}): Promise<void> {\n const {\n access,\n app,\n applicationId,\n icon,\n isApp,\n isAutoUpdating,\n isExternal = false,\n label = 'Deploying...',\n onDeployed,\n slug,\n sourceDir,\n title,\n version,\n visibility,\n workspaces,\n } = options\n const mfManifest = JSON.parse(await readFile(join(sourceDir, 'mf-manifest.json'), 'utf8'))\n const tarball = isExternal\n ? undefined\n : createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n const spin = spinner(label).start()\n try {\n await createDeployment({\n access,\n applicationId,\n // Brett assigns the id and resolves modules by `moduleId`, so neither travels.\n interfaces: deriveInterfaces(app, {appTitle: title, isApp}).map((iface) =>\n toBrettInterface(iface, version),\n ),\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n })\n onDeployed?.()\n try {\n await updateApplication(applicationId, {\n title,\n ...(icon ? {icon} : {}),\n ...(slug ? {slug} : {}),\n ...(visibility ? {visibility} : {}),\n })\n } catch (error) {\n throw toSlugRejection(error, slug)\n }\n spin.succeed()\n } catch (error) {\n spin.clear()\n throw error\n }\n}\n\n/**\n * The slug is the one synced field the server validates — it must be free\n * within the organization, and a singleton app only accepts its reserved\n * identifiers — so a 4xx on the metadata patch is a rejected rename. Name the\n * slug and the server's reason; anything else propagates untouched.\n */\nfunction toSlugRejection(error: unknown, slug: string | undefined): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (!slug || statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `Slug \"${slug}\" was rejected: ${getErrorMessage(error)}. The deployment is live at the application's previous slug — change \\`app.slug\\` in sanity.cli.ts and deploy again.`,\n {cause: error},\n )\n}\n"],"names":["readFile","basename","dirname","join","createGzip","getErrorMessage","spinner","c","createTar","deriveInterfaces","createApplication","createDeployment","deleteApplication","updateApplication","toBrettInterface","iface","version","id","_id","src","_src","declaration","surface","view","type","createCoreApp","options","spin","start","application","succeed","rollback","error","fail","createStudio","deployWorkbenchApp","access","app","applicationId","icon","isApp","isAutoUpdating","isExternal","label","onDeployed","slug","sourceDir","title","visibility","workspaces","mfManifest","JSON","parse","tarball","undefined","cwd","pipe","interfaces","appTitle","map","toSlugRejection","clear","statusCode","Error","cause"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,QAAQ,EAAEC,OAAO,EAAEC,IAAI,QAAO,YAAW;AACjD,SAAQC,UAAU,QAAO,YAAW;AAGpC,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAA+BC,gBAAgB,QAAO,4BAA2B;AACjF,SAKEC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,iBAAiB,QACZ,iCAAgC;AAWvC,SAASC,iBAAiBC,KAAuB,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,KAAKG,OAAO;IACd,EAAE,OAAOE,OAAO;QACdL,KAAKkC,KAAK;QACV,MAAM7B;IACR;AACF;AAEA;;;;;CAKC,GACD,SAAS4B,gBAAgB5B,KAAc,EAAEa,IAAwB;IAC/D,MAAMiB,aAAc9B,OAAiC8B;IACrD,IAAI,CAACjB,QAAQiB,eAAeR,aAAaQ,aAAa,OAAOA,cAAc,KAAK,OAAO9B;IACvF,OAAO,IAAI+B,MACT,CAAC,MAAM,EAAElB,KAAK,gBAAgB,EAAExC,gBAAgB2B,OAAO,oHAAoH,CAAC,EAC5K;QAACgC,OAAOhC;IAAK;AAEjB"}
@@ -1,8 +1,17 @@
1
1
  import { SERVICE_CONTRACT_VERSION } from './contract.js';
2
2
  /**
3
3
  * Define a Sanity Dashboard background service. The first argument narrows the
4
- * callback shape — `"worker"` runs the callback inside a Web Worker, where it
5
- * can emit dock-badge updates and return a disposer.
4
+ * callback shape — `"worker"` runs the callback inside a Web Worker.
5
+ *
6
+ * The callback receives `bus`, its connection to the Dashboard message bus:
7
+ * `bus.emit` sends an event (such as a dock-badge update), `bus.query` reads the
8
+ * current value of a state topic, and `bus.subscribe` runs a handler on each
9
+ * new value of a state topic until its `signal` aborts. A refused, unanswered
10
+ * or timed-out request rejects with an `Error` named `MessageBusError` whose
11
+ * `code` says why; it is not an instance of the SDK's `MessageBusError` class.
12
+ * The callback can return a disposer, which runs when Dashboard stops the
13
+ * worker. By then the bus is closed: subscriptions have ended, `emit` and
14
+ * `query` reject with code `ABORTED`, and `subscribe` throws that error.
6
15
  *
7
16
  * Identity at runtime: returns the callback tagged with its type and the contract
8
17
  * version, for the CLI build to generate a worker artifact from. Used as the
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defineService.ts"],"sourcesContent":["import {SERVICE_CONTRACT_VERSION, type ServiceType} from './contract.js'\n\n/**\n * The service's own declaration, surfaced to the callback.\n * @public\n */\nexport interface ServiceInfo {\n readonly name: string\n readonly type: string\n}\n\n/**\n * Context every service callback receives when its worker starts. Mirrors how a\n * view component receives its `view` — the service receives its own `service`.\n * @public\n */\nexport interface ServiceContext {\n readonly service: ServiceInfo\n}\n\n/**\n * A service callback. Runs once inside the worker on start; returns an optional\n * disposer the host calls before terminating the worker.\n * @public\n */\nexport type ServiceCallback = (context: ServiceContext) => (() => void) | void\n\n/** The callback shape each service type defines, keyed by type. */\ninterface ServiceCallbacksByType {\n worker: ServiceCallback\n}\n\n/**\n * The result of `unstable_defineService`: the author's callback, the service\n * type, and the internal contract version the worker artifact targets.\n * @public\n */\nexport interface DefinedService<TType extends ServiceType = ServiceType> {\n readonly run: ServiceCallbacksByType[TType]\n readonly type: TType\n /** @internal */\n readonly version: typeof SERVICE_CONTRACT_VERSION\n}\n\n/**\n * Define a Sanity Dashboard background service. The first argument narrows the\n * callback shape — `\"worker\"` runs the callback inside a Web Worker, where it\n * can emit dock-badge updates and return a disposer.\n *\n * Identity at runtime: returns the callback tagged with its type and the contract\n * version, for the CLI build to generate a worker artifact from. Used as the\n * default export of a service's `src` file.\n * @public\n */\nexport function unstable_defineService<TType extends ServiceType>(\n type: TType,\n run: ServiceCallbacksByType[TType],\n): DefinedService<TType> {\n return {run, type, version: SERVICE_CONTRACT_VERSION}\n}\n"],"names":["SERVICE_CONTRACT_VERSION","unstable_defineService","type","run","version"],"mappings":"AAAA,SAAQA,wBAAwB,QAAyB,gBAAe;AA4CxE;;;;;;;;;CASC,GACD,OAAO,SAASC,uBACdC,IAAW,EACXC,GAAkC;IAElC,OAAO;QAACA;QAAKD;QAAME,SAASJ;IAAwB;AACtD"}
1
+ {"version":3,"sources":["../src/defineService.ts"],"sourcesContent":["import {\n type MessageBus,\n type MessageBusAbortOptions,\n type StateTopic,\n type ValueOf,\n} from '@sanity/sdk/dashboard'\n\nimport {SERVICE_CONTRACT_VERSION, type ServiceType} from './contract.js'\n\n/**\n * The service's own declaration, surfaced to the callback.\n * @public\n */\nexport interface ServiceInfo {\n readonly name: string\n readonly type: string\n}\n\n/**\n * The message bus as a service sees it: `emit` and `query` as in the SDK, and\n * `subscribe` for state topics only. Only Dashboard can respond to its event\n * topics, so a service has no reason to subscribe to them. There is no\n * `disconnect`: Dashboard owns the connection and ends it when it stops the\n * worker.\n * @public\n */\nexport interface ServiceBus extends Omit<MessageBus, 'subscribe'> {\n /** Runs a handler for each state value until its signal aborts. */\n subscribe<K extends StateTopic>(\n type: K,\n handler: (value: ValueOf<K>) => void,\n options?: MessageBusAbortOptions,\n ): void\n}\n\n/**\n * Context every service callback receives when its worker starts. Mirrors how a\n * view component receives its `view` — the service receives its own `service`.\n * @public\n */\nexport interface ServiceContext {\n readonly bus: ServiceBus\n readonly service: ServiceInfo\n}\n\n/**\n * A service callback. Runs once inside the worker on start; returns an optional\n * disposer the host calls before terminating the worker.\n * @public\n */\nexport type ServiceCallback = (context: ServiceContext) => (() => void) | void\n\n/** The callback shape each service type defines, keyed by type. */\ninterface ServiceCallbacksByType {\n worker: ServiceCallback\n}\n\n/**\n * The result of `unstable_defineService`: the author's callback, the service\n * type, and the internal contract version the worker artifact targets.\n * @public\n */\nexport interface DefinedService<TType extends ServiceType = ServiceType> {\n readonly run: ServiceCallbacksByType[TType]\n readonly type: TType\n /** @internal */\n readonly version: typeof SERVICE_CONTRACT_VERSION\n}\n\n/**\n * Define a Sanity Dashboard background service. The first argument narrows the\n * callback shape — `\"worker\"` runs the callback inside a Web Worker.\n *\n * The callback receives `bus`, its connection to the Dashboard message bus:\n * `bus.emit` sends an event (such as a dock-badge update), `bus.query` reads the\n * current value of a state topic, and `bus.subscribe` runs a handler on each\n * new value of a state topic until its `signal` aborts. A refused, unanswered\n * or timed-out request rejects with an `Error` named `MessageBusError` whose\n * `code` says why; it is not an instance of the SDK's `MessageBusError` class.\n * The callback can return a disposer, which runs when Dashboard stops the\n * worker. By then the bus is closed: subscriptions have ended, `emit` and\n * `query` reject with code `ABORTED`, and `subscribe` throws that error.\n *\n * Identity at runtime: returns the callback tagged with its type and the contract\n * version, for the CLI build to generate a worker artifact from. Used as the\n * default export of a service's `src` file.\n * @public\n */\nexport function unstable_defineService<TType extends ServiceType>(\n type: TType,\n run: ServiceCallbacksByType[TType],\n): DefinedService<TType> {\n return {run, type, version: SERVICE_CONTRACT_VERSION}\n}\n"],"names":["SERVICE_CONTRACT_VERSION","unstable_defineService","type","run","version"],"mappings":"AAOA,SAAQA,wBAAwB,QAAyB,gBAAe;AA8DxE;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,uBACdC,IAAW,EACXC,GAAkC;IAElC,OAAO;QAACA;QAAKD;QAAME,SAASJ;IAAwB;AACtD"}
@@ -4,8 +4,24 @@
4
4
  // is not an app. The build and deploy accessors (actions/build, actions/deploy)
5
5
  // each build their command-specific view on top of this one brand-check +
6
6
  // extraction, so the discrimination lives in exactly one place.
7
+ import { defineWindowView } from './contract.js';
7
8
  import { isWorkbenchApp } from './defineApp.js';
8
9
  import { formatWorkbenchAppErrors, validateWorkbenchApp } from './validateWorkbenchApp.js';
10
+ /**
11
+ * The module behind the app's `./App` expose. `entry` is shorthand for a window view.
12
+ * @internal
13
+ */ export function resolveAppEntry(app) {
14
+ if (!isWorkbenchApp(app)) return app?.entry;
15
+ const views = app.entry === undefined ? app.views ?? [] : [
16
+ defineWindowView({
17
+ name: app.name ?? app.slug,
18
+ src: app.entry,
19
+ title: app.title
20
+ }),
21
+ ...app.views ?? []
22
+ ];
23
+ return views.find((view)=>view.surface === 'window')?.src;
24
+ }
9
25
  /**
10
26
  * Resolve the workbench app for a CLI config, or `null` for a plain project or a
11
27
  * config (which is not an app — read it with `resolveWorkbenchConfig`).
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/resolveWorkbenchApp.ts"],"sourcesContent":["// Package-internal shared resolver: turn a CLI config's branded\n// `defineApplication` app into its declared interfaces, or `null` for a plain\n// project — and for a config (a branded `unstable_defineMediaLibrary`), which\n// is not an app. The build and deploy accessors (actions/build, actions/deploy)\n// each build their command-specific view on top of this one brand-check +\n// extraction, so the discrimination lives in exactly one place.\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\n\nimport {type WorkbenchConfigValue} from './contract.js'\nimport {type DefineAppInput, isWorkbenchApp} from './defineApp.js'\nimport {formatWorkbenchAppErrors, validateWorkbenchApp} from './validateWorkbenchApp.js'\n\n/**\n * Bundled so adding a declaration family touches this type and the artifact\n * expanders, not every hop of build/dev plumbing in between. `config` is sourced\n * from `resolveWorkbenchConfig` (a config is not an app), not from this resolver.\n * @internal\n */\nexport interface WorkbenchExposes {\n config?: WorkbenchConfigValue\n views?: DefineAppInput['views']\n webWorkers?: DefineAppInput['webWorkers']\n}\n\n/** @public */\nexport interface ResolvedWorkbenchApp {\n /**\n * Stable identity, distinct from the `slug` address. Defaults to `slug`, and is\n * what every identity key (build id, interface ids) is built from.\n */\n readonly name: string\n /** Organization that owns the app — part of its build-id identity. */\n readonly organizationId: string\n readonly slug: string\n\n /** Views the app declares. */\n readonly views: NonNullable<DefineAppInput['views']>\n\n /** Background web workers the app declares. */\n readonly webWorkers: NonNullable<DefineAppInput['webWorkers']>\n\n /** Resolved app kind — `studio` or one of the SDK app types. */\n readonly applicationType?: string\n /** SDK app-view entrypoint, when declared. */\n readonly entry?: string\n /** Path to the app's icon SVG, resolved and shipped to Brett on deploy. */\n readonly icon?: string\n /** Explicit singleton flag for Sanity-owned apps. */\n readonly isSingleton?: boolean\n /** Dashboard visibility declared by the app; `undefined` when unset. */\n readonly visibility?: AppVisibility\n}\n\n/**\n * Resolve the workbench app for a CLI config, or `null` for a plain project or a\n * config (which is not an app — read it with `resolveWorkbenchConfig`).\n * @public\n */\nexport function resolveWorkbenchApp(\n cliConfig: CliConfig | null | undefined,\n): ResolvedWorkbenchApp | null {\n const app = cliConfig?.app\n // A config carries a distinct brand, so `isWorkbenchApp` is false for it — it\n // resolves to `null` here, like a plain project.\n if (!isWorkbenchApp(app)) return null\n\n const errors = validateWorkbenchApp(app)\n if (errors.length > 0) throw new Error(formatWorkbenchAppErrors(errors))\n\n return {\n applicationType: app.applicationType,\n entry: app.entry,\n icon: app.icon,\n ...(app.isSingleton === undefined ? {} : {isSingleton: app.isSingleton}),\n // Identity defaults to the address, so existing apps behave identically.\n name: app.name ?? app.slug,\n organizationId: app.organizationId,\n slug: app.slug,\n views: app.views ?? [],\n visibility: app.visibility,\n webWorkers: app.webWorkers ?? [],\n }\n}\n"],"names":["isWorkbenchApp","formatWorkbenchAppErrors","validateWorkbenchApp","resolveWorkbenchApp","cliConfig","app","errors","length","Error","applicationType","entry","icon","isSingleton","undefined","name","slug","organizationId","views","visibility","webWorkers"],"mappings":"AAAA,gEAAgE;AAChE,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,0EAA0E;AAC1E,gEAAgE;AAKhE,SAA6BA,cAAc,QAAO,iBAAgB;AAClE,SAAQC,wBAAwB,EAAEC,oBAAoB,QAAO,4BAA2B;AA2CxF;;;;CAIC,GACD,OAAO,SAASC,oBACdC,SAAuC;IAEvC,MAAMC,MAAMD,WAAWC;IACvB,8EAA8E;IAC9E,iDAAiD;IACjD,IAAI,CAACL,eAAeK,MAAM,OAAO;IAEjC,MAAMC,SAASJ,qBAAqBG;IACpC,IAAIC,OAAOC,MAAM,GAAG,GAAG,MAAM,IAAIC,MAAMP,yBAAyBK;IAEhE,OAAO;QACLG,iBAAiBJ,IAAII,eAAe;QACpCC,OAAOL,IAAIK,KAAK;QAChBC,MAAMN,IAAIM,IAAI;QACd,GAAIN,IAAIO,WAAW,KAAKC,YAAY,CAAC,IAAI;YAACD,aAAaP,IAAIO,WAAW;QAAA,CAAC;QACvE,yEAAyE;QACzEE,MAAMT,IAAIS,IAAI,IAAIT,IAAIU,IAAI;QAC1BC,gBAAgBX,IAAIW,cAAc;QAClCD,MAAMV,IAAIU,IAAI;QACdE,OAAOZ,IAAIY,KAAK,IAAI,EAAE;QACtBC,YAAYb,IAAIa,UAAU;QAC1BC,YAAYd,IAAIc,UAAU,IAAI,EAAE;IAClC;AACF"}
1
+ {"version":3,"sources":["../src/resolveWorkbenchApp.ts"],"sourcesContent":["// Package-internal shared resolver: turn a CLI config's branded\n// `defineApplication` app into its declared interfaces, or `null` for a plain\n// project — and for a config (a branded `unstable_defineMediaLibrary`), which\n// is not an app. The build and deploy accessors (actions/build, actions/deploy)\n// each build their command-specific view on top of this one brand-check +\n// extraction, so the discrimination lives in exactly one place.\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\n\nimport {defineWindowView, type WorkbenchConfigValue} from './contract.js'\nimport {type DefineAppInput, isWorkbenchApp} from './defineApp.js'\nimport {formatWorkbenchAppErrors, validateWorkbenchApp} from './validateWorkbenchApp.js'\n\n/**\n * Bundled so adding a declaration family touches this type and the artifact\n * expanders, not every hop of build/dev plumbing in between. `config` is sourced\n * from `resolveWorkbenchConfig` (a config is not an app), not from this resolver.\n * @internal\n */\nexport interface WorkbenchExposes {\n config?: WorkbenchConfigValue\n views?: DefineAppInput['views']\n webWorkers?: DefineAppInput['webWorkers']\n}\n\n/** @public */\nexport interface ResolvedWorkbenchApp {\n /**\n * Stable identity, distinct from the `slug` address. Defaults to `slug`, and is\n * what every identity key (build id, interface ids) is built from.\n */\n readonly name: string\n /** Organization that owns the app — part of its build-id identity. */\n readonly organizationId: string\n readonly slug: string\n\n /** Views the app declares. */\n readonly views: NonNullable<DefineAppInput['views']>\n\n /** Background web workers the app declares. */\n readonly webWorkers: NonNullable<DefineAppInput['webWorkers']>\n\n /** Resolved app kind — `studio` or one of the SDK app types. */\n readonly applicationType?: string\n /** SDK app-view entrypoint, when declared. */\n readonly entry?: string\n /** Path to the app's icon SVG, resolved and shipped to Brett on deploy. */\n readonly icon?: string\n /** Explicit singleton flag for Sanity-owned apps. */\n readonly isSingleton?: boolean\n /** Dashboard visibility declared by the app; `undefined` when unset. */\n readonly visibility?: AppVisibility\n}\n\n/**\n * The module behind the app's `./App` expose. `entry` is shorthand for a window view.\n * @internal\n */\nexport function resolveAppEntry(app: CliConfig['app']): string | undefined {\n if (!isWorkbenchApp(app)) return app?.entry\n\n const views =\n app.entry === undefined\n ? (app.views ?? [])\n : [\n defineWindowView({name: app.name ?? app.slug, src: app.entry, title: app.title}),\n ...(app.views ?? []),\n ]\n\n return views.find((view) => view.surface === 'window')?.src\n}\n\n/**\n * Resolve the workbench app for a CLI config, or `null` for a plain project or a\n * config (which is not an app — read it with `resolveWorkbenchConfig`).\n * @public\n */\nexport function resolveWorkbenchApp(\n cliConfig: CliConfig | null | undefined,\n): ResolvedWorkbenchApp | null {\n const app = cliConfig?.app\n // A config carries a distinct brand, so `isWorkbenchApp` is false for it — it\n // resolves to `null` here, like a plain project.\n if (!isWorkbenchApp(app)) return null\n\n const errors = validateWorkbenchApp(app)\n if (errors.length > 0) throw new Error(formatWorkbenchAppErrors(errors))\n\n return {\n applicationType: app.applicationType,\n entry: app.entry,\n icon: app.icon,\n ...(app.isSingleton === undefined ? {} : {isSingleton: app.isSingleton}),\n // Identity defaults to the address, so existing apps behave identically.\n name: app.name ?? app.slug,\n organizationId: app.organizationId,\n slug: app.slug,\n views: app.views ?? [],\n visibility: app.visibility,\n webWorkers: app.webWorkers ?? [],\n }\n}\n"],"names":["defineWindowView","isWorkbenchApp","formatWorkbenchAppErrors","validateWorkbenchApp","resolveAppEntry","app","entry","views","undefined","name","slug","src","title","find","view","surface","resolveWorkbenchApp","cliConfig","errors","length","Error","applicationType","icon","isSingleton","organizationId","visibility","webWorkers"],"mappings":"AAAA,gEAAgE;AAChE,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,0EAA0E;AAC1E,gEAAgE;AAIhE,SAAQA,gBAAgB,QAAkC,gBAAe;AACzE,SAA6BC,cAAc,QAAO,iBAAgB;AAClE,SAAQC,wBAAwB,EAAEC,oBAAoB,QAAO,4BAA2B;AA2CxF;;;CAGC,GACD,OAAO,SAASC,gBAAgBC,GAAqB;IACnD,IAAI,CAACJ,eAAeI,MAAM,OAAOA,KAAKC;IAEtC,MAAMC,QACJF,IAAIC,KAAK,KAAKE,YACTH,IAAIE,KAAK,IAAI,EAAE,GAChB;QACEP,iBAAiB;YAACS,MAAMJ,IAAII,IAAI,IAAIJ,IAAIK,IAAI;YAAEC,KAAKN,IAAIC,KAAK;YAAEM,OAAOP,IAAIO,KAAK;QAAA;WAC1EP,IAAIE,KAAK,IAAI,EAAE;KACpB;IAEP,OAAOA,MAAMM,IAAI,CAAC,CAACC,OAASA,KAAKC,OAAO,KAAK,WAAWJ;AAC1D;AAEA;;;;CAIC,GACD,OAAO,SAASK,oBACdC,SAAuC;IAEvC,MAAMZ,MAAMY,WAAWZ;IACvB,8EAA8E;IAC9E,iDAAiD;IACjD,IAAI,CAACJ,eAAeI,MAAM,OAAO;IAEjC,MAAMa,SAASf,qBAAqBE;IACpC,IAAIa,OAAOC,MAAM,GAAG,GAAG,MAAM,IAAIC,MAAMlB,yBAAyBgB;IAEhE,OAAO;QACLG,iBAAiBhB,IAAIgB,eAAe;QACpCf,OAAOD,IAAIC,KAAK;QAChBgB,MAAMjB,IAAIiB,IAAI;QACd,GAAIjB,IAAIkB,WAAW,KAAKf,YAAY,CAAC,IAAI;YAACe,aAAalB,IAAIkB,WAAW;QAAA,CAAC;QACvE,yEAAyE;QACzEd,MAAMJ,IAAII,IAAI,IAAIJ,IAAIK,IAAI;QAC1Bc,gBAAgBnB,IAAImB,cAAc;QAClCd,MAAML,IAAIK,IAAI;QACdH,OAAOF,IAAIE,KAAK,IAAI,EAAE;QACtBkB,YAAYpB,IAAIoB,UAAU;QAC1BC,YAAYrB,IAAIqB,UAAU,IAAI,EAAE;IAClC;AACF"}
@@ -42,7 +42,7 @@ export async function getApplication(applicationId) {
42
42
  * Create an application record (no deployment), so the CLI can build with the
43
43
  * returned id, then ship it via {@link createDeployment}.
44
44
  */ export async function createApplication(options) {
45
- const { isSingleton, name, organizationId, projectId, slug, title, type, visibility } = options;
45
+ const { externalUrl, isSingleton, name, organizationId, projectId, slug, title, type, visibility } = options;
46
46
  const client = await getClient();
47
47
  return client.request({
48
48
  body: {
@@ -62,6 +62,9 @@ export async function getApplication(applicationId) {
62
62
  ...visibility ? {
63
63
  visibility
64
64
  } : {},
65
+ ...externalUrl ? {
66
+ externalUrl
67
+ } : {},
65
68
  // Studio config is set once, at create — it's immutable on redeploy.
66
69
  ...projectId ? {
67
70
  config: {
@@ -84,13 +87,18 @@ export async function updateApplication(applicationId, update) {
84
87
  url: `/applications/${applicationId}`
85
88
  });
86
89
  }
87
- /** Deploy a new active version to an existing application. */ export async function createDeployment(options) {
88
- const { access, applicationId, interfaces, isAutoUpdating, tarball, version, workspaces } = options;
90
+ /**
91
+ * Deploy a new active version to an existing application. `mfManifest` is the
92
+ * build's `mf-manifest.json`; `tarball` is omitted for an external application,
93
+ * whose build the customer serves themselves.
94
+ */ export async function createDeployment(options) {
95
+ const { access, applicationId, interfaces, isAutoUpdating, mfManifest, tarball, version, workspaces } = options;
89
96
  const formData = new FormData();
90
97
  formData.append('isAutoUpdating', isAutoUpdating.toString());
91
98
  appendDeploymentParts(formData, {
92
99
  access,
93
100
  interfaces,
101
+ mfManifest,
94
102
  tarball,
95
103
  version,
96
104
  workspaces
@@ -108,17 +116,21 @@ export async function updateApplication(applicationId, update) {
108
116
  if (err?.statusCode !== 404) throw err;
109
117
  }
110
118
  }
111
- function appendDeploymentParts(formData, { access, interfaces, tarball, version, workspaces }) {
119
+ function appendDeploymentParts(formData, { access, interfaces, mfManifest, tarball, version, workspaces }) {
112
120
  formData.append('version', version);
113
121
  appendJson(formData, 'interfaces', interfaces);
114
122
  // Studio-only — the server rejects a workspaces part on non-studio types.
115
123
  if (workspaces?.length) appendJson(formData, 'workspaces', workspaces);
116
124
  // Per-deployment; forbidden for singletons, so callers omit it there.
117
125
  if (access?.length) appendJson(formData, 'access', access);
118
- formData.append('tarball', tarball, {
119
- contentType: 'application/gzip',
120
- filename: 'app.tar.gz'
121
- });
126
+ appendJson(formData, 'mfManifest', mfManifest);
127
+ // Last: the server requires every field part to precede the tarball.
128
+ if (tarball) {
129
+ formData.append('tarball', tarball, {
130
+ contentType: 'application/gzip',
131
+ filename: 'app.tar.gz'
132
+ });
133
+ }
122
134
  }
123
135
  /** Structured parts must arrive as JSON so the server parses them. */ function appendJson(formData, name, value) {
124
136
  formData.append(name, JSON.stringify(value), {