@vitejs/devtools 0.0.0-alpha.18 → 0.0.0-alpha.19

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,16 +1,66 @@
1
1
  import { RpcDefinitionsToFunctions, RpcFunctionsCollector, RpcFunctionsCollectorBase } from "birpc-x";
2
2
  import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
3
- import { Emitter } from "nanoevents";
4
3
  import { Raw } from "vue";
5
4
  import { BirpcGroup, BirpcReturn } from "birpc";
5
+ import { ChildProcess } from "node:child_process";
6
6
  import "@vitejs/devtools-rpc/presets/ws/client";
7
7
 
8
+ //#region ../kit/src/types/events.d.ts
9
+ interface EventsMap {
10
+ [event: string]: any;
11
+ }
12
+ interface EventUnsubscribe {
13
+ (): void;
14
+ }
15
+ interface EventEmitter<Events extends EventsMap> {
16
+ /**
17
+ * Calls each of the listeners registered for a given event.
18
+ *
19
+ * ```js
20
+ * ee.emit('tick', tickType, tickDuration)
21
+ * ```
22
+ *
23
+ * @param event The event name.
24
+ * @param args The arguments for listeners.
25
+ */
26
+ emit: <K extends keyof Events>(this: this, event: K, ...args: Parameters<Events[K]>) => void;
27
+ /**
28
+ * Event names in keys and arrays with listeners in values.
29
+ *
30
+ * @internal
31
+ */
32
+ _listeners: Partial<{ [E in keyof Events]: Events[E][] }>;
33
+ /**
34
+ * Add a listener for a given event.
35
+ *
36
+ * ```js
37
+ * const unbind = ee.on('tick', (tickType, tickDuration) => {
38
+ * count += 1
39
+ * })
40
+ *
41
+ * disable () {
42
+ * unbind()
43
+ * }
44
+ * ```
45
+ *
46
+ * @param event The event name.
47
+ * @param cb The listener function.
48
+ * @returns Unbind listener from event.
49
+ */
50
+ on: <K extends keyof Events>(this: this, event: K, cb: Events[K]) => EventUnsubscribe;
51
+ }
52
+ //#endregion
8
53
  //#region ../kit/src/types/docks.d.ts
9
54
  interface DevToolsDockHost {
10
- views: Map<string, DevToolsDockEntry>;
11
- register: (entry: DevToolsDockEntry) => void;
12
- update: (entry: DevToolsDockEntry) => void;
13
- values: () => DevToolsDockEntry[];
55
+ readonly views: Map<string, DevToolsDockUserEntry>;
56
+ readonly events: EventEmitter<{
57
+ 'dock:entry:updated': (entry: DevToolsDockUserEntry) => void;
58
+ }>;
59
+ register: <T extends DevToolsDockUserEntry>(entry: T, force?: boolean) => {
60
+ update: (patch: Partial<T>) => void;
61
+ };
62
+ update: (entry: DevToolsDockUserEntry) => void;
63
+ values: () => DevToolsDockUserEntry[];
14
64
  }
15
65
  type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default';
