//#region src/client/core.d.ts /** * Framework-agnostic command handlers — the heart of the in-page client. * * Everything here speaks only the DOM, `window`, `fetch`, `performance` and * web storage. There is no Vue, React, Pinia or build-tool coupling, so the * same handlers run when pasted into the Console of *any* site. * * Framework-specific inspectors (vue/pinia/react) are NOT here — they ship as * optional adapters and are merged in via `connect({ registerCommands })`. */ type Respond = (data: Record) => void; type CmdHandler = (parsed: Record, respond: Respond) => void; //#endregion //#region src/client/adapters/shared.d.ts /** A framework/state inspector: a named bundle of ws-devtools command handlers. */ interface Adapter { /** Stable id, typically the primary command name (e.g. 'react', 'query'). */ name: string; /** The ws-devtools command handlers this adapter registers on the client. */ commands: Record; } /** Merge adapters into the command map that `connect({ registerCommands })` expects. */ declare function mergeAdapters(...adapters: Adapter[]): Record; /** * Collect app-defined *custom* adapters the page published on a window global, * for the extension path (where there's no `connect()` call to pass them in). * The app sets `window.__WS_DEVTOOLS_ADAPTERS__` to an array of {@link Adapter} * objects — set it **before arming the tab** so the commands exist when the * extension's client registers them. Malformed entries are skipped. Returns a * flat command map ready to merge over the built-ins. */ declare function readCustomAdapters(explicit?: unknown, global?: string): Record; /** Deep-clone to a plain, JSON-safe value — unwraps proxies, tames circular refs. */ declare function plain(value: unknown): unknown; /** * Resolve a dependency an adapter needs (a store / client / router): prefer the * one passed explicitly at register time, else a window global the app exposed * for the extension path (where there's no app code to pass it in). */ declare function resolveDep(explicit: T | undefined, ...globals: string[]): T | undefined; /** * Read a per-instance *registry* the app exposes — a `Map`, array, or plain * object of live instances (forms, tables) keyed by id. Unlike a singleton * (`resolveDep`), these come and go as components mount/unmount, so the app * publishes a container the instances register into. Returns `[id, instance]` * pairs (empty when the registry is absent or the wrong shape). */ declare function readRegistry(explicit: unknown, ...globals: string[]): Array<[string, unknown]>; //#endregion //#region src/client/adapters/tree.d.ts /** Assign (or reuse) the stable `fN` handle this node carries across walks. */ declare function handleFor(node: object): string; /** Extract the id from an `@fN` handle, or `null` when it isn't one. */ declare function parseHandle(target: string): string | null; /** Resolve an `@fN` handle back to its node, or `null` if it's gone. */ declare function nodeByHandle(target: string): N | null; /** What a framework reports about one node in its tree. */ interface NodeInfo { /** Display name, e.g. `UserCard`, `Memo(Row)`, `Suspense`, `div`. */ name: string; /** * Coarse classification the framework decides, e.g. `function` / `class`. * Two values are load-bearing: **`host`** marks a DOM element node and * **`text`** a text node, and both are hidden from the listing unless * `includeHost` is set. Everything else is treated as a component. */ kind: string; /** The list key, when the framework tracks one. */ key?: string | null; /** The DOM element this node owns, used to bridge a component to a `@ref`. */ host?: Element | null; /** True for structural nodes that should be walked through but not listed. */ skip?: boolean; /** Extra fields merged into the emitted row (e.g. `suspended`). */ extra?: Record; } /** How to walk one framework's component tree. */ interface TreeSpec { /** The tree's entry points (usually one app root). */ roots(): N[]; /** Describe a node, or return `null` to walk through it without listing it. */ describe(node: N): NodeInfo | null; /** This node's direct children, outermost first. */ children(node: N): N[]; } /** One listed component. `ref` is present when the node owns a DOM element. */ interface TreeRow extends Record { id: string; name: string; kind: string; depth: number; } interface WalkOptions { /** Stop listing below this component depth (the walk still descends for refs). */ maxDepth?: number; maxRows?: number; maxNodes?: number; /** Keep host/DOM nodes in the listing (they're structural noise by default). */ includeHost?: boolean; /** Bridge a DOM element to a `snapshot` `@ref` you can click. */ refFor?: (el: Element) => string; } interface WalkResult { rows: TreeRow[]; /** Components that matched, before `maxRows` trimmed the list. */ total: number; truncated: boolean; /** Nodes visited — near `maxNodes` means the tree was cut short. */ scanned: number; } /** * Bounded depth-first walk over a component tree. * * Three things are worth knowing about the traversal: * * - **Depth counts listed components, not raw nodes.** Host elements and * structural wrappers are walked through but don't advance depth, so * `--depth 2` means two levels of *your* components rather than two levels of * whatever the framework happened to nest in between. * - **`maxDepth` stops listing, not descending.** The walk keeps going so a * shallow row can still be handed the `@ref` of a DOM node further down. * - **A component adopts the first DOM element in its subtree.** A component * whose own node is not a host element (the common case) has no element of its * own, so the first host found beneath it is attributed to it *and* to every * ancestor still lacking one — which is exactly right for a chain of wrappers * that all render through to the same element. */ declare function walkComponentTree(spec: TreeSpec, opts?: WalkOptions): WalkResult; //#endregion //#region src/client/adapters/react.d.ts declare function createReactAdapter(): Adapter; //#endregion //#region src/client/adapters/react-query.d.ts declare function createReactQueryAdapter(client?: unknown): Adapter; //#endregion //#region src/client/adapters/tanstack-router.d.ts declare function createTanstackRouterAdapter(router?: unknown): Adapter; //#endregion //#region src/client/adapters/tanstack-form.d.ts declare function createTanstackFormAdapter(forms?: unknown): Adapter; //#endregion //#region src/client/adapters/tanstack-table.d.ts declare function createTanstackTableAdapter(tables?: unknown): Adapter; //#endregion //#region src/client/adapters/sonner.d.ts declare function createSonnerAdapter(toasts?: unknown): Adapter; //#endregion //#region src/client/adapters/auth.d.ts declare function createAuthAdapter(snapshot?: unknown): Adapter; //#endregion //#region src/client/adapters/vue.d.ts declare function createVueAdapter(): Adapter; //#endregion //#region src/client/adapters/pinia.d.ts declare function createPiniaAdapter(pinia?: unknown): Adapter; //#endregion export { type Adapter, type NodeInfo, type TreeRow, type TreeSpec, type WalkOptions, type WalkResult, createAuthAdapter, createPiniaAdapter, createReactAdapter, createReactQueryAdapter, createSonnerAdapter, createTanstackFormAdapter, createTanstackRouterAdapter, createTanstackTableAdapter, createVueAdapter, handleFor, mergeAdapters, nodeByHandle, parseHandle, plain, readCustomAdapters, readRegistry, resolveDep, walkComponentTree };