@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as defineHubRpcFunction } from "./define-Ceekw2EO.mjs";
|
|
2
|
-
import { DEFAULT_STATE_USER_SETTINGS } from "./constants.mjs";
|
|
3
|
-
import { t as buildRemoteConnectionUrl } from "./remote-url-
|
|
2
|
+
import { n as DEFAULT_STATE_USER_SETTINGS, o as HUB_EVENTS } from "./constants-C2b2cACy.mjs";
|
|
3
|
+
import { i as isBareModuleSpecifier, t as buildRemoteConnectionUrl } from "./remote-url-Bgc7gtsP.mjs";
|
|
4
4
|
import { createEventEmitter } from "devframe/utils/events";
|
|
5
5
|
import { createHostContext, createStorage } from "devframe/node";
|
|
6
6
|
import { getInternalContext, resolveBasePath } from "devframe/node/hub-internals";
|
|
@@ -74,6 +74,10 @@ const diagnostics = defineDiagnostics({
|
|
|
74
74
|
why: (p) => `Dock type "${p.type}" is not a servable renderer-module name — the hub serves each module at \`<base>__renderers/<type>.mjs\``,
|
|
75
75
|
fix: "Renderer types become URL segments, so they may only contain letters, digits, `_`, `-`, and `.`. Use a route-safe dock type (e.g. `json-render`)."
|
|
76
76
|
},
|
|
77
|
+
DF8111: {
|
|
78
|
+
why: (p) => `Dock "${p.id}" declares the bare-specifier client script "${p.specifier}", but this host advertises no client-module resolution — the browser cannot resolve a bare npm specifier natively, so the script will fail to load.`,
|
|
79
|
+
fix: "Run under a host that declares `initHub({ clientModuleResolution })` (e.g. Vite's `'/@id/{specifier}'`), ship the script as a self-contained bundle served by URL, or resolve it in the viewer via `createDevframeClientHost({ resolveClientModule })` (then disregard this warning)."
|
|
80
|
+
},
|
|
77
81
|
DF8200: { why: (p) => `Terminal session with id "${p.id}" already registered` },
|
|
78
82
|
DF8201: { why: (p) => `Terminal session with id "${p.id}" not registered` },
|
|
79
83
|
DF8202: {
|
|
@@ -152,7 +156,7 @@ var DevframeCommandsHost = class {
|
|
|
152
156
|
validateCommandIds(this.commands, command);
|
|
153
157
|
this.validateAgentExposure(command);
|
|
154
158
|
this.commands.set(command.id, command);
|
|
155
|
-
this.events.emit(
|
|
159
|
+
this.events.emit(HUB_EVENTS.bus.commandsRegistered, this.toSerializable(command));
|
|
156
160
|
this.agentProvider?.notifyChanged();
|
|
157
161
|
return {
|
|
158
162
|
id: command.id,
|
|
@@ -168,7 +172,7 @@ var DevframeCommandsHost = class {
|
|
|
168
172
|
validateCommandIds(this.commands, next, existing.id);
|
|
169
173
|
this.validateAgentExposure(next);
|
|
170
174
|
Object.assign(existing, patch);
|
|
171
|
-
this.events.emit(
|
|
175
|
+
this.events.emit(HUB_EVENTS.bus.commandsRegistered, this.toSerializable(existing));
|
|
172
176
|
this.agentProvider?.notifyChanged();
|
|
173
177
|
},
|
|
174
178
|
unregister: () => this.unregister(command.id)
|
|
@@ -177,7 +181,7 @@ var DevframeCommandsHost = class {
|
|
|
177
181
|
unregister(id) {
|
|
178
182
|
const deleted = this.commands.delete(id);
|
|
179
183
|
if (deleted) {
|
|
180
|
-
this.events.emit(
|
|
184
|
+
this.events.emit(HUB_EVENTS.bus.commandsUnregistered, id);
|
|
181
185
|
this.agentProvider?.notifyChanged();
|
|
182
186
|
}
|
|
183
187
|
return deleted;
|
|
@@ -259,7 +263,7 @@ var DevframeDocksHost = class {
|
|
|
259
263
|
this.context = context;
|
|
260
264
|
}
|
|
261
265
|
async init() {
|
|
262
|
-
this.userSettings = await this.context.rpc.sharedState.get(
|
|
266
|
+
this.userSettings = await this.context.rpc.sharedState.get(HUB_EVENTS.sharedState.userSettings, { sharedState: createStorage({
|
|
263
267
|
filepath: join(this.context.host.getStorageDir("project"), "settings.json"),
|
|
264
268
|
initialValue: DEFAULT_STATE_USER_SETTINGS()
|
|
265
269
|
}) });
|
|
@@ -290,9 +294,10 @@ var DevframeDocksHost = class {
|
|
|
290
294
|
register(view, force) {
|
|
291
295
|
if (this.views.has(view.id) && !force) throw diagnostics.DF8100({ id: view.id });
|
|
292
296
|
this.validateGroupMembership(view);
|
|
297
|
+
this.warnUnresolvableClientScript(view);
|
|
293
298
|
this.prepareRemoteRegistration(view);
|
|
294
299
|
this.views.set(view.id, view);
|
|
295
|
-
this.events.emit(
|
|
300
|
+
this.events.emit(HUB_EVENTS.bus.docksEntryUpdated, view);
|
|
296
301
|
return { update: (patch) => {
|
|
297
302
|
if (patch.id && patch.id !== view.id) throw diagnostics.DF8101({
|
|
298
303
|
id: view.id,
|
|
@@ -309,15 +314,30 @@ var DevframeDocksHost = class {
|
|
|
309
314
|
this.validateGroupMembership(view);
|
|
310
315
|
this.prepareRemoteRegistration(view);
|
|
311
316
|
this.views.set(view.id, view);
|
|
312
|
-
this.events.emit(
|
|
317
|
+
this.events.emit(HUB_EVENTS.bus.docksEntryUpdated, view);
|
|
313
318
|
}
|
|
314
319
|
activate(dockId, params) {
|
|
315
320
|
if (!this.views.has(dockId)) diagnostics.DF8107({ id: dockId });
|
|
316
|
-
this.events.emit(
|
|
321
|
+
this.events.emit(HUB_EVENTS.bus.docksActivate, {
|
|
317
322
|
dockId,
|
|
318
323
|
params
|
|
319
324
|
});
|
|
320
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Warn (don't throw — a viewer-side `resolveClientModule` may still cover
|
|
328
|
+
* it) when a dock declares a **bare-specifier** client script on a host
|
|
329
|
+
* that advertises no `staticConfig.dock.clientModuleResolution`: the
|
|
330
|
+
* browser cannot resolve a bare npm specifier natively, so the script is
|
|
331
|
+
* doomed to fail there.
|
|
332
|
+
*/
|
|
333
|
+
warnUnresolvableClientScript(view) {
|
|
334
|
+
if (this.context.staticConfig?.dock?.clientModuleResolution) return;
|
|
335
|
+
const script = view.clientScript ?? view.action ?? view.renderer;
|
|
336
|
+
if (script?.importFrom && isBareModuleSpecifier(script.importFrom)) diagnostics.DF8111({
|
|
337
|
+
id: view.id,
|
|
338
|
+
specifier: script.importFrom
|
|
339
|
+
});
|
|
340
|
+
}
|
|
321
341
|
validateGroupMembership(view) {
|
|
322
342
|
if (view.groupId === void 0) return;
|
|
323
343
|
if (view.groupId === view.id) throw diagnostics.DF8103({ id: view.id });
|
|
@@ -395,7 +415,7 @@ var DevframeMessagesHost = class {
|
|
|
395
415
|
}
|
|
396
416
|
this.entries.set(entry.id, entry);
|
|
397
417
|
this.lastModified.set(entry.id, this._tick());
|
|
398
|
-
this.events.emit(
|
|
418
|
+
this.events.emit(HUB_EVENTS.bus.messagesAdded, entry);
|
|
399
419
|
if (entry.autoDelete) this._autoDeleteTimers.set(entry.id, setTimeout(() => {
|
|
400
420
|
this.remove(entry.id);
|
|
401
421
|
}, entry.autoDelete));
|
|
@@ -413,7 +433,7 @@ var DevframeMessagesHost = class {
|
|
|
413
433
|
};
|
|
414
434
|
this.entries.set(id, updated);
|
|
415
435
|
this.lastModified.set(id, this._tick());
|
|
416
|
-
this.events.emit(
|
|
436
|
+
this.events.emit(HUB_EVENTS.bus.messagesUpdated, updated);
|
|
417
437
|
if (patch.autoDelete !== void 0) {
|
|
418
438
|
const timer = this._autoDeleteTimers.get(id);
|
|
419
439
|
if (timer) {
|
|
@@ -435,7 +455,7 @@ var DevframeMessagesHost = class {
|
|
|
435
455
|
this.entries.delete(id);
|
|
436
456
|
this.lastModified.delete(id);
|
|
437
457
|
this._recordRemoval(id, this._tick());
|
|
438
|
-
this.events.emit(
|
|
458
|
+
this.events.emit(HUB_EVENTS.bus.messagesRemoved, id);
|
|
439
459
|
}
|
|
440
460
|
info(message, extra) {
|
|
441
461
|
return this.add({
|
|
@@ -479,7 +499,7 @@ var DevframeMessagesHost = class {
|
|
|
479
499
|
for (const id of this.entries.keys()) this._recordRemoval(id, tick);
|
|
480
500
|
this.entries.clear();
|
|
481
501
|
this.lastModified.clear();
|
|
482
|
-
this.events.emit(
|
|
502
|
+
this.events.emit(HUB_EVENTS.bus.messagesCleared);
|
|
483
503
|
}
|
|
484
504
|
listSince(since) {
|
|
485
505
|
const version = this._clock;
|
|
@@ -523,7 +543,7 @@ var DevframeMessagesHost = class {
|
|
|
523
543
|
* Channel name used for terminal stream output. Stable, well-known so
|
|
524
544
|
* hub-aware clients can subscribe by name.
|
|
525
545
|
*/
|
|
526
|
-
const TERMINAL_STREAM_CHANNEL =
|
|
546
|
+
const TERMINAL_STREAM_CHANNEL = HUB_EVENTS.stream.terminals;
|
|
527
547
|
const TERMINAL_REPLAY_WINDOW = 1e3;
|
|
528
548
|
/** Max chunks retained in the per-session scrollback buffer (bounded like the replay window). */
|
|
529
549
|
const TERMINAL_BUFFER_LIMIT = 1e3;
|
|
@@ -553,7 +573,7 @@ var DevframeTerminalsHost = class {
|
|
|
553
573
|
if (this.sessions.has(session.id)) throw diagnostics.DF8200({ id: session.id });
|
|
554
574
|
this.sessions.set(session.id, session);
|
|
555
575
|
this.bindStream(session);
|
|
556
|
-
this.events.emit(
|
|
576
|
+
this.events.emit(HUB_EVENTS.bus.terminalsSessionUpdated, session);
|
|
557
577
|
return session;
|
|
558
578
|
}
|
|
559
579
|
update(patch) {
|
|
@@ -562,12 +582,12 @@ var DevframeTerminalsHost = class {
|
|
|
562
582
|
Object.assign(session, patch);
|
|
563
583
|
this.sessions.set(patch.id, session);
|
|
564
584
|
this.bindStream(session);
|
|
565
|
-
this.events.emit(
|
|
585
|
+
this.events.emit(HUB_EVENTS.bus.terminalsSessionUpdated, session);
|
|
566
586
|
}
|
|
567
587
|
remove(session) {
|
|
568
588
|
this._boundStreams.get(session.id)?.dispose();
|
|
569
589
|
this.sessions.delete(session.id);
|
|
570
|
-
this.events.emit(
|
|
590
|
+
this.events.emit(HUB_EVENTS.bus.terminalsSessionUpdated, session);
|
|
571
591
|
this._boundStreams.delete(session.id);
|
|
572
592
|
}
|
|
573
593
|
bindStream(session) {
|
|
@@ -621,7 +641,7 @@ var DevframeTerminalsHost = class {
|
|
|
621
641
|
const markStatus = (next) => {
|
|
622
642
|
if (session.status === next) return;
|
|
623
643
|
session.status = next;
|
|
624
|
-
this.events.emit(
|
|
644
|
+
this.events.emit(HUB_EVENTS.bus.terminalsSessionUpdated, session);
|
|
625
645
|
};
|
|
626
646
|
const closeStream = () => {
|
|
627
647
|
if (streamClosed) return;
|
|
@@ -755,7 +775,7 @@ var DevframeTerminalsHost = class {
|
|
|
755
775
|
const markStatus = (next) => {
|
|
756
776
|
if (session.status === next) return;
|
|
757
777
|
session.status = next;
|
|
758
|
-
this.events.emit(
|
|
778
|
+
this.events.emit(HUB_EVENTS.bus.terminalsSessionUpdated, session);
|
|
759
779
|
};
|
|
760
780
|
const closeStream = () => {
|
|
761
781
|
if (streamClosed) return;
|
|
@@ -884,7 +904,18 @@ function nextAvailableDockId(views, baseId) {
|
|
|
884
904
|
* machinery — e.g. `@vitejs/devtools-kit`'s `createPluginFromDevframe`
|
|
885
905
|
* returns a Vite `Plugin` whose `devtools.setup` ultimately delegates here.
|
|
886
906
|
*/
|
|
887
|
-
|
|
907
|
+
/**
|
|
908
|
+
* Phase one of an install: run the duplication guard, serve the SPA + meta,
|
|
909
|
+
* register the iframe dock, and queue the definition's declarative wire
|
|
910
|
+
* services — everything up to (but not including) `setup(ctx)`. Returns a
|
|
911
|
+
* deferred setup thunk, or `null` when the devframe was deduplicated.
|
|
912
|
+
*
|
|
913
|
+
* The hub's initial batch uses this to collect every devframe's services
|
|
914
|
+
* across the whole hub, `ready()` them once, and only then run the setups —
|
|
915
|
+
* so services are ready before any setup, and a plugin can consume a service
|
|
916
|
+
* another plugin declared regardless of mount order.
|
|
917
|
+
*/
|
|
918
|
+
async function prepareDevframe(ctx, d, options = {}) {
|
|
888
919
|
const strategy = d.duplicationStrategy ?? "warn";
|
|
889
920
|
const isDuplicate = ctx.docks.views.has(d.id);
|
|
890
921
|
if (isDuplicate && strategy !== "duplicate") {
|
|
@@ -896,7 +927,7 @@ async function installDevframe(ctx, d, options = {}) {
|
|
|
896
927
|
id: d.id,
|
|
897
928
|
name: d.name
|
|
898
929
|
});
|
|
899
|
-
return;
|
|
930
|
+
return null;
|
|
900
931
|
}
|
|
901
932
|
const id = isDuplicate ? nextAvailableDockId(ctx.docks.views, d.id) : d.id;
|
|
902
933
|
const base = options.base ?? (id === d.id ? resolveBasePath(d, "hosted") : resolveBasePath({
|
|
@@ -912,7 +943,7 @@ async function installDevframe(ctx, d, options = {}) {
|
|
|
912
943
|
base
|
|
913
944
|
});
|
|
914
945
|
const distSource = d.cli.distDir;
|
|
915
|
-
ctx.views.hostStatic(base, typeof distSource === "string" ? resolve(distSource) : distSource);
|
|
946
|
+
ctx.views.hostStatic(base, typeof distSource === "string" ? resolve(distSource) : distSource, d.importMetaUrl);
|
|
916
947
|
}
|
|
917
948
|
ctx.docks.register({
|
|
918
949
|
id,
|
|
@@ -923,7 +954,21 @@ async function installDevframe(ctx, d, options = {}) {
|
|
|
923
954
|
type: "iframe",
|
|
924
955
|
url: base
|
|
925
956
|
});
|
|
926
|
-
|
|
957
|
+
for (const input of d.services ?? []) ctx.services.install(input, { resolveFrom: d.importMetaUrl });
|
|
958
|
+
return () => Promise.resolve(d.setup(ctx));
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Install a {@link DevframeDefinition} into a hub in one call — serve its SPA,
|
|
962
|
+
* register its dock, ready its services, and run `setup(ctx)`. The imperative
|
|
963
|
+
* counterpart to the hub's declarative `devframes` list (which batches the
|
|
964
|
+
* phases via {@link prepareDevframe}); use it from `configure(ctx)` or
|
|
965
|
+
* wherever you hold the context to plug in an extra devframe after startup.
|
|
966
|
+
*/
|
|
967
|
+
async function installDevframe(ctx, d, options = {}) {
|
|
968
|
+
const run = await prepareDevframe(ctx, d, options);
|
|
969
|
+
if (!run) return;
|
|
970
|
+
await ctx.services.ready();
|
|
971
|
+
await run();
|
|
927
972
|
}
|
|
928
973
|
//#endregion
|
|
929
974
|
//#region src/node/rpc-builtins.ts
|
|
@@ -957,7 +1002,7 @@ function resolveControllableSession(sessions, id) {
|
|
|
957
1002
|
* from the shared state and dispatch by id via this RPC.
|
|
958
1003
|
*/
|
|
959
1004
|
const hubCommandsExecute = defineHubRpcFunction({
|
|
960
|
-
name:
|
|
1005
|
+
name: HUB_EVENTS.rpc.commandsExecute,
|
|
961
1006
|
type: "action",
|
|
962
1007
|
setup: (context) => ({ async handler(id, ...args) {
|
|
963
1008
|
return context.commands.execute(id, ...args);
|
|
@@ -973,7 +1018,7 @@ const hubCommandsExecute = defineHubRpcFunction({
|
|
|
973
1018
|
* dock client script can report into the same feed the server writes to.
|
|
974
1019
|
*/
|
|
975
1020
|
const hubMessagesAdd = defineHubRpcFunction({
|
|
976
|
-
name:
|
|
1021
|
+
name: HUB_EVENTS.rpc.messagesAdd,
|
|
977
1022
|
type: "action",
|
|
978
1023
|
jsonSerializable: true,
|
|
979
1024
|
setup: (context) => ({ async handler(input) {
|
|
@@ -985,7 +1030,7 @@ const hubMessagesAdd = defineHubRpcFunction({
|
|
|
985
1030
|
});
|
|
986
1031
|
/** `hub:messages:update` — Patch a message by id; returns the updated entry (or `undefined`). */
|
|
987
1032
|
const hubMessagesUpdate = defineHubRpcFunction({
|
|
988
|
-
name:
|
|
1033
|
+
name: HUB_EVENTS.rpc.messagesUpdate,
|
|
989
1034
|
type: "action",
|
|
990
1035
|
jsonSerializable: true,
|
|
991
1036
|
setup: (context) => ({ async handler(id, patch) {
|
|
@@ -994,7 +1039,7 @@ const hubMessagesUpdate = defineHubRpcFunction({
|
|
|
994
1039
|
});
|
|
995
1040
|
/** `hub:messages:remove` — Remove a message by id. */
|
|
996
1041
|
const hubMessagesRemove = defineHubRpcFunction({
|
|
997
|
-
name:
|
|
1042
|
+
name: HUB_EVENTS.rpc.messagesRemove,
|
|
998
1043
|
type: "action",
|
|
999
1044
|
setup: (context) => ({ async handler(id) {
|
|
1000
1045
|
await context.messages.remove(id);
|
|
@@ -1002,7 +1047,7 @@ const hubMessagesRemove = defineHubRpcFunction({
|
|
|
1002
1047
|
});
|
|
1003
1048
|
/** `hub:messages:clear` — Remove every message. */
|
|
1004
1049
|
const hubMessagesClear = defineHubRpcFunction({
|
|
1005
|
-
name:
|
|
1050
|
+
name: HUB_EVENTS.rpc.messagesClear,
|
|
1006
1051
|
type: "action",
|
|
1007
1052
|
setup: (context) => ({ async handler() {
|
|
1008
1053
|
await context.messages.clear();
|
|
@@ -1014,7 +1059,7 @@ const hubMessagesClear = defineHubRpcFunction({
|
|
|
1014
1059
|
* terminals plugin) drive a session owned by another plugin.
|
|
1015
1060
|
*/
|
|
1016
1061
|
const hubTerminalsWrite = defineHubRpcFunction({
|
|
1017
|
-
name:
|
|
1062
|
+
name: HUB_EVENTS.rpc.terminalsWrite,
|
|
1018
1063
|
type: "action",
|
|
1019
1064
|
setup: (context) => ({ async handler(id, data) {
|
|
1020
1065
|
resolveInteractiveSession(context.terminals.sessions, id).write(data);
|
|
@@ -1022,7 +1067,7 @@ const hubTerminalsWrite = defineHubRpcFunction({
|
|
|
1022
1067
|
});
|
|
1023
1068
|
/** `hub:terminals:resize` — Resize an interactive PTY session by id. */
|
|
1024
1069
|
const hubTerminalsResize = defineHubRpcFunction({
|
|
1025
|
-
name:
|
|
1070
|
+
name: HUB_EVENTS.rpc.terminalsResize,
|
|
1026
1071
|
type: "action",
|
|
1027
1072
|
setup: (context) => ({ async handler(id, cols, rows) {
|
|
1028
1073
|
resolveInteractiveSession(context.terminals.sessions, id).resize(cols, rows);
|
|
@@ -1035,7 +1080,7 @@ const hubTerminalsResize = defineHubRpcFunction({
|
|
|
1035
1080
|
* force-kill a session owned by another plugin.
|
|
1036
1081
|
*/
|
|
1037
1082
|
const hubTerminalsTerminate = defineHubRpcFunction({
|
|
1038
|
-
name:
|
|
1083
|
+
name: HUB_EVENTS.rpc.terminalsTerminate,
|
|
1039
1084
|
type: "action",
|
|
1040
1085
|
setup: (context) => ({ async handler(id) {
|
|
1041
1086
|
await resolveControllableSession(context.terminals.sessions, id).terminate();
|
|
@@ -1047,7 +1092,7 @@ const hubTerminalsTerminate = defineHubRpcFunction({
|
|
|
1047
1092
|
* elsewhere.
|
|
1048
1093
|
*/
|
|
1049
1094
|
const hubTerminalsRestart = defineHubRpcFunction({
|
|
1050
|
-
name:
|
|
1095
|
+
name: HUB_EVENTS.rpc.terminalsRestart,
|
|
1051
1096
|
type: "action",
|
|
1052
1097
|
setup: (context) => ({ async handler(id) {
|
|
1053
1098
|
const session = resolveControllableSession(context.terminals.sessions, id);
|
|
@@ -1061,7 +1106,7 @@ const hubTerminalsRestart = defineHubRpcFunction({
|
|
|
1061
1106
|
* terminal UI discard a stopped aggregated session.
|
|
1062
1107
|
*/
|
|
1063
1108
|
const hubTerminalsRemove = defineHubRpcFunction({
|
|
1064
|
-
name:
|
|
1109
|
+
name: HUB_EVENTS.rpc.terminalsRemove,
|
|
1065
1110
|
type: "action",
|
|
1066
1111
|
setup: (context) => ({ async handler(id) {
|
|
1067
1112
|
const session = context.terminals.sessions.get(id);
|
|
@@ -1084,7 +1129,7 @@ const hubTerminalsRemove = defineHubRpcFunction({
|
|
|
1084
1129
|
* mounts in response still converges on it).
|
|
1085
1130
|
*/
|
|
1086
1131
|
const hubDocksActivate = defineHubRpcFunction({
|
|
1087
|
-
name:
|
|
1132
|
+
name: HUB_EVENTS.rpc.docksActivate,
|
|
1088
1133
|
type: "action",
|
|
1089
1134
|
setup: (context) => ({ async handler(input) {
|
|
1090
1135
|
context.docks.activate(input.dockId, input.params);
|
|
@@ -1133,50 +1178,50 @@ async function createHubContext(options) {
|
|
|
1133
1178
|
context.install = (devframe, options) => installDevframe(context, devframe, options);
|
|
1134
1179
|
await docks.init();
|
|
1135
1180
|
const debounceMs = options.mode === "build" ? 0 : 10;
|
|
1136
|
-
const docksSharedState = await context.rpc.sharedState.get(
|
|
1181
|
+
const docksSharedState = await context.rpc.sharedState.get(HUB_EVENTS.sharedState.docks, { initialValue: [] });
|
|
1137
1182
|
const refreshDocks = debounce(() => {
|
|
1138
1183
|
docksSharedState.mutate(() => docks.values());
|
|
1139
1184
|
}, debounceMs);
|
|
1140
|
-
docks.events.on(
|
|
1185
|
+
docks.events.on(HUB_EVENTS.bus.docksEntryUpdated, refreshDocks);
|
|
1141
1186
|
getInternalContext(context).onWsEndpointChange(refreshDocks);
|
|
1142
1187
|
docksSharedState.mutate(() => docks.values());
|
|
1143
|
-
const activeDockSharedState = await context.rpc.sharedState.get(
|
|
1144
|
-
docks.events.on(
|
|
1188
|
+
const activeDockSharedState = await context.rpc.sharedState.get(HUB_EVENTS.sharedState.docksActive, { initialValue: { activation: null } });
|
|
1189
|
+
docks.events.on(HUB_EVENTS.bus.docksActivate, (activation) => {
|
|
1145
1190
|
activeDockSharedState.mutate((state) => {
|
|
1146
1191
|
state.activation = activation;
|
|
1147
1192
|
});
|
|
1148
1193
|
context.rpc.broadcast({
|
|
1149
|
-
method:
|
|
1194
|
+
method: HUB_EVENTS.broadcast.docksActivate,
|
|
1150
1195
|
args: [activation]
|
|
1151
1196
|
});
|
|
1152
1197
|
});
|
|
1153
1198
|
const broadcastTerminals = debounce(() => {
|
|
1154
1199
|
context.rpc.broadcast({
|
|
1155
|
-
method:
|
|
1200
|
+
method: HUB_EVENTS.broadcast.terminalsUpdated,
|
|
1156
1201
|
args: []
|
|
1157
1202
|
});
|
|
1158
1203
|
docksSharedState.mutate(() => docks.values());
|
|
1159
1204
|
}, debounceMs);
|
|
1160
|
-
terminals.events.on(
|
|
1205
|
+
terminals.events.on(HUB_EVENTS.bus.terminalsSessionUpdated, broadcastTerminals);
|
|
1161
1206
|
const broadcastMessages = debounce(() => {
|
|
1162
1207
|
context.rpc.broadcast({
|
|
1163
|
-
method:
|
|
1208
|
+
method: HUB_EVENTS.broadcast.messagesUpdated,
|
|
1164
1209
|
args: []
|
|
1165
1210
|
});
|
|
1166
1211
|
docksSharedState.mutate(() => docks.values());
|
|
1167
1212
|
}, debounceMs);
|
|
1168
|
-
messages.events.on(
|
|
1169
|
-
messages.events.on(
|
|
1170
|
-
messages.events.on(
|
|
1171
|
-
messages.events.on(
|
|
1172
|
-
const commandsSharedState = await context.rpc.sharedState.get(
|
|
1213
|
+
messages.events.on(HUB_EVENTS.bus.messagesAdded, broadcastMessages);
|
|
1214
|
+
messages.events.on(HUB_EVENTS.bus.messagesUpdated, broadcastMessages);
|
|
1215
|
+
messages.events.on(HUB_EVENTS.bus.messagesRemoved, broadcastMessages);
|
|
1216
|
+
messages.events.on(HUB_EVENTS.bus.messagesCleared, broadcastMessages);
|
|
1217
|
+
const commandsSharedState = await context.rpc.sharedState.get(HUB_EVENTS.sharedState.commands, { initialValue: [] });
|
|
1173
1218
|
const syncCommands = debounce(() => {
|
|
1174
1219
|
commandsSharedState.mutate(() => commands.list());
|
|
1175
1220
|
}, debounceMs);
|
|
1176
|
-
commands.events.on(
|
|
1177
|
-
commands.events.on(
|
|
1221
|
+
commands.events.on(HUB_EVENTS.bus.commandsRegistered, syncCommands);
|
|
1222
|
+
commands.events.on(HUB_EVENTS.bus.commandsUnregistered, syncCommands);
|
|
1178
1223
|
commandsSharedState.mutate(() => commands.list());
|
|
1179
1224
|
return context;
|
|
1180
1225
|
}
|
|
1181
1226
|
//#endregion
|
|
1182
|
-
export {
|
|
1227
|
+
export { DevframeDocksHost as _, hubMessagesAdd as a, hubMessagesUpdate as c, hubTerminalsRestart as d, hubTerminalsTerminate as f, DevframeMessagesHost as g, DevframeTerminalsHost as h, hubDocksActivate as i, hubTerminalsRemove as l, prepareDevframe as m, builtinHubRpcDeclarations as n, hubMessagesClear as o, hubTerminalsWrite as p, hubCommandsExecute as r, hubMessagesRemove as s, createHubContext as t, hubTerminalsResize as u, DevframeCommandsHost as v, diagnostics as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./context-
|
|
2
|
-
import "./settings-
|
|
1
|
+
import "./context-BVkxwz5k.mjs";
|
|
2
|
+
import "./settings-D7whfcx2.mjs";
|
|
3
3
|
import { RpcDefinitionsFilter, RpcDefinitionsToFunctions } from "devframe/rpc";
|
|
4
4
|
import { ConnectionMeta as ConnectionMeta$1, DevframeCapabilities, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeHost as DevframeHost$1, DevframeNodeRpcSession, DevframeRpcClientFunctions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeViewHost, EventEmitter as EventEmitter$1, EventUnsubscribe, EventsMap, RpcBroadcastOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost } from "devframe/types";
|
|
5
5
|
export { RpcStreamingHost as S, RpcFunctionsHost as _, DevframeHost$1 as a, RpcStreamingChannel as b, DevframeRpcServerFunctions as c, EventEmitter$1 as d, EventUnsubscribe as f, RpcDefinitionsToFunctions as g, RpcDefinitionsFilter as h, DevframeDiagnosticsLogger as i, DevframeRpcSharedStates as l, RpcBroadcastOptions as m, DevframeCapabilities as n, DevframeNodeRpcSession as o, EventsMap as p, DevframeDiagnosticsHost as r, DevframeRpcClientFunctions as s, ConnectionMeta$1 as t, DevframeViewHost as u, RpcSharedStateGetOptions as v, RpcStreamingChannelOptions as x, RpcSharedStateHost as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as DevframeMessageHandle, D as DevframeMessagesHost, E as DevframeMessagesClient, O as DevframeMessagesLevelShortcuts, S as DevframeMessageFilePosition, T as DevframeMessageShortcutInput, _ as DevframeMessageCommandAction, a as DevframeChildProcessExecuteOptions, b as DevframeMessageEntryFrom, c as DevframeChildProcessTerminalSession, d as DevframeTerminalSession, f as DevframeTerminalSessionBase, g as DevframeMessageActivateAction, h as DevframeMessageAction, k as DevframeMessagesListDelta, l as DevframePtyExecuteOptions, m as DevframeTerminalsHost, n as DevframeHubContext, o as DevframeChildProcessOutput, p as DevframeTerminalStatus, s as DevframeChildProcessResult, t as CreateHubContextOptions, u as DevframePtyTerminalSession, v as DevframeMessageElementPosition, w as DevframeMessageLevel, x as DevframeMessageEntryInput, y as DevframeMessageEntry } from "./context-
|
|
2
|
-
import { A as DevframeViewLauncher, C as DevframeDocksActiveState, D as DevframeViewCustomRender, E as DevframeViewBuiltin, F as RemoteDockOptions, M as FrameSubTabsConfig, N as NavTarget, O as DevframeViewGroup, P as RemoteConnectionInfo, S as DevframeDockUserEntry, T as DevframeViewAction, _ as DevframeDockEntry, a as DevframeCommandEntry, b as DevframeDockEntryIcon, c as DevframeCommandShortcutOverrides, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, g as DevframeDockEntriesGrouped, h as DevframeDockBadgeVariant, i as DevframeCommandBase, j as DevframeViewLauncherStatus, k as DevframeViewIframe, l as DevframeCommandsHost, m as DevframeDockActivation, n as DevframeClientCommand, o as DevframeCommandHandle, p as ClientScriptEntry, r as DevframeCommandAgentOptions, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings, u as DevframeCommandsHostEvents, v as DevframeDockEntryBase, w as DevframeDocksHost, x as DevframeDockEntryRegistry, y as DevframeDockEntryCategory } from "./settings-
|
|
3
|
-
import { S as RpcStreamingHost, _ as RpcFunctionsHost, a as DevframeHost, b as RpcStreamingChannel, c as DevframeRpcServerFunctions, d as EventEmitter, f as EventUnsubscribe, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, i as DevframeDiagnosticsLogger, l as DevframeRpcSharedStates, m as RpcBroadcastOptions, n as DevframeCapabilities, o as DevframeNodeRpcSession, p as EventsMap, r as DevframeDiagnosticsHost, s as DevframeRpcClientFunctions, t as ConnectionMeta, u as DevframeViewHost, v as RpcSharedStateGetOptions, x as RpcStreamingChannelOptions, y as RpcSharedStateHost } from "./index-
|
|
1
|
+
import { C as DevframeMessageHandle, D as DevframeMessagesHost, E as DevframeMessagesClient, O as DevframeMessagesLevelShortcuts, S as DevframeMessageFilePosition, T as DevframeMessageShortcutInput, _ as DevframeMessageCommandAction, a as DevframeChildProcessExecuteOptions, b as DevframeMessageEntryFrom, c as DevframeChildProcessTerminalSession, d as DevframeTerminalSession, f as DevframeTerminalSessionBase, g as DevframeMessageActivateAction, h as DevframeMessageAction, k as DevframeMessagesListDelta, l as DevframePtyExecuteOptions, m as DevframeTerminalsHost, n as DevframeHubContext, o as DevframeChildProcessOutput, p as DevframeTerminalStatus, s as DevframeChildProcessResult, t as CreateHubContextOptions, u as DevframePtyTerminalSession, v as DevframeMessageElementPosition, w as DevframeMessageLevel, x as DevframeMessageEntryInput, y as DevframeMessageEntry } from "./context-BVkxwz5k.mjs";
|
|
2
|
+
import { A as DevframeViewLauncher, C as DevframeDocksActiveState, D as DevframeViewCustomRender, E as DevframeViewBuiltin, F as RemoteDockOptions, M as FrameSubTabsConfig, N as NavTarget, O as DevframeViewGroup, P as RemoteConnectionInfo, S as DevframeDockUserEntry, T as DevframeViewAction, _ as DevframeDockEntry, a as DevframeCommandEntry, b as DevframeDockEntryIcon, c as DevframeCommandShortcutOverrides, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, g as DevframeDockEntriesGrouped, h as DevframeDockBadgeVariant, i as DevframeCommandBase, j as DevframeViewLauncherStatus, k as DevframeViewIframe, l as DevframeCommandsHost, m as DevframeDockActivation, n as DevframeClientCommand, o as DevframeCommandHandle, p as ClientScriptEntry, r as DevframeCommandAgentOptions, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings, u as DevframeCommandsHostEvents, v as DevframeDockEntryBase, w as DevframeDocksHost, x as DevframeDockEntryRegistry, y as DevframeDockEntryCategory } from "./settings-D7whfcx2.mjs";
|
|
3
|
+
import { S as RpcStreamingHost, _ as RpcFunctionsHost, a as DevframeHost, b as RpcStreamingChannel, c as DevframeRpcServerFunctions, d as EventEmitter, f as EventUnsubscribe, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, i as DevframeDiagnosticsLogger, l as DevframeRpcSharedStates, m as RpcBroadcastOptions, n as DevframeCapabilities, o as DevframeNodeRpcSession, p as EventsMap, r as DevframeDiagnosticsHost, s as DevframeRpcClientFunctions, t as ConnectionMeta, u as DevframeViewHost, v as RpcSharedStateGetOptions, x as RpcStreamingChannelOptions, y as RpcSharedStateHost } from "./index-CyEyZHB3.mjs";
|
|
4
4
|
import { WhenContext, WhenExpression } from "devframe/utils/when";
|
|
5
5
|
//#region src/define.d.ts
|
|
6
6
|
declare const defineHubRpcFunction: <NAME extends string, TYPE extends import("devframe/rpc").RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends import("devframe/rpc").RpcArgsSchema | undefined = undefined, const RS extends import("devframe/rpc").RpcReturnSchema | undefined = undefined>(definition: import("devframe/rpc").RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeHubContext>) => import("devframe/rpc").RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeHubContext>;
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as DevframeMessageHandle, D as DevframeMessagesHost$1, T as DevframeMessageShortcutInput, a as DevframeChildProcessExecuteOptions, c as DevframeChildProcessTerminalSession, d as DevframeTerminalSession, f as DevframeTerminalSessionBase, i as InstallDevframeOptions, k as DevframeMessagesListDelta, l as DevframePtyExecuteOptions, m as DevframeTerminalsHost$1, n as DevframeHubContext, r as createHubContext, t as CreateHubContextOptions, u as DevframePtyTerminalSession, x as DevframeMessageEntryInput, y as DevframeMessageEntry } from "../context-
|
|
2
|
-
import { S as DevframeDockUserEntry, _ as DevframeDockEntry, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, l as DevframeCommandsHost$1, o as DevframeCommandHandle, p as ClientScriptEntry, t as DevframeDocksUserSettings, w as DevframeDocksHost$1 } from "../settings-
|
|
1
|
+
import { C as DevframeMessageHandle, D as DevframeMessagesHost$1, T as DevframeMessageShortcutInput, a as DevframeChildProcessExecuteOptions, c as DevframeChildProcessTerminalSession, d as DevframeTerminalSession, f as DevframeTerminalSessionBase, i as InstallDevframeOptions, k as DevframeMessagesListDelta, l as DevframePtyExecuteOptions, m as DevframeTerminalsHost$1, n as DevframeHubContext, r as createHubContext, t as CreateHubContextOptions, u as DevframePtyTerminalSession, x as DevframeMessageEntryInput, y as DevframeMessageEntry } from "../context-BVkxwz5k.mjs";
|
|
2
|
+
import { S as DevframeDockUserEntry, _ as DevframeDockEntry, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, l as DevframeCommandsHost$1, o as DevframeCommandHandle, p as ClientScriptEntry, t as DevframeDocksUserSettings, w as DevframeDocksHost$1 } from "../settings-D7whfcx2.mjs";
|
|
3
3
|
import { RpcFunctionDefinitionAny } from "devframe/rpc";
|
|
4
4
|
import { SharedState } from "devframe/utils/shared-state";
|
|
5
5
|
//#region src/node/host-commands.d.ts
|
|
@@ -51,6 +51,14 @@ declare class DevframeDocksHost implements DevframeDocksHost$1 {
|
|
|
51
51
|
};
|
|
52
52
|
update(view: DevframeDockUserEntry): void;
|
|
53
53
|
activate(dockId: string, params?: Record<string, unknown>): void;
|
|
54
|
+
/**
|
|
55
|
+
* Warn (don't throw — a viewer-side `resolveClientModule` may still cover
|
|
56
|
+
* it) when a dock declares a **bare-specifier** client script on a host
|
|
57
|
+
* that advertises no `staticConfig.dock.clientModuleResolution`: the
|
|
58
|
+
* browser cannot resolve a bare npm specifier natively, so the script is
|
|
59
|
+
* doomed to fail there.
|
|
60
|
+
*/
|
|
61
|
+
private warnUnresolvableClientScript;
|
|
54
62
|
private validateGroupMembership;
|
|
55
63
|
private prepareRemoteRegistration;
|
|
56
64
|
}
|