/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { Listenable } from "@fluidframework/core-interfaces"; import type { DeepReadonly, JsonDeserialized, JsonSerializable } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes"; import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControlsTypes.js"; import type { InternalTypes } from "./exposedInternalTypes.js"; import type { LatestClientData, LatestData, ProxiedValueAccessor, RawValueAccessor, StateSchemaValidator, ValueAccessor } from "./latestValueTypes.js"; import type { Attendee, Presence } from "./presence.js"; /** * Events from {@link LatestRaw}. * * @sealed * @public */ export interface LatestEvents = ProxiedValueAccessor> { /** * Raised when remote client's value is updated, which may be the same value. * * @eventProperty */ remoteUpdated: (update: LatestClientData) => void; /** * Raised when local client's value is updated, which may be the same value. * * @eventProperty */ localUpdated: (update: { value: DeepReadonly>; }) => void; } /** * Events from {@link LatestRaw}. * * @sealed * @public */ export type LatestRawEvents = LatestEvents>; /** * State that provides the latest known value from this client to others and read access to their values. * All participant clients must provide a value. * * @remarks Create using {@link @fluidframework/presence#StateFactory|StateFactory}.{@link LatestFactory|latest} registered to {@link StatesWorkspace}. * * @sealed * @public */ export type LatestRaw = Latest>; /** * State that provides the latest known value from this client to others and read access to their values. * All participant clients must provide a value. * * @remarks Create using {@link @fluidframework/presence#StateFactory|StateFactory}.{@link LatestFactory|latest} registered to {@link StatesWorkspace}. * * @sealed * @public */ export interface Latest = ProxiedValueAccessor> { /** * Containing {@link Presence} */ readonly presence: Presence; /** * Events for LatestRaw. */ readonly events: Listenable>; /** * Controls for management of sending updates. */ readonly controls: BroadcastControls; /** * Current state for this client. * State for this client that will be transmitted to all other connected clients. * @remarks Manager assumes ownership of the value and its references. Make a deep clone before * setting, if needed. No comparison is done to detect changes; all sets are transmitted. */ get local(): DeepReadonly>; set local(value: JsonSerializable); /** * Array of {@link Attendee}s that have provided states. */ getStateAttendees(): Attendee[]; /** * Iterable access to remote clients' values. */ getRemotes(): IterableIterator>; /** * Access to a specific attendee's value. */ getRemote(attendee: Attendee): LatestData; } /** * Arguments that are passed to the {@link @fluidframework/presence#StateFactory.latest} function to create a {@link LatestRaw} State object. * * @input * @public */ export interface LatestArgumentsRaw { /** * The initial value of the local state. * * @remarks * `latest` assumes ownership of the value and its references. * Make a deep clone before passing, if needed. */ local: JsonSerializable; /** * See {@link BroadcastControlSettings}. */ settings?: BroadcastControlSettings | undefined; } /** * Arguments that are passed to the {@link @fluidframework/presence#StateFactory.latest} function to create a {@link Latest} State object. * * @input * @public */ export interface LatestArguments extends LatestArgumentsRaw { /** * See {@link StateSchemaValidator}. */ validator: StateSchemaValidator; } /** * Type alias for the return type of {@link LatestFactory} when called with * {@link LatestArguments}. * * @remarks * Use this type instead of any InternalPresenceTypes that may be revealed from * examining factory return type. * * @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain * allowed registration keys for this State object within a workspace. * Specification is recommended to highlight connection between schema and * factory when spread across modules. * * @public * @sealed */ export type LatestConfiguration = InternalTypes.ManagerFactory, Latest>; /** * Type alias for the return type of {@link LatestFactory} when called with * {@link LatestArgumentsRaw}. * * @remarks * Use this type instead of any InternalPresenceTypes that may be revealed from * examining factory return type. * * @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain * allowed registration keys for this State object within a workspace. * Specification is recommended to highlight connection between schema and * factory when spread across modules. * * @public * @sealed */ export type LatestRawConfiguration = InternalTypes.ManagerFactory, LatestRaw>; /** * Factory for creating a {@link Latest} or {@link LatestRaw} State object. * * @public * @sealed */ export interface LatestFactory { /** * Factory for creating a {@link Latest} State object. * * @remarks * This overload is used when called with {@link LatestArguments}. * That is, if a validator function is provided. */ (args: LatestArguments): LatestConfiguration; /** * Factory for creating a {@link LatestRaw} State object. * * @remarks * This overload is used when called with {@link LatestArgumentsRaw}. * That is, if a validator function is _not_ provided. */ (args: LatestArgumentsRaw): LatestRawConfiguration; } //# sourceMappingURL=latestTypes.d.ts.map