@devframes/hub 0.9.10 → 0.9.12
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/{assemble-Hj36CCzH.mjs → assemble-CbPTcI7d.mjs} +4 -8
- package/dist/client/index.d.mts +2 -2
- package/dist/{context-Di-fhMKP.d.mts → context-BmHQp89a.d.mts} +22 -1
- package/dist/{context-BWaW6N53.mjs → context-nVwOE7i1.mjs} +12 -29
- package/dist/{index-faD2d5iX.d.mts → index-Dv8iu9St.d.mts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/node/build.d.mts +29 -7
- package/dist/node/build.mjs +100 -60
- package/dist/node/index.d.mts +2 -2
- package/dist/node/index.mjs +1 -1
- package/dist/node/initiate.d.mts +13 -1
- package/dist/node/initiate.mjs +17 -6
- package/dist/types/index.d.mts +2 -2
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as resolveClientModuleSpecifier } from "./remote-url-UClKLQ5_.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { v as prepareDevframe, y as diagnostics } from "./context-nVwOE7i1.mjs";
|
|
3
3
|
import { joinURL, withTrailingSlash } from "ufo";
|
|
4
4
|
import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_DOCK_IMPORTS_FILENAME, DEVFRAME_MCP_ROUTE, DEVFRAME_WS_ROUTE } from "devframe/constants";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
@@ -77,9 +77,10 @@ function renderClientImportsModule(ctx) {
|
|
|
77
77
|
/**
|
|
78
78
|
* Pass 1: mount each devframe under `<base><id>/` (SPA, meta, iframe dock)
|
|
79
79
|
* and queue its declared services, guarding the id against reserved hub
|
|
80
|
-
* filenames and route-pattern characters. Returns the deferred setup thunks
|
|
80
|
+
* filenames and route-pattern characters. Returns the deferred setup thunks;
|
|
81
|
+
* each mounted frame is recorded on `ctx.frames`.
|
|
81
82
|
*/
|
|
82
|
-
async function mountDevframes(ctx, devframes, base,
|
|
83
|
+
async function mountDevframes(ctx, devframes, base, hubMcpEnabled) {
|
|
83
84
|
const setups = [];
|
|
84
85
|
for (const { devframe: def, dock } of devframes) {
|
|
85
86
|
if (RESERVED_HUB_PATHS.includes(def.id)) throw diagnostics.DF8000({ id: def.id });
|
|
@@ -91,11 +92,6 @@ async function mountDevframes(ctx, devframes, base, frames, hubMcpEnabled) {
|
|
|
91
92
|
...dock ? { dock } : {}
|
|
92
93
|
});
|
|
93
94
|
if (run) setups.push(run);
|
|
94
|
-
if (!skippedInStaticBuild(ctx, def)) frames.push({
|
|
95
|
-
id: def.id,
|
|
96
|
-
base: frameBase,
|
|
97
|
-
title: def.name
|
|
98
|
-
});
|
|
99
95
|
}
|
|
100
96
|
return setups;
|
|
101
97
|
}
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as DevframeMessagesClient, w as DevframeMessageEntryInput } from "../context-BmHQp89a.mjs";
|
|
2
2
|
import { A as DevframeViewIframe, C as DevframeDockUserEntry, F as RemoteConnectionInfo, P as NavTarget, S as DevframeDockPanelState, _ as DevframeDockEntry, a as DevframeCommandEntry, b as DevframeDockEntryIcon, g as DevframeDockEntriesGrouped, n as DevframeClientCommand, p as ClientScriptEntry, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings } from "../settings-CWHPzCWS.mjs";
|
|
3
|
-
import "../index-
|
|
3
|
+
import "../index-Dv8iu9St.mjs";
|
|
4
4
|
import { DevframeClientRpcHost, DevframeConnection, DevframeConnectionStatus, DevframeRpcClient, DevframeRpcClientOptions, DevframeRpcContext, RpcClientEvents, RpcClientEvents as RpcClientEvents$1 } from "devframe/client";
|
|
5
5
|
import { EventEmitter } from "devframe/types";
|
|
6
6
|
import { SharedState } from "devframe/utils/shared-state";
|
|
@@ -476,6 +476,20 @@ declare module 'devframe/types' {
|
|
|
476
476
|
'hub:terminals:resize': (id: string, cols: number, rows: number) => Promise<void>;
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* A devframe mounted into a hub context, recorded as it is installed
|
|
481
|
+
* (whether through `initHub({ devframes })`, `buildHub`, or `ctx.install`).
|
|
482
|
+
* Enumerable via {@link DevframeHubContext.frames} so a host that mounted the
|
|
483
|
+
* context itself can still discover what to advertise in `__index.json`.
|
|
484
|
+
*/
|
|
485
|
+
interface HubMountedFrame {
|
|
486
|
+
/** Dock id the devframe mounted under (disambiguated for duplicates). */
|
|
487
|
+
id: string;
|
|
488
|
+
/** Hub-base-relative mount base of the frame's SPA (trailing slash). */
|
|
489
|
+
base: string;
|
|
490
|
+
/** Human title (the definition's `name`). */
|
|
491
|
+
title: string;
|
|
492
|
+
}
|
|
479
493
|
/**
|
|
480
494
|
* Hub-augmented node context that extends devframe's framework-neutral
|
|
481
495
|
* `DevframeNodeContext` with the hub-level subsystems (`docks`,
|
|
@@ -495,6 +509,13 @@ interface DevframeHubContext extends DevframeNodeContext {
|
|
|
495
509
|
terminals: DevframeTerminalsHost;
|
|
496
510
|
messages: DevframeMessagesHost;
|
|
497
511
|
commands: DevframeCommandsHost;
|
|
512
|
+
/**
|
|
513
|
+
* Every devframe mounted into this context, in mount order. Populated by
|
|
514
|
+
* `ctx.install` (and the batch mount `initHub`/`buildHub` run through it),
|
|
515
|
+
* so a host that assembled and mounted the context itself can hand it to
|
|
516
|
+
* `buildHub({ context })` to emit the discovery documents.
|
|
517
|
+
*/
|
|
518
|
+
readonly frames: readonly HubMountedFrame[];
|
|
498
519
|
/**
|
|
499
520
|
* Install a {@link DevframeDefinition} into this hub: serve its SPA at the
|
|
500
521
|
* resolved base, synthesize an iframe dock from its metadata, and run its
|
|
@@ -518,4 +539,4 @@ interface CreateHubContextOptions extends CreateHostContextOptions {}
|
|
|
518
539
|
*/
|
|
519
540
|
declare function createHubContext(options: CreateHubContextOptions): Promise<DevframeHubContext>;
|
|
520
541
|
//#endregion
|
|
521
|
-
export {
|
|
542
|
+
export { DevframeMessagesHost as A, DevframeMessageEntryFrom as C, DevframeMessageLevel as D, DevframeMessageHandle as E, DevframeMessagesListDelta as M, DevframeMessageShortcutInput as O, DevframeMessageEntry as S, DevframeMessageFilePosition as T, DevframeTerminalsHost as _, InstallDevframeOptions as a, DevframeMessageCommandAction as b, DevframeChildProcessResult as c, DevframePtyOutput as d, DevframePtyResult as f, DevframeTerminalStatus as g, DevframeTerminalSessionBase as h, createHubContext as i, DevframeMessagesLevelShortcuts as j, DevframeMessagesClient as k, DevframeChildProcessTerminalSession as l, DevframeTerminalSession as m, DevframeHubContext as n, DevframeChildProcessExecuteOptions as o, DevframePtyTerminalSession as p, HubMountedFrame as r, DevframeChildProcessOutput as s, CreateHubContextOptions as t, DevframePtyExecuteOptions as u, DevframeMessageAction as v, DevframeMessageEntryInput as w, DevframeMessageElementPosition as x, DevframeMessageActivateAction as y };
|
|
@@ -32,8 +32,8 @@ const diagnostics = defineDiagnostics({
|
|
|
32
32
|
fix: "The filenames directly under the hub base (`__connection.json`, `__ws`, `__index.json`, `__client-imports.js`, `__mcp`, `embedded.js`) are reserved for the hub protocol. Rename the devframe id, or override its mount with a non-colliding `basePath`."
|
|
33
33
|
},
|
|
34
34
|
DF8002: {
|
|
35
|
-
why: "initHub received both `devframes` and `context`; the two assembly modes are mutually exclusive.",
|
|
36
|
-
fix: "Pass `devframes` to let
|
|
35
|
+
why: "`initHub`/`buildHub` received both `devframes` and `context`; the two assembly modes are mutually exclusive.",
|
|
36
|
+
fix: "Pass `devframes` to let it create the hub context and mount each frame itself, or pass a pre-built `context` (your host already mounted the frames), but never both."
|
|
37
37
|
},
|
|
38
38
|
DF8003: {
|
|
39
39
|
why: "connectionMeta() was called before initHub finished initializing.",
|
|
@@ -48,8 +48,8 @@ const diagnostics = defineDiagnostics({
|
|
|
48
48
|
fix: "A hub exposes one aggregate MCP endpoint over every mounted devframe, so per-devframe `mcp` settings are ignored. Drop `mcp: false` from `initHub` (the `'auto'` default mounts the aggregate route once agent tools exist) to surface this devframe's tools, or drop `mcp` from the devframe to silence this warning."
|
|
49
49
|
},
|
|
50
50
|
DF8006: {
|
|
51
|
-
why: (p) => `A static hub build
|
|
52
|
-
fix: "buildHub maps
|
|
51
|
+
why: (p) => `A static hub build writes each mount either under its base ("${p.base}") or as an absolute-path sibling of it, but "${p.urlBase}" is neither.`,
|
|
52
|
+
fix: "buildHub maps a mount under the hub base into its `outDir`, and any other mount to the deploy root (`outDir`'s parent) by its absolute path. Give the mount an absolute base (starting with `/`) so it resolves to one of those."
|
|
53
53
|
},
|
|
54
54
|
DF8100: {
|
|
55
55
|
why: (p) => `Dock with id "${p.id}" is already registered`,
|
|
@@ -155,36 +155,13 @@ async function resolvePageScriptClientScript(ctx, clientScript, base) {
|
|
|
155
155
|
const { importFrom } = clientScript;
|
|
156
156
|
if (!isAbsolute(importFrom) || !existsSync(importFrom)) return clientScript;
|
|
157
157
|
const scriptBase = withTrailingSlash(joinURL(base, "__page-script"));
|
|
158
|
-
|
|
158
|
+
ctx.views.hostStatic(scriptBase, dirname(importFrom));
|
|
159
159
|
return {
|
|
160
160
|
...clientScript,
|
|
161
161
|
importFrom: joinURL(scriptBase, basename(importFrom))
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
|
-
* Framework-neutral primitive backing {@link DevframeHubContext.install} -
|
|
166
|
-
* installs a {@link DevframeDefinition} as a dock inside a hub-aware context:
|
|
167
|
-
* serves the devframe's SPA at the resolved base path, synthesizes an iframe
|
|
168
|
-
* dock entry from the definition's metadata, and runs the definition's
|
|
169
|
-
* `setup(ctx)`. Reach for it through `ctx.install(devframe)` rather than
|
|
170
|
-
* calling it directly.
|
|
171
|
-
*
|
|
172
|
-
* Framework kits wrap `ctx.install` with their own plugin/middleware
|
|
173
|
-
* machinery, e.g. `@vitejs/devtools-kit`'s `createPluginFromDevframe`
|
|
174
|
-
* returns a Vite `Plugin` whose `devtools.setup` ultimately delegates here.
|
|
175
|
-
*/
|
|
176
|
-
/**
|
|
177
|
-
* Phase one of an install: run the duplication guard, serve the SPA + meta,
|
|
178
|
-
* register the iframe dock, and queue the definition's declarative wire
|
|
179
|
-
* services, everything up to (but not including) `setup(ctx)`. Returns a
|
|
180
|
-
* deferred setup thunk, or `null` when the devframe was deduplicated.
|
|
181
|
-
*
|
|
182
|
-
* The hub's initial batch uses this to collect every devframe's services
|
|
183
|
-
* across the whole hub, `ready()` them once, and only then run the setups,
|
|
184
|
-
* so services are ready before any setup, and a plugin can consume a service
|
|
185
|
-
* another plugin declared regardless of mount order.
|
|
186
|
-
*/
|
|
187
|
-
/**
|
|
188
165
|
* Serve a devframe's SPA (and the hub's connection meta) under `base`, if the
|
|
189
166
|
* definition ships client assets.
|
|
190
167
|
*/
|
|
@@ -235,6 +212,11 @@ async function prepareDevframe(ctx, d, options = {}) {
|
|
|
235
212
|
const clientScript = await resolvePageScriptClientScript(ctx, dockDefaults.clientScript, base);
|
|
236
213
|
if (clientScript) dockDefaults.clientScript = clientScript;
|
|
237
214
|
await serveDevframeAssets(ctx, d, id, base);
|
|
215
|
+
ctx.frames.push({
|
|
216
|
+
id,
|
|
217
|
+
base,
|
|
218
|
+
title: d.name
|
|
219
|
+
});
|
|
238
220
|
ctx.docks.register({
|
|
239
221
|
id,
|
|
240
222
|
title: d.name,
|
|
@@ -1288,6 +1270,7 @@ async function createHubContext(options) {
|
|
|
1288
1270
|
context.terminals = terminals;
|
|
1289
1271
|
context.messages = messages;
|
|
1290
1272
|
context.commands = commands;
|
|
1273
|
+
context.frames = [];
|
|
1291
1274
|
context.install = (devframe, options) => installDevframe(context, devframe, options);
|
|
1292
1275
|
await docks.init();
|
|
1293
1276
|
const debounceMs = options.mode === "build" ? 0 : 10;
|
|
@@ -1337,4 +1320,4 @@ async function createHubContext(options) {
|
|
|
1337
1320
|
return context;
|
|
1338
1321
|
}
|
|
1339
1322
|
//#endregion
|
|
1340
|
-
export { DevframeCommandsHost as _, hubMessagesAdd as a,
|
|
1323
|
+
export { DevframeCommandsHost as _, hubMessagesAdd as a, hubMessagesUpdate as c, hubTerminalsRestart as d, hubTerminalsTerminate as f, DevframeDocksHost as g, DevframeMessagesHost as h, hubDocksActivate as i, hubTerminalsRemove as l, DevframeTerminalsHost as m, builtinHubRpcDeclarations as n, hubMessagesClear as o, hubTerminalsWrite as p, hubCommandsExecute as r, hubMessagesRemove as s, createHubContext as t, hubTerminalsResize as u, prepareDevframe as v, diagnostics as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./context-
|
|
1
|
+
import "./context-BmHQp89a.mjs";
|
|
2
2
|
import "./settings-CWHPzCWS.mjs";
|
|
3
3
|
import { RpcDefinitionsFilter, RpcDefinitionsToFunctions } from "devframe/rpc";
|
|
4
4
|
import { ConnectionMeta as ConnectionMeta$1, DevframeCapabilities, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeHost as DevframeHost$1, DevframeNodeRpcSession, DevframeRpcClientFunctions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeViewHost, EventEmitter as EventEmitter$1, EventUnsubscribe, EventsMap, RpcBroadcastOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost } from "devframe/types";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as DevframeMessagesHost, C as DevframeMessageEntryFrom, D as DevframeMessageLevel, E as DevframeMessageHandle, M as DevframeMessagesListDelta, O as DevframeMessageShortcutInput, S as DevframeMessageEntry, T as DevframeMessageFilePosition, _ as DevframeTerminalsHost, b as DevframeMessageCommandAction, c as DevframeChildProcessResult, d as DevframePtyOutput, f as DevframePtyResult, g as DevframeTerminalStatus, h as DevframeTerminalSessionBase, j as DevframeMessagesLevelShortcuts, k as DevframeMessagesClient, l as DevframeChildProcessTerminalSession, m as DevframeTerminalSession, n as DevframeHubContext, o as DevframeChildProcessExecuteOptions, p as DevframePtyTerminalSession, s as DevframeChildProcessOutput, t as CreateHubContextOptions, u as DevframePtyExecuteOptions, v as DevframeMessageAction, w as DevframeMessageEntryInput, x as DevframeMessageElementPosition, y as DevframeMessageActivateAction } from "./context-BmHQp89a.mjs";
|
|
2
2
|
import { A as DevframeViewIframe, C as DevframeDockUserEntry, D as DevframeViewBuiltin, E as DevframeViewAction, F as RemoteConnectionInfo, I as RemoteDockOptions, M as DevframeViewLauncherStatus, N as FrameSubTabsConfig, O as DevframeViewCustomRender, P as NavTarget, S as DevframeDockPanelState, T as DevframeDocksHost, _ as DevframeDockEntry, a as DevframeCommandEntry, b as DevframeDockEntryIcon, c as DevframeCommandShortcutOverrides, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, g as DevframeDockEntriesGrouped, h as DevframeDockBadgeVariant, i as DevframeCommandBase, j as DevframeViewLauncher, k as DevframeViewGroup, l as DevframeCommandsHost, m as DevframeDockActivation, n as DevframeClientCommand, o as DevframeCommandHandle, p as ClientScriptEntry, r as DevframeCommandAgentOptions, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings, u as DevframeCommandsHostEvents, v as DevframeDockEntryBase, w as DevframeDocksActiveState, x as DevframeDockEntryRegistry, y as DevframeDockEntryCategory } from "./settings-CWHPzCWS.mjs";
|
|
3
|
-
import { S as RpcStreamingHost, _ as RpcFunctionsHost, a as DevframeHost, b as RpcStreamingChannel, c as DevframeRpcServerFunctions, d as EventEmitter, f as EventUnsubscribe, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, i as DevframeDiagnosticsLogger, l as DevframeRpcSharedStates, m as RpcBroadcastOptions, n as DevframeCapabilities, o as DevframeNodeRpcSession, p as EventsMap, r as DevframeDiagnosticsHost, s as DevframeRpcClientFunctions, t as ConnectionMeta, u as DevframeViewHost, v as RpcSharedStateGetOptions, x as RpcStreamingChannelOptions, y as RpcSharedStateHost } from "./index-
|
|
3
|
+
import { S as RpcStreamingHost, _ as RpcFunctionsHost, a as DevframeHost, b as RpcStreamingChannel, c as DevframeRpcServerFunctions, d as EventEmitter, f as EventUnsubscribe, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, i as DevframeDiagnosticsLogger, l as DevframeRpcSharedStates, m as RpcBroadcastOptions, n as DevframeCapabilities, o as DevframeNodeRpcSession, p as EventsMap, r as DevframeDiagnosticsHost, s as DevframeRpcClientFunctions, t as ConnectionMeta, u as DevframeViewHost, v as RpcSharedStateGetOptions, x as RpcStreamingChannelOptions, y as RpcSharedStateHost } from "./index-Dv8iu9St.mjs";
|
|
4
4
|
import { WhenContext, WhenExpression } from "devframe/utils/when";
|
|
5
5
|
//#region src/define.d.ts
|
|
6
6
|
declare const defineHubRpcFunction: <NAME extends string, TYPE extends import("devframe/rpc").RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends import("devframe/rpc").RpcArgsSchema | undefined = undefined, const RS extends import("devframe/rpc").RpcReturnSchema | undefined = undefined>(definition: import("devframe/rpc").RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeHubContext>) => import("devframe/rpc").RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeHubContext>;
|
package/dist/node/build.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as DevframeHubContext, t as CreateHubContextOptions } from "../context-
|
|
1
|
+
import { n as DevframeHubContext, t as CreateHubContextOptions } from "../context-BmHQp89a.mjs";
|
|
2
2
|
import { DevframeHubUi, DevframesInput, DockRendererRegistration } from "./initiate.mjs";
|
|
3
3
|
import { DevframeServiceInput, DevframeStorageScope } from "devframe/types";
|
|
4
4
|
//#region src/node/build.d.ts
|
|
@@ -7,7 +7,10 @@ interface BuildHubOptions {
|
|
|
7
7
|
* Output directory the hub subtree is written into. It corresponds to the
|
|
8
8
|
* hub {@link BuildHubOptions.base} at serve time: building with
|
|
9
9
|
* `base: '/__devframes/'` into `dist/__devframes` makes the deployed app's
|
|
10
|
-
* `dist/` servable as-is by any static file server.
|
|
10
|
+
* `dist/` servable as-is by any static file server. A mount served outside
|
|
11
|
+
* the hub base (a devframe SPA or asset dir kept as a sibling of it) is
|
|
12
|
+
* written to this directory's parent (the deploy root) by its absolute path,
|
|
13
|
+
* so `dist/` still serves the whole layout.
|
|
11
14
|
*/
|
|
12
15
|
outDir: string;
|
|
13
16
|
/**
|
|
@@ -18,6 +21,17 @@ interface BuildHubOptions {
|
|
|
18
21
|
base?: string;
|
|
19
22
|
/** Devframes to bake as docks, same input as `initHub({ devframes })`. */
|
|
20
23
|
devframes?: DevframesInput;
|
|
24
|
+
/**
|
|
25
|
+
* Bring your own already-mounted hub context instead of `devframes`, the
|
|
26
|
+
* build counterpart of `initHub({ context })`: a host that assembled
|
|
27
|
+
* `createHubContext` + `ctx.install` itself (Vite DevTools' kit-augmented
|
|
28
|
+
* context, devframes mounted from Vite plugins) hands the mounted context
|
|
29
|
+
* here and `buildHub` bakes it, reading `ctx.frames` and
|
|
30
|
+
* `ctx.views.buildStaticDirs` for what to emit. `configure` and the UI
|
|
31
|
+
* slot's `setup` still run against it, so pass them here rather than running
|
|
32
|
+
* them yourself. Mutually exclusive with `devframes`.
|
|
33
|
+
*/
|
|
34
|
+
context?: DevframeHubContext;
|
|
21
35
|
/** Host-level wire services, same contract as `initHub({ services })`. */
|
|
22
36
|
services?: DevframeServiceInput[];
|
|
23
37
|
/** Extra RPC declarations registered at context creation. */
|
|
@@ -47,14 +61,22 @@ interface BuildHubOptions {
|
|
|
47
61
|
getStorageDir?: (scope: DevframeStorageScope) => string;
|
|
48
62
|
/** Pretty-print RPC dump JSON files. Default: `false` (minified shards). */
|
|
49
63
|
pretty?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Remove {@link BuildHubOptions.outDir} before writing. Default `true`,
|
|
66
|
+
* matching a from-scratch build. Pass `false` to bake into a directory that
|
|
67
|
+
* already holds sibling output (an app's own `dist/` the hub subtree lives
|
|
68
|
+
* beside).
|
|
69
|
+
*/
|
|
70
|
+
clean?: boolean;
|
|
50
71
|
}
|
|
51
72
|
/**
|
|
52
73
|
* Produce a self-contained static deploy of a whole hub, the multi-devframe
|
|
53
74
|
* counterpart of devframe's `createBuild`:
|
|
54
75
|
*
|
|
55
|
-
* - Build a `mode: 'build'` hub context and mount every devframe
|
|
56
|
-
* SPA is copied to `<outDir>/<id>/`,
|
|
57
|
-
* `<outDir>/<id>/__page-script/`, and its
|
|
76
|
+
* - Build a `mode: 'build'` hub context and mount every devframe (or reuse a
|
|
77
|
+
* `context` a host mounted itself): each SPA is copied to `<outDir>/<id>/`,
|
|
78
|
+
* an absolute-path page script to `<outDir>/<id>/__page-script/`, and its
|
|
79
|
+
* `setup(ctx)` runs.
|
|
58
80
|
* - Copy the UI slot's viewer SPA, `embedded.js`, and the renderer
|
|
59
81
|
* modules, and write the discovery documents (`__index.json`,
|
|
60
82
|
* `__client-imports.js`).
|
|
@@ -66,8 +88,8 @@ interface BuildHubOptions {
|
|
|
66
88
|
* (docks, commands, renderer manifest), so `createDevframeClientRuntime`
|
|
67
89
|
* and every frame SPA boot from the dump with no live server.
|
|
68
90
|
*
|
|
69
|
-
* Reads work from the baked dump; live writes (messages, terminals,
|
|
70
|
-
*
|
|
91
|
+
* Reads work from the baked dump; live writes (messages, terminals, commands
|
|
92
|
+
* execution) have no server and degrade to no-ops in the clients.
|
|
71
93
|
*/
|
|
72
94
|
declare function buildHub(options: BuildHubOptions): Promise<void>;
|
|
73
95
|
//#endregion
|
package/dist/node/build.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as normalizeHubBase, i as DOCK_RENDERERS_STATE_KEY } from "../constants-Da23JxCZ.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { i as resolveRendererRegistrations, n as renderClientImportsModule, r as resolveDevframesInput, t as mountDevframes } from "../assemble-
|
|
2
|
+
import { t as createHubContext, y as diagnostics } from "../context-nVwOE7i1.mjs";
|
|
3
|
+
import { i as resolveRendererRegistrations, n as renderClientImportsModule, r as resolveDevframesInput, t as mountDevframes } from "../assemble-CbPTcI7d.mjs";
|
|
4
4
|
import { joinURL } from "ufo";
|
|
5
5
|
import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_DOCK_IMPORTS_FILENAME } from "devframe/constants";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
@@ -9,15 +9,17 @@ import process from "node:process";
|
|
|
9
9
|
import { createH3DevframeHost } from "devframe/internal";
|
|
10
10
|
import { collectStaticRpcDump, writeStaticRpcDump } from "devframe/rpc/dump";
|
|
11
11
|
import { colors } from "devframe/utils/colors";
|
|
12
|
+
import { resolveStaticAssetsSource } from "devframe/utils/remote-assets";
|
|
12
13
|
import { dirname, resolve } from "pathe";
|
|
13
14
|
//#region src/node/build.ts
|
|
14
15
|
/**
|
|
15
16
|
* Produce a self-contained static deploy of a whole hub, the multi-devframe
|
|
16
17
|
* counterpart of devframe's `createBuild`:
|
|
17
18
|
*
|
|
18
|
-
* - Build a `mode: 'build'` hub context and mount every devframe
|
|
19
|
-
* SPA is copied to `<outDir>/<id>/`,
|
|
20
|
-
* `<outDir>/<id>/__page-script/`, and its
|
|
19
|
+
* - Build a `mode: 'build'` hub context and mount every devframe (or reuse a
|
|
20
|
+
* `context` a host mounted itself): each SPA is copied to `<outDir>/<id>/`,
|
|
21
|
+
* an absolute-path page script to `<outDir>/<id>/__page-script/`, and its
|
|
22
|
+
* `setup(ctx)` runs.
|
|
21
23
|
* - Copy the UI slot's viewer SPA, `embedded.js`, and the renderer
|
|
22
24
|
* modules, and write the discovery documents (`__index.json`,
|
|
23
25
|
* `__client-imports.js`).
|
|
@@ -29,46 +31,65 @@ import { dirname, resolve } from "pathe";
|
|
|
29
31
|
* (docks, commands, renderer manifest), so `createDevframeClientRuntime`
|
|
30
32
|
* and every frame SPA boot from the dump with no live server.
|
|
31
33
|
*
|
|
32
|
-
* Reads work from the baked dump; live writes (messages, terminals,
|
|
33
|
-
*
|
|
34
|
+
* Reads work from the baked dump; live writes (messages, terminals, commands
|
|
35
|
+
* execution) have no server and degrade to no-ops in the clients.
|
|
34
36
|
*/
|
|
35
37
|
async function buildHub(options) {
|
|
38
|
+
if (options.context && options.devframes?.length) throw diagnostics.DF8002();
|
|
36
39
|
const base = normalizeHubBase(options.base ?? "/__devframes/");
|
|
37
40
|
const cwd = options.cwd ?? process.cwd();
|
|
38
41
|
const outDir = resolve(cwd, options.outDir);
|
|
39
42
|
const rendererRegistrations = resolveRendererRegistrations(options.renderers ?? []);
|
|
40
|
-
|
|
43
|
+
const ctx = options.context ?? await createAndMountContext(options, base, cwd);
|
|
44
|
+
await options.configure?.(ctx);
|
|
45
|
+
await options.ui?.setup?.(ctx);
|
|
46
|
+
if (options.clean !== false && existsSync(outDir)) await fs.rm(outDir, { recursive: true });
|
|
41
47
|
await fs.mkdir(outDir, { recursive: true });
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Map a served URL base to its on-disk location. A base under the hub
|
|
50
|
+
* {@link base} writes into the hub subtree at `outDir` (so `outDir`
|
|
51
|
+
* corresponds to the hub base). A base outside it is a deploy-root sibling:
|
|
52
|
+
* `outDir`'s parent is the deploy root, and the base resolves under it by its
|
|
53
|
+
* absolute path. This is the layout Vite DevTools serves, where devframe SPAs
|
|
54
|
+
* and assets sit beside `/__devtools/` rather than under it.
|
|
55
|
+
*/
|
|
56
|
+
const deployRoot = dirname(outDir);
|
|
57
|
+
const resolveOutPath = (urlBase) => {
|
|
58
|
+
if (urlBase.startsWith(base)) return resolve(outDir, urlBase.slice(base.length));
|
|
59
|
+
if (!urlBase.startsWith("/")) throw diagnostics.DF8006({
|
|
45
60
|
urlBase,
|
|
46
61
|
base
|
|
47
62
|
});
|
|
48
|
-
return resolve(
|
|
49
|
-
}
|
|
50
|
-
|
|
63
|
+
return resolve(deployRoot, urlBase.slice(1));
|
|
64
|
+
};
|
|
65
|
+
await copyBuildStatics(ctx, resolveOutPath);
|
|
66
|
+
await publishRendererManifest(ctx, rendererRegistrations, base, outDir);
|
|
67
|
+
await writeUiArtifacts(options.ui, outDir);
|
|
68
|
+
await fs.writeFile(resolve(outDir, DEVFRAME_DOCK_IMPORTS_FILENAME), renderClientImportsModule(ctx), "utf-8");
|
|
69
|
+
await writeHubIndex(ctx, base, outDir, options);
|
|
70
|
+
await writeConnectionMetas(ctx, base, outDir, resolveOutPath);
|
|
71
|
+
console.log(colors.cyan`[devframes-hub] writing RPC dump to ${resolve(outDir, "__rpc-dump")}`);
|
|
72
|
+
const dump = await collectStaticRpcDump(ctx.rpc.definitions.values(), ctx);
|
|
73
|
+
await writeStaticRpcDump(dump, outDir, { pretty: options.pretty });
|
|
74
|
+
const count = ctx.frames.length;
|
|
75
|
+
console.log(colors.green`[devframes-hub] built ${count} devframe${count === 1 ? "" : "s"} -> ${outDir}`);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Build a `mode: 'build'` hub context and mount the `devframes` input. The host
|
|
79
|
+
* copies nothing live (`mountStatic`/`mountConnectionMeta` are no-ops): every
|
|
80
|
+
* static is copied afterwards from `ctx.views.buildStaticDirs`, and each frame's
|
|
81
|
+
* meta is written from `ctx.frames`.
|
|
82
|
+
*/
|
|
83
|
+
async function createAndMountContext(options, base, cwd) {
|
|
51
84
|
const host = {
|
|
52
85
|
...createH3DevframeHost({
|
|
53
86
|
origin: "http://localhost",
|
|
54
87
|
appName: "devframes",
|
|
55
88
|
workspaceRoot: cwd,
|
|
56
|
-
|
|
57
|
-
* A static build "serves" by copying: a local dist verbatim, a remote
|
|
58
|
-
* assets source by materializing every listed file.
|
|
59
|
-
*/
|
|
60
|
-
mount: async (mountBase, source) => {
|
|
61
|
-
const target = resolveOutPath(mountBase);
|
|
62
|
-
await fs.mkdir(dirname(target), { recursive: true });
|
|
63
|
-
if (typeof source === "string") await fs.cp(source, target, { recursive: true });
|
|
64
|
-
else await source.materialize(target);
|
|
65
|
-
}
|
|
89
|
+
mount: () => {}
|
|
66
90
|
}),
|
|
67
91
|
...options.getStorageDir ? { getStorageDir: options.getStorageDir } : {},
|
|
68
|
-
mountConnectionMeta: (
|
|
69
|
-
resolveOutPath(frameBase);
|
|
70
|
-
frameMetaBases.push(frameBase);
|
|
71
|
-
}
|
|
92
|
+
mountConnectionMeta: () => {}
|
|
72
93
|
};
|
|
73
94
|
const ctx = await createHubContext({
|
|
74
95
|
cwd,
|
|
@@ -79,32 +100,30 @@ async function buildHub(options) {
|
|
|
79
100
|
});
|
|
80
101
|
const devframes = await resolveDevframesInput(options.devframes ?? []);
|
|
81
102
|
for (const input of options.services ?? []) ctx.services.install(input);
|
|
82
|
-
const
|
|
83
|
-
const setups = await mountDevframes(ctx, devframes, base, frames, false);
|
|
103
|
+
const setups = await mountDevframes(ctx, devframes, base, false);
|
|
84
104
|
await ctx.services.ready();
|
|
85
105
|
for (const run of setups) await run();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
console.log(colors.green`[devframes-hub] built ${frames.length} devframe${frames.length === 1 ? "" : "s"} -> ${outDir}`);
|
|
106
|
+
return ctx;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Copy every static the context registered through `ctx.views.hostStatic`
|
|
110
|
+
* (recorded in `ctx.views.buildStaticDirs`): a local dir verbatim, a remote
|
|
111
|
+
* source by materializing every listed file. Reads the list rather than
|
|
112
|
+
* relying on a live host `mountStatic`, so a context whose host copied no
|
|
113
|
+
* statics at mount time (the build host, or a kit's) still gets its assets in.
|
|
114
|
+
* Each source re-resolves with the `resolveFrom` it was mounted with, so a
|
|
115
|
+
* remote source (e.g. a plugin's `--assets` package) resolves to the same
|
|
116
|
+
* locally-installed copy it would serve live.
|
|
117
|
+
*/
|
|
118
|
+
async function copyBuildStatics(ctx, resolveOutPath) {
|
|
119
|
+
const storageDir = ctx.host.getStorageDir("project");
|
|
120
|
+
for (const { baseUrl, source, resolveFrom } of ctx.views.buildStaticDirs) {
|
|
121
|
+
const target = resolveOutPath(baseUrl);
|
|
122
|
+
const resolved = resolveStaticAssetsSource(source, storageDir, resolveFrom);
|
|
123
|
+
await fs.mkdir(dirname(target), { recursive: true });
|
|
124
|
+
if (typeof resolved === "string") await fs.cp(resolved, target, { recursive: true });
|
|
125
|
+
else await resolved.materialize(target);
|
|
126
|
+
}
|
|
108
127
|
}
|
|
109
128
|
/**
|
|
110
129
|
* Publish the renderer manifest exactly like `initHub` does, so it is baked
|
|
@@ -137,14 +156,33 @@ async function writeUiArtifacts(ui, outDir) {
|
|
|
137
156
|
await fs.writeFile(target, produce());
|
|
138
157
|
}
|
|
139
158
|
}
|
|
159
|
+
/** Write `<base>__index.json`: the discovery document listing every frame. */
|
|
160
|
+
async function writeHubIndex(ctx, base, outDir, options) {
|
|
161
|
+
await fs.writeFile(resolve(outDir, "__index.json"), `${JSON.stringify({
|
|
162
|
+
name: options.name,
|
|
163
|
+
version: options.version,
|
|
164
|
+
base,
|
|
165
|
+
frames: ctx.frames.map(({ id, base, title }) => ({
|
|
166
|
+
id,
|
|
167
|
+
base,
|
|
168
|
+
title
|
|
169
|
+
})),
|
|
170
|
+
endpoints: {
|
|
171
|
+
connection: DEVFRAME_CONNECTION_META_FILENAME,
|
|
172
|
+
clientImports: DEVFRAME_DOCK_IMPORTS_FILENAME,
|
|
173
|
+
index: "__index.json",
|
|
174
|
+
...options.ui?.embedded ? { embedded: "embedded.js" } : {}
|
|
175
|
+
}
|
|
176
|
+
}, null, 2)}\n`, "utf-8");
|
|
177
|
+
}
|
|
140
178
|
/**
|
|
141
|
-
* Write the `backend: 'static'` connection meta at the hub base, and a copy
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* finds the shared dump.
|
|
179
|
+
* Write the `backend: 'static'` connection meta at the hub base, and a copy at
|
|
180
|
+
* every frame base that served its own SPA (i.e. registered a static mount at
|
|
181
|
+
* that base) whose `baseUrl` points relative resolution (the RPC dump) back at
|
|
182
|
+
* the hub's own meta, so a frame SPA that fetched its per-frame copy (instead
|
|
183
|
+
* of inheriting the host page's connection) still finds the shared dump.
|
|
146
184
|
*/
|
|
147
|
-
async function writeConnectionMetas(ctx, base, outDir,
|
|
185
|
+
async function writeConnectionMetas(ctx, base, outDir, resolveOutPath) {
|
|
148
186
|
const jsonSerializableMethods = [];
|
|
149
187
|
for (const def of ctx.rpc.definitions.values()) if (def.jsonSerializable === true) jsonSerializableMethods.push(def.name);
|
|
150
188
|
const meta = {
|
|
@@ -157,8 +195,10 @@ async function writeConnectionMetas(ctx, base, outDir, frameDirs) {
|
|
|
157
195
|
...meta,
|
|
158
196
|
baseUrl: joinURL(base, DEVFRAME_CONNECTION_META_FILENAME)
|
|
159
197
|
};
|
|
160
|
-
|
|
161
|
-
|
|
198
|
+
const servedBases = new Set(ctx.views.buildStaticDirs.map((dir) => dir.baseUrl));
|
|
199
|
+
for (const frame of ctx.frames) {
|
|
200
|
+
if (!servedBases.has(frame.base)) continue;
|
|
201
|
+
const target = resolve(resolveOutPath(frame.base), DEVFRAME_CONNECTION_META_FILENAME);
|
|
162
202
|
await fs.mkdir(dirname(target), { recursive: true });
|
|
163
203
|
await fs.writeFile(target, JSON.stringify(frameMeta, null, 2), "utf-8");
|
|
164
204
|
}
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as DevframeMessagesHost$1, E as DevframeMessageHandle, M as DevframeMessagesListDelta, O as DevframeMessageShortcutInput, S as DevframeMessageEntry, _ as DevframeTerminalsHost$1, a as InstallDevframeOptions, h as DevframeTerminalSessionBase, i as createHubContext, l as DevframeChildProcessTerminalSession, m as DevframeTerminalSession, n as DevframeHubContext, o as DevframeChildProcessExecuteOptions, p as DevframePtyTerminalSession, r as HubMountedFrame, t as CreateHubContextOptions, u as DevframePtyExecuteOptions, w as DevframeMessageEntryInput } from "../context-BmHQp89a.mjs";
|
|
2
2
|
import { C as DevframeDockUserEntry, T as DevframeDocksHost$1, _ as DevframeDockEntry, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, l as DevframeCommandsHost$1, o as DevframeCommandHandle, p as ClientScriptEntry, t as DevframeDocksUserSettings } from "../settings-CWHPzCWS.mjs";
|
|
3
3
|
import { RpcFunctionDefinitionAny } from "devframe/rpc";
|
|
4
4
|
import { SharedState } from "devframe/utils/shared-state";
|
|
@@ -388,4 +388,4 @@ declare const builtinHubRpcDeclarations: readonly RpcFunctionDefinitionAny[];
|
|
|
388
388
|
*/
|
|
389
389
|
declare function createSimpleClientScript(fn: string | ((ctx: any) => void)): ClientScriptEntry;
|
|
390
390
|
//#endregion
|
|
391
|
-
export { CreateHubContextOptions, DevframeCommandsHost, DevframeDocksHost, DevframeHubContext, DevframeMessagesHost, DevframeTerminalsHost, type InstallDevframeOptions, builtinHubRpcDeclarations, createHubContext, createSimpleClientScript, hubCommandsExecute, hubDocksActivate, hubMessagesAdd, hubMessagesClear, hubMessagesRemove, hubMessagesUpdate, hubTerminalsRemove, hubTerminalsResize, hubTerminalsRestart, hubTerminalsTerminate, hubTerminalsWrite };
|
|
391
|
+
export { CreateHubContextOptions, DevframeCommandsHost, DevframeDocksHost, DevframeHubContext, DevframeMessagesHost, DevframeTerminalsHost, HubMountedFrame, type InstallDevframeOptions, builtinHubRpcDeclarations, createHubContext, createSimpleClientScript, hubCommandsExecute, hubDocksActivate, hubMessagesAdd, hubMessagesClear, hubMessagesRemove, hubMessagesUpdate, hubTerminalsRemove, hubTerminalsResize, hubTerminalsRestart, hubTerminalsTerminate, hubTerminalsWrite };
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as DevframeCommandsHost, a as hubMessagesAdd, c as hubMessagesUpdate, d as hubTerminalsRestart, f as hubTerminalsTerminate, g as DevframeDocksHost, h as DevframeMessagesHost, i as hubDocksActivate, l as hubTerminalsRemove, m as DevframeTerminalsHost, n as builtinHubRpcDeclarations, o as hubMessagesClear, p as hubTerminalsWrite, r as hubCommandsExecute, s as hubMessagesRemove, t as createHubContext, u as hubTerminalsResize } from "../context-
|
|
1
|
+
import { _ as DevframeCommandsHost, a as hubMessagesAdd, c as hubMessagesUpdate, d as hubTerminalsRestart, f as hubTerminalsTerminate, g as DevframeDocksHost, h as DevframeMessagesHost, i as hubDocksActivate, l as hubTerminalsRemove, m as DevframeTerminalsHost, n as builtinHubRpcDeclarations, o as hubMessagesClear, p as hubTerminalsWrite, r as hubCommandsExecute, s as hubMessagesRemove, t as createHubContext, u as hubTerminalsResize } from "../context-nVwOE7i1.mjs";
|
|
2
2
|
import "ufo";
|
|
3
3
|
import "node:fs";
|
|
4
4
|
import "node:process";
|
package/dist/node/initiate.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as InstallDevframeOptions, n as DevframeHubContext, t as CreateHubContextOptions } from "../context-BmHQp89a.mjs";
|
|
2
2
|
import { r as DEVFRAMES_HUB_BASE } from "../constants-Bz4yclHo.mjs";
|
|
3
3
|
import { DevframeInstanceRecord } from "devframe/internal";
|
|
4
|
+
import { AuthBannerFunction } from "devframe/recipes/interactive-auth";
|
|
4
5
|
import { ConnectionMeta, DevframeDefinition, DevframeServiceInput, DevframeSseOptions, DevframeStorageScope, DevframeWsOptions, McpSetting } from "devframe/types";
|
|
5
6
|
import { DevframeAuthHandler } from "devframe/node/auth";
|
|
6
7
|
import { WsOriginRegistry } from "devframe/rpc/transports/ws-server";
|
|
@@ -86,6 +87,17 @@ interface DevframeHubUi {
|
|
|
86
87
|
* The hub stays policy-free about what the UI writes.
|
|
87
88
|
*/
|
|
88
89
|
setup?: (ctx: DevframeHubContext) => void | Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* The interactive OTP banner (auth code + magic-link URL) to print when
|
|
92
|
+
* {@link InitHubOptions.auth} is left at its default. A node-side
|
|
93
|
+
* counterpart to `setup`'s browser-facing branding: the reference UI's
|
|
94
|
+
* `createUi()` derives one from its own `branding.productName` via
|
|
95
|
+
* `createAuthBanner` (see `devframe/recipes/interactive-auth`), so the
|
|
96
|
+
* printed code matches the rebranded viewer without the caller wiring
|
|
97
|
+
* `auth` themselves. Ignored once `auth` is set explicitly - a `false` or
|
|
98
|
+
* a full {@link DevframeAuthHandler} both mean the caller owns the banner.
|
|
99
|
+
*/
|
|
100
|
+
authBanner?: AuthBannerFunction;
|
|
89
101
|
}
|
|
90
102
|
type DevframesInput = Array<DevframeDefinition | HubDevframeEntry | Thenable<Arrayable<DevframeDefinition | HubDevframeEntry | null | undefined>> | (() => Thenable<Arrayable<DevframeDefinition | HubDevframeEntry | null | undefined>>)>;
|
|
91
103
|
interface InitHubOptions {
|
package/dist/node/initiate.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { a as normalizeHubBase, i as DOCK_RENDERERS_STATE_KEY, r as DEVFRAMES_HUB_BASE } from "../constants-Da23JxCZ.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { i as resolveRendererRegistrations, n as renderClientImportsModule, r as resolveDevframesInput, t as mountDevframes } from "../assemble-
|
|
2
|
+
import { t as createHubContext, y as diagnostics } from "../context-nVwOE7i1.mjs";
|
|
3
|
+
import { i as resolveRendererRegistrations, n as renderClientImportsModule, r as resolveDevframesInput, t as mountDevframes } from "../assemble-CbPTcI7d.mjs";
|
|
4
4
|
import { joinURL, withoutLeadingSlash } from "ufo";
|
|
5
5
|
import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_DOCK_IMPORTS_FILENAME, DEVFRAME_MCP_ROUTE } from "devframe/constants";
|
|
6
6
|
import { readFile } from "node:fs/promises";
|
|
7
7
|
import process from "node:process";
|
|
8
8
|
import { createH3DevframeHost, createInstanceShell, importRuntimeModule, loadAutoMcpAdapter, resolveInstanceRegister, resolveMcpConfig } from "devframe/internal";
|
|
9
9
|
import { resolve } from "pathe";
|
|
10
|
+
import { createInteractiveAuth } from "devframe/recipes/interactive-auth";
|
|
10
11
|
import { mountStaticHandler } from "devframe/utils/serve-static";
|
|
11
12
|
import { H3 } from "h3";
|
|
12
13
|
//#region src/node/initiate.ts
|
|
@@ -75,14 +76,20 @@ function initHub(options) {
|
|
|
75
76
|
const baseNoSlash = base.slice(0, -1);
|
|
76
77
|
const app = new H3();
|
|
77
78
|
const cwd = options.cwd ?? process.cwd();
|
|
78
|
-
const frames = [];
|
|
79
79
|
const rendererRegistrations = resolveRendererRegistrations(options.renderers ?? []);
|
|
80
80
|
const shell = createInstanceShell({
|
|
81
81
|
base,
|
|
82
82
|
app,
|
|
83
83
|
host: options.host,
|
|
84
84
|
origin: options.origin,
|
|
85
|
-
|
|
85
|
+
/**
|
|
86
|
+
* `false`/an explicit handler are the caller's own call, passed through
|
|
87
|
+
* as-is; `true`/unset both mean "gate with the defaults", so the handler
|
|
88
|
+
* is built lazily from `ctx` either way, taking the UI slot's
|
|
89
|
+
* `authBanner` (e.g. `createUi()`'s branded box) without the caller
|
|
90
|
+
* wiring `auth` themselves.
|
|
91
|
+
*/
|
|
92
|
+
auth: options.auth === false || typeof options.auth === "object" ? options.auth : (ctx) => createInteractiveAuth(ctx, { banner: options.ui?.authBanner }),
|
|
86
93
|
server: options.server,
|
|
87
94
|
ws: options.ws,
|
|
88
95
|
sse: options.sse,
|
|
@@ -118,7 +125,7 @@ function initHub(options) {
|
|
|
118
125
|
};
|
|
119
126
|
const devframes = await resolveDevframesInput(options.devframes ?? []);
|
|
120
127
|
for (const input of options.services ?? []) ctx.services.install(input);
|
|
121
|
-
const setups = await mountDevframes(ctx, devframes, base,
|
|
128
|
+
const setups = await mountDevframes(ctx, devframes, base, options.mcp !== false);
|
|
122
129
|
await ctx.services.ready();
|
|
123
130
|
for (const run of setups) await run();
|
|
124
131
|
await options.configure?.(ctx);
|
|
@@ -158,7 +165,11 @@ function initHub(options) {
|
|
|
158
165
|
name: options.name,
|
|
159
166
|
version: options.version,
|
|
160
167
|
base,
|
|
161
|
-
frames,
|
|
168
|
+
frames: ctx.frames.map(({ id, base, title }) => ({
|
|
169
|
+
id,
|
|
170
|
+
base,
|
|
171
|
+
title
|
|
172
|
+
})),
|
|
162
173
|
endpoints: {
|
|
163
174
|
connection: DEVFRAME_CONNECTION_META_FILENAME,
|
|
164
175
|
clientImports: DEVFRAME_DOCK_IMPORTS_FILENAME,
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as DevframeMessagesHost, C as DevframeMessageEntryFrom, D as DevframeMessageLevel, E as DevframeMessageHandle, M as DevframeMessagesListDelta, O as DevframeMessageShortcutInput, S as DevframeMessageEntry, T as DevframeMessageFilePosition, _ as DevframeTerminalsHost, b as DevframeMessageCommandAction, c as DevframeChildProcessResult, d as DevframePtyOutput, f as DevframePtyResult, g as DevframeTerminalStatus, h as DevframeTerminalSessionBase, j as DevframeMessagesLevelShortcuts, k as DevframeMessagesClient, l as DevframeChildProcessTerminalSession, m as DevframeTerminalSession, n as DevframeHubContext, o as DevframeChildProcessExecuteOptions, p as DevframePtyTerminalSession, s as DevframeChildProcessOutput, t as CreateHubContextOptions, u as DevframePtyExecuteOptions, v as DevframeMessageAction, w as DevframeMessageEntryInput, x as DevframeMessageElementPosition, y as DevframeMessageActivateAction } from "../context-BmHQp89a.mjs";
|
|
2
2
|
import { A as DevframeViewIframe, C as DevframeDockUserEntry, D as DevframeViewBuiltin, E as DevframeViewAction, F as RemoteConnectionInfo, I as RemoteDockOptions, M as DevframeViewLauncherStatus, N as FrameSubTabsConfig, O as DevframeViewCustomRender, P as NavTarget, S as DevframeDockPanelState, T as DevframeDocksHost, _ as DevframeDockEntry, a as DevframeCommandEntry, b as DevframeDockEntryIcon, c as DevframeCommandShortcutOverrides, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, g as DevframeDockEntriesGrouped, h as DevframeDockBadgeVariant, i as DevframeCommandBase, j as DevframeViewLauncher, k as DevframeViewGroup, l as DevframeCommandsHost, m as DevframeDockActivation, n as DevframeClientCommand, o as DevframeCommandHandle, p as ClientScriptEntry, r as DevframeCommandAgentOptions, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings, u as DevframeCommandsHostEvents, v as DevframeDockEntryBase, w as DevframeDocksActiveState, x as DevframeDockEntryRegistry, y as DevframeDockEntryCategory } from "../settings-CWHPzCWS.mjs";
|
|
3
|
-
import { S as RpcStreamingHost, _ as RpcFunctionsHost, a as DevframeHost, b as RpcStreamingChannel, c as DevframeRpcServerFunctions, d as EventEmitter, f as EventUnsubscribe, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, i as DevframeDiagnosticsLogger, l as DevframeRpcSharedStates, m as RpcBroadcastOptions, n as DevframeCapabilities, o as DevframeNodeRpcSession, p as EventsMap, r as DevframeDiagnosticsHost, s as DevframeRpcClientFunctions, t as ConnectionMeta, u as DevframeViewHost, v as RpcSharedStateGetOptions, x as RpcStreamingChannelOptions, y as RpcSharedStateHost } from "../index-
|
|
3
|
+
import { S as RpcStreamingHost, _ as RpcFunctionsHost, a as DevframeHost, b as RpcStreamingChannel, c as DevframeRpcServerFunctions, d as EventEmitter, f as EventUnsubscribe, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, i as DevframeDiagnosticsLogger, l as DevframeRpcSharedStates, m as RpcBroadcastOptions, n as DevframeCapabilities, o as DevframeNodeRpcSession, p as EventsMap, r as DevframeDiagnosticsHost, s as DevframeRpcClientFunctions, t as ConnectionMeta, u as DevframeViewHost, v as RpcSharedStateGetOptions, x as RpcStreamingChannelOptions, y as RpcSharedStateHost } from "../index-Dv8iu9St.mjs";
|
|
4
4
|
export { ClientScriptEntry, type ConnectionMeta, type CreateHubContextOptions, type DevframeCapabilities, DevframeChildProcessExecuteOptions, DevframeChildProcessOutput, DevframeChildProcessResult, DevframeChildProcessTerminalSession, DevframeClientCommand, DevframeCommandAgentOptions, DevframeCommandBase, DevframeCommandEntry, DevframeCommandHandle, DevframeCommandKeybinding, DevframeCommandShortcutOverrides, DevframeCommandsHost, DevframeCommandsHostEvents, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, DevframeDockActivation, DevframeDockBadgeVariant, DevframeDockEntriesGrouped, DevframeDockEntry, DevframeDockEntryBase, DevframeDockEntryCategory, DevframeDockEntryIcon, DevframeDockEntryRegistry, DevframeDockPanelState, DevframeDockUserEntry, DevframeDocksActiveState, DevframeDocksHost, DevframeDocksUserSettings, type DevframeHost, type DevframeHubContext, DevframeMessageAction, DevframeMessageActivateAction, DevframeMessageCommandAction, DevframeMessageElementPosition, DevframeMessageEntry, DevframeMessageEntryFrom, DevframeMessageEntryInput, DevframeMessageFilePosition, DevframeMessageHandle, DevframeMessageLevel, DevframeMessageShortcutInput, DevframeMessagesClient, DevframeMessagesHost, DevframeMessagesLevelShortcuts, DevframeMessagesListDelta, type DevframeNodeRpcSession, DevframePtyExecuteOptions, DevframePtyOutput, DevframePtyResult, DevframePtyTerminalSession, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, DevframeServerCommandEntry, DevframeServerCommandInput, DevframeTerminalSession, DevframeTerminalSessionBase, DevframeTerminalStatus, DevframeTerminalsHost, DevframeViewAction, DevframeViewBuiltin, DevframeViewCustomRender, DevframeViewGroup, type DevframeViewHost, DevframeViewIframe, DevframeViewLauncher, DevframeViewLauncherStatus, type EventEmitter, type EventUnsubscribe, type EventsMap, FrameSubTabsConfig, NavTarget, RemoteConnectionInfo, RemoteDockOptions, type RpcBroadcastOptions, type RpcDefinitionsFilter, type RpcDefinitionsToFunctions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devframes/hub",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.12",
|
|
5
5
|
"description": "Hub layer that orchestrates devframe docks, terminals, messages, and commands on any host.",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"devframe": "0.9.
|
|
38
|
+
"devframe": "0.9.12"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@standard-schema/spec": "^1.1.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^26.4.0",
|
|
52
|
-
"devframe": "0.9.
|
|
52
|
+
"devframe": "0.9.12",
|
|
53
53
|
"get-port-please": "^3.2.0",
|
|
54
54
|
"mlly": "^1.8.2",
|
|
55
55
|
"tsdown": "^0.22.14",
|