@vitejs/devtools-kit 0.0.0-alpha.17 → 0.0.0-alpha.18
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/client.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as DockEntryState, c as DocksContext, d as ClientRpcReturn, f as DevToolsRpcClient, i as DockClientType, l as DocksEntriesContext, m as getDevToolsRpcClient, n as DevToolsClientContext, o as DockEntryStateEvents, p as DevToolsRpcClientOptions, r as DevToolsClientRpcHost, s as DockPanelStorage, t as DockClientScriptContext, u as DocksPanelContext } from "./index-
|
|
1
|
+
import { a as DockEntryState, c as DocksContext, d as ClientRpcReturn, f as DevToolsRpcClient, i as DockClientType, l as DocksEntriesContext, m as getDevToolsRpcClient, n as DevToolsClientContext, o as DockEntryStateEvents, p as DevToolsRpcClientOptions, r as DevToolsClientRpcHost, s as DockPanelStorage, t as DockClientScriptContext, u as DocksPanelContext } from "./index-C7lGA5jg.mjs";
|
|
2
2
|
export { ClientRpcReturn, DevToolsClientContext, DevToolsClientRpcHost, DevToolsRpcClient, DevToolsRpcClientOptions, DockClientScriptContext, DockClientType, DockEntryState, DockEntryStateEvents, DockPanelStorage, DocksContext, DocksEntriesContext, DocksPanelContext, getDevToolsRpcClient };
|
package/dist/client.mjs
CHANGED
|
@@ -3,23 +3,36 @@ import { createRpcClient } from "@vitejs/devtools-rpc";
|
|
|
3
3
|
import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/client";
|
|
4
4
|
|
|
5
5
|
//#region src/client/rpc.ts
|
|
6
|
+
const CONNECTION_META_KEY = "__VITE_DEVTOOLS_CONNECTION_META__";
|
|
6
7
|
function isNumeric(str) {
|
|
7
8
|
if (str == null) return false;
|
|
8
9
|
return `${+str}` === `${str}`;
|
|
9
10
|
}
|
|
11
|
+
function findConnectionMetaFromWindows() {
|
|
12
|
+
const getters = [
|
|
13
|
+
() => window[CONNECTION_META_KEY],
|
|
14
|
+
() => globalThis[CONNECTION_META_KEY],
|
|
15
|
+
() => parent.window[CONNECTION_META_KEY]
|
|
16
|
+
];
|
|
17
|
+
for (const getter of getters) try {
|
|
18
|
+
const value = getter();
|
|
19
|
+
if (value) return value;
|
|
20
|
+
} catch {}
|
|
21
|
+
}
|
|
10
22
|
async function getDevToolsRpcClient(options = {}) {
|
|
11
23
|
const { baseURL = "/.devtools/", rpcOptions = {} } = options;
|
|
12
|
-
const
|
|
13
|
-
let connectionMeta = options.connectionMeta;
|
|
24
|
+
const bases = Array.isArray(baseURL) ? baseURL : [baseURL];
|
|
25
|
+
let connectionMeta = options.connectionMeta || findConnectionMetaFromWindows();
|
|
14
26
|
if (!connectionMeta) {
|
|
15
27
|
const errors = [];
|
|
16
|
-
for (const
|
|
17
|
-
connectionMeta = await fetch(`${
|
|
28
|
+
for (const base of bases) try {
|
|
29
|
+
connectionMeta = await fetch(`${base}.vdt-connection.json`).then((r) => r.json());
|
|
30
|
+
globalThis[CONNECTION_META_KEY] = connectionMeta;
|
|
18
31
|
break;
|
|
19
32
|
} catch (e) {
|
|
20
33
|
errors.push(e);
|
|
21
34
|
}
|
|
22
|
-
if (!connectionMeta) throw new Error(`Failed to get connection meta from ${
|
|
35
|
+
if (!connectionMeta) throw new Error(`Failed to get connection meta from ${bases.join(", ")}`, { cause: errors });
|
|
23
36
|
}
|
|
24
37
|
const url = isNumeric(connectionMeta.websocket) ? `${location.protocol.replace("http", "ws")}//${location.hostname}:${connectionMeta.websocket}` : connectionMeta.websocket;
|
|
25
38
|
const context = { rpc: void 0 };
|
|
@@ -5,46 +5,22 @@ import { Raw } from "vue";
|
|
|
5
5
|
import { BirpcGroup, BirpcOptions, BirpcReturn } from "birpc";
|
|
6
6
|
import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
|
|
7
7
|
|
|
8
|
-
//#region src/types/
|
|
9
|
-
/**
|
|
10
|
-
* To be extended
|
|
11
|
-
*/
|
|
12
|
-
interface DevToolsRpcClientFunctions {}
|
|
13
|
-
/**
|
|
14
|
-
* To be extended
|
|
15
|
-
*/
|
|
16
|
-
interface DevToolsRpcServerFunctions {}
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/types/views.d.ts
|
|
8
|
+
//#region src/types/docks.d.ts
|
|
19
9
|
interface DevToolsDockHost {
|
|
20
10
|
views: Map<string, DevToolsDockEntry>;
|
|
21
11
|
register: (entry: DevToolsDockEntry) => void;
|
|
22
12
|
update: (entry: DevToolsDockEntry) => void;
|
|
23
13
|
values: () => DevToolsDockEntry[];
|
|
24
14
|
}
|
|
25
|
-
interface DevToolsViewHost {
|
|
26
|
-
/**
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
buildStaticDirs: {
|
|
30
|
-
baseUrl: string;
|
|
31
|
-
distDir: string;
|
|
32
|
-
}[];
|
|
33
|
-
/**
|
|
34
|
-
* Helper to host static files
|
|
35
|
-
* - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files
|
|
36
|
-
* - In `build` mode, it will copy the static files to the dist directory
|
|
37
|
-
*/
|
|
38
|
-
hostStatic: (baseUrl: string, distDir: string) => void;
|
|
39
|
-
}
|
|
40
15
|
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default';
|
|
16
|
+
type DevToolsDockEntryIcon = string | {
|
|
17
|
+
light: string;
|
|
18
|
+
dark: string;
|
|
19
|
+
};
|
|
41
20
|
interface DevToolsDockEntryBase {
|
|
42
21
|
id: string;
|
|
43
22
|
title: string;
|
|
44
|
-
icon:
|
|
45
|
-
light: string;
|
|
46
|
-
dark: string;
|
|
47
|
-
};
|
|
23
|
+
icon: DevToolsDockEntryIcon;
|
|
48
24
|
/**
|
|
49
25
|
* The default order of the entry in the dock.
|
|
50
26
|
* The higher the number the earlier it appears.
|
|
@@ -83,6 +59,20 @@ interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
|
83
59
|
*/
|
|
84
60
|
clientScript?: ClientScriptEntry;
|
|
85
61
|
}
|
|
62
|
+
type DevToolsViewLauncherStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
63
|
+
interface DevToolsViewLauncher extends DevToolsDockEntryBase {
|
|
64
|
+
type: 'launcher';
|
|
65
|
+
launcher: {
|
|
66
|
+
icon?: DevToolsDockEntryIcon;
|
|
67
|
+
title: string;
|
|
68
|
+
status?: DevToolsViewLauncherStatus;
|
|
69
|
+
error?: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
buttonStart?: string;
|
|
72
|
+
buttonLoading?: string;
|
|
73
|
+
onLaunch: () => Promise<void>;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
86
76
|
interface DevToolsViewAction extends DevToolsDockEntryBase {
|
|
87
77
|
type: 'action';
|
|
88
78
|
action: ClientScriptEntry;
|
|
@@ -91,7 +81,34 @@ interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
|
91
81
|
type: 'custom-render';
|
|
92
82
|
renderer: ClientScriptEntry;
|
|
93
83
|
}
|
|
94
|
-
type DevToolsDockEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender;
|
|
84
|
+
type DevToolsDockEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/types/rpc-augments.d.ts
|
|
87
|
+
/**
|
|
88
|
+
* To be extended
|
|
89
|
+
*/
|
|
90
|
+
interface DevToolsRpcClientFunctions {}
|
|
91
|
+
/**
|
|
92
|
+
* To be extended
|
|
93
|
+
*/
|
|
94
|
+
interface DevToolsRpcServerFunctions {}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/types/views.d.ts
|
|
97
|
+
interface DevToolsViewHost {
|
|
98
|
+
/**
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
buildStaticDirs: {
|
|
102
|
+
baseUrl: string;
|
|
103
|
+
distDir: string;
|
|
104
|
+
}[];
|
|
105
|
+
/**
|
|
106
|
+
* Helper to host static files
|
|
107
|
+
* - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files
|
|
108
|
+
* - In `build` mode, it will copy the static files to the dist directory
|
|
109
|
+
*/
|
|
110
|
+
hostStatic: (baseUrl: string, distDir: string) => void;
|
|
111
|
+
}
|
|
95
112
|
//#endregion
|
|
96
113
|
//#region src/types/vite-plugin.d.ts
|
|
97
114
|
interface DevToolsCapabilities {
|
|
@@ -185,7 +202,7 @@ interface DocksContext extends DevToolsClientContext {
|
|
|
185
202
|
* Type of the client environment
|
|
186
203
|
*
|
|
187
204
|
* 'embedded' - running inside an embedded floating panel
|
|
188
|
-
* 'standalone' - running inside a
|
|
205
|
+
* 'standalone' - running inside a standalone window (no user app)
|
|
189
206
|
*/
|
|
190
207
|
readonly clientType: 'embedded' | 'standalone';
|
|
191
208
|
/**
|
|
@@ -209,7 +226,8 @@ interface DocksPanelContext {
|
|
|
209
226
|
readonly isVertical: boolean;
|
|
210
227
|
}
|
|
211
228
|
interface DocksEntriesContext {
|
|
212
|
-
|
|
229
|
+
selectedId: string | null;
|
|
230
|
+
readonly selected: DevToolsDockEntry | null;
|
|
213
231
|
entries: DevToolsDockEntry[];
|
|
214
232
|
entryToStateMap: Map<string, DockEntryState>;
|
|
215
233
|
/**
|
|
@@ -251,4 +269,4 @@ interface DockClientScriptContext extends DocksContext {
|
|
|
251
269
|
current: DockEntryState;
|
|
252
270
|
}
|
|
253
271
|
//#endregion
|
|
254
|
-
export {
|
|
272
|
+
export { DevToolsDockEntry as A, DevToolsNodeContext as C, DevToolsRpcClientFunctions as D, DevToolsViewHost as E, DevToolsViewAction as F, DevToolsViewCustomRender as I, DevToolsViewIframe as L, DevToolsDockEntryCategory as M, DevToolsDockEntryIcon as N, DevToolsRpcServerFunctions as O, DevToolsDockHost as P, DevToolsViewLauncher as R, DevToolsCapabilities as S, DevToolsPluginOptions as T, PluginWithDevTools as _, DockEntryState as a, RpcFunctionsHost as b, DocksContext as c, ClientRpcReturn as d, DevToolsRpcClient as f, RpcDefinitionsToFunctions as g, RpcDefinitionsFilter as h, DockClientType as i, DevToolsDockEntryBase as j, ClientScriptEntry as k, DocksEntriesContext as l, getDevToolsRpcClient as m, DevToolsClientContext as n, DockEntryStateEvents as o, DevToolsRpcClientOptions as p, DevToolsClientRpcHost as r, DockPanelStorage as s, DockClientScriptContext as t, DocksPanelContext as u, EntriesToObject as v, DevToolsNodeUtils as w, ConnectionMeta as x, Thenable as y, DevToolsViewLauncherStatus as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as DevToolsDockEntry, C as DevToolsNodeContext, D as DevToolsRpcClientFunctions, E as DevToolsViewHost, F as DevToolsViewAction, I as DevToolsViewCustomRender, L as DevToolsViewIframe, M as DevToolsDockEntryCategory, N as DevToolsDockEntryIcon, O as DevToolsRpcServerFunctions, P as DevToolsDockHost, R as DevToolsViewLauncher, S as DevToolsCapabilities, T as DevToolsPluginOptions, _ as PluginWithDevTools, b as RpcFunctionsHost, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, j as DevToolsDockEntryBase, k as ClientScriptEntry, v as EntriesToObject, w as DevToolsNodeUtils, x as ConnectionMeta, y as Thenable, z as DevToolsViewLauncherStatus } from "./index-C7lGA5jg.mjs";
|
|
2
2
|
import * as birpc_x0 from "birpc-x";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/rpc.d.ts
|
|
5
5
|
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>;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockHost, DevToolsNodeContext, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, EntriesToObject, PluginWithDevTools, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsHost, Thenable, defineRpcFunction };
|
|
7
|
+
export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsNodeContext, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, DevToolsViewLauncher, DevToolsViewLauncherStatus, EntriesToObject, PluginWithDevTools, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsHost, Thenable, defineRpcFunction };
|
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.
|
|
4
|
+
"version": "0.0.0-alpha.18",
|
|
5
5
|
"description": "Vite DevTools Kit",
|
|
6
6
|
"author": "VoidZero Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"birpc": "^2.8.0",
|
|
37
37
|
"birpc-x": "0.0.5",
|
|
38
38
|
"nanoevents": "^9.1.0",
|
|
39
|
-
"@vitejs/devtools-rpc": "0.0.0-alpha.
|
|
39
|
+
"@vitejs/devtools-rpc": "0.0.0-alpha.18"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"tsdown": "^0.16.1",
|