import { type Constructor } from "@dao-xyz/borsh"; import { type TypedEventTarget } from "@libp2p/interface"; import { type Blocks } from "@peerbit/blocks-interface"; import { PublicSignKey } from "@peerbit/crypto"; import type { PeerRefs } from "@peerbit/stream-interface"; import { type Block } from "multiformats/block"; import { type Address } from "./address.js"; import { type Client } from "./client.js"; import { Handler, type Manageable, type ProgramInitializationOptions, TERMINAL_BASE_CHECKPOINT, TERMINAL_BASE_COMMIT, TERMINAL_BASE_RETRY, TERMINAL_OUTER_CLEANUP_RELEASE, TERMINAL_OUTER_CLEANUP_RETAIN, type TerminalBaseCommit } from "./handler.js"; export declare class ClosedError extends Error { constructor(message?: string); } export declare class MissingAddressError extends Error { constructor(); } export type OpenProgram = (program: Program) => Promise; export interface NetworkEvents { join: CustomEvent; leave: CustomEvent; } export interface LifeCycleEvents { drop: CustomEvent; open: CustomEvent; close: CustomEvent; } export interface ProgramEvents extends NetworkEvents, LifeCycleEvents { } export type ProgramClient = Client; declare class ProgramHandler extends Handler { constructor(properties: { client: ProgramClient; }); } export { ProgramHandler }; type ExtractArgs = T extends Program ? Args : never; type TerminalOperation = "close" | "drop"; export declare abstract class Program implements Manageable { static [Symbol.hasInstance](instance: any): boolean; constructor(); private _node; private _allPrograms; private _acceptsParentAttachments; private _events; private _closed; private _terminalCalls; private _dropDeletePending; private _failedTerminalChildren; private _emittedTerminalEvents; private _terminalBaseCommitVersion; private _terminalBaseCommitEpoch; private _terminalBaseCommitsByParent; private _rootTerminalBaseCommits; private _terminalRetryContexts; private _pendingTerminalTail; private _terminalLifecycleCallbackRunning; private _terminalOuterCleanupLeases; private _pendingInverseParentReleases; parents: (Program | undefined)[]; children: Program[]; private _address?; get address(): Address; set address(address: Address); get isRoot(): boolean; get rootAddress(): Address; calculateAddress(options?: { reset?: boolean; }): Promise<{ address: string; block?: Block; }>; get events(): TypedEventTarget; get closed(): boolean; set closed(closed: boolean); get acceptsParentAttachments(): boolean; get pendingTerminalOperation(): TerminalOperation | undefined; get terminalLifecycleCallbackRunning(): boolean; /** * Fence Handler reuse while a subclass performs irreversible terminal work * before delegating to Program.end(). A subsequent successful reopen clears * the fence in beforeOpen(). */ protected preventParentAttachments(): void; get node(): ProgramClient; set node(node: ProgramClient); private _eventOptions; beforeOpen(node: ProgramClient, options?: ProgramInitializationOptions): Promise; afterOpen(): Promise; abstract open(args?: Args): Promise; private _clear; private _emittedEventsFor; private _peerTopicsByHash; private _seedPeerTopicsFromSubscribers?; private get emittedEventsFor(); private get peerTopicsByHash(); private recordPeerSubscription; private recordPeerUnsubscription; private peerHasAllTopics; private getAllTopicsIncludingThis; private seedPeerTopicsSnapshot; private emitJoinIfReady; private _emitJoinNetworkEvents; private _emitLeaveNetworkEvents; private _subscriptionEventListener; private _unsubscriptionEventListener; [TERMINAL_BASE_CHECKPOINT](): number; [TERMINAL_OUTER_CLEANUP_RETAIN](): object; [TERMINAL_OUTER_CLEANUP_RELEASE](lease: object): void; [TERMINAL_BASE_COMMIT](afterVersion: number, type: TerminalOperation, from?: Manageable): TerminalBaseCommit | undefined; [TERMINAL_BASE_RETRY](commit: TerminalBaseCommit, operation: () => Promise): Promise; private consumeTerminalRetry; private recordTerminalBaseCommit; private retainInverseParentRelease; private reconcilePendingInverseParentReleases; private isOutermostBaseTerminalOperation; private processEnd; private finishTerminalTail; private end; private performTerminalOperation; private performDrop; private terminalOperation; private finishTerminalCall; close(from?: Program): Promise; drop(from?: Program): Promise; emitEvent(event: CustomEvent, parents?: boolean): void; /** * Wait for another peer to be 'ready' to talk with you for this particular program * @param other * @throws TimeoutError if the timeout is reached */ waitFor(other: PeerRefs, options?: { seek?: "any" | "present"; signal?: AbortSignal; timeout?: number; }): Promise; getReady(): Promise>; get allPrograms(): Program[]; get programs(): Program[]; clone(): this; getTopics?(): string[]; save(store?: Blocks, options?: { reset?: boolean; skipOnAddress?: boolean; save?: (address: string) => boolean | Promise; }): Promise
; delete(): Promise; static load

>(address: Address, store: Blocks, options?: { timeout?: number; }): Promise

; static open>>(this: Constructor, address: string, node: ProgramClient, options?: ProgramInitializationOptions, T>): Promise; } export declare const getProgramFromVariants: () => Constructor[]; export declare const getProgramFromVariant: (variant: string) => Constructor | undefined; //# sourceMappingURL=program.d.ts.map