@vitejs/devtools-kit
Advanced tools
| import { BirpcFn, BirpcReturn as BirpcReturn$1 } from "birpc"; | ||
| import { Plugin, ResolvedConfig, ViteDevServer } from "vite"; | ||
| //#region src/types/rpc-augments.d.ts | ||
| /** | ||
| * To be extended | ||
| */ | ||
| interface DevToolsRpcClientFunctions {} | ||
| /** | ||
| * To be extended | ||
| */ | ||
| interface DevToolsRpcServerFunctions {} | ||
| //#endregion | ||
| //#region src/types/utils.d.ts | ||
| type Thenable<T> = T | Promise<T>; | ||
| type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as K[0]]: K[1] }; | ||
| //#endregion | ||
| //#region src/types/views.d.ts | ||
| interface DevToolsDockHost { | ||
| views: Map<string, DevToolsDockEntry>; | ||
| register: (entry: DevToolsDockEntry) => void; | ||
| update: (entry: DevToolsDockEntry) => void; | ||
| values: () => DevToolsDockEntry[]; | ||
| } | ||
| interface DevToolsViewHost { | ||
| /** | ||
| * @internal | ||
| */ | ||
| buildStaticDirs: { | ||
| baseUrl: string; | ||
| distDir: string; | ||
| }[]; | ||
| /** | ||
| * Helper to host static files | ||
| * - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files | ||
| * - In `build` mode, it will copy the static files to the dist directory | ||
| */ | ||
| hostStatic: (baseUrl: string, distDir: string) => void; | ||
| } | ||
| interface DevToolsDockEntryBase { | ||
| id: string; | ||
| title: string; | ||
| icon: string; | ||
| } | ||
| interface ClientScriptEntry { | ||
| /** | ||
| * The filepath or module name to import from | ||
| */ | ||
| importFrom: string; | ||
| /** | ||
| * The name to import the module as | ||
| * | ||
| * @default 'default' | ||
| */ | ||
| importName?: string; | ||
| } | ||
| interface DevToolsViewIframe extends DevToolsDockEntryBase { | ||
| type: 'iframe'; | ||
| url: string; | ||
| /** | ||
| * The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared. | ||
| * | ||
| * When not provided, it would be treated as a unique frame. | ||
| */ | ||
| frameId?: string; | ||
| /** | ||
| * Optional script to import into the iframe | ||
| */ | ||
| import?: ClientScriptEntry; | ||
| } | ||
| interface DevToolsViewWebComponent extends DevToolsDockEntryBase { | ||
| type: 'webcomponent'; | ||
| import: ClientScriptEntry; | ||
| } | ||
| interface DevToolsViewAction extends DevToolsDockEntryBase { | ||
| type: 'action'; | ||
| import: ClientScriptEntry; | ||
| } | ||
| interface DevToolsViewCustomRender extends DevToolsDockEntryBase { | ||
| type: 'custom-render'; | ||
| import: ClientScriptEntry; | ||
| } | ||
| type DevToolsDockEntry = DevToolsViewIframe | DevToolsViewWebComponent | DevToolsViewAction | DevToolsViewCustomRender; | ||
| //#endregion | ||
| //#region src/types/vite-plugin.d.ts | ||
| interface DevToolsCapabilities { | ||
| rpc?: boolean; | ||
| views?: boolean; | ||
| } | ||
| interface DevToolsPluginOptions { | ||
| capabilities?: { | ||
| dev?: DevToolsCapabilities | boolean; | ||
| build?: DevToolsCapabilities | boolean; | ||
| }; | ||
| setup: (context: DevToolsNodeContext) => void | Promise<void>; | ||
| } | ||
| interface DevToolsNodeContext { | ||
| readonly cwd: string; | ||
| readonly mode: 'dev' | 'build'; | ||
| readonly viteConfig: ResolvedConfig; | ||
| readonly viteServer?: ViteDevServer; | ||
| rpc: RpcFunctionsHost; | ||
| docks: DevToolsDockHost; | ||
| views: DevToolsViewHost; | ||
| utils: DevToolsNodeUtils; | ||
| } | ||
| interface DevToolsNodeUtils { | ||
| clientEntryFromSimpleFunction: (fn: () => void) => ClientScriptEntry; | ||
| } | ||
| interface ConnectionMeta { | ||
| backend: 'websocket' | 'static'; | ||
| websocket?: number | string; | ||
| } | ||
| //#endregion | ||
| //#region src/types/rpc.d.ts | ||
| /** | ||
| * Type of the RPC function, | ||
| * - static: A function that returns a static data (can be cached and dumped) | ||
| * - action: A function that performs an action (no data returned) | ||
| * - query: A function that queries a resource | ||
| */ | ||
| type RpcFunctionType = 'static' | 'action' | 'query'; | ||
| interface RpcFunctionsHost { | ||
| context: DevToolsNodeContext; | ||
| readonly functions: DevToolsRpcServerFunctions; | ||
| readonly definitions: Map<string, RpcFunctionDefinition<string, any, any, any>>; | ||
| register: (fn: RpcFunctionDefinition<string, any, any, any>) => void; | ||
| update: (fn: RpcFunctionDefinition<string, any, any, any>) => void; | ||
| } | ||
| interface RpcFunctionSetupResult<ARGS extends any[], RETURN = void> { | ||
| handler: (...args: ARGS) => RETURN; | ||
| } | ||
| interface RpcFunctionDefinition<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[] = [], RETURN = void> { | ||
| name: NAME; | ||
| type: TYPE; | ||
| setup: (context: DevToolsNodeContext) => Thenable<RpcFunctionSetupResult<ARGS, RETURN>>; | ||
| handler?: (...args: ARGS) => RETURN; | ||
| __resolved?: RpcFunctionSetupResult<ARGS, RETURN>; | ||
| __promise?: Thenable<RpcFunctionSetupResult<ARGS, RETURN>>; | ||
| } | ||
| type RpcDefinitionsToFunctions<T extends readonly RpcFunctionDefinition<any, any, any>[]> = EntriesToObject<{ [K in keyof T]: [T[K]['name'], Awaited<ReturnType<T[K]['setup']>>['handler']] }>; | ||
| type RpcDefinitionsFilter<T extends readonly RpcFunctionDefinition<any, any, any>[], Type extends RpcFunctionType> = { [K in keyof T]: T[K] extends { | ||
| type: Type; | ||
| } ? T[K] : never }; | ||
| //#endregion | ||
| //#region src/types/vite-augment.d.ts | ||
| declare module 'vite' { | ||
| interface Plugin { | ||
| devtools?: DevToolsPluginOptions; | ||
| } | ||
| } | ||
| interface PluginWithDevTools extends Plugin { | ||
| devtools?: DevToolsPluginOptions; | ||
| } | ||
| //#endregion | ||
| 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 }; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import { ConnectionMeta, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions } from "./rpc-DVF6QKW4.js"; | ||
| import { D as DevToolsRpcServerFunctions, E as DevToolsRpcClientFunctions, u as ConnectionMeta } from "./index-BtaHil_c.js"; | ||
| import { WebSocketRpcClientOptions } from "@vitejs/devtools-rpc/presets/ws/client"; | ||
@@ -3,0 +3,0 @@ import { BirpcOptions, BirpcReturn } from "birpc"; |
+3
-4
@@ -15,4 +15,4 @@ import { createRpcClient } from "@vitejs/devtools-rpc"; | ||
| const errors = []; | ||
| for (const url$1 of urls) try { | ||
| connectionMeta = await fetch(`${url$1}.vdt-connection.json`).then((r) => r.json()); | ||
| for (const url of urls) try { | ||
| connectionMeta = await fetch(`${url}.vdt-connection.json`).then((r) => r.json()); | ||
| break; | ||
@@ -24,6 +24,5 @@ } catch (e) { | ||
| } | ||
| const url = isNumeric(connectionMeta.websocket) ? `${location.protocol.replace("http", "ws")}//${location.hostname}:${connectionMeta.websocket}` : connectionMeta.websocket; | ||
| const rpc = createRpcClient({}, { | ||
| preset: createWsRpcPreset({ | ||
| url, | ||
| url: isNumeric(connectionMeta.websocket) ? `${location.protocol.replace("http", "ws")}//${location.hostname}:${connectionMeta.websocket}` : connectionMeta.websocket, | ||
| ...options.wsOptions | ||
@@ -30,0 +29,0 @@ }), |
+2
-13
@@ -1,14 +0,3 @@ | ||
| import { BirpcFn, BirpcReturn, ConnectionMeta, DevToolsCapabilities, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockHost, DevToolsNodeContext, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction, DevToolsViewHost, DevToolsViewIframe, DevToolsViewWebComponent, EntriesToObject, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionDefinition, RpcFunctionSetupResult, RpcFunctionType, RpcFunctionsHost, Thenable } from "./rpc-DVF6QKW4.js"; | ||
| import { Plugin } from "vite"; | ||
| 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"; | ||
| //#region src/types/vite-augment.d.ts | ||
| declare module 'vite' { | ||
| interface Plugin { | ||
| devtools?: DevToolsPluginOptions; | ||
| } | ||
| } | ||
| interface PluginWithDevTools extends Plugin { | ||
| devtools?: DevToolsPluginOptions; | ||
| } | ||
| //#endregion | ||
| //#region src/utils/rpc.d.ts | ||
@@ -18,2 +7,2 @@ 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>; | ||
| //#endregion | ||
| 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 }; | ||
| 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 }; |
+5
-5
| { | ||
| "name": "@vitejs/devtools-kit", | ||
| "type": "module", | ||
| "version": "0.0.0-alpha.6", | ||
| "version": "0.0.0-alpha.7", | ||
| "description": "Vite DevTools Kit", | ||
@@ -33,11 +33,11 @@ "author": "VoidZero Inc.", | ||
| "peerDependencies": { | ||
| "vite": "npm:rolldown-vite@^7.1.14" | ||
| "vite": "npm:rolldown-vite@^7.1.20" | ||
| }, | ||
| "dependencies": { | ||
| "birpc": "^2.6.1", | ||
| "@vitejs/devtools-rpc": "0.0.0-alpha.6" | ||
| "@vitejs/devtools-rpc": "0.0.0-alpha.7" | ||
| }, | ||
| "devDependencies": { | ||
| "tsdown": "^0.15.6", | ||
| "vite": "npm:rolldown-vite@^7.1.14" | ||
| "tsdown": "^0.15.12", | ||
| "vite": "npm:rolldown-vite@^7.1.20" | ||
| }, | ||
@@ -44,0 +44,0 @@ "scripts": { |
| import { BirpcFn, BirpcReturn as BirpcReturn$1 } from "birpc"; | ||
| import { ResolvedConfig, ViteDevServer } from "vite"; | ||
| //#region src/types/rpc-augments.d.ts | ||
| /** | ||
| * To be extended | ||
| */ | ||
| interface DevToolsRpcClientFunctions {} | ||
| /** | ||
| * To be extended | ||
| */ | ||
| interface DevToolsRpcServerFunctions {} | ||
| //#endregion | ||
| //#region src/types/utils.d.ts | ||
| type Thenable<T> = T | Promise<T>; | ||
| type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as K[0]]: K[1] }; | ||
| //#endregion | ||
| //#region src/types/views.d.ts | ||
| interface DevToolsDockHost { | ||
| register: (entry: DevToolsDockEntry) => void; | ||
| values: () => DevToolsDockEntry[]; | ||
| } | ||
| interface DevToolsViewHost { | ||
| /** | ||
| * @internal | ||
| */ | ||
| buildStaticDirs: { | ||
| baseUrl: string; | ||
| distDir: string; | ||
| }[]; | ||
| /** | ||
| * Helper to host static files | ||
| * - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files | ||
| * - In `build` mode, it will copy the static files to the dist directory | ||
| */ | ||
| hostStatic: (baseUrl: string, distDir: string) => void; | ||
| } | ||
| interface DevToolsDockEntryBase { | ||
| id: string; | ||
| title: string; | ||
| icon: string; | ||
| } | ||
| interface DevToolsViewIframe extends DevToolsDockEntryBase { | ||
| type: 'iframe'; | ||
| url: string; | ||
| /** | ||
| * The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared. | ||
| * | ||
| * When not provided, it would be treated as a unique frame. | ||
| */ | ||
| frameId?: string; | ||
| } | ||
| interface DevToolsViewWebComponent extends DevToolsDockEntryBase { | ||
| type: 'webcomponent'; | ||
| from: string; | ||
| import: string; | ||
| } | ||
| interface DevToolsViewAction extends DevToolsDockEntryBase { | ||
| type: 'action'; | ||
| importFrom: string; | ||
| /** | ||
| * @default 'default' | ||
| */ | ||
| importName?: string; | ||
| } | ||
| type DevToolsDockEntry = DevToolsViewIframe | DevToolsViewWebComponent | DevToolsViewAction; | ||
| //#endregion | ||
| //#region src/types/vite-plugin.d.ts | ||
| interface DevToolsCapabilities { | ||
| rpc?: boolean; | ||
| views?: boolean; | ||
| } | ||
| interface DevToolsPluginOptions { | ||
| capabilities?: { | ||
| dev?: DevToolsCapabilities | boolean; | ||
| build?: DevToolsCapabilities | boolean; | ||
| }; | ||
| setup: (context: DevToolsNodeContext) => void | Promise<void>; | ||
| } | ||
| interface DevToolsNodeContext { | ||
| readonly cwd: string; | ||
| readonly mode: 'dev' | 'build'; | ||
| readonly viteConfig: ResolvedConfig; | ||
| readonly viteServer?: ViteDevServer; | ||
| rpc: RpcFunctionsHost; | ||
| docks: DevToolsDockHost; | ||
| views: DevToolsViewHost; | ||
| } | ||
| interface ConnectionMeta { | ||
| backend: 'websocket' | 'static'; | ||
| websocket?: number | string; | ||
| } | ||
| //#endregion | ||
| //#region src/types/rpc.d.ts | ||
| /** | ||
| * Type of the RPC function, | ||
| * - static: A function that returns a static data (can be cached and dumped) | ||
| * - action: A function that performs an action (no data returned) | ||
| * - query: A function that queries a resource | ||
| */ | ||
| type RpcFunctionType = 'static' | 'action' | 'query'; | ||
| interface RpcFunctionsHost { | ||
| context: DevToolsNodeContext; | ||
| readonly functions: DevToolsRpcServerFunctions; | ||
| readonly definitions: Map<string, RpcFunctionDefinition<string, any, any, any>>; | ||
| register: (fn: RpcFunctionDefinition<string, any, any, any>) => void; | ||
| } | ||
| interface RpcFunctionSetupResult<ARGS extends any[], RETURN = void> { | ||
| handler: (...args: ARGS) => RETURN; | ||
| } | ||
| interface RpcFunctionDefinition<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[] = [], RETURN = void> { | ||
| name: NAME; | ||
| type: TYPE; | ||
| setup: (context: DevToolsNodeContext) => Thenable<RpcFunctionSetupResult<ARGS, RETURN>>; | ||
| handler?: (...args: ARGS) => RETURN; | ||
| __resolved?: RpcFunctionSetupResult<ARGS, RETURN>; | ||
| __promise?: Thenable<RpcFunctionSetupResult<ARGS, RETURN>>; | ||
| } | ||
| type RpcDefinitionsToFunctions<T extends readonly RpcFunctionDefinition<any, any, any>[]> = EntriesToObject<{ [K in keyof T]: [T[K]['name'], Awaited<ReturnType<T[K]['setup']>>['handler']] }>; | ||
| type RpcDefinitionsFilter<T extends readonly RpcFunctionDefinition<any, any, any>[], Type extends RpcFunctionType> = { [K in keyof T]: T[K] extends { | ||
| type: Type; | ||
| } ? T[K] : never }; | ||
| //#endregion | ||
| export { type BirpcFn, type BirpcReturn$1 as BirpcReturn, ConnectionMeta, DevToolsCapabilities, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockHost, DevToolsNodeContext, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsViewAction, DevToolsViewHost, DevToolsViewIframe, DevToolsViewWebComponent, EntriesToObject, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionDefinition, RpcFunctionSetupResult, RpcFunctionType, RpcFunctionsHost, Thenable }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
12078
10.46%225
10.29%2
100%+ Added
- Removed