/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { BroadcastControls } from "./broadcastControlsTypes.js"; import type { InternalTypes } from "./exposedInternalTypes.js"; import type { InternalUtilityTypes } from "./exposedUtilityTypes.js"; import type { NotificationsManager } from "./notificationsManagerTypes.js"; import type { Presence, PresenceWithNotifications } from "./presence.js"; /** * Unique address within a session. * * @remarks * A string known to all clients working with a certain Workspace and unique * among Workspaces. Recommend using specifying concatenation of: type of * unique identifier, `:` (required), and unique identifier. * * @example Examples * ```typescript * "guid:g0fl001d-1415-5000-c00l-g0fa54g0b1g1" * "address:object0/sub-object2:pointers" * ``` * * @public */ export type WorkspaceAddress = `${string}:${string}`; /** * Single entry in {@link StatesWorkspaceSchema} or {@link NotificationsWorkspaceSchema}. * * @public */ export type StatesWorkspaceEntry, TManager = unknown> = InternalTypes.ManagerFactory; /** * Schema for a {@link StatesWorkspace} workspace. * * Keys of schema are the keys of the {@link StatesWorkspace} providing access to State objects. * * @public */ export type StatesWorkspaceSchema = { [Key in Keys]: StatesWorkspaceEntry>; }; /** * Map of State objects registered with {@link StatesWorkspace}. * * @sealed * @public */ export type StatesWorkspaceEntries>, TSchemaKeys extends string & keyof TSchema = string & keyof TSchema> = { /** * Registered State objects. */ readonly [Key in keyof TSchema]: ReturnType>["manager"] extends InternalTypes.StateValue ? TManager : never; }; /** * `StatesWorkspace` maintains a registry of State objects that all share and provide access to * presence state values across client members in a session. * * State objects offer variations on how to manage states, but all share same principle that * each client's state is independent and may only be updated by originating client. * * @sealed * @public */ export interface StatesWorkspace>, TManagerConstraints = unknown, TSchemaKeys extends string & keyof TSchema = string & keyof TSchema> { /** * Registers a new State object with the {@link StatesWorkspace}. * @param key - new unique key for the State object within the workspace * @param configuration - factory/settings for creating a State object. Use * {@link @fluidframework/presence#StateFactory} to create. */ add, TManager extends TManagerConstraints>(key: TKey, configuration: InternalTypes.ManagerFactory): asserts this is StatesWorkspace>, TManagerConstraints>; /** * Registry of State objects. */ readonly states: StatesWorkspaceEntries; /** * Default controls for management of broadcast updates. */ readonly controls: BroadcastControls; /** * Containing {@link Presence} */ readonly presence: Presence; } /** * Schema for a {@link NotificationsWorkspace} workspace. * * Keys of schema are the keys of the {@link NotificationsWorkspace} providing access to {@link NotificationsManager}s. * * @alpha */ export type NotificationsWorkspaceSchema = { [Key in Keys]: InternalTypes.ManagerFactory, NotificationsManager>>; }; /** * `NotificationsWorkspace` maintains a registry of {@link NotificationsManager}s * that facilitate messages across client members in a session. * * @privateRemarks * This should be kept mostly in sync with {@link StatesWorkspace}. Notably the * return type of `add` is limited here and the `controls` property is omitted. * The `PresenceStatesImpl` class implements `AnyWorkspace` and therefore * `NotificationsWorkspace`, so long as this is proper subset. * * @sealed * @alpha */ export interface NotificationsWorkspace>, TSchemaKeys extends string & keyof TSchema = string & keyof TSchema> { /** * Registers a new `NotificationsManager` with the {@link NotificationsWorkspace}. * @param key - new unique key for the `NotificationsManager` within the workspace * @param manager - factory for creating a `NotificationsManager` */ add, TManager extends NotificationsManager>>(key: TKey, manager: InternalTypes.ManagerFactory): asserts this is NotificationsWorkspace>>; /** * Registry of `NotificationsManager`s. */ readonly notifications: StatesWorkspaceEntries; /** * Containing {@link PresenceWithNotifications} */ readonly presence: PresenceWithNotifications; } /** * `AnyWorkspace` is a superset of {@link StatesWorkspace} and {@link NotificationsWorkspace}. * * @internal */ export interface AnyWorkspace extends StatesWorkspace { readonly notifications: StatesWorkspaceEntries; readonly presence: PresenceWithNotifications; } //# sourceMappingURL=types.d.ts.map