Field Notes
    Preparing search index...

    Interface ManagedSyncConnectionOptions

    interface ManagedSyncConnectionOptions {
        clientId: string;
        elementRegistry?: ElementRegistry;
        isAuthClose?: (code: number) => boolean;
        isTerminalClose?: (code: number) => boolean;
        layers?: { applyLayer: (update: RemoteLayerUpdate) => void };
        maxAuthFailures?: number;
        onStatus?: (status: ManagedSyncStatus) => void;
        onTransportMessage?: (raw: string) => void;
        plugins?: readonly ClientSyncPlugin[];
        resolveAudience?: (element: CanvasElement) => string | undefined;
        resolveLocalOnly?: ResolveLocalOnly;
        resolveUrl: () => | string
        | ManagedSyncEndpoint
        | Promise<string | ManagedSyncEndpoint | null>
        | null;
        retryInitialDelayMs?: number;
        retryMaxDelayMs?: number;
        store: ElementStore;
        transportFactory?: (
            url: string,
            protocols?: readonly string[],
        ) => ManagedSyncTransport;
    }
    Index
    clientId: string

    Stable client identity. It must not change across reconnects and, for authenticated relays, must equal the server-authenticated user id so ownership authorization and reconnect echo-suppression keep working. When Plugins may impose additional identity constraints.

    elementRegistry?: ElementRegistry

    Registry used to translate runtime extension envelopes to the v3 wire format.

    isAuthClose?: (code: number) => boolean

    Terminal close codes that count toward the consecutive-authentication failure bound. Default: 4401.

    isTerminalClose?: (code: number) => boolean

    Close codes the transport will NOT reconnect from itself; the manager rebuilds the transport and client with freshly resolved credentials. Default: application close codes 4000-4999, matching WebSocketTransport's default shouldReconnect.

    layers?: { applyLayer: (update: RemoteLayerUpdate) => void }

    Enables versioned layer-definition sync. The manager owns one LayerLedger for its whole lifetime and passes it to every client it builds, so version counters and tombstones survive credential rebuilds and locally-newer records are re-pushed after each reconnect snapshot.

    maxAuthFailures?: number

    Consecutive auth closes before settling on denied. Default: 4.

    onStatus?: (status: ManagedSyncStatus) => void
    onTransportMessage?: (raw: string) => void

    Optional observer for raw transport frames. It is subscribed before the internal SyncClient on every transport, so it sees each frame before the client applies it to the store. It must not throw.

    plugins?: readonly ClientSyncPlugin[]
    resolveAudience?: (element: CanvasElement) => string | undefined
    resolveLocalOnly?: ResolveLocalOnly

    Authoritative bootstrap/reconcile hook, forwarded to every SyncClient the manager creates. The manager keeps one hub-knowledge set for its whole lifetime and starts rebuilt clients in reconcile mode, so hubKnown classification and deleted-while-away semantics stay correct across credential rebuilds.

    resolveUrl: () => | string
    | ManagedSyncEndpoint
    | Promise<string | ManagedSyncEndpoint | null>
    | null

    Resolves the connection endpoint. Called once per connect cycle, so an expired token is refreshed by returning a fresh result. Return a plain URL (credentials in the query, the legacy form) or { url, protocols } to offer subprotocols — bearerSubprotocols(token) keeps the token out of the URL. Return null (or throw) to signal a mint failure; the manager retries with exponential backoff.

    retryInitialDelayMs?: number

    First retry delay for failed connect cycles. Default: 1000ms.

    retryMaxDelayMs?: number

    Retry delay cap. Default: 15000ms.

    store: ElementStore
    transportFactory?: (
        url: string,
        protocols?: readonly string[],
    ) => ManagedSyncTransport

    DI seam for tests; defaults to (url, protocols) => new WebSocketTransport(url, { protocols }).