import { RootStore, Store, Transceiver } from "atom.io/internal"; import { Json } from "atom.io/foundations/json"; import { UList } from "atom.io/transceivers/u-list"; import * as AtomIO from "atom.io"; import { MutableAtomToken, ReadonlyPureSelectorToken, RegularAtomToken, ViewOf, WritableToken } from "atom.io"; import { AnyMosaicTransceiver, Clock, MosaicAtomAddress, MosaicIntent, MosaicOperation, MosaicOperationProposal, MosaicPresenceEnvelope, MosaicRecovery, MosaicRejectionCode, MosaicSignal, RoomKey, Socket, SocketKey, UserKey } from "atom.io/realtime"; import { Canonical } from "atom.io/foundations/canonical"; //#region src/realtime-client/create-subscriber.d.ts type SubData = { clock: Clock; close: () => void; coalesceMs: number; completion: Promise | null; completionResolve: (() => void) | null; refcount: number; sessionId: string | undefined; stopWatchingForReconnect: () => void; task: number | null; }; declare const SUBSCRIPTION_COALESCE_MS = 50; type SubscriberOptions = { /** Injectable for deterministic coalescing tests. Defaults to wall time. */ readonly clock?: Clock; readonly coalesceMs?: number; }; declare function getSubMap(socket: Socket): Map; declare function createSubscriber(socket: Socket, key: K, open: (key: K) => () => void, options?: SubscriberOptions): () => void; //#endregion //#region src/realtime-client/mosaic/types.d.ts type MosaicClientStatus = `live` | `offline` | `recovering` | `rejected` | `syncing`; /** The small transport surface required by the Store-bound client. */ type MosaicClientTransport = { /** Socket.IO exposes this; transports without it are presumed connected. */ readonly connected?: boolean; emit(event: string, ...args: Json.Serializable[]): void; off(event: string, listener?: (...args: Json.Serializable[]) => void): void; on(event: string, listener: (...args: Json.Serializable[]) => void): void; }; type MosaicClientIdKind = `group` | `operation` | `session`; type MosaicClientIdContext = { readonly actor: string; readonly kind: MosaicClientIdKind; readonly now: number; readonly sequence: number; readonly session: string | null; }; /** Must return a unique stable ID for every supplied sequence. */ type MosaicClientIdSource = (context: MosaicClientIdContext) => string; type MosaicClientClock = { now(): number; }; type MosaicClientProblem = { readonly code: MosaicRejectionCode; readonly discarded: readonly MosaicOperationProposal>[]; readonly kind: `rejection`; readonly operationId: string | null; readonly reason: string; readonly recovery: MosaicRecovery; } | { readonly discarded: readonly MosaicOperationProposal>[]; readonly kind: `protocol`; readonly reason: string; }; type MosaicSubmitOptions = { /** Use `createGroupId` to group several intents into one undo gesture. */ readonly group?: string | null; }; type MosaicSyncOptions = { readonly actor: string; readonly clock?: MosaicClientClock | (() => number); readonly idSource?: MosaicClientIdSource; /** Stable for the lifetime of an outbox; supply it to persist across reloads. */ readonly session?: string; readonly transport?: MosaicClientTransport; }; type MosaicSyncState = { readonly pending: readonly string[]; readonly presence: readonly MosaicPresenceEnvelope[]; readonly problem: MosaicClientProblem | null; readonly revision: number; readonly status: MosaicClientStatus; }; /** Store-owned control plane for an ordinary Mosaic mutable atom. */ interface MosaicController { readonly actor: string; readonly address: MosaicAtomAddress; readonly atom: MutableAtomToken; readonly session: string; readonly store: RootStore; readonly syncState: RegularAtomToken>; change(intent: MosaicIntent, options?: MosaicSubmitOptions): MosaicSignal | null; clearProblem(): void; connect(transport: MosaicClientTransport): () => void; createGroupId(): string; dispose(): void; publishPresence(presence: Presence | null): void; /** Resend unacknowledged envelopes without assigning new operation IDs. */ retryPending(): void; /** Request a fresh checkpoint while retaining the optimistic outbox. */ synchronize(): void; } //#endregion //#region src/realtime-client/mosaic/sync-mosaic.d.ts /** * Synchronize an ordinary Mosaic mutable atom in one Store. Equivalent callers * share the Store-owned replica for this atom address and session. */ declare function syncMosaic(store: RootStore, token: MutableAtomToken, options: MosaicSyncOptions): MosaicController; //#endregion //#region src/realtime-client/observe-socket-wind-down.d.ts /** * Observe the current cleanup wave for a socket's pending subscriptions. * * @remarks * This is exported for internal framework coordination, especially test * teardown, and is not intended as a general-purpose public utility. */ declare function observeSocketWindDown(socket: Socket): Promise; //#endregion //#region src/realtime-client/pull-atom.d.ts declare function pullAtom(store: Store, socket: Socket, token: AtomIO.RegularAtomToken): () => void; //#endregion //#region src/realtime-client/pull-atom-family-member.d.ts declare function pullAtomFamilyMember(store: Store, socket: Socket, family: AtomIO.AtomFamilyToken, key: NoInfer): () => void; //#endregion //#region src/realtime-client/pull-mutable-atom.d.ts declare function pullMutableAtom>(store: Store, socket: Socket, token: AtomIO.MutableAtomToken): () => void; //#endregion //#region src/realtime-client/pull-mutable-atom-family-member.d.ts declare function pullMutableAtomFamilyMember, K extends Canonical>(store: Store, socket: Socket, family: AtomIO.MutableAtomFamilyToken, key: NoInfer): () => void; //#endregion //#region src/realtime-client/pull-selector.d.ts declare function pullSelector(store: Store, socket: Socket, token: AtomIO.SelectorToken): () => void; //#endregion //#region src/realtime-client/pull-selector-family-member.d.ts declare function pullSelectorFamilyMember(store: Store, socket: Socket, familyToken: AtomIO.SelectorFamilyToken, key: NoInfer): () => void; //#endregion //#region src/realtime-client/push-state.d.ts declare function pushState(store: Store, socket: Socket, token: WritableToken): () => void; //#endregion //#region src/realtime-client/realtime-client-stores/client-main-store.d.ts declare const mySocketKeyAtom: RegularAtomToken; declare const myUserKeyAtom: RegularAtomToken; declare const myRoomKeySelector: ReadonlyPureSelectorToken; declare const usersHereSelector: ReadonlyPureSelectorToken | null>>; declare const roomOwnerSelector: ReadonlyPureSelectorToken; //#endregion export { type MosaicClientClock, type MosaicClientIdContext, type MosaicClientIdKind, type MosaicClientIdSource, type MosaicClientProblem, type MosaicClientStatus, type MosaicClientTransport, type MosaicController, type MosaicSubmitOptions, type MosaicSyncOptions, type MosaicSyncState, SUBSCRIPTION_COALESCE_MS, SubscriberOptions, createSubscriber, getSubMap, myRoomKeySelector, mySocketKeyAtom, myUserKeyAtom, observeSocketWindDown, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, roomOwnerSelector, syncMosaic, usersHereSelector }; //# sourceMappingURL=index.d.ts.map