/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { DeepReadonly, JsonDeserialized } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes"; import type { Attendee } from "./presence.js"; /** * Metadata for the value state. * * @sealed * @public */ export interface LatestMetadata { /** * The revision number for value that increases as value is changed. */ revision: number; /** * Local time when the value was last updated. * @remarks Currently this is a placeholder for future implementation. */ timestamp: number; } /** * Represents a value that is accessed directly. * * @system * @public */ export interface RawValueAccessor { readonly kind: "raw"; readonly data: T; } /** * Represents a value that is accessed via a function call, which may result in no value. * * @system * @public */ export interface ProxiedValueAccessor { readonly kind: "proxied"; readonly data: T; } /** * Union of possible accessor types for a value. * * @system * @public */ export type ValueAccessor = RawValueAccessor | ProxiedValueAccessor; /** * Utility type that conditionally represents an accessor type based on the base accessor type. * * @system * @public */ export type Accessor> = BaseAccessor extends ProxiedValueAccessor ? () => DeepReadonly> | undefined : BaseAccessor extends RawValueAccessor ? DeepReadonly> : never; /** * State of a value and its metadata. * * @sealed * @public */ export interface LatestData> { /** * The value of the state or an accessor function. * * @remarks * If the State object was created with a {@link StateSchemaValidator}, then the `value` * will be a function returning a validated, deeply readonly `T` or `undefined`. * Without a validator, `value` will be an unvalidated, deeply readonly `T`. * * Any `T` is always deeply readonly, meaning it cannot be modified. */ value: Accessor; /** * Metadata associated with the value. */ metadata: LatestMetadata; } /** * State of a specific {@link Attendee}'s value and its metadata. * * @sealed * @public */ export interface LatestClientData = ProxiedValueAccessor> extends LatestData { /** * Associated {@link Attendee}. */ attendee: Attendee; } /** * A validator function that can optionally be provided to do runtime validation of the custom data stored in a * presence workspace and managed by a state object. * * @param unvalidatedData - The unknown data that should be validated. **This data should not be mutated.** * * @returns The validated data, or `undefined` if the data is invalid. * * @public */ export type StateSchemaValidator = ( /** * Unknown data that should be validated. **This data should not be mutated.** */ unvalidatedData: unknown) => JsonDeserialized | undefined; //# sourceMappingURL=latestValueTypes.d.ts.map