@vitejs/devtools-kit 0.0.0-alpha.1 → 0.0.0-alpha.10
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 +20 -2
- package/dist/client.js +4 -5
- package/dist/{rpc-ls6mUIa2.d.ts → index-BtaHil_c.d.ts} +58 -20
- 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-BtaHil_c.js";
|
|
2
2
|
import { WebSocketRpcClientOptions } from "@vitejs/devtools-rpc/presets/ws/client";
|
|
3
3
|
import { BirpcOptions, BirpcReturn } from "birpc";
|
|
4
4
|
|
|
@@ -9,9 +9,27 @@ interface DevToolsRpcClientOptions {
|
|
|
9
9
|
wsOptions?: Partial<WebSocketRpcClientOptions>;
|
|
10
10
|
rpcOptions?: Partial<BirpcOptions<DevToolsRpcServerFunctions>>;
|
|
11
11
|
}
|
|
12
|
+
interface ImportScriptContext {
|
|
13
|
+
/**
|
|
14
|
+
* The dock entry info of the current dock item
|
|
15
|
+
*/
|
|
16
|
+
dockEntry: DevToolsDockEntry;
|
|
17
|
+
/**
|
|
18
|
+
* The current state of the dock
|
|
19
|
+
*/
|
|
20
|
+
dockState: 'active' | 'inactive';
|
|
21
|
+
/**
|
|
22
|
+
* Function to hide the panel, if applicable
|
|
23
|
+
*/
|
|
24
|
+
hidePanel: () => void;
|
|
25
|
+
/**
|
|
26
|
+
* The panel element to mount into, if applicable
|
|
27
|
+
*/
|
|
28
|
+
elPanel?: HTMLElement | null;
|
|
29
|
+
}
|
|
12
30
|
declare function getDevToolsRpcClient(options?: DevToolsRpcClientOptions): Promise<{
|
|
13
31
|
connectionMeta: ConnectionMeta;
|
|
14
32
|
rpc: BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>;
|
|
15
33
|
}>;
|
|
16
34
|
//#endregion
|
|
17
|
-
export { DevToolsRpcClientOptions, getDevToolsRpcClient };
|
|
35
|
+
export { DevToolsRpcClientOptions, ImportScriptContext, 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,14 +17,43 @@ 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
|
+
}
|
|
23
40
|
interface DevToolsDockEntryBase {
|
|
24
41
|
id: string;
|
|
25
42
|
title: string;
|
|
26
43
|
icon: string;
|
|
27
44
|
}
|
|
45
|
+
interface ClientScriptEntry {
|
|
46
|
+
/**
|
|
47
|
+
* The filepath or module name to import from
|
|
48
|
+
*/
|
|
49
|
+
importFrom: string;
|
|
50
|
+
/**
|
|
51
|
+
* The name to import the module as
|
|
52
|
+
*
|
|
53
|
+
* @default 'default'
|
|
54
|
+
*/
|
|
55
|
+
importName?: string;
|
|
56
|
+
}
|
|
28
57
|
interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
29
58
|
type: 'iframe';
|
|
30
59
|
url: string;
|
|
@@ -34,21 +63,24 @@ interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
|
34
63
|
* When not provided, it would be treated as a unique frame.
|
|
35
64
|
*/
|
|
36
65
|
frameId?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Optional script to import into the iframe
|
|
68
|
+
*/
|
|
69
|
+
import?: ClientScriptEntry;
|
|
37
70
|
}
|
|
38
71
|
interface DevToolsViewWebComponent extends DevToolsDockEntryBase {
|
|
39
72
|
type: 'webcomponent';
|
|
40
|
-
|
|
41
|
-
import: string;
|
|
73
|
+
import: ClientScriptEntry;
|
|
42
74
|
}
|
|
43
75
|
interface DevToolsViewAction extends DevToolsDockEntryBase {
|
|
44
76
|
type: 'action';
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
77
|
+
import: ClientScriptEntry;
|
|
78
|
+
}
|
|
79
|
+
interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
80
|
+
type: 'custom-render';
|
|
81
|
+
import: ClientScriptEntry;
|
|
50
82
|
}
|
|
51
|
-
type DevToolsDockEntry = DevToolsViewIframe | DevToolsViewWebComponent | DevToolsViewAction;
|
|
83
|
+
type DevToolsDockEntry = DevToolsViewIframe | DevToolsViewWebComponent | DevToolsViewAction | DevToolsViewCustomRender;
|
|
52
84
|
//#endregion
|
|
53
85
|
//#region src/types/vite-plugin.d.ts
|
|
54
86
|
interface DevToolsCapabilities {
|
|
@@ -69,16 +101,11 @@ interface DevToolsNodeContext {
|
|
|
69
101
|
readonly viteServer?: ViteDevServer;
|
|
70
102
|
rpc: RpcFunctionsHost;
|
|
71
103
|
docks: DevToolsDockHost;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
hostStatic: (baseUrl: string, distDir: string) => void;
|
|
78
|
-
staticDirs: {
|
|
79
|
-
baseUrl: string;
|
|
80
|
-
distDir: string;
|
|
81
|
-
}[];
|
|
104
|
+
views: DevToolsViewHost;
|
|
105
|
+
utils: DevToolsNodeUtils;
|
|
106
|
+
}
|
|
107
|
+
interface DevToolsNodeUtils {
|
|
108
|
+
clientEntryFromSimpleFunction: (fn: () => void) => ClientScriptEntry;
|
|
82
109
|
}
|
|
83
110
|
interface ConnectionMeta {
|
|
84
111
|
backend: 'websocket' | 'static';
|
|
@@ -98,6 +125,7 @@ interface RpcFunctionsHost {
|
|
|
98
125
|
readonly functions: DevToolsRpcServerFunctions;
|
|
99
126
|
readonly definitions: Map<string, RpcFunctionDefinition<string, any, any, any>>;
|
|
100
127
|
register: (fn: RpcFunctionDefinition<string, any, any, any>) => void;
|
|
128
|
+
update: (fn: RpcFunctionDefinition<string, any, any, any>) => void;
|
|
101
129
|
}
|
|
102
130
|
interface RpcFunctionSetupResult<ARGS extends any[], RETURN = void> {
|
|
103
131
|
handler: (...args: ARGS) => RETURN;
|
|
@@ -115,4 +143,14 @@ type RpcDefinitionsFilter<T extends readonly RpcFunctionDefinition<any, any, any
|
|
|
115
143
|
type: Type;
|
|
116
144
|
} ? T[K] : never };
|
|
117
145
|
//#endregion
|
|
118
|
-
|
|
146
|
+
//#region src/types/vite-augment.d.ts
|
|
147
|
+
declare module 'vite' {
|
|
148
|
+
interface Plugin {
|
|
149
|
+
devtools?: DevToolsPluginOptions;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
interface PluginWithDevTools extends Plugin {
|
|
153
|
+
devtools?: DevToolsPluginOptions;
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
export { DevToolsViewWebComponent as C, DevToolsRpcServerFunctions as D, DevToolsRpcClientFunctions as E, DevToolsViewIframe as S, Thenable as T, DevToolsDockEntryBase as _, RpcDefinitionsToFunctions as a, DevToolsViewCustomRender 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, DevToolsDockHost as v, EntriesToObject as w, DevToolsViewHost as x, DevToolsViewAction as y };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Plugin } from "vite";
|
|
1
|
+
import { C as DevToolsViewWebComponent, D as DevToolsRpcServerFunctions, E as DevToolsRpcClientFunctions, S as DevToolsViewIframe, T as Thenable, _ as DevToolsDockEntryBase, a as RpcDefinitionsToFunctions, b as DevToolsViewCustomRender, 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 DevToolsDockHost, w as EntriesToObject, x as DevToolsViewHost, y as DevToolsViewAction } from "./index-BtaHil_c.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, DevToolsViewIframe, DevToolsViewWebComponent, EntriesToObject, PluginWithDevTools, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionDefinition, RpcFunctionSetupResult, RpcFunctionType, RpcFunctionsHost, Thenable, defineRpcFunction, getRpcHandler };
|
|
7
|
+
export { BirpcFn, BirpcReturn, ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockHost, DevToolsNodeContext, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, DevToolsViewWebComponent, 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.10",
|
|
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.10"
|
|
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",
|