@vitejs/devtools-kit 0.0.0-alpha.20 → 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.
@@ -1,9 +1,11 @@
1
- import { t as EventEmitter } from "./events-S6nCJ_5X.mjs";
1
+ import { t as EventEmitter } from "./events-ChUECkY3.mjs";
2
+ import { o as SharedState } from "./shared-state-BLTtoMWB.mjs";
2
3
  import { RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsCollector, RpcFunctionsCollectorBase } from "birpc-x";
3
4
  import { Raw } from "vue";
5
+ import { BirpcOptions, BirpcReturn } from "birpc";
6
+ import { WebSocket } from "ws";
4
7
  import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
5
8
  import { ChildProcess } from "node:child_process";
6
- import { BirpcOptions, BirpcReturn } from "birpc";
7
9
 
8
10
  //#region src/types/docks.d.ts
9
11
  interface DevToolsDockHost {
@@ -93,11 +95,19 @@ interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
93
95
  }
94
96
  interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
95
97
  type: '~builtin';
96
- id: '~terminals' | '~logs';
98
+ id: '~terminals' | '~logs' | '~client-auth-notice';
97
99
  }
98
100
  type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
99
101
  type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
100
102
  //#endregion
103
+ //#region ../rpc/src/presets/ws/server.d.ts
104
+ interface DevToolsNodeRpcSessionMeta {
105
+ id: number;
106
+ ws?: WebSocket;
107
+ clientAuthId?: string;
108
+ isTrusted?: boolean;
109
+ }
110
+ //#endregion
101
111
  //#region src/types/rpc-augments.d.ts
102
112
  /**
103
113
  * To be extended
@@ -107,6 +117,10 @@ interface DevToolsRpcClientFunctions {}
107
117
  * To be extended
108
118
  */
109
119
  interface DevToolsRpcServerFunctions {}
120
+ /**
121
+ * To be extended
122
+ */
123
+ interface DevToolsRpcSharedStates {}
110
124
  //#endregion
111
125
  //#region src/types/terminals.d.ts
