@fluidframework/map 2.42.0 → 2.43.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 (43) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/directory.d.ts +2 -16
  3. package/dist/directory.d.ts.map +1 -1
  4. package/dist/directory.js +21 -38
  5. package/dist/directory.js.map +1 -1
  6. package/dist/localValues.d.ts +10 -58
  7. package/dist/localValues.d.ts.map +1 -1
  8. package/dist/localValues.js +29 -83
  9. package/dist/localValues.js.map +1 -1
  10. package/dist/map.d.ts.map +1 -1
  11. package/dist/map.js +4 -4
  12. package/dist/map.js.map +1 -1
  13. package/dist/mapKernel.d.ts +5 -22
  14. package/dist/mapKernel.d.ts.map +1 -1
  15. package/dist/mapKernel.js +14 -57
  16. package/dist/mapKernel.js.map +1 -1
  17. package/dist/packageVersion.d.ts +1 -1
  18. package/dist/packageVersion.js +1 -1
  19. package/dist/packageVersion.js.map +1 -1
  20. package/lib/directory.d.ts +2 -16
  21. package/lib/directory.d.ts.map +1 -1
  22. package/lib/directory.js +22 -39
  23. package/lib/directory.js.map +1 -1
  24. package/lib/localValues.d.ts +10 -58
  25. package/lib/localValues.d.ts.map +1 -1
  26. package/lib/localValues.js +26 -79
  27. package/lib/localValues.js.map +1 -1
  28. package/lib/map.d.ts.map +1 -1
  29. package/lib/map.js +4 -4
  30. package/lib/map.js.map +1 -1
  31. package/lib/mapKernel.d.ts +5 -22
  32. package/lib/mapKernel.d.ts.map +1 -1
  33. package/lib/mapKernel.js +15 -58
  34. package/lib/mapKernel.js.map +1 -1
  35. package/lib/packageVersion.d.ts +1 -1
  36. package/lib/packageVersion.js +1 -1
  37. package/lib/packageVersion.js.map +1 -1
  38. package/package.json +20 -20
  39. package/src/directory.ts +30 -59
  40. package/src/localValues.ts +33 -106
  41. package/src/map.ts +7 -5
  42. package/src/mapKernel.ts +24 -74
  43. package/src/packageVersion.ts +1 -1
@@ -9,70 +9,22 @@ import type { ISerializableValue, ISerializedValue } from "./internalInterfaces.
9
9
  * A local value to be stored in a container type Distributed Data Store (DDS).
10
10
  */
11
11
  export interface ILocalValue {
12
- /**
13
- * Type indicator of the value stored within.
14
- */
15
- readonly type: string;
16
12
  /**
17
13
  * The in-memory value stored within.
18
14
  */
19
- readonly value: any;
20
- /**
21
- * Retrieve the serialized form of the value stored within.
22
- * @param serializer - Data store runtime's serializer
23
- * @param bind - Container type's handle
24
- * @returns The serialized form of the contained value
25
- */
26
- makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;
15
+ readonly value: unknown;
27
16
  }
28
17
  /**
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}
18
+ * Convert a value to its serialized form, i.e. to be used in ops and summaries.
36
19
  */
37
- export declare function makeSerializable(localValue: ILocalValue, serializer: IFluidSerializer, bind: IFluidHandle): ISerializableValue;
20
+ export declare const serializeValue: (value: unknown, serializer: IFluidSerializer, bind: IFluidHandle) => ISerializedValue;
38
21
  /**
39
- * Manages a contained plain value. May also contain shared object handles.
40
- */
41
- export declare class PlainLocalValue implements ILocalValue {
42
- readonly value: unknown;
43
- /**
44
- * Create a new PlainLocalValue.
45
- * @param value - The value to store, which may contain shared object handles
46
- */
47
- constructor(value: unknown);
48
- /**
49
- * {@inheritDoc ILocalValue."type"}
50
- */
51
- get type(): string;
52
- /**
53
- * {@inheritDoc ILocalValue.makeSerialized}
54
- */
55
- makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;
56
- }
57
- /**
58
- * Enables a container type {@link https://fluidframework.com/docs/build/dds/ | DDS} to produce and store local
59
- * values with minimal awareness of how those objects are stored, serialized, and deserialized.
22
+ * Very old versions of Fluid permitted a different type of stored value, which represented a
23
+ * SharedObject held directly. This functionality has since been replaced with handles.
24
+ *
25
+ * If the passed serializable is one of these old values, this function will mutate it to a modern
26
+ * value with a handle. Otherwise it does nothing.
27
+ * @param serializable - The serializable value to potentially convert.
60
28
  */
61
- export declare class LocalValueMaker {
62
- /**
63
- * Create a new LocalValueMaker.
64
- */
65
- constructor();
66
- /**
67
- * Create a new local value from an incoming serialized value.
68
- * @param serializable - The serializable value to make local
69
- */
70
- fromSerializable(serializable: ISerializableValue, serializer: IFluidSerializer, bind: IFluidHandle): ILocalValue;
71
- /**
72
- * Create a new local value containing a given plain object.
73
- * @param value - The value to store
74
- * @returns An ILocalValue containing the value
75
- */
76
- fromInMemory(value: unknown): ILocalValue;
77
- }
29
+ export declare const migrateIfSharedSerializable: (serializable: ISerializableValue, serializer: IFluidSerializer, bind: IFluidHandle) => void;
78
30
  //# 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,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAQpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IAGH,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC;IAEpB;;;;;OAKG;IACH,cAAc,CAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAAC;CACnF;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,WAAW,EACvB,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GAEhB,kBAAkB,CAOpB;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,WAAW;aAKf,KAAK,EAAE,OAAO;IAJjD;;;OAGG;gBACgC,KAAK,EAAE,OAAO;IAEjD;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACI,cAAc,CAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,GAAG,gBAAgB;CAUzF;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC3B;;OAEG;;IAGH;;;OAGG;IACI,gBAAgB,CAEtB,YAAY,EAAE,kBAAkB,EAChC,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GAChB,WAAW;IAkBd;;;;OAIG;IACI,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW;CAGhD"}
