@vitejs/devtools-kit 0.0.0-alpha.6 → 0.0.0-alpha.7
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 +1 -1
- package/dist/client.js +3 -4
- package/dist/{rpc-DVF6QKW4.d.ts → index-BtaHil_c.d.ts} +42 -10
- package/dist/index.d.ts +2 -13
- package/package.json +5 -5
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as DevToolsRpcServerFunctions, E as DevToolsRpcClientFunctions, 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
|
|
package/dist/client.js
CHANGED
|
@@ -12,18 +12,17 @@ async function getDevToolsRpcClient(options = {}) {
|
|
|
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,7 +17,9 @@ 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
|
}
|
|
23
25
|
interface DevToolsViewHost {
|
|
@@ -40,6 +42,18 @@ interface DevToolsDockEntryBase {
|
|
|
40
42
|
title: string;
|
|
41
43
|
icon: string;
|
|
42
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
|
+
}
|
|
43
57
|
interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
44
58
|
type: 'iframe';
|
|
45
59
|
url: string;
|
|
@@ -49,21 +63,24 @@ interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
|
49
63
|
* When not provided, it would be treated as a unique frame.
|
|
50
64
|
*/
|
|
51
65
|
frameId?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Optional script to import into the iframe
|
|
68
|
+
*/
|
|
69
|
+
import?: ClientScriptEntry;
|
|
52
70
|
}
|
|
53
71
|
interface DevToolsViewWebComponent extends DevToolsDockEntryBase {
|
|
54
72
|
type: 'webcomponent';
|
|
55
|
-
|
|
56
|
-
import: string;
|
|
73
|
+
import: ClientScriptEntry;
|
|
57
74
|
}
|
|
58
75
|
interface DevToolsViewAction extends DevToolsDockEntryBase {
|
|
59
76
|
type: 'action';
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @default 'default'
|
|
63
|
-
*/
|
|
64
|
-
importName?: string;
|
|
77
|
+
import: ClientScriptEntry;
|
|
65
78
|
}
|
|
66
|
-
|
|
79
|
+
interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
80
|
+
type: 'custom-render';
|
|
81
|
+
import: ClientScriptEntry;
|
|
82
|
+
}
|
|
83
|
+
type DevToolsDockEntry = DevToolsViewIframe | DevToolsViewWebComponent | DevToolsViewAction | DevToolsViewCustomRender;
|
|
67
84
|
//#endregion
|
|
68
85
|
//#region src/types/vite-plugin.d.ts
|
|
69
86
|
interface DevToolsCapabilities {
|
|
@@ -85,6 +102,10 @@ interface DevToolsNodeContext {
|
|
|
85
102
|
rpc: RpcFunctionsHost;
|
|
86
103
|
docks: DevToolsDockHost;
|
|
87
104
|
views: DevToolsViewHost;
|
|
105
|
+
utils: DevToolsNodeUtils;
|
|
106
|
+
}
|
|
107
|
+
interface DevToolsNodeUtils {
|
|
108
|
+
clientEntryFromSimpleFunction: (fn: () => void) => ClientScriptEntry;
|
|
88
109
|
}
|
|
89
110
|
interface ConnectionMeta {
|
|
90
111
|
backend: 'websocket' | 'static';
|
|
@@ -104,6 +125,7 @@ interface RpcFunctionsHost {
|
|
|
104
125
|
readonly functions: DevToolsRpcServerFunctions;
|
|
105
126
|
readonly definitions: Map<string, RpcFunctionDefinition<string, any, any, any>>;
|
|
106
127
|
register: (fn: RpcFunctionDefinition<string, any, any, any>) => void;
|
|
128
|
+
update: (fn: RpcFunctionDefinition<string, any, any, any>) => void;
|
|
107
129
|
}
|
|
108
130
|
interface RpcFunctionSetupResult<ARGS extends any[], RETURN = void> {
|
|
109
131
|
handler: (...args: ARGS) => RETURN;
|
|
@@ -121,4 +143,14 @@ type RpcDefinitionsFilter<T extends readonly RpcFunctionDefinition<any, any, any
|
|
|
121
143
|
type: Type;
|
|
122
144
|
} ? T[K] : never };
|
|
123
145
|
//#endregion
|
|
124
|
-
|
|
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, DevToolsViewHost, 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,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.7",
|
|
5
5
|
"description": "Vite DevTools Kit",
|
|
6
6
|
"author": "VoidZero Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -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.7"
|
|
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",
|