@vitejs/devtools 0.0.0-alpha.2 → 0.0.0-alpha.21

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,493 @@
1
+ import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
2
+ import { RpcDefinitionsToFunctions, RpcFunctionsCollector, RpcFunctionsCollectorBase } from "birpc-x";
3
+ import { Raw } from "vue";
4
+ import { BirpcReturn } from "birpc";
5
+ import { WebSocket } from "ws";
6
+ import { ChildProcess } from "node:child_process";
7
+
8
+ //#region ../kit/src/types/events.d.ts
9
+ interface EventsMap {
10
+ [event: string]: any;
11
+ }
12
+ interface EventUnsubscribe {
13
+ (): void;
14
+ }
15
+ interface EventEmitter<Events extends EventsMap> {
16
+ /**
17
+ * Calls each of the listeners registered for a given event.
18
+ *
19
+ * ```js
20
+ * ee.emit('tick', tickType, tickDuration)
21
+ * ```
22
+ *
23
+ * @param event The event name.
24
+ * @param args The arguments for listeners.
25
+ */
26
+ emit: <K extends keyof Events>(event: K, ...args: Parameters<Events[K]>) => void;
27
+ /**
28
+ * Calls the listeners for a given event once and then removes the listener.
29
+ *
30
+ * @param event The event name.
31
+ * @param args The arguments for listeners.
32
+ */
33
+ emitOnce: <K extends keyof Events>(event: K, ...args: Parameters<Events[K]>) => void;
34
+ /**
35
+ * Event names in keys and arrays with listeners in values.
36
+ *
37
+ * @internal
38
+ */
39
+ _listeners: Partial<{ [E in keyof Events]: Events[E][] }>;
40
+ /**
41
+ * Add a listener for a given event.
42
+ *
43
+ * ```js
44
+ * const unbind = ee.on('tick', (tickType, tickDuration) => {
45
+ * count += 1
46
+ * })
47
+ *
48
+ * disable () {
49
+ * unbind()
50
+ * }
51
+ * ```
52
+ *
53
+ * @param event The event name.
54
+ * @param cb The listener function.
55
+ * @returns Unbind listener from event.
56
+ */
57
+ on: <K extends keyof Events>(event: K, cb: Events[K]) => EventUnsubscribe;
58
+ /**
59
+ * Add a listener for a given event once.
60
+ *
61
+ * ```js
62
+ * const unbind = ee.once('tick', (tickType, tickDuration) => {
63
+ * count += 1
64
+ * })
65
+ *
66
+ * disable () {
67
+ * unbind()
68
+ * }
69
+ * ```
70
+ *
71
+ * @param event The event name.
72
+ * @param cb The listener function.
73
+ * @returns Unbind listener from event.
74
+ */
75
+ once: <K extends keyof Events>(event: K, cb: Events[K]) => EventUnsubscribe;
76
+ }
77
+ //#endregion
78
+ //#region ../kit/src/types/docks.d.ts
79
+ interface DevToolsDockHost {
80
+ readonly views: Map<string, DevToolsDockUserEntry>;
81
+ readonly events: EventEmitter<{
82
+ 'dock:entry:updated': (entry: DevToolsDockUserEntry) => void;
83
+ }>;
84
+ register: <T extends DevToolsDockUserEntry>(entry: T, force?: boolean) => {
85
+ update: (patch: Partial<T>) => void;
86
+ };
87
+ update: (entry: DevToolsDockUserEntry) => void;
88
+ values: () => DevToolsDockUserEntry[];
89
+ }
90
+ type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default';
91
+ type DevToolsDockEntryIcon = string | {
92
+ light: string;
93
+ dark: string;
94
+ };
95
+ interface DevToolsDockEntryBase {
96
+ id: string;
97
+ title: string;
98
+ icon: DevToolsDockEntryIcon;
99
+ /**
100
+ * The default order of the entry in the dock.
101
+ * The higher the number the earlier it appears.
102
+ * @default 0
103
+ */
104
+ defaultOrder?: number;
105
+ /**
106
+ * The category of the entry
107
+ * @default 'default'
108
+ */
109
+ category?: DevToolsDockEntryCategory;
110
+ /**
111
+ * Whether the entry should be hidden from the user.
112
+ * @default false
113
+ */
114
+ isHidden?: boolean;
115
+ }
116
+ interface ClientScriptEntry {
117
+ /**
118
+ * The filepath or module name to import from
119
+ */
120
+ importFrom: string;
121
+ /**
122
+ * The name to import the module as
123
+ *
124
+ * @default 'default'
125
+ */
126
+ importName?: string;
127
+ }
128
+ interface DevToolsViewIframe extends DevToolsDockEntryBase {
129
+ type: 'iframe';
130
+ url: string;
131
+ /**
132
+ * The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared.
133
+ *
134
+ * When not provided, it would be treated as a unique frame.
135
+ */
136
+ frameId?: string;
137
+ /**
138
+ * Optional client script to import into the iframe
139
+ */
140
+ clientScript?: ClientScriptEntry;
141
+ }
142
+ type DevToolsViewLauncherStatus = 'idle' | 'loading' | 'success' | 'error';
143
+ interface DevToolsViewLauncher extends DevToolsDockEntryBase {
144
+ type: 'launcher';
145
+ launcher: {
146
+ icon?: DevToolsDockEntryIcon;
147
+ title: string;
148
+ status?: DevToolsViewLauncherStatus;
149
+ error?: string;
150
+ description?: string;
151
+ buttonStart?: string;
152
+ buttonLoading?: string;
153
+ onLaunch: () => Promise<void>;
154
+ };
155
+ }
156
+ interface DevToolsViewAction extends DevToolsDockEntryBase {
157
+ type: 'action';
158
+ action: ClientScriptEntry;
159
+ }
160
+ interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
161
+ type: 'custom-render';
162
+ renderer: ClientScriptEntry;
163
+ }
164
+ interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
165
+ type: '~builtin';
166
+ id: '~terminals' | '~logs' | '~client-auth-notice';
167
+ }
168
+ type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
169
+ type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
170
+ //#endregion
171
+ //#region ../kit/src/types/rpc-augments.d.ts
172
+ /**
173
+ * To be extended
174
+ */
175
+ interface DevToolsRpcClientFunctions {}
176
+ /**
177
+ * To be extended
178
+ */
179
+ interface DevToolsRpcServerFunctions {}
180
+ //#endregion
181
+ //#region ../kit/src/types/terminals.d.ts
182
+ interface DevToolsTerminalSessionStreamChunkEvent {
183
+ id: string;
184
+ chunks: string[];
185
+ ts: number;
186
+ }
187
+ interface DevToolsTerminalHost {
188
+ readonly sessions: Map<string, DevToolsTerminalSession>;
189
+ readonly events: EventEmitter<{
190
+ 'terminal:session:updated': (session: DevToolsTerminalSession) => void;
191
+ 'terminal:session:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => void;
192
+ }>;
193
+ register: (session: DevToolsTerminalSession) => DevToolsTerminalSession;
194
+ update: (session: DevToolsTerminalSession) => void;
195
+ startChildProcess: (executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>) => Promise<DevToolsChildProcessTerminalSession>;
196
+ }
197
+ type DevToolsTerminalStatus = 'running' | 'stopped' | 'error';
198
+ interface DevToolsTerminalSessionBase {
199
+ id: string;
200
+ title: string;
201
+ description?: string;
202
+ status: DevToolsTerminalStatus;
203
+ icon?: DevToolsDockEntryIcon;
204
+ }
205
+ interface DevToolsTerminalSession extends DevToolsTerminalSessionBase {
206
+ buffer?: string[];
207
+ stream?: ReadableStream<string>;
208
+ }
209
+ interface DevToolsChildProcessExecuteOptions {
210
+ command: string;
211
+ args: string[];
212
+ cwd?: string;
213
+ env?: Record<string, string>;
214
+ }
215
+ interface DevToolsChildProcessTerminalSession extends DevToolsTerminalSession {
216
+ type: 'child-process';
217
+ executeOptions: DevToolsChildProcessExecuteOptions;
218
+ getChildProcess: () => ChildProcess | undefined;
219
+ terminate: () => Promise<void>;
220
+ restart: () => Promise<void>;
221
+ }
222
+ //#endregion
223
+ //#region ../kit/src/types/views.d.ts
224
+ interface DevToolsViewHost {
225
+ /**
226
+ * @internal
227
+ */
228
+ buildStaticDirs: {
229
+ baseUrl: string;
230
+ distDir: string;
231
+ }[];
232
+ /**
233
+ * Helper to host static files
234
+ * - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files
235
+ * - In `build` mode, it will copy the static files to the dist directory
236
+ */
237
+ hostStatic: (baseUrl: string, distDir: string) => void;
238
+ }
239
+ //#endregion
240
+ //#region ../kit/src/types/vite-plugin.d.ts
241
+ interface DevToolsCapabilities {
242
+ rpc?: boolean;
243
+ views?: boolean;
244
+ }
245
+ interface DevToolsPluginOptions {
246
+ capabilities?: {
247
+ dev?: DevToolsCapabilities | boolean;
248
+ build?: DevToolsCapabilities | boolean;
249
+ };
250
+ setup: (context: DevToolsNodeContext) => void | Promise<void>;
251
+ }
252
+ interface DevToolsNodeContext {
253
+ /**
254
+ * Workspace root directory of Vite DevTools
255
+ */
256
+ readonly workspaceRoot: string;
257
+ /**
258
+ * Current working directory of Vite DevTools
259
+ */
260
+ readonly cwd: string;
261
+ /**
262
+ * Current mode of Vite DevTools
263
+ * - 'dev' - when Vite DevTools is running in dev mode
264
+ * - 'build' - when Vite DevTools is running in build mode (no server)
265
+ */
266
+ readonly mode: 'dev' | 'build';
267
+ /**
268
+ * Resolved Vite configuration
269
+ */
270
+ readonly viteConfig: ResolvedConfig;
271
+ /**
272
+ * Vite dev server instance (only available in dev mode)
273
+ */
274
+ readonly viteServer?: ViteDevServer;
275
+ /**
276
+ * RPC functions host, for registering server-side RPC functions and calling client-side RPC functions
277
+ */
278
+ rpc: RpcFunctionsHost;
279
+ /**
280
+ * Docks host, for registering dock entries
281
+ */
282
+ docks: DevToolsDockHost;
283
+ /**
284
+ * Views host, for registering static views
285
+ */
286
+ views: DevToolsViewHost;
287
+ /**
288
+ * Utils for the node context
289
+ */
290
+ utils: DevToolsNodeUtils;
291
+ /**
292
+ * Terminals host, for registering terminal sessions and streaming terminal output
293
+ */
294
+ terminals: DevToolsTerminalHost;
295
+ }
296
+ interface DevToolsNodeUtils {
297
+ /**
298
+ * Create a simple client script from a function or stringified code
299
+ *
300
+ * @deprecated DO NOT USE. This is mostly for testing only. Please use a proper importable module instead.
301
+ * @experimental
302
+ */
303
+ createSimpleClientScript: (fn: string | ((ctx: DockClientScriptContext) => void)) => ClientScriptEntry;
304
+ }
305
+ interface ConnectionMeta {
306
+ backend: 'websocket' | 'static';
307
+ websocket?: number | string;
308
+ }
309
+ //#endregion
310
+ //#region ../kit/src/types/rpc.d.ts
311
+ interface DevToolsNodeRpcSessionMeta {
312
+ id: number;
313
+ ws?: WebSocket;
314
+ clientAuthId?: string;
315
+ isTrusted?: boolean;
316
+ }
317
+ interface DevToolsNodeRpcSession {
318
+ meta: DevToolsNodeRpcSessionMeta;
319
+ rpc: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
320
+ }
321
+ type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> & {
322
+ /**
323
+ * Broadcast a message to all connected clients
324
+ */
325
+ broadcast: <T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(name: T, ...args: Args) => Promise<(Awaited<ReturnType<DevToolsRpcClientFunctions[T]>> | undefined)[]>;
326
+ /**
327
+ * Get the current RPC client
328
+ *
329
+ * Available in RPC functions to get the current RPC client
330
+ */
331
+ getCurrentRpcSession: () => DevToolsNodeRpcSession | undefined;
332
+ };
333
+ //#endregion
334
+ //#region ../kit/src/types/vite-augment.d.ts
335
+ declare module 'vite' {
336
+ interface Plugin {
337
+ devtools?: DevToolsPluginOptions;
338
+ }
339
+ interface UserConfig {
340
+ devtools?: ViteConfigDevtoolsOptions;
341
+ }
342
+ }
343
+ interface ViteConfigDevtoolsOptions {
344
+ /**
345
+ * Disable client authentication.
346
+ *
347
+ * Beware that if you disable client authentication,
348
+ * any browsers can connect to the devtools and access to your server and filesystem.
349
+ * (including other devices, if you open server `host` option to LAN or WAN)
350
+ *
351
+ * @default true
352
+ */
353
+ clientAuth?: boolean;
354
+ }
355
+ //#endregion
356
+ //#region ../kit/src/client/rpc.d.ts
357
+ interface DevToolsRpcClient {
358
+ /**
359
+ * The events of the client
360
+ */
361
+ events: EventEmitter<RpcClientEvents>;
362
+ /**
363
+ * Whether the client is trusted
364
+ */
365
+ readonly isTrusted: boolean | null;
366
+ /**
367
+ * The connection meta
368
+ */
369
+ readonly connectionMeta: ConnectionMeta;
370
+ /**
371
+ * Return a promise that resolves when the client is trusted
372
+ *
373
+ * Rejects with an error if the timeout is reached
374
+ *
375
+ * @param timeout - The timeout in milliseconds, default to 60 seconds
376
+ */
377
+ ensureTrusted: (timeout?: number) => Promise<boolean>;
378
+ /**
379
+ * Request trust from the server
380
+ */
381
+ requestTrust: () => Promise<boolean>;
382
+ /**
383
+ * Call a RPC function on the server
384
+ */
385
+ call: BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$call'];
386
+ /**
387
+ * Call a RPC event on the server, and does not expect a response
388
+ */
389
+ callEvent: BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$callEvent'];
390
+ /**
391
+ * Call a RPC optional function on the server
392
+ */
393
+ callOptional: BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$callOptional'];
394
+ /**
395
+ * The client RPC host
396
+ */
397
+ client: DevToolsClientRpcHost;
398
+ }
399
+ //#endregion
400
+ //#region ../kit/src/client/docks.d.ts
401
+ interface DockPanelStorage {
402
+ width: number;
403
+ height: number;
404
+ top: number;
405
+ left: number;
406
+ position: 'left' | 'right' | 'bottom' | 'top';
407
+ open: boolean;
408
+ inactiveTimeout: number;
409
+ }
410
+ interface DevToolsClientContext {
411
+ /**
412
+ * The RPC client to interact with the server
413
+ */
414
+ readonly rpc: DevToolsRpcClient;
415
+ }
416
+ interface DocksContext extends DevToolsClientContext {
417
+ /**
418
+ * Type of the client environment
419
+ *
420
+ * 'embedded' - running inside an embedded floating panel
421
+ * 'standalone' - running inside a standalone window (no user app)
422
+ */
423
+ readonly clientType: 'embedded' | 'standalone';
424
+ /**
425
+ * The panel context
426
+ */
427
+ readonly panel: DocksPanelContext;
428
+ /**
429
+ * The docks entries context
430
+ */
431
+ readonly docks: DocksEntriesContext;
432
+ }
433
+ type DevToolsClientRpcHost = RpcFunctionsCollector<DevToolsRpcClientFunctions, DevToolsClientContext>;
434
+ interface DocksPanelContext {
435
+ store: DockPanelStorage;
436
+ isDragging: boolean;
437
+ isResizing: boolean;
438
+ readonly isVertical: boolean;
439
+ }
440
+ interface DocksEntriesContext {
441
+ selectedId: string | null;
442
+ readonly selected: DevToolsDockEntry | null;
443
+ entries: DevToolsDockEntry[];
444
+ entryToStateMap: Map<string, DockEntryState>;
445
+ /**
446
+ * Get the state of a dock entry by its ID
447
+ */
448
+ getStateById: (id: string) => DockEntryState | undefined;
449
+ /**
450
+ * Switch to the selected dock entry, pass `null` to clear the selection
451
+ *
452
+ * @returns Whether the selection was changed successfully
453
+ */
454
+ switchEntry: (id?: string | null) => Promise<boolean>;
455
+ /**
456
+ * Toggle the selected dock entry
457
+ *
458
+ * @returns Whether the selection was changed successfully
459
+ */
460
+ toggleEntry: (id: string) => Promise<boolean>;
461
+ }
462
+ interface DockEntryState {
463
+ entryMeta: DevToolsDockEntry;
464
+ readonly isActive: boolean;
465
+ domElements: {
466
+ iframe?: HTMLIFrameElement | null;
467
+ panel?: HTMLDivElement | null;
468
+ };
469
+ events: Raw<EventEmitter<DockEntryStateEvents>>;
470
+ }
471
+ interface DockEntryStateEvents {
472
+ 'entry:activated': () => void;
473
+ 'entry:deactivated': () => void;
474
+ 'entry:updated': (newMeta: DevToolsDockUserEntry) => void;
475
+ 'dom:panel:mounted': (panel: HTMLDivElement) => void;
476
+ 'dom:iframe:mounted': (iframe: HTMLIFrameElement) => void;
477
+ }
478
+ interface RpcClientEvents {
479
+ 'rpc:is-trusted:updated': (isTrusted: boolean) => void;
480
+ }
481
+ //#endregion
482
+ //#region ../kit/src/client/client-script.d.ts
483
+ /**
484
+ * Context for client scripts running in dock entries
485
+ */
486
+ interface DockClientScriptContext extends DocksContext {
487
+ /**
488
+ * The state of the current dock entry
489
+ */
490
+ current: DockEntryState;
491
+ }
492
+ //#endregion
493
+ export { RpcDefinitionsToFunctions as a, DevToolsTerminalSessionBase as c, DevToolsRpcServerFunctions as d, DevToolsDockEntry as f, DevToolsRpcClient as i, DevToolsTerminalSessionStreamChunkEvent as l, DockPanelStorage as n, ConnectionMeta as o, DocksContext as r, DevToolsNodeContext as s, DockEntryState as t, DevToolsRpcClientFunctions as u };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,43 @@
1
- import { DevToolsNodeContext } from "@vitejs/devtools-kit";
2
- import "@vitejs/devtools-vite";
1
+ import { a as RpcDefinitionsToFunctions, c as DevToolsTerminalSessionBase, d as DevToolsRpcServerFunctions, f as DevToolsDockEntry, l as DevToolsTerminalSessionStreamChunkEvent, o as ConnectionMeta, s as DevToolsNodeContext, u as DevToolsRpcClientFunctions } from "./index-CWvzFILY.js";
3
2
  import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
