@vitejs/devtools-kit 0.0.0-alpha.17 → 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/client.mjs +18 -5
- package/dist/events-DDdYnct9.d.mts +46 -0
- package/dist/{index-C-bl_jKJ.d.mts → index-CgOheNVD.d.mts} +124 -42
- 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 };
|
package/dist/client.mjs
CHANGED
|
@@ -3,23 +3,36 @@ import { createRpcClient } from "@vitejs/devtools-rpc";
|
|
|
3
3
|
import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/client";
|
|
4
4
|
|
|
5
5
|
//#region src/client/rpc.ts
|
|
6
|
+
const CONNECTION_META_KEY = "__VITE_DEVTOOLS_CONNECTION_META__";
|
|
6
7
|
function isNumeric(str) {
|
|
7
8
|
if (str == null) return false;
|
|
8
9
|
return `${+str}` === `${str}`;
|
|
9
10
|
}
|
|
11
|
+
function findConnectionMetaFromWindows() {
|
|
12
|
+
const getters = [
|
|
13
|
+
() => window[CONNECTION_META_KEY],
|
|
14
|
+
() => globalThis[CONNECTION_META_KEY],
|
|
15
|
+
() => parent.window[CONNECTION_META_KEY]
|
|
16
|
+
];
|
|
17
|
+
for (const getter of getters) try {
|
|
18
|
+
const value = getter();
|
|
19
|
+
if (value) return value;
|
|
20
|
+
} catch {}
|
|
21
|
+
}
|
|
10
22
|
async function getDevToolsRpcClient(options = {}) {
|
|
11
23
|
const { baseURL = "/.devtools/", rpcOptions = {} } = options;
|
|
12
|
-
const
|
|
13
|
-
let connectionMeta = options.connectionMeta;
|
|
24
|
+
const bases = Array.isArray(baseURL) ? baseURL : [baseURL];
|
|
25
|
+
let connectionMeta = options.connectionMeta || findConnectionMetaFromWindows();
|
|
14
26
|
if (!connectionMeta) {
|
|
15
27
|
const errors = [];
|
|
16
|
-
for (const
|
|
17
|
-
connectionMeta = await fetch(`${
|
|
28
|
+
for (const base of bases) try {
|
|
29
|
+
connectionMeta = await fetch(`${base}.vdt-connection.json`).then((r) => r.json());
|
|
30
|
+
globalThis[CONNECTION_META_KEY] = connectionMeta;
|
|
18
31
|
break;
|
|
19
32
|
} catch (e) {
|
|
20
33
|
errors.push(e);
|
|
21
34
|
}
|
|
22
|
-
if (!connectionMeta) throw new Error(`Failed to get connection meta from ${
|
|
35
|
+
if (!connectionMeta) throw new Error(`Failed to get connection meta from ${bases.join(", ")}`, { cause: errors });
|
|
23
36
|
}
|
|
24
37
|
const url = isNumeric(connectionMeta.websocket) ? `${location.protocol.replace("http", "ws")}//${location.hostname}:${connectionMeta.websocket}` : connectionMeta.websocket;
|
|
25
38
|
const context = { rpc: void 0 };
|
|
@@ -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,50 +1,32 @@
|
|
|
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
|
-
//#region src/types/
|
|
9
|
-
/**
|
|
10
|
-
* To be extended
|
|
11
|
-
*/
|
|
12
|
-
interface DevToolsRpcClientFunctions {}
|
|
13
|
-
/**
|
|
14
|
-
* To be extended
|
|
15
|
-
*/
|
|
16
|
-
interface DevToolsRpcServerFunctions {}
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/types/views.d.ts
|
|
9
|
+
//#region src/types/docks.d.ts
|
|
19
10
|
interface DevToolsDockHost {
|
|
20
|
-
views: Map<string,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
buildStaticDirs: {
|
|
30
|
-
baseUrl: string;
|
|
31
|
-
distDir: string;
|
|
32
|
-
}[];
|
|
33
|
-
/**
|
|
34
|
-
* Helper to host static files
|
|
35
|
-
* - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files
|
|
36
|
-
* - In `build` mode, it will copy the static files to the dist directory
|
|
37
|
-
*/
|
|
38
|
-
hostStatic: (baseUrl: string, distDir: string) => void;
|
|
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[];
|
|
39
20
|
}
|
|
40
21
|
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default';
|
|
22
|
+
type DevToolsDockEntryIcon = string | {
|
|
23
|
+
light: string;
|
|
24
|
+
dark: string;
|
|
25
|
+
};
|
|
41
26
|
interface DevToolsDockEntryBase {
|
|
42
27
|
id: string;
|
|
43
28
|
title: string;
|
|
44
|
-
icon:
|
|
45
|
-
light: string;
|
|
46
|
-
dark: string;
|
|
47
|
-
};
|
|
29
|
+
icon: DevToolsDockEntryIcon;
|
|
48
30
|
/**
|
|
49
31
|
* The default order of the entry in the dock.
|
|
50
32
|
* The higher the number the earlier it appears.
|
|
@@ -56,6 +38,11 @@ interface DevToolsDockEntryBase {
|
|
|
56
38
|
* @default 'default'
|
|
57
39
|
*/
|
|
58
40
|
category?: DevToolsDockEntryCategory;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the entry should be hidden from the user.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
isHidden?: boolean;
|
|
59
46
|
}
|
|
60
47
|
interface ClientScriptEntry {
|
|
61
48
|
/**
|
|
@@ -83,6 +70,20 @@ interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
|
83
70
|
*/
|
|
84
71
|
clientScript?: ClientScriptEntry;
|
|
85
72
|
}
|
|
73
|
+
type DevToolsViewLauncherStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
74
|
+
interface DevToolsViewLauncher extends DevToolsDockEntryBase {
|
|
75
|
+
type: 'launcher';
|
|
76
|
+
launcher: {
|
|
77
|
+
icon?: DevToolsDockEntryIcon;
|
|
78
|
+
title: string;
|
|
79
|
+
status?: DevToolsViewLauncherStatus;
|
|
80
|
+
error?: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
buttonStart?: string;
|
|
83
|
+
buttonLoading?: string;
|
|
84
|
+
onLaunch: () => Promise<void>;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
86
87
|
interface DevToolsViewAction extends DevToolsDockEntryBase {
|
|
87
88
|
type: 'action';
|
|
88
89
|
action: ClientScriptEntry;
|
|
@@ -91,7 +92,81 @@ interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
|
91
92
|
type: 'custom-render';
|
|
92
93
|
renderer: ClientScriptEntry;
|
|
93
94
|
}
|
|
94
|
-
|
|
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;
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/types/rpc-augments.d.ts
|
|
103
|
+
/**
|
|
104
|
+
* To be extended
|
|
105
|
+
*/
|
|
106
|
+
interface DevToolsRpcClientFunctions {}
|
|
107
|
+
/**
|
|
108
|
+
* To be extended
|
|
109
|
+
*/
|
|
110
|
+
interface DevToolsRpcServerFunctions {}
|
|
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
|
|
154
|
+
//#region src/types/views.d.ts
|
|
155
|
+
interface DevToolsViewHost {
|
|
156
|
+
/**
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
buildStaticDirs: {
|
|
160
|
+
baseUrl: string;
|
|
161
|
+
distDir: string;
|
|
162
|
+
}[];
|
|
163
|
+
/**
|
|
164
|
+
* Helper to host static files
|
|
165
|
+
* - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files
|
|
166
|
+
* - In `build` mode, it will copy the static files to the dist directory
|
|
167
|
+
*/
|
|
168
|
+
hostStatic: (baseUrl: string, distDir: string) => void;
|
|
169
|
+
}
|
|
95
170
|
//#endregion
|
|
96
171
|
//#region src/types/vite-plugin.d.ts
|
|
97
172
|
interface DevToolsCapabilities {
|
|
@@ -114,6 +189,7 @@ interface DevToolsNodeContext {
|
|
|
114
189
|
docks: DevToolsDockHost;
|
|
115
190
|
views: DevToolsViewHost;
|
|
116
191
|
utils: DevToolsNodeUtils;
|
|
192
|
+
terminals: DevToolsTerminalHost;
|
|
117
193
|
}
|
|
118
194
|
interface DevToolsNodeUtils {
|
|
119
195
|
/**
|
|
@@ -137,6 +213,11 @@ type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, De
|
|
|
137
213
|
//#region src/types/utils.d.ts
|
|
138
214
|
type Thenable<T> = T | Promise<T>;
|
|
139
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
|
+
};
|
|
140
221
|
//#endregion
|
|
141
222
|
//#region src/types/vite-augment.d.ts
|
|
142
223
|
declare module 'vite' {
|
|
@@ -185,7 +266,7 @@ interface DocksContext extends DevToolsClientContext {
|
|
|
185
266
|
* Type of the client environment
|
|
186
267
|
*
|
|
187
268
|
* 'embedded' - running inside an embedded floating panel
|
|
188
|
-
* 'standalone' - running inside a
|
|
269
|
+
* 'standalone' - running inside a standalone window (no user app)
|
|
189
270
|
*/
|
|
190
271
|
readonly clientType: 'embedded' | 'standalone';
|
|
191
272
|
/**
|
|
@@ -209,7 +290,8 @@ interface DocksPanelContext {
|
|
|
209
290
|
readonly isVertical: boolean;
|
|
210
291
|
}
|
|
211
292
|
interface DocksEntriesContext {
|
|
212
|
-
|
|
293
|
+
selectedId: string | null;
|
|
294
|
+
readonly selected: DevToolsDockEntry | null;
|
|
213
295
|
entries: DevToolsDockEntry[];
|
|
214
296
|
entryToStateMap: Map<string, DockEntryState>;
|
|
215
297
|
/**
|
|
@@ -221,7 +303,7 @@ interface DocksEntriesContext {
|
|
|
221
303
|
*
|
|
222
304
|
* @returns Whether the selection was changed successfully
|
|
223
305
|
*/
|
|
224
|
-
switchEntry: (id
|
|
306
|
+
switchEntry: (id?: string | null) => Promise<boolean>;
|
|
225
307
|
}
|
|
226
308
|
interface DockEntryState {
|
|
227
309
|
entryMeta: DevToolsDockEntry;
|
|
@@ -230,12 +312,12 @@ interface DockEntryState {
|
|
|
230
312
|
iframe?: HTMLIFrameElement | null;
|
|
231
313
|
panel?: HTMLDivElement | null;
|
|
232
314
|
};
|
|
233
|
-
events: Raw<
|
|
315
|
+
events: Raw<EventEmitter<DockEntryStateEvents>>;
|
|
234
316
|
}
|
|
235
317
|
interface DockEntryStateEvents {
|
|
236
318
|
'entry:activated': () => void;
|
|
237
319
|
'entry:deactivated': () => void;
|
|
238
|
-
'entry:updated': (newMeta:
|
|
320
|
+
'entry:updated': (newMeta: DevToolsDockUserEntry) => void;
|
|
239
321
|
'dom:panel:mounted': (panel: HTMLDivElement) => void;
|
|
240
322
|
'dom:iframe:mounted': (iframe: HTMLIFrameElement) => void;
|
|
241
323
|
}
|
|
@@ -251,4 +333,4 @@ interface DockClientScriptContext extends DocksContext {
|
|
|
251
333
|
current: DockEntryState;
|
|
252
334
|
}
|
|
253
335
|
//#endregion
|
|
254
|
-
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, DevToolsDockHost, DevToolsNodeContext, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, 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.17"
|
|
39
|
+
"@vitejs/devtools-rpc": "0.0.0-alpha.19"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"tsdown": "^0.16.1",
|