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

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
+ import { I as shallowRef, N as reactive, T as watch, j as markRaw } from "./vue.runtime.esm-bundler-B98sE5ly.js";
2
+ import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
3
+
4
+ //#region src/client/webcomponents/constants.ts
5
+ const BUILTIN_ENTRY_CLIENT_AUTH_NOTICE = Object.freeze({
6
+ type: "~builtin",
7
+ id: "~client-auth-notice",
8
+ title: "Unauthorized",
9
+ icon: "i-fluent-emoji-flat-warning"
10
+ });
11
+ const BUILTIN_ENTRIES = Object.freeze([BUILTIN_ENTRY_CLIENT_AUTH_NOTICE]);
12
+ const DEFAULT_CATEGORIES_ORDER = {
13
+ default: 0,
14
+ app: 100,
15
+ framework: 200,
16
+ web: 300,
17
+ advanced: 400,
18
+ builtin: 500
19
+ };
20
+
21
+ //#endregion
22
+ //#region src/client/webcomponents/state/docks.ts
23
+ function DEFAULT_DOCK_PANEL_STORE() {
24
+ return {
25
+ width: 80,
26
+ height: 80,
27
+ top: 0,
28
+ left: 10,
29
+ position: "bottom",
30
+ open: false,
31
+ inactiveTimeout: 3e3
32
+ };
33
+ }
34
+ function createDockEntryState(entry, selected) {
35
+ const events = createEventEmitter();
36
+ const state = reactive({
37
+ entryMeta: entry,
38
+ get isActive() {
39
+ return selected.value?.id === entry.id;
40
+ },
41
+ domElements: {},
42
+ events: markRaw(events)
43
+ });
44
+ watch(() => selected.value?.id, (newSelectedId) => {
45
+ if (newSelectedId === entry.id) events.emit("entry:activated");
46
+ else events.emit("entry:deactivated");
47
+ }, { immediate: true });
48
+ watch(() => state.domElements.iframe, (newIframe) => {
49
+ if (newIframe) events.emit("dom:iframe:mounted", newIframe);
50
+ }, { immediate: true });
51
+ watch(() => state.domElements.panel, (newPanel) => {
52
+ if (newPanel) events.emit("dom:panel:mounted", newPanel);
53
+ }, { immediate: true });
54
+ return state;
55
+ }
56
+ function sharedStateToRef(sharedState) {
57
+ const ref = shallowRef(sharedState.value());
58
+ sharedState.on("updated", (newState) => {
59
+ ref.value = newState;
60
+ });
61
+ return ref;
62
+ }
63
+ let _docksEntriesRef;
64
+ async function useDocksEntries(rpc) {
65
+ if (_docksEntriesRef) return _docksEntriesRef;
66
+ _docksEntriesRef = sharedStateToRef(await rpc.sharedState.get("vite:internal:docks", { initialValue: [] }));
67
+ return _docksEntriesRef;
68
+ }
69
+
70
+ //#endregion
71
+ export { BUILTIN_ENTRY_CLIENT_AUTH_NOTICE as a, BUILTIN_ENTRIES as i, createDockEntryState as n, DEFAULT_CATEGORIES_ORDER as o, useDocksEntries as r, DEFAULT_DOCK_PANEL_STORE as t };
@@ -0,0 +1,9 @@
1
+ //#region \0/plugin-vue/export-helper
2
+ var export_helper_default = (sfc, props) => {
3
+ const target = sfc.__vccOpts || sfc;
4
+ for (const [key, val] of props) target[key] = val;
5
+ return target;
6
+ };
7
+
8
+ //#endregion
9
+ export { export_helper_default as t };
@@ -87,9 +87,11 @@ interface DevToolsDockHost {
87
87
  update: (patch: Partial<T>) => void;
88
88
  };
89
89
  update: (entry: DevToolsDockUserEntry) => void;
90
- values: () => DevToolsDockUserEntry[];
90
+ values: (options?: {
91
+ includeBuiltin?: boolean;
92
+ }) => DevToolsDockEntry[];
91
93
  }
92
- type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default';
94
+ type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default' | 'builtin';
93
95
  type DevToolsDockEntryIcon = string | {
94
96
  light: string;
95
97
  dark: string;
@@ -165,7 +167,7 @@ interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
165
167
  }
166
168
  interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
167
169
  type: '~builtin';
168
- id: '~terminals' | '~logs' | '~client-auth-notice';
170
+ id: '~terminals' | '~logs' | '~client-auth-notice' | '~settings';
169
171
  }
170
172
  type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
171
173
  type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
