@fluidframework/map 1.0.1 → 1.1.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/dist/directory.js +4 -4
- package/dist/directory.js.map +1 -1
- package/dist/interfaces.d.ts +13 -14
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/map.d.ts +5 -0
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +7 -0
- package/dist/map.js.map +1 -1
- package/dist/mapKernel.d.ts +20 -11
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +160 -82
- 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.js +4 -4
- package/lib/directory.js.map +1 -1
- package/lib/interfaces.d.ts +13 -14
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/map.d.ts +5 -0
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +7 -0
- package/lib/map.js.map +1 -1
- package/lib/mapKernel.d.ts +20 -11
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +160 -82
- 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 +15 -15
- package/src/directory.ts +4 -4
- package/src/interfaces.ts +14 -16
- package/src/map.ts +8 -0
- package/src/mapKernel.ts +195 -90
- package/src/packageVersion.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qBAAqB,CAAC;AAChC,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/map\";\nexport const pkgVersion = \"1.0
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qBAAqB,CAAC;AAChC,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/map\";\nexport const pkgVersion = \"1.1.0\";\n"]}
|
package/lib/directory.js
CHANGED
|
@@ -1030,13 +1030,13 @@ class SubDirectory extends TypedEventEmitter {
|
|
|
1030
1030
|
// If I have a NACK clear, we can ignore all ops.
|
|
1031
1031
|
return false;
|
|
1032
1032
|
}
|
|
1033
|
-
|
|
1033
|
+
const pendingKeyMessageId = this.pendingKeys.get(op.key);
|
|
1034
|
+
if (pendingKeyMessageId !== undefined) {
|
|
1034
1035
|
// Found an NACK op, clear it from the directory if the latest sequence number in the directory
|
|
1035
1036
|
// match the message's and don't process the op.
|
|
1036
1037
|
if (local) {
|
|
1037
1038
|
assert(localOpMetadata !== undefined, 0x011 /* pendingMessageId is missing from the local client's operation */);
|
|
1038
1039
|
const pendingMessageId = localOpMetadata;
|
|
1039
|
-
const pendingKeyMessageId = this.pendingKeys.get(op.key);
|
|
1040
1040
|
if (pendingKeyMessageId === pendingMessageId) {
|
|
1041
1041
|
this.pendingKeys.delete(op.key);
|
|
1042
1042
|
}
|
|
@@ -1057,11 +1057,11 @@ class SubDirectory extends TypedEventEmitter {
|
|
|
1057
1057
|
* @returns True if the operation should be processed, false otherwise
|
|
1058
1058
|
*/
|
|
1059
1059
|
needProcessSubDirectoryOperations(op, local, localOpMetadata) {
|
|
1060
|
-
|
|
1060
|
+
const pendingSubDirectoryMessageId = this.pendingSubDirectories.get(op.subdirName);
|
|
1061
|
+
if (pendingSubDirectoryMessageId !== undefined) {
|
|
1061
1062
|
if (local) {
|
|
1062
1063
|
assert(localOpMetadata !== undefined, 0x012 /* pendingMessageId is missing from the local client's operation */);
|
|
1063
1064
|
const pendingMessageId = localOpMetadata;
|
|
1064
|
-
const pendingSubDirectoryMessageId = this.pendingSubDirectories.get(op.subdirName);
|
|
1065
1065
|
if (pendingSubDirectoryMessageId === pendingMessageId) {
|
|
1066
1066
|
this.pendingSubDirectories.delete(op.subdirName);
|
|
1067
1067
|
}
|
package/lib/directory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAEH,WAAW,GACd,MAAM,sCAAsC,CAAC;AAS9C,OAAO,EAAoB,YAAY,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAWxC,OAAO,EAEH,eAAe,EACf,gBAAgB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,sFAAsF;AACtF,oDAAoD;AACpD,MAAM,KAAK,GAAgC,IAAI,CAAC,KAAK,CAAC;AAEtD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAkKlC;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAezB;;OAEG;IACH,IAAW,IAAI;QACX,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E,IAAI,aAAa,KAAK,SAAS,EAAE;YAC7B,IAAI,CAAC,uBAAuB,CAAC,aAAa,CAAC,CAAC;YAC5C,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SAC7D;QACD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEO,uBAAuB,CAAC,SAAiC;QAC7D,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO;SACV;QACD,0FAA0F;QAC1F,MAAM,cAAc,GAAG,SAAS,CAAC,cAAc,EAAE,CAAC;QAClD,KAAK,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,cAAc,EAAE;YAC5C,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;SAC9C;QACD,IAAI,OAAO,SAAS,CAAC,OAAO,KAAK,UAAU,EAAE;YACzC,SAAS,CAAC,OAAO,EAAE,CAAC;SACvB;IACL,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: typeof import(\"path\").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\n/**\n * Operation indicating a value should be set for a key.\n */\ninterface 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 */\ninterface 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 */\ntype IDirectoryKeyOperation = IDirectorySetOperation | IDirectoryDeleteOperation;\n\n/**\n * Operation indicating the directory should be cleared.\n */\ninterface 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 */\ntype IDirectoryStorageOperation = IDirectoryKeyOperation | IDirectoryClearOperation;\n\n/**\n * Operation indicating a subdirectory should be created.\n */\ninterface 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 */\ninterface 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 */\ntype IDirectorySubDirectoryOperation = IDirectoryCreateSubDirectoryOperation | 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 * @privateRemarks\n * Directly used in JSON.stringify, direct result from JSON.parse.\n */\nexport interface IDirectoryDataObject {\n storage?: { [key: string]: ISerializableValue; };\n subdirectories?: { [subdirName: string]: IDirectoryDataObject; };\n}\n\nexport interface IDirectoryNewStorageFormat {\n blobs: string[];\n content: IDirectoryDataObject;\n}\n\n/**\n * The factory that defines the directory.\n * @sealed\n */\nexport class DirectoryFactory {\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() {\n return DirectoryFactory.Type;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public get attributes() {\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 * SharedDirectory provides a hierarchical organization of map-like data structures as SubDirectories.\n * The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.\n * SubDirectories can be retrieved for use as working directories.\n *\n * @example\n * ```ts\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 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 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 = any>(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 public forEach(callback: (value: any, key: string, map: Map<string, any>) => void): void {\n this.root.forEach(callback);\n }\n\n /**\n * Get an iterator over the entries under this IDirectory.\n * @returns The iterator\n */\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 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 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.substr(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) {\n this.submitLocalMessage(op, localOpMetadata);\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n * @internal\n */\n protected onDisconnect() {}\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n * @internal\n */\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\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) {\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) {\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 * 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 // We don't reuse the metadata but send a new one on each submit.\n subdir.submitClearMessage(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 // We don't reuse the metadata but send a new one on each submit.\n subdir.submitKeyMessage(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 // We don't reuse the metadata but send a new one on each submit.\n subdir.submitKeyMessage(op);\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.submitSubDirectoryMessage(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.submitSubDirectoryMessage(op);\n }\n },\n },\n );\n }\n\n /**\n * @internal\n */\n protected applyStashedOp() {\n throw new Error(\"not implemented\");\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 // eslint-disable-next-line @typescript-eslint/ban-types\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.substr(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\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 disposed or not.\n */\n private _disposed = 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 * If a clear has been performed locally but not yet ack'd from the server, then this stores the pending id\n * of that clear operation. Otherwise, is -1.\n */\n private pendingClearMessageId: number = -1;\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 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._disposed = true;\n this.emit(\"disposed\", this);\n }\n\n public get disposed(): boolean {\n return this._disposed;\n }\n\n private throwIfDisposed() {\n if (this._disposed) {\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 = any>(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 = any>(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 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);\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 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.submitSubDirectoryMessage(op);\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 successfullyRemoved = this.deleteSubDirectoryCore(subdirName, true);\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return successfullyRemoved;\n }\n\n const op: IDirectoryDeleteSubDirectoryOperation = {\n path: this.absolutePath,\n subdirName,\n type: \"deleteSubDirectory\",\n };\n\n this.submitSubDirectoryMessage(op);\n return successfullyRemoved;\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 successfullyRemoved = this.deleteCore(key, true);\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return successfullyRemoved;\n }\n\n const op: IDirectoryDeleteOperation = {\n key,\n path: this.absolutePath,\n type: \"delete\",\n };\n\n this.submitKeyMessage(op);\n return successfullyRemoved;\n }\n\n /**\n * Deletes all keys from within this IDirectory.\n */\n public clear(): void {\n this.throwIfDisposed();\n // Clear the data locally first.\n this.clearCore(true);\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return;\n }\n\n const op: IDirectoryClearOperation = {\n path: this.absolutePath,\n type: \"clear\",\n };\n this.submitClearMessage(op);\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: any, key: string, map: Map<string, any>) => void): void {\n this.throwIfDisposed();\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, any]> {\n this.throwIfDisposed();\n const localEntriesIterator = this._storage.entries();\n const iterator = {\n next(): IteratorResult<[string, any]> {\n const nextVal = localEntriesIterator.next();\n if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: [nextVal.value[0], nextVal.value[1].value], done: false };\n }\n },\n [Symbol.iterator]() {\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<any> {\n this.throwIfDisposed();\n const localValuesIterator = this._storage.values();\n const iterator = {\n next(): IteratorResult<any> {\n const nextVal = localValuesIterator.next();\n if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: nextVal.value.value, done: false };\n }\n },\n [Symbol.iterator]() {\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, any]> {\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 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 * @internal\n */\n public processClearMessage(\n op: IDirectoryClearOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (local) {\n assert(localOpMetadata !== undefined,\n 0x00f /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageId = localOpMetadata as number;\n if (this.pendingClearMessageId === pendingMessageId) {\n this.pendingClearMessageId = -1;\n }\n return;\n }\n this.clearExceptPendingKeys();\n this.directory.emit(\"clear\", local, this.directory);\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 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 * @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 * Process a set operation.\n * @param op - The op to process\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 * @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 * 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 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 * @internal\n */\n public processCreateSubDirectoryMessage(\n op: IDirectoryCreateSubDirectoryOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {\n return;\n }\n this.createSubDirectoryCore(op.subdirName, local);\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 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 * @internal\n */\n public processDeleteSubDirectoryMessage(\n op: IDirectoryDeleteSubDirectoryOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {\n return;\n }\n this.deleteSubDirectoryCore(op.subdirName, local);\n }\n\n /**\n * Submit a clear operation.\n * @param op - The operation\n * @internal\n */\n public submitClearMessage(op: IDirectoryClearOperation): void {\n this.throwIfDisposed();\n const pendingMessageId = ++this.pendingMessageId;\n this.directory.submitDirectoryMessage(op, pendingMessageId);\n this.pendingClearMessageId = pendingMessageId;\n }\n\n /**\n * Submit a key operation.\n * @param op - The operation\n * @internal\n */\n public submitKeyMessage(op: IDirectoryKeyOperation): void {\n this.throwIfDisposed();\n const pendingMessageId = ++this.pendingMessageId;\n this.directory.submitDirectoryMessage(op, pendingMessageId);\n this.pendingKeys.set(op.key, pendingMessageId);\n }\n\n /**\n * Submit a subdirectory operation.\n * @param op - The operation\n * @internal\n */\n public submitSubDirectoryMessage(op: IDirectorySubDirectoryOperation): void {\n this.throwIfDisposed();\n const pendingMessageId = ++this.pendingMessageId;\n this.directory.submitDirectoryMessage(op, pendingMessageId);\n this.pendingSubDirectories.set(op.subdirName, pendingMessageId);\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) {\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 * 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 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 needProcessStorageOperation(\n op: IDirectoryKeyOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): boolean {\n if (this.pendingClearMessageId !== -1) {\n if (local) {\n assert(localOpMetadata !== undefined && localOpMetadata as number < this.pendingClearMessageId,\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 if (this.pendingKeys.has(op.key)) {\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,\n 0x011 /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageId = localOpMetadata as number;\n const pendingKeyMessageId = this.pendingKeys.get(op.key);\n if (pendingKeyMessageId === pendingMessageId) {\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 needProcessSubDirectoryOperations(\n op: IDirectorySubDirectoryOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): boolean {\n if (this.pendingSubDirectories.has(op.subdirName)) {\n if (local) {\n assert(localOpMetadata !== undefined,\n 0x012 /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageId = localOpMetadata as number;\n const pendingSubDirectoryMessageId = this.pendingSubDirectories.get(op.subdirName);\n if (pendingSubDirectoryMessageId === pendingMessageId) {\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() {\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 this.pendingKeys.forEach((value, key, map) => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n temp.set(key, this._storage.get(key)!);\n });\n this._storage.clear();\n temp.forEach((value, key, map) => {\n this._storage.set(key, value);\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 * @param op - The message if from a remote clear, or null if from a local clear\n */\n private clearCore(local: boolean) {\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 * @param op - The message if from a remote delete, or null if from a local delete\n * @returns True if the key existed and was deleted, false if it did not exist\n */\n private deleteCore(key: string, local: boolean) {\n const previousValue = this.get(key);\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 successfullyRemoved;\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 * @param op - The message if from a remote set, or null if from a local set\n */\n private setCore(key: string, value: ILocalValue, local: boolean) {\n const previousValue = this.get(key);\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 }\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 */\n private createSubDirectoryCore(subdirName: string, local: 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 }\n }\n\n private registerEventsOnSubDirectory(subDirectory: SubDirectory, subDirName: string) {\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 * @param op - The message if from a remote delete, or null if from a local delete\n */\n private deleteSubDirectoryCore(subdirName: string, local: boolean) {\n const previousValue = this.getSubDirectory(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?\n const successfullyRemoved = this._subdirectories.delete(subdirName);\n if (previousValue !== undefined) {\n this.disposeSubDirectoryTree(previousValue);\n this.emit(\"subDirectoryDeleted\", subdirName, local, this);\n }\n return successfullyRemoved;\n }\n\n private disposeSubDirectoryTree(directory: IDirectory | undefined) {\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"]}
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAEH,WAAW,GACd,MAAM,sCAAsC,CAAC;AAS9C,OAAO,EAAoB,YAAY,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAWxC,OAAO,EAEH,eAAe,EACf,gBAAgB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,sFAAsF;AACtF,oDAAoD;AACpD,MAAM,KAAK,GAAgC,IAAI,CAAC,KAAK,CAAC;AAEtD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAkKlC;;;GAGG;AACH,MAAM,OAAO,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,C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C,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;SAC9C;QACD,IAAI,OAAO,SAAS,CAAC,OAAO,KAAK,UAAU,EAAE;YACzC,SAAS,CAAC,OAAO,EAAE,CAAC;SACvB;IACL,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: typeof import(\"path\").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\n/**\n * Operation indicating a value should be set for a key.\n */\ninterface 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 */\ninterface 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 */\ntype IDirectoryKeyOperation = IDirectorySetOperation | IDirectoryDeleteOperation;\n\n/**\n * Operation indicating the directory should be cleared.\n */\ninterface 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 */\ntype IDirectoryStorageOperation = IDirectoryKeyOperation | IDirectoryClearOperation;\n\n/**\n * Operation indicating a subdirectory should be created.\n */\ninterface 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 */\ninterface 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 */\ntype IDirectorySubDirectoryOperation = IDirectoryCreateSubDirectoryOperation | 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 * @privateRemarks\n * Directly used in JSON.stringify, direct result from JSON.parse.\n */\nexport interface IDirectoryDataObject {\n storage?: { [key: string]: ISerializableValue; };\n subdirectories?: { [subdirName: string]: IDirectoryDataObject; };\n}\n\nexport interface IDirectoryNewStorageFormat {\n blobs: string[];\n content: IDirectoryDataObject;\n}\n\n/**\n * The factory that defines the directory.\n * @sealed\n */\nexport class DirectoryFactory {\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() {\n return DirectoryFactory.Type;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public get attributes() {\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 * SharedDirectory provides a hierarchical organization of map-like data structures as SubDirectories.\n * The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.\n * SubDirectories can be retrieved for use as working directories.\n *\n * @example\n * ```ts\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 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 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 = any>(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 public forEach(callback: (value: any, key: string, map: Map<string, any>) => void): void {\n this.root.forEach(callback);\n }\n\n /**\n * Get an iterator over the entries under this IDirectory.\n * @returns The iterator\n */\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 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 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.substr(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) {\n this.submitLocalMessage(op, localOpMetadata);\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n * @internal\n */\n protected onDisconnect() {}\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n * @internal\n */\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\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) {\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) {\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 * 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 // We don't reuse the metadata but send a new one on each submit.\n subdir.submitClearMessage(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 // We don't reuse the metadata but send a new one on each submit.\n subdir.submitKeyMessage(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 // We don't reuse the metadata but send a new one on each submit.\n subdir.submitKeyMessage(op);\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.submitSubDirectoryMessage(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.submitSubDirectoryMessage(op);\n }\n },\n },\n );\n }\n\n /**\n * @internal\n */\n protected applyStashedOp() {\n throw new Error(\"not implemented\");\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 // eslint-disable-next-line @typescript-eslint/ban-types\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.substr(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\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 disposed or not.\n */\n private _disposed = 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 * If a clear has been performed locally but not yet ack'd from the server, then this stores the pending id\n * of that clear operation. Otherwise, is -1.\n */\n private pendingClearMessageId: number = -1;\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 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._disposed = true;\n this.emit(\"disposed\", this);\n }\n\n public get disposed(): boolean {\n return this._disposed;\n }\n\n private throwIfDisposed() {\n if (this._disposed) {\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 = any>(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 = any>(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 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);\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 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.submitSubDirectoryMessage(op);\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 successfullyRemoved = this.deleteSubDirectoryCore(subdirName, true);\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return successfullyRemoved;\n }\n\n const op: IDirectoryDeleteSubDirectoryOperation = {\n path: this.absolutePath,\n subdirName,\n type: \"deleteSubDirectory\",\n };\n\n this.submitSubDirectoryMessage(op);\n return successfullyRemoved;\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 successfullyRemoved = this.deleteCore(key, true);\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return successfullyRemoved;\n }\n\n const op: IDirectoryDeleteOperation = {\n key,\n path: this.absolutePath,\n type: \"delete\",\n };\n\n this.submitKeyMessage(op);\n return successfullyRemoved;\n }\n\n /**\n * Deletes all keys from within this IDirectory.\n */\n public clear(): void {\n this.throwIfDisposed();\n // Clear the data locally first.\n this.clearCore(true);\n\n // If we are not attached, don't submit the op.\n if (!this.directory.isAttached()) {\n return;\n }\n\n const op: IDirectoryClearOperation = {\n path: this.absolutePath,\n type: \"clear\",\n };\n this.submitClearMessage(op);\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: any, key: string, map: Map<string, any>) => void): void {\n this.throwIfDisposed();\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, any]> {\n this.throwIfDisposed();\n const localEntriesIterator = this._storage.entries();\n const iterator = {\n next(): IteratorResult<[string, any]> {\n const nextVal = localEntriesIterator.next();\n if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: [nextVal.value[0], nextVal.value[1].value], done: false };\n }\n },\n [Symbol.iterator]() {\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<any> {\n this.throwIfDisposed();\n const localValuesIterator = this._storage.values();\n const iterator = {\n next(): IteratorResult<any> {\n const nextVal = localValuesIterator.next();\n if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: nextVal.value.value, done: false };\n }\n },\n [Symbol.iterator]() {\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, any]> {\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 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 * @internal\n */\n public processClearMessage(\n op: IDirectoryClearOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (local) {\n assert(localOpMetadata !== undefined,\n 0x00f /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageId = localOpMetadata as number;\n if (this.pendingClearMessageId === pendingMessageId) {\n this.pendingClearMessageId = -1;\n }\n return;\n }\n this.clearExceptPendingKeys();\n this.directory.emit(\"clear\", local, this.directory);\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 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 * @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 * Process a set operation.\n * @param op - The op to process\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 * @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 * 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 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 * @internal\n */\n public processCreateSubDirectoryMessage(\n op: IDirectoryCreateSubDirectoryOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {\n return;\n }\n this.createSubDirectoryCore(op.subdirName, local);\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 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 * @internal\n */\n public processDeleteSubDirectoryMessage(\n op: IDirectoryDeleteSubDirectoryOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): void {\n this.throwIfDisposed();\n if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {\n return;\n }\n this.deleteSubDirectoryCore(op.subdirName, local);\n }\n\n /**\n * Submit a clear operation.\n * @param op - The operation\n * @internal\n */\n public submitClearMessage(op: IDirectoryClearOperation): void {\n this.throwIfDisposed();\n const pendingMessageId = ++this.pendingMessageId;\n this.directory.submitDirectoryMessage(op, pendingMessageId);\n this.pendingClearMessageId = pendingMessageId;\n }\n\n /**\n * Submit a key operation.\n * @param op - The operation\n * @internal\n */\n public submitKeyMessage(op: IDirectoryKeyOperation): void {\n this.throwIfDisposed();\n const pendingMessageId = ++this.pendingMessageId;\n this.directory.submitDirectoryMessage(op, pendingMessageId);\n this.pendingKeys.set(op.key, pendingMessageId);\n }\n\n /**\n * Submit a subdirectory operation.\n * @param op - The operation\n * @internal\n */\n public submitSubDirectoryMessage(op: IDirectorySubDirectoryOperation): void {\n this.throwIfDisposed();\n const pendingMessageId = ++this.pendingMessageId;\n this.directory.submitDirectoryMessage(op, pendingMessageId);\n this.pendingSubDirectories.set(op.subdirName, pendingMessageId);\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) {\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 * 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 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 needProcessStorageOperation(\n op: IDirectoryKeyOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): boolean {\n if (this.pendingClearMessageId !== -1) {\n if (local) {\n assert(localOpMetadata !== undefined && localOpMetadata as number < this.pendingClearMessageId,\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,\n 0x011 /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageId = localOpMetadata as number;\n if (pendingKeyMessageId === pendingMessageId) {\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 needProcessSubDirectoryOperations(\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(localOpMetadata !== undefined,\n 0x012 /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageId = localOpMetadata as number;\n if (pendingSubDirectoryMessageId === pendingMessageId) {\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() {\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 this.pendingKeys.forEach((value, key, map) => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n temp.set(key, this._storage.get(key)!);\n });\n this._storage.clear();\n temp.forEach((value, key, map) => {\n this._storage.set(key, value);\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 * @param op - The message if from a remote clear, or null if from a local clear\n */\n private clearCore(local: boolean) {\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 * @param op - The message if from a remote delete, or null if from a local delete\n * @returns True if the key existed and was deleted, false if it did not exist\n */\n private deleteCore(key: string, local: boolean) {\n const previousValue = this.get(key);\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 successfullyRemoved;\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 * @param op - The message if from a remote set, or null if from a local set\n */\n private setCore(key: string, value: ILocalValue, local: boolean) {\n const previousValue = this.get(key);\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 }\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 */\n private createSubDirectoryCore(subdirName: string, local: 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 }\n }\n\n private registerEventsOnSubDirectory(subDirectory: SubDirectory, subDirName: string) {\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 * @param op - The message if from a remote delete, or null if from a local delete\n */\n private deleteSubDirectoryCore(subdirName: string, local: boolean) {\n const previousValue = this.getSubDirectory(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?\n const successfullyRemoved = this._subdirectories.delete(subdirName);\n if (previousValue !== undefined) {\n this.disposeSubDirectoryTree(previousValue);\n this.emit(\"subDirectoryDeleted\", subdirName, local, this);\n }\n return successfullyRemoved;\n }\n\n private disposeSubDirectoryTree(directory: IDirectory | undefined) {\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"]}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -130,9 +130,10 @@ export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryE
|
|
|
130
130
|
* ```typescript
|
|
131
131
|
* (path: string, local: boolean, target: IEventThisPlaceHolder) => void
|
|
132
132
|
* ```
|
|
133
|
-
* - `path` - The relative path to the
|
|
133
|
+
* - `path` - The relative path to the subdirectory that is created.
|
|
134
|
+
* It is relative from the object which raises the event.
|
|
134
135
|
*
|
|
135
|
-
* - `local` - Whether the
|
|
136
|
+
* - `local` - Whether the create originated from the this client.
|
|
136
137
|
*
|
|
137
138
|
* - `target` - The ISharedDirectory itself.
|
|
138
139
|
*
|
|
@@ -145,9 +146,10 @@ export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryE
|
|
|
145
146
|
* ```typescript
|
|
146
147
|
* (path: string, local: boolean, target: IEventThisPlaceHolder) => void
|
|
147
148
|
* ```
|
|
148
|
-
* - `path` - The relative path to the
|
|
149
|
+
* - `path` - The relative path to the subdirectory that is deleted.
|
|
150
|
+
* It is relative from the object which raises the event.
|
|
149
151
|
*
|
|
150
|
-
* - `local` - Whether the
|
|
152
|
+
* - `local` - Whether the delete originated from the this client.
|
|
151
153
|
*
|
|
152
154
|
* - `target` - The ISharedDirectory itself.
|
|
153
155
|
*/
|
|
@@ -185,9 +187,10 @@ export interface ISharedDirectoryEvents extends ISharedObjectEvents {
|
|
|
185
187
|
* ```typescript
|
|
186
188
|
* (path: string, local: boolean, target: IEventThisPlaceHolder) => void
|
|
187
189
|
* ```
|
|
188
|
-
* - `path` - The relative path to the
|
|
190
|
+
* - `path` - The relative path to the subdirectory that is created.
|
|
191
|
+
* It is relative from the object which raises the event.
|
|
189
192
|
*
|
|
190
|
-
* - `local` - Whether the
|
|
193
|
+
* - `local` - Whether the creation originated from the this client.
|
|
191
194
|
*
|
|
192
195
|
* - `target` - The ISharedDirectory itself.
|
|
193
196
|
*
|
|
@@ -200,9 +203,10 @@ export interface ISharedDirectoryEvents extends ISharedObjectEvents {
|
|
|
200
203
|
* ```typescript
|
|
201
204
|
* (path: string, local: boolean, target: IEventThisPlaceHolder) => void
|
|
202
205
|
* ```
|
|
203
|
-
* - `path` - The relative path to the
|
|
206
|
+
* - `path` - The relative path to the subdirectory that is deleted.
|
|
207
|
+
* It is relative from the object which raises the event.
|
|
204
208
|
*
|
|
205
|
-
* - `local` - Whether the
|
|
209
|
+
* - `local` - Whether the delete originated from the this client.
|
|
206
210
|
*
|
|
207
211
|
* - `target` - The ISharedDirectory itself.
|
|
208
212
|
*
|
|
@@ -253,7 +257,6 @@ export interface IDirectoryValueChanged extends IValueChanged {
|
|
|
253
257
|
* (
|
|
254
258
|
* changed: IValueChanged,
|
|
255
259
|
* local: boolean,
|
|
256
|
-
* op: ISequencedDocumentMessage | null,
|
|
257
260
|
* target: IEventThisPlaceHolder,
|
|
258
261
|
* ) => void
|
|
259
262
|
* ```
|
|
@@ -261,8 +264,6 @@ export interface IDirectoryValueChanged extends IValueChanged {
|
|
|
261
264
|
*
|
|
262
265
|
* - `local` - Whether the change originated from the this client.
|
|
263
266
|
*
|
|
264
|
-
* - `op` - The op that caused the change in value.
|
|
265
|
-
*
|
|
266
267
|
* - `target` - The map itself.
|
|
267
268
|
*
|
|
268
269
|
* ### "clear"
|
|
@@ -272,12 +273,10 @@ export interface IDirectoryValueChanged extends IValueChanged {
|
|
|
272
273
|
* #### Listener signature
|
|
273
274
|
*
|
|
274
275
|
* ```typescript
|
|
275
|
-
* (local: boolean,
|
|
276
|
+
* (local: boolean, target: IEventThisPlaceHolder) => void
|
|
276
277
|
* ```
|
|
277
278
|
* - `local` - Whether the clear originated from the this client.
|
|
278
279
|
*
|
|
279
|
-
* - `op` - The op that caused the clear.
|
|
280
|
-
*
|
|
281
280
|
* - `target` - The map itself.
|
|
282
281
|
*/
|
|
283
282
|
export interface ISharedMapEvents extends ISharedObjectEvents {
|
package/lib/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,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAEhH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IAC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