devframe 0.0.0 → 0.1.17
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-Bxa2_kq7.mjs +20 -0
- package/dist/adapters/build.d.mts +37 -0
- package/dist/adapters/build.mjs +68 -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 +228 -0
- package/dist/client/index.mjs +2 -0
- package/dist/client-CsR1_h3o.mjs +1569 -0
- package/dist/constants.d.mts +20 -0
- package/dist/constants.mjs +34 -0
- package/dist/context-xQo1FcxX.mjs +6827 -0
- package/dist/define-CW9gLnyG.mjs +11 -0
- package/dist/devtool-CHT-4_OU.d.mts +1233 -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-DEqg5kOd.mjs +894 -0
- package/dist/index-Cei8vVcd.d.mts +140 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +2 -0
- package/dist/main-BJD9t8dk.mjs +601 -0
- package/dist/node/index.d.mts +393 -0
- package/dist/node/index.mjs +69 -0
- package/dist/open-BMO2_-wC.mjs +533 -0
- package/dist/recipes/open-helpers.d.mts +108 -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 +3 -0
- package/dist/rpc/index.mjs +4 -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 +58 -0
- package/dist/rpc/transports/ws-server.d.mts +2 -0
- package/dist/rpc/transports/ws-server.mjs +73 -0
- package/dist/rpc-hbRk8qtt.mjs +456 -0
- package/dist/serialization-CWcWE7x7.mjs +112 -0
- package/dist/server-DkJ2-s0Y.mjs +49 -0
- package/dist/src-DIKqQIjp.mjs +85 -0
- package/dist/static-dump-DwFfj4U_.mjs +97 -0
- package/dist/transports-4bqw6Fqg.mjs +15 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/types/index.mjs +6 -0
- package/dist/types-BkyzI9r4.d.mts +273 -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-aBBXAEh5.d.mts +401 -0
- package/dist/ws-client-CDGmViwt.d.mts +26 -0
- package/dist/ws-server-Cu8tmZcF.d.mts +49 -0
- package/package.json +116 -8
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { A as DevToolsViewHost$1, At as DevToolsDiagnosticsHost$1, Bt as DevToolsServerCommandEntry, F as DevToolsChildProcessTerminalSession, Ft as DevToolsCommandHandle, Gt as AgentResourceContent, H as DevToolsRpcClientFunctions, Ht as AgentHandle, I as DevToolsTerminalHost$1, Jt as AgentToolInput, Kt as AgentResourceInput, L as DevToolsTerminalSession, M as PartialWithoutId, P as DevToolsChildProcessExecuteOptions, R as DevToolsTerminalSessionBase, Rt as DevToolsCommandsHost$1, U as DevToolsRpcServerFunctions, Ut as AgentManifest, V as DevToolsDocksUserSettings, Vt as DevToolsServerCommandInput, Wt as AgentResource, Xt as DevToolsAgentHostEvents, Yt as DevToolsAgentHost$1, Zt as EventEmitter, _t as DevToolsDockUserEntry, at as DevToolsMessageHandle, ct as DevToolsMessagesHost$1, d as DevToolsNodeContext, ft as DevToolsDockEntry, g as RpcFunctionsHost$1, gt as DevToolsDockHost$1, h as RpcBroadcastOptions, jt as DevToolsDiagnosticsLogger, lt as DevToolsHost, m as DevToolsNodeRpcSession, qt as AgentTool, rt as DevToolsMessageEntryInput, tt as DevToolsMessageEntry, ut as ClientScriptEntry, v as RpcSharedStateHost, w as SharedState } from "../devtool-CHT-4_OU.mjs";
|
|
2
|
+
import { g as RpcFunctionsCollectorBase } from "../index-Cei8vVcd.mjs";
|
|
3
|
+
import { g as RpcFunctionDefinitionAny } from "../types-BkyzI9r4.mjs";
|
|
4
|
+
import { createLogger, defineDiagnostics } from "logs-sdk";
|
|
5
|
+
import { BirpcGroup } from "birpc";
|
|
6
|
+
import { WebSocketServer } from "ws";
|
|
7
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
|
+
import { App } from "h3";
|
|
9
|
+
|
|
10
|
+
//#region src/node/context-internal.d.ts
|
|
11
|
+
interface InternalAnonymousAuthStorage {
|
|
12
|
+
trusted: Record<string, {
|
|
13
|
+
authToken: string;
|
|
14
|
+
ua: string;
|
|
15
|
+
origin: string;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
} | undefined>;
|
|
18
|
+
}
|
|
19
|
+
interface RemoteTokenRecord {
|
|
20
|
+
dockId: string;
|
|
21
|
+
/** Dock URL origin — matched against WS handshake `Origin` header when `originLock` is on. */
|
|
22
|
+
origin: string;
|
|
23
|
+
originLock: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface DevToolsInternalContext {
|
|
26
|
+
storage: {
|
|
27
|
+
auth: SharedState<InternalAnonymousAuthStorage>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Revoke an auth token: remove from storage and notify all connected clients
|
|
31
|
+
* using this token that they are no longer trusted.
|
|
32
|
+
*/
|
|
33
|
+
revokeAuthToken: (token: string) => Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Session-only tokens issued to remote-UI iframe docks. Not persisted —
|
|
36
|
+
* regenerated on every dev-server restart.
|
|
37
|
+
*/
|
|
38
|
+
remoteTokens: Map<string, RemoteTokenRecord>;
|
|
39
|
+
allocateRemoteToken: (dockId: string, origin: string, originLock: boolean) => string;
|
|
40
|
+
revokeRemoteToken: (token: string) => void;
|
|
41
|
+
revokeRemoteTokensForDock: (dockId: string) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Returns true if `token` is a valid remote token and, when `originLock` is
|
|
44
|
+
* on, `requestOrigin` matches the recorded dock origin.
|
|
45
|
+
*/
|
|
46
|
+
isRemoteTokenTrusted: (token: string, requestOrigin?: string) => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Populated by `createWsServer` once the WS port is bound. Consumed by the
|
|
49
|
+
* docks host when enriching remote iframe URLs with a connection descriptor.
|
|
50
|
+
*/
|
|
51
|
+
wsEndpoint?: {
|
|
52
|
+
/** Full `ws://` or `wss://` URL with host and port. */url: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
declare const internalContextMap: WeakMap<DevToolsNodeContext, DevToolsInternalContext>;
|
|
56
|
+
declare function getInternalContext(context: DevToolsNodeContext): DevToolsInternalContext;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/node/auth-revoke.d.ts
|
|
59
|
+
/**
|
|
60
|
+
* Flip `isTrusted` to false on any live WS clients connected with `token`
|
|
61
|
+
* and broadcast the `auth:revoked` event so they can react.
|
|
62
|
+
*
|
|
63
|
+
* Shared between persisted-auth revocation and remote-dock token revocation.
|
|
64
|
+
*/
|
|
65
|
+
declare function revokeActiveConnectionsForToken(context: DevToolsNodeContext, token: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Revoke an auth token: remove from storage and notify all connected clients
|
|
68
|
+
* using this token that they are no longer trusted.
|
|
69
|
+
*/
|
|
70
|
+
declare function revokeAuthToken(context: DevToolsNodeContext, storage: SharedState<InternalAnonymousAuthStorage>, token: string): Promise<void>;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/node/auth-state.d.ts
|
|
73
|
+
interface PendingAuthRequest {
|
|
74
|
+
clientAuthToken: string;
|
|
75
|
+
session: DevToolsNodeRpcSession;
|
|
76
|
+
ua: string;
|
|
77
|
+
origin: string;
|
|
78
|
+
resolve: (result: {
|
|
79
|
+
isTrusted: boolean;
|
|
80
|
+
}) => void;
|
|
81
|
+
abortController: AbortController;
|
|
82
|
+
timeout: ReturnType<typeof setTimeout>;
|
|
83
|
+
}
|
|
84
|
+
declare function getTempAuthToken(): string;
|
|
85
|
+
declare function refreshTempAuthToken(): string;
|
|
86
|
+
declare function getPendingAuth(): PendingAuthRequest | null;
|
|
87
|
+
declare function setPendingAuth(request: PendingAuthRequest | null): void;
|
|
88
|
+
/**
|
|
89
|
+
* Abort and clean up any existing pending auth request.
|
|
90
|
+
*/
|
|
91
|
+
declare function abortPendingAuth(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Consume the temp auth ID: verify it matches, trust the pending client, and clean up.
|
|
94
|
+
* Returns the client's authToken if successful, null otherwise.
|
|
95
|
+
*/
|
|
96
|
+
declare function consumeTempAuthToken(id: string, storage: SharedState<InternalAnonymousAuthStorage>): string | null;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/node/context.d.ts
|
|
99
|
+
interface CreateHostContextOptions {
|
|
100
|
+
cwd: string;
|
|
101
|
+
workspaceRoot?: string;
|
|
102
|
+
mode: 'dev' | 'build';
|
|
103
|
+
host: DevToolsHost;
|
|
104
|
+
/**
|
|
105
|
+
* Built-in RPC declarations to register on the host. Framework
|
|
106
|
+
* adapters (vite, rolldown, cli) can pass the ones they need; the
|
|
107
|
+
* host itself has no opinions about the built-in set.
|
|
108
|
+
*/
|
|
109
|
+
builtinRpcDeclarations?: readonly RpcFunctionDefinitionAny[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Framework-neutral core of the DevTools node context. Wires the six
|
|
113
|
+
* host subsystems, the JSON-render factory, and the standard shared-state
|
|
114
|
+
* bookkeeping. Framework-specific extensions (Vite plugin scan, Vite
|
|
115
|
+
* config/server fields, built-in RPCs like `open-in-editor`) layer on
|
|
116
|
+
* top via wrapper functions such as kit's `createDevToolsContext`.
|
|
117
|
+
*/
|
|
118
|
+
declare function createHostContext(options: CreateHostContextOptions): Promise<DevToolsNodeContext>;
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/node/context-utils.d.ts
|
|
121
|
+
declare const ContextUtils: {
|
|
122
|
+
createSimpleClientScript(fn: string | ((ctx: any) => void)): ClientScriptEntry;
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/node/host-agent.d.ts
|
|
126
|
+
/**
|
|
127
|
+
* Framework-neutral host aggregating the agent-exposed surface of a
|
|
128
|
+
* devtool. Auto-discovers RPC functions with an `agent` field from
|
|
129
|
+
* `ctx.rpc.definitions`, and accepts plugin-registered tools /
|
|
130
|
+
* resources via `registerTool` / `registerResource`.
|
|
131
|
+
*
|
|
132
|
+
* @experimental
|
|
133
|
+
*/
|
|
134
|
+
declare class DevToolsAgentHost implements DevToolsAgentHost$1 {
|
|
135
|
+
readonly context: DevToolsNodeContext;
|
|
136
|
+
readonly events: EventEmitter<DevToolsAgentHostEvents>;
|
|
137
|
+
private readonly tools;
|
|
138
|
+
private readonly resources;
|
|
139
|
+
private _rpcUnsubscribe;
|
|
140
|
+
constructor(context: DevToolsNodeContext);
|
|
141
|
+
registerTool(input: AgentToolInput): AgentHandle;
|
|
142
|
+
unregisterTool(id: string): boolean;
|
|
143
|
+
registerResource(input: AgentResourceInput): AgentHandle;
|
|
144
|
+
unregisterResource(id: string): boolean;
|
|
145
|
+
list(): AgentManifest;
|
|
146
|
+
getTool(id: string): AgentTool | undefined;
|
|
147
|
+
getResource(id: string): AgentResource | undefined;
|
|
148
|
+
invoke(id: string, args: unknown): Promise<unknown>;
|
|
149
|
+
read(id: string): Promise<AgentResourceContent>;
|
|
150
|
+
/** @internal */
|
|
151
|
+
_dispose(): void;
|
|
152
|
+
private _validateToolId;
|
|
153
|
+
private _projectTool;
|
|
154
|
+
private _collectRpcTools;
|
|
155
|
+
private _findRpcDefinition;
|
|
156
|
+
private _coercePositionalArgs;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/node/host-commands.d.ts
|
|
160
|
+
declare class DevToolsCommandsHost implements DevToolsCommandsHost$1 {
|
|
161
|
+
readonly context: DevToolsNodeContext;
|
|
162
|
+
readonly commands: DevToolsCommandsHost$1['commands'];
|
|
163
|
+
readonly events: DevToolsCommandsHost$1['events'];
|
|
164
|
+
constructor(context: DevToolsNodeContext);
|
|
165
|
+
register(command: DevToolsServerCommandInput): DevToolsCommandHandle;
|
|
166
|
+
unregister(id: string): boolean;
|
|
167
|
+
execute(id: string, ...args: any[]): Promise<unknown>;
|
|
168
|
+
list(): DevToolsServerCommandEntry[];
|
|
169
|
+
private findCommand;
|
|
170
|
+
private toSerializable;
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/node/host-diagnostics.d.ts
|
|
174
|
+
declare class DevToolsDiagnosticsHost implements DevToolsDiagnosticsHost$1 {
|
|
175
|
+
readonly context: DevToolsNodeContext;
|
|
176
|
+
private _definitions;
|
|
177
|
+
private _logger;
|
|
178
|
+
readonly defineDiagnostics: typeof defineDiagnostics;
|
|
179
|
+
readonly createLogger: typeof createLogger;
|
|
180
|
+
constructor(context: DevToolsNodeContext, initialDefinitions?: unknown[]);
|
|
181
|
+
get logger(): DevToolsDiagnosticsLogger;
|
|
182
|
+
register(definitions: unknown): void;
|
|
183
|
+
private _rebuild;
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/node/host-docks.d.ts
|
|
187
|
+
declare class DevToolsDockHost implements DevToolsDockHost$1 {
|
|
188
|
+
readonly context: DevToolsNodeContext;
|
|
189
|
+
readonly views: DevToolsDockHost$1['views'];
|
|
190
|
+
readonly events: DevToolsDockHost$1['events'];
|
|
191
|
+
userSettings: SharedState<DevToolsDocksUserSettings>;
|
|
192
|
+
/** Dock-id → allocated remote token + resolved options. */
|
|
193
|
+
private readonly remoteDocks;
|
|
194
|
+
constructor(context: DevToolsNodeContext);
|
|
195
|
+
init(): Promise<void>;
|
|
196
|
+
values({
|
|
197
|
+
includeBuiltin
|
|
198
|
+
}?: {
|
|
199
|
+
includeBuiltin?: boolean;
|
|
200
|
+
}): DevToolsDockEntry[];
|
|
201
|
+
private projectView;
|
|
202
|
+
private resolveDevServerOrigin;
|
|
203
|
+
register<T extends DevToolsDockUserEntry>(view: T, force?: boolean): {
|
|
204
|
+
update: (patch: Partial<T>) => void;
|
|
205
|
+
};
|
|
206
|
+
update(view: DevToolsDockUserEntry): void;
|
|
207
|
+
private prepareRemoteRegistration;
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/node/host-functions.d.ts
|
|
211
|
+
declare class RpcFunctionsHost extends RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> implements RpcFunctionsHost$1 {
|
|
212
|
+
/**
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
_rpcGroup: BirpcGroup<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
|
|
216
|
+
_asyncStorage: AsyncLocalStorage<DevToolsNodeRpcSession>;
|
|
217
|
+
constructor(context: DevToolsNodeContext);
|
|
218
|
+
sharedState: RpcSharedStateHost;
|
|
219
|
+
invokeLocal<T extends keyof DevToolsRpcServerFunctions, Args extends Parameters<DevToolsRpcServerFunctions[T]>>(method: T, ...args: Args): Promise<Awaited<ReturnType<DevToolsRpcServerFunctions[T]>>>;
|
|
220
|
+
broadcast<T extends keyof DevToolsRpcClientFunctions, Args extends Parameters<DevToolsRpcClientFunctions[T]>>(options: RpcBroadcastOptions<T, Args>): Promise<void>;
|
|
221
|
+
getCurrentRpcSession(): DevToolsNodeRpcSession | undefined;
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/node/host-h3.d.ts
|
|
225
|
+
interface CreateH3DevToolsHostOptions {
|
|
226
|
+
/** The h3 app instance — registered once the CLI adapter lands. */
|
|
227
|
+
app?: unknown;
|
|
228
|
+
/**
|
|
229
|
+
* Host the standalone server listens on, e.g. `http://localhost:9999`.
|
|
230
|
+
* Consumed by `resolveOrigin` for dock entries that need an absolute URL.
|
|
231
|
+
*/
|
|
232
|
+
origin: string;
|
|
233
|
+
/**
|
|
234
|
+
* Register a static-file handler at `base` serving files from `distDir`.
|
|
235
|
+
* Wired into the h3 app once the CLI adapter lands (commit 5). For now
|
|
236
|
+
* the CLI isn't running, so the default is a no-op.
|
|
237
|
+
*/
|
|
238
|
+
mount?: (base: string, distDir: string) => void | Promise<void>;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* h3-backed {@link DevToolsHost} — used by the standalone CLI adapter.
|
|
242
|
+
* This commit adds the shell; the CLI adapter in commit 5 wires it up
|
|
243
|
+
* with a real h3 app and sirv handler.
|
|
244
|
+
*/
|
|
245
|
+
declare function createH3DevToolsHost(options: CreateH3DevToolsHostOptions): DevToolsHost;
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/node/host-messages.d.ts
|
|
248
|
+
declare class DevToolsMessagesHost implements DevToolsMessagesHost$1 {
|
|
249
|
+
readonly context: DevToolsNodeContext;
|
|
250
|
+
readonly entries: DevToolsMessagesHost$1['entries'];
|
|
251
|
+
readonly events: DevToolsMessagesHost$1['events'];
|
|
252
|
+
/** Tracks when each entry was last added or updated (monotonic) */
|
|
253
|
+
readonly lastModified: Map<string, number>;
|
|
254
|
+
/** Tracks recently removed entry IDs with their removal time */
|
|
255
|
+
readonly removals: Array<{
|
|
256
|
+
id: string;
|
|
257
|
+
time: number;
|
|
258
|
+
}>;
|
|
259
|
+
private _autoDeleteTimers;
|
|
260
|
+
private _clock;
|
|
261
|
+
private _tick;
|
|
262
|
+
constructor(context: DevToolsNodeContext);
|
|
263
|
+
add(input: DevToolsMessageEntryInput): Promise<DevToolsMessageHandle>;
|
|
264
|
+
update(id: string, patch: Partial<DevToolsMessageEntryInput>): Promise<DevToolsMessageEntry | undefined>;
|
|
265
|
+
remove(id: string): Promise<void>;
|
|
266
|
+
clear(): Promise<void>;
|
|
267
|
+
private _createHandle;
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/node/host-terminals.d.ts
|
|
271
|
+
declare class DevToolsTerminalHost implements DevToolsTerminalHost$1 {
|
|
272
|
+
readonly context: DevToolsNodeContext;
|
|
273
|
+
readonly sessions: DevToolsTerminalHost$1['sessions'];
|
|
274
|
+
readonly events: DevToolsTerminalHost$1['events'];
|
|
275
|
+
private _boundStreams;
|
|
276
|
+
constructor(context: DevToolsNodeContext);
|
|
277
|
+
register(session: DevToolsTerminalSession): DevToolsTerminalSession;
|
|
278
|
+
update(patch: PartialWithoutId<DevToolsTerminalSession>): void;
|
|
279
|
+
remove(session: DevToolsTerminalSession): void;
|
|
280
|
+
private bindStream;
|
|
281
|
+
startChildProcess(executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>): Promise<DevToolsChildProcessTerminalSession>;
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/node/host-views.d.ts
|
|
285
|
+
declare class DevToolsViewHost implements DevToolsViewHost$1 {
|
|
286
|
+
readonly context: DevToolsNodeContext;
|
|
287
|
+
/**
|
|
288
|
+
* @internal
|
|
289
|
+
*/
|
|
290
|
+
buildStaticDirs: {
|
|
291
|
+
baseUrl: string;
|
|
292
|
+
distDir: string;
|
|
293
|
+
}[];
|
|
294
|
+
constructor(context: DevToolsNodeContext);
|
|
295
|
+
hostStatic(baseUrl: string, distDir: string): void;
|
|
296
|
+
}
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/node/rpc-shared-state.d.ts
|
|
299
|
+
declare function createRpcSharedStateServerHost(rpc: RpcFunctionsHost$1): RpcSharedStateHost;
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/node/server.d.ts
|
|
302
|
+
interface StartHttpAndWsOptions {
|
|
303
|
+
context: DevToolsNodeContext;
|
|
304
|
+
host?: string;
|
|
305
|
+
port: number;
|
|
306
|
+
/**
|
|
307
|
+
* Optional h3 app to mount on. When omitted a fresh one is created;
|
|
308
|
+
* when provided, callers can add their own routes (sirv etc.) first.
|
|
309
|
+
*/
|
|
310
|
+
app?: App;
|
|
311
|
+
/**
|
|
312
|
+
* When `false`, the RPC server is started without a trust handshake.
|
|
313
|
+
* Intended for single-user localhost tools where an auth round-trip
|
|
314
|
+
* would only get in the way. The Vite-flavoured auth layer in
|
|
315
|
+
* `@vitejs/devtools` already honors the equivalent
|
|
316
|
+
* `devtools.clientAuth` setting; devframe records the intent here so
|
|
317
|
+
* future auth plumbing can consult it without another API change.
|
|
318
|
+
*
|
|
319
|
+
* Default: `true`.
|
|
320
|
+
*/
|
|
321
|
+
auth?: boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Called once the WS server is bound so callers can mount static
|
|
324
|
+
* handlers whose origin depends on the resolved port, or print their
|
|
325
|
+
* own startup banner. Devframe does not print one itself.
|
|
326
|
+
*/
|
|
327
|
+
onReady?: (info: {
|
|
328
|
+
origin: string;
|
|
329
|
+
port: number;
|
|
330
|
+
app: App;
|
|
331
|
+
}) => void | Promise<void>;
|
|
332
|
+
}
|
|
333
|
+
interface StartedServer {
|
|
334
|
+
/** Listening origin, e.g. `http://localhost:9999`. */
|
|
335
|
+
origin: string;
|
|
336
|
+
port: number;
|
|
337
|
+
app: App;
|
|
338
|
+
wss: WebSocketServer;
|
|
339
|
+
rpcGroup: BirpcGroup<DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, false>;
|
|
340
|
+
close: () => Promise<void>;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Compose an h3 + WebSocket server for a devtool context. The RPC
|
|
344
|
+
* group is bound to `context.rpc.functions`; the WS endpoint lives on
|
|
345
|
+
* the same port as the HTTP server.
|
|
346
|
+
*/
|
|
347
|
+
declare function startHttpAndWs(options: StartHttpAndWsOptions): Promise<StartedServer>;
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/node/static-dump.d.ts
|
|
350
|
+
type StaticRpcDumpSerialization = 'json' | 'structured-clone';
|
|
351
|
+
interface StaticRpcDumpManifestStaticEntry {
|
|
352
|
+
type: 'static';
|
|
353
|
+
path: string;
|
|
354
|
+
/** Encoder used when this entry's file was written. Default: `'json'`. */
|
|
355
|
+
serialization?: StaticRpcDumpSerialization;
|
|
356
|
+
}
|
|
357
|
+
interface StaticRpcDumpManifestQueryEntry {
|
|
358
|
+
type: 'query';
|
|
359
|
+
records: Record<string, string>;
|
|
360
|
+
fallback?: string;
|
|
361
|
+
/** Encoder used when each record/fallback file was written. Default: `'json'`. */
|
|
362
|
+
serialization?: StaticRpcDumpSerialization;
|
|
363
|
+
}
|
|
364
|
+
type StaticRpcDumpManifestValue = StaticRpcDumpManifestStaticEntry | StaticRpcDumpManifestQueryEntry | any;
|
|
365
|
+
type StaticRpcDumpManifest = Record<string, StaticRpcDumpManifestValue>;
|
|
366
|
+
interface StaticRpcDumpFile {
|
|
367
|
+
/** Whether this file was written via `JSON.stringify` or `structured-clone-es.stringify`. */
|
|
368
|
+
serialization: StaticRpcDumpSerialization;
|
|
369
|
+
/** Function name the file belongs to — used to scope `DF0019` errors during write. */
|
|
370
|
+
fnName: string;
|
|
371
|
+
/** Payload to encode. */
|
|
372
|
+
data: unknown;
|
|
373
|
+
}
|
|
374
|
+
interface StaticRpcDumpCollection {
|
|
375
|
+
manifest: StaticRpcDumpManifest;
|
|
376
|
+
files: Record<string, StaticRpcDumpFile>;
|
|
377
|
+
}
|
|
378
|
+
declare function collectStaticRpcDump(definitions: Iterable<RpcFunctionDefinitionAny>, context: any): Promise<StaticRpcDumpCollection>;
|
|
379
|
+
//#endregion
|
|
380
|
+
//#region src/node/storage.d.ts
|
|
381
|
+
interface CreateStorageOptions<T extends object> {
|
|
382
|
+
filepath: string;
|
|
383
|
+
initialValue: T;
|
|
384
|
+
mergeInitialValue?: false | ((initialValue: T, savedValue: T) => T);
|
|
385
|
+
debounce?: number;
|
|
386
|
+
}
|
|
387
|
+
declare function createStorage<T extends object>(options: CreateStorageOptions<T>): SharedState<T>;
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/node/utils.d.ts
|
|
390
|
+
declare function isObject(value: unknown): value is Record<string, any>;
|
|
391
|
+
declare function normalizeHttpServerUrl(host: string, port: number | string): string;
|
|
392
|
+
//#endregion
|
|
393
|
+
export { ContextUtils, CreateH3DevToolsHostOptions, CreateHostContextOptions, CreateStorageOptions, DevToolsAgentHost, DevToolsCommandsHost, DevToolsDiagnosticsHost, DevToolsDockHost, DevToolsInternalContext, DevToolsMessagesHost, DevToolsTerminalHost, DevToolsViewHost, InternalAnonymousAuthStorage, PendingAuthRequest, RemoteTokenRecord, RpcFunctionsHost, StartHttpAndWsOptions, StartedServer, StaticRpcDumpCollection, StaticRpcDumpFile, StaticRpcDumpManifest, StaticRpcDumpManifestQueryEntry, StaticRpcDumpManifestStaticEntry, StaticRpcDumpManifestValue, StaticRpcDumpSerialization, abortPendingAuth, collectStaticRpcDump, consumeTempAuthToken, createH3DevToolsHost, createHostContext, createRpcSharedStateServerHost, createStorage, getInternalContext, getPendingAuth, getTempAuthToken, internalContextMap, isObject, normalizeHttpServerUrl, refreshTempAuthToken, revokeActiveConnectionsForToken, revokeAuthToken, setPendingAuth, startHttpAndWs };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { t as import_dist } from "../human-id-CHS0s28X.mjs";
|
|
2
|
+
import { _ as revokeAuthToken, a as RpcFunctionsHost, c as getInternalContext, d as DevToolsDiagnosticsHost, f as DevToolsCommandsHost, g as revokeActiveConnectionsForToken, h as ContextUtils, i as DevToolsMessagesHost, l as internalContextMap, n as DevToolsViewHost, o as createRpcSharedStateServerHost, p as DevToolsAgentHost, r as DevToolsTerminalHost, s as DevToolsDockHost, t as createHostContext, u as createStorage } from "../context-xQo1FcxX.mjs";
|
|
3
|
+
import { n as createH3DevToolsHost, t as collectStaticRpcDump } from "../static-dump-DwFfj4U_.mjs";
|
|
4
|
+
import { t as startHttpAndWs } from "../server-DkJ2-s0Y.mjs";
|
|
5
|
+
import { isIP } from "node:net";
|
|
6
|
+
//#region src/node/auth-state.ts
|
|
7
|
+
let pendingAuth = null;
|
|
8
|
+
let tempAuthToken = generateTempId();
|
|
9
|
+
function generateTempId() {
|
|
10
|
+
return (0, import_dist.humanId)({
|
|
11
|
+
separator: "-",
|
|
12
|
+
capitalize: false
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function getTempAuthToken() {
|
|
16
|
+
return tempAuthToken;
|
|
17
|
+
}
|
|
18
|
+
function refreshTempAuthToken() {
|
|
19
|
+
tempAuthToken = generateTempId();
|
|
20
|
+
return tempAuthToken;
|
|
21
|
+
}
|
|
22
|
+
function getPendingAuth() {
|
|
23
|
+
return pendingAuth;
|
|
24
|
+
}
|
|
25
|
+
function setPendingAuth(request) {
|
|
26
|
+
pendingAuth = request;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Abort and clean up any existing pending auth request.
|
|
30
|
+
*/
|
|
31
|
+
function abortPendingAuth() {
|
|
32
|
+
if (pendingAuth) {
|
|
33
|
+
pendingAuth.abortController.abort();
|
|
34
|
+
clearTimeout(pendingAuth.timeout);
|
|
35
|
+
pendingAuth = null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Consume the temp auth ID: verify it matches, trust the pending client, and clean up.
|
|
40
|
+
* Returns the client's authToken if successful, null otherwise.
|
|
41
|
+
*/
|
|
42
|
+
function consumeTempAuthToken(id, storage) {
|
|
43
|
+
if (id !== tempAuthToken || !pendingAuth) return null;
|
|
44
|
+
const { clientAuthToken, session, ua, origin, resolve } = pendingAuth;
|
|
45
|
+
storage.mutate((state) => {
|
|
46
|
+
state.trusted[clientAuthToken] = {
|
|
47
|
+
authToken: clientAuthToken,
|
|
48
|
+
ua,
|
|
49
|
+
origin,
|
|
50
|
+
timestamp: Date.now()
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
session.meta.clientAuthToken = clientAuthToken;
|
|
54
|
+
session.meta.isTrusted = true;
|
|
55
|
+
resolve({ isTrusted: true });
|
|
56
|
+
abortPendingAuth();
|
|
57
|
+
refreshTempAuthToken();
|
|
58
|
+
return clientAuthToken;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/node/utils.ts
|
|
62
|
+
function isObject(value) {
|
|
63
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
64
|
+
}
|
|
65
|
+
function normalizeHttpServerUrl(host, port) {
|
|
66
|
+
return `http://${host === "127.0.0.1" ? "localhost" : isIP(host) === 6 ? `[${host}]` : host}:${port}`;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { ContextUtils, DevToolsAgentHost, DevToolsCommandsHost, DevToolsDiagnosticsHost, DevToolsDockHost, DevToolsMessagesHost, DevToolsTerminalHost, DevToolsViewHost, RpcFunctionsHost, abortPendingAuth, collectStaticRpcDump, consumeTempAuthToken, createH3DevToolsHost, createHostContext, createRpcSharedStateServerHost, createStorage, getInternalContext, getPendingAuth, getTempAuthToken, internalContextMap, isObject, normalizeHttpServerUrl, refreshTempAuthToken, revokeActiveConnectionsForToken, revokeAuthToken, setPendingAuth, startHttpAndWs };
|