@fluidframework/map 2.0.0-internal.2.2.0 → 2.0.0-internal.2.3.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.
Files changed (59) hide show
  1. package/.eslintrc.js +4 -1
  2. package/dist/directory.d.ts +5 -4
  3. package/dist/directory.d.ts.map +1 -1
  4. package/dist/directory.js +26 -11
  5. package/dist/directory.js.map +1 -1
  6. package/dist/interfaces.d.ts +3 -4
  7. package/dist/interfaces.d.ts.map +1 -1
  8. package/dist/interfaces.js.map +1 -1
  9. package/dist/internalInterfaces.d.ts +39 -0
  10. package/dist/internalInterfaces.d.ts.map +1 -1
  11. package/dist/internalInterfaces.js.map +1 -1
  12. package/dist/localValues.d.ts +12 -3
  13. package/dist/localValues.d.ts.map +1 -1
  14. package/dist/localValues.js +10 -0
  15. package/dist/localValues.js.map +1 -1
  16. package/dist/map.d.ts +4 -4
  17. package/dist/map.d.ts.map +1 -1
  18. package/dist/map.js +11 -0
  19. package/dist/map.js.map +1 -1
  20. package/dist/mapKernel.d.ts +5 -5
  21. package/dist/mapKernel.d.ts.map +1 -1
  22. package/dist/mapKernel.js +25 -11
  23. package/dist/mapKernel.js.map +1 -1
  24. package/dist/packageVersion.d.ts +1 -1
  25. package/dist/packageVersion.js +1 -1
  26. package/dist/packageVersion.js.map +1 -1
  27. package/lib/directory.d.ts +5 -4
  28. package/lib/directory.d.ts.map +1 -1
  29. package/lib/directory.js +26 -11
  30. package/lib/directory.js.map +1 -1
  31. package/lib/interfaces.d.ts +3 -4
  32. package/lib/interfaces.d.ts.map +1 -1
  33. package/lib/interfaces.js.map +1 -1
  34. package/lib/internalInterfaces.d.ts +39 -0
  35. package/lib/internalInterfaces.d.ts.map +1 -1
  36. package/lib/internalInterfaces.js.map +1 -1
  37. package/lib/localValues.d.ts +12 -3
  38. package/lib/localValues.d.ts.map +1 -1
  39. package/lib/localValues.js +10 -0
  40. package/lib/localValues.js.map +1 -1
  41. package/lib/map.d.ts +4 -4
  42. package/lib/map.d.ts.map +1 -1
  43. package/lib/map.js +11 -0
  44. package/lib/map.js.map +1 -1
  45. package/lib/mapKernel.d.ts +5 -5
  46. package/lib/mapKernel.d.ts.map +1 -1
  47. package/lib/mapKernel.js +25 -11
  48. package/lib/mapKernel.js.map +1 -1
  49. package/lib/packageVersion.d.ts +1 -1
  50. package/lib/packageVersion.js +1 -1
  51. package/lib/packageVersion.js.map +1 -1
  52. package/package.json +17 -16
  53. package/src/directory.ts +85 -54
  54. package/src/interfaces.ts +19 -9
  55. package/src/internalInterfaces.ts +45 -0
  56. package/src/localValues.ts +18 -7
  57. package/src/map.ts +28 -17
  58. package/src/mapKernel.ts +50 -32
  59. package/src/packageVersion.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { IDisposable, IEvent, IEventProvider, IEventThisPlaceHolder } from \"@fluidframework/common-definitions\";\n\n/**\n * Type of \"valueChanged\" event parameter.\n */\nexport interface IValueChanged {\n /**\n * The key storing the value that changed.\n */\n key: string;\n\n /**\n * The value that was stored at the key prior to the change.\n */\n previousValue: any;\n}\n\n/**\n * Interface describing actions on a directory.\n *\n * @remarks\n * When used as a Map, operates on its keys.\n */\nexport interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryEvents>, Partial<IDisposable> {\n /**\n * The absolute path of the directory.\n */\n readonly absolutePath: string;\n\n /**\n * Retrieves the value stored at the given key from the directory.\n * @param key - Key to retrieve from\n * @returns The stored value, or undefined if the key is not set\n */\n get<T = any>(key: string): T | undefined;\n\n /**\n * Sets the value stored at key to the provided value.\n * @param key - Key to set at\n * @param value - Value to set\n * @returns The IDirectory itself\n */\n set<T = any>(key: string, value: T): this;\n\n /**\n * Get the number of sub directory within the directory.\n * @returns The number of sub directory within a directory.\n */\n countSubDirectory?(): number;\n\n /**\n * Creates an IDirectory child of this IDirectory, or retrieves the existing IDirectory child if one with the\n * same name already exists.\n * @param subdirName - Name of the new child directory to create\n * @returns The IDirectory child that was created or retrieved\n */\n createSubDirectory(subdirName: string): IDirectory;\n\n /**\n * Gets an IDirectory child of this IDirectory, if it exists.\n * @param subdirName - Name of the child directory to get\n * @returns The requested IDirectory\n */\n getSubDirectory(subdirName: string): IDirectory | undefined;\n\n /**\n * Checks whether this directory has a child directory with the given name.\n * @param subdirName - Name of the child directory to check\n * @returns True if it exists, false otherwise\n */\n hasSubDirectory(subdirName: string): boolean;\n\n /**\n * Deletes an IDirectory child of this IDirectory, if it exists, along with all descendent keys and directories.\n * @param subdirName - Name of the child directory to delete\n * @returns True if the IDirectory existed and was deleted, false if it did not exist\n */\n deleteSubDirectory(subdirName: string): boolean;\n\n /**\n * Gets an iterator over the IDirectory children of this IDirectory.\n * @returns The IDirectory iterator\n */\n subdirectories(): IterableIterator<[string, IDirectory]>;\n\n /**\n * Get an IDirectory within the directory, in order to use relative paths from that location.\n * @param relativePath - Path of the IDirectory to get, relative to this IDirectory\n * @returns The requested IDirectory\n */\n getWorkingDirectory(relativePath: string): IDirectory | undefined;\n}\n\n/**\n * Events emitted in response to changes to the directory data.\n * These events only emit on the {@link ISharedDirectory} itself, and not on subdirectories.\n */\nexport interface ISharedDirectoryEvents extends ISharedObjectEvents {\n /**\n * Emitted when a key is set or deleted. This is emitted for any key in the {@link ISharedDirectory} or any\n * subdirectory.\n *\n * @remarks Listener parameters:\n *\n * - `changed` - Information on the key that changed, its value prior to the change, and the path to the\n * key that changed.\n *\n * - `local` - Whether the change originated from this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"valueChanged\", listener: (\n changed: IDirectoryValueChanged,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when the {@link ISharedDirectory} is cleared.\n *\n * @remarks Listener parameters:\n *\n * - `local` - Whether the clear originated from this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"clear\", listener: (\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when a subdirectory is created.\n *\n * @remarks Listener parameters:\n *\n * - `path` - The relative path to the subdirectory that is created.\n * It is relative from the object which raises the event.\n *\n * - `local` - Whether the create originated from the this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"subDirectoryCreated\", listener: (\n path: string,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when a subdirectory is deleted.\n *\n * @remarks Listener parameters:\n *\n * - `path` - The relative path to the subdirectory that is deleted.\n * It is relative from the object which raises the event.\n *\n * - `local` - Whether the delete originated from the this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n (event: \"subDirectoryDeleted\", listener: (\n path: string,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n}\n\n/**\n * Events emitted in response to changes to the directory data.\n */\nexport interface IDirectoryEvents extends IEvent {\n /**\n * Emitted when a key is set or deleted. As opposed to the\n * {@link SharedDirectory}'s valueChanged event, this is emitted only on the {@link IDirectory} that directly\n * contains the key.\n *\n * @remarks Listener parameters:\n *\n * - `changed` - Information on the key that changed and its value prior to the change.\n *\n * - `local` - Whether the change originated from this client.\n *\n * - `target` - The {@link IDirectory} itself.\n */\n (event: \"containedValueChanged\", listener: (\n changed: IValueChanged,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when a subdirectory is created.\n *\n * @remarks Listener parameters:\n *\n * - `path` - The relative path to the subdirectory that is created.\n * It is relative from the object which raises the event.\n *\n * - `local` - Whether the creation originated from the this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"subDirectoryCreated\", listener: (\n path: string,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when a subdirectory is deleted.\n *\n * @remarks Listener parameters:\n *\n * - `path` - The relative path to the subdirectory that is deleted.\n * It is relative from the object which raises the event.\n *\n * - `local` - Whether the delete originated from the this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n (event: \"subDirectoryDeleted\", listener: (\n path: string,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when this sub directory is deleted.\n *\n * @remarks Listener parameters:\n *\n * - `target` - The {@link IDirectory} itself.\n */\n (event: \"disposed\", listener: (\n target: IEventThisPlaceHolder,\n ) => void);\n}\n\n/**\n * 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 */\nexport interface ISharedDirectory extends\n ISharedObject<ISharedDirectoryEvents & IDirectoryEvents>,\n Omit<IDirectory, \"on\" | \"once\" | \"off\"> {\n // The Omit type excludes symbols, which we don't want to exclude. Adding them back here manually.\n // https://github.com/microsoft/TypeScript/issues/31671\n [Symbol.iterator](): IterableIterator<[string, any]>;\n readonly [Symbol.toStringTag]: string;\n}\n\n/**\n * Type of \"valueChanged\" event parameter for {@link ISharedDirectory}\n */\nexport interface IDirectoryValueChanged extends IValueChanged {\n /**\n * The absolute path to the IDirectory storing the key which changed.\n */\n path: string;\n}\n\n/**\n * Events emitted in response to changes to the {@link ISharedMap | map} data.\n */\nexport interface ISharedMapEvents extends ISharedObjectEvents {\n /**\n * Emitted when a key is set or deleted.\n *\n * @remarks Listener parameters:\n *\n * - `changed` - Information on the key that changed and its value prior to the change.\n *\n * - `local` - Whether the change originated from this client.\n *\n * - `target` - The {@link ISharedMap} itself.\n */\n (event: \"valueChanged\", listener: (\n changed: IValueChanged,\n local: boolean,\n target: IEventThisPlaceHolder) => void);\n\n /**\n * Emitted when the map is cleared.\n *\n * @remarks Listener parameters:\n *\n * - `local` - Whether the clear originated from this client.\n *\n * - `target` - The {@link ISharedMap} itself.\n */\n (event: \"clear\", listener: (\n local: boolean,\n target: IEventThisPlaceHolder) => void);\n}\n\n/**\n * The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting\n * and retrieving values that JavaScript developers are accustomed to with the\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.\n * However, the keys of a SharedMap must be strings, and the values must either be a JSON-serializable object or a\n * {@link @fluidframework/datastore#FluidObjectHandle}.\n *\n * For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.\n */\nexport interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {\n /**\n * Retrieves the given key from the map if it exists.\n * @param key - Key to retrieve from\n * @returns The stored value, or undefined if the key is not set\n */\n get<T = any>(key: string): T | undefined;\n\n /**\n * Sets the value stored at key to the provided value.\n * @param key - Key to set\n * @param value - Value to set\n * @returns The {@link ISharedMap} itself\n */\n set<T = any>(key: string, value: T): this;\n}\n\n/**\n * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use\n * {@link ISerializableValue.\"type\"} to understand whether they're storing a Plain JavaScript object,\n * a {@link @fluidframework/shared-object-base#SharedObject}, or a value type.\n *\n * @remarks\n *\n * Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with\n * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to\n * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)\n * and ops (set).\n *\n * If type is Plain, it must be a plain JS object that can survive a JSON.stringify/parse. E.g. a URL object will\n * just get stringified to a URL string and not rehydrate as a URL object on the other side. It may contain members\n * that are ISerializedHandle (the serialized form of a handle).\n *\n * If type is a value type then it must be amongst the types registered via registerValueType or we won't know how\n * to serialize/deserialize it (we rely on its factory via .load() and .store()). Its value will be type-dependent.\n * If type is Shared, then the in-memory value will just be a reference to the SharedObject. Its value will be a\n * channel ID.\n *\n * @deprecated This type is legacy and deprecated.\n */\nexport interface ISerializableValue {\n /**\n * A type annotation to help indicate how the value serializes.\n */\n type: string;\n\n /**\n * The JSONable representation of the value.\n */\n value: any;\n}\n\n/**\n * Serialized {@link ISerializableValue} counterpart.\n */\nexport interface ISerializedValue {\n /**\n * A type annotation to help indicate how the value serializes.\n */\n type: string;\n\n /**\n * String representation of the value.\n *\n * @remarks Will be undefined if the original value was undefined.\n */\n value: string | undefined;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { IDisposable, IEvent, IEventProvider, IEventThisPlaceHolder } from \"@fluidframework/common-definitions\";\n\n/**\n * Type of \"valueChanged\" event parameter.\n */\nexport interface IValueChanged {\n /**\n * The key storing the value that changed.\n */\n key: string;\n\n /**\n * The value that was stored at the key prior to the change.\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n previousValue: any;\n}\n\n/**\n * Interface describing actions on a directory.\n *\n * @remarks When used as a Map, operates on its keys.\n */\n// TODO: Use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryEvents>, Partial<IDisposable> {\n /**\n * The absolute path of the directory.\n */\n readonly absolutePath: string;\n\n /**\n * Retrieves the value stored at the given key from the directory.\n * @param key - Key to retrieve from\n * @returns The stored value, or undefined if the key is not set\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get<T = any>(key: string): T | undefined;\n\n /**\n * Sets the value stored at key to the provided value.\n * @param key - Key to set at\n * @param value - Value to set\n * @returns The IDirectory itself\n */\n set<T = unknown>(key: string, value: T): this;\n\n /**\n * Get the number of sub directory within the directory.\n * @returns The number of sub directory within a directory.\n */\n countSubDirectory?(): number;\n\n /**\n * Creates an IDirectory child of this IDirectory, or retrieves the existing IDirectory child if one with the\n * same name already exists.\n * @param subdirName - Name of the new child directory to create\n * @returns The IDirectory child that was created or retrieved\n */\n createSubDirectory(subdirName: string): IDirectory;\n\n /**\n * Gets an IDirectory child of this IDirectory, if it exists.\n * @param subdirName - Name of the child directory to get\n * @returns The requested IDirectory\n */\n getSubDirectory(subdirName: string): IDirectory | undefined;\n\n /**\n * Checks whether this directory has a child directory with the given name.\n * @param subdirName - Name of the child directory to check\n * @returns True if it exists, false otherwise\n */\n hasSubDirectory(subdirName: string): boolean;\n\n /**\n * Deletes an IDirectory child of this IDirectory, if it exists, along with all descendent keys and directories.\n * @param subdirName - Name of the child directory to delete\n * @returns True if the IDirectory existed and was deleted, false if it did not exist\n */\n deleteSubDirectory(subdirName: string): boolean;\n\n /**\n * Gets an iterator over the IDirectory children of this IDirectory.\n * @returns The IDirectory iterator\n */\n subdirectories(): IterableIterator<[string, IDirectory]>;\n\n /**\n * Get an IDirectory within the directory, in order to use relative paths from that location.\n * @param relativePath - Path of the IDirectory to get, relative to this IDirectory\n * @returns The requested IDirectory\n */\n getWorkingDirectory(relativePath: string): IDirectory | undefined;\n}\n\n/**\n * Events emitted in response to changes to the directory data.\n * These events only emit on the {@link ISharedDirectory} itself, and not on subdirectories.\n */\nexport interface ISharedDirectoryEvents extends ISharedObjectEvents {\n /**\n * Emitted when a key is set or deleted. This is emitted for any key in the {@link ISharedDirectory} or any\n * subdirectory.\n *\n * @remarks Listener parameters:\n *\n * - `changed` - Information on the key that changed, its value prior to the change, and the path to the\n * key that changed.\n *\n * - `local` - Whether the change originated from this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"valueChanged\", listener: (\n changed: IDirectoryValueChanged,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when the {@link ISharedDirectory} is cleared.\n *\n * @remarks Listener parameters:\n *\n * - `local` - Whether the clear originated from this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"clear\", listener: (\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when a subdirectory is created.\n *\n * @remarks Listener parameters:\n *\n * - `path` - The relative path to the subdirectory that is created.\n * It is relative from the object which raises the event.\n *\n * - `local` - Whether the create originated from the this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"subDirectoryCreated\", listener: (\n path: string,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when a subdirectory is deleted.\n *\n * @remarks Listener parameters:\n *\n * - `path` - The relative path to the subdirectory that is deleted.\n * It is relative from the object which raises the event.\n *\n * - `local` - Whether the delete originated from the this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"subDirectoryDeleted\", listener: (\n path: string,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n}\n\n/**\n * Events emitted in response to changes to the directory data.\n */\nexport interface IDirectoryEvents extends IEvent {\n /**\n * Emitted when a key is set or deleted. As opposed to the\n * {@link SharedDirectory}'s valueChanged event, this is emitted only on the {@link IDirectory} that directly\n * contains the key.\n *\n * @remarks Listener parameters:\n *\n * - `changed` - Information on the key that changed and its value prior to the change.\n *\n * - `local` - Whether the change originated from this client.\n *\n * - `target` - The {@link IDirectory} itself.\n */\n (event: \"containedValueChanged\", listener: (\n changed: IValueChanged,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when a subdirectory is created.\n *\n * @remarks Listener parameters:\n *\n * - `path` - The relative path to the subdirectory that is created.\n * It is relative from the object which raises the event.\n *\n * - `local` - Whether the creation originated from the this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"subDirectoryCreated\", listener: (\n path: string,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when a subdirectory is deleted.\n *\n * @remarks Listener parameters:\n *\n * - `path` - The relative path to the subdirectory that is deleted.\n * It is relative from the object which raises the event.\n *\n * - `local` - Whether the delete originated from the this client.\n *\n * - `target` - The {@link ISharedDirectory} itself.\n */\n (event: \"subDirectoryDeleted\", listener: (\n path: string,\n local: boolean,\n target: IEventThisPlaceHolder,\n ) => void);\n\n /**\n * Emitted when this sub directory is deleted.\n *\n * @remarks Listener parameters:\n *\n * - `target` - The {@link IDirectory} itself.\n */\n (event: \"disposed\", listener: (\n target: IEventThisPlaceHolder,\n ) => void);\n}\n\n/**\n * 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 */\nexport interface ISharedDirectory\n extends ISharedObject<ISharedDirectoryEvents & IDirectoryEvents>, Omit<IDirectory, \"on\" | \"once\" | \"off\">\n{\n // The Omit type excludes symbols, which we don't want to exclude. Adding them back here manually.\n // https://github.com/microsoft/TypeScript/issues/31671\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.iterator](): IterableIterator<[string, any]>;\n readonly [Symbol.toStringTag]: string;\n}\n\n/**\n * Type of \"valueChanged\" event parameter for {@link ISharedDirectory}\n */\nexport interface IDirectoryValueChanged extends IValueChanged {\n /**\n * The absolute path to the IDirectory storing the key which changed.\n */\n path: string;\n}\n\n/**\n * Events emitted in response to changes to the {@link ISharedMap | map} data.\n */\nexport interface ISharedMapEvents extends ISharedObjectEvents {\n /**\n * Emitted when a key is set or deleted.\n *\n * @remarks Listener parameters:\n *\n * - `changed` - Information on the key that changed and its value prior to the change.\n *\n * - `local` - Whether the change originated from this client.\n *\n * - `target` - The {@link ISharedMap} itself.\n */\n (event: \"valueChanged\", listener: (\n changed: IValueChanged,\n local: boolean,\n target: IEventThisPlaceHolder) => void);\n\n /**\n * Emitted when the map is cleared.\n *\n * @remarks Listener parameters:\n *\n * - `local` - Whether the clear originated from this client.\n *\n * - `target` - The {@link ISharedMap} itself.\n */\n (event: \"clear\", listener: (\n local: boolean,\n target: IEventThisPlaceHolder) => void);\n}\n\n/**\n * The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting\n * and retrieving values that JavaScript developers are accustomed to with the\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.\n * However, the keys of a SharedMap must be strings, and the values must either be a JSON-serializable object or a\n * {@link @fluidframework/datastore#FluidObjectHandle}.\n *\n * For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.\n */\n// TODO: Use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {\n /**\n * Retrieves the given key from the map if it exists.\n * @param key - Key to retrieve from\n * @returns The stored value, or undefined if the key is not set\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get<T = any>(key: string): T | undefined;\n\n /**\n * Sets the value stored at key to the provided value.\n * @param key - Key to set\n * @param value - Value to set\n * @returns The {@link ISharedMap} itself\n */\n set<T = unknown>(key: string, value: T): this;\n}\n\n/**\n * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use\n * {@link ISerializableValue.\"type\"} to understand whether they're storing a Plain JavaScript object,\n * a {@link @fluidframework/shared-object-base#SharedObject}, or a value type.\n *\n * @remarks\n *\n * Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with\n * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to\n * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)\n * and ops (set).\n *\n * If type is Plain, it must be a plain JS object that can survive a JSON.stringify/parse. E.g. a URL object will\n * just get stringified to a URL string and not rehydrate as a URL object on the other side. It may contain members\n * that are ISerializedHandle (the serialized form of a handle).\n *\n * If type is a value type then it must be amongst the types registered via registerValueType or we won't know how\n * to serialize/deserialize it (we rely on its factory via .load() and .store()). Its value will be type-dependent.\n * If type is Shared, then the in-memory value will just be a reference to the SharedObject. Its value will be a\n * channel ID.\n *\n * @deprecated This type is legacy and deprecated.\n */\nexport interface ISerializableValue {\n /**\n * A type annotation to help indicate how the value serializes.\n */\n type: string;\n\n /**\n * The JSONable representation of the value.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value: any;\n}\n\n/**\n * Serialized {@link ISerializableValue} counterpart.\n */\nexport interface ISerializedValue {\n /**\n * A type annotation to help indicate how the value serializes.\n */\n type: string;\n\n /**\n * String representation of the value.\n *\n * @remarks Will be undefined if the original value was undefined.\n */\n value: string | undefined;\n}\n"]}