1
+ {"version":3,"file":"localValues.d.ts","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAQpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,UACnB,OAAO,cACF,gBAAgB,QACtB,YAAY,KAChB,gBAOF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,iBAEzB,kBAAkB,cACpB,gBAAgB,QACtB,YAAY,KAChB,IAaF,CAAC"}
@@ -4,96 +4,42 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.LocalValueMaker = exports.PlainLocalValue = exports.makeSerializable = void 0;
7
+ exports.migrateIfSharedSerializable = exports.serializeValue = void 0;
8
8
  const internal_1 = require("@fluidframework/shared-object-base/internal");
9
9
  /**
10
- * Converts the provided `localValue` to its serialized form.
11
- *
12
- * @param localValue - The value to serialize.
13
- * @param serializer - Data store runtime's serializer.
14
- * @param bind - Container type's handle.
15
- *
16
- * @see {@link ILocalValue.makeSerialized}
10
+ * Convert a value to its serialized form, i.e. to be used in ops and summaries.
17
11
  */
18
- function makeSerializable(localValue, serializer, bind) {
19
- const value = localValue.makeSerialized(serializer, bind);
12
+ const serializeValue = (value, serializer, bind) => {
13
+ const serializedValue = (0, internal_1.serializeHandles)(value, serializer, bind);
20
14
  return {
21
- type: value.type,
22
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
23
- value: value.value && JSON.parse(value.value),
15
+ type: internal_1.ValueType[internal_1.ValueType.Plain],
16
+ value: serializedValue,
24
17
  };
25
- }
26
- exports.makeSerializable = makeSerializable;
18
+ };
19
+ exports.serializeValue = serializeValue;
27
20
  /**
28
- * Manages a contained plain value. May also contain shared object handles.
21
+ * Very old versions of Fluid permitted a different type of stored value, which represented a
22
+ * SharedObject held directly. This functionality has since been replaced with handles.
23
+ *
24
+ * If the passed serializable is one of these old values, this function will mutate it to a modern
25
+ * value with a handle. Otherwise it does nothing.
26
+ * @param serializable - The serializable value to potentially convert.
29
27
  */
