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

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/dirs.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as dirDist, t as dirClientStandalone } from "./dirs-C0s1Ghvy.js";
1
+ import { n as dirDist, t as dirClientStandalone } from "./dirs-BJIz1OY5.js";
2
2
 
3
3
  export { dirClientStandalone, dirDist };
@@ -1,8 +1,10 @@
1
1
  import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
2
2
  import { RpcDefinitionsToFunctions, RpcFunctionsCollector, RpcFunctionsCollectorBase } from "birpc-x";
3
+ import "node:http";
3
4
  import { Raw } from "vue";
4
5
  import { BirpcReturn } from "birpc";
5
6
  import { WebSocket } from "ws";
7
+ import { Patch, Patch as SharedStatePatch } from "immer";
6
8
  import { ChildProcess } from "node:child_process";
7
9
 
8
10
  //#region ../kit/src/types/events.d.ts
@@ -23,14 +25,14 @@ interface EventEmitter<Events extends EventsMap> {
23
25
  * @param event The event name.
24
26
  * @param args The arguments for listeners.
25
27
  */
26
- emit: <K extends keyof Events>(event: K, ...args: Parameters<Events[K]>) => void;
28
+ emit: <K$1 extends keyof Events>(event: K$1, ...args: Parameters<Events[K$1]>) => void;
27
29
  /**
28
30
  * Calls the listeners for a given event once and then removes the listener.
29
31
  *
30
32
  * @param event The event name.
31
33
  * @param args The arguments for listeners.
32
34
  */
33
- emitOnce: <K extends keyof Events>(event: K, ...args: Parameters<Events[K]>) => void;
35
+ emitOnce: <K$1 extends keyof Events>(event: K$1, ...args: Parameters<Events[K$1]>) => void;
34
36
  /**
35
37
  * Event names in keys and arrays with listeners in values.
36
38
  *
@@ -54,7 +56,7 @@ interface EventEmitter<Events extends EventsMap> {
54
56
  * @param cb The listener function.
55
57
  * @returns Unbind listener from event.
56
58
  */
57
- on: <K extends keyof Events>(event: K, cb: Events[K]) => EventUnsubscribe;
59
+ on: <K$1 extends keyof Events>(event: K$1, cb: Events[K$1]) => EventUnsubscribe;
58
60
  /**
59
61
  * Add a listener for a given event once.
60
62
  *
@@ -72,7 +74,7 @@ interface EventEmitter<Events extends EventsMap> {
72
74
  * @param cb The listener function.
73
75
  * @returns Unbind listener from event.
74
76
  */
75
- once: <K extends keyof Events>(event: K, cb: Events[K]) => EventUnsubscribe;
77
+ once: <K$1 extends keyof Events>(event: K$1, cb: Events[K$1]) => EventUnsubscribe;
76
78
  }
77
79
  //#endregion
78
80
  //#region ../kit/src/types/docks.d.ts
@@ -168,6 +170,50 @@ interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
168
170
  type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
169
171
  type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
170
172
  //#endregion
173
+ //#region ../rpc/src/presets/ws/server.d.ts
174
+ interface DevToolsNodeRpcSessionMeta {
175
+ id: number;
176
+ ws?: WebSocket;
177
+ clientAuthId?: string;
178
+ isTrusted?: boolean;
179
+ }
180
+ //#endregion
181
+ //#region ../kit/src/utils/shared-state.d.ts
182
+ type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
183
+ 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>;
184
+ type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
185
+ type ImmutableMap<K$1, V$1> = ReadonlyMap<Immutable<K$1>, Immutable<V$1>>;
186
+ type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
187
+ type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
188
+ /**
189
+ * State host that is immutable by default with explicit mutate.
190
+ */
191
+ interface SharedState<T> {
192
+ /**
193
+ * Get the current state. Immutable.
194
+ */
195
+ value: () => Immutable<T>;
196
+ /**
197
+ * Subscribe to state changes.
198
+ */
199
+ on: EventEmitter<SharedStateEvents<T>>['on'];
200
+ /**
201
+ * Mutate the state.
202
+ */
203
+ mutate: (fn: (state: T) => void, syncId?: string) => void;
204
+ /**
205
+ * Apply patches to the state.
206
+ */
207
+ patch: (patches: Patch[], syncId?: string) => void;
208
+ /**
209
+ * Sync IDs that have been applied to the state.
210
+ */
211
+ syncIds: Set<string>;
212
+ }
213
+ interface SharedStateEvents<T> {
214
+ updated: (fullState: T, patches: Patch[] | undefined, syncId: string) => void;
215
+ }
216
+ //#endregion
171
217
  //#region ../kit/src/types/rpc-augments.d.ts
172
218
  /**
173
219
  * To be extended
@@ -177,6 +223,10 @@ interface DevToolsRpcClientFunctions {}
177
223
  * To be extended
178
224
  */
179
225
  interface DevToolsRpcServerFunctions {}
226
+ /**
227
+ * To be extended
228
+ */
229
+ interface DevToolsRpcSharedStates {}
180
230
  //#endregion
181
231
  //#region ../kit/src/types/terminals.d.ts
