@devframes/hub 0.5.4 → 0.6.0-beta.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.
@@ -1,433 +0,0 @@
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
- * Id of the group this entry belongs to. When set, hosts collapse this entry
229
- * under the matching group's button instead of showing it directly on the
230
- * dock bar.
231
- *
232
- * This is a flat pointer — membership, not containment. The entry stays an
233
- * independently-registered, top-level entry; only its rendering is grouped
234
- * downstream. If the referenced group is never registered, the entry renders
235
- * as a normal top-level entry (orphan tolerance).
236
- *
237
- * @see {@link DevframeViewGroup}
238
- */
239
- groupId?: string;
240
- }
241
- interface ClientScriptEntry {
242
- /**
243
- * The filepath or module name to import from
244
- */
245
- importFrom: string;
246
- /**
247
- * The name to import the module as
248
- *
249
- * @default 'default'
250
- */
251
- importName?: string;
252
- }
253
- interface DevframeViewIframe extends DevframeDockEntryBase {
254
- type: 'iframe';
255
- url: string;
256
- /**
257
- * The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared.
258
- *
259
- * When not provided, it would be treated as a unique frame.
260
- */
261
- frameId?: string;
262
- /**
263
- * Optional client script to import into the iframe
264
- */
265
- clientScript?: ClientScriptEntry;
266
- /**
267
- * Enable remote-UI mode: the hub injects a connection descriptor
268
- * (WS URL + pre-approved auth token) into the iframe URL so a hosted
269
- * page can connect back via `connectRemoteDevframe()` from
270
- * `@devframes/hub/client` — without needing to ship a dist with the
271
- * plugin.
272
- *
273
- * Requires dev mode (no effect in build mode — no WS server exists).
274
- * When enabled, the dock is automatically hidden in build mode unless
275
- * the author provides an explicit `when` clause.
276
- */
277
- remote?: boolean | RemoteDockOptions;
278
- }
279
- interface RemoteDockOptions {
280
- /**
281
- * How to pass the connection descriptor to the hosted page.
282
- *
283
- * - `'fragment'` (default): appended as a URL fragment.
284
- * Not sent in HTTP requests or Referer headers — safest for auth tokens.
285
- * - `'query'`: appended as a URL query parameter. Use when your hosting
286
- * platform rewrites fragments or your SPA router repurposes the fragment
287
- * for navigation. The token will appear in server access logs and
288
- * outbound Referer headers.
289
- *
290
- * @default 'fragment'
291
- */
292
- transport?: 'fragment' | 'query';
293
- /**
294
- * Reject WS handshakes whose `Origin` header doesn't match the dock URL
295
- * origin. Turn off when the same hosted app is served from multiple
296
- * origins (e.g. preview deploys).
297
- *
298
- * @default true
299
- */
300
- originLock?: boolean;
301
- }
302
- interface RemoteConnectionInfo extends ConnectionMeta {
303
- backend: 'websocket';
304
- websocket: string;
305
- v: 1;
306
- authToken: string;
307
- origin: string;
308
- }
309
- type DevframeViewLauncherStatus = 'idle' | 'loading' | 'success' | 'error';
310
- interface DevframeViewLauncher extends DevframeDockEntryBase {
311
- type: 'launcher';
312
- launcher: {
313
- icon?: DevframeDockEntryIcon;
314
- title: string;
315
- status?: DevframeViewLauncherStatus;
316
- error?: string;
317
- description?: string;
318
- buttonStart?: string;
319
- buttonLoading?: string;
320
- onLaunch: () => Promise<void>;
321
- };
322
- }
323
- interface DevframeViewAction extends DevframeDockEntryBase {
324
- type: 'action';
325
- action: ClientScriptEntry;
326
- }
327
- interface DevframeViewCustomRender extends DevframeDockEntryBase {
328
- type: 'custom-render';
329
- renderer: ClientScriptEntry;
330
- }
331
- interface DevframeViewBuiltin extends DevframeDockEntryBase {
332
- type: '~builtin';
333
- id: '~terminals' | '~messages' | '~client-auth-notice' | '~settings' | '~popup';
334
- }
335
- interface DevframeViewJsonRender extends DevframeDockEntryBase {
336
- type: 'json-render';
337
- /** JsonRenderer handle created by ctx.createJsonRenderer() */
338
- ui: JsonRenderer;
339
- }
340
- /**
341
- * A dock group: a single dock-bar button that collapses every entry whose
342
- * {@link DevframeDockEntryBase.groupId} matches this group's `id`.
343
- *
344
- * A group carries its own `title`/`icon`/`category`/`defaultOrder`/`when`
345
- * (inherited from {@link DevframeDockEntryBase}) and has no view payload of its
346
- * own — hosts render its members in a popover / sub-navigation. It flows
347
- * through the same `register`/`update`/`values` machinery as every other entry,
348
- * keyed by `id`.
349
- *
350
- * Grouping is one level deep: a group entry must not itself set `groupId`.
351
- */
352
- interface DevframeViewGroup extends DevframeDockEntryBase {
353
- type: 'group';
354
- /**
355
- * Member id auto-opened when the group button is activated. When unset,
356
- * activating the group only reveals its members (popover-only); no view
357
- * opens until a member is chosen.
358
- */
359
- defaultChildId?: string;
360
- }
361
- type DevframeDockUserEntry = DevframeViewIframe | DevframeViewAction | DevframeViewCustomRender | DevframeViewLauncher | DevframeViewJsonRender | DevframeViewGroup;
362
- type DevframeDockEntry = DevframeDockUserEntry | DevframeViewBuiltin;
363
- type DevframeDockEntriesGrouped = [category: string, entries: DevframeDockEntry[]][];
364
- //#endregion
365
- //#region src/types/terminals.d.ts
366
- interface DevframeTerminalsHost {
367
- readonly sessions: Map<string, DevframeTerminalSession>;
368
- readonly events: EventEmitter<{
369
- 'terminal:session:updated': (session: DevframeTerminalSession) => void;
370
- }>;
371
- register: (session: DevframeTerminalSession) => DevframeTerminalSession;
372
- update: (session: DevframeTerminalSession) => void;
373
- startChildProcess: (executeOptions: DevframeChildProcessExecuteOptions, terminal: Omit<DevframeTerminalSessionBase, 'status'>) => Promise<DevframeChildProcessTerminalSession>;
374
- }
375
- type DevframeTerminalStatus = 'running' | 'stopped' | 'error';
376
- interface DevframeTerminalSessionBase {
377
- id: string;
378
- title: string;
379
- description?: string;
380
- status: DevframeTerminalStatus;
381
- icon?: DevframeDockEntryIcon;
382
- }
383
- interface DevframeTerminalSession extends DevframeTerminalSessionBase {
384
- buffer?: string[];
385
- stream?: ReadableStream<string>;
386
- }
387
- interface DevframeChildProcessExecuteOptions {
388
- command: string;
389
- args: string[];
390
- cwd?: string;
391
- env?: Record<string, string>;
392
- }
393
- interface DevframeChildProcessTerminalSession extends DevframeTerminalSession {
394
- type: 'child-process';
395
- executeOptions: DevframeChildProcessExecuteOptions;
396
- getChildProcess: () => ChildProcess | undefined;
397
- terminate: () => Promise<void>;
398
- restart: () => Promise<void>;
399
- }
400
- //#endregion
401
- //#region src/node/context.d.ts
402
- /**
403
- * Hub-augmented node context — extends devframe's framework-neutral
404
- * `DevframeNodeContext` with the hub-level subsystems (`docks`,
405
- * `terminals`, `messages`, `commands`) and the `createJsonRenderer`
406
- * factory.
407
- *
408
- * Framework kits further extend this with their own slots (e.g.
409
- * `viteConfig`, `viteServer`). Host-specific capabilities (editor open,
410
- * filesystem reveal, etc.) ship as kit-registered RPC functions rather
411
- * than as part of this surface.
412
- */
413
- interface DevframeHubContext extends DevframeNodeContext {
414
- readonly host: DevframeHost;
415
- docks: DevframeDocksHost;
416
- terminals: DevframeTerminalsHost;
417
- messages: DevframeMessagesHost;
418
- commands: DevframeCommandsHost;
419
- /**
420
- * Create a JsonRenderer handle for building json-render powered UIs.
421
- */
422
- createJsonRenderer: (spec: JsonRenderSpec) => JsonRenderer;
423
- }
424
- interface CreateHubContextOptions extends CreateHostContextOptions {}
425
- /**
426
- * Create a hub-level node context: wraps devframe's `createHostContext`,
427
- * attaches the hub hosts (`docks`, `terminals`, `messages`, `commands`),
428
- * registers the hub's built-in RPC commands, and wires the shared-state
429
- * synchronization that powers a hub-aware client UI.
430
- */
431
- declare function createHubContext(options: CreateHubContextOptions): Promise<DevframeHubContext>;
432
- //#endregion
433
- export { JsonRenderer as A, DevframeViewJsonRender as C, RemoteDockOptions as D, RemoteConnectionInfo as E, DevframeMessageFilePosition as F, DevframeMessageHandle as I, DevframeMessageLevel as L, DevframeMessageEntry as M, DevframeMessageEntryFrom as N, JsonRenderElement as O, DevframeMessageEntryInput as P, DevframeMessagesClient as R, DevframeViewIframe as S, DevframeViewLauncherStatus 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, DevframeMessageElementPosition as j, JsonRenderSpec 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, DevframeViewLauncher as w, DevframeViewGroup as x, DevframeViewBuiltin as y, DevframeMessagesHost as z };
@@ -1,131 +0,0 @@
1
- import { EventEmitter } from "devframe/types";
2
-
3
- //#region src/types/commands.d.ts
4
- interface DevframeCommandKeybinding {
5
- /**
6
- * Keyboard shortcut string.
7
- * Use "Mod" for platform-aware modifier (Cmd on macOS, Ctrl elsewhere).
8
- * Examples: "Mod+K", "Mod+Shift+P", "Alt+N"
9
- */
10
- key: string;
11
- }
12
- interface DevframeCommandBase {
13
- /**
14
- * Unique namespaced ID, e.g. "vite:open-in-editor"
15
- */
16
- id: string;
17
- title: string;
18
- description?: string;
19
- /**
20
- * Iconify icon string, e.g. "ph:pencil-duotone"
21
- */
22
- icon?: string;
23
- category?: string;
24
- /**
25
- * Whether to show in command palette. Default: true
26
- *
27
- * - `true` — show the command and flatten its children into search results
28
- * - `false` — hide the command entirely from the palette
29
- * - `'without-children'` — show the command but don't flatten children into top-level search (children are still accessible via drill-down)
30
- */
31
- showInPalette?: boolean | 'without-children';
32
- /**
33
- * Optional context expression for conditional visibility.
34
- * When set, the command is only shown in the palette and only executable
35
- * when the expression evaluates to true.
36
- */
37
- when?: string;
38
- /**
39
- * Default keyboard shortcut(s) for this command
40
- */
41
- keybindings?: DevframeCommandKeybinding[];
42
- }
43
- /**
44
- * Server command input — what plugins pass to `ctx.commands.register()`.
45
- */
46
- interface DevframeServerCommandInput extends DevframeCommandBase {
47
- /**
48
- * Handler for this command. Optional if the command only serves as a group for children.
49
- */
50
- handler?: (...args: any[]) => any | Promise<any>;
51
- /**
52
- * Static sub-commands. Two levels max (parent → children).
53
- * Each child must have a globally unique `id`.
54
- */
55
- children?: DevframeServerCommandInput[];
56
- }
57
- /**
58
- * Serializable server command entry — sent over RPC (no handler).
59
- */
60
- interface DevframeServerCommandEntry extends DevframeCommandBase {
61
- source: 'server';
62
- children?: DevframeServerCommandEntry[];
63
- }
64
- /**
65
- * Client command — registered in the webcomponent context.
66
- */
67
- interface DevframeClientCommand extends DevframeCommandBase {
68
- source: 'client';
69
- /**
70
- * Action for this command. Optional if the command only serves as a group for children.
71
- * Return sub-commands for dynamic nested palette menus (runtime submenus).
72
- */
73
- action?: (...args: any[]) => void | DevframeClientCommand[] | Promise<void | DevframeClientCommand[]>;
74
- /**
75
- * Static sub-commands. Two levels max (parent → children).
76
- */
77
- children?: DevframeClientCommand[];
78
- }
79
- /**
80
- * Union of command entries visible in the palette.
81
- */
82
- type DevframeCommandEntry = DevframeServerCommandEntry | DevframeClientCommand;
83
- interface DevframeCommandHandle {
84
- readonly id: string;
85
- update: (patch: Partial<Omit<DevframeServerCommandInput, 'id'>>) => void;
86
- unregister: () => void;
87
- }
88
- interface DevframeCommandsHostEvents {
89
- 'command:registered': (command: DevframeServerCommandEntry) => void;
90
- 'command:unregistered': (id: string) => void;
91
- }
92
- interface DevframeCommandsHost {
93
- readonly commands: Map<string, DevframeServerCommandInput>;
94
- readonly events: EventEmitter<DevframeCommandsHostEvents>;
95
- /**
96
- * Register a command (with optional children).
97
- */
98
- register: (command: DevframeServerCommandInput) => DevframeCommandHandle;
99
- /**
100
- * Unregister a command by ID (removes parent and all children).
101
- */
102
- unregister: (id: string) => boolean;
103
- /**
104
- * Execute a command by ID. Searches top-level and children.
105
- * Throws if not found or if command has no handler.
106
- */
107
- execute: (id: string, ...args: any[]) => Promise<unknown>;
108
- /**
109
- * Returns serializable list (no handlers), preserving tree structure.
110
- */
111
- list: () => DevframeServerCommandEntry[];
112
- }
113
- interface DevframeCommandShortcutOverrides {
114
- /**
115
- * Command ID → keybinding overrides. Empty array = shortcut disabled.
116
- */
117
- [commandId: string]: DevframeCommandKeybinding[];
118
- }
119
- //#endregion
120
- //#region src/types/settings.d.ts
121
- interface DevframeDocksUserSettings {
122
- docksHidden: string[];
123
- docksCategoriesHidden: string[];
124
- docksPinned: string[];
125
- docksCustomOrder: Record<string, number>;
126
- showIframeAddressBar: boolean;
127
- closeOnOutsideClick: boolean;
128
- commandShortcuts: DevframeCommandShortcutOverrides;
129
- }
130
- //#endregion
131
- export { DevframeCommandHandle as a, DevframeCommandsHost as c, DevframeServerCommandInput as d, DevframeCommandEntry as i, DevframeCommandsHostEvents as l, DevframeClientCommand as n, DevframeCommandKeybinding as o, DevframeCommandBase as r, DevframeCommandShortcutOverrides as s, DevframeDocksUserSettings as t, DevframeServerCommandEntry as u };