@@ -43,20 +43,59 @@ export interface IMapDeleteOperation {
43
43
  */
44
44
  key: string;
45
45
  }
46
+ /**
47
+ * Metadata for an local `edit` operation.
48
+ */
46
49
  export interface IMapKeyEditLocalOpMetadata {
50
+ /**
51
+ * String identifier of the operation type.
52
+ */
47
53
  type: "edit";
54
+ /**
55
+ * Unique identifier for the local operation.
56
+ */
48
57
  pendingMessageId: number;
58
+ /**
59
+ * Local value prior to the edit.
60
+ */
49
61
  previousValue: ILocalValue;
50
62
  }
63
+ /**
64
+ * Metadata for an local `add` operation.
65
+ */
51
66
  export interface IMapKeyAddLocalOpMetadata {
67
+ /**
68
+ * String identifier of the operation type.
69
+ */
52
70
  type: "add";
71
+ /**
72
+ * Unique identifier for the local operation.
73
+ */
53
74
  pendingMessageId: number;
54
75
  }
76
+ /**
77
+ * Metadata for an local `clear` operation.
78
+ */
55
79
  export interface IMapClearLocalOpMetadata {
80
+ /**
81
+ * String identifier of the operation type.
82
+ */
56
83
  type: "clear";
84
+ /**
85
+ * Unique identifier for the local operation.
86
+ */
57
87
  pendingMessageId: number;
88
+ /**
89
+ * Local map contents prior to clearing it.
90
+ */
58
91
  previousMap?: Map<string, ILocalValue>;
59
92
  }
