export { CloudflareBroadcastTransport, CloudflareBroadcastAuthorityState }; export type { BroadcastDeliverRequest, BroadcastPublishRequest, TelefuncBroadcastStub }; import type { BroadcastBinaryOnMessage, BroadcastOnMessage, BroadcastPublishResult, BroadcastAdapter, BroadcastUnsubscribe } from '../../broadcast.js'; import type { WirePublishInfo } from '../../../shared-ws.js'; import type { CloudflareScale, LocationBucket } from './routing.js'; type BroadcastPublishRequest = { key: string; locationBucket: LocationBucket; forwarded?: boolean; doNames?: string[]; info?: WirePublishInfo; serialized?: string; binaryData?: Uint8Array; }; type BroadcastDeliverRequest = { key: string; info: WirePublishInfo; serialized?: string; binaryData?: Uint8Array; }; type TelefuncBroadcastStub = DurableObjectStub & { telefuncBroadcastPublish(request: BroadcastPublishRequest): Promise; telefuncBroadcastDeliver(request: BroadcastDeliverRequest): Promise; }; declare class CloudflareBroadcastAuthorityState { private readonly state; private authorityPublishChain; private readonly keySeqCache; private readonly authorityBucketCache; constructor(state: DurableObjectState); getNextKeySeq(key: string): Promise; runInAuthorityChain(fn: () => Promise): Promise; getOrInitAuthorityBucket(key: string, preferredBucket: LocationBucket): Promise; } declare class CloudflareBroadcastTransport implements BroadcastAdapter { private readonly baseInstanceName; private readonly scale; private bindingName; private binding; private kv; private locationBucket; private representativeDOName; private readonly memberStates; private readonly textSubs; private readonly binarySubs; constructor({ baseInstanceName, scale }: { baseInstanceName: string; scale?: CloudflareScale; }); attachBinding(binding: DurableObjectNamespace, bindingName: string): void; attachKV(kv: KVNamespace): void; attachIsolateInfo(doName: string, locationBucket: LocationBucket): void; private requireKV; private requireLocationBucket; private requireRepresentativeDOName; private getPresenceKey; private getPresencePrefix; private putPresence; private deletePresence; private listPresenceByBucket; private hasLocalCallbacks; private deliverLocal; subscribe(key: string, onMessage: BroadcastOnMessage): BroadcastUnsubscribe; subscribeBinary(key: string, onMessage: BroadcastBinaryOnMessage): BroadcastUnsubscribe; publish(key: string, serialized: string): Promise; publishBinary(key: string, data: Uint8Array): Promise; /** * Fans out one keyed publish from either a key authority or a bucket coordinator. * * Non-forwarded: reads KV presence, sequences through authority, forwards to bucket coordinators. * Forwarded: delivers to listed DO names without reading KV again. */ publishToSubscribers(authorityState: CloudflareBroadcastAuthorityState, request: BroadcastPublishRequest): Promise; /** * Delivers a publish to local subscribers. Called via RPC on the representative DO for this isolate. */ deliverToLocal(request: BroadcastDeliverRequest): void; private ensurePresence; private teardownPresenceIfEmpty; private initializePresence; private getBucketCoordinatorStub; private getAuthorityStub; private getBoundStub; }