@vitejs/devtools 0.0.0-alpha.3 → 0.0.0-alpha.31

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,131 @@
1
+ import { I as reactive, O as watch, P as markRaw, z as shallowRef } from "./vue.runtime.esm-bundler-DL0i8o0W.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
+ "~viteplus": -1e3,
14
+ "default": 0,
15
+ "app": 100,
16
+ "framework": 200,
17
+ "web": 300,
18
+ "advanced": 400,
19
+ "~builtin": 1e3
20
+ };
21
+
22
+ //#endregion
23
+ //#region src/client/webcomponents/state/dock-settings.ts
24
+ /**
25
+ * Group and sort dock entries based on user settings.
26
+ * Filters out hidden entries and categories, sorts by pinned status, custom order, and default order.
27
+ */
28
+ function docksGroupByCategories(entries, settings, options) {
29
+ const { docksHidden, docksCategoriesHidden, docksCustomOrder, docksPinned } = settings;
30
+ const { includeHidden = false } = options ?? {};
31
+ const map = /* @__PURE__ */ new Map();
32
+ for (const entry of entries) {
33
+ if (entry.isHidden && !includeHidden) continue;
34
+ if (!includeHidden && docksHidden.includes(entry.id)) continue;
35
+ const category = entry.category ?? "default";
36
+ if (!includeHidden && docksCategoriesHidden.includes(category)) continue;
37
+ if (!map.has(category)) map.set(category, []);
38
+ map.get(category).push(entry);
39
+ }
40
+ const grouped = Array.from(map.entries()).sort(([a], [b]) => {
41
+ const ia = DEFAULT_CATEGORIES_ORDER[a] || 0;
42
+ const ib = DEFAULT_CATEGORIES_ORDER[b] || 0;
43
+ return ib === ia ? b.localeCompare(a) : ia - ib;
44
+ });
45
+ grouped.forEach(([_, items]) => {
46
+ items.sort((a, b) => {
47
+ const aPinned = docksPinned.includes(a.id);
48
+ if (aPinned !== docksPinned.includes(b.id)) return aPinned ? -1 : 1;
49
+ const customOrderA = docksCustomOrder[a.id] ?? 0;
50
+ const customOrderB = docksCustomOrder[b.id] ?? 0;
51
+ if (customOrderA !== customOrderB) return customOrderA - customOrderB;
52
+ const ia = a.defaultOrder ?? 0;
53
+ const ib = b.defaultOrder ?? 0;
54
+ return ib === ia ? b.title.localeCompare(a.title) : ia - ib;
55
+ });
56
+ });
57
+ return grouped;
58
+ }
59
+ /**
60
+ * Split grouped entries into visible and overflow based on capacity.
61
+ */
62
+ function docksSplitGroupsWithCapacity(groups, capacity) {
63
+ const visible = [];
64
+ const overflow = [];
65
+ let left = capacity;
66
+ for (const [category, items] of groups) if (left <= 0) overflow.push([category, items]);
67
+ else if (items.length > left) {
68
+ visible.push([category, items.slice(0, left)]);
69
+ overflow.push([category, items.slice(left)]);
70
+ left = 0;
71
+ } else {
72
+ left -= items.length;
73
+ visible.push([category, items]);
74
+ }
75
+ return {
76
+ visible,
77
+ overflow
78
+ };
79
+ }
80
+
81
+ //#endregion
82
+ //#region src/client/webcomponents/state/docks.ts
83
+ function DEFAULT_DOCK_PANEL_STORE() {
84
+ return {
85
+ width: 80,
86
+ height: 80,
87
+ top: 0,
88
+ left: 10,
89
+ position: "bottom",
90
+ open: false,
91
+ inactiveTimeout: 3e3
92
+ };
93
+ }
94
+ function createDockEntryState(entry, selected) {
95
+ const events = createEventEmitter();
96
+ const state = reactive({
97
+ entryMeta: entry,
98
+ get isActive() {
99
+ return selected.value?.id === entry.id;
100
+ },
101
+ domElements: {},
102
+ events: markRaw(events)
103
+ });
104
+ watch(() => selected.value?.id, (newSelectedId) => {
105
+ if (newSelectedId === entry.id) events.emit("entry:activated");
106
+ else events.emit("entry:deactivated");
107
+ }, { immediate: true });
108
+ watch(() => state.domElements.iframe, (newIframe) => {
109
+ if (newIframe) events.emit("dom:iframe:mounted", newIframe);
110
+ }, { immediate: true });
111
+ watch(() => state.domElements.panel, (newPanel) => {
112
+ if (newPanel) events.emit("dom:panel:mounted", newPanel);
113
+ }, { immediate: true });
114
+ return state;
115
+ }
116
+ function sharedStateToRef(sharedState) {
117
+ const ref = shallowRef(sharedState.value());
118
+ sharedState.on("updated", (newState) => {
119
+ ref.value = newState;
120
+ });
121
+ return ref;
122
+ }
123
+ let _docksEntriesRef;
124
+ async function useDocksEntries(rpc) {
125
+ if (_docksEntriesRef) return _docksEntriesRef;
126
+ _docksEntriesRef = sharedStateToRef(await rpc.sharedState.get("devtoolskit:internal:docks", { initialValue: [] }));
127
+ return _docksEntriesRef;
128
+ }
129
+
130
+ //#endregion
131
+ export { docksGroupByCategories as a, BUILTIN_ENTRY_CLIENT_AUTH_NOTICE as c, useDocksEntries as i, createDockEntryState as n, docksSplitGroupsWithCapacity as o, sharedStateToRef as r, BUILTIN_ENTRIES as s, 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 };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,199 @@
1
- import { DevToolsNodeContext } from "@vitejs/devtools-kit";
2
- import "@vitejs/devtools-vite";
3
1
  import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