93
+ /**
94
+ * Metadata for a local operation associated with a specific key entry in the map.
95
+ */
60
96
  export declare type MapKeyLocalOpMetadata = IMapKeyEditLocalOpMetadata | IMapKeyAddLocalOpMetadata;
97
+ /**
98
+ * Metadata for a local operation.
99
+ */
61
100
  export declare type MapLocalOpMetadata = IMapClearLocalOpMetadata | MapKeyLocalOpMetadata;
62
101
  //# sourceMappingURL=internalInterfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internalInterfaces.d.ts","sourceRoot":"","sources":["../src/internalInterfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACF,MAAM,WAAW,gBAAgB;IAC9B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC7B;AAED;;GAEG;AACF,MAAM,WAAW,kBAAkB;IAChC;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACF,MAAM,WAAW,mBAAmB;IACjC;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IAEf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,0BAA0B;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,yBAAyB;IACtC,IAAI,EAAE,KAAK,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CAC1C;AAED,oBAAY,qBAAqB,GAAG,0BAA0B,GAAG,yBAAyB,CAA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AAE3F;;GAEG;AACH,oBAAY,kBAAkB,GAAG,wBAAwB,GAAG,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"internalInterfaces.js","sourceRoot":"","sources":["../src/internalInterfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISerializableValue } from \"./interfaces\";\nimport { ILocalValue } from \"./localValues\";\n\n/**\n * Operation indicating a value should be set for a key.\n */\n export interface IMapSetOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"set\";\n\n /**\n * Map key being modified.\n */\n key: string;\n\n /**\n * Value to be set on the key.\n */\n value: ISerializableValue;\n}\n\n/**\n * Operation indicating the map should be cleared.\n */\n export interface IMapClearOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"clear\";\n}\n\n/**\n * Operation indicating a key should be deleted from the map.\n */\n export interface IMapDeleteOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"delete\";\n\n /**\n * Map key being modified.\n */\n key: string;\n}\n\nexport interface IMapKeyEditLocalOpMetadata {\n type: \"edit\";\n pendingMessageId: number;\n previousValue: ILocalValue;\n}\n\nexport interface IMapKeyAddLocalOpMetadata {\n type: \"add\";\n pendingMessageId: number;\n}\n\nexport interface IMapClearLocalOpMetadata {\n type: \"clear\";\n pendingMessageId: number;\n previousMap?: Map<string, ILocalValue>;\n}\n\nexport type MapKeyLocalOpMetadata = IMapKeyEditLocalOpMetadata | IMapKeyAddLocalOpMetadata;\nexport type MapLocalOpMetadata = IMapClearLocalOpMetadata | MapKeyLocalOpMetadata;\n"]}
