@devframes/hub 0.9.0 → 0.9.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.
- package/dist/client/index.d.mts +38 -5
- package/dist/client/index.mjs +19 -15
- package/dist/constants-C2b2cACy.mjs +120 -0
- package/dist/constants-CmESZCBq.d.mts +105 -0
- package/dist/constants.d.mts +2 -33
- package/dist/constants.mjs +2 -52
- package/dist/{context-D5TJIHwp.d.mts → context-BVkxwz5k.d.mts} +6 -6
- package/dist/{context-DzqMQ2mI.mjs → context-TgU_TKiY.mjs} +95 -50
- package/dist/{index-coDmWngQ.d.mts → index-CyEyZHB3.d.mts} +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/node/index.d.mts +10 -2
- package/dist/node/index.mjs +80 -57
- package/dist/node/initiate.d.mts +24 -3
- package/dist/node/initiate.mjs +17 -5
- package/dist/{remote-url-KVXtKP47.mjs → remote-url-Bgc7gtsP.mjs} +48 -2
- package/dist/{settings-DfrRa9Wf.d.mts → settings-D7whfcx2.d.mts} +29 -5
- package/dist/types/index.d.mts +3 -3
- package/package.json +3 -3
package/dist/client/index.d.mts
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
import { E as DevframeMessagesClient, x as DevframeMessageEntryInput } from "../context-
|
|
2
|
-
import { N as NavTarget, P as RemoteConnectionInfo, S as DevframeDockUserEntry, _ as DevframeDockEntry, a as DevframeCommandEntry, b as DevframeDockEntryIcon, g as DevframeDockEntriesGrouped, k as DevframeViewIframe, n as DevframeClientCommand, p as ClientScriptEntry, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings } from "../settings-
|
|
3
|
-
import "../index-
|
|
1
|
+
import { E as DevframeMessagesClient, x as DevframeMessageEntryInput } from "../context-BVkxwz5k.mjs";
|
|
2
|
+
import { N as NavTarget, P as RemoteConnectionInfo, S as DevframeDockUserEntry, _ as DevframeDockEntry, a as DevframeCommandEntry, b as DevframeDockEntryIcon, g as DevframeDockEntriesGrouped, k as DevframeViewIframe, n as DevframeClientCommand, p as ClientScriptEntry, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings } from "../settings-D7whfcx2.mjs";
|
|
3
|
+
import "../index-CyEyZHB3.mjs";
|
|
4
4
|
import { DevframeClientRpcHost, DevframeConnection, DevframeConnectionStatus, DevframeRpcClient, DevframeRpcClientOptions, DevframeRpcContext, RpcClientEvents, RpcClientEvents as RpcClientEvents$1 } from "devframe/client";
|
|
5
5
|
import { EventEmitter } from "devframe/types";
|
|
6
6
|
import { SharedState } from "devframe/utils/shared-state";
|
|
7
7
|
import { WhenContext } from "devframe/utils/when";
|
|
8
8
|
export * from "devframe/client";
|
|
9
|
+
//#region src/client-modules.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a dock client script's `importFrom` to the URL to import. URL
|
|
12
|
+
* specifiers pass through untouched; a **bare** specifier resolves through
|
|
13
|
+
* the explicit `resolveClientModule` callback (a viewer's own policy), then
|
|
14
|
+
* the host-advertised `template` (`ConnectionMeta.configs.dock.clientModuleResolution`,
|
|
15
|
+
* its `{specifier}` token replaced — e.g. Vite's `'/@id/{specifier}'`),
|
|
16
|
+
* resolved against `metaBaseUrl` so it targets the host's origin from any
|
|
17
|
+
* viewer. With neither, it stays unchanged — a page import map may still
|
|
18
|
+
* cover it.
|
|
19
|
+
*/
|
|
20
|
+
declare function resolveClientModuleSpecifier(specifier: string, options?: {
|
|
21
|
+
resolveClientModule?: (specifier: string) => string | undefined;
|
|
22
|
+
template?: string;
|
|
23
|
+
metaBaseUrl?: string;
|
|
24
|
+
}): string;
|
|
25
|
+
/**
|
|
26
|
+
* Diagnose a failed client-script import: name the likely cause instead of
|
|
27
|
+
* leaving only the browser's opaque `TypeError`. `importFrom` is the entry's
|
|
28
|
+
* declared specifier, `specifier` what was actually imported (after
|
|
29
|
+
* {@link resolveClientModuleSpecifier}).
|
|
30
|
+
*/
|
|
31
|
+
declare function clientScriptFailureHint(importFrom: string, specifier: string): string;
|
|
32
|
+
//#endregion
|
|
9
33
|
//#region src/client/renderers.d.ts
|
|
10
34
|
/**
|
|
11
35
|
* Options handed to a dock renderer when the client host mounts a dock entry.
|
|
@@ -478,7 +502,7 @@ declare function watchFrameLocation(options: WatchFrameLocationOptions): () => v
|
|
|
478
502
|
* decoupled — the embedded app takes no hub/RPC dependency, only the shim.
|
|
479
503
|
*/
|
|
480
504
|
/** `postMessage` channel tag shared by both halves of the protocol. */
|
|
481
|
-
declare const FRAME_NAV_CHANNEL
|
|
505
|
+
declare const FRAME_NAV_CHANNEL: string;
|
|
482
506
|
/** Protocol version. */
|
|
483
507
|
declare const FRAME_NAV_VERSION = 1;
|
|
484
508
|
/** Envelope every frame-nav message carries. */
|
|
@@ -599,6 +623,15 @@ interface DevframeClientHostOptions {
|
|
|
599
623
|
* `custom-render`, and iframe `clientScript`). Default `true`.
|
|
600
624
|
*/
|
|
601
625
|
loadClientScripts?: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* Resolve a **bare-specifier** client script (`importFrom` naming an npm
|
|
628
|
+
* module) to a URL this page can import — a viewer's own policy, winning
|
|
629
|
+
* over the host-advertised `ConnectionMeta.configs.dock.clientModuleResolution`
|
|
630
|
+
* template (return `undefined` to fall through to it). URL specifiers never
|
|
631
|
+
* reach this hook. E.g. on a Vite-served page:
|
|
632
|
+
* `resolveClientModule: s => `/@id/${s}``.
|
|
633
|
+
*/
|
|
634
|
+
resolveClientModule?: (specifier: string) => string | undefined;
|
|
602
635
|
/**
|
|
603
636
|
* Dock renderers to register at boot, keyed by dock `type`. The host
|
|
604
637
|
* application injects the ones it wants (e.g.
|
|
@@ -698,4 +731,4 @@ declare function parseRemoteConnection(input?: string): RemoteConnectionInfo | n
|
|
|
698
731
|
*/
|
|
699
732
|
declare function connectRemoteDevframe(options?: ConnectRemoteDevframeOptions): Promise<DevframeRpcClient>;
|
|
700
733
|
//#endregion
|
|
701
|
-
export { CLIENT_CONTEXT_KEY, CommandsContext, ConnectRemoteDevframeOptions, CreateDockRenderersContextOptions, DevframeClientContext, DevframeClientHost, DevframeClientHostOptions, type DevframeClientRpcHost, DockClientScriptContext, DockClientType, DockEntryState, DockEntryStateEvents, DockPanelStorage, DockRegistration, DockRenderer, DockRendererInstance, DockRendererManifest, DockRendererMountOptions, DockRendererMountResult, DockRenderersContext, DockSessionStorage, DocksConnectionContext, DocksContext, DocksEntriesContext, DocksPanelContext, FRAME_NAV_CHANNEL, FRAME_NAV_VERSION, FrameLocationHistory, FrameLocationTarget, FrameLocationWindow, FrameNavClient, FrameNavClientOptions, FrameNavEnvelope, FrameNavFrameMessage, FrameNavHostMessage, FrameNavHostPayload, FrameNavListenTarget, FrameTab, MessagesClientOptions, type RpcClientEvents, WatchFrameLocationOptions, WhenClauseContext, attachFrameNavClient, buildRemoteDevframeUrl, connectRemoteDevframe, createDevframeClientHost, createDockRenderersContext, createMessagesClient, getDevframeClientContext, parseRemoteConnection, resolveDockIcon, resolveDockUrl, setDevframeClientContext, stripRemoteConnectionFromUrl, watchFrameLocation };
|
|
734
|
+
export { CLIENT_CONTEXT_KEY, CommandsContext, ConnectRemoteDevframeOptions, CreateDockRenderersContextOptions, DevframeClientContext, DevframeClientHost, DevframeClientHostOptions, type DevframeClientRpcHost, DockClientScriptContext, DockClientType, DockEntryState, DockEntryStateEvents, DockPanelStorage, DockRegistration, DockRenderer, DockRendererInstance, DockRendererManifest, DockRendererMountOptions, DockRendererMountResult, DockRenderersContext, DockSessionStorage, DocksConnectionContext, DocksContext, DocksEntriesContext, DocksPanelContext, FRAME_NAV_CHANNEL, FRAME_NAV_VERSION, FrameLocationHistory, FrameLocationTarget, FrameLocationWindow, FrameNavClient, FrameNavClientOptions, FrameNavEnvelope, FrameNavFrameMessage, FrameNavHostMessage, FrameNavHostPayload, FrameNavListenTarget, FrameTab, MessagesClientOptions, type RpcClientEvents, WatchFrameLocationOptions, WhenClauseContext, attachFrameNavClient, buildRemoteDevframeUrl, clientScriptFailureHint, connectRemoteDevframe, createDevframeClientHost, createDockRenderersContext, createMessagesClient, getDevframeClientContext, parseRemoteConnection, resolveClientModuleSpecifier, resolveDockIcon, resolveDockUrl, setDevframeClientContext, stripRemoteConnectionFromUrl, watchFrameLocation };
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as stripRemoteConnectionFromUrl, t as buildRemoteConnectionUrl } from "../remote-url-
|
|
1
|
+
import { i as DOCK_RENDERERS_STATE_KEY, n as DEFAULT_STATE_USER_SETTINGS, o as HUB_EVENTS, t as DEFAULT_CATEGORIES_ORDER } from "../constants-C2b2cACy.mjs";
|
|
2
|
+
import { a as resolveClientModuleSpecifier, n as stripRemoteConnectionFromUrl, r as clientScriptFailureHint, t as buildRemoteConnectionUrl } from "../remote-url-Bgc7gtsP.mjs";
|
|
3
3
|
import { REMOTE_CONNECTION_KEY } from "devframe/constants";
|
|
4
4
|
import { connectDevframe, getDevframeRpcClient, resolveWsUrl } from "devframe/client";
|
|
5
5
|
import { createEventEmitter } from "devframe/utils/events";
|
|
@@ -172,7 +172,7 @@ function watchFrameLocation(options) {
|
|
|
172
172
|
* decoupled — the embedded app takes no hub/RPC dependency, only the shim.
|
|
173
173
|
*/
|
|
174
174
|
/** `postMessage` channel tag shared by both halves of the protocol. */
|
|
175
|
-
const FRAME_NAV_CHANNEL =
|
|
175
|
+
const FRAME_NAV_CHANNEL = HUB_EVENTS.postMessage.frameNav;
|
|
176
176
|
/** Protocol version. */
|
|
177
177
|
const FRAME_NAV_VERSION = 1;
|
|
178
178
|
/**
|
|
@@ -203,16 +203,14 @@ function attachFrameNavClient(options) {
|
|
|
203
203
|
if (disposed) return;
|
|
204
204
|
if (expectedOrigin !== "*" && ev.origin !== expectedOrigin) return;
|
|
205
205
|
const data = ev.data;
|
|
206
|
-
if (!data || data.channel !==
|
|
206
|
+
if (!data || data.channel !== FRAME_NAV_CHANNEL || data.v !== 1 || data.frameId !== frameId || data.from !== "frame") return;
|
|
207
207
|
switch (data.type) {
|
|
208
208
|
case "ready":
|
|
209
209
|
case "manifest":
|
|
210
210
|
markReady();
|
|
211
211
|
reconcileManifest(data.tabs ?? [], data.current);
|
|
212
212
|
break;
|
|
213
|
-
case "navigated":
|
|
214
|
-
onNavigated(data.tabId);
|
|
215
|
-
break;
|
|
213
|
+
case "navigated": onNavigated(data.tabId);
|
|
216
214
|
}
|
|
217
215
|
}
|
|
218
216
|
function markReady() {
|
|
@@ -498,10 +496,10 @@ function createDockRenderersContext(options) {
|
|
|
498
496
|
}
|
|
499
497
|
//#endregion
|
|
500
498
|
//#region src/client/host.ts
|
|
501
|
-
const DOCKS_STATE_KEY =
|
|
502
|
-
const COMMANDS_STATE_KEY =
|
|
503
|
-
const USER_SETTINGS_STATE_KEY =
|
|
504
|
-
const DOCKS_ACTIVATE_EVENT =
|
|
499
|
+
const DOCKS_STATE_KEY = HUB_EVENTS.sharedState.docks;
|
|
500
|
+
const COMMANDS_STATE_KEY = HUB_EVENTS.sharedState.commands;
|
|
501
|
+
const USER_SETTINGS_STATE_KEY = HUB_EVENTS.sharedState.userSettings;
|
|
502
|
+
const DOCKS_ACTIVATE_EVENT = HUB_EVENTS.broadcast.docksActivate;
|
|
505
503
|
/**
|
|
506
504
|
* Boot the framework-level client host: connect RPC, assemble the full
|
|
507
505
|
* {@link DevframeClientContext} (panel, docks, commands, when) from the hub's
|
|
@@ -798,12 +796,17 @@ async function createDevframeClientHost(options = {}) {
|
|
|
798
796
|
}
|
|
799
797
|
}
|
|
800
798
|
async function runClientScript(entryId, script) {
|
|
799
|
+
const specifier = resolveClientModuleSpecifier(script.importFrom, {
|
|
800
|
+
resolveClientModule: options.resolveClientModule,
|
|
801
|
+
template: rpc.connectionMeta?.configs?.dock?.clientModuleResolution,
|
|
802
|
+
metaBaseUrl: rpc.connection?.metaBaseUrl
|
|
803
|
+
});
|
|
801
804
|
try {
|
|
802
805
|
const fn = (await import(
|
|
803
806
|
/* @vite-ignore */
|
|
804
807
|
/* webpackIgnore: true */
|
|
805
808
|
/* turbopackIgnore: true */
|
|
806
|
-
|
|
809
|
+
specifier
|
|
807
810
|
))[script.importName ?? "default"];
|
|
808
811
|
if (typeof fn !== "function") return;
|
|
809
812
|
const current = entryToStateMap.get(entryId);
|
|
@@ -816,7 +819,7 @@ async function createDevframeClientHost(options = {}) {
|
|
|
816
819
|
});
|
|
817
820
|
} catch (error) {
|
|
818
821
|
loadedScripts.delete(entryId);
|
|
819
|
-
console.error(`[@devframes/hub] failed to load client script for "${entryId}" from ${script.importFrom}`, error);
|
|
822
|
+
console.error(`[@devframes/hub] failed to load client script for "${entryId}" from ${specifier}${clientScriptFailureHint(script.importFrom, specifier)}`, error);
|
|
820
823
|
}
|
|
821
824
|
}
|
|
822
825
|
}
|
|
@@ -883,10 +886,11 @@ function buildRemoteDevframeUrl(url, connection) {
|
|
|
883
886
|
} catch {
|
|
884
887
|
return url;
|
|
885
888
|
}
|
|
889
|
+
const websocket = resolveWsUrl(connection.connectionMeta.websocket, connection.metaBaseUrl, base);
|
|
886
890
|
return buildRemoteConnectionUrl(url, {
|
|
887
891
|
v: 1,
|
|
888
892
|
backend: "websocket",
|
|
889
|
-
websocket
|
|
893
|
+
websocket,
|
|
890
894
|
authToken: connection.authToken,
|
|
891
895
|
origin: base.origin
|
|
892
896
|
});
|
|
@@ -967,4 +971,4 @@ async function connectRemoteDevframe(options = {}) {
|
|
|
967
971
|
});
|
|
968
972
|
}
|
|
969
973
|
//#endregion
|
|
970
|
-
export { CLIENT_CONTEXT_KEY, FRAME_NAV_CHANNEL, FRAME_NAV_VERSION, attachFrameNavClient, buildRemoteDevframeUrl, connectRemoteDevframe, createDevframeClientHost, createDockRenderersContext, createMessagesClient, getDevframeClientContext, parseRemoteConnection, resolveDockIcon, resolveDockUrl, setDevframeClientContext, stripRemoteConnectionFromUrl, watchFrameLocation };
|
|
974
|
+
export { CLIENT_CONTEXT_KEY, FRAME_NAV_CHANNEL, FRAME_NAV_VERSION, attachFrameNavClient, buildRemoteDevframeUrl, clientScriptFailureHint, connectRemoteDevframe, createDevframeClientHost, createDockRenderersContext, createMessagesClient, getDevframeClientContext, parseRemoteConnection, resolveClientModuleSpecifier, resolveDockIcon, resolveDockUrl, setDevframeClientContext, stripRemoteConnectionFromUrl, watchFrameLocation };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { cleanDoubleSlashes, withLeadingSlash, withTrailingSlash } from "ufo";
|
|
2
|
+
//#region src/events.ts
|
|
3
|
+
/**
|
|
4
|
+
* Centralized registry of every event, broadcast, RPC method, shared-state
|
|
5
|
+
* key, and channel name the hub uses — the single source of truth that keeps
|
|
6
|
+
* these names out of scattered string literals.
|
|
7
|
+
*
|
|
8
|
+
* **Keep this in sync with [`docs/guide/events.md`](../../../docs/guide/events.md)**
|
|
9
|
+
* (the Hub Events Reference): every name here appears in that page's tables, and
|
|
10
|
+
* every name there resolves to an entry here. Add, rename, or remove a name in
|
|
11
|
+
* both places in the same change, and reference `HUB_EVENTS.*` from call sites
|
|
12
|
+
* instead of re-typing a literal.
|
|
13
|
+
*
|
|
14
|
+
* The `.events` EventEmitter maps in `types/{docks,terminals,messages,commands}.ts`
|
|
15
|
+
* and the RPC augmentation interfaces in `node/context.ts` declare these same
|
|
16
|
+
* names as type-level keys (a literal is unavoidable in a type position); those
|
|
17
|
+
* declarations mirror this map and move with it.
|
|
18
|
+
*/
|
|
19
|
+
const HUB_EVENTS = {
|
|
20
|
+
/**
|
|
21
|
+
* Internal node `EventEmitter` events on `ctx.<subsystem>.events`. Emitted
|
|
22
|
+
* and consumed inside the node process (chiefly by `createHubContext`, which
|
|
23
|
+
* fans them out onto the wire); they never cross to the browser.
|
|
24
|
+
*/
|
|
25
|
+
bus: {
|
|
26
|
+
docksEntryUpdated: "docks:entry:updated",
|
|
27
|
+
docksActivate: "docks:activate",
|
|
28
|
+
terminalsSessionUpdated: "terminals:session:updated",
|
|
29
|
+
messagesAdded: "messages:added",
|
|
30
|
+
messagesUpdated: "messages:updated",
|
|
31
|
+
messagesRemoved: "messages:removed",
|
|
32
|
+
messagesCleared: "messages:cleared",
|
|
33
|
+
commandsRegistered: "commands:registered",
|
|
34
|
+
commandsUnregistered: "commands:unregistered"
|
|
35
|
+
},
|
|
36
|
+
/** Server RPC methods a connected client calls (client → server), `hub:` prefix. */
|
|
37
|
+
rpc: {
|
|
38
|
+
docksActivate: "hub:docks:activate",
|
|
39
|
+
commandsExecute: "hub:commands:execute",
|
|
40
|
+
messagesAdd: "hub:messages:add",
|
|
41
|
+
messagesUpdate: "hub:messages:update",
|
|
42
|
+
messagesRemove: "hub:messages:remove",
|
|
43
|
+
messagesClear: "hub:messages:clear",
|
|
44
|
+
terminalsWrite: "hub:terminals:write",
|
|
45
|
+
terminalsResize: "hub:terminals:resize",
|
|
46
|
+
terminalsTerminate: "hub:terminals:terminate",
|
|
47
|
+
terminalsRestart: "hub:terminals:restart",
|
|
48
|
+
terminalsRemove: "hub:terminals:remove"
|
|
49
|
+
},
|
|
50
|
+
/** Broadcast notifications the server pushes to clients (server → client), `devframe:` prefix. */
|
|
51
|
+
broadcast: {
|
|
52
|
+
docksActivate: "devframe:docks:activate",
|
|
53
|
+
terminalsUpdated: "devframe:terminals:updated",
|
|
54
|
+
messagesUpdated: "devframe:messages:updated"
|
|
55
|
+
},
|
|
56
|
+
/** Shared-state slot keys a hub-aware client reads (server → client), `devframe:` prefix. */
|
|
57
|
+
sharedState: {
|
|
58
|
+
docks: "devframe:docks",
|
|
59
|
+
docksActive: "devframe:docks:active",
|
|
60
|
+
commands: "devframe:commands",
|
|
61
|
+
userSettings: "devframe:user-settings",
|
|
62
|
+
dockRenderers: "devframe:dock-renderers"
|
|
63
|
+
},
|
|
64
|
+
/** Streaming channel ids (server → client), `devframe:` prefix. */
|
|
65
|
+
stream: { terminals: "devframe:terminals" },
|
|
66
|
+
/** `postMessage` channels for host ↔ iframe protocols, `devframe:` prefix. */
|
|
67
|
+
postMessage: { frameNav: "devframe:frame-nav" }
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/constants.ts
|
|
71
|
+
/** Default mount base for a hub instance — one namespace, one catch-all. */
|
|
72
|
+
const DEVFRAMES_HUB_BASE = "/__devframes/";
|
|
73
|
+
/**
|
|
74
|
+
* Normalize a hub mount base to an absolute path with leading and trailing
|
|
75
|
+
* slashes (e.g. `devframes` → `/devframes/`), collapsing any doubled
|
|
76
|
+
* slashes the input introduced. The one implementation every hub-aware
|
|
77
|
+
* host (`@devframes/hub` itself, and the Vite/Nuxt/Next adapters) resolves
|
|
78
|
+
* `options.base` through.
|
|
79
|
+
*/
|
|
80
|
+
function normalizeHubBase(base) {
|
|
81
|
+
return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base)));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The default ordering weight for each known dock category — lower sorts
|
|
85
|
+
* earlier. Downstream viewers (e.g. `@vitejs/devtools-kit`) import this as the
|
|
86
|
+
* single source of truth so the hub and its viewers agree on category order.
|
|
87
|
+
* `framework` sorts first; `~builtin` (the viewer's own built-in views) last.
|
|
88
|
+
*
|
|
89
|
+
* The buckets read from "closest to your app" → "platform / analysis" →
|
|
90
|
+
* "peripheral". Gaps between the weights are intentional: a kit can interleave
|
|
91
|
+
* its own categories (or override these) without editing this table.
|
|
92
|
+
*/
|
|
93
|
+
const DEFAULT_CATEGORIES_ORDER = {
|
|
94
|
+
"framework": -100,
|
|
95
|
+
"default": 0,
|
|
96
|
+
"app": 100,
|
|
97
|
+
"ui": 150,
|
|
98
|
+
"data": 250,
|
|
99
|
+
"web": 300,
|
|
100
|
+
"performance": 350,
|
|
101
|
+
"advanced": 400,
|
|
102
|
+
"docs": 500,
|
|
103
|
+
"~builtin": 1e3
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Shared-state slot carrying the hub's renderer manifest — one
|
|
107
|
+
* {@link import('./client/renderers').DockRendererManifest} entry per dock
|
|
108
|
+
* `type`, published by `initHub({ renderers })` and consumed by every
|
|
109
|
+
* hub-aware client (the headless client host and viewers alike).
|
|
110
|
+
*/
|
|
111
|
+
const DOCK_RENDERERS_STATE_KEY = HUB_EVENTS.sharedState.dockRenderers;
|
|
112
|
+
const DEFAULT_STATE_USER_SETTINGS = () => ({
|
|
113
|
+
docksHidden: [],
|
|
114
|
+
docksCategoriesHidden: [],
|
|
115
|
+
docksPinned: [],
|
|
116
|
+
docksCustomOrder: {},
|
|
117
|
+
commandShortcuts: {}
|
|
118
|
+
});
|
|
119
|
+
//#endregion
|
|
120
|
+
export { normalizeHubBase as a, DOCK_RENDERERS_STATE_KEY as i, DEFAULT_STATE_USER_SETTINGS as n, HUB_EVENTS as o, DEVFRAMES_HUB_BASE as r, DEFAULT_CATEGORIES_ORDER as t };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { t as DevframeDocksUserSettings } from "./settings-D7whfcx2.mjs";
|
|
2
|
+
//#region src/events.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Centralized registry of every event, broadcast, RPC method, shared-state
|
|
5
|
+
* key, and channel name the hub uses — the single source of truth that keeps
|
|
6
|
+
* these names out of scattered string literals.
|
|
7
|
+
*
|
|
8
|
+
* **Keep this in sync with [`docs/guide/events.md`](../../../docs/guide/events.md)**
|
|
9
|
+
* (the Hub Events Reference): every name here appears in that page's tables, and
|
|
10
|
+
* every name there resolves to an entry here. Add, rename, or remove a name in
|
|
11
|
+
* both places in the same change, and reference `HUB_EVENTS.*` from call sites
|
|
12
|
+
* instead of re-typing a literal.
|
|
13
|
+
*
|
|
14
|
+
* The `.events` EventEmitter maps in `types/{docks,terminals,messages,commands}.ts`
|
|
15
|
+
* and the RPC augmentation interfaces in `node/context.ts` declare these same
|
|
16
|
+
* names as type-level keys (a literal is unavoidable in a type position); those
|
|
17
|
+
* declarations mirror this map and move with it.
|
|
18
|
+
*/
|
|
19
|
+
declare const HUB_EVENTS: {
|
|
20
|
+
/**
|
|
21
|
+
* Internal node `EventEmitter` events on `ctx.<subsystem>.events`. Emitted
|
|
22
|
+
* and consumed inside the node process (chiefly by `createHubContext`, which
|
|
23
|
+
* fans them out onto the wire); they never cross to the browser.
|
|
24
|
+
*/
|
|
25
|
+
readonly bus: {
|
|
26
|
+
readonly docksEntryUpdated: "docks:entry:updated";
|
|
27
|
+
readonly docksActivate: "docks:activate";
|
|
28
|
+
readonly terminalsSessionUpdated: "terminals:session:updated";
|
|
29
|
+
readonly messagesAdded: "messages:added";
|
|
30
|
+
readonly messagesUpdated: "messages:updated";
|
|
31
|
+
readonly messagesRemoved: "messages:removed";
|
|
32
|
+
readonly messagesCleared: "messages:cleared";
|
|
33
|
+
readonly commandsRegistered: "commands:registered";
|
|
34
|
+
readonly commandsUnregistered: "commands:unregistered";
|
|
35
|
+
};
|
|
36
|
+
/** Server RPC methods a connected client calls (client → server), `hub:` prefix. */
|
|
37
|
+
readonly rpc: {
|
|
38
|
+
readonly docksActivate: "hub:docks:activate";
|
|
39
|
+
readonly commandsExecute: "hub:commands:execute";
|
|
40
|
+
readonly messagesAdd: "hub:messages:add";
|
|
41
|
+
readonly messagesUpdate: "hub:messages:update";
|
|
42
|
+
readonly messagesRemove: "hub:messages:remove";
|
|
43
|
+
readonly messagesClear: "hub:messages:clear";
|
|
44
|
+
readonly terminalsWrite: "hub:terminals:write";
|
|
45
|
+
readonly terminalsResize: "hub:terminals:resize";
|
|
46
|
+
readonly terminalsTerminate: "hub:terminals:terminate";
|
|
47
|
+
readonly terminalsRestart: "hub:terminals:restart";
|
|
48
|
+
readonly terminalsRemove: "hub:terminals:remove";
|
|
49
|
+
};
|
|
50
|
+
/** Broadcast notifications the server pushes to clients (server → client), `devframe:` prefix. */
|
|
51
|
+
readonly broadcast: {
|
|
52
|
+
readonly docksActivate: "devframe:docks:activate";
|
|
53
|
+
readonly terminalsUpdated: "devframe:terminals:updated";
|
|
54
|
+
readonly messagesUpdated: "devframe:messages:updated";
|
|
55
|
+
};
|
|
56
|
+
/** Shared-state slot keys a hub-aware client reads (server → client), `devframe:` prefix. */
|
|
57
|
+
readonly sharedState: {
|
|
58
|
+
readonly docks: "devframe:docks";
|
|
59
|
+
readonly docksActive: "devframe:docks:active";
|
|
60
|
+
readonly commands: "devframe:commands";
|
|
61
|
+
readonly userSettings: "devframe:user-settings";
|
|
62
|
+
readonly dockRenderers: "devframe:dock-renderers";
|
|
63
|
+
};
|
|
64
|
+
/** Streaming channel ids (server → client), `devframe:` prefix. */
|
|
65
|
+
readonly stream: {
|
|
66
|
+
readonly terminals: "devframe:terminals";
|
|
67
|
+
};
|
|
68
|
+
/** `postMessage` channels for host ↔ iframe protocols, `devframe:` prefix. */
|
|
69
|
+
readonly postMessage: {
|
|
70
|
+
readonly frameNav: "devframe:frame-nav";
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/constants.d.ts
|
|
75
|
+
/** Default mount base for a hub instance — one namespace, one catch-all. */
|
|
76
|
+
declare const DEVFRAMES_HUB_BASE = "/__devframes/";
|
|
77
|
+
/**
|
|
78
|
+
* Normalize a hub mount base to an absolute path with leading and trailing
|
|
79
|
+
* slashes (e.g. `devframes` → `/devframes/`), collapsing any doubled
|
|
80
|
+
* slashes the input introduced. The one implementation every hub-aware
|
|
81
|
+
* host (`@devframes/hub` itself, and the Vite/Nuxt/Next adapters) resolves
|
|
82
|
+
* `options.base` through.
|
|
83
|
+
*/
|
|
84
|
+
declare function normalizeHubBase(base: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* The default ordering weight for each known dock category — lower sorts
|
|
87
|
+
* earlier. Downstream viewers (e.g. `@vitejs/devtools-kit`) import this as the
|
|
88
|
+
* single source of truth so the hub and its viewers agree on category order.
|
|
89
|
+
* `framework` sorts first; `~builtin` (the viewer's own built-in views) last.
|
|
90
|
+
*
|
|
91
|
+
* The buckets read from "closest to your app" → "platform / analysis" →
|
|
92
|
+
* "peripheral". Gaps between the weights are intentional: a kit can interleave
|
|
93
|
+
* its own categories (or override these) without editing this table.
|
|
94
|
+
*/
|
|
95
|
+
declare const DEFAULT_CATEGORIES_ORDER: Record<string, number>;
|
|
96
|
+
/**
|
|
97
|
+
* Shared-state slot carrying the hub's renderer manifest — one
|
|
98
|
+
* {@link import('./client/renderers').DockRendererManifest} entry per dock
|
|
99
|
+
* `type`, published by `initHub({ renderers })` and consumed by every
|
|
100
|
+
* hub-aware client (the headless client host and viewers alike).
|
|
101
|
+
*/
|
|
102
|
+
declare const DOCK_RENDERERS_STATE_KEY: string;
|
|
103
|
+
declare const DEFAULT_STATE_USER_SETTINGS: () => DevframeDocksUserSettings;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { normalizeHubBase as a, DOCK_RENDERERS_STATE_KEY as i, DEFAULT_STATE_USER_SETTINGS as n, HUB_EVENTS as o, DEVFRAMES_HUB_BASE as r, DEFAULT_CATEGORIES_ORDER as t };
|
package/dist/constants.d.mts
CHANGED
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { a as normalizeHubBase, i as DOCK_RENDERERS_STATE_KEY, n as DEFAULT_STATE_USER_SETTINGS, o as HUB_EVENTS, r as DEVFRAMES_HUB_BASE, t as DEFAULT_CATEGORIES_ORDER } from "./constants-CmESZCBq.mjs";
|
|
2
2
|
export * from "devframe/constants";
|
|
3
|
-
|
|
4
|
-
/** Default mount base for a hub instance — one namespace, one catch-all. */
|
|
5
|
-
declare const DEVFRAMES_HUB_BASE = "/__devframes/";
|
|
6
|
-
/**
|
|
7
|
-
* Normalize a hub mount base to an absolute path with leading and trailing
|
|
8
|
-
* slashes (e.g. `devframes` → `/devframes/`), collapsing any doubled
|
|
9
|
-
* slashes the input introduced. The one implementation every hub-aware
|
|
10
|
-
* host (`@devframes/hub` itself, and the Vite/Nuxt/Next adapters) resolves
|
|
11
|
-
* `options.base` through.
|
|
12
|
-
*/
|
|
13
|
-
declare function normalizeHubBase(base: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* The default ordering weight for each known dock category — lower sorts
|
|
16
|
-
* earlier. Downstream viewers (e.g. `@vitejs/devtools-kit`) import this as the
|
|
17
|
-
* single source of truth so the hub and its viewers agree on category order.
|
|
18
|
-
* `framework` sorts first; `~builtin` (the viewer's own built-in views) last.
|
|
19
|
-
*
|
|
20
|
-
* The buckets read from "closest to your app" → "platform / analysis" →
|
|
21
|
-
* "peripheral". Gaps between the weights are intentional: a kit can interleave
|
|
22
|
-
* its own categories (or override these) without editing this table.
|
|
23
|
-
*/
|
|
24
|
-
declare const DEFAULT_CATEGORIES_ORDER: Record<string, number>;
|
|
25
|
-
/**
|
|
26
|
-
* Shared-state slot carrying the hub's renderer manifest — one
|
|
27
|
-
* {@link import('./client/renderers').DockRendererManifest} entry per dock
|
|
28
|
-
* `type`, published by `initHub({ renderers })` and consumed by every
|
|
29
|
-
* hub-aware client (the headless client host and viewers alike).
|
|
30
|
-
*/
|
|
31
|
-
declare const DOCK_RENDERERS_STATE_KEY = "devframe:dock-renderers";
|
|
32
|
-
declare const DEFAULT_STATE_USER_SETTINGS: () => DevframeDocksUserSettings;
|
|
33
|
-
//#endregion
|
|
34
|
-
export { DEFAULT_CATEGORIES_ORDER, DEFAULT_STATE_USER_SETTINGS, DEVFRAMES_HUB_BASE, DOCK_RENDERERS_STATE_KEY, normalizeHubBase };
|
|
3
|
+
export { DEFAULT_CATEGORIES_ORDER, DEFAULT_STATE_USER_SETTINGS, DEVFRAMES_HUB_BASE, DOCK_RENDERERS_STATE_KEY, HUB_EVENTS, normalizeHubBase };
|
package/dist/constants.mjs
CHANGED
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as normalizeHubBase, i as DOCK_RENDERERS_STATE_KEY, n as DEFAULT_STATE_USER_SETTINGS, o as HUB_EVENTS, r as DEVFRAMES_HUB_BASE, t as DEFAULT_CATEGORIES_ORDER } from "./constants-C2b2cACy.mjs";
|
|
2
2
|
export * from "devframe/constants";
|
|
3
|
-
|
|
4
|
-
/** Default mount base for a hub instance — one namespace, one catch-all. */
|
|
5
|
-
const DEVFRAMES_HUB_BASE = "/__devframes/";
|
|
6
|
-
/**
|
|
7
|
-
* Normalize a hub mount base to an absolute path with leading and trailing
|
|
8
|
-
* slashes (e.g. `devframes` → `/devframes/`), collapsing any doubled
|
|
9
|
-
* slashes the input introduced. The one implementation every hub-aware
|
|
10
|
-
* host (`@devframes/hub` itself, and the Vite/Nuxt/Next adapters) resolves
|
|
11
|
-
* `options.base` through.
|
|
12
|
-
*/
|
|
13
|
-
function normalizeHubBase(base) {
|
|
14
|
-
return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base)));
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* The default ordering weight for each known dock category — lower sorts
|
|
18
|
-
* earlier. Downstream viewers (e.g. `@vitejs/devtools-kit`) import this as the
|
|
19
|
-
* single source of truth so the hub and its viewers agree on category order.
|
|
20
|
-
* `framework` sorts first; `~builtin` (the viewer's own built-in views) last.
|
|
21
|
-
*
|
|
22
|
-
* The buckets read from "closest to your app" → "platform / analysis" →
|
|
23
|
-
* "peripheral". Gaps between the weights are intentional: a kit can interleave
|
|
24
|
-
* its own categories (or override these) without editing this table.
|
|
25
|
-
*/
|
|
26
|
-
const DEFAULT_CATEGORIES_ORDER = {
|
|
27
|
-
"framework": -100,
|
|
28
|
-
"default": 0,
|
|
29
|
-
"app": 100,
|
|
30
|
-
"ui": 150,
|
|
31
|
-
"data": 250,
|
|
32
|
-
"web": 300,
|
|
33
|
-
"performance": 350,
|
|
34
|
-
"advanced": 400,
|
|
35
|
-
"docs": 500,
|
|
36
|
-
"~builtin": 1e3
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Shared-state slot carrying the hub's renderer manifest — one
|
|
40
|
-
* {@link import('./client/renderers').DockRendererManifest} entry per dock
|
|
41
|
-
* `type`, published by `initHub({ renderers })` and consumed by every
|
|
42
|
-
* hub-aware client (the headless client host and viewers alike).
|
|
43
|
-
*/
|
|
44
|
-
const DOCK_RENDERERS_STATE_KEY = "devframe:dock-renderers";
|
|
45
|
-
const DEFAULT_STATE_USER_SETTINGS = () => ({
|
|
46
|
-
docksHidden: [],
|
|
47
|
-
docksCategoriesHidden: [],
|
|
48
|
-
docksPinned: [],
|
|
49
|
-
docksCustomOrder: {},
|
|
50
|
-
commandShortcuts: {}
|
|
51
|
-
});
|
|
52
|
-
//#endregion
|
|
53
|
-
export { DEFAULT_CATEGORIES_ORDER, DEFAULT_STATE_USER_SETTINGS, DEVFRAMES_HUB_BASE, DOCK_RENDERERS_STATE_KEY, normalizeHubBase };
|
|
3
|
+
export { DEFAULT_CATEGORIES_ORDER, DEFAULT_STATE_USER_SETTINGS, DEVFRAMES_HUB_BASE, DOCK_RENDERERS_STATE_KEY, HUB_EVENTS, normalizeHubBase };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as DevframeDockEntryIcon, k as DevframeViewIframe, l as DevframeCommandsHost, m as DevframeDockActivation, w as DevframeDocksHost } from "./settings-
|
|
1
|
+
import { b as DevframeDockEntryIcon, k as DevframeViewIframe, l as DevframeCommandsHost, m as DevframeDockActivation, w as DevframeDocksHost } from "./settings-D7whfcx2.mjs";
|
|
2
2
|
import { CreateHostContextOptions } from "devframe/node";
|
|
3
3
|
import { DevframeDefinition, DevframeHost, DevframeNodeContext, EventEmitter } from "devframe/types";
|
|
4
4
|
import { ChildProcess } from "node:child_process";
|
|
@@ -207,10 +207,10 @@ interface DevframeMessagesListDelta {
|
|
|
207
207
|
interface DevframeMessagesHost extends DevframeMessagesLevelShortcuts {
|
|
208
208
|
readonly entries: Map<string, DevframeMessageEntry>;
|
|
209
209
|
readonly events: EventEmitter<{
|
|
210
|
-
'
|
|
211
|
-
'
|
|
212
|
-
'
|
|
213
|
-
'
|
|
210
|
+
'messages:added': (entry: DevframeMessageEntry) => void;
|
|
211
|
+
'messages:updated': (entry: DevframeMessageEntry) => void;
|
|
212
|
+
'messages:removed': (id: string) => void;
|
|
213
|
+
'messages:cleared': () => void;
|
|
214
214
|
}>;
|
|
215
215
|
/**
|
|
216
216
|
* Add a new message entry. If an entry with the same `id` already exists, it will be updated instead.
|
|
@@ -244,7 +244,7 @@ interface DevframeMessagesHost extends DevframeMessagesLevelShortcuts {
|
|
|
244
244
|
interface DevframeTerminalsHost {
|
|
245
245
|
readonly sessions: Map<string, DevframeTerminalSession>;
|
|
246
246
|
readonly events: EventEmitter<{
|
|
247
|
-
'
|
|
247
|
+
'terminals:session:updated': (session: DevframeTerminalSession) => void;
|
|
248
248
|
}>;
|
|
249
249
|
register: (session: DevframeTerminalSession) => DevframeTerminalSession;
|
|
250
250
|
update: (session: DevframeTerminalSession) => void;
|