@vitejs/devtools-kit 0.0.0-alpha.12 → 0.0.0-alpha.14
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 +2 -45
- package/dist/client.js +1 -1
- package/dist/{index-CQIA5hSl.d.ts → index-6FiVMI6v.d.ts} +120 -10
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -14
- package/package.json +5 -4
package/dist/client.d.ts
CHANGED
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { BirpcOptions, BirpcReturn } from "birpc";
|
|
4
|
-
|
|
5
|
-
//#region src/client/index.d.ts
|
|
6
|
-
interface DevToolsRpcClientOptions {
|
|
7
|
-
connectionMeta?: ConnectionMeta;
|
|
8
|
-
baseURL?: string[];
|
|
9
|
-
wsOptions?: Partial<WebSocketRpcClientOptions>;
|
|
10
|
-
rpcOptions?: Partial<BirpcOptions<DevToolsRpcServerFunctions>>;
|
|
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
|
-
}
|
|
40
|
-
declare function getDevToolsRpcClient(options?: DevToolsRpcClientOptions): Promise<{
|
|
41
|
-
connectionMeta: ConnectionMeta;
|
|
42
|
-
rpc: BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>;
|
|
43
|
-
}>;
|
|
44
|
-
//#endregion
|
|
45
|
-
export { DevToolsRpcClientOptions, DockClientScriptContext, getDevToolsRpcClient };
|
|
1
|
+
import { a as DockPanelStorage, c as DocksPanelContext, d as getDevToolsRpcClient, i as DockEntryState, l as DevToolsRpcClient, n as DockClientScriptCurrent, o as DocksContext, r as DockClientType, s as DocksEntriesContext, t as DockClientScriptContext, u as DevToolsRpcClientOptions } from "./index-6FiVMI6v.js";
|
|
2
|
+
export { DevToolsRpcClient, DevToolsRpcClientOptions, DockClientScriptContext, DockClientScriptCurrent, DockClientType, DockEntryState, DockPanelStorage, DocksContext, DocksEntriesContext, DocksPanelContext, getDevToolsRpcClient };
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRpcClient } from "@vitejs/devtools-rpc";
|
|
2
2
|
import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/client";
|
|
3
3
|
|
|
4
|
-
//#region src/client/
|
|
4
|
+
//#region src/client/rpc.ts
|
|
5
5
|
function isNumeric(str) {
|
|
6
6
|
if (str == null) return false;
|
|
7
7
|
return `${+str}` === `${str}`;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RpcFunctionsCollectorBase } from "birpc-x";
|
|
2
|
+
import { WebSocketRpcClientOptions } from "@vitejs/devtools-rpc/presets/ws/client";
|
|
2
3
|
import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
|
|
4
|
+
import { BirpcFn, BirpcOptions, BirpcReturn, BirpcReturn as BirpcReturn$1 } from "birpc";
|
|
3
5
|
|
|
4
6
|
//#region src/types/rpc-augments.d.ts
|
|
5
7
|
/**
|
|
@@ -116,7 +118,13 @@ interface DevToolsNodeContext {
|
|
|
116
118
|
utils: DevToolsNodeUtils;
|
|
117
119
|
}
|
|
118
120
|
interface DevToolsNodeUtils {
|
|
119
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Create a simple client script from a function or stringified code
|
|
123
|
+
*
|
|
124
|
+
* @deprecated DO NOT USE. This is mostly for testing only. Please use a proper importable module instead.
|
|
125
|
+
* @experimental
|
|
126
|
+
*/
|
|
127
|
+
createSimpleClientScript: (fn: string | ((ctx: DockClientScriptContext) => void)) => ClientScriptEntry;
|
|
120
128
|
}
|
|
121
129
|
interface ConnectionMeta {
|
|
122
130
|
backend: 'websocket' | 'static';
|
|
@@ -131,13 +139,7 @@ interface ConnectionMeta {
|
|
|
131
139
|
* - query: A function that queries a resource
|
|
132
140
|
*/
|
|
133
141
|
type RpcFunctionType = 'static' | 'action' | 'query';
|
|
134
|
-
|
|
135
|
-
context: DevToolsNodeContext;
|
|
136
|
-
readonly functions: DevToolsRpcServerFunctions;
|
|
137
|
-
readonly definitions: Map<string, RpcFunctionDefinition<string, any, any, any>>;
|
|
138
|
-
register: (fn: RpcFunctionDefinition<string, any, any, any>) => void;
|
|
139
|
-
update: (fn: RpcFunctionDefinition<string, any, any, any>) => void;
|
|
140
|
-
}
|
|
142
|
+
type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext>;
|
|
141
143
|
interface RpcFunctionSetupResult<ARGS extends any[], RETURN = void> {
|
|
142
144
|
handler: (...args: ARGS) => RETURN;
|
|
143
145
|
}
|
|
@@ -164,4 +166,112 @@ interface PluginWithDevTools extends Plugin {
|
|
|
164
166
|
devtools?: DevToolsPluginOptions;
|
|
165
167
|
}
|
|
166
168
|
//#endregion
|
|
167
|
-
|
|
169
|
+
//#region src/client/rpc.d.ts
|
|
170
|
+
interface DevToolsRpcClientOptions {
|
|
171
|
+
connectionMeta?: ConnectionMeta;
|
|
172
|
+
baseURL?: string[];
|
|
173
|
+
wsOptions?: Partial<WebSocketRpcClientOptions>;
|
|
174
|
+
rpcOptions?: Partial<BirpcOptions<DevToolsRpcServerFunctions>>;
|
|
175
|
+
}
|
|
176
|
+
type DevToolsRpcClient = BirpcReturn<DevToolsRpcServerFunctions, DevToolsRpcClientFunctions>;
|
|
177
|
+
declare function getDevToolsRpcClient(options?: DevToolsRpcClientOptions): Promise<{
|
|
178
|
+
connectionMeta: ConnectionMeta;
|
|
179
|
+
rpc: DevToolsRpcClient;
|
|
180
|
+
}>;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/client/docks.d.ts
|
|
183
|
+
interface DockPanelStorage {
|
|
184
|
+
width: number;
|
|
185
|
+
height: number;
|
|
186
|
+
top: number;
|
|
187
|
+
left: number;
|
|
188
|
+
position: 'left' | 'right' | 'bottom' | 'top';
|
|
189
|
+
open: boolean;
|
|
190
|
+
inactiveTimeout: number;
|
|
191
|
+
}
|
|
192
|
+
type DockClientType = 'embedded' | 'standalone';
|
|
193
|
+
interface DocksContext {
|
|
194
|
+
/**
|
|
195
|
+
* Type of the client environment
|
|
196
|
+
*
|
|
197
|
+
* 'embedded' - running inside an embedded floating panel
|
|
198
|
+
* 'standalone' - running inside a standlone window (no user app)
|
|
199
|
+
*/
|
|
200
|
+
readonly clientType: 'embedded' | 'standalone';
|
|
201
|
+
/**
|
|
202
|
+
* The RPC client to interact with the server
|
|
203
|
+
*/
|
|
204
|
+
readonly rpc: DevToolsRpcClient;
|
|
205
|
+
/**
|
|
206
|
+
* The panel context
|
|
207
|
+
*/
|
|
208
|
+
panel: DocksPanelContext;
|
|
209
|
+
/**
|
|
210
|
+
* The docks entries context
|
|
211
|
+
*/
|
|
212
|
+
docks: DocksEntriesContext;
|
|
213
|
+
}
|
|
214
|
+
interface DocksPanelContext {
|
|
215
|
+
store: DockPanelStorage;
|
|
216
|
+
isDragging: boolean;
|
|
217
|
+
isResizing: boolean;
|
|
218
|
+
readonly isVertical: boolean;
|
|
219
|
+
}
|
|
220
|
+
interface DocksEntriesContext {
|
|
221
|
+
selected: DevToolsDockEntry | null;
|
|
222
|
+
entries: DevToolsDockEntry[];
|
|
223
|
+
entryToStateMap: Map<string, DockEntryState>;
|
|
224
|
+
/**
|
|
225
|
+
* Get the state of a dock entry by its ID
|
|
226
|
+
*/
|
|
227
|
+
getStateById: (id: string) => DockEntryState | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* Switch to the selected dock entry, pass `null` to clear the selection
|
|
230
|
+
*
|
|
231
|
+
* @returns Whether the selection was changed successfully
|
|
232
|
+
*/
|
|
233
|
+
switchEntry: (id: string | null) => Promise<boolean>;
|
|
234
|
+
}
|
|
235
|
+
interface DockEntryState {
|
|
236
|
+
entryMeta: DevToolsDockEntry;
|
|
237
|
+
readonly isActive: boolean;
|
|
238
|
+
domElements: {
|
|
239
|
+
iframe?: HTMLIFrameElement | null;
|
|
240
|
+
panel?: HTMLDivElement | null;
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/client/client-script.d.ts
|
|
245
|
+
/**
|
|
246
|
+
* Context for client scripts running in dock entries
|
|
247
|
+
*/
|
|
248
|
+
interface DockClientScriptContext extends DocksContext {
|
|
249
|
+
/**
|
|
250
|
+
* The state if the current dock entry
|
|
251
|
+
*/
|
|
252
|
+
current: DockEntryState;
|
|
253
|
+
}
|
|
254
|
+
interface DockClientScriptCurrent {
|
|
255
|
+
/**
|
|
256
|
+
* The dock entry info of the current dock item
|
|
257
|
+
*/
|
|
258
|
+
entryMeta: DevToolsDockEntry;
|
|
259
|
+
/**
|
|
260
|
+
* The current state of the dock
|
|
261
|
+
*/
|
|
262
|
+
state: 'active' | 'inactive';
|
|
263
|
+
/**
|
|
264
|
+
* The panel element to mount into, when the entry type is `custom-render`
|
|
265
|
+
*/
|
|
266
|
+
elPanel?: HTMLDivElement | null;
|
|
267
|
+
/**
|
|
268
|
+
* The iframe element to mount into, when the entry type is `iframe`
|
|
269
|
+
*/
|
|
270
|
+
elIframe?: HTMLIFrameElement | null;
|
|
271
|
+
/**
|
|
272
|
+
* The dock icon element
|
|
273
|
+
*/
|
|
274
|
+
elDockIcon?: HTMLDivElement | null;
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
277
|
+
export { DevToolsDockHost as A, DevToolsNodeContext as C, DevToolsDockEntry as D, ClientScriptEntry as E, EntriesToObject as F, Thenable as I, DevToolsRpcClientFunctions as L, DevToolsViewCustomRender as M, DevToolsViewHost as N, DevToolsDockEntryBase as O, DevToolsViewIframe as P, DevToolsRpcServerFunctions as R, DevToolsCapabilities as S, DevToolsPluginOptions as T, RpcFunctionDefinition as _, DockPanelStorage as a, RpcFunctionsHost as b, DocksPanelContext as c, getDevToolsRpcClient as d, PluginWithDevTools as f, RpcDefinitionsToFunctions as g, RpcDefinitionsFilter as h, DockEntryState as i, DevToolsViewAction as j, DevToolsDockEntryCategory as k, DevToolsRpcClient as l, BirpcReturn$1 as m, DockClientScriptCurrent as n, DocksContext as o, BirpcFn as p, DockClientType as r, DocksEntriesContext as s, DockClientScriptContext as t, DevToolsRpcClientOptions as u, RpcFunctionSetupResult as v, DevToolsNodeUtils as w, ConnectionMeta as x, RpcFunctionType as y };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as DevToolsDockHost, C as DevToolsNodeContext, D as DevToolsDockEntry, E as ClientScriptEntry, F as EntriesToObject, I as Thenable, L as DevToolsRpcClientFunctions, M as DevToolsViewCustomRender, N as DevToolsViewHost, O as DevToolsDockEntryBase, P as DevToolsViewIframe, R as DevToolsRpcServerFunctions, S as DevToolsCapabilities, T as DevToolsPluginOptions, _ as RpcFunctionDefinition, b as RpcFunctionsHost, f as PluginWithDevTools, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, j as DevToolsViewAction, k as DevToolsDockEntryCategory, m as BirpcReturn, p as BirpcFn, v as RpcFunctionSetupResult, w as DevToolsNodeUtils, x as ConnectionMeta, y as RpcFunctionType } from "./index-6FiVMI6v.js";
|
|
2
|
+
import * as birpc_x0 from "birpc-x";
|
|
2
3
|
|
|
3
4
|
//#region src/utils/rpc.d.ts
|
|
4
|
-
declare
|
|
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>;
|
|
5
|
+
declare const defineRpcFunction: <NAME extends string, TYPE extends birpc_x0.RpcFunctionType, ARGS extends any[], RETURN = void>(definition: birpc_x0.RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, DevToolsNodeContext>) => birpc_x0.RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, DevToolsNodeContext>;
|
|
6
6
|
//#endregion
|
|
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
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
+
import { createDefineWrapperWithContext } from "birpc-x";
|
|
2
|
+
|
|
1
3
|
//#region src/utils/rpc.ts
|
|
2
|
-
|
|
3
|
-
return definition;
|
|
4
|
-
}
|
|
5
|
-
async function getRpcHandler(definition, context) {
|
|
6
|
-
if (definition.handler) return definition.handler;
|
|
7
|
-
if (definition.__resolved?.handler) return definition.__resolved.handler;
|
|
8
|
-
definition.__promise ??= Promise.resolve(definition.setup(context)).then((r) => {
|
|
9
|
-
definition.__resolved = r;
|
|
10
|
-
definition.__promise = void 0;
|
|
11
|
-
return r;
|
|
12
|
-
});
|
|
13
|
-
return (definition.__resolved ??= await definition.__promise).handler;
|
|
14
|
-
}
|
|
4
|
+
const defineRpcFunction = createDefineWrapperWithContext();
|
|
15
5
|
|
|
16
6
|
//#endregion
|
|
17
|
-
export { defineRpcFunction
|
|
7
|
+
export { 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.14",
|
|
5
5
|
"description": "Vite DevTools Kit",
|
|
6
6
|
"author": "VoidZero Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,12 +33,13 @@
|
|
|
33
33
|
"vite": "*"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"birpc": "^2.
|
|
37
|
-
"
|
|
36
|
+
"birpc": "^2.7.0",
|
|
37
|
+
"birpc-x": "0.0.1",
|
|
38
|
+
"@vitejs/devtools-rpc": "0.0.0-alpha.14"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"tsdown": "^0.15.12",
|
|
41
|
-
"vite": "npm:rolldown-vite@^7.
|
|
42
|
+
"vite": "npm:rolldown-vite@^7.2.2"
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
44
45
|
"build": "tsdown",
|