4
- import * as h30 from "h3";
5
- import * as birpc0 from "birpc";
2
+ import { SharedStatePatch } from "@vitejs/devtools-kit/utils/shared-state";
3
+ import * as _vitejs_devtools_rpc0 from "@vitejs/devtools-rpc";
4
+ import { RpcFunctionsCollectorBase } from "@vitejs/devtools-rpc";
5
+ import * as _vitejs_devtools_kit0 from "@vitejs/devtools-kit";
6
+ import { DevToolsDockEntry, DevToolsDocksUserSettings, DevToolsNodeContext, DevToolsTerminalSessionStreamChunkEvent, RpcDefinitionsToFunctions } from "@vitejs/devtools-kit";
7
+ import * as h3 from "h3";
8
+ import { AsyncLocalStorage } from "node:async_hooks";
9
+ import * as birpc from "birpc";
6
10
 
7
11
  //#region src/node/context.d.ts
8
12
  declare function createDevToolsContext(viteConfig: ResolvedConfig, viteServer?: ViteDevServer): Promise<DevToolsNodeContext>;
9
13
  //#endregion
14
+ //#region src/node/rpc/anonymous/auth.d.ts
15
+ interface DevToolsAuthInput {
16
+ authId: string;
17
+ ua: string;
18
+ origin: string;
19
+ }
20
+ interface DevToolsAuthReturn {
21
+ isTrusted: boolean;
22
+ }
23
+ //#endregion
24
+ //#region src/node/rpc/index.d.ts
25
+ declare const builtinRpcDeclarations: readonly [{
26
+ name: "vite:core:open-in-editor";
27
+ type?: "action" | undefined;
28
+ cacheable?: boolean;
29
+ args?: undefined;
30
+ returns?: undefined;
31
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[path: string], Promise<void>>>) | undefined;
32
+ handler?: ((path: string) => Promise<void>) | undefined;
33
+ dump?: _vitejs_devtools_rpc0.RpcDump<[path: string], Promise<void>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
34
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[path: string], Promise<void>> | undefined;
35
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[path: string], Promise<void>>> | undefined;
36
+ }, {
37
+ name: "vite:core:open-in-finder";
38
+ type?: "action" | undefined;
39
+ cacheable?: boolean;
40
+ args?: undefined;
41
+ returns?: undefined;
42
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[path: string], Promise<void>>>) | undefined;
43
+ handler?: ((path: string) => Promise<void>) | undefined;
44
+ dump?: _vitejs_devtools_rpc0.RpcDump<[path: string], Promise<void>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
45
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[path: string], Promise<void>> | undefined;
46
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[path: string], Promise<void>>> | undefined;
47
+ }, {
48
+ name: "vite:anonymous:auth";
49
+ type?: "action" | undefined;
50
+ cacheable?: boolean;
51
+ args?: undefined;
52
+ returns?: undefined;
53
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[query: DevToolsAuthInput], Promise<DevToolsAuthReturn>>>) | undefined;
54
+ handler?: ((query: DevToolsAuthInput) => Promise<DevToolsAuthReturn>) | undefined;
55
+ dump?: _vitejs_devtools_rpc0.RpcDump<[query: DevToolsAuthInput], Promise<DevToolsAuthReturn>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
56
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[query: DevToolsAuthInput], Promise<DevToolsAuthReturn>> | undefined;
57
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[query: DevToolsAuthInput], Promise<DevToolsAuthReturn>>> | undefined;
58
+ }, {
59
+ name: "devtoolskit:internal:docks:on-launch";
60
+ type?: "action" | undefined;
61
+ cacheable?: boolean;
62
+ args?: undefined;
63
+ returns?: undefined;
64
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[entryId: string], Promise<void>>>) | undefined;
65
+ handler?: ((entryId: string) => Promise<void>) | undefined;
66
+ dump?: _vitejs_devtools_rpc0.RpcDump<[entryId: string], Promise<void>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
67
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[entryId: string], Promise<void>> | undefined;
68
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[entryId: string], Promise<void>>> | undefined;
69
+ }, {
70
+ name: "devtoolskit:internal:rpc:server:list";
71
+ type?: "static" | undefined;
72
+ cacheable?: boolean;
73
+ args?: undefined;
74
+ returns?: undefined;
75
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[], Promise<{
76
+ [k: string]: {
77
+ type: any;
78
+ };
79
+ }>>>) | undefined;
80
+ handler?: (() => Promise<{
81
+ [k: string]: {
82
+ type: any;
83
+ };
84
+ }>) | undefined;
85
+ dump?: _vitejs_devtools_rpc0.RpcDump<[], Promise<{
86
+ [k: string]: {
87
+ type: any;
88
+ };
89
+ }>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
90
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[], Promise<{
91
+ [k: string]: {
92
+ type: any;
93
+ };
94
+ }>> | undefined;
95
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[], Promise<{
96
+ [k: string]: {
97
+ type: any;
98
+ };
99
+ }>>> | undefined;
100
+ }, {
101
+ name: "devtoolskit:internal:rpc:server-state:get";
102
+ type?: "query" | undefined;
103
+ cacheable?: boolean;
104
+ args?: undefined;
105
+ returns?: undefined;
106
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string], Promise<any>>>) | undefined;
107
+ handler?: ((key: string) => Promise<any>) | undefined;
108
+ dump?: _vitejs_devtools_rpc0.RpcDump<[key: string], Promise<any>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
109
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string], Promise<any>> | undefined;
110
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string], Promise<any>>> | undefined;
111
+ }, {
112
+ name: "devtoolskit:internal:rpc:server-state:patch";
113
+ type?: "query" | undefined;
114
+ cacheable?: boolean;
115
+ args?: undefined;
116
+ returns?: undefined;
117
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string, patches: SharedStatePatch[], syncId: string], Promise<void>>>) | undefined;
118
+ handler?: ((key: string, patches: SharedStatePatch[], syncId: string) => Promise<void>) | undefined;
119
+ dump?: _vitejs_devtools_rpc0.RpcDump<[key: string, patches: SharedStatePatch[], syncId: string], Promise<void>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
120
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string, patches: SharedStatePatch[], syncId: string], Promise<void>> | undefined;
121
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string, patches: SharedStatePatch[], syncId: string], Promise<void>>> | undefined;
122
+ }, {
123
+ name: "devtoolskit:internal:rpc:server-state:set";
124
+ type?: "query" | undefined;
125
+ cacheable?: boolean;
126
+ args?: undefined;
127
+ returns?: undefined;
128
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string, value: any, syncId: string], Promise<void>>>) | undefined;
129
+ handler?: ((key: string, value: any, syncId: string) => Promise<void>) | undefined;
130
+ dump?: _vitejs_devtools_rpc0.RpcDump<[key: string, value: any, syncId: string], Promise<void>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
131
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string, value: any, syncId: string], Promise<void>> | undefined;
132
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string, value: any, syncId: string], Promise<void>>> | undefined;
133
+ }, {
134
+ name: "devtoolskit:internal:rpc:server-state:subscribe";
135
+ type?: "event" | undefined;
136
+ cacheable?: boolean;
137
+ args?: undefined;
138
+ returns?: undefined;
139
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string], Promise<void>>>) | undefined;
140
+ handler?: ((key: string) => Promise<void>) | undefined;
141
+ dump?: _vitejs_devtools_rpc0.RpcDump<[key: string], Promise<void>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
142
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string], Promise<void>> | undefined;
143
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[key: string], Promise<void>>> | undefined;
144
+ }, {
145
+ name: "devtoolskit:internal:terminals:list";
146
+ type?: "static" | undefined;
147
+ cacheable?: boolean;
148
+ args?: undefined;
149
+ returns?: undefined;
150
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[], Promise<_vitejs_devtools_kit0.DevToolsTerminalSessionBase[]>>>) | undefined;
151
+ handler?: (() => Promise<_vitejs_devtools_kit0.DevToolsTerminalSessionBase[]>) | undefined;
152
+ dump?: _vitejs_devtools_rpc0.RpcDump<[], Promise<_vitejs_devtools_kit0.DevToolsTerminalSessionBase[]>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
153
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[], Promise<_vitejs_devtools_kit0.DevToolsTerminalSessionBase[]>> | undefined;
154
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[], Promise<_vitejs_devtools_kit0.DevToolsTerminalSessionBase[]>>> | undefined;
155
+ }, {
156
+ name: "devtoolskit:internal:terminals:read";
157
+ type?: "query" | undefined;
158
+ cacheable?: boolean;
159
+ args?: undefined;
160
+ returns?: undefined;
161
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[id: string], Promise<{
162
+ buffer: string[];
163
+ ts: number;
164
+ }>>>) | undefined;
165
+ handler?: ((id: string) => Promise<{
166
+ buffer: string[];
167
+ ts: number;
168
+ }>) | undefined;
169
+ dump?: _vitejs_devtools_rpc0.RpcDump<[id: string], Promise<{
170
+ buffer: string[];
171
+ ts: number;
172
+ }>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
173
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[id: string], Promise<{
174
+ buffer: string[];
175
+ ts: number;
176
+ }>> | undefined;
177
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[id: string], Promise<{
178
+ buffer: string[];
179
+ ts: number;
180
+ }>>> | undefined;
181
+ }];
182
+ type BuiltinServerFunctions = RpcDefinitionsToFunctions<typeof builtinRpcDeclarations>;
183
+ declare module '@vitejs/devtools-kit' {
184
+ interface DevToolsRpcServerFunctions extends BuiltinServerFunctions {}
185
+ interface DevToolsRpcClientFunctions {
186
+ 'devtoolskit:internal:rpc:client-state:patch': (key: string, patches: SharedStatePatch[], syncId: string) => Promise<void>;
187
+ 'devtoolskit:internal:rpc:client-state:updated': (key: string, fullState: any, syncId: string) => Promise<void>;
188
+ 'devtoolskit:internal:terminals:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => Promise<void>;
189
+ 'devtoolskit:internal:terminals:updated': () => Promise<void>;
190
+ }
191
+ interface DevToolsRpcSharedStates {
192
+ 'devtoolskit:internal:docks': DevToolsDockEntry[];
193
+ 'devtoolskit:internal:user-settings': DevToolsDocksUserSettings;
194
+ }
195
+ }
196
+ //#endregion
10
197
  //#region src/node/plugins/index.d.ts
