flugrekorder 1.2.0-beta.0 → 2.0.0-beta.0

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../source/flugrekorder.ts","../source/types.ts","../source/graph.ts","../source/serialize.ts","../source/slots.ts","../source/specs.ts","../source/errors.ts","../source/retry.ts","../source/inspection.ts","../source/format.ts"],"sourcesContent":["import type { Writable } from 'node:stream';\nimport type { GraphNode } from './graph';\nimport { Graph } from './graph';\nimport type { SerialConfig } from './serialize';\nimport { serialize, origin as serializeOrigin } from './serialize';\nimport type { Spec, Wrapper } from './specs';\nimport { makeSpecs } from './specs';\nimport type {\n\tCallTrap,\n\tOrigin,\n\tPropertyTrap,\n\tProxiable,\n\tRedactor,\n\tRekording,\n} from './types';\nimport { isProxiable } from './types';\nimport { retryFlows } from './retry';\n\nexport { format } from './format';\nexport {\n\tgetAncestors,\n\tgetOrigin,\n\tgetPath,\n\tgetProxyById,\n\tgetTarget,\n} from './inspection';\nexport type {\n\tCallTrap,\n\tOrigin,\n\tPropertyTrap,\n\tProxiable,\n\tRedactor,\n\tRekording,\n\tSerialized,\n} from './types';\nexport { isProxiable } from './types';\n\n\n/** Resolved runtime configuration — derived from CreateOptions and passed through the proxy factory. */\ntype Config = {\n\twrite: (r: Rekording) => void;\n\trecursive: boolean;\n\tonly: Set<string> | null;\n\tfilter: ((r: Rekording) => boolean) | null;\n\tserial: SerialConfig;\n\tspecs: Partial<Record<string, Spec>>;\n\tbind: boolean | undefined;\n};\n\ntype CommonCreateOptions = {\n\tid?: number | (() => string);\n\trecursive?: boolean;\n\tonly?: Array<string>;\n\tfilter?: (rekording: Rekording) => boolean;\n\tdepth?: number;\n\tredact?: Redactor | Array<Redactor>;\n\ttruncate?: number;\n\tbind?: boolean;\n};\n\ntype StreamCreateOptions = CommonCreateOptions & { stream: Writable };\ntype CallbackCreateOptions = CommonCreateOptions & {\n\tcallback: (record: Rekording) => void;\n};\ntype CreateOptions = StreamCreateOptions | CallbackCreateOptions;\n\n/**\n * Creates a recording proxy for `target` within `graph`.\n * Reuses existing proxies for stability, handles Promises specially,\n * and registers every new proxy in both the graph and the module-level index.\n */\nfunction makeProxy<T extends Proxiable>(\n\ttarget: T,\n\tgraph: Graph,\n\tconfig: Config,\n\torigin: Origin,\n): T {\n\t// Already a proxy (in any graph) — return unchanged, preventing double-wrapping.\n\tif (Graph.isProxy(<Proxiable>target)) return target;\n\n\t// Already have a proxy for this original — reuse it (stability guarantee).\n\tconst existing = graph.getByTarget(<Proxiable>target);\n\n\tif (existing) return <T>existing.proxy;\n\n\t// Promises cannot be proxied directly: native methods like .then() check for\n\t// the [[PromiseState]] internal slot and throw if `this` is a Proxy. Instead,\n\t// return a new Promise that resolves to a proxy of the settled value.\n\tif (target instanceof Promise) {\n\t\tconst chained = <T>(\n\t\t\t(<unknown>(\n\t\t\t\ttarget.then((value) =>\n\t\t\t\t\tisProxiable(value)\n\t\t\t\t\t\t? makeProxy(<Proxiable>value, graph, config, origin)\n\t\t\t\t\t\t: value,\n\t\t\t\t)\n\t\t\t))\n\t\t);\n\t\t// Register with a placeholder node so stability lookups work.\n\t\tconst id = graph.nextId();\n\n\t\tgraph.register(<Proxiable>chained, <Proxiable>target, origin, id);\n\n\t\treturn chained;\n\t}\n\n\tconst proxyId = graph.nextId();\n\n\tconst traps = (<Array<keyof typeof Reflect>>(\n\t\tObject.getOwnPropertyNames(Reflect)\n\t)).filter((trap) => config.only === null || config.only.has(trap));\n\n\tconst handler: ProxyHandler<Proxiable> = Object.fromEntries(\n\t\ttraps.map((trap) => [\n\t\t\ttrap,\n\t\t\t(...rawArgs: Array<unknown>) => {\n\t\t\t\tconst selfId = (<GraphNode>graph.getByTarget(target)).id;\n\n\t\t\t\tlet childOrigin: Origin =\n\t\t\t\t\t/get|set|defineProperty|getOwnPropertyDescriptor/.test(trap)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\ttrap: <PropertyTrap>trap,\n\t\t\t\t\t\t\t\tparent: selfId,\n\t\t\t\t\t\t\t\tkey: <string | symbol>rawArgs[1],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: /apply|construct/.test(trap)\n\t\t\t\t\t\t\t? { trap: <CallTrap>trap, source: selfId }\n\t\t\t\t\t\t\t: null;\n\n\t\t\t\tconst wrap: Wrapper = (v) => {\n\t\t\t\t\tif (!isProxiable(v) || Graph.isProxy(<Proxiable>v))\n\t\t\t\t\t\treturn v;\n\t\t\t\t\tif (!config.recursive) return v;\n\n\t\t\t\t\treturn makeProxy(<Proxiable>v, graph, config, childOrigin);\n\t\t\t\t};\n\n\t\t\t\t// Only wraps values already in the graph — new plain data passes through.\n\t\t\t\tconst known: Wrapper = (v) => {\n\t\t\t\t\tif (!isProxiable(v)) return v;\n\t\t\t\t\tif (Graph.isProxy(<Proxiable>v)) return v;\n\n\t\t\t\t\tconst existing = graph.getByTarget(<Proxiable>v);\n\n\t\t\t\t\tif (existing) return existing.proxy;\n\n\t\t\t\t\treturn v;\n\t\t\t\t};\n\n\t\t\t\tconst spec = config.specs[trap] ?? {};\n\t\t\t\tconst preArgs = spec.pre\n\t\t\t\t\t? spec.pre(rawArgs, wrap, known)\n\t\t\t\t\t: rawArgs;\n\n\t\t\t\tlet effectiveTrap: string = trap;\n\t\t\t\tlet effectiveArgs = preArgs;\n\t\t\t\tlet result: unknown;\n\n\t\t\t\ttry {\n\t\t\t\t\tresult = (<(...args: Array<unknown>) => unknown>(\n\t\t\t\t\t\tReflect[trap]\n\t\t\t\t\t))(...preArgs);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconst flow = retryFlows.find(({ is }) =>\n\t\t\t\t\t\tis(trap, e, config.bind),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (flow) {\n\t\t\t\t\t\t// is() matched preArgs to this flow's parameter shape at runtime;\n\t\t\t\t\t\t// the union can't express that statically.\n\t\t\t\t\t\tconst invoke = flow.handle as (\n\t\t\t\t\t\t\tg: Graph | undefined,\n\t\t\t\t\t\t\t...a: Array<unknown>\n\t\t\t\t\t\t) => { args?: Array<unknown>; result: unknown };\n\t\t\t\t\t\tconst output = invoke(graph, ...preArgs);\n\t\t\t\t\t\tif (flow.trap) {\n\t\t\t\t\t\t\teffectiveTrap = flow.trap;\n\t\t\t\t\t\t\tchildOrigin = {\n\t\t\t\t\t\t\t\ttrap: <CallTrap>flow.trap,\n\t\t\t\t\t\t\t\tsource: selfId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (output?.args) effectiveArgs = output.args;\n\t\t\t\t\t\tresult = output.result;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst output = spec.post\n\t\t\t\t\t? spec.post(result, effectiveArgs, wrap)\n\t\t\t\t\t: result;\n\n\t\t\t\tconst rekording: Rekording = {\n\t\t\t\t\tid: graph.nextId(),\n\t\t\t\t\ttrap: effectiveTrap,\n\t\t\t\t\torigin: serializeOrigin(childOrigin),\n\t\t\t\t\targs: effectiveArgs.map((arg) =>\n\t\t\t\t\t\tserialize(arg, graph, new Set(), config.serial),\n\t\t\t\t\t),\n\t\t\t\t\tresult: serialize(output, graph, new Set(), config.serial),\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t};\n\t\t\t\tif (!config.filter || config.filter(rekording))\n\t\t\t\t\tconfig.write(rekording);\n\n\t\t\t\treturn output;\n\t\t\t},\n\t\t]),\n\t);\n\n\tconst pxy = <T>(<unknown>new Proxy(<Proxiable>target, handler));\n\n\tgraph.register(<Proxiable>pxy, <Proxiable>target, origin, proxyId);\n\tGraph.track(<Proxiable>pxy);\n\n\treturn pxy;\n}\n\n/**\n * Wraps `target` in a transparent recording proxy.\n * Every Reflect trap that fires emits a `Rekording` to `callback` or `stream`.\n */\nexport function create<T extends Proxiable>(\n\ttarget: T,\n\toptions: CreateOptions,\n): T {\n\tconst write: (r: Rekording) => void =\n\t\t'stream' in options\n\t\t\t? (r) => options.stream.write(`${JSON.stringify(r)}\\n`)\n\t\t\t: options.callback;\n\tconst recursive = options.recursive !== false;\n\tconst only = options.only ? new Set(options.only) : null;\n\tconst filter = options.filter ?? null;\n\tconst { redact } = options;\n\tconst serial: SerialConfig = {\n\t\tdepth: options.depth ?? Infinity,\n\t\tredactors: redact ? (Array.isArray(redact) ? redact : [redact]) : [],\n\t\ttruncate: options.truncate ?? Infinity,\n\t};\n\tconst graph = new Graph(options.id ?? 0);\n\tconst specs = makeSpecs(options.bind);\n\n\treturn makeProxy(\n\t\ttarget,\n\t\tgraph,\n\t\t{ write, recursive, only, filter, serial, specs, bind: options.bind },\n\t\tnull,\n\t);\n}\n\n/** Returns `true` if `value` is a proxy created by this module. */\nexport function isFlugrekorder(value: unknown): value is Proxiable {\n\treturn isProxiable(value) && Graph.isProxy(<Proxiable>value);\n}\n","import type { Graph } from './graph';\nexport type Proxiable = object;\n\n/** Reflect traps that operate on a property — carry a parent ID and key in their origin. */\nexport type PropertyTrap =\n\t| 'get'\n\t| 'set'\n\t| 'defineProperty'\n\t| 'getOwnPropertyDescriptor';\n\n/** Reflect traps that invoke a callable — carry a source ID in their origin. Includes synthetic variants for native boundary crossings. */\nexport type CallTrap =\n\t| 'apply'\n\t| 'construct'\n\t| 'apply:native'\n\t| 'construct:native'\n\t| 'apply:structure'\n\t| 'apply:private';\n\n/** Describes how a proxy was created — which trap fired, on which parent, and under which key or source. Null for root proxies. */\nexport type Origin =\n\t| { trap: PropertyTrap; parent: string; key: string | symbol }\n\t| { trap: CallTrap; source: string }\n\t| null;\n\n/** Origin with symbol keys coerced to strings — safe to include in a Rekording. */\nexport type SerializedOrigin =\n\t| { trap: PropertyTrap; parent: string; key: string }\n\t| { trap: CallTrap; source: string }\n\t| null;\n\n/** A JSON-safe representation of any value. Proxiable values are replaced with `{ $proxy: id }` tags. Raw targets (proxiable values known to the graph but passed unwrapped) are tagged `{ $unwrap: { $proxy: id } }`. */\nexport type Serialized =\n\t| string\n\t| number\n\t| boolean\n\t| bigint\n\t| null\n\t| undefined\n\t| { readonly $proxy: string }\n\t| { readonly $unwrap: { readonly $proxy: string } }\n\t| Array<Serialized>\n\t| { [key: string]: Serialized };\n\n/** Returns true for any value that can meaningfully be wrapped in a Proxy. */\nexport function isProxiable(value: unknown): value is Proxiable {\n\treturn (\n\t\tvalue !== null &&\n\t\t(typeof value === 'object' || typeof value === 'function')\n\t);\n}\n\n/**\n * Determines whether and how a key/value pair should be redacted during serialization.\n * Return `false` to keep as-is, `true` to replace with `\"[redacted]\"`,\n * a string to use as a custom replacement, or `null` to drop the key entirely.\n */\nexport type Redactor = (\n\tkey: string | symbol,\n\tvalue: unknown,\n\ttarget: object,\n) => string | boolean | null;\n\n/** A single recorded interaction — one Reflect trap firing on one proxy. */\nexport type Rekording = {\n\tid: string;\n\ttrap: string;\n\torigin: SerializedOrigin;\n\targs: Array<Serialized>;\n\tresult: Serialized;\n\ttimestamp: number;\n};\n\ntype Fn = (...args: Array<unknown>) => unknown;\n\n/** Describes a retry handler for an apply trap boundary crossing. */\ntype ApplyRetryFlow = {\n\tis: (trap: string, error: unknown, bind?: boolean) => boolean;\n\ttrap?: string;\n\thandle: (\n\t\tgraph: Graph | undefined,\n\t\tfn: Fn,\n\t\tthisArg: unknown,\n\t\targList: Array<unknown>,\n\t) => { args: [Fn, unknown, Array<unknown>]; result: unknown };\n};\n\n/** Describes a retry handler for a get trap boundary crossing. */\ntype GetRetryFlow = {\n\tis: (trap: string, error: unknown, bind?: boolean) => boolean;\n\ttrap?: never;\n\thandle: (\n\t\tgraph: Graph | undefined,\n\t\ttarget: object,\n\t\tpropertyKey: PropertyKey,\n\t\treceiver: unknown,\n\t) => { result: unknown };\n};\n\n/** Describes a native boundary crossing retry handler. */\nexport type RetryFlow = ApplyRetryFlow | GetRetryFlow;\n","import { isProxiable } from './types';\nimport type { Origin, Proxiable } from './types';\n\n/** A node in the proxy graph — links a proxy to its original target, its origin, and its ID. */\nexport type GraphNode = {\n\treadonly id: string;\n\treadonly proxy: Proxiable;\n\treadonly target: Proxiable;\n\treadonly origin: Origin;\n};\n\n/**\n * Session-scoped proxy registry.\n * Each `create()` call produces its own Graph so proxied trees are\n * independent and GC-eligible once no longer referenced.\n */\nexport class Graph {\n\tstatic #index = new WeakMap<Proxiable, Graph>();\n\tstatic #all = new WeakSet<Proxiable>();\n\n\t/** Returns the Graph that owns `pxy`, or `undefined` for non-proxies. */\n\tstatic for(pxy: Proxiable): Graph | undefined {\n\t\treturn Graph.#index.get(pxy);\n\t}\n\n\t/** Returns `true` if `pxy` is a proxy created by this module. */\n\tstatic isProxy(pxy: Proxiable): boolean {\n\t\treturn Graph.#all.has(pxy);\n\t}\n\n\t/** Marks `pxy` as a known proxy across all graphs (double-wrap guard). */\n\tstatic track(pxy: Proxiable): void {\n\t\tGraph.#all.add(pxy);\n\t}\n\n\t#byId = new Map<string, GraphNode>();\n\t#byProxy = new WeakMap<Proxiable, GraphNode>();\n\t#byTarget = new WeakMap<Proxiable, GraphNode>();\n\t#generator: () => string;\n\n\tconstructor(id: number | (() => string)) {\n\t\tlet counter = typeof id === 'number' ? id : 0;\n\n\t\tthis.#generator = typeof id === 'function' ? id : () => `#${++counter}`;\n\t}\n\n\tnextId(): string {\n\t\treturn this.#generator();\n\t}\n\n\t/** Returns the underlying target if `value` is a proxy known to this graph, otherwise `value` unchanged. */\n\tunwrap(value: unknown): unknown {\n\t\tif (!isProxiable(value)) return value;\n\t\treturn this.#byProxy.get(value)?.target ?? value;\n\t}\n\n\tgetByProxy(v: Proxiable): GraphNode | undefined {\n\t\treturn this.#byProxy.get(v);\n\t}\n\tgetByTarget(v: Proxiable): GraphNode | undefined {\n\t\treturn this.#byTarget.get(v);\n\t}\n\tgetById(id: string): GraphNode | undefined {\n\t\treturn this.#byId.get(id);\n\t}\n\n\tregister(\n\t\tproxy: Proxiable,\n\t\ttarget: Proxiable,\n\t\torigin: Origin,\n\t\tid: string,\n\t): GraphNode {\n\t\tconst node: GraphNode = { id, proxy, target, origin };\n\n\t\tthis.#byId.set(id, node);\n\t\tthis.#byProxy.set(proxy, node);\n\t\tthis.#byTarget.set(target, node);\n\t\tGraph.#index.set(proxy, this);\n\n\t\treturn node;\n\t}\n}\n","import type { Graph } from './graph';\nimport {\n\tisProxiable,\n\ttype Origin,\n\ttype Proxiable,\n\ttype Redactor,\n\ttype Serialized,\n\ttype SerializedOrigin,\n} from './types';\n\nexport type SerialConfig = {\n\tdepth: number;\n\tredactors: Array<Redactor>;\n\ttruncate: number;\n};\n\nexport const defaults: SerialConfig = {\n\tdepth: Infinity,\n\tredactors: [],\n\ttruncate: Infinity,\n};\n\n/** Find and apply any redaction for the given key/value/target context */\nfunction redact(\n\tredactors: Array<Redactor>,\n\tkey: string | symbol,\n\tvalue: unknown,\n\ttarget: object,\n): string | null | false {\n\tfor (const redactor of redactors) {\n\t\tconst result = redactor(key, value, target);\n\t\tif (result === false) continue;\n\n\t\treturn result === true ? '[redacted]' : result;\n\t}\n\n\treturn false;\n}\n\n/** Serializes an object or function value — tags known proxies by ID, inlines arrays and plain objects. */\nfunction proxiable(\n\tv: unknown,\n\tgraph: Graph,\n\tseen: Set<unknown>,\n\tserial: SerialConfig,\n\tdepth: number,\n): Serialized {\n\t// Check for a known proxy BEFORE Array.isArray: iterating a proxied\n\t// array via its proxy triggers get traps which call serialize again,\n\t// causing infinite recursion. A proxy is always tagged by ID.\n\tconst proxyNode = graph.getByProxy(<Proxiable>v);\n\tif (proxyNode !== undefined) return { $proxy: proxyNode.id };\n\n\tconst targetNode = graph.getByTarget(<Proxiable>v);\n\tif (targetNode !== undefined) return { $unwrap: { $proxy: targetNode.id } };\n\tif (depth >= serial.depth) return '[…]';\n\n\t// Plain (unproxied) arrays are safe to iterate directly.\n\tif (Array.isArray(v)) {\n\t\treturn (<Array<unknown>>v).map((item) =>\n\t\t\tserialize(item, graph, seen, serial, depth + 1),\n\t\t);\n\t}\n\n\t// Plain (unproxied) objects: serialize by value with a circular-reference guard.\n\tif (seen.has(v)) return { $proxy: '?' };\n\n\tseen.add(v);\n\n\tconst entries: Array<[string, Serialized]> = [];\n\n\tfor (const [k, val] of Object.entries(<object>v)) {\n\t\tif (serial.redactors.length > 0) {\n\t\t\tconst decision = redact(serial.redactors, k, val, <object>v);\n\t\t\tif (decision === null) continue;\n\t\t\tif (decision !== false) {\n\t\t\t\tentries.push([k, decision]);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tentries.push([k, serialize(val, graph, seen, serial, depth + 1)]);\n\t}\n\n\tseen.delete(v);\n\n\treturn Object.fromEntries(entries);\n}\n\n/** Converts any value to a JSON-safe Serialized form, tagging graph members by ID. */\nexport function serialize(\n\tv: unknown,\n\tgraph: Graph,\n\tseen = new Set<unknown>(),\n\tserial = defaults,\n\tdepth = 0,\n): Serialized {\n\tif (v === null || v === undefined) return v;\n\tif (isProxiable(v)) return proxiable(v, graph, seen, serial, depth);\n\n\treturn typeof v === 'string'\n\t\t? (<string>v).length > serial.truncate\n\t\t\t? `${(<string>v).slice(0, serial.truncate)}…`\n\t\t\t: <string>v\n\t\t: <Serialized>v;\n}\n\n/** Converts an Origin to its serialized form — coerces symbol keys to strings. */\nexport function origin(o: Origin): SerializedOrigin {\n\tif (!o) return null;\n\tif ('key' in o)\n\t\treturn { trap: o.trap, parent: o.parent, key: String(o.key) };\n\n\treturn o;\n}\n","import type { Proxiable } from './types';\n\ntype AnyFn = (...args: Array<unknown>) => unknown;\n\n// Per-prototype cache: true if any getter on this prototype (or its chain)\n// throws TypeError when called through a blank Proxy — the signature of an\n// internal slot check. Keyed by the direct prototype of the proxied target\n// so all instances of the same type share one probe result.\nconst slotProtos = new WeakMap<object, boolean>();\n\n// Stable bound-method cache: (target, key) → fn.bind(target).\n// Ensures the same proxied bound function is returned every time the same\n// method is accessed on the same target — required for graph proxy stability.\nconst bindCache = new WeakMap<object, Map<PropertyKey, AnyFn>>();\n\n// Slot-check TypeErrors have specific messages; filter by them to avoid\n// misclassifying TypeErrors thrown for other reasons (e.g. wrong arg count).\nconst slotError = /incompatible receiver|this is not|illegal invocation/i;\n\n/**\n * Returns true if `target`'s prototype chain contains a getter that throws\n * TypeError when called through a Proxy — the JS-observable signature of an\n * ECMAScript internal slot check (e.g. Map, Set, WeakMap, WeakSet, Date).\n * Result is cached per prototype so the probe runs at most once per type.\n */\nexport function hasInternalSlots(target: Proxiable): boolean {\n\tif (typeof target !== 'object' || target === null) return false;\n\n\tconst direct = Object.getPrototypeOf(target as object) as object | null;\n\tif (!direct) return false;\n\tconst cached = slotProtos.get(direct);\n\tif (cached !== undefined) return cached;\n\n\tconst probe = new Proxy(target as object, {\n\t\tset: () => true,\n\t\tdefineProperty: () => true,\n\t\tdeleteProperty: () => true,\n\t\tsetPrototypeOf: () => true,\n\t});\n\tlet proto: object | null = direct;\n\n\twhile (proto && proto !== Object.prototype) {\n\t\tfor (const key of Object.getOwnPropertyNames(proto)) {\n\t\t\tif (key === 'constructor') continue;\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(proto, key);\n\t\t\tconst fn =\n\t\t\t\tdesc?.get ??\n\t\t\t\t(typeof desc?.value === 'function'\n\t\t\t\t\t? (desc.value as AnyFn)\n\t\t\t\t\t: null);\n\t\t\tif (fn) {\n\t\t\t\tlet slots = false;\n\t\t\t\ttry {\n\t\t\t\t\tfn.call(probe);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (e instanceof TypeError && slotError.test(String(e)))\n\t\t\t\t\t\tslots = true;\n\t\t\t\t}\n\t\t\t\tslotProtos.set(direct, slots);\n\t\t\t\treturn slots;\n\t\t\t}\n\t\t}\n\t\tproto = Object.getPrototypeOf(proto) as object | null;\n\t}\n\n\tslotProtos.set(direct, false);\n\treturn false;\n}\n\n/** Returns a stable bound version of `fn` for `(target, key)` — created once, reused on every access. */\nexport function boundMethod(\n\ttarget: object,\n\tkey: PropertyKey,\n\tfn: AnyFn,\n): AnyFn {\n\tlet cache = bindCache.get(target);\n\tif (!cache) {\n\t\tcache = new Map();\n\t\tbindCache.set(target, cache);\n\t}\n\tconst existing = cache.get(key);\n\tif (existing) return existing;\n\tconst bound = fn.bind(target);\n\tcache.set(key, bound);\n\treturn bound;\n}\n","import { boundMethod, hasInternalSlots } from './slots';\nimport { isProxiable, type Proxiable } from './types';\n\n/** A function that conditionally wraps a value in a proxy. */\nexport type Wrapper = (v: unknown) => unknown;\n\n// %TypedArray% — the abstract base class shared by all TypedArray constructors.\n// Not exposed as a global; reached via the prototype chain of any TypedArray.\nconst TypedArray = Object.getPrototypeOf(Int8Array);\n\nconst ecmaBuiltins = [\n\tPromise,\n\tMap,\n\tSet,\n\tWeakMap,\n\tWeakSet,\n\tDate,\n\tRegExp,\n\tArrayBuffer,\n\tTypedArray,\n\tDataView,\n];\n\n/**\n * Returns true for standard ECMAScript built-ins whose C++ implementations\n * perform a JavaScript-level type check before touching internal fields —\n * so they throw a catchable TypeError when called through a Proxy rather\n * than crashing the process. Distinguishes them from Node.js C++ bindings\n * (TCP handles, ConnectionsList, HTTPParser, …) that crash fatally.\n *\n * Uses instanceof to cover subclasses — a JS subclass of Map has the same\n * internal-slot behaviour as Map itself and is equally safe to proxy.\n */\nfunction isECMABuiltin(v: unknown): boolean {\n\treturn ecmaBuiltins.some((B) => v instanceof B);\n}\n\n/** Returns true when v is a C++ binding object that would crash Node.js if proxied. */\nfunction isUnsafeBinding(v: unknown): boolean {\n\treturn isProxiable(v) && hasInternalSlots(v) && !isECMABuiltin(v);\n}\n\n// Exported for testing only.\nexport { isECMABuiltin, isUnsafeBinding };\n\n/** Pre/post hooks for a Reflect trap — transform args before dispatch and/or wrap the result. */\nexport type Spec = {\n\tpre?: (\n\t\targs: Array<unknown>,\n\t\twrap: Wrapper,\n\t\tknown: Wrapper,\n\t) => Array<unknown>;\n\tpost?: (result: unknown, args: Array<unknown>, wrap: Wrapper) => unknown;\n};\n\n/**\n * Builds per-trap hooks for a proxy session.\n * When `bind` is true, all method results and getter receivers are\n * bound to the real target — the same strategy used for ECMAScript built-ins\n * with internal slots, extended to user-defined classes with `#` private fields.\n */\nexport function makeSpecs(bind: boolean | undefined): Partial<Record<string, Spec>> {\n\treturn {\n\tget: {\n\t\t// For targets with internal slots (Map, Set, WeakMap, WeakSet, Date …)\n\t\t// or when bind is true, use the real target as the Reflect.get\n\t\t// receiver so that getter-based slot checks and #private field reads\n\t\t// (e.g. `get value() { return this.#count; }`) don't throw TypeError.\n\t\tpre: ([target, key, receiver], _wrap, _known) => [\n\t\t\ttarget,\n\t\t\tkey,\n\t\t\thasInternalSlots(target as Proxiable) || bind ? target : receiver,\n\t\t],\n\t\t// For the same targets, bind method results to the real target before\n\t\t// wrapping so that apply-level slot checks (e.g. Map.prototype.get)\n\t\t// and #private field access inside methods also pass.\n\t\t// The bind cache ensures proxy stability.\n\t\tpost: (result, [target, key], wrap) => {\n\t\t\tif (key === 'prototype') return result;\n\t\t\tif (hasInternalSlots(target as Proxiable) || bind) {\n\t\t\t\tif (typeof result === 'function')\n\t\t\t\t\treturn wrap(\n\t\t\t\t\t\tboundMethod(\n\t\t\t\t\t\t\ttarget as object,\n\t\t\t\t\t\t\tkey as PropertyKey,\n\t\t\t\t\t\t\tresult as (...args: Array<unknown>) => unknown,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t}\n\t\t\t// Don't proxy C++ binding objects — they crash native code when\n\t\t\t// used as Proxies (e.g. ConnectionsList, TCP handles). ECMAScript\n\t\t\t// built-ins (Map, Set, Promise, Date …) are excluded: they have\n\t\t\t// proper JS-level type checks and can be safely proxied.\n\t\t\tif (isUnsafeBinding(result)) return result;\n\t\t\treturn wrap(result);\n\t\t},\n\t},\n\tset: {\n\t\tpre: ([target, key, value, receiver], wrap) => [\n\t\t\ttarget,\n\t\t\tkey,\n\t\t\t// Don't wrap when target has slots (Map/Set internals) or when the\n\t\t\t// value is an unsafe C++ binding (TCP handles, etc.).\n\t\t\thasInternalSlots(target as Proxiable) || isUnsafeBinding(value)\n\t\t\t\t? value\n\t\t\t\t: wrap(value),\n\t\t\treceiver,\n\t\t],\n\t},\n\tapply: {\n\t\t// thisArg is wrapped normally (it's always a graph node).\n\t\t// Call arguments are wrapped with known — only existing graph nodes\n\t\t// get proxied; plain data passes through and is inlined by serialize().\n\t\tpre: ([target, thisArg, callArgs], wrap, known) => [\n\t\t\ttarget,\n\t\t\twrap(thisArg),\n\t\t\t(<Array<unknown>>callArgs).map(known),\n\t\t],\n\t\tpost: (result, _args, wrap) => wrap(result),\n\t},\n\tconstruct: {\n\t\tpre: ([target, callArgs, newTarget], wrap) => [\n\t\t\ttarget,\n\t\t\t(<Array<unknown>>callArgs).map(wrap),\n\t\t\tnewTarget,\n\t\t],\n\t\tpost: (result, _args, wrap) => wrap(result),\n\t},\n\tdefineProperty: {\n\t\tpre: (args, wrap) => {\n\t\t\tconst [target, key, descriptor] = <\n\t\t\t\t[unknown, unknown, PropertyDescriptor]\n\t\t\t>args;\n\t\t\tconst patch: PropertyDescriptor = {};\n\n\t\t\tif (descriptor.value != null && !isUnsafeBinding(descriptor.value))\n\t\t\t\tpatch.value = wrap(descriptor.value);\n\t\t\tif (typeof descriptor.get === 'function')\n\t\t\t\tpatch.get = <() => unknown>wrap(descriptor.get);\n\t\t\tif (typeof descriptor.set === 'function')\n\t\t\t\tpatch.set = <(v: unknown) => void>wrap(descriptor.set);\n\n\t\t\treturn Object.keys(patch).length > 0\n\t\t\t\t? [target, key, { ...descriptor, ...patch }]\n\t\t\t\t: args;\n\t\t},\n\t},\n\tgetOwnPropertyDescriptor: {\n\t\tpost: (result, _args, wrap) => {\n\t\t\tconst desc = <PropertyDescriptor | undefined>result;\n\n\t\t\tif (!desc) return result;\n\n\t\t\tconst patch: PropertyDescriptor = {};\n\n\t\t\tif (desc.value != null && !isUnsafeBinding(desc.value))\n\t\t\t\tpatch.value = wrap(desc.value);\n\t\t\tif (typeof desc.get === 'function')\n\t\t\t\tpatch.get = <() => unknown>wrap(desc.get);\n\t\t\tif (typeof desc.set === 'function')\n\t\t\t\tpatch.set = <(v: unknown) => void>wrap(desc.set);\n\n\t\t\treturn Object.keys(patch).length > 0\n\t\t\t\t? { ...desc, ...patch }\n\t\t\t\t: result;\n\t\t},\n\t},\n\t};\n}\n","export function isError(input: unknown): input is Error {\n\treturn input ? input instanceof Error : false;\n}\n\nexport function createErrorGuard(\n\tname: string,\n\tcontains?: RegExp,\n): (input: unknown) => input is Error {\n\tconst checks: Array<(input: unknown) => boolean> = [\n\t\tisError,\n\t\t(sub: unknown) =>\n\t\t\ttypeof sub === 'object' &&\n\t\t\t(sub as Record<string, unknown>)?.name === name,\n\t];\n\n\tif (contains instanceof RegExp) {\n\t\tchecks.push((v) => contains.test(String(v)));\n\t}\n\n\treturn (input: unknown): input is Error =>\n\t\tchecks.every((predicate) => predicate(input));\n}\n","import { createErrorGuard } from './errors';\nimport type { Graph } from './graph';\nimport type { RetryFlow } from './types';\n\n/** Returns the underlying target if `value` is a proxy known to `graph`, otherwise `value` unchanged. */\nexport function unwrap(graph: Graph | undefined, value: unknown): unknown {\n\treturn graph?.unwrap(value) ?? value;\n}\n\nconst isDataCloneDOMException = createErrorGuard('DataCloneError');\nconst isTypeErrorPrivateMember = createErrorGuard('TypeError', /private member/i);\nconst isTypeErrorIllegalInvocation = createErrorGuard('TypeError', /illegal invocation/i);\n\n/** Retry handlers for native boundary crossings — defined once at module level. */\nexport const retryFlows: Array<RetryFlow> = [\n\t{\n\t\t// Native methods (console.log, DOM APIs, http.Server) check the internal\n\t\t// [[Receiver]] slot and throw \"Illegal invocation\" when called through a\n\t\t// proxy. Unwrap the real target from the graph and retry as the receiver.\n\t\tis: (trap, error) =>\n\t\t\ttrap === 'apply' && isTypeErrorIllegalInvocation(error),\n\t\ttrap: 'apply:native',\n\t\thandle: (graph, fn, thisArg, argList) => {\n\t\t\tconst realThis = unwrap(graph, thisArg);\n\t\t\treturn {\n\t\t\t\targs: [fn, realThis, argList],\n\t\t\t\tresult: Reflect.apply(fn, realThis, argList),\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\t// structuredClone and postMessage can't clone proxy objects — they throw a\n\t\t// DataCloneError. Unwrap any proxy arguments to their real targets and retry.\n\t\tis: (trap, error) => trap === 'apply' && isDataCloneDOMException(error),\n\t\ttrap: 'apply:structure',\n\t\thandle: (graph, fn, thisArg, argList) => {\n\t\t\tconst unwrappedArgs = argList.map((arg) => unwrap(graph, arg));\n\t\t\treturn {\n\t\t\t\targs: [fn, thisArg, unwrappedArgs],\n\t\t\t\tresult: Reflect.apply(fn, thisArg, unwrappedArgs),\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\t// Private fields (#field) use brand checking — accessing #field on a proxy\n\t\t// (rather than the original instance) throws \"Cannot read private member\".\n\t\t// Unwrap the real instance from the graph and use it as the receiver.\n\t\tis: (trap, error, bind) =>\n\t\t\tbind !== false &&\n\t\t\ttrap === 'apply' &&\n\t\t\tisTypeErrorPrivateMember(error),\n\t\ttrap: 'apply:private',\n\t\thandle: (graph, fn, thisArg, argList) => {\n\t\t\tconst realThis = unwrap(graph, thisArg);\n\t\t\treturn {\n\t\t\t\targs: [fn, realThis, argList],\n\t\t\t\tresult: Reflect.apply(fn, realThis, argList),\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\t// A getter that reads a #private field hits the same brand check, but the\n\t\t// apply retry doesn't apply here. Re-invoke Reflect.get with the real target\n\t\t// as its own receiver so the brand check passes.\n\t\tis: (trap, error, bind) =>\n\t\t\tbind !== false && trap === 'get' && isTypeErrorPrivateMember(error),\n\t\thandle: (_graph, target, propertyKey) => ({\n\t\t\tresult: Reflect.get(target, propertyKey, target),\n\t\t}),\n\t},\n];\n","import { Graph } from './graph';\nimport type { Origin, Proxiable } from './types';\n\n/** Returns the original unwrapped target of a proxy, or `null` for non-proxies. */\nexport function getTarget(pxy: Proxiable): Proxiable | null {\n\treturn Graph.for(pxy)?.getByProxy(pxy)?.target ?? null;\n}\n\n/**\n * Looks up a proxy by its recorded ID within the same graph as `pxy`.\n * Use this to resolve `{ $proxy: id }` references in recorded args and results back to live proxies.\n */\nexport function getProxyById(\n\tid: string,\n\tpxy: Proxiable,\n): Proxiable | undefined {\n\treturn Graph.for(pxy)?.getById(id)?.proxy;\n}\n\n/** Returns the `Origin` of a proxy — how and from where it was created. Returns `null` for root proxies and non-proxies. */\nexport function getOrigin(pxy: Proxiable): Origin {\n\treturn Graph.for(pxy)?.getByProxy(pxy)?.origin ?? null;\n}\n\n/**\n * Walks the origin chain from the root proxy down to `pxy`.\n * Returns an ordered array of `{ proxy, origin }` pairs, root first.\n * Returns an empty array for non-proxies.\n */\nexport function getAncestors(\n\tpxy: Proxiable,\n): Array<{ proxy: Proxiable; origin: Origin }> {\n\tconst graph = Graph.for(pxy);\n\n\tif (!graph) return [];\n\n\tconst result: Array<{ proxy: Proxiable; origin: Origin }> = [];\n\tlet node = graph.getByProxy(pxy);\n\n\twhile (node) {\n\t\tresult.unshift({ proxy: node.proxy, origin: node.origin });\n\t\tif (!node.origin) break;\n\n\t\tconst parentId =\n\t\t\t'parent' in node.origin ? node.origin.parent : node.origin.source;\n\n\t\tnode = graph.getById(parentId);\n\t}\n\n\treturn result;\n}\n\n/**\n * Returns a human-readable dotted path string for a proxy.\n * Function and constructor calls are annotated with `()`.\n * Returns an empty string for the root proxy and for non-proxies.\n */\nexport function getPath(pxy: Proxiable): string {\n\tconst ancestors = getAncestors(pxy);\n\tconst parts: Array<string> = [];\n\n\tfor (const { origin: o } of ancestors) {\n\t\tif (!o) continue;\n\t\tif ('key' in o) {\n\t\t\tparts.push(String(o.key));\n\t\t} else {\n\t\t\tif (parts.length > 0) {\n\t\t\t\tparts[parts.length - 1] += '()';\n\t\t\t} else {\n\t\t\t\tparts.push('()');\n\t\t\t}\n\t\t}\n\t}\n\n\treturn parts.join('.');\n}\n","import { getPath, getProxyById } from './inspection';\nimport type { Proxiable, Rekording, Serialized } from './types';\n\nfunction resolve(id: string, proxy?: Proxiable): string {\n\tif (!proxy) return id;\n\tconst p = getProxyById(id, proxy);\n\treturn p !== undefined ? getPath(p) : id;\n}\n\nfunction display(v: Serialized, proxy?: Proxiable, limit = 80): string {\n\tif (v === null || v === undefined) return String(v);\n\tif (typeof v !== 'object') return String(v);\n\tif (!Array.isArray(v) && '$proxy' in v)\n\t\treturn resolve(<string>v.$proxy, proxy);\n\tif (!Array.isArray(v) && '$unwrap' in v)\n\t\treturn `↓${resolve((<{ $unwrap: { $proxy: string } }>v).$unwrap.$proxy, proxy)}`;\n\tconst raw = Array.isArray(v)\n\t\t? `[${v.map((i) => display(i, proxy)).join(', ')}]`\n\t\t: JSON.stringify(v);\n\treturn raw.length > limit ? `${raw.slice(0, limit)}…` : raw;\n}\n\n/** Converts a `Rekording` to a human-readable string.\n * When `proxy` is supplied, `{ $proxy: id }` tags in args and results resolve to dotted paths.\n * When omitted, raw IDs are shown instead. */\nexport function format(rekording: Rekording, proxy?: Proxiable): string {\n\tconst { id, trap, origin, args, result } = rekording;\n\n\tif (origin && 'parent' in origin) {\n\t\tconst parent = resolve(origin.parent, proxy);\n\t\tconst path = parent ? `${parent}.${origin.key}` : String(origin.key);\n\t\tif (trap === 'set') return `${path} = ${display(args[2], proxy)}`;\n\t\tif (trap === 'get') return `${path} → ${display(result, proxy)}`;\n\t\treturn `${trap} ${path}`;\n\t}\n\n\tif (origin && 'source' in origin) {\n\t\tconst path = resolve(origin.source, proxy);\n\t\tconst callArgs = (\n\t\t\tArray.isArray(trap === 'construct' ? args[1] : args[2])\n\t\t\t\t? <Array<Serialized>>(trap === 'construct' ? args[1] : args[2])\n\t\t\t\t: []\n\t\t)\n\t\t\t.map((a) => display(a, proxy))\n\t\t\t.join(', ');\n\t\tif (/^apply(:|$)/.test(trap))\n\t\t\treturn `${path}(${callArgs})`;\n\t\tif (trap === 'construct' || trap === 'construct:native')\n\t\t\treturn `new ${path}(${callArgs})`;\n\t}\n\n\treturn `${trap} on ${id}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAA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AAG,QAAO,IAAI;AACnB,QAAM,SAAuB;AAAA,IAC5B,OAAO,QAAQ,SAAS;AAAA,IACxB,WAAWA,UAAU,MAAM,QAAQA,OAAM,IAAIA,UAAS,CAACA,OAAM,IAAK,CAAC;AAAA,IACnE,UAAU,QAAQ,YAAY;AAAA,EAC/B;AACA,QAAM,QAAQ,IAAI,MAAM,QAAQ,MAAM,CAAC;AACvC,QAAM,QAAQ,UAAU,QAAQ,IAAI;AAEpC,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,EAAE,OAAO,WAAW,MAAM,QAAQ,QAAQ,OAAO,MAAM,QAAQ,KAAK;AAAA,IACpE;AAAA,EACD;AACD;AAGO,SAAS,eAAe,OAAoC;AAClE,SAAO,YAAY,KAAK,KAAK,MAAM,QAAmB,KAAK;AAC5D;","names":["origin","origin","origin","existing","output","redact"]}
1
+ {"version":3,"sources":["../source/types.ts","../source/graph.ts","../source/serialize.ts","../source/slots.ts","../source/specs.ts","../source/errors.ts","../source/retry.ts","../source/inspection.ts","../source/format.ts","../source/flugrekorder.ts"],"sourcesContent":["import type { Graph } from './graph.ts';\nexport type Proxiable = object;\n\n/** Reflect traps that operate on a property — carry a parent ID and key in their origin. */\nexport type PropertyTrap =\n\t| 'get'\n\t| 'set'\n\t| 'defineProperty'\n\t| 'getOwnPropertyDescriptor';\n\n/** Reflect traps that invoke a callable — carry a source ID in their origin. Includes synthetic variants for native boundary crossings. */\nexport type CallTrap =\n\t| 'apply'\n\t| 'construct'\n\t| 'apply:native'\n\t| 'construct:native'\n\t| 'apply:structure'\n\t| 'apply:private';\n\n/** Describes how a proxy was created — which trap fired, on which parent, and under which key or source. Null for root proxies. */\nexport type Origin =\n\t| { trap: PropertyTrap; parent: string; key: string | symbol }\n\t| { trap: CallTrap; source: string }\n\t| null;\n\n/** Origin with symbol keys coerced to strings — safe to include in a Rekording. */\nexport type SerializedOrigin =\n\t| { trap: PropertyTrap; parent: string; key: string }\n\t| { trap: CallTrap; source: string }\n\t| null;\n\n/** A JSON-safe representation of any value. Proxiable values are replaced with `{ $proxy: id }` tags. Raw targets (proxiable values known to the graph but passed unwrapped) are tagged `{ $unwrap: { $proxy: id } }`. */\nexport type Serialized =\n\t| string\n\t| number\n\t| boolean\n\t| bigint\n\t| null\n\t| undefined\n\t| { readonly $proxy: string }\n\t| { readonly $unwrap: { readonly $proxy: string } }\n\t| Array<Serialized>\n\t| { [key: string]: Serialized };\n\n/** Returns true for any value that can meaningfully be wrapped in a Proxy. */\nexport function isProxiable(value: unknown): value is Proxiable {\n\treturn (\n\t\tvalue !== null &&\n\t\t(typeof value === 'object' || typeof value === 'function')\n\t);\n}\n\n/**\n * Determines whether and how a key/value pair should be redacted during serialization.\n * Return `false` to keep as-is, `true` to replace with `\"[redacted]\"`,\n * a string to use as a custom replacement, or `null` to drop the key entirely.\n */\nexport type Redactor = (\n\tkey: string | symbol,\n\tvalue: unknown,\n\ttarget: object,\n) => string | boolean | null;\n\n/** A single recorded interaction — one Reflect trap firing on one proxy. */\nexport type Rekording = {\n\tid: string;\n\ttrap: string;\n\torigin: SerializedOrigin;\n\targs: Array<Serialized>;\n\tresult: Serialized;\n\ttimestamp: number;\n};\n\ntype Fn = (...args: Array<unknown>) => unknown;\n\n/** Describes a retry handler for an apply trap boundary crossing. */\ntype ApplyRetryFlow = {\n\tis: (trap: string, error: unknown, bind?: boolean) => boolean;\n\ttrap?: string;\n\thandle: (\n\t\tgraph: Graph | undefined,\n\t\tfn: Fn,\n\t\tthisArg: unknown,\n\t\targList: Array<unknown>,\n\t) => { args: [Fn, unknown, Array<unknown>]; result: unknown };\n};\n\n/** Describes a retry handler for a get trap boundary crossing. */\ntype GetRetryFlow = {\n\tis: (trap: string, error: unknown, bind?: boolean) => boolean;\n\ttrap?: never;\n\thandle: (\n\t\tgraph: Graph | undefined,\n\t\ttarget: object,\n\t\tpropertyKey: PropertyKey,\n\t\treceiver: unknown,\n\t) => { result: unknown };\n};\n\n/** Describes a native boundary crossing retry handler. */\nexport type RetryFlow = ApplyRetryFlow | GetRetryFlow;\n","import { isProxiable } from './types.ts';\nimport type { Origin, Proxiable } from './types.ts';\n\n/** A node in the proxy graph — links a proxy to its original target, its origin, and its ID. */\nexport type GraphNode = {\n\treadonly id: string;\n\treadonly proxy: Proxiable;\n\treadonly target: Proxiable;\n\treadonly origin: Origin;\n};\n\n/**\n * Session-scoped proxy registry.\n * Each `create()` call produces its own Graph so proxied trees are\n * independent and GC-eligible once no longer referenced.\n */\nexport class Graph {\n\tstatic #index = new WeakMap<Proxiable, Graph>();\n\tstatic #all = new WeakSet<Proxiable>();\n\n\t/** Returns the Graph that owns `pxy`, or `undefined` for non-proxies. */\n\tstatic for(pxy: Proxiable): Graph | undefined {\n\t\treturn Graph.#index.get(pxy);\n\t}\n\n\t/** Returns `true` if `pxy` is a proxy created by this module. */\n\tstatic isProxy(pxy: Proxiable): boolean {\n\t\treturn Graph.#all.has(pxy);\n\t}\n\n\t/** Marks `pxy` as a known proxy across all graphs (double-wrap guard). */\n\tstatic track(pxy: Proxiable): void {\n\t\tGraph.#all.add(pxy);\n\t}\n\n\t#byId = new Map<string, GraphNode>();\n\t#byProxy = new WeakMap<Proxiable, GraphNode>();\n\t#byTarget = new WeakMap<Proxiable, GraphNode>();\n\t#generator: () => string;\n\n\tconstructor(id: number | (() => string)) {\n\t\tlet counter = typeof id === 'number' ? id : 0;\n\n\t\tthis.#generator = typeof id === 'function' ? id : () => `#${++counter}`;\n\t}\n\n\tnextId(): string {\n\t\treturn this.#generator();\n\t}\n\n\t/** Returns the underlying target if `value` is a proxy known to this graph, otherwise `value` unchanged. */\n\tunwrap(value: unknown): unknown {\n\t\tif (!isProxiable(value)) return value;\n\t\treturn this.#byProxy.get(value)?.target ?? value;\n\t}\n\n\tgetByProxy(v: Proxiable): GraphNode | undefined {\n\t\treturn this.#byProxy.get(v);\n\t}\n\tgetByTarget(v: Proxiable): GraphNode | undefined {\n\t\treturn this.#byTarget.get(v);\n\t}\n\tgetById(id: string): GraphNode | undefined {\n\t\treturn this.#byId.get(id);\n\t}\n\n\tregister(\n\t\tproxy: Proxiable,\n\t\ttarget: Proxiable,\n\t\torigin: Origin,\n\t\tid: string,\n\t): GraphNode {\n\t\tconst node: GraphNode = { id, proxy, target, origin };\n\n\t\tthis.#byId.set(id, node);\n\t\tthis.#byProxy.set(proxy, node);\n\t\tthis.#byTarget.set(target, node);\n\t\tGraph.#index.set(proxy, this);\n\n\t\treturn node;\n\t}\n}\n","import type { Graph } from './graph.ts';\nimport {\n\tisProxiable,\n\ttype Origin,\n\ttype Proxiable,\n\ttype Redactor,\n\ttype Serialized,\n\ttype SerializedOrigin,\n} from './types.ts';\n\nexport type SerialConfig = {\n\tdepth: number;\n\tredactors: Array<Redactor>;\n\ttruncate: number;\n};\n\nexport const defaults: SerialConfig = {\n\tdepth: Infinity,\n\tredactors: [],\n\ttruncate: Infinity,\n};\n\n/** Find and apply any redaction for the given key/value/target context */\nfunction redact(\n\tredactors: Array<Redactor>,\n\tkey: string | symbol,\n\tvalue: unknown,\n\ttarget: object,\n): string | null | false {\n\tfor (const redactor of redactors) {\n\t\tconst result = redactor(key, value, target);\n\t\tif (result === false) continue;\n\n\t\treturn result === true ? '[redacted]' : result;\n\t}\n\n\treturn false;\n}\n\n/** Serializes an object or function value — tags known proxies by ID, inlines arrays and plain objects. */\nfunction proxiable(\n\tv: unknown,\n\tgraph: Graph,\n\tseen: Set<unknown>,\n\tserial: SerialConfig,\n\tdepth: number,\n): Serialized {\n\t// Check for a known proxy BEFORE Array.isArray: iterating a proxied\n\t// array via its proxy triggers get traps which call serialize again,\n\t// causing infinite recursion. A proxy is always tagged by ID.\n\tconst proxyNode = graph.getByProxy(v as Proxiable);\n\tif (proxyNode !== undefined) return { $proxy: proxyNode.id };\n\n\tconst targetNode = graph.getByTarget(v as Proxiable);\n\tif (targetNode !== undefined) return { $unwrap: { $proxy: targetNode.id } };\n\tif (depth >= serial.depth) return '[…]';\n\n\t// Plain (unproxied) arrays are safe to iterate directly.\n\tif (Array.isArray(v)) {\n\t\treturn (v as Array<unknown>).map((item) =>\n\t\t\tserialize(item, graph, seen, serial, depth + 1),\n\t\t);\n\t}\n\n\t// Plain (unproxied) objects: serialize by value with a circular-reference guard.\n\tif (seen.has(v)) return { $proxy: '?' };\n\n\tseen.add(v);\n\n\tconst entries: Array<[string, Serialized]> = [];\n\n\tfor (const [k, val] of Object.entries(v as object)) {\n\t\tif (serial.redactors.length > 0) {\n\t\t\tconst decision = redact(serial.redactors, k, val, v as object);\n\t\t\tif (decision === null) continue;\n\t\t\tif (decision !== false) {\n\t\t\t\tentries.push([k, decision]);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tentries.push([k, serialize(val, graph, seen, serial, depth + 1)]);\n\t}\n\n\tseen.delete(v);\n\n\treturn Object.fromEntries(entries);\n}\n\n/** Converts any value to a JSON-safe Serialized form, tagging graph members by ID. */\nexport function serialize(\n\tv: unknown,\n\tgraph: Graph,\n\tseen = new Set<unknown>(),\n\tserial = defaults,\n\tdepth = 0,\n): Serialized {\n\tif (v === null || v === undefined) return v;\n\tif (isProxiable(v)) return proxiable(v, graph, seen, serial, depth);\n\n\treturn typeof v === 'string'\n\t\t? (v as string).length > serial.truncate\n\t\t\t? `${(v as string).slice(0, serial.truncate)}…`\n\t\t\t: (v as string)\n\t\t: (v as Serialized);\n}\n\n/** Converts an Origin to its serialized form — coerces symbol keys to strings. */\nexport function origin(o: Origin): SerializedOrigin {\n\tif (!o) return null;\n\tif ('key' in o)\n\t\treturn { trap: o.trap, parent: o.parent, key: String(o.key) };\n\n\treturn o;\n}\n","import type { Proxiable } from './types.ts';\n\ntype AnyFn = (...args: Array<unknown>) => unknown;\n\n// Per-prototype cache: true if any getter on this prototype (or its chain)\n// throws TypeError when called through a blank Proxy — the signature of an\n// internal slot check. Keyed by the direct prototype of the proxied target\n// so all instances of the same type share one probe result.\nconst slotProtos = new WeakMap<object, boolean>();\n\n// Stable bound-method cache: (target, key) → fn.bind(target).\n// Ensures the same proxied bound function is returned every time the same\n// method is accessed on the same target — required for graph proxy stability.\nconst bindCache = new WeakMap<object, Map<PropertyKey, AnyFn>>();\n\n// Slot-check TypeErrors have specific messages; filter by them to avoid\n// misclassifying TypeErrors thrown for other reasons (e.g. wrong arg count).\nconst slotError = /incompatible receiver|this is not|illegal invocation/i;\n\n/**\n * Returns true if `target`'s prototype chain contains a getter that throws\n * TypeError when called through a Proxy — the JS-observable signature of an\n * ECMAScript internal slot check (e.g. Map, Set, WeakMap, WeakSet, Date).\n * Result is cached per prototype so the probe runs at most once per type.\n */\nexport function hasInternalSlots(target: Proxiable): boolean {\n\tif (typeof target !== 'object' || target === null) return false;\n\n\tconst direct = Object.getPrototypeOf(target as object) as object | null;\n\tif (!direct) return false;\n\tconst cached = slotProtos.get(direct);\n\tif (cached !== undefined) return cached;\n\n\tconst probe = new Proxy(target as object, {\n\t\tset: () => true,\n\t\tdefineProperty: () => true,\n\t\tdeleteProperty: () => true,\n\t\tsetPrototypeOf: () => true,\n\t});\n\tlet proto: object | null = direct;\n\n\twhile (proto && proto !== Object.prototype) {\n\t\tfor (const key of Object.getOwnPropertyNames(proto)) {\n\t\t\tif (key === 'constructor') continue;\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(proto, key);\n\t\t\tconst fn =\n\t\t\t\tdesc?.get ??\n\t\t\t\t(typeof desc?.value === 'function'\n\t\t\t\t\t? (desc.value as AnyFn)\n\t\t\t\t\t: null);\n\t\t\tif (fn) {\n\t\t\t\tlet slots = false;\n\t\t\t\ttry {\n\t\t\t\t\tfn.call(probe);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (e instanceof TypeError && slotError.test(String(e)))\n\t\t\t\t\t\tslots = true;\n\t\t\t\t}\n\t\t\t\tslotProtos.set(direct, slots);\n\t\t\t\treturn slots;\n\t\t\t}\n\t\t}\n\t\tproto = Object.getPrototypeOf(proto) as object | null;\n\t}\n\n\tslotProtos.set(direct, false);\n\treturn false;\n}\n\n/** Returns a stable bound version of `fn` for `(target, key)` — created once, reused on every access. */\nexport function boundMethod(\n\ttarget: object,\n\tkey: PropertyKey,\n\tfn: AnyFn,\n): AnyFn {\n\tlet cache = bindCache.get(target);\n\tif (!cache) {\n\t\tcache = new Map();\n\t\tbindCache.set(target, cache);\n\t}\n\tconst existing = cache.get(key);\n\tif (existing) return existing;\n\tconst bound = fn.bind(target);\n\tcache.set(key, bound);\n\treturn bound;\n}\n","import { boundMethod, hasInternalSlots } from './slots.ts';\nimport { isProxiable, type Proxiable } from './types.ts';\n\n/** A function that conditionally wraps a value in a proxy. */\nexport type Wrapper = (v: unknown) => unknown;\n\n// %TypedArray% — the abstract base class shared by all TypedArray constructors.\n// Not exposed as a global; reached via the prototype chain of any TypedArray.\nconst TypedArray = Object.getPrototypeOf(Int8Array);\n\nconst ecmaBuiltins = [\n\tPromise,\n\tMap,\n\tSet,\n\tWeakMap,\n\tWeakSet,\n\tDate,\n\tRegExp,\n\tArrayBuffer,\n\tTypedArray,\n\tDataView,\n];\n\n/**\n * Returns true for standard ECMAScript built-ins whose C++ implementations\n * perform a JavaScript-level type check before touching internal fields —\n * so they throw a catchable TypeError when called through a Proxy rather\n * than crashing the process. Distinguishes them from Node.js C++ bindings\n * (TCP handles, ConnectionsList, HTTPParser, …) that crash fatally.\n *\n * Uses instanceof to cover subclasses — a JS subclass of Map has the same\n * internal-slot behaviour as Map itself and is equally safe to proxy.\n */\nfunction isECMABuiltin(v: unknown): boolean {\n\treturn ecmaBuiltins.some((B) => v instanceof B);\n}\n\n/** Returns true when v is a C++ binding object that would crash Node.js if proxied. */\nfunction isUnsafeBinding(v: unknown): boolean {\n\treturn isProxiable(v) && hasInternalSlots(v) && !isECMABuiltin(v);\n}\n\n// Exported for testing only.\nexport { isECMABuiltin, isUnsafeBinding };\n\n/** Pre/post hooks for a Reflect trap — transform args before dispatch and/or wrap the result. */\nexport type Spec = {\n\tpre?: (\n\t\targs: Array<unknown>,\n\t\twrap: Wrapper,\n\t\tknown: Wrapper,\n\t) => Array<unknown>;\n\tpost?: (result: unknown, args: Array<unknown>, wrap: Wrapper) => unknown;\n};\n\n/**\n * Builds per-trap hooks for a proxy session.\n * When `bind` is true, all method results and getter receivers are\n * bound to the real target — the same strategy used for ECMAScript built-ins\n * with internal slots, extended to user-defined classes with `#` private fields.\n */\nexport function makeSpecs(\n\tbind: boolean | undefined,\n): Partial<Record<string, Spec>> {\n\treturn {\n\t\tget: {\n\t\t\t// For targets with internal slots (Map, Set, WeakMap, WeakSet, Date …)\n\t\t\t// or when bind is true, use the real target as the Reflect.get\n\t\t\t// receiver so that getter-based slot checks and #private field reads\n\t\t\t// (e.g. `get value() { return this.#count; }`) don't throw TypeError.\n\t\t\tpre: ([target, key, receiver], _wrap, _known) => [\n\t\t\t\ttarget,\n\t\t\t\tkey,\n\t\t\t\thasInternalSlots(target as Proxiable) || bind\n\t\t\t\t\t? target\n\t\t\t\t\t: receiver,\n\t\t\t],\n\t\t\t// For the same targets, bind method results to the real target before\n\t\t\t// wrapping so that apply-level slot checks (e.g. Map.prototype.get)\n\t\t\t// and #private field access inside methods also pass.\n\t\t\t// The bind cache ensures proxy stability.\n\t\t\tpost: (result, [target, key], wrap) => {\n\t\t\t\tif (key === 'prototype') return result;\n\t\t\t\tif (hasInternalSlots(target as Proxiable) || bind) {\n\t\t\t\t\tif (typeof result === 'function')\n\t\t\t\t\t\treturn wrap(\n\t\t\t\t\t\t\tboundMethod(\n\t\t\t\t\t\t\t\ttarget as object,\n\t\t\t\t\t\t\t\tkey as PropertyKey,\n\t\t\t\t\t\t\t\tresult as (...args: Array<unknown>) => unknown,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Don't proxy C++ binding objects — they crash native code when\n\t\t\t\t// used as Proxies (e.g. ConnectionsList, TCP handles). ECMAScript\n\t\t\t\t// built-ins (Map, Set, Promise, Date …) are excluded: they have\n\t\t\t\t// proper JS-level type checks and can be safely proxied.\n\t\t\t\tif (isUnsafeBinding(result)) return result;\n\t\t\t\treturn wrap(result);\n\t\t\t},\n\t\t},\n\t\tset: {\n\t\t\tpre: ([target, key, value, receiver], wrap) => [\n\t\t\t\ttarget,\n\t\t\t\tkey,\n\t\t\t\t// Don't wrap when target has slots (Map/Set internals) or when the\n\t\t\t\t// value is an unsafe C++ binding (TCP handles, etc.).\n\t\t\t\thasInternalSlots(target as Proxiable) || isUnsafeBinding(value)\n\t\t\t\t\t? value\n\t\t\t\t\t: wrap(value),\n\t\t\t\treceiver,\n\t\t\t],\n\t\t},\n\t\tapply: {\n\t\t\t// thisArg is wrapped normally (it's always a graph node).\n\t\t\t// Call arguments are wrapped with known — only existing graph nodes\n\t\t\t// get proxied; plain data passes through and is inlined by serialize().\n\t\t\tpre: ([target, thisArg, callArgs], wrap, known) => [\n\t\t\t\ttarget,\n\t\t\t\twrap(thisArg),\n\t\t\t\t(callArgs as Array<unknown>).map(known),\n\t\t\t],\n\t\t\tpost: (result, _args, wrap) => wrap(result),\n\t\t},\n\t\tconstruct: {\n\t\t\tpre: ([target, callArgs, newTarget], wrap) => [\n\t\t\t\ttarget,\n\t\t\t\t(callArgs as Array<unknown>).map(wrap),\n\t\t\t\tnewTarget,\n\t\t\t],\n\t\t\tpost: (result, _args, wrap) => wrap(result),\n\t\t},\n\t\tdefineProperty: {\n\t\t\tpre: (args, wrap) => {\n\t\t\t\tconst [target, key, descriptor] = args as [\n\t\t\t\t\tunknown,\n\t\t\t\t\tunknown,\n\t\t\t\t\tPropertyDescriptor,\n\t\t\t\t];\n\t\t\t\tconst patch: PropertyDescriptor = {};\n\n\t\t\t\tif (\n\t\t\t\t\tdescriptor.value != null &&\n\t\t\t\t\t!isUnsafeBinding(descriptor.value)\n\t\t\t\t)\n\t\t\t\t\tpatch.value = wrap(descriptor.value);\n\t\t\t\tif (typeof descriptor.get === 'function')\n\t\t\t\t\tpatch.get = wrap(descriptor.get) as () => unknown;\n\t\t\t\tif (typeof descriptor.set === 'function')\n\t\t\t\t\tpatch.set = wrap(descriptor.set) as (v: unknown) => void;\n\n\t\t\t\treturn Object.keys(patch).length > 0\n\t\t\t\t\t? [target, key, { ...descriptor, ...patch }]\n\t\t\t\t\t: args;\n\t\t\t},\n\t\t},\n\t\tgetOwnPropertyDescriptor: {\n\t\t\tpost: (result, _args, wrap) => {\n\t\t\t\tconst desc = result as PropertyDescriptor | undefined;\n\n\t\t\t\tif (!desc) return result;\n\n\t\t\t\tconst patch: PropertyDescriptor = {};\n\n\t\t\t\tif (desc.value != null && !isUnsafeBinding(desc.value))\n\t\t\t\t\tpatch.value = wrap(desc.value);\n\t\t\t\tif (typeof desc.get === 'function')\n\t\t\t\t\tpatch.get = wrap(desc.get) as () => unknown;\n\t\t\t\tif (typeof desc.set === 'function')\n\t\t\t\t\tpatch.set = wrap(desc.set) as (v: unknown) => void;\n\n\t\t\t\treturn Object.keys(patch).length > 0\n\t\t\t\t\t? { ...desc, ...patch }\n\t\t\t\t\t: result;\n\t\t\t},\n\t\t},\n\t};\n}\n","export function isError(input: unknown): input is Error {\n\treturn input ? input instanceof Error : false;\n}\n\nexport function createErrorGuard(\n\tname: string,\n\tcontains?: RegExp,\n): (input: unknown) => input is Error {\n\tconst checks: Array<(input: unknown) => boolean> = [\n\t\tisError,\n\t\t(sub: unknown) =>\n\t\t\ttypeof sub === 'object' &&\n\t\t\t(sub as Record<string, unknown>)?.name === name,\n\t];\n\n\tif (contains instanceof RegExp) {\n\t\tchecks.push((v) => contains.test(String(v)));\n\t}\n\n\treturn (input: unknown): input is Error =>\n\t\tchecks.every((predicate) => predicate(input));\n}\n","import { createErrorGuard } from './errors.ts';\nimport type { Graph } from './graph.ts';\nimport type { RetryFlow } from './types.ts';\n\n/** Returns the underlying target if `value` is a proxy known to `graph`, otherwise `value` unchanged. */\nexport function unwrap(graph: Graph | undefined, value: unknown): unknown {\n\treturn graph?.unwrap(value) ?? value;\n}\n\nconst isDataCloneDOMException = createErrorGuard('DataCloneError');\nconst isTypeErrorPrivateMember = createErrorGuard('TypeError', /private member/i);\nconst isTypeErrorIllegalInvocation = createErrorGuard('TypeError', /illegal invocation/i);\n\n/** Retry handlers for native boundary crossings — defined once at module level. */\nexport const retryFlows: Array<RetryFlow> = [\n\t{\n\t\t// Native methods (console.log, DOM APIs, http.Server) check the internal\n\t\t// [[Receiver]] slot and throw \"Illegal invocation\" when called through a\n\t\t// proxy. Unwrap the real target from the graph and retry as the receiver.\n\t\tis: (trap, error) =>\n\t\t\ttrap === 'apply' && isTypeErrorIllegalInvocation(error),\n\t\ttrap: 'apply:native',\n\t\thandle: (graph, fn, thisArg, argList) => {\n\t\t\tconst realThis = unwrap(graph, thisArg);\n\t\t\treturn {\n\t\t\t\targs: [fn, realThis, argList],\n\t\t\t\tresult: Reflect.apply(fn, realThis, argList),\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\t// structuredClone and postMessage can't clone proxy objects — they throw a\n\t\t// DataCloneError. Unwrap any proxy arguments to their real targets and retry.\n\t\tis: (trap, error) => trap === 'apply' && isDataCloneDOMException(error),\n\t\ttrap: 'apply:structure',\n\t\thandle: (graph, fn, thisArg, argList) => {\n\t\t\tconst unwrappedArgs = argList.map((arg) => unwrap(graph, arg));\n\t\t\treturn {\n\t\t\t\targs: [fn, thisArg, unwrappedArgs],\n\t\t\t\tresult: Reflect.apply(fn, thisArg, unwrappedArgs),\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\t// Private fields (#field) use brand checking — accessing #field on a proxy\n\t\t// (rather than the original instance) throws \"Cannot read private member\".\n\t\t// Unwrap the real instance from the graph and use it as the receiver.\n\t\tis: (trap, error, bind) =>\n\t\t\tbind !== false &&\n\t\t\ttrap === 'apply' &&\n\t\t\tisTypeErrorPrivateMember(error),\n\t\ttrap: 'apply:private',\n\t\thandle: (graph, fn, thisArg, argList) => {\n\t\t\tconst realThis = unwrap(graph, thisArg);\n\t\t\treturn {\n\t\t\t\targs: [fn, realThis, argList],\n\t\t\t\tresult: Reflect.apply(fn, realThis, argList),\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\t// A getter that reads a #private field hits the same brand check, but the\n\t\t// apply retry doesn't apply here. Re-invoke Reflect.get with the real target\n\t\t// as its own receiver so the brand check passes.\n\t\tis: (trap, error, bind) =>\n\t\t\tbind !== false && trap === 'get' && isTypeErrorPrivateMember(error),\n\t\thandle: (_graph, target, propertyKey) => ({\n\t\t\tresult: Reflect.get(target, propertyKey, target),\n\t\t}),\n\t},\n];\n","import { Graph } from './graph.ts';\nimport type { Origin, Proxiable } from './types.ts';\n\n/** Returns the original unwrapped target of a proxy, or `null` for non-proxies. */\nexport function getTarget(pxy: Proxiable): Proxiable | null {\n\treturn Graph.for(pxy)?.getByProxy(pxy)?.target ?? null;\n}\n\n/**\n * Looks up a proxy by its recorded ID within the same graph as `pxy`.\n * Use this to resolve `{ $proxy: id }` references in recorded args and results back to live proxies.\n */\nexport function getProxyById(\n\tid: string,\n\tpxy: Proxiable,\n): Proxiable | undefined {\n\treturn Graph.for(pxy)?.getById(id)?.proxy;\n}\n\n/** Returns the `Origin` of a proxy — how and from where it was created. Returns `null` for root proxies and non-proxies. */\nexport function getOrigin(pxy: Proxiable): Origin {\n\treturn Graph.for(pxy)?.getByProxy(pxy)?.origin ?? null;\n}\n\n/**\n * Walks the origin chain from the root proxy down to `pxy`.\n * Returns an ordered array of `{ proxy, origin }` pairs, root first.\n * Returns an empty array for non-proxies.\n */\nexport function getAncestors(\n\tpxy: Proxiable,\n): Array<{ proxy: Proxiable; origin: Origin }> {\n\tconst graph = Graph.for(pxy);\n\n\tif (!graph) return [];\n\n\tconst result: Array<{ proxy: Proxiable; origin: Origin }> = [];\n\tlet node = graph.getByProxy(pxy);\n\n\twhile (node) {\n\t\tresult.unshift({ proxy: node.proxy, origin: node.origin });\n\t\tif (!node.origin) break;\n\n\t\tconst parentId =\n\t\t\t'parent' in node.origin ? node.origin.parent : node.origin.source;\n\n\t\tnode = graph.getById(parentId);\n\t}\n\n\treturn result;\n}\n\n/**\n * Returns a human-readable dotted path string for a proxy.\n * Function and constructor calls are annotated with `()`.\n * Returns an empty string for the root proxy and for non-proxies.\n */\nexport function getPath(pxy: Proxiable): string {\n\tconst ancestors = getAncestors(pxy);\n\tconst parts: Array<string> = [];\n\n\tfor (const { origin: o } of ancestors) {\n\t\tif (!o) continue;\n\t\tif ('key' in o) {\n\t\t\tparts.push(String(o.key));\n\t\t} else {\n\t\t\tif (parts.length > 0) {\n\t\t\t\tparts[parts.length - 1] += '()';\n\t\t\t} else {\n\t\t\t\tparts.push('()');\n\t\t\t}\n\t\t}\n\t}\n\n\treturn parts.join('.');\n}\n","import { getPath, getProxyById } from './inspection.ts';\nimport type { Proxiable, Rekording, Serialized } from './types.ts';\n\nfunction resolve(id: string, proxy?: Proxiable): string {\n\tif (!proxy) return id;\n\tconst p = getProxyById(id, proxy);\n\treturn p !== undefined ? getPath(p) : id;\n}\n\nfunction display(v: Serialized, proxy?: Proxiable, limit = 80): string {\n\tif (v === null || v === undefined) return String(v);\n\tif (typeof v !== 'object') return String(v);\n\tif (!Array.isArray(v) && '$proxy' in v)\n\t\treturn resolve(v.$proxy as string, proxy);\n\tif (!Array.isArray(v) && '$unwrap' in v)\n\t\treturn `↓${resolve((v as { $unwrap: { $proxy: string } }).$unwrap.$proxy, proxy)}`;\n\tconst raw = Array.isArray(v)\n\t\t? `[${v.map((i) => display(i, proxy)).join(', ')}]`\n\t\t: JSON.stringify(v);\n\treturn raw.length > limit ? `${raw.slice(0, limit)}…` : raw;\n}\n\n/** Converts a `Rekording` to a human-readable string.\n * When `proxy` is supplied, `{ $proxy: id }` tags in args and results resolve to dotted paths.\n * When omitted, raw IDs are shown instead. */\nexport function format(rekording: Rekording, proxy?: Proxiable): string {\n\tconst { id, trap, origin, args, result } = rekording;\n\n\tif (origin && 'parent' in origin) {\n\t\tconst parent = resolve(origin.parent, proxy);\n\t\tconst path = parent ? `${parent}.${origin.key}` : String(origin.key);\n\t\tif (trap === 'set') return `${path} = ${display(args[2], proxy)}`;\n\t\tif (trap === 'get') return `${path} → ${display(result, proxy)}`;\n\t\treturn `${trap} ${path}`;\n\t}\n\n\tif (origin && 'source' in origin) {\n\t\tconst path = resolve(origin.source, proxy);\n\t\tconst callArgs = (\n\t\t\tArray.isArray(trap === 'construct' ? args[1] : args[2])\n\t\t\t\t? ((trap === 'construct'\n\t\t\t\t\t\t? args[1]\n\t\t\t\t\t\t: args[2]) as Array<Serialized>)\n\t\t\t\t: []\n\t\t)\n\t\t\t.map((a) => display(a, proxy))\n\t\t\t.join(', ');\n\t\tif (/^apply(:|$)/.test(trap)) return `${path}(${callArgs})`;\n\t\tif (trap === 'construct' || trap === 'construct:native')\n\t\t\treturn `new ${path}(${callArgs})`;\n\t}\n\n\treturn `${trap} on ${id}`;\n}\n","import type { Writable } from 'node:stream';\nimport type { GraphNode } from './graph.ts';\nimport { Graph } from './graph.ts';\nimport type { SerialConfig } from './serialize.ts';\nimport { serialize, origin as serializeOrigin } from './serialize.ts';\nimport type { Spec, Wrapper } from './specs.ts';\nimport { makeSpecs } from './specs.ts';\nimport type {\n\tCallTrap,\n\tOrigin,\n\tPropertyTrap,\n\tProxiable,\n\tRedactor,\n\tRekording,\n} from './types.ts';\nimport { isProxiable } from './types.ts';\nimport { retryFlows } from './retry.ts';\n\nexport { format } from './format.ts';\nexport {\n\tgetAncestors,\n\tgetOrigin,\n\tgetPath,\n\tgetProxyById,\n\tgetTarget,\n} from './inspection.ts';\nexport type {\n\tCallTrap,\n\tOrigin,\n\tPropertyTrap,\n\tProxiable,\n\tRedactor,\n\tRekording,\n\tSerialized,\n} from './types.ts';\nexport { isProxiable } from './types.ts';\n\n/** Resolved runtime configuration — derived from CreateOptions and passed through the proxy factory. */\ntype Config = {\n\twrite: (r: Rekording) => void;\n\trecursive: boolean;\n\tonly: Set<string> | null;\n\tfilter: ((r: Rekording) => boolean) | null;\n\tserial: SerialConfig;\n\tspecs: Partial<Record<string, Spec>>;\n\tbind: boolean | undefined;\n};\n\ntype CommonCreateOptions = {\n\tid?: number | (() => string);\n\trecursive?: boolean;\n\tonly?: Array<string>;\n\tfilter?: (rekording: Rekording) => boolean;\n\tdepth?: number;\n\tredact?: Redactor | Array<Redactor>;\n\ttruncate?: number;\n\tbind?: boolean;\n};\n\ntype StreamCreateOptions = CommonCreateOptions & { stream: Writable };\ntype CallbackCreateOptions = CommonCreateOptions & {\n\tcallback: (record: Rekording) => void;\n};\ntype CreateOptions = StreamCreateOptions | CallbackCreateOptions;\n\n/**\n * Creates a recording proxy for `target` within `graph`.\n * Reuses existing proxies for stability, handles Promises specially,\n * and registers every new proxy in both the graph and the module-level index.\n */\nfunction makeProxy<T extends Proxiable>(\n\ttarget: T,\n\tgraph: Graph,\n\tconfig: Config,\n\torigin: Origin,\n): T {\n\t// Already a proxy (in any graph) — return unchanged, preventing double-wrapping.\n\tif (Graph.isProxy(target as Proxiable)) return target;\n\n\t// Already have a proxy for this original — reuse it (stability guarantee).\n\tconst existing = graph.getByTarget(target as Proxiable);\n\n\tif (existing) return existing.proxy as T;\n\n\t// Promises cannot be proxied directly: native methods like .then() check for\n\t// the [[PromiseState]] internal slot and throw if `this` is a Proxy. Instead,\n\t// return a new Promise that resolves to a proxy of the settled value.\n\tif (target instanceof Promise) {\n\t\tconst chained = target.then((value) =>\n\t\t\tisProxiable(value)\n\t\t\t\t? makeProxy(value as Proxiable, graph, config, origin)\n\t\t\t\t: value,\n\t\t) as unknown as T;\n\t\t// Register with a placeholder node so stability lookups work.\n\t\tconst id = graph.nextId();\n\n\t\tgraph.register(chained as Proxiable, target as Proxiable, origin, id);\n\n\t\treturn chained;\n\t}\n\n\tconst proxyId = graph.nextId();\n\n\tconst traps = (\n\t\tObject.getOwnPropertyNames(Reflect) as Array<keyof typeof Reflect>\n\t).filter((trap) => config.only === null || config.only.has(trap));\n\n\tconst handler: ProxyHandler<Proxiable> = Object.fromEntries(\n\t\ttraps.map((trap) => [\n\t\t\ttrap,\n\t\t\t(...rawArgs: Array<unknown>) => {\n\t\t\t\tconst selfId = (graph.getByTarget(target) as GraphNode).id;\n\n\t\t\t\tlet childOrigin: Origin =\n\t\t\t\t\t/get|set|defineProperty|getOwnPropertyDescriptor/.test(trap)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\ttrap: trap as PropertyTrap,\n\t\t\t\t\t\t\t\tparent: selfId,\n\t\t\t\t\t\t\t\tkey: rawArgs[1] as string | symbol,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: /apply|construct/.test(trap)\n\t\t\t\t\t\t\t? { trap: trap as CallTrap, source: selfId }\n\t\t\t\t\t\t\t: null;\n\n\t\t\t\tconst wrap: Wrapper = (v) => {\n\t\t\t\t\tif (!isProxiable(v) || Graph.isProxy(v as Proxiable))\n\t\t\t\t\t\treturn v;\n\t\t\t\t\tif (!config.recursive) return v;\n\n\t\t\t\t\treturn makeProxy(\n\t\t\t\t\t\tv as Proxiable,\n\t\t\t\t\t\tgraph,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tchildOrigin,\n\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\t// Only wraps values already in the graph — new plain data passes through.\n\t\t\t\tconst known: Wrapper = (v) => {\n\t\t\t\t\tif (!isProxiable(v)) return v;\n\t\t\t\t\tif (Graph.isProxy(v as Proxiable)) return v;\n\n\t\t\t\t\tconst existing = graph.getByTarget(v as Proxiable);\n\n\t\t\t\t\tif (existing) return existing.proxy;\n\n\t\t\t\t\treturn v;\n\t\t\t\t};\n\n\t\t\t\tconst spec = config.specs[trap] ?? {};\n\t\t\t\tconst preArgs = spec.pre\n\t\t\t\t\t? spec.pre(rawArgs, wrap, known)\n\t\t\t\t\t: rawArgs;\n\n\t\t\t\tlet effectiveTrap: string = trap;\n\t\t\t\tlet effectiveArgs = preArgs;\n\t\t\t\tlet result: unknown;\n\n\t\t\t\ttry {\n\t\t\t\t\tresult = (\n\t\t\t\t\t\tReflect[trap] as (...args: Array<unknown>) => unknown\n\t\t\t\t\t)(...preArgs);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconst flow = retryFlows.find(({ is }) =>\n\t\t\t\t\t\tis(trap, e, config.bind),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (flow) {\n\t\t\t\t\t\t// is() matched preArgs to this flow's parameter shape at runtime;\n\t\t\t\t\t\t// the union can't express that statically.\n\t\t\t\t\t\tconst invoke = flow.handle as (\n\t\t\t\t\t\t\tg: Graph | undefined,\n\t\t\t\t\t\t\t...a: Array<unknown>\n\t\t\t\t\t\t) => { args?: Array<unknown>; result: unknown };\n\t\t\t\t\t\tconst output = invoke(graph, ...preArgs);\n\t\t\t\t\t\tif (flow.trap) {\n\t\t\t\t\t\t\teffectiveTrap = flow.trap;\n\t\t\t\t\t\t\tchildOrigin = {\n\t\t\t\t\t\t\t\ttrap: flow.trap as CallTrap,\n\t\t\t\t\t\t\t\tsource: selfId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (output?.args) effectiveArgs = output.args;\n\t\t\t\t\t\tresult = output.result;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst output = spec.post\n\t\t\t\t\t? spec.post(result, effectiveArgs, wrap)\n\t\t\t\t\t: result;\n\n\t\t\t\tconst rekording: Rekording = {\n\t\t\t\t\tid: graph.nextId(),\n\t\t\t\t\ttrap: effectiveTrap,\n\t\t\t\t\torigin: serializeOrigin(childOrigin),\n\t\t\t\t\targs: effectiveArgs.map((arg) =>\n\t\t\t\t\t\tserialize(arg, graph, new Set(), config.serial),\n\t\t\t\t\t),\n\t\t\t\t\tresult: serialize(output, graph, new Set(), config.serial),\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t};\n\t\t\t\tif (!config.filter || config.filter(rekording))\n\t\t\t\t\tconfig.write(rekording);\n\n\t\t\t\treturn output;\n\t\t\t},\n\t\t]),\n\t);\n\n\tconst pxy = new Proxy(target as Proxiable, handler) as unknown as T;\n\n\tgraph.register(pxy as Proxiable, target as Proxiable, origin, proxyId);\n\tGraph.track(pxy as Proxiable);\n\n\treturn pxy;\n}\n\n/**\n * Wraps `target` in a transparent recording proxy.\n * Every Reflect trap that fires emits a `Rekording` to `callback` or `stream`.\n */\nexport function create<T extends Proxiable>(\n\ttarget: T,\n\toptions: CreateOptions,\n): T {\n\tconst write: (r: Rekording) => void =\n\t\t'stream' in options\n\t\t\t? (r) => options.stream.write(`${JSON.stringify(r)}\\n`)\n\t\t\t: options.callback;\n\tconst recursive = options.recursive !== false;\n\tconst only = options.only ? new Set(options.only) : null;\n\tconst filter = options.filter ?? null;\n\tconst { redact } = options;\n\tconst serial: SerialConfig = {\n\t\tdepth: options.depth ?? Infinity,\n\t\tredactors: redact ? (Array.isArray(redact) ? redact : [redact]) : [],\n\t\ttruncate: options.truncate ?? Infinity,\n\t};\n\tconst graph = new Graph(options.id ?? 0);\n\tconst specs = makeSpecs(options.bind);\n\n\treturn makeProxy(\n\t\ttarget,\n\t\tgraph,\n\t\t{ write, recursive, only, filter, serial, specs, bind: options.bind },\n\t\tnull,\n\t);\n}\n\n/** Returns `true` if `value` is a proxy created by this module. */\nexport function isFlugrekorder(value: unknown): value is Proxiable {\n\treturn isProxiable(value) && Graph.isProxy(value as Proxiable);\n}\n"],"mappings":";AA6CO,SAAS,YAAY,OAAoC;AAC/D,SACC,UAAU,SACT,OAAO,UAAU,YAAY,OAAO,UAAU;AAEjD;;;AClCO,IAAM,QAAN,MAAM,OAAM;AAAA,EAClB,OAAO,SAAS,oBAAI,QAA0B;AAAA,EAC9C,OAAO,OAAO,oBAAI,QAAmB;AAAA;AAAA,EAGrC,OAAO,IAAI,KAAmC;AAC7C,WAAO,OAAM,OAAO,IAAI,GAAG;AAAA,EAC5B;AAAA;AAAA,EAGA,OAAO,QAAQ,KAAyB;AACvC,WAAO,OAAM,KAAK,IAAI,GAAG;AAAA,EAC1B;AAAA;AAAA,EAGA,OAAO,MAAM,KAAsB;AAClC,WAAM,KAA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
2
2
  "name": "flugrekorder",
3
- "version": "1.2.0-beta.0",
3
+ "version": "2.0.0-beta.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,14 +12,20 @@
12
12
  "url": "https://github.com/rspieker/flugrekorder/issues"
13
13
  },
14
14
  "homepage": "https://github.com/rspieker/flugrekorder#readme",
15
- "main": "dist/flugrekorder.js",
16
- "module": "dist/flugrekorder.mjs",
15
+ "type": "module",
16
+ "main": "dist/flugrekorder.cjs",
17
+ "module": "dist/flugrekorder.js",
17
18
  "types": "dist/flugrekorder.d.ts",
18
19
  "exports": {
19
20
  ".": {
20
- "types": "./dist/flugrekorder.d.ts",
21
- "import": "./dist/flugrekorder.mjs",
22
- "require": "./dist/flugrekorder.js"
21
+ "import": {
22
+ "types": "./dist/flugrekorder.d.ts",
23
+ "default": "./dist/flugrekorder.js"
24
+ },
25
+ "require": {
26
+ "types": "./dist/flugrekorder.d.cts",
27
+ "default": "./dist/flugrekorder.cjs"
28
+ }
23
29
  }
24
30
  },
25
31
  "files": [
@@ -35,11 +41,11 @@
35
41
  "check:write": "biome check --write",
36
42
  "release": "release-it --ci",
37
43
  "prepublishOnly": "npm run build",
38
- "test": "npm run test:unit && npm run test:functional",
39
- "test:unit": "node --require ./test.register.cjs --test 'source/**/*.spec.ts'",
40
- "test:functional": "node --require ./test.register.cjs --test 'test/**/*.spec.ts'",
41
- "test:coverage": "odz -- node --require ./test.register.cjs --test 'source/**/*.spec.ts' 'test/**/*.spec.ts'",
42
- "test:coverage:html": "odz -r html -rd ./coverage -- node --require ./test.register.cjs --test 'source/**/*.spec.ts' 'test/**/*.spec.ts'",
44
+ "typecheck": "tsc -p tsconfig.test.json",
45
+ "test": "npm run typecheck && npm run test:unit && npm run test:functional",
46
+ "test:unit": "node --test 'source/**/*.spec.ts'",
47
+ "test:functional": "node --test 'test/**/*.spec.ts'",
48
+ "test:coverage": "node --experimental-test-coverage --test-coverage-include='source/**/*.ts' --test-coverage-exclude='source/**/*.spec.ts' --test 'source/**/*.spec.ts' 'test/**/*.spec.ts'",
43
49
  "prepare": "husky || true"
44
50
  },
45
51
  "keywords": [
@@ -60,17 +66,18 @@
60
66
  },
61
67
  "devDependencies": {
62
68
  "@biomejs/biome": "^2.4.15",
63
- "@commitlint/config-conventional": "^20.5.3",
64
- "@release-it/conventional-changelog": "^11.0.0",
69
+ "@commitlint/config-conventional": "^21.2.4",
70
+ "@release-it/conventional-changelog": "^12.0.2",
65
71
  "@types/node": "^25.9.1",
66
- "commitlint": "^20.5.3",
72
+ "commitlint": "^21.2.4",
67
73
  "fast-check": "^4.8.0",
68
74
  "husky": "^9.1.7",
69
- "one-double-zero": "^1.1.1",
70
- "release-it": "^20.0.1",
75
+ "release-it": "^21.1.1",
71
76
  "template-literal-each": "^3.0.1",
72
- "ts-node": "^10.9.2",
73
- "tsup": "^8.5.1",
77
+ "tsup": "^9.0.0",
74
78
  "typescript": "^6.0.3"
79
+ },
80
+ "overrides": {
81
+ "basic-ftp": "^6.2.3"
75
82
  }
76
83
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../source/types.ts","../source/graph.ts","../source/serialize.ts","../source/slots.ts","../source/specs.ts","../source/errors.ts","../source/retry.ts","../source/inspection.ts","../source/format.ts","../source/flugrekorder.ts"],"sourcesContent":["import type { Graph } from './graph';\nexport type Proxiable = object;\n\n/** Reflect traps that operate on a property — carry a parent ID and key in their origin. */\nexport type PropertyTrap =\n\t| 'get'\n\t| 'set'\n\t| 'defineProperty'\n\t| 'getOwnPropertyDescriptor';\n\n/** Reflect traps that invoke a callable — carry a source ID in their origin. Includes synthetic variants for native boundary crossings. */\nexport type CallTrap =\n\t| 'apply'\n\t| 'construct'\n\t| 'apply:native'\n\t| 'construct:native'\n\t| 'apply:structure'\n\t| 'apply:private';\n\n/** Describes how a proxy was created — which trap fired, on which parent, and under which key or source. Null for root proxies. */\nexport type Origin =\n\t| { trap: PropertyTrap; parent: string; key: string | symbol }\n\t| { trap: CallTrap; source: string }\n\t| null;\n\n/** Origin with symbol keys coerced to strings — safe to include in a Rekording. */\nexport type SerializedOrigin =\n\t| { trap: PropertyTrap; parent: string; key: string }\n\t| { trap: CallTrap; source: string }\n\t| null;\n\n/** A JSON-safe representation of any value. Proxiable values are replaced with `{ $proxy: id }` tags. Raw targets (proxiable values known to the graph but passed unwrapped) are tagged `{ $unwrap: { $proxy: id } }`. */\nexport type Serialized =\n\t| string\n\t| number\n\t| boolean\n\t| bigint\n\t| null\n\t| undefined\n\t| { readonly $proxy: string }\n\t| { readonly $unwrap: { readonly $proxy: string } }\n\t| Array<Serialized>\n\t| { [key: string]: Serialized };\n\n/** Returns true for any value that can meaningfully be wrapped in a Proxy. */\nexport function isProxiable(value: unknown): value is Proxiable {\n\treturn (\n\t\tvalue !== null &&\n\t\t(typeof value === 'object' || typeof value === 'function')\n\t);\n}\n\n/**\n * Determines whether and how a key/value pair should be redacted during serialization.\n * Return `false` to keep as-is, `true` to replace with `\"[redacted]\"`,\n * a string to use as a custom replacement, or `null` to drop the key entirely.\n */\nexport type Redactor = (\n\tkey: string | symbol,\n\tvalue: unknown,\n\ttarget: object,\n) => string | boolean | null;\n\n/** A single recorded interaction — one Reflect trap firing on one proxy. */\nexport type Rekording = {\n\tid: string;\n\ttrap: string;\n\torigin: SerializedOrigin;\n\targs: Array<Serialized>;\n\tresult: Serialized;\n\ttimestamp: number;\n};\n\ntype Fn = (...args: Array<unknown>) => unknown;\n\n/** Describes a retry handler for an apply trap boundary crossing. */\ntype ApplyRetryFlow = {\n\tis: (trap: string, error: unknown, bind?: boolean) => boolean;\n\ttrap?: string;\n\thandle: (\n\t\tgraph: Graph | undefined,\n\t\tfn: Fn,\n\t\tthisArg: unknown,\n\t\targList: Array<unknown>,\n\t) => { args: [Fn, unknown, Array<unknown>]; result: unknown };\n};\n\n/** Describes a retry handler for a get trap boundary crossing. */\ntype GetRetryFlow = {\n\tis: (trap: string, error: unknown, bind?: boolean) => boolean;\n\ttrap?: never;\n\thandle: (\n\t\tgraph: Graph | undefined,\n\t\ttarget: object,\n\t\tpropertyKey: PropertyKey,\n\t\treceiver: unknown,\n\t) => { result: unknown };\n};\n\n/** Describes a native boundary crossing retry handler. */\nexport type RetryFlow = ApplyRetryFlow | GetRetryFlow;\n","import { isProxiable } from './types';\nimport type { Origin, Proxiable } from './types';\n\n/** A node in the proxy graph — links a proxy to its original target, its origin, and its ID. */\nexport type GraphNode = {\n\treadonly id: string;\n\treadonly proxy: Proxiable;\n\treadonly target: Proxiable;\n\treadonly origin: Origin;\n};\n\n/**\n * Session-scoped proxy registry.\n * Each `create()` call produces its own Graph so proxied trees are\n * independent and GC-eligible once no longer referenced.\n */\nexport class Graph {\n\tstatic #index = new WeakMap<Proxiable, Graph>();\n\tstatic #all = new WeakSet<Proxiable>();\n\n\t/** Returns the Graph that owns `pxy`, or `undefined` for non-proxies. */\n\tstatic for(pxy: Proxiable): Graph | undefined {\n\t\treturn Graph.#index.get(pxy);\n\t}\n\n\t/** Returns `true` if `pxy` is a proxy created by this module. */\n\tstatic isProxy(pxy: Proxiable): boolean {\n\t\treturn Graph.#all.has(pxy);\n\t}\n\n\t/** Marks `pxy` as a known proxy across all graphs (double-wrap guard). */\n\tstatic track(pxy: Proxiable): void {\n\t\tGraph.#all.add(pxy);\n\t}\n\n\t#byId = new Map<string, GraphNode>();\n\t#byProxy = new WeakMap<Proxiable, GraphNode>();\n\t#byTarget = new WeakMap<Proxiable, GraphNode>();\n\t#generator: () => string;\n\n\tconstructor(id: number | (() => string)) {\n\t\tlet counter = typeof id === 'number' ? id : 0;\n\n\t\tthis.#generator = typeof id === 'function' ? id : () => `#${++counter}`;\n\t}\n\n\tnextId(): string {\n\t\treturn this.#generator();\n\t}\n\n\t/** Returns the underlying target if `value` is a proxy known to this graph, otherwise `value` unchanged. */\n\tunwrap(value: unknown): unknown {\n\t\tif (!isProxiable(value)) return value;\n\t\treturn this.#byProxy.get(value)?.target ?? value;\n\t}\n\n\tgetByProxy(v: Proxiable): GraphNode | undefined {\n\t\treturn this.#byProxy.get(v);\n\t}\n\tgetByTarget(v: Proxiable): GraphNode | undefined {\n\t\treturn this.#byTarget.get(v);\n\t}\n\tgetById(id: string): GraphNode | undefined {\n\t\treturn this.#byId.get(id);\n\t}\n\n\tregister(\n\t\tproxy: Proxiable,\n\t\ttarget: Proxiable,\n\t\torigin: Origin,\n\t\tid: string,\n\t): GraphNode {\n\t\tconst node: GraphNode = { id, proxy, target, origin };\n\n\t\tthis.#byId.set(id, node);\n\t\tthis.#byProxy.set(proxy, node);\n\t\tthis.#byTarget.set(target, node);\n\t\tGraph.#index.set(proxy, this);\n\n\t\treturn node;\n\t}\n}\n","import type { Graph } from './graph';\nimport {\n\tisProxiable,\n\ttype Origin,\n\ttype Proxiable,\n\ttype Redactor,\n\ttype Serialized,\n\ttype SerializedOrigin,\n} from './types';\n\nexport type SerialConfig = {\n\tdepth: number;\n\tredactors: Array<Redactor>;\n\ttruncate: number;\n};\n\nexport const defaults: SerialConfig = {\n\tdepth: Infinity,\n\tredactors: [],\n\ttruncate: Infinity,\n};\n\n/** Find and apply any redaction for the given key/value/target context */\nfunction redact(\n\tredactors: Array<Redactor>,\n\tkey: string | symbol,\n\tvalue: unknown,\n\ttarget: object,\n): string | null | false {\n\tfor (const redactor of redactors) {\n\t\tconst result = redactor(key, value, target);\n\t\tif (result === false) continue;\n\n\t\treturn result === true ? '[redacted]' : result;\n\t}\n\n\treturn false;\n}\n\n/** Serializes an object or function value — tags known proxies by ID, inlines arrays and plain objects. */\nfunction proxiable(\n\tv: unknown,\n\tgraph: Graph,\n\tseen: Set<unknown>,\n\tserial: SerialConfig,\n\tdepth: number,\n): Serialized {\n\t// Check for a known proxy BEFORE Array.isArray: iterating a proxied\n\t// array via its proxy triggers get traps which call serialize again,\n\t// causing infinite recursion. A proxy is always tagged by ID.\n\tconst proxyNode = graph.getByProxy(<Proxiable>v);\n\tif (proxyNode !== undefined) return { $proxy: proxyNode.id };\n\n\tconst targetNode = graph.getByTarget(<Proxiable>v);\n\tif (targetNode !== undefined) return { $unwrap: { $proxy: targetNode.id } };\n\tif (depth >= serial.depth) return '[…]';\n\n\t// Plain (unproxied) arrays are safe to iterate directly.\n\tif (Array.isArray(v)) {\n\t\treturn (<Array<unknown>>v).map((item) =>\n\t\t\tserialize(item, graph, seen, serial, depth + 1),\n\t\t);\n\t}\n\n\t// Plain (unproxied) objects: serialize by value with a circular-reference guard.\n\tif (seen.has(v)) return { $proxy: '?' };\n\n\tseen.add(v);\n\n\tconst entries: Array<[string, Serialized]> = [];\n\n\tfor (const [k, val] of Object.entries(<object>v)) {\n\t\tif (serial.redactors.length > 0) {\n\t\t\tconst decision = redact(serial.redactors, k, val, <object>v);\n\t\t\tif (decision === null) continue;\n\t\t\tif (decision !== false) {\n\t\t\t\tentries.push([k, decision]);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tentries.push([k, serialize(val, graph, seen, serial, depth + 1)]);\n\t}\n\n\tseen.delete(v);\n\n\treturn Object.fromEntries(entries);\n}\n\n/** Converts any value to a JSON-safe Serialized form, tagging graph members by ID. */\nexport function serialize(\n\tv: unknown,\n\tgraph: Graph,\n\tseen = new Set<unknown>(),\n\tserial = defaults,\n\tdepth = 0,\n): Serialized {\n\tif (v === null || v === undefined) return v;\n\tif (isProxiable(v)) return proxiable(v, graph, seen, serial, depth);\n\n\treturn typeof v === 'string'\n\t\t? (<string>v).length > serial.truncate\n\t\t\t? `${(<string>v).slice(0, serial.truncate)}…`\n\t\t\t: <string>v\n\t\t: <Serialized>v;\n}\n\n/** Converts an Origin to its serialized form — coerces symbol keys to strings. */\nexport function origin(o: Origin): SerializedOrigin {\n\tif (!o) return null;\n\tif ('key' in o)\n\t\treturn { trap: o.trap, parent: o.parent, key: String(o.key) };\n\n\treturn o;\n}\n","import type { Proxiable } from './types';\n\ntype AnyFn = (...args: Array<unknown>) => unknown;\n\n// Per-prototype cache: true if any getter on this prototype (or its chain)\n// throws TypeError when called through a blank Proxy — the signature of an\n// internal slot check. Keyed by the direct prototype of the proxied target\n// so all instances of the same type share one probe result.\nconst slotProtos = new WeakMap<object, boolean>();\n\n// Stable bound-method cache: (target, key) → fn.bind(target).\n// Ensures the same proxied bound function is returned every time the same\n// method is accessed on the same target — required for graph proxy stability.\nconst bindCache = new WeakMap<object, Map<PropertyKey, AnyFn>>();\n\n// Slot-check TypeErrors have specific messages; filter by them to avoid\n// misclassifying TypeErrors thrown for other reasons (e.g. wrong arg count).\nconst slotError = /incompatible receiver|this is not|illegal invocation/i;\n\n/**\n * Returns true if `target`'s prototype chain contains a getter that throws\n * TypeError when called through a Proxy — the JS-observable signature of an\n * ECMAScript internal slot check (e.g. Map, Set, WeakMap, WeakSet, Date).\n * Result is cached per prototype so the probe runs at most once per type.\n */\nexport function hasInternalSlots(target: Proxiable): boolean {\n\tif (typeof target !== 'object' || target === null) return false;\n\n\tconst direct = Object.getPrototypeOf(target as object) as object | null;\n\tif (!direct) return false;\n\tconst cached = slotProtos.get(direct);\n\tif (cached !== undefined) return cached;\n\n\tconst probe = new Proxy(target as object, {\n\t\tset: () => true,\n\t\tdefineProperty: () => true,\n\t\tdeleteProperty: () => true,\n\t\tsetPrototypeOf: () => true,\n\t});\n\tlet proto: object | null = direct;\n\n\twhile (proto && proto !== Object.prototype) {\n\t\tfor (const key of Object.getOwnPropertyNames(proto)) {\n\t\t\tif (key === 'constructor') continue;\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(proto, key);\n\t\t\tconst fn =\n\t\t\t\tdesc?.get ??\n\t\t\t\t(typeof desc?.value === 'function'\n\t\t\t\t\t? (desc.value as AnyFn)\n\t\t\t\t\t: null);\n\t\t\tif (fn) {\n\t\t\t\tlet slots = false;\n\t\t\t\ttry {\n\t\t\t\t\tfn.call(probe);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (e instanceof TypeError && slotError.test(String(e)))\n\t\t\t\t\t\tslots = true;\n\t\t\t\t}\n\t\t\t\tslotProtos.set(direct, slots);\n\t\t\t\treturn slots;\n\t\t\t}\n\t\t}\n\t\tproto = Object.getPrototypeOf(proto) as object | null;\n\t}\n\n\tslotProtos.set(direct, false);\n\treturn false;\n}\n\n/** Returns a stable bound version of `fn` for `(target, key)` — created once, reused on every access. */\nexport function boundMethod(\n\ttarget: object,\n\tkey: PropertyKey,\n\tfn: AnyFn,\n): AnyFn {\n\tlet cache = bindCache.get(target);\n\tif (!cache) {\n\t\tcache = new Map();\n\t\tbindCache.set(target, cache);\n\t}\n\tconst existing = cache.get(key);\n\tif (existing) return existing;\n\tconst bound = fn.bind(target);\n\tcache.set(key, bound);\n\treturn bound;\n}\n","import { boundMethod, hasInternalSlots } from './slots';\nimport { isProxiable, type Proxiable } from './types';\n\n/** A function that conditionally wraps a value in a proxy. */\nexport type Wrapper = (v: unknown) => unknown;\n\n// %TypedArray% — the abstract base class shared by all TypedArray constructors.\n// Not exposed as a global; reached via the prototype chain of any TypedArray.\nconst TypedArray = Object.getPrototypeOf(Int8Array);\n\nconst ecmaBuiltins = [\n\tPromise,\n\tMap,\n\tSet,\n\tWeakMap,\n\tWeakSet,\n\tDate,\n\tRegExp,\n\tArrayBuffer,\n\tTypedArray,\n\tDataView,\n];\n\n/**\n * Returns true for standard ECMAScript built-ins whose C++ implementations\n * perform a JavaScript-level type check before touching internal fields —\n * so they throw a catchable TypeError when called through a Proxy rather\n * than crashing the process. Distinguishes them from Node.js C++ bindings\n * (TCP handles, ConnectionsList, HTTPParser, …) that crash fatally.\n *\n * Uses instanceof to cover subclasses — a JS subclass of Map has the same\n * internal-slot behaviour as Map itself and is equally safe to proxy.\n */\nfunction isECMABuiltin(v: unknown): boolean {\n\treturn ecmaBuiltins.some((B) => v instanceof B);\n}\n\n/** Returns true when v is a C++ binding object that would crash Node.js if proxied. */\nfunction isUnsafeBinding(v: unknown): boolean {\n\treturn isProxiable(v) && hasInternalSlots(v) && !isECMABuiltin(v);\n}\n\n// Exported for testing only.\nexport { isECMABuiltin, isUnsafeBinding };\n\n/** Pre/post hooks for a Reflect trap — transform args before dispatch and/or wrap the result. */\nexport type Spec = {\n\tpre?: (\n\t\targs: Array<unknown>,\n\t\twrap: Wrapper,\n\t\tknown: Wrapper,\n\t) => Array<unknown>;\n\tpost?: (result: unknown, args: Array<unknown>, wrap: Wrapper) => unknown;\n};\n\n/**\n * Builds per-trap hooks for a proxy session.\n * When `bind` is true, all method results and getter receivers are\n * bound to the real target — the same strategy used for ECMAScript built-ins\n * with internal slots, extended to user-defined classes with `#` private fields.\n */\nexport function makeSpecs(bind: boolean | undefined): Partial<Record<string, Spec>> {\n\treturn {\n\tget: {\n\t\t// For targets with internal slots (Map, Set, WeakMap, WeakSet, Date …)\n\t\t// or when bind is true, use the real target as the Reflect.get\n\t\t// receiver so that getter-based slot checks and #private field reads\n\t\t// (e.g. `get value() { return this.#count; }`) don't throw TypeError.\n\t\tpre: ([target, key, receiver], _wrap, _known) => [\n\t\t\ttarget,\n\t\t\tkey,\n\t\t\thasInternalSlots(target as Proxiable) || bind ? target : receiver,\n\t\t],\n\t\t// For the same targets, bind method results to the real target before\n\t\t// wrapping so that apply-level slot checks (e.g. Map.prototype.get)\n\t\t// and #private field access inside methods also pass.\n\t\t// The bind cache ensures proxy stability.\n\t\tpost: (result, [target, key], wrap) => {\n\t\t\tif (key === 'prototype') return result;\n\t\t\tif (hasInternalSlots(target as Proxiable) || bind) {\n\t\t\t\tif (typeof result === 'function')\n\t\t\t\t\treturn wrap(\n\t\t\t\t\t\tboundMethod(\n\t\t\t\t\t\t\ttarget as object,\n\t\t\t\t\t\t\tkey as PropertyKey,\n\t\t\t\t\t\t\tresult as (...args: Array<unknown>) => unknown,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t}\n\t\t\t// Don't proxy C++ binding objects — they crash native code when\n\t\t\t// used as Proxies (e.g. ConnectionsList, TCP handles). ECMAScript\n\t\t\t// built-ins (Map, Set, Promise, Date …) are excluded: they have\n\t\t\t// proper JS-level type checks and can be safely proxied.\n\t\t\tif (isUnsafeBinding(result)) return result;\n\t\t\treturn wrap(result);\n\t\t},\n\t},\n\tset: {\n\t\tpre: ([target, key, value, receiver], wrap) => [\n\t\t\ttarget,\n\t\t\tkey,\n\t\t\t// Don't wrap when target has slots (Map/Set internals) or when the\n\t\t\t// value is an unsafe C++ binding (TCP handles, etc.).\n\t\t\thasInternalSlots(target as Proxiable) || isUnsafeBinding(value)\n\t\t\t\t? value\n\t\t\t\t: wrap(value),\n\t\t\treceiver,\n\t\t],\n\t},\n\tapply: {\n\t\t// thisArg is wrapped normally (it's always a graph node).\n\t\t// Call arguments are wrapped with known — only existing graph nodes\n\t\t// get proxied; plain data passes through and is inlined by serialize().\n\t\tpre: ([target, thisArg, callArgs], wrap, known) => [\n\t\t\ttarget,\n\t\t\twrap(thisArg),\n\t\t\t(<Array<unknown>>callArgs).map(known),\n\t\t],\n\t\tpost: (result, _args, wrap) => wrap(result),\n\t},\n\tconstruct: {\n\t\tpre: ([target, callArgs, newTarget], wrap) => [\n\t\t\ttarget,\n\t\t\t(<Array<unknown>>callArgs).map(wrap),\n\t\t\tnewTarget,\n\t\t],\n\t\tpost: (result, _args, wrap) => wrap(result),\n\t},\n\tdefineProperty: {\n\t\tpre: (args, wrap) => {\n\t\t\tconst [target, key, descriptor] = <\n\t\t\t\t[unknown, unknown, PropertyDescriptor]\n\t\t\t>args;\n\t\t\tconst patch: PropertyDescriptor = {};\n\n\t\t\tif (descriptor.value != null && !isUnsafeBinding(descriptor.value))\n\t\t\t\tpatch.value = wrap(descriptor.value);\n\t\t\tif (typeof descriptor.get === 'function')\n\t\t\t\tpatch.get = <() => unknown>wrap(descriptor.get);\n\t\t\tif (typeof descriptor.set === 'function')\n\t\t\t\tpatch.set = <(v: unknown) => void>wrap(descriptor.set);\n\n\t\t\treturn Object.keys(patch).length > 0\n\t\t\t\t? [target, key, { ...descriptor, ...patch }]\n\t\t\t\t: args;\n\t\t},\n\t},\n\tgetOwnPropertyDescriptor: {\n\t\tpost: (result, _args, wrap) => {\n\t\t\tconst desc = <PropertyDescriptor | undefined>result;\n\n\t\t\tif (!desc) return result;\n\n\t\t\tconst patch: PropertyDescriptor = {};\n\n\t\t\tif (desc.value != null && !isUnsafeBinding(desc.value))\n\t\t\t\tpatch.value = wrap(desc.value);\n\t\t\tif (typeof desc.get === 'function')\n\t\t\t\tpatch.get = <() => unknown>wrap(desc.get);\n\t\t\tif (typeof desc.set === 'function')\n\t\t\t\tpatch.set = <(v: unknown) => void>wrap(desc.set);\n\n\t\t\treturn Object.keys(patch).length > 0\n\t\t\t\t? { ...desc, ...patch }\n\t\t\t\t: result;\n\t\t},\n\t},\n\t};\n}\n","export function isError(input: unknown): input is Error {\n\treturn input ? input instanceof Error : false;\n}\n\nexport function createErrorGuard(\n\tname: string,\n\tcontains?: RegExp,\n): (input: unknown) => input is Error {\n\tconst checks: Array<(input: unknown) => boolean> = [\n\t\tisError,\n\t\t(sub: unknown) =>\n\t\t\ttypeof sub === 'object' &&\n\t\t\t(sub as Record<string, unknown>)?.name === name,\n\t];\n\n\tif (contains instanceof RegExp) {\n\t\tchecks.push((v) => contains.test(String(v)));\n\t}\n\n\treturn (input: unknown): input is Error =>\n\t\tchecks.every((predicate) => predicate(input));\n}\n","import { createErrorGuard } from './errors';\nimport type { Graph } from './graph';\nimport type { RetryFlow } from './types';\n\n/** Returns the underlying target if `value` is a proxy known to `graph`, otherwise `value` unchanged. */\nexport function unwrap(graph: Graph | undefined, value: unknown): unknown {\n\treturn graph?.unwrap(value) ?? value;\n}\n\nconst isDataCloneDOMException = createErrorGuard('DataCloneError');\nconst isTypeErrorPrivateMember = createErrorGuard('TypeError', /private member/i);\nconst isTypeErrorIllegalInvocation = createErrorGuard('TypeError', /illegal invocation/i);\n\n/** Retry handlers for native boundary crossings — defined once at module level. */\nexport const retryFlows: Array<RetryFlow> = [\n\t{\n\t\t// Native methods (console.log, DOM APIs, http.Server) check the internal\n\t\t// [[Receiver]] slot and throw \"Illegal invocation\" when called through a\n\t\t// proxy. Unwrap the real target from the graph and retry as the receiver.\n\t\tis: (trap, error) =>\n\t\t\ttrap === 'apply' && isTypeErrorIllegalInvocation(error),\n\t\ttrap: 'apply:native',\n\t\thandle: (graph, fn, thisArg, argList) => {\n\t\t\tconst realThis = unwrap(graph, thisArg);\n\t\t\treturn {\n\t\t\t\targs: [fn, realThis, argList],\n\t\t\t\tresult: Reflect.apply(fn, realThis, argList),\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\t// structuredClone and postMessage can't clone proxy objects — they throw a\n\t\t// DataCloneError. Unwrap any proxy arguments to their real targets and retry.\n\t\tis: (trap, error) => trap === 'apply' && isDataCloneDOMException(error),\n\t\ttrap: 'apply:structure',\n\t\thandle: (graph, fn, thisArg, argList) => {\n\t\t\tconst unwrappedArgs = argList.map((arg) => unwrap(graph, arg));\n\t\t\treturn {\n\t\t\t\targs: [fn, thisArg, unwrappedArgs],\n\t\t\t\tresult: Reflect.apply(fn, thisArg, unwrappedArgs),\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\t// Private fields (#field) use brand checking — accessing #field on a proxy\n\t\t// (rather than the original instance) throws \"Cannot read private member\".\n\t\t// Unwrap the real instance from the graph and use it as the receiver.\n\t\tis: (trap, error, bind) =>\n\t\t\tbind !== false &&\n\t\t\ttrap === 'apply' &&\n\t\t\tisTypeErrorPrivateMember(error),\n\t\ttrap: 'apply:private',\n\t\thandle: (graph, fn, thisArg, argList) => {\n\t\t\tconst realThis = unwrap(graph, thisArg);\n\t\t\treturn {\n\t\t\t\targs: [fn, realThis, argList],\n\t\t\t\tresult: Reflect.apply(fn, realThis, argList),\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\t// A getter that reads a #private field hits the same brand check, but the\n\t\t// apply retry doesn't apply here. Re-invoke Reflect.get with the real target\n\t\t// as its own receiver so the brand check passes.\n\t\tis: (trap, error, bind) =>\n\t\t\tbind !== false && trap === 'get' && isTypeErrorPrivateMember(error),\n\t\thandle: (_graph, target, propertyKey) => ({\n\t\t\tresult: Reflect.get(target, propertyKey, target),\n\t\t}),\n\t},\n];\n","import { Graph } from './graph';\nimport type { Origin, Proxiable } from './types';\n\n/** Returns the original unwrapped target of a proxy, or `null` for non-proxies. */\nexport function getTarget(pxy: Proxiable): Proxiable | null {\n\treturn Graph.for(pxy)?.getByProxy(pxy)?.target ?? null;\n}\n\n/**\n * Looks up a proxy by its recorded ID within the same graph as `pxy`.\n * Use this to resolve `{ $proxy: id }` references in recorded args and results back to live proxies.\n */\nexport function getProxyById(\n\tid: string,\n\tpxy: Proxiable,\n): Proxiable | undefined {\n\treturn Graph.for(pxy)?.getById(id)?.proxy;\n}\n\n/** Returns the `Origin` of a proxy — how and from where it was created. Returns `null` for root proxies and non-proxies. */\nexport function getOrigin(pxy: Proxiable): Origin {\n\treturn Graph.for(pxy)?.getByProxy(pxy)?.origin ?? null;\n}\n\n/**\n * Walks the origin chain from the root proxy down to `pxy`.\n * Returns an ordered array of `{ proxy, origin }` pairs, root first.\n * Returns an empty array for non-proxies.\n */\nexport function getAncestors(\n\tpxy: Proxiable,\n): Array<{ proxy: Proxiable; origin: Origin }> {\n\tconst graph = Graph.for(pxy);\n\n\tif (!graph) return [];\n\n\tconst result: Array<{ proxy: Proxiable; origin: Origin }> = [];\n\tlet node = graph.getByProxy(pxy);\n\n\twhile (node) {\n\t\tresult.unshift({ proxy: node.proxy, origin: node.origin });\n\t\tif (!node.origin) break;\n\n\t\tconst parentId =\n\t\t\t'parent' in node.origin ? node.origin.parent : node.origin.source;\n\n\t\tnode = graph.getById(parentId);\n\t}\n\n\treturn result;\n}\n\n/**\n * Returns a human-readable dotted path string for a proxy.\n * Function and constructor calls are annotated with `()`.\n * Returns an empty string for the root proxy and for non-proxies.\n */\nexport function getPath(pxy: Proxiable): string {\n\tconst ancestors = getAncestors(pxy);\n\tconst parts: Array<string> = [];\n\n\tfor (const { origin: o } of ancestors) {\n\t\tif (!o) continue;\n\t\tif ('key' in o) {\n\t\t\tparts.push(String(o.key));\n\t\t} else {\n\t\t\tif (parts.length > 0) {\n\t\t\t\tparts[parts.length - 1] += '()';\n\t\t\t} else {\n\t\t\t\tparts.push('()');\n\t\t\t}\n\t\t}\n\t}\n\n\treturn parts.join('.');\n}\n","import { getPath, getProxyById } from './inspection';\nimport type { Proxiable, Rekording, Serialized } from './types';\n\nfunction resolve(id: string, proxy?: Proxiable): string {\n\tif (!proxy) return id;\n\tconst p = getProxyById(id, proxy);\n\treturn p !== undefined ? getPath(p) : id;\n}\n\nfunction display(v: Serialized, proxy?: Proxiable, limit = 80): string {\n\tif (v === null || v === undefined) return String(v);\n\tif (typeof v !== 'object') return String(v);\n\tif (!Array.isArray(v) && '$proxy' in v)\n\t\treturn resolve(<string>v.$proxy, proxy);\n\tif (!Array.isArray(v) && '$unwrap' in v)\n\t\treturn `↓${resolve((<{ $unwrap: { $proxy: string } }>v).$unwrap.$proxy, proxy)}`;\n\tconst raw = Array.isArray(v)\n\t\t? `[${v.map((i) => display(i, proxy)).join(', ')}]`\n\t\t: JSON.stringify(v);\n\treturn raw.length > limit ? `${raw.slice(0, limit)}…` : raw;\n}\n\n/** Converts a `Rekording` to a human-readable string.\n * When `proxy` is supplied, `{ $proxy: id }` tags in args and results resolve to dotted paths.\n * When omitted, raw IDs are shown instead. */\nexport function format(rekording: Rekording, proxy?: Proxiable): string {\n\tconst { id, trap, origin, args, result } = rekording;\n\n\tif (origin && 'parent' in origin) {\n\t\tconst parent = resolve(origin.parent, proxy);\n\t\tconst path = parent ? `${parent}.${origin.key}` : String(origin.key);\n\t\tif (trap === 'set') return `${path} = ${display(args[2], proxy)}`;\n\t\tif (trap === 'get') return `${path} → ${display(result, proxy)}`;\n\t\treturn `${trap} ${path}`;\n\t}\n\n\tif (origin && 'source' in origin) {\n\t\tconst path = resolve(origin.source, proxy);\n\t\tconst callArgs = (\n\t\t\tArray.isArray(trap === 'construct' ? args[1] : args[2])\n\t\t\t\t? <Array<Serialized>>(trap === 'construct' ? args[1] : args[2])\n\t\t\t\t: []\n\t\t)\n\t\t\t.map((a) => display(a, proxy))\n\t\t\t.join(', ');\n\t\tif (/^apply(:|$)/.test(trap))\n\t\t\treturn `${path}(${callArgs})`;\n\t\tif (trap === 'construct' || trap === 'construct:native')\n\t\t\treturn `new ${path}(${callArgs})`;\n\t}\n\n\treturn `${trap} on ${id}`;\n}\n","import type { Writable } from 'node:stream';\nimport type { GraphNode } from './graph';\nimport { Graph } from './graph';\nimport type { SerialConfig } from './serialize';\nimport { serialize, origin as serializeOrigin } from './serialize';\nimport type { Spec, Wrapper } from './specs';\nimport { makeSpecs } from './specs';\nimport type {\n\tCallTrap,\n\tOrigin,\n\tPropertyTrap,\n\tProxiable,\n\tRedactor,\n\tRekording,\n} from './types';\nimport { isProxiable } from './types';\nimport { retryFlows } from './retry';\n\nexport { format } from './format';\nexport {\n\tgetAncestors,\n\tgetOrigin,\n\tgetPath,\n\tgetProxyById,\n\tgetTarget,\n} from './inspection';\nexport type {\n\tCallTrap,\n\tOrigin,\n\tPropertyTrap,\n\tProxiable,\n\tRedactor,\n\tRekording,\n\tSerialized,\n} from './types';\nexport { isProxiable } from './types';\n\n\n/** Resolved runtime configuration — derived from CreateOptions and passed through the proxy factory. */\ntype Config = {\n\twrite: (r: Rekording) => void;\n\trecursive: boolean;\n\tonly: Set<string> | null;\n\tfilter: ((r: Rekording) => boolean) | null;\n\tserial: SerialConfig;\n\tspecs: Partial<Record<string, Spec>>;\n\tbind: boolean | undefined;\n};\n\ntype CommonCreateOptions = {\n\tid?: number | (() => string);\n\trecursive?: boolean;\n\tonly?: Array<string>;\n\tfilter?: (rekording: Rekording) => boolean;\n\tdepth?: number;\n\tredact?: Redactor | Array<Redactor>;\n\ttruncate?: number;\n\tbind?: boolean;\n};\n\ntype StreamCreateOptions = CommonCreateOptions & { stream: Writable };\ntype CallbackCreateOptions = CommonCreateOptions & {\n\tcallback: (record: Rekording) => void;\n};\ntype CreateOptions = StreamCreateOptions | CallbackCreateOptions;\n\n/**\n * Creates a recording proxy for `target` within `graph`.\n * Reuses existing proxies for stability, handles Promises specially,\n * and registers every new proxy in both the graph and the module-level index.\n */\nfunction makeProxy<T extends Proxiable>(\n\ttarget: T,\n\tgraph: Graph,\n\tconfig: Config,\n\torigin: Origin,\n): T {\n\t// Already a proxy (in any graph) — return unchanged, preventing double-wrapping.\n\tif (Graph.isProxy(<Proxiable>target)) return target;\n\n\t// Already have a proxy for this original — reuse it (stability guarantee).\n\tconst existing = graph.getByTarget(<Proxiable>target);\n\n\tif (existing) return <T>existing.proxy;\n\n\t// Promises cannot be proxied directly: native methods like .then() check for\n\t// the [[PromiseState]] internal slot and throw if `this` is a Proxy. Instead,\n\t// return a new Promise that resolves to a proxy of the settled value.\n\tif (target instanceof Promise) {\n\t\tconst chained = <T>(\n\t\t\t(<unknown>(\n\t\t\t\ttarget.then((value) =>\n\t\t\t\t\tisProxiable(value)\n\t\t\t\t\t\t? makeProxy(<Proxiable>value, graph, config, origin)\n\t\t\t\t\t\t: value,\n\t\t\t\t)\n\t\t\t))\n\t\t);\n\t\t// Register with a placeholder node so stability lookups work.\n\t\tconst id = graph.nextId();\n\n\t\tgraph.register(<Proxiable>chained, <Proxiable>target, origin, id);\n\n\t\treturn chained;\n\t}\n\n\tconst proxyId = graph.nextId();\n\n\tconst traps = (<Array<keyof typeof Reflect>>(\n\t\tObject.getOwnPropertyNames(Reflect)\n\t)).filter((trap) => config.only === null || config.only.has(trap));\n\n\tconst handler: ProxyHandler<Proxiable> = Object.fromEntries(\n\t\ttraps.map((trap) => [\n\t\t\ttrap,\n\t\t\t(...rawArgs: Array<unknown>) => {\n\t\t\t\tconst selfId = (<GraphNode>graph.getByTarget(target)).id;\n\n\t\t\t\tlet childOrigin: Origin =\n\t\t\t\t\t/get|set|defineProperty|getOwnPropertyDescriptor/.test(trap)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\ttrap: <PropertyTrap>trap,\n\t\t\t\t\t\t\t\tparent: selfId,\n\t\t\t\t\t\t\t\tkey: <string | symbol>rawArgs[1],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: /apply|construct/.test(trap)\n\t\t\t\t\t\t\t? { trap: <CallTrap>trap, source: selfId }\n\t\t\t\t\t\t\t: null;\n\n\t\t\t\tconst wrap: Wrapper = (v) => {\n\t\t\t\t\tif (!isProxiable(v) || Graph.isProxy(<Proxiable>v))\n\t\t\t\t\t\treturn v;\n\t\t\t\t\tif (!config.recursive) return v;\n\n\t\t\t\t\treturn makeProxy(<Proxiable>v, graph, config, childOrigin);\n\t\t\t\t};\n\n\t\t\t\t// Only wraps values already in the graph — new plain data passes through.\n\t\t\t\tconst known: Wrapper = (v) => {\n\t\t\t\t\tif (!isProxiable(v)) return v;\n\t\t\t\t\tif (Graph.isProxy(<Proxiable>v)) return v;\n\n\t\t\t\t\tconst existing = graph.getByTarget(<Proxiable>v);\n\n\t\t\t\t\tif (existing) return existing.proxy;\n\n\t\t\t\t\treturn v;\n\t\t\t\t};\n\n\t\t\t\tconst spec = config.specs[trap] ?? {};\n\t\t\t\tconst preArgs = spec.pre\n\t\t\t\t\t? spec.pre(rawArgs, wrap, known)\n\t\t\t\t\t: rawArgs;\n\n\t\t\t\tlet effectiveTrap: string = trap;\n\t\t\t\tlet effectiveArgs = preArgs;\n\t\t\t\tlet result: unknown;\n\n\t\t\t\ttry {\n\t\t\t\t\tresult = (<(...args: Array<unknown>) => unknown>(\n\t\t\t\t\t\tReflect[trap]\n\t\t\t\t\t))(...preArgs);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconst flow = retryFlows.find(({ is }) =>\n\t\t\t\t\t\tis(trap, e, config.bind),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (flow) {\n\t\t\t\t\t\t// is() matched preArgs to this flow's parameter shape at runtime;\n\t\t\t\t\t\t// the union can't express that statically.\n\t\t\t\t\t\tconst invoke = flow.handle as (\n\t\t\t\t\t\t\tg: Graph | undefined,\n\t\t\t\t\t\t\t...a: Array<unknown>\n\t\t\t\t\t\t) => { args?: Array<unknown>; result: unknown };\n\t\t\t\t\t\tconst output = invoke(graph, ...preArgs);\n\t\t\t\t\t\tif (flow.trap) {\n\t\t\t\t\t\t\teffectiveTrap = flow.trap;\n\t\t\t\t\t\t\tchildOrigin = {\n\t\t\t\t\t\t\t\ttrap: <CallTrap>flow.trap,\n\t\t\t\t\t\t\t\tsource: selfId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (output?.args) effectiveArgs = output.args;\n\t\t\t\t\t\tresult = output.result;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst output = spec.post\n\t\t\t\t\t? spec.post(result, effectiveArgs, wrap)\n\t\t\t\t\t: result;\n\n\t\t\t\tconst rekording: Rekording = {\n\t\t\t\t\tid: graph.nextId(),\n\t\t\t\t\ttrap: effectiveTrap,\n\t\t\t\t\torigin: serializeOrigin(childOrigin),\n\t\t\t\t\targs: effectiveArgs.map((arg) =>\n\t\t\t\t\t\tserialize(arg, graph, new Set(), config.serial),\n\t\t\t\t\t),\n\t\t\t\t\tresult: serialize(output, graph, new Set(), config.serial),\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t};\n\t\t\t\tif (!config.filter || config.filter(rekording))\n\t\t\t\t\tconfig.write(rekording);\n\n\t\t\t\treturn output;\n\t\t\t},\n\t\t]),\n\t);\n\n\tconst pxy = <T>(<unknown>new Proxy(<Proxiable>target, handler));\n\n\tgraph.register(<Proxiable>pxy, <Proxiable>target, origin, proxyId);\n\tGraph.track(<Proxiable>pxy);\n\n\treturn pxy;\n}\n\n/**\n * Wraps `target` in a transparent recording proxy.\n * Every Reflect trap that fires emits a `Rekording` to `callback` or `stream`.\n */\nexport function create<T extends Proxiable>(\n\ttarget: T,\n\toptions: CreateOptions,\n): T {\n\tconst write: (r: Rekording) => void =\n\t\t'stream' in options\n\t\t\t? (r) => options.stream.write(`${JSON.stringify(r)}\\n`)\n\t\t\t: options.callback;\n\tconst recursive = options.recursive !== false;\n\tconst only = options.only ? new Set(options.only) : null;\n\tconst filter = options.filter ?? null;\n\tconst { redact } = options;\n\tconst serial: SerialConfig = {\n\t\tdepth: options.depth ?? Infinity,\n\t\tredactors: redact ? (Array.isArray(redact) ? redact : [redact]) : [],\n\t\ttruncate: options.truncate ?? Infinity,\n\t};\n\tconst graph = new Graph(options.id ?? 0);\n\tconst specs = makeSpecs(options.bind);\n\n\treturn makeProxy(\n\t\ttarget,\n\t\tgraph,\n\t\t{ write, recursive, only, filter, serial, specs, bind: options.bind },\n\t\tnull,\n\t);\n}\n\n/** Returns `true` if `value` is a proxy created by this module. */\nexport function isFlugrekorder(value: unknown): value is Proxiable {\n\treturn isProxiable(value) && Graph.isProxy(<Proxiable>value);\n}\n"],"mappings":";;;;;;;;;AA6CO,SAAS,YAAY,OAAoC;AAC/D,SACC,UAAU,SACT,OAAO,UAAU,YAAY,OAAO,UAAU;AAEjD;;;AClDA;AAgBO,IAAM,SAAN,MAAM,OAAM;AAAA,EAwBlB,YAAY,IAA6B;AALzC,8BAAQ,oBAAI,IAAuB;AACnC,iCAAW,oBAAI,QAA8B;AAC7C,kCAAY,oBAAI,QAA8B;AAC9C;AAGC,QAAI,UAAU,OAAO,OAAO,WAAW,KAAK;AAE5C,uBAAK,YAAa,OAAO,OAAO,aAAa,KAAK,MAAM,IAAI,EAAE,OAAO;AAAA,EACtE;AAAA;AAAA,EAvBA,OAAO,IAAI,KAAmC;AAC7C,WAAO,qBAAM,QAAO,IAAI,GAAG;AAAA,EAC5B;AAAA;AAAA,EAGA,OAAO,QAAQ,KAAyB;AACvC,WAAO,qBAAM,MAAK,IAAI,GAAG;AAAA,EAC1B;AAAA;AAAA,EAGA,OAAO,MAAM,KAAsB;AAClC,yBAAM,MAAK,IAAI,GAAG;AAAA,EACnB;AAAA,EAaA,SAAiB;AAChB,WAAO,mBAAK,YAAL;AAAA,EACR;AAAA;AAAA,EAGA,OAAO,OAAyB;AAC/B,QAAI,CAA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