@devframes/hub 0.7.2 → 0.7.3

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.
@@ -1,6 +1,6 @@
1
- import { S as DevframeMessagesClient, _ as DevframeMessageEntryInput } from "../context-CANUHYpc.mjs";
2
- import { O as RemoteConnectionInfo, i as DevframeCommandEntry, m as DevframeDockEntry, n as DevframeClientCommand, o as DevframeCommandKeybinding, p as DevframeDockEntriesGrouped, t as DevframeDocksUserSettings, v as DevframeDockUserEntry } from "../settings-0U1BorGE.mjs";
3
- import "../index-DmNIgq0_.mjs";
1
+ import { S as DevframeMessagesClient, _ as DevframeMessageEntryInput } from "../context-C36xWGWi.mjs";
2
+ import { A as RemoteConnectionInfo, h as DevframeDockEntry, i as DevframeCommandEntry, m as DevframeDockEntriesGrouped, n as DevframeClientCommand, o as DevframeCommandKeybinding, t as DevframeDocksUserSettings, y as DevframeDockUserEntry } from "../settings-BY2Ec77-.mjs";
3
+ import "../index-DcPSmxA5.mjs";
4
4
  import { DevframeClientRpcHost, 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";
@@ -76,6 +76,7 @@ function createMessagesClient(rpc, options = {}) {
76
76
  const DOCKS_STATE_KEY = "devframe:docks";
77
77
  const COMMANDS_STATE_KEY = "devframe:commands";
78
78
  const USER_SETTINGS_STATE_KEY = "devframe:user-settings";
79
+ const DOCKS_ACTIVATE_EVENT = "devframe:docks:activate";
79
80
  /**
80
81
  * Boot the framework-level client host: connect RPC, assemble the full
81
82
  * {@link DevframeClientContext} (panel, docks, commands, when) from the hub's
@@ -126,6 +127,21 @@ async function createDevframeClientHost(options = {}) {
126
127
  const disposers = [];
127
128
  reconcileEntries();
128
129
  disposers.push(docksState.on("updated", reconcileEntries));
130
+ const activateHandler = (activation) => {
131
+ if (activation?.dockId) switchEntry(activation.dockId);
132
+ };
133
+ const existingActivate = rpc.client.definitions.get(DOCKS_ACTIVATE_EVENT);
134
+ if (existingActivate) {
135
+ const prev = existingActivate.handler;
136
+ existingActivate.handler = (...args) => {
137
+ activateHandler(args[0]);
138
+ return prev?.(...args);
139
+ };
140
+ } else rpc.client.register({
141
+ name: DOCKS_ACTIVATE_EVENT,
142
+ type: "action",
143
+ handler: (activation) => activateHandler(activation)
144
+ });
129
145
  if (getDevframeClientContext()) console.warn("[@devframes/hub] A client host context is already published on this page — replacing it. Boot createDevframeClientHost() once per page (e.g. HTML injection combined with a manual import boots it twice).");
130
146
  setDevframeClientContext(context);
131
147
  const loadedScripts = /* @__PURE__ */ new Set();
@@ -1,4 +1,4 @@
1
- import { t as DevframeDocksUserSettings } from "./settings-0U1BorGE.mjs";
1
+ import { t as DevframeDocksUserSettings } from "./settings-BY2Ec77-.mjs";
2
2
  export * from "devframe/constants";
3
3
  //#region src/constants.d.ts
4
4
  declare const DEFAULT_CATEGORIES_ORDER: Record<string, number>;
@@ -1,4 +1,4 @@
1
- import { M as JsonRenderer, _ as DevframeDockEntryIcon, c as DevframeCommandsHost, j as JsonRenderSpec, y as DevframeDocksHost } from "./settings-0U1BorGE.mjs";
1
+ import { N as JsonRenderSpec, P as JsonRenderer, c as DevframeCommandsHost, p as DevframeDockActivation, v as DevframeDockEntryIcon, x as DevframeDocksHost } from "./settings-BY2Ec77-.mjs";
2
2
  import { CreateHostContextOptions } from "devframe/node";
3
3
  import { DevframeHost, DevframeNodeContext, EventEmitter } from "devframe/types";
4
4
  import { ChildProcess } from "node:child_process";
@@ -310,6 +310,17 @@ interface DevframePtyTerminalSession extends DevframeTerminalSession {
310
310
  //#region src/node/context.d.ts
311
311
  declare module 'devframe/types' {
312
312
  interface DevframeRpcClientFunctions {
313
+ /**
314
+ * Server→client request to switch the active dock. Broadcast by the hub
315
+ * context in response to `ctx.docks.activate()` (driven by the
316
+ * `hub:docks:activate` RPC). The client host registers a handler that
317
+ * calls its local `switchEntry(dockId)`; the target dock reads
318
+ * `activation.params` to react (e.g. focus a session). Do not register
319
+ * manually.
320
+ *
321
+ * @internal
322
+ */
323
+ 'devframe:docks:activate': (activation: DevframeDockActivation) => Promise<void>;
313
324
  /**
314
325
  * Server→client notification that terminal sessions changed. Broadcast
315
326
  * by the hub context; a hub-aware client re-reads terminal state in
@@ -1,5 +1,5 @@
1
- import "./context-CANUHYpc.mjs";
2
- import "./settings-0U1BorGE.mjs";
1
+ import "./context-C36xWGWi.mjs";
2
+ import "./settings-BY2Ec77-.mjs";
3
3
  import { RpcDefinitionsFilter, RpcDefinitionsToFunctions } from "devframe/rpc";
4
4
  import { ConnectionMeta as ConnectionMeta$1, DevframeCapabilities, DevframeDiagnosticsDefinition, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeHost as DevframeHost$1, DevframeNodeRpcSession, DevframeRpcClientFunctions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeViewHost, EntriesToObject, EventEmitter as EventEmitter$1, EventUnsubscribe, EventsMap, PartialWithoutId, RpcBroadcastOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, Thenable } from "devframe/types";
5
5
  export { RpcStreamingChannel as C, Thenable as E, RpcSharedStateHost as S, RpcStreamingHost as T, RpcBroadcastOptions as _, DevframeDiagnosticsLogger as a, RpcFunctionsHost as b, DevframeRpcClientFunctions as c, DevframeViewHost as d, EntriesToObject as f, PartialWithoutId as g, EventsMap as h, DevframeDiagnosticsHost as i, DevframeRpcServerFunctions as l, EventUnsubscribe as m, DevframeCapabilities as n, DevframeHost$1 as o, EventEmitter$1 as p, DevframeDiagnosticsDefinition as r, DevframeNodeRpcSession as s, ConnectionMeta$1 as t, DevframeRpcSharedStates as u, RpcDefinitionsFilter as v, RpcStreamingChannelOptions as w, RpcSharedStateGetOptions as x, RpcDefinitionsToFunctions as y };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as DevframeMessagesHost, S as DevframeMessagesClient, T as DevframeMessagesListDelta, _ as DevframeMessageEntryInput, a as DevframeChildProcessOutput, b as DevframeMessageLevel, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, f as DevframeTerminalStatus, g as DevframeMessageEntryFrom, h as DevframeMessageEntry, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, m as DevframeMessageElementPosition, n as DevframeHubContext, o as DevframeChildProcessResult, p as DevframeTerminalsHost, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, v as DevframeMessageFilePosition, w as DevframeMessagesLevelShortcuts, x as DevframeMessageShortcutInput, y as DevframeMessageHandle } from "./context-CANUHYpc.mjs";
2
- import { A as JsonRenderElement, C as DevframeViewGroup, D as DevframeViewLauncherStatus, E as DevframeViewLauncher, M as JsonRenderer, O as RemoteConnectionInfo, S as DevframeViewCustomRender, T as DevframeViewJsonRender, _ as DevframeDockEntryIcon, a as DevframeCommandHandle, b as DevframeViewAction, c as DevframeCommandsHost, d as DevframeServerCommandInput, f as ClientScriptEntry, g as DevframeDockEntryCategory, h as DevframeDockEntryBase, i as DevframeCommandEntry, j as JsonRenderSpec, k as RemoteDockOptions, l as DevframeCommandsHostEvents, m as DevframeDockEntry, n as DevframeClientCommand, o as DevframeCommandKeybinding, p as DevframeDockEntriesGrouped, r as DevframeCommandBase, s as DevframeCommandShortcutOverrides, t as DevframeDocksUserSettings, u as DevframeServerCommandEntry, v as DevframeDockUserEntry, w as DevframeViewIframe, x as DevframeViewBuiltin, y as DevframeDocksHost } from "./settings-0U1BorGE.mjs";
3
- import { C as RpcStreamingChannel, E as Thenable, S as RpcSharedStateHost, T as RpcStreamingHost, _ as RpcBroadcastOptions, a as DevframeDiagnosticsLogger, b as RpcFunctionsHost, c as DevframeRpcClientFunctions, d as DevframeViewHost, f as EntriesToObject, g as PartialWithoutId, h as EventsMap, i as DevframeDiagnosticsHost, l as DevframeRpcServerFunctions, m as EventUnsubscribe, n as DevframeCapabilities, o as DevframeHost, p as EventEmitter, r as DevframeDiagnosticsDefinition, s as DevframeNodeRpcSession, t as ConnectionMeta, u as DevframeRpcSharedStates, v as RpcDefinitionsFilter, w as RpcStreamingChannelOptions, x as RpcSharedStateGetOptions, y as RpcDefinitionsToFunctions } from "./index-DmNIgq0_.mjs";
1
+ import { C as DevframeMessagesHost, S as DevframeMessagesClient, T as DevframeMessagesListDelta, _ as DevframeMessageEntryInput, a as DevframeChildProcessOutput, b as DevframeMessageLevel, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, f as DevframeTerminalStatus, g as DevframeMessageEntryFrom, h as DevframeMessageEntry, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, m as DevframeMessageElementPosition, n as DevframeHubContext, o as DevframeChildProcessResult, p as DevframeTerminalsHost, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, v as DevframeMessageFilePosition, w as DevframeMessagesLevelShortcuts, x as DevframeMessageShortcutInput, y as DevframeMessageHandle } from "./context-C36xWGWi.mjs";
2
+ import { A as RemoteConnectionInfo, C as DevframeViewBuiltin, D as DevframeViewJsonRender, E as DevframeViewIframe, M as JsonRenderElement, N as JsonRenderSpec, O as DevframeViewLauncher, P as JsonRenderer, S as DevframeViewAction, T as DevframeViewGroup, _ as DevframeDockEntryCategory, a as DevframeCommandHandle, b as DevframeDocksActiveState, c as DevframeCommandsHost, d as DevframeServerCommandInput, f as ClientScriptEntry, g as DevframeDockEntryBase, h as DevframeDockEntry, i as DevframeCommandEntry, j as RemoteDockOptions, k as DevframeViewLauncherStatus, l as DevframeCommandsHostEvents, m as DevframeDockEntriesGrouped, n as DevframeClientCommand, o as DevframeCommandKeybinding, p as DevframeDockActivation, r as DevframeCommandBase, s as DevframeCommandShortcutOverrides, t as DevframeDocksUserSettings, u as DevframeServerCommandEntry, v as DevframeDockEntryIcon, w as DevframeViewCustomRender, x as DevframeDocksHost, y as DevframeDockUserEntry } from "./settings-BY2Ec77-.mjs";
3
+ import { C as RpcStreamingChannel, E as Thenable, S as RpcSharedStateHost, T as RpcStreamingHost, _ as RpcBroadcastOptions, a as DevframeDiagnosticsLogger, b as RpcFunctionsHost, c as DevframeRpcClientFunctions, d as DevframeViewHost, f as EntriesToObject, g as PartialWithoutId, h as EventsMap, i as DevframeDiagnosticsHost, l as DevframeRpcServerFunctions, m as EventUnsubscribe, n as DevframeCapabilities, o as DevframeHost, p as EventEmitter, r as DevframeDiagnosticsDefinition, s as DevframeNodeRpcSession, t as ConnectionMeta, u as DevframeRpcSharedStates, v as RpcDefinitionsFilter, w as RpcStreamingChannelOptions, x as RpcSharedStateGetOptions, y as RpcDefinitionsToFunctions } from "./index-DcPSmxA5.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>;
@@ -12,4 +12,4 @@ declare function defineDockEntry<const T extends DevframeDockUserEntry, const W
12
12
  }): T;
13
13
  declare function defineJsonRenderSpec(spec: JsonRenderSpec): JsonRenderSpec;
14
14
  //#endregion
15
- export { type ClientScriptEntry, type ConnectionMeta, type CreateHubContextOptions, type DevframeCapabilities, type DevframeChildProcessExecuteOptions, type DevframeChildProcessOutput, type DevframeChildProcessResult, type DevframeChildProcessTerminalSession, type DevframeClientCommand, type DevframeCommandBase, type DevframeCommandEntry, type DevframeCommandHandle, type DevframeCommandKeybinding, type DevframeCommandShortcutOverrides, type DevframeCommandsHost, type DevframeCommandsHostEvents, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDockEntriesGrouped, type DevframeDockEntry, type DevframeDockEntryBase, type DevframeDockEntryCategory, type DevframeDockEntryIcon, type DevframeDockUserEntry, type DevframeDocksHost, type DevframeDocksUserSettings, type DevframeHost, type DevframeHubContext, type DevframeMessageElementPosition, type DevframeMessageEntry, type DevframeMessageEntryFrom, type DevframeMessageEntryInput, type DevframeMessageFilePosition, type DevframeMessageHandle, type DevframeMessageLevel, type DevframeMessageShortcutInput, type DevframeMessagesClient, type DevframeMessagesHost, type DevframeMessagesLevelShortcuts, type DevframeMessagesListDelta, type DevframeNodeRpcSession, type DevframePtyExecuteOptions, type DevframePtyTerminalSession, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeServerCommandEntry, type DevframeServerCommandInput, type DevframeTerminalSession, type DevframeTerminalSessionBase, type DevframeTerminalStatus, type DevframeTerminalsHost, type DevframeViewAction, type DevframeViewBuiltin, type DevframeViewCustomRender, type DevframeViewGroup, type DevframeViewHost, type DevframeViewIframe, type DevframeViewJsonRender, type DevframeViewLauncher, type DevframeViewLauncherStatus, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, type JsonRenderElement, type JsonRenderSpec, type JsonRenderer, type PartialWithoutId, type RemoteConnectionInfo, type RemoteDockOptions, type RpcBroadcastOptions, type RpcDefinitionsFilter, type RpcDefinitionsToFunctions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type Thenable, defineCommand, defineDockEntry, defineHubRpcFunction, defineJsonRenderSpec };
15
+ export { type ClientScriptEntry, type ConnectionMeta, type CreateHubContextOptions, type DevframeCapabilities, type DevframeChildProcessExecuteOptions, type DevframeChildProcessOutput, type DevframeChildProcessResult, type DevframeChildProcessTerminalSession, type DevframeClientCommand, type DevframeCommandBase, type DevframeCommandEntry, type DevframeCommandHandle, type DevframeCommandKeybinding, type DevframeCommandShortcutOverrides, type DevframeCommandsHost, type DevframeCommandsHostEvents, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDockActivation, type DevframeDockEntriesGrouped, type DevframeDockEntry, type DevframeDockEntryBase, type DevframeDockEntryCategory, type DevframeDockEntryIcon, type DevframeDockUserEntry, type DevframeDocksActiveState, type DevframeDocksHost, type DevframeDocksUserSettings, type DevframeHost, type DevframeHubContext, type DevframeMessageElementPosition, type DevframeMessageEntry, type DevframeMessageEntryFrom, type DevframeMessageEntryInput, type DevframeMessageFilePosition, type DevframeMessageHandle, type DevframeMessageLevel, type DevframeMessageShortcutInput, type DevframeMessagesClient, type DevframeMessagesHost, type DevframeMessagesLevelShortcuts, type DevframeMessagesListDelta, type DevframeNodeRpcSession, type DevframePtyExecuteOptions, type DevframePtyTerminalSession, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeServerCommandEntry, type DevframeServerCommandInput, type DevframeTerminalSession, type DevframeTerminalSessionBase, type DevframeTerminalStatus, type DevframeTerminalsHost, type DevframeViewAction, type DevframeViewBuiltin, type DevframeViewCustomRender, type DevframeViewGroup, type DevframeViewHost, type DevframeViewIframe, type DevframeViewJsonRender, type DevframeViewLauncher, type DevframeViewLauncherStatus, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, type JsonRenderElement, type JsonRenderSpec, type JsonRenderer, type PartialWithoutId, type RemoteConnectionInfo, type RemoteDockOptions, type RpcBroadcastOptions, type RpcDefinitionsFilter, type RpcDefinitionsToFunctions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type Thenable, defineCommand, defineDockEntry, defineHubRpcFunction, defineJsonRenderSpec };
@@ -1,5 +1,5 @@
1
- import { C as DevframeMessagesHost$1, T as DevframeMessagesListDelta, _ as DevframeMessageEntryInput, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, h as DevframeMessageEntry, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, n as DevframeHubContext, p as DevframeTerminalsHost$1, r as createHubContext, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, x as DevframeMessageShortcutInput, y as DevframeMessageHandle } from "../context-CANUHYpc.mjs";
2
- import { a as DevframeCommandHandle, c as DevframeCommandsHost$1, d as DevframeServerCommandInput, f as ClientScriptEntry, m as DevframeDockEntry, t as DevframeDocksUserSettings, u as DevframeServerCommandEntry, v as DevframeDockUserEntry, w as DevframeViewIframe, y as DevframeDocksHost$1 } from "../settings-0U1BorGE.mjs";
1
+ import { C as DevframeMessagesHost$1, T as DevframeMessagesListDelta, _ as DevframeMessageEntryInput, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, h as DevframeMessageEntry, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, n as DevframeHubContext, p as DevframeTerminalsHost$1, r as createHubContext, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, x as DevframeMessageShortcutInput, y as DevframeMessageHandle } from "../context-C36xWGWi.mjs";
2
+ import { E as DevframeViewIframe, a as DevframeCommandHandle, c as DevframeCommandsHost$1, d as DevframeServerCommandInput, f as ClientScriptEntry, h as DevframeDockEntry, t as DevframeDocksUserSettings, u as DevframeServerCommandEntry, x as DevframeDocksHost$1, y as DevframeDockUserEntry } from "../settings-BY2Ec77-.mjs";
3
3
  import { RpcFunctionDefinitionAny } from "devframe/rpc";
4
4
  import { DevframeDefinition } from "devframe/types";
5
5
  import { SharedState } from "devframe/utils/shared-state";
@@ -34,6 +34,7 @@ declare class DevframeDocksHost implements DevframeDocksHost$1 {
34
34
  update: (patch: Partial<T>) => void;
35
35
  };
36
36
  update(view: DevframeDockUserEntry): void;
37
+ activate(dockId: string, params?: Record<string, unknown>): void;
37
38
  private validateGroupMembership;
38
39
  private prepareRemoteRegistration;
39
40
  }
@@ -260,6 +261,48 @@ declare const hubTerminalsResize: {
260
261
  __cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[id: string, cols: number, rows: number], Promise<void>>>> | undefined;
261
262
  __promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[id: string, cols: number, rows: number], Promise<void>>> | undefined;
262
263
  };
264
+ /**
265
+ * `hub:docks:activate` — Ask the active viewer to switch its focused dock to
266
+ * `dockId`, optionally carrying `params` for the target dock to interpret
267
+ * (e.g. `{ sessionId }` for the terminals dock to focus a session).
268
+ *
269
+ * Any connected client may call it, which is the point: a mounted devframe
270
+ * running in its own iframe (on its own RPC client) can steer the host shell's
271
+ * dock selection — client-local state it otherwise can't reach. The hub
272
+ * broadcasts the request live to connected clients (the host shell switches)
273
+ * and mirrors it into the `devframe:docks:active` shared state (a dock that
274
+ * mounts in response still converges on it).
275
+ */
276
+ declare const hubDocksActivate: {
277
+ name: "hub:docks:activate";
278
+ type?: "action" | undefined;
279
+ cacheable?: boolean;
280
+ args?: undefined;
281
+ returns?: undefined;
282
+ jsonSerializable?: boolean;
283
+ agent?: import("devframe").RpcFunctionAgentOptions;
284
+ setup?: ((context: DevframeHubContext) => import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[input: {
285
+ dockId: string;
286
+ params?: Record<string, unknown>;
287
+ }], Promise<void>>>) | undefined;
288
+ handler?: ((input: {
289
+ dockId: string;
290
+ params?: Record<string, unknown>;
291
+ }) => Promise<void>) | undefined;
292
+ dump?: import("devframe/rpc").RpcDump<[input: {
293
+ dockId: string;
294
+ params?: Record<string, unknown>;
295
+ }], Promise<void>, DevframeHubContext> | undefined;
296
+ snapshot?: boolean;
297
+ __cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[input: {
298
+ dockId: string;
299
+ params?: Record<string, unknown>;
300
+ }], Promise<void>>>> | undefined;
301
+ __promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[input: {
302
+ dockId: string;
303
+ params?: Record<string, unknown>;
304
+ }], Promise<void>>> | undefined;
305
+ };
263
306
  /**
264
307
  * Framework-neutral RPC declarations auto-registered by
265
308
  * {@link createHubContext}. Provide additional RPCs by passing your own
@@ -278,4 +321,4 @@ declare const builtinHubRpcDeclarations: readonly RpcFunctionDefinitionAny[];
278
321
  */
279
322
  declare function createSimpleClientScript(fn: string | ((ctx: any) => void)): ClientScriptEntry;
280
323
  //#endregion
281
- export { CreateHubContextOptions, DevframeCommandsHost, DevframeDocksHost, DevframeHubContext, DevframeMessagesHost, DevframeTerminalsHost, MountDevframeOptions, builtinHubRpcDeclarations, createHubContext, createSimpleClientScript, hubCommandsExecute, hubMessagesAdd, hubMessagesClear, hubMessagesRemove, hubMessagesUpdate, hubTerminalsResize, hubTerminalsWrite, mountDevframe };
324
+ export { CreateHubContextOptions, DevframeCommandsHost, DevframeDocksHost, DevframeHubContext, DevframeMessagesHost, DevframeTerminalsHost, MountDevframeOptions, builtinHubRpcDeclarations, createHubContext, createSimpleClientScript, hubCommandsExecute, hubDocksActivate, hubMessagesAdd, hubMessagesClear, hubMessagesRemove, hubMessagesUpdate, hubTerminalsResize, hubTerminalsWrite, mountDevframe };
@@ -57,6 +57,10 @@ const diagnostics = defineDiagnostics({
57
57
  why: (p) => `The host cannot serve the RPC connection meta for devframe "${p.name}" (id "${p.id}") at "${p.base}" — its \`DevframeHost\` does not implement \`mountConnectionMeta\`.`,
58
58
  fix: "Implement `mountConnectionMeta(base)` on your DevframeHost so it serves `__connection.json` at each mounted base. Without it, the devframe SPA connects only when it shares an origin with the hub UI (same-origin window inheritance); cross-origin, sandboxed, or directly-opened iframes stay disconnected. Static-snapshot hosts that bake the meta into the served files can implement it as a no-op to acknowledge this intentionally."
59
59
  },
60
+ DF8107: {
61
+ why: (p) => `Dock activation requested for unknown dock id "${p.id}"`,
62
+ fix: "Pass a `dockId` that matches a registered dock entry. The activation is still broadcast, but no viewer will switch to it. Ids are case-sensitive — check for typos, and ensure the target dock is registered before activating it."
63
+ },
60
64
  DF8200: { why: (p) => `Terminal session with id "${p.id}" already registered` },
61
65
  DF8201: { why: (p) => `Terminal session with id "${p.id}" not registered` },
62
66
  DF8202: {
@@ -269,6 +273,13 @@ var DevframeDocksHost = class {
269
273
  this.views.set(view.id, view);
270
274
  this.events.emit("dock:entry:updated", view);
271
275
  }
276
+ activate(dockId, params) {
277
+ if (!this.views.has(dockId)) diagnostics.DF8107({ id: dockId });
278
+ this.events.emit("dock:activate", {
279
+ dockId,
280
+ params
281
+ });
282
+ }
272
283
  validateGroupMembership(view) {
273
284
  if (view.groupId === void 0) return;
274
285
  if (view.groupId === view.id) throw diagnostics.DF8103({ id: view.id });
@@ -878,6 +889,25 @@ const hubTerminalsResize = defineHubRpcFunction({
878
889
  } })
879
890
  });
880
891
  /**
892
+ * `hub:docks:activate` — Ask the active viewer to switch its focused dock to
893
+ * `dockId`, optionally carrying `params` for the target dock to interpret
894
+ * (e.g. `{ sessionId }` for the terminals dock to focus a session).
895
+ *
896
+ * Any connected client may call it, which is the point: a mounted devframe
897
+ * running in its own iframe (on its own RPC client) can steer the host shell's
898
+ * dock selection — client-local state it otherwise can't reach. The hub
899
+ * broadcasts the request live to connected clients (the host shell switches)
900
+ * and mirrors it into the `devframe:docks:active` shared state (a dock that
901
+ * mounts in response still converges on it).
902
+ */
903
+ const hubDocksActivate = defineHubRpcFunction({
904
+ name: "hub:docks:activate",
905
+ type: "action",
906
+ setup: (context) => ({ async handler(input) {
907
+ context.docks.activate(input.dockId, input.params);
908
+ } })
909
+ });
910
+ /**
881
911
  * Framework-neutral RPC declarations auto-registered by
882
912
  * {@link createHubContext}. Provide additional RPCs by passing your own
883
913
  * array via `CreateHubContextOptions.builtinRpcDeclarations`; the hub's
@@ -885,6 +915,7 @@ const hubTerminalsResize = defineHubRpcFunction({
885
915
  */
886
916
  const builtinHubRpcDeclarations = [
887
917
  hubCommandsExecute,
918
+ hubDocksActivate,
888
919
  hubMessagesAdd,
889
920
  hubMessagesUpdate,
890
921
  hubMessagesRemove,
@@ -940,6 +971,16 @@ async function createHubContext(options) {
940
971
  }, debounceMs);
941
972
  docks.events.on("dock:entry:updated", refreshDocks);
942
973
  docksSharedState.mutate(() => docks.values());
974
+ const activeDockSharedState = await context.rpc.sharedState.get("devframe:docks:active", { initialValue: { activation: null } });
975
+ docks.events.on("dock:activate", (activation) => {
976
+ activeDockSharedState.mutate((state) => {
977
+ state.activation = activation;
978
+ });
979
+ context.rpc.broadcast({
980
+ method: "devframe:docks:activate",
981
+ args: [activation]
982
+ });
983
+ });
943
984
  const broadcastTerminals = debounce(() => {
944
985
  context.rpc.broadcast({
945
986
  method: "devframe:terminals:updated",
@@ -6492,4 +6533,4 @@ function createSimpleClientScript(fn) {
6492
6533
  };
6493
6534
  }
6494
6535
  //#endregion
6495
- export { DevframeCommandsHost, DevframeDocksHost, DevframeMessagesHost, DevframeTerminalsHost, builtinHubRpcDeclarations, createHubContext, createSimpleClientScript, hubCommandsExecute, hubMessagesAdd, hubMessagesClear, hubMessagesRemove, hubMessagesUpdate, hubTerminalsResize, hubTerminalsWrite, mountDevframe };
6536
+ export { DevframeCommandsHost, DevframeDocksHost, DevframeMessagesHost, DevframeTerminalsHost, builtinHubRpcDeclarations, createHubContext, createSimpleClientScript, hubCommandsExecute, hubDocksActivate, hubMessagesAdd, hubMessagesClear, hubMessagesRemove, hubMessagesUpdate, hubTerminalsResize, hubTerminalsWrite, mountDevframe };
@@ -33,12 +33,45 @@ interface DevframeDocksHost {
33
33
  readonly views: Map<string, DevframeDockUserEntry>;
34
34
  readonly events: EventEmitter<{
35
35
  'dock:entry:updated': (entry: DevframeDockUserEntry) => void;
36
+ 'dock:activate': (activation: DevframeDockActivation) => void;
36
37
  }>;
37
38
  register: <T extends DevframeDockUserEntry>(entry: T, force?: boolean) => {
38
39
  update: (patch: Partial<T>) => void;
39
40
  };
40
41
  update: (entry: DevframeDockUserEntry) => void;
41
42
  values: () => DevframeDockEntry[];
43
+ /**
44
+ * Request the active viewer switch its focused dock to `dockId`, optionally
45
+ * carrying `params` for the target dock to interpret (e.g. a terminals
46
+ * session id).
47
+ *
48
+ * Any connected client may drive this via the `hub:docks:activate` RPC — a
49
+ * mounted devframe running in its own iframe can steer the host shell's dock
50
+ * selection, which is otherwise client-local. The request is delivered live
51
+ * to connected clients (broadcast) and mirrored into the
52
+ * `devframe:docks:active` shared state so a dock that mounts in response
53
+ * still sees it. Activation is best-effort: unknown dock ids degrade
54
+ * gracefully.
55
+ */
56
+ activate: (dockId: string, params?: Record<string, unknown>) => void;
57
+ }
58
+ /**
59
+ * A request to switch the active dock. `params` is an opaque, serializable
60
+ * bag the target dock interprets — the terminals dock reads `params.sessionId`
61
+ * to focus a specific session.
62
+ */
63
+ interface DevframeDockActivation {
64
+ dockId: string;
65
+ params?: Record<string, unknown>;
66
+ }
67
+ /**
68
+ * Shape of the `devframe:docks:active` shared-state slot — the most recent
69
+ * {@link DevframeDockActivation}, or `null` before any activation. Mirrored
70
+ * so a dock that mounts in response to an activation can still converge on the
71
+ * request instead of missing the live broadcast.
72
+ */
73
+ interface DevframeDocksActiveState {
74
+ activation: DevframeDockActivation | null;
42
75
  }
43
76
  type DevframeDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default' | '~builtin' | (string & {});
44
77
  type DevframeDockEntryIcon = string | {
@@ -352,4 +385,4 @@ interface DevframeDocksUserSettings {
352
385
  commandShortcuts: DevframeCommandShortcutOverrides;
353
386
  }
354
387
  //#endregion
355
- export { JsonRenderElement as A, DevframeViewGroup as C, DevframeViewLauncherStatus as D, DevframeViewLauncher as E, JsonRenderer as M, RemoteConnectionInfo as O, DevframeViewCustomRender as S, DevframeViewJsonRender as T, DevframeDockEntryIcon as _, DevframeCommandHandle as a, DevframeViewAction as b, DevframeCommandsHost as c, DevframeServerCommandInput as d, ClientScriptEntry as f, DevframeDockEntryCategory as g, DevframeDockEntryBase as h, DevframeCommandEntry as i, JsonRenderSpec as j, RemoteDockOptions as k, DevframeCommandsHostEvents as l, DevframeDockEntry as m, DevframeClientCommand as n, DevframeCommandKeybinding as o, DevframeDockEntriesGrouped as p, DevframeCommandBase as r, DevframeCommandShortcutOverrides as s, DevframeDocksUserSettings as t, DevframeServerCommandEntry as u, DevframeDockUserEntry as v, DevframeViewIframe as w, DevframeViewBuiltin as x, DevframeDocksHost as y };
388
+ export { RemoteConnectionInfo as A, DevframeViewBuiltin as C, DevframeViewJsonRender as D, DevframeViewIframe as E, JsonRenderElement as M, JsonRenderSpec as N, DevframeViewLauncher as O, JsonRenderer as P, DevframeViewAction as S, DevframeViewGroup as T, DevframeDockEntryCategory as _, DevframeCommandHandle as a, DevframeDocksActiveState as b, DevframeCommandsHost as c, DevframeServerCommandInput as d, ClientScriptEntry as f, DevframeDockEntryBase as g, DevframeDockEntry as h, DevframeCommandEntry as i, RemoteDockOptions as j, DevframeViewLauncherStatus as k, DevframeCommandsHostEvents as l, DevframeDockEntriesGrouped as m, DevframeClientCommand as n, DevframeCommandKeybinding as o, DevframeDockActivation as p, DevframeCommandBase as r, DevframeCommandShortcutOverrides as s, DevframeDocksUserSettings as t, DevframeServerCommandEntry as u, DevframeDockEntryIcon as v, DevframeViewCustomRender as w, DevframeDocksHost as x, DevframeDockUserEntry as y };
@@ -1,4 +1,4 @@
1
- import { C as DevframeMessagesHost, S as DevframeMessagesClient, T as DevframeMessagesListDelta, _ as DevframeMessageEntryInput, a as DevframeChildProcessOutput, b as DevframeMessageLevel, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, f as DevframeTerminalStatus, g as DevframeMessageEntryFrom, h as DevframeMessageEntry, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, m as DevframeMessageElementPosition, n as DevframeHubContext, o as DevframeChildProcessResult, p as DevframeTerminalsHost, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, v as DevframeMessageFilePosition, w as DevframeMessagesLevelShortcuts, x as DevframeMessageShortcutInput, y as DevframeMessageHandle } from "../context-CANUHYpc.mjs";
2
- import { A as JsonRenderElement, C as DevframeViewGroup, D as DevframeViewLauncherStatus, E as DevframeViewLauncher, M as JsonRenderer, O as RemoteConnectionInfo, S as DevframeViewCustomRender, T as DevframeViewJsonRender, _ as DevframeDockEntryIcon, a as DevframeCommandHandle, b as DevframeViewAction, c as DevframeCommandsHost, d as DevframeServerCommandInput, f as ClientScriptEntry, g as DevframeDockEntryCategory, h as DevframeDockEntryBase, i as DevframeCommandEntry, j as JsonRenderSpec, k as RemoteDockOptions, l as DevframeCommandsHostEvents, m as DevframeDockEntry, n as DevframeClientCommand, o as DevframeCommandKeybinding, p as DevframeDockEntriesGrouped, r as DevframeCommandBase, s as DevframeCommandShortcutOverrides, t as DevframeDocksUserSettings, u as DevframeServerCommandEntry, v as DevframeDockUserEntry, w as DevframeViewIframe, x as DevframeViewBuiltin, y as DevframeDocksHost } from "../settings-0U1BorGE.mjs";
3
- import { C as RpcStreamingChannel, E as Thenable, S as RpcSharedStateHost, T as RpcStreamingHost, _ as RpcBroadcastOptions, a as DevframeDiagnosticsLogger, b as RpcFunctionsHost, c as DevframeRpcClientFunctions, d as DevframeViewHost, f as EntriesToObject, g as PartialWithoutId, h as EventsMap, i as DevframeDiagnosticsHost, l as DevframeRpcServerFunctions, m as EventUnsubscribe, n as DevframeCapabilities, o as DevframeHost, p as EventEmitter, r as DevframeDiagnosticsDefinition, s as DevframeNodeRpcSession, t as ConnectionMeta, u as DevframeRpcSharedStates, v as RpcDefinitionsFilter, w as RpcStreamingChannelOptions, x as RpcSharedStateGetOptions, y as RpcDefinitionsToFunctions } from "../index-DmNIgq0_.mjs";
4
- export { ClientScriptEntry, type ConnectionMeta, type CreateHubContextOptions, type DevframeCapabilities, DevframeChildProcessExecuteOptions, DevframeChildProcessOutput, DevframeChildProcessResult, DevframeChildProcessTerminalSession, DevframeClientCommand, DevframeCommandBase, DevframeCommandEntry, DevframeCommandHandle, DevframeCommandKeybinding, DevframeCommandShortcutOverrides, DevframeCommandsHost, DevframeCommandsHostEvents, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, DevframeDockEntriesGrouped, DevframeDockEntry, DevframeDockEntryBase, DevframeDockEntryCategory, DevframeDockEntryIcon, DevframeDockUserEntry, DevframeDocksHost, DevframeDocksUserSettings, type DevframeHost, type DevframeHubContext, DevframeMessageElementPosition, DevframeMessageEntry, DevframeMessageEntryFrom, DevframeMessageEntryInput, DevframeMessageFilePosition, DevframeMessageHandle, DevframeMessageLevel, DevframeMessageShortcutInput, DevframeMessagesClient, DevframeMessagesHost, DevframeMessagesLevelShortcuts, DevframeMessagesListDelta, type DevframeNodeRpcSession, DevframePtyExecuteOptions, DevframePtyTerminalSession, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, DevframeServerCommandEntry, DevframeServerCommandInput, DevframeTerminalSession, DevframeTerminalSessionBase, DevframeTerminalStatus, DevframeTerminalsHost, DevframeViewAction, DevframeViewBuiltin, DevframeViewCustomRender, DevframeViewGroup, type DevframeViewHost, DevframeViewIframe, DevframeViewJsonRender, DevframeViewLauncher, DevframeViewLauncherStatus, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, JsonRenderElement, JsonRenderSpec, JsonRenderer, type PartialWithoutId, RemoteConnectionInfo, RemoteDockOptions, type RpcBroadcastOptions, type RpcDefinitionsFilter, type RpcDefinitionsToFunctions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type Thenable };
1
+ import { C as DevframeMessagesHost, S as DevframeMessagesClient, T as DevframeMessagesListDelta, _ as DevframeMessageEntryInput, a as DevframeChildProcessOutput, b as DevframeMessageLevel, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, f as DevframeTerminalStatus, g as DevframeMessageEntryFrom, h as DevframeMessageEntry, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, m as DevframeMessageElementPosition, n as DevframeHubContext, o as DevframeChildProcessResult, p as DevframeTerminalsHost, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, v as DevframeMessageFilePosition, w as DevframeMessagesLevelShortcuts, x as DevframeMessageShortcutInput, y as DevframeMessageHandle } from "../context-C36xWGWi.mjs";
2
+ import { A as RemoteConnectionInfo, C as DevframeViewBuiltin, D as DevframeViewJsonRender, E as DevframeViewIframe, M as JsonRenderElement, N as JsonRenderSpec, O as DevframeViewLauncher, P as JsonRenderer, S as DevframeViewAction, T as DevframeViewGroup, _ as DevframeDockEntryCategory, a as DevframeCommandHandle, b as DevframeDocksActiveState, c as DevframeCommandsHost, d as DevframeServerCommandInput, f as ClientScriptEntry, g as DevframeDockEntryBase, h as DevframeDockEntry, i as DevframeCommandEntry, j as RemoteDockOptions, k as DevframeViewLauncherStatus, l as DevframeCommandsHostEvents, m as DevframeDockEntriesGrouped, n as DevframeClientCommand, o as DevframeCommandKeybinding, p as DevframeDockActivation, r as DevframeCommandBase, s as DevframeCommandShortcutOverrides, t as DevframeDocksUserSettings, u as DevframeServerCommandEntry, v as DevframeDockEntryIcon, w as DevframeViewCustomRender, x as DevframeDocksHost, y as DevframeDockUserEntry } from "../settings-BY2Ec77-.mjs";
3
+ import { C as RpcStreamingChannel, E as Thenable, S as RpcSharedStateHost, T as RpcStreamingHost, _ as RpcBroadcastOptions, a as DevframeDiagnosticsLogger, b as RpcFunctionsHost, c as DevframeRpcClientFunctions, d as DevframeViewHost, f as EntriesToObject, g as PartialWithoutId, h as EventsMap, i as DevframeDiagnosticsHost, l as DevframeRpcServerFunctions, m as EventUnsubscribe, n as DevframeCapabilities, o as DevframeHost, p as EventEmitter, r as DevframeDiagnosticsDefinition, s as DevframeNodeRpcSession, t as ConnectionMeta, u as DevframeRpcSharedStates, v as RpcDefinitionsFilter, w as RpcStreamingChannelOptions, x as RpcSharedStateGetOptions, y as RpcDefinitionsToFunctions } from "../index-DcPSmxA5.mjs";
4
+ export { ClientScriptEntry, type ConnectionMeta, type CreateHubContextOptions, type DevframeCapabilities, DevframeChildProcessExecuteOptions, DevframeChildProcessOutput, DevframeChildProcessResult, DevframeChildProcessTerminalSession, DevframeClientCommand, DevframeCommandBase, DevframeCommandEntry, DevframeCommandHandle, DevframeCommandKeybinding, DevframeCommandShortcutOverrides, DevframeCommandsHost, DevframeCommandsHostEvents, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, DevframeDockActivation, DevframeDockEntriesGrouped, DevframeDockEntry, DevframeDockEntryBase, DevframeDockEntryCategory, DevframeDockEntryIcon, DevframeDockUserEntry, DevframeDocksActiveState, DevframeDocksHost, DevframeDocksUserSettings, type DevframeHost, type DevframeHubContext, DevframeMessageElementPosition, DevframeMessageEntry, DevframeMessageEntryFrom, DevframeMessageEntryInput, DevframeMessageFilePosition, DevframeMessageHandle, DevframeMessageLevel, DevframeMessageShortcutInput, DevframeMessagesClient, DevframeMessagesHost, DevframeMessagesLevelShortcuts, DevframeMessagesListDelta, type DevframeNodeRpcSession, DevframePtyExecuteOptions, DevframePtyTerminalSession, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, DevframeServerCommandEntry, DevframeServerCommandInput, DevframeTerminalSession, DevframeTerminalSessionBase, DevframeTerminalStatus, DevframeTerminalsHost, DevframeViewAction, DevframeViewBuiltin, DevframeViewCustomRender, DevframeViewGroup, type DevframeViewHost, DevframeViewIframe, DevframeViewJsonRender, DevframeViewLauncher, DevframeViewLauncherStatus, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, JsonRenderElement, JsonRenderSpec, JsonRenderer, type PartialWithoutId, RemoteConnectionInfo, RemoteDockOptions, type RpcBroadcastOptions, type RpcDefinitionsFilter, type RpcDefinitionsToFunctions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type Thenable };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devframes/hub",
3
3
  "type": "module",
4
- "version": "0.7.2",
4
+ "version": "0.7.3",
5
5
  "description": "Framework-neutral hub layer for devframe — docks, terminals, messages, commands.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "dist"
34
34
  ],
35
35
  "peerDependencies": {
36
- "devframe": "0.7.2"
36
+ "devframe": "0.7.3"
37
37
  },
38
38
  "dependencies": {
39
39
  "birpc": "^4.0.0",
@@ -48,7 +48,7 @@
48
48
  "@types/node": "^26.1.1",
49
49
  "mlly": "^1.8.2",
50
50
  "tsdown": "^0.22.7",
51
- "devframe": "0.7.2"
51
+ "devframe": "0.7.3"
52
52
  },
53
53
  "scripts": {
54
54
  "build": "tsdown",