@@ -176,6 +178,7 @@ interface DevToolsNodeRpcSessionMeta {
176
178
  ws?: WebSocket;
177
179
  clientAuthId?: string;
178
180
  isTrusted?: boolean;
181
+ subscribedStates: Set<string>;
179
182
  }
180
183
  //#endregion
181
184
  //#region ../kit/src/utils/shared-state.d.ts
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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";
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-BYIZX1ss.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";
@@ -20,24 +20,26 @@ interface DevToolsAuthReturn {
20
20
  }
21
21
  //#endregion
22
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<{
23
+ declare const builtinRpcDeclarations: 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:on-launch", "action", [entryId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server:list", "static", [], Promise<{
24
24
  [k: string]: {
25
25
  type: any;
26
26
  };
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<{
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:rpc:server-state:subscribe", "event", [key: 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>];
31
- type BuiltinServerFunctions = RpcDefinitionsToFunctions<typeof builtinRpcDecalrations>;
31
+ type BuiltinServerFunctions = RpcDefinitionsToFunctions<typeof builtinRpcDeclarations>;
32
32
  declare module '@vitejs/devtools-kit' {
33
33
  interface DevToolsRpcServerFunctions extends BuiltinServerFunctions {}
34
34
  interface DevToolsRpcClientFunctions {
35
- 'vite:internal:docks:updated': () => Promise<void>;
36
35
  '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
+ 'vite:internal:rpc:client-state:updated': (key: string, fullState: any, syncId: string) => Promise<void>;
38
37
  'vite:internal:terminals:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => Promise<void>;
39
38
  'vite:internal:terminals:updated': () => Promise<void>;
40
39
  }
40
+ interface DevToolsRpcSharedStates {
41
+ 'vite:internal:docks': DevToolsDockEntry[];
42
+ }
41
43
  }
42
44
  //#endregion
43
45
  //#region src/node/plugins/index.d.ts
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as createDevToolsMiddleware, t as DevTools, u as createDevToolsContext } from "./plugins-C1AF2q2c.js";
1
+ import { n as createDevToolsMiddleware, t as DevTools, u as createDevToolsContext } from "./plugins-BTYJ2nZg.js";
2
2
 
3
3
  export { DevTools, createDevToolsContext, createDevToolsMiddleware };
@@ -1,6 +1,5 @@
1
- import { n as __toESM, t as __commonJSMin } from "./chunk-CwIu-FEx.js";
2
- import { n as dirDist, t as dirClientStandalone } from "./dirs-BJIz1OY5.js";
3
- import Debug from "debug";
1
+ import { n as dirDist, t as dirClientStandalone } from "./dirs-C0s1Ghvy.js";
2
+ import { createDebug } from "obug";
4
3
  import { debounce } from "perfect-debounce";
5
4
  import { normalizePath, searchForWorkspaceRoot } from "vite";
6
5
  import { toDataURL } from "mlly";
@@ -24,6 +23,34 @@ import { createServer } from "node:net";
24
23
  import { networkInterfaces } from "node:os";
25
24
  import "node:fs/promises";
26
25
 
26
+ //#region rolldown:runtime
27
+ var __create = Object.create;
28
+ var __defProp = Object.defineProperty;
29
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
30
+ var __getOwnPropNames = Object.getOwnPropertyNames;
31
+ var __getProtoOf = Object.getPrototypeOf;
32
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
33
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
+ var __copyProps = (to, from, except, desc) => {
35
+ if (from && typeof from === "object" || typeof from === "function") {
36
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
37
+ key = keys[i];
38
+ if (!__hasOwnProp.call(to, key) && key !== except) {
39
+ __defProp(to, key, {
40
+ get: ((k$2) => from[k$2]).bind(null, key),
41
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
42
+ });
43
+ }
44
+ }
45
+ }
46
+ return to;
47
+ };
48
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
49
+ value: mod,
50
+ enumerable: true
51
+ }) : target, mod));
52
+
53
+ //#endregion
27
54
  //#region src/node/context-utils.ts