112
126
  interface DevToolsTerminalSessionStreamChunkEvent {
@@ -180,14 +194,47 @@ interface DevToolsPluginOptions {
180
194
  setup: (context: DevToolsNodeContext) => void | Promise<void>;
181
195
  }
182
196
  interface DevToolsNodeContext {
197
+ /**
198
+ * Workspace root directory of Vite DevTools
199
+ */
200
+ readonly workspaceRoot: string;
201
+ /**
202
+ * Current working directory of Vite DevTools
203
+ */
183
204
  readonly cwd: string;
205
+ /**
206
+ * Current mode of Vite DevTools
207
+ * - 'dev' - when Vite DevTools is running in dev mode
208
+ * - 'build' - when Vite DevTools is running in build mode (no server)
209
+ */
184
210
  readonly mode: 'dev' | 'build';
211
+ /**
212
+ * Resolved Vite configuration
213
+ */
185
214
  readonly viteConfig: ResolvedConfig;
215
+ /**
216
+ * Vite dev server instance (only available in dev mode)
217
+ */
186
218
  readonly viteServer?: ViteDevServer;
219
+ /**
220
+ * RPC functions host, for registering server-side RPC functions and calling client-side RPC functions
221
+ */
187
222
  rpc: RpcFunctionsHost;
223
+ /**
224
+ * Docks host, for registering dock entries
225
+ */
188
226
  docks: DevToolsDockHost;
227
+ /**
228
+ * Views host, for registering static views
229
+ */
189
230
  views: DevToolsViewHost;
231
+ /**
232
+ * Utils for the node context
233
+ */
190
234
  utils: DevToolsNodeUtils;
235
+ /**
236
+ * Terminals host, for registering terminal sessions and streaming terminal output
237
+ */
191
238
  terminals: DevToolsTerminalHost;
192
239
  }
193
240
  interface DevToolsNodeUtils {
@@ -205,9 +252,39 @@ interface ConnectionMeta {
205
252
  }
206
253
  //#endregion
207
254
  //#region src/types/rpc.d.ts
255
+ interface DevToolsNodeRpcSession {
256
+ meta: DevToolsNodeRpcSessionMeta;
257
+ rpc: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
258
+ }
259
+ interface RpcBroadcastOptions<METHOD, Args extends any[]> {
260
+ method: METHOD;
261
+ args: Args;
262
+ optional?: boolean;
263
+ event?: boolean;
264
+ filter?: (client: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>) => boolean | void;
265
+ }
208
266
  type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> & {
209
- boardcast: <T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(name: T, ...args: Args) => Promise<(Awaited<ReturnType<DevToolsRpcClientFunctions[T]>> | undefined)[]>;
267
+ /**
268
+ * Broadcast a message to all connected clients
269
+ */
270
+ broadcast: <T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(options: RpcBroadcastOptions<T, Args>) => Promise<void>;
271
+ /**
272
+ * Get the current RPC client
273
+ *
274
+ * Available in RPC functions to get the current RPC client
275
+ */
276
+ getCurrentRpcSession: () => DevToolsNodeRpcSession | undefined;
277
+ /**
278
+ * The shared state host
279
+ */
280
+ sharedState: RpcSharedStateHost;
210
281
  };
282
+ interface RpcSharedStateGetOptions<T> {
283
+ initialValue?: T;
284
+ }
285
+ interface RpcSharedStateHost {
286
+ get: <T extends keyof DevToolsRpcSharedStates>(key: T, options?: RpcSharedStateGetOptions<DevToolsRpcSharedStates[T]>) => Promise<SharedState<DevToolsRpcSharedStates[T]>>;
287
+ }
211
288
  //#endregion
212
289
  //#region src/types/utils.d.ts
213
290
  type Thenable<T> = T | Promise<T>;
@@ -223,6 +300,21 @@ declare module 'vite' {
223
300
  interface Plugin {
224
301
  devtools?: DevToolsPluginOptions;
225
302
  }
303
+ interface UserConfig {
304
+ devtools?: ViteConfigDevtoolsOptions;
305
+ }
306
+ }
307
+ interface ViteConfigDevtoolsOptions {
308
+ /**
309
+ * Disable client authentication.
310
+ *
311
+ * Beware that if you disable client authentication,
312
+ * any browsers can connect to the devtools and access to your server and filesystem.
313
+ * (including other devices, if you open server `host` option to LAN or WAN)
314
+ *
315
+ * @default true
316
+ */
317
+ clientAuth?: boolean;
226
318
  }
227
319
  interface PluginWithDevTools extends Plugin {
228
320
  devtools?: DevToolsPluginOptions;
@@ -234,12 +326,17 @@ interface WebSocketRpcClientOptions {
234
326
  onConnected?: (e: Event) => void;
235
327
  onError?: (e: Error) => void;
236
328
  onDisconnected?: (e: CloseEvent) => void;
329
+ authId?: string;
237
330
  }
238
331
  //#endregion
239
332
  //#region src/client/rpc.d.ts
240
333
  interface DevToolsRpcClientOptions {
241
334
  connectionMeta?: ConnectionMeta;
242
335
  baseURL?: string[];
336
+ /**
337
+ * The auth id to use for the client
338
+ */
339
+ authId?: string;
243
340
  wsOptions?: Partial<WebSocketRpcClientOptions>;
244
341
  rpcOptions?: Partial<BirpcOptions<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions, boolean>>;
245
342
  }
@@ -248,10 +345,26 @@ interface DevToolsRpcClient {
248
345
  * The events of the client
249
346
  */
250
347
  events: EventEmitter<RpcClientEvents>;
348
+ /**
349
+ * Whether the client is trusted
350
+ */
351
+ readonly isTrusted: boolean | null;
251
352
  /**
252
353
  * The connection meta
253
354
  */
254
355
  readonly connectionMeta: ConnectionMeta;
356
+ /**
357
+ * Return a promise that resolves when the client is trusted
358
+ *
359
+ * Rejects with an error if the timeout is reached
360
+ *
361
+ * @param timeout - The timeout in milliseconds, default to 60 seconds
362
+ */
363
+ ensureTrusted: (timeout?: number) => Promise<boolean>;
364
+ /**
365
+ * Request trust from the server
366
+ */
367
+ requestTrust: () => Promise<boolean>;
255
368
  /**
256
369
  * Call a RPC function on the server
257
370
  */
@@ -268,6 +381,10 @@ interface DevToolsRpcClient {
268
381
  * The client RPC host
269
382
  */
270
383
  client: DevToolsClientRpcHost;
384
+ /**
385
+ * The shared state host
386
+ */
387
+ sharedState: RpcSharedStateHost;
271
388
  }
272
389
  declare function getDevToolsRpcClient(options?: DevToolsRpcClientOptions): Promise<DevToolsRpcClient>;
273
390
  //#endregion
@@ -327,6 +444,12 @@ interface DocksEntriesContext {
327
444
  * @returns Whether the selection was changed successfully
328
445
  */
329
446
  switchEntry: (id?: string | null) => Promise<boolean>;
447
+ /**
448
+ * Toggle the selected dock entry
449
+ *
450
+ * @returns Whether the selection was changed successfully
451
+ */
452
+ toggleEntry: (id: string) => Promise<boolean>;
330
453
  }
331
454
  interface DockEntryState {
332
455
  entryMeta: DevToolsDockEntry;
@@ -344,7 +467,9 @@ interface DockEntryStateEvents {
344
467
  'dom:panel:mounted': (panel: HTMLDivElement) => void;
345
468
  'dom:iframe:mounted': (iframe: HTMLIFrameElement) => void;
346
469
  }
347
- interface RpcClientEvents {}
470
+ interface RpcClientEvents {
471
+ 'rpc:is-trusted:updated': (isTrusted: boolean) => void;
472
+ }
348
473
  //#endregion
349
474
  //#region src/client/client-script.d.ts
350
475
  /**
@@ -357,4 +482,4 @@ interface DockClientScriptContext extends DocksContext {
357
482
  current: DockEntryState;
358
483
  }
359
484
  //#endregion
360
- export { DevToolsTerminalHost as A, DevToolsDockEntryCategory as B, DevToolsCapabilities as C, DevToolsViewHost as D, DevToolsPluginOptions as E, DevToolsRpcClientFunctions as F, DevToolsViewBuiltin as G, DevToolsDockHost as H, DevToolsRpcServerFunctions as I, DevToolsViewLauncher as J, DevToolsViewCustomRender as K, ClientScriptEntry as L, DevToolsTerminalSessionBase as M, DevToolsTerminalSessionStreamChunkEvent as N, DevToolsChildProcessExecuteOptions as O, DevToolsTerminalStatus as P, DevToolsDockEntry as R, ConnectionMeta as S, DevToolsNodeUtils as T, DevToolsDockUserEntry as U, DevToolsDockEntryIcon as V, DevToolsViewAction as W, DevToolsViewLauncherStatus as Y, PluginWithDevTools as _, DockEntryState as a, Thenable as b, DocksContext as c, RpcClientEvents as d, DevToolsRpcClient as f, RpcDefinitionsToFunctions as g, RpcDefinitionsFilter as h, DockClientType as i, DevToolsTerminalSession as j, DevToolsChildProcessTerminalSession as k, DocksEntriesContext as l, getDevToolsRpcClient as m, DevToolsClientContext as n, DockEntryStateEvents as o, DevToolsRpcClientOptions as p, DevToolsViewIframe as q, DevToolsClientRpcHost as r, DockPanelStorage as s, DockClientScriptContext as t, DocksPanelContext as u, EntriesToObject as v, DevToolsNodeContext as w, RpcFunctionsHost as x, PartialWithoutId as y, DevToolsDockEntryBase as z };
485
+ export { DevToolsViewCustomRender as $, DevToolsNodeUtils as A, DevToolsRpcClientFunctions as B, RpcBroadcastOptions as C, ConnectionMeta as D, RpcSharedStateHost as E, DevToolsTerminalHost as F, DevToolsDockEntry as G, DevToolsRpcSharedStates as H, DevToolsTerminalSession as I, DevToolsDockEntryIcon as J, DevToolsDockEntryBase as K, DevToolsTerminalSessionBase as L, DevToolsViewHost as M, DevToolsChildProcessExecuteOptions as N, DevToolsCapabilities as O, DevToolsChildProcessTerminalSession as P, DevToolsViewBuiltin as Q, DevToolsTerminalSessionStreamChunkEvent as R, DevToolsNodeRpcSession as S, RpcSharedStateGetOptions as T, DevToolsNodeRpcSessionMeta as U, DevToolsRpcServerFunctions as V, ClientScriptEntry as W, DevToolsDockUserEntry as X, DevToolsDockHost as Y, DevToolsViewAction as Z, PluginWithDevTools as _, DockEntryState as a, PartialWithoutId as b, DocksContext as c, RpcClientEvents as d, DevToolsViewIframe as et, DevToolsRpcClient as f, RpcDefinitionsToFunctions as g, RpcDefinitionsFilter as h, DockClientType as i, DevToolsPluginOptions as j, DevToolsNodeContext as k, DocksEntriesContext as l, getDevToolsRpcClient as m, DevToolsClientContext as n, DevToolsViewLauncherStatus as nt, DockEntryStateEvents as o, DevToolsRpcClientOptions as p, DevToolsDockEntryCategory as q, DevToolsClientRpcHost as r, DockPanelStorage as s, DockClientScriptContext as t, DevToolsViewLauncher as tt, DocksPanelContext as u, ViteConfigDevtoolsOptions as v, RpcFunctionsHost as w, Thenable as x, EntriesToObject as y, DevToolsTerminalStatus as z };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import { n as EventUnsubscribe, r as EventsMap, t as EventEmitter } from "./events-S6nCJ_5X.mjs";
2
- import { A as DevToolsTerminalHost, B as DevToolsDockEntryCategory, C as DevToolsCapabilities, D as DevToolsViewHost, E as DevToolsPluginOptions, F as DevToolsRpcClientFunctions, G as DevToolsViewBuiltin, H as DevToolsDockHost, I as DevToolsRpcServerFunctions, J as DevToolsViewLauncher, K as DevToolsViewCustomRender, L as ClientScriptEntry, M as DevToolsTerminalSessionBase, N as DevToolsTerminalSessionStreamChunkEvent, O as DevToolsChildProcessExecuteOptions, P as DevToolsTerminalStatus, R as DevToolsDockEntry, S as ConnectionMeta, T as DevToolsNodeUtils, U as DevToolsDockUserEntry, V as DevToolsDockEntryIcon, W as DevToolsViewAction, Y as DevToolsViewLauncherStatus, _ as PluginWithDevTools, b as Thenable, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, j as DevToolsTerminalSession, k as DevToolsChildProcessTerminalSession, q as DevToolsViewIframe, v as EntriesToObject, w as DevToolsNodeContext, x as RpcFunctionsHost, y as PartialWithoutId, z as DevToolsDockEntryBase } from "./index-DLPbKO1M.mjs";
1
+ import { n as EventUnsubscribe, r as EventsMap, t as EventEmitter } from "./events-ChUECkY3.mjs";
2
+ import { $ as DevToolsViewCustomRender, A as DevToolsNodeUtils, B as DevToolsRpcClientFunctions, C as RpcBroadcastOptions, D as ConnectionMeta, E as RpcSharedStateHost, F as DevToolsTerminalHost, G as DevToolsDockEntry, H as DevToolsRpcSharedStates, I as DevToolsTerminalSession, J as DevToolsDockEntryIcon, K as DevToolsDockEntryBase, L as DevToolsTerminalSessionBase, M as DevToolsViewHost, N as DevToolsChildProcessExecuteOptions, O as DevToolsCapabilities, P as DevToolsChildProcessTerminalSession, Q as DevToolsViewBuiltin, R as DevToolsTerminalSessionStreamChunkEvent, S as DevToolsNodeRpcSession, T as RpcSharedStateGetOptions, U as DevToolsNodeRpcSessionMeta, V as DevToolsRpcServerFunctions, W as ClientScriptEntry, X as DevToolsDockUserEntry, Y as DevToolsDockHost, Z as DevToolsViewAction, _ as PluginWithDevTools, b as PartialWithoutId, et as DevToolsViewIframe, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, j as DevToolsPluginOptions, k as DevToolsNodeContext, nt as DevToolsViewLauncherStatus, q as DevToolsDockEntryCategory, tt as DevToolsViewLauncher, v as ViteConfigDevtoolsOptions, w as RpcFunctionsHost, x as Thenable, y as EntriesToObject, z as DevToolsTerminalStatus } from "./index-mqRYU7D7.mjs";
3
+ import "./shared-state-BLTtoMWB.mjs";
3
4
  import * as birpc_x0 from "birpc-x";
4
5
 
5
6
  //#region src/utils/define.d.ts
6
7
  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
8
  //#endregion
8
- export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsChildProcessExecuteOptions, DevToolsChildProcessTerminalSession, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsDockUserEntry, DevToolsNodeContext, 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, defineRpcFunction };
9
+ export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsChildProcessExecuteOptions, DevToolsChildProcessTerminalSession, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsDockUserEntry, 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, ViteConfigDevtoolsOptions, 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,53 @@
1
+ import { t as EventEmitter } from "./events-ChUECkY3.mjs";
2
+ import { Objectish, Patch, Patch as SharedStatePatch } 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
+ value: () => 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, syncId?: string) => void;
27
+ /**
28
+ * Apply patches to the state.
29
+ */
30
+ patch: (patches: Patch[], syncId?: string) => void;
31
+ /**
32
+ * Sync IDs that have been applied to the state.
33
+ */
34
+ syncIds: Set<string>;
35
+ }
36
+ interface SharedStateEvents<T> {
37
+ updated: (fullState: T, patches: Patch[] | undefined, syncId: string) => void;
38
+ }
39
+ interface SharedStateOptions<T> {
40
+ /**
41
+ * Initial state.
42
+ */
43
+ initialState: T;
44
+ /**
45
+ * Enable patches.
46
+ *
47
+ * @default false
48
+ */
49
+ enablePatches?: boolean;
50
+ }
51
+ declare function createSharedState<T extends Objectish>(options: SharedStateOptions<T>): SharedState<T>;
52
+ //#endregion
53
+ export { ImmutableSet as a, SharedStateOptions as c, ImmutableObject as i, SharedStatePatch as l, ImmutableArray as n, SharedState as o, ImmutableMap as r, SharedStateEvents as s, Immutable as t, createSharedState as u };
@@ -0,0 +1,38 @@
1
+ import { t as createEventEmitter } from "./events-CWYZG96x.mjs";
2
+ import { t as nanoid } from "./nanoid-B0pJU5uW.mjs";
3
+ import { applyPatches, enablePatches, produce, produceWithPatches } from "immer";
4
+
5
+ //#region src/utils/shared-state.ts
6
+ function createSharedState(options) {
7
+ const { enablePatches: enablePatches$1 = false } = options;
8
+ const events = createEventEmitter();
9
+ let state = options.initialState;
10
+ const syncIds = /* @__PURE__ */ new Set();
11
+ return {
12
+ on: events.on,
13
+ value: () => state,
14
+ patch: (patches, syncId = nanoid()) => {
15
+ if (syncIds.has(syncId)) return;
16
+ enablePatches();
17
+ state = applyPatches(state, patches);
18
+ syncIds.add(syncId);
19
+ events.emit("updated", state, void 0, syncId);
20
+ },
21
+ mutate: (fn, syncId = nanoid()) => {
22
+ if (syncIds.has(syncId)) return;
23
+ syncIds.add(syncId);
24
+ if (enablePatches$1) {
25
+ const [newState, patches] = produceWithPatches(state, fn);
26
+ state = newState;
27
+ events.emit("updated", state, patches, syncId);
28
+ } else {
29
+ state = produce(state, fn);
30
+ events.emit("updated", state, void 0, syncId);
31
+ }
32
+ },
33
+ syncIds
34
+ };
35
+ }
36
+
37
+ //#endregion
38
+ export { createSharedState as t };
@@ -1,4 +1,4 @@
1
- import { r as EventsMap, t as EventEmitter } from "../events-S6nCJ_5X.mjs";
1
+ import { r as EventsMap, t as EventEmitter } from "../events-ChUECkY3.mjs";
2
2
 
3
3
  //#region src/utils/events.d.ts
4
4
 
@@ -1,3 +1,3 @@
1
- import { t as createEventEmitter } from "../events-AmnAXhnR.mjs";
1
+ import { t as createEventEmitter } from "../events-CWYZG96x.mjs";
2
2
 
3
3
  export { createEventEmitter };
@@ -1,11 +1,3 @@
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
- }
1
+ import { t as nanoid } from "../nanoid-B0pJU5uW.mjs";
9
2
 
10
- //#endregion
11
3
  export { nanoid };
@@ -0,0 +1,2 @@
1
+ import { a as ImmutableSet, c as SharedStateOptions, i as ImmutableObject, l as SharedStatePatch, n as ImmutableArray, o as SharedState, r as ImmutableMap, s as SharedStateEvents, t as Immutable, u as createSharedState } from "../shared-state-BLTtoMWB.mjs";
2
+ export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, SharedStatePatch, createSharedState };
@@ -0,0 +1,3 @@
1
+ import { t as createSharedState } from "../shared-state-Bi50d6nv.mjs";
2
+
3
+ export { createSharedState };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitejs/devtools-kit",
3
3
  "type": "module",
4
- "version": "0.0.0-alpha.20",
4
+ "version": "0.0.0-alpha.22",
5
5
  "description": "Vite DevTools Kit",
6
6
  "author": "VoidZero Inc.",
7
7
  "license": "MIT",
@@ -23,6 +23,7 @@
23
23
  "./client": "./dist/client.mjs",
24
24
  "./utils/events": "./dist/utils/events.mjs",
25
25
  "./utils/nanoid": "./dist/utils/nanoid.mjs",
26
+ "./utils/shared-state": "./dist/utils/shared-state.mjs",
26
27
  "./package.json": "./package.json"
27
28
  },
28
29
  "main": "./dist/index.mjs",
@@ -37,12 +38,13 @@
37
38
  "dependencies": {
38
39
  "birpc": "^4.0.0",
39
40
  "birpc-x": "0.0.6",
40
- "@vitejs/devtools-rpc": "0.0.0-alpha.20"
41
+ "immer": "^11.1.0",
42
+ "@vitejs/devtools-rpc": "0.0.0-alpha.22"
41
43
  },
42
44
  "devDependencies": {
43
45
  "my-ua-parser": "^2.0.4",
44
- "tsdown": "^0.17.4",
45
- "vite": "^8.0.0-beta.2"
46
+ "tsdown": "^0.18.2",
47
+ "vite": "^8.0.0-beta.3"
46
48
  },
47
49
  "scripts": {
48
50
  "build": "tsdown",