1
+ {"version":3,"file":"internalInterfaces.js","sourceRoot":"","sources":["../src/internalInterfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISerializableValue } from \"./interfaces\";\nimport { ILocalValue } from \"./localValues\";\n\n/**\n * Operation indicating a value should be set for a key.\n */\n export interface IMapSetOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"set\";\n\n /**\n * Map key being modified.\n */\n key: string;\n\n /**\n * Value to be set on the key.\n */\n value: ISerializableValue;\n}\n\n/**\n * Operation indicating the map should be cleared.\n */\n export interface IMapClearOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"clear\";\n}\n\n/**\n * Operation indicating a key should be deleted from the map.\n */\n export interface IMapDeleteOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"delete\";\n\n /**\n * Map key being modified.\n */\n key: string;\n}\n\n/**\n * Metadata for an local `edit` operation.\n */\nexport interface IMapKeyEditLocalOpMetadata {\n /**\n * String identifier of the operation type.\n */\n type: \"edit\";\n\n /**\n * Unique identifier for the local operation.\n */\n pendingMessageId: number;\n\n /**\n * Local value prior to the edit.\n */\n previousValue: ILocalValue;\n}\n\n/**\n * Metadata for an local `add` operation.\n */\nexport interface IMapKeyAddLocalOpMetadata {\n /**\n * String identifier of the operation type.\n */\n type: \"add\";\n\n /**\n * Unique identifier for the local operation.\n */\n pendingMessageId: number;\n}\n\n/**\n * Metadata for an local `clear` operation.\n */\nexport interface IMapClearLocalOpMetadata {\n /**\n * String identifier of the operation type.\n */\n type: \"clear\";\n\n /**\n * Unique identifier for the local operation.\n */\n pendingMessageId: number;\n\n /**\n * Local map contents prior to clearing it.\n */\n previousMap?: Map<string, ILocalValue>;\n}\n\n/**\n * Metadata for a local operation associated with a specific key entry in the map.\n */\nexport type MapKeyLocalOpMetadata = IMapKeyEditLocalOpMetadata | IMapKeyAddLocalOpMetadata;\n\n/**\n * Metadata for a local operation.\n */\nexport type MapLocalOpMetadata = IMapClearLocalOpMetadata | MapKeyLocalOpMetadata;\n"]}
@@ -25,17 +25,26 @@ export interface ILocalValue {
25
25
  */
26
26
  makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;
27
27
  }
28
+ /**
29
+ * Converts the provided `localValue` to its serialized form.
30
+ *
31
+ * @param localValue - The value to serialize.
32
+ * @param serializer - Data store runtime's serializer.
33
+ * @param bind - Container type's handle.
34
+ *
35
+ * @see {@link ILocalValue.makeSerialized}
36
+ */
28
37
  export declare function makeSerializable(localValue: ILocalValue, serializer: IFluidSerializer, bind: IFluidHandle): ISerializableValue;
29
38
  /**
30
39
  * Manages a contained plain value. May also contain shared object handles.
31
40
  */