182
232
  interface DevToolsTerminalSessionStreamChunkEvent {
@@ -308,28 +358,39 @@ interface ConnectionMeta {
308
358
  }
309
359
  //#endregion
310
360
  //#region ../kit/src/types/rpc.d.ts
311
- interface DevToolsNodeRpcSessionMeta {
312
- id: number;
313
- ws?: WebSocket;
314
- clientAuthId?: string;
315
- isTrusted?: boolean;
316
- }
317
361
  interface DevToolsNodeRpcSession {
318
362
  meta: DevToolsNodeRpcSessionMeta;
319
363
  rpc: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
320
364
  }
365
+ interface RpcBroadcastOptions<METHOD, Args extends any[]> {
366
+ method: METHOD;
367
+ args: Args;
368
+ optional?: boolean;
369
+ event?: boolean;
370
+ filter?: (client: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>) => boolean | void;
371
+ }
321
372
  type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> & {
322
373
  /**
323
374
  * Broadcast a message to all connected clients
324
375
  */
325
- broadcast: <T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(name: T, ...args: Args) => Promise<(Awaited<ReturnType<DevToolsRpcClientFunctions[T]>> | undefined)[]>;
376
+ broadcast: <T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(options: RpcBroadcastOptions<T, Args>) => Promise<void>;
326
377
  /**
327
378
  * Get the current RPC client
328
379
  *
329
380
  * Available in RPC functions to get the current RPC client
330
381
  */
331
382
  getCurrentRpcSession: () => DevToolsNodeRpcSession | undefined;
383
+ /**
384
+ * The shared state host
385
+ */
386
+ sharedState: RpcSharedStateHost;
332
387
  };
388
+ interface RpcSharedStateGetOptions<T> {
389
+ initialValue?: T;
390
+ }
391
+ interface RpcSharedStateHost {
392
+ get: <T extends keyof DevToolsRpcSharedStates>(key: T, options?: RpcSharedStateGetOptions<DevToolsRpcSharedStates[T]>) => Promise<SharedState<DevToolsRpcSharedStates[T]>>;
393
+ }
333
394
  //#endregion
334
395
  //#region ../kit/src/types/vite-augment.d.ts
335
396
  declare module 'vite' {
@@ -395,6 +456,10 @@ interface DevToolsRpcClient {
395
456
  * The client RPC host
396
457
  */
397
458
  client: DevToolsClientRpcHost;
459
+ /**
460
+ * The shared state host
461
+ */
462
+ sharedState: RpcSharedStateHost;
398
463
  }
399
464
  //#endregion
400
465
  //#region ../kit/src/client/docks.d.ts
@@ -490,4 +555,4 @@ interface DockClientScriptContext extends DocksContext {
490
555
  current: DockEntryState;
491
556
  }
492
557
  //#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 };
558
+ export { RpcDefinitionsToFunctions as a, DevToolsTerminalSessionBase as c, DevToolsRpcServerFunctions as d, SharedStatePatch as f, DevToolsRpcClient as i, DevToolsTerminalSessionStreamChunkEvent as l, DockPanelStorage as n, ConnectionMeta as o, DevToolsDockEntry as p, DocksContext as r, DevToolsNodeContext as s, DockEntryState as t, DevToolsRpcClientFunctions as u };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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";
1
+ import { a as RpcDefinitionsToFunctions, c as DevToolsTerminalSessionBase, d as DevToolsRpcServerFunctions, f as SharedStatePatch, l as DevToolsTerminalSessionStreamChunkEvent, o as ConnectionMeta, p as DevToolsDockEntry, s as DevToolsNodeContext, u as DevToolsRpcClientFunctions } from "./index-CLc-E8sF.js";
2
2
  import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
3
3
  import * as birpc_x0 from "birpc-x";
4
4
  import { RpcFunctionsCollectorBase } from "birpc-x";
@@ -24,7 +24,7 @@ declare const builtinRpcDecalrations: readonly [birpc_x0.RpcFunctionDefinition<"
24
24
  [k: string]: {
25
25
  type: any;
26
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<{
27
+ }>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:get", "query", [key: string], Promise<any>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:patch", "query", [key: string, patches: SharedStatePatch[], syncId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:set", "query", [key: string, value: any, syncId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:list", "static", [], Promise<DevToolsTerminalSessionBase[]>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:read", "query", [id: string], Promise<{
28
28
  buffer: string[];
29
29
  ts: number;
30
30
  }>, DevToolsNodeContext>];
@@ -33,6 +33,8 @@ declare module '@vitejs/devtools-kit' {
33
33
  interface DevToolsRpcServerFunctions extends BuiltinServerFunctions {}
34
34
  interface DevToolsRpcClientFunctions {
35
35
  'vite:internal:docks:updated': () => Promise<void>;
36
+ 'vite:internal:rpc:client-state:patch': (key: string, patches: SharedStatePatch[], syncId: string) => Promise<void>;
37
+ 'vite:internal:rpc:client-state:updated': (key: string, syncId: string) => Promise<void>;
36
38
  'vite:internal:terminals:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => Promise<void>;
37
39
  'vite:internal:terminals:updated': () => Promise<void>;
38
40
  }
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as createDevToolsMiddleware, t as DevTools, u as createDevToolsContext } from "./plugins-Chcj6ENu.js";
1
+ import { n as createDevToolsMiddleware, t as DevTools, u as createDevToolsContext } from "./plugins-C1AF2q2c.js";
2
2
 
3
3
  export { DevTools, createDevToolsContext, createDevToolsMiddleware };