@vitejs/devtools-kit 0.0.0-alpha.1 → 0.0.0-alpha.11
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.ts +30 -2
- package/dist/client.js +4 -5
- package/dist/{rpc-ls6mUIa2.d.ts → index-CQIA5hSl.d.ts} +73 -24
- package/dist/index.d.ts +2 -13
- package/package.json +6 -6
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as DevToolsRpcServerFunctions, E as DevToolsRpcClientFunctions, g as DevToolsDockEntry, u as ConnectionMeta } from "./index-CQIA5hSl.js";
|
|
2
2
|
import { WebSocketRpcClientOptions } from "@vitejs/devtools-rpc/presets/ws/client";
|
|
3
3
|
import { BirpcOptions, BirpcReturn } from "birpc";
|
|
4
4
|
|
|
@@ -9,9 +9,37 @@ interface DevToolsRpcClientOptions {
|
|
|
9
9
|
wsOptions?: Partial<WebSocketRpcClientOptions>;
|
|
10
10
|
rpcOptions?: Partial<BirpcOptions<DevToolsRpcServerFunctions>>;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Context for client scripts running in dock entries
|
|
14
|
+
*/
|
|
15
|
+
interface DockClientScriptContext {
|
|
16
|
+
/**
|
|
17
|
+
* The dock entry info of the current dock item
|
|
18
|
+
*/
|
|
19
|
+
dockEntry: DevToolsDockEntry;
|
|
20
|
+
/**
|
|
21
|
+
* The current state of the dock
|
|
22
|
+
*/
|
|
23
|
+
dockState: 'active' | 'inactive';
|
|
24
|
+
/**
|
|
25
|
+
* Type of the client environment
|
|
26
|
+
*
|
|
27
|
+
* 'embedded' - running inside an embedded floating panel
|
|
28
|
+
* 'standalone' - running inside a standlone window (no user app)
|
|
29
|
+
*/
|
|
30
|
+
clientType: 'embedded' | 'standalone';
|
|
31
|
+
/**
|
|
32
|
+
* Function to hide the panel, if applicable
|
|
33
|
+
*/
|
|
34
|
+
hidePanel: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* The panel element to mount into, if applicable
|
|
37
|
+
*/
|
|
38
|
+
elPanel?: HTMLElement | null;
|
|
39
|
+
}
|
|
12
40
|
declare function getDevToolsRpcClient(options?: DevToolsRpcClientOptions): Promise<{
|
|
13
41
|
connectionMeta: ConnectionMeta;
|
|
14
42
|
rpc: BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>;
|
|
15
43
|
}>;
|
|
16
44
|
//#endregion
|
|
17
|
-
export { DevToolsRpcClientOptions, getDevToolsRpcClient };
|
|
45
|
+
export { DevToolsRpcClientOptions, DockClientScriptContext, getDevToolsRpcClient };
|
package/dist/client.js
CHANGED
|
@@ -7,23 +7,22 @@ function isNumeric(str) {
|
|
|
7
7
|
return `${+str}` === `${str}`;
|
|
8
8
|
}
|
|
9
9
|
async function getDevToolsRpcClient(options = {}) {
|
|
10
|
-
const { baseURL = "/
|
|
10
|
+
const { baseURL = "/.devtools/" } = options;
|
|
11
11
|
const urls = Array.isArray(baseURL) ? baseURL : [baseURL];
|
|
12
12
|
let connectionMeta = options.connectionMeta;
|
|
13
13
|
if (!connectionMeta) {
|
|
14
14
|
const errors = [];
|
|
15
|
-
for (const url
|
|
16
|
-
connectionMeta = await fetch(`${url
|
|
15
|
+
for (const url of urls) try {
|
|
16
|
+
connectionMeta = await fetch(`${url}.vdt-connection.json`).then((r) => r.json());
|
|
17
17
|
break;
|
|
18
18
|
} catch (e) {
|
|
19
19
|
errors.push(e);
|
|
20
20
|
}
|
|
21
21
|
if (!connectionMeta) throw new Error(`Failed to get connection meta from ${urls.join(", ")}`, { cause: errors });
|
|
22
22
|
}
|
|
23
|
-
const url = isNumeric(connectionMeta.websocket) ? `${location.protocol.replace("http", "ws")}//${location.hostname}:${connectionMeta.websocket}` : connectionMeta.websocket;
|
|
24
23
|
const rpc = createRpcClient({}, {
|
|
25
24
|
preset: createWsRpcPreset({
|
|
26
|
-
url,
|
|
25
|
+
url: isNumeric(connectionMeta.websocket) ? `${location.protocol.replace("http", "ws")}//${location.hostname}:${connectionMeta.websocket}` : connectionMeta.websocket,
|
|
27
26
|
...options.wsOptions
|
|
28
27
|
}),
|
|
29
28
|
...options.rpcOptions
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BirpcFn, BirpcReturn as BirpcReturn$1 } from "birpc";
|
|
2
|
-
import { ResolvedConfig, ViteDevServer } from "vite";
|
|
2
|
+
import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/types/rpc-augments.d.ts
|
|
5
5
|
/**
|
|
@@ -17,13 +17,57 @@ type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/types/views.d.ts
|
|
19
19
|
interface DevToolsDockHost {
|
|
20
|
+
views: Map<string, DevToolsDockEntry>;
|
|
20
21
|
register: (entry: DevToolsDockEntry) => void;
|
|
22
|
+
update: (entry: DevToolsDockEntry) => void;
|
|
21
23
|
values: () => DevToolsDockEntry[];
|
|
22
24
|
}
|
|
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
|
+
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default';
|
|
23
41
|
interface DevToolsDockEntryBase {
|
|
24
42
|
id: string;
|
|
25
43
|
title: string;
|
|
26
|
-
icon: string
|
|
44
|
+
icon: string | {
|
|
45
|
+
light: string;
|
|
46
|
+
dark: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The default order of the entry in the dock.
|
|
50
|
+
* The higher the number the earlier it appears.
|
|
51
|
+
* @default 0
|
|
52
|
+
*/
|
|
53
|
+
defaultOrder?: number;
|
|
54
|
+
/**
|
|
55
|
+
* The category of the entry
|
|
56
|
+
* @default 'default'
|
|
57
|
+
*/
|
|
58
|
+
category?: DevToolsDockEntryCategory;
|
|
59
|
+
}
|
|
60
|
+
interface ClientScriptEntry {
|
|
61
|
+
/**
|
|
62
|
+
* The filepath or module name to import from
|
|
63
|
+
*/
|
|
64
|
+
importFrom: string;
|
|
65
|
+
/**
|
|
66
|
+
* The name to import the module as
|
|
67
|
+
*
|
|
68
|
+
* @default 'default'
|
|
69
|
+
*/
|
|
70
|
+
importName?: string;
|
|
27
71
|
}
|
|
28
72
|
interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
29
73
|
type: 'iframe';
|
|
@@ -34,21 +78,20 @@ interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
|
34
78
|
* When not provided, it would be treated as a unique frame.
|
|
35
79
|
*/
|
|
36
80
|
frameId?: string;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
import: string;
|
|
81
|
+
/**
|
|
82
|
+
* Optional client script to import into the iframe
|
|
83
|
+
*/
|
|
84
|
+
clientScript?: ClientScriptEntry;
|
|
42
85
|
}
|
|
43
86
|
interface DevToolsViewAction extends DevToolsDockEntryBase {
|
|
44
87
|
type: 'action';
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
88
|
+
action: ClientScriptEntry;
|
|
89
|
+
}
|
|
90
|
+
interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
91
|
+
type: 'custom-render';
|
|
92
|
+
renderer: ClientScriptEntry;
|
|
50
93
|
}
|
|
51
|
-
type DevToolsDockEntry = DevToolsViewIframe |
|
|
94
|
+
type DevToolsDockEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender;
|
|
52
95
|
//#endregion
|
|
53
96
|
//#region src/types/vite-plugin.d.ts
|
|
54
97
|
interface DevToolsCapabilities {
|
|
@@ -69,16 +112,11 @@ interface DevToolsNodeContext {
|
|
|
69
112
|
readonly viteServer?: ViteDevServer;
|
|
70
113
|
rpc: RpcFunctionsHost;
|
|
71
114
|
docks: DevToolsDockHost;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
hostStatic: (baseUrl: string, distDir: string) => void;
|
|
78
|
-
staticDirs: {
|
|
79
|
-
baseUrl: string;
|
|
80
|
-
distDir: string;
|
|
81
|
-
}[];
|
|
115
|
+
views: DevToolsViewHost;
|
|
116
|
+
utils: DevToolsNodeUtils;
|
|
117
|
+
}
|
|
118
|
+
interface DevToolsNodeUtils {
|
|
119
|
+
clientEntryFromSimpleFunction: (fn: () => void) => ClientScriptEntry;
|
|
82
120
|
}
|
|
83
121
|
interface ConnectionMeta {
|
|
84
122
|
backend: 'websocket' | 'static';
|
|
@@ -98,6 +136,7 @@ interface RpcFunctionsHost {
|
|
|
98
136
|
readonly functions: DevToolsRpcServerFunctions;
|
|
99
137
|
readonly definitions: Map<string, RpcFunctionDefinition<string, any, any, any>>;
|
|
100
138
|
register: (fn: RpcFunctionDefinition<string, any, any, any>) => void;
|
|
139
|
+
update: (fn: RpcFunctionDefinition<string, any, any, any>) => void;
|
|
101
140
|
}
|
|
102
141
|
interface RpcFunctionSetupResult<ARGS extends any[], RETURN = void> {
|
|
103
142
|
handler: (...args: ARGS) => RETURN;
|
|
@@ -115,4 +154,14 @@ type RpcDefinitionsFilter<T extends readonly RpcFunctionDefinition<any, any, any
|
|
|
115
154
|
type: Type;
|
|
116
155
|
} ? T[K] : never };
|
|
117
156
|
//#endregion
|
|
118
|
-
|
|
157
|
+
//#region src/types/vite-augment.d.ts
|
|
158
|
+
declare module 'vite' {
|
|
159
|
+
interface Plugin {
|
|
160
|
+
devtools?: DevToolsPluginOptions;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
interface PluginWithDevTools extends Plugin {
|
|
164
|
+
devtools?: DevToolsPluginOptions;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
export { DevToolsViewIframe as C, DevToolsRpcServerFunctions as D, DevToolsRpcClientFunctions as E, DevToolsViewHost as S, Thenable as T, DevToolsDockEntryBase as _, RpcDefinitionsToFunctions as a, DevToolsViewAction as b, RpcFunctionType as c, DevToolsCapabilities as d, DevToolsNodeContext as f, DevToolsDockEntry as g, ClientScriptEntry as h, RpcDefinitionsFilter as i, RpcFunctionsHost as l, DevToolsPluginOptions as m, BirpcFn as n, RpcFunctionDefinition as o, DevToolsNodeUtils as p, BirpcReturn$1 as r, RpcFunctionSetupResult as s, PluginWithDevTools as t, ConnectionMeta as u, DevToolsDockEntryCategory as v, EntriesToObject as w, DevToolsViewCustomRender as x, DevToolsDockHost as y };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Plugin } from "vite";
|
|
1
|
+
import { C as DevToolsViewIframe, D as DevToolsRpcServerFunctions, E as DevToolsRpcClientFunctions, S as DevToolsViewHost, T as Thenable, _ as DevToolsDockEntryBase, a as RpcDefinitionsToFunctions, b as DevToolsViewAction, c as RpcFunctionType, d as DevToolsCapabilities, f as DevToolsNodeContext, g as DevToolsDockEntry, h as ClientScriptEntry, i as RpcDefinitionsFilter, l as RpcFunctionsHost, m as DevToolsPluginOptions, n as BirpcFn, o as RpcFunctionDefinition, p as DevToolsNodeUtils, r as BirpcReturn, s as RpcFunctionSetupResult, t as PluginWithDevTools, u as ConnectionMeta, v as DevToolsDockEntryCategory, w as EntriesToObject, x as DevToolsViewCustomRender, y as DevToolsDockHost } from "./index-CQIA5hSl.js";
|
|
3
2
|
|
|
4
|
-
//#region src/types/vite-augment.d.ts
|
|
5
|
-
declare module 'vite' {
|
|
6
|
-
interface Plugin {
|
|
7
|
-
devtools?: DevToolsPluginOptions;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
interface PluginWithDevTools extends Plugin {
|
|
11
|
-
devtools?: DevToolsPluginOptions;
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
3
|
//#region src/utils/rpc.d.ts
|
|
15
4
|
declare function defineRpcFunction<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN>): RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN>;
|
|
16
5
|
declare function getRpcHandler<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN>, context: DevToolsNodeContext): Promise<(...args: ARGS) => RETURN>;
|
|
17
6
|
//#endregion
|
|
18
|
-
export { BirpcFn, BirpcReturn, ConnectionMeta, DevToolsCapabilities, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockHost, DevToolsNodeContext, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction,
|
|
7
|
+
export { BirpcFn, BirpcReturn, ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockHost, DevToolsNodeContext, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, EntriesToObject, PluginWithDevTools, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionDefinition, RpcFunctionSetupResult, RpcFunctionType, RpcFunctionsHost, Thenable, defineRpcFunction, getRpcHandler };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/devtools-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-alpha.
|
|
4
|
+
"version": "0.0.0-alpha.11",
|
|
5
5
|
"description": "Vite DevTools Kit",
|
|
6
6
|
"author": "VoidZero Inc.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/vitejs/devtools#readme",
|
|
9
9
|
"repository": {
|
|
10
|
-
"directory": "packages/
|
|
10
|
+
"directory": "packages/kit",
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git+https://github.com/vitejs/devtools.git"
|
|
13
13
|
},
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"vite": "npm:rolldown-vite@^7.1.
|
|
33
|
+
"vite": "npm:rolldown-vite@^7.1.20"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"birpc": "^2.6.1",
|
|
37
|
-
"@vitejs/devtools-rpc": "0.0.0-alpha.
|
|
37
|
+
"@vitejs/devtools-rpc": "0.0.0-alpha.11"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"tsdown": "^0.15.
|
|
41
|
-
"vite": "npm:rolldown-vite@^7.1.
|
|
40
|
+
"tsdown": "^0.15.12",
|
|
41
|
+
"vite": "npm:rolldown-vite@^7.1.20"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsdown",
|