@vitejs/devtools-kit 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,71 @@
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>(event: K, ...args: Parameters<Events[K]>) => void;
20
+ /**
21
+ * Calls the listeners for a given event once and then removes the listener.
22
+ *
23
+ * @param event The event name.
24
+ * @param args The arguments for listeners.
25
+ */
26
+ emitOnce: <K extends keyof Events>(event: K, ...args: Parameters<Events[K]>) => void;
27
+ /**
28
+ * Event names in keys and arrays with listeners in values.
29
+ *
30
+ * @internal
31
+ */
32
+ _listeners: Partial<{ [E in keyof Events]: Events[E][] }>;
33
+ /**
34
+ * Add a listener for a given event.
35
+ *
36
+ * ```js
37
+ * const unbind = ee.on('tick', (tickType, tickDuration) => {
38
+ * count += 1
39
+ * })
40
+ *
41
+ * disable () {
42
+ * unbind()
43
+ * }
44
+ * ```
45
+ *
46
+ * @param event The event name.
47
+ * @param cb The listener function.
48
+ * @returns Unbind listener from event.
49
+ */
50
+ on: <K extends keyof Events>(event: K, cb: Events[K]) => EventUnsubscribe;
51
+ /**
52
+ * Add a listener for a given event once.
53
+ *
54
+ * ```js
55
+ * const unbind = ee.once('tick', (tickType, tickDuration) => {
56
+ * count += 1
57
+ * })
58
+ *
59
+ * disable () {
60
+ * unbind()
61
+ * }
62
+ * ```
63
+ *
64
+ * @param event The event name.
65
+ * @param cb The listener function.
66
+ * @returns Unbind listener from event.
67
+ */
68
+ once: <K extends keyof Events>(event: K, cb: Events[K]) => EventUnsubscribe;
69
+ }
70
+ //#endregion
71
+ export { EventUnsubscribe as n, EventsMap as r, EventEmitter as t };
@@ -0,0 +1,41 @@
1
+ //#region src/utils/events.ts
2
+ /**
3
+ * Create event emitter.
4
+ */
5
+ function createEventEmitter() {
6
+ const _listeners = {};
7
+ function emit(event, ...args) {
8
+ const callbacks = _listeners[event] || [];
9
+ for (let i = 0, length = callbacks.length; i < length; i++) {
10
+ const callback = callbacks[i];
11
+ if (callback) callback(...args);
12
+ }
13
+ }
14
+ function emitOnce(event, ...args) {
15
+ emit(event, ...args);
16
+ delete _listeners[event];
17
+ }
18
+ function on(event, cb) {
19
+ (_listeners[event] ||= []).push(cb);
20
+ return () => {
21
+ _listeners[event] = _listeners[event]?.filter((i) => cb !== i);
22
+ };
23
+ }
24
+ function once(event, cb) {
25
+ const unsubscribe = on(event, ((...args) => {
26
+ unsubscribe();
27
+ return cb(...args);
28
+ }));
29
+ return unsubscribe;
30
+ }
31
+ return {
32
+ _listeners,
33
+ emit,
34
+ emitOnce,
35
+ on,
36
+ once
37
+ };
38
+ }
39
+
40
+ //#endregion
41
+ export { createEventEmitter as t };
@@ -0,0 +1,456 @@
1
+ import { t as EventEmitter } from "./events-BrHMyEqJ.mjs";
2
+ import { RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsCollector, RpcFunctionsCollectorBase } from "birpc-x";
3
+ import { Raw } from "vue";
4
+ import { BirpcOptions, BirpcReturn } from "birpc";
5
+ import { WebSocket } from "ws";
6
+ import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
7
+ import { ChildProcess } from "node:child_process";
8
+
9
+ //#region src/types/docks.d.ts
10
+ interface DevToolsDockHost {
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[];
20
+ }
21
+ type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default';
22
+ type DevToolsDockEntryIcon = string | {
23
+ light: string;
24
+ dark: string;
25
+ };
26
+ interface DevToolsDockEntryBase {
27
+ id: string;
28
+ title: string;
29
+ icon: DevToolsDockEntryIcon;
30
+ /**
31
+ * The default order of the entry in the dock.
32
+ * The higher the number the earlier it appears.
33
+ * @default 0
34
+ */
35
+ defaultOrder?: number;
36
+ /**
37
+ * The category of the entry
38
+ * @default 'default'
39
+ */
40
+ category?: DevToolsDockEntryCategory;
41
+ /**
42
+ * Whether the entry should be hidden from the user.
43
+ * @default false
44
+ */
45
+ isHidden?: boolean;
46
+ }
47
+ interface ClientScriptEntry {
48
+ /**
49
+ * The filepath or module name to import from
50
+ */
51
+ importFrom: string;
52
+ /**
53
+ * The name to import the module as
54
+ *
55
+ * @default 'default'
56
+ */
57
+ importName?: string;
58
+ }
59
+ interface DevToolsViewIframe extends DevToolsDockEntryBase {
60
+ type: 'iframe';
61
+ url: string;
62
+ /**
63
+ * The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared.
64
+ *
65
+ * When not provided, it would be treated as a unique frame.
66
+ */
67
+ frameId?: string;
68
+ /**
69
+ * Optional client script to import into the iframe
70
+ */
71
+ clientScript?: ClientScriptEntry;
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
+ }
87
+ interface DevToolsViewAction extends DevToolsDockEntryBase {
88
+ type: 'action';
89
+ action: ClientScriptEntry;
90
+ }
91
+ interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
92
+ type: 'custom-render';
93
+ renderer: ClientScriptEntry;
94
+ }
95
+ interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
96
+ type: '~builtin';
97
+ id: '~terminals' | '~logs' | '~client-auth-notice';
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
+ }
170
+ //#endregion
171
+ //#region src/types/vite-plugin.d.ts
172
+ interface DevToolsCapabilities {
173
+ rpc?: boolean;
174
+ views?: boolean;
175
+ }
176
+ interface DevToolsPluginOptions {
177
+ capabilities?: {
178
+ dev?: DevToolsCapabilities | boolean;
179
+ build?: DevToolsCapabilities | boolean;
180
+ };
181
+ setup: (context: DevToolsNodeContext) => void | Promise<void>;
182
+ }
183
+ interface DevToolsNodeContext {
184
+ /**
185
+ * Workspace root directory of Vite DevTools
186
+ */
187
+ readonly workspaceRoot: string;
188
+ /**
189
+ * Current working directory of Vite DevTools
190
+ */
191
+ readonly cwd: string;
192
+ /**
193
+ * Current mode of Vite DevTools
194
+ * - 'dev' - when Vite DevTools is running in dev mode
195
+ * - 'build' - when Vite DevTools is running in build mode (no server)
196
+ */
197
+ readonly mode: 'dev' | 'build';
198
+ /**
199
+ * Resolved Vite configuration
200
+ */
201
+ readonly viteConfig: ResolvedConfig;
202
+ /**
203
+ * Vite dev server instance (only available in dev mode)
204
+ */
205
+ readonly viteServer?: ViteDevServer;
206
+ /**
207
+ * RPC functions host, for registering server-side RPC functions and calling client-side RPC functions
208
+ */
209
+ rpc: RpcFunctionsHost;
210
+ /**
211
+ * Docks host, for registering dock entries
212
+ */
213
+ docks: DevToolsDockHost;
214
+ /**
215
+ * Views host, for registering static views
216
+ */
217
+ views: DevToolsViewHost;
218
+ /**
219
+ * Utils for the node context
220
+ */
221
+ utils: DevToolsNodeUtils;
222
+ /**
223
+ * Terminals host, for registering terminal sessions and streaming terminal output
224
+ */
225
+ terminals: DevToolsTerminalHost;
226
+ }
227
+ interface DevToolsNodeUtils {
228
+ /**
229
+ * Create a simple client script from a function or stringified code
230
+ *
231
+ * @deprecated DO NOT USE. This is mostly for testing only. Please use a proper importable module instead.
232
+ * @experimental
233
+ */
234
+ createSimpleClientScript: (fn: string | ((ctx: DockClientScriptContext) => void)) => ClientScriptEntry;
235
+ }
236
+ interface ConnectionMeta {
237
+ backend: 'websocket' | 'static';
238
+ websocket?: number | string;
239
+ }
240
+ //#endregion
241
+ //#region src/types/rpc.d.ts
242
+ interface DevToolsNodeRpcSessionMeta {
243
+ id: number;
244
+ ws?: WebSocket;
245
+ clientAuthId?: string;
246
+ isTrusted?: boolean;
247
+ }
248
+ interface DevToolsNodeRpcSession {
249
+ meta: DevToolsNodeRpcSessionMeta;
250
+ rpc: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
251
+ }
252
+ type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> & {
253
+ /**
254
+ * Broadcast a message to all connected clients
255
+ */
256
+ broadcast: <T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(name: T, ...args: Args) => Promise<(Awaited<ReturnType<DevToolsRpcClientFunctions[T]>> | undefined)[]>;
257
+ /**
258
+ * Get the current RPC client
259
+ *
260
+ * Available in RPC functions to get the current RPC client
261
+ */
262
+ getCurrentRpcSession: () => DevToolsNodeRpcSession | undefined;
263
+ };
264
+ //#endregion
265
+ //#region src/types/utils.d.ts
266
+ type Thenable<T> = T | Promise<T>;
267
+ type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as K[0]]: K[1] };
268
+ type PartialWithoutId<T extends {
269
+ id: string;
270
+ }> = Partial<Omit<T, 'id'>> & {
271
+ id: string;
272
+ };
273
+ //#endregion
274
+ //#region src/types/vite-augment.d.ts
275
+ declare module 'vite' {
276
+ interface Plugin {
277
+ devtools?: DevToolsPluginOptions;
278
+ }
279
+ interface UserConfig {
280
+ devtools?: ViteConfigDevtoolsOptions;
281
+ }
282
+ }
283
+ interface ViteConfigDevtoolsOptions {
284
+ /**
285
+ * Disable client authentication.
286
+ *
287
+ * Beware that if you disable client authentication,
288
+ * any browsers can connect to the devtools and access to your server and filesystem.
289
+ * (including other devices, if you open server `host` option to LAN or WAN)
290
+ *
291
+ * @default true
292
+ */
293
+ clientAuth?: boolean;
294
+ }
295
+ interface PluginWithDevTools extends Plugin {
296
+ devtools?: DevToolsPluginOptions;
297
+ }
298
+ //#endregion
299
+ //#region ../rpc/src/presets/ws/client.d.ts
300
+ interface WebSocketRpcClientOptions {
301
+ url: string;
302
+ onConnected?: (e: Event) => void;
303
+ onError?: (e: Error) => void;
304
+ onDisconnected?: (e: CloseEvent) => void;
305
+ }
306
+ //#endregion
307
+ //#region src/client/rpc.d.ts
308
+ interface DevToolsRpcClientOptions {
309
+ connectionMeta?: ConnectionMeta;
310
+ baseURL?: string[];
311
+ /**
312
+ * The auth id to use for the client
313
+ */
314
+ authId?: string;
315
+ wsOptions?: Partial<WebSocketRpcClientOptions>;
316
+ rpcOptions?: Partial<BirpcOptions<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions, boolean>>;
317
+ }
318
+ interface DevToolsRpcClient {
319
+ /**
320
+ * The events of the client
321
+ */
322
+ events: EventEmitter<RpcClientEvents>;
323
+ /**
324
+ * Whether the client is trusted
325
+ */
326
+ readonly isTrusted: boolean | null;
327
+ /**
328
+ * The connection meta
329
+ */
330
+ readonly connectionMeta: ConnectionMeta;
331
+ /**
332
+ * Return a promise that resolves when the client is trusted
333
+ *
334
+ * Rejects with an error if the timeout is reached
335
+ *
336
+ * @param timeout - The timeout in milliseconds, default to 60 seconds
337
+ */
338
+ ensureTrusted: (timeout?: number) => Promise<boolean>;
339
+ /**
340
+ * Request trust from the server
341
+ */
342
+ requestTrust: () => Promise<boolean>;
343
+ /**
344
+ * Call a RPC function on the server
345
+ */
346
+ call: BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$call'];
347
+ /**
348
+ * Call a RPC event on the server, and does not expect a response
349
+ */
350
+ callEvent: BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$callEvent'];
351
+ /**
352
+ * Call a RPC optional function on the server
353
+ */
354
+ callOptional: BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>['$callOptional'];
355
+ /**
356
+ * The client RPC host
357
+ */
358
+ client: DevToolsClientRpcHost;
359
+ }
360
+ declare function getDevToolsRpcClient(options?: DevToolsRpcClientOptions): Promise<DevToolsRpcClient>;
361
+ //#endregion
362
+ //#region src/client/docks.d.ts
363
+ interface DockPanelStorage {
364
+ width: number;
365
+ height: number;
366
+ top: number;
367
+ left: number;
368
+ position: 'left' | 'right' | 'bottom' | 'top';
369
+ open: boolean;
370
+ inactiveTimeout: number;
371
+ }
372
+ type DockClientType = 'embedded' | 'standalone';
373
+ interface DevToolsClientContext {
374
+ /**
375
+ * The RPC client to interact with the server
376
+ */
377
+ readonly rpc: DevToolsRpcClient;
378
+ }
379
+ interface DocksContext extends DevToolsClientContext {
380
+ /**
381
+ * Type of the client environment
382
+ *
383
+ * 'embedded' - running inside an embedded floating panel
384
+ * 'standalone' - running inside a standalone window (no user app)
385
+ */
386
+ readonly clientType: 'embedded' | 'standalone';
387
+ /**
388
+ * The panel context
389
+ */
390
+ readonly panel: DocksPanelContext;
391
+ /**
392
+ * The docks entries context
393
+ */
394
+ readonly docks: DocksEntriesContext;
395
+ }
396
+ type DevToolsClientRpcHost = RpcFunctionsCollector<DevToolsRpcClientFunctions, DevToolsClientContext>;
397
+ interface DocksPanelContext {
398
+ store: DockPanelStorage;
399
+ isDragging: boolean;
400
+ isResizing: boolean;
401
+ readonly isVertical: boolean;
402
+ }
403
+ interface DocksEntriesContext {
404
+ selectedId: string | null;
405
+ readonly selected: DevToolsDockEntry | null;
406
+ entries: DevToolsDockEntry[];
407
+ entryToStateMap: Map<string, DockEntryState>;
408
+ /**
409
+ * Get the state of a dock entry by its ID
410
+ */
411
+ getStateById: (id: string) => DockEntryState | undefined;
412
+ /**
413
+ * Switch to the selected dock entry, pass `null` to clear the selection
414
+ *
415
+ * @returns Whether the selection was changed successfully
416
+ */
417
+ switchEntry: (id?: string | null) => Promise<boolean>;
418
+ /**
419
+ * Toggle the selected dock entry
420
+ *
421
+ * @returns Whether the selection was changed successfully
422
+ */
423
+ toggleEntry: (id: string) => Promise<boolean>;
424
+ }
425
+ interface DockEntryState {
426
+ entryMeta: DevToolsDockEntry;
427
+ readonly isActive: boolean;
428
+ domElements: {
429
+ iframe?: HTMLIFrameElement | null;
430
+ panel?: HTMLDivElement | null;
431
+ };
432
+ events: Raw<EventEmitter<DockEntryStateEvents>>;
433
+ }
434
+ interface DockEntryStateEvents {
435
+ 'entry:activated': () => void;
436
+ 'entry:deactivated': () => void;
437
+ 'entry:updated': (newMeta: DevToolsDockUserEntry) => void;
438
+ 'dom:panel:mounted': (panel: HTMLDivElement) => void;
439
+ 'dom:iframe:mounted': (iframe: HTMLIFrameElement) => void;
440
+ }
441
+ interface RpcClientEvents {
442
+ 'rpc:is-trusted:updated': (isTrusted: boolean) => void;
443
+ }
444
+ //#endregion
445
+ //#region src/client/client-script.d.ts
446
+ /**
447
+ * Context for client scripts running in dock entries
448
+ */
449
+ interface DockClientScriptContext extends DocksContext {
450
+ /**
451
+ * The state of the current dock entry
452
+ */
453
+ current: DockEntryState;
454
+ }
455
+ //#endregion
456
+ export { DevToolsViewHost as A, ClientScriptEntry as B, DevToolsNodeRpcSessionMeta as C, DevToolsNodeContext as D, DevToolsCapabilities as E, DevToolsTerminalSessionBase as F, DevToolsDockHost as G, DevToolsDockEntryBase as H, DevToolsTerminalSessionStreamChunkEvent as I, DevToolsViewBuiltin as J, DevToolsDockUserEntry as K, DevToolsTerminalStatus as L, DevToolsChildProcessTerminalSession as M, DevToolsTerminalHost as N, DevToolsNodeUtils as O, DevToolsTerminalSession as P, DevToolsViewLauncherStatus as Q, DevToolsRpcClientFunctions as R, DevToolsNodeRpcSession as S, ConnectionMeta as T, DevToolsDockEntryCategory as U, DevToolsDockEntry as V, DevToolsDockEntryIcon as W, DevToolsViewIframe as X, DevToolsViewCustomRender as Y, DevToolsViewLauncher as Z, PluginWithDevTools as _, DockEntryState as a, PartialWithoutId as b, DocksContext as c, RpcClientEvents as d, DevToolsRpcClient as f, RpcDefinitionsToFunctions as g, RpcDefinitionsFilter as h, DockClientType as i, DevToolsChildProcessExecuteOptions as j, DevToolsPluginOptions as k, DocksEntriesContext as l, getDevToolsRpcClient as m, DevToolsClientContext as n, DockEntryStateEvents as o, DevToolsRpcClientOptions as p, DevToolsViewAction as q, DevToolsClientRpcHost as r, DockPanelStorage as s, DockClientScriptContext as t, DocksPanelContext as u, ViteConfigDevtoolsOptions as v, RpcFunctionsHost as w, Thenable as x, EntriesToObject as y, DevToolsRpcServerFunctions as z };
@@ -0,0 +1,8 @@
1
+ import { n as EventUnsubscribe, r as EventsMap, t as EventEmitter } from "./events-BrHMyEqJ.mjs";
2
+ import { A as DevToolsViewHost, B as ClientScriptEntry, C as DevToolsNodeRpcSessionMeta, D as DevToolsNodeContext, E as DevToolsCapabilities, F as DevToolsTerminalSessionBase, G as DevToolsDockHost, H as DevToolsDockEntryBase, I as DevToolsTerminalSessionStreamChunkEvent, J as DevToolsViewBuiltin, K as DevToolsDockUserEntry, L as DevToolsTerminalStatus, M as DevToolsChildProcessTerminalSession, N as DevToolsTerminalHost, O as DevToolsNodeUtils, P as DevToolsTerminalSession, Q as DevToolsViewLauncherStatus, R as DevToolsRpcClientFunctions, S as DevToolsNodeRpcSession, T as ConnectionMeta, U as DevToolsDockEntryCategory, V as DevToolsDockEntry, W as DevToolsDockEntryIcon, X as DevToolsViewIframe, Y as DevToolsViewCustomRender, Z as DevToolsViewLauncher, _ as PluginWithDevTools, b as PartialWithoutId, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, j as DevToolsChildProcessExecuteOptions, k as DevToolsPluginOptions, q as DevToolsViewAction, v as ViteConfigDevtoolsOptions, w as RpcFunctionsHost, x as Thenable, y as EntriesToObject, z as DevToolsRpcServerFunctions } from "./index-FzXSK6np.mjs";
3
+ import * as birpc_x0 from "birpc-x";
4
+
5
+ //#region src/utils/define.d.ts
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>;
7
+ //#endregion
8
+ export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsChildProcessExecuteOptions, DevToolsChildProcessTerminalSession, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsDockUserEntry, DevToolsNodeContext, DevToolsNodeRpcSession, DevToolsNodeRpcSessionMeta, 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, ViteConfigDevtoolsOptions, defineRpcFunction };
package/dist/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ import { createDefineWrapperWithContext } from "birpc-x";
2
+
3
+ //#region src/utils/define.ts
4
+ const defineRpcFunction = createDefineWrapperWithContext();
5
+
6
+ //#endregion
7
+ export { defineRpcFunction };
@@ -0,0 +1,11 @@
1
+ //#region src/utils/nanoid.ts
2
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
3
+ function nanoid(size = 21) {
4
+ let id = "";
5
+ let i = size;
6
+ while (i--) id += urlAlphabet[Math.random() * 64 | 0];
7
+ return id;
8
+ }
9
+
10
+ //#endregion
11
+ export { nanoid as t };
@@ -0,0 +1,10 @@
1
+ import { r as EventsMap, t as EventEmitter } from "../events-BrHMyEqJ.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,3 @@
1
+ import { t as createEventEmitter } from "../events-CWYZG96x.mjs";
2
+
3
+ export { createEventEmitter };
@@ -0,0 +1,4 @@
1
+ //#region src/utils/nanoid.d.ts
2
+ declare function nanoid(size?: number): string;
3
+ //#endregion
4
+ export { nanoid };
@@ -0,0 +1,3 @@
1
+ import { t as nanoid } from "../nanoid-B0pJU5uW.mjs";
2
+
3
+ export { nanoid };
@@ -0,0 +1,50 @@
1
+ import { t as EventEmitter } from "../events-BrHMyEqJ.mjs";
2
+ import { Objectish, Patch } from "immer";
3
+
4
+ //#region src/utils/shared-state.d.ts
5
+ type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
6
+ type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
7
+ type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
8
+ type ImmutableMap<K$1, V$1> = ReadonlyMap<Immutable<K$1>, Immutable<V$1>>;
9
+ type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
10
+ type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
11
+ /**
12
+ * State host that is immutable by default with explicit mutate.
13
+ */
14
+ interface SharedState<T> {
15
+ /**
16
+ * Get the current state. Immutable.
17
+ */
18
+ get: () => Immutable<T>;
19
+ /**
20
+ * Subscribe to state changes.
21
+ */
22
+ on: EventEmitter<SharedStateEvents<T>>['on'];
23
+ /**
24
+ * Mutate the state.
25
+ */
26
+ mutate: (fn: (state: T) => void) => void;
27
+ /**
28
+ * Apply patches to the state.
29
+ */
30
+ patch: (patches: Patch[]) => void;
31
+ }
32
+ interface SharedStateEvents<T> {
33
+ updated: (state: T) => void;
34
+ patches: (patches: Patch[]) => void;
35
+ }
36
+ interface SharedStateOptions<T> {
37
+ /**
38
+ * Initial state.
39
+ */
40
+ initialState: T;
41
+ /**
42
+ * Enable patches.
43
+ *
44
+ * @default false
45
+ */
46
+ enablePatches?: boolean;
47
+ }
48
+ declare function createSharedState<T extends Objectish>(options: SharedStateOptions<T>): SharedState<T>;
49
+ //#endregion
50
+ export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, createSharedState };