28
55
  const ContextUtils = { createSimpleClientScript(fn) {
29
56
  return {
@@ -40,8 +67,36 @@ var DevToolsDockHost = class {
40
67
  constructor(context) {
41
68
  this.context = context;
42
69
  }
43
- values() {
44
- return Array.from(this.views.values());
70
+ values({ includeBuiltin = true } = {}) {
71
+ const context = this.context;
72
+ const builtinDocksEntries = [
73
+ {
74
+ type: "~builtin",
75
+ id: "~terminals",
76
+ title: "Terminals",
77
+ icon: "ph:terminal-duotone",
78
+ category: "builtin",
79
+ get isHidden() {
80
+ return context.terminals.sessions.size === 0;
81
+ }
82
+ },
83
+ {
84
+ type: "~builtin",
85
+ id: "~logs",
86
+ title: "Logs",
87
+ icon: "ph:notification-duotone",
88
+ category: "builtin",
89
+ isHidden: true
90
+ },
91
+ {
92
+ type: "~builtin",
93
+ id: "~settings",
94
+ title: "Settings",
95
+ category: "builtin",
96
+ icon: "ph:gear-duotone"
97
+ }
98
+ ];
99
+ return [...Array.from(this.views.values()), ...includeBuiltin ? builtinDocksEntries : []];
45
100
  }
46
101
  register(view, force) {
47
102
  if (this.views.has(view.id) && !force) throw new Error(`Dock with id "${view.id}" is already registered`);
@@ -61,23 +116,41 @@ var DevToolsDockHost = class {
61
116
 
62
117
  //#endregion
63
118
  //#region src/node/rpc-shared-state.ts
119
+ const debug$1 = createDebug("vite:devtools:rpc:state:changed");
64
120
  function createRpcSharedStateServerHost(rpc) {
65
121
  const sharedState = /* @__PURE__ */ new Map();
66
122
  function registerSharedState(key, state) {
67
123
  const offs = [];
68
- offs.push(state.on("updated", (_fullState, patches, syncId) => {
69
- if (patches) rpc.broadcast({
70
- method: "vite:internal:rpc:client-state:patch",
71
- args: [
124
+ offs.push(state.on("updated", (fullState, patches, syncId) => {
125
+ if (patches) {
126
+ debug$1("patch", {
72
127
  key,
73
- patches,
74
128
  syncId
75
- ]
76
- });
77
- else rpc.broadcast({
78
- method: "vite:internal:rpc:client-state:updated",
79
- args: [key, syncId]
80
- });
129
+ });
130
+ rpc.broadcast({
131
+ method: "vite:internal:rpc:client-state:patch",
132
+ args: [
133
+ key,
134
+ patches,
135
+ syncId
136
+ ],
137
+ filter: (client) => client.$meta.subscribedStates.has(key)
138
+ });
139
+ } else {
140
+ debug$1("updated", {
141
+ key,
142
+ syncId
143
+ });
144
+ rpc.broadcast({
145
+ method: "vite:internal:rpc:client-state:updated",
146
+ args: [
147
+ key,
148
+ fullState,
149
+ syncId
150
+ ],
151
+ filter: (client) => client.$meta.subscribedStates.has(key)
152
+ });
153
+ }
81
154
  }));
82
155
  return () => {
83
156
  for (const off of offs) off();
@@ -86,8 +159,9 @@ function createRpcSharedStateServerHost(rpc) {
86
159
  return { get: async (key, options) => {
87
160
  if (sharedState.has(key)) return sharedState.get(key);
88
161
  if (options?.initialValue === void 0) throw new Error(`Shared state of "${key}" is not found, please provide an initial value for the first time`);
162
+ debug$1("new-state", key);
89
163
  const state = createSharedState({
90
- initialState: options.initialValue,
164
+ initialValue: options.initialValue,
91
165
  enablePatches: false
92
166
  });
93
167
  registerSharedState(key, state);
@@ -98,6 +172,7 @@ function createRpcSharedStateServerHost(rpc) {
98
172
 
99
173
  //#endregion
100
174
  //#region src/node/host-functions.ts
175
+ const debugBroadcast = createDebug("vite:devtools:rpc:broadcast");
101
176
  var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
102
177
  /**
103
178
  * @internal
@@ -111,6 +186,7 @@ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
111
186
  sharedState;
112
187
  async broadcast(options) {
113
188
  if (!this._rpcGroup) throw new Error("RpcFunctionsHost] RpcGroup is not set, it likely to be an internal bug of Vite DevTools");
189
+ debugBroadcast(JSON.stringify(options.method));
114
190
  await Promise.all(this._rpcGroup.clients.map((client) => {
115
191
  if (options.filter?.(client) === false) return void 0;
116
192
  return client.$callRaw({
@@ -1550,11 +1626,11 @@ const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible,
1550
1626
  //#endregion
1551
1627
  //#region src/node/storage.ts
1552
1628
  function createStorage(options) {
1553
- let initialState;
1554
- if (fs.existsSync(options.filepath)) initialState = JSON.parse(fs.readFileSync(options.filepath, "utf-8"));
1555
- else initialState = options.initialValue;
1629
+ let initialValue;
1630
+ if (fs.existsSync(options.filepath)) initialValue = JSON.parse(fs.readFileSync(options.filepath, "utf-8"));
1631
+ else initialValue = options.initialValue;
1556
1632
  const state = createSharedState({
1557
- initialState,
1633
+ initialValue,
1558
1634
  enablePatches: false
1559
1635
  });
1560
1636
  state.on("updated", (newState) => {
@@ -1627,27 +1703,6 @@ const anonymousAuth = defineRpcFunction({
1627
1703
  }
1628
1704
  });
1629
1705
 
1630
- //#endregion
1631
- //#region src/node/rpc/internal/docks-list.ts
1632
- const docksList = defineRpcFunction({
1633
- name: "vite:internal:docks:list",
1634
- type: "static",
1635
- setup: (context) => {
1636
- const builtinDocksEntries = [{
1637
- type: "~builtin",
1638
- id: "~terminals",
1639
- title: "Terminals",
1640
- icon: "ph:terminal-duotone",
1641
- get isHidden() {
1642
- return context.terminals.sessions.size === 0;
1643
- }
1644
- }];
1645
- return { handler() {
1646
- return [...Array.from(context.docks.values()), ...builtinDocksEntries];
1647
- } };
1648
- }
1649
- });
1650
-
1651
1706
  //#endregion
1652
1707
  //#region src/node/rpc/internal/docks-on-launch.ts
1653
1708
  const docksOnLaunch = defineRpcFunction({
@@ -1743,6 +1798,25 @@ const sharedStateSet = defineRpcFunction({
1743
1798
  }
1744
1799
  });
1745
1800
 
1801
+ //#endregion
1802
+ //#region src/node/rpc/internal/state/subscribe.ts
1803
+ const debug = createDebug("vite:devtools:rpc:state:subscribe");
1804
+ const sharedStateSubscribe = defineRpcFunction({
1805
+ name: "vite:internal:rpc:server-state:subscribe",
1806
+ type: "event",
1807
+ setup: (context) => {
1808
+ return { handler: async (key) => {
1809
+ const session = context.rpc.getCurrentRpcSession();
1810
+ if (!session) return;
1811
+ debug("subscribe", {
1812
+ key,
1813
+ session: session.meta.id
1814
+ });
1815
+ session.meta.subscribedStates.add(key);
1816
+ } };
1817
+ }
1818
+ });
1819
+
1746
1820
  //#endregion
1747
1821
  //#region src/node/rpc/internal/terminals-list.ts
1748
1822
  const terminalsList = defineRpcFunction({
@@ -1769,10 +1843,10 @@ const terminalsRead = defineRpcFunction({
1769
1843
  type: "query",
1770
1844
  setup: (context) => {
1771
1845
  return { async handler(id) {
1772
- const seesion = context.terminals.sessions.get(id);
1773
- if (!seesion) throw new Error(`Terminal session with id "${id}" not found`);
1846
+ const session = context.terminals.sessions.get(id);
1847
+ if (!session) throw new Error(`Terminal session with id "${id}" not found`);
1774
1848
  return {
1775
- buffer: seesion.buffer ?? [],
1849
+ buffer: session.buffer ?? [],
1776
1850
  ts: Date.now()
1777
1851
  };
1778
1852
  } };
@@ -1805,27 +1879,27 @@ const openInFinder = defineRpcFunction({
1805
1879
 
1806
1880
  //#endregion
1807
1881
  //#region src/node/rpc/index.ts
1808
- const builtinPublicRpcDecalrations = [openInEditor, openInFinder];
1809
- const builtinAnonymousRpcDecalrations = [anonymousAuth];
1810
- const builtinInternalRpcDecalrations = [
1811
- docksList,
1882
+ const builtinPublicRpcDeclarations = [openInEditor, openInFinder];
1883
+ const builtinAnonymousRpcDeclarations = [anonymousAuth];
1884
+ const builtinInternalRpcDeclarations = [
1812
1885
  docksOnLaunch,
1813
1886
  rpcServerList,
1814
1887
  sharedStateGet,
1815
1888
  sharedStatePatch,
1816
1889
  sharedStateSet,
1890
+ sharedStateSubscribe,
1817
1891
  terminalsList,
1818
1892
  terminalsRead
1819
1893
  ];
1820
- const builtinRpcDecalrations = [
1821
- ...builtinPublicRpcDecalrations,
1822
- ...builtinAnonymousRpcDecalrations,
1823
- ...builtinInternalRpcDecalrations
1894
+ const builtinRpcDeclarations = [
1895
+ ...builtinPublicRpcDeclarations,
1896
+ ...builtinAnonymousRpcDeclarations,
1897
+ ...builtinInternalRpcDeclarations
1824
1898
  ];
1825
1899
 
1826
1900
  //#endregion
1827
1901
  //#region src/node/context.ts
1828
- const debug = Debug("vite:devtools:context");
1902
+ const debugSetup = createDebug("vite:devtools:context:setup");
1829
1903
  async function createDevToolsContext(viteConfig, viteServer) {
1830
1904
  const cwd = viteConfig.root;
1831
1905
  const context = {
@@ -1848,22 +1922,17 @@ async function createDevToolsContext(viteConfig, viteServer) {
1848
1922
  context.docks = docksHost;
1849
1923
  context.views = viewsHost;
1850
1924
  context.terminals = terminalsHost;
1851
- for (const fn of builtinRpcDecalrations) rpcHost.register(fn);
1925
+ for (const fn of builtinRpcDeclarations) rpcHost.register(fn);
1926
+ const docksSharedState = await rpcHost.sharedState.get("vite:internal:docks", { initialValue: [] });
1852
1927
  docksHost.events.on("dock:entry:updated", debounce(() => {
1853
- rpcHost.broadcast({
1854
- method: "vite:internal:docks:updated",
1855
- args: []
1856
- });
1928
+ docksSharedState.mutate(() => context.docks.values());
1857
1929
  }, 10));
1858
1930
  terminalsHost.events.on("terminal:session:updated", debounce(() => {
1859
1931
  rpcHost.broadcast({
1860
1932
  method: "vite:internal:terminals:updated",
1861
1933
  args: []
1862
1934
  });
1863
- rpcHost.broadcast({
1864
- method: "vite:internal:docks:updated",
1865
- args: []
1866
- });
1935
+ docksSharedState.mutate(() => context.docks.values());
1867
1936
  }, 10));
1868
1937
  terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
1869
1938
  rpcHost.broadcast({
@@ -1875,7 +1944,7 @@ async function createDevToolsContext(viteConfig, viteServer) {
1875
1944
  for (const plugin of plugins) {
1876
1945
  if (!plugin.devtools?.setup) continue;
1877
1946
  try {
1878
- debug(`Setting up plugin ${plugin.name}`);
1947
+ debugSetup(`setting up plugin ${JSON.stringify(plugin.name)}`);
1879
1948
  await plugin.devtools?.setup?.(context);
1880
1949
  } catch (error) {
1881
1950
  console.error(`[Vite DevTools] Error setting up plugin ${plugin.name}:`, error);
@@ -2096,7 +2165,7 @@ function createError(input) {
2096
2165
  if (input.unhandled !== void 0) err.unhandled = input.unhandled;
2097
2166
  return err;
2098
2167
  }
2099
- function sendError(event, error, debug$1) {
2168
+ function sendError(event, error, debug$2) {
2100
2169
  if (event.handled) return;
2101
2170
  const h3Error = isError(error) ? error : createError(error);
2102
2171
  const responseBody = {
@@ -2105,7 +2174,7 @@ function sendError(event, error, debug$1) {
2105
2174
  stack: [],
2106
2175
  data: h3Error.data
2107
2176
  };
2108
- if (debug$1) responseBody.stack = (h3Error.stack || "").split("\n").map((l$1) => l$1.trim());
2177
+ if (debug$2) responseBody.stack = (h3Error.stack || "").split("\n").map((l$1) => l$1.trim());
2109
2178
  if (event.handled) return;
2110
2179
  setResponseStatus(event, Number.parseInt(h3Error.statusCode), h3Error.statusMessage);
2111
2180
  event.node.res.setHeader("content-type", MIMES.json);
@@ -2804,6 +2873,7 @@ const MARK_NODE = "⬢";
2804
2873
 
2805
2874
  //#endregion
2806
2875
  //#region src/node/ws.ts
2876
+ const debugInvoked = createDebug("vite:devtools:rpc:invoked");
2807
2877
  const ANONYMOUS_SCOPE = "vite:anonymous:";
2808
2878
  async function createWsServer(options) {
2809
2879
  const rpcHost = options.context.rpc;
@@ -2855,6 +2925,7 @@ async function createWsServer(options) {
2855
2925
  };
2856
2926
  if (!fn) return void 0;
2857
2927
  return async function(...args) {
2928
+ debugInvoked(`${JSON.stringify(name)} from #${rpc.$meta.id}`);
2858
2929
  return await asyncStorage.run({
2859
2930
  rpc,
2860
2931
  meta: rpc.$meta