import type { createHeliaLight } from "helia"; import type { HeliaWithLibp2p } from "@helia/libp2p"; import type { ServiceMap } from "@libp2p/interface"; import type { KuboRpcClient } from "../types.js"; import type { PubsubRoutingComponents } from "@helia/ipns"; import type { GossipSub } from "@libp2p/gossipsub"; import type { Fetch } from "@libp2p/fetch"; import type { Identify } from "@libp2p/identify"; import type { IPNSRecord } from "ipns"; export interface IpnsRecordArrival { pubsubTopic: string; record: IPNSRecord; } export type IpnsRecordArrivalListener = (arrival: IpnsRecordArrival) => void; export interface IpnsPushChannelState { watchdogMs: number; lastValidRecordArrivalMs: Map; highestKnownSequenceByTopic: Map; routingKeyByTopic: Map; } export interface HeliaWithKuboRpcClientFunctions extends Pick, "add" | "cat" | "pubsub" | "stop"> { add: KuboRpcClient["_client"]["add"]; name: Pick; cat(ipfsPath: Parameters[0], options?: Parameters[1] & { bitswapSessionSeedScopeIpnsPubsubTopic?: string; }): ReturnType; pubsub: KuboRpcClient["_client"]["pubsub"]; stop: KuboRpcClient["_client"]["stop"]; ipnsRecordArrivals: { subscribe(args: { pubsubTopic: string; listener: IpnsRecordArrivalListener; }): void; unsubscribe(args: { pubsubTopic: string; listener: IpnsRecordArrivalListener; }): void; }; isIpnsPushChannelHealthy(args: { pubsubTopic: string; }): boolean; _bitswapSessionStalledGetFailoverMs?: number; } type GossipSubWithMeshPeers = GossipSub & { getMeshPeers(topic: string): string[]; }; export interface PkcLibp2pServices extends ServiceMap { identify: Identify; pubsub: PubsubRoutingComponents["libp2p"]["services"]["pubsub"] & GossipSubWithMeshPeers; fetch: Fetch; } export type HeliaWithLibp2pPubsub = ReturnType & HeliaWithLibp2p; export {};