/** * Lenient parser for what Node's `console.log` prints — `util.inspect` output — * and for plain JSON, producing a serializable `LogValue` tree a viewer can * render with syntax highlighting. * * Inspect output is not a data format: it is not JSON (unquoted keys, single * quotes, `undefined`), it carries annotations (`[Object: null prototype]`, * ``, `Map(2)`), and it is lossy (`[Object]` past depth 2, `... 20 more * items`). The parser keeps every annotation as a node — a `tag` on containers * or a `special` leaf — so nothing the log said is dropped, and it fails closed: * anything it can't read whole returns `null` and the caller shows plain text. */ /** A `key: value` field of an object, or a named extra on an array. */ export interface LogProp { key: string; value: LogValue; } /** Shared by every container. `tag` is the annotation printed before it. */ interface ContainerBase { /** `Foo`, `Map(2)`, `[Object: null prototype]`, `Error: boom\n at …`. */ tag?: string; /** Set when printed as `` — the target of a later `[Circular *N]`. */ ref?: number; /** Count from a trailing `... N more items` (inspect truncated the list). */ more?: number; } export interface LogObject extends ContainerBase { kind: 'object'; props: LogProp[]; /** Keyless members: `Promise { 3 }`, `WeakMap { }`. */ items?: LogValue[]; } export interface LogArray extends ContainerBase { kind: 'array'; /** Elements; also the members of a `Set(n) { … }`. */ items: LogValue[]; /** Named extras: `[ 1, 2, extra: 'y' ]`. */ props?: LogProp[]; } export interface LogMap extends ContainerBase { kind: 'map'; pairs: { key: LogValue; value: LogValue; }[]; } export type LogValue = { kind: 'string'; value: string; } /** Kept as printed so `NaN`, `-0`, `1e+21` and bigints (`10n`) survive JSON. */ | { kind: 'number'; text: string; } | { kind: 'boolean'; value: boolean; } | { kind: 'null'; } | { kind: 'undefined'; } /** A `Date`, which inspect prints bare: `2026-10-21T13:34:06.000Z`. */ | { kind: 'date'; text: string; } /** * Anything inspect prints as an opaque token: `[Function: f]`, `[class K]`, * `[Circular *1]`, `[Object]`, `[Getter]`, `Symbol(x)`, `/re/g`, * ``, `<2 empty items>`, an `Error: …` with its stack. */ | { kind: 'special'; text: string; } | LogObject | LogArray | LogMap; export interface ParsedLogText { /** Text before the value (`WidgetController.getBootstrapData executed`), trimmed. */ message: string; /** The trailing object/array, or null when the text holds none. */ value: LogValue | null; } /** * Split a log text into its message and a trailing structured value — the * shape of `console.log('msg', obj)` — or a whole-text JSON object/array. * Only a container counts as a value: `handler is [Function: f]` stays text. * * The value must start the text or follow whitespace (that is how * `console.log` joins its arguments) and must run to the end of the text, so a * path like `/accounts/{accountId}/x` is never mistaken for an object. */ export declare function parseLogText(text: string): ParsedLogText; /** Parse a whole text as exactly one inspect value (scalar or container). */ export declare function parseInspect(text: string): LogValue | null; /** Convert a JSON value (e.g. a structured log line already parsed upstream). */ export declare function fromJson(v: unknown): LogValue; /** * Best-effort JSON for "copy as JSON". Lossy where JSON can't express inspect: * specials, dates and non-finite numbers become their printed text, Map keys * are stringified, and annotations (`tag`, `ref`, `more`) are dropped. */ export declare function toJson(v: LogValue): unknown; export {}; //# sourceMappingURL=inspect-parse.d.ts.map