/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { MaybePromise, Mutex, Observable } from "@matter/general"; import { DatatypeModel } from "@matter/model"; import { ClientSubscription, Subscribe, type Peer } from "@matter/protocol"; import { EventNumber } from "@matter/types"; import { ClientNetworkRuntime } from "./ClientNetworkRuntime.js"; import { NetworkBehavior } from "./NetworkBehavior.js"; export declare class NetworkClient extends NetworkBehavior { #private; internal: NetworkClient.Internal; readonly state: NetworkClient.State; readonly events: NetworkClient.Events; initialize(): void; startup(): Promise; /** * Returns if we actually have an active and established subscription * When a Sustained subscription is used we return the active value, otherwise we know when the subscription instance * is set. */ get subscriptionActive(): any; [Symbol.asyncDispose](): Promise; /** * Define logical schema for fields that should persist. */ static readonly schema: DatatypeModel; } export declare namespace NetworkClient { class Internal extends NetworkBehavior.Internal { runtime?: ClientNetworkRuntime; /** * The active default subscription. */ activeSubscription?: ClientSubscription; /** * Identifies the default subscription being established or active. Its callbacks change the subscription * status and liveness and emit events only while it is set. Event numbers are recorded only for events it * emits. */ subscriptionOwner?: object; /** * Runs startup and the reactions to {@link State.autoSubscribe} and {@link State.defaultSubscription} one at a * time. */ subscriptionChanges: Mutex; /** * Indicates the node is newly commissioned. * * When newly commissioned we perform a one-time read before returning from {@link NetworkClient#startup} * (regardless of autoSubscribe, unless {@link NetworkClient.State.autoStateInitialize} is false). This * ensures we have a complete snapshot of the node's state when commissioning logic is complete. */ isNewlyCommissioned: boolean; /** * Latch indicating the peer is likely offline (unresponsive establishment, hard send failure or a missed ICD * check-in). Set by liveness signals, cleared on a fresh session, an active subscription or when the node is * disabled/stopped. Drives {@link NodeConnectionState.WaitingForDeviceDiscovery}. */ likelyOffline: boolean; /** * The operational peer backing this node, once wired at startup. Its session set feeds * {@link NodeConnectionState} recomputation. Undefined for group nodes and before startup. */ peer?: Peer; /** Was the fabric label already checked? */ fabricLabelReconciled: boolean; /** * The highest number of an event the default subscription or the read that initializes a newly-commissioned * node emitted to the node's event observers since the node started. Each new default subscription requests * only events above it or above {@link State.maxEventNumber}, whichever is higher. */ emittedEventNumber?: EventNumber; /** * Raises {@link State.maxEventNumber} to {@link emittedEventNumber} in a transaction of its own; calls run one * after the other. Undefined for group nodes. */ storeMaxEventNumber?: () => MaybePromise; } class State extends NetworkBehavior.State { /** * This subscription defines the default set of attributes and events to which the node will automatically * subscribe when started, if autoSubscribe is true. * * {@link Subscribe.Options} are merged into the default: all attributes and urgent events, fabric filtered. * * A built {@link Subscribe} or `Read` is sent as given, with its paths and fabric filter. The node sets the * event filter from the higher of the stored and the emitted event number, adds data versions as for any subscription and sets * `keepSubscriptions` to false where the request has none. A built request that should keep the node's * Leave handling needs the attributes and events of the Basic Information cluster and the `fabrics` attribute * of the Operational Credentials cluster. Without them the node notices a device going offline only through * the subscription timeout, and it does not see the Leave of a device that leaves the fabric. * * Only values selected by this subscription update automatically. * * The node's cache follows this subscription's fabric filter; changing the filter makes the cache forget its * data versions. The default subscription updates automatically if you change this property. */ defaultSubscription?: Subscribe | Subscribe.Options; /** * Represents the current operational network state of the node. When true the node is enabled and operational. * When false the node is disabled and not operational. * * This state can be changed at any time to enable or disable the node. */ isDisabled: boolean; /** * If true, automatically subscribe to the provided default subscription (or all attributes and events) when * the node is started. If false, do not automatically subscribe. * * The subscription will activate or deactivate automatically if you change this property. * * Newly commissioned nodes default to true. */ autoSubscribe: boolean; /** * When false, skip the one-time read a newly-commissioned node performs to initialize its state. * Undefined or true performs the read. */ autoStateInitialize?: boolean; /** * The highest number of an event the default subscription, or the read that initializes a newly-commissioned * node, emitted to the node's event observers. Each new default subscription requests only events above it. */ maxEventNumber: EventNumber; /** * Per-peer transport preference override. * If not set, inherits from NetworkServer.transportPreference. */ transportPreference?: "tcp" | "udp"; } class Events extends NetworkBehavior.Events { autoSubscribe$Changed: Observable<[value: boolean, oldValue: boolean], void>; defaultSubscription$Changed: Observable<[value: Subscribe | undefined, oldValue: Subscribe | undefined], void>; isDisabled$Changed: Observable<[value: boolean, oldValue: boolean], void>; subscriptionStatusChanged: Observable<[isActive: boolean], void>; subscriptionAlive: Observable<[], void>; } } //# sourceMappingURL=NetworkClient.d.ts.map