@devframes/hub 0.5.1 → 0.5.2

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.
@@ -0,0 +1,399 @@
1
+ import { c as DevframeCommandsHost } from "./settings-Bp5Ax6Os.mjs";
2
+ import { CreateHostContextOptions } from "devframe/node";
3
+ import { ConnectionMeta, DevframeHost, DevframeNodeContext, EventEmitter } from "devframe/types";
4
+ import { ChildProcess } from "node:child_process";
5
+
6
+ //#region src/types/messages.d.ts
7
+ type DevframeMessageLevel = 'info' | 'warn' | 'error' | 'success' | 'debug';
8
+ type DevframeMessageEntryFrom = 'server' | 'browser';
9
+ interface DevframeMessageElementPosition {
10
+ /** CSS selector for the element */
11
+ selector?: string;
12
+ /** Bounding box of the element */
13
+ boundingBox?: {
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ };
19
+ /** Human-readable description of the element */
20
+ description?: string;
21
+ }
22
+ interface DevframeMessageFilePosition {
23
+ /** Absolute or relative file path */
24
+ file: string;
25
+ /** Line number (1-based) */
26
+ line?: number;
27
+ /** Column number (1-based) */
28
+ column?: number;
29
+ }
30
+ interface DevframeMessageEntry {
31
+ /**
32
+ * Unique identifier for this message entry (auto-generated if not provided)
33
+ */
34
+ id: string;
35
+ /**
36
+ * Short title or summary of the message
37
+ */
38
+ message: string;
39
+ /**
40
+ * Optional detailed description or explanation
41
+ */
42
+ description?: string;
43
+ /**
44
+ * Severity level, determines color and icon
45
+ */
46
+ level: DevframeMessageLevel;
47
+ /**
48
+ * Optional stack trace string
49
+ */
50
+ stacktrace?: string;
51
+ /**
52
+ * Optional DOM element position info (e.g., for a11y issues)
53
+ */
54
+ elementPosition?: DevframeMessageElementPosition;
55
+ /**
56
+ * Optional source file position info (e.g., for lint errors)
57
+ */
58
+ filePosition?: DevframeMessageFilePosition;
59
+ /**
60
+ * Whether this message should also appear as a toast notification
61
+ */
62
+ notify?: boolean;
63
+ /**
64
+ * Origin of the message entry, automatically set by the context
65
+ */
66
+ from: DevframeMessageEntryFrom;
67
+ /**
68
+ * Grouping category (e.g., 'a11y', 'lint', 'runtime', 'test')
69
+ */
70
+ category?: string;
71
+ /**
72
+ * Optional tags/labels for filtering
73
+ */
74
+ labels?: string[];
75
+ /**
76
+ * Time in ms to auto-dismiss the toast notification (client-side)
77
+ */
78
+ autoDismiss?: number;
79
+ /**
80
+ * Time in ms to auto-delete this message entry (server-side)
81
+ */
82
+ autoDelete?: number;
83
+ /**
84
+ * Timestamp when the message was created (auto-generated if not provided)
85
+ */
86
+ timestamp: number;
87
+ /**
88
+ * Status of the message entry (e.g., 'loading' while an operation is in progress).
89
+ * Defaults to 'idle' when not specified.
90
+ */
91
+ status?: 'loading' | 'idle';
92
+ }
93
+ /**
94
+ * Input type for creating a message entry.
95
+ * `id`, `timestamp`, and `from` are auto-filled by the host.
96
+ */
97
+ type DevframeMessageEntryInput = Omit<DevframeMessageEntry, 'id' | 'timestamp' | 'from'> & {
98
+ id?: string;
99
+ timestamp?: number;
100
+ };
101
+ interface DevframeMessageHandle {
102
+ /** The underlying message entry data */
103
+ readonly entry: DevframeMessageEntry;
104
+ /** Shortcut to entry.id */
105
+ readonly id: string;
106
+ /** Partial update of this message entry */
107
+ update: (patch: Partial<DevframeMessageEntryInput>) => Promise<DevframeMessageEntry | undefined>;
108
+ /** Remove this message entry */
109
+ dismiss: () => Promise<void>;
110
+ }
111
+ interface DevframeMessagesClient {
112
+ /**
113
+ * Add a message entry. Returns a Promise resolving to a handle for subsequent updates/dismissal.
114
+ * Can be used without `await` for fire-and-forget usage.
115
+ */
116
+ add: (input: DevframeMessageEntryInput) => Promise<DevframeMessageHandle>;
117
+ /** Remove a message entry by id */
118
+ remove: (id: string) => Promise<void>;
119
+ /** Clear all message entries */
120
+ clear: () => Promise<void>;
121
+ }
122
+ interface DevframeMessagesHost {
123
+ readonly entries: Map<string, DevframeMessageEntry>;
124
+ readonly events: EventEmitter<{
125
+ 'message:added': (entry: DevframeMessageEntry) => void;
126
+ 'message:updated': (entry: DevframeMessageEntry) => void;
127
+ 'message:removed': (id: string) => void;
128
+ 'message:cleared': () => void;
129
+ }>;
130
+ /**
131
+ * Add a new message entry. If an entry with the same `id` already exists, it will be updated instead.
132
+ * Returns a handle for subsequent updates/dismissal. Can be used without `await` for fire-and-forget.
133
+ */
134
+ add: (entry: DevframeMessageEntryInput) => Promise<DevframeMessageHandle>;
135
+ /**
136
+ * Update an existing message entry by id (partial update)
137
+ */
138
+ update: (id: string, patch: Partial<DevframeMessageEntryInput>) => Promise<DevframeMessageEntry | undefined>;
139
+ /**
140
+ * Remove a message entry by id
141
+ */
142
+ remove: (id: string) => Promise<void>;
143
+ /**
144
+ * Clear all message entries
145
+ */
146
+ clear: () => Promise<void>;
147
+ }
148
+ //#endregion
149
+ //#region src/types/json-render.d.ts
150
+ interface JsonRenderElement {
151
+ type: string;
152
+ props?: Record<string, unknown>;
153
+ children?: string[];
154
+ /** json-render event bindings (e.g. `{ press: { action: "my:action" } }`) */
155
+ on?: Record<string, unknown>;
156
+ /** json-render visibility condition */
157
+ visible?: unknown;
158
+ /** json-render repeat binding */
159
+ repeat?: unknown;
160
+ /** Allow additional json-render element fields */
161
+ [key: string]: unknown;
162
+ }
163
+ interface JsonRenderSpec {
164
+ root: string;
165
+ elements: Record<string, JsonRenderElement>;
166
+ /** Initial client-side state model for $state/$bindState expressions */
167
+ state?: Record<string, unknown>;
168
+ }
169
+ interface JsonRenderer {
170
+ /** Replace the entire spec */
171
+ updateSpec: (spec: JsonRenderSpec) => void | Promise<void>;
172
+ /** Update json-render state values (shallow merge into spec.state) */
173
+ updateState: (state: Record<string, unknown>) => void | Promise<void>;
174
+ /** Internal: shared state key used by the client to subscribe */
175
+ readonly _stateKey: string;
176
+ }
177
+ //#endregion
178
+ //#region src/types/docks.d.ts
179
+ interface DevframeDocksHost {
180
+ readonly views: Map<string, DevframeDockUserEntry>;
181
+ readonly events: EventEmitter<{
182
+ 'dock:entry:updated': (entry: DevframeDockUserEntry) => void;
183
+ }>;
184
+ register: <T extends DevframeDockUserEntry>(entry: T, force?: boolean) => {
185
+ update: (patch: Partial<T>) => void;
186
+ };
187
+ update: (entry: DevframeDockUserEntry) => void;
188
+ values: (options?: {
189
+ includeBuiltin?: boolean;
190
+ }) => DevframeDockEntry[];
191
+ }
192
+ type DevframeDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default' | '~builtin' | (string & {});
193
+ type DevframeDockEntryIcon = string | {
194
+ light: string;
195
+ dark: string;
196
+ };
197
+ interface DevframeDockEntryBase {
198
+ id: string;
199
+ title: string;
200
+ icon: DevframeDockEntryIcon;
201
+ /**
202
+ * The default order of the entry in the dock.
203
+ * The higher the number the earlier it appears.
204
+ * @default 0
205
+ */
206
+ defaultOrder?: number;
207
+ /**
208
+ * The category of the entry
209
+ * @default 'default'
210
+ */
211
+ category?: DevframeDockEntryCategory;
212
+ /**
213
+ * Conditional visibility expression.
214
+ * When set, the dock entry is only visible when the expression evaluates to true.
215
+ * Uses the same syntax as command `when` clauses.
216
+ *
217
+ * Set to `'false'` to unconditionally hide the entry.
218
+ *
219
+ * @example 'clientType == embedded'
220
+ * @see {@link import('devframe/utils/when').evaluateWhen}
221
+ */
222
+ when?: string;
223
+ /**
224
+ * Badge text to display on the dock icon (e.g., unread count)
225
+ */
226
+ badge?: string;
227
+ }
228
+ interface ClientScriptEntry {
229
+ /**
230
+ * The filepath or module name to import from
231
+ */
232
+ importFrom: string;
233
+ /**
234
+ * The name to import the module as
235
+ *
236
+ * @default 'default'
237
+ */
238
+ importName?: string;
239
+ }
240
+ interface DevframeViewIframe extends DevframeDockEntryBase {
241
+ type: 'iframe';
242
+ url: string;
243
+ /**
244
+ * The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared.
245
+ *
246
+ * When not provided, it would be treated as a unique frame.
247
+ */
248
+ frameId?: string;
249
+ /**
250
+ * Optional client script to import into the iframe
251
+ */
252
+ clientScript?: ClientScriptEntry;
253
+ /**
254
+ * Enable remote-UI mode: the hub injects a connection descriptor
255
+ * (WS URL + pre-approved auth token) into the iframe URL so a hosted
256
+ * page can connect back via `connectRemoteDevframe()` from
257
+ * `@devframes/hub/client` — without needing to ship a dist with the
258
+ * plugin.
259
+ *
260
+ * Requires dev mode (no effect in build mode — no WS server exists).
261
+ * When enabled, the dock is automatically hidden in build mode unless
262
+ * the author provides an explicit `when` clause.
263
+ */
264
+ remote?: boolean | RemoteDockOptions;
265
+ }
266
+ interface RemoteDockOptions {
267
+ /**
268
+ * How to pass the connection descriptor to the hosted page.
269
+ *
270
+ * - `'fragment'` (default): appended as a URL fragment.
271
+ * Not sent in HTTP requests or Referer headers — safest for auth tokens.
272
+ * - `'query'`: appended as a URL query parameter. Use when your hosting
273
+ * platform rewrites fragments or your SPA router repurposes the fragment
274
+ * for navigation. The token will appear in server access logs and
275
+ * outbound Referer headers.
276
+ *
277
+ * @default 'fragment'
278
+ */
279
+ transport?: 'fragment' | 'query';
280
+ /**
281
+ * Reject WS handshakes whose `Origin` header doesn't match the dock URL
282
+ * origin. Turn off when the same hosted app is served from multiple
283
+ * origins (e.g. preview deploys).
284
+ *
285
+ * @default true
286
+ */
287
+ originLock?: boolean;
288
+ }
289
+ interface RemoteConnectionInfo extends ConnectionMeta {
290
+ backend: 'websocket';
291
+ websocket: string;
292
+ v: 1;
293
+ authToken: string;
294
+ origin: string;
295
+ }
296
+ type DevframeViewLauncherStatus = 'idle' | 'loading' | 'success' | 'error';
297
+ interface DevframeViewLauncher extends DevframeDockEntryBase {
298
+ type: 'launcher';
299
+ launcher: {
300
+ icon?: DevframeDockEntryIcon;
301
+ title: string;
302
+ status?: DevframeViewLauncherStatus;
303
+ error?: string;
304
+ description?: string;
305
+ buttonStart?: string;
306
+ buttonLoading?: string;
307
+ onLaunch: () => Promise<void>;
308
+ };
309
+ }
310
+ interface DevframeViewAction extends DevframeDockEntryBase {
311
+ type: 'action';
312
+ action: ClientScriptEntry;
313
+ }
314
+ interface DevframeViewCustomRender extends DevframeDockEntryBase {
315
+ type: 'custom-render';
316
+ renderer: ClientScriptEntry;
317
+ }
318
+ interface DevframeViewBuiltin extends DevframeDockEntryBase {
319
+ type: '~builtin';
320
+ id: '~terminals' | '~messages' | '~client-auth-notice' | '~settings' | '~popup';
321
+ }
322
+ interface DevframeViewJsonRender extends DevframeDockEntryBase {
323
+ type: 'json-render';
324
+ /** JsonRenderer handle created by ctx.createJsonRenderer() */
325
+ ui: JsonRenderer;
326
+ }
327
+ type DevframeDockUserEntry = DevframeViewIframe | DevframeViewAction | DevframeViewCustomRender | DevframeViewLauncher | DevframeViewJsonRender;
328
+ type DevframeDockEntry = DevframeDockUserEntry | DevframeViewBuiltin;
329
+ type DevframeDockEntriesGrouped = [category: string, entries: DevframeDockEntry[]][];
330
+ //#endregion
331
+ //#region src/types/terminals.d.ts
332
+ interface DevframeTerminalsHost {
333
+ readonly sessions: Map<string, DevframeTerminalSession>;
334
+ readonly events: EventEmitter<{
335
+ 'terminal:session:updated': (session: DevframeTerminalSession) => void;
336
+ }>;
337
+ register: (session: DevframeTerminalSession) => DevframeTerminalSession;
338
+ update: (session: DevframeTerminalSession) => void;
339
+ startChildProcess: (executeOptions: DevframeChildProcessExecuteOptions, terminal: Omit<DevframeTerminalSessionBase, 'status'>) => Promise<DevframeChildProcessTerminalSession>;
340
+ }
341
+ type DevframeTerminalStatus = 'running' | 'stopped' | 'error';
342
+ interface DevframeTerminalSessionBase {
343
+ id: string;
344
+ title: string;
345
+ description?: string;
346
+ status: DevframeTerminalStatus;
347
+ icon?: DevframeDockEntryIcon;
348
+ }
349
+ interface DevframeTerminalSession extends DevframeTerminalSessionBase {
350
+ buffer?: string[];
351
+ stream?: ReadableStream<string>;
352
+ }
353
+ interface DevframeChildProcessExecuteOptions {
354
+ command: string;
355
+ args: string[];
356
+ cwd?: string;
357
+ env?: Record<string, string>;
358
+ }
359
+ interface DevframeChildProcessTerminalSession extends DevframeTerminalSession {
360
+ type: 'child-process';
361
+ executeOptions: DevframeChildProcessExecuteOptions;
362
+ getChildProcess: () => ChildProcess | undefined;
363
+ terminate: () => Promise<void>;
364
+ restart: () => Promise<void>;
365
+ }
366
+ //#endregion
367
+ //#region src/node/context.d.ts
368
+ /**
369
+ * Hub-augmented node context — extends devframe's framework-neutral
370
+ * `DevframeNodeContext` with the hub-level subsystems (`docks`,
371
+ * `terminals`, `messages`, `commands`) and the `createJsonRenderer`
372
+ * factory.
373
+ *
374
+ * Framework kits further extend this with their own slots (e.g.
375
+ * `viteConfig`, `viteServer`). Host-specific capabilities (editor open,
376
+ * filesystem reveal, etc.) ship as kit-registered RPC functions rather
377
+ * than as part of this surface.
378
+ */
379
+ interface DevframeHubContext extends DevframeNodeContext {
380
+ readonly host: DevframeHost;
381
+ docks: DevframeDocksHost;
382
+ terminals: DevframeTerminalsHost;
383
+ messages: DevframeMessagesHost;
384
+ commands: DevframeCommandsHost;
385
+ /**
386
+ * Create a JsonRenderer handle for building json-render powered UIs.
387
+ */
388
+ createJsonRenderer: (spec: JsonRenderSpec) => JsonRenderer;
389
+ }
390
+ interface CreateHubContextOptions extends CreateHostContextOptions {}
391
+ /**
392
+ * Create a hub-level node context: wraps devframe's `createHostContext`,
393
+ * attaches the hub hosts (`docks`, `terminals`, `messages`, `commands`),
394
+ * registers the hub's built-in RPC commands, and wires the shared-state
395
+ * synchronization that powers a hub-aware client UI.
396
+ */
397
+ declare function createHubContext(options: CreateHubContextOptions): Promise<DevframeHubContext>;
398
+ //#endregion
399
+ export { DevframeMessageElementPosition as A, DevframeViewLauncher as C, JsonRenderElement as D, RemoteDockOptions as E, DevframeMessageHandle as F, DevframeMessageLevel as I, DevframeMessagesClient as L, DevframeMessageEntryFrom as M, DevframeMessageEntryInput as N, JsonRenderSpec as O, DevframeMessageFilePosition as P, DevframeMessagesHost as R, DevframeViewJsonRender as S, RemoteConnectionInfo as T, DevframeDocksHost as _, DevframeChildProcessTerminalSession as a, DevframeViewCustomRender as b, DevframeTerminalStatus as c, DevframeDockEntriesGrouped as d, DevframeDockEntry as f, DevframeDockUserEntry as g, DevframeDockEntryIcon as h, DevframeChildProcessExecuteOptions as i, DevframeMessageEntry as j, JsonRenderer as k, DevframeTerminalsHost as l, DevframeDockEntryCategory as m, DevframeHubContext as n, DevframeTerminalSession as o, DevframeDockEntryBase as p, createHubContext as r, DevframeTerminalSessionBase as s, CreateHubContextOptions as t, ClientScriptEntry as u, DevframeViewAction as v, DevframeViewLauncherStatus as w, DevframeViewIframe as x, DevframeViewBuiltin as y };
@@ -0,0 +1,14 @@
1
+ import { createDefineWrapperWithContext } from "devframe/rpc";
2
+ //#region src/define.ts
3
+ const defineHubRpcFunction = createDefineWrapperWithContext();
4
+ function defineCommand(command) {
5
+ return command;
6
+ }
7
+ function defineDockEntry(entry) {
8
+ return entry;
9
+ }
10
+ function defineJsonRenderSpec(spec) {
11
+ return spec;
12
+ }
13
+ //#endregion
14
+ export { defineJsonRenderSpec as i, defineDockEntry as n, defineHubRpcFunction as r, defineCommand as t };
@@ -0,0 +1,3 @@
1
+ import { RpcDefinitionsFilter, RpcDefinitionsToFunctions } from "devframe/rpc";
2
+ 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";
3
+ 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 };
@@ -0,0 +1,17 @@
1
+ import { A as DevframeMessageElementPosition, C as DevframeViewLauncher, D as JsonRenderElement, E as RemoteDockOptions, F as DevframeMessageHandle, I as DevframeMessageLevel, L as DevframeMessagesClient, M as DevframeMessageEntryFrom, N as DevframeMessageEntryInput, O as JsonRenderSpec, P as DevframeMessageFilePosition, R as DevframeMessagesHost, S as DevframeViewJsonRender, T as RemoteConnectionInfo, _ as DevframeDocksHost, a as DevframeChildProcessTerminalSession, b as DevframeViewCustomRender, c as DevframeTerminalStatus, d as DevframeDockEntriesGrouped, f as DevframeDockEntry, g as DevframeDockUserEntry, h as DevframeDockEntryIcon, i as DevframeChildProcessExecuteOptions, j as DevframeMessageEntry, k as JsonRenderer, l as DevframeTerminalsHost, m as DevframeDockEntryCategory, n as DevframeHubContext, o as DevframeTerminalSession, p as DevframeDockEntryBase, s as DevframeTerminalSessionBase, t as CreateHubContextOptions, u as ClientScriptEntry, v as DevframeViewAction, w as DevframeViewLauncherStatus, x as DevframeViewIframe, y as DevframeViewBuiltin } from "./context-BGXfnFEd.mjs";
2
+ import { a as DevframeCommandHandle, c as DevframeCommandsHost, d as DevframeServerCommandInput, i as DevframeCommandEntry, l as DevframeCommandsHostEvents, n as DevframeClientCommand, o as DevframeCommandKeybinding, r as DevframeCommandBase, s as DevframeCommandShortcutOverrides, t as DevframeDocksUserSettings, u as DevframeServerCommandEntry } from "./settings-Bp5Ax6Os.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-BWTfvdqa.mjs";
4
+ import * as _$devframe_rpc0 from "devframe/rpc";
5
+ import { WhenContext, WhenExpression } from "devframe/utils/when";
6
+
7
+ //#region src/define.d.ts
8
+ declare const defineHubRpcFunction: <NAME extends string, TYPE extends _$devframe_rpc0.RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends _$devframe_rpc0.RpcArgsSchema | undefined = undefined, const RS extends _$devframe_rpc0.RpcReturnSchema | undefined = undefined>(definition: _$devframe_rpc0.RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeHubContext>) => _$devframe_rpc0.RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeHubContext>;
9
+ declare function defineCommand<const W extends string = ''>(command: Omit<DevframeServerCommandInput, 'when'> & {
10
+ when?: WhenExpression<WhenContext, W>;
11
+ }): DevframeServerCommandInput;
12
+ declare function defineDockEntry<const T extends DevframeDockUserEntry, const W extends string = ''>(entry: Omit<T, 'when'> & {
13
+ when?: WhenExpression<WhenContext, W>;
14
+ }): T;
15
+ declare function defineJsonRenderSpec(spec: JsonRenderSpec): JsonRenderSpec;
16
+ //#endregion
17
+ export { ClientScriptEntry, ConnectionMeta, CreateHubContextOptions, DevframeCapabilities, DevframeChildProcessExecuteOptions, DevframeChildProcessTerminalSession, DevframeClientCommand, DevframeCommandBase, DevframeCommandEntry, DevframeCommandHandle, DevframeCommandKeybinding, DevframeCommandShortcutOverrides, DevframeCommandsHost, DevframeCommandsHostEvents, DevframeDiagnosticsDefinition, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockEntriesGrouped, DevframeDockEntry, DevframeDockEntryBase, DevframeDockEntryCategory, DevframeDockEntryIcon, DevframeDockUserEntry, DevframeDocksHost, DevframeDocksUserSettings, DevframeHost, DevframeHubContext, DevframeMessageElementPosition, DevframeMessageEntry, DevframeMessageEntryFrom, DevframeMessageEntryInput, DevframeMessageFilePosition, DevframeMessageHandle, DevframeMessageLevel, DevframeMessagesClient, DevframeMessagesHost, DevframeNodeRpcSession, DevframeRpcClientFunctions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeServerCommandEntry, DevframeServerCommandInput, DevframeTerminalSession, DevframeTerminalSessionBase, DevframeTerminalStatus, DevframeTerminalsHost, DevframeViewAction, DevframeViewBuiltin, DevframeViewCustomRender, DevframeViewHost, DevframeViewIframe, DevframeViewJsonRender, DevframeViewLauncher, DevframeViewLauncherStatus, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, JsonRenderElement, JsonRenderSpec, JsonRenderer, PartialWithoutId, RemoteConnectionInfo, RemoteDockOptions, RpcBroadcastOptions, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, Thenable, defineCommand, defineDockEntry, defineHubRpcFunction, defineJsonRenderSpec };
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { i as defineJsonRenderSpec, n as defineDockEntry, r as defineHubRpcFunction, t as defineCommand } from "./define-tHP6fX6A.mjs";
2
+ export { defineCommand, defineDockEntry, defineHubRpcFunction, defineJsonRenderSpec };
@@ -0,0 +1,164 @@
1
+ import { F as DevframeMessageHandle, N as DevframeMessageEntryInput, R as DevframeMessagesHost$1, _ as DevframeDocksHost$1, a as DevframeChildProcessTerminalSession, f as DevframeDockEntry, g as DevframeDockUserEntry, i as DevframeChildProcessExecuteOptions, j as DevframeMessageEntry, l as DevframeTerminalsHost$1, n as DevframeHubContext, o as DevframeTerminalSession, r as createHubContext, s as DevframeTerminalSessionBase, t as CreateHubContextOptions, u as ClientScriptEntry, x as DevframeViewIframe } from "../context-BGXfnFEd.mjs";
2
+ import { a as DevframeCommandHandle, c as DevframeCommandsHost$1, d as DevframeServerCommandInput, t as DevframeDocksUserSettings, u as DevframeServerCommandEntry } from "../settings-Bp5Ax6Os.mjs";
3
+ import * as _$devframe_rpc0 from "devframe/rpc";
4
+ import { RpcFunctionDefinitionAny } from "devframe/rpc";
5
+ import { DevframeDefinition } from "devframe/types";
6
+ import { SharedState } from "devframe/utils/shared-state";
7
+ import * as _$devframe from "devframe";
8
+
9
+ //#region src/node/host-commands.d.ts
10
+ declare class DevframeCommandsHost implements DevframeCommandsHost$1 {
11
+ readonly context: DevframeHubContext;
12
+ readonly commands: DevframeCommandsHost$1['commands'];
13
+ readonly events: DevframeCommandsHost$1['events'];
14
+ constructor(context: DevframeHubContext);
15
+ register(command: DevframeServerCommandInput): DevframeCommandHandle;
16
+ unregister(id: string): boolean;
17
+ execute(id: string, ...args: any[]): Promise<unknown>;
18
+ list(): DevframeServerCommandEntry[];
19
+ private findCommand;
20
+ private toSerializable;
21
+ }
22
+ //#endregion
23
+ //#region src/node/host-docks.d.ts
24
+ declare class DevframeDocksHost implements DevframeDocksHost$1 {
25
+ readonly context: DevframeHubContext;
26
+ readonly views: DevframeDocksHost$1['views'];
27
+ readonly events: DevframeDocksHost$1['events'];
28
+ userSettings: SharedState<DevframeDocksUserSettings>;
29
+ /** Dock-id → allocated remote token + resolved options. */
30
+ private readonly remoteDocks;
31
+ constructor(context: DevframeHubContext);
32
+ init(): Promise<void>;
33
+ values({
34
+ includeBuiltin
35
+ }?: {
36
+ includeBuiltin?: boolean;
37
+ }): DevframeDockEntry[];
38
+ private projectView;
39
+ private resolveDevServerOrigin;
40
+ register<T extends DevframeDockUserEntry>(view: T, force?: boolean): {
41
+ update: (patch: Partial<T>) => void;
42
+ };
43
+ update(view: DevframeDockUserEntry): void;
44
+ private prepareRemoteRegistration;
45
+ }
46
+ //#endregion
47
+ //#region src/node/host-messages.d.ts
48
+ declare class DevframeMessagesHost implements DevframeMessagesHost$1 {
49
+ readonly context: DevframeHubContext;
50
+ readonly entries: DevframeMessagesHost$1['entries'];
51
+ readonly events: DevframeMessagesHost$1['events'];
52
+ /** Tracks when each entry was last added or updated (monotonic) */
53
+ readonly lastModified: Map<string, number>;
54
+ /** Tracks recently removed entry IDs with their removal time */
55
+ readonly removals: Array<{
56
+ id: string;
57
+ time: number;
58
+ }>;
59
+ private _autoDeleteTimers;
60
+ private _clock;
61
+ private _tick;
62
+ constructor(context: DevframeHubContext);
63
+ add(input: DevframeMessageEntryInput): Promise<DevframeMessageHandle>;
64
+ update(id: string, patch: Partial<DevframeMessageEntryInput>): Promise<DevframeMessageEntry | undefined>;
65
+ remove(id: string): Promise<void>;
66
+ clear(): Promise<void>;
67
+ private _createHandle;
68
+ }
69
+ //#endregion
70
+ //#region src/node/host-terminals.d.ts
71
+ type PartialWithoutId<T extends {
72
+ id: string;
73
+ }> = Partial<T> & {
74
+ id: string;
75
+ };
76
+ declare class DevframeTerminalsHost implements DevframeTerminalsHost$1 {
77
+ readonly context: DevframeHubContext;
78
+ readonly sessions: DevframeTerminalsHost$1['sessions'];
79
+ readonly events: DevframeTerminalsHost$1['events'];
80
+ private _boundStreams;
81
+ private _channel?;
82
+ constructor(context: DevframeHubContext);
83
+ /**
84
+ * Lazily acquire the streaming channel — `context.rpc` isn't assigned
85
+ * until after every host is constructed, so we can't grab it in the
86
+ * constructor.
87
+ */
88
+ private getStreamingChannel;
89
+ register(session: DevframeTerminalSession): DevframeTerminalSession;
90
+ update(patch: PartialWithoutId<DevframeTerminalSession>): void;
91
+ remove(session: DevframeTerminalSession): void;
92
+ private bindStream;
93
+ startChildProcess(executeOptions: DevframeChildProcessExecuteOptions, terminal: Omit<DevframeTerminalSessionBase, 'status'>): Promise<DevframeChildProcessTerminalSession>;
94
+ }
95
+ //#endregion
96
+ //#region src/node/mount-devframe.d.ts
97
+ interface MountDevframeOptions {
98
+ /**
99
+ * Mount path override. Defaults to `d.basePath` or `/__${d.id}/`.
100
+ */
101
+ base?: string;
102
+ /**
103
+ * Overrides for the auto-synthesized iframe dock entry. Use this to
104
+ * customize the entry's `category`, override the icon, hide it via
105
+ * `when`, etc. Cannot change `id`, `type`, or `url` — those are
106
+ * derived from the devframe definition.
107
+ */
108
+ dock?: Partial<Omit<DevframeViewIframe, 'id' | 'type' | 'url'>>;
109
+ }
110
+ /**
111
+ * Framework-neutral primitive — mounts a {@link DevframeDefinition} as a
112
+ * dock inside a hub-aware context: serves the devframe's SPA at the
113
+ * resolved base path, synthesizes an iframe dock entry from the
114
+ * definition's metadata, and runs the definition's `setup(ctx)`.
115
+ *
116
+ * Framework kits wrap this with their own plugin/middleware machinery —
117
+ * e.g. `@vitejs/devtools-kit`'s `createPluginFromDevframe` returns a
118
+ * Vite `Plugin` whose `devtools.setup` ultimately delegates here.
119
+ */
120
+ declare function mountDevframe(ctx: DevframeHubContext, d: DevframeDefinition, options?: MountDevframeOptions): Promise<void>;
121
+ //#endregion
122
+ //#region src/node/rpc-builtins.d.ts
123
+ /**
124
+ * `hub:commands:execute` — Invoke a registered server command by id. The
125
+ * arguments after `id` are forwarded to the command's `handler(...)`.
126
+ * Returns whatever the handler returns.
127
+ *
128
+ * Pairs with the `devframe:commands` shared state: clients read the list
129
+ * from the shared state and dispatch by id via this RPC.
130
+ */
131
+ declare const hubCommandsExecute: {
132
+ name: "hub:commands:execute";
133
+ type?: "action" | undefined;
134
+ cacheable?: boolean;
135
+ args?: undefined;
136
+ returns?: undefined;
137
+ jsonSerializable?: boolean;
138
+ agent?: _$devframe.RpcFunctionAgentOptions;
139
+ setup?: ((context: DevframeHubContext) => _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[id: string, ...args: any[]], Promise<unknown>>>) | undefined;
140
+ handler?: ((id: string, ...args: any[]) => Promise<unknown>) | undefined;
141
+ dump?: _$devframe_rpc0.RpcDump<[id: string, ...args: any[]], Promise<unknown>, DevframeHubContext> | undefined;
142
+ snapshot?: boolean;
143
+ __cache?: WeakMap<object, _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[id: string, ...args: any[]], Promise<unknown>>>> | undefined;
144
+ __promise?: _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[id: string, ...args: any[]], Promise<unknown>>> | undefined;
145
+ };
146
+ /**
147
+ * Framework-neutral RPC declarations auto-registered by
148
+ * {@link createHubContext}. Provide additional RPCs by passing your own
149
+ * array via `CreateHubContextOptions.builtinRpcDeclarations`; the hub's
150
+ * list is prepended automatically.
151
+ */
152
+ declare const builtinHubRpcDeclarations: readonly RpcFunctionDefinitionAny[];
153
+ //#endregion
154
+ //#region src/node/utils.d.ts
155
+ /**
156
+ * Create a quick `ClientScriptEntry` from an inline function or
157
+ * stringified code. Useful for prototyping `action` / `renderer`
158
+ * dock entries without setting up a separate importable module.
159
+ *
160
+ * @experimental Prefer a proper importable module for production use.
161
+ */
162
+ declare function createSimpleClientScript(fn: string | ((ctx: any) => void)): ClientScriptEntry;
163
+ //#endregion
164
+ export { CreateHubContextOptions, DevframeCommandsHost, DevframeDocksHost, DevframeHubContext, DevframeMessagesHost, DevframeTerminalsHost, MountDevframeOptions, builtinHubRpcDeclarations, createHubContext, createSimpleClientScript, hubCommandsExecute, mountDevframe };