@fluidframework/map 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +11 -16
- package/.mocharc.js +2 -2
- package/README.md +3 -3
- package/api-extractor.json +2 -2
- package/dist/directory.d.ts +1 -1
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +40 -18
- package/dist/directory.js.map +1 -1
- package/dist/interfaces.d.ts +12 -12
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/internalInterfaces.d.ts.map +1 -1
- package/dist/internalInterfaces.js.map +1 -1
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js.map +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +4 -2
- package/dist/map.js.map +1 -1
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +33 -22
- package/dist/mapKernel.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/directory.d.ts +1 -1
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +42 -20
- package/lib/directory.js.map +1 -1
- package/lib/interfaces.d.ts +12 -12
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/internalInterfaces.d.ts.map +1 -1
- package/lib/internalInterfaces.js.map +1 -1
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js.map +1 -1
- package/lib/map.d.ts +1 -1
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +5 -3
- package/lib/map.js.map +1 -1
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +34 -23
- package/lib/mapKernel.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +50 -50
- package/prettier.config.cjs +1 -1
- package/src/directory.ts +1952 -1875
- package/src/interfaces.ts +303 -306
- package/src/internalInterfaces.ts +67 -67
- package/src/localValues.ts +85 -94
- package/src/map.ts +363 -355
- package/src/mapKernel.ts +725 -690
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +5 -5
- package/tsconfig.json +9 -15
package/dist/directory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;AAEH,+DAAyE;AACzE,qEAA6D;AAC7D,+DAA4D;AAC5D,+EAG8C;AAS9C,2EAA+F;AAC/F,iEAAmE;AACnE,sDAAwC;AAWxC,+CAIuB;AACvB,qDAA8C;AAE9C,sFAAsF;AACtF,oDAAoD;AACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;AAEzB,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AA2LlC;;;;GAIG;AACH,MAAa,gBAAgB;IAezB;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,gBAAgB,CAAC,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACvC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CACb,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAC9B,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC/D,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE/B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,OAA+B,EAAE,EAAU;QACrD,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,EAAE,EAAE,OAAO,EAAE,gBAAgB,CAAC,UAAU,C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AC,YAAY,CAAC,CAAC;SAC/C;QACD,SAAS,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n ISequencedDocumentMessage,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelServices,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\nimport { IFluidSerializer, SharedObject, ValueType } from \"@fluidframework/shared-object-base\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport * as path from \"path-browserify\";\nimport {\n IDirectory,\n IDirectoryEvents,\n IDirectoryValueChanged,\n ISerializableValue,\n ISerializedValue,\n ISharedDirectory,\n ISharedDirectoryEvents,\n IValueChanged,\n} from \"./interfaces\";\nimport {\n ILocalValue,\n LocalValueMaker,\n makeSerializable,\n} from \"./localValues\";\nimport { pkgVersion } from \"./packageVersion\";\n\n// We use path-browserify since this code can run safely on the server or the browser.\n// We standardize on using posix slashes everywhere.\nconst posix = path.posix;\n\nconst snapshotFileName = \"header\";\n\n/**\n * Defines the means to process and submit a given op on a directory.\n */\ninterface IDirectoryMessageHandler {\n /**\n * Apply the given operation.\n * @param op - The directory operation to apply\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n process(\n op: IDirectoryOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void;\n\n /**\n * Communicate the operation to remote clients.\n * @param op - The directory operation to submit\n * @param localOpMetadata - The metadata to be submitted with the message.\n */\n submit(op: IDirectoryOperation, localOpMetadata: unknown): void;\n\n applyStashedOp(op: IDirectoryOperation): unknown;\n}\n\n/**\n * Operation indicating a value should be set for a key.\n */\nexport interface IDirectorySetOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"set\";\n\n /**\n * Directory key being modified.\n */\n key: string;\n\n /**\n * Absolute path of the directory where the modified key is located.\n */\n path: string;\n\n /**\n * Value to be set on the key.\n */\n value: ISerializableValue;\n}\n\n/**\n * Operation indicating a key should be deleted from the directory.\n */\nexport interface IDirectoryDeleteOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"delete\";\n\n /**\n * Directory key being modified.\n */\n key: string;\n\n /**\n * Absolute path of the directory where the modified key is located.\n */\n path: string;\n}\n\n/**\n * An operation on a specific key within a directory\n */\nexport type IDirectoryKeyOperation = IDirectorySetOperation | IDirectoryDeleteOperation;\n\n/**\n * Operation indicating the directory should be cleared.\n */\nexport interface IDirectoryClearOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"clear\";\n\n /**\n * Absolute path of the directory being cleared.\n */\n path: string;\n}\n\n/**\n * An operation on one or more of the keys within a directory\n */\nexport type IDirectoryStorageOperation = IDirectoryKeyOperation | IDirectoryClearOperation;\n\n/**\n * Operation indicating a subdirectory should be created.\n */\nexport interface IDirectoryCreateSubDirectoryOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"createSubDirectory\";\n\n /**\n * Absolute path of the directory that will contain the new subdirectory.\n */\n path: string;\n\n /**\n * Name of the new subdirectory.\n */\n subdirName: string;\n}\n\n/**\n * Operation indicating a subdirectory should be deleted.\n */\nexport interface IDirectoryDeleteSubDirectoryOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"deleteSubDirectory\";\n\n /**\n * Absolute path of the directory that contains the directory to be deleted.\n */\n path: string;\n\n /**\n * Name of the subdirectory to be deleted.\n */\n subdirName: string;\n}\n\n/**\n * An operation on the subdirectories within a directory\n */\nexport type IDirectorySubDirectoryOperation = IDirectoryCreateSubDirectoryOperation\n | IDirectoryDeleteSubDirectoryOperation;\n\n/**\n * Any operation on a directory\n */\nexport type IDirectoryOperation = IDirectoryStorageOperation | IDirectorySubDirectoryOperation;\n\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n *\n * @remarks Directly used in\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\n * | JSON.stringify}, direct result from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.\n */\nexport interface IDirectoryDataObject {\n /**\n * Key/value date set by the user.\n */\n storage?: { [key: string]: ISerializableValue; };\n\n /**\n * Recursive sub-directories {@link IDirectoryDataObject | objects}.\n */\n subdirectories?: { [subdirName: string]: IDirectoryDataObject; };\n}\n\n/**\n * {@link IDirectory} storage format.\n *\n * @internal\n */\nexport interface IDirectoryNewStorageFormat {\n /**\n * Blob IDs representing larger directory data that was serialized.\n */\n blobs: string[];\n\n /**\n * Storage content representing directory data that was not serialized.\n */\n content: IDirectoryDataObject;\n}\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedDirectory}.\n *\n * @sealed\n */\nexport class DirectoryFactory implements IChannelFactory {\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n */\n public static readonly Type = \"https://graph.microsoft.com/types/directory\";\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public static readonly Attributes: IChannelAttributes = {\n type: DirectoryFactory.Type,\n snapshotFormatVersion: \"0.1\",\n packageVersion: pkgVersion,\n };\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n */\n public get type(): string {\n return DirectoryFactory.Type;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public get attributes(): IChannelAttributes {\n return DirectoryFactory.Attributes;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n */\n public async load(\n runtime: IFluidDataStoreRuntime,\n id: string,\n services: IChannelServices,\n attributes: IChannelAttributes): Promise<ISharedDirectory> {\n const directory = new SharedDirectory(id, runtime, attributes);\n await directory.load(services);\n\n return directory;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n */\n public create(runtime: IFluidDataStoreRuntime, id: string): ISharedDirectory {\n const directory = new SharedDirectory(id, runtime, DirectoryFactory.Attributes);\n directory.initializeLocal();\n\n return directory;\n }\n}\n\n/**\n * {@inheritDoc ISharedDirectory}\n *\n * @example\n * ```typescript\n * mySharedDirectory.createSubDirectory(\"a\").createSubDirectory(\"b\").createSubDirectory(\"c\").set(\"foo\", val1);\n * const mySubDir = mySharedDirectory.getWorkingDirectory(\"/a/b/c\");\n * mySubDir.get(\"foo\"); // returns val1\n * ```\n *\n * @sealed\n */\nexport class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implements ISharedDirectory {\n /**\n * Create a new shared directory\n *\n * @param runtime - Data store runtime the new shared directory belongs to\n * @param id - Optional name of the shared directory\n * @returns Newly create shared directory (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string): SharedDirectory {\n return runtime.createChannel(id, DirectoryFactory.Type) as SharedDirectory;\n }\n\n /**\n * Get a factory for SharedDirectory to register with the data store.\n *\n * @returns A factory that creates and load SharedDirectory\n */\n public static getFactory(): IChannelFactory {\n return new DirectoryFactory();\n }\n\n /**\n * String representation for the class.\n */\n public [Symbol.toStringTag]: string = \"SharedDirectory\";\n\n /**\n * {@inheritDoc IDirectory.absolutePath}\n */\n public get absolutePath(): string {\n return this.root.absolutePath;\n }\n\n /**\n * @internal\n */\n public readonly localValueMaker: LocalValueMaker;\n\n /**\n * Root of the SharedDirectory, most operations on the SharedDirectory itself act on the root.\n */\n private readonly root: SubDirectory = new SubDirectory(this, this.runtime, this.serializer, posix.sep);\n\n /**\n * Mapping of op types to message handlers.\n */\n private readonly messageHandlers: Map<string, IDirectoryMessageHandler> = new Map();\n\n /**\n * Constructs a new shared directory. If the object is non-local an id and service interfaces will\n * be provided.\n * @param id - String identifier for the SharedDirectory\n * @param runtime - Data store runtime\n * @param type - Type identifier\n */\n public constructor(\n id: string,\n runtime: IFluidDataStoreRuntime,\n attributes: IChannelAttributes,\n ) {\n super(id, runtime, attributes, \"fluid_directory_\");\n this.localValueMaker = new LocalValueMaker(this.serializer);\n this.setMessageHandlers();\n // Mirror the containedValueChanged op on the SharedDirectory\n this.root.on(\n \"containedValueChanged\",\n (changed: IValueChanged, local: boolean) => {\n this.emit(\"containedValueChanged\", changed, local, this);\n },\n );\n this.root.on(\n \"subDirectoryCreated\",\n (relativePath: string, local: boolean) => {\n this.emit(\"subDirectoryCreated\", relativePath, local, this);\n },\n );\n this.root.on(\n \"subDirectoryDeleted\",\n (relativePath: string, local: boolean) => {\n this.emit(\"subDirectoryDeleted\", relativePath, local, this);\n },\n );\n }\n\n /**\n * {@inheritDoc IDirectory.get}\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public get<T = any>(key: string): T | undefined {\n return this.root.get<T>(key);\n }\n\n /**\n * {@inheritDoc IDirectory.set}\n */\n public set<T = unknown>(key: string, value: T): this {\n this.root.set(key, value);\n return this;\n }\n\n public dispose(error?: Error): void {\n this.root.dispose(error);\n }\n\n public get disposed(): boolean {\n return this.root.disposed;\n }\n\n /**\n * Deletes the given key from within this IDirectory.\n * @param key - The key to delete\n * @returns True if the key existed and was deleted, false if it did not exist\n */\n public delete(key: string): boolean {\n return this.root.delete(key);\n }\n\n /**\n * Deletes all keys from within this IDirectory.\n */\n public clear(): void {\n this.root.clear();\n }\n\n /**\n * Checks whether the given key exists in this IDirectory.\n * @param key - The key to check\n * @returns True if the key exists, false otherwise\n */\n public has(key: string): boolean {\n return this.root.has(key);\n }\n\n /**\n * The number of entries under this IDirectory.\n */\n public get size(): number {\n return this.root.size;\n }\n\n /**\n * Issue a callback on each entry under this IDirectory.\n * @param callback - Callback to issue\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public forEach(callback: (value: any, key: string, map: Map<string, any>) => void): void {\n // eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference\n this.root.forEach(callback);\n }\n\n /**\n * Get an iterator over the entries under this IDirectory.\n * @returns The iterator\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public [Symbol.iterator](): IterableIterator<[string, any]> {\n return this.root[Symbol.iterator]();\n }\n\n /**\n * Get an iterator over the entries under this IDirectory.\n * @returns The iterator\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public entries(): IterableIterator<[string, any]> {\n return this.root.entries();\n }\n\n /**\n * {@inheritDoc IDirectory.countSubDirectory}\n */\n public countSubDirectory(): number {\n return this.root.countSubDirectory();\n }\n\n /**\n * Get an iterator over the keys under this IDirectory.\n * @returns The iterator\n */\n public keys(): IterableIterator<string> {\n return this.root.keys();\n }\n\n /**\n * Get an iterator over the values under this IDirectory.\n * @returns The iterator\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public values(): IterableIterator<any> {\n return this.root.values();\n }\n\n /**\n * {@inheritDoc IDirectory.createSubDirectory}\n */\n public createSubDirectory(subdirName: string): IDirectory {\n return this.root.createSubDirectory(subdirName);\n }\n\n /**\n * {@inheritDoc IDirectory.getSubDirectory}\n */\n public getSubDirectory(subdirName: string): IDirectory | undefined {\n return this.root.getSubDirectory(subdirName);\n }\n\n /**\n * {@inheritDoc IDirectory.hasSubDirectory}\n */\n public hasSubDirectory(subdirName: string): boolean {\n return this.root.hasSubDirectory(subdirName);\n }\n\n /**\n * {@inheritDoc IDirectory.deleteSubDirectory}\n */\n public deleteSubDirectory(subdirName: string): boolean {\n return this.root.deleteSubDirectory(subdirName);\n }\n\n /**\n * {@inheritDoc IDirectory.subdirectories}\n */\n public subdirectories(): IterableIterator<[string, IDirectory]> {\n return this.root.subdirectories();\n }\n\n /**\n * {@inheritDoc IDirectory.getWorkingDirectory}\n */\n public getWorkingDirectory(relativePath: string): IDirectory | undefined {\n const absolutePath = this.makeAbsolute(relativePath);\n if (absolutePath === posix.sep) {\n return this.root;\n }\n\n let currentSubDir = this.root;\n const subdirs = absolutePath.slice(1).split(posix.sep);\n for (const subdir of subdirs) {\n currentSubDir = currentSubDir.getSubDirectory(subdir) as SubDirectory;\n if (!currentSubDir) {\n return undefined;\n }\n }\n return currentSubDir;\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n * @internal\n */\n protected summarizeCore(\n serializer: IFluidSerializer,\n telemetryContext?: ITelemetryContext,\n ): ISummaryTreeWithStats {\n return this.serializeDirectory(this.root, serializer);\n }\n\n /**\n * Submits an operation\n * @param op - Op to submit\n * @param localOpMetadata - The local metadata associated with the op. We send a unique id that is used to track\n * this op while it has not been ack'd. This will be sent when we receive this op back from the server.\n * @internal\n */\n public submitDirectoryMessage(op: IDirectoryOperation, localOpMetadata: unknown): void {\n this.submitLocalMessage(op, localOpMetadata);\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n * @internal\n */\n protected onDisconnect(): void { }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n * @internal\n */\n protected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n const message = content as IDirectoryOperation;\n const handler = this.messageHandlers.get(message.type);\n assert(handler !== undefined, 0x00d /* Missing message handler for message type */);\n handler.submit(message, localOpMetadata);\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n * @internal\n */\n protected async loadCore(storage: IChannelStorageService): Promise<void> {\n const data = await readAndParse(storage, snapshotFileName);\n const newFormat = data as IDirectoryNewStorageFormat;\n if (Array.isArray(newFormat.blobs)) {\n // New storage format\n this.populate(newFormat.content);\n await Promise.all(newFormat.blobs.map(async (value) => {\n const dataExtra = await readAndParse(storage, value);\n this.populate(dataExtra as IDirectoryDataObject);\n }));\n } else {\n // Old storage format\n this.populate(data as IDirectoryDataObject);\n }\n }\n\n /**\n * Populate the directory with the given directory data.\n * @param data - A JSON string containing serialized directory data\n * @internal\n */\n protected populate(data: IDirectoryDataObject): void {\n const stack: [SubDirectory, IDirectoryDataObject][] = [];\n stack.push([this.root, data]);\n while (stack.length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const [currentSubDir, currentSubDirObject] = stack.pop()!;\n if (currentSubDirObject.subdirectories) {\n for (const [subdirName, subdirObject] of Object.entries(currentSubDirObject.subdirectories)) {\n let newSubDir = currentSubDir.getSubDirectory(subdirName) as SubDirectory;\n if (!newSubDir) {\n newSubDir = new SubDirectory(\n this,\n this.runtime,\n this.serializer,\n posix.join(currentSubDir.absolutePath, subdirName),\n );\n currentSubDir.populateSubDirectory(subdirName, newSubDir);\n }\n stack.push([newSubDir, subdirObject]);\n }\n }\n\n if (currentSubDirObject.storage) {\n for (const [key, serializable] of Object.entries(currentSubDirObject.storage)) {\n const localValue = this.makeLocal(\n key,\n currentSubDir.absolutePath,\n serializable,\n );\n currentSubDir.populateStorage(key, localValue);\n }\n }\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n * @internal\n */\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n if (message.type === MessageType.Operation) {\n const op: IDirectoryOperation = message.contents as IDirectoryOperation;\n const handler = this.messageHandlers.get(op.type);\n assert(handler !== undefined, 0x00e /* Missing message handler for message type */);\n handler.process(op, local, localOpMetadata);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n * @internal\n */\n protected rollback(content: unknown, localOpMetadata: unknown): void {\n const op: IDirectoryOperation = content as IDirectoryOperation;\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n subdir.rollback(op, localOpMetadata);\n }\n }\n\n /**\n * Converts the given relative path to absolute against the root.\n * @param relativePath - The path to convert\n */\n private makeAbsolute(relativePath: string): string {\n return posix.resolve(posix.sep, relativePath);\n }\n\n /**\n * The remote ISerializableValue we're receiving (either as a result of a snapshot load or an incoming set op)\n * will have the information we need to create a real object, but will not be the real object yet. For example,\n * we might know it's a map and the ID but not have the actual map or its data yet. makeLocal's job\n * is to convert that information into a real object for local usage.\n * @param key - Key of element being converted\n * @param absolutePath - Path of element being converted\n * @param serializable - The remote information that we can convert into a real object\n * @returns The local value that was produced\n */\n private makeLocal(\n key: string,\n absolutePath: string,\n serializable: ISerializableValue,\n ): ILocalValue {\n assert(\n serializable.type === ValueType[ValueType.Plain] || serializable.type === ValueType[ValueType.Shared],\n 0x1e4 /* \"Unexpected serializable type\" */,\n );\n return this.localValueMaker.fromSerializable(serializable);\n }\n\n /**\n * Set the message handlers for the directory.\n */\n private setMessageHandlers(): void {\n this.messageHandlers.set(\n \"clear\",\n {\n process: (op: IDirectoryClearOperation, local, localOpMetadata) => {\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n subdir.processClearMessage(op, local, localOpMetadata);\n }\n },\n submit: (op: IDirectoryClearOperation, localOpMetadata: unknown) => {\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n subdir.resubmitClearMessage(op, localOpMetadata);\n }\n },\n applyStashedOp: (op: IDirectoryClearOperation): IClearLocalOpMetadata | undefined => {\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n return subdir.applyStashedClearMessage(op);\n }\n },\n },\n );\n this.messageHandlers.set(\n \"delete\",\n {\n process: (op: IDirectoryDeleteOperation, local, localOpMetadata) => {\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n subdir.processDeleteMessage(op, local, localOpMetadata);\n }\n },\n submit: (op: IDirectoryDeleteOperation, localOpMetadata: unknown) => {\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n subdir.resubmitKeyMessage(op, localOpMetadata);\n }\n },\n applyStashedOp: (op: IDirectoryDeleteOperation): IKeyEditLocalOpMetadata | undefined => {\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n return subdir.applyStashedDeleteMessage(op);\n }\n },\n },\n );\n this.messageHandlers.set(\n \"set\",\n {\n process: (op: IDirectorySetOperation, local, localOpMetadata) => {\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n const context = local ? undefined : this.makeLocal(op.key, op.path, op.value);\n subdir.processSetMessage(op, context, local, localOpMetadata);\n }\n },\n submit: (op: IDirectorySetOperation, localOpMetadata: unknown) => {\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n subdir.resubmitKeyMessage(op, localOpMetadata);\n }\n },\n applyStashedOp: (op: IDirectorySetOperation): IKeyEditLocalOpMetadata | undefined => {\n const subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (subdir) {\n const context = this.makeLocal(op.key, op.path, op.value);\n return subdir.applyStashedSetMessage(op, context);\n }\n },\n },\n );\n\n this.messageHandlers.set(\n \"createSubDirectory\",\n {\n process: (op: IDirectoryCreateSubDirectoryOperation, local, localOpMetadata) => {\n const parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (parentSubdir) {\n parentSubdir.processCreateSubDirectoryMessage(op, local, localOpMetadata);\n }\n },\n submit: (op: IDirectoryCreateSubDirectoryOperation, localOpMetadata: unknown) => {\n const parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (parentSubdir) {\n // We don't reuse the metadata but send a new one on each submit.\n parentSubdir.resubmitSubDirectoryMessage(op, localOpMetadata);\n }\n },\n applyStashedOp: (op: IDirectoryCreateSubDirectoryOperation): ICreateSubDirLocalOpMetadata | undefined => {\n const parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (parentSubdir) {\n return parentSubdir.applyStashedCreateSubDirMessage(op);\n }\n },\n },\n );\n\n this.messageHandlers.set(\n \"deleteSubDirectory\",\n {\n process: (op: IDirectoryDeleteSubDirectoryOperation, local, localOpMetadata) => {\n const parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (parentSubdir) {\n parentSubdir.processDeleteSubDirectoryMessage(op, local, localOpMetadata);\n }\n },\n submit: (op: IDirectoryDeleteSubDirectoryOperation, localOpMetadata: unknown) => {\n const parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (parentSubdir) {\n // We don't reuse the metadata but send a new one on each submit.\n parentSubdir.resubmitSubDirectoryMessage(op, localOpMetadata);\n }\n },\n applyStashedOp: (op: IDirectoryDeleteSubDirectoryOperation): IDeleteSubDirLocalOpMetadata | undefined => {\n const parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n if (parentSubdir) {\n return parentSubdir.applyStashedDeleteSubDirMessage(op);\n }\n },\n },\n );\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n * @internal\n */\n protected applyStashedOp(op: unknown): unknown {\n const handler = this.messageHandlers.get((op as IDirectoryOperation).type);\n if (handler === undefined) {\n throw new Error(\"no apply stashed op handler\");\n }\n return handler.applyStashedOp(op as IDirectoryOperation);\n }\n\n private serializeDirectory(\n root: SubDirectory,\n serializer: IFluidSerializer,\n telemetryContext?: ITelemetryContext,\n ): ISummaryTreeWithStats {\n const MinValueSizeSeparateSnapshotBlob = 8 * 1024;\n\n const builder = new SummaryTreeBuilder();\n let counter = 0;\n const blobs: string[] = [];\n\n const stack: [SubDirectory, IDirectoryDataObject][] = [];\n const content: IDirectoryDataObject = {};\n stack.push([root, content]);\n\n while (stack.length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const [currentSubDir, currentSubDirObject] = stack.pop()!;\n for (const [key, value] of currentSubDir.getSerializedStorage(serializer)) {\n if (!currentSubDirObject.storage) {\n currentSubDirObject.storage = {};\n }\n const result: ISerializableValue = {\n type: value.type,\n value: value.value && JSON.parse(value.value) as object,\n };\n if (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {\n const extraContent: IDirectoryDataObject = {};\n let largeContent = extraContent;\n if (currentSubDir.absolutePath !== posix.sep) {\n for (const dir of currentSubDir.absolutePath.slice(1).split(posix.sep)) {\n const subDataObject: IDirectoryDataObject = {};\n largeContent.subdirectories = { [dir]: subDataObject };\n largeContent = subDataObject;\n }\n }\n largeContent.storage = { [key]: result };\n const blobName = `blob${counter}`;\n counter++;\n blobs.push(blobName);\n builder.addBlob(blobName, JSON.stringify(extraContent));\n } else {\n currentSubDirObject.storage[key] = result;\n }\n }\n\n for (const [subdirName, subdir] of currentSubDir.subdirectories()) {\n if (!currentSubDirObject.subdirectories) {\n currentSubDirObject.subdirectories = {};\n }\n const subDataObject: IDirectoryDataObject = {};\n currentSubDirObject.subdirectories[subdirName] = subDataObject;\n stack.push([subdir as SubDirectory, subDataObject]);\n }\n }\n\n const newFormat: IDirectoryNewStorageFormat = {\n blobs,\n content,\n };\n builder.addBlob(snapshotFileName, JSON.stringify(newFormat));\n\n return builder.getSummaryTree();\n }\n}\n\ninterface IKeyEditLocalOpMetadata {\n type: \"edit\";\n pendingMessageId: number;\n previousValue: ILocalValue | undefined;\n}\n\ninterface IClearLocalOpMetadata {\n type: \"clear\";\n pendingMessageId: number;\n previousStorage: Map<string, ILocalValue>;\n}\n\ninterface ICreateSubDirLocalOpMetadata {\n type: \"createSubDir\";\n pendingMessageId: number;\n previouslyExisted: boolean;\n}\n\ninterface IDeleteSubDirLocalOpMetadata {\n type: \"deleteSubDir\";\n pendingMessageId: number;\n subDirectory: SubDirectory | undefined;\n}\n\ntype SubDirLocalOpMetadata = ICreateSubDirLocalOpMetadata | IDeleteSubDirLocalOpMetadata;\ntype DirectoryLocalOpMetadata = IClearLocalOpMetadata | IKeyEditLocalOpMetadata | SubDirLocalOpMetadata;\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\nfunction isKeyEditLocalOpMetadata(metadata: any): metadata is IKeyEditLocalOpMetadata {\n return metadata !== undefined && typeof metadata.pendingMessageId === \"number\" && metadata.type === \"edit\";\n}\n\nfunction isClearLocalOpMetadata(metadata: any): metadata is IClearLocalOpMetadata {\n return metadata !== undefined && metadata.type === \"clear\" && typeof metadata.pendingMessageId === \"number\" &&\n typeof metadata.previousStorage === \"object\";\n}\n\nfunction isSubDirLocalOpMetadata(metadata: any): metadata is SubDirLocalOpMetadata {\n return metadata !== undefined && typeof metadata.pendingMessageId === \"number\" &&\n ((metadata.type === \"createSubDir\" && typeof metadata.previouslyExisted === \"boolean\") ||\n metadata.type === \"deleteSubDir\");\n}\n\nfunction isDirectoryLocalOpMetadata(metadata: any): metadata is DirectoryLocalOpMetadata {\n return metadata !== undefined && typeof metadata.pendingMessageId === \"number\" &&\n (metadata.type === \"edit\" || metadata.type === \"deleteSubDir\" ||\n (metadata.type === \"clear\" && typeof metadata.previousStorage === \"object\") ||\n (metadata.type === \"createSubDir\" && typeof metadata.previouslyExisted === \"boolean\"));\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\n/**\n * Node of the directory tree.\n * @sealed\n */\nclass SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirectory {\n /**\n * Tells if the sub directory is deleted or not.\n */\n private _deleted = false;\n\n /**\n * String representation for the class.\n */\n public [Symbol.toStringTag]: string = \"SubDirectory\";\n\n /**\n * The in-memory data the directory is storing.\n */\n private readonly _storage: Map<string, ILocalValue> = new Map();\n\n /**\n * The subdirectories the directory is holding.\n */\n private readonly _subdirectories: Map<string, SubDirectory> = new Map();\n\n /**\n * Keys that have been modified locally but not yet ack'd from the server.\n */\n private readonly pendingKeys: Map<string, number[]> = new Map();\n\n /**\n * Subdirectories that have been modified locally but not yet ack'd from the server.\n */\n private readonly pendingSubDirectories: Map<string, number[]> = new Map();\n\n /**\n * This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.\n */\n private pendingMessageId: number = -1;\n\n /**\n * The pending ids of any clears that have been performed locally but not yet ack'd from the server\n */\n private readonly pendingClearMessageIds: number[] = [];\n\n /**\n * Constructor.\n * @param directory - Reference back to the SharedDirectory to perform operations\n * @param runtime - The data store runtime this directory is associated with\n * @param serializer - The serializer to serialize / parse handles\n * @param absolutePath - The absolute path of this IDirectory\n */\n public constructor(\n private readonly directory: SharedDirectory,\n private readonly runtime: IFluidDataStoreRuntime,\n private readonly serializer: IFluidSerializer,\n public readonly absolutePath: string,\n ) {\n super();\n }\n\n public dispose(error?: Error): void {\n this._deleted = true;\n this.emit(\"disposed\", this);\n }\n\n /**\n * Unmark the deleted property only when rolling back delete.\n */\n private undispose(): void {\n this._deleted = false;\n this.emit(\"undisposed\", this);\n }\n\n public get disposed(): boolean {\n return this._deleted;\n }\n\n private throwIfDisposed(): void {\n if (this._deleted) {\n throw new UsageError(\"Cannot access Disposed subDirectory\");\n }\n }\n\n /**\n * Checks whether the given key exists in this IDirectory.\n * @param key - The key to check\n * @returns True if the key exists, false otherwise\n */\n public has(key: string): boolean {\n this.throwIfDisposed();\n return this._storage.has(key);\n }\n\n /**\n * {@inheritDoc IDirectory.get}\n */\n public get<T = unknown>(key: string): T | undefined {\n this.throwIfDisposed();\n return this._storage.get(key)?.value as T | undefined;\n }\n\n /**\n * {@inheritDoc IDirectory.set}\n */\n public set<T = unknown>(key: string, value: T): this {\n this.throwIfDisposed();\n // Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.\n if (key === undefined || key === null) {\n throw new Error(\"Undefined and null keys are not supported\");\n }\n\n // Create a local value and serialize it.\n const localValue = this.directory.localValueMaker.fromInMemory(value);\n const serializableValue = makeSerializable(\n localValue,\n this.serializer,\n this.directory.handle);\n\n // Set the value locally.\n const previousValue = this.setCore(\n key,\n localValue,\n true,\n );\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return this;\n }\n\n const op: IDirectorySetOperation = {\n key,\n path: this.absolutePath,\n type: \"set\",\n value: serializableValue,\n };\n this.submitKeyMessage(op, previousValue);\n return this;\n }\n\n /**\n * {@inheritDoc IDirectory.countSubDirectory}\n */\n public countSubDirectory(): number {\n return this._subdirectories.size;\n }\n\n /**\n * {@inheritDoc IDirectory.createSubDirectory}\n */\n public createSubDirectory(subdirName: string): IDirectory {\n this.throwIfDisposed();\n // Undefined/null subdirectory names can't be serialized to JSON in the manner we currently snapshot.\n if (subdirName === undefined || subdirName === null) {\n throw new Error(\"SubDirectory name may not be undefined or null\");\n }\n\n if (subdirName.includes(posix.sep)) {\n throw new Error(`SubDirectory name may not contain ${posix.sep}`);\n }\n\n // Create the sub directory locally first.\n const isNew = this.createSubDirectoryCore(subdirName, true);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const subDir: IDirectory = this._subdirectories.get(subdirName)!;\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return subDir;\n }\n\n const op: IDirectoryCreateSubDirectoryOperation = {\n path: this.absolutePath,\n subdirName,\n type: \"createSubDirectory\",\n };\n this.submitCreateSubDirectoryMessage(op, !isNew);\n\n return subDir;\n }\n\n /**\n * {@inheritDoc IDirectory.getSubDirectory}\n */\n public getSubDirectory(subdirName: string): IDirectory | undefined {\n this.throwIfDisposed();\n return this._subdirectories.get(subdirName);\n }\n\n /**\n * {@inheritDoc IDirectory.hasSubDirectory}\n */\n public hasSubDirectory(subdirName: string): boolean {\n this.throwIfDisposed();\n return this._subdirectories.has(subdirName);\n }\n\n /**\n * {@inheritDoc IDirectory.deleteSubDirectory}\n */\n public deleteSubDirectory(subdirName: string): boolean {\n this.throwIfDisposed();\n // Delete the sub directory locally first.\n const subDir = this.deleteSubDirectoryCore(subdirName, true);\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return subDir !== undefined;\n }\n\n const op: IDirectoryDeleteSubDirectoryOperation = {\n path: this.absolutePath,\n subdirName,\n type: \"deleteSubDirectory\",\n };\n\n this.submitDeleteSubDirectoryMessage(op, subDir);\n return subDir !== undefined;\n }\n\n /**\n * {@inheritDoc IDirectory.subdirectories}\n */\n public subdirectories(): IterableIterator<[string, IDirectory]> {\n this.throwIfDisposed();\n return this._subdirectories.entries();\n }\n\n /**\n * {@inheritDoc IDirectory.getWorkingDirectory}\n */\n public getWorkingDirectory(relativePath: string): IDirectory | undefined {\n this.throwIfDisposed();\n return this.directory.getWorkingDirectory(this.makeAbsolute(relativePath));\n }\n\n /**\n * Deletes the given key from within this IDirectory.\n * @param key - The key to delete\n * @returns True if the key existed and was deleted, false if it did not exist\n */\n public delete(key: string): boolean {\n this.throwIfDisposed();\n // Delete the key locally first.\n const previousValue = this.deleteCore(key, true);\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return previousValue !== undefined;\n }\n\n const op: IDirectoryDeleteOperation = {\n key,\n path: this.absolutePath,\n type: \"delete\",\n };\n\n this.submitKeyMessage(op, previousValue);\n return previousValue !== undefined;\n }\n\n /**\n * Deletes all keys from within this IDirectory.\n */\n public clear(): void {\n this.throwIfDisposed();\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n this.clearCore(true);\n return;\n }\n\n const copy = new Map<string, ILocalValue>(this._storage);\n this.clearCore(true);\n const op: IDirectoryClearOperation = {\n path: this.absolutePath,\n type: \"clear\",\n };\n this.submitClearMessage(op, copy);\n }\n\n /**\n * Issue a callback on each entry under this IDirectory.\n * @param callback - Callback to issue\n */\n public forEach(callback: (value: unknown, key: string, map: Map<string, unknown>) => void): void {\n this.throwIfDisposed();\n // eslint-disable-next-line unicorn/no-array-for-each\n this._storage.forEach((localValue, key, map) => {\n callback(localValue.value, key, map);\n });\n }\n\n /**\n * The number of entries under this IDirectory.\n */\n public get size(): number {\n this.throwIfDisposed();\n return this._storage.size;\n }\n\n /**\n * Get an iterator over the entries under this IDirectory.\n * @returns The iterator\n */\n public entries(): IterableIterator<[string, unknown]> {\n this.throwIfDisposed();\n const localEntriesIterator = this._storage.entries();\n const iterator = {\n next(): IteratorResult<[string, unknown]> {\n const nextVal = localEntriesIterator.next();\n return nextVal.done\n ? { value: undefined, done: true }\n : { value: [nextVal.value[0], nextVal.value[1].value], done: false };\n },\n [Symbol.iterator](): IterableIterator<[string, unknown]> {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the keys under this IDirectory.\n * @returns The iterator\n */\n public keys(): IterableIterator<string> {\n this.throwIfDisposed();\n return this._storage.keys();\n }\n\n /**\n * Get an iterator over the values under this IDirectory.\n * @returns The iterator\n */\n public values(): IterableIterator<unknown> {\n this.throwIfDisposed();\n const localValuesIterator = this._storage.values();\n const iterator = {\n next(): IteratorResult<unknown> {\n const nextVal = localValuesIterator.next();\n return nextVal.done\n ? { value: undefined, done: true }\n : { value: nextVal.value.value, done: false };\n },\n [Symbol.iterator](): IterableIterator<unknown> {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the entries under this IDirectory.\n * @returns The iterator\n */\n public [Symbol.iterator](): IterableIterator<[string, unknown]> {\n this.throwIfDisposed();\n return this.entries();\n }\n\n /**\n * Process a clear operation.\n * @param op - The op to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @internal\n */\n public processClearMessage(\n op: IDirectoryClearOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (local) {\n assert(isClearLocalOpMetadata(localOpMetadata),\n 0x00f /* pendingMessageId is missing from the local client's operation */);\n const pendingClearMessageId = this.pendingClearMessageIds.shift();\n assert(pendingClearMessageId === localOpMetadata.pendingMessageId,\n 0x32a /* pendingMessageId does not match */);\n return;\n }\n this.clearExceptPendingKeys(false);\n }\n\n /**\n * Apply clear operation locally and generate metadata\n * @param op - Op to apply\n * @returns metadata generated for stahed op\n */\n public applyStashedClearMessage(op: IDirectoryClearOperation): IClearLocalOpMetadata {\n this.throwIfDisposed();\n const previousValue = new Map<string, ILocalValue>(this._storage);\n this.clearExceptPendingKeys(true);\n const pendingMsgId = ++this.pendingMessageId;\n this.pendingClearMessageIds.push(pendingMsgId);\n const metadata: IClearLocalOpMetadata = {\n type: \"clear\",\n pendingMessageId: pendingMsgId,\n previousStorage: previousValue,\n };\n return metadata;\n }\n\n /**\n * Process a delete operation.\n * @param op - The op to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @internal\n */\n public processDeleteMessage(\n op: IDirectoryDeleteOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {\n return;\n }\n this.deleteCore(op.key, local);\n }\n\n /**\n * Apply delete operation locally and generate metadata\n * @param op - Op to apply\n * @returns metadata generated for stahed op\n */\n public applyStashedDeleteMessage(op: IDirectoryDeleteOperation): IKeyEditLocalOpMetadata {\n this.throwIfDisposed();\n const previousValue = this.deleteCore(op.key, true);\n const pendingMessageId = this.getKeyMessageId(op);\n const localMetadata: IKeyEditLocalOpMetadata = { type: \"edit\", pendingMessageId, previousValue };\n return localMetadata;\n }\n\n /**\n * Process a set operation.\n * @param op - The op to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @internal\n */\n public processSetMessage(\n op: IDirectorySetOperation,\n context: ILocalValue | undefined,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {\n return;\n }\n\n // needProcessStorageOperation should have returned false if local is true\n // so we can assume context is not undefined\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.setCore(op.key, context!, local);\n }\n\n /**\n * Apply set operation locally and generate metadata\n * @param op - Op to apply\n * @returns metadata generated for stahed op\n */\n public applyStashedSetMessage(op: IDirectorySetOperation, context: ILocalValue): IKeyEditLocalOpMetadata {\n this.throwIfDisposed();\n // Set the value locally.\n const previousValue = this.setCore(\n op.key,\n context,\n true,\n );\n\n // Create metadata\n const pendingMessageId = this.getKeyMessageId(op);\n const localMetadata: IKeyEditLocalOpMetadata = { type: \"edit\", pendingMessageId, previousValue };\n return localMetadata;\n }\n /**\n * Process a create subdirectory operation.\n * @param op - The op to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @internal\n */\n public processCreateSubDirectoryMessage(\n op: IDirectoryCreateSubDirectoryOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (!this.needProcessSubDirectoryOperation(op, local, localOpMetadata)) {\n return;\n }\n this.createSubDirectoryCore(op.subdirName, local);\n }\n\n /**\n * Apply createSubDirectory operation locally and generate metadata\n * @param op - Op to apply\n * @returns metadata generated for stahed op\n */\n public applyStashedCreateSubDirMessage(op: IDirectoryCreateSubDirectoryOperation):\n ICreateSubDirLocalOpMetadata {\n this.throwIfDisposed();\n // Create the sub directory locally first.\n const isNew = this.createSubDirectoryCore(op.subdirName, true);\n const newMessageId = this.getSubDirMessageId(op);\n\n const localOpMetadata: ICreateSubDirLocalOpMetadata = {\n type: \"createSubDir\",\n pendingMessageId: newMessageId,\n previouslyExisted: !isNew,\n };\n return localOpMetadata;\n }\n\n /**\n * Process a delete subdirectory operation.\n * @param op - The op to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @internal\n */\n public processDeleteSubDirectoryMessage(\n op: IDirectoryDeleteSubDirectoryOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (!this.needProcessSubDirectoryOperation(op, local, localOpMetadata)) {\n return;\n }\n this.deleteSubDirectoryCore(op.subdirName, local);\n }\n\n /**\n * Apply deleteSubDirectory operation locally and generate metadata\n * @param op - Op to apply\n * @returns metadata generated for stahed op\n */\n public applyStashedDeleteSubDirMessage(op: IDirectoryDeleteSubDirectoryOperation): IDeleteSubDirLocalOpMetadata {\n this.throwIfDisposed();\n const subDir = this.deleteSubDirectoryCore(op.subdirName, true);\n const newMessageId = this.getSubDirMessageId(op);\n const metadata: IDeleteSubDirLocalOpMetadata = {\n type: \"deleteSubDir\",\n pendingMessageId: newMessageId,\n subDirectory: subDir,\n };\n return metadata;\n }\n\n /**\n * Submit a clear operation.\n * @param op - The operation\n */\n private submitClearMessage(op: IDirectoryClearOperation,\n previousValue: Map<string, ILocalValue>): void {\n this.throwIfDisposed();\n const pendingMsgId = ++this.pendingMessageId;\n this.pendingClearMessageIds.push(pendingMsgId);\n const metadata: IClearLocalOpMetadata = {\n type: \"clear\",\n pendingMessageId: pendingMsgId,\n previousStorage: previousValue,\n };\n this.directory.submitDirectoryMessage(op, metadata);\n }\n\n /**\n * Resubmit a clear operation.\n * @param op - The operation\n * @internal\n */\n public resubmitClearMessage(op: IDirectoryClearOperation, localOpMetadata: unknown): void {\n assert(isClearLocalOpMetadata(localOpMetadata), 0x32b /* Invalid localOpMetadata for clear */);\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const pendingClearMessageId = this.pendingClearMessageIds.shift();\n assert(pendingClearMessageId === localOpMetadata.pendingMessageId,\n 0x32c /* pendingMessageId does not match */);\n this.submitClearMessage(op, localOpMetadata.previousStorage);\n }\n\n /**\n * Get a new pending message id for the op and cache it to track the pending op\n */\n private getKeyMessageId(op: IDirectoryKeyOperation): number {\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const pendingMessageId = ++this.pendingMessageId;\n const pendingMessageIds = this.pendingKeys.get(op.key);\n if (pendingMessageIds !== undefined) {\n pendingMessageIds.push(pendingMessageId);\n } else {\n this.pendingKeys.set(op.key, [pendingMessageId]);\n }\n return pendingMessageId;\n }\n\n /**\n * Submit a key operation.\n * @param op - The operation\n * @param previousValue - The value of the key before this op\n */\n private submitKeyMessage(op: IDirectoryKeyOperation, previousValue?: ILocalValue): void {\n this.throwIfDisposed();\n const pendingMessageId = this.getKeyMessageId(op);\n const localMetadata = { type: \"edit\", pendingMessageId, previousValue };\n this.directory.submitDirectoryMessage(op, localMetadata);\n }\n\n /**\n * Submit a key message to remote clients based on a previous submit.\n * @param op - The map key message\n * @param localOpMetadata - Metadata from the previous submit\n * @internal\n */\n public resubmitKeyMessage(op: IDirectoryKeyOperation, localOpMetadata: unknown): void {\n assert(isKeyEditLocalOpMetadata(localOpMetadata), 0x32d /* Invalid localOpMetadata in submit */);\n\n // clear the old pending message id\n const pendingMessageIds = this.pendingKeys.get(op.key);\n assert(pendingMessageIds !== undefined && pendingMessageIds[0] === localOpMetadata.pendingMessageId,\n 0x32e /* Unexpected pending message received */);\n pendingMessageIds.shift();\n if (pendingMessageIds.length === 0) {\n this.pendingKeys.delete(op.key);\n }\n\n this.submitKeyMessage(op, localOpMetadata.previousValue);\n }\n\n /**\n * Get a new pending message id for the op and cache it to track the pending op\n */\n private getSubDirMessageId(op: IDirectorySubDirectoryOperation): number {\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const newMessageId = ++this.pendingMessageId;\n const pendingMessageIds = this.pendingSubDirectories.get(op.subdirName);\n if (pendingMessageIds !== undefined) {\n pendingMessageIds.push(newMessageId);\n } else {\n this.pendingSubDirectories.set(op.subdirName, [newMessageId]);\n }\n return newMessageId;\n }\n\n /**\n * Submit a create subdirectory operation.\n * @param op - The operation\n * @param prevExisted - Whether the subdirectory existed before the op\n */\n private submitCreateSubDirectoryMessage(op: IDirectorySubDirectoryOperation,\n prevExisted: boolean): void {\n this.throwIfDisposed();\n const newMessageId = this.getSubDirMessageId(op);\n\n const localOpMetadata: ICreateSubDirLocalOpMetadata = {\n type: \"createSubDir\",\n pendingMessageId: newMessageId,\n previouslyExisted: prevExisted,\n };\n this.directory.submitDirectoryMessage(op, localOpMetadata);\n }\n\n /**\n * Submit a delete subdirectory operation.\n * @param op - The operation\n * @param subDir - Any subdirectory deleted by the op\n */\n private submitDeleteSubDirectoryMessage(op: IDirectorySubDirectoryOperation,\n subDir: SubDirectory | undefined): void {\n this.throwIfDisposed();\n const newMessageId = this.getSubDirMessageId(op);\n\n const localOpMetadata: IDeleteSubDirLocalOpMetadata = {\n type: \"deleteSubDir\",\n pendingMessageId: newMessageId,\n subDirectory: subDir,\n };\n this.directory.submitDirectoryMessage(op, localOpMetadata);\n }\n\n /**\n * Submit a subdirectory operation again\n * @param op - The operation\n * @param localOpMetadata - metadata submitted with the op originally\n * @internal\n */\n public resubmitSubDirectoryMessage(op: IDirectorySubDirectoryOperation, localOpMetadata: unknown): void {\n assert(isSubDirLocalOpMetadata(localOpMetadata), 0x32f /* Invalid localOpMetadata for sub directory op */);\n\n // clear the old pending message id\n const pendingMessageIds = this.pendingSubDirectories.get(op.subdirName);\n assert(pendingMessageIds !== undefined && pendingMessageIds[0] === localOpMetadata.pendingMessageId,\n 0x330 /* Unexpected pending message received */);\n pendingMessageIds.shift();\n if (pendingMessageIds.length === 0) {\n this.pendingSubDirectories.delete(op.subdirName);\n }\n\n if (localOpMetadata.type === \"createSubDir\") {\n this.submitCreateSubDirectoryMessage(op, localOpMetadata.previouslyExisted);\n } else {\n this.submitDeleteSubDirectoryMessage(op, localOpMetadata.subDirectory);\n }\n }\n\n /**\n * Get the storage of this subdirectory in a serializable format, to be used in snapshotting.\n * @param serializer - The serializer to use to serialize handles in its values.\n * @returns The JSONable string representing the storage of this subdirectory\n * @internal\n */\n public *getSerializedStorage(serializer: IFluidSerializer): Generator<[string, ISerializedValue], void> {\n this.throwIfDisposed();\n for (const [key, localValue] of this._storage) {\n const value = localValue.makeSerialized(serializer, this.directory.handle);\n const res: [string, ISerializedValue] = [key, value];\n yield res;\n }\n }\n\n /**\n * Populate a key value in this subdirectory's storage, to be used when loading from snapshot.\n * @param key - The key to populate\n * @param localValue - The local value to populate into it\n * @internal\n */\n public populateStorage(key: string, localValue: ILocalValue): void {\n this.throwIfDisposed();\n this._storage.set(key, localValue);\n }\n\n /**\n * Populate a subdirectory into this subdirectory, to be used when loading from snapshot.\n * @param subdirName - The name of the subdirectory to add\n * @param newSubDir - The new subdirectory to add\n * @internal\n */\n public populateSubDirectory(subdirName: string, newSubDir: SubDirectory): void {\n this.throwIfDisposed();\n this._subdirectories.set(subdirName, newSubDir);\n }\n\n /**\n * Retrieve the local value at the given key. This is used to get value type information stashed on the local\n * value so op handlers can be retrieved\n * @param key - The key to retrieve from\n * @returns The local value\n * @internal\n */\n public getLocalValue<T extends ILocalValue = ILocalValue>(key: string): T {\n this.throwIfDisposed();\n return this._storage.get(key) as T;\n }\n\n /**\n * Remove the pendingMessageId from the map tracking it on rollback\n * @param map - map tracking the pending messages\n * @param key - key of the edit in the op\n */\n private rollbackPendingMessageId(map: Map<string, number[]>, key: string, pendingMessageId): void {\n const pendingMessageIds = map.get(key);\n const lastPendingMessageId = pendingMessageIds?.pop();\n if (!pendingMessageIds || lastPendingMessageId !== pendingMessageId) {\n throw new Error(\"Rollback op does not match last pending\");\n }\n if (pendingMessageIds.length === 0) {\n map.delete(key);\n }\n }\n\n /* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\n /**\n * Rollback a local op\n * @param op - The operation to rollback\n * @param localOpMetadata - The local metadata associated with the op.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public rollback(op: any, localOpMetadata: unknown): void {\n if (!isDirectoryLocalOpMetadata(localOpMetadata)) {\n throw new Error(\"Invalid localOpMetadata\");\n }\n\n if (op.type === \"clear\" && localOpMetadata.type === \"clear\") {\n for (const [key, localValue] of localOpMetadata.previousStorage.entries()) {\n this.setCore(key, localValue, true);\n }\n\n const lastPendingClearId = this.pendingClearMessageIds.pop();\n if (lastPendingClearId === undefined || lastPendingClearId !== localOpMetadata.pendingMessageId) {\n throw new Error(\"Rollback op does match last clear\");\n }\n } else if ((op.type === \"delete\" || op.type === \"set\") && localOpMetadata.type === \"edit\") {\n if (localOpMetadata.previousValue === undefined) {\n this.deleteCore(op.key as string, true);\n } else {\n this.setCore(op.key as string, localOpMetadata.previousValue, true);\n }\n\n this.rollbackPendingMessageId(this.pendingKeys, op.key as string, localOpMetadata.pendingMessageId);\n } else if (op.type === \"createSubDirectory\" && localOpMetadata.type === \"createSubDir\") {\n if (!localOpMetadata.previouslyExisted) {\n this.deleteSubDirectoryCore(op.subdirName as string, true);\n }\n\n this.rollbackPendingMessageId(\n this.pendingSubDirectories,\n op.subdirName as string,\n localOpMetadata.pendingMessageId\n );\n } else if (op.type === \"deleteSubDirectory\" && localOpMetadata.type === \"deleteSubDir\") {\n if (localOpMetadata.subDirectory !== undefined) {\n this.undeleteSubDirectoryTree(localOpMetadata.subDirectory);\n // don't need to register events because deleting never unregistered\n this._subdirectories.set(op.subdirName as string, localOpMetadata.subDirectory);\n this.emit(\"subDirectoryCreated\", op.subdirName, true, this);\n }\n\n this.rollbackPendingMessageId(\n this.pendingSubDirectories,\n op.subdirName as string,\n localOpMetadata.pendingMessageId\n );\n } else {\n throw new Error(\"Unsupported op for rollback\");\n }\n }\n\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n\n /**\n * Converts the given relative path into an absolute path.\n * @param path - Relative path to convert\n * @returns The equivalent absolute path\n */\n private makeAbsolute(relativePath: string): string {\n return posix.resolve(this.absolutePath, relativePath);\n }\n\n /**\n * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should\n * not process the incoming operation.\n * @param op - Operation to check\n * @param local - Whether the operation originated from the local client\n * @param localOpMetadata - For local client ops, this is the metadata that was submitted with the op.\n * For ops from a remote client, this will be undefined.\n * @returns True if the operation should be processed, false otherwise\n */\n private needProcessStorageOperation(\n op: IDirectoryKeyOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): boolean {\n if (this.pendingClearMessageIds.length > 0) {\n if (local) {\n assert(localOpMetadata !== undefined && isKeyEditLocalOpMetadata(localOpMetadata) &&\n localOpMetadata.pendingMessageId < this.pendingClearMessageIds[0],\n 0x010 /* \"Received out of order storage op when there is an unackd clear message\" */);\n }\n // If I have a NACK clear, we can ignore all ops.\n return false;\n }\n\n const pendingKeyMessageId = this.pendingKeys.get(op.key);\n if (pendingKeyMessageId !== undefined) {\n // Found an NACK op, clear it from the directory if the latest sequence number in the directory\n // match the message's and don't process the op.\n if (local) {\n assert(localOpMetadata !== undefined && isKeyEditLocalOpMetadata(localOpMetadata),\n 0x011 /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageIds = this.pendingKeys.get(op.key);\n assert(pendingMessageIds !== undefined && pendingMessageIds[0] === localOpMetadata.pendingMessageId,\n 0x331 /* Unexpected pending message received */);\n pendingMessageIds.shift();\n if (pendingMessageIds.length === 0) {\n this.pendingKeys.delete(op.key);\n }\n }\n return false;\n }\n\n // If we don't have a NACK op on the key, we need to process the remote ops.\n return !local;\n }\n\n /**\n * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should\n * not process the incoming operation.\n * @param op - Operation to check\n * @param local - Whether the message originated from the local client\n * @param message - The message\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @returns True if the operation should be processed, false otherwise\n */\n private needProcessSubDirectoryOperation(\n op: IDirectorySubDirectoryOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): boolean {\n const pendingSubDirectoryMessageId = this.pendingSubDirectories.get(op.subdirName);\n if (pendingSubDirectoryMessageId !== undefined) {\n if (local) {\n assert(isSubDirLocalOpMetadata(localOpMetadata),\n 0x012 /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageIds = this.pendingSubDirectories.get(op.subdirName);\n assert(pendingMessageIds !== undefined && pendingMessageIds[0] === localOpMetadata.pendingMessageId,\n 0x332 /* Unexpected pending message received */);\n pendingMessageIds.shift();\n if (pendingMessageIds.length === 0) {\n this.pendingSubDirectories.delete(op.subdirName);\n }\n }\n return false;\n }\n\n return !local;\n }\n\n /**\n * Clear all keys in memory in response to a remote clear, but retain keys we have modified but not yet been ack'd.\n */\n private clearExceptPendingKeys(local: boolean): void {\n // Assuming the pendingKeys is small and the map is large\n // we will get the value for the pendingKeys and clear the map\n const temp = new Map<string, ILocalValue>();\n\n for (const [key] of this.pendingKeys) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n temp.set(key, this._storage.get(key)!);\n }\n\n this.clearCore(local);\n\n for (const [key, value] of temp.entries()) {\n this.setCore(key, value, true);\n }\n }\n\n /**\n * Clear implementation used for both locally sourced clears as well as incoming remote clears.\n * @param local - Whether the message originated from the local client\n */\n private clearCore(local: boolean): void {\n this._storage.clear();\n this.directory.emit(\"clear\", local, this.directory);\n }\n\n /**\n * Delete implementation used for both locally sourced deletes as well as incoming remote deletes.\n * @param key - The key being deleted\n * @param local - Whether the message originated from the local client\n * @returns Previous local value of the key if it existed, undefined if it did not exist\n */\n private deleteCore(key: string, local: boolean): ILocalValue | undefined {\n const previousLocalValue = this._storage.get(key);\n const previousValue: unknown = previousLocalValue?.value;\n const successfullyRemoved = this._storage.delete(key);\n if (successfullyRemoved) {\n const event: IDirectoryValueChanged = { key, path: this.absolutePath, previousValue };\n this.directory.emit(\"valueChanged\", event, local, this.directory);\n const containedEvent: IValueChanged = { key, previousValue };\n this.emit(\"containedValueChanged\", containedEvent, local, this);\n }\n return previousLocalValue;\n }\n\n /**\n * Set implementation used for both locally sourced sets as well as incoming remote sets.\n * @param key - The key being set\n * @param value - The value being set\n * @param local - Whether the message originated from the local client\n * @returns Previous local value of the key, if any\n */\n private setCore(key: string, value: ILocalValue, local: boolean): ILocalValue | undefined {\n const previousLocalValue = this._storage.get(key);\n const previousValue: unknown = previousLocalValue?.value;\n this._storage.set(key, value);\n const event: IDirectoryValueChanged = { key, path: this.absolutePath, previousValue };\n this.directory.emit(\"valueChanged\", event, local, this.directory);\n const containedEvent: IValueChanged = { key, previousValue };\n this.emit(\"containedValueChanged\", containedEvent, local, this);\n return previousLocalValue;\n }\n\n /**\n * Create subdirectory implementation used for both locally sourced creation as well as incoming remote creation.\n * @param subdirName - The name of the subdirectory being created\n * @param local - Whether the message originated from the local client\n * @returns - True if is newly created, false if it already existed.\n */\n private createSubDirectoryCore(subdirName: string, local: boolean): boolean {\n if (!this._subdirectories.has(subdirName)) {\n const absolutePath = posix.join(this.absolutePath, subdirName);\n const subDir = new SubDirectory(this.directory, this.runtime, this.serializer, absolutePath);\n this.registerEventsOnSubDirectory(subDir, subdirName);\n this._subdirectories.set(subdirName, subDir);\n this.emit(\"subDirectoryCreated\", subdirName, local, this);\n return true;\n }\n return false;\n }\n\n private registerEventsOnSubDirectory(subDirectory: SubDirectory, subDirName: string): void {\n subDirectory.on(\"subDirectoryCreated\", (relativePath: string, local: boolean) => {\n this.emit(\"subDirectoryCreated\", posix.join(subDirName, relativePath), local, this);\n });\n subDirectory.on(\"subDirectoryDeleted\", (relativePath: string, local: boolean) => {\n this.emit(\"subDirectoryDeleted\", posix.join(subDirName, relativePath), local, this);\n });\n }\n\n /**\n * Delete subdirectory implementation used for both locally sourced creation as well as incoming remote creation.\n * @param subdirName - The name of the subdirectory being deleted\n * @param local - Whether the message originated from the local client\n */\n private deleteSubDirectoryCore(subdirName: string, local: boolean): SubDirectory | undefined {\n const previousValue = this._subdirectories.get(subdirName);\n // This should make the subdirectory structure unreachable so it can be GC'd and won't appear in snapshots\n // Might want to consider cleaning out the structure more exhaustively though? But not when rollback.\n if (previousValue !== undefined) {\n this._subdirectories.delete(subdirName);\n this.disposeSubDirectoryTree(previousValue);\n this.emit(\"subDirectoryDeleted\", subdirName, local, this);\n }\n return previousValue;\n }\n\n private disposeSubDirectoryTree(directory: IDirectory | undefined): void {\n if (!directory) {\n return;\n }\n // Dispose the subdirectory tree. This will dispose the subdirectories from bottom to top.\n const subDirectories = directory.subdirectories();\n for (const [_, subDirectory] of subDirectories) {\n this.disposeSubDirectoryTree(subDirectory);\n }\n if (typeof directory.dispose === \"function\") {\n directory.dispose();\n }\n }\n\n private undeleteSubDirectoryTree(directory: SubDirectory): void {\n // Restore deleted subdirectory tree. This will unmark \"deleted\" from the subdirectories from bottom to top.\n for (const [_, subDirectory] of this._subdirectories.entries()) {\n this.undeleteSubDirectoryTree(subDirectory);\n }\n directory.undispose();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;AAEH,+DAAyE;AACzE,qEAA6D;AAC7D,+DAA4D;AAC5D,+EAA8F;AAS9F,2EAA+F;AAC/F,iEAAmE;AACnE,sDAAwC;AAWxC,+CAA+E;AAC/E,qDAA8C;AAE9C,sFAAsF;AACtF,oDAAoD;AACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;AAEzB,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAwLlC;;;;GAIG;AACH,MAAa,gBAAgB;IAe5B;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,gBAAgB,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC/D,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE/B,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,EAAE,EAAE,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAChF,SAAS,CAAC,eAAe,EAAE,CAAC;QAE5B,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D,SAAS,CAAC,SAAS,EAAE,CAAC;IACvB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelServices,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\nimport { IFluidSerializer, SharedObject, ValueType } from \"@fluidframework/shared-object-base\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport * as path from \"path-browserify\";\nimport {\n\tIDirectory,\n\tIDirectoryEvents,\n\tIDirectoryValueChanged,\n\tISerializableValue,\n\tISerializedValue,\n\tISharedDirectory,\n\tISharedDirectoryEvents,\n\tIValueChanged,\n} from \"./interfaces\";\nimport { ILocalValue, LocalValueMaker, makeSerializable } from \"./localValues\";\nimport { pkgVersion } from \"./packageVersion\";\n\n// We use path-browserify since this code can run safely on the server or the browser.\n// We standardize on using posix slashes everywhere.\nconst posix = path.posix;\n\nconst snapshotFileName = \"header\";\n\n/**\n * Defines the means to process and submit a given op on a directory.\n */\ninterface IDirectoryMessageHandler {\n\t/**\n\t * Apply the given operation.\n\t * @param op - The directory operation to apply\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprocess(op: IDirectoryOperation, local: boolean, localOpMetadata: unknown): void;\n\n\t/**\n\t * Communicate the operation to remote clients.\n\t * @param op - The directory operation to submit\n\t * @param localOpMetadata - The metadata to be submitted with the message.\n\t */\n\tsubmit(op: IDirectoryOperation, localOpMetadata: unknown): void;\n\n\tapplyStashedOp(op: IDirectoryOperation): unknown;\n}\n\n/**\n * Operation indicating a value should be set for a key.\n */\nexport interface IDirectorySetOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"set\";\n\n\t/**\n\t * Directory key being modified.\n\t */\n\tkey: string;\n\n\t/**\n\t * Absolute path of the directory where the modified key is located.\n\t */\n\tpath: string;\n\n\t/**\n\t * Value to be set on the key.\n\t */\n\tvalue: ISerializableValue;\n}\n\n/**\n * Operation indicating a key should be deleted from the directory.\n */\nexport interface IDirectoryDeleteOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"delete\";\n\n\t/**\n\t * Directory key being modified.\n\t */\n\tkey: string;\n\n\t/**\n\t * Absolute path of the directory where the modified key is located.\n\t */\n\tpath: string;\n}\n\n/**\n * An operation on a specific key within a directory\n */\nexport type IDirectoryKeyOperation = IDirectorySetOperation | IDirectoryDeleteOperation;\n\n/**\n * Operation indicating the directory should be cleared.\n */\nexport interface IDirectoryClearOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"clear\";\n\n\t/**\n\t * Absolute path of the directory being cleared.\n\t */\n\tpath: string;\n}\n\n/**\n * An operation on one or more of the keys within a directory\n */\nexport type IDirectoryStorageOperation = IDirectoryKeyOperation | IDirectoryClearOperation;\n\n/**\n * Operation indicating a subdirectory should be created.\n */\nexport interface IDirectoryCreateSubDirectoryOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"createSubDirectory\";\n\n\t/**\n\t * Absolute path of the directory that will contain the new subdirectory.\n\t */\n\tpath: string;\n\n\t/**\n\t * Name of the new subdirectory.\n\t */\n\tsubdirName: string;\n}\n\n/**\n * Operation indicating a subdirectory should be deleted.\n */\nexport interface IDirectoryDeleteSubDirectoryOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"deleteSubDirectory\";\n\n\t/**\n\t * Absolute path of the directory that contains the directory to be deleted.\n\t */\n\tpath: string;\n\n\t/**\n\t * Name of the subdirectory to be deleted.\n\t */\n\tsubdirName: string;\n}\n\n/**\n * An operation on the subdirectories within a directory\n */\nexport type IDirectorySubDirectoryOperation =\n\t| IDirectoryCreateSubDirectoryOperation\n\t| IDirectoryDeleteSubDirectoryOperation;\n\n/**\n * Any operation on a directory\n */\nexport type IDirectoryOperation = IDirectoryStorageOperation | IDirectorySubDirectoryOperation;\n\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n *\n * @remarks Directly used in\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\n * | JSON.stringify}, direct result from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.\n */\nexport interface IDirectoryDataObject {\n\t/**\n\t * Key/value date set by the user.\n\t */\n\tstorage?: { [key: string]: ISerializableValue };\n\n\t/**\n\t * Recursive sub-directories {@link IDirectoryDataObject | objects}.\n\t */\n\tsubdirectories?: { [subdirName: string]: IDirectoryDataObject };\n}\n\n/**\n * {@link IDirectory} storage format.\n *\n * @internal\n */\nexport interface IDirectoryNewStorageFormat {\n\t/**\n\t * Blob IDs representing larger directory data that was serialized.\n\t */\n\tblobs: string[];\n\n\t/**\n\t * Storage content representing directory data that was not serialized.\n\t */\n\tcontent: IDirectoryDataObject;\n}\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedDirectory}.\n *\n * @sealed\n */\nexport class DirectoryFactory implements IChannelFactory {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/directory\";\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: DirectoryFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn DirectoryFactory.Type;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn DirectoryFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedDirectory> {\n\t\tconst directory = new SharedDirectory(id, runtime, attributes);\n\t\tawait directory.load(services);\n\n\t\treturn directory;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): ISharedDirectory {\n\t\tconst directory = new SharedDirectory(id, runtime, DirectoryFactory.Attributes);\n\t\tdirectory.initializeLocal();\n\n\t\treturn directory;\n\t}\n}\n\n/**\n * {@inheritDoc ISharedDirectory}\n *\n * @example\n * ```typescript\n * mySharedDirectory.createSubDirectory(\"a\").createSubDirectory(\"b\").createSubDirectory(\"c\").set(\"foo\", val1);\n * const mySubDir = mySharedDirectory.getWorkingDirectory(\"/a/b/c\");\n * mySubDir.get(\"foo\"); // returns val1\n * ```\n *\n * @sealed\n */\nexport class SharedDirectory\n\textends SharedObject<ISharedDirectoryEvents>\n\timplements ISharedDirectory\n{\n\t/**\n\t * Create a new shared directory\n\t *\n\t * @param runtime - Data store runtime the new shared directory belongs to\n\t * @param id - Optional name of the shared directory\n\t * @returns Newly create shared directory (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedDirectory {\n\t\treturn runtime.createChannel(id, DirectoryFactory.Type) as SharedDirectory;\n\t}\n\n\t/**\n\t * Get a factory for SharedDirectory to register with the data store.\n\t *\n\t * @returns A factory that creates and load SharedDirectory\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new DirectoryFactory();\n\t}\n\n\t/**\n\t * String representation for the class.\n\t */\n\tpublic [Symbol.toStringTag]: string = \"SharedDirectory\";\n\n\t/**\n\t * {@inheritDoc IDirectory.absolutePath}\n\t */\n\tpublic get absolutePath(): string {\n\t\treturn this.root.absolutePath;\n\t}\n\n\t/**\n\t * @internal\n\t */\n\tpublic readonly localValueMaker: LocalValueMaker;\n\n\t/**\n\t * Root of the SharedDirectory, most operations on the SharedDirectory itself act on the root.\n\t */\n\tprivate readonly root: SubDirectory = new SubDirectory(\n\t\tthis,\n\t\tthis.runtime,\n\t\tthis.serializer,\n\t\tposix.sep,\n\t);\n\n\t/**\n\t * Mapping of op types to message handlers.\n\t */\n\tprivate readonly messageHandlers: Map<string, IDirectoryMessageHandler> = new Map();\n\n\t/**\n\t * Constructs a new shared directory. If the object is non-local an id and service interfaces will\n\t * be provided.\n\t * @param id - String identifier for the SharedDirectory\n\t * @param runtime - Data store runtime\n\t * @param type - Type identifier\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_directory_\");\n\t\tthis.localValueMaker = new LocalValueMaker(this.serializer);\n\t\tthis.setMessageHandlers();\n\t\t// Mirror the containedValueChanged op on the SharedDirectory\n\t\tthis.root.on(\"containedValueChanged\", (changed: IValueChanged, local: boolean) => {\n\t\t\tthis.emit(\"containedValueChanged\", changed, local, this);\n\t\t});\n\t\tthis.root.on(\"subDirectoryCreated\", (relativePath: string, local: boolean) => {\n\t\t\tthis.emit(\"subDirectoryCreated\", relativePath, local, this);\n\t\t});\n\t\tthis.root.on(\"subDirectoryDeleted\", (relativePath: string, local: boolean) => {\n\t\t\tthis.emit(\"subDirectoryDeleted\", relativePath, local, this);\n\t\t});\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.get}\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get<T = any>(key: string): T | undefined {\n\t\treturn this.root.get<T>(key);\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.set}\n\t */\n\tpublic set<T = unknown>(key: string, value: T): this {\n\t\tthis.root.set(key, value);\n\t\treturn this;\n\t}\n\n\tpublic dispose(error?: Error): void {\n\t\tthis.root.dispose(error);\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this.root.disposed;\n\t}\n\n\t/**\n\t * Deletes the given key from within this IDirectory.\n\t * @param key - The key to delete\n\t * @returns True if the key existed and was deleted, false if it did not exist\n\t */\n\tpublic delete(key: string): boolean {\n\t\treturn this.root.delete(key);\n\t}\n\n\t/**\n\t * Deletes all keys from within this IDirectory.\n\t */\n\tpublic clear(): void {\n\t\tthis.root.clear();\n\t}\n\n\t/**\n\t * Checks whether the given key exists in this IDirectory.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.root.has(key);\n\t}\n\n\t/**\n\t * The number of entries under this IDirectory.\n\t */\n\tpublic get size(): number {\n\t\treturn this.root.size;\n\t}\n\n\t/**\n\t * Issue a callback on each entry under this IDirectory.\n\t * @param callback - Callback to issue\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic forEach(callback: (value: any, key: string, map: Map<string, any>) => void): void {\n\t\t// eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference\n\t\tthis.root.forEach(callback);\n\t}\n\n\t/**\n\t * Get an iterator over the entries under this IDirectory.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic [Symbol.iterator](): IterableIterator<[string, any]> {\n\t\treturn this.root[Symbol.iterator]();\n\t}\n\n\t/**\n\t * Get an iterator over the entries under this IDirectory.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic entries(): IterableIterator<[string, any]> {\n\t\treturn this.root.entries();\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.countSubDirectory}\n\t */\n\tpublic countSubDirectory(): number {\n\t\treturn this.root.countSubDirectory();\n\t}\n\n\t/**\n\t * Get an iterator over the keys under this IDirectory.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.root.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the values under this IDirectory.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic values(): IterableIterator<any> {\n\t\treturn this.root.values();\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.createSubDirectory}\n\t */\n\tpublic createSubDirectory(subdirName: string): IDirectory {\n\t\treturn this.root.createSubDirectory(subdirName);\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.getSubDirectory}\n\t */\n\tpublic getSubDirectory(subdirName: string): IDirectory | undefined {\n\t\treturn this.root.getSubDirectory(subdirName);\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.hasSubDirectory}\n\t */\n\tpublic hasSubDirectory(subdirName: string): boolean {\n\t\treturn this.root.hasSubDirectory(subdirName);\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.deleteSubDirectory}\n\t */\n\tpublic deleteSubDirectory(subdirName: string): boolean {\n\t\treturn this.root.deleteSubDirectory(subdirName);\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.subdirectories}\n\t */\n\tpublic subdirectories(): IterableIterator<[string, IDirectory]> {\n\t\treturn this.root.subdirectories();\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.getWorkingDirectory}\n\t */\n\tpublic getWorkingDirectory(relativePath: string): IDirectory | undefined {\n\t\tconst absolutePath = this.makeAbsolute(relativePath);\n\t\tif (absolutePath === posix.sep) {\n\t\t\treturn this.root;\n\t\t}\n\n\t\tlet currentSubDir = this.root;\n\t\tconst subdirs = absolutePath.slice(1).split(posix.sep);\n\t\tfor (const subdir of subdirs) {\n\t\t\tcurrentSubDir = currentSubDir.getSubDirectory(subdir) as SubDirectory;\n\t\t\tif (!currentSubDir) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\t\treturn currentSubDir;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t * @internal\n\t */\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\treturn this.serializeDirectory(this.root, serializer);\n\t}\n\n\t/**\n\t * Submits an operation\n\t * @param op - Op to submit\n\t * @param localOpMetadata - The local metadata associated with the op. We send a unique id that is used to track\n\t * this op while it has not been ack'd. This will be sent when we receive this op back from the server.\n\t * @internal\n\t */\n\tpublic submitDirectoryMessage(op: IDirectoryOperation, localOpMetadata: unknown): void {\n\t\tthis.submitLocalMessage(op, localOpMetadata);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t * @internal\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n\t * @internal\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tconst message = content as IDirectoryOperation;\n\t\tconst handler = this.messageHandlers.get(message.type);\n\t\tassert(handler !== undefined, 0x00d /* Missing message handler for message type */);\n\t\thandler.submit(message, localOpMetadata);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t * @internal\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst data = await readAndParse(storage, snapshotFileName);\n\t\tconst newFormat = data as IDirectoryNewStorageFormat;\n\t\tif (Array.isArray(newFormat.blobs)) {\n\t\t\t// New storage format\n\t\t\tthis.populate(newFormat.content);\n\t\t\tawait Promise.all(\n\t\t\t\tnewFormat.blobs.map(async (value) => {\n\t\t\t\t\tconst dataExtra = await readAndParse(storage, value);\n\t\t\t\t\tthis.populate(dataExtra as IDirectoryDataObject);\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\t// Old storage format\n\t\t\tthis.populate(data as IDirectoryDataObject);\n\t\t}\n\t}\n\n\t/**\n\t * Populate the directory with the given directory data.\n\t * @param data - A JSON string containing serialized directory data\n\t * @internal\n\t */\n\tprotected populate(data: IDirectoryDataObject): void {\n\t\tconst stack: [SubDirectory, IDirectoryDataObject][] = [];\n\t\tstack.push([this.root, data]);\n\t\twhile (stack.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst [currentSubDir, currentSubDirObject] = stack.pop()!;\n\t\t\tif (currentSubDirObject.subdirectories) {\n\t\t\t\tfor (const [subdirName, subdirObject] of Object.entries(\n\t\t\t\t\tcurrentSubDirObject.subdirectories,\n\t\t\t\t)) {\n\t\t\t\t\tlet newSubDir = currentSubDir.getSubDirectory(subdirName) as SubDirectory;\n\t\t\t\t\tif (!newSubDir) {\n\t\t\t\t\t\tnewSubDir = new SubDirectory(\n\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\tthis.runtime,\n\t\t\t\t\t\t\tthis.serializer,\n\t\t\t\t\t\t\tposix.join(currentSubDir.absolutePath, subdirName),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcurrentSubDir.populateSubDirectory(subdirName, newSubDir);\n\t\t\t\t\t}\n\t\t\t\t\tstack.push([newSubDir, subdirObject]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (currentSubDirObject.storage) {\n\t\t\t\tfor (const [key, serializable] of Object.entries(currentSubDirObject.storage)) {\n\t\t\t\t\tconst localValue = this.makeLocal(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tcurrentSubDir.absolutePath,\n\t\t\t\t\t\tserializable,\n\t\t\t\t\t);\n\t\t\t\t\tcurrentSubDir.populateStorage(key, localValue);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t * @internal\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op: IDirectoryOperation = message.contents as IDirectoryOperation;\n\t\t\tconst handler = this.messageHandlers.get(op.type);\n\t\t\tassert(handler !== undefined, 0x00e /* Missing message handler for message type */);\n\t\t\thandler.process(op, local, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @internal\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tconst op: IDirectoryOperation = content as IDirectoryOperation;\n\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\tif (subdir) {\n\t\t\tsubdir.rollback(op, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Converts the given relative path to absolute against the root.\n\t * @param relativePath - The path to convert\n\t */\n\tprivate makeAbsolute(relativePath: string): string {\n\t\treturn posix.resolve(posix.sep, relativePath);\n\t}\n\n\t/**\n\t * The remote ISerializableValue we're receiving (either as a result of a snapshot load or an incoming set op)\n\t * will have the information we need to create a real object, but will not be the real object yet. For example,\n\t * we might know it's a map and the ID but not have the actual map or its data yet. makeLocal's job\n\t * is to convert that information into a real object for local usage.\n\t * @param key - Key of element being converted\n\t * @param absolutePath - Path of element being converted\n\t * @param serializable - The remote information that we can convert into a real object\n\t * @returns The local value that was produced\n\t */\n\tprivate makeLocal(\n\t\tkey: string,\n\t\tabsolutePath: string,\n\t\tserializable: ISerializableValue,\n\t): ILocalValue {\n\t\tassert(\n\t\t\tserializable.type === ValueType[ValueType.Plain] ||\n\t\t\t\tserializable.type === ValueType[ValueType.Shared],\n\t\t\t0x1e4 /* \"Unexpected serializable type\" */,\n\t\t);\n\t\treturn this.localValueMaker.fromSerializable(serializable);\n\t}\n\n\t/**\n\t * Set the message handlers for the directory.\n\t */\n\tprivate setMessageHandlers(): void {\n\t\tthis.messageHandlers.set(\"clear\", {\n\t\t\tprocess: (op: IDirectoryClearOperation, local, localOpMetadata) => {\n\t\t\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (subdir) {\n\t\t\t\t\tsubdir.processClearMessage(op, local, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsubmit: (op: IDirectoryClearOperation, localOpMetadata: unknown) => {\n\t\t\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (subdir) {\n\t\t\t\t\tsubdir.resubmitClearMessage(op, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tapplyStashedOp: (op: IDirectoryClearOperation): IClearLocalOpMetadata | undefined => {\n\t\t\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (subdir) {\n\t\t\t\t\treturn subdir.applyStashedClearMessage(op);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t\tthis.messageHandlers.set(\"delete\", {\n\t\t\tprocess: (op: IDirectoryDeleteOperation, local, localOpMetadata) => {\n\t\t\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (subdir) {\n\t\t\t\t\tsubdir.processDeleteMessage(op, local, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsubmit: (op: IDirectoryDeleteOperation, localOpMetadata: unknown) => {\n\t\t\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (subdir) {\n\t\t\t\t\tsubdir.resubmitKeyMessage(op, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tapplyStashedOp: (\n\t\t\t\top: IDirectoryDeleteOperation,\n\t\t\t): IKeyEditLocalOpMetadata | undefined => {\n\t\t\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (subdir) {\n\t\t\t\t\treturn subdir.applyStashedDeleteMessage(op);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t\tthis.messageHandlers.set(\"set\", {\n\t\t\tprocess: (op: IDirectorySetOperation, local, localOpMetadata) => {\n\t\t\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (subdir) {\n\t\t\t\t\tconst context = local ? undefined : this.makeLocal(op.key, op.path, op.value);\n\t\t\t\t\tsubdir.processSetMessage(op, context, local, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsubmit: (op: IDirectorySetOperation, localOpMetadata: unknown) => {\n\t\t\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (subdir) {\n\t\t\t\t\tsubdir.resubmitKeyMessage(op, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tapplyStashedOp: (op: IDirectorySetOperation): IKeyEditLocalOpMetadata | undefined => {\n\t\t\t\tconst subdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (subdir) {\n\t\t\t\t\tconst context = this.makeLocal(op.key, op.path, op.value);\n\t\t\t\t\treturn subdir.applyStashedSetMessage(op, context);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\tthis.messageHandlers.set(\"createSubDirectory\", {\n\t\t\tprocess: (op: IDirectoryCreateSubDirectoryOperation, local, localOpMetadata) => {\n\t\t\t\tconst parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (parentSubdir) {\n\t\t\t\t\tparentSubdir.processCreateSubDirectoryMessage(op, local, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsubmit: (op: IDirectoryCreateSubDirectoryOperation, localOpMetadata: unknown) => {\n\t\t\t\tconst parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (parentSubdir) {\n\t\t\t\t\t// We don't reuse the metadata but send a new one on each submit.\n\t\t\t\t\tparentSubdir.resubmitSubDirectoryMessage(op, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tapplyStashedOp: (\n\t\t\t\top: IDirectoryCreateSubDirectoryOperation,\n\t\t\t): ICreateSubDirLocalOpMetadata | undefined => {\n\t\t\t\tconst parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (parentSubdir) {\n\t\t\t\t\treturn parentSubdir.applyStashedCreateSubDirMessage(op);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\tthis.messageHandlers.set(\"deleteSubDirectory\", {\n\t\t\tprocess: (op: IDirectoryDeleteSubDirectoryOperation, local, localOpMetadata) => {\n\t\t\t\tconst parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (parentSubdir) {\n\t\t\t\t\tparentSubdir.processDeleteSubDirectoryMessage(op, local, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsubmit: (op: IDirectoryDeleteSubDirectoryOperation, localOpMetadata: unknown) => {\n\t\t\t\tconst parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (parentSubdir) {\n\t\t\t\t\t// We don't reuse the metadata but send a new one on each submit.\n\t\t\t\t\tparentSubdir.resubmitSubDirectoryMessage(op, localOpMetadata);\n\t\t\t\t}\n\t\t\t},\n\t\t\tapplyStashedOp: (\n\t\t\t\top: IDirectoryDeleteSubDirectoryOperation,\n\t\t\t): IDeleteSubDirLocalOpMetadata | undefined => {\n\t\t\t\tconst parentSubdir = this.getWorkingDirectory(op.path) as SubDirectory | undefined;\n\t\t\t\tif (parentSubdir) {\n\t\t\t\t\treturn parentSubdir.applyStashedDeleteSubDirMessage(op);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t * @internal\n\t */\n\tprotected applyStashedOp(op: unknown): unknown {\n\t\tconst handler = this.messageHandlers.get((op as IDirectoryOperation).type);\n\t\tif (handler === undefined) {\n\t\t\tthrow new Error(\"no apply stashed op handler\");\n\t\t}\n\t\treturn handler.applyStashedOp(op as IDirectoryOperation);\n\t}\n\n\tprivate serializeDirectory(\n\t\troot: SubDirectory,\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst MinValueSizeSeparateSnapshotBlob = 8 * 1024;\n\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tlet counter = 0;\n\t\tconst blobs: string[] = [];\n\n\t\tconst stack: [SubDirectory, IDirectoryDataObject][] = [];\n\t\tconst content: IDirectoryDataObject = {};\n\t\tstack.push([root, content]);\n\n\t\twhile (stack.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst [currentSubDir, currentSubDirObject] = stack.pop()!;\n\t\t\tfor (const [key, value] of currentSubDir.getSerializedStorage(serializer)) {\n\t\t\t\tif (!currentSubDirObject.storage) {\n\t\t\t\t\tcurrentSubDirObject.storage = {};\n\t\t\t\t}\n\t\t\t\tconst result: ISerializableValue = {\n\t\t\t\t\ttype: value.type,\n\t\t\t\t\tvalue: value.value && (JSON.parse(value.value) as object),\n\t\t\t\t};\n\t\t\t\tif (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {\n\t\t\t\t\tconst extraContent: IDirectoryDataObject = {};\n\t\t\t\t\tlet largeContent = extraContent;\n\t\t\t\t\tif (currentSubDir.absolutePath !== posix.sep) {\n\t\t\t\t\t\tfor (const dir of currentSubDir.absolutePath.slice(1).split(posix.sep)) {\n\t\t\t\t\t\t\tconst subDataObject: IDirectoryDataObject = {};\n\t\t\t\t\t\t\tlargeContent.subdirectories = { [dir]: subDataObject };\n\t\t\t\t\t\t\tlargeContent = subDataObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tlargeContent.storage = { [key]: result };\n\t\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\t\tcounter++;\n\t\t\t\t\tblobs.push(blobName);\n\t\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(extraContent));\n\t\t\t\t} else {\n\t\t\t\t\tcurrentSubDirObject.storage[key] = result;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const [subdirName, subdir] of currentSubDir.subdirectories()) {\n\t\t\t\tif (!currentSubDirObject.subdirectories) {\n\t\t\t\t\tcurrentSubDirObject.subdirectories = {};\n\t\t\t\t}\n\t\t\t\tconst subDataObject: IDirectoryDataObject = {};\n\t\t\t\tcurrentSubDirObject.subdirectories[subdirName] = subDataObject;\n\t\t\t\tstack.push([subdir as SubDirectory, subDataObject]);\n\t\t\t}\n\t\t}\n\n\t\tconst newFormat: IDirectoryNewStorageFormat = {\n\t\t\tblobs,\n\t\t\tcontent,\n\t\t};\n\t\tbuilder.addBlob(snapshotFileName, JSON.stringify(newFormat));\n\n\t\treturn builder.getSummaryTree();\n\t}\n}\n\ninterface IKeyEditLocalOpMetadata {\n\ttype: \"edit\";\n\tpendingMessageId: number;\n\tpreviousValue: ILocalValue | undefined;\n}\n\ninterface IClearLocalOpMetadata {\n\ttype: \"clear\";\n\tpendingMessageId: number;\n\tpreviousStorage: Map<string, ILocalValue>;\n}\n\ninterface ICreateSubDirLocalOpMetadata {\n\ttype: \"createSubDir\";\n\tpendingMessageId: number;\n\tpreviouslyExisted: boolean;\n}\n\ninterface IDeleteSubDirLocalOpMetadata {\n\ttype: \"deleteSubDir\";\n\tpendingMessageId: number;\n\tsubDirectory: SubDirectory | undefined;\n}\n\ntype SubDirLocalOpMetadata = ICreateSubDirLocalOpMetadata | IDeleteSubDirLocalOpMetadata;\ntype DirectoryLocalOpMetadata =\n\t| IClearLocalOpMetadata\n\t| IKeyEditLocalOpMetadata\n\t| SubDirLocalOpMetadata;\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\nfunction isKeyEditLocalOpMetadata(metadata: any): metadata is IKeyEditLocalOpMetadata {\n\treturn (\n\t\tmetadata !== undefined &&\n\t\ttypeof metadata.pendingMessageId === \"number\" &&\n\t\tmetadata.type === \"edit\"\n\t);\n}\n\nfunction isClearLocalOpMetadata(metadata: any): metadata is IClearLocalOpMetadata {\n\treturn (\n\t\tmetadata !== undefined &&\n\t\tmetadata.type === \"clear\" &&\n\t\ttypeof metadata.pendingMessageId === \"number\" &&\n\t\ttypeof metadata.previousStorage === \"object\"\n\t);\n}\n\nfunction isSubDirLocalOpMetadata(metadata: any): metadata is SubDirLocalOpMetadata {\n\treturn (\n\t\tmetadata !== undefined &&\n\t\ttypeof metadata.pendingMessageId === \"number\" &&\n\t\t((metadata.type === \"createSubDir\" && typeof metadata.previouslyExisted === \"boolean\") ||\n\t\t\tmetadata.type === \"deleteSubDir\")\n\t);\n}\n\nfunction isDirectoryLocalOpMetadata(metadata: any): metadata is DirectoryLocalOpMetadata {\n\treturn (\n\t\tmetadata !== undefined &&\n\t\ttypeof metadata.pendingMessageId === \"number\" &&\n\t\t(metadata.type === \"edit\" ||\n\t\t\tmetadata.type === \"deleteSubDir\" ||\n\t\t\t(metadata.type === \"clear\" && typeof metadata.previousStorage === \"object\") ||\n\t\t\t(metadata.type === \"createSubDir\" && typeof metadata.previouslyExisted === \"boolean\"))\n\t);\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\n/**\n * Node of the directory tree.\n * @sealed\n */\nclass SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirectory {\n\t/**\n\t * Tells if the sub directory is deleted or not.\n\t */\n\tprivate _deleted = false;\n\n\t/**\n\t * String representation for the class.\n\t */\n\tpublic [Symbol.toStringTag]: string = \"SubDirectory\";\n\n\t/**\n\t * The in-memory data the directory is storing.\n\t */\n\tprivate readonly _storage: Map<string, ILocalValue> = new Map();\n\n\t/**\n\t * The subdirectories the directory is holding.\n\t */\n\tprivate readonly _subdirectories: Map<string, SubDirectory> = new Map();\n\n\t/**\n\t * Keys that have been modified locally but not yet ack'd from the server.\n\t */\n\tprivate readonly pendingKeys: Map<string, number[]> = new Map();\n\n\t/**\n\t * Subdirectories that have been modified locally but not yet ack'd from the server.\n\t */\n\tprivate readonly pendingSubDirectories: Map<string, number[]> = new Map();\n\n\t/**\n\t * This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.\n\t */\n\tprivate pendingMessageId: number = -1;\n\n\t/**\n\t * The pending ids of any clears that have been performed locally but not yet ack'd from the server\n\t */\n\tprivate readonly pendingClearMessageIds: number[] = [];\n\n\t/**\n\t * Constructor.\n\t * @param directory - Reference back to the SharedDirectory to perform operations\n\t * @param runtime - The data store runtime this directory is associated with\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param absolutePath - The absolute path of this IDirectory\n\t */\n\tpublic constructor(\n\t\tprivate readonly directory: SharedDirectory,\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tpublic readonly absolutePath: string,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic dispose(error?: Error): void {\n\t\tthis._deleted = true;\n\t\tthis.emit(\"disposed\", this);\n\t}\n\n\t/**\n\t * Unmark the deleted property only when rolling back delete.\n\t */\n\tprivate undispose(): void {\n\t\tthis._deleted = false;\n\t\tthis.emit(\"undisposed\", this);\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this._deleted;\n\t}\n\n\tprivate throwIfDisposed(): void {\n\t\tif (this._deleted) {\n\t\t\tthrow new UsageError(\"Cannot access Disposed subDirectory\");\n\t\t}\n\t}\n\n\t/**\n\t * Checks whether the given key exists in this IDirectory.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\tthis.throwIfDisposed();\n\t\treturn this._storage.has(key);\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.get}\n\t */\n\tpublic get<T = unknown>(key: string): T | undefined {\n\t\tthis.throwIfDisposed();\n\t\treturn this._storage.get(key)?.value as T | undefined;\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.set}\n\t */\n\tpublic set<T = unknown>(key: string, value: T): this {\n\t\tthis.throwIfDisposed();\n\t\t// Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.\n\t\tif (key === undefined || key === null) {\n\t\t\tthrow new Error(\"Undefined and null keys are not supported\");\n\t\t}\n\n\t\t// Create a local value and serialize it.\n\t\tconst localValue = this.directory.localValueMaker.fromInMemory(value);\n\t\tconst serializableValue = makeSerializable(\n\t\t\tlocalValue,\n\t\t\tthis.serializer,\n\t\t\tthis.directory.handle,\n\t\t);\n\n\t\t// Set the value locally.\n\t\tconst previousValue = this.setCore(key, localValue, true);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.directory.isAttached()) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst op: IDirectorySetOperation = {\n\t\t\tkey,\n\t\t\tpath: this.absolutePath,\n\t\t\ttype: \"set\",\n\t\t\tvalue: serializableValue,\n\t\t};\n\t\tthis.submitKeyMessage(op, previousValue);\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.countSubDirectory}\n\t */\n\tpublic countSubDirectory(): number {\n\t\treturn this._subdirectories.size;\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.createSubDirectory}\n\t */\n\tpublic createSubDirectory(subdirName: string): IDirectory {\n\t\tthis.throwIfDisposed();\n\t\t// Undefined/null subdirectory names can't be serialized to JSON in the manner we currently snapshot.\n\t\tif (subdirName === undefined || subdirName === null) {\n\t\t\tthrow new Error(\"SubDirectory name may not be undefined or null\");\n\t\t}\n\n\t\tif (subdirName.includes(posix.sep)) {\n\t\t\tthrow new Error(`SubDirectory name may not contain ${posix.sep}`);\n\t\t}\n\n\t\t// Create the sub directory locally first.\n\t\tconst isNew = this.createSubDirectoryCore(subdirName, true);\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst subDir: IDirectory = this._subdirectories.get(subdirName)!;\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.directory.isAttached()) {\n\t\t\treturn subDir;\n\t\t}\n\n\t\tconst op: IDirectoryCreateSubDirectoryOperation = {\n\t\t\tpath: this.absolutePath,\n\t\t\tsubdirName,\n\t\t\ttype: \"createSubDirectory\",\n\t\t};\n\t\tthis.submitCreateSubDirectoryMessage(op, !isNew);\n\n\t\treturn subDir;\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.getSubDirectory}\n\t */\n\tpublic getSubDirectory(subdirName: string): IDirectory | undefined {\n\t\tthis.throwIfDisposed();\n\t\treturn this._subdirectories.get(subdirName);\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.hasSubDirectory}\n\t */\n\tpublic hasSubDirectory(subdirName: string): boolean {\n\t\tthis.throwIfDisposed();\n\t\treturn this._subdirectories.has(subdirName);\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.deleteSubDirectory}\n\t */\n\tpublic deleteSubDirectory(subdirName: string): boolean {\n\t\tthis.throwIfDisposed();\n\t\t// Delete the sub directory locally first.\n\t\tconst subDir = this.deleteSubDirectoryCore(subdirName, true);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.directory.isAttached()) {\n\t\t\treturn subDir !== undefined;\n\t\t}\n\n\t\tconst op: IDirectoryDeleteSubDirectoryOperation = {\n\t\t\tpath: this.absolutePath,\n\t\t\tsubdirName,\n\t\t\ttype: \"deleteSubDirectory\",\n\t\t};\n\n\t\tthis.submitDeleteSubDirectoryMessage(op, subDir);\n\t\treturn subDir !== undefined;\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.subdirectories}\n\t */\n\tpublic subdirectories(): IterableIterator<[string, IDirectory]> {\n\t\tthis.throwIfDisposed();\n\t\treturn this._subdirectories.entries();\n\t}\n\n\t/**\n\t * {@inheritDoc IDirectory.getWorkingDirectory}\n\t */\n\tpublic getWorkingDirectory(relativePath: string): IDirectory | undefined {\n\t\tthis.throwIfDisposed();\n\t\treturn this.directory.getWorkingDirectory(this.makeAbsolute(relativePath));\n\t}\n\n\t/**\n\t * Deletes the given key from within this IDirectory.\n\t * @param key - The key to delete\n\t * @returns True if the key existed and was deleted, false if it did not exist\n\t */\n\tpublic delete(key: string): boolean {\n\t\tthis.throwIfDisposed();\n\t\t// Delete the key locally first.\n\t\tconst previousValue = this.deleteCore(key, true);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.directory.isAttached()) {\n\t\t\treturn previousValue !== undefined;\n\t\t}\n\n\t\tconst op: IDirectoryDeleteOperation = {\n\t\t\tkey,\n\t\t\tpath: this.absolutePath,\n\t\t\ttype: \"delete\",\n\t\t};\n\n\t\tthis.submitKeyMessage(op, previousValue);\n\t\treturn previousValue !== undefined;\n\t}\n\n\t/**\n\t * Deletes all keys from within this IDirectory.\n\t */\n\tpublic clear(): void {\n\t\tthis.throwIfDisposed();\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.directory.isAttached()) {\n\t\t\tthis.clearCore(true);\n\t\t\treturn;\n\t\t}\n\n\t\tconst copy = new Map<string, ILocalValue>(this._storage);\n\t\tthis.clearCore(true);\n\t\tconst op: IDirectoryClearOperation = {\n\t\t\tpath: this.absolutePath,\n\t\t\ttype: \"clear\",\n\t\t};\n\t\tthis.submitClearMessage(op, copy);\n\t}\n\n\t/**\n\t * Issue a callback on each entry under this IDirectory.\n\t * @param callback - Callback to issue\n\t */\n\tpublic forEach(\n\t\tcallback: (value: unknown, key: string, map: Map<string, unknown>) => void,\n\t): void {\n\t\tthis.throwIfDisposed();\n\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\tthis._storage.forEach((localValue, key, map) => {\n\t\t\tcallback(localValue.value, key, map);\n\t\t});\n\t}\n\n\t/**\n\t * The number of entries under this IDirectory.\n\t */\n\tpublic get size(): number {\n\t\tthis.throwIfDisposed();\n\t\treturn this._storage.size;\n\t}\n\n\t/**\n\t * Get an iterator over the entries under this IDirectory.\n\t * @returns The iterator\n\t */\n\tpublic entries(): IterableIterator<[string, unknown]> {\n\t\tthis.throwIfDisposed();\n\t\tconst localEntriesIterator = this._storage.entries();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<[string, unknown]> {\n\t\t\t\tconst nextVal = localEntriesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: [nextVal.value[0], nextVal.value[1].value], done: false };\n\t\t\t},\n\t\t\t[Symbol.iterator](): IterableIterator<[string, unknown]> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the keys under this IDirectory.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\tthis.throwIfDisposed();\n\t\treturn this._storage.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the values under this IDirectory.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<unknown> {\n\t\tthis.throwIfDisposed();\n\t\tconst localValuesIterator = this._storage.values();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<unknown> {\n\t\t\t\tconst nextVal = localValuesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: nextVal.value.value, done: false };\n\t\t\t},\n\t\t\t[Symbol.iterator](): IterableIterator<unknown> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the entries under this IDirectory.\n\t * @returns The iterator\n\t */\n\tpublic [Symbol.iterator](): IterableIterator<[string, unknown]> {\n\t\tthis.throwIfDisposed();\n\t\treturn this.entries();\n\t}\n\n\t/**\n\t * Process a clear operation.\n\t * @param op - The op to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @internal\n\t */\n\tpublic processClearMessage(\n\t\top: IDirectoryClearOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.throwIfDisposed();\n\t\tif (local) {\n\t\t\tassert(\n\t\t\t\tisClearLocalOpMetadata(localOpMetadata),\n\t\t\t\t0x00f /* pendingMessageId is missing from the local client's operation */,\n\t\t\t);\n\t\t\tconst pendingClearMessageId = this.pendingClearMessageIds.shift();\n\t\t\tassert(\n\t\t\t\tpendingClearMessageId === localOpMetadata.pendingMessageId,\n\t\t\t\t0x32a /* pendingMessageId does not match */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis.clearExceptPendingKeys(false);\n\t}\n\n\t/**\n\t * Apply clear operation locally and generate metadata\n\t * @param op - Op to apply\n\t * @returns metadata generated for stahed op\n\t */\n\tpublic applyStashedClearMessage(op: IDirectoryClearOperation): IClearLocalOpMetadata {\n\t\tthis.throwIfDisposed();\n\t\tconst previousValue = new Map<string, ILocalValue>(this._storage);\n\t\tthis.clearExceptPendingKeys(true);\n\t\tconst pendingMsgId = ++this.pendingMessageId;\n\t\tthis.pendingClearMessageIds.push(pendingMsgId);\n\t\tconst metadata: IClearLocalOpMetadata = {\n\t\t\ttype: \"clear\",\n\t\t\tpendingMessageId: pendingMsgId,\n\t\t\tpreviousStorage: previousValue,\n\t\t};\n\t\treturn metadata;\n\t}\n\n\t/**\n\t * Process a delete operation.\n\t * @param op - The op to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @internal\n\t */\n\tpublic processDeleteMessage(\n\t\top: IDirectoryDeleteOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.throwIfDisposed();\n\t\tif (!this.needProcessStorageOperation(op, local, localOpMetadata)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.deleteCore(op.key, local);\n\t}\n\n\t/**\n\t * Apply delete operation locally and generate metadata\n\t * @param op - Op to apply\n\t * @returns metadata generated for stahed op\n\t */\n\tpublic applyStashedDeleteMessage(op: IDirectoryDeleteOperation): IKeyEditLocalOpMetadata {\n\t\tthis.throwIfDisposed();\n\t\tconst previousValue = this.deleteCore(op.key, true);\n\t\tconst pendingMessageId = this.getKeyMessageId(op);\n\t\tconst localMetadata: IKeyEditLocalOpMetadata = {\n\t\t\ttype: \"edit\",\n\t\t\tpendingMessageId,\n\t\t\tpreviousValue,\n\t\t};\n\t\treturn localMetadata;\n\t}\n\n\t/**\n\t * Process a set operation.\n\t * @param op - The op to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @internal\n\t */\n\tpublic processSetMessage(\n\t\top: IDirectorySetOperation,\n\t\tcontext: ILocalValue | undefined,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.throwIfDisposed();\n\t\tif (!this.needProcessStorageOperation(op, local, localOpMetadata)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// needProcessStorageOperation should have returned false if local is true\n\t\t// so we can assume context is not undefined\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.setCore(op.key, context!, local);\n\t}\n\n\t/**\n\t * Apply set operation locally and generate metadata\n\t * @param op - Op to apply\n\t * @returns metadata generated for stahed op\n\t */\n\tpublic applyStashedSetMessage(\n\t\top: IDirectorySetOperation,\n\t\tcontext: ILocalValue,\n\t): IKeyEditLocalOpMetadata {\n\t\tthis.throwIfDisposed();\n\t\t// Set the value locally.\n\t\tconst previousValue = this.setCore(op.key, context, true);\n\n\t\t// Create metadata\n\t\tconst pendingMessageId = this.getKeyMessageId(op);\n\t\tconst localMetadata: IKeyEditLocalOpMetadata = {\n\t\t\ttype: \"edit\",\n\t\t\tpendingMessageId,\n\t\t\tpreviousValue,\n\t\t};\n\t\treturn localMetadata;\n\t}\n\t/**\n\t * Process a create subdirectory operation.\n\t * @param op - The op to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @internal\n\t */\n\tpublic processCreateSubDirectoryMessage(\n\t\top: IDirectoryCreateSubDirectoryOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.throwIfDisposed();\n\t\tif (!this.needProcessSubDirectoryOperation(op, local, localOpMetadata)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.createSubDirectoryCore(op.subdirName, local);\n\t}\n\n\t/**\n\t * Apply createSubDirectory operation locally and generate metadata\n\t * @param op - Op to apply\n\t * @returns metadata generated for stahed op\n\t */\n\tpublic applyStashedCreateSubDirMessage(\n\t\top: IDirectoryCreateSubDirectoryOperation,\n\t): ICreateSubDirLocalOpMetadata {\n\t\tthis.throwIfDisposed();\n\t\t// Create the sub directory locally first.\n\t\tconst isNew = this.createSubDirectoryCore(op.subdirName, true);\n\t\tconst newMessageId = this.getSubDirMessageId(op);\n\n\t\tconst localOpMetadata: ICreateSubDirLocalOpMetadata = {\n\t\t\ttype: \"createSubDir\",\n\t\t\tpendingMessageId: newMessageId,\n\t\t\tpreviouslyExisted: !isNew,\n\t\t};\n\t\treturn localOpMetadata;\n\t}\n\n\t/**\n\t * Process a delete subdirectory operation.\n\t * @param op - The op to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @internal\n\t */\n\tpublic processDeleteSubDirectoryMessage(\n\t\top: IDirectoryDeleteSubDirectoryOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.throwIfDisposed();\n\t\tif (!this.needProcessSubDirectoryOperation(op, local, localOpMetadata)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.deleteSubDirectoryCore(op.subdirName, local);\n\t}\n\n\t/**\n\t * Apply deleteSubDirectory operation locally and generate metadata\n\t * @param op - Op to apply\n\t * @returns metadata generated for stahed op\n\t */\n\tpublic applyStashedDeleteSubDirMessage(\n\t\top: IDirectoryDeleteSubDirectoryOperation,\n\t): IDeleteSubDirLocalOpMetadata {\n\t\tthis.throwIfDisposed();\n\t\tconst subDir = this.deleteSubDirectoryCore(op.subdirName, true);\n\t\tconst newMessageId = this.getSubDirMessageId(op);\n\t\tconst metadata: IDeleteSubDirLocalOpMetadata = {\n\t\t\ttype: \"deleteSubDir\",\n\t\t\tpendingMessageId: newMessageId,\n\t\t\tsubDirectory: subDir,\n\t\t};\n\t\treturn metadata;\n\t}\n\n\t/**\n\t * Submit a clear operation.\n\t * @param op - The operation\n\t */\n\tprivate submitClearMessage(\n\t\top: IDirectoryClearOperation,\n\t\tpreviousValue: Map<string, ILocalValue>,\n\t): void {\n\t\tthis.throwIfDisposed();\n\t\tconst pendingMsgId = ++this.pendingMessageId;\n\t\tthis.pendingClearMessageIds.push(pendingMsgId);\n\t\tconst metadata: IClearLocalOpMetadata = {\n\t\t\ttype: \"clear\",\n\t\t\tpendingMessageId: pendingMsgId,\n\t\t\tpreviousStorage: previousValue,\n\t\t};\n\t\tthis.directory.submitDirectoryMessage(op, metadata);\n\t}\n\n\t/**\n\t * Resubmit a clear operation.\n\t * @param op - The operation\n\t * @internal\n\t */\n\tpublic resubmitClearMessage(op: IDirectoryClearOperation, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\tisClearLocalOpMetadata(localOpMetadata),\n\t\t\t0x32b /* Invalid localOpMetadata for clear */,\n\t\t);\n\t\t// We don't reuse the metadata pendingMessageId but send a new one on each submit.\n\t\tconst pendingClearMessageId = this.pendingClearMessageIds.shift();\n\t\tassert(\n\t\t\tpendingClearMessageId === localOpMetadata.pendingMessageId,\n\t\t\t0x32c /* pendingMessageId does not match */,\n\t\t);\n\t\tthis.submitClearMessage(op, localOpMetadata.previousStorage);\n\t}\n\n\t/**\n\t * Get a new pending message id for the op and cache it to track the pending op\n\t */\n\tprivate getKeyMessageId(op: IDirectoryKeyOperation): number {\n\t\t// We don't reuse the metadata pendingMessageId but send a new one on each submit.\n\t\tconst pendingMessageId = ++this.pendingMessageId;\n\t\tconst pendingMessageIds = this.pendingKeys.get(op.key);\n\t\tif (pendingMessageIds !== undefined) {\n\t\t\tpendingMessageIds.push(pendingMessageId);\n\t\t} else {\n\t\t\tthis.pendingKeys.set(op.key, [pendingMessageId]);\n\t\t}\n\t\treturn pendingMessageId;\n\t}\n\n\t/**\n\t * Submit a key operation.\n\t * @param op - The operation\n\t * @param previousValue - The value of the key before this op\n\t */\n\tprivate submitKeyMessage(op: IDirectoryKeyOperation, previousValue?: ILocalValue): void {\n\t\tthis.throwIfDisposed();\n\t\tconst pendingMessageId = this.getKeyMessageId(op);\n\t\tconst localMetadata = { type: \"edit\", pendingMessageId, previousValue };\n\t\tthis.directory.submitDirectoryMessage(op, localMetadata);\n\t}\n\n\t/**\n\t * Submit a key message to remote clients based on a previous submit.\n\t * @param op - The map key message\n\t * @param localOpMetadata - Metadata from the previous submit\n\t * @internal\n\t */\n\tpublic resubmitKeyMessage(op: IDirectoryKeyOperation, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\tisKeyEditLocalOpMetadata(localOpMetadata),\n\t\t\t0x32d /* Invalid localOpMetadata in submit */,\n\t\t);\n\n\t\t// clear the old pending message id\n\t\tconst pendingMessageIds = this.pendingKeys.get(op.key);\n\t\tassert(\n\t\t\tpendingMessageIds !== undefined &&\n\t\t\t\tpendingMessageIds[0] === localOpMetadata.pendingMessageId,\n\t\t\t0x32e /* Unexpected pending message received */,\n\t\t);\n\t\tpendingMessageIds.shift();\n\t\tif (pendingMessageIds.length === 0) {\n\t\t\tthis.pendingKeys.delete(op.key);\n\t\t}\n\n\t\tthis.submitKeyMessage(op, localOpMetadata.previousValue);\n\t}\n\n\t/**\n\t * Get a new pending message id for the op and cache it to track the pending op\n\t */\n\tprivate getSubDirMessageId(op: IDirectorySubDirectoryOperation): number {\n\t\t// We don't reuse the metadata pendingMessageId but send a new one on each submit.\n\t\tconst newMessageId = ++this.pendingMessageId;\n\t\tconst pendingMessageIds = this.pendingSubDirectories.get(op.subdirName);\n\t\tif (pendingMessageIds !== undefined) {\n\t\t\tpendingMessageIds.push(newMessageId);\n\t\t} else {\n\t\t\tthis.pendingSubDirectories.set(op.subdirName, [newMessageId]);\n\t\t}\n\t\treturn newMessageId;\n\t}\n\n\t/**\n\t * Submit a create subdirectory operation.\n\t * @param op - The operation\n\t * @param prevExisted - Whether the subdirectory existed before the op\n\t */\n\tprivate submitCreateSubDirectoryMessage(\n\t\top: IDirectorySubDirectoryOperation,\n\t\tprevExisted: boolean,\n\t): void {\n\t\tthis.throwIfDisposed();\n\t\tconst newMessageId = this.getSubDirMessageId(op);\n\n\t\tconst localOpMetadata: ICreateSubDirLocalOpMetadata = {\n\t\t\ttype: \"createSubDir\",\n\t\t\tpendingMessageId: newMessageId,\n\t\t\tpreviouslyExisted: prevExisted,\n\t\t};\n\t\tthis.directory.submitDirectoryMessage(op, localOpMetadata);\n\t}\n\n\t/**\n\t * Submit a delete subdirectory operation.\n\t * @param op - The operation\n\t * @param subDir - Any subdirectory deleted by the op\n\t */\n\tprivate submitDeleteSubDirectoryMessage(\n\t\top: IDirectorySubDirectoryOperation,\n\t\tsubDir: SubDirectory | undefined,\n\t): void {\n\t\tthis.throwIfDisposed();\n\t\tconst newMessageId = this.getSubDirMessageId(op);\n\n\t\tconst localOpMetadata: IDeleteSubDirLocalOpMetadata = {\n\t\t\ttype: \"deleteSubDir\",\n\t\t\tpendingMessageId: newMessageId,\n\t\t\tsubDirectory: subDir,\n\t\t};\n\t\tthis.directory.submitDirectoryMessage(op, localOpMetadata);\n\t}\n\n\t/**\n\t * Submit a subdirectory operation again\n\t * @param op - The operation\n\t * @param localOpMetadata - metadata submitted with the op originally\n\t * @internal\n\t */\n\tpublic resubmitSubDirectoryMessage(\n\t\top: IDirectorySubDirectoryOperation,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tassert(\n\t\t\tisSubDirLocalOpMetadata(localOpMetadata),\n\t\t\t0x32f /* Invalid localOpMetadata for sub directory op */,\n\t\t);\n\n\t\t// clear the old pending message id\n\t\tconst pendingMessageIds = this.pendingSubDirectories.get(op.subdirName);\n\t\tassert(\n\t\t\tpendingMessageIds !== undefined &&\n\t\t\t\tpendingMessageIds[0] === localOpMetadata.pendingMessageId,\n\t\t\t0x330 /* Unexpected pending message received */,\n\t\t);\n\t\tpendingMessageIds.shift();\n\t\tif (pendingMessageIds.length === 0) {\n\t\t\tthis.pendingSubDirectories.delete(op.subdirName);\n\t\t}\n\n\t\tif (localOpMetadata.type === \"createSubDir\") {\n\t\t\tthis.submitCreateSubDirectoryMessage(op, localOpMetadata.previouslyExisted);\n\t\t} else {\n\t\t\tthis.submitDeleteSubDirectoryMessage(op, localOpMetadata.subDirectory);\n\t\t}\n\t}\n\n\t/**\n\t * Get the storage of this subdirectory in a serializable format, to be used in snapshotting.\n\t * @param serializer - The serializer to use to serialize handles in its values.\n\t * @returns The JSONable string representing the storage of this subdirectory\n\t * @internal\n\t */\n\tpublic *getSerializedStorage(\n\t\tserializer: IFluidSerializer,\n\t): Generator<[string, ISerializedValue], void> {\n\t\tthis.throwIfDisposed();\n\t\tfor (const [key, localValue] of this._storage) {\n\t\t\tconst value = localValue.makeSerialized(serializer, this.directory.handle);\n\t\t\tconst res: [string, ISerializedValue] = [key, value];\n\t\t\tyield res;\n\t\t}\n\t}\n\n\t/**\n\t * Populate a key value in this subdirectory's storage, to be used when loading from snapshot.\n\t * @param key - The key to populate\n\t * @param localValue - The local value to populate into it\n\t * @internal\n\t */\n\tpublic populateStorage(key: string, localValue: ILocalValue): void {\n\t\tthis.throwIfDisposed();\n\t\tthis._storage.set(key, localValue);\n\t}\n\n\t/**\n\t * Populate a subdirectory into this subdirectory, to be used when loading from snapshot.\n\t * @param subdirName - The name of the subdirectory to add\n\t * @param newSubDir - The new subdirectory to add\n\t * @internal\n\t */\n\tpublic populateSubDirectory(subdirName: string, newSubDir: SubDirectory): void {\n\t\tthis.throwIfDisposed();\n\t\tthis._subdirectories.set(subdirName, newSubDir);\n\t}\n\n\t/**\n\t * Retrieve the local value at the given key. This is used to get value type information stashed on the local\n\t * value so op handlers can be retrieved\n\t * @param key - The key to retrieve from\n\t * @returns The local value\n\t * @internal\n\t */\n\tpublic getLocalValue<T extends ILocalValue = ILocalValue>(key: string): T {\n\t\tthis.throwIfDisposed();\n\t\treturn this._storage.get(key) as T;\n\t}\n\n\t/**\n\t * Remove the pendingMessageId from the map tracking it on rollback\n\t * @param map - map tracking the pending messages\n\t * @param key - key of the edit in the op\n\t */\n\tprivate rollbackPendingMessageId(\n\t\tmap: Map<string, number[]>,\n\t\tkey: string,\n\t\tpendingMessageId,\n\t): void {\n\t\tconst pendingMessageIds = map.get(key);\n\t\tconst lastPendingMessageId = pendingMessageIds?.pop();\n\t\tif (!pendingMessageIds || lastPendingMessageId !== pendingMessageId) {\n\t\t\tthrow new Error(\"Rollback op does not match last pending\");\n\t\t}\n\t\tif (pendingMessageIds.length === 0) {\n\t\t\tmap.delete(key);\n\t\t}\n\t}\n\n\t/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\n\t/**\n\t * Rollback a local op\n\t * @param op - The operation to rollback\n\t * @param localOpMetadata - The local metadata associated with the op.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic rollback(op: any, localOpMetadata: unknown): void {\n\t\tif (!isDirectoryLocalOpMetadata(localOpMetadata)) {\n\t\t\tthrow new Error(\"Invalid localOpMetadata\");\n\t\t}\n\n\t\tif (op.type === \"clear\" && localOpMetadata.type === \"clear\") {\n\t\t\tfor (const [key, localValue] of localOpMetadata.previousStorage.entries()) {\n\t\t\t\tthis.setCore(key, localValue, true);\n\t\t\t}\n\n\t\t\tconst lastPendingClearId = this.pendingClearMessageIds.pop();\n\t\t\tif (\n\t\t\t\tlastPendingClearId === undefined ||\n\t\t\t\tlastPendingClearId !== localOpMetadata.pendingMessageId\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Rollback op does match last clear\");\n\t\t\t}\n\t\t} else if ((op.type === \"delete\" || op.type === \"set\") && localOpMetadata.type === \"edit\") {\n\t\t\tif (localOpMetadata.previousValue === undefined) {\n\t\t\t\tthis.deleteCore(op.key as string, true);\n\t\t\t} else {\n\t\t\t\tthis.setCore(op.key as string, localOpMetadata.previousValue, true);\n\t\t\t}\n\n\t\t\tthis.rollbackPendingMessageId(\n\t\t\t\tthis.pendingKeys,\n\t\t\t\top.key as string,\n\t\t\t\tlocalOpMetadata.pendingMessageId,\n\t\t\t);\n\t\t} else if (op.type === \"createSubDirectory\" && localOpMetadata.type === \"createSubDir\") {\n\t\t\tif (!localOpMetadata.previouslyExisted) {\n\t\t\t\tthis.deleteSubDirectoryCore(op.subdirName as string, true);\n\t\t\t}\n\n\t\t\tthis.rollbackPendingMessageId(\n\t\t\t\tthis.pendingSubDirectories,\n\t\t\t\top.subdirName as string,\n\t\t\t\tlocalOpMetadata.pendingMessageId,\n\t\t\t);\n\t\t} else if (op.type === \"deleteSubDirectory\" && localOpMetadata.type === \"deleteSubDir\") {\n\t\t\tif (localOpMetadata.subDirectory !== undefined) {\n\t\t\t\tthis.undeleteSubDirectoryTree(localOpMetadata.subDirectory);\n\t\t\t\t// don't need to register events because deleting never unregistered\n\t\t\t\tthis._subdirectories.set(op.subdirName as string, localOpMetadata.subDirectory);\n\t\t\t\tthis.emit(\"subDirectoryCreated\", op.subdirName, true, this);\n\t\t\t}\n\n\t\t\tthis.rollbackPendingMessageId(\n\t\t\t\tthis.pendingSubDirectories,\n\t\t\t\top.subdirName as string,\n\t\t\t\tlocalOpMetadata.pendingMessageId,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow new Error(\"Unsupported op for rollback\");\n\t\t}\n\t}\n\n\t/* eslint-enable @typescript-eslint/no-unsafe-member-access */\n\n\t/**\n\t * Converts the given relative path into an absolute path.\n\t * @param path - Relative path to convert\n\t * @returns The equivalent absolute path\n\t */\n\tprivate makeAbsolute(relativePath: string): string {\n\t\treturn posix.resolve(this.absolutePath, relativePath);\n\t}\n\n\t/**\n\t * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should\n\t * not process the incoming operation.\n\t * @param op - Operation to check\n\t * @param local - Whether the operation originated from the local client\n\t * @param localOpMetadata - For local client ops, this is the metadata that was submitted with the op.\n\t * For ops from a remote client, this will be undefined.\n\t * @returns True if the operation should be processed, false otherwise\n\t */\n\tprivate needProcessStorageOperation(\n\t\top: IDirectoryKeyOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tif (this.pendingClearMessageIds.length > 0) {\n\t\t\tif (local) {\n\t\t\t\tassert(\n\t\t\t\t\tlocalOpMetadata !== undefined &&\n\t\t\t\t\t\tisKeyEditLocalOpMetadata(localOpMetadata) &&\n\t\t\t\t\t\tlocalOpMetadata.pendingMessageId < this.pendingClearMessageIds[0],\n\t\t\t\t\t0x010 /* \"Received out of order storage op when there is an unackd clear message\" */,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// If I have a NACK clear, we can ignore all ops.\n\t\t\treturn false;\n\t\t}\n\n\t\tconst pendingKeyMessageId = this.pendingKeys.get(op.key);\n\t\tif (pendingKeyMessageId !== undefined) {\n\t\t\t// Found an NACK op, clear it from the directory if the latest sequence number in the directory\n\t\t\t// match the message's and don't process the op.\n\t\t\tif (local) {\n\t\t\t\tassert(\n\t\t\t\t\tlocalOpMetadata !== undefined && isKeyEditLocalOpMetadata(localOpMetadata),\n\t\t\t\t\t0x011 /* pendingMessageId is missing from the local client's operation */,\n\t\t\t\t);\n\t\t\t\tconst pendingMessageIds = this.pendingKeys.get(op.key);\n\t\t\t\tassert(\n\t\t\t\t\tpendingMessageIds !== undefined &&\n\t\t\t\t\t\tpendingMessageIds[0] === localOpMetadata.pendingMessageId,\n\t\t\t\t\t0x331 /* Unexpected pending message received */,\n\t\t\t\t);\n\t\t\t\tpendingMessageIds.shift();\n\t\t\t\tif (pendingMessageIds.length === 0) {\n\t\t\t\t\tthis.pendingKeys.delete(op.key);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\t// If we don't have a NACK op on the key, we need to process the remote ops.\n\t\treturn !local;\n\t}\n\n\t/**\n\t * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should\n\t * not process the incoming operation.\n\t * @param op - Operation to check\n\t * @param local - Whether the message originated from the local client\n\t * @param message - The message\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation should be processed, false otherwise\n\t */\n\tprivate needProcessSubDirectoryOperation(\n\t\top: IDirectorySubDirectoryOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tconst pendingSubDirectoryMessageId = this.pendingSubDirectories.get(op.subdirName);\n\t\tif (pendingSubDirectoryMessageId !== undefined) {\n\t\t\tif (local) {\n\t\t\t\tassert(\n\t\t\t\t\tisSubDirLocalOpMetadata(localOpMetadata),\n\t\t\t\t\t0x012 /* pendingMessageId is missing from the local client's operation */,\n\t\t\t\t);\n\t\t\t\tconst pendingMessageIds = this.pendingSubDirectories.get(op.subdirName);\n\t\t\t\tassert(\n\t\t\t\t\tpendingMessageIds !== undefined &&\n\t\t\t\t\t\tpendingMessageIds[0] === localOpMetadata.pendingMessageId,\n\t\t\t\t\t0x332 /* Unexpected pending message received */,\n\t\t\t\t);\n\t\t\t\tpendingMessageIds.shift();\n\t\t\t\tif (pendingMessageIds.length === 0) {\n\t\t\t\t\tthis.pendingSubDirectories.delete(op.subdirName);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\treturn !local;\n\t}\n\n\t/**\n\t * Clear all keys in memory in response to a remote clear, but retain keys we have modified but not yet been ack'd.\n\t */\n\tprivate clearExceptPendingKeys(local: boolean): void {\n\t\t// Assuming the pendingKeys is small and the map is large\n\t\t// we will get the value for the pendingKeys and clear the map\n\t\tconst temp = new Map<string, ILocalValue>();\n\n\t\tfor (const [key] of this.pendingKeys) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\ttemp.set(key, this._storage.get(key)!);\n\t\t}\n\n\t\tthis.clearCore(local);\n\n\t\tfor (const [key, value] of temp.entries()) {\n\t\t\tthis.setCore(key, value, true);\n\t\t}\n\t}\n\n\t/**\n\t * Clear implementation used for both locally sourced clears as well as incoming remote clears.\n\t * @param local - Whether the message originated from the local client\n\t */\n\tprivate clearCore(local: boolean): void {\n\t\tthis._storage.clear();\n\t\tthis.directory.emit(\"clear\", local, this.directory);\n\t}\n\n\t/**\n\t * Delete implementation used for both locally sourced deletes as well as incoming remote deletes.\n\t * @param key - The key being deleted\n\t * @param local - Whether the message originated from the local client\n\t * @returns Previous local value of the key if it existed, undefined if it did not exist\n\t */\n\tprivate deleteCore(key: string, local: boolean): ILocalValue | undefined {\n\t\tconst previousLocalValue = this._storage.get(key);\n\t\tconst previousValue: unknown = previousLocalValue?.value;\n\t\tconst successfullyRemoved = this._storage.delete(key);\n\t\tif (successfullyRemoved) {\n\t\t\tconst event: IDirectoryValueChanged = { key, path: this.absolutePath, previousValue };\n\t\t\tthis.directory.emit(\"valueChanged\", event, local, this.directory);\n\t\t\tconst containedEvent: IValueChanged = { key, previousValue };\n\t\t\tthis.emit(\"containedValueChanged\", containedEvent, local, this);\n\t\t}\n\t\treturn previousLocalValue;\n\t}\n\n\t/**\n\t * Set implementation used for both locally sourced sets as well as incoming remote sets.\n\t * @param key - The key being set\n\t * @param value - The value being set\n\t * @param local - Whether the message originated from the local client\n\t * @returns Previous local value of the key, if any\n\t */\n\tprivate setCore(key: string, value: ILocalValue, local: boolean): ILocalValue | undefined {\n\t\tconst previousLocalValue = this._storage.get(key);\n\t\tconst previousValue: unknown = previousLocalValue?.value;\n\t\tthis._storage.set(key, value);\n\t\tconst event: IDirectoryValueChanged = { key, path: this.absolutePath, previousValue };\n\t\tthis.directory.emit(\"valueChanged\", event, local, this.directory);\n\t\tconst containedEvent: IValueChanged = { key, previousValue };\n\t\tthis.emit(\"containedValueChanged\", containedEvent, local, this);\n\t\treturn previousLocalValue;\n\t}\n\n\t/**\n\t * Create subdirectory implementation used for both locally sourced creation as well as incoming remote creation.\n\t * @param subdirName - The name of the subdirectory being created\n\t * @param local - Whether the message originated from the local client\n\t * @returns - True if is newly created, false if it already existed.\n\t */\n\tprivate createSubDirectoryCore(subdirName: string, local: boolean): boolean {\n\t\tif (!this._subdirectories.has(subdirName)) {\n\t\t\tconst absolutePath = posix.join(this.absolutePath, subdirName);\n\t\t\tconst subDir = new SubDirectory(\n\t\t\t\tthis.directory,\n\t\t\t\tthis.runtime,\n\t\t\t\tthis.serializer,\n\t\t\t\tabsolutePath,\n\t\t\t);\n\t\t\tthis.registerEventsOnSubDirectory(subDir, subdirName);\n\t\t\tthis._subdirectories.set(subdirName, subDir);\n\t\t\tthis.emit(\"subDirectoryCreated\", subdirName, local, this);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate registerEventsOnSubDirectory(subDirectory: SubDirectory, subDirName: string): void {\n\t\tsubDirectory.on(\"subDirectoryCreated\", (relativePath: string, local: boolean) => {\n\t\t\tthis.emit(\"subDirectoryCreated\", posix.join(subDirName, relativePath), local, this);\n\t\t});\n\t\tsubDirectory.on(\"subDirectoryDeleted\", (relativePath: string, local: boolean) => {\n\t\t\tthis.emit(\"subDirectoryDeleted\", posix.join(subDirName, relativePath), local, this);\n\t\t});\n\t}\n\n\t/**\n\t * Delete subdirectory implementation used for both locally sourced creation as well as incoming remote creation.\n\t * @param subdirName - The name of the subdirectory being deleted\n\t * @param local - Whether the message originated from the local client\n\t */\n\tprivate deleteSubDirectoryCore(subdirName: string, local: boolean): SubDirectory | undefined {\n\t\tconst previousValue = this._subdirectories.get(subdirName);\n\t\t// This should make the subdirectory structure unreachable so it can be GC'd and won't appear in snapshots\n\t\t// Might want to consider cleaning out the structure more exhaustively though? But not when rollback.\n\t\tif (previousValue !== undefined) {\n\t\t\tthis._subdirectories.delete(subdirName);\n\t\t\tthis.disposeSubDirectoryTree(previousValue);\n\t\t\tthis.emit(\"subDirectoryDeleted\", subdirName, local, this);\n\t\t}\n\t\treturn previousValue;\n\t}\n\n\tprivate disposeSubDirectoryTree(directory: IDirectory | undefined): void {\n\t\tif (!directory) {\n\t\t\treturn;\n\t\t}\n\t\t// Dispose the subdirectory tree. This will dispose the subdirectories from bottom to top.\n\t\tconst subDirectories = directory.subdirectories();\n\t\tfor (const [_, subDirectory] of subDirectories) {\n\t\t\tthis.disposeSubDirectoryTree(subDirectory);\n\t\t}\n\t\tif (typeof directory.dispose === \"function\") {\n\t\t\tdirectory.dispose();\n\t\t}\n\t}\n\n\tprivate undeleteSubDirectoryTree(directory: SubDirectory): void {\n\t\t// Restore deleted subdirectory tree. This will unmark \"deleted\" from the subdirectories from bottom to top.\n\t\tfor (const [_, subDirectory] of this._subdirectories.entries()) {\n\t\t\tthis.undeleteSubDirectoryTree(subDirectory);\n\t\t}\n\t\tdirectory.undispose();\n\t}\n}\n"]}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -88,18 +88,18 @@ export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryE
|
|
|
88
88
|
*/
|
|
89
89
|
export interface ISharedDirectoryEvents extends ISharedObjectEvents {
|
|
90
90
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
91
|
+
* Emitted when a key is set or deleted. This is emitted for any key in the {@link ISharedDirectory} or any
|
|
92
|
+
* subdirectory.
|
|
93
|
+
*
|
|
94
|
+
* @remarks Listener parameters:
|
|
95
|
+
*
|
|
96
|
+
* - `changed` - Information on the key that changed, its value prior to the change, and the path to the
|
|
97
|
+
* key that changed.
|
|
98
|
+
*
|
|
99
|
+
* - `local` - Whether the change originated from this client.
|
|
100
|
+
*
|
|
101
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
102
|
+
*/
|
|
103
103
|
(event: "valueChanged", listener: (changed: IDirectoryValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
104
104
|
/**
|
|
105
105
|
* Emitted when the {@link ISharedDirectory} is cleared.
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EACN,WAAW,EACX,MAAM,EACN,cAAc,EACd,qBAAqB,EACrB,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IAGH,aAAa,EAAE,GAAG,CAAC;CACnB;AAED;;;;GAIG;AAGH,MAAM,WAAW,UAChB,SAAQ,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EACvB,cAAc,CAAC,gBAAgB,CAAC,EAChC,OAAO,CAAC,WAA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