devframe 0.0.0 → 0.1.16
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/LICENSE.md +21 -0
- package/README.md +62 -0
- package/dist/_shared-CU6dE-VX.mjs +20 -0
- package/dist/adapters/build.d.mts +37 -0
- package/dist/adapters/build.mjs +61 -0
- package/dist/adapters/cli.d.mts +35 -0
- package/dist/adapters/cli.mjs +357 -0
- package/dist/adapters/embedded.d.mts +19 -0
- package/dist/adapters/embedded.mjs +15 -0
- package/dist/adapters/kit.d.mts +23 -0
- package/dist/adapters/kit.mjs +16 -0
- package/dist/adapters/mcp.d.mts +39 -0
- package/dist/adapters/mcp.mjs +278 -0
- package/dist/adapters/vite.d.mts +32 -0
- package/dist/adapters/vite.mjs +31 -0
- package/dist/client/index.d.mts +227 -0
- package/dist/client/index.mjs +2 -0
- package/dist/client-4WrEozlH.mjs +1561 -0
- package/dist/constants.d.mts +20 -0
- package/dist/constants.mjs +34 -0
- package/dist/context-BrePWeyd.mjs +6776 -0
- package/dist/define-Bb4zh-Dc.mjs +11 -0
- package/dist/devtool-OJ3QW0ns.d.mts +1125 -0
- package/dist/helpers/nuxt/index.d.mts +46 -0
- package/dist/helpers/nuxt/index.mjs +58 -0
- package/dist/helpers/nuxt/runtime/plugin.client.d.mts +8 -0
- package/dist/helpers/nuxt/runtime/plugin.client.mjs +12 -0
- package/dist/human-id-CHS0s28X.mjs +844 -0
- package/dist/immer-HjMAm3b6.mjs +894 -0
- package/dist/index-DvKDO5H8.d.mts +333 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +2 -0
- package/dist/main-DpINGndA.mjs +601 -0
- package/dist/node/index.d.mts +365 -0
- package/dist/node/index.mjs +69 -0
- package/dist/open-BtOOEldu.mjs +533 -0
- package/dist/recipes/open-helpers.d.mts +104 -0
- package/dist/recipes/open-helpers.mjs +69 -0
- package/dist/rpc/client.d.mts +9 -0
- package/dist/rpc/client.mjs +13 -0
- package/dist/rpc/index.d.mts +2 -0
- package/dist/rpc/index.mjs +3 -0
- package/dist/rpc/server.d.mts +8 -0
- package/dist/rpc/server.mjs +10 -0
- package/dist/rpc/transports/ws-client.d.mts +2 -0
- package/dist/rpc/transports/ws-client.mjs +43 -0
- package/dist/rpc/transports/ws-server.d.mts +2 -0
- package/dist/rpc/transports/ws-server.mjs +58 -0
- package/dist/rpc-9FNa3Inb.mjs +474 -0
- package/dist/server-DrBxa6ZV.mjs +49 -0
- package/dist/src-BoIqXRc9.mjs +85 -0
- package/dist/static-dump-CQUC1aIW.mjs +82 -0
- package/dist/transports-BPUzHhI2.mjs +15 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/types/index.mjs +6 -0
- package/dist/utils/events.d.mts +9 -0
- package/dist/utils/events.mjs +40 -0
- package/dist/utils/human-id.d.mts +10 -0
- package/dist/utils/human-id.mjs +3 -0
- package/dist/utils/nanoid.d.mts +4 -0
- package/dist/utils/nanoid.mjs +10 -0
- package/dist/utils/promise.d.mts +8 -0
- package/dist/utils/promise.mjs +15 -0
- package/dist/utils/shared-state.d.mts +2 -0
- package/dist/utils/shared-state.mjs +36 -0
- package/dist/utils/state.d.mts +49 -0
- package/dist/utils/state.mjs +26 -0
- package/dist/utils/when.d.mts +2 -0
- package/dist/utils/when.mjs +424 -0
- package/dist/when-CGLewRtm.d.mts +401 -0
- package/dist/ws-client-CklfxUHE.d.mts +17 -0
- package/dist/ws-server--IuUAaGi.d.mts +37 -0
- package/package.json +116 -8
|
@@ -0,0 +1,1125 @@
|
|
|
1
|
+
import { u as RpcFunctionsCollectorBase } from "./index-DvKDO5H8.mjs";
|
|
2
|
+
import { t as DevToolsNodeRpcSessionMeta } from "./ws-server--IuUAaGi.mjs";
|
|
3
|
+
import { GenericSchema, InferOutput } from "valibot";
|
|
4
|
+
import { BirpcReturn } from "birpc";
|
|
5
|
+
import { CAC } from "cac";
|
|
6
|
+
import { ChildProcess } from "node:child_process";
|
|
7
|
+
|
|
8
|
+
//#region src/adapters/flags.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Schema map for typed CLI flags. Keys are flag names in camelCase —
|
|
11
|
+
* this matches CAC's parsed-flag output ( `--no-open` → `noOpen` ). Each
|
|
12
|
+
* value is a valibot schema used to both (a) derive the CAC option type
|
|
13
|
+
* when the flag is registered and (b) validate / coerce the parsed
|
|
14
|
+
* value before it's forwarded to `setup(ctx, { flags })`.
|
|
15
|
+
*/
|
|
16
|
+
type CliFlagsSchema = Record<string, GenericSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* Identity helper that preserves the literal schema-map type — use this
|
|
19
|
+
* so `InferCliFlags<typeof myFlags>` resolves to the right object shape.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const appFlags = defineCliFlags({
|
|
23
|
+
* depth: v.pipe(v.number(), v.integer()),
|
|
24
|
+
* config: v.optional(v.string()),
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* defineDevtool({
|
|
28
|
+
* cli: { flags: appFlags },
|
|
29
|
+
* setup(ctx, info) {
|
|
30
|
+
* const flags = info.flags as InferCliFlags<typeof appFlags>
|
|
31
|
+
* flags.depth // number
|
|
32
|
+
* flags.config // string | undefined
|
|
33
|
+
* },
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare function defineCliFlags<T extends CliFlagsSchema>(flags: T): T;
|
|
38
|
+
/** Extract the parsed-output type from a {@link CliFlagsSchema}. */
|
|
39
|
+
type InferCliFlags<T extends CliFlagsSchema> = { [K in keyof T]: InferOutput<T[K]> };
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/types/events.d.ts
|
|
42
|
+
interface EventsMap {
|
|
43
|
+
[event: string]: any;
|
|
44
|
+
}
|
|
45
|
+
interface EventUnsubscribe {
|
|
46
|
+
(): void;
|
|
47
|
+
}
|
|
48
|
+
interface EventEmitter<Events extends EventsMap> {
|
|
49
|
+
/**
|
|
50
|
+
* Calls each of the listeners registered for a given event.
|
|
51
|
+
*
|
|
52
|
+
* ```js
|
|
53
|
+
* ee.emit('tick', tickType, tickDuration)
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param event The event name.
|
|
57
|
+
* @param args The arguments for listeners.
|
|
58
|
+
*/
|
|
59
|
+
emit: <K extends keyof Events>(event: K, ...args: Parameters<Events[K]>) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Calls the listeners for a given event once and then removes the listener.
|
|
62
|
+
*
|
|
63
|
+
* @param event The event name.
|
|
64
|
+
* @param args The arguments for listeners.
|
|
65
|
+
*/
|
|
66
|
+
emitOnce: <K extends keyof Events>(event: K, ...args: Parameters<Events[K]>) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Event names in keys and arrays with listeners in values.
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
_listeners: Partial<{ [E in keyof Events]: Events[E][] }>;
|
|
73
|
+
/**
|
|
74
|
+
* Add a listener for a given event.
|
|
75
|
+
*
|
|
76
|
+
* ```js
|
|
77
|
+
* const unbind = ee.on('tick', (tickType, tickDuration) => {
|
|
78
|
+
* count += 1
|
|
79
|
+
* })
|
|
80
|
+
*
|
|
81
|
+
* disable () {
|
|
82
|
+
* unbind()
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param event The event name.
|
|
87
|
+
* @param cb The listener function.
|
|
88
|
+
* @returns Unbind listener from event.
|
|
89
|
+
*/
|
|
90
|
+
on: <K extends keyof Events>(event: K, cb: Events[K]) => EventUnsubscribe;
|
|
91
|
+
/**
|
|
92
|
+
* Add a listener for a given event once.
|
|
93
|
+
*
|
|
94
|
+
* ```js
|
|
95
|
+
* const unbind = ee.once('tick', (tickType, tickDuration) => {
|
|
96
|
+
* count += 1
|
|
97
|
+
* })
|
|
98
|
+
*
|
|
99
|
+
* disable () {
|
|
100
|
+
* unbind()
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @param event The event name.
|
|
105
|
+
* @param cb The listener function.
|
|
106
|
+
* @returns Unbind listener from event.
|
|
107
|
+
*/
|
|
108
|
+
once: <K extends keyof Events>(event: K, cb: Events[K]) => EventUnsubscribe;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/types/agent.d.ts
|
|
112
|
+
/**
|
|
113
|
+
* Serializable description of an agent-exposed tool. This is the shape
|
|
114
|
+
* returned by the agent host manifest and surfaced over the wire by
|
|
115
|
+
* the `devframe:agent:list-tools` introspection RPC.
|
|
116
|
+
*
|
|
117
|
+
* @experimental The agent-native surface is experimental and may change
|
|
118
|
+
* without a major version bump until it stabilizes.
|
|
119
|
+
*/
|
|
120
|
+
interface AgentTool {
|
|
121
|
+
/** Stable identifier. For RPC-backed tools, matches the RPC name. */
|
|
122
|
+
id: string;
|
|
123
|
+
/** `'rpc'` when backed by a registered RPC function, `'tool'` when registered via `ctx.agent.registerTool()`. */
|
|
124
|
+
kind: 'rpc' | 'tool';
|
|
125
|
+
/** Display title (falls back to `id`). */
|
|
126
|
+
title: string;
|
|
127
|
+
/** Human-readable description shown to the agent. */
|
|
128
|
+
description: string;
|
|
129
|
+
/** Safety classification — drives MCP hint annotations downstream. */
|
|
130
|
+
safety: 'read' | 'action' | 'destructive';
|
|
131
|
+
/** Free-form tags for grouping/filtering. */
|
|
132
|
+
tags?: readonly string[];
|
|
133
|
+
/** Present for `kind === 'rpc'` — points to the RPC function name. */
|
|
134
|
+
rpcName?: string;
|
|
135
|
+
/** JSON Schema describing the input (positional args synthesized to an object). */
|
|
136
|
+
inputSchema?: unknown;
|
|
137
|
+
/** JSON Schema describing the output. */
|
|
138
|
+
outputSchema?: unknown;
|
|
139
|
+
/** Example invocations shown to agents. */
|
|
140
|
+
examples?: readonly {
|
|
141
|
+
args: unknown[];
|
|
142
|
+
description?: string;
|
|
143
|
+
}[];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Input accepted by `DevToolsAgentHost.registerTool()`. Handler is
|
|
147
|
+
* stripped from the serializable `AgentTool` projection.
|
|
148
|
+
*
|
|
149
|
+
* @experimental
|
|
150
|
+
*/
|
|
151
|
+
interface AgentToolInput {
|
|
152
|
+
id: string;
|
|
153
|
+
title?: string;
|
|
154
|
+
description: string;
|
|
155
|
+
safety?: 'read' | 'action' | 'destructive';
|
|
156
|
+
tags?: readonly string[];
|
|
157
|
+
inputSchema?: unknown;
|
|
158
|
+
outputSchema?: unknown;
|
|
159
|
+
examples?: readonly {
|
|
160
|
+
args: unknown[];
|
|
161
|
+
description?: string;
|
|
162
|
+
}[];
|
|
163
|
+
/** Invoked when the tool is called. Receives args as provided by the caller. */
|
|
164
|
+
handler: (args: any) => unknown | Promise<unknown>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Serializable description of an agent-readable resource. Resources
|
|
168
|
+
* surface structured or textual snapshots of devtools state.
|
|
169
|
+
*
|
|
170
|
+
* @experimental
|
|
171
|
+
*/
|
|
172
|
+
interface AgentResource {
|
|
173
|
+
id: string;
|
|
174
|
+
/** URI used by MCP clients. Defaults to `devframe://resource/<id>`. */
|
|
175
|
+
uri: string;
|
|
176
|
+
name: string;
|
|
177
|
+
description?: string;
|
|
178
|
+
/** Defaults to `application/json`. */
|
|
179
|
+
mimeType?: string;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Input accepted by `DevToolsAgentHost.registerResource()`.
|
|
183
|
+
*
|
|
184
|
+
* @experimental
|
|
185
|
+
*/
|
|
186
|
+
interface AgentResourceInput {
|
|
187
|
+
id: string;
|
|
188
|
+
name: string;
|
|
189
|
+
description?: string;
|
|
190
|
+
mimeType?: string;
|
|
191
|
+
/** Optional URI override — if omitted, a `devframe://resource/<id>` URI is generated. */
|
|
192
|
+
uri?: string;
|
|
193
|
+
/** Snapshot reader. Called on each read. */
|
|
194
|
+
read: () => Promise<AgentResourceContent> | AgentResourceContent;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Payload returned by `AgentResourceInput.read`. Either `text` or `json` must be set.
|
|
198
|
+
*
|
|
199
|
+
* @experimental
|
|
200
|
+
*/
|
|
201
|
+
interface AgentResourceContent {
|
|
202
|
+
text?: string;
|
|
203
|
+
json?: unknown;
|
|
204
|
+
/** Override the resource's declared mimeType for this read. */
|
|
205
|
+
mimeType?: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Unified view of the agent-exposed surface.
|
|
209
|
+
*
|
|
210
|
+
* @experimental
|
|
211
|
+
*/
|
|
212
|
+
interface AgentManifest {
|
|
213
|
+
tools: readonly AgentTool[];
|
|
214
|
+
resources: readonly AgentResource[];
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Handle returned by `registerTool` / `registerResource`.
|
|
218
|
+
*
|
|
219
|
+
* @experimental
|
|
220
|
+
*/
|
|
221
|
+
interface AgentHandle {
|
|
222
|
+
unregister: () => void;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Events emitted by `DevToolsAgentHost`.
|
|
226
|
+
*
|
|
227
|
+
* @experimental
|
|
228
|
+
*/
|
|
229
|
+
interface DevToolsAgentHostEvents {
|
|
230
|
+
'agent:tool:registered': (tool: AgentTool) => void;
|
|
231
|
+
'agent:tool:unregistered': (id: string) => void;
|
|
232
|
+
'agent:resource:registered': (resource: AgentResource) => void;
|
|
233
|
+
'agent:resource:unregistered': (id: string) => void;
|
|
234
|
+
/**
|
|
235
|
+
* Fires when the unified manifest changes — including when a new
|
|
236
|
+
* RPC function with an `agent` field is registered on `ctx.rpc`.
|
|
237
|
+
*/
|
|
238
|
+
'agent:manifest:changed': () => void;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Host that aggregates the agent-exposed surface of a devtool: both
|
|
242
|
+
* RPC functions flagged with `agent` and plugin-registered tools /
|
|
243
|
+
* resources. Consumed by protocol adapters such as the devframe MCP
|
|
244
|
+
* adapter.
|
|
245
|
+
*
|
|
246
|
+
* @experimental The agent-native surface is experimental and may change
|
|
247
|
+
* without a major version bump until it stabilizes.
|
|
248
|
+
*/
|
|
249
|
+
interface DevToolsAgentHost {
|
|
250
|
+
readonly events: EventEmitter<DevToolsAgentHostEvents>;
|
|
251
|
+
/**
|
|
252
|
+
* Register a tool not backed by an RPC function. Use this when you
|
|
253
|
+
* want a plain agent action (e.g. a synthesized summary) that
|
|
254
|
+
* shouldn't exist as a full RPC.
|
|
255
|
+
*/
|
|
256
|
+
registerTool: (tool: AgentToolInput) => AgentHandle;
|
|
257
|
+
/** Unregister a previously registered tool by id. */
|
|
258
|
+
unregisterTool: (id: string) => boolean;
|
|
259
|
+
/** Register a readable resource. */
|
|
260
|
+
registerResource: (resource: AgentResourceInput) => AgentHandle;
|
|
261
|
+
/** Unregister a previously registered resource by id. */
|
|
262
|
+
unregisterResource: (id: string) => boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Unified snapshot of agent-exposed surface: RPC functions with an
|
|
265
|
+
* `agent` field (auto-discovered from `ctx.rpc.definitions`) plus
|
|
266
|
+
* tools/resources registered on the host.
|
|
267
|
+
*/
|
|
268
|
+
list: () => AgentManifest;
|
|
269
|
+
/**
|
|
270
|
+
* Invoke any tool by id. Routes to the underlying RPC handler for
|
|
271
|
+
* `kind === 'rpc'`, or to the registered handler for `kind === 'tool'`.
|
|
272
|
+
*/
|
|
273
|
+
invoke: (id: string, args: unknown) => Promise<unknown>;
|
|
274
|
+
/** Read a resource by id. */
|
|
275
|
+
read: (id: string) => Promise<AgentResourceContent>;
|
|
276
|
+
/** Look up a tool by id (returns the serializable projection). */
|
|
277
|
+
getTool: (id: string) => AgentTool | undefined;
|
|
278
|
+
/** Look up a resource by id. */
|
|
279
|
+
getResource: (id: string) => AgentResource | undefined;
|
|
280
|
+
}
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/types/commands.d.ts
|
|
283
|
+
interface DevToolsCommandKeybinding {
|
|
284
|
+
/**
|
|
285
|
+
* Keyboard shortcut string.
|
|
286
|
+
* Use "Mod" for platform-aware modifier (Cmd on macOS, Ctrl elsewhere).
|
|
287
|
+
* Examples: "Mod+K", "Mod+Shift+P", "Alt+N"
|
|
288
|
+
*/
|
|
289
|
+
key: string;
|
|
290
|
+
}
|
|
291
|
+
interface DevToolsCommandBase {
|
|
292
|
+
/**
|
|
293
|
+
* Unique namespaced ID, e.g. "vite:open-in-editor"
|
|
294
|
+
*/
|
|
295
|
+
id: string;
|
|
296
|
+
title: string;
|
|
297
|
+
description?: string;
|
|
298
|
+
/**
|
|
299
|
+
* Iconify icon string, e.g. "ph:pencil-duotone"
|
|
300
|
+
*/
|
|
301
|
+
icon?: string;
|
|
302
|
+
category?: string;
|
|
303
|
+
/**
|
|
304
|
+
* Whether to show in command palette. Default: true
|
|
305
|
+
*
|
|
306
|
+
* - `true` — show the command and flatten its children into search results
|
|
307
|
+
* - `false` — hide the command entirely from the palette
|
|
308
|
+
* - `'without-children'` — show the command but don't flatten children into top-level search (children are still accessible via drill-down)
|
|
309
|
+
*/
|
|
310
|
+
showInPalette?: boolean | 'without-children';
|
|
311
|
+
/**
|
|
312
|
+
* Optional context expression for conditional visibility.
|
|
313
|
+
* When set, the command is only shown in the palette and only executable
|
|
314
|
+
* when the expression evaluates to true.
|
|
315
|
+
*
|
|
316
|
+
* Uses the same syntax as keybinding `when` clauses.
|
|
317
|
+
* @example 'clientType == embedded'
|
|
318
|
+
* @example 'dockOpen && !paletteOpen'
|
|
319
|
+
*/
|
|
320
|
+
when?: string;
|
|
321
|
+
/**
|
|
322
|
+
* Default keyboard shortcut(s) for this command
|
|
323
|
+
*/
|
|
324
|
+
keybindings?: DevToolsCommandKeybinding[];
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Server command input — what plugins pass to `ctx.commands.register()`.
|
|
328
|
+
*/
|
|
329
|
+
interface DevToolsServerCommandInput extends DevToolsCommandBase {
|
|
330
|
+
/**
|
|
331
|
+
* Handler for this command. Optional if the command only serves as a group for children.
|
|
332
|
+
*/
|
|
333
|
+
handler?: (...args: any[]) => any | Promise<any>;
|
|
334
|
+
/**
|
|
335
|
+
* Static sub-commands. Two levels max (parent → children).
|
|
336
|
+
* Each child must have a globally unique `id`.
|
|
337
|
+
*/
|
|
338
|
+
children?: DevToolsServerCommandInput[];
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Serializable server command entry — sent over RPC (no handler).
|
|
342
|
+
*/
|
|
343
|
+
interface DevToolsServerCommandEntry extends DevToolsCommandBase {
|
|
344
|
+
source: 'server';
|
|
345
|
+
children?: DevToolsServerCommandEntry[];
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Client command — registered in the webcomponent context.
|
|
349
|
+
*/
|
|
350
|
+
interface DevToolsClientCommand extends DevToolsCommandBase {
|
|
351
|
+
source: 'client';
|
|
352
|
+
/**
|
|
353
|
+
* Action for this command. Optional if the command only serves as a group for children.
|
|
354
|
+
* Return sub-commands for dynamic nested palette menus (runtime submenus).
|
|
355
|
+
*/
|
|
356
|
+
action?: (...args: any[]) => void | DevToolsClientCommand[] | Promise<void | DevToolsClientCommand[]>;
|
|
357
|
+
/**
|
|
358
|
+
* Static sub-commands. Two levels max (parent → children).
|
|
359
|
+
*/
|
|
360
|
+
children?: DevToolsClientCommand[];
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Union of command entries visible in the palette.
|
|
364
|
+
*/
|
|
365
|
+
type DevToolsCommandEntry = DevToolsServerCommandEntry | DevToolsClientCommand;
|
|
366
|
+
interface DevToolsCommandHandle {
|
|
367
|
+
readonly id: string;
|
|
368
|
+
update: (patch: Partial<Omit<DevToolsServerCommandInput, 'id'>>) => void;
|
|
369
|
+
unregister: () => void;
|
|
370
|
+
}
|
|
371
|
+
interface DevToolsCommandsHostEvents {
|
|
372
|
+
'command:registered': (command: DevToolsServerCommandEntry) => void;
|
|
373
|
+
'command:unregistered': (id: string) => void;
|
|
374
|
+
}
|
|
375
|
+
interface DevToolsCommandsHost {
|
|
376
|
+
readonly commands: Map<string, DevToolsServerCommandInput>;
|
|
377
|
+
readonly events: EventEmitter<DevToolsCommandsHostEvents>;
|
|
378
|
+
/**
|
|
379
|
+
* Register a command (with optional children).
|
|
380
|
+
*/
|
|
381
|
+
register: (command: DevToolsServerCommandInput) => DevToolsCommandHandle;
|
|
382
|
+
/**
|
|
383
|
+
* Unregister a command by ID (removes parent and all children).
|
|
384
|
+
*/
|
|
385
|
+
unregister: (id: string) => boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Execute a command by ID. Searches top-level and children.
|
|
388
|
+
* Throws if not found or if command has no handler.
|
|
389
|
+
*/
|
|
390
|
+
execute: (id: string, ...args: any[]) => Promise<unknown>;
|
|
391
|
+
/**
|
|
392
|
+
* Returns serializable list (no handlers), preserving tree structure.
|
|
393
|
+
*/
|
|
394
|
+
list: () => DevToolsServerCommandEntry[];
|
|
395
|
+
}
|
|
396
|
+
interface DevToolsCommandShortcutOverrides {
|
|
397
|
+
/**
|
|
398
|
+
* Command ID → keybinding overrides. Empty array = shortcut disabled.
|
|
399
|
+
*/
|
|
400
|
+
[commandId: string]: DevToolsCommandKeybinding[];
|
|
401
|
+
}
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/types/docks.d.ts
|
|
404
|
+
interface DevToolsDockHost {
|
|
405
|
+
readonly views: Map<string, DevToolsDockUserEntry>;
|
|
406
|
+
readonly events: EventEmitter<{
|
|
407
|
+
'dock:entry:updated': (entry: DevToolsDockUserEntry) => void;
|
|
408
|
+
}>;
|
|
409
|
+
register: <T extends DevToolsDockUserEntry>(entry: T, force?: boolean) => {
|
|
410
|
+
update: (patch: Partial<T>) => void;
|
|
411
|
+
};
|
|
412
|
+
update: (entry: DevToolsDockUserEntry) => void;
|
|
413
|
+
values: (options?: {
|
|
414
|
+
includeBuiltin?: boolean;
|
|
415
|
+
}) => DevToolsDockEntry[];
|
|
416
|
+
}
|
|
417
|
+
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default' | '~viteplus' | '~builtin';
|
|
418
|
+
type DevToolsDockEntryIcon = string | {
|
|
419
|
+
light: string;
|
|
420
|
+
dark: string;
|
|
421
|
+
};
|
|
422
|
+
interface DevToolsDockEntryBase {
|
|
423
|
+
id: string;
|
|
424
|
+
title: string;
|
|
425
|
+
icon: DevToolsDockEntryIcon;
|
|
426
|
+
/**
|
|
427
|
+
* The default order of the entry in the dock.
|
|
428
|
+
* The higher the number the earlier it appears.
|
|
429
|
+
* @default 0
|
|
430
|
+
*/
|
|
431
|
+
defaultOrder?: number;
|
|
432
|
+
/**
|
|
433
|
+
* The category of the entry
|
|
434
|
+
* @default 'default'
|
|
435
|
+
*/
|
|
436
|
+
category?: DevToolsDockEntryCategory;
|
|
437
|
+
/**
|
|
438
|
+
* Conditional visibility expression.
|
|
439
|
+
* When set, the dock entry is only visible when the expression evaluates to true.
|
|
440
|
+
* Uses the same syntax as command `when` clauses.
|
|
441
|
+
*
|
|
442
|
+
* Set to `'false'` to unconditionally hide the entry.
|
|
443
|
+
*
|
|
444
|
+
* @example 'clientType == embedded'
|
|
445
|
+
* @see {@link import('../utils/when').evaluateWhen}
|
|
446
|
+
*/
|
|
447
|
+
when?: string;
|
|
448
|
+
/**
|
|
449
|
+
* Badge text to display on the dock icon (e.g., unread count)
|
|
450
|
+
*/
|
|
451
|
+
badge?: string;
|
|
452
|
+
}
|
|
453
|
+
interface ClientScriptEntry {
|
|
454
|
+
/**
|
|
455
|
+
* The filepath or module name to import from
|
|
456
|
+
*/
|
|
457
|
+
importFrom: string;
|
|
458
|
+
/**
|
|
459
|
+
* The name to import the module as
|
|
460
|
+
*
|
|
461
|
+
* @default 'default'
|
|
462
|
+
*/
|
|
463
|
+
importName?: string;
|
|
464
|
+
}
|
|
465
|
+
interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
466
|
+
type: 'iframe';
|
|
467
|
+
url: string;
|
|
468
|
+
/**
|
|
469
|
+
* The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared.
|
|
470
|
+
*
|
|
471
|
+
* When not provided, it would be treated as a unique frame.
|
|
472
|
+
*/
|
|
473
|
+
frameId?: string;
|
|
474
|
+
/**
|
|
475
|
+
* Optional client script to import into the iframe
|
|
476
|
+
*/
|
|
477
|
+
clientScript?: ClientScriptEntry;
|
|
478
|
+
/**
|
|
479
|
+
* Enable remote-UI mode: the core injects a connection descriptor
|
|
480
|
+
* (WS URL + pre-approved auth token) into the iframe URL so a hosted
|
|
481
|
+
* page can connect back via `connectRemoteDevTools()` from
|
|
482
|
+
* `@vitejs/devtools-kit/client` — without needing to ship a dist with
|
|
483
|
+
* the plugin.
|
|
484
|
+
*
|
|
485
|
+
* Requires dev mode (no effect in build mode — no WS server exists).
|
|
486
|
+
* When enabled, the dock is automatically hidden in build mode unless
|
|
487
|
+
* the author provides an explicit `when` clause.
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* remote: true
|
|
491
|
+
* remote: { transport: 'query', originLock: false }
|
|
492
|
+
*/
|
|
493
|
+
remote?: boolean | RemoteDockOptions;
|
|
494
|
+
}
|
|
495
|
+
interface RemoteDockOptions {
|
|
496
|
+
/**
|
|
497
|
+
* How to pass the connection descriptor to the hosted page.
|
|
498
|
+
*
|
|
499
|
+
* - `'fragment'` (default): appended as `#vite-devtools-kit-connection=...`.
|
|
500
|
+
* Not sent in HTTP requests or Referer headers — safest for auth tokens.
|
|
501
|
+
* - `'query'`: appended as `?vite-devtools-kit-connection=...`. Use when
|
|
502
|
+
* your hosting platform rewrites fragments or your SPA router repurposes
|
|
503
|
+
* the fragment for navigation. The token will appear in server access
|
|
504
|
+
* logs and outbound Referer headers.
|
|
505
|
+
*
|
|
506
|
+
* @default 'fragment'
|
|
507
|
+
*/
|
|
508
|
+
transport?: 'fragment' | 'query';
|
|
509
|
+
/**
|
|
510
|
+
* Reject WS handshakes whose `Origin` header doesn't match the dock URL
|
|
511
|
+
* origin. Turn off when the same hosted app is served from multiple
|
|
512
|
+
* origins (e.g. preview deploys).
|
|
513
|
+
*
|
|
514
|
+
* @default true
|
|
515
|
+
*/
|
|
516
|
+
originLock?: boolean;
|
|
517
|
+
}
|
|
518
|
+
type DevToolsViewLauncherStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
519
|
+
interface DevToolsViewLauncher extends DevToolsDockEntryBase {
|
|
520
|
+
type: 'launcher';
|
|
521
|
+
launcher: {
|
|
522
|
+
icon?: DevToolsDockEntryIcon;
|
|
523
|
+
title: string;
|
|
524
|
+
status?: DevToolsViewLauncherStatus;
|
|
525
|
+
error?: string;
|
|
526
|
+
description?: string;
|
|
527
|
+
buttonStart?: string;
|
|
528
|
+
buttonLoading?: string;
|
|
529
|
+
onLaunch: () => Promise<void>;
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
interface DevToolsViewAction extends DevToolsDockEntryBase {
|
|
533
|
+
type: 'action';
|
|
534
|
+
action: ClientScriptEntry;
|
|
535
|
+
}
|
|
536
|
+
interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
537
|
+
type: 'custom-render';
|
|
538
|
+
renderer: ClientScriptEntry;
|
|
539
|
+
}
|
|
540
|
+
interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
|
|
541
|
+
type: '~builtin';
|
|
542
|
+
id: '~terminals' | '~logs' | '~client-auth-notice' | '~settings' | '~popup';
|
|
543
|
+
}
|
|
544
|
+
interface JsonRenderElement {
|
|
545
|
+
type: string;
|
|
546
|
+
props?: Record<string, unknown>;
|
|
547
|
+
children?: string[];
|
|
548
|
+
/** json-render event bindings (e.g. `{ press: { action: "my:action" } }`) */
|
|
549
|
+
on?: Record<string, unknown>;
|
|
550
|
+
/** json-render visibility condition */
|
|
551
|
+
visible?: unknown;
|
|
552
|
+
/** json-render repeat binding */
|
|
553
|
+
repeat?: unknown;
|
|
554
|
+
/** Allow additional json-render element fields */
|
|
555
|
+
[key: string]: unknown;
|
|
556
|
+
}
|
|
557
|
+
interface JsonRenderSpec {
|
|
558
|
+
root: string;
|
|
559
|
+
elements: Record<string, JsonRenderElement>;
|
|
560
|
+
/** Initial client-side state model for $state/$bindState expressions */
|
|
561
|
+
state?: Record<string, unknown>;
|
|
562
|
+
}
|
|
563
|
+
interface JsonRenderer {
|
|
564
|
+
/** Replace the entire spec */
|
|
565
|
+
updateSpec: (spec: JsonRenderSpec) => void | Promise<void>;
|
|
566
|
+
/** Update json-render state values (shallow merge into spec.state) */
|
|
567
|
+
updateState: (state: Record<string, unknown>) => void | Promise<void>;
|
|
568
|
+
/** Internal: shared state key used by the client to subscribe */
|
|
569
|
+
readonly _stateKey: string;
|
|
570
|
+
}
|
|
571
|
+
interface DevToolsViewJsonRender extends DevToolsDockEntryBase {
|
|
572
|
+
type: 'json-render';
|
|
573
|
+
/** JsonRenderer handle created by ctx.createJsonRenderer() */
|
|
574
|
+
ui: JsonRenderer;
|
|
575
|
+
}
|
|
576
|
+
type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher | DevToolsViewJsonRender;
|
|
577
|
+
type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
|
|
578
|
+
type DevToolsDockEntriesGrouped = [category: string, entries: DevToolsDockEntry[]][];
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/types/host.d.ts
|
|
581
|
+
interface DevToolsHost {
|
|
582
|
+
/**
|
|
583
|
+
* Serve a static directory at the given URL base. Called by
|
|
584
|
+
* `DevToolsViewHost.hostStatic`. Implementations map this to whatever
|
|
585
|
+
* the underlying runtime expects (Vite middleware, h3 handler, no-op
|
|
586
|
+
* for build snapshots).
|
|
587
|
+
*/
|
|
588
|
+
mountStatic: (base: string, distDir: string) => void | Promise<void>;
|
|
589
|
+
/**
|
|
590
|
+
* Return the public origin the host is reachable at, e.g.
|
|
591
|
+
* `http://localhost:5173`. Used by the dock host to enrich remote
|
|
592
|
+
* iframe URLs with a full `origin`. Called only when a dock needs an
|
|
593
|
+
* absolute URL; hosts that never serve remote docks can return any
|
|
594
|
+
* reasonable value.
|
|
595
|
+
*/
|
|
596
|
+
resolveOrigin: () => string;
|
|
597
|
+
}
|
|
598
|
+
//#endregion
|
|
599
|
+
//#region src/types/logs.d.ts
|
|
600
|
+
type DevToolsLogLevel = 'info' | 'warn' | 'error' | 'success' | 'debug';
|
|
601
|
+
type DevToolsLogEntryFrom = 'server' | 'browser';
|
|
602
|
+
interface DevToolsLogElementPosition {
|
|
603
|
+
/** CSS selector for the element */
|
|
604
|
+
selector?: string;
|
|
605
|
+
/** Bounding box of the element */
|
|
606
|
+
boundingBox?: {
|
|
607
|
+
x: number;
|
|
608
|
+
y: number;
|
|
609
|
+
width: number;
|
|
610
|
+
height: number;
|
|
611
|
+
};
|
|
612
|
+
/** Human-readable description of the element */
|
|
613
|
+
description?: string;
|
|
614
|
+
}
|
|
615
|
+
interface DevToolsLogFilePosition {
|
|
616
|
+
/** Absolute or relative file path */
|
|
617
|
+
file: string;
|
|
618
|
+
/** Line number (1-based) */
|
|
619
|
+
line?: number;
|
|
620
|
+
/** Column number (1-based) */
|
|
621
|
+
column?: number;
|
|
622
|
+
}
|
|
623
|
+
interface DevToolsLogEntry {
|
|
624
|
+
/**
|
|
625
|
+
* Unique identifier for this log entry (auto-generated if not provided)
|
|
626
|
+
*/
|
|
627
|
+
id: string;
|
|
628
|
+
/**
|
|
629
|
+
* Short title or summary of the log
|
|
630
|
+
*/
|
|
631
|
+
message: string;
|
|
632
|
+
/**
|
|
633
|
+
* Optional detailed description or explanation
|
|
634
|
+
*/
|
|
635
|
+
description?: string;
|
|
636
|
+
/**
|
|
637
|
+
* Severity level, determines color and icon
|
|
638
|
+
*/
|
|
639
|
+
level: DevToolsLogLevel;
|
|
640
|
+
/**
|
|
641
|
+
* Optional stack trace string
|
|
642
|
+
*/
|
|
643
|
+
stacktrace?: string;
|
|
644
|
+
/**
|
|
645
|
+
* Optional DOM element position info (e.g., for a11y issues)
|
|
646
|
+
*/
|
|
647
|
+
elementPosition?: DevToolsLogElementPosition;
|
|
648
|
+
/**
|
|
649
|
+
* Optional source file position info (e.g., for lint errors)
|
|
650
|
+
*/
|
|
651
|
+
filePosition?: DevToolsLogFilePosition;
|
|
652
|
+
/**
|
|
653
|
+
* Whether this log should also appear as a toast notification
|
|
654
|
+
*/
|
|
655
|
+
notify?: boolean;
|
|
656
|
+
/**
|
|
657
|
+
* Origin of the log entry, automatically set by the context
|
|
658
|
+
*/
|
|
659
|
+
from: DevToolsLogEntryFrom;
|
|
660
|
+
/**
|
|
661
|
+
* Grouping category (e.g., 'a11y', 'lint', 'runtime', 'test')
|
|
662
|
+
*/
|
|
663
|
+
category?: string;
|
|
664
|
+
/**
|
|
665
|
+
* Optional tags/labels for filtering
|
|
666
|
+
*/
|
|
667
|
+
labels?: string[];
|
|
668
|
+
/**
|
|
669
|
+
* Time in ms to auto-dismiss the toast notification (client-side)
|
|
670
|
+
*/
|
|
671
|
+
autoDismiss?: number;
|
|
672
|
+
/**
|
|
673
|
+
* Time in ms to auto-delete this log entry (server-side)
|
|
674
|
+
*/
|
|
675
|
+
autoDelete?: number;
|
|
676
|
+
/**
|
|
677
|
+
* Timestamp when the log was created (auto-generated if not provided)
|
|
678
|
+
*/
|
|
679
|
+
timestamp: number;
|
|
680
|
+
/**
|
|
681
|
+
* Status of the log entry (e.g., 'loading' while an operation is in progress).
|
|
682
|
+
* Defaults to 'idle' when not specified.
|
|
683
|
+
*/
|
|
684
|
+
status?: 'loading' | 'idle';
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Input type for creating a log entry.
|
|
688
|
+
* `id`, `timestamp`, and `source` are auto-filled by the host.
|
|
689
|
+
*/
|
|
690
|
+
type DevToolsLogEntryInput = Omit<DevToolsLogEntry, 'id' | 'timestamp' | 'from'> & {
|
|
691
|
+
id?: string;
|
|
692
|
+
timestamp?: number;
|
|
693
|
+
};
|
|
694
|
+
interface DevToolsLogHandle {
|
|
695
|
+
/** The underlying log entry data */
|
|
696
|
+
readonly entry: DevToolsLogEntry;
|
|
697
|
+
/** Shortcut to entry.id */
|
|
698
|
+
readonly id: string;
|
|
699
|
+
/** Partial update of this log entry */
|
|
700
|
+
update: (patch: Partial<DevToolsLogEntryInput>) => Promise<DevToolsLogEntry | undefined>;
|
|
701
|
+
/** Remove this log entry */
|
|
702
|
+
dismiss: () => Promise<void>;
|
|
703
|
+
}
|
|
704
|
+
interface DevToolsLogsClient {
|
|
705
|
+
/**
|
|
706
|
+
* Add a log entry. Returns a Promise resolving to a handle for subsequent updates/dismissal.
|
|
707
|
+
* Can be used without `await` for fire-and-forget usage.
|
|
708
|
+
*/
|
|
709
|
+
add: (input: DevToolsLogEntryInput) => Promise<DevToolsLogHandle>;
|
|
710
|
+
/** Remove a log entry by id */
|
|
711
|
+
remove: (id: string) => Promise<void>;
|
|
712
|
+
/** Clear all log entries */
|
|
713
|
+
clear: () => Promise<void>;
|
|
714
|
+
}
|
|
715
|
+
interface DevToolsLogsHost {
|
|
716
|
+
readonly entries: Map<string, DevToolsLogEntry>;
|
|
717
|
+
readonly events: EventEmitter<{
|
|
718
|
+
'log:added': (entry: DevToolsLogEntry) => void;
|
|
719
|
+
'log:updated': (entry: DevToolsLogEntry) => void;
|
|
720
|
+
'log:removed': (id: string) => void;
|
|
721
|
+
'log:cleared': () => void;
|
|
722
|
+
}>;
|
|
723
|
+
/**
|
|
724
|
+
* Add a new log entry. If an entry with the same `id` already exists, it will be updated instead.
|
|
725
|
+
* Returns a handle for subsequent updates/dismissal. Can be used without `await` for fire-and-forget.
|
|
726
|
+
*/
|
|
727
|
+
add: (entry: DevToolsLogEntryInput) => Promise<DevToolsLogHandle>;
|
|
728
|
+
/**
|
|
729
|
+
* Update an existing log entry by id (partial update)
|
|
730
|
+
*/
|
|
731
|
+
update: (id: string, patch: Partial<DevToolsLogEntryInput>) => Promise<DevToolsLogEntry | undefined>;
|
|
732
|
+
/**
|
|
733
|
+
* Remove a log entry by id
|
|
734
|
+
*/
|
|
735
|
+
remove: (id: string) => Promise<void>;
|
|
736
|
+
/**
|
|
737
|
+
* Clear all log entries
|
|
738
|
+
*/
|
|
739
|
+
clear: () => Promise<void>;
|
|
740
|
+
}
|
|
741
|
+
//#endregion
|
|
742
|
+
//#region src/types/rpc-augments.d.ts
|
|
743
|
+
/**
|
|
744
|
+
* To be extended
|
|
745
|
+
*/
|
|
746
|
+
interface DevToolsRpcClientFunctions {}
|
|
747
|
+
/**
|
|
748
|
+
* To be extended
|
|
749
|
+
*/
|
|
750
|
+
interface DevToolsRpcServerFunctions {}
|
|
751
|
+
/**
|
|
752
|
+
* To be extended
|
|
753
|
+
*/
|
|
754
|
+
interface DevToolsRpcSharedStates {}
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region src/types/settings.d.ts
|
|
757
|
+
interface DevToolsDocksUserSettings {
|
|
758
|
+
docksHidden: string[];
|
|
759
|
+
docksCategoriesHidden: string[];
|
|
760
|
+
docksPinned: string[];
|
|
761
|
+
docksCustomOrder: Record<string, number>;
|
|
762
|
+
showIframeAddressBar: boolean;
|
|
763
|
+
closeOnOutsideClick: boolean;
|
|
764
|
+
commandShortcuts: DevToolsCommandShortcutOverrides;
|
|
765
|
+
}
|
|
766
|
+
//#endregion
|
|
767
|
+
//#region src/types/terminals.d.ts
|
|
768
|
+
interface DevToolsTerminalSessionStreamChunkEvent {
|
|
769
|
+
id: string;
|
|
770
|
+
chunks: string[];
|
|
771
|
+
ts: number;
|
|
772
|
+
}
|
|
773
|
+
interface DevToolsTerminalHost {
|
|
774
|
+
readonly sessions: Map<string, DevToolsTerminalSession>;
|
|
775
|
+
readonly events: EventEmitter<{
|
|
776
|
+
'terminal:session:updated': (session: DevToolsTerminalSession) => void;
|
|
777
|
+
'terminal:session:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => void;
|
|
778
|
+
}>;
|
|
779
|
+
register: (session: DevToolsTerminalSession) => DevToolsTerminalSession;
|
|
780
|
+
update: (session: DevToolsTerminalSession) => void;
|
|
781
|
+
startChildProcess: (executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>) => Promise<DevToolsChildProcessTerminalSession>;
|
|
782
|
+
}
|
|
783
|
+
type DevToolsTerminalStatus = 'running' | 'stopped' | 'error';
|
|
784
|
+
interface DevToolsTerminalSessionBase {
|
|
785
|
+
id: string;
|
|
786
|
+
title: string;
|
|
787
|
+
description?: string;
|
|
788
|
+
status: DevToolsTerminalStatus;
|
|
789
|
+
icon?: DevToolsDockEntryIcon;
|
|
790
|
+
}
|
|
791
|
+
interface DevToolsTerminalSession extends DevToolsTerminalSessionBase {
|
|
792
|
+
buffer?: string[];
|
|
793
|
+
stream?: ReadableStream<string>;
|
|
794
|
+
}
|
|
795
|
+
interface DevToolsChildProcessExecuteOptions {
|
|
796
|
+
command: string;
|
|
797
|
+
args: string[];
|
|
798
|
+
cwd?: string;
|
|
799
|
+
env?: Record<string, string>;
|
|
800
|
+
}
|
|
801
|
+
interface DevToolsChildProcessTerminalSession extends DevToolsTerminalSession {
|
|
802
|
+
type: 'child-process';
|
|
803
|
+
executeOptions: DevToolsChildProcessExecuteOptions;
|
|
804
|
+
getChildProcess: () => ChildProcess | undefined;
|
|
805
|
+
terminate: () => Promise<void>;
|
|
806
|
+
restart: () => Promise<void>;
|
|
807
|
+
}
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/types/utils.d.ts
|
|
810
|
+
type Thenable<T> = T | Promise<T>;
|
|
811
|
+
type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as K[0]]: K[1] };
|
|
812
|
+
type PartialWithoutId<T extends {
|
|
813
|
+
id: string;
|
|
814
|
+
}> = Partial<Omit<T, 'id'>> & {
|
|
815
|
+
id: string;
|
|
816
|
+
};
|
|
817
|
+
//#endregion
|
|
818
|
+
//#region src/types/views.d.ts
|
|
819
|
+
interface DevToolsViewHost {
|
|
820
|
+
/**
|
|
821
|
+
* @internal
|
|
822
|
+
*/
|
|
823
|
+
buildStaticDirs: {
|
|
824
|
+
baseUrl: string;
|
|
825
|
+
distDir: string;
|
|
826
|
+
}[];
|
|
827
|
+
/**
|
|
828
|
+
* Helper to host static files
|
|
829
|
+
* - In `dev` mode, it will register middleware to `viteServer.middlewares` to host the static files
|
|
830
|
+
* - In `build` mode, it will copy the static files to the dist directory
|
|
831
|
+
*/
|
|
832
|
+
hostStatic: (baseUrl: string, distDir: string) => void;
|
|
833
|
+
}
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region ../../../node_modules/.pnpm/immer@11.1.4/node_modules/immer/dist/immer.d.ts
|
|
836
|
+
interface Patch {
|
|
837
|
+
op: "replace" | "remove" | "add";
|
|
838
|
+
path: (string | number)[];
|
|
839
|
+
value?: any;
|
|
840
|
+
}
|
|
841
|
+
type Objectish = AnyObject | AnyArray | AnyMap | AnySet;
|
|
842
|
+
type AnyObject = {
|
|
843
|
+
[key: string]: any;
|
|
844
|
+
};
|
|
845
|
+
type AnyArray = Array<any>;
|
|
846
|
+
type AnySet = Set<any>;
|
|
847
|
+
type AnyMap = Map<any, any>;
|
|
848
|
+
/** Returns true if the given value is an Immer draft */
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region src/utils/shared-state.d.ts
|
|
851
|
+
type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
|
|
852
|
+
type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
853
|
+
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
854
|
+
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
855
|
+
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
856
|
+
type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
|
|
857
|
+
/**
|
|
858
|
+
* State host that is immutable by default with explicit mutate.
|
|
859
|
+
*/
|
|
860
|
+
interface SharedState<T> {
|
|
861
|
+
/**
|
|
862
|
+
* Get the current state. Immutable.
|
|
863
|
+
*/
|
|
864
|
+
value: () => Immutable<T>;
|
|
865
|
+
/**
|
|
866
|
+
* Subscribe to state changes.
|
|
867
|
+
*/
|
|
868
|
+
on: EventEmitter<SharedStateEvents<T>>['on'];
|
|
869
|
+
/**
|
|
870
|
+
* Mutate the state.
|
|
871
|
+
*/
|
|
872
|
+
mutate: (fn: (state: T) => void, syncId?: string) => void;
|
|
873
|
+
/**
|
|
874
|
+
* Apply patches to the state.
|
|
875
|
+
*/
|
|
876
|
+
patch: (patches: Patch[], syncId?: string) => void;
|
|
877
|
+
/**
|
|
878
|
+
* Sync IDs that have been applied to the state.
|
|
879
|
+
*/
|
|
880
|
+
syncIds: Set<string>;
|
|
881
|
+
}
|
|
882
|
+
interface SharedStateEvents<T> {
|
|
883
|
+
updated: (fullState: T, patches: Patch[] | undefined, syncId: string) => void;
|
|
884
|
+
}
|
|
885
|
+
interface SharedStateOptions<T> {
|
|
886
|
+
/**
|
|
887
|
+
* Initial state.
|
|
888
|
+
*/
|
|
889
|
+
initialValue: T;
|
|
890
|
+
/**
|
|
891
|
+
* Enable patches.
|
|
892
|
+
*
|
|
893
|
+
* @default false
|
|
894
|
+
*/
|
|
895
|
+
enablePatches?: boolean;
|
|
896
|
+
}
|
|
897
|
+
declare function createSharedState<T extends Objectish>(options: SharedStateOptions<T>): SharedState<T>;
|
|
898
|
+
//#endregion
|
|
899
|
+
//#region src/types/rpc.d.ts
|
|
900
|
+
interface DevToolsNodeRpcSession {
|
|
901
|
+
meta: DevToolsNodeRpcSessionMeta;
|
|
902
|
+
rpc: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
|
|
903
|
+
}
|
|
904
|
+
interface RpcBroadcastOptions<METHOD, Args extends any[]> {
|
|
905
|
+
method: METHOD;
|
|
906
|
+
args: Args;
|
|
907
|
+
optional?: boolean;
|
|
908
|
+
event?: boolean;
|
|
909
|
+
filter?: (client: BirpcReturn<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>) => boolean | void;
|
|
910
|
+
}
|
|
911
|
+
type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> & {
|
|
912
|
+
/**
|
|
913
|
+
* Invoke a locally registered server RPC function directly.
|
|
914
|
+
*
|
|
915
|
+
* This bypasses transport and is useful for server-side cross-function calls.
|
|
916
|
+
*/
|
|
917
|
+
invokeLocal: <T extends keyof DevToolsRpcServerFunctions, Args extends Parameters<DevToolsRpcServerFunctions[T]>>(method: T, ...args: Args) => Promise<Awaited<ReturnType<DevToolsRpcServerFunctions[T]>>>;
|
|
918
|
+
/**
|
|
919
|
+
* Broadcast a message to all connected clients
|
|
920
|
+
*/
|
|
921
|
+
broadcast: <T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(options: RpcBroadcastOptions<T, Args>) => Promise<void>;
|
|
922
|
+
/**
|
|
923
|
+
* Get the current RPC client
|
|
924
|
+
*
|
|
925
|
+
* Available in RPC functions to get the current RPC client
|
|
926
|
+
*/
|
|
927
|
+
getCurrentRpcSession: () => DevToolsNodeRpcSession | undefined;
|
|
928
|
+
/**
|
|
929
|
+
* The shared state host
|
|
930
|
+
*/
|
|
931
|
+
sharedState: RpcSharedStateHost;
|
|
932
|
+
};
|
|
933
|
+
interface RpcSharedStateGetOptions<T> {
|
|
934
|
+
sharedState?: SharedState<T>;
|
|
935
|
+
initialValue?: T;
|
|
936
|
+
}
|
|
937
|
+
interface RpcSharedStateHost {
|
|
938
|
+
get: <T extends keyof DevToolsRpcSharedStates>(key: T, options?: RpcSharedStateGetOptions<DevToolsRpcSharedStates[T]>) => Promise<SharedState<DevToolsRpcSharedStates[T]>>;
|
|
939
|
+
keys: () => string[];
|
|
940
|
+
/**
|
|
941
|
+
* Subscribe to new shared-state keys becoming available. Fires when
|
|
942
|
+
* `get(key, ...)` creates a fresh entry (not on subsequent gets).
|
|
943
|
+
* Useful for protocol adapters (e.g. MCP) that surface shared state
|
|
944
|
+
* as dynamic resources.
|
|
945
|
+
*/
|
|
946
|
+
onKeyAdded: (fn: (key: string) => void) => () => void;
|
|
947
|
+
}
|
|
948
|
+
//#endregion
|
|
949
|
+
//#region src/types/context.d.ts
|
|
950
|
+
interface DevToolsCapabilities {
|
|
951
|
+
rpc?: boolean;
|
|
952
|
+
views?: boolean;
|
|
953
|
+
}
|
|
954
|
+
interface DevToolsNodeContext {
|
|
955
|
+
readonly workspaceRoot: string;
|
|
956
|
+
readonly cwd: string;
|
|
957
|
+
readonly mode: 'dev' | 'build';
|
|
958
|
+
/**
|
|
959
|
+
* Host runtime abstraction — exposes `mountStatic` / `resolveOrigin`.
|
|
960
|
+
*/
|
|
961
|
+
host: DevToolsHost;
|
|
962
|
+
rpc: RpcFunctionsHost;
|
|
963
|
+
docks: DevToolsDockHost;
|
|
964
|
+
views: DevToolsViewHost;
|
|
965
|
+
utils: DevToolsNodeUtils;
|
|
966
|
+
terminals: DevToolsTerminalHost;
|
|
967
|
+
logs: DevToolsLogsHost;
|
|
968
|
+
commands: DevToolsCommandsHost;
|
|
969
|
+
/**
|
|
970
|
+
* Agent host — aggregates the agent-exposed surface of this devtool.
|
|
971
|
+
*
|
|
972
|
+
* @experimental
|
|
973
|
+
*/
|
|
974
|
+
agent: DevToolsAgentHost;
|
|
975
|
+
/**
|
|
976
|
+
* Create a JsonRenderer handle for building json-render powered UIs.
|
|
977
|
+
*/
|
|
978
|
+
createJsonRenderer: (spec: JsonRenderSpec) => JsonRenderer;
|
|
979
|
+
}
|
|
980
|
+
interface DevToolsNodeUtils {
|
|
981
|
+
/**
|
|
982
|
+
* Create a simple client script from a function or stringified code.
|
|
983
|
+
*
|
|
984
|
+
* @deprecated testing helper; prefer a proper importable module.
|
|
985
|
+
* @experimental
|
|
986
|
+
*/
|
|
987
|
+
createSimpleClientScript: (fn: string | ((ctx: any) => void)) => ClientScriptEntry;
|
|
988
|
+
}
|
|
989
|
+
interface ConnectionMeta {
|
|
990
|
+
backend: 'websocket' | 'static';
|
|
991
|
+
websocket?: number | string;
|
|
992
|
+
}
|
|
993
|
+
interface RemoteConnectionInfo extends ConnectionMeta {
|
|
994
|
+
backend: 'websocket';
|
|
995
|
+
websocket: string;
|
|
996
|
+
v: 1;
|
|
997
|
+
authToken: string;
|
|
998
|
+
origin: string;
|
|
999
|
+
}
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region src/types/devtool.d.ts
|
|
1002
|
+
type DevtoolRuntime = 'cli' | 'build' | 'spa' | 'vite' | 'kit' | 'embedded';
|
|
1003
|
+
/**
|
|
1004
|
+
* Classification of how a devtool is being deployed. Hosted adapters
|
|
1005
|
+
* (`vite`, `kit`, `embedded`) share their origin with a host app and
|
|
1006
|
+
* must namespace their mount path under `/.<id>/`. Standalone adapters
|
|
1007
|
+
* (`cli`, `spa`, `build`) own the origin and default to `/`.
|
|
1008
|
+
*/
|
|
1009
|
+
type DevtoolDeploymentKind = 'standalone' | 'hosted';
|
|
1010
|
+
interface DevtoolCliOptions {
|
|
1011
|
+
/** Binary name; default: the devtool's `id`. */
|
|
1012
|
+
command?: string;
|
|
1013
|
+
/** Preferred port for the dev server (default 9999). */
|
|
1014
|
+
port?: number;
|
|
1015
|
+
/** Port scan range, forwarded to `get-port-please`. */
|
|
1016
|
+
portRange?: [number, number];
|
|
1017
|
+
/** Prefer a random open port. */
|
|
1018
|
+
random?: boolean;
|
|
1019
|
+
/** Default host to bind to; `--host` overrides. */
|
|
1020
|
+
host?: string;
|
|
1021
|
+
/**
|
|
1022
|
+
* Auto-open the browser when the dev server starts.
|
|
1023
|
+
* `true` opens the resolved origin; a string opens that relative path.
|
|
1024
|
+
* The `--open` / `--no-open` flags override this.
|
|
1025
|
+
*/
|
|
1026
|
+
open?: boolean | string;
|
|
1027
|
+
/**
|
|
1028
|
+
* Skip the RPC trust handshake. Set to `false` for trusted
|
|
1029
|
+
* single-user localhost tools. Default `true`.
|
|
1030
|
+
*
|
|
1031
|
+
* Forwarded to `startHttpAndWs` as a no-op placeholder until devframe
|
|
1032
|
+
* ships its own auth layer; `@vitejs/devtools` honors the equivalent
|
|
1033
|
+
* `devtools.clientAuth` today.
|
|
1034
|
+
*/
|
|
1035
|
+
auth?: boolean;
|
|
1036
|
+
/** Author's SPA dist directory (served as the devtool's UI). */
|
|
1037
|
+
distDir?: string;
|
|
1038
|
+
/**
|
|
1039
|
+
* Capability-side CAC hook. Called with the CAC instance after the
|
|
1040
|
+
* adapter registers its built-in commands (`build` / `spa` / `mcp`)
|
|
1041
|
+
* but before `createCli`'s own `configureCli` caller. Use this to
|
|
1042
|
+
* contribute tool-specific flags and subcommands from the definition
|
|
1043
|
+
* itself.
|
|
1044
|
+
*/
|
|
1045
|
+
configure?: (cli: CAC) => void;
|
|
1046
|
+
/**
|
|
1047
|
+
* Typed CLI flags for the default `dev` command, backed by valibot
|
|
1048
|
+
* schemas. The adapter registers matching `--kebab-key` options on
|
|
1049
|
+
* CAC, validates the parsed values, and forwards the typed bag to
|
|
1050
|
+
* `setup(ctx, { flags })`.
|
|
1051
|
+
*
|
|
1052
|
+
* Use {@link defineCliFlags} to preserve the literal schema-map
|
|
1053
|
+
* shape, and {@link InferCliFlags} to recover the typed output at the
|
|
1054
|
+
* call site:
|
|
1055
|
+
*
|
|
1056
|
+
* ```ts
|
|
1057
|
+
* const appFlags = defineCliFlags({
|
|
1058
|
+
* depth: v.pipe(v.number(), v.integer()),
|
|
1059
|
+
* config: v.optional(v.string()),
|
|
1060
|
+
* })
|
|
1061
|
+
*
|
|
1062
|
+
* defineDevtool({
|
|
1063
|
+
* cli: { flags: appFlags },
|
|
1064
|
+
* setup(ctx, info) {
|
|
1065
|
+
* const flags = info.flags as InferCliFlags<typeof appFlags>
|
|
1066
|
+
* },
|
|
1067
|
+
* })
|
|
1068
|
+
* ```
|
|
1069
|
+
*/
|
|
1070
|
+
flags?: CliFlagsSchema;
|
|
1071
|
+
}
|
|
1072
|
+
interface DevtoolSpaOptions {
|
|
1073
|
+
base?: string;
|
|
1074
|
+
/**
|
|
1075
|
+
* How the deployed SPA loads its data.
|
|
1076
|
+
* - `'query'` — read from URL search params.
|
|
1077
|
+
* - `'upload'` — accept a file drag-drop.
|
|
1078
|
+
* - `'none'` — use the baked RPC dump only.
|
|
1079
|
+
*/
|
|
1080
|
+
loader?: 'query' | 'upload' | 'none';
|
|
1081
|
+
}
|
|
1082
|
+
interface DevtoolBrowserContext {
|
|
1083
|
+
/**
|
|
1084
|
+
* The connected RPC client (may be write-disabled in static/spa modes).
|
|
1085
|
+
*/
|
|
1086
|
+
rpc: unknown;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Runtime information threaded into `setup(ctx, info)`. Adapters
|
|
1090
|
+
* populate the fields that make sense for their deployment. In
|
|
1091
|
+
* particular, `createCli` fills `flags` with the parsed CAC bag.
|
|
1092
|
+
*/
|
|
1093
|
+
interface DevtoolSetupInfo {
|
|
1094
|
+
/** Parsed CLI flags, populated by the CLI adapter. */
|
|
1095
|
+
flags?: Record<string, unknown>;
|
|
1096
|
+
}
|
|
1097
|
+
interface DevtoolDefinition {
|
|
1098
|
+
id: string;
|
|
1099
|
+
name: string;
|
|
1100
|
+
icon?: string | {
|
|
1101
|
+
light: string;
|
|
1102
|
+
dark: string;
|
|
1103
|
+
};
|
|
1104
|
+
version?: string;
|
|
1105
|
+
/**
|
|
1106
|
+
* Mount path override. Defaults depend on the adapter:
|
|
1107
|
+
* `/` for standalone (`cli` / `spa` / `build`), `/.<id>/` for hosted
|
|
1108
|
+
* (`vite` / `kit` / `embedded`).
|
|
1109
|
+
*/
|
|
1110
|
+
basePath?: string;
|
|
1111
|
+
capabilities?: {
|
|
1112
|
+
dev?: boolean | Record<string, boolean>;
|
|
1113
|
+
build?: boolean | Record<string, boolean>;
|
|
1114
|
+
spa?: boolean | Record<string, boolean>;
|
|
1115
|
+
};
|
|
1116
|
+
/** Server-side setup — the primary entrypoint. Runs in every runtime. */
|
|
1117
|
+
setup: (ctx: DevToolsNodeContext, info?: DevtoolSetupInfo) => void | Promise<void>;
|
|
1118
|
+
/** Browser-only setup for the SPA adapter (bundled into the client). */
|
|
1119
|
+
setupBrowser?: (ctx: DevtoolBrowserContext) => void | Promise<void>;
|
|
1120
|
+
cli?: DevtoolCliOptions;
|
|
1121
|
+
spa?: DevtoolSpaOptions;
|
|
1122
|
+
}
|
|
1123
|
+
declare function defineDevtool(d: DevtoolDefinition): DevtoolDefinition;
|
|
1124
|
+
//#endregion
|
|
1125
|
+
export { DevToolsLogsHost as $, DevToolsViewHost as A, AgentHandle as At, DevToolsTerminalStatus as B, EventUnsubscribe as Bt, ImmutableSet as C, DevToolsCommandHandle as Ct, createSharedState as D, DevToolsCommandsHostEvents as Dt, SharedStateOptions as E, DevToolsCommandsHost as Et, DevToolsChildProcessTerminalSession as F, AgentTool as Ft, DevToolsLogElementPosition as G, DevToolsRpcClientFunctions as H, CliFlagsSchema as Ht, DevToolsTerminalHost as I, AgentToolInput as It, DevToolsLogEntryInput as J, DevToolsLogEntry as K, DevToolsTerminalSession as L, DevToolsAgentHost as Lt, PartialWithoutId as M, AgentResource as Mt, Thenable as N, AgentResourceContent as Nt, Objectish as O, DevToolsServerCommandEntry as Ot, DevToolsChildProcessExecuteOptions as P, AgentResourceInput as Pt, DevToolsLogsClient as Q, DevToolsTerminalSessionBase as R, DevToolsAgentHostEvents as Rt, ImmutableObject as S, DevToolsCommandEntry as St, SharedStateEvents as T, DevToolsCommandShortcutOverrides as Tt, DevToolsRpcServerFunctions as U, InferCliFlags as Ut, DevToolsDocksUserSettings as V, EventsMap as Vt, DevToolsRpcSharedStates as W, defineCliFlags as Wt, DevToolsLogHandle as X, DevToolsLogFilePosition as Y, DevToolsLogLevel as Z, RpcSharedStateGetOptions as _, JsonRenderSpec as _t, DevtoolRuntime as a, DevToolsDockEntryCategory as at, ImmutableArray as b, DevToolsClientCommand as bt, defineDevtool as c, DevToolsDockUserEntry as ct, DevToolsNodeContext as d, DevToolsViewCustomRender as dt, DevToolsHost as et, DevToolsNodeUtils as f, DevToolsViewIframe as ft, RpcFunctionsHost as g, JsonRenderElement as gt, RpcBroadcastOptions as h, DevToolsViewLauncherStatus as ht, DevtoolDeploymentKind as i, DevToolsDockEntryBase as it, EntriesToObject as j, AgentManifest as jt, Patch as k, DevToolsServerCommandInput as kt, ConnectionMeta as l, DevToolsViewAction as lt, DevToolsNodeRpcSession as m, DevToolsViewLauncher as mt, DevtoolCliOptions as n, DevToolsDockEntriesGrouped as nt, DevtoolSetupInfo as o, DevToolsDockEntryIcon as ot, RemoteConnectionInfo as p, DevToolsViewJsonRender as pt, DevToolsLogEntryFrom as q, DevtoolDefinition as r, DevToolsDockEntry as rt, DevtoolSpaOptions as s, DevToolsDockHost as st, DevtoolBrowserContext as t, ClientScriptEntry as tt, DevToolsCapabilities as u, DevToolsViewBuiltin as ut, RpcSharedStateHost as v, JsonRenderer as vt, SharedState as w, DevToolsCommandKeybinding as wt, ImmutableMap as x, DevToolsCommandBase as xt, Immutable as y, RemoteDockOptions as yt, DevToolsTerminalSessionStreamChunkEvent as z, EventEmitter as zt };
|