@sanity/workbench-cli 1.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/_exports/build.d.ts +129 -0
- package/dist/_exports/build.js +9 -0
- package/dist/_exports/build.js.map +1 -0
- package/dist/_exports/deploy.d.ts +115 -0
- package/dist/_exports/deploy.js +6 -0
- package/dist/_exports/deploy.js.map +1 -0
- package/dist/_exports/dev.d.ts +166 -0
- package/dist/_exports/dev.js +10 -0
- package/dist/_exports/dev.js.map +1 -0
- package/dist/_exports/index.d.ts +307 -0
- package/dist/_exports/index.js +15 -0
- package/dist/_exports/index.js.map +1 -0
- package/dist/_exports/init.d.ts +12 -0
- package/dist/_exports/init.js +5 -0
- package/dist/_exports/init.js.map +1 -0
- package/dist/actions/build/artifact.js +29 -0
- package/dist/actions/build/artifact.js.map +1 -0
- package/dist/actions/build/render-remote.js +69 -0
- package/dist/actions/build/render-remote.js.map +1 -0
- package/dist/actions/build/services/artifact.js +122 -0
- package/dist/actions/build/services/artifact.js.map +1 -0
- package/dist/actions/build/views/artifact.js +31 -0
- package/dist/actions/build/views/artifact.js.map +1 -0
- package/dist/actions/build/vite/constants.js +5 -0
- package/dist/actions/build/vite/constants.js.map +1 -0
- package/dist/actions/build/vite/plugin.js +74 -0
- package/dist/actions/build/vite/plugin.js.map +1 -0
- package/dist/actions/build/vite/plugins/plugin-module-federation.js +53 -0
- package/dist/actions/build/vite/plugins/plugin-module-federation.js.map +1 -0
- package/dist/actions/build/vite/plugins/plugin-sanity-environment.js +29 -0
- package/dist/actions/build/vite/plugins/plugin-sanity-environment.js.map +1 -0
- package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js +33 -0
- package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js.map +1 -0
- package/dist/actions/build/vite/plugins/plugin-sanity-federation-runtime.js +83 -0
- package/dist/actions/build/vite/plugins/plugin-sanity-federation-runtime.js.map +1 -0
- package/dist/actions/build/vite/workbench-vite-plugins.js +43 -0
- package/dist/actions/build/vite/workbench-vite-plugins.js.map +1 -0
- package/dist/actions/deploy/getWorkbench.js +40 -0
- package/dist/actions/deploy/getWorkbench.js.map +1 -0
- package/dist/actions/dev/canonicalizeWatchDir.js +23 -0
- package/dist/actions/dev/canonicalizeWatchDir.js.map +1 -0
- package/dist/actions/dev/processLiveness.js +109 -0
- package/dist/actions/dev/processLiveness.js.map +1 -0
- package/dist/actions/dev/registry.js +279 -0
- package/dist/actions/dev/registry.js.map +1 -0
- package/dist/actions/init/cliConfig.js +45 -0
- package/dist/actions/init/cliConfig.js.map +1 -0
- package/dist/contract.js +66 -0
- package/dist/contract.js.map +1 -0
- package/dist/defineApp.js +82 -0
- package/dist/defineApp.js.map +1 -0
- package/dist/defineService.js +19 -0
- package/dist/defineService.js.map +1 -0
- package/dist/defineView.js +19 -0
- package/dist/defineView.js.map +1 -0
- package/dist/resolveWorkbenchApp.js +21 -0
- package/dist/resolveWorkbenchApp.js.map +1 -0
- package/package.json +83 -0
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @sanity/workbench-cli
|
|
2
|
+
|
|
3
|
+
Internal implementation detail of the [Sanity CLI](https://github.com/sanity-io/cli).
|
|
4
|
+
It backs the CLI's **unstable** workbench support and is not meant to be installed
|
|
5
|
+
or imported directly — its API can change or be removed without notice.
|
|
6
|
+
|
|
7
|
+
Workbench is opt-in per project via `unstable_defineApp` in `sanity.cli.ts`; use it
|
|
8
|
+
through the `sanity` CLI, not this package.
|
|
9
|
+
|
|
10
|
+
Maintainers: see `ARCHITECTURE.md` (not published) for how this package fits together.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { CliConfig } from "@sanity/cli-core";
|
|
2
|
+
import { PluginOption } from "vite";
|
|
3
|
+
import { z } from "zod/mini";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* User-facing input for `unstable_defineApp`. Excludes the internal
|
|
7
|
+
* `applicationType` — that field is validated by the schema but is not part of
|
|
8
|
+
* the public surface (Sanity-owned apps set it via `@ts-expect-error`).
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare type DefineAppInput = Omit<
|
|
12
|
+
z.output<typeof DefineAppInputSchema>,
|
|
13
|
+
"applicationType"
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Runtime-validation schema for `unstable_defineApp`. Validates the full shape
|
|
18
|
+
* including the internal `applicationType`; the user-facing `DefineAppInput`
|
|
19
|
+
* type below omits that field.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
declare const DefineAppInputSchema: z.ZodMiniObject<
|
|
23
|
+
{
|
|
24
|
+
applicationType: z.ZodMiniOptional<
|
|
25
|
+
z.ZodMiniEnum<{
|
|
26
|
+
coreApp: "coreApp";
|
|
27
|
+
studio: "studio";
|
|
28
|
+
canvas: "canvas";
|
|
29
|
+
dashboard: "dashboard";
|
|
30
|
+
"media-library": "media-library";
|
|
31
|
+
}>
|
|
32
|
+
>;
|
|
33
|
+
entry: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
34
|
+
group: z.ZodMiniOptional<
|
|
35
|
+
z.ZodMiniEnum<{
|
|
36
|
+
"dock.system": "dock.system";
|
|
37
|
+
"dock.applications": "dock.applications";
|
|
38
|
+
"dock.user": "dock.user";
|
|
39
|
+
}>
|
|
40
|
+
>;
|
|
41
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
42
|
+
name: z.ZodMiniString<string>;
|
|
43
|
+
organizationId: z.ZodMiniString<string>;
|
|
44
|
+
priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
45
|
+
services: z.ZodMiniOptional<
|
|
46
|
+
z.ZodMiniArray<
|
|
47
|
+
z.ZodMiniDiscriminatedUnion<
|
|
48
|
+
[
|
|
49
|
+
z.ZodMiniObject<
|
|
50
|
+
{
|
|
51
|
+
name: z.ZodMiniString<string>;
|
|
52
|
+
src: z.ZodMiniString<string>;
|
|
53
|
+
type: z.ZodMiniLiteral<"worker">;
|
|
54
|
+
},
|
|
55
|
+
z.core.$strip
|
|
56
|
+
>,
|
|
57
|
+
],
|
|
58
|
+
"type"
|
|
59
|
+
>
|
|
60
|
+
>
|
|
61
|
+
>;
|
|
62
|
+
title: z.ZodMiniString<string>;
|
|
63
|
+
views: z.ZodMiniOptional<
|
|
64
|
+
z.ZodMiniArray<
|
|
65
|
+
z.ZodMiniDiscriminatedUnion<
|
|
66
|
+
[
|
|
67
|
+
z.ZodMiniObject<
|
|
68
|
+
{
|
|
69
|
+
name: z.ZodMiniString<string>;
|
|
70
|
+
src: z.ZodMiniString<string>;
|
|
71
|
+
type: z.ZodMiniLiteral<"panel">;
|
|
72
|
+
},
|
|
73
|
+
z.core.$strip
|
|
74
|
+
>,
|
|
75
|
+
],
|
|
76
|
+
"type"
|
|
77
|
+
>
|
|
78
|
+
>
|
|
79
|
+
>;
|
|
80
|
+
},
|
|
81
|
+
z.core.$strip
|
|
82
|
+
>;
|
|
83
|
+
|
|
84
|
+
/** @public */
|
|
85
|
+
declare interface ResolvedWorkbenchApp {
|
|
86
|
+
/** Background worker services the app declares. */
|
|
87
|
+
readonly services: NonNullable<DefineAppInput["services"]>;
|
|
88
|
+
/** Dock panel views the app declares. */
|
|
89
|
+
readonly views: NonNullable<DefineAppInput["views"]>;
|
|
90
|
+
/** Resolved app kind — `studio` or one of the SDK app types. */
|
|
91
|
+
readonly applicationType?: string;
|
|
92
|
+
/** SDK app-view entrypoint, when declared. */
|
|
93
|
+
readonly entry?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Resolve the workbench app for a CLI config, or `null` for a plain project.
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
export declare function resolveWorkbenchApp(
|
|
101
|
+
cliConfig: CliConfig | null | undefined,
|
|
102
|
+
): ResolvedWorkbenchApp | null;
|
|
103
|
+
|
|
104
|
+
declare interface WorkbenchViteOptions {
|
|
105
|
+
/** Project root — read for the federation remote name, and the plugin workDir. */
|
|
106
|
+
cwd: string;
|
|
107
|
+
/**
|
|
108
|
+
* Build entry paths relative to the federation runtime dir. `relativeEntry` is
|
|
109
|
+
* the app's `entry` (null for a dock-only app with no app view);
|
|
110
|
+
* `relativeConfigLocation` is the studio's `sanity.config.*` (null when absent).
|
|
111
|
+
*/
|
|
112
|
+
entries: {
|
|
113
|
+
relativeConfigLocation: string | null;
|
|
114
|
+
relativeEntry: string | null;
|
|
115
|
+
};
|
|
116
|
+
/** App (vs studio) build — selects the discriminated federation option shape. */
|
|
117
|
+
isApp?: boolean;
|
|
118
|
+
/** Declared background services. */
|
|
119
|
+
services?: DefineAppInput["services"];
|
|
120
|
+
/** Declared dock views. */
|
|
121
|
+
views?: DefineAppInput["views"];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Build the Vite plugins for a workbench app's module-federation remote. */
|
|
125
|
+
export declare function workbenchVitePlugins(
|
|
126
|
+
options: WorkbenchViteOptions,
|
|
127
|
+
): Promise<PluginOption>;
|
|
128
|
+
|
|
129
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Node-only build entry: the module-federation Vite plugins that
|
|
2
|
+
// `@sanity/cli-build`'s `getViteConfig` swaps in for a workbench app, plus the
|
|
3
|
+
// resolver the build reads declared views/services from. The build needs no
|
|
4
|
+
// deploy-time guards, so it takes the bare `resolveWorkbenchApp` — the guarded
|
|
5
|
+
// view (`getWorkbench`) is the deploy entry's export.
|
|
6
|
+
export { workbenchVitePlugins } from '../actions/build/vite/workbench-vite-plugins.js';
|
|
7
|
+
export { resolveWorkbenchApp } from '../resolveWorkbenchApp.js';
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/build.ts"],"sourcesContent":["// Node-only build entry: the module-federation Vite plugins that\n// `@sanity/cli-build`'s `getViteConfig` swaps in for a workbench app, plus the\n// resolver the build reads declared views/services from. The build needs no\n// deploy-time guards, so it takes the bare `resolveWorkbenchApp` — the guarded\n// view (`getWorkbench`) is the deploy entry's export.\n\nexport {workbenchVitePlugins} from '../actions/build/vite/workbench-vite-plugins.js'\nexport {resolveWorkbenchApp} from '../resolveWorkbenchApp.js'\n"],"names":["workbenchVitePlugins","resolveWorkbenchApp"],"mappings":"AAAA,iEAAiE;AACjE,+EAA+E;AAC/E,4EAA4E;AAC5E,+EAA+E;AAC/E,sDAAsD;AAEtD,SAAQA,oBAAoB,QAAO,kDAAiD;AACpF,SAAQC,mBAAmB,QAAO,4BAA2B"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { CliConfig } from "@sanity/cli-core";
|
|
2
|
+
import { z } from "zod/mini";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* User-facing input for `unstable_defineApp`. Excludes the internal
|
|
6
|
+
* `applicationType` — that field is validated by the schema but is not part of
|
|
7
|
+
* the public surface (Sanity-owned apps set it via `@ts-expect-error`).
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
declare type DefineAppInput = Omit<
|
|
11
|
+
z.output<typeof DefineAppInputSchema>,
|
|
12
|
+
"applicationType"
|
|
13
|
+
>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Runtime-validation schema for `unstable_defineApp`. Validates the full shape
|
|
17
|
+
* including the internal `applicationType`; the user-facing `DefineAppInput`
|
|
18
|
+
* type below omits that field.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
declare const DefineAppInputSchema: z.ZodMiniObject<
|
|
22
|
+
{
|
|
23
|
+
applicationType: z.ZodMiniOptional<
|
|
24
|
+
z.ZodMiniEnum<{
|
|
25
|
+
coreApp: "coreApp";
|
|
26
|
+
studio: "studio";
|
|
27
|
+
canvas: "canvas";
|
|
28
|
+
dashboard: "dashboard";
|
|
29
|
+
"media-library": "media-library";
|
|
30
|
+
}>
|
|
31
|
+
>;
|
|
32
|
+
entry: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
33
|
+
group: z.ZodMiniOptional<
|
|
34
|
+
z.ZodMiniEnum<{
|
|
35
|
+
"dock.system": "dock.system";
|
|
36
|
+
"dock.applications": "dock.applications";
|
|
37
|
+
"dock.user": "dock.user";
|
|
38
|
+
}>
|
|
39
|
+
>;
|
|
40
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
41
|
+
name: z.ZodMiniString<string>;
|
|
42
|
+
organizationId: z.ZodMiniString<string>;
|
|
43
|
+
priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
44
|
+
services: z.ZodMiniOptional<
|
|
45
|
+
z.ZodMiniArray<
|
|
46
|
+
z.ZodMiniDiscriminatedUnion<
|
|
47
|
+
[
|
|
48
|
+
z.ZodMiniObject<
|
|
49
|
+
{
|
|
50
|
+
name: z.ZodMiniString<string>;
|
|
51
|
+
src: z.ZodMiniString<string>;
|
|
52
|
+
type: z.ZodMiniLiteral<"worker">;
|
|
53
|
+
},
|
|
54
|
+
z.core.$strip
|
|
55
|
+
>,
|
|
56
|
+
],
|
|
57
|
+
"type"
|
|
58
|
+
>
|
|
59
|
+
>
|
|
60
|
+
>;
|
|
61
|
+
title: z.ZodMiniString<string>;
|
|
62
|
+
views: z.ZodMiniOptional<
|
|
63
|
+
z.ZodMiniArray<
|
|
64
|
+
z.ZodMiniDiscriminatedUnion<
|
|
65
|
+
[
|
|
66
|
+
z.ZodMiniObject<
|
|
67
|
+
{
|
|
68
|
+
name: z.ZodMiniString<string>;
|
|
69
|
+
src: z.ZodMiniString<string>;
|
|
70
|
+
type: z.ZodMiniLiteral<"panel">;
|
|
71
|
+
},
|
|
72
|
+
z.core.$strip
|
|
73
|
+
>,
|
|
74
|
+
],
|
|
75
|
+
"type"
|
|
76
|
+
>
|
|
77
|
+
>
|
|
78
|
+
>;
|
|
79
|
+
},
|
|
80
|
+
z.core.$strip
|
|
81
|
+
>;
|
|
82
|
+
|
|
83
|
+
declare interface DeployableWorkbenchApp extends ResolvedWorkbenchApp {
|
|
84
|
+
/**
|
|
85
|
+
* Throws when the app declares nothing the build can expose — no entry, view
|
|
86
|
+
* or service. A federated app with none would ship a remote with nothing to
|
|
87
|
+
* load, so deploy gates on this before any prompts or API calls.
|
|
88
|
+
*/
|
|
89
|
+
assertDeployable(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Throws unless `sourceDir` is a directory holding a federation build.
|
|
92
|
+
* Workbench builds emit a module-federation remote instead of a static SPA,
|
|
93
|
+
* so the usual `index.html` contract doesn't apply — `mf-manifest.json` is the
|
|
94
|
+
* marker that `sanity build` produced a federation build.
|
|
95
|
+
*/
|
|
96
|
+
checkBuiltOutput(sourceDir: string): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export declare function getWorkbench(
|
|
100
|
+
cliConfig: CliConfig | null | undefined,
|
|
101
|
+
): DeployableWorkbenchApp | null;
|
|
102
|
+
|
|
103
|
+
/** @public */
|
|
104
|
+
declare interface ResolvedWorkbenchApp {
|
|
105
|
+
/** Background worker services the app declares. */
|
|
106
|
+
readonly services: NonNullable<DefineAppInput["services"]>;
|
|
107
|
+
/** Dock panel views the app declares. */
|
|
108
|
+
readonly views: NonNullable<DefineAppInput["views"]>;
|
|
109
|
+
/** Resolved app kind — `studio` or one of the SDK app types. */
|
|
110
|
+
readonly applicationType?: string;
|
|
111
|
+
/** SDK app-view entrypoint, when declared. */
|
|
112
|
+
readonly entry?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Node-only deploy entry: the workbench-app accessor with the deploy-time guards
|
|
2
|
+
// (`assertDeployable`, `checkBuiltOutput`) the deploy command runs before
|
|
3
|
+
// shipping. Built on the same shared resolver as the build accessor.
|
|
4
|
+
export { getWorkbench } from '../actions/deploy/getWorkbench.js';
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/deploy.ts"],"sourcesContent":["// Node-only deploy entry: the workbench-app accessor with the deploy-time guards\n// (`assertDeployable`, `checkBuiltOutput`) the deploy command runs before\n// shipping. Built on the same shared resolver as the build accessor.\nexport {getWorkbench} from '../actions/deploy/getWorkbench.js'\n"],"names":["getWorkbench"],"mappings":"AAAA,iFAAiF;AACjF,0EAA0E;AAC1E,qEAAqE;AACrE,SAAQA,YAAY,QAAO,oCAAmC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { z } from "zod/mini";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Attempt to acquire an exclusive lock for the workbench process.
|
|
5
|
+
* Uses `O_EXCL` (the `wx` flag) which is atomic at the OS level — only one
|
|
6
|
+
* process can create the file.
|
|
7
|
+
*
|
|
8
|
+
* The lock stores `{pid, host, port}` so other processes can find the
|
|
9
|
+
* running workbench. Call `updatePort` after the Vite server starts to
|
|
10
|
+
* write the actual port (Vite may pick a different one).
|
|
11
|
+
*
|
|
12
|
+
* @returns A {@link WorkbenchLock} if acquired, or `undefined` if another
|
|
13
|
+
* live process already holds it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function acquireWorkbenchLock(
|
|
16
|
+
info: {
|
|
17
|
+
host: string;
|
|
18
|
+
port: number;
|
|
19
|
+
},
|
|
20
|
+
retries?: number,
|
|
21
|
+
): WorkbenchLock | undefined;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Resolve a directory to its canonical (long) form before handing it to
|
|
25
|
+
* `fs.watch`.
|
|
26
|
+
*
|
|
27
|
+
* On Windows, `fs.watch` aborts with a libuv assertion
|
|
28
|
+
* (`!_wcsnicmp(filename, dir, dirlen)` in `fs-event.c`) when the watched path
|
|
29
|
+
* is an 8.3 short name — e.g. temp dirs under `RUNNER~1` — because the OS
|
|
30
|
+
* reports long-form filenames that fail libuv's prefix check.
|
|
31
|
+
* `realpathSync.native` expands short names to their long form so the
|
|
32
|
+
* prefixes match.
|
|
33
|
+
*
|
|
34
|
+
* Falls back to the original path when it can't be resolved (e.g. it doesn't
|
|
35
|
+
* exist yet), which is no worse than watching it directly.
|
|
36
|
+
*/
|
|
37
|
+
export declare function canonicalizeWatchDir(dir: string): string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A manifest describing a running dev server process (studio or app).
|
|
41
|
+
* Stored as `~/.sanity/dev-servers/<pid>.json`.
|
|
42
|
+
*
|
|
43
|
+
* The workbench singleton is tracked separately via the lock file — see
|
|
44
|
+
* `acquireWorkbenchLock` and `readWorkbenchLock` below.
|
|
45
|
+
*/
|
|
46
|
+
export declare type DevServerManifest = z.infer<typeof devServerManifestSchema>;
|
|
47
|
+
|
|
48
|
+
declare const devServerManifestSchema: z.ZodMiniObject<
|
|
49
|
+
{
|
|
50
|
+
host: z.ZodMiniString<string>;
|
|
51
|
+
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
52
|
+
interfaces: z.ZodMiniOptional<
|
|
53
|
+
z.ZodMiniArray<
|
|
54
|
+
z.ZodMiniObject<
|
|
55
|
+
{
|
|
56
|
+
entry_point: z.ZodMiniString<string>;
|
|
57
|
+
interface_type: z.ZodMiniString<string>;
|
|
58
|
+
name: z.ZodMiniString<string>;
|
|
59
|
+
},
|
|
60
|
+
z.core.$strip
|
|
61
|
+
>
|
|
62
|
+
>
|
|
63
|
+
>;
|
|
64
|
+
manifest: z.ZodMiniOptional<
|
|
65
|
+
z.ZodMiniUnion<
|
|
66
|
+
readonly [
|
|
67
|
+
z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>,
|
|
68
|
+
z.ZodMiniObject<
|
|
69
|
+
{
|
|
70
|
+
group: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
71
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
72
|
+
priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
73
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
74
|
+
version: z.ZodMiniString<string>;
|
|
75
|
+
},
|
|
76
|
+
z.core.$strip
|
|
77
|
+
>,
|
|
78
|
+
]
|
|
79
|
+
>
|
|
80
|
+
>;
|
|
81
|
+
manifestUpdatedAt: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
82
|
+
pid: z.ZodMiniNumber<number>;
|
|
83
|
+
port: z.ZodMiniNumber<number>;
|
|
84
|
+
projectId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
85
|
+
startedAt: z.ZodMiniString<string>;
|
|
86
|
+
type: z.ZodMiniEnum<{
|
|
87
|
+
coreApp: "coreApp";
|
|
88
|
+
studio: "studio";
|
|
89
|
+
}>;
|
|
90
|
+
version: z.ZodMiniLiteral<1>;
|
|
91
|
+
workDir: z.ZodMiniString<string>;
|
|
92
|
+
},
|
|
93
|
+
z.core.$strip
|
|
94
|
+
>;
|
|
95
|
+
|
|
96
|
+
declare interface DevServerRegistration {
|
|
97
|
+
/** Remove the registry entry. */
|
|
98
|
+
release: () => void;
|
|
99
|
+
/**
|
|
100
|
+
* Rewrite the registry entry with partial updates merged in. Also bumps the
|
|
101
|
+
* file's mtime, which fires `watchRegistry` in any workbench process and
|
|
102
|
+
* triggers a rebroadcast to connected clients.
|
|
103
|
+
*/
|
|
104
|
+
update: (
|
|
105
|
+
patch: Partial<Omit<DevServerManifest, "pid" | "startedAt" | "version">>,
|
|
106
|
+
) => void;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Read all manifest files from the registry, prune stale entries (dead PIDs),
|
|
111
|
+
* and return the live ones.
|
|
112
|
+
*/
|
|
113
|
+
export declare function getRegisteredServers(): DevServerManifest[];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Read the workbench lock file and return its contents if the holding
|
|
117
|
+
* process is still alive. Prunes stale locks from crashed processes.
|
|
118
|
+
*/
|
|
119
|
+
export declare function readWorkbenchLock():
|
|
120
|
+
| z.infer<typeof workbenchLockSchema>
|
|
121
|
+
| undefined;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Write a manifest file for the current process and return a handle with a
|
|
125
|
+
* `release` function that removes it plus an `update` function for patching
|
|
126
|
+
* fields post-registration. Uses synchronous I/O so the file exists before
|
|
127
|
+
* any signal handler could fire.
|
|
128
|
+
*/
|
|
129
|
+
export declare function registerDevServer(
|
|
130
|
+
manifest: Omit<DevServerManifest, "pid" | "startedAt" | "version">,
|
|
131
|
+
): DevServerRegistration;
|
|
132
|
+
|
|
133
|
+
declare interface RegistryWatcher {
|
|
134
|
+
close(): void;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Watch the registry directory for changes and invoke the callback with the
|
|
139
|
+
* current list of live servers whenever a change is detected.
|
|
140
|
+
*
|
|
141
|
+
* Uses `fs.watch` with a debounce to coalesce rapid file changes (e.g. a
|
|
142
|
+
* server starting and writing its manifest triggers multiple FS events).
|
|
143
|
+
*/
|
|
144
|
+
export declare function watchRegistry(
|
|
145
|
+
callback: (servers: DevServerManifest[]) => void,
|
|
146
|
+
): RegistryWatcher;
|
|
147
|
+
|
|
148
|
+
declare interface WorkbenchLock {
|
|
149
|
+
/** Release the lock file. */
|
|
150
|
+
release: () => void;
|
|
151
|
+
/** Update the lock with the actual port after the server starts listening. */
|
|
152
|
+
updatePort: (port: number) => void;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
declare const workbenchLockSchema: z.ZodMiniObject<
|
|
156
|
+
{
|
|
157
|
+
host: z.ZodMiniString<string>;
|
|
158
|
+
pid: z.ZodMiniNumber<number>;
|
|
159
|
+
port: z.ZodMiniNumber<number>;
|
|
160
|
+
startedAt: z.ZodMiniString<string>;
|
|
161
|
+
version: z.ZodMiniLiteral<1>;
|
|
162
|
+
},
|
|
163
|
+
z.core.$strip
|
|
164
|
+
>;
|
|
165
|
+
|
|
166
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Node-only dev entry: the workbench dev-server registry the CLI's dev
|
|
2
|
+
// orchestration drives. It tracks running studio/app dev servers (single
|
|
3
|
+
// instance via a lock + PID-liveness), and the workbench host watches it to
|
|
4
|
+
// render local panels/services without a deploy. The CLI owns the orchestration
|
|
5
|
+
// (starting servers, extracting manifests); this package owns the registry it
|
|
6
|
+
// registers into and watches.
|
|
7
|
+
export { canonicalizeWatchDir } from '../actions/dev/canonicalizeWatchDir.js';
|
|
8
|
+
export { acquireWorkbenchLock, getRegisteredServers, readWorkbenchLock, registerDevServer, watchRegistry } from '../actions/dev/registry.js';
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/dev.ts"],"sourcesContent":["// Node-only dev entry: the workbench dev-server registry the CLI's dev\n// orchestration drives. It tracks running studio/app dev servers (single\n// instance via a lock + PID-liveness), and the workbench host watches it to\n// render local panels/services without a deploy. The CLI owns the orchestration\n// (starting servers, extracting manifests); this package owns the registry it\n// registers into and watches.\nexport {canonicalizeWatchDir} from '../actions/dev/canonicalizeWatchDir.js'\nexport {\n acquireWorkbenchLock,\n type DevServerManifest,\n getRegisteredServers,\n readWorkbenchLock,\n registerDevServer,\n watchRegistry,\n} from '../actions/dev/registry.js'\n"],"names":["canonicalizeWatchDir","acquireWorkbenchLock","getRegisteredServers","readWorkbenchLock","registerDevServer","watchRegistry"],"mappings":"AAAA,uEAAuE;AACvE,yEAAyE;AACzE,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,8BAA8B;AAC9B,SAAQA,oBAAoB,QAAO,yCAAwC;AAC3E,SACEC,oBAAoB,EAEpBC,oBAAoB,EACpBC,iBAAiB,EACjBC,iBAAiB,EACjBC,aAAa,QACR,6BAA4B"}
|