/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { IEvent, IEventProvider, IFluidHandle } from "@fluidframework/core-interfaces"; import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal"; import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal"; import { IntervalCollection } from "./intervalCollection.js"; import type { IIntervalCollectionTypeOperationValue, ISerializableIntervalCollection, SequenceOptions } from "./intervalCollectionMapInterfaces.js"; /** * Description of a map delta operation */ export interface IMapOperation { /** * String identifier of the operation type. */ type: "act"; /** * Map key being modified. */ key: string; /** * Value of the operation, specific to the value type. */ value: IIntervalCollectionTypeOperationValue; } /** * Defines the in-memory object structure to be used for the conversion to/from serialized. * Directly used in JSON.stringify, direct result from JSON.parse */ export interface IMapDataObjectSerializable { [key: string]: ISerializableIntervalCollection; } export interface IntervalCollectionMapEvents extends IEvent { (event: "createIntervalCollection", listener: (key: string, local: boolean) => void): void; } /** * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by * string key locations. * * Creation of values is implicit on access (either via `get` or a remote op application referring to * a collection that wasn't previously known) */ export declare class IntervalCollectionMap { private readonly serializer; private readonly handle; private readonly submitMessage; private readonly options?; /** * The number of key/value pairs stored in the map. */ get size(): number; /** * The in-memory data the map is storing. */ private readonly data; private readonly eventEmitter; get events(): IEventProvider; /** * Create a new default map. * @param serializer - The serializer to serialize / parse handles * @param handle - The handle of the shared object using the kernel * @param submitMessage - A callback to submit a message through the shared object * @param type - The value type to create at values of this map * @param eventEmitter - The object that will emit map events */ constructor(serializer: IFluidSerializer, handle: IFluidHandle, submitMessage: (op: IMapOperation, localOpMetadata: unknown) => void, options?: Partial | undefined); /** * Get an iterator over the keys in this map. * @returns The iterator */ keys(): IterableIterator; /** * Get an iterator over the values in this map. * @returns The iterator */ values(): IterableIterator; /** * {@inheritDoc ISharedMap.get} */ get(key: string): IntervalCollection; serialize(serializer: IFluidSerializer): string; /** * Populate the kernel with the given map data. * * @param serialized - A JSON string containing serialized map data */ populate(serialized: string): void; /** * Submit the given op if a handler is registered. * @param content - The operation to attempt to submit * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime * and not sent to the server. This will be sent back when this message is received back from the server. This is * also sent if we are asked to resubmit the message. * @returns True if the operation was submitted, false otherwise. */ tryResubmitMessage(content: unknown, localOpMetadata: unknown, squash: boolean): boolean; tryRollback(content: any, localOpMetadata: unknown): boolean; tryApplyStashedOp(content: unknown): boolean; /** * Process the given op if a handler is registered. * @param message - The message to process * @param local - Whether the message originated from the local client * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message. * For messages from a remote client, this will be undefined. * @returns True if the operation was recognized and thus processed, false otherwise. * * @remarks * When this returns false and the caller doesn't handle the op itself, then the op could be from a different version of this code. * In such a case, not applying the op would result in this client becoming out of sync with clients that do handle the op * and could result in data corruption or data loss as well. * Therefore, in such cases the caller should typically throw an error, ensuring that this client treats the situation as data corruption * (since its data no longer matches what other clients think the data should be) and will avoid overriding document content or misleading the users into thinking their current state is accurate. */ tryProcessMessage(content: unknown, local: boolean, message: ISequencedDocumentMessage, localOpMetadata: unknown): boolean; /** * Initializes a default ValueType at the provided key. * Should be used when a map operation incurs creation. * @param key - The key being initialized */ private createCore; } //# sourceMappingURL=intervalCollectionMap.d.ts.map