@sanity/workbench-cli 2.15.2 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_exports/_internal_worker_bus.d.ts +3 -3
- package/dist/_exports/_internal_worker_bus.js +1 -1
- package/dist/_exports/_internal_worker_bus.js.map +1 -1
- package/dist/_exports/build.d.ts +3 -3
- package/dist/_exports/{contract-C4Y6gi-b.d.ts → contract-WrU3aOYd.d.ts} +9 -6
- package/dist/_exports/deploy.d.ts +3 -3
- package/dist/_exports/dev.d.ts +1 -1
- package/dist/_exports/index.d.ts +5 -4
- package/dist/_exports/index.js +1 -1
- package/dist/_exports/index.js.map +1 -1
- package/dist/_exports/{resolveWorkbenchConfig-CgKD8AJ7.d.ts → resolveWorkbenchConfig-JRi01VJM.d.ts} +2 -2
- package/dist/_exports/{summarizeInterfaces-CeV5Umpj.d.ts → summarizeInterfaces-CpCUSMrz.d.ts} +6 -6
- package/dist/_exports/undeploy.d.ts +2 -2
- package/dist/_exports/{defineService-DPZwNN6_.d.ts → webWorker-TWUbh0uo.d.ts} +63 -39
- package/dist/actions/build/artifact.js +2 -2
- package/dist/actions/build/artifact.js.map +1 -1
- package/dist/actions/build/render-remote.js +11 -5
- package/dist/actions/build/render-remote.js.map +1 -1
- package/dist/actions/build/views/artifact.js +7 -5
- package/dist/actions/build/views/artifact.js.map +1 -1
- package/dist/actions/build/vite/optimize-deps.js +2 -2
- package/dist/actions/build/vite/optimize-deps.js.map +1 -1
- package/dist/actions/build/vite/plugin.js +2 -2
- package/dist/actions/build/vite/plugin.js.map +1 -1
- package/dist/actions/build/vite/plugins/plugin-sanity-environment.js +1 -0
- package/dist/actions/build/vite/plugins/plugin-sanity-environment.js.map +1 -1
- package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js +2 -2
- package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js.map +1 -1
- package/dist/actions/build/vite/plugins/plugin-sanity-federation-runtime.js +5 -2
- package/dist/actions/build/vite/plugins/plugin-sanity-federation-runtime.js.map +1 -1
- package/dist/actions/build/{services → webWorkers}/artifact.js +28 -27
- package/dist/actions/build/webWorkers/artifact.js.map +1 -0
- package/dist/actions/build/{services → webWorkers}/workerBus.js +1 -1
- package/dist/actions/build/webWorkers/workerBus.js.map +1 -0
- package/dist/actions/deploy/deployWorkbenchApp.js +7 -14
- package/dist/actions/deploy/deployWorkbenchApp.js.map +1 -1
- package/dist/actions/deploy/getWorkbench.js.map +1 -1
- package/dist/actions/deploy/summarizeInterfaces.js +3 -3
- package/dist/actions/deploy/summarizeInterfaces.js.map +1 -1
- package/dist/actions/dev/appServerSupervisor.js +2 -2
- package/dist/actions/dev/appServerSupervisor.js.map +1 -1
- package/dist/actions/dev/exposesSetId.js +1 -1
- package/dist/actions/dev/exposesSetId.js.map +1 -1
- package/dist/actions/dev/registry.js +14 -4
- package/dist/actions/dev/registry.js.map +1 -1
- package/dist/actions/dev/startWorkbenchDev.js +1 -1
- package/dist/actions/dev/startWorkbenchDev.js.map +1 -1
- package/dist/contract.js +8 -8
- package/dist/contract.js.map +1 -1
- package/dist/defineApp.js +2 -2
- package/dist/defineApp.js.map +1 -1
- package/dist/defineView.js +2 -2
- package/dist/defineView.js.map +1 -1
- package/dist/deriveInterfaces.js.map +1 -1
- package/dist/webWorker.js +20 -0
- package/dist/webWorker.js.map +1 -0
- package/package.json +11 -11
- package/dist/actions/build/services/artifact.js.map +0 -1
- package/dist/actions/build/services/workerBus.js.map +0 -1
- package/dist/defineService.js +0 -52
- package/dist/defineService.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as WebWorkerBus } from "./webWorker-TWUbh0uo.js";
|
|
2
2
|
/**
|
|
3
3
|
* The worker's side of the `workbench.bus.*` wire contract. The host relays
|
|
4
4
|
* each request to the Dashboard bus and stamps it with the worker's identity,
|
|
@@ -7,10 +7,10 @@ import { n as ServiceBus } from "./defineService-DPZwNN6_.js";
|
|
|
7
7
|
*/
|
|
8
8
|
declare function createWorkerBus(): {
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
10
|
+
* The web worker author's API. The host owns the connection, opening it and ending it when
|
|
11
11
|
* it terminates the worker, so the worker cannot end it.
|
|
12
12
|
*/
|
|
13
|
-
bus:
|
|
13
|
+
bus: WebWorkerBus;
|
|
14
14
|
/**
|
|
15
15
|
* The generated entry's terminate hook, not the author's. It sends nothing to
|
|
16
16
|
* the host, which has already disconnected; it only marks the client closed so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/_internal_worker_bus.ts"],"sourcesContent":["export {createWorkerBus} from '../actions/build/
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/_internal_worker_bus.ts"],"sourcesContent":["export {createWorkerBus} from '../actions/build/webWorkers/workerBus.js'\n"],"names":["createWorkerBus"],"mappings":"AAAA,SAAQA,eAAe,QAAO,2CAA0C"}
|
package/dist/_exports/build.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveAppEntry, i as WorkbenchExposes, n as resolveWorkbenchConfig, o as resolveWorkbenchApp, r as ResolvedWorkbenchApp, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-
|
|
1
|
+
import { a as resolveAppEntry, i as WorkbenchExposes, n as resolveWorkbenchConfig, o as resolveWorkbenchApp, r as ResolvedWorkbenchApp, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-JRi01VJM.js";
|
|
2
2
|
import { InlineConfig, PluginOption } from "vite";
|
|
3
3
|
/**
|
|
4
4
|
* Resolves to the parsed federation manifest in `sourceDir`. A workbench build
|
|
@@ -66,12 +66,12 @@ declare function buildFederatedApp(config: InlineConfig, { reuseStandaloneBuild
|
|
|
66
66
|
* app's `entry` (or a studio's config) — never the federation `exposes` (dock
|
|
67
67
|
* views, web workers, media-library config fields), which the host loads
|
|
68
68
|
* dynamically at runtime. So a dep imported only by an exposed module (e.g.
|
|
69
|
-
* `sanity/workbench` in a
|
|
69
|
+
* `sanity/workbench` in a web worker or view) escapes the startup scan; Vite
|
|
70
70
|
* discovers it on first request, re-optimizes, and full-page reloads — which
|
|
71
71
|
* flakes Playwright in e2e.
|
|
72
72
|
*
|
|
73
73
|
* Point `entries` at the source of every interface: the app `entry` (or, for a
|
|
74
|
-
* studio, its config), plus each view,
|
|
74
|
+
* studio, its config), plus each view, web worker, and installation-config source.
|
|
75
75
|
* `entries` follows real import statements, so it covers whatever those sources
|
|
76
76
|
* transitively use — correct subpaths and all — with no hand-maintained dep
|
|
77
77
|
* list, and never crashes on an unresolvable name the way a bad `include` entry
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { z } from "zod/mini";
|
|
2
2
|
/** @internal */
|
|
3
|
-
declare const
|
|
4
|
-
/** @internal */
|
|
5
|
-
declare const SERVICE_CONTRACT_VERSION = 1;
|
|
3
|
+
declare const WEB_WORKER_CONTRACT_VERSION = 1;
|
|
6
4
|
/**
|
|
7
5
|
* A view component. The return is opaque so the runtime helpers carry no React
|
|
8
6
|
* dependency — the generated artifact renders it with the app's own React.
|
|
@@ -37,7 +35,12 @@ declare const TileSizeSchema: z.ZodMiniEnum<{
|
|
|
37
35
|
/** @public */
|
|
38
36
|
type TileSize = z.infer<typeof TileSizeSchema>;
|
|
39
37
|
/** @public */
|
|
40
|
-
type
|
|
38
|
+
type WebWorkerType = 'worker';
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use `WebWorkerType`.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
type ServiceType = WebWorkerType;
|
|
41
44
|
declare const DockGroupSchema: z.ZodMiniEnum<{
|
|
42
45
|
system: "system";
|
|
43
46
|
applications: "applications";
|
|
@@ -180,5 +183,5 @@ declare const ConfigSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
|
180
183
|
* @internal
|
|
181
184
|
*/
|
|
182
185
|
type WorkbenchConfigValue = z.output<typeof ConfigSchema>;
|
|
183
|
-
export { defineTileView as C, definePanelView as S, defineWindowView as T,
|
|
184
|
-
//# sourceMappingURL=contract-
|
|
186
|
+
export { defineTileView as C, definePanelView as S, defineWindowView as T, WebWorker as _, DefineWebWorkerInput as a, WorkbenchConfigValue as b, PanelView as c, TileView as d, ViewComponent as f, WEB_WORKER_CONTRACT_VERSION as g, ViewSurface as h, DefineTileViewInput as i, ServiceType as l, ViewDeclaration as m, DefineAssetSourceViewInput as n, DefineWindowViewInput as o, ViewComponentBaseProps as p, DefinePanelViewInput as r, DockGroup as s, AssetSourceView as t, TileSize as u, WebWorkerType as v, defineWebWorker as w, defineAssetSourceView as x, WindowView as y };
|
|
187
|
+
//# sourceMappingURL=contract-WrU3aOYd.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./contract-
|
|
2
|
-
import { n as resolveWorkbenchConfig, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-
|
|
3
|
-
import { a as DeployableWorkbenchApp, i as summarizeInterfaces, n as DeployedView, o as getWorkbench, r as DeployedWebWorker, t as DeployedInterface } from "./summarizeInterfaces-
|
|
1
|
+
import "./contract-WrU3aOYd.js";
|
|
2
|
+
import { n as resolveWorkbenchConfig, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-JRi01VJM.js";
|
|
3
|
+
import { a as DeployableWorkbenchApp, i as summarizeInterfaces, n as DeployedView, o as getWorkbench, r as DeployedWebWorker, t as DeployedInterface } from "./summarizeInterfaces-CpCUSMrz.js";
|
|
4
4
|
import { AppVisibility, CliConfig, Output } from "@sanity/cli-core";
|
|
5
5
|
import "node:zlib";
|
|
6
6
|
/**
|
package/dist/_exports/dev.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ interface StartWorkbenchDevOptions {
|
|
|
42
42
|
/**
|
|
43
43
|
* Orchestrate the dev servers a workbench project needs: a singleton workbench
|
|
44
44
|
* Vite server plus the app/studio dev server it renders, wired to the dev-server
|
|
45
|
-
* registry so view/
|
|
45
|
+
* registry so view/web worker edits re-sync live.
|
|
46
46
|
*
|
|
47
47
|
* A running workbench claims the configured port, so the app server binds the
|
|
48
48
|
* next one. If the workbench can't start (package or port unavailable), the app
|
package/dist/_exports/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as defineTileView, S as definePanelView, T as defineWindowView, _ as
|
|
2
|
-
import { a as ServiceInfo, i as ServiceContext, n as ServiceBus, o as
|
|
1
|
+
import { C as defineTileView, S as definePanelView, T as defineWindowView, _ as WebWorker, a as DefineWebWorkerInput, c as PanelView, d as TileView, f as ViewComponent, h as ViewSurface, i as DefineTileViewInput, l as ServiceType, m as ViewDeclaration, n as DefineAssetSourceViewInput, o as DefineWindowViewInput, p as ViewComponentBaseProps, r as DefinePanelViewInput, s as DockGroup, t as AssetSourceView, u as TileSize, v as WebWorkerType, w as defineWebWorker, x as defineAssetSourceView, y as WindowView } from "./contract-WrU3aOYd.js";
|
|
2
|
+
import { a as ServiceInfo, c as WebWorkerProps, i as ServiceContext, l as unstable_defineService, n as ServiceBus, o as WebWorkerBus, r as ServiceCallback, s as WebWorkerInfo, t as DefinedService } from "./webWorker-TWUbh0uo.js";
|
|
3
3
|
import { a as WorkbenchApp, c as isWorkbenchApp, i as MediaLibraryField, l as isWorkbenchConfig, n as DefineAppResult, o as WorkbenchConfig, r as DefineMediaLibraryInput, s as defineApplication, t as DefineAppInput, u as unstable_defineMediaLibrary } from "./defineApp-vbUu_rBA.js";
|
|
4
4
|
import { AssetSourceComponentProps } from "@sanity/types";
|
|
5
5
|
/** @public */
|
|
@@ -98,7 +98,7 @@ interface DefinedView<TSurface extends ViewSurface = ViewSurface> {
|
|
|
98
98
|
readonly components: ViewComponentsBySurface[TSurface];
|
|
99
99
|
readonly surface: TSurface;
|
|
100
100
|
/** @internal */
|
|
101
|
-
readonly version:
|
|
101
|
+
readonly version: 1;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Define a Sanity Dashboard view. The first argument narrows the component shape
|
|
@@ -108,8 +108,9 @@ interface DefinedView<TSurface extends ViewSurface = ViewSurface> {
|
|
|
108
108
|
* Returns the component(s) tagged with their surface and contract version, for
|
|
109
109
|
* the CLI build to generate render artifacts from. Used as the default export of
|
|
110
110
|
* a view's `src` file.
|
|
111
|
+
* @deprecated Default-export a plain React component from the view's `src` file instead.
|
|
111
112
|
* @public
|
|
112
113
|
*/
|
|
113
114
|
declare function unstable_defineView<TSurface extends ViewSurface>(surface: TSurface, components: ViewComponentsBySurface[TSurface]): DefinedView<TSurface>;
|
|
114
|
-
export { type AssetSourceComponent, type AssetSourceView, type AssetSourceViewComponents, type DefineAppInput, type DefineAppResult, type DefineAssetSourceViewInput, type DefineMediaLibraryInput, type DefinePanelViewInput, type DefineTileViewInput, type DefineWebWorkerInput, type DefineWindowViewInput, type DefinedService, type DefinedView, type DockGroup, type MediaLibraryField, type PanelComponent, type PanelView, type PanelViewComponents, type PanelViewProps, type ServiceBus, type ServiceCallback, type ServiceContext, type ServiceInfo, type ServiceType, type TileComponent, type TileSize, type TileView, type TileViewComponents, type TileViewProps, type ViewComponentsBySurface, type ViewDeclaration, type ViewSurface, type WebWorker, type WindowView, type WindowViewProps, type WorkbenchApp, type WorkbenchConfig, defineApplication, defineAssetSourceView, definePanelView, defineTileView, defineWebWorker, defineWindowView, isWorkbenchApp, isWorkbenchConfig, unstable_defineMediaLibrary, unstable_defineService, unstable_defineView };
|
|
115
|
+
export { type AssetSourceComponent, type AssetSourceView, type AssetSourceViewComponents, type DefineAppInput, type DefineAppResult, type DefineAssetSourceViewInput, type DefineMediaLibraryInput, type DefinePanelViewInput, type DefineTileViewInput, type DefineWebWorkerInput, type DefineWindowViewInput, type DefinedService, type DefinedView, type DockGroup, type MediaLibraryField, type PanelComponent, type PanelView, type PanelViewComponents, type PanelViewProps, type ServiceBus, type ServiceCallback, type ServiceContext, type ServiceInfo, type ServiceType, type TileComponent, type TileSize, type TileView, type TileViewComponents, type TileViewProps, type ViewComponentsBySurface, type ViewDeclaration, type ViewSurface, type WebWorker, type WebWorkerBus, type WebWorkerInfo, type WebWorkerProps, type WebWorkerType, type WindowView, type WindowViewProps, type WorkbenchApp, type WorkbenchConfig, defineApplication, defineAssetSourceView, definePanelView, defineTileView, defineWebWorker, defineWindowView, isWorkbenchApp, isWorkbenchConfig, unstable_defineMediaLibrary, unstable_defineService, unstable_defineView };
|
|
115
116
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/_exports/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { defineAssetSourceView, definePanelView, defineTileView, defineWebWorker, defineWindowView } from '../contract.js';
|
|
2
2
|
export { defineApplication, isWorkbenchApp, isWorkbenchConfig, unstable_defineMediaLibrary } from '../defineApp.js';
|
|
3
|
-
export { unstable_defineService } from '../defineService.js';
|
|
4
3
|
export { unstable_defineView } from '../defineView.js';
|
|
4
|
+
export { unstable_defineService } from '../webWorker.js';
|
|
5
5
|
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -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 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 {
|
|
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"}
|
package/dist/_exports/{resolveWorkbenchConfig-CgKD8AJ7.d.ts → resolveWorkbenchConfig-JRi01VJM.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as WorkbenchConfigValue } from "./contract-
|
|
1
|
+
import { b as WorkbenchConfigValue } from "./contract-WrU3aOYd.js";
|
|
2
2
|
import { t as DefineAppInput } from "./defineApp-vbUu_rBA.js";
|
|
3
3
|
import { AppVisibility, CliConfig } from "@sanity/cli-core";
|
|
4
4
|
/**
|
|
@@ -65,4 +65,4 @@ interface ResolvedMediaLibraryConfig {
|
|
|
65
65
|
*/
|
|
66
66
|
declare function resolveWorkbenchConfig(cliConfig: CliConfig | null | undefined): ResolvedMediaLibraryConfig | null;
|
|
67
67
|
export { resolveAppEntry as a, WorkbenchExposes as i, resolveWorkbenchConfig as n, resolveWorkbenchApp as o, ResolvedWorkbenchApp as r, ResolvedMediaLibraryConfig as t };
|
|
68
|
-
//# sourceMappingURL=resolveWorkbenchConfig-
|
|
68
|
+
//# sourceMappingURL=resolveWorkbenchConfig-JRi01VJM.d.ts.map
|
package/dist/_exports/{summarizeInterfaces-CeV5Umpj.d.ts → summarizeInterfaces-CpCUSMrz.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as WorkbenchExposes, r as ResolvedWorkbenchApp } from "./resolveWorkbenchConfig-
|
|
1
|
+
import { h as ViewSurface, v as WebWorkerType } from "./contract-WrU3aOYd.js";
|
|
2
|
+
import { i as WorkbenchExposes, r as ResolvedWorkbenchApp } from "./resolveWorkbenchConfig-JRi01VJM.js";
|
|
3
3
|
import { z } from "zod/mini";
|
|
4
4
|
import { CliConfig } from "@sanity/cli-core";
|
|
5
5
|
/**
|
|
@@ -25,7 +25,7 @@ declare const viewDeploymentPayloadSchema: z.ZodMiniObject<{
|
|
|
25
25
|
type ViewDeploymentPayload = z.infer<typeof viewDeploymentPayloadSchema>;
|
|
26
26
|
interface DeployableWorkbenchApp extends ResolvedWorkbenchApp {
|
|
27
27
|
/**
|
|
28
|
-
* Throws when the app exposes nothing (no entry, view, or
|
|
28
|
+
* Throws when the app exposes nothing (no entry, view, or web worker) — the
|
|
29
29
|
* remote would have nothing to load. Gated before any prompt or API call.
|
|
30
30
|
*/
|
|
31
31
|
assertDeployable(): void;
|
|
@@ -34,7 +34,7 @@ interface DeployableWorkbenchApp extends ResolvedWorkbenchApp {
|
|
|
34
34
|
* Throws when a view declaration is malformed.
|
|
35
35
|
*/
|
|
36
36
|
buildViewDeploymentPayload(applicationId: string): ViewDeploymentPayload;
|
|
37
|
-
/** Declares something to host as an application — an entry, view, or
|
|
37
|
+
/** Declares something to host as an application — an entry, view, or web worker. */
|
|
38
38
|
hasInterfaces: boolean;
|
|
39
39
|
}
|
|
40
40
|
declare function getWorkbench(cliConfig: CliConfig | null | undefined): DeployableWorkbenchApp | null;
|
|
@@ -49,7 +49,7 @@ interface DeployedView extends DeployedInterfaceBase {
|
|
|
49
49
|
}
|
|
50
50
|
/** A web worker as the deploy report and `--json` output surface it. */
|
|
51
51
|
interface DeployedWebWorker extends DeployedInterfaceBase {
|
|
52
|
-
type:
|
|
52
|
+
type: WebWorkerType;
|
|
53
53
|
}
|
|
54
54
|
type DeployedInterface = DeployedView | DeployedWebWorker;
|
|
55
55
|
/**
|
|
@@ -62,4 +62,4 @@ declare function summarizeInterfaces({ views, webWorkers }: WorkbenchExposes): {
|
|
|
62
62
|
views: DeployedView[];
|
|
63
63
|
};
|
|
64
64
|
export { DeployableWorkbenchApp as a, summarizeInterfaces as i, DeployedView as n, getWorkbench as o, DeployedWebWorker as r, DeployedInterface as t };
|
|
65
|
-
//# sourceMappingURL=summarizeInterfaces-
|
|
65
|
+
//# sourceMappingURL=summarizeInterfaces-CpCUSMrz.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-
|
|
2
|
-
import { a as DeployableWorkbenchApp, n as DeployedView, r as DeployedWebWorker } from "./summarizeInterfaces-
|
|
1
|
+
import { t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-JRi01VJM.js";
|
|
2
|
+
import { a as DeployableWorkbenchApp, n as DeployedView, r as DeployedWebWorker } from "./summarizeInterfaces-CpCUSMrz.js";
|
|
3
3
|
import "node:zlib";
|
|
4
4
|
import { UndeployAdapter, UndeployApplicationTarget, UndeployConfigTarget } from "@sanity/cli-core/undeploy";
|
|
5
5
|
interface ConfigSnapshot {
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as WEB_WORKER_CONTRACT_VERSION, v as WebWorkerType } from "./contract-WrU3aOYd.js";
|
|
2
2
|
import { EventTopic, MessageBus, MessageBusAbortOptions, MessageBusMessage, PayloadOf, ReplyOf, StateTopic, ValueOf } from "@sanity/sdk/dashboard";
|
|
3
3
|
/**
|
|
4
|
-
* The
|
|
4
|
+
* The web worker's own declaration.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
interface
|
|
7
|
+
interface WebWorkerInfo {
|
|
8
8
|
readonly name: string;
|
|
9
9
|
readonly type: string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* The message bus as a
|
|
13
|
-
* `subscribe` forms that return observables, which would make the
|
|
12
|
+
* The message bus as a web worker sees it: the SDK's `MessageBus` without the
|
|
13
|
+
* `subscribe` forms that return observables, which would make the web worker's
|
|
14
14
|
* project install rxjs. There is no `disconnect`: Dashboard owns the connection
|
|
15
15
|
* and ends it when it stops the worker.
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
|
-
interface
|
|
18
|
+
interface WebWorkerBus extends Omit<MessageBus, 'subscribe'> {
|
|
19
19
|
/** Runs a responder for each event until its signal aborts. */
|
|
20
20
|
subscribe<K extends EventTopic>(type: K, handler: (message: MessageBusMessage<PayloadOf<K>, ReplyOf<K>, K>) => void, options?: MessageBusAbortOptions): void;
|
|
21
21
|
/** Runs a handler for each state value until its signal aborts. */
|
|
@@ -24,38 +24,18 @@ interface ServiceBus extends Omit<MessageBus, 'subscribe'> {
|
|
|
24
24
|
/**
|
|
25
25
|
* Context every service callback receives when its worker starts. Mirrors how a
|
|
26
26
|
* view component receives its `view` — the service receives its own `service`.
|
|
27
|
+
* @deprecated Use {@link WebWorkerProps}.
|
|
27
28
|
* @public
|
|
28
29
|
*/
|
|
29
30
|
interface ServiceContext {
|
|
30
|
-
readonly bus:
|
|
31
|
-
readonly service:
|
|
31
|
+
readonly bus: WebWorkerBus;
|
|
32
|
+
readonly service: WebWorkerInfo;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
type ServiceCallback = (context: ServiceContext) => (() => void) | void;
|
|
39
|
-
/** The callback shape each service type defines, keyed by type. */
|
|
40
|
-
interface ServiceCallbacksByType {
|
|
41
|
-
worker: ServiceCallback;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The result of `unstable_defineService`: the author's callback, the service
|
|
45
|
-
* type, and the internal contract version the worker artifact targets.
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
interface DefinedService<TType extends ServiceType = ServiceType> {
|
|
49
|
-
readonly run: ServiceCallbacksByType[TType];
|
|
50
|
-
readonly type: TType;
|
|
51
|
-
/** @internal */
|
|
52
|
-
readonly version: typeof SERVICE_CONTRACT_VERSION;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Define a Sanity Dashboard background service. The first argument narrows the
|
|
56
|
-
* callback shape — `"worker"` runs the callback inside a Web Worker.
|
|
35
|
+
* Props a web worker function receives when its worker starts. The default
|
|
36
|
+
* export of a web worker's `src` file runs once inside the worker.
|
|
57
37
|
*
|
|
58
|
-
*
|
|
38
|
+
* `bus` is its connection to the Dashboard message bus:
|
|
59
39
|
* `bus.emit` sends an event (such as a dock-badge update), `bus.query` reads the
|
|
60
40
|
* current value of a state topic, and `bus.subscribe` runs a handler on each
|
|
61
41
|
* new value of a state topic, or on each event of an event topic, until its
|
|
@@ -68,13 +48,13 @@ interface DefinedService<TType extends ServiceType = ServiceType> {
|
|
|
68
48
|
*
|
|
69
49
|
* An event handler answers the sender with `message.reply(value)` or refuses
|
|
70
50
|
* with `message.reject(reason)`; one that throws refuses with code
|
|
71
|
-
* `HANDLER_THREW`. For example, a
|
|
51
|
+
* `HANDLER_THREW`. For example, a worker that keeps a snapshot for its app's
|
|
72
52
|
* views, which listen with `useWorker` first and then post to it. A view's post
|
|
73
53
|
* arrives on `workers.post` as `{name, payload}`, and `workers.message` reaches
|
|
74
54
|
* only this app's views:
|
|
75
55
|
*
|
|
76
56
|
* ```ts
|
|
77
|
-
* export default
|
|
57
|
+
* export default ({bus}: WebWorkerProps) => {
|
|
78
58
|
* const controller = new AbortController()
|
|
79
59
|
* bus.subscribe('workers.post', (message) => message.reply(snapshot), {
|
|
80
60
|
* signal: controller.signal,
|
|
@@ -82,18 +62,62 @@ interface DefinedService<TType extends ServiceType = ServiceType> {
|
|
|
82
62
|
* // Views that are already listening post again.
|
|
83
63
|
* bus.emit('workers.message', {type: 'welcome'})
|
|
84
64
|
* return () => controller.abort()
|
|
85
|
-
* }
|
|
65
|
+
* }
|
|
86
66
|
* ```
|
|
87
67
|
*
|
|
88
|
-
* The
|
|
68
|
+
* The function can return a disposer, which runs when Dashboard stops the
|
|
89
69
|
* worker. By then the bus is closed: subscriptions have ended, `emit` and
|
|
90
70
|
* `query` reject with code `ABORTED`, and `subscribe` throws that error.
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
interface WebWorkerProps {
|
|
74
|
+
readonly bus: WebWorkerBus;
|
|
75
|
+
readonly worker: WebWorkerInfo;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A service callback. Runs once inside the worker on start; returns an optional
|
|
79
|
+
* disposer the host calls before terminating the worker.
|
|
80
|
+
* @deprecated Default-export a plain function that receives {@link WebWorkerProps} instead.
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
type ServiceCallback = (context: ServiceContext) => (() => void) | void;
|
|
84
|
+
/** The callback shape each service type defines, keyed by type. */
|
|
85
|
+
interface ServiceCallbacksByType {
|
|
86
|
+
worker: ServiceCallback;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The result of `unstable_defineService`: the author's callback, the service
|
|
90
|
+
* type, and the internal contract version the worker artifact targets.
|
|
91
|
+
* @deprecated Default-export a plain function that receives {@link WebWorkerProps} instead.
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
interface DefinedService<TType extends WebWorkerType = WebWorkerType> {
|
|
95
|
+
readonly run: ServiceCallbacksByType[TType];
|
|
96
|
+
readonly type: TType;
|
|
97
|
+
/** @internal */
|
|
98
|
+
readonly version: typeof WEB_WORKER_CONTRACT_VERSION;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Define a Sanity Dashboard background service. The first argument narrows the
|
|
102
|
+
* callback shape — `"worker"` runs the callback inside a Web Worker with the
|
|
103
|
+
* bus described on {@link WebWorkerProps}.
|
|
91
104
|
*
|
|
92
105
|
* Identity at runtime: returns the callback tagged with its type and the contract
|
|
93
106
|
* version, for the CLI build to generate a worker artifact from. Used as the
|
|
94
107
|
* default export of a service's `src` file.
|
|
108
|
+
* @deprecated Default-export a plain function that receives {@link WebWorkerProps} from the web worker's `src` file instead.
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
declare function unstable_defineService<TType extends WebWorkerType>(type: TType, run: ServiceCallbacksByType[TType]): DefinedService<TType>;
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated Use `WebWorkerBus`.
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
type ServiceBus = WebWorkerBus;
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated Use `WebWorkerInfo`.
|
|
95
119
|
* @public
|
|
96
120
|
*/
|
|
97
|
-
|
|
98
|
-
export { ServiceInfo as a, ServiceContext as i, ServiceBus as n,
|
|
99
|
-
//# sourceMappingURL=
|
|
121
|
+
type ServiceInfo = WebWorkerInfo;
|
|
122
|
+
export { ServiceInfo as a, WebWorkerProps as c, ServiceContext as i, unstable_defineService as l, ServiceBus as n, WebWorkerBus as o, ServiceCallback as r, WebWorkerInfo as s, DefinedService as t };
|
|
123
|
+
//# sourceMappingURL=webWorker-TWUbh0uo.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mediaLibraryConfigArtifacts } from './configs/artifact.js';
|
|
2
|
-
import { serviceArtifacts } from './services/artifact.js';
|
|
3
2
|
import { viewArtifacts } from './views/artifact.js';
|
|
3
|
+
import { webWorkerArtifacts } from './webWorkers/artifact.js';
|
|
4
4
|
/**
|
|
5
5
|
* Map the artifacts the host loads directly (those with an `expose`) to their
|
|
6
6
|
* runtime-dir paths, for the module-federation `exposes` field. `toExposePath`
|
|
@@ -22,7 +22,7 @@ import { viewArtifacts } from './views/artifact.js';
|
|
|
22
22
|
*/ export function workbenchArtifacts(exposes, configOptions = {}) {
|
|
23
23
|
return [
|
|
24
24
|
...viewArtifacts(exposes.views ?? []),
|
|
25
|
-
...
|
|
25
|
+
...webWorkerArtifacts(exposes.webWorkers ?? []),
|
|
26
26
|
...mediaLibraryConfigArtifacts(exposes.config, configOptions)
|
|
27
27
|
];
|
|
28
28
|
}
|
|
@@ -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 {
|
|
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"}
|
|
@@ -20,8 +20,8 @@ const HMR_REMOUNT = `if (import.meta.hot) {
|
|
|
20
20
|
}`;
|
|
21
21
|
/**
|
|
22
22
|
* - `app`: omit when the preamble imports `App` itself (the SDK-app entry).
|
|
23
|
-
* - `version`:
|
|
24
|
-
*/ export function renderRemote({ app, hmr = false, isolateStyles = false, preamble, version }) {
|
|
23
|
+
* - `version`: the contract version the host checks before rendering.
|
|
24
|
+
*/ export function renderRemote({ app, hmr = false, isolateStyles = false, preamble, version, viewType }) {
|
|
25
25
|
// Keep apps without styled-components buildable; the unused branch is removed from their bundle.
|
|
26
26
|
const stylesheetImport = isolateStyles ? "import { StyleSheetManager } from 'styled-components'" : 'const StyleSheetManager = undefined';
|
|
27
27
|
return `\
|
|
@@ -31,7 +31,9 @@ import * as React from 'react'
|
|
|
31
31
|
import { createRoot } from 'react-dom/client'
|
|
32
32
|
${stylesheetImport}
|
|
33
33
|
${preamble}
|
|
34
|
-
${app ? `\nconst App = ${app}\n` : ''}
|
|
34
|
+
${app ? `\nconst App = ${app}\n` : ''}
|
|
35
|
+
export const version = ${version}
|
|
36
|
+
|
|
35
37
|
// The SDK reads this slot via getDashboardRootContext(), so its symbol, key and value are a
|
|
36
38
|
// contract. Keyed by createContext, not the React namespace: Vite dev pre-bundling can give two
|
|
37
39
|
// importers of one React copy different namespaces.
|
|
@@ -70,7 +72,7 @@ function mount(rootElement, args) {
|
|
|
70
72
|
const controller = new AbortController()
|
|
71
73
|
// Read once: the SDK pins the root's bus identity when it first connects.
|
|
72
74
|
const { moduleId, parentKey } = args?.renderOptions ?? {}
|
|
73
|
-
rootContexts.set(rootElement, { controller, value: { signal: controller.signal, moduleId, parentKey } })
|
|
75
|
+
rootContexts.set(rootElement, { controller, value: { signal: controller.signal, moduleId, parentKey${viewType ? `, viewType: ${JSON.stringify(viewType)}` : ''} } })
|
|
74
76
|
if (StyleSheetManager) {
|
|
75
77
|
const target = rootElement.ownerDocument.createElement('sanity-styles')
|
|
76
78
|
if (typeof __SANITY_APP_ID__ === 'string') target.setAttribute('data-application-id', __SANITY_APP_ID__)
|
|
@@ -80,7 +82,11 @@ function mount(rootElement, args) {
|
|
|
80
82
|
stylisPlugins.set(rootElement, [uniqueStylisPlugin()])
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
|
-
|
|
85
|
+
const rootContext = rootContexts.get(rootElement)
|
|
86
|
+
|
|
87
|
+
if (rootContext.value.props !== args.props) rootContext.value = { ...rootContext.value, props: args.props }
|
|
88
|
+
|
|
89
|
+
let element = React.createElement(RootContext.Provider, { value: rootContext.value }, React.createElement(App, args.props))
|
|
84
90
|
if (StyleSheetManager) element = React.createElement(StyleSheetManager, { target: styleTargets.get(rootElement), stylisPlugins: stylisPlugins.get(rootElement) }, element)
|
|
85
91
|
// The host's React can't pause this root, so the host pauses the app through this Activity.
|
|
86
92
|
// Keep it inside StrictMode: outside, it stops StrictMode double-invoking effects.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/render-remote.ts"],"sourcesContent":["/**\n * Every generated entry (studio, SDK app, view artifacts) shares one render body\n * so the host can drive them all the same way; only the `App` they bind differs.\n * The workbench host depends on `render`'s signature and return shape, so change\n * them together.\n */\n\n// Re-renders through the new module so edits apply without a page reload. The\n// new module mounts in the foreground, so reapply the host's lifecycle. The host\n// still holds this module's controller, so it forwards to the new one.\nconst HMR_REMOUNT = `if (import.meta.hot) {\n import.meta.hot.accept((next) => {\n if (!next) return\n for (const [rootElement, args] of renderArgs) {\n rootMap.get(rootElement)?.unmount()\n rootMap.delete(rootElement)\n closeRoot(rootElement)\n args.next = next.render(rootElement, args.props, args.renderOptions)\n args.next.setLifecycle(args.lifecycle)\n }\n })\n}`\n\n/**\n * - `app`: omit when the preamble imports `App` itself (the SDK-app entry).\n * - `version`:
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/render-remote.ts"],"sourcesContent":["/**\n * Every generated entry (studio, SDK app, view artifacts) shares one render body\n * so the host can drive them all the same way; only the `App` they bind differs.\n * The workbench host depends on `render`'s signature and return shape, so change\n * them together.\n */\n\n// Re-renders through the new module so edits apply without a page reload. The\n// new module mounts in the foreground, so reapply the host's lifecycle. The host\n// still holds this module's controller, so it forwards to the new one.\nconst HMR_REMOUNT = `if (import.meta.hot) {\n import.meta.hot.accept((next) => {\n if (!next) return\n for (const [rootElement, args] of renderArgs) {\n rootMap.get(rootElement)?.unmount()\n rootMap.delete(rootElement)\n closeRoot(rootElement)\n args.next = next.render(rootElement, args.props, args.renderOptions)\n args.next.setLifecycle(args.lifecycle)\n }\n })\n}`\n\n/**\n * - `app`: omit when the preamble imports `App` itself (the SDK-app entry).\n * - `version`: the contract version the host checks before rendering.\n */\nexport function renderRemote({\n app,\n hmr = false,\n isolateStyles = false,\n preamble,\n version,\n viewType,\n}: {\n app?: string\n hmr?: boolean\n isolateStyles?: boolean\n preamble: string\n version: string\n viewType?: string\n}): string {\n // Keep apps without styled-components buildable; the unused branch is removed from their bundle.\n const stylesheetImport = isolateStyles\n ? \"import { StyleSheetManager } from 'styled-components'\"\n : 'const StyleSheetManager = undefined'\n\n return `\\\n// This file is auto-generated on 'sanity build' / 'sanity dev'\n// Modifications to this file are automatically discarded\nimport * as React from 'react'\nimport { createRoot } from 'react-dom/client'\n${stylesheetImport}\n${preamble}\n${app ? `\\nconst App = ${app}\\n` : ''}\nexport const version = ${version}\n\n// The SDK reads this slot via getDashboardRootContext(), so its symbol, key and value are a\n// contract. Keyed by createContext, not the React namespace: Vite dev pre-bundling can give two\n// importers of one React copy different namespaces.\nconst rootSlot = (globalThis[Symbol.for('sanity.os.root')] ??= new WeakMap())\nif (!rootSlot.has(React.createContext)) rootSlot.set(React.createContext, React.createContext(undefined))\nconst RootContext = rootSlot.get(React.createContext)\nconst rootMap = new Map()\nconst rootContexts = new Map()\n// A shared default sheet can overwrite another app's global rules; each root needs its own sheet.\nconst styleTargets = new Map()\nconst stylisPlugins = new Map()\nconst renderArgs = new Map()\n// On globalThis: every module embeds its own copy of this harness, and names must be page-unique.\nconst stylisPluginCount = Symbol.for('sanity.os.stylisPluginCount')\n\n// Identical CSS gets an identical class in every sheet, so a later sheet overrides earlier rules.\n// StyleSheetManager hashes stylis plugin names into class names: a uniquely named no-op isolates a root.\nfunction uniqueStylisPlugin() {\n globalThis[stylisPluginCount] = (globalThis[stylisPluginCount] ?? 0) + 1\n return Object.defineProperty(() => {}, 'name', { value: 'sanity-root-' + globalThis[stylisPluginCount] })\n}\n\n// The SDK disposes the root's instance, closing its bus connection, when the signal aborts. Next tick:\n// a host disposing a child root from its own cleanup code leaves the child still unmounting.\nfunction closeRoot(rootElement) {\n const closing = rootContexts.get(rootElement)\n rootContexts.delete(rootElement)\n if (closing) setTimeout(() => closing.controller.abort(), 0)\n}\n\nfunction mount(rootElement, args) {\n let root = rootMap.get(rootElement)\n if (!root) {\n root = createRoot(rootElement, args?.renderOptions?.rootOptions)\n rootMap.set(rootElement, root)\n const controller = new AbortController()\n // Read once: the SDK pins the root's bus identity when it first connects.\n const { moduleId, parentKey } = args?.renderOptions ?? {}\n rootContexts.set(rootElement, { controller, value: { signal: controller.signal, moduleId, parentKey${viewType ? `, viewType: ${JSON.stringify(viewType)}` : ''} } })\n if (StyleSheetManager) {\n const target = rootElement.ownerDocument.createElement('sanity-styles')\n if (typeof __SANITY_APP_ID__ === 'string') target.setAttribute('data-application-id', __SANITY_APP_ID__)\n // React can replace the mount node's contents; keep its stylesheet outside that node.\n rootElement.ownerDocument.head.appendChild(target)\n styleTargets.set(rootElement, target)\n stylisPlugins.set(rootElement, [uniqueStylisPlugin()])\n }\n }\n const rootContext = rootContexts.get(rootElement)\n\n if (rootContext.value.props !== args.props) rootContext.value = { ...rootContext.value, props: args.props }\n\n let element = React.createElement(RootContext.Provider, { value: rootContext.value }, React.createElement(App, args.props))\n if (StyleSheetManager) element = React.createElement(StyleSheetManager, { target: styleTargets.get(rootElement), stylisPlugins: stylisPlugins.get(rootElement) }, element)\n // The host's React can't pause this root, so the host pauses the app through this Activity.\n // Keep it inside StrictMode: outside, it stops StrictMode double-invoking effects.\n element = React.createElement(React.Activity, { mode: args.lifecycle === 'background' ? 'hidden' : 'visible' }, element)\n if (args?.renderOptions?.reactStrictMode) element = React.createElement(React.StrictMode, null, element)\n root.render(element)\n}\n\nexport function render(rootElement, props, renderOptions) {\n const args = { lifecycle: 'foreground', props, renderOptions }\n renderArgs.set(rootElement, args)\n mount(rootElement, args)\n return {\n dispose() {\n const current = renderArgs.get(rootElement)\n renderArgs.delete(rootElement)\n if (current?.next) return current.next.dispose()\n const root = rootMap.get(rootElement)\n rootMap.delete(rootElement)\n root?.unmount()\n // Unmount first so effect cleanup can still reach this root's stylesheet.\n styleTargets.get(rootElement)?.remove()\n styleTargets.delete(rootElement)\n stylisPlugins.delete(rootElement)\n closeRoot(rootElement)\n },\n setLifecycle(state) {\n const current = renderArgs.get(rootElement)\n if (!current) return\n if (current.next) return current.next.setLifecycle(state)\n current.lifecycle = state\n mount(rootElement, current)\n },\n }\n}${hmr ? `\\n\\n${HMR_REMOUNT}` : ''}\n`\n}\n"],"names":["HMR_REMOUNT","renderRemote","app","hmr","isolateStyles","preamble","version","viewType","stylesheetImport","JSON","stringify"],"mappings":"AAAA;;;;;CAKC,GAED,8EAA8E;AAC9E,iFAAiF;AACjF,uEAAuE;AACvE,MAAMA,cAAc,CAAC;;;;;;;;;;;CAWpB,CAAC;AAEF;;;CAGC,GACD,OAAO,SAASC,aAAa,EAC3BC,GAAG,EACHC,MAAM,KAAK,EACXC,gBAAgB,KAAK,EACrBC,QAAQ,EACRC,OAAO,EACPC,QAAQ,EAQT;IACC,iGAAiG;IACjG,MAAMC,mBAAmBJ,gBACrB,0DACA;IAEJ,OAAO,CAAC;;;;;AAKV,EAAEI,iBAAiB;AACnB,EAAEH,SAAS;AACX,EAAEH,MAAM,CAAC,cAAc,EAAEA,IAAI,EAAE,CAAC,GAAG,GAAG;uBACf,EAAEI,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGAwCsE,EAAEC,WAAW,CAAC,YAAY,EAAEE,KAAKC,SAAS,CAACH,WAAW,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDlK,EAAEJ,MAAM,CAAC,IAAI,EAAEH,aAAa,GAAG,GAAG;AACnC,CAAC;AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VIEW_COMPONENTS } from '../../../contract.js';
|
|
1
|
+
import { VIEW_COMPONENTS, VIEW_CONTRACT_VERSION } from '../../../contract.js';
|
|
2
2
|
import { renderRemote } from '../render-remote.js';
|
|
3
3
|
/** Subdirectory under the federation runtime dir where view artifacts are written. */ const VIEWS_DIR_NAME = 'views';
|
|
4
4
|
/**
|
|
@@ -7,8 +7,8 @@ import { renderRemote } from '../render-remote.js';
|
|
|
7
7
|
* module-federation expose, so the host renders each as an independent island.
|
|
8
8
|
*
|
|
9
9
|
* Each artifact binds its component as the `App` the render contract renders —
|
|
10
|
-
* a
|
|
11
|
-
* name — behind an HMR boundary so view edits re-render through the new module.
|
|
10
|
+
* a plain component renders without props, an `unstable_defineView` result keys
|
|
11
|
+
* by name — behind an HMR boundary so view edits re-render through the new module.
|
|
12
12
|
*/ export function viewArtifacts(views) {
|
|
13
13
|
const artifacts = [];
|
|
14
14
|
for (const view of views){
|
|
@@ -17,11 +17,13 @@ import { renderRemote } from '../render-remote.js';
|
|
|
17
17
|
expose: `./${VIEWS_DIR_NAME}/${view.name}/${component}`,
|
|
18
18
|
path: `${VIEWS_DIR_NAME}/${view.name}/${component}.js`,
|
|
19
19
|
source: ({ isolateStyles, resolveImport })=>renderRemote({
|
|
20
|
-
|
|
20
|
+
// Backwards compatibility: an `unstable_defineView` result is a v1 view that renders its slot with host props. Remove in SDK-3210.
|
|
21
|
+
app: `view.components ? view.components[${JSON.stringify(component)}] : () => React.createElement(view)`,
|
|
21
22
|
hmr: true,
|
|
22
23
|
isolateStyles,
|
|
23
24
|
preamble: `import view from ${JSON.stringify(resolveImport(view.src))}`,
|
|
24
|
-
version: `view.version
|
|
25
|
+
version: `view.components ? view.version : ${VIEW_CONTRACT_VERSION}`,
|
|
26
|
+
viewType: view.surface
|
|
25
27
|
})
|
|
26
28
|
});
|
|
27
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/build/views/artifact.ts"],"sourcesContent":["import {VIEW_COMPONENTS, type ViewSurface} from '../../../contract.js'\nimport {type GeneratedArtifact} from '../artifact.js'\nimport {renderRemote} from '../render-remote.js'\n\n/** Subdirectory under the federation runtime dir where view artifacts are written. */\nconst VIEWS_DIR_NAME = 'views'\n\n/**\n * An interface to generate render artifacts for. The `src` file default-exports\n * an `unstable_defineView(...)` result; the build emits one render-contract\n * artifact per component the view surface exposes.\n * @internal\n */\nexport interface InterfaceArtifact {\n /** Interface name, unique within the app. */\n name: string\n /** Path to the interface `src` file, relative to the app root (or absolute). */\n src: string\n /** Selects which components the build expands. */\n surface: ViewSurface\n}\n\n/**\n * Expand each view into one generated artifact per component it exposes. A\n * panel's `title` and `panel` each become their own render-contract module and\n * module-federation expose, so the host renders each as an independent island.\n *\n * Each artifact binds its component as the `App` the render contract renders —\n * a
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/build/views/artifact.ts"],"sourcesContent":["import {VIEW_COMPONENTS, VIEW_CONTRACT_VERSION, type ViewSurface} from '../../../contract.js'\nimport {type GeneratedArtifact} from '../artifact.js'\nimport {renderRemote} from '../render-remote.js'\n\n/** Subdirectory under the federation runtime dir where view artifacts are written. */\nconst VIEWS_DIR_NAME = 'views'\n\n/**\n * An interface to generate render artifacts for. The `src` file default-exports\n * a view component or an `unstable_defineView(...)` result; the build emits one render-contract\n * artifact per component the view surface exposes.\n * @internal\n */\nexport interface InterfaceArtifact {\n /** Interface name, unique within the app. */\n name: string\n /** Path to the interface `src` file, relative to the app root (or absolute). */\n src: string\n /** Selects which components the build expands. */\n surface: ViewSurface\n}\n\n/**\n * Expand each view into one generated artifact per component it exposes. A\n * panel's `title` and `panel` each become their own render-contract module and\n * module-federation expose, so the host renders each as an independent island.\n *\n * Each artifact binds its component as the `App` the render contract renders —\n * a plain component renders without props, an `unstable_defineView` result keys\n * by name — behind an HMR boundary so view edits re-render through the new module.\n */\nexport function viewArtifacts(views: readonly InterfaceArtifact[]): GeneratedArtifact[] {\n const artifacts: GeneratedArtifact[] = []\n for (const view of views) {\n for (const component of VIEW_COMPONENTS[view.surface]) {\n artifacts.push({\n expose: `./${VIEWS_DIR_NAME}/${view.name}/${component}`,\n path: `${VIEWS_DIR_NAME}/${view.name}/${component}.js`,\n source: ({isolateStyles, resolveImport}) =>\n renderRemote({\n // Backwards compatibility: an `unstable_defineView` result is a v1 view that renders its slot with host props. Remove in SDK-3210.\n app: `view.components ? view.components[${JSON.stringify(component)}] : () => React.createElement(view)`,\n hmr: true,\n isolateStyles,\n preamble: `import view from ${JSON.stringify(resolveImport(view.src))}`,\n version: `view.components ? view.version : ${VIEW_CONTRACT_VERSION}`,\n viewType: view.surface,\n }),\n })\n }\n }\n return artifacts\n}\n"],"names":["VIEW_COMPONENTS","VIEW_CONTRACT_VERSION","renderRemote","VIEWS_DIR_NAME","viewArtifacts","views","artifacts","view","component","surface","push","expose","name","path","source","isolateStyles","resolveImport","app","JSON","stringify","hmr","preamble","src","version","viewType"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,qBAAqB,QAAyB,uBAAsB;AAE7F,SAAQC,YAAY,QAAO,sBAAqB;AAEhD,oFAAoF,GACpF,MAAMC,iBAAiB;AAiBvB;;;;;;;;CAQC,GACD,OAAO,SAASC,cAAcC,KAAmC;IAC/D,MAAMC,YAAiC,EAAE;IACzC,KAAK,MAAMC,QAAQF,MAAO;QACxB,KAAK,MAAMG,aAAaR,eAAe,CAACO,KAAKE,OAAO,CAAC,CAAE;YACrDH,UAAUI,IAAI,CAAC;gBACbC,QAAQ,CAAC,EAAE,EAAER,eAAe,CAAC,EAAEI,KAAKK,IAAI,CAAC,CAAC,EAAEJ,WAAW;gBACvDK,MAAM,GAAGV,eAAe,CAAC,EAAEI,KAAKK,IAAI,CAAC,CAAC,EAAEJ,UAAU,GAAG,CAAC;gBACtDM,QAAQ,CAAC,EAACC,aAAa,EAAEC,aAAa,EAAC,GACrCd,aAAa;wBACX,mIAAmI;wBACnIe,KAAK,CAAC,kCAAkC,EAAEC,KAAKC,SAAS,CAACX,WAAW,mCAAmC,CAAC;wBACxGY,KAAK;wBACLL;wBACAM,UAAU,CAAC,iBAAiB,EAAEH,KAAKC,SAAS,CAACH,cAAcT,KAAKe,GAAG,IAAI;wBACvEC,SAAS,CAAC,iCAAiC,EAAEtB,uBAAuB;wBACpEuB,UAAUjB,KAAKE,OAAO;oBACxB;YACJ;QACF;IACF;IACA,OAAOH;AACT"}
|
|
@@ -43,12 +43,12 @@ import { hasMediaLibraryIslandRuntime, MEDIA_LIBRARY_ISLAND_RUNTIME_MODULE } fro
|
|
|
43
43
|
* app's `entry` (or a studio's config) — never the federation `exposes` (dock
|
|
44
44
|
* views, web workers, media-library config fields), which the host loads
|
|
45
45
|
* dynamically at runtime. So a dep imported only by an exposed module (e.g.
|
|
46
|
-
* `sanity/workbench` in a
|
|
46
|
+
* `sanity/workbench` in a web worker or view) escapes the startup scan; Vite
|
|
47
47
|
* discovers it on first request, re-optimizes, and full-page reloads — which
|
|
48
48
|
* flakes Playwright in e2e.
|
|
49
49
|
*
|
|
50
50
|
* Point `entries` at the source of every interface: the app `entry` (or, for a
|
|
51
|
-
* studio, its config), plus each view,
|
|
51
|
+
* studio, its config), plus each view, web worker, and installation-config source.
|
|
52
52
|
* `entries` follows real import statements, so it covers whatever those sources
|
|
53
53
|
* transitively use — correct subpaths and all — with no hand-maintained dep
|
|
54
54
|
* list, and never crashes on an unresolvable name the way a bad `include` entry
|