16
66
  type DevToolsDockEntryIcon = string | {
@@ -32,6 +82,11 @@ interface DevToolsDockEntryBase {
32
82
  * @default 'default'
33
83
  */
34
84
  category?: DevToolsDockEntryCategory;
85
+ /**
86
+ * Whether the entry should be hidden from the user.
87
+ * @default false
88
+ */
89
+ isHidden?: boolean;
35
90
  }
36
91
  interface ClientScriptEntry {
37
92
  /**
@@ -81,7 +136,12 @@ interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
81
136
  type: 'custom-render';
82
137
  renderer: ClientScriptEntry;
83
138
  }
84
- type DevToolsDockEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
139
+ interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
140
+ type: '~builtin';
141
+ id: '~terminals' | '~logs';
142
+ }
143
+ type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
144
+ type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
85
145
  //#endregion
86
146
  //#region ../kit/src/types/rpc-augments.d.ts
87
147
  /**
@@ -93,6 +153,48 @@ interface DevToolsRpcClientFunctions {}
93
153
  */
94
154
  interface DevToolsRpcServerFunctions {}
95
155
  //#endregion
156
+ //#region ../kit/src/types/terminals.d.ts
157
+ interface DevToolsTerminalSessionStreamChunkEvent {
158
+ id: string;
159
+ chunks: string[];
160
+ ts: number;
161
+ }
162
+ interface DevToolsTerminalHost {
163
+ readonly sessions: Map<string, DevToolsTerminalSession>;
164
+ readonly events: EventEmitter<{
165
+ 'terminal:session:updated': (session: DevToolsTerminalSession) => void;
166
+ 'terminal:session:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => void;
167
+ }>;
168
+ register: (session: DevToolsTerminalSession) => DevToolsTerminalSession;
169
+ update: (session: DevToolsTerminalSession) => void;
170
+ startChildProcess: (executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>) => Promise<DevToolsChildProcessTerminalSession>;
171
+ }
172
+ type DevToolsTerminalStatus = 'running' | 'stopped' | 'error';
173
+ interface DevToolsTerminalSessionBase {
174
+ id: string;
175
+ title: string;
176
+ description?: string;
177
+ status: DevToolsTerminalStatus;
178
+ icon?: DevToolsDockEntryIcon;
179
+ }
180
+ interface DevToolsTerminalSession extends DevToolsTerminalSessionBase {
181
+ buffer?: string[];
182
+ stream?: ReadableStream<string>;
183
+ }
184
+ interface DevToolsChildProcessExecuteOptions {
185
+ command: string;
186
+ args: string[];
187
+ cwd?: string;
188
+ env?: Record<string, string>;
189
+ }
190
+ interface DevToolsChildProcessTerminalSession extends DevToolsTerminalSession {
191
+ type: 'child-process';
192
+ executeOptions: DevToolsChildProcessExecuteOptions;
193
+ getChildProcess: () => ChildProcess | undefined;
194
+ terminate: () => Promise<void>;
195
+ restart: () => Promise<void>;
196
+ }
197
+ //#endregion
96
198
  //#region ../kit/src/types/views.d.ts
97
199
  interface DevToolsViewHost {
98
200
  /**
@@ -131,6 +233,7 @@ interface DevToolsNodeContext {
131
233
  docks: DevToolsDockHost;
132
234
  views: DevToolsViewHost;
133
235
  utils: DevToolsNodeUtils;
236
+ terminals: DevToolsTerminalHost;
134
237
  }
135
238
  interface DevToolsNodeUtils {
136
239
  /**
@@ -224,7 +327,7 @@ interface DocksEntriesContext {
224
327
  *
225
328
  * @returns Whether the selection was changed successfully
226
329
  */
227
- switchEntry: (id: string | null) => Promise<boolean>;
330
+ switchEntry: (id?: string | null) => Promise<boolean>;
228
331
  }
229
332
  interface DockEntryState {
230
333
  entryMeta: DevToolsDockEntry;
@@ -233,12 +336,12 @@ interface DockEntryState {
233
336
  iframe?: HTMLIFrameElement | null;
234
337
  panel?: HTMLDivElement | null;
235
338
  };
236
- events: Raw<Emitter<DockEntryStateEvents>>;
339
+ events: Raw<EventEmitter<DockEntryStateEvents>>;
237
340
  }
238
341
  interface DockEntryStateEvents {
239
342
  'entry:activated': () => void;
240
343
  'entry:deactivated': () => void;
241
- 'entry:updated': (newMeta: DevToolsDockEntry) => void;
344
+ 'entry:updated': (newMeta: DevToolsDockUserEntry) => void;
242
345
  'dom:panel:mounted': (panel: HTMLDivElement) => void;
243
346
  'dom:iframe:mounted': (iframe: HTMLIFrameElement) => void;
244
347
  }
@@ -254,4 +357,4 @@ interface DockClientScriptContext extends DocksContext {
254
357
  current: DockEntryState;
255
358
  }
256
359
  //#endregion
257
- export { ConnectionMeta as a, DevToolsRpcServerFunctions as c, RpcDefinitionsToFunctions as i, DevToolsDockEntry as l, DocksContext as n, DevToolsNodeContext as o, ClientRpcReturn as r, DevToolsRpcClientFunctions as s, DockPanelStorage as t };
360
+ export { RpcDefinitionsToFunctions as a, DevToolsTerminalSessionBase as c, DevToolsRpcServerFunctions as d, DevToolsDockEntry as f, ClientRpcReturn as i, DevToolsTerminalSessionStreamChunkEvent as l, DockPanelStorage as n, ConnectionMeta as o, DocksContext as r, DevToolsNodeContext as s, DockEntryState as t, DevToolsRpcClientFunctions as u };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ConnectionMeta, c as DevToolsRpcServerFunctions, i as RpcDefinitionsToFunctions, l as DevToolsDockEntry, o as DevToolsNodeContext, s as DevToolsRpcClientFunctions } from "./index-Dt5HYF60.js";
1
+ import { a as RpcDefinitionsToFunctions, c as DevToolsTerminalSessionBase, d as DevToolsRpcServerFunctions, f as DevToolsDockEntry, l as DevToolsTerminalSessionStreamChunkEvent, o as ConnectionMeta, s as DevToolsNodeContext, u as DevToolsRpcClientFunctions } from "./index-Wdefo_Ne.js";
2
2
  import * as birpc_x0 from "birpc-x";
3
3
  import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
4
4
  import * as birpc0 from "birpc";
@@ -8,16 +8,21 @@ import * as h30 from "h3";
8
8
  declare function createDevToolsContext(viteConfig: ResolvedConfig, viteServer?: ViteDevServer): Promise<DevToolsNodeContext>;
9
9
  //#endregion
10
10
  //#region src/node/rpc/index.d.ts
11
- declare const builtinRpcFunctions: readonly [birpc_x0.RpcFunctionDefinition<"vite:core:list-rpc-functions", "action", [], Promise<{
11
+ declare const builtinRpcDecalrations: readonly [birpc_x0.RpcFunctionDefinition<"vite:core:open-in-editor", "action", [path: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:core:open-in-finder", "action", [path: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:docks:list", "static", [], DevToolsDockEntry[], DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:docks:on-launch", "action", [entryId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server:list", "static", [], Promise<{
12
12
  [k: string]: {
13
13
  type: any;
14
14
  };
15
- }>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:core:list-dock-entries", "query", [], DevToolsDockEntry[], DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:core:open-in-editor", "action", [path: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:core:open-in-finder", "action", [path: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:core:on-dock-launch", "action", [entryId: string], Promise<void>, DevToolsNodeContext>];
16
- type ServerFunctions = RpcDefinitionsToFunctions<typeof builtinRpcFunctions>;
15
+ }>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:list", "static", [], Promise<DevToolsTerminalSessionBase[]>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:read", "query", [id: string], Promise<{
16
+ buffer: string[];
17
+ ts: number;
18
+ }>, DevToolsNodeContext>];
19
+ type BuiltinServerFunctions = RpcDefinitionsToFunctions<typeof builtinRpcDecalrations>;
17
20
  declare module '@vitejs/devtools-kit' {
18
- interface DevToolsRpcServerFunctions extends ServerFunctions {}
21
+ interface DevToolsRpcServerFunctions extends BuiltinServerFunctions {}
19
22
  interface DevToolsRpcClientFunctions {
20
- 'vite:core:list-dock-entries:updated': () => Promise<void>;
23
+ 'vite:internal:docks:updated': () => Promise<void>;
24
+ 'vite:internal:terminals:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => Promise<void>;
25
+ 'vite:internal:terminals:updated': () => Promise<void>;
21
26
  }
22
27
  }
23
28
  //#endregion
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { d as createDevToolsContext, n as createDevToolsMiddleware, t as DevTools } from "./plugins-LceePuMU.js";
1
+ import { d as createDevToolsContext, n as createDevToolsMiddleware, t as DevTools } from "./plugins-l6D28NJB.js";
2
2
  import "./dirs-DcSK9l9L.js";
3
3
 
4
4
  export { DevTools, createDevToolsContext, createDevToolsMiddleware };
@@ -1,13 +1,14 @@
1
1
  import { n as dirDist, t as dirClientStandalone } from "./dirs-DcSK9l9L.js";
2
2
  import Debug from "debug";
3
- import { toDataURL } from "mlly";
4
3
  import { debounce } from "perfect-debounce";
4
+ import { toDataURL } from "mlly";
5
+ import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
5
6
  import { RpcFunctionsCollectorBase } from "birpc-x";
7
+ import process$1 from "node:process";
6
8
  import { existsSync } from "node:fs";
7
9
  import sirv from "sirv";
8
10
  import { defineRpcFunction } from "@vitejs/devtools-kit";
9
11
  import { join } from "node:path";
10
- import process$1 from "node:process";
11
12
  import { normalizePath } from "vite";
12
13
  import { createRpcServer } from "@vitejs/devtools-rpc";
13
14
  import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/server";
@@ -53,12 +54,9 @@ const ContextUtils = { createSimpleClientScript(fn) {
53
54
  //#region src/node/host-docks.ts
54
55
  var DevToolsDockHost = class {
55
56
  views = /* @__PURE__ */ new Map();
56
- _sendOnChange;
57
+ events = createEventEmitter();
57
58
  constructor(context) {
58
59
  this.context = context;
59
- this._sendOnChange = debounce(() => {
60
- context.rpc?.boardcast?.$callOptional("vite:core:list-dock-entries:updated");
61
- }, 10);
62
60
  }
63
61
  values() {
64
62
  return Array.from(this.views.values());
@@ -66,12 +64,16 @@ var DevToolsDockHost = class {
66
64
  register(view, force) {
67
65
  if (this.views.has(view.id) && !force) throw new Error(`Dock with id "${view.id}" is already registered`);
68
66
  this.views.set(view.id, view);
69
- this._sendOnChange();
67
+ this.events.emit("dock:entry:updated", view);
68
+ return { update: (patch) => {
69
+ if (patch.id && patch.id !== view.id) throw new Error(`Cannot change the id of a dock. Use register() to add new docks.`);
70
+ this.update(Object.assign(this.views.get(view.id), patch));
71
+ } };
70
72
  }
71
73
  update(view) {
72
74
  if (!this.views.has(view.id)) throw new Error(`Dock with id "${view.id}" is not registered. Use register() to add new docks.`);
73
75
  this.views.set(view.id, view);
74
- this._sendOnChange();
76
+ this.events.emit("dock:entry:updated", view);
75
77
  }
76
78
  };
77
79
 
@@ -84,6 +86,104 @@ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
84
86
  }
85
87
  };
86
88
 
89
+ //#endregion
90
+ //#region src/node/host-terminals.ts
91
+ var DevToolsTerminalHost = class {
92
+ sessions = /* @__PURE__ */ new Map();
93
+ events = createEventEmitter();
94
+ _boundStreams = /* @__PURE__ */ new Map();
95
+ constructor(context) {
96
+ this.context = context;
97
+ }
98
+ register(session) {
99
+ if (this.sessions.has(session.id)) throw new Error(`Terminal session with id "${session.id}" already registered`);
100
+ this.sessions.set(session.id, session);
101
+ this.bindStream(session);
102
+ this.events.emit("terminal:session:updated", session);
103
+ return session;
104
+ }
105
+ update(patch) {
106
+ if (!this.sessions.has(patch.id)) throw new Error(`Terminal session with id "${patch.id}" not registered`);
107
+ const session = this.sessions.get(patch.id);
108
+ Object.assign(session, patch);
109
+ this.sessions.set(patch.id, session);
110
+ this.bindStream(session);
111
+ this.events.emit("terminal:session:updated", session);
112
+ }
113
+ remove(session) {
114
+ this.sessions.delete(session.id);
115
+ this.events.emit("terminal:session:updated", session);
116
+ this._boundStreams.delete(session.id);
117
+ }
118
+ bindStream(session) {
119
+ if (this._boundStreams.has(session.id) && this._boundStreams.get(session.id)?.stream === session.stream) return;
120
+ this._boundStreams.get(session.id)?.dispose();
121
+ this._boundStreams.delete(session.id);
122
+ if (!session.stream) return;
123
+ session.buffer ||= [];
124
+ const events = this.events;
125
+ const writer = new WritableStream({ write(chunk) {
126
+ session.buffer.push(chunk);
127
+ events.emit("terminal:session:stream-chunk", {
128
+ id: session.id,
129
+ chunks: [chunk],
130
+ ts: Date.now()
131
+ });
132
+ } });
133
+ session.stream.pipeTo(writer);
134
+ this._boundStreams.set(session.id, {
135
+ dispose: () => {
136
+ writer.close();
137
+ },
138
+ stream: session.stream
139
+ });
140
+ }
141
+ async startChildProcess(executeOptions, terminal) {
142
+ if (this.sessions.has(terminal.id)) throw new Error(`Terminal session with id "${terminal.id}" already registered`);
143
+ const { exec } = await import("tinyexec");
144
+ let controller;
145
+ const stream = new ReadableStream({ start(_controller) {
146
+ controller = _controller;
147
+ } });
148
+ function createChildProcess() {
149
+ const cp$1 = exec(executeOptions.command, executeOptions.args || [], { nodeOptions: {
150
+ env: {
151
+ COLORS: "true",
152
+ FORCE_COLOR: "true",
153
+ ...executeOptions.env || {}
154
+ },
155
+ cwd: executeOptions.cwd ?? process$1.cwd(),
156
+ stdio: "pipe"
157
+ } });
158
+ (async () => {
159
+ for await (const chunk of cp$1) controller?.enqueue(chunk);
160
+ })();
161
+ return cp$1;
162
+ }
163
+ let cp = createChildProcess();
164
+ const restart = async () => {
165
+ cp?.kill();
166
+ cp = createChildProcess();
167
+ };
168
+ const terminate = async () => {
169
+ cp?.kill();
170
+ cp = void 0;
171
+ };
172
+ const session = {
173
+ ...terminal,
174
+ status: "running",
175
+ stream,
176
+ type: "child-process",
177
+ executeOptions,
178
+ getChildProcess: () => cp?.process,
179
+ terminate,
180
+ restart
181
+ };
182
+ this.register(session);
183
+ return Promise.resolve(session);
184
+ }
185
+ };
186
+
87
187
  //#endregion
88
188
  //#region src/node/host-views.ts
89
189
  var DevToolsViewHost = class {
@@ -111,31 +211,28 @@ var DevToolsViewHost = class {
111
211
  };
112
212
 
113
213
  //#endregion
114
- //#region src/node/rpc/list-dock-entries.ts
115
- const listDockEntries = defineRpcFunction({
116
- name: "vite:core:list-dock-entries",
117
- type: "query",
118
- setup: (context) => {
119
- return { handler: () => Array.from(context.docks.values()) };
120
- }
121
- });
122
-
123
- //#endregion
124
- //#region src/node/rpc/list-rpc-functions.ts
125
- const listRpcFunctions = defineRpcFunction({
126
- name: "vite:core:list-rpc-functions",
127
- type: "action",
214
+ //#region src/node/rpc/internal/docks-list.ts
215
+ const docksList = defineRpcFunction({
216
+ name: "vite:internal:docks:list",
217
+ type: "static",
128
218
  setup: (context) => {
129
- return { async handler() {
130
- return Object.fromEntries(Array.from(context.rpc.definitions.entries()).map(([name, fn]) => [name, { type: fn.type }]));
131
- } };
219
+ const builtinDocksEntries = [{
220
+ type: "~builtin",
221
+ id: "~terminals",
222
+ title: "Terminals",
223
+ icon: "ph:terminal-duotone",
224
+ get isHidden() {
225
+ return context.terminals.sessions.size === 0;
226
+ }
227
+ }];
228
+ return { handler: () => [...Array.from(context.docks.values()), ...builtinDocksEntries] };
132
229
  }
133
230
  });
134
231
 
135
232
  //#endregion
136
- //#region src/node/rpc/on-dock-launch.ts
137
- const onDockLaunch = defineRpcFunction({
138
- name: "vite:core:on-dock-launch",
233
+ //#region src/node/rpc/internal/docks-on-launch.ts
234
+ const docksOnLaunch = defineRpcFunction({
235
+ name: "vite:internal:docks:on-launch",
139
236
  type: "action",
140
237
  setup: (context) => {
141
238
  const launchMap = /* @__PURE__ */ new Map();
@@ -180,7 +277,55 @@ const onDockLaunch = defineRpcFunction({
180
277
  });
181
278
 
182
279
  //#endregion
183
- //#region src/node/rpc/open-in-editor.ts
280
+ //#region src/node/rpc/internal/rpc-server-list.ts
281
+ const rpcServerList = defineRpcFunction({
282
+ name: "vite:internal:rpc:server:list",
283
+ type: "static",
284
+ setup: (context) => {
285
+ return { async handler() {
286
+ return Object.fromEntries(Array.from(context.rpc.definitions.entries()).map(([name, fn]) => [name, { type: fn.type }]));
287
+ } };
288
+ }
289
+ });
290
+
291
+ //#endregion
292
+ //#region src/node/rpc/internal/terminals-list.ts
293
+ const terminalsList = defineRpcFunction({
294
+ name: "vite:internal:terminals:list",
295
+ type: "static",
296
+ setup: (context) => {
297
+ return { async handler() {
298
+ return Array.from(context.terminals.sessions.values()).map((i$1) => {
299
+ return {
300
+ id: i$1.id,
301
+ title: i$1.title,
302
+ description: i$1.description,
303
+ status: i$1.status
304
+ };
305
+ });
306
+ } };
307
+ }
308
+ });
309
+
310
+ //#endregion
311
+ //#region src/node/rpc/internal/terminals-read.ts
312
+ const terminalsRead = defineRpcFunction({
313
+ name: "vite:internal:terminals:read",
314
+ type: "query",
315
+ setup: (context) => {
316
+ return { async handler(id) {
317
+ const seesion = context.terminals.sessions.get(id);
318
+ if (!seesion) throw new Error(`Terminal session with id "${id}" not found`);
319
+ return {
320
+ buffer: seesion.buffer ?? [],
321
+ ts: Date.now()
322
+ };
323
+ } };
324
+ }
325
+ });
326
+
327
+ //#endregion
328
+ //#region src/node/rpc/public/open-in-editor.ts
184
329
  const openInEditor = defineRpcFunction({
185
330
  name: "vite:core:open-in-editor",
186
331
  type: "action",
@@ -192,7 +337,7 @@ const openInEditor = defineRpcFunction({
192
337
  });
193
338
 
194
339
  //#endregion
195
- //#region src/node/rpc/open-in-finder.ts
340
+ //#region src/node/rpc/public/open-in-finder.ts
196
341
  const openInFinder = defineRpcFunction({
197
342
  name: "vite:core:open-in-finder",
198
343
  type: "action",
@@ -205,13 +350,15 @@ const openInFinder = defineRpcFunction({
205
350
 
206
351
  //#endregion
207
352
  //#region src/node/rpc/index.ts
208
- const builtinRpcFunctions = [
209
- listRpcFunctions,
210
- listDockEntries,
211
- openInEditor,
212
- openInFinder,
213
- onDockLaunch
353
+ const builtinPublicRpcDecalrations = [openInEditor, openInFinder];
354
+ const builtinInternalRpcDecalrations = [
355
+ docksList,
356
+ docksOnLaunch,
357
+ rpcServerList,
358
+ terminalsList,
359
+ terminalsRead
214
360
  ];
361
+ const builtinRpcDecalrations = [...builtinPublicRpcDecalrations, ...builtinInternalRpcDecalrations];
215
362
 
216
363
  //#endregion
217
364
  //#region src/node/context.ts
@@ -225,15 +372,28 @@ async function createDevToolsContext(viteConfig, viteServer) {
225
372
  rpc: void 0,
226
373
  docks: void 0,
227
374
  views: void 0,
228
- utils: ContextUtils
375
+ utils: ContextUtils,
376
+ terminals: void 0
229
377
  };
230
378
  const rpcHost = new RpcFunctionsHost(context);
231
379
  const docksHost = new DevToolsDockHost(context);
232
380
  const viewsHost = new DevToolsViewHost(context);
381
+ const terminalsHost = new DevToolsTerminalHost(context);
233
382
  context.rpc = rpcHost;
234
383
  context.docks = docksHost;
235
384
  context.views = viewsHost;
236
- for (const fn of builtinRpcFunctions) rpcHost.register(fn);
385
+ context.terminals = terminalsHost;
386
+ for (const fn of builtinRpcDecalrations) rpcHost.register(fn);
387
+ docksHost.events.on("dock:entry:updated", debounce(() => {
388
+ rpcHost.boardcast.$callOptional("vite:internal:docks:updated");
389
+ }, 10));
390
+ terminalsHost.events.on("terminal:session:updated", debounce(() => {
391
+ rpcHost.boardcast.$callOptional("vite:internal:terminals:updated");
392
+ rpcHost.boardcast.$callOptional("vite:internal:docks:updated");
393
+ }, 10));
394
+ terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
395
+ rpcHost.boardcast.$callOptional("vite:internal:terminals:stream-chunk", data);
396
+ });
237
397
  const plugins = viteConfig.plugins.filter((plugin) => "devtools" in plugin);
238
398
  for (const plugin of plugins) {
239
399
  if (!plugin.devtools?.setup) continue;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitejs/devtools",
3
3
  "type": "module",
4
- "version": "0.0.0-alpha.18",
4
+ "version": "0.0.0-alpha.19",
5
5
  "description": "Vite DevTools",
6
6
  "author": "VoidZero Inc.",
7
7
  "license": "MIT",
@@ -47,26 +47,28 @@
47
47
  "debug": "^4.4.3",
48
48
  "launch-editor": "^2.12.0",
49
49
  "mlly": "^1.8.0",
50
- "nanoevents": "^9.1.0",
51
50
  "open": "^11.0.0",
52
51
  "pathe": "^2.0.3",
53
52
  "perfect-debounce": "^2.0.0",
54
53
  "sirv": "^3.0.2",
54
+ "tinyexec": "^1.0.2",
55
55
  "ws": "^8.18.3",
56
- "@vitejs/devtools-kit": "0.0.0-alpha.18",
57
- "@vitejs/devtools-rpc": "0.0.0-alpha.18",
58
- "@vitejs/devtools-vite": "0.0.0-alpha.18"
56
+ "@vitejs/devtools-rpc": "0.0.0-alpha.19",
57
+ "@vitejs/devtools-kit": "0.0.0-alpha.19",
58
+ "@vitejs/devtools-vite": "0.0.0-alpha.19"
59
59
  },
60
60
  "devDependencies": {
61
- "@vitejs/plugin-vue": "^6.0.1",
61
+ "@vitejs/plugin-vue": "^6.0.2",
62
+ "@xterm/addon-fit": "^0.10.0",
63
+ "@xterm/xterm": "^5.5.0",
62
64
  "tsdown": "^0.16.1",
63
65
  "typescript": "^5.9.3",
64
- "unplugin-vue": "^7.0.7",
66
+ "unplugin-vue": "^7.0.8",
65
67
  "vite": "npm:rolldown-vite@^7.2.2",
66
- "vue": "^3.5.24",
67
- "vue-tsc": "^3.1.4",
68
- "@vitejs/devtools": "0.0.0-alpha.18",
69
- "@vitejs/devtools-vite": "0.0.0-alpha.18"
68
+ "vue": "^3.5.25",
69
+ "vue-tsc": "^3.1.5",
70
+ "@vitejs/devtools-vite": "0.0.0-alpha.19",
71
+ "@vitejs/devtools": "0.0.0-alpha.19"
70
72
  },
71
73
  "scripts": {
72
74
  "build": "pnpm build:js && pnpm build:standalone",