devframe 0.1.19 → 0.1.21
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/README.md +2 -2
- package/dist/{_shared-BcPXmcjq.mjs → _shared-iZy45oG3.mjs} +2 -2
- package/dist/adapters/build.d.mts +3 -3
- package/dist/adapters/build.mjs +12 -9
- package/dist/adapters/cli.d.mts +1 -1
- package/dist/adapters/cli.mjs +2 -2
- package/dist/adapters/dev.d.mts +2 -2
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +2 -2
- package/dist/adapters/embedded.mjs +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.mjs +6 -2
- package/dist/adapters/vite.d.mts +5 -4
- package/dist/adapters/vite.mjs +4 -3
- package/dist/client/index.d.mts +51 -145
- package/dist/client/index.mjs +1664 -2
- package/dist/constants.d.mts +12 -15
- package/dist/constants.mjs +12 -29
- package/dist/context-BJ4r2SmR.mjs +1051 -0
- package/dist/context-internal-Dx_NoSv1.mjs +199 -0
- package/dist/context-internal-saIAfNVw.d.mts +51 -0
- package/dist/{dev-Djy5hbgs.mjs → dev-CdAy400a.mjs} +7 -6
- package/dist/{devtool-CIqONpYU.d.mts → devtool-CNvLs2_Y.d.mts} +367 -530
- package/dist/diagnostics-DxPnRoXO.mjs +51 -0
- package/dist/host-h3-9jeHcltx.mjs +24 -0
- package/dist/{human-id-CHS0s28X.mjs → human-id-BLoGo_e5.mjs} +0 -1
- package/dist/{index-BwrLhNmz.d.mts → index-CuLRIMto.d.mts} +1 -1
- package/dist/index.d.mts +4 -5
- package/dist/index.mjs +1 -4
- package/dist/internal/index.d.mts +16 -0
- package/dist/internal/index.mjs +3 -0
- package/dist/node/index.d.mts +45 -140
- package/dist/node/index.mjs +7 -6
- package/dist/recipes/open-helpers.d.mts +1 -1
- package/dist/recipes/open-helpers.mjs +3 -1
- package/dist/rpc/index.d.mts +2 -2
- package/dist/rpc/index.mjs +2 -2
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-client.mjs +1 -1
- package/dist/rpc/transports/ws-server.d.mts +1 -1
- package/dist/rpc/transports/ws-server.mjs +1 -1
- package/dist/{rpc-D7LxIh8t.mjs → rpc-INbWfHoX.mjs} +1 -1
- package/dist/{serialization-BN2ZQEE9.mjs → serialization-DwKi05Pn.mjs} +1 -1
- package/dist/{server-CaUeMcAh.d.mts → server-BAqOajx_.d.mts} +1 -1
- package/dist/{server-DrBxa6ZV.mjs → server-CBsxXIH5.mjs} +27 -2
- package/dist/{static-dump-cyGfMmRf.mjs → static-dump-D5VH8Iqk.mjs} +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/human-id.mjs +1 -1
- package/dist/utils/shared-state.d.mts +2 -2
- package/dist/utils/shared-state.mjs +1 -1
- package/dist/utils/state.d.mts +2 -1
- package/dist/utils/state.mjs +1 -1
- package/dist/utils/streaming-channel.d.mts +2 -0
- package/dist/utils/streaming-channel.mjs +255 -0
- package/dist/utils/when.d.mts +401 -2
- package/dist/{ws-client-DOYwYluO.d.mts → ws-client-CjPuPFbA.d.mts} +1 -1
- package/dist/{ws-server-DHMeNOY_.d.mts → ws-server-C7LnhOHi.d.mts} +13 -1
- package/package.json +10 -21
- package/skills/devframe/README.md +13 -0
- package/skills/devframe/SKILL.md +406 -0
- package/skills/devframe/templates/counter-devtool.ts +24 -0
- package/skills/devframe/templates/spa-devtool.ts +28 -0
- package/skills/devframe/templates/vite-client.ts +11 -0
- package/dist/adapters/kit.d.mts +0 -23
- package/dist/adapters/kit.mjs +0 -16
- package/dist/client-C6w_NshP.mjs +0 -1569
- package/dist/context-BsNZMCnr.mjs +0 -6827
- package/dist/helpers/nuxt/index.d.mts +0 -46
- package/dist/helpers/nuxt/index.mjs +0 -58
- package/dist/helpers/nuxt/runtime/plugin.client.d.mts +0 -8
- package/dist/helpers/nuxt/runtime/plugin.client.mjs +0 -12
- package/dist/host-h3-w3c0t8ZO.mjs +0 -18
- package/dist/immer-HjMAm3b6.mjs +0 -894
- package/dist/main-CuGOfqoX.mjs +0 -601
- package/dist/when-BAE663Hv.d.mts +0 -401
- package/dist/{open-JfacLHs0.mjs → open-Dede_w9r.mjs} +4 -4
- /package/dist/{types-gWbe-b2R.d.mts → types-C5OVe4AC.d.mts} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { g as RpcFunctionsCollectorBase } from "./index-
|
|
2
|
-
import { t as DevToolsNodeRpcSessionMeta } from "./ws-server-
|
|
1
|
+
import { g as RpcFunctionsCollectorBase } from "./index-CuLRIMto.mjs";
|
|
2
|
+
import { t as DevToolsNodeRpcSessionMeta } from "./ws-server-C7LnhOHi.mjs";
|
|
3
3
|
import { Logger, createLogger, defineDiagnostics } from "logs-sdk";
|
|
4
4
|
import { BirpcReturn } from "birpc";
|
|
5
|
+
import { Objectish, Patch, Patch as SharedStatePatch } from "immer";
|
|
5
6
|
import { CAC } from "cac";
|
|
6
7
|
import { GenericSchema, InferOutput } from "valibot";
|
|
7
|
-
import { ChildProcess } from "node:child_process";
|
|
8
8
|
|
|
9
9
|
//#region src/adapters/flags.d.ts
|
|
10
10
|
/**
|
|
@@ -285,127 +285,6 @@ interface DevToolsAgentHost {
|
|
|
285
285
|
getResource: (id: string) => AgentResource | undefined;
|
|
286
286
|
}
|
|
287
287
|
//#endregion
|
|
288
|
-
//#region src/types/commands.d.ts
|
|
289
|
-
interface DevToolsCommandKeybinding {
|
|
290
|
-
/**
|
|
291
|
-
* Keyboard shortcut string.
|
|
292
|
-
* Use "Mod" for platform-aware modifier (Cmd on macOS, Ctrl elsewhere).
|
|
293
|
-
* Examples: "Mod+K", "Mod+Shift+P", "Alt+N"
|
|
294
|
-
*/
|
|
295
|
-
key: string;
|
|
296
|
-
}
|
|
297
|
-
interface DevToolsCommandBase {
|
|
298
|
-
/**
|
|
299
|
-
* Unique namespaced ID, e.g. "vite:open-in-editor"
|
|
300
|
-
*/
|
|
301
|
-
id: string;
|
|
302
|
-
title: string;
|
|
303
|
-
description?: string;
|
|
304
|
-
/**
|
|
305
|
-
* Iconify icon string, e.g. "ph:pencil-duotone"
|
|
306
|
-
*/
|
|
307
|
-
icon?: string;
|
|
308
|
-
category?: string;
|
|
309
|
-
/**
|
|
310
|
-
* Whether to show in command palette. Default: true
|
|
311
|
-
*
|
|
312
|
-
* - `true` — show the command and flatten its children into search results
|
|
313
|
-
* - `false` — hide the command entirely from the palette
|
|
314
|
-
* - `'without-children'` — show the command but don't flatten children into top-level search (children are still accessible via drill-down)
|
|
315
|
-
*/
|
|
316
|
-
showInPalette?: boolean | 'without-children';
|
|
317
|
-
/**
|
|
318
|
-
* Optional context expression for conditional visibility.
|
|
319
|
-
* When set, the command is only shown in the palette and only executable
|
|
320
|
-
* when the expression evaluates to true.
|
|
321
|
-
*
|
|
322
|
-
* Uses the same syntax as keybinding `when` clauses.
|
|
323
|
-
* @example 'clientType == embedded'
|
|
324
|
-
* @example 'dockOpen && !paletteOpen'
|
|
325
|
-
*/
|
|
326
|
-
when?: string;
|
|
327
|
-
/**
|
|
328
|
-
* Default keyboard shortcut(s) for this command
|
|
329
|
-
*/
|
|
330
|
-
keybindings?: DevToolsCommandKeybinding[];
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Server command input — what plugins pass to `ctx.commands.register()`.
|
|
334
|
-
*/
|
|
335
|
-
interface DevToolsServerCommandInput extends DevToolsCommandBase {
|
|
336
|
-
/**
|
|
337
|
-
* Handler for this command. Optional if the command only serves as a group for children.
|
|
338
|
-
*/
|
|
339
|
-
handler?: (...args: any[]) => any | Promise<any>;
|
|
340
|
-
/**
|
|
341
|
-
* Static sub-commands. Two levels max (parent → children).
|
|
342
|
-
* Each child must have a globally unique `id`.
|
|
343
|
-
*/
|
|
344
|
-
children?: DevToolsServerCommandInput[];
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Serializable server command entry — sent over RPC (no handler).
|
|
348
|
-
*/
|
|
349
|
-
interface DevToolsServerCommandEntry extends DevToolsCommandBase {
|
|
350
|
-
source: 'server';
|
|
351
|
-
children?: DevToolsServerCommandEntry[];
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Client command — registered in the webcomponent context.
|
|
355
|
-
*/
|
|
356
|
-
interface DevToolsClientCommand extends DevToolsCommandBase {
|
|
357
|
-
source: 'client';
|
|
358
|
-
/**
|
|
359
|
-
* Action for this command. Optional if the command only serves as a group for children.
|
|
360
|
-
* Return sub-commands for dynamic nested palette menus (runtime submenus).
|
|
361
|
-
*/
|
|
362
|
-
action?: (...args: any[]) => void | DevToolsClientCommand[] | Promise<void | DevToolsClientCommand[]>;
|
|
363
|
-
/**
|
|
364
|
-
* Static sub-commands. Two levels max (parent → children).
|
|
365
|
-
*/
|
|
366
|
-
children?: DevToolsClientCommand[];
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Union of command entries visible in the palette.
|
|
370
|
-
*/
|
|
371
|
-
type DevToolsCommandEntry = DevToolsServerCommandEntry | DevToolsClientCommand;
|
|
372
|
-
interface DevToolsCommandHandle {
|
|
373
|
-
readonly id: string;
|
|
374
|
-
update: (patch: Partial<Omit<DevToolsServerCommandInput, 'id'>>) => void;
|
|
375
|
-
unregister: () => void;
|
|
376
|
-
}
|
|
377
|
-
interface DevToolsCommandsHostEvents {
|
|
378
|
-
'command:registered': (command: DevToolsServerCommandEntry) => void;
|
|
379
|
-
'command:unregistered': (id: string) => void;
|
|
380
|
-
}
|
|
381
|
-
interface DevToolsCommandsHost {
|
|
382
|
-
readonly commands: Map<string, DevToolsServerCommandInput>;
|
|
383
|
-
readonly events: EventEmitter<DevToolsCommandsHostEvents>;
|
|
384
|
-
/**
|
|
385
|
-
* Register a command (with optional children).
|
|
386
|
-
*/
|
|
387
|
-
register: (command: DevToolsServerCommandInput) => DevToolsCommandHandle;
|
|
388
|
-
/**
|
|
389
|
-
* Unregister a command by ID (removes parent and all children).
|
|
390
|
-
*/
|
|
391
|
-
unregister: (id: string) => boolean;
|
|
392
|
-
/**
|
|
393
|
-
* Execute a command by ID. Searches top-level and children.
|
|
394
|
-
* Throws if not found or if command has no handler.
|
|
395
|
-
*/
|
|
396
|
-
execute: (id: string, ...args: any[]) => Promise<unknown>;
|
|
397
|
-
/**
|
|
398
|
-
* Returns serializable list (no handlers), preserving tree structure.
|
|
399
|
-
*/
|
|
400
|
-
list: () => DevToolsServerCommandEntry[];
|
|
401
|
-
}
|
|
402
|
-
interface DevToolsCommandShortcutOverrides {
|
|
403
|
-
/**
|
|
404
|
-
* Command ID → keybinding overrides. Empty array = shortcut disabled.
|
|
405
|
-
*/
|
|
406
|
-
[commandId: string]: DevToolsCommandKeybinding[];
|
|
407
|
-
}
|
|
408
|
-
//#endregion
|
|
409
288
|
//#region src/types/diagnostics.d.ts
|
|
410
289
|
/**
|
|
411
290
|
* A diagnostics definition object built with `defineDiagnostics`. Typed as
|
|
@@ -472,147 +351,43 @@ interface DevToolsDiagnosticsHost {
|
|
|
472
351
|
createLogger: typeof createLogger;
|
|
473
352
|
}
|
|
474
353
|
//#endregion
|
|
475
|
-
//#region src/types/
|
|
476
|
-
interface
|
|
477
|
-
readonly views: Map<string, DevToolsDockUserEntry>;
|
|
478
|
-
readonly events: EventEmitter<{
|
|
479
|
-
'dock:entry:updated': (entry: DevToolsDockUserEntry) => void;
|
|
480
|
-
}>;
|
|
481
|
-
register: <T extends DevToolsDockUserEntry>(entry: T, force?: boolean) => {
|
|
482
|
-
update: (patch: Partial<T>) => void;
|
|
483
|
-
};
|
|
484
|
-
update: (entry: DevToolsDockUserEntry) => void;
|
|
485
|
-
values: (options?: {
|
|
486
|
-
includeBuiltin?: boolean;
|
|
487
|
-
}) => DevToolsDockEntry[];
|
|
488
|
-
}
|
|
489
|
-
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default' | '~viteplus' | '~builtin';
|
|
490
|
-
type DevToolsDockEntryIcon = string | {
|
|
491
|
-
light: string;
|
|
492
|
-
dark: string;
|
|
493
|
-
};
|
|
494
|
-
interface DevToolsDockEntryBase {
|
|
495
|
-
id: string;
|
|
496
|
-
title: string;
|
|
497
|
-
icon: DevToolsDockEntryIcon;
|
|
498
|
-
/**
|
|
499
|
-
* The default order of the entry in the dock.
|
|
500
|
-
* The higher the number the earlier it appears.
|
|
501
|
-
* @default 0
|
|
502
|
-
*/
|
|
503
|
-
defaultOrder?: number;
|
|
504
|
-
/**
|
|
505
|
-
* The category of the entry
|
|
506
|
-
* @default 'default'
|
|
507
|
-
*/
|
|
508
|
-
category?: DevToolsDockEntryCategory;
|
|
509
|
-
/**
|
|
510
|
-
* Conditional visibility expression.
|
|
511
|
-
* When set, the dock entry is only visible when the expression evaluates to true.
|
|
512
|
-
* Uses the same syntax as command `when` clauses.
|
|
513
|
-
*
|
|
514
|
-
* Set to `'false'` to unconditionally hide the entry.
|
|
515
|
-
*
|
|
516
|
-
* @example 'clientType == embedded'
|
|
517
|
-
* @see {@link import('../utils/when').evaluateWhen}
|
|
518
|
-
*/
|
|
519
|
-
when?: string;
|
|
520
|
-
/**
|
|
521
|
-
* Badge text to display on the dock icon (e.g., unread count)
|
|
522
|
-
*/
|
|
523
|
-
badge?: string;
|
|
524
|
-
}
|
|
525
|
-
interface ClientScriptEntry {
|
|
526
|
-
/**
|
|
527
|
-
* The filepath or module name to import from
|
|
528
|
-
*/
|
|
529
|
-
importFrom: string;
|
|
530
|
-
/**
|
|
531
|
-
* The name to import the module as
|
|
532
|
-
*
|
|
533
|
-
* @default 'default'
|
|
534
|
-
*/
|
|
535
|
-
importName?: string;
|
|
536
|
-
}
|
|
537
|
-
interface DevToolsViewIframe extends DevToolsDockEntryBase {
|
|
538
|
-
type: 'iframe';
|
|
539
|
-
url: string;
|
|
540
|
-
/**
|
|
541
|
-
* The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared.
|
|
542
|
-
*
|
|
543
|
-
* When not provided, it would be treated as a unique frame.
|
|
544
|
-
*/
|
|
545
|
-
frameId?: string;
|
|
354
|
+
//#region src/types/host.d.ts
|
|
355
|
+
interface DevToolsHost {
|
|
546
356
|
/**
|
|
547
|
-
*
|
|
357
|
+
* Serve a static directory at the given URL base. Called by
|
|
358
|
+
* `DevToolsViewHost.hostStatic`. Implementations map this to whatever
|
|
359
|
+
* the underlying runtime expects (Vite middleware, h3 handler, no-op
|
|
360
|
+
* for build snapshots).
|
|
548
361
|
*/
|
|
549
|
-
|
|
362
|
+
mountStatic: (base: string, distDir: string) => void | Promise<void>;
|
|
550
363
|
/**
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
* Requires dev mode (no effect in build mode — no WS server exists).
|
|
558
|
-
* When enabled, the dock is automatically hidden in build mode unless
|
|
559
|
-
* the author provides an explicit `when` clause.
|
|
560
|
-
*
|
|
561
|
-
* @example
|
|
562
|
-
* remote: true
|
|
563
|
-
* remote: { transport: 'query', originLock: false }
|
|
364
|
+
* Return the public origin the host is reachable at, e.g.
|
|
365
|
+
* `http://localhost:5173`. Used by the dock host to enrich remote
|
|
366
|
+
* iframe URLs with a full `origin`. Called only when a dock needs an
|
|
367
|
+
* absolute URL; hosts that never serve remote docks can return any
|
|
368
|
+
* reasonable value.
|
|
564
369
|
*/
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
interface RemoteDockOptions {
|
|
370
|
+
resolveOrigin: () => string;
|
|
568
371
|
/**
|
|
569
|
-
*
|
|
372
|
+
* Resolve a directory the host owns for persisted devtools state.
|
|
373
|
+
* Each host picks its own app-name namespace so storage doesn't
|
|
374
|
+
* collide between, say, the Vite host (`.vite/devtools`) and a
|
|
375
|
+
* standalone CLI host (`.<appName>/devtools`).
|
|
570
376
|
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
* logs and outbound Referer headers.
|
|
377
|
+
* - `workspace` — per-project state (settings, caches). Typically
|
|
378
|
+
* under `${workspaceRoot}/node_modules/.<appName>/devtools/`.
|
|
379
|
+
* - `global` — per-user state (auth tokens, machine-wide
|
|
380
|
+
* preferences). Typically under
|
|
381
|
+
* `${homedir()}/.<appName>/devtools/`.
|
|
577
382
|
*
|
|
578
|
-
*
|
|
383
|
+
* Implementations should ensure the directory exists or be safe to
|
|
384
|
+
* pass to a downstream `createStorage(...)` call that creates it
|
|
385
|
+
* lazily.
|
|
579
386
|
*/
|
|
580
|
-
|
|
581
|
-
/**
|
|
582
|
-
* Reject WS handshakes whose `Origin` header doesn't match the dock URL
|
|
583
|
-
* origin. Turn off when the same hosted app is served from multiple
|
|
584
|
-
* origins (e.g. preview deploys).
|
|
585
|
-
*
|
|
586
|
-
* @default true
|
|
587
|
-
*/
|
|
588
|
-
originLock?: boolean;
|
|
589
|
-
}
|
|
590
|
-
type DevToolsViewLauncherStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
591
|
-
interface DevToolsViewLauncher extends DevToolsDockEntryBase {
|
|
592
|
-
type: 'launcher';
|
|
593
|
-
launcher: {
|
|
594
|
-
icon?: DevToolsDockEntryIcon;
|
|
595
|
-
title: string;
|
|
596
|
-
status?: DevToolsViewLauncherStatus;
|
|
597
|
-
error?: string;
|
|
598
|
-
description?: string;
|
|
599
|
-
buttonStart?: string;
|
|
600
|
-
buttonLoading?: string;
|
|
601
|
-
onLaunch: () => Promise<void>;
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
interface DevToolsViewAction extends DevToolsDockEntryBase {
|
|
605
|
-
type: 'action';
|
|
606
|
-
action: ClientScriptEntry;
|
|
607
|
-
}
|
|
608
|
-
interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
609
|
-
type: 'custom-render';
|
|
610
|
-
renderer: ClientScriptEntry;
|
|
611
|
-
}
|
|
612
|
-
interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
|
|
613
|
-
type: '~builtin';
|
|
614
|
-
id: '~terminals' | '~messages' | '~client-auth-notice' | '~settings' | '~popup';
|
|
387
|
+
getStorageDir: (scope: 'workspace' | 'global') => string;
|
|
615
388
|
}
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/types/json-render.d.ts
|
|
616
391
|
interface JsonRenderElement {
|
|
617
392
|
type: string;
|
|
618
393
|
props?: Record<string, unknown>;
|
|
@@ -640,262 +415,115 @@ interface JsonRenderer {
|
|
|
640
415
|
/** Internal: shared state key used by the client to subscribe */
|
|
641
416
|
readonly _stateKey: string;
|
|
642
417
|
}
|
|
643
|
-
interface DevToolsViewJsonRender extends DevToolsDockEntryBase {
|
|
644
|
-
type: 'json-render';
|
|
645
|
-
/** JsonRenderer handle created by ctx.createJsonRenderer() */
|
|
646
|
-
ui: JsonRenderer;
|
|
647
|
-
}
|
|
648
|
-
type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher | DevToolsViewJsonRender;
|
|
649
|
-
type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
|
|
650
|
-
type DevToolsDockEntriesGrouped = [category: string, entries: DevToolsDockEntry[]][];
|
|
651
|
-
//#endregion
|
|
652
|
-
//#region src/types/host.d.ts
|
|
653
|
-
interface DevToolsHost {
|
|
654
|
-
/**
|
|
655
|
-
* Serve a static directory at the given URL base. Called by
|
|
656
|
-
* `DevToolsViewHost.hostStatic`. Implementations map this to whatever
|
|
657
|
-
* the underlying runtime expects (Vite middleware, h3 handler, no-op
|
|
658
|
-
* for build snapshots).
|
|
659
|
-
*/
|
|
660
|
-
mountStatic: (base: string, distDir: string) => void | Promise<void>;
|
|
661
|
-
/**
|
|
662
|
-
* Return the public origin the host is reachable at, e.g.
|
|
663
|
-
* `http://localhost:5173`. Used by the dock host to enrich remote
|
|
664
|
-
* iframe URLs with a full `origin`. Called only when a dock needs an
|
|
665
|
-
* absolute URL; hosts that never serve remote docks can return any
|
|
666
|
-
* reasonable value.
|
|
667
|
-
*/
|
|
668
|
-
resolveOrigin: () => string;
|
|
669
|
-
}
|
|
670
418
|
//#endregion
|
|
671
|
-
//#region src/types/
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
selector?: string;
|
|
677
|
-
/** Bounding box of the element */
|
|
678
|
-
boundingBox?: {
|
|
679
|
-
x: number;
|
|
680
|
-
y: number;
|
|
681
|
-
width: number;
|
|
682
|
-
height: number;
|
|
683
|
-
};
|
|
684
|
-
/** Human-readable description of the element */
|
|
685
|
-
description?: string;
|
|
686
|
-
}
|
|
687
|
-
interface DevToolsMessageFilePosition {
|
|
688
|
-
/** Absolute or relative file path */
|
|
689
|
-
file: string;
|
|
690
|
-
/** Line number (1-based) */
|
|
691
|
-
line?: number;
|
|
692
|
-
/** Column number (1-based) */
|
|
693
|
-
column?: number;
|
|
694
|
-
}
|
|
695
|
-
interface DevToolsMessageEntry {
|
|
696
|
-
/**
|
|
697
|
-
* Unique identifier for this message entry (auto-generated if not provided)
|
|
698
|
-
*/
|
|
699
|
-
id: string;
|
|
700
|
-
/**
|
|
701
|
-
* Short title or summary of the message
|
|
702
|
-
*/
|
|
703
|
-
message: string;
|
|
704
|
-
/**
|
|
705
|
-
* Optional detailed description or explanation
|
|
706
|
-
*/
|
|
707
|
-
description?: string;
|
|
708
|
-
/**
|
|
709
|
-
* Severity level, determines color and icon
|
|
710
|
-
*/
|
|
711
|
-
level: DevToolsMessageLevel;
|
|
712
|
-
/**
|
|
713
|
-
* Optional stack trace string
|
|
714
|
-
*/
|
|
715
|
-
stacktrace?: string;
|
|
716
|
-
/**
|
|
717
|
-
* Optional DOM element position info (e.g., for a11y issues)
|
|
718
|
-
*/
|
|
719
|
-
elementPosition?: DevToolsMessageElementPosition;
|
|
720
|
-
/**
|
|
721
|
-
* Optional source file position info (e.g., for lint errors)
|
|
722
|
-
*/
|
|
723
|
-
filePosition?: DevToolsMessageFilePosition;
|
|
724
|
-
/**
|
|
725
|
-
* Whether this message should also appear as a toast notification
|
|
726
|
-
*/
|
|
727
|
-
notify?: boolean;
|
|
419
|
+
//#region src/types/rpc-augments.d.ts
|
|
420
|
+
/**
|
|
421
|
+
* To be extended
|
|
422
|
+
*/
|
|
423
|
+
interface DevToolsRpcClientFunctions {
|
|
728
424
|
/**
|
|
729
|
-
*
|
|
425
|
+
* Streaming chunk pushed from server to subscribed clients. Wired by
|
|
426
|
+
* `RpcStreamingHost`; do not register manually.
|
|
427
|
+
*
|
|
428
|
+
* @internal
|
|
730
429
|
*/
|
|
731
|
-
|
|
430
|
+
'devframe:streaming:chunk': (channel: string, id: string, seq: number, chunk: any) => Promise<void>;
|
|
732
431
|
/**
|
|
733
|
-
*
|
|
432
|
+
* Streaming terminator pushed from server to subscribed clients. Wired by
|
|
433
|
+
* `RpcStreamingHost`; do not register manually.
|
|
434
|
+
*
|
|
435
|
+
* @internal
|
|
734
436
|
*/
|
|
735
|
-
|
|
437
|
+
'devframe:streaming:end': (channel: string, id: string, error?: {
|
|
438
|
+
name: string;
|
|
439
|
+
message: string;
|
|
440
|
+
}) => Promise<void>;
|
|
736
441
|
/**
|
|
737
|
-
*
|
|
442
|
+
* Server→client cancel for an in-flight upload. Wired by
|
|
443
|
+
* `RpcStreamingHost`; do not register manually.
|
|
444
|
+
*
|
|
445
|
+
* @internal
|
|
738
446
|
*/
|
|
739
|
-
|
|
447
|
+
'devframe:streaming:upload-cancel': (channel: string, id: string) => Promise<void>;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* To be extended
|
|
451
|
+
*/
|
|
452
|
+
interface DevToolsRpcServerFunctions {
|
|
740
453
|
/**
|
|
741
|
-
*
|
|
454
|
+
* Subscribe a client to a shared-state key. Wired by
|
|
455
|
+
* `RpcSharedStateHost`; do not register manually.
|
|
456
|
+
*
|
|
457
|
+
* @internal
|
|
742
458
|
*/
|
|
743
|
-
|
|
459
|
+
'devframe:rpc:server-state:subscribe': (key: string) => Promise<void>;
|
|
744
460
|
/**
|
|
745
|
-
*
|
|
461
|
+
* Read the current value for a shared-state key. Wired by
|
|
462
|
+
* `RpcSharedStateHost`; do not register manually.
|
|
463
|
+
*
|
|
464
|
+
* @internal
|
|
746
465
|
*/
|
|
747
|
-
|
|
466
|
+
'devframe:rpc:server-state:get': (key: string) => Promise<any>;
|
|
748
467
|
/**
|
|
749
|
-
*
|
|
468
|
+
* Replace a shared-state value (from the client). Wired by
|
|
469
|
+
* `RpcSharedStateHost`; do not register manually.
|
|
470
|
+
*
|
|
471
|
+
* @internal
|
|
750
472
|
*/
|
|
751
|
-
|
|
473
|
+
'devframe:rpc:server-state:set': (key: string, value: any, syncId: string) => Promise<void>;
|
|
752
474
|
/**
|
|
753
|
-
*
|
|
754
|
-
*
|
|
475
|
+
* Apply a patch to a shared-state value (from the client). Wired by
|
|
476
|
+
* `RpcSharedStateHost`; do not register manually.
|
|
477
|
+
*
|
|
478
|
+
* @internal
|
|
755
479
|
*/
|
|
756
|
-
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* Input type for creating a message entry.
|
|
760
|
-
* `id`, `timestamp`, and `from` are auto-filled by the host.
|
|
761
|
-
*/
|
|
762
|
-
type DevToolsMessageEntryInput = Omit<DevToolsMessageEntry, 'id' | 'timestamp' | 'from'> & {
|
|
763
|
-
id?: string;
|
|
764
|
-
timestamp?: number;
|
|
765
|
-
};
|
|
766
|
-
interface DevToolsMessageHandle {
|
|
767
|
-
/** The underlying message entry data */
|
|
768
|
-
readonly entry: DevToolsMessageEntry;
|
|
769
|
-
/** Shortcut to entry.id */
|
|
770
|
-
readonly id: string;
|
|
771
|
-
/** Partial update of this message entry */
|
|
772
|
-
update: (patch: Partial<DevToolsMessageEntryInput>) => Promise<DevToolsMessageEntry | undefined>;
|
|
773
|
-
/** Remove this message entry */
|
|
774
|
-
dismiss: () => Promise<void>;
|
|
775
|
-
}
|
|
776
|
-
interface DevToolsMessagesClient {
|
|
480
|
+
'devframe:rpc:server-state:patch': (key: string, patches: any[], syncId: string) => Promise<void>;
|
|
777
481
|
/**
|
|
778
|
-
*
|
|
779
|
-
*
|
|
482
|
+
* Client→server streaming subscription with optional replay cursor.
|
|
483
|
+
* Wired by `RpcStreamingHost`; do not register manually.
|
|
484
|
+
*
|
|
485
|
+
* @internal
|
|
780
486
|
*/
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
/** Clear all message entries */
|
|
785
|
-
clear: () => Promise<void>;
|
|
786
|
-
}
|
|
787
|
-
interface DevToolsMessagesHost {
|
|
788
|
-
readonly entries: Map<string, DevToolsMessageEntry>;
|
|
789
|
-
readonly events: EventEmitter<{
|
|
790
|
-
'message:added': (entry: DevToolsMessageEntry) => void;
|
|
791
|
-
'message:updated': (entry: DevToolsMessageEntry) => void;
|
|
792
|
-
'message:removed': (id: string) => void;
|
|
793
|
-
'message:cleared': () => void;
|
|
794
|
-
}>;
|
|
487
|
+
'devframe:streaming:subscribe': (channel: string, id: string, opts?: {
|
|
488
|
+
afterSeq?: number;
|
|
489
|
+
}) => Promise<void>;
|
|
795
490
|
/**
|
|
796
|
-
*
|
|
797
|
-
*
|
|
491
|
+
* Client→server streaming unsubscribe. Wired by `RpcStreamingHost`;
|
|
492
|
+
* do not register manually.
|
|
493
|
+
*
|
|
494
|
+
* @internal
|
|
798
495
|
*/
|
|
799
|
-
|
|
496
|
+
'devframe:streaming:unsubscribe': (channel: string, id: string) => Promise<void>;
|
|
800
497
|
/**
|
|
801
|
-
*
|
|
498
|
+
* Client→server streaming cancellation request. Wired by
|
|
499
|
+
* `RpcStreamingHost`; do not register manually.
|
|
500
|
+
*
|
|
501
|
+
* @internal
|
|
802
502
|
*/
|
|
803
|
-
|
|
503
|
+
'devframe:streaming:cancel': (channel: string, id: string) => Promise<void>;
|
|
804
504
|
/**
|
|
805
|
-
*
|
|
505
|
+
* Client→server upload chunk. Wired by `RpcStreamingHost`; do not
|
|
506
|
+
* register manually.
|
|
507
|
+
*
|
|
508
|
+
* @internal
|
|
806
509
|
*/
|
|
807
|
-
|
|
510
|
+
'devframe:streaming:upload-chunk': (channel: string, id: string, seq: number, chunk: any) => Promise<void>;
|
|
808
511
|
/**
|
|
809
|
-
*
|
|
512
|
+
* Client→server upload terminator. Wired by `RpcStreamingHost`; do not
|
|
513
|
+
* register manually.
|
|
514
|
+
*
|
|
515
|
+
* @internal
|
|
810
516
|
*/
|
|
811
|
-
|
|
517
|
+
'devframe:streaming:upload-end': (channel: string, id: string, error?: {
|
|
518
|
+
name: string;
|
|
519
|
+
message: string;
|
|
520
|
+
}) => Promise<void>;
|
|
812
521
|
}
|
|
813
|
-
/** @deprecated alias of {@link DevToolsMessageLevel}. Will be removed in a future release. */
|
|
814
|
-
type DevToolsLogLevel = DevToolsMessageLevel;
|
|
815
|
-
/** @deprecated alias of {@link DevToolsMessageEntryFrom}. Will be removed in a future release. */
|
|
816
|
-
type DevToolsLogEntryFrom = DevToolsMessageEntryFrom;
|
|
817
|
-
/** @deprecated alias of {@link DevToolsMessageElementPosition}. Will be removed in a future release. */
|
|
818
|
-
type DevToolsLogElementPosition = DevToolsMessageElementPosition;
|
|
819
|
-
/** @deprecated alias of {@link DevToolsMessageFilePosition}. Will be removed in a future release. */
|
|
820
|
-
type DevToolsLogFilePosition = DevToolsMessageFilePosition;
|
|
821
|
-
/** @deprecated alias of {@link DevToolsMessageEntry}. Will be removed in a future release. */
|
|
822
|
-
type DevToolsLogEntry = DevToolsMessageEntry;
|
|
823
|
-
/** @deprecated alias of {@link DevToolsMessageEntryInput}. Will be removed in a future release. */
|
|
824
|
-
type DevToolsLogEntryInput = DevToolsMessageEntryInput;
|
|
825
|
-
/** @deprecated alias of {@link DevToolsMessageHandle}. Will be removed in a future release. */
|
|
826
|
-
type DevToolsLogHandle = DevToolsMessageHandle;
|
|
827
|
-
/** @deprecated alias of {@link DevToolsMessagesClient}. Will be removed in a future release. */
|
|
828
|
-
type DevToolsLogsClient = DevToolsMessagesClient;
|
|
829
|
-
/** @deprecated alias of {@link DevToolsMessagesHost}. Will be removed in a future release. */
|
|
830
|
-
type DevToolsLogsHost = DevToolsMessagesHost;
|
|
831
|
-
//#endregion
|
|
832
|
-
//#region src/types/rpc-augments.d.ts
|
|
833
|
-
/**
|
|
834
|
-
* To be extended
|
|
835
|
-
*/
|
|
836
|
-
interface DevToolsRpcClientFunctions {}
|
|
837
|
-
/**
|
|
838
|
-
* To be extended
|
|
839
|
-
*/
|
|
840
|
-
interface DevToolsRpcServerFunctions {}
|
|
841
522
|
/**
|
|
842
523
|
* To be extended
|
|
843
524
|
*/
|
|
844
525
|
interface DevToolsRpcSharedStates {}
|
|
845
526
|
//#endregion
|
|
846
|
-
//#region src/types/settings.d.ts
|
|
847
|
-
interface DevToolsDocksUserSettings {
|
|
848
|
-
docksHidden: string[];
|
|
849
|
-
docksCategoriesHidden: string[];
|
|
850
|
-
docksPinned: string[];
|
|
851
|
-
docksCustomOrder: Record<string, number>;
|
|
852
|
-
showIframeAddressBar: boolean;
|
|
853
|
-
closeOnOutsideClick: boolean;
|
|
854
|
-
commandShortcuts: DevToolsCommandShortcutOverrides;
|
|
855
|
-
}
|
|
856
|
-
//#endregion
|
|
857
|
-
//#region src/types/terminals.d.ts
|
|
858
|
-
interface DevToolsTerminalSessionStreamChunkEvent {
|
|
859
|
-
id: string;
|
|
860
|
-
chunks: string[];
|
|
861
|
-
ts: number;
|
|
862
|
-
}
|
|
863
|
-
interface DevToolsTerminalHost {
|
|
864
|
-
readonly sessions: Map<string, DevToolsTerminalSession>;
|
|
865
|
-
readonly events: EventEmitter<{
|
|
866
|
-
'terminal:session:updated': (session: DevToolsTerminalSession) => void;
|
|
867
|
-
'terminal:session:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => void;
|
|
868
|
-
}>;
|
|
869
|
-
register: (session: DevToolsTerminalSession) => DevToolsTerminalSession;
|
|
870
|
-
update: (session: DevToolsTerminalSession) => void;
|
|
871
|
-
startChildProcess: (executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>) => Promise<DevToolsChildProcessTerminalSession>;
|
|
872
|
-
}
|
|
873
|
-
type DevToolsTerminalStatus = 'running' | 'stopped' | 'error';
|
|
874
|
-
interface DevToolsTerminalSessionBase {
|
|
875
|
-
id: string;
|
|
876
|
-
title: string;
|
|
877
|
-
description?: string;
|
|
878
|
-
status: DevToolsTerminalStatus;
|
|
879
|
-
icon?: DevToolsDockEntryIcon;
|
|
880
|
-
}
|
|
881
|
-
interface DevToolsTerminalSession extends DevToolsTerminalSessionBase {
|
|
882
|
-
buffer?: string[];
|
|
883
|
-
stream?: ReadableStream<string>;
|
|
884
|
-
}
|
|
885
|
-
interface DevToolsChildProcessExecuteOptions {
|
|
886
|
-
command: string;
|
|
887
|
-
args: string[];
|
|
888
|
-
cwd?: string;
|
|
889
|
-
env?: Record<string, string>;
|
|
890
|
-
}
|
|
891
|
-
interface DevToolsChildProcessTerminalSession extends DevToolsTerminalSession {
|
|
892
|
-
type: 'child-process';
|
|
893
|
-
executeOptions: DevToolsChildProcessExecuteOptions;
|
|
894
|
-
getChildProcess: () => ChildProcess | undefined;
|
|
895
|
-
terminate: () => Promise<void>;
|
|
896
|
-
restart: () => Promise<void>;
|
|
897
|
-
}
|
|
898
|
-
//#endregion
|
|
899
527
|
//#region src/types/utils.d.ts
|
|
900
528
|
type Thenable<T> = T | Promise<T>;
|
|
901
529
|
type EntriesToObject<T extends readonly [string, any][]> = { [K in T[number] as K[0]]: K[1] };
|
|
@@ -922,21 +550,6 @@ interface DevToolsViewHost {
|
|
|
922
550
|
hostStatic: (baseUrl: string, distDir: string) => void;
|
|
923
551
|
}
|
|
924
552
|
//#endregion
|
|
925
|
-
//#region ../../../node_modules/.pnpm/immer@11.1.4/node_modules/immer/dist/immer.d.ts
|
|
926
|
-
interface Patch {
|
|
927
|
-
op: "replace" | "remove" | "add";
|
|
928
|
-
path: (string | number)[];
|
|
929
|
-
value?: any;
|
|
930
|
-
}
|
|
931
|
-
type Objectish = AnyObject | AnyArray | AnyMap | AnySet;
|
|
932
|
-
type AnyObject = {
|
|
933
|
-
[key: string]: any;
|
|
934
|
-
};
|
|
935
|
-
type AnyArray = Array<any>;
|
|
936
|
-
type AnySet = Set<any>;
|
|
937
|
-
type AnyMap = Map<any, any>;
|
|
938
|
-
/** Returns true if the given value is an Immer draft */
|
|
939
|
-
//#endregion
|
|
940
553
|
//#region src/utils/shared-state.d.ts
|
|
941
554
|
type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
|
|
942
555
|
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>;
|
|
@@ -986,6 +599,128 @@ interface SharedStateOptions<T> {
|
|
|
986
599
|
}
|
|
987
600
|
declare function createSharedState<T extends Objectish>(options: SharedStateOptions<T>): SharedState<T>;
|
|
988
601
|
//#endregion
|
|
602
|
+
//#region src/utils/streaming-channel.d.ts
|
|
603
|
+
/**
|
|
604
|
+
* Serialized error shape sent over the wire when a stream ends with a failure.
|
|
605
|
+
* Stays JSON-safe so the strict-JSON encoder can carry it without coercion.
|
|
606
|
+
*/
|
|
607
|
+
interface StreamErrorPayload {
|
|
608
|
+
name: string;
|
|
609
|
+
message: string;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Single buffered chunk in the server-side ring buffer.
|
|
613
|
+
*
|
|
614
|
+
* Sequence numbers start at 1 and increment per write. Subscribers track
|
|
615
|
+
* `lastSeenSeq` and ask for `afterSeq` on resubscribe so the server can
|
|
616
|
+
* replay any chunks the client missed during a brief disconnect.
|
|
617
|
+
*/
|
|
618
|
+
interface BufferedChunk<T> {
|
|
619
|
+
seq: number;
|
|
620
|
+
chunk: T;
|
|
621
|
+
}
|
|
622
|
+
interface StreamSinkEvents<T> {
|
|
623
|
+
/** Fired for each `write()`. The RPC layer subscribes and broadcasts. */
|
|
624
|
+
chunk: (seq: number, chunk: T) => void;
|
|
625
|
+
/** Terminal — fired exactly once per sink lifetime. */
|
|
626
|
+
end: (error?: StreamErrorPayload) => void;
|
|
627
|
+
}
|
|
628
|
+
interface CreateStreamSinkOptions {
|
|
629
|
+
id?: string;
|
|
630
|
+
/**
|
|
631
|
+
* Size of the per-stream ring buffer kept for replay-on-resubscribe.
|
|
632
|
+
* `0` (default) disables replay.
|
|
633
|
+
*/
|
|
634
|
+
replayWindow?: number;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Server-side producer handle. Two equivalent surfaces share one piece of
|
|
638
|
+
* state: the imperative `write/error/close` triple, and a `WritableStream<T>`
|
|
639
|
+
* for `pipeTo`-style consumption.
|
|
640
|
+
*/
|
|
641
|
+
interface StreamSink<T> {
|
|
642
|
+
/** Stable id used by clients to subscribe. */
|
|
643
|
+
readonly id: string;
|
|
644
|
+
/**
|
|
645
|
+
* Aborts when the consumer cancels (server-side) or when the transport
|
|
646
|
+
* loses every subscriber. Producers should poll `signal.aborted` and exit
|
|
647
|
+
* cleanly.
|
|
648
|
+
*/
|
|
649
|
+
readonly signal: AbortSignal;
|
|
650
|
+
/** `true` after `close()` / `error()`. Further writes throw. */
|
|
651
|
+
readonly closed: boolean;
|
|
652
|
+
/** Last allocated sequence number. `0` until the first write. */
|
|
653
|
+
readonly lastSeq: number;
|
|
654
|
+
write: (chunk: T) => void;
|
|
655
|
+
error: (reason: unknown) => void;
|
|
656
|
+
close: () => void;
|
|
657
|
+
/** External-cancel path. Aborts the signal so handlers can short-circuit. */
|
|
658
|
+
abort: (reason?: unknown) => void;
|
|
659
|
+
/** `WritableStream<T>` adapter — same in-memory state as the imperative API. */
|
|
660
|
+
readonly writable: WritableStream<T>;
|
|
661
|
+
/**
|
|
662
|
+
* Internal — RPC layer subscribes to receive chunk/end notifications.
|
|
663
|
+
* Not part of the public contract; do not call directly.
|
|
664
|
+
*
|
|
665
|
+
* @internal
|
|
666
|
+
*/
|
|
667
|
+
readonly events: EventEmitter<StreamSinkEvents<T>>;
|
|
668
|
+
/**
|
|
669
|
+
* Internal — replay buffer. RPC layer reads on (re)subscribe to feed
|
|
670
|
+
* missed chunks before going live.
|
|
671
|
+
*
|
|
672
|
+
* @internal
|
|
673
|
+
*/
|
|
674
|
+
readonly buffer: ReadonlyArray<BufferedChunk<T>>;
|
|
675
|
+
}
|
|
676
|
+
interface CreateStreamReaderOptions {
|
|
677
|
+
id?: string;
|
|
678
|
+
/**
|
|
679
|
+
* Maximum number of buffered chunks held client-side while the consumer
|
|
680
|
+
* isn't draining. On overflow, the oldest chunk is dropped.
|
|
681
|
+
*/
|
|
682
|
+
highWaterMark?: number;
|
|
683
|
+
/**
|
|
684
|
+
* Called when the chunk queue overflows the high-water mark. The RPC
|
|
685
|
+
* layer wires this to a coded warning; the primitive itself is
|
|
686
|
+
* RPC-agnostic.
|
|
687
|
+
*/
|
|
688
|
+
onOverflow?: (dropped: number) => void;
|
|
689
|
+
/** Called when the consumer cancels — the RPC layer sends `:cancel` upstream. */
|
|
690
|
+
onCancel?: () => void;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Client-side consumer handle. Both an `AsyncIterable<T>` (for `for await`)
|
|
694
|
+
* and exposes `readable: ReadableStream<T>` (for `pipeTo`). Pick one — they
|
|
695
|
+
* share a single internal queue, so concurrent draining will race.
|
|
696
|
+
*/
|
|
697
|
+
interface StreamReader<T> extends AsyncIterable<T> {
|
|
698
|
+
readonly id: string;
|
|
699
|
+
readonly cancelled: boolean;
|
|
700
|
+
readonly done: boolean;
|
|
701
|
+
/** Highest `seq` observed. Used for replay on reconnect. */
|
|
702
|
+
readonly lastSeenSeq: number;
|
|
703
|
+
/** `ReadableStream<T>` adapter for `pipeTo`-style consumption. */
|
|
704
|
+
readonly readable: ReadableStream<T>;
|
|
705
|
+
cancel: () => void;
|
|
706
|
+
/** @internal */
|
|
707
|
+
_push: (seq: number, chunk: T) => void;
|
|
708
|
+
/** @internal */
|
|
709
|
+
_end: (error?: StreamErrorPayload) => void;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Build a server-side stream sink. RPC-agnostic — the RPC host wires
|
|
713
|
+
* `events.on('chunk' | 'end')` to broadcast, and reads `buffer` to replay
|
|
714
|
+
* for late or reconnecting subscribers.
|
|
715
|
+
*/
|
|
716
|
+
declare function createStreamSink<T>(options?: CreateStreamSinkOptions): StreamSink<T>;
|
|
717
|
+
/**
|
|
718
|
+
* Build a client-side stream reader. RPC-agnostic — the RPC host calls
|
|
719
|
+
* `_push(seq, chunk)` on each incoming chunk and `_end(error?)` on the
|
|
720
|
+
* terminal frame. Consumers iterate with `for await` or pipe `readable`.
|
|
721
|
+
*/
|
|
722
|
+
declare function createStreamReader<T>(options?: CreateStreamReaderOptions): StreamReader<T>;
|
|
723
|
+
//#endregion
|
|
989
724
|
//#region src/types/rpc.d.ts
|
|
990
725
|
interface DevToolsNodeRpcSession {
|
|
991
726
|
meta: DevToolsNodeRpcSessionMeta;
|
|
@@ -1019,6 +754,13 @@ type RpcFunctionsHost = RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, De
|
|
|
1019
754
|
* The shared state host
|
|
1020
755
|
*/
|
|
1021
756
|
sharedState: RpcSharedStateHost;
|
|
757
|
+
/**
|
|
758
|
+
* The streaming channel host. Provides per-channel `start()` /
|
|
759
|
+
* `pipeFrom()` producers; clients consume via `rpc.streaming.subscribe()`.
|
|
760
|
+
*
|
|
761
|
+
* @see RpcStreamingHost
|
|
762
|
+
*/
|
|
763
|
+
streaming: RpcStreamingHost;
|
|
1022
764
|
};
|
|
1023
765
|
interface RpcSharedStateGetOptions<T> {
|
|
1024
766
|
sharedState?: SharedState<T>;
|
|
@@ -1035,41 +777,152 @@ interface RpcSharedStateHost {
|
|
|
1035
777
|
*/
|
|
1036
778
|
onKeyAdded: (fn: (key: string) => void) => () => void;
|
|
1037
779
|
}
|
|
780
|
+
/**
|
|
781
|
+
* Options for `RpcStreamingHost.create()`.
|
|
782
|
+
*/
|
|
783
|
+
interface RpcStreamingChannelOptions {
|
|
784
|
+
/**
|
|
785
|
+
* Size of the per-stream ring buffer kept on the server for
|
|
786
|
+
* replay-on-resubscribe. `0` (default) disables replay; on reconnect
|
|
787
|
+
* the consumer only sees chunks that arrive after subscribing.
|
|
788
|
+
*
|
|
789
|
+
* The buffer is per stream id, not per channel — each `channel.start()`
|
|
790
|
+
* gets its own.
|
|
791
|
+
*/
|
|
792
|
+
replayWindow?: number;
|
|
793
|
+
/**
|
|
794
|
+
* Milliseconds a closed stream is retained on the server after its
|
|
795
|
+
* last subscriber leaves (or if no subscriber ever arrived). During
|
|
796
|
+
* this window, late subscribers can still join and replay the buffer
|
|
797
|
+
* + receive the `end` frame.
|
|
798
|
+
*
|
|
799
|
+
* Defaults to `30_000` (30 s) when `replayWindow > 0`, else `0`
|
|
800
|
+
* (immediate free). Set to `0` to opt out, or higher for longer
|
|
801
|
+
* post-mortem replay.
|
|
802
|
+
*/
|
|
803
|
+
closedStreamRetention?: number;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Channel handle returned by `ctx.rpc.streaming.create(name, opts)`. A
|
|
807
|
+
* channel owns a wire namespace; calling `start()` produces individual
|
|
808
|
+
* streams keyed by id.
|
|
809
|
+
*
|
|
810
|
+
* @see {@link https://devfra.me/guide/streaming Streaming guide}
|
|
811
|
+
*/
|
|
812
|
+
interface RpcStreamingChannel<T = unknown> {
|
|
813
|
+
/** Channel name as registered with `ctx.rpc.streaming.create()`. */
|
|
814
|
+
readonly name: string;
|
|
815
|
+
/**
|
|
816
|
+
* Start a new stream. Returns a server-side sink with both an imperative
|
|
817
|
+
* (`write` / `close` / `error`) surface and a `WritableStream<T>` for
|
|
818
|
+
* `pipeTo` consumption. The sink's `signal` aborts when every subscriber
|
|
819
|
+
* disconnects or cancels.
|
|
820
|
+
*/
|
|
821
|
+
start: (opts?: {
|
|
822
|
+
id?: string;
|
|
823
|
+
}) => StreamSink<T>;
|
|
824
|
+
/**
|
|
825
|
+
* Convenience: start a stream and pipe a `ReadableStream<T>` into it.
|
|
826
|
+
* The pipe uses `sink.signal` so cancellation propagates upstream.
|
|
827
|
+
*
|
|
828
|
+
* Node-stream interop: convert a `Readable` with `Readable.toWeb(node)`
|
|
829
|
+
* before passing it here.
|
|
830
|
+
*/
|
|
831
|
+
pipeFrom: (readable: ReadableStream<T>, opts?: {
|
|
832
|
+
id?: string;
|
|
833
|
+
}) => Promise<StreamSink<T>>;
|
|
834
|
+
/** Look up an active stream by id. Returns `undefined` if none. */
|
|
835
|
+
get: (id: string) => StreamSink<T> | undefined;
|
|
836
|
+
/** All active outbound stream ids on this channel. */
|
|
837
|
+
ids: () => string[];
|
|
838
|
+
/**
|
|
839
|
+
* Open an inbound stream — the server side of a client-to-server
|
|
840
|
+
* upload. Allocates an id, returns a `StreamReader<T>` that fills as
|
|
841
|
+
* the client writes chunks. Typical pattern is to call this from an
|
|
842
|
+
* action handler, kick off background processing, and return the id
|
|
843
|
+
* so the caller can start uploading:
|
|
844
|
+
*
|
|
845
|
+
* ```ts
|
|
846
|
+
* handler: async () => {
|
|
847
|
+
* const reader = channel.openInbound()
|
|
848
|
+
* ;(async () => {
|
|
849
|
+
* for await (const chunk of reader) processChunk(chunk)
|
|
850
|
+
* })()
|
|
851
|
+
* return { uploadId: reader.id }
|
|
852
|
+
* }
|
|
853
|
+
* ```
|
|
854
|
+
*
|
|
855
|
+
* Calling `reader.cancel()` on the server sends an `upload-cancel` to
|
|
856
|
+
* the uploading client, which aborts its sink.
|
|
857
|
+
*/
|
|
858
|
+
openInbound: (opts?: {
|
|
859
|
+
id?: string;
|
|
860
|
+
}) => StreamReader<T>;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Server-side streaming host. Lives on `ctx.rpc.streaming` alongside
|
|
864
|
+
* `ctx.rpc.sharedState`. Each named channel owns its own stream registry
|
|
865
|
+
* and wire namespace.
|
|
866
|
+
*/
|
|
867
|
+
interface RpcStreamingHost {
|
|
868
|
+
/**
|
|
869
|
+
* Register a streaming channel. Names follow the `<plugin-id>:<channel>`
|
|
870
|
+
* convention (e.g. `'my-devtool:chat-stream'`). Throws `DF0032` if the
|
|
871
|
+
* name is already taken.
|
|
872
|
+
*/
|
|
873
|
+
create: <T = unknown>(name: string, opts?: RpcStreamingChannelOptions) => RpcStreamingChannel<T>;
|
|
874
|
+
/**
|
|
875
|
+
* Adapters call this when a session disconnects so the host can drop
|
|
876
|
+
* subscribers and abort orphaned streams. Most users do not need this;
|
|
877
|
+
* it's wired by `startHttpAndWs` automatically.
|
|
878
|
+
*
|
|
879
|
+
* @internal
|
|
880
|
+
*/
|
|
881
|
+
_onSessionDisconnected: (meta: DevToolsNodeRpcSessionMeta) => void;
|
|
882
|
+
}
|
|
1038
883
|
//#endregion
|
|
1039
884
|
//#region src/types/context.d.ts
|
|
1040
885
|
interface DevToolsCapabilities {
|
|
1041
886
|
rpc?: boolean;
|
|
1042
887
|
views?: boolean;
|
|
1043
888
|
}
|
|
889
|
+
/**
|
|
890
|
+
* Framework-neutral node context — RPC + diagnostics + agent + the
|
|
891
|
+
* view-host (HTTP file-serving). Hub-level subsystems (docks,
|
|
892
|
+
* terminals, messages, commands) are not part of this surface; they are
|
|
893
|
+
* added by `@vitejs/devtools-kit`'s `createKitContext` when the devtool
|
|
894
|
+
* is mounted into a multi-integration hub.
|
|
895
|
+
*/
|
|
1044
896
|
interface DevToolsNodeContext {
|
|
1045
897
|
readonly workspaceRoot: string;
|
|
1046
898
|
readonly cwd: string;
|
|
899
|
+
/**
|
|
900
|
+
* Lifecycle distinction surfaced to plugin authors:
|
|
901
|
+
*
|
|
902
|
+
* - `'dev'` — long-running, interactive session. Connections come and
|
|
903
|
+
* go; broadcasts and shared-state mutations are debounced
|
|
904
|
+
* to keep the UI responsive.
|
|
905
|
+
* - `'build'` — one-shot batch run. The context is set up, the devtool
|
|
906
|
+
* collects what it needs, and a snapshot is written. No
|
|
907
|
+
* live UI, no WS server.
|
|
908
|
+
*
|
|
909
|
+
* Names are inherited from Vite's serve/build dichotomy but the meaning
|
|
910
|
+
* is general: the same distinction applies to any tool that runs in
|
|
911
|
+
* either an interactive or a static-output mode.
|
|
912
|
+
*/
|
|
1047
913
|
readonly mode: 'dev' | 'build';
|
|
1048
914
|
/**
|
|
1049
|
-
* Host runtime abstraction — exposes `mountStatic` / `resolveOrigin
|
|
915
|
+
* Host runtime abstraction — exposes `mountStatic` / `resolveOrigin` /
|
|
916
|
+
* `getStorageDir`.
|
|
1050
917
|
*/
|
|
1051
918
|
host: DevToolsHost;
|
|
1052
919
|
rpc: RpcFunctionsHost;
|
|
1053
|
-
docks: DevToolsDockHost;
|
|
1054
920
|
views: DevToolsViewHost;
|
|
1055
|
-
utils: DevToolsNodeUtils;
|
|
1056
|
-
terminals: DevToolsTerminalHost;
|
|
1057
|
-
/**
|
|
1058
|
-
* User-facing message subsystem — toast notifications and the
|
|
1059
|
-
* "Messages & Notifications" dock panel. Plugins call
|
|
1060
|
-
* `ctx.messages.add({ ... })` to surface activity to users.
|
|
1061
|
-
*/
|
|
1062
|
-
messages: DevToolsMessagesHost;
|
|
1063
|
-
/**
|
|
1064
|
-
* @deprecated Use `ctx.messages` instead. Will be removed in a future release.
|
|
1065
|
-
*/
|
|
1066
|
-
readonly logs: DevToolsMessagesHost;
|
|
1067
921
|
/**
|
|
1068
922
|
* Structured diagnostics host — wraps `logs-sdk` and lets integrations
|
|
1069
923
|
* register their own coded errors/warnings into the shared logger.
|
|
1070
924
|
*/
|
|
1071
925
|
diagnostics: DevToolsDiagnosticsHost;
|
|
1072
|
-
commands: DevToolsCommandsHost;
|
|
1073
926
|
/**
|
|
1074
927
|
* Agent host — aggregates the agent-exposed surface of this devtool.
|
|
1075
928
|
*
|
|
@@ -1081,15 +934,6 @@ interface DevToolsNodeContext {
|
|
|
1081
934
|
*/
|
|
1082
935
|
createJsonRenderer: (spec: JsonRenderSpec) => JsonRenderer;
|
|
1083
936
|
}
|
|
1084
|
-
interface DevToolsNodeUtils {
|
|
1085
|
-
/**
|
|
1086
|
-
* Create a simple client script from a function or stringified code.
|
|
1087
|
-
*
|
|
1088
|
-
* @deprecated testing helper; prefer a proper importable module.
|
|
1089
|
-
* @experimental
|
|
1090
|
-
*/
|
|
1091
|
-
createSimpleClientScript: (fn: string | ((ctx: any) => void)) => ClientScriptEntry;
|
|
1092
|
-
}
|
|
1093
937
|
interface ConnectionMeta {
|
|
1094
938
|
backend: 'websocket' | 'static';
|
|
1095
939
|
websocket?: number | string;
|
|
@@ -1103,20 +947,13 @@ interface ConnectionMeta {
|
|
|
1103
947
|
*/
|
|
1104
948
|
jsonSerializableMethods?: string[];
|
|
1105
949
|
}
|
|
1106
|
-
interface RemoteConnectionInfo extends ConnectionMeta {
|
|
1107
|
-
backend: 'websocket';
|
|
1108
|
-
websocket: string;
|
|
1109
|
-
v: 1;
|
|
1110
|
-
authToken: string;
|
|
1111
|
-
origin: string;
|
|
1112
|
-
}
|
|
1113
950
|
//#endregion
|
|
1114
951
|
//#region src/types/devtool.d.ts
|
|
1115
952
|
type DevtoolRuntime = 'cli' | 'build' | 'spa' | 'vite' | 'kit' | 'embedded';
|
|
1116
953
|
/**
|
|
1117
954
|
* Classification of how a devtool is being deployed. Hosted adapters
|
|
1118
955
|
* (`vite`, `kit`, `embedded`) share their origin with a host app and
|
|
1119
|
-
* must namespace their mount path under
|
|
956
|
+
* must namespace their mount path under `/__<id>/`. Standalone adapters
|
|
1120
957
|
* (`cli`, `spa`, `build`) own the origin and default to `/`.
|
|
1121
958
|
*/
|
|
1122
959
|
type DevtoolDeploymentKind = 'standalone' | 'hosted';
|
|
@@ -1217,7 +1054,7 @@ interface DevtoolDefinition {
|
|
|
1217
1054
|
version?: string;
|
|
1218
1055
|
/**
|
|
1219
1056
|
* Mount path override. Defaults depend on the adapter:
|
|
1220
|
-
* `/` for standalone (`cli` / `spa` / `build`),
|
|
1057
|
+
* `/` for standalone (`cli` / `spa` / `build`), `/__<id>/` for hosted
|
|
1221
1058
|
* (`vite` / `kit` / `embedded`).
|
|
1222
1059
|
*/
|
|
1223
1060
|
basePath?: string;
|
|
@@ -1235,4 +1072,4 @@ interface DevtoolDefinition {
|
|
|
1235
1072
|
}
|
|
1236
1073
|
declare function defineDevtool(d: DevtoolDefinition): DevtoolDefinition;
|
|
1237
1074
|
//#endregion
|
|
1238
|
-
export {
|
|
1075
|
+
export { AgentHandle as $, ImmutableArray as A, EntriesToObject as B, StreamErrorPayload as C, createStreamReader as D, StreamSinkEvents as E, SharedStateEvents as F, DevToolsRpcSharedStates as G, Thenable as H, SharedStateOptions as I, JsonRenderer as J, JsonRenderElement as K, SharedStatePatch as L, ImmutableObject as M, ImmutableSet as N, createStreamSink as O, SharedState as P, DevToolsDiagnosticsLogger as Q, createSharedState as R, CreateStreamSinkOptions as S, StreamSink as T, DevToolsRpcClientFunctions as U, PartialWithoutId as V, DevToolsRpcServerFunctions as W, DevToolsDiagnosticsDefinition as X, DevToolsHost as Y, DevToolsDiagnosticsHost as Z, RpcStreamingChannel as _, DevtoolRuntime as a, AgentToolInput as at, BufferedChunk as b, defineDevtool as c, EventEmitter as ct, DevToolsNodeContext as d, CliFlagsSchema as dt, AgentManifest as et, DevToolsNodeRpcSession as f, InferCliFlags as ft, RpcSharedStateHost as g, RpcSharedStateGetOptions as h, DevtoolDeploymentKind as i, AgentTool as it, ImmutableMap as j, Immutable as k, ConnectionMeta as l, EventUnsubscribe as lt, RpcFunctionsHost as m, parseCliFlags as mt, DevtoolCliOptions as n, AgentResourceContent as nt, DevtoolSetupInfo as o, DevToolsAgentHost as ot, RpcBroadcastOptions as p, defineCliFlags as pt, JsonRenderSpec as q, DevtoolDefinition as r, AgentResourceInput as rt, DevtoolSpaOptions as s, DevToolsAgentHostEvents as st, DevtoolBrowserContext as t, AgentResource as tt, DevToolsCapabilities as u, EventsMap as ut, RpcStreamingChannelOptions as v, StreamReader as w, CreateStreamReaderOptions as x, RpcStreamingHost as y, DevToolsViewHost as z };
|