import { Envelope, type BackendReply } from './protocol'; export declare function nothing(...args: any[]): any; export declare const call: (f: Function) => any; export declare const identity: (x: T) => T; export declare function dispose(this: ISink): void; export type ObservableInputTuple = { [K in keyof T]: Observable; }; export type EventHandler = (event: T) => void; type EventMethod = (name: N, handler: EventHandler) => void; export type EventDispachter = { on: EventMethod; off: EventMethod; } | { addListener: EventMethod; removeListener: EventMethod; } | { addEventListener: EventMethod; removeEventListener: EventMethod; }; export interface Observer { subscribe(source: Observable): void; next(data: T): void; complete(): void; error(err: any): void; dispose(): void; } export declare class Inspect extends Function { id: string; name: string; args: IArguments; streamId: number; source?: InspectObservable; _label?: string; toString(): string; /** Attach a stable display label for the devtools panel. Does not change the node id. */ label(name: string): this; subscribe(sink: ISink): ISink; } declare type Dispose = () => any; export type Observable = (sink: ISink) => void; export type InspectObservable = Observable & Inspect; export type Operator = (source: Observable) => Observable; export declare class LastSink implements Observer { sourceId: string; defers: Set; disposed: boolean; next(data: T): void; complete(): void; error(err: any): void; get bindDispose(): () => void; dispose(): void; subscribe(source: Observable): this; get bindSubscribe(): (source: Observable) => this; doDefer(): void; defer(df: Dispose): void; removeDefer(df: Dispose): void; reset(): void; resetNext(): void; resetComplete(): void; resetError(): void; } export type ISink = LastSink; export declare class Sink extends LastSink { readonly sink: ISink; constructor(sink: ISink); next(data: T | R): void; complete(): void; error(err: any): void; } export declare class Subscribe extends LastSink { _next: typeof nothing; _error: typeof nothing; _complete: typeof nothing; then: typeof nothing; constructor(source: Observable | InspectObservable, _next?: typeof nothing, _error?: typeof nothing, _complete?: typeof nothing); next(data: T): void; complete(): void; error(err: any): void; } type Subscription = Subscribe | Promise | Observable; /** * Why use function overloads instead of a generic recursive type? * * 1. Inference vs Validation: TypeScript infers argument types independently before validating them against the function signature. * A recursive type (like PipeArgs) requires the type of the Nth argument to depend on the (N-1)th argument's return type. * However, TS often infers 'unknown' or 'any' for intermediate operators during the initial pass, causing the recursive match to fail * with confusing errors (e.g., "Type ... is not assignable to type 'never'"). * * 2. Developer Experience: Overloads provide precise type inference for each step in the pipeline. * If a type mismatch occurs (e.g., op2 expects string but op1 returns number), the error points exactly to the failing argument, * rather than a generic error on the entire function call. * * 3. Performance: Deeply recursive types can be computationally expensive for the compiler. Overloads are straightforward and fast. * * This is the standard approach used by libraries like RxJS. */ export declare function pipe>(first: Observable, sub: (source: Observable) => L): L; export declare function pipe>(first: Observable, op1: Operator, sub: (source: Observable) => L): L; export declare function pipe>(first: Observable, op1: Operator, op2: Operator, sub: (source: Observable) => L): L; export declare function pipe>(first: Observable, op1: Operator, op2: Operator, op3: Operator, sub: (source: Observable) => L): L; export declare function pipe>(first: Observable, op1: Operator, op2: Operator, op3: Operator, op4: Operator, sub: (source: Observable) => L): L; export declare function pipe>(first: Observable, op1: Operator, op2: Operator, op3: Operator, op4: Operator, op5: Operator, sub: (source: Observable) => L): L; export declare function pipe>(first: Observable, op1: Operator, op2: Operator, op3: Operator, op4: Operator, op5: Operator, op6: Operator, sub: (source: Observable) => L): L; export declare function pipe>(first: Observable, op1: Operator, op2: Operator, op3: Operator, op4: Operator, op5: Operator, op6: Operator, op7: Operator, sub: (source: Observable) => L): L; export declare function pipe>(...cbs: [Observable, ...any, (source: Observable) => L]): L; export declare function create(ob: (sink: ISink) => void, name: string, args: { [index: number]: any; length: number; }): Observable; export declare function deliver(c: { new (sink: ISink, ...args: ARG): ISink; }, name: string): (...args: ARG) => (Operator); /** Handle a panel command; returns a reply to post back (or undefined). */ export declare function handlePanelCommand(msg: any): BackendReply | undefined; /** @internal Test / playground seam: receive all emitted envelopes (drains * the ring first) without replacing the Chrome DevTools port, so both can * listen at once. Returns a disconnect function and a `sendCommand` helper. */ export declare function __testInstallBackend(emit: (e: Envelope) => void): () => void; export declare function __testInstallBackend(emit: (e: Envelope) => void, onReply: (reply: BackendReply) => void): { disconnect: () => void; sendCommand: (msg: any) => void; }; interface Node { id: string; name: string; _label?: string; toString(): string; source?: Node; } export declare const Events: { addSource(who: Node, source: Node): void; next(who: Node, streamId: number, data?: unknown, cause?: { nodeId: string; sequence: number; } | undefined): number; subscribe(id: { id: string; }, sink?: { nodeId: string; streamId: number; }): void; complete(who: Node, streamId: number, cause?: { nodeId: string; sequence: number; } | undefined): number; error(who: Node, streamId: number, err: unknown, cause?: { nodeId: string; sequence: number; } | undefined): number; defer(who: Node, streamId: number): void; pipe(who: Node): void; create(who: Node): void; }; export declare class TimeoutError extends Error { readonly timeout: number; constructor(timeout: number); } export {}; //# sourceMappingURL=common.d.ts.map