30
- class PlainLocalValue {
31
- /**
32
- * Create a new PlainLocalValue.
33
- * @param value - The value to store, which may contain shared object handles
34
- */
35
- constructor(value) {
36
- this.value = value;
37
- }
38
- /**
39
- * {@inheritDoc ILocalValue."type"}
40
- */
41
- get type() {
42
- return internal_1.ValueType[internal_1.ValueType.Plain];
43
- }
44
- /**
45
- * {@inheritDoc ILocalValue.makeSerialized}
46
- */
47
- makeSerialized(serializer, bind) {
48
- // Stringify to convert to the serialized handle values - and then parse in order to create
49
- // a POJO for the op
50
- const value = (0, internal_1.serializeHandles)(this.value, serializer, bind);
51
- return {
52
- type: this.type,
53
- value,
28
+ const migrateIfSharedSerializable = (
29
+ // eslint-disable-next-line import/no-deprecated
30
+ serializable, serializer, bind) => {
31
+ // Migrate from old shared value to handles
32
+ if (serializable.type === internal_1.ValueType[internal_1.ValueType.Shared]) {
33
+ serializable.type = internal_1.ValueType[internal_1.ValueType.Plain];
34
+ const handle = {
35
+ type: "__fluid_handle__",
36
+ url: serializable.value,
54
37
  };
38
+ // NOTE: here we require the use of `parseHandles` because the roundtrip
39
+ // through a string is necessary to resolve the absolute path of
40
+ // legacy handles (`ValueType.Shared`)
41
+ serializable.value = serializer.encode((0, internal_1.parseHandles)(handle, serializer), bind);
55
42
  }
56
- }
57
- exports.PlainLocalValue = PlainLocalValue;
58
- /**
59
- * Enables a container type {@link https://fluidframework.com/docs/build/dds/ | DDS} to produce and store local
60
- * values with minimal awareness of how those objects are stored, serialized, and deserialized.
61
- */
62
- class LocalValueMaker {
63
- /**
64
- * Create a new LocalValueMaker.
65
- */
66
- constructor() { }
67
- /**
68
- * Create a new local value from an incoming serialized value.
69
- * @param serializable - The serializable value to make local
70
- */
71
- fromSerializable(
72
- // eslint-disable-next-line import/no-deprecated
73
- serializable, serializer, bind) {
74
- // Migrate from old shared value to handles
75
- if (serializable.type === internal_1.ValueType[internal_1.ValueType.Shared]) {
76
- serializable.type = internal_1.ValueType[internal_1.ValueType.Plain];
77
- const handle = {
78
- type: "__fluid_handle__",
79
- url: serializable.value,
80
- };
81
- // NOTE: here we require the use of `parseHandles` because the roundtrip
82
- // through a string is necessary to resolve the absolute path of
83
- // legacy handles (`ValueType.Shared`)
84
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
85
- serializable.value = serializer.encode((0, internal_1.parseHandles)(handle, serializer), bind);
86
- }
87
- return new PlainLocalValue(serializable.value);
88
- }
89
- /**
90
- * Create a new local value containing a given plain object.
91
- * @param value - The value to store
92
- * @returns An ILocalValue containing the value
93
- */
94
- fromInMemory(value) {
95
- return new PlainLocalValue(value);
96
- }
97
- }
98
- exports.LocalValueMaker = LocalValueMaker;
43
+ };
44
+ exports.migrateIfSharedSerializable = migrateIfSharedSerializable;
99
45
  //# sourceMappingURL=localValues.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"localValues.js","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,0EAIqD;AA8BrD;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAC/B,UAAuB,EACvB,UAA4B,EAC5B,IAAkB;IAGlB,MAAM,KAAK,GAAG,UAAU,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC1D,OAAO;QACN,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,mEAAmE;QACnE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;KAC7C,CAAC;AACH,CAAC;AAZD,4CAYC;AAED;;GAEG;AACH,MAAa,eAAe;IAC3B;;;OAGG;IACH,YAAmC,KAAc;QAAd,UAAK,GAAL,KAAK,CAAS;IAAG,CAAC;IAErD;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,oBAAS,CAAC,oBAAS,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,UAA4B,EAAE,IAAkB;QACrE,2FAA2F;QAC3F,oBAAoB;QACpB,MAAM,KAAK,GAAG,IAAA,2BAAgB,EAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAE7D,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK;SACL,CAAC;IACH,CAAC;CACD;AA3BD,0CA2BC;AAED;;;GAGG;AACH,MAAa,eAAe;IAC3B;;OAEG;IACH,gBAAsB,CAAC;IAEvB;;;OAGG;IACI,gBAAgB;IACtB,gDAAgD;IAChD,YAAgC,EAChC,UAA4B,EAC5B,IAAkB;QAElB,2CAA2C;QAC3C,IAAI,YAAY,CAAC,IAAI,KAAK,oBAAS,CAAC,oBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YACvD,YAAY,CAAC,IAAI,GAAG,oBAAS,CAAC,oBAAS,CAAC,KAAK,CAAC,CAAC;YAC/C,MAAM,MAAM,GAAsB;gBACjC,IAAI,EAAE,kBAAkB;gBACxB,GAAG,EAAE,YAAY,CAAC,KAAe;aACjC,CAAC;YACF,wEAAwE;YACxE,gEAAgE;YAChE,sCAAsC;YACtC,mEAAmE;YACnE,YAAY,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,IAAA,uBAAY,EAAC,MAAM,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;QAChF,CAAC;QAED,OAAO,IAAI,eAAe,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,KAAc;QACjC,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACD;AAzCD,0CAyCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { ISerializedHandle } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tValueType,\n\tparseHandles,\n\tserializeHandles,\n} from \"@fluidframework/shared-object-base/internal\";\n\n// eslint-disable-next-line import/no-deprecated\nimport type { ISerializableValue, ISerializedValue } from \"./internalInterfaces.js\";\n\n/**\n * A local value to be stored in a container type Distributed Data Store (DDS).\n */\nexport interface ILocalValue {\n\t/**\n\t * Type indicator of the value stored within.\n\t */\n\treadonly type: string;\n\n\t/**\n\t * The in-memory value stored within.\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\treadonly value: any;\n\n\t/**\n\t * Retrieve the serialized form of the value stored within.\n\t * @param serializer - Data store runtime's serializer\n\t * @param bind - Container type's handle\n\t * @returns The serialized form of the contained value\n\t */\n\tmakeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): 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\tlocalValue: ILocalValue,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n\t// eslint-disable-next-line import/no-deprecated\n): ISerializableValue {\n\tconst value = localValue.makeSerialized(serializer, bind);\n\treturn {\n\t\ttype: value.type,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\tvalue: value.value && JSON.parse(value.value),\n\t};\n}\n\n/**\n * Manages a contained plain value. May also contain shared object handles.\n */\nexport class PlainLocalValue implements ILocalValue {\n\t/**\n\t * Create a new PlainLocalValue.\n\t * @param value - The value to store, which may contain shared object handles\n\t */\n\tpublic constructor(public readonly value: unknown) {}\n\n\t/**\n\t * {@inheritDoc ILocalValue.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn ValueType[ValueType.Plain];\n\t}\n\n\t/**\n\t * {@inheritDoc ILocalValue.makeSerialized}\n\t */\n\tpublic makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue {\n\t\t// Stringify to convert to the serialized handle values - and then parse in order to create\n\t\t// a POJO for the op\n\t\tconst value = serializeHandles(this.value, serializer, bind);\n\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tvalue,\n\t\t};\n\t}\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\t/**\n\t * Create a new LocalValueMaker.\n\t */\n\tpublic constructor() {}\n\n\t/**\n\t * Create a new local value from an incoming serialized value.\n\t * @param serializable - The serializable value to make local\n\t */\n\tpublic fromSerializable(\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tserializable: ISerializableValue,\n\t\tserializer: IFluidSerializer,\n\t\tbind: IFluidHandle,\n\t): ILocalValue {\n\t\t// Migrate from old shared value to handles\n\t\tif (serializable.type === ValueType[ValueType.Shared]) {\n\t\t\tserializable.type = ValueType[ValueType.Plain];\n\t\t\tconst handle: ISerializedHandle = {\n\t\t\t\ttype: \"__fluid_handle__\",\n\t\t\t\turl: serializable.value as string,\n\t\t\t};\n\t\t\t// NOTE: here we require the use of `parseHandles` because the roundtrip\n\t\t\t// through a string is necessary to resolve the absolute path of\n\t\t\t// legacy handles (`ValueType.Shared`)\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tserializable.value = serializer.encode(parseHandles(handle, serializer), bind);\n\t\t}\n\n\t\treturn new PlainLocalValue(serializable.value);\n\t}\n\n\t/**\n\t * Create a new local value containing a given plain object.\n\t * @param value - The value to store\n\t * @returns An ILocalValue containing the value\n\t */\n\tpublic fromInMemory(value: unknown): ILocalValue {\n\t\treturn new PlainLocalValue(value);\n\t}\n}\n"]}
1
+ {"version":3,"file":"localValues.js","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,0EAIqD;AAerD;;GAEG;AACI,MAAM,cAAc,GAAG,CAC7B,KAAc,EACd,UAA4B,EAC5B,IAAkB,EACC,EAAE;IACrB,MAAM,eAAe,GAAG,IAAA,2BAAgB,EAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAElE,OAAO;QACN,IAAI,EAAE,oBAAS,CAAC,oBAAS,CAAC,KAAK,CAAC;QAChC,KAAK,EAAE,eAAe;KACtB,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,cAAc,kBAWzB;AAEF;;;;;;;GAOG;AACI,MAAM,2BAA2B,GAAG;AAC1C,gDAAgD;AAChD,YAAgC,EAChC,UAA4B,EAC5B,IAAkB,EACX,EAAE;IACT,2CAA2C;IAC3C,IAAI,YAAY,CAAC,IAAI,KAAK,oBAAS,CAAC,oBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,YAAY,CAAC,IAAI,GAAG,oBAAS,CAAC,oBAAS,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAsB;YACjC,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,YAAY,CAAC,KAAe;SACjC,CAAC;QACF,wEAAwE;QACxE,gEAAgE;QAChE,sCAAsC;QACtC,YAAY,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,IAAA,uBAAY,EAAC,MAAM,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;AACF,CAAC,CAAC;AAlBW,QAAA,2BAA2B,+BAkBtC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { ISerializedHandle } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tValueType,\n\tparseHandles,\n\tserializeHandles,\n} from \"@fluidframework/shared-object-base/internal\";\n\n// eslint-disable-next-line import/no-deprecated\nimport type { ISerializableValue, ISerializedValue } from \"./internalInterfaces.js\";\n\n/**\n * A local value to be stored in a container type Distributed Data Store (DDS).\n */\nexport interface ILocalValue {\n\t/**\n\t * The in-memory value stored within.\n\t */\n\treadonly value: unknown;\n}\n\n/**\n * Convert a value to its serialized form, i.e. to be used in ops and summaries.\n */\nexport const serializeValue = (\n\tvalue: unknown,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): ISerializedValue => {\n\tconst serializedValue = serializeHandles(value, serializer, bind);\n\n\treturn {\n\t\ttype: ValueType[ValueType.Plain],\n\t\tvalue: serializedValue,\n\t};\n};\n\n/**\n * Very old versions of Fluid permitted a different type of stored value, which represented a\n * SharedObject held directly. This functionality has since been replaced with handles.\n *\n * If the passed serializable is one of these old values, this function will mutate it to a modern\n * value with a handle. Otherwise it does nothing.\n * @param serializable - The serializable value to potentially convert.\n */\nexport const migrateIfSharedSerializable = (\n\t// eslint-disable-next-line import/no-deprecated\n\tserializable: ISerializableValue,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): void => {\n\t// Migrate from old shared value to handles\n\tif (serializable.type === ValueType[ValueType.Shared]) {\n\t\tserializable.type = ValueType[ValueType.Plain];\n\t\tconst handle: ISerializedHandle = {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: serializable.value as string,\n\t\t};\n\t\t// NOTE: here we require the use of `parseHandles` because the roundtrip\n\t\t// through a string is necessary to resolve the absolute path of\n\t\t// legacy handles (`ValueType.Shared`)\n\t\tserializable.value = serializer.encode(parseHandles(handle, serializer), bind);\n\t}\n};\n"]}
package/dist/map.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAEN,KAAK,yBAAyB,EAC9B,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAE3E,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAcpE;;GAEG;AACH,qBAAa,SAAU,SAAQ,YAAY,CAAC,gBAAgB,CAAE,YAAW,UAAU;IAClF;;OAEG;IACH,SAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAe;IAE3D;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IAEnC;;;;;;OAMG;gBAEF,EAAE,EAAE,MAAM,E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ClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAcP;;OAEG;cACgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAG7E"}
package/dist/map.js CHANGED
@@ -191,10 +191,10 @@ class SharedMap extends internal_5.SharedObject {
191
191
  const newFormat = json;
192
192
  if (Array.isArray(newFormat.blobs)) {
193
193
  this.kernel.populateFromSerializable(newFormat.content);
194
- await Promise.all(newFormat.blobs.map(async (value) => {
195
- const content = await (0, internal_3.readAndParse)(storage, value);
196
- this.kernel.populateFromSerializable(content);
197
- }));
194
+ const blobContents = await Promise.all(newFormat.blobs.map(async (blobName) => (0, internal_3.readAndParse)(storage, blobName)));
195
+ for (const blobContent of blobContents) {
196
+ this.kernel.populateFromSerializable(blobContent);
197
+ }
198
198
  }
199
199
  else {
200
200
  this.kernel.populateFromSerializable(json);
package/dist/map.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kEAA6D;AAM7D,0EAGqD;AACrD,oEAAqE;AAKrE,qEAA4E;AAE5E,0EAA2E;AAG3E,iDAIwB;AAOxB,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,MAAa,SAAU,SAAQ,uBAA8B;IAW5D;;;;;;OAMG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;QAtB9C;;WAEG;QACa,QAAoB,GAAW,WAAW,CAAC;QAoB1D,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAS,CAC1B,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,MAAM,EACX,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,eAAe,CAAC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ACf,EACD,KAAK,CAAC,oEAAoE,CAC1E,CAAC;QACH,CAAC;IACF,CAAC;IAED;;OAEG;IACgB,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QACrE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CACD;AA/QD,8BA+QC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tMessageType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedMap, ISharedMapEvents } from \"./interfaces.js\";\nimport {\n\ttype IMapDataObjectSerializable,\n\ttype IMapOperation,\n\tMapKernel,\n} from \"./mapKernel.js\";\n\ninterface IMapSerializationFormat {\n\tblobs?: string[];\n\tcontent: IMapDataObjectSerializable;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedMap}\n */\nexport class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {\n\t/**\n\t * String representation for the class.\n\t */\n\tpublic readonly [Symbol.toStringTag]: string = \"SharedMap\";\n\n\t/**\n\t * MapKernel which manages actual map operations.\n\t */\n\tprivate readonly kernel: MapKernel;\n\n\t/**\n\t * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.\n\t *\n\t * @param id - String identifier.\n\t * @param runtime - Data store runtime.\n\t * @param attributes - The attributes for the map.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_map_\");\n\t\tthis.kernel = new MapKernel(\n\t\t\tthis.serializer,\n\t\t\tthis.handle,\n\t\t\t(op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n\t\t\t() => this.isAttached(),\n\t\t\tthis,\n\t\t);\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.kernel.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic entries(): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic values(): IterableIterator<any> {\n\t\treturn this.kernel.values();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic [Symbol.iterator](): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.kernel.size;\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n\t\t// eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference\n\t\tthis.kernel.forEach(callbackFn);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get<T = any>(key: string): T | undefined {\n\t\treturn this.kernel.get<T>(key);\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.kernel.has(key);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.set}\n\t */\n\tpublic set(key: string, value: unknown): this {\n\t\tthis.kernel.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Delete a key from the map.\n\t * @param key - Key to delete\n\t * @returns True if the key existed and was deleted, false if it did not exist\n\t */\n\tpublic delete(key: string): boolean {\n\t\treturn this.kernel.delete(key);\n\t}\n\n\t/**\n\t * Clear all data from the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.kernel.clear();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tlet currentSize = 0;\n\t\tlet counter = 0;\n\t\tlet headerBlob: IMapDataObjectSerializable = {};\n\t\tconst blobs: string[] = [];\n\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\tconst data = this.kernel.getSerializedStorage(serializer);\n\n\t\t// If single property exceeds this size, it goes into its own blob\n\t\tconst MinValueSizeSeparateSnapshotBlob = 8 * 1024;\n\n\t\t// Maximum blob size for multiple map properties\n\t\t// Should be bigger than MinValueSizeSeparateSnapshotBlob\n\t\tconst MaxSnapshotBlobSize = 16 * 1024;\n\n\t\t// Partitioning algorithm:\n\t\t// 1) Split large (over MinValueSizeSeparateSnapshotBlob = 8K) properties into their own blobs.\n\t\t// Naming (across snapshots) of such blob does not have to be stable across snapshots,\n\t\t// As de-duping process (in driver) should not care about paths, only content.\n\t\t// 2) Split remaining properties into blobs of MaxSnapshotBlobSize (16K) size.\n\t\t// This process does not produce stable partitioning. This means\n\t\t// modification (including addition / deletion) of property can shift properties across blobs\n\t\t// and result in non-incremental snapshot.\n\t\t// This can be improved in the future, without being format breaking change, as loading sequence\n\t\t// loads all blobs at once and partitioning schema has no impact on that process.\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {\n\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\tcounter++;\n\t\t\t\tblobs.push(blobName);\n\t\t\t\tconst content: IMapDataObjectSerializable = {\n\t\t\t\t\t[key]: {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tvalue: JSON.parse(value.value) as unknown,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(content));\n\t\t\t} else {\n\t\t\t\tcurrentSize += value.type.length + 21; // Approximation cost of property header\n\t\t\t\tif (value.value) {\n\t\t\t\t\tcurrentSize += value.value.length;\n\t\t\t\t}\n\n\t\t\t\tif (currentSize > MaxSnapshotBlobSize) {\n\t\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\t\tcounter++;\n\t\t\t\t\tblobs.push(blobName);\n\t\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(headerBlob));\n\t\t\t\t\theaderBlob = {};\n\t\t\t\t\tcurrentSize = 0;\n\t\t\t\t}\n\t\t\t\theaderBlob[key] = {\n\t\t\t\t\ttype: value.type,\n\t\t\t\t\tvalue: value.value === undefined ? undefined : (JSON.parse(value.value) as unknown),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst header: IMapSerializationFormat = {\n\t\t\tblobs,\n\t\t\tcontent: headerBlob,\n\t\t};\n\t\tbuilder.addBlob(snapshotFileName, JSON.stringify(header));\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst json = await readAndParse<object>(storage, snapshotFileName);\n\t\tconst newFormat = json as IMapSerializationFormat;\n\t\tif (Array.isArray(newFormat.blobs)) {\n\t\t\tthis.kernel.populateFromSerializable(newFormat.content);\n\t\t\tawait Promise.all(\n\t\t\t\tnewFormat.blobs.map(async (value) => {\n\t\t\t\t\tconst content = await readAndParse<IMapDataObjectSerializable>(storage, value);\n\t\t\t\t\tthis.kernel.populateFromSerializable(content);\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\tthis.kernel.populateFromSerializable(json as IMapDataObjectSerializable);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n\t */\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.trySubmitMessage(content as IMapOperation, localOpMetadata);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(content: unknown): void {\n\t\tthis.kernel.tryApplyStashedOp(content as IMapOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tassert(\n\t\t\t\tthis.kernel.tryProcessMessage(\n\t\t\t\t\tmessage.contents as IMapOperation,\n\t\t\t\t\tlocal,\n\t\t\t\t\tlocalOpMetadata,\n\t\t\t\t),\n\t\t\t\t0xab2 /* Map received an unrecognized op, possibly from a newer version */,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t */\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.rollback(content, localOpMetadata);\n\t}\n}\n"]}
1
+ {"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kEAA6D;AAM7D,0EAGqD;AACrD,oEAAqE;AAKrE,qEAA4E;AAE5E,0EAA2E;AAG3E,iDAIwB;AAOxB,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,MAAa,SAAU,SAAQ,uBAA8B;IAW5D;;;;;;OAMG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;QAtB9C;;WAEG;QACa,QAAoB,GAAW,WAAW,CAAC;QAoB1D,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAS,CAC1B,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,MAAM,EACX,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,eAAe,CAAC,EACrE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,EACvB,IAAI,CACJ,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,IAAI;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,iDAAiD;IACjD,8DAA8D;IACvD,OAAO;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,iDAAiD;IACjD,8DAA8D;IACvD,MAAM;QACZ,OAAO,IAAI,CAA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AC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CACtC,IAAA,uBAAY,EAA6B,OAAO,EAAE,QAAQ,CAAC,CAC3D,CACD,CAAC;YACF,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;gBACxC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,WAAW,CAAC,CAAC;YACnD,CAAC;QACF,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAkC,CAAC,CAAC;QAC1E,CAAC;IACF,CAAC;IAED;;OAEG;IACO,YAAY,KAAU,CAAC;IAEjC;;OAEG;IACgB,YAAY,CAAC,OAAgB,EAAE,eAAwB;QACzE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAwB,EAAE,eAAe,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,OAAgB;QACxC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAwB,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACO,WAAW,CACpB,OAAkC,EAClC,KAAc,EACd,eAAwB;QAExB,wEAAwE;QACxE,IAAI,OAAO,CAAC,IAAI,KAAK,sBAAW,CAAC,SAAS,EAAE,CAAC;YAC5C,IAAA,iBAAM,EACL,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAC5B,OAAO,CAAC,QAAyB,EACjC,KAAK,EACL,eAAe,CACf,EACD,KAAK,CAAC,oEAAoE,CAC1E,CAAC;QACH,CAAC;IACF,CAAC;IAED;;OAEG;IACgB,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QACrE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CACD;AAjRD,8BAiRC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tMessageType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedMap, ISharedMapEvents } from \"./interfaces.js\";\nimport {\n\ttype IMapDataObjectSerializable,\n\ttype IMapOperation,\n\tMapKernel,\n} from \"./mapKernel.js\";\n\ninterface IMapSerializationFormat {\n\tblobs?: string[];\n\tcontent: IMapDataObjectSerializable;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedMap}\n */\nexport class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {\n\t/**\n\t * String representation for the class.\n\t */\n\tpublic readonly [Symbol.toStringTag]: string = \"SharedMap\";\n\n\t/**\n\t * MapKernel which manages actual map operations.\n\t */\n\tprivate readonly kernel: MapKernel;\n\n\t/**\n\t * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.\n\t *\n\t * @param id - String identifier.\n\t * @param runtime - Data store runtime.\n\t * @param attributes - The attributes for the map.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_map_\");\n\t\tthis.kernel = new MapKernel(\n\t\t\tthis.serializer,\n\t\t\tthis.handle,\n\t\t\t(op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n\t\t\t() => this.isAttached(),\n\t\t\tthis,\n\t\t);\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.kernel.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic entries(): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic values(): IterableIterator<any> {\n\t\treturn this.kernel.values();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic [Symbol.iterator](): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.kernel.size;\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n\t\t// eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference\n\t\tthis.kernel.forEach(callbackFn);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get<T = any>(key: string): T | undefined {\n\t\treturn this.kernel.get<T>(key);\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.kernel.has(key);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.set}\n\t */\n\tpublic set(key: string, value: unknown): this {\n\t\tthis.kernel.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Delete a key from the map.\n\t * @param key - Key to delete\n\t * @returns True if the key existed and was deleted, false if it did not exist\n\t */\n\tpublic delete(key: string): boolean {\n\t\treturn this.kernel.delete(key);\n\t}\n\n\t/**\n\t * Clear all data from the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.kernel.clear();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tlet currentSize = 0;\n\t\tlet counter = 0;\n\t\tlet headerBlob: IMapDataObjectSerializable = {};\n\t\tconst blobs: string[] = [];\n\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\tconst data = this.kernel.getSerializedStorage(serializer);\n\n\t\t// If single property exceeds this size, it goes into its own blob\n\t\tconst MinValueSizeSeparateSnapshotBlob = 8 * 1024;\n\n\t\t// Maximum blob size for multiple map properties\n\t\t// Should be bigger than MinValueSizeSeparateSnapshotBlob\n\t\tconst MaxSnapshotBlobSize = 16 * 1024;\n\n\t\t// Partitioning algorithm:\n\t\t// 1) Split large (over MinValueSizeSeparateSnapshotBlob = 8K) properties into their own blobs.\n\t\t// Naming (across snapshots) of such blob does not have to be stable across snapshots,\n\t\t// As de-duping process (in driver) should not care about paths, only content.\n\t\t// 2) Split remaining properties into blobs of MaxSnapshotBlobSize (16K) size.\n\t\t// This process does not produce stable partitioning. This means\n\t\t// modification (including addition / deletion) of property can shift properties across blobs\n\t\t// and result in non-incremental snapshot.\n\t\t// This can be improved in the future, without being format breaking change, as loading sequence\n\t\t// loads all blobs at once and partitioning schema has no impact on that process.\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {\n\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\tcounter++;\n\t\t\t\tblobs.push(blobName);\n\t\t\t\tconst content: IMapDataObjectSerializable = {\n\t\t\t\t\t[key]: {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tvalue: JSON.parse(value.value) as unknown,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(content));\n\t\t\t} else {\n\t\t\t\tcurrentSize += value.type.length + 21; // Approximation cost of property header\n\t\t\t\tif (value.value) {\n\t\t\t\t\tcurrentSize += value.value.length;\n\t\t\t\t}\n\n\t\t\t\tif (currentSize > MaxSnapshotBlobSize) {\n\t\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\t\tcounter++;\n\t\t\t\t\tblobs.push(blobName);\n\t\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(headerBlob));\n\t\t\t\t\theaderBlob = {};\n\t\t\t\t\tcurrentSize = 0;\n\t\t\t\t}\n\t\t\t\theaderBlob[key] = {\n\t\t\t\t\ttype: value.type,\n\t\t\t\t\tvalue: value.value === undefined ? undefined : (JSON.parse(value.value) as unknown),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst header: IMapSerializationFormat = {\n\t\t\tblobs,\n\t\t\tcontent: headerBlob,\n\t\t};\n\t\tbuilder.addBlob(snapshotFileName, JSON.stringify(header));\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst json = await readAndParse<object>(storage, snapshotFileName);\n\t\tconst newFormat = json as IMapSerializationFormat;\n\t\tif (Array.isArray(newFormat.blobs)) {\n\t\t\tthis.kernel.populateFromSerializable(newFormat.content);\n\t\t\tconst blobContents = await Promise.all(\n\t\t\t\tnewFormat.blobs.map(async (blobName) =>\n\t\t\t\t\treadAndParse<IMapDataObjectSerializable>(storage, blobName),\n\t\t\t\t),\n\t\t\t);\n\t\t\tfor (const blobContent of blobContents) {\n\t\t\t\tthis.kernel.populateFromSerializable(blobContent);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.kernel.populateFromSerializable(json as IMapDataObjectSerializable);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n\t */\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.trySubmitMessage(content as IMapOperation, localOpMetadata);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(content: unknown): void {\n\t\tthis.kernel.tryApplyStashedOp(content as IMapOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tassert(\n\t\t\t\tthis.kernel.tryProcessMessage(\n\t\t\t\t\tmessage.contents as IMapOperation,\n\t\t\t\t\tlocal,\n\t\t\t\t\tlocalOpMetadata,\n\t\t\t\t),\n\t\t\t\t0xab2 /* Map received an unrecognized op, possibly from a newer version */,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t */\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.rollback(content, localOpMetadata);\n\t}\n}\n"]}
@@ -56,15 +56,11 @@ export declare class MapKernel {
56
56
  /**
57
57
  * This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.
58
58
  */
59
- private pendingMessageId;
59
+ private nextPendingMessageId;
60
60
  /**
61
61
  * The pending ids of any clears that have been performed locally but not yet ack'd from the server
62
62
  */
63
63
  private readonly pendingClearMessageIds;
64
- /**
65
- * Object to create encapsulations of the values stored in the map.
66
- */
67
- private readonly localValueMaker;
68
64
  /**
69
65
  * Create a new shared map kernel.
70
66
  * @param serializer - The serializer to serialize / parse handles
@@ -84,17 +80,17 @@ export declare class MapKernel {
84
80
  * Get an iterator over the entries in this map.
85
81
  * @returns The iterator
86
82
  */
87
- entries(): IterableIterator<[string, any]>;
83
+ entries(): IterableIterator<[string, unknown]>;
88
84
  /**
89
85
  * Get an iterator over the values in this map.
90
86
  * @returns The iterator
91
87
  */
92
- values(): IterableIterator<any>;
88
+ values(): IterableIterator<unknown>;
93
89
  /**
94
90
  * Get an iterator over the entries in this map.
95
91
  * @returns The iterator
96
92
  */
97
- [Symbol.iterator](): IterableIterator<[string, any]>;
93
+ [Symbol.iterator](): IterableIterator<[string, unknown]>;
98
94
  /**
99
95
  * Executes the given callback on each entry in the map.
100
96
  * @param callbackFn - Callback function
@@ -103,7 +99,7 @@ export declare class MapKernel {
103
99
  /**
104
100
  * {@inheritDoc ISharedMap.get}
105
101
  */
106
- get<T = any>(key: string): T | undefined;
102
+ get<T = unknown>(key: string): T | undefined;
107
103
  /**
108
104
  * Check if a key exists in the map.
109
105
  * @param key - The key to check
@@ -130,8 +126,6 @@ export declare class MapKernel {
130
126
  * @returns A JSON string containing serialized map data
131
127
  */
132
128
  getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized;
133
- getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable;
134
- serialize(serializer: IFluidSerializer): string;
135
129
  /**
136
130
  * Populate the kernel with the given map data.
137
131
  * @param data - A JSON string containing serialized map data
@@ -193,17 +187,6 @@ export declare class MapKernel {
193
187
  * Clear all keys in memory in response to a remote clear, but retain keys we have modified but not yet been ack'd.
194
188
  */
195
189
  private clearExceptPendingKeys;
196
- /**
197
- * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will
198
- * have the information we need to create a real object, but will not be the real object yet. For example,
199
- * we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's
200
- * job is to convert that information into a real object for local usage.
201
- * @param key - The key that the caller intends to store the local value into (used for ops later). But
202
- * doesn't actually store the local value into that key. So better not lie!
203
- * @param serializable - The remote information that we can convert into a real object
204
- * @returns The local value that was produced
205
- */
206
- private makeLocal;
207
190
  /**
208
191
  * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should
209
192
  * not process the incoming operation.
@@ -1 +1 @@
1
- {"version":3,"file":"mapKernel.d.ts","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAGpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAEX,kBAAkB,EAClB,mBAAmB,EAGnB,gBAAgB,EAEhB,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,yBAAyB,CAAC;AAwBjC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;AAElE;;;;;;;GAOG;AAEH,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAyDxE;;GAEG;AACH,qBAAa,SAAS;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outgoing operation and helps in tracking unack'd ops.
81
81
  */
82
- this.pendingMessageId = -1;
82
+ this.nextPendingMessageId = 0;
83
83
  /**
84
84
  * The pending ids of any clears that have been performed locally but not yet ack'd from the server
85
85
  */
86
86
  this.pendingClearMessageIds = [];
87
- this.localValueMaker = new localValues_js_1.LocalValueMaker();
88
87
  this.messageHandlers = this.getMessageHandlers();
89
88
  }
