@vitejs/devtools-kit 0.0.0-alpha.8 → 0.1.0
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.ts +2 -17
- package/dist/client.js +1734 -19
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +28 -0
- package/dist/events-B41U-zeg.d.ts +71 -0
- package/dist/index-Bl6l5FTi.d.ts +642 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +4 -16
- package/dist/shared-state-BFKKxNt1.d.ts +53 -0
- package/dist/utils/events.d.ts +9 -0
- package/dist/utils/events.js +40 -0
- package/dist/utils/nanoid.d.ts +4 -0
- package/dist/utils/nanoid.js +10 -0
- package/dist/utils/shared-state.d.ts +2 -0
- package/dist/utils/shared-state.js +36 -0
- package/package.json +19 -10
- package/skills/vite-devtools-kit/SKILL.md +436 -0
- package/skills/vite-devtools-kit/references/dock-entry-types.md +295 -0
- package/skills/vite-devtools-kit/references/logs-patterns.md +188 -0
- package/skills/vite-devtools-kit/references/project-structure.md +256 -0
- package/skills/vite-devtools-kit/references/rpc-patterns.md +185 -0
- package/skills/vite-devtools-kit/references/shared-state-patterns.md +292 -0
- package/dist/index-BtaHil_c.d.ts +0 -156
|
@@ -0,0 +1,642 @@
|
|
|
1
|
+
import { t as EventEmitter } from "./events-B41U-zeg.js";
|
|
2
|
+
import { o as SharedState } from "./shared-state-BFKKxNt1.js";
|
|
3
|
+
import { RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsCollector, RpcFunctionsCollectorBase } from "@vitejs/devtools-rpc";
|
|
4
|
+
import { WebSocketRpcClientOptions } from "@vitejs/devtools-rpc/presets/ws/client";
|
|
5
|
+
import { DevToolsNodeRpcSessionMeta } from "@vitejs/devtools-rpc/presets/ws/server";
|
|
6
|
+
import { BirpcOptions, BirpcReturn } from "birpc";
|
|
7
|
+
import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
|
|
8
|
+
import { ChildProcess } from "node:child_process";
|
|
9
|
+
|
|
10
|
+
//#region src/types/logs.d.ts
|
|
11
|
+
type DevToolsLogLevel = 'info' | 'warn' | 'error' | 'success' | 'debug';
|
|
12
|
+
type DevToolsLogEntryFrom = 'server' | 'browser';
|
|
13
|
+
interface DevToolsLogElementPosition {
|
|
14
|
+
/** CSS selector for the element */
|
|
15
|
+
selector?: string;
|
|
16
|
+
/** Bounding box of the element */
|
|
17
|
+
boundingBox?: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
};
|
|
23
|
+
/** Human-readable description of the element */
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
interface DevToolsLogFilePosition {
|
|
27
|
+
/** Absolute or relative file path */
|
|
28
|
+
file: string;
|
|
29
|
+
/** Line number (1-based) */
|
|
30
|
+
line?: number;
|
|
31
|
+
/** Column number (1-based) */
|
|
32
|
+
column?: number;
|
|
33
|
+
}
|
|
34
|
+
interface DevToolsLogEntry {
|
|
35
|
+
/**
|
|
36
|
+
* Unique identifier for this log entry (auto-generated if not provided)
|
|
37
|
+
*/
|
|
38
|
+
id: string;
|
|
39
|
+
/**
|
|
40
|
+
* Short title or summary of the log
|
|
41
|
+
*/
|
|
42
|
+
message: string;
|
|
43
|
+
/**
|
|
44
|
+
* Optional detailed description or explanation
|
|
45
|
+
*/
|
|
46
|
+
description?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Severity level, determines color and icon
|
|
49
|
+
*/
|
|
50
|
+
level: DevToolsLogLevel;
|
|
51
|
+
/**
|
|
52
|
+
* Optional stack trace string
|
|
53
|
+
*/
|
|
54
|
+
stacktrace?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Optional DOM element position info (e.g., for a11y issues)
|
|
57
|
+
*/
|
|
58
|
+
elementPosition?: DevToolsLogElementPosition;
|
|
59
|
+
/**
|
|
60
|
+
* Optional source file position info (e.g., for lint errors)
|
|
61
|
+
*/
|
|
62
|
+
filePosition?: DevToolsLogFilePosition;
|
|
63
|
+
/**
|
|
64
|
+
* Whether this log should also appear as a toast notification
|
|
65
|
+
*/
|
|
66
|
+
notify?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Origin of the log entry, automatically set by the context
|
|
69
|
+
*/
|
|
70
|
+
from: DevToolsLogEntryFrom;
|
|
71
|
+
/**
|
|
72
|
+
* Grouping category (e.g., 'a11y', 'lint', 'runtime', 'test')
|
|
73
|
+
*/
|
|
74
|
+
category?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Optional tags/labels for filtering
|
|
77
|
+
*/
|
|
78
|
+
labels?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* Time in ms to auto-dismiss the toast notification (client-side)
|
|
81
|
+
*/
|
|
82
|
+
autoDismiss?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Time in ms to auto-delete this log entry (server-side)
|
|
85
|
+
*/
|
|
86
|
+
autoDelete?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Timestamp when the log was created (auto-generated if not provided)
|
|
89
|
+
*/
|
|
90
|
+
timestamp: number;
|
|
91
|
+
/**
|
|
92
|
+
* Status of the log entry (e.g., 'loading' while an operation is in progress).
|
|
93
|
+
* Defaults to 'idle' when not specified.
|
|
94
|
+
*/
|
|
95
|
+
status?: 'loading' | 'idle';
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Input type for creating a log entry.
|
|
99
|
+
* `id`, `timestamp`, and `source` are auto-filled by the host.
|
|
100
|
+
*/
|
|
101
|
+
type DevToolsLogEntryInput = Omit<DevToolsLogEntry, 'id' | 'timestamp' | 'from'> & {
|
|
102
|
+
id?: string;
|
|
103
|
+
timestamp?: number;
|
|
104
|
+
};
|
|
105
|
+
interface DevToolsLogHandle {
|
|
106
|
+
/** The underlying log entry data */
|
|
107
|
+
readonly entry: DevToolsLogEntry;
|
|
108
|
+
/** Shortcut to entry.id */
|
|
109
|
+
readonly id: string;
|
|
110
|
+
/** Partial update of this log entry */
|
|
111
|
+
update: (patch: Partial<DevToolsLogEntryInput>) => Promise<DevToolsLogEntry | undefined>;
|
|
112
|
+
/** Remove this log entry */
|
|
113
|
+
dismiss: () => Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
interface DevToolsLogsClient {
|
|
116
|
+
/**
|
|
117
|
+
* Add a log entry. Returns a Promise resolving to a handle for subsequent updates/dismissal.
|
|
118
|
+
* Can be used without `await` for fire-and-forget usage.
|
|
119
|
+
*/
|
|
120
|
+
add: (input: DevToolsLogEntryInput) => Promise<DevToolsLogHandle>;
|
|
121
|
+
/** Remove a log entry by id */
|
|
122
|
+
remove: (id: string) => Promise<void>;
|
|
123
|
+
/** Clear all log entries */
|
|
124
|
+
clear: () => Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
interface DevToolsLogsHost {
|
|
127
|
+
readonly entries: Map<string, DevToolsLogEntry>;
|
|
128
|
+
readonly events: EventEmitter<{
|
|
129
|
+
'log:added': (entry: DevToolsLogEntry) => void;
|
|
130
|
+
'log:updated': (entry: DevToolsLogEntry) => void;
|
|
131
|
+
'log:removed': (id: string) => void;
|
|
132
|
+
'log:cleared': () => void;
|
|
133
|
+
}>;
|
|
134
|
+
/**
|
|
135
|
+
* Add a new log entry. If an entry with the same `id` already exists, it will be updated instead.
|
|
136
|
+
* Returns a handle for subsequent updates/dismissal. Can be used without `await` for fire-and-forget.
|
|
137
|
+
*/
|
|
138
|
+
add: (entry: DevToolsLogEntryInput) => Promise<DevToolsLogHandle>;
|
|
139
|
+
/**
|
|
140
|
+
* Update an existing log entry by id (partial update)
|
|
141
|
+
*/
|
|
142
|
+
update: (id: string, patch: Partial<DevToolsLogEntryInput>) => Promise<DevToolsLogEntry | undefined>;
|
|
143
|
+
/**
|
|
144
|
+
* Remove a log entry by id
|
|
145
|
+
*/
|
|
146
|
+
remove: (id: string) => Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Clear all log entries
|
|
149
|
+
*/
|
|
150
|
+
clear: () => Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/types/docks.d.ts
|
|
154
|
+
interface DevToolsDockHost {
|
|
155
|
+
readonly views: Map<string, DevToolsDockUserEntry>;
|
|
156
|
+
readonly events: EventEmitter<{
|
|
157
|
+
'dock:entry:updated': (entry: DevToolsDockUserEntry) => void;
|
|
158
|
+
}>;
|
|
159
|
+
register: <T extends DevToolsDockUserEntry>(entry: T, force?: boolean) => {
|
|
160
|
+
update: (patch: Partial<T>) => void;
|
|
161
|
+
};
|
|
162
|
+
update: (entry: DevToolsDockUserEntry) => void;
|
|
163
|
+
values: (options?: {
|
|
164
|
+
includeBuiltin?: boolean;
|
|
165
|
+
}) => DevToolsDockEntry[];
|
|
166
|
+
}
|
|
167
|
+
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default' | '~viteplus' | '~builtin';
|
|
168
|
+
type DevToolsDockEntryIcon = string | {
|
|
169
|
+
light: string;
|
|
170
|
+
dark: string;
|
|
171
|
+
};
|
|
172
|
+
interface DevToolsDockEntryBase {
|
|
173
|
+
id: string;
|
|
174
|
+
title: string;
|
|
175
|
+
icon: DevToolsDockEntryIcon;
|
|
176
|
+
/**
|
|
177
|
+
* The default order of the entry in the dock.
|
|
178
|
+
* The higher the number the earlier it appears.
|
|
179
|
+
* @default 0
|
|
180
|
+
*/
|
|
181
|
+
defaultOrder?: number;
|
|
182
|
+
/**
|
|
183
|
+
* The category of the entry
|
|
184
|
+
* @default 'default'
|
|
185
|
+
*/
|
|
186
|
+
category?: DevToolsDockEntryCategory;
|
|
187
|
+
/**
|
|
188
|
+
* Whether the entry should be hidden from the user.
|
|
189
|
+
* @default false
|
|
190
|
+
*/
|
|
191
|
+
isHidden?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Badge text to display on the dock icon (e.g., unread count)
|
|
194
|
+
*/
|
|
195
|
+
badge?: string;
|
|
196
|
+
}
|
|
197
|
+
interface ClientScriptEntry {
|
|
198
|
+
/**
|
|
199
|
+
* The filepath or module name to import from
|
|
200
|
+
*/
|
|
201
|
+
importFrom: string;
|
|
202
|
+
/**
|
|
203
|
+
* The name to import the module as
|
|
204
|
+
*
|
|
205
|
+
* @default 'default'
|
|
206
|
+
*/
|
|
207
|
+
importName?: string;
|
|
208
|
+
}
|
|
209
|
+
interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
210
|
+
type: 'iframe';
|
|
211
|
+
url: string;
|
|
212
|
+
/**
|
|
213
|
+
* The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared.
|
|
214
|
+
*
|
|
215
|
+
* When not provided, it would be treated as a unique frame.
|
|
216
|
+
*/
|
|
217
|
+
frameId?: string;
|
|
218
|
+
/**
|
|
219
|
+
* Optional client script to import into the iframe
|
|
220
|
+
*/
|
|
221
|
+
clientScript?: ClientScriptEntry;
|
|
222
|
+
}
|
|
223
|
+
type DevToolsViewLauncherStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
224
|
+
interface DevToolsViewLauncher extends DevToolsDockEntryBase {
|
|
225
|
+
type: 'launcher';
|
|
226
|
+
launcher: {
|
|
227
|
+
icon?: DevToolsDockEntryIcon;
|
|
228
|
+
title: string;
|
|
229
|
+
status?: DevToolsViewLauncherStatus;
|
|
230
|
+
error?: string;
|
|
231
|
+
description?: string;
|
|
232
|
+
buttonStart?: string;
|
|
233
|
+
buttonLoading?: string;
|
|
234
|
+
onLaunch: () => Promise<void>;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
interface DevToolsViewAction extends DevToolsDockEntryBase {
|
|
238
|
+
type: 'action';
|
|
239
|
+
action: ClientScriptEntry;
|
|
240
|
+
}
|
|
241
|
+
interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
242
|
+
type: 'custom-render';
|
|
243
|
+
renderer: ClientScriptEntry;
|
|
244
|
+
}
|
|
245
|
+
interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
|
|
246
|
+
type: '~builtin';
|
|
247
|
+
id: '~terminals' | '~logs' | '~client-auth-notice' | '~settings' | '~popup';
|
|
248
|
+
}
|
|
249
|
+
type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
|
|
250
|
+
type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
|
|
251
|
+
type DevToolsDockEntriesGrouped = [category: string, entries: DevToolsDockEntry[]][];
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/types/rpc-augments.d.ts
|
|
254
|
+
/**
|
|
255
|
+
* To be extended
|
|
256
|
+
*/
|
|
257
|
+
interface DevToolsRpcClientFunctions {}
|
|
258
|
+
/**
|
|
259
|
+
* To be extended
|
|
260
|
+
*/
|
|
261
|
+
interface DevToolsRpcServerFunctions {}
|
|
262
|
+
/**
|
|
263
|
+
* To be extended
|
|
264
|
+
*/
|
|
265
|
+
interface DevToolsRpcSharedStates {}
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/types/terminals.d.ts
|
|
268
|
+
interface DevToolsTerminalSessionStreamChunkEvent {
|
|
269
|
+
id: string;
|
|
270
|
+
chunks: string[];
|
|
271
|
+
ts: number;
|
|
272
|
+
}
|
|
273
|
+
interface DevToolsTerminalHost {
|
|
274
|
+
readonly sessions: Map<string, DevToolsTerminalSession>;
|
|
275
|
+
readonly events: EventEmitter<{
|
|
276
|
+
'terminal:session:updated': (session: DevToolsTerminalSession) => void;
|
|
277
|
+
'terminal:session:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => void;
|
|
278
|
+
}>;
|
|
279
|
+
register: (session: DevToolsTerminalSession) => DevToolsTerminalSession;
|
|
280
|
+
update: (session: DevToolsTerminalSession) => void;
|
|
281
|
+
startChildProcess: (executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>) => Promise<DevToolsChildProcessTerminalSession>;
|
|
282
|
+
}
|
|
283
|
+
type DevToolsTerminalStatus = 'running' | 'stopped' | 'error';
|
|
284
|
+
interface DevToolsTerminalSessionBase {
|
|
285
|
+
id: string;
|
|
286
|
+
title: string;
|
|
287
|
+
description?: string;
|
|
288
|
+
status: DevToolsTerminalStatus;
|
|
289
|
+
icon?: DevToolsDockEntryIcon;
|
|
290
|
+
}
|
|
291
|
+
interface DevToolsTerminalSession extends DevToolsTerminalSessionBase {
|
|
292
|
+
buffer?: string[];
|
|
293
|
+
stream?: ReadableStream<string>;
|
|
294
|
+
}
|
|
295
|
+
interface DevToolsChildProcessExecuteOptions {
|
|
296
|
+
command: string;
|
|
297
|
+
args: string[];
|
|
298
|
+
cwd?: string;
|
|
299
|
+
env?: Record<string, string>;
|
|
300
|
+
}
|
|
301
|
+
interface DevToolsChildProcessTerminalSession extends DevToolsTerminalSession {
|
|
302
|
+
type: 'child-process';
|
|
303
|
+
executeOptions: DevToolsChildProcessExecuteOptions;
|
|
304
|
+
getChildProcess: () => ChildProcess | undefined;
|
|
305
|
+
terminate: () => Promise<void>;
|
|
306
|
+
restart: () => Promise<void>;
|
|
307
|
+
}
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/types/views.d.ts
|
|
310
|
+
interface DevToolsViewHost {
|
|
311
|
+
/**
|
|
312
|
+
* @internal
|
|
313
|
+
*/
|
|
314
|
+
buildStaticDirs: {
|
|
315
|
+
baseUrl: string;
|
|
316
|
+
distDir: string;
|
|
317
|
+
}[];
|
|
318
|
+
/**
|
|
319
|
+
* Helper to host static files
|
|
320
|
+
* - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files
|
|
321
|
+
* - In `build` mode, it will copy the static files to the dist directory
|
|
322
|
+
*/
|
|
323
|
+
hostStatic: (baseUrl: string, distDir: string) => void;
|
|
324
|
+
}
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/types/vite-plugin.d.ts
|
|
327
|
+
interface DevToolsCapabilities {
|
|
328
|
+
rpc?: boolean;
|
|
329
|
+
views?: boolean;
|
|
330
|
+
}
|
|
331
|
+
interface DevToolsPluginOptions {
|
|
332
|
+
capabilities?: {
|
|
333
|
+
dev?: DevToolsCapabilities | boolean;
|
|
334
|
+
build?: DevToolsCapabilities | boolean;
|
|
335
|
+
};
|
|
336
|
+
setup: (context: DevToolsNodeContext) => void | Promise<void>;
|
|
337
|
+
}
|
|
338
|
+
interface DevToolsNodeContext {
|
|
339
|
+
/**
|
|
340
|
+
* Workspace root directory of Vite DevTools
|
|
341
|
+
*/
|
|
342
|
+
readonly workspaceRoot: string;
|
|
343
|
+
/**
|
|
344
|
+
* Current working directory of Vite DevTools
|
|
345
|
+
*/
|
|
346
|
+
readonly cwd: string;
|
|
347
|
+
/**
|
|
348
|
+
* Current mode of Vite DevTools
|
|
349
|
+
* - 'dev' - when Vite DevTools is running in dev mode
|
|
350
|
+
* - 'build' - when Vite DevTools is running in build mode (no server)
|
|
351
|
+
*/
|
|
352
|
+
readonly mode: 'dev' | 'build';
|
|
353
|
+
/**
|
|
354
|
+
* Resolved Vite configuration
|
|
355
|
+
*/
|
|
356
|
+
readonly viteConfig: ResolvedConfig;
|
|
357
|
+
/**
|
|
358
|
+
* Vite dev server instance (only available in dev mode)
|
|
359
|
+
*/
|
|
360
|
+
readonly viteServer?: ViteDevServer;
|
|
361
|
+
/**
|
|
362
|
+
* RPC functions host, for registering server-side RPC functions and calling client-side RPC functions
|
|
363
|
+
*/
|
|
364
|
+
rpc: RpcFunctionsHost;
|
|
365
|
+
/**
|
|
366
|
+
* Docks host, for registering dock entries
|
|
367
|
+
*/
|
|
368
|
+
docks: DevToolsDockHost;
|
|
369
|
+
/**
|
|
370
|
+
* Views host, for registering static views
|
|
371
|
+
*/
|
|
372
|
+
views: DevToolsViewHost;
|
|
373
|
+
/**
|
|
374
|
+
* Utils for the node context
|
|
375
|
+
*/
|
|
376
|
+
utils: DevToolsNodeUtils;
|
|
377
|
+
/**
|
|
378
|
+
* Terminals host, for registering terminal sessions and streaming terminal output
|
|
379
|
+
*/
|
|
380
|
+
terminals: DevToolsTerminalHost;
|
|
381
|
+
/**
|
|
382
|
+
* Logs host, for emitting and managing structured log entries
|
|
383
|
+
*/
|
|
384
|
+
logs: DevToolsLogsHost;
|
|
385
|
+
}
|
|
386
|
+
interface DevToolsNodeUtils {
|
|
387
|
+
/**
|
|
388
|
+
* Create a simple client script from a function or stringified code
|
|
389
|
+
*
|
|
390
|
+
* @deprecated DO NOT USE. This is mostly for testing only. Please use a proper importable module instead.
|
|
391
|
+
* @experimental
|
|
392
|
+
*/
|
|
393
|
+
createSimpleClientScript: (fn: string | ((ctx: DockClientScriptContext) => void)) => ClientScriptEntry;
|
|
394
|
+
}
|
|
395
|
+
interface ConnectionMeta {
|
|
396
|
+
backend: 'websocket' | 'static';
|
|
397
|
+
websocket?: number | string;
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/types/rpc.d.ts
|
|
401
|
+
interface DevToolsNodeRpcSession {
|
|
402
|
+
meta: DevToolsNodeRpcSessionMeta;
|
|
403
|
+
rpc: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
|
|
404
|
+
}
|
|
405
|
+
interface RpcBroadcastOptions<METHOD, Args extends any[]> {
|
|
406
|
+
method: METHOD;
|
|
407
|
+
args: Args;
|
|
408
|
+
optional?: boolean;
|
|
409
|
+
event?: boolean;
|
|
410
|
+
filter?: (client: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>) => boolean | void;
|
|
411
|
+
}
|
|
412
|
+
type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> & {
|
|
413
|
+
/**
|
|
414
|
+
* Invoke a locally registered server RPC function directly.
|
|
415
|
+
*
|
|
416
|
+
* This bypasses transport and is useful for server-side cross-function calls.
|
|
417
|
+
*/
|
|
418
|
+
invokeLocal: <T extends keyof DevToolsRpcServerFunctions, Args extends Parameters<DevToolsRpcServerFunctions[T]>>(method: T, ...args: Args) => Promise<Awaited<ReturnType<DevToolsRpcServerFunctions[T]>>>;
|
|
419
|
+
/**
|
|
420
|
+
* Broadcast a message to all connected clients
|
|
421
|
+
*/
|
|
422
|
+
broadcast: <T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(options: RpcBroadcastOptions<T, Args>) => Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Get the current RPC client
|
|
425
|
+
*
|
|
426
|
+
* Available in RPC functions to get the current RPC client
|
|
427
|
+
*/
|
|
428
|
+
getCurrentRpcSession: () => DevToolsNodeRpcSession | undefined;
|
|
429
|
+
/**
|
|
430
|
+
* The shared state host
|
|
431
|
+
*/
|
|
432
|
+
sharedState: RpcSharedStateHost;
|
|
433
|
+
};
|
|
434
|
+
interface RpcSharedStateGetOptions<T> {
|
|
435
|
+
sharedState?: SharedState<T>;
|
|
436
|
+
initialValue?: T;
|
|
437
|
+
}
|
|
438
|
+
interface RpcSharedStateHost {
|
|
439
|
+
get: <T extends keyof DevToolsRpcSharedStates>(key: T, options?: RpcSharedStateGetOptions<DevToolsRpcSharedStates[T]>) => Promise<SharedState<DevToolsRpcSharedStates[T]>>;
|
|
440
|
+
keys: () => string[];
|
|
441
|
+
}
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/types/settings.d.ts
|
|
444
|
+
interface DevToolsDocksUserSettings {
|
|
445
|
+
docksHidden: string[];
|
|
446
|
+
docksCategoriesHidden: string[];
|
|
447
|
+
docksPinned: string[];
|
|
448
|
+
docksCustomOrder: Record<string, number>;
|
|
449
|
+
showIframeAddressBar: boolean;
|
|
450
|
+
closeOnOutsideClick: boolean;
|
|
451
|
+
}
|
|
452
|
+
//#endregion
|
|
453
|
+
//#region src/types/utils.d.ts
|
|
454
|
+
type Thenable<T> = T | Promise<T>;
|
|
455
|
+
type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as K[0]]: K[1] };
|
|
456
|
+
type PartialWithoutId<T extends {
|
|
457
|
+
id: string;
|
|
458
|
+
}> = Partial<Omit<T, 'id'>> & {
|
|
459
|
+
id: string;
|
|
460
|
+
};
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/types/vite-augment.d.ts
|
|
463
|
+
declare module 'vite' {
|
|
464
|
+
interface Plugin {
|
|
465
|
+
devtools?: DevToolsPluginOptions;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
interface PluginWithDevTools extends Plugin {
|
|
469
|
+
devtools?: DevToolsPluginOptions;
|
|
470
|
+
}
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/client/rpc.d.ts
|
|
473
|
+
interface DevToolsRpcClientOptions {
|
|
474
|
+
connectionMeta?: ConnectionMeta;
|
|
475
|
+
baseURL?: string | string[];
|
|
476
|
+
/**
|
|
477
|
+
* The auth id to use for the client
|
|
478
|
+
*/
|
|
479
|
+
authId?: string;
|
|
480
|
+
wsOptions?: Partial<WebSocketRpcClientOptions>;
|
|
481
|
+
rpcOptions?: Partial<BirpcOptions<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions, boolean>>;
|
|
482
|
+
}
|
|
483
|
+
type DevToolsRpcClientCall = BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$call'];
|
|
484
|
+
type DevToolsRpcClientCallEvent = BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$callEvent'];
|
|
485
|
+
type DevToolsRpcClientCallOptional = BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$callOptional'];
|
|
486
|
+
interface DevToolsRpcClient {
|
|
487
|
+
/**
|
|
488
|
+
* The events of the client
|
|
489
|
+
*/
|
|
490
|
+
events: EventEmitter<RpcClientEvents>;
|
|
491
|
+
/**
|
|
492
|
+
* Whether the client is trusted
|
|
493
|
+
*/
|
|
494
|
+
readonly isTrusted: boolean | null;
|
|
495
|
+
/**
|
|
496
|
+
* The connection meta
|
|
497
|
+
*/
|
|
498
|
+
readonly connectionMeta: ConnectionMeta;
|
|
499
|
+
/**
|
|
500
|
+
* Return a promise that resolves when the client is trusted
|
|
501
|
+
*
|
|
502
|
+
* Rejects with an error if the timeout is reached
|
|
503
|
+
*
|
|
504
|
+
* @param timeout - The timeout in milliseconds, default to 60 seconds
|
|
505
|
+
*/
|
|
506
|
+
ensureTrusted: (timeout?: number) => Promise<boolean>;
|
|
507
|
+
/**
|
|
508
|
+
* Request trust from the server
|
|
509
|
+
*/
|
|
510
|
+
requestTrust: () => Promise<boolean>;
|
|
511
|
+
/**
|
|
512
|
+
* Call a RPC function on the server
|
|
513
|
+
*/
|
|
514
|
+
call: DevToolsRpcClientCall;
|
|
515
|
+
/**
|
|
516
|
+
* Call a RPC event on the server, and does not expect a response
|
|
517
|
+
*/
|
|
518
|
+
callEvent: DevToolsRpcClientCallEvent;
|
|
519
|
+
/**
|
|
520
|
+
* Call a RPC optional function on the server
|
|
521
|
+
*/
|
|
522
|
+
callOptional: DevToolsRpcClientCallOptional;
|
|
523
|
+
/**
|
|
524
|
+
* The client RPC host
|
|
525
|
+
*/
|
|
526
|
+
client: DevToolsClientRpcHost;
|
|
527
|
+
/**
|
|
528
|
+
* The shared state host
|
|
529
|
+
*/
|
|
530
|
+
sharedState: RpcSharedStateHost;
|
|
531
|
+
}
|
|
532
|
+
interface DevToolsRpcClientMode {
|
|
533
|
+
readonly isTrusted: boolean;
|
|
534
|
+
ensureTrusted: DevToolsRpcClient['ensureTrusted'];
|
|
535
|
+
requestTrust: DevToolsRpcClient['requestTrust'];
|
|
536
|
+
call: DevToolsRpcClient['call'];
|
|
537
|
+
callEvent: DevToolsRpcClient['callEvent'];
|
|
538
|
+
callOptional: DevToolsRpcClient['callOptional'];
|
|
539
|
+
}
|
|
540
|
+
declare function getDevToolsRpcClient(options?: DevToolsRpcClientOptions): Promise<DevToolsRpcClient>;
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region src/client/docks.d.ts
|
|
543
|
+
interface DockPanelStorage {
|
|
544
|
+
width: number;
|
|
545
|
+
height: number;
|
|
546
|
+
top: number;
|
|
547
|
+
left: number;
|
|
548
|
+
position: 'left' | 'right' | 'bottom' | 'top';
|
|
549
|
+
open: boolean;
|
|
550
|
+
inactiveTimeout: number;
|
|
551
|
+
}
|
|
552
|
+
type DockClientType = 'embedded' | 'standalone';
|
|
553
|
+
interface DevToolsClientContext {
|
|
554
|
+
/**
|
|
555
|
+
* The RPC client to interact with the server
|
|
556
|
+
*/
|
|
557
|
+
readonly rpc: DevToolsRpcClient;
|
|
558
|
+
}
|
|
559
|
+
interface DocksContext extends DevToolsClientContext {
|
|
560
|
+
/**
|
|
561
|
+
* Type of the client environment
|
|
562
|
+
*
|
|
563
|
+
* 'embedded' - running inside an embedded floating panel
|
|
564
|
+
* 'standalone' - running inside a standalone window (no user app)
|
|
565
|
+
*/
|
|
566
|
+
readonly clientType: 'embedded' | 'standalone';
|
|
567
|
+
/**
|
|
568
|
+
* The panel context
|
|
569
|
+
*/
|
|
570
|
+
readonly panel: DocksPanelContext;
|
|
571
|
+
/**
|
|
572
|
+
* The docks entries context
|
|
573
|
+
*/
|
|
574
|
+
readonly docks: DocksEntriesContext;
|
|
575
|
+
}
|
|
576
|
+
type DevToolsClientRpcHost = RpcFunctionsCollector<DevToolsRpcClientFunctions, DevToolsClientContext>;
|
|
577
|
+
interface DocksPanelContext {
|
|
578
|
+
store: DockPanelStorage;
|
|
579
|
+
isDragging: boolean;
|
|
580
|
+
isResizing: boolean;
|
|
581
|
+
readonly isVertical: boolean;
|
|
582
|
+
}
|
|
583
|
+
interface DocksEntriesContext {
|
|
584
|
+
selectedId: string | null;
|
|
585
|
+
readonly selected: DevToolsDockEntry | null;
|
|
586
|
+
entries: DevToolsDockEntry[];
|
|
587
|
+
entryToStateMap: Map<string, DockEntryState>;
|
|
588
|
+
groupedEntries: DevToolsDockEntriesGrouped;
|
|
589
|
+
settings: SharedState<DevToolsDocksUserSettings>;
|
|
590
|
+
/**
|
|
591
|
+
* Get the state of a dock entry by its ID
|
|
592
|
+
*/
|
|
593
|
+
getStateById: (id: string) => DockEntryState | undefined;
|
|
594
|
+
/**
|
|
595
|
+
* Switch to the selected dock entry, pass `null` to clear the selection
|
|
596
|
+
*
|
|
597
|
+
* @returns Whether the selection was changed successfully
|
|
598
|
+
*/
|
|
599
|
+
switchEntry: (id?: string | null) => Promise<boolean>;
|
|
600
|
+
/**
|
|
601
|
+
* Toggle the selected dock entry
|
|
602
|
+
*
|
|
603
|
+
* @returns Whether the selection was changed successfully
|
|
604
|
+
*/
|
|
605
|
+
toggleEntry: (id: string) => Promise<boolean>;
|
|
606
|
+
}
|
|
607
|
+
interface DockEntryState {
|
|
608
|
+
entryMeta: DevToolsDockEntry;
|
|
609
|
+
readonly isActive: boolean;
|
|
610
|
+
domElements: {
|
|
611
|
+
iframe?: HTMLIFrameElement | null;
|
|
612
|
+
panel?: HTMLDivElement | null;
|
|
613
|
+
};
|
|
614
|
+
events: EventEmitter<DockEntryStateEvents>;
|
|
615
|
+
}
|
|
616
|
+
interface DockEntryStateEvents {
|
|
617
|
+
'entry:activated': () => void;
|
|
618
|
+
'entry:deactivated': () => void;
|
|
619
|
+
'entry:updated': (newMeta: DevToolsDockUserEntry) => void;
|
|
620
|
+
'dom:panel:mounted': (panel: HTMLDivElement) => void;
|
|
621
|
+
'dom:iframe:mounted': (iframe: HTMLIFrameElement) => void;
|
|
622
|
+
}
|
|
623
|
+
interface RpcClientEvents {
|
|
624
|
+
'rpc:is-trusted:updated': (isTrusted: boolean) => void;
|
|
625
|
+
}
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region src/client/client-script.d.ts
|
|
628
|
+
/**
|
|
629
|
+
* Context for client scripts running in dock entries
|
|
630
|
+
*/
|
|
631
|
+
interface DockClientScriptContext extends DocksContext {
|
|
632
|
+
/**
|
|
633
|
+
* The state of the current dock entry
|
|
634
|
+
*/
|
|
635
|
+
current: DockEntryState;
|
|
636
|
+
/**
|
|
637
|
+
* Logs client scoped to this dock entry's source
|
|
638
|
+
*/
|
|
639
|
+
logs: DevToolsLogsClient;
|
|
640
|
+
}
|
|
641
|
+
//#endregion
|
|
642
|
+
export { DevToolsDockEntryIcon as $, RpcSharedStateGetOptions as A, DevToolsTerminalHost as B, PartialWithoutId as C, DevToolsNodeRpcSessionMeta as D, DevToolsNodeRpcSession as E, DevToolsNodeUtils as F, DevToolsRpcClientFunctions as G, DevToolsTerminalSessionBase as H, DevToolsPluginOptions as I, ClientScriptEntry as J, DevToolsRpcServerFunctions as K, DevToolsViewHost as L, ConnectionMeta as M, DevToolsCapabilities as N, RpcBroadcastOptions as O, DevToolsNodeContext as P, DevToolsDockEntryCategory as Q, DevToolsChildProcessExecuteOptions as R, EntriesToObject as S, DevToolsDocksUserSettings as T, DevToolsTerminalSessionStreamChunkEvent as U, DevToolsTerminalSession as V, DevToolsTerminalStatus as W, DevToolsDockEntry as X, DevToolsDockEntriesGrouped as Y, DevToolsDockEntryBase as Z, DevToolsRpcClientOptions as _, DockEntryState as a, DevToolsViewIframe as at, RpcDefinitionsToFunctions as b, DocksContext as c, DevToolsLogElementPosition as ct, RpcClientEvents as d, DevToolsLogEntryInput as dt, DevToolsDockHost as et, DevToolsRpcClient as f, DevToolsLogFilePosition as ft, DevToolsRpcClientMode as g, DevToolsLogsHost as gt, DevToolsRpcClientCallOptional as h, DevToolsLogsClient as ht, DockClientType as i, DevToolsViewCustomRender as it, RpcSharedStateHost as j, RpcFunctionsHost as k, DocksEntriesContext as l, DevToolsLogEntry as lt, DevToolsRpcClientCallEvent as m, DevToolsLogLevel as mt, DevToolsClientContext as n, DevToolsViewAction as nt, DockEntryStateEvents as o, DevToolsViewLauncher as ot, DevToolsRpcClientCall as p, DevToolsLogHandle as pt, DevToolsRpcSharedStates as q, DevToolsClientRpcHost as r, DevToolsViewBuiltin as rt, DockPanelStorage as s, DevToolsViewLauncherStatus as st, DockClientScriptContext as t, DevToolsDockUserEntry as tt, DocksPanelContext as u, DevToolsLogEntryFrom as ut, getDevToolsRpcClient as v, Thenable as w, PluginWithDevTools as x, RpcDefinitionsFilter as y, DevToolsChildProcessTerminalSession as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as EventUnsubscribe, r as EventsMap, t as EventEmitter } from "./events-B41U-zeg.js";
|
|
2
|
+
import { $ as DevToolsDockEntryIcon, A as RpcSharedStateGetOptions, B as DevToolsTerminalHost, C as PartialWithoutId, D as DevToolsNodeRpcSessionMeta, E as DevToolsNodeRpcSession, F as DevToolsNodeUtils, G as DevToolsRpcClientFunctions, H as DevToolsTerminalSessionBase, I as DevToolsPluginOptions, J as ClientScriptEntry, K as DevToolsRpcServerFunctions, L as DevToolsViewHost, M as ConnectionMeta, N as DevToolsCapabilities, O as RpcBroadcastOptions, P as DevToolsNodeContext, Q as DevToolsDockEntryCategory, R as DevToolsChildProcessExecuteOptions, S as EntriesToObject, T as DevToolsDocksUserSettings, U as DevToolsTerminalSessionStreamChunkEvent, V as DevToolsTerminalSession, W as DevToolsTerminalStatus, X as DevToolsDockEntry, Y as DevToolsDockEntriesGrouped, Z as DevToolsDockEntryBase, at as DevToolsViewIframe, b as RpcDefinitionsToFunctions, ct as DevToolsLogElementPosition, dt as DevToolsLogEntryInput, et as DevToolsDockHost, ft as DevToolsLogFilePosition, gt as DevToolsLogsHost, ht as DevToolsLogsClient, it as DevToolsViewCustomRender, j as RpcSharedStateHost, k as RpcFunctionsHost, lt as DevToolsLogEntry, mt as DevToolsLogLevel, nt as DevToolsViewAction, ot as DevToolsViewLauncher, pt as DevToolsLogHandle, q as DevToolsRpcSharedStates, rt as DevToolsViewBuiltin, st as DevToolsViewLauncherStatus, tt as DevToolsDockUserEntry, ut as DevToolsLogEntryFrom, w as Thenable, x as PluginWithDevTools, y as RpcDefinitionsFilter, z as DevToolsChildProcessTerminalSession } from "./index-Bl6l5FTi.js";
|
|
3
|
+
import * as _vitejs_devtools_rpc0 from "@vitejs/devtools-rpc";
|
|
2
4
|
|
|
3
|
-
//#region src/utils/
|
|
4
|
-
declare
|
|
5
|
-
declare function getRpcHandler<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN>, context: DevToolsNodeContext): Promise<(...args: ARGS) => RETURN>;
|
|
5
|
+
//#region src/utils/define.d.ts
|
|
6
|
+
declare const defineRpcFunction: <NAME extends string, TYPE extends _vitejs_devtools_rpc0.RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends _vitejs_devtools_rpc0.RpcArgsSchema | undefined = undefined, const RS extends _vitejs_devtools_rpc0.RpcReturnSchema | undefined = undefined>(definition: _vitejs_devtools_rpc0.RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevToolsNodeContext>) => _vitejs_devtools_rpc0.RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevToolsNodeContext>;
|
|
6
7
|
//#endregion
|
|
7
|
-
export {
|
|
8
|
+
export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsChildProcessExecuteOptions, DevToolsChildProcessTerminalSession, DevToolsDockEntriesGrouped, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsDockUserEntry, DevToolsDocksUserSettings, DevToolsLogElementPosition, DevToolsLogEntry, DevToolsLogEntryFrom, DevToolsLogEntryInput, DevToolsLogFilePosition, DevToolsLogHandle, DevToolsLogLevel, DevToolsLogsClient, DevToolsLogsHost, DevToolsNodeContext, DevToolsNodeRpcSession, DevToolsNodeRpcSessionMeta, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsRpcSharedStates, DevToolsTerminalHost, DevToolsTerminalSession, DevToolsTerminalSessionBase, DevToolsTerminalSessionStreamChunkEvent, DevToolsTerminalStatus, DevToolsViewAction, DevToolsViewBuiltin, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, DevToolsViewLauncher, DevToolsViewLauncherStatus, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, PartialWithoutId, PluginWithDevTools, RpcBroadcastOptions, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, Thenable, defineRpcFunction };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
async function getRpcHandler(definition, context) {
|
|
6
|
-
if (definition.handler) return definition.handler;
|
|
7
|
-
if (definition.__resolved?.handler) return definition.__resolved.handler;
|
|
8
|
-
definition.__promise ??= Promise.resolve(definition.setup(context)).then((r) => {
|
|
9
|
-
definition.__resolved = r;
|
|
10
|
-
definition.__promise = void 0;
|
|
11
|
-
return r;
|
|
12
|
-
});
|
|
13
|
-
return (definition.__resolved ??= await definition.__promise).handler;
|
|
14
|
-
}
|
|
15
|
-
|
|
1
|
+
import { createDefineWrapperWithContext } from "@vitejs/devtools-rpc";
|
|
2
|
+
//#region src/utils/define.ts
|
|
3
|
+
const defineRpcFunction = createDefineWrapperWithContext();
|
|
16
4
|
//#endregion
|
|
17
|
-
export { defineRpcFunction
|
|
5
|
+
export { defineRpcFunction };
|