32
41
  export declare class PlainLocalValue implements ILocalValue {
33
- readonly value: any;
42
+ readonly value: unknown;
34
43
  /**
35
44
  * Create a new PlainLocalValue.
36
45
  * @param value - The value to store, which may contain shared object handles
37
46
  */
38
- constructor(value: any);
47
+ constructor(value: unknown);
39
48
  /**
40
49
  * {@inheritDoc ILocalValue."type"}
41
50
  */
@@ -66,6 +75,6 @@ export declare class LocalValueMaker {
66
75
  * @param value - The value to store
67
76
  * @returns An ILocalValue containing the value
68
77
  */
69
- fromInMemory(value: any): ILocalValue;
78
+ fromInMemory(value: unknown): ILocalValue;
70
79
  }
71
80
  //# sourceMappingURL=localValues.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localValues.d.ts","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACH,gBAAgB,EAKnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EACnB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC;IAEpB;;;;;OAKG;IACH,cAAc,CACV,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GACnB,gBAAgB,CAAC;CACvB;AAED,wBAAgB,gBAAgB,CAC5B,UAAU,EAAE,WAAW,EACvB,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;;GAEG;AACH,qBAAa,eAAgB,YAAW,WAAW;aAKZ,KAAK,EAAE,OAAO;IAJjD;;;OAGG;gBACgC,KAAK,EAAE,OAAO;IAEjD;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACI,cAAc,CACjB,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GACnB,gBAAgB;CAUtB;AAED;;;GAGG;AACH,qBAAa,eAAe;IAKL,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ9C;;;OAGG;gBACiC,UAAU,EAAE,gBAAgB;IAEhE;;;OAGG;IACI,gBAAgB,CAAC,YAAY,EAAE,kBAAkB,GAAG,WAAW;IAgBtE;;;;OAIG;IACI,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW;CAGnD"}
@@ -3,10 +3,20 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { parseHandles, serializeHandles, ValueType, } from "@fluidframework/shared-object-base";
6
+ /**
7
+ * Converts the provided `localValue` to its serialized form.
8
+ *
9
+ * @param localValue - The value to serialize.
10
+ * @param serializer - Data store runtime's serializer.
11
+ * @param bind - Container type's handle.
12
+ *
13
+ * @see {@link ILocalValue.makeSerialized}
14
+ */
6
15
  export function makeSerializable(localValue, serializer, bind) {
7
16
  const value = localValue.makeSerialized(serializer, bind);
8
17
  return {
9
18
  type: value.type,
19
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
10
20
  value: value.value && JSON.parse(value.value),
11
21
  };
12
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"localValues.js","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGH,YAAY,EACZ,gBAAgB,EAChB,SAAS,GACZ,MAAM,oCAAoC,CAAC;AAgC5C,MAAM,UAAU,gBAAgB,CAC5B,UAAuB,EACvB,UAA4B,EAC5B,IAAkB;IAClB,MAAM,KAAK,GAAG,UAAU,CAAC,cAAc,CAA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IAAI,eAAe,CAAC,eAAe,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,KAAU;QAC1B,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n IFluidSerializer,\n ISerializedHandle,\n parseHandles,\n serializeHandles,\n ValueType,\n} from \"@fluidframework/shared-object-base\";\nimport {\n ISerializableValue,\n ISerializedValue,\n} from \"./interfaces\";\n\n/**\n * A local value to be stored in a container type Distributed Data Store (DDS).\n */\nexport interface ILocalValue {\n /**\n * Type indicator of the value stored within.\n */\n readonly type: string;\n\n /**\n * The in-memory value stored within.\n */\n readonly value: any;\n\n /**\n * Retrieve the serialized form of the value stored within.\n * @param serializer - Data store runtime's serializer\n * @param bind - Container type's handle\n * @returns The serialized form of the contained value\n */\n makeSerialized(\n serializer: IFluidSerializer,\n bind: IFluidHandle,\n ): ISerializedValue;\n}\n\nexport function makeSerializable(\n localValue: ILocalValue,\n serializer: IFluidSerializer,\n bind: IFluidHandle): ISerializableValue {\n const value = localValue.makeSerialized(serializer, bind);\n return {\n type: value.type,\n value: value.value && JSON.parse(value.value),\n };\n}\n\n/**\n * Manages a contained plain value. May also contain shared object handles.\n */\nexport class PlainLocalValue implements ILocalValue {\n /**\n * Create a new PlainLocalValue.\n * @param value - The value to store, which may contain shared object handles\n */\n constructor(public readonly value: any) {\n }\n\n /**\n * {@inheritDoc ILocalValue.\"type\"}\n */\n public get type(): string {\n return ValueType[ValueType.Plain];\n }\n\n /**\n * {@inheritDoc ILocalValue.makeSerialized}\n */\n public makeSerialized(\n serializer: IFluidSerializer,\n bind: IFluidHandle,\n ): ISerializedValue {\n // Stringify to convert to the serialized handle values - and then parse in order to create\n // a POJO for the op\n const value = serializeHandles(this.value, serializer, bind);\n\n return {\n type: this.type,\n value,\n };\n }\n}\n\n/**\n * Enables a container type {@link https://fluidframework.com/docs/build/dds/ | DDS} to produce and store local\n * values with minimal awareness of how those objects are stored, serialized, and deserialized.\n */\nexport class LocalValueMaker {\n /**\n * Create a new LocalValueMaker.\n * @param serializer - The serializer to serialize / parse handles.\n */\n constructor(private readonly serializer: IFluidSerializer) {\n }\n\n /**\n * Create a new local value from an incoming serialized value.\n * @param serializable - The serializable value to make local\n */\n public fromSerializable(serializable: ISerializableValue): ILocalValue {\n // Migrate from old shared value to handles\n if (serializable.type === ValueType[ValueType.Shared]) {\n serializable.type = ValueType[ValueType.Plain];\n const handle: ISerializedHandle = {\n type: \"__fluid_handle__\",\n url: serializable.value as string,\n };\n serializable.value = handle;\n }\n\n const translatedValue = parseHandles(serializable.value, this.serializer);\n\n return new PlainLocalValue(translatedValue);\n }\n\n /**\n * Create a new local value containing a given plain object.\n * @param value - The value to store\n * @returns An ILocalValue containing the value\n */\n public fromInMemory(value: any): ILocalValue {\n return new PlainLocalValue(value);\n }\n}\n"]}
1
+ {"version":3,"file":"localValues.js","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGH,YAAY,EACZ,gBAAgB,EAChB,SAAS,GACZ,MAAM,oCAAoC,CAAC;AAkC5C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC5B,UAAuB,EACvB,UAA4B,EAC5B,IAAkB;IAElB,MAAM,KAAK,GAAG,UAAU,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC1D,OAAO;QACH,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,mEAAmE;QACnE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;KAChD,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,eAAe;IACxB;;;OAGG;IACH,YAAmC,KAAc;QAAd,UAAK,GAAL,KAAK,CAAS;IAAI,CAAC;IAEtD;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,cAAc,CACjB,UAA4B,EAC5B,IAAkB;QAElB,2FAA2F;QAC3F,oBAAoB;QACpB,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAE7D,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK;SACR,CAAC;IACN,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAO,eAAe;IACxB;;;OAGG;IACH,YAAoC,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;IAAI,CAAC;IAErE;;;OAGG;IACI,gBAAgB,CAAC,YAAgC;QACpD,2CAA2C;QAC3C,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;YACnD,YAAY,CAAC,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAC/C,MAAM,MAAM,GAAsB;gBAC9B,IAAI,EAAE,kBAAkB;gBACxB,GAAG,EAAE,YAAY,CAAC,KAAe;aACpC,CAAC;YACF,YAAY,CAAC,KAAK,GAAG,MAAM,CAAC;SAC/B;QAED,MAAM,eAAe,GAAY,YAAY,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEnF,OAAO,IAAI,eAAe,CAAC,eAAe,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,KAAc;QAC9B,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n IFluidSerializer,\n ISerializedHandle,\n parseHandles,\n serializeHandles,\n ValueType,\n} from \"@fluidframework/shared-object-base\";\nimport {\n ISerializableValue,\n ISerializedValue,\n} from \"./interfaces\";\n\n/**\n * A local value to be stored in a container type Distributed Data Store (DDS).\n */\nexport interface ILocalValue {\n /**\n * Type indicator of the value stored within.\n */\n readonly type: string;\n\n /**\n * The in-memory value stored within.\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly value: any;\n\n /**\n * Retrieve the serialized form of the value stored within.\n * @param serializer - Data store runtime's serializer\n * @param bind - Container type's handle\n * @returns The serialized form of the contained value\n */\n makeSerialized(\n serializer: IFluidSerializer,\n bind: IFluidHandle,\n ): ISerializedValue;\n}\n\n/**\n * Converts the provided `localValue` to its serialized form.\n *\n * @param localValue - The value to serialize.\n * @param serializer - Data store runtime's serializer.\n * @param bind - Container type's handle.\n *\n * @see {@link ILocalValue.makeSerialized}\n */\nexport function makeSerializable(\n localValue: ILocalValue,\n serializer: IFluidSerializer,\n bind: IFluidHandle,\n): ISerializableValue {\n const value = localValue.makeSerialized(serializer, bind);\n return {\n type: value.type,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n value: value.value && JSON.parse(value.value),\n };\n}\n\n/**\n * Manages a contained plain value. May also contain shared object handles.\n */\nexport class PlainLocalValue implements ILocalValue {\n /**\n * Create a new PlainLocalValue.\n * @param value - The value to store, which may contain shared object handles\n */\n public constructor(public readonly value: unknown) { }\n\n /**\n * {@inheritDoc ILocalValue.\"type\"}\n */\n public get type(): string {\n return ValueType[ValueType.Plain];\n }\n\n /**\n * {@inheritDoc ILocalValue.makeSerialized}\n */\n public makeSerialized(\n serializer: IFluidSerializer,\n bind: IFluidHandle,\n ): ISerializedValue {\n // Stringify to convert to the serialized handle values - and then parse in order to create\n // a POJO for the op\n const value = serializeHandles(this.value, serializer, bind);\n\n return {\n type: this.type,\n value,\n };\n }\n}\n\n/**\n * Enables a container type {@link https://fluidframework.com/docs/build/dds/ | DDS} to produce and store local\n * values with minimal awareness of how those objects are stored, serialized, and deserialized.\n */\nexport class LocalValueMaker {\n /**\n * Create a new LocalValueMaker.\n * @param serializer - The serializer to serialize / parse handles.\n */\n public constructor(private readonly serializer: IFluidSerializer) { }\n\n /**\n * Create a new local value from an incoming serialized value.\n * @param serializable - The serializable value to make local\n */\n public fromSerializable(serializable: ISerializableValue): ILocalValue {\n // Migrate from old shared value to handles\n if (serializable.type === ValueType[ValueType.Shared]) {\n serializable.type = ValueType[ValueType.Plain];\n const handle: ISerializedHandle = {\n type: \"__fluid_handle__\",\n url: serializable.value as string,\n };\n serializable.value = handle;\n }\n\n const translatedValue: unknown = parseHandles(serializable.value, this.serializer);\n\n return new PlainLocalValue(translatedValue);\n }\n\n /**\n * Create a new local value containing a given plain object.\n * @param value - The value to store\n * @returns An ILocalValue containing the value\n */\n public fromInMemory(value: unknown): ILocalValue {\n return new PlainLocalValue(value);\n }\n}\n"]}
package/lib/map.d.ts CHANGED
@@ -119,7 +119,7 @@ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements
119
119
  /**
120
120
  * {@inheritDoc ISharedMap.set}
121
121
  */