11
198
  interface DevToolsOptions {
12
199
  /**
@@ -16,21 +203,23 @@ interface DevToolsOptions {
16
203
  */
17
204
  builtinDevTools?: boolean;
18
205
  }
19
- declare function DevTools(options?: DevToolsOptions): Plugin[];
206
+ declare function DevTools(options?: DevToolsOptions): Promise<Plugin[]>;
20
207
  //#endregion
21
208
  //#region src/node/ws.d.ts
22
209
  interface CreateWsServerOptions {
23
210
  cwd: string;
24
211
  portWebSocket?: number;
212
+ hostWebSocket: string;
25
213
  base?: string;
26
214
  context: DevToolsNodeContext;
27
215
  }
28
216
  //#endregion
29
217
  //#region src/node/server.d.ts
30
218
  declare function createDevToolsMiddleware(options: CreateWsServerOptions): Promise<{
31
- h3: h30.App;
32
- middleware: h30.NodeListener;
33
- rpc: birpc0.BirpcGroup<any, any>;
219
+ h3: h3.App;
220
+ rpc: birpc.BirpcGroup<_vitejs_devtools_kit0.DevToolsRpcClientFunctions, _vitejs_devtools_kit0.DevToolsRpcServerFunctions, false>;
221
+ middleware: h3.NodeListener;
222
+ getConnectionMeta: () => Promise<_vitejs_devtools_kit0.ConnectionMeta>;
34
223
  }>;
35
224
  //#endregion
36
225
  export { DevTools, createDevToolsContext, createDevToolsMiddleware };
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import { DevTools, createDevToolsContext, createDevToolsMiddleware } from "./plugins-DDjui9Ga.js";
2
- import "./dirs-B7dOX6eI.js";
1
+ import { a as createDevToolsContext, n as createDevToolsMiddleware, t as DevTools } from "./plugins-BbzqUdpu.js";
3
2
 
4
3
  export { DevTools, createDevToolsContext, createDevToolsMiddleware };