@vitejs/devtools-kit 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.
- package/dist/client.d.mts +2 -1
- package/dist/events-DDdYnct9.d.mts +46 -0
- package/dist/{index-C7lGA5jg.d.mts → index-CgOheNVD.d.mts} +74 -10
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +1 -1
- package/dist/utils/events.d.mts +10 -0
- package/dist/utils/events.mjs +26 -0
- package/package.json +3 -3
package/dist/client.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./events-DDdYnct9.mjs";
|
|
2
|
+
import { a as DockEntryState, c as DocksContext, d as ClientRpcReturn, f as DevToolsRpcClient, i as DockClientType, l as DocksEntriesContext, m as getDevToolsRpcClient, n as DevToolsClientContext, o as DockEntryStateEvents, p as DevToolsRpcClientOptions, r as DevToolsClientRpcHost, s as DockPanelStorage, t as DockClientScriptContext, u as DocksPanelContext } from "./index-CgOheNVD.mjs";
|
|
2
3
|
export { ClientRpcReturn, DevToolsClientContext, DevToolsClientRpcHost, DevToolsRpcClient, DevToolsRpcClientOptions, DockClientScriptContext, DockClientType, DockEntryState, DockEntryStateEvents, DockPanelStorage, DocksContext, DocksEntriesContext, DocksPanelContext, getDevToolsRpcClient };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/types/events.d.ts
|
|
2
|
+
interface EventsMap {
|
|
3
|
+
[event: string]: any;
|
|
4
|
+
}
|
|
5
|
+
interface EventUnsubscribe {
|
|
6
|
+
(): void;
|
|
7
|
+
}
|
|
8
|
+
interface EventEmitter<Events extends EventsMap> {
|
|
9
|
+
/**
|
|
10
|
+
* Calls each of the listeners registered for a given event.
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* ee.emit('tick', tickType, tickDuration)
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param event The event name.
|
|
17
|
+
* @param args The arguments for listeners.
|
|
18
|
+
*/
|
|
19
|
+
emit: <K extends keyof Events>(this: this, event: K, ...args: Parameters<Events[K]>) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Event names in keys and arrays with listeners in values.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
_listeners: Partial<{ [E in keyof Events]: Events[E][] }>;
|
|
26
|
+
/**
|
|
27
|
+
* Add a listener for a given event.
|
|
28
|
+
*
|
|
29
|
+
* ```js
|
|
30
|
+
* const unbind = ee.on('tick', (tickType, tickDuration) => {
|
|
31
|
+
* count += 1
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* disable () {
|
|
35
|
+
* unbind()
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param event The event name.
|
|
40
|
+
* @param cb The listener function.
|
|
41
|
+
* @returns Unbind listener from event.
|
|
42
|
+
*/
|
|
43
|
+
on: <K extends keyof Events>(this: this, event: K, cb: Events[K]) => EventUnsubscribe;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { EventUnsubscribe as n, EventsMap as r, EventEmitter as t };
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
import { t as EventEmitter } from "./events-DDdYnct9.mjs";
|
|
1
2
|
import { RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsCollector, RpcFunctionsCollectorBase } from "birpc-x";
|
|
2
3
|
import { WebSocketRpcClientOptions } from "@vitejs/devtools-rpc/presets/ws/client";
|
|
3
|
-
import { Emitter } from "nanoevents";
|
|
4
4
|
import { Raw } from "vue";
|
|
5
5
|
import { BirpcGroup, BirpcOptions, BirpcReturn } from "birpc";
|
|
6
6
|
import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
|
|
7
|
+
import { ChildProcess } from "node:child_process";
|
|
7
8
|
|
|
8
9
|
//#region src/types/docks.d.ts
|
|
9
10
|
interface DevToolsDockHost {
|
|
10
|
-
views: Map<string,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
readonly views: Map<string, DevToolsDockUserEntry>;
|
|
12
|
+
readonly events: EventEmitter<{
|
|
13
|
+
'dock:entry:updated': (entry: DevToolsDockUserEntry) => void;
|
|
14
|
+
}>;
|
|
15
|
+
register: <T extends DevToolsDockUserEntry>(entry: T, force?: boolean) => {
|
|
16
|
+
update: (patch: Partial<T>) => void;
|
|
17
|
+
};
|
|
18
|
+
update: (entry: DevToolsDockUserEntry) => void;
|
|
19
|
+
values: () => DevToolsDockUserEntry[];
|
|
14
20
|
}
|
|
15
21
|
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default';
|
|
16
22
|
type DevToolsDockEntryIcon = string | {
|
|
@@ -32,6 +38,11 @@ interface DevToolsDockEntryBase {
|
|
|
32
38
|
* @default 'default'
|
|
33
39
|
*/
|
|
34
40
|
category?: DevToolsDockEntryCategory;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the entry should be hidden from the user.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
isHidden?: boolean;
|
|
35
46
|
}
|
|
36
47
|
interface ClientScriptEntry {
|
|
37
48
|
/**
|
|
@@ -81,7 +92,12 @@ interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
|
81
92
|
type: 'custom-render';
|
|
82
93
|
renderer: ClientScriptEntry;
|
|
83
94
|
}
|
|
84
|
-
|
|
95
|
+
interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
|
|
96
|
+
type: '~builtin';
|
|
97
|
+
id: '~terminals' | '~logs';
|
|
98
|
+
}
|
|
99
|
+
type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
|
|
100
|
+
type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
|
|
85
101
|
//#endregion
|
|
86
102
|
//#region src/types/rpc-augments.d.ts
|
|
87
103
|
/**
|
|
@@ -93,6 +109,48 @@ interface DevToolsRpcClientFunctions {}
|
|
|
93
109
|
*/
|
|
94
110
|
interface DevToolsRpcServerFunctions {}
|
|
95
111
|
//#endregion
|
|
112
|
+
//#region src/types/terminals.d.ts
|
|
113
|
+
interface DevToolsTerminalSessionStreamChunkEvent {
|
|
114
|
+
id: string;
|
|
115
|
+
chunks: string[];
|
|
116
|
+
ts: number;
|
|
117
|
+
}
|
|
118
|
+
interface DevToolsTerminalHost {
|
|
119
|
+
readonly sessions: Map<string, DevToolsTerminalSession>;
|
|
120
|
+
readonly events: EventEmitter<{
|
|
121
|
+
'terminal:session:updated': (session: DevToolsTerminalSession) => void;
|
|
122
|
+
'terminal:session:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => void;
|
|
123
|
+
}>;
|
|
124
|
+
register: (session: DevToolsTerminalSession) => DevToolsTerminalSession;
|
|
125
|
+
update: (session: DevToolsTerminalSession) => void;
|
|
126
|
+
startChildProcess: (executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>) => Promise<DevToolsChildProcessTerminalSession>;
|
|
127
|
+
}
|
|
128
|
+
type DevToolsTerminalStatus = 'running' | 'stopped' | 'error';
|
|
129
|
+
interface DevToolsTerminalSessionBase {
|
|
130
|
+
id: string;
|
|
131
|
+
title: string;
|
|
132
|
+
description?: string;
|
|
133
|
+
status: DevToolsTerminalStatus;
|
|
134
|
+
icon?: DevToolsDockEntryIcon;
|
|
135
|
+
}
|
|
136
|
+
interface DevToolsTerminalSession extends DevToolsTerminalSessionBase {
|
|
137
|
+
buffer?: string[];
|
|
138
|
+
stream?: ReadableStream<string>;
|
|
139
|
+
}
|
|
140
|
+
interface DevToolsChildProcessExecuteOptions {
|
|
141
|
+
command: string;
|
|
142
|
+
args: string[];
|
|
143
|
+
cwd?: string;
|
|
144
|
+
env?: Record<string, string>;
|
|
145
|
+
}
|
|
146
|
+
interface DevToolsChildProcessTerminalSession extends DevToolsTerminalSession {
|
|
147
|
+
type: 'child-process';
|
|
148
|
+
executeOptions: DevToolsChildProcessExecuteOptions;
|
|
149
|
+
getChildProcess: () => ChildProcess | undefined;
|
|
150
|
+
terminate: () => Promise<void>;
|
|
151
|
+
restart: () => Promise<void>;
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
96
154
|
//#region src/types/views.d.ts
|
|
97
155
|
interface DevToolsViewHost {
|
|
98
156
|
/**
|
|
@@ -131,6 +189,7 @@ interface DevToolsNodeContext {
|
|
|
131
189
|
docks: DevToolsDockHost;
|
|
132
190
|
views: DevToolsViewHost;
|
|
133
191
|
utils: DevToolsNodeUtils;
|
|
192
|
+
terminals: DevToolsTerminalHost;
|
|
134
193
|
}
|
|
135
194
|
interface DevToolsNodeUtils {
|
|
136
195
|
/**
|
|
@@ -154,6 +213,11 @@ type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, De
|
|
|
154
213
|
//#region src/types/utils.d.ts
|
|
155
214
|
type Thenable<T> = T | Promise<T>;
|
|
156
215
|
type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as K[0]]: K[1] };
|
|
216
|
+
type PartialWithoutId<T extends {
|
|
217
|
+
id: string;
|
|
218
|
+
}> = Partial<Omit<T, 'id'>> & {
|
|
219
|
+
id: string;
|
|
220
|
+
};
|
|
157
221
|
//#endregion
|
|
158
222
|
//#region src/types/vite-augment.d.ts
|
|
159
223
|
declare module 'vite' {
|
|
@@ -239,7 +303,7 @@ interface DocksEntriesContext {
|
|
|
239
303
|
*
|
|
240
304
|
* @returns Whether the selection was changed successfully
|
|
241
305
|
*/
|
|
242
|
-
switchEntry: (id
|
|
306
|
+
switchEntry: (id?: string | null) => Promise<boolean>;
|
|
243
307
|
}
|
|
244
308
|
interface DockEntryState {
|
|
245
309
|
entryMeta: DevToolsDockEntry;
|
|
@@ -248,12 +312,12 @@ interface DockEntryState {
|
|
|
248
312
|
iframe?: HTMLIFrameElement | null;
|
|
249
313
|
panel?: HTMLDivElement | null;
|
|
250
314
|
};
|
|
251
|
-
events: Raw<
|
|
315
|
+
events: Raw<EventEmitter<DockEntryStateEvents>>;
|
|
252
316
|
}
|
|
253
317
|
interface DockEntryStateEvents {
|
|
254
318
|
'entry:activated': () => void;
|
|
255
319
|
'entry:deactivated': () => void;
|
|
256
|
-
'entry:updated': (newMeta:
|
|
320
|
+
'entry:updated': (newMeta: DevToolsDockUserEntry) => void;
|
|
257
321
|
'dom:panel:mounted': (panel: HTMLDivElement) => void;
|
|
258
322
|
'dom:iframe:mounted': (iframe: HTMLIFrameElement) => void;
|
|
259
323
|
}
|
|
@@ -269,4 +333,4 @@ interface DockClientScriptContext extends DocksContext {
|
|
|
269
333
|
current: DockEntryState;
|
|
270
334
|
}
|
|
271
335
|
//#endregion
|
|
272
|
-
export {
|
|
336
|
+
export { DevToolsTerminalHost as A, DevToolsDockEntryCategory as B, DevToolsCapabilities as C, DevToolsViewHost as D, DevToolsPluginOptions as E, DevToolsRpcClientFunctions as F, DevToolsViewBuiltin as G, DevToolsDockHost as H, DevToolsRpcServerFunctions as I, DevToolsViewLauncher as J, DevToolsViewCustomRender as K, ClientScriptEntry as L, DevToolsTerminalSessionBase as M, DevToolsTerminalSessionStreamChunkEvent as N, DevToolsChildProcessExecuteOptions as O, DevToolsTerminalStatus as P, DevToolsDockEntry as R, ConnectionMeta as S, DevToolsNodeUtils as T, DevToolsDockUserEntry as U, DevToolsDockEntryIcon as V, DevToolsViewAction as W, DevToolsViewLauncherStatus as Y, PluginWithDevTools as _, DockEntryState as a, Thenable as b, DocksContext as c, ClientRpcReturn as d, DevToolsRpcClient as f, RpcDefinitionsToFunctions as g, RpcDefinitionsFilter as h, DockClientType as i, DevToolsTerminalSession as j, DevToolsChildProcessTerminalSession as k, DocksEntriesContext as l, getDevToolsRpcClient as m, DevToolsClientContext as n, DockEntryStateEvents as o, DevToolsRpcClientOptions as p, DevToolsViewIframe as q, DevToolsClientRpcHost as r, DockPanelStorage as s, DockClientScriptContext as t, DocksPanelContext as u, EntriesToObject as v, DevToolsNodeContext as w, RpcFunctionsHost as x, PartialWithoutId as y, DevToolsDockEntryBase as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as EventUnsubscribe, r as EventsMap, t as EventEmitter } from "./events-DDdYnct9.mjs";
|
|
2
|
+
import { A as DevToolsTerminalHost, B as DevToolsDockEntryCategory, C as DevToolsCapabilities, D as DevToolsViewHost, E as DevToolsPluginOptions, F as DevToolsRpcClientFunctions, G as DevToolsViewBuiltin, H as DevToolsDockHost, I as DevToolsRpcServerFunctions, J as DevToolsViewLauncher, K as DevToolsViewCustomRender, L as ClientScriptEntry, M as DevToolsTerminalSessionBase, N as DevToolsTerminalSessionStreamChunkEvent, O as DevToolsChildProcessExecuteOptions, P as DevToolsTerminalStatus, R as DevToolsDockEntry, S as ConnectionMeta, T as DevToolsNodeUtils, U as DevToolsDockUserEntry, V as DevToolsDockEntryIcon, W as DevToolsViewAction, Y as DevToolsViewLauncherStatus, _ as PluginWithDevTools, b as Thenable, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, j as DevToolsTerminalSession, k as DevToolsChildProcessTerminalSession, q as DevToolsViewIframe, v as EntriesToObject, w as DevToolsNodeContext, x as RpcFunctionsHost, y as PartialWithoutId, z as DevToolsDockEntryBase } from "./index-CgOheNVD.mjs";
|
|
2
3
|
import * as birpc_x0 from "birpc-x";
|
|
3
4
|
|
|
4
|
-
//#region src/utils/
|
|
5
|
+
//#region src/utils/define.d.ts
|
|
5
6
|
declare const defineRpcFunction: <NAME extends string, TYPE extends birpc_x0.RpcFunctionType, ARGS$1 extends any[], RETURN$1 = void>(definition: birpc_x0.RpcFunctionDefinition<NAME, TYPE, ARGS$1, RETURN$1, DevToolsNodeContext>) => birpc_x0.RpcFunctionDefinition<NAME, TYPE, ARGS$1, RETURN$1, DevToolsNodeContext>;
|
|
6
7
|
//#endregion
|
|
7
|
-
export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsNodeContext, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, DevToolsViewLauncher, DevToolsViewLauncherStatus, EntriesToObject, PluginWithDevTools, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsHost, Thenable, defineRpcFunction };
|
|
8
|
+
export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsChildProcessExecuteOptions, DevToolsChildProcessTerminalSession, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsDockUserEntry, DevToolsNodeContext, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsTerminalHost, DevToolsTerminalSession, DevToolsTerminalSessionBase, DevToolsTerminalSessionStreamChunkEvent, DevToolsTerminalStatus, DevToolsViewAction, DevToolsViewBuiltin, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, DevToolsViewLauncher, DevToolsViewLauncherStatus, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, PartialWithoutId, PluginWithDevTools, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsHost, Thenable, defineRpcFunction };
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { r as EventsMap, t as EventEmitter } from "../events-DDdYnct9.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/events.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create event emitter.
|
|
7
|
+
*/
|
|
8
|
+
declare function createEventEmitter<Events extends EventsMap>(): EventEmitter<Events>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createEventEmitter };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/utils/events.ts
|
|
2
|
+
/**
|
|
3
|
+
* Create event emitter.
|
|
4
|
+
*/
|
|
5
|
+
function createEventEmitter() {
|
|
6
|
+
const _listeners = {};
|
|
7
|
+
return {
|
|
8
|
+
emit(event, ...args) {
|
|
9
|
+
const callbacks = _listeners[event] || [];
|
|
10
|
+
for (let i = 0, length = callbacks.length; i < length; i++) {
|
|
11
|
+
const callback = callbacks[i];
|
|
12
|
+
if (callback) callback(...args);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
_listeners,
|
|
16
|
+
on(event, cb) {
|
|
17
|
+
(_listeners[event] ||= []).push(cb);
|
|
18
|
+
return () => {
|
|
19
|
+
_listeners[event] = _listeners[event]?.filter((i) => cb !== i);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { createEventEmitter };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/devtools-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-alpha.
|
|
4
|
+
"version": "0.0.0-alpha.19",
|
|
5
5
|
"description": "Vite DevTools Kit",
|
|
6
6
|
"author": "VoidZero Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": "./dist/index.mjs",
|
|
23
23
|
"./client": "./dist/client.mjs",
|
|
24
|
+
"./utils/events": "./dist/utils/events.mjs",
|
|
24
25
|
"./package.json": "./package.json"
|
|
25
26
|
},
|
|
26
27
|
"main": "./dist/index.mjs",
|
|
@@ -35,8 +36,7 @@
|
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"birpc": "^2.8.0",
|
|
37
38
|
"birpc-x": "0.0.5",
|
|
38
|
-
"
|
|
39
|
-
"@vitejs/devtools-rpc": "0.0.0-alpha.18"
|
|
39
|
+
"@vitejs/devtools-rpc": "0.0.0-alpha.19"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"tsdown": "^0.16.1",
|