/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import type { Behavior } from "#behavior/Behavior.js"; import type { BehaviorBacking } from "#behavior/internal/BehaviorBacking.js"; import type { Endpoint } from "#endpoint/Endpoint.js"; import type { ServerNode } from "#node/ServerNode.js"; import { Observable, Timestamp } from "@matter/general"; import { EventModel } from "@matter/model"; import { Val } from "@matter/protocol"; import { EventNumber, Priority } from "@matter/types"; /** * High-level change notification service. * * This service provides an optimized path to detecting property changes for all endpoints associated with a node. This * includes endpoints on peers. * * The service reports nothing once its node begins destruction. Destruction destroys every endpoint, peers included, * and that teardown is not a removal of the endpoints. * * An observer that throws is logged; the remaining observers still receive the change, and the code that made the * change does not see the error. */ export declare class ChangeNotificationService { #private; constructor(node: ServerNode); /** * Change event source. */ get change(): Observable<[changes: ChangeNotificationService.Change], void>; /** * Invoked by the {@link BehaviorBacking} when state changes. */ broadcastUpdate(backing: BehaviorBacking, properties: string[]): void; /** * Invoked by {@link Events} or {@link ClientEventEmitter} as events occur. */ broadcastEvent(endpoint: Endpoint, behavior: Behavior.Type, event: EventModel, occurrence: ChangeNotificationService.OccurrenceProperties): void; close(): void; } export declare namespace ChangeNotificationService { type Key = string | number; /** * Emits when state changes. * * If present, {@link properties} indicates the specific updated properties. Otherwise the recipient should * consider all properties. */ interface PropertyUpdate { kind: "update"; endpoint: Endpoint; behavior: Behavior.Type; version: number; properties?: string[]; } /** * The wire timestamp variant {@link OccurrenceProperties.timestamp} carries. Matter Core ยง10.7 defines exactly * four and an event sets exactly one: an absolute time against the Posix epoch or against device system (uptime) * time, or, on either clock, a delta from the preceding event of the same priority. A consumer forwarding the * occurrence must not guess which, as neither the clock nor absolute-vs-delta is recoverable from the value. */ type TimestampKind = "epoch" | "system" | "epoch-delta" | "system-delta"; interface OccurrenceProperties { number: EventNumber; timestamp: Timestamp; timestampKind: TimestampKind; priority: Priority; payload?: Val.Struct; } /** * Emits when a Matter event occurs. */ interface EventOccurrence extends OccurrenceProperties { kind: "event"; endpoint: Endpoint; behavior: Behavior.Type; event: EventModel; } /** * Emits when endpoints/nodes are deleted. * * This indicates to the recipient to drop the associated data subtree. Like every other change, it is not reported * once the service's node begins destruction. */ interface EndpointDelete { kind: "delete"; endpoint: Endpoint; } /** * Emits when an endpoint's state becomes readable because a construction completed: every construction an endpoint * starts while its node is observed, and that of a node still constructing when its observation begins. * * State changes made while an endpoint was unreadable may not have reached a recipient that skipped them. */ interface EndpointReadable { kind: "readable"; endpoint: Endpoint; } type Change = PropertyUpdate | EventOccurrence | EndpointDelete | EndpointReadable; } //# sourceMappingURL=ChangeNotificationService.d.ts.map