@vitejs/devtools-kit 0.0.0-alpha.9 → 0.1.1

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.
@@ -0,0 +1,679 @@
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
+ interface JsonRenderElement {
250
+ type: string;
251
+ props?: Record<string, unknown>;
252
+ children?: string[];
253
+ /** json-render event bindings (e.g. `{ press: { action: "my:action" } }`) */
254
+ on?: Record<string, unknown>;
255
+ /** json-render visibility condition */
256
+ visible?: unknown;
257
+ /** json-render repeat binding */
258
+ repeat?: unknown;
259
+ /** Allow additional json-render element fields */
260
+ [key: string]: unknown;
261
+ }
262
+ interface JsonRenderSpec {
263
+ root: string;
264
+ elements: Record<string, JsonRenderElement>;
265
+ /** Initial client-side state model for $state/$bindState expressions */
266
+ state?: Record<string, unknown>;
267
+ }
268
+ interface JsonRenderer {
269
+ /** Replace the entire spec */
270
+ updateSpec: (spec: JsonRenderSpec) => void | Promise<void>;
271
+ /** Update json-render state values (shallow merge into spec.state) */
272
+ updateState: (state: Record<string, unknown>) => void | Promise<void>;
273
+ /** Internal: shared state key used by the client to subscribe */
274
+ readonly _stateKey: string;
275
+ }
276
+ interface DevToolsViewJsonRender extends DevToolsDockEntryBase {
277
+ type: 'json-render';
278
+ /** JsonRenderer handle created by ctx.createJsonRenderer() */
279
+ ui: JsonRenderer;
280
+ }
281
+ type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher | DevToolsViewJsonRender;
282
+ type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
283
+ type DevToolsDockEntriesGrouped = [category: string, entries: DevToolsDockEntry[]][];
284
+ //#endregion
285
+ //#region src/types/rpc-augments.d.ts
286
+ /**
287
+ * To be extended
288
+ */
289
+ interface DevToolsRpcClientFunctions {}
290
+ /**
291
+ * To be extended
292
+ */
293
+ interface DevToolsRpcServerFunctions {}
294
+ /**
295
+ * To be extended
296
+ */
297
+ interface DevToolsRpcSharedStates {}
298
+ //#endregion
299
+ //#region src/types/terminals.d.ts
300
+ interface DevToolsTerminalSessionStreamChunkEvent {
301
+ id: string;
302
+ chunks: string[];
303
+ ts: number;
304
+ }
305
+ interface DevToolsTerminalHost {
306
+ readonly sessions: Map<string, DevToolsTerminalSession>;
307
+ readonly events: EventEmitter<{
308
+ 'terminal:session:updated': (session: DevToolsTerminalSession) => void;
309
+ 'terminal:session:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => void;
310
+ }>;
311
+ register: (session: DevToolsTerminalSession) => DevToolsTerminalSession;
312
+ update: (session: DevToolsTerminalSession) => void;
313
+ startChildProcess: (executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>) => Promise<DevToolsChildProcessTerminalSession>;
314
+ }
315
+ type DevToolsTerminalStatus = 'running' | 'stopped' | 'error';
316
+ interface DevToolsTerminalSessionBase {
317
+ id: string;
318
+ title: string;
319
+ description?: string;
320
+ status: DevToolsTerminalStatus;
321
+ icon?: DevToolsDockEntryIcon;
322
+ }
323
+ interface DevToolsTerminalSession extends DevToolsTerminalSessionBase {
324
+ buffer?: string[];
325
+ stream?: ReadableStream<string>;
326
+ }
327
+ interface DevToolsChildProcessExecuteOptions {
328
+ command: string;
329
+ args: string[];
330
+ cwd?: string;
331
+ env?: Record<string, string>;
332
+ }
333
+ interface DevToolsChildProcessTerminalSession extends DevToolsTerminalSession {
334
+ type: 'child-process';
335
+ executeOptions: DevToolsChildProcessExecuteOptions;
336
+ getChildProcess: () => ChildProcess | undefined;
337
+ terminate: () => Promise<void>;
338
+ restart: () => Promise<void>;
339
+ }
340
+ //#endregion
341
+ //#region src/types/views.d.ts
342
+ interface DevToolsViewHost {
343
+ /**
344
+ * @internal
345
+ */
346
+ buildStaticDirs: {
347
+ baseUrl: string;
348
+ distDir: string;
349
+ }[];
350
+ /**
351
+ * Helper to host static files
352
+ * - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files
353
+ * - In `build` mode, it will copy the static files to the dist directory
354
+ */
355
+ hostStatic: (baseUrl: string, distDir: string) => void;
356
+ }
357
+ //#endregion
358
+ //#region src/types/vite-plugin.d.ts
359
+ interface DevToolsCapabilities {
360
+ rpc?: boolean;
361
+ views?: boolean;
362
+ }
363
+ interface DevToolsPluginOptions {
364
+ capabilities?: {
365
+ dev?: DevToolsCapabilities | boolean;
366
+ build?: DevToolsCapabilities | boolean;
367
+ };
368
+ setup: (context: DevToolsNodeContext) => void | Promise<void>;
369
+ }
370
+ interface DevToolsNodeContext {
371
+ /**
372
+ * Workspace root directory of Vite DevTools
373
+ */
374
+ readonly workspaceRoot: string;
375
+ /**
376
+ * Current working directory of Vite DevTools
377
+ */
378
+ readonly cwd: string;
379
+ /**
380
+ * Current mode of Vite DevTools
381
+ * - 'dev' - when Vite DevTools is running in dev mode
382
+ * - 'build' - when Vite DevTools is running in build mode (no server)
383
+ */
384
+ readonly mode: 'dev' | 'build';
385
+ /**
386
+ * Resolved Vite configuration
387
+ */
388
+ readonly viteConfig: ResolvedConfig;
389
+ /**
390
+ * Vite dev server instance (only available in dev mode)
391
+ */
392
+ readonly viteServer?: ViteDevServer;
393
+ /**
394
+ * RPC functions host, for registering server-side RPC functions and calling client-side RPC functions
395
+ */
396
+ rpc: RpcFunctionsHost;
397
+ /**
398
+ * Docks host, for registering dock entries
399
+ */
400
+ docks: DevToolsDockHost;
401
+ /**
402
+ * Views host, for registering static views
403
+ */
404
+ views: DevToolsViewHost;
405
+ /**
406
+ * Utils for the node context
407
+ */
408
+ utils: DevToolsNodeUtils;
409
+ /**
410
+ * Terminals host, for registering terminal sessions and streaming terminal output
411
+ */
412
+ terminals: DevToolsTerminalHost;
413
+ /**
414
+ * Logs host, for emitting and managing structured log entries
415
+ */
416
+ logs: DevToolsLogsHost;
417
+ /**
418
+ * Create a JsonRenderer handle for building json-render powered UIs.
419
+ * Pass the returned handle as `ui` when registering a `json-render` dock entry.
420
+ */
421
+ createJsonRenderer: (spec: JsonRenderSpec) => JsonRenderer;
422
+ }
423
+ interface DevToolsNodeUtils {
424
+ /**
425
+ * Create a simple client script from a function or stringified code
426
+ *
427
+ * @deprecated DO NOT USE. This is mostly for testing only. Please use a proper importable module instead.
428
+ * @experimental
429
+ */
430
+ createSimpleClientScript: (fn: string | ((ctx: DockClientScriptContext) => void)) => ClientScriptEntry;
431
+ }
432
+ interface ConnectionMeta {
433
+ backend: 'websocket' | 'static';
434
+ websocket?: number | string;
435
+ }
436
+ //#endregion
437
+ //#region src/types/rpc.d.ts
438
+ interface DevToolsNodeRpcSession {
439
+ meta: DevToolsNodeRpcSessionMeta;
440
+ rpc: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
441
+ }
442
+ interface RpcBroadcastOptions<METHOD, Args extends any[]> {
443
+ method: METHOD;
444
+ args: Args;
445
+ optional?: boolean;
446
+ event?: boolean;
447
+ filter?: (client: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>) => boolean | void;
448
+ }
449
+ type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> & {
450
+ /**
451
+ * Invoke a locally registered server RPC function directly.
452
+ *
453
+ * This bypasses transport and is useful for server-side cross-function calls.
454
+ */
455
+ invokeLocal: <T extends keyof DevToolsRpcServerFunctions, Args extends Parameters<DevToolsRpcServerFunctions[T]>>(method: T, ...args: Args) => Promise<Awaited<ReturnType<DevToolsRpcServerFunctions[T]>>>;
456
+ /**
457
+ * Broadcast a message to all connected clients
458
+ */
459
+ broadcast: <T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(options: RpcBroadcastOptions<T, Args>) => Promise<void>;
460
+ /**
461
+ * Get the current RPC client
462
+ *
463
+ * Available in RPC functions to get the current RPC client
464
+ */
465
+ getCurrentRpcSession: () => DevToolsNodeRpcSession | undefined;
466
+ /**
467
+ * The shared state host
468
+ */
469
+ sharedState: RpcSharedStateHost;
470
+ };
471
+ interface RpcSharedStateGetOptions<T> {
472
+ sharedState?: SharedState<T>;
473
+ initialValue?: T;
474
+ }
475
+ interface RpcSharedStateHost {
476
+ get: <T extends keyof DevToolsRpcSharedStates>(key: T, options?: RpcSharedStateGetOptions<DevToolsRpcSharedStates[T]>) => Promise<SharedState<DevToolsRpcSharedStates[T]>>;
477
+ keys: () => string[];
478
+ }
479
+ //#endregion
480
+ //#region src/types/settings.d.ts
481
+ interface DevToolsDocksUserSettings {
482
+ docksHidden: string[];
483
+ docksCategoriesHidden: string[];
484
+ docksPinned: string[];
485
+ docksCustomOrder: Record<string, number>;
486
+ showIframeAddressBar: boolean;
487
+ closeOnOutsideClick: boolean;
488
+ }
489
+ //#endregion
490
+ //#region src/types/utils.d.ts
491
+ type Thenable<T> = T | Promise<T>;
492
+ type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as K[0]]: K[1] };
493
+ type PartialWithoutId<T extends {
494
+ id: string;
495
+ }> = Partial<Omit<T, 'id'>> & {
496
+ id: string;
497
+ };
498
+ //#endregion
499
+ //#region src/types/vite-augment.d.ts
500
+ declare module 'vite' {
501
+ interface Plugin {
502
+ devtools?: DevToolsPluginOptions;
503
+ }
504
+ }
505
+ interface PluginWithDevTools extends Plugin {
506
+ devtools?: DevToolsPluginOptions;
507
+ }
508
+ //#endregion
509
+ //#region src/client/rpc.d.ts
510
+ interface DevToolsRpcClientOptions {
511
+ connectionMeta?: ConnectionMeta;
512
+ baseURL?: string | string[];
513
+ /**
514
+ * The auth id to use for the client
515
+ */
516
+ authId?: string;
517
+ wsOptions?: Partial<WebSocketRpcClientOptions>;
518
+ rpcOptions?: Partial<BirpcOptions<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions, boolean>>;
519
+ }
520
+ type DevToolsRpcClientCall = BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$call'];
521
+ type DevToolsRpcClientCallEvent = BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$callEvent'];
522
+ type DevToolsRpcClientCallOptional = BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$callOptional'];
523
+ interface DevToolsRpcClient {
524
+ /**
525
+ * The events of the client
526
+ */
527
+ events: EventEmitter<RpcClientEvents>;
528
+ /**
529
+ * Whether the client is trusted
530
+ */
531
+ readonly isTrusted: boolean | null;
532
+ /**
533
+ * The connection meta
534
+ */
535
+ readonly connectionMeta: ConnectionMeta;
536
+ /**
537
+ * Return a promise that resolves when the client is trusted
538
+ *
539
+ * Rejects with an error if the timeout is reached
540
+ *
541
+ * @param timeout - The timeout in milliseconds, default to 60 seconds
542
+ */
543
+ ensureTrusted: (timeout?: number) => Promise<boolean>;
544
+ /**
545
+ * Request trust from the server
546
+ */
547
+ requestTrust: () => Promise<boolean>;
548
+ /**
549
+ * Call a RPC function on the server
550
+ */
551
+ call: DevToolsRpcClientCall;
552
+ /**
553
+ * Call a RPC event on the server, and does not expect a response
554
+ */
555
+ callEvent: DevToolsRpcClientCallEvent;
556
+ /**
557
+ * Call a RPC optional function on the server
558
+ */
559
+ callOptional: DevToolsRpcClientCallOptional;
560
+ /**
561
+ * The client RPC host
562
+ */
563
+ client: DevToolsClientRpcHost;
564
+ /**
565
+ * The shared state host
566
+ */
567
+ sharedState: RpcSharedStateHost;
568
+ }
569
+ interface DevToolsRpcClientMode {
570
+ readonly isTrusted: boolean;
571
+ ensureTrusted: DevToolsRpcClient['ensureTrusted'];
572
+ requestTrust: DevToolsRpcClient['requestTrust'];
573
+ call: DevToolsRpcClient['call'];
574
+ callEvent: DevToolsRpcClient['callEvent'];
575
+ callOptional: DevToolsRpcClient['callOptional'];
576
+ }
577
+ declare function getDevToolsRpcClient(options?: DevToolsRpcClientOptions): Promise<DevToolsRpcClient>;
578
+ //#endregion
579
+ //#region src/client/docks.d.ts
580
+ interface DockPanelStorage {
581
+ width: number;
582
+ height: number;
583
+ top: number;
584
+ left: number;
585
+ position: 'left' | 'right' | 'bottom' | 'top';
586
+ open: boolean;
587
+ inactiveTimeout: number;
588
+ }
589
+ type DockClientType = 'embedded' | 'standalone';
590
+ interface DevToolsClientContext {
591
+ /**
592
+ * The RPC client to interact with the server
593
+ */
594
+ readonly rpc: DevToolsRpcClient;
595
+ }
596
+ interface DocksContext extends DevToolsClientContext {
597
+ /**
598
+ * Type of the client environment
599
+ *
600
+ * 'embedded' - running inside an embedded floating panel
601
+ * 'standalone' - running inside a standalone window (no user app)
602
+ */
603
+ readonly clientType: 'embedded' | 'standalone';
604
+ /**
605
+ * The panel context
606
+ */
607
+ readonly panel: DocksPanelContext;
608
+ /**
609
+ * The docks entries context
610
+ */
611
+ readonly docks: DocksEntriesContext;
612
+ }
613
+ type DevToolsClientRpcHost = RpcFunctionsCollector<DevToolsRpcClientFunctions, DevToolsClientContext>;
614
+ interface DocksPanelContext {
615
+ store: DockPanelStorage;
616
+ isDragging: boolean;
617
+ isResizing: boolean;
618
+ readonly isVertical: boolean;
619
+ }
620
+ interface DocksEntriesContext {
621
+ selectedId: string | null;
622
+ readonly selected: DevToolsDockEntry | null;
623
+ entries: DevToolsDockEntry[];
624
+ entryToStateMap: Map<string, DockEntryState>;
625
+ groupedEntries: DevToolsDockEntriesGrouped;
626
+ settings: SharedState<DevToolsDocksUserSettings>;
627
+ /**
628
+ * Get the state of a dock entry by its ID
629
+ */
630
+ getStateById: (id: string) => DockEntryState | undefined;
631
+ /**
632
+ * Switch to the selected dock entry, pass `null` to clear the selection
633
+ *
634
+ * @returns Whether the selection was changed successfully
635
+ */
636
+ switchEntry: (id?: string | null) => Promise<boolean>;
637
+ /**
638
+ * Toggle the selected dock entry
639
+ *
640
+ * @returns Whether the selection was changed successfully
641
+ */
642
+ toggleEntry: (id: string) => Promise<boolean>;
643
+ }
644
+ interface DockEntryState {
645
+ entryMeta: DevToolsDockEntry;
646
+ readonly isActive: boolean;
647
+ domElements: {
648
+ iframe?: HTMLIFrameElement | null;
649
+ panel?: HTMLDivElement | null;
650
+ };
651
+ events: EventEmitter<DockEntryStateEvents>;
652
+ }
653
+ interface DockEntryStateEvents {
654
+ 'entry:activated': () => void;
655
+ 'entry:deactivated': () => void;
656
+ 'entry:updated': (newMeta: DevToolsDockUserEntry) => void;
657
+ 'dom:panel:mounted': (panel: HTMLDivElement) => void;
658
+ 'dom:iframe:mounted': (iframe: HTMLIFrameElement) => void;
659
+ }
660
+ interface RpcClientEvents {
661
+ 'rpc:is-trusted:updated': (isTrusted: boolean) => void;
662
+ }
663
+ //#endregion
664
+ //#region src/client/client-script.d.ts
665
+ /**
666
+ * Context for client scripts running in dock entries
667
+ */
668
+ interface DockClientScriptContext extends DocksContext {
669
+ /**
670
+ * The state of the current dock entry
671
+ */
672
+ current: DockEntryState;
673
+ /**
674
+ * Logs client scoped to this dock entry's source
675
+ */
676
+ logs: DevToolsLogsClient;
677
+ }
678
+ //#endregion
679
+ 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 _, DevToolsLogHandle as _t, DockEntryState as a, DevToolsViewIframe as at, RpcDefinitionsToFunctions as b, DevToolsLogsHost as bt, DocksContext as c, DevToolsViewLauncherStatus as ct, RpcClientEvents as d, JsonRenderer as dt, DevToolsDockHost as et, DevToolsRpcClient as f, DevToolsLogElementPosition as ft, DevToolsRpcClientMode as g, DevToolsLogFilePosition as gt, DevToolsRpcClientCallOptional as h, DevToolsLogEntryInput as ht, DockClientType as i, DevToolsViewCustomRender as it, RpcSharedStateHost as j, RpcFunctionsHost as k, DocksEntriesContext as l, JsonRenderElement as lt, DevToolsRpcClientCallEvent as m, DevToolsLogEntryFrom as mt, DevToolsClientContext as n, DevToolsViewAction as nt, DockEntryStateEvents as o, DevToolsViewJsonRender as ot, DevToolsRpcClientCall as p, DevToolsLogEntry as pt, DevToolsRpcSharedStates as q, DevToolsClientRpcHost as r, DevToolsViewBuiltin as rt, DockPanelStorage as s, DevToolsViewLauncher as st, DockClientScriptContext as t, DevToolsDockUserEntry as tt, DocksPanelContext as u, JsonRenderSpec as ut, getDevToolsRpcClient as v, DevToolsLogLevel as vt, Thenable as w, PluginWithDevTools as x, RpcDefinitionsFilter as y, DevToolsLogsClient as yt, DevToolsChildProcessTerminalSession as z };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
- import { C as DevToolsViewWebComponent, D as DevToolsRpcServerFunctions, E as DevToolsRpcClientFunctions, S as DevToolsViewIframe, T as Thenable, _ as DevToolsDockEntryBase, a as RpcDefinitionsToFunctions, b as DevToolsViewCustomRender, c as RpcFunctionType, d as DevToolsCapabilities, f as DevToolsNodeContext, g as DevToolsDockEntry, h as ClientScriptEntry, i as RpcDefinitionsFilter, l as RpcFunctionsHost, m as DevToolsPluginOptions, n as BirpcFn, o as RpcFunctionDefinition, p as DevToolsNodeUtils, r as BirpcReturn, s as RpcFunctionSetupResult, t as PluginWithDevTools, u as ConnectionMeta, v as DevToolsDockHost, w as EntriesToObject, x as DevToolsViewHost, y as DevToolsViewAction } from "./index-BtaHil_c.js";
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, _t as DevToolsLogHandle, at as DevToolsViewIframe, b as RpcDefinitionsToFunctions, bt as DevToolsLogsHost, ct as DevToolsViewLauncherStatus, dt as JsonRenderer, et as DevToolsDockHost, ft as DevToolsLogElementPosition, gt as DevToolsLogFilePosition, ht as DevToolsLogEntryInput, it as DevToolsViewCustomRender, j as RpcSharedStateHost, k as RpcFunctionsHost, lt as JsonRenderElement, mt as DevToolsLogEntryFrom, nt as DevToolsViewAction, ot as DevToolsViewJsonRender, pt as DevToolsLogEntry, q as DevToolsRpcSharedStates, rt as DevToolsViewBuiltin, st as DevToolsViewLauncher, tt as DevToolsDockUserEntry, ut as JsonRenderSpec, vt as DevToolsLogLevel, w as Thenable, x as PluginWithDevTools, y as RpcDefinitionsFilter, yt as DevToolsLogsClient, z as DevToolsChildProcessTerminalSession } from "./index-WxzZW3L-.js";
3
+ import * as _vitejs_devtools_rpc0 from "@vitejs/devtools-rpc";
2
4
 
3
- //#region src/utils/rpc.d.ts
4
- declare function defineRpcFunction<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN>): RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN>;
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 { BirpcFn, BirpcReturn, ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockHost, DevToolsNodeContext, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, DevToolsViewWebComponent, EntriesToObject, PluginWithDevTools, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionDefinition, RpcFunctionSetupResult, RpcFunctionType, RpcFunctionsHost, Thenable, defineRpcFunction, getRpcHandler };
8
+ //#region src/utils/json-render.d.ts
9
+ declare function defineJsonRenderSpec(spec: JsonRenderSpec): JsonRenderSpec;
10
+ //#endregion
11
+ 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, DevToolsViewJsonRender, DevToolsViewLauncher, DevToolsViewLauncherStatus, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, JsonRenderElement, JsonRenderSpec, JsonRenderer, PartialWithoutId, PluginWithDevTools, RpcBroadcastOptions, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, Thenable, defineJsonRenderSpec, defineRpcFunction };