122
- set(key: string, value: any): this;
122
+ set(key: string, value: unknown): this;
123
123
  /**
124
124
  * Delete a key from the map.
125
125
  * @param key - Key to delete
@@ -149,12 +149,12 @@ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements
149
149
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
150
150
  * @internal
151
151
  */
152
- protected reSubmitCore(content: any, localOpMetadata: unknown): void;
152
+ protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
153
153
  /**
154
154
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
155
155
  * @internal
156
156
  */
157
- protected applyStashedOp(content: any): unknown;
157
+ protected applyStashedOp(content: unknown): unknown;
158
158
  /**
159
159
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
160
160
  * @internal
@@ -164,6 +164,6 @@ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements
164
164
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
165
165
  * @internal
166
166
  */
167
- protected rollback(content: any, localOpMetadata: unknown): void;
167
+ protected rollback(content: unknown, localOpMetadata: unknown): void;
168
168
  }
169
169
  //# sourceMappingURL=map.d.ts.map
package/lib/map.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE/F,OAAO,EACH,gBAAgB,EAChB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,UAAU,EACV,gBAAgB,EACnB,MAAM,cAAc,CAAC;AAWtB;;;;GAIG;AACH,qBAAa,UAAW,YAAW,eAAe;IAC9C;;OAEG;IACH,gBAAuB,IAAI,2CAA2C;IAEtE;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF;;OAEG;IACH,IAAW,IAAI,WAEd;IAED;;OAEG;IACH,IAAW,UAAU,uBAEpB;IAED;;OAEG;IACU,IAAI,CACb,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IAOxD;;OAEG;IACI,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU;CAMzE;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,YAAY,C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G,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,GAAG,IAAI;IAK1F;;OAEG;IAGI,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI/C;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAK7C;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAInC;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;;OAGG;IACH,SAAS,CAAC,aAAa,CACnB,UAAU,EAAE,gBAAgB,EAC5B,gBAAgB,CAAC,EAAE,iBAAiB,GACrC,qBAAqB;IAsExB;;;OAGG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxE;;;OAGG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAIxE;;;OAGG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAInD;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAMzG;;;MAGE;IACF,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAGvE"}
package/lib/map.js CHANGED
@@ -110,6 +110,8 @@ export class SharedMap extends SharedObject {
110
110
  * Get an iterator over the entries in this map.
111
111
  * @returns The iterator
112
112
  */
113
+ // TODO: Use `unknown` instead (breaking change).
114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
115
  entries() {
114
116
  return this.kernel.entries();
115
117
  }
@@ -117,6 +119,8 @@ export class SharedMap extends SharedObject {
117
119
  * Get an iterator over the values in this map.
118
120
  * @returns The iterator
119
121
  */
122
+ // TODO: Use `unknown` instead (breaking change).
123
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
124
  values() {
121
125
  return this.kernel.values();
122
126
  }
@@ -124,6 +128,8 @@ export class SharedMap extends SharedObject {
124
128
  * Get an iterator over the entries in this map.
125
129
  * @returns The iterator
126
130
  */
131
+ // TODO: Use `unknown` instead (breaking change).
132
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
133
  [(_a = Symbol.toStringTag, Symbol.iterator)]() {
128
134
  return this.kernel.entries();
129
135
  }
@@ -137,12 +143,17 @@ export class SharedMap extends SharedObject {
137
143
  * Executes the given callback on each entry in the map.
138
144
  * @param callbackFn - Callback function
139
145
  */
146
+ // TODO: Use `unknown` instead (breaking change).
147
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
140
148
  forEach(callbackFn) {
149
+ // eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference
141
150
  this.kernel.forEach(callbackFn);
142
151
  }
143
152
  /**
144
153
  * {@inheritDoc ISharedMap.get}
145
154
  */
155
+ // TODO: Use `unknown` instead (breaking change).
156
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
157
  get(key) {
147
158
  return this.kernel.get(key);
148
159
  }
package/lib/map.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAS9F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAEH,YAAY,GACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAKnE,OAAO,EAA8B,S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,eAAwB;QAC9F,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;SAC3E;IACL,CAAC;IAED;;;MAGE;IACQ,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACrD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, MessageType } 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 { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n IFluidSerializer,\n SharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport {\n ISharedMap,\n ISharedMapEvents,\n} from \"./interfaces\";\nimport { IMapDataObjectSerializable, MapKernel } from \"./mapKernel\";\nimport { pkgVersion } from \"./packageVersion\";\n\ninterface IMapSerializationFormat {\n blobs?: string[];\n content: IMapDataObjectSerializable;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.\n *\n * @sealed\n */\nexport class MapFactory implements IChannelFactory {\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n */\n public static readonly Type = \"https://graph.microsoft.com/types/map\";\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public static readonly Attributes: IChannelAttributes = {\n type: MapFactory.Type,\n snapshotFormatVersion: \"0.2\",\n packageVersion: pkgVersion,\n };\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n */\n public get type() {\n return MapFactory.Type;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public get attributes() {\n return MapFactory.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<ISharedMap> {\n const map = new SharedMap(id, runtime, attributes);\n await map.load(services);\n\n return map;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n */\n public create(runtime: IFluidDataStoreRuntime, id: string): ISharedMap {\n const map = new SharedMap(id, runtime, MapFactory.Attributes);\n map.initializeLocal();\n\n return map;\n }\n}\n\n/**\n * {@inheritDoc ISharedMap}\n */\nexport class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {\n /**\n * Create a new shared map.\n * @param runtime - The data store runtime that the new shared map belongs to.\n * @param id - Optional name of the shared map.\n * @returns Newly created shared map.\n *\n * @example\n * To create a `SharedMap`, call the static create method:\n *\n * ```typescript\n * const myMap = SharedMap.create(this.runtime, id);\n * ```\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string): SharedMap {\n return runtime.createChannel(id, MapFactory.Type) as SharedMap;\n }\n\n /**\n * Get a factory for SharedMap to register with the data store.\n * @returns A factory that creates SharedMaps and loads them from storage.\n */\n public static getFactory(): IChannelFactory {\n return new MapFactory();\n }\n\n /**\n * String representation for the class.\n */\n public readonly [Symbol.toStringTag]: string = \"SharedMap\";\n\n /**\n * MapKernel which manages actual map operations.\n */\n private readonly kernel: MapKernel;\n\n /**\n * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.\n *\n * @param id - String identifier.\n * @param runtime - Data store runtime.\n * @param attributes - The attributes for the map.\n */\n constructor(\n id: string,\n runtime: IFluidDataStoreRuntime,\n attributes: IChannelAttributes,\n ) {\n super(id, runtime, attributes, \"fluid_map_\");\n this.kernel = new MapKernel(\n this.serializer,\n this.handle,\n (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n () => this.isAttached(),\n this,\n );\n }\n\n /**\n * Get an iterator over the keys in this map.\n * @returns The iterator\n */\n public keys(): IterableIterator<string> {\n return this.kernel.keys();\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n public entries(): IterableIterator<[string, any]> {\n return this.kernel.entries();\n }\n\n /**\n * Get an iterator over the values in this map.\n * @returns The iterator\n */\n public values(): IterableIterator<any> {\n return this.kernel.values();\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n public [Symbol.iterator](): IterableIterator<[string, any]> {\n return this.kernel.entries();\n }\n\n /**\n * The number of key/value pairs stored in the map.\n */\n public get size() {\n return this.kernel.size;\n }\n\n /**\n * Executes the given callback on each entry in the map.\n * @param callbackFn - Callback function\n */\n public forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n this.kernel.forEach(callbackFn);\n }\n\n /**\n * {@inheritDoc ISharedMap.get}\n */\n public get<T = any>(key: string): T | undefined {\n return this.kernel.get<T>(key);\n }\n\n /**\n * Check if a key exists in the map.\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.kernel.has(key);\n }\n\n /**\n * {@inheritDoc ISharedMap.set}\n */\n public set(key: string, value: any): this {\n this.kernel.set(key, value);\n return this;\n }\n\n /**\n * Delete a key from the map.\n * @param key - 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.kernel.delete(key);\n }\n\n /**\n * Clear all data from the map.\n */\n public clear(): void {\n this.kernel.clear();\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 let currentSize = 0;\n let counter = 0;\n let headerBlob: IMapDataObjectSerializable = {};\n const blobs: string[] = [];\n\n const builder = new SummaryTreeBuilder();\n\n const data = this.kernel.getSerializedStorage(serializer);\n\n // If single property exceeds this size, it goes into its own blob\n const MinValueSizeSeparateSnapshotBlob = 8 * 1024;\n\n // Maximum blob size for multiple map properties\n // Should be bigger than MinValueSizeSeparateSnapshotBlob\n const MaxSnapshotBlobSize = 16 * 1024;\n\n // Partitioning algorithm:\n // 1) Split large (over MinValueSizeSeparateSnapshotBlob = 8K) properties into their own blobs.\n // Naming (across snapshots) of such blob does not have to be stable across snapshots,\n // As de-duping process (in driver) should not care about paths, only content.\n // 2) Split remaining properties into blobs of MaxSnapshotBlobSize (16K) size.\n // This process does not produce stable partitioning. This means\n // modification (including addition / deletion) of property can shift properties across blobs\n // and result in non-incremental snapshot.\n // This can be improved in the future, without being format breaking change, as loading sequence\n // loads all blobs at once and partitioning schema has no impact on that process.\n for (const key of Object.keys(data)) {\n const value = data[key];\n if (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {\n const blobName = `blob${counter}`;\n counter++;\n blobs.push(blobName);\n const content: IMapDataObjectSerializable = {\n [key]: {\n type: value.type,\n value: JSON.parse(value.value),\n },\n };\n builder.addBlob(blobName, JSON.stringify(content));\n } else {\n currentSize += value.type.length + 21; // Approximation cost of property header\n if (value.value) {\n currentSize += value.value.length;\n }\n\n if (currentSize > MaxSnapshotBlobSize) {\n const blobName = `blob${counter}`;\n counter++;\n blobs.push(blobName);\n builder.addBlob(blobName, JSON.stringify(headerBlob));\n headerBlob = {};\n currentSize = 0;\n }\n headerBlob[key] = {\n type: value.type,\n value: value.value === undefined ? undefined : JSON.parse(value.value),\n };\n }\n }\n\n const header: IMapSerializationFormat = {\n blobs,\n content: headerBlob,\n };\n builder.addBlob(snapshotFileName, JSON.stringify(header));\n\n return builder.getSummaryTree();\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n * @internal\n */\n protected async loadCore(storage: IChannelStorageService) {\n const json = await readAndParse<object>(storage, snapshotFileName);\n const newFormat = json as IMapSerializationFormat;\n if (Array.isArray(newFormat.blobs)) {\n this.kernel.populateFromSerializable(newFormat.content);\n await Promise.all(newFormat.blobs.map(async (value) => {\n const content = await readAndParse<IMapDataObjectSerializable>(storage, value);\n this.kernel.populateFromSerializable(content);\n }));\n } else {\n this.kernel.populateFromSerializable(json as IMapDataObjectSerializable);\n }\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 this.kernel.trySubmitMessage(content, localOpMetadata);\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n * @internal\n */\n protected applyStashedOp(content: any): unknown {\n return this.kernel.tryApplyStashedOp(content);\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n * @internal\n */\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n if (message.type === MessageType.Operation) {\n this.kernel.tryProcessMessage(message.contents, local, localOpMetadata);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n * @internal\n */\n protected rollback(content: any, localOpMetadata: unknown) {\n this.kernel.rollback(content, localOpMetadata);\n }\n}\n"]}
1
+ {"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAS9F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAEH,YAAY,GACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+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,CAAC,CAAC;IAC5E,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,OAAgB;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAwB,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACO,WAAW,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QAC9F,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAyB,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;SAC5F;IACL,CAAC;IAED;;;MAGE;IACQ,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QACzD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, MessageType } 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 { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n IFluidSerializer,\n SharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport {\n ISharedMap,\n ISharedMapEvents,\n} from \"./interfaces\";\nimport { IMapDataObjectSerializable, IMapOperation, MapKernel } from \"./mapKernel\";\nimport { pkgVersion } from \"./packageVersion\";\n\ninterface IMapSerializationFormat {\n blobs?: string[];\n content: IMapDataObjectSerializable;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.\n *\n * @sealed\n */\nexport class MapFactory implements IChannelFactory {\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n */\n public static readonly Type = \"https://graph.microsoft.com/types/map\";\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public static readonly Attributes: IChannelAttributes = {\n type: MapFactory.Type,\n snapshotFormatVersion: \"0.2\",\n packageVersion: pkgVersion,\n };\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n */\n public get type(): string {\n return MapFactory.Type;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public get attributes(): IChannelAttributes {\n return MapFactory.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<ISharedMap> {\n const map = new SharedMap(id, runtime, attributes);\n await map.load(services);\n\n return map;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n */\n public create(runtime: IFluidDataStoreRuntime, id: string): ISharedMap {\n const map = new SharedMap(id, runtime, MapFactory.Attributes);\n map.initializeLocal();\n\n return map;\n }\n}\n\n/**\n * {@inheritDoc ISharedMap}\n */\nexport class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {\n /**\n * Create a new shared map.\n * @param runtime - The data store runtime that the new shared map belongs to.\n * @param id - Optional name of the shared map.\n * @returns Newly created shared map.\n *\n * @example\n * To create a `SharedMap`, call the static create method:\n *\n * ```typescript\n * const myMap = SharedMap.create(this.runtime, id);\n * ```\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string): SharedMap {\n return runtime.createChannel(id, MapFactory.Type) as SharedMap;\n }\n\n /**\n * Get a factory for SharedMap to register with the data store.\n * @returns A factory that creates SharedMaps and loads them from storage.\n */\n public static getFactory(): IChannelFactory {\n return new MapFactory();\n }\n\n /**\n * String representation for the class.\n */\n public readonly [Symbol.toStringTag]: string = \"SharedMap\";\n\n /**\n * MapKernel which manages actual map operations.\n */\n private readonly kernel: MapKernel;\n\n /**\n * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.\n *\n * @param id - String identifier.\n * @param runtime - Data store runtime.\n * @param attributes - The attributes for the map.\n */\n public constructor(\n id: string,\n runtime: IFluidDataStoreRuntime,\n attributes: IChannelAttributes,\n ) {\n super(id, runtime, attributes, \"fluid_map_\");\n this.kernel = new MapKernel(\n this.serializer,\n this.handle,\n (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n () => this.isAttached(),\n this,\n );\n }\n\n /**\n * Get an iterator over the keys in this map.\n * @returns The iterator\n */\n public keys(): IterableIterator<string> {\n return this.kernel.keys();\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public entries(): IterableIterator<[string, any]> {\n return this.kernel.entries();\n }\n\n /**\n * Get an iterator over the values in this map.\n * @returns The iterator\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public values(): IterableIterator<any> {\n return this.kernel.values();\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public [Symbol.iterator](): IterableIterator<[string, any]> {\n return this.kernel.entries();\n }\n\n /**\n * The number of key/value pairs stored in the map.\n */\n public get size(): number {\n return this.kernel.size;\n }\n\n /**\n * Executes the given callback on each entry in the map.\n * @param callbackFn - Callback function\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n // eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference\n this.kernel.forEach(callbackFn);\n }\n\n /**\n * {@inheritDoc ISharedMap.get}\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public get<T = any>(key: string): T | undefined {\n return this.kernel.get<T>(key);\n }\n\n /**\n * Check if a key exists in the map.\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.kernel.has(key);\n }\n\n /**\n * {@inheritDoc ISharedMap.set}\n */\n public set(key: string, value: unknown): this {\n this.kernel.set(key, value);\n return this;\n }\n\n /**\n * Delete a key from the map.\n * @param key - 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.kernel.delete(key);\n }\n\n /**\n * Clear all data from the map.\n */\n public clear(): void {\n this.kernel.clear();\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 let currentSize = 0;\n let counter = 0;\n let headerBlob: IMapDataObjectSerializable = {};\n const blobs: string[] = [];\n\n const builder = new SummaryTreeBuilder();\n\n const data = this.kernel.getSerializedStorage(serializer);\n\n // If single property exceeds this size, it goes into its own blob\n const MinValueSizeSeparateSnapshotBlob = 8 * 1024;\n\n // Maximum blob size for multiple map properties\n // Should be bigger than MinValueSizeSeparateSnapshotBlob\n const MaxSnapshotBlobSize = 16 * 1024;\n\n // Partitioning algorithm:\n // 1) Split large (over MinValueSizeSeparateSnapshotBlob = 8K) properties into their own blobs.\n // Naming (across snapshots) of such blob does not have to be stable across snapshots,\n // As de-duping process (in driver) should not care about paths, only content.\n // 2) Split remaining properties into blobs of MaxSnapshotBlobSize (16K) size.\n // This process does not produce stable partitioning. This means\n // modification (including addition / deletion) of property can shift properties across blobs\n // and result in non-incremental snapshot.\n // This can be improved in the future, without being format breaking change, as loading sequence\n // loads all blobs at once and partitioning schema has no impact on that process.\n for (const key of Object.keys(data)) {\n const value = data[key];\n if (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {\n const blobName = `blob${counter}`;\n counter++;\n blobs.push(blobName);\n const content: IMapDataObjectSerializable = {\n [key]: {\n type: value.type,\n value: JSON.parse(value.value) as unknown,\n },\n };\n builder.addBlob(blobName, JSON.stringify(content));\n } else {\n currentSize += value.type.length + 21; // Approximation cost of property header\n if (value.value) {\n currentSize += value.value.length;\n }\n\n if (currentSize > MaxSnapshotBlobSize) {\n const blobName = `blob${counter}`;\n counter++;\n blobs.push(blobName);\n builder.addBlob(blobName, JSON.stringify(headerBlob));\n headerBlob = {};\n currentSize = 0;\n }\n headerBlob[key] = {\n type: value.type,\n value: value.value === undefined ? undefined : JSON.parse(value.value) as unknown,\n };\n }\n }\n\n const header: IMapSerializationFormat = {\n blobs,\n content: headerBlob,\n };\n builder.addBlob(snapshotFileName, JSON.stringify(header));\n\n return builder.getSummaryTree();\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n * @internal\n */\n protected async loadCore(storage: IChannelStorageService): Promise<void> {\n const json = await readAndParse<object>(storage, snapshotFileName);\n const newFormat = json as IMapSerializationFormat;\n if (Array.isArray(newFormat.blobs)) {\n this.kernel.populateFromSerializable(newFormat.content);\n await Promise.all(newFormat.blobs.map(async (value) => {\n const content = await readAndParse<IMapDataObjectSerializable>(storage, value);\n this.kernel.populateFromSerializable(content);\n }));\n } else {\n this.kernel.populateFromSerializable(json as IMapDataObjectSerializable);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n * @internal\n */\n protected onDisconnect(): void { }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n * @internal\n */\n protected reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n this.kernel.trySubmitMessage(content as IMapOperation, localOpMetadata);\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n * @internal\n */\n protected applyStashedOp(content: unknown): unknown {\n return this.kernel.tryApplyStashedOp(content as IMapOperation);\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 this.kernel.tryProcessMessage(message.contents as IMapOperation, local, localOpMetadata);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n * @internal\n */\n protected rollback(content: unknown, localOpMetadata: unknown): void {\n this.kernel.rollback(content, localOpMetadata);\n }\n}\n"]}
@@ -78,7 +78,7 @@ export declare class MapKernel {
78
78
  * @param valueTypes - The value types to register
79
79
  * @param eventEmitter - The object that will emit map events
80
80
  */
81
- constructor(serializer: IFluidSerializer, handle: IFluidHandle, submitMessage: (op: any, localOpMetadata: unknown) => void, isAttached: () => boolean, eventEmitter: TypedEventEmitter<ISharedMapEvents>);
81
+ constructor(serializer: IFluidSerializer, handle: IFluidHandle, submitMessage: (op: unknown, localOpMetadata: unknown) => void, isAttached: () => boolean, eventEmitter: TypedEventEmitter<ISharedMapEvents>);
82
82
  /**
83
83
  * Get an iterator over the keys in this map.
84
84
  * @returns The iterator
@@ -103,7 +103,7 @@ export declare class MapKernel {
103
103
  * Executes the given callback on each entry in the map.
104
104
  * @param callbackFn - Callback function
105
105
  */
106
- forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void;
106
+ forEach(callbackFn: (value: unknown, key: string, map: Map<string, unknown>) => void): void;
107
107
  /**
108
108
  * {@inheritDoc ISharedMap.get}
109
109
  */
@@ -117,7 +117,7 @@ export declare class MapKernel {
117
117
  /**
118
118
  * {@inheritDoc ISharedMap.set}
119
119
  */
120
- set(key: string, value: any): void;
120
+ set(key: string, value: unknown): void;
121
121
  /**
122
122
  * Delete a key from the map.
123
123
  * @param key - Key to delete
@@ -150,8 +150,8 @@ export declare class MapKernel {
150
150
  * also sent if we are asked to resubmit the message.
151
151
  * @returns True if the operation was submitted, false otherwise.
152
152
  */
153
- trySubmitMessage(op: any, localOpMetadata: unknown): boolean;
154
- tryApplyStashedOp(op: any): unknown;
153
+ trySubmitMessage(op: IMapOperation, localOpMetadata: unknown): boolean;
154
+ tryApplyStashedOp(op: IMapOperation): unknown;
155
155
  /**
156
156
  * Process the given op if a handler is registered.
157
157
  * @param op - The message to process
@@ -1 +1 @@
1
- {"version":3,"file":"mapKernel.d.ts","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAa,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAIrB,MAAM,sBAAsB,CAAC;AAkC9B;;GAEG;AACH,oBAAY,gBAAgB,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAEtE;;GAEG;AACH,oBAAY,aAAa,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;AAElE;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACnC;AAoCD;;GAEG;AACH,qBAAa,SAAS;IAgDd,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAnDjC;;OAEG;IACH,IAAW,IAA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