4
- import * as h30 from "h3";
3
+ import * as birpc_x0 from "birpc-x";
4
+ import { RpcFunctionsCollectorBase } from "birpc-x";
5
+ import { AsyncLocalStorage } from "node:async_hooks";
5
6
  import * as birpc0 from "birpc";
7
+ import * as h30 from "h3";
6
8
 
7
9
  //#region src/node/context.d.ts
8
10
  declare function createDevToolsContext(viteConfig: ResolvedConfig, viteServer?: ViteDevServer): Promise<DevToolsNodeContext>;
9
11
  //#endregion
12
+ //#region src/node/rpc/anonymous/auth.d.ts
13
+ interface DevToolsAuthInput {
14
+ authId: string;
15
+ ua: string;
16
+ origin: string;
17
+ }
18
+ interface DevToolsAuthReturn {
19
+ isTrusted: boolean;
20
+ }
21
+ //#endregion
22
+ //#region src/node/rpc/index.d.ts
23
+ declare const builtinRpcDecalrations: readonly [birpc_x0.RpcFunctionDefinition<"vite:core:open-in-editor", "action", [path: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:core:open-in-finder", "action", [path: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:anonymous:auth", "action", [query: DevToolsAuthInput], Promise<DevToolsAuthReturn>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:docks:list", "static", [], DevToolsDockEntry[], DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:docks:on-launch", "action", [entryId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server:list", "static", [], Promise<{
24
+ [k: string]: {
25
+ type: any;
26
+ };
27
+ }>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:list", "static", [], Promise<DevToolsTerminalSessionBase[]>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:read", "query", [id: string], Promise<{
28
+ buffer: string[];
29
+ ts: number;
30
+ }>, DevToolsNodeContext>];
31
+ type BuiltinServerFunctions = RpcDefinitionsToFunctions<typeof builtinRpcDecalrations>;
32
+ declare module '@vitejs/devtools-kit' {
33
+ interface DevToolsRpcServerFunctions extends BuiltinServerFunctions {}
34
+ interface DevToolsRpcClientFunctions {
35
+ 'vite:internal:docks:updated': () => Promise<void>;
36
+ 'vite:internal:terminals:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => Promise<void>;
37
+ 'vite:internal:terminals:updated': () => Promise<void>;
38
+ }
39
+ }
40
+ //#endregion
10
41
  //#region src/node/plugins/index.d.ts
11
42
  interface DevToolsOptions {
12
43
  /**
@@ -16,12 +47,13 @@ interface DevToolsOptions {
16
47
  */
17
48
  builtinDevTools?: boolean;
18
49
  }
19
- declare function DevTools(options?: DevToolsOptions): Plugin[];
50
+ declare function DevTools(options?: DevToolsOptions): Promise<Plugin[]>;
20
51
  //#endregion
21
52
  //#region src/node/ws.d.ts
22
53
  interface CreateWsServerOptions {
23
54
  cwd: string;
24
55
  portWebSocket?: number;
56
+ hostWebSocket: string;
25
57
  base?: string;
26
58
  context: DevToolsNodeContext;
27
59
  }
@@ -29,8 +61,9 @@ interface CreateWsServerOptions {
29
61
  //#region src/node/server.d.ts
30
62
  declare function createDevToolsMiddleware(options: CreateWsServerOptions): Promise<{
31
63
  h3: h30.App;
64
+ rpc: birpc0.BirpcGroup<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
32
65
  middleware: h30.NodeListener;
33
- rpc: birpc0.BirpcGroup<any, any>;
66
+ getConnectionMeta: () => Promise<ConnectionMeta>;
34
67
  }>;
35
68
  //#endregion
36
69
  export { DevTools, createDevToolsContext, createDevToolsMiddleware };
package/dist/index.js CHANGED
@@ -1,57 +1,3 @@
1
- import { createDevToolsContext, createDevToolsMiddleware } from "./server-B_q0HJ88.js";
2
- import { dirDist } from "./dirs-B7dOX6eI.js";
3
- import { DevToolsViteUI } from "@vitejs/devtools-vite";
4
- import { join } from "node:path";
5
- import process from "node:process";
6
- import { normalizePath } from "vite";
1
+ import { n as createDevToolsMiddleware, t as DevTools, u as createDevToolsContext } from "./plugins-Chcj6ENu.js";
7
2
 
8
- //#region src/node/plugins/injection.ts
9
- function DevToolsInjection() {
10
- return {
11
- name: "vite:devtools:injection",
12
- enforce: "post",
13
- transformIndexHtml() {
14
- return [{
15
- tag: "script",
16
- attrs: {
17
- src: `/@fs/${process.env.VITE_DEVTOOLS_LOCAL_DEV ? normalizePath(join(dirDist, "..", "src/client/inject/index.ts")) : normalizePath(join(dirDist, "client/inject.js"))}`,
18
- type: "module"
19
- },
20
- injectTo: "body"
21
- }];
22
- }
23
- };
24
- }
25
-
26
- //#endregion
27
- //#region src/node/plugins/server.ts
28
- /**
29
- * Core plugin for enabling Vite DevTools
30
- */
31
- function DevToolsServer() {
32
- return {
33
- name: "vite:devtools:server",
34
- enforce: "post",
35
- apply: "serve",
36
- async configureServer(viteDevServer) {
37
- const context = await createDevToolsContext(viteDevServer.config, viteDevServer);
38
- const { middleware } = await createDevToolsMiddleware({
39
- cwd: viteDevServer.config.root,
40
- context
41
- });
42
- viteDevServer.middlewares.use("/__vite_devtools__/", middleware);
43
- }
44
- };
45
- }
46
-
47
- //#endregion
48
- //#region src/node/plugins/index.ts
49
- function DevTools(options = {}) {
50
- const { builtinDevTools = true } = options;
51
- const plugins = [DevToolsInjection(), DevToolsServer()];
52
- if (builtinDevTools) plugins.push(DevToolsViteUI());
53
- return plugins;
54
- }
55
-
56
- //#endregion
57
3
  export { DevTools, createDevToolsContext, createDevToolsMiddleware };