90
89
  /**
@@ -98,8 +97,6 @@ class MapKernel {
98
97
  * Get an iterator over the entries in this map.
99
98
  * @returns The iterator
100
99
  */
101
- // TODO: Use `unknown` instead (breaking change).
102
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
100
  entries() {
104
101
  const localEntriesIterator = this.data.entries();
105
102
  const iterator = {
@@ -120,8 +117,6 @@ class MapKernel {
120
117
  * Get an iterator over the values in this map.
121
118
  * @returns The iterator
122
119
  */
123
- // TODO: Use `unknown` instead (breaking change).
124
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
120
  values() {
126
121
  const localValuesIterator = this.data.values();
127
122
  const iterator = {
@@ -142,8 +137,6 @@ class MapKernel {
142
137
  * Get an iterator over the entries in this map.
143
138
  * @returns The iterator
144
139
  */
145
- // TODO: Use `unknown` instead (breaking change).
146
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
147
140
  [Symbol.iterator]() {
148
141
  return this.entries();
149
142
  }
@@ -160,8 +153,6 @@ class MapKernel {
160
153
  /**
161
154
  * {@inheritDoc ISharedMap.get}
162
155
  */
163
- // TODO: Use `unknown` instead (breaking change).
164
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
156
  get(key) {
166
157
  const localValue = this.data.get(key);
167
158
  return localValue === undefined ? undefined : localValue.value;
@@ -182,10 +173,8 @@ class MapKernel {
182
173
  if (key === undefined || key === null) {
183
174
  throw new Error("Undefined and null keys are not supported");
184
175
  }
185
- // Create a local value and serialize it.
186
- const localValue = this.localValueMaker.fromInMemory(value);
187
176
  // Set the value locally.
188
- const previousValue = this.setCore(key, localValue, true);
177
+ const previousValue = this.setCore(key, { value }, true);
189
178
  // If we are not attached, don't submit the op.
190
179
  if (!this.isAttached()) {
191
180
  return;
@@ -193,7 +182,7 @@ class MapKernel {
193
182
  const op = {
194
183
  key,
195
184
  type: "set",
196
- value: { type: localValue.type, value: localValue.value },
185
+ value: { type: internal_2.ValueType[internal_2.ValueType.Plain], value },
197
186
  };
198
187
  this.submitMapKeyMessage(op, previousValue);
199
188
  }
@@ -240,21 +229,11 @@ class MapKernel {
240
229
  * @returns A JSON string containing serialized map data
241
230
  */
242
231
  getSerializedStorage(serializer) {
243
- const serializableMapData = {};
232
+ const serializedMapData = {};
244
233
  for (const [key, localValue] of this.data.entries()) {
245
- serializableMapData[key] = localValue.makeSerialized(serializer, this.handle);
234
+ serializedMapData[key] = (0, localValues_js_1.serializeValue)(localValue.value, serializer, this.handle);
246
235
  }
247
- return serializableMapData;
248
- }
249
- getSerializableStorage(serializer) {
250
- const serializableMapData = {};
251
- for (const [key, localValue] of this.data.entries()) {
252
- serializableMapData[key] = (0, localValues_js_1.makeSerializable)(localValue, serializer, this.handle);
253
- }
254
- return serializableMapData;
255
- }
256
- serialize(serializer) {
257
- return JSON.stringify(this.getSerializableStorage(serializer));
236
+ return serializedMapData;
258
237
  }
259
238
  /**
260
239
  * Populate the kernel with the given map data.
@@ -262,11 +241,8 @@ class MapKernel {
262
241
  */
263
242
  populateFromSerializable(json) {
264
243
  for (const [key, serializable] of Object.entries(this.serializer.decode(json))) {
265
- const localValue = {
266
- key,
267
- value: this.makeLocal(key, serializable),
268
- };
269
- this.data.set(localValue.key, localValue.value);
244
+ (0, localValues_js_1.migrateIfSharedSerializable)(serializable, this.serializer, this.handle);
245
+ this.data.set(key, { value: serializable.value });
270
246
  }
271
247
  }
272
248
  /**
@@ -296,7 +272,8 @@ class MapKernel {
296
272
  break;
297
273
  }
298
274
  case "set": {
299
- this.set(op.key, this.makeLocal(op.key, op.value).value);
275
+ (0, localValues_js_1.migrateIfSharedSerializable)(op.value, this.serializer, this.handle);
276
+ this.set(op.key, op.value.value);
300
277
  break;
301
278
  }
302
279
  default: {
@@ -432,26 +409,6 @@ class MapKernel {
432
409
  this.setCore(key, value, true);
433
410
  }
434
411
  }
435
- /**
436
- * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will
437
- * have the information we need to create a real object, but will not be the real object yet. For example,
438
- * we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's
439
- * job is to convert that information into a real object for local usage.
440
- * @param key - The key that the caller intends to store the local value into (used for ops later). But
441
- * doesn't actually store the local value into that key. So better not lie!
442
- * @param serializable - The remote information that we can convert into a real object
443
- * @returns The local value that was produced
444
- */
445
- // eslint-disable-next-line import/no-deprecated
446
- makeLocal(key, serializable) {
447
- if (serializable.type === internal_2.ValueType[internal_2.ValueType.Plain] ||
448
- serializable.type === internal_2.ValueType[internal_2.ValueType.Shared]) {
449
- return this.localValueMaker.fromSerializable(serializable, this.serializer, this.handle);
450
- }
451
- else {
452
- throw new Error("Unknown local value type");
453
- }
454
- }
455
412
  /**
456
413
  * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should
457
414
  * not process the incoming operation.
@@ -533,8 +490,8 @@ class MapKernel {
533
490
  return;
534
491
  }
535
492
  // needProcessKeyOperation should have returned false if local is true
536
- const context = this.makeLocal(op.key, op.value);
537
- this.setCore(op.key, context, local);
493
+ (0, localValues_js_1.migrateIfSharedSerializable)(op.value, this.serializer, this.handle);
494
+ this.setCore(op.key, { value: op.value.value }, local);
538
495
  },
539
496
  submit: (op, localOpMetadata) => {
540
497
  this.resubmitMapKeyMessage(op, localOpMetadata);
@@ -543,7 +500,7 @@ class MapKernel {
543
500
  return messageHandlers;
544
501
  }
545
502
  getMapClearMessageId() {
546
- const pendingMessageId = ++this.pendingMessageId;
503
+ const pendingMessageId = this.nextPendingMessageId++;
547
504
  this.pendingClearMessageIds.push(pendingMessageId);
548
505
  return pendingMessageId;
549
506
  }
@@ -556,7 +513,7 @@ class MapKernel {
556
513
  this.submitMessage(op, metadata);
557
514
  }
558
515
  getMapKeyMessageId(op) {
559
- const pendingMessageId = ++this.pendingMessageId;
516
+ const pendingMessageId = this.nextPendingMessageId++;
560
517
  const pendingMessageIds = this.pendingKeys.get(op.key);
561
518
  if (pendingMessageIds === undefined) {
562
519
  this.pendingKeys.set(op.key, [pendingMessageId]);