@fluidframework/map 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419

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 (118) hide show
  1. package/.eslintrc.js +12 -11
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +162 -0
  4. package/README.md +24 -8
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/map.api.md +297 -0
  8. package/dist/{directory.js → directory.cjs} +749 -228
  9. package/dist/directory.cjs.map +1 -0
  10. package/dist/directory.d.ts +567 -34
  11. package/dist/directory.d.ts.map +1 -1
  12. package/dist/index.cjs +27 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.ts +5 -5
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/{interfaces.js → interfaces.cjs} +1 -1
  17. package/dist/interfaces.cjs.map +1 -0
  18. package/dist/interfaces.d.ts +167 -184
  19. package/dist/interfaces.d.ts.map +1 -1
  20. package/dist/internalInterfaces.cjs +7 -0
  21. package/dist/internalInterfaces.cjs.map +1 -0
  22. package/dist/internalInterfaces.d.ts +101 -0
  23. package/dist/internalInterfaces.d.ts.map +1 -0
  24. package/dist/{localValues.js → localValues.cjs} +15 -3
  25. package/dist/localValues.cjs.map +1 -0
  26. package/dist/localValues.d.ts +17 -6
  27. package/dist/localValues.d.ts.map +1 -1
  28. package/dist/map-alpha.d.ts +982 -0
  29. package/dist/map-beta.d.ts +275 -0
  30. package/dist/map-public.d.ts +275 -0
  31. package/dist/map-untrimmed.d.ts +996 -0
  32. package/dist/{map.js → map.cjs} +39 -34
  33. package/dist/map.cjs.map +1 -0
  34. package/dist/map.d.ts +10 -17
  35. package/dist/map.d.ts.map +1 -1
  36. package/dist/{mapKernel.js → mapKernel.cjs} +122 -79
  37. package/dist/mapKernel.cjs.map +1 -0
  38. package/dist/mapKernel.d.ts +17 -48
  39. package/dist/mapKernel.d.ts.map +1 -1
  40. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  41. package/dist/packageVersion.cjs.map +1 -0
  42. package/dist/packageVersion.d.ts +1 -1
  43. package/dist/packageVersion.d.ts.map +1 -1
  44. package/dist/tsdoc-metadata.json +11 -0
  45. package/lib/directory.d.mts +902 -0
  46. package/lib/directory.d.mts.map +1 -0
  47. package/lib/{directory.js → directory.mjs} +736 -199
  48. package/lib/directory.mjs.map +1 -0
  49. package/lib/index.d.mts +9 -0
  50. package/lib/index.d.mts.map +1 -0
  51. package/lib/index.mjs +8 -0
  52. package/lib/index.mjs.map +1 -0
  53. package/lib/{interfaces.d.ts → interfaces.d.mts} +167 -184
  54. package/lib/interfaces.d.mts.map +1 -0
  55. package/lib/{interfaces.js → interfaces.mjs} +1 -1
  56. package/lib/interfaces.mjs.map +1 -0
  57. package/lib/internalInterfaces.d.mts +101 -0
  58. package/lib/internalInterfaces.d.mts.map +1 -0
  59. package/lib/internalInterfaces.mjs +6 -0
  60. package/lib/internalInterfaces.mjs.map +1 -0
  61. package/lib/{localValues.d.ts → localValues.d.mts} +18 -7
  62. package/lib/localValues.d.mts.map +1 -0
  63. package/lib/{localValues.js → localValues.mjs} +15 -3
  64. package/lib/localValues.mjs.map +1 -0
  65. package/lib/map-alpha.d.mts +982 -0
  66. package/lib/map-beta.d.mts +275 -0
  67. package/lib/map-public.d.mts +275 -0
  68. package/lib/map-untrimmed.d.mts +996 -0
  69. package/lib/{map.d.ts → map.d.mts} +11 -18
  70. package/lib/map.d.mts.map +1 -0
  71. package/lib/{map.js → map.mjs} +40 -35
  72. package/lib/map.mjs.map +1 -0
  73. package/lib/{mapKernel.d.ts → mapKernel.d.mts} +18 -49
  74. package/lib/mapKernel.d.mts.map +1 -0
  75. package/lib/{mapKernel.js → mapKernel.mjs} +116 -73
  76. package/lib/mapKernel.mjs.map +1 -0
  77. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
  78. package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
  79. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  80. package/lib/packageVersion.mjs.map +1 -0
  81. package/map.test-files.tar +0 -0
  82. package/package.json +105 -65
  83. package/prettier.config.cjs +8 -0
  84. package/src/directory.ts +2544 -1727
  85. package/src/index.ts +31 -5
  86. package/src/interfaces.ts +346 -345
  87. package/src/internalInterfaces.ts +119 -0
  88. package/src/localValues.ts +103 -96
  89. package/src/map.ts +362 -351
  90. package/src/mapKernel.ts +755 -722
  91. package/src/packageVersion.ts +1 -1
  92. package/tsc-multi.test.json +4 -0
  93. package/tsconfig.json +10 -15
  94. package/dist/directory.js.map +0 -1
  95. package/dist/index.js +0 -34
  96. package/dist/index.js.map +0 -1
  97. package/dist/interfaces.js.map +0 -1
  98. package/dist/localValues.js.map +0 -1
  99. package/dist/map.js.map +0 -1
  100. package/dist/mapKernel.js.map +0 -1
  101. package/dist/packageVersion.js.map +0 -1
  102. package/lib/directory.d.ts +0 -369
  103. package/lib/directory.d.ts.map +0 -1
  104. package/lib/directory.js.map +0 -1
  105. package/lib/index.d.ts +0 -20
  106. package/lib/index.d.ts.map +0 -1
  107. package/lib/index.js +0 -20
  108. package/lib/index.js.map +0 -1
  109. package/lib/interfaces.d.ts.map +0 -1
  110. package/lib/interfaces.js.map +0 -1
  111. package/lib/localValues.d.ts.map +0 -1
  112. package/lib/localValues.js.map +0 -1
  113. package/lib/map.d.ts.map +0 -1
  114. package/lib/map.js.map +0 -1
  115. package/lib/mapKernel.d.ts.map +0 -1
  116. package/lib/mapKernel.js.map +0 -1
  117. package/lib/packageVersion.js.map +0 -1
  118. package/tsconfig.esnext.json +0 -7
@@ -6,10 +6,12 @@ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions"
6
6
  import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelServices, IChannelFactory } from "@fluidframework/datastore-definitions";
7
7
  import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
8
8
  import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
9
- import { ISharedMap, ISharedMapEvents } from "./interfaces";
9
+ import { ISharedMap, ISharedMapEvents } from "./interfaces.mjs";
10
10
  /**
11
- * The factory that defines the map.
11
+ * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.
12
+ *
12
13
  * @sealed
14
+ * @alpha
13
15
  */
14
16
  export declare class MapFactory implements IChannelFactory {
15
17
  /**
@@ -38,10 +40,8 @@ export declare class MapFactory implements IChannelFactory {
38
40
  create(runtime: IFluidDataStoreRuntime, id: string): ISharedMap;
39
41
  }
40
42
  /**
41
- * The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting
42
- * and retrieving values that JavaScript developers are accustomed to with the
43
- * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.
44
- * However, the keys of a SharedMap must be strings.
43
+ * {@inheritDoc ISharedMap}
44
+ * @public
45
45
  */
46
46
  export declare class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {
47
47
  /**
@@ -121,7 +121,7 @@ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements
121
121
  /**
122
122
  * {@inheritDoc ISharedMap.set}
123
123
  */
124
- set(key: string, value: any): this;
124
+ set(key: string, value: unknown): this;
125
125
  /**
126
126
  * Delete a key from the map.
127
127
  * @param key - Key to delete
@@ -134,38 +134,31 @@ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements
134
134
  clear(): void;
135
135
  /**
136
136
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
137
- * @internal
138
137
  */
139
138
  protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
140
139
  /**
141
140
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
142
- * @internal
143
141
  */
144
142
  protected loadCore(storage: IChannelStorageService): Promise<void>;
145
143
  /**
146
144
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
147
- * @internal
148
145
  */
149
146
  protected onDisconnect(): void;
150
147
  /**
151
148
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
152
- * @internal
153
149
  */
154
- protected reSubmitCore(content: any, localOpMetadata: unknown): void;
150
+ protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
155
151
  /**
156
152
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
157
- * @internal
158
153
  */
159
- protected applyStashedOp(content: any): unknown;
154
+ protected applyStashedOp(content: unknown): unknown;
160
155
  /**
161
156
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
162
- * @internal
163
157
  */
164
158
  protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
165
159
  /**
166
160
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
167
- * @internal
168
- */
169
- protected rollback(content: any, localOpMetadata: unknown): void;
161
+ */
162
+ protected rollback(content: unknown, localOpMetadata: unknown): void;
170
163
  }
171
164
  //# sourceMappingURL=map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,yBAAyB,EAAe,MAAM,sCAAsC;OACtF,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,MAAM,uCAAuC;OACvC,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC;OAEvF,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC;OAE5E,EAAE,UAAU,EAAE,gBAAgB,EAAE;AAWvC;;;;;GAKG;AACH,qBAAa,UAAW,YAAW,eAAe;IACjD;;OAEG;IACH,gBAAuB,IAAI,2CAA2C;IAEtE;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF;;OAEG;IACH,IAAW,IAAI,IAAI,MA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E,GAAG,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;;OAEG;IACH,SAAS,CAAC,aAAa,CACtB,UAAU,EAAE,gBAAgB,EAC5B,gBAAgB,CAAC,EAAE,iBAAiB,GAClC,qBAAqB;IAyExB;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxE;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAIxE;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAInD;;OAEG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAUP;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAGpE"}
@@ -5,14 +5,16 @@
5
5
  var _a;
6
6
  import { MessageType } from "@fluidframework/protocol-definitions";
7
7
  import { readAndParse } from "@fluidframework/driver-utils";
8
- import { SharedObject, } from "@fluidframework/shared-object-base";
8
+ import { SharedObject } from "@fluidframework/shared-object-base";
9
9
  import { SummaryTreeBuilder } from "@fluidframework/runtime-utils";
10
- import { MapKernel } from "./mapKernel";
11
- import { pkgVersion } from "./packageVersion";
10
+ import { MapKernel } from "./mapKernel.mjs";
11
+ import { pkgVersion } from "./packageVersion.mjs";
12
12
  const snapshotFileName = "header";
13
13
  /**
14
- * The factory that defines the map.
14
+ * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.
15
+ *
15
16
  * @sealed
17
+ * @alpha
16
18
  */
17
19
  export class MapFactory {
18
20
  /**
@@ -57,27 +59,10 @@ MapFactory.Attributes = {
57
59
  packageVersion: pkgVersion,
58
60
  };
59
61
  /**
60
- * The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting
61
- * and retrieving values that JavaScript developers are accustomed to with the
62
- * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.
63
- * However, the keys of a SharedMap must be strings.
62
+ * {@inheritDoc ISharedMap}
63
+ * @public
64
64
  */
65
65
  export class SharedMap extends SharedObject {
66
- /**
67
- * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.
68
- *
69
- * @param id - String identifier.
70
- * @param runtime - Data store runtime.
71
- * @param attributes - The attributes for the map.
72
- */
73
- constructor(id, runtime, attributes) {
74
- super(id, runtime, attributes, "fluid_map_");
75
- /**
76
- * String representation for the class.
77
- */
78
- this[_a] = "SharedMap";
79
- this.kernel = new MapKernel(this.serializer, this.handle, (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata), () => this.isAttached(), this);
80
- }
81
66
  /**
82
67
  * Create a new shared map.
83
68
  * @param runtime - The data store runtime that the new shared map belongs to.
@@ -101,6 +86,21 @@ export class SharedMap extends SharedObject {
101
86
  static getFactory() {
102
87
  return new MapFactory();
103
88
  }
89
+ /**
90
+ * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.
91
+ *
92
+ * @param id - String identifier.
93
+ * @param runtime - Data store runtime.
94
+ * @param attributes - The attributes for the map.
95
+ */
96
+ constructor(id, runtime, attributes) {
97
+ super(id, runtime, attributes, "fluid_map_");
98
+ /**
99
+ * String representation for the class.
100
+ */
101
+ this[_a] = "SharedMap";
102
+ this.kernel = new MapKernel(this.serializer, this.handle, (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata), () => this.isAttached(), this);
103
+ }
104
104
  /**
105
105
  * Get an iterator over the keys in this map.
106
106
  * @returns The iterator
@@ -112,6 +112,8 @@ export class SharedMap extends SharedObject {
112
112
  * Get an iterator over the entries in this map.
113
113
  * @returns The iterator
114
114
  */
115
+ // TODO: Use `unknown` instead (breaking change).
116
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
117
  entries() {
116
118
  return this.kernel.entries();
117
119
  }
@@ -119,6 +121,8 @@ export class SharedMap extends SharedObject {
119
121
  * Get an iterator over the values in this map.
120
122
  * @returns The iterator
121
123
  */
124
+ // TODO: Use `unknown` instead (breaking change).
125
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
122
126
  values() {
123
127
  return this.kernel.values();
124
128
  }
@@ -126,6 +130,8 @@ export class SharedMap extends SharedObject {
126
130
  * Get an iterator over the entries in this map.
127
131
  * @returns The iterator
128
132
  */
133
+ // TODO: Use `unknown` instead (breaking change).
134
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
135
  [(_a = Symbol.toStringTag, Symbol.iterator)]() {
130
136
  return this.kernel.entries();
131
137
  }
@@ -139,12 +145,17 @@ export class SharedMap extends SharedObject {
139
145
  * Executes the given callback on each entry in the map.
140
146
  * @param callbackFn - Callback function
141
147
  */
148
+ // TODO: Use `unknown` instead (breaking change).
149
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
150
  forEach(callbackFn) {
151
+ // eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference
143
152
  this.kernel.forEach(callbackFn);
144
153
  }
145
154
  /**
146
155
  * {@inheritDoc ISharedMap.get}
147
156
  */
157
+ // TODO: Use `unknown` instead (breaking change).
158
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
159
  get(key) {
149
160
  return this.kernel.get(key);
150
161
  }
@@ -179,7 +190,6 @@ export class SharedMap extends SharedObject {
179
190
  }
180
191
  /**
181
192
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
182
- * @internal
183
193
  */
184
194
  summarizeCore(serializer, telemetryContext) {
185
195
  let currentSize = 0;
@@ -232,7 +242,9 @@ export class SharedMap extends SharedObject {
232
242
  }
233
243
  headerBlob[key] = {
234
244
  type: value.type,
235
- value: value.value === undefined ? undefined : JSON.parse(value.value),
245
+ value: value.value === undefined
246
+ ? undefined
247
+ : JSON.parse(value.value),
236
248
  };
237
249
  }
238
250
  }
@@ -245,7 +257,6 @@ export class SharedMap extends SharedObject {
245
257
  }
246
258
  /**
247
259
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
248
- * @internal
249
260
  */
250
261
  async loadCore(storage) {
251
262
  const json = await readAndParse(storage, snapshotFileName);
@@ -263,27 +274,22 @@ export class SharedMap extends SharedObject {
263
274
  }
264
275
  /**
265
276
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
266
- * @internal
267
277
  */
268
278
  onDisconnect() { }
269
279
  /**
270
280
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
271
- * @internal
272
281
  */
273
282
  reSubmitCore(content, localOpMetadata) {
274
283
  this.kernel.trySubmitMessage(content, localOpMetadata);
275
284
  }
276
285
  /**
277
286
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
278
- * @internal
279
287
  */
280
288
  applyStashedOp(content) {
281
- this.kernel.tryProcessMessage(content, false, undefined);
282
- return this.kernel.tryGetStashedOpLocalMetadata(content);
289
+ return this.kernel.tryApplyStashedOp(content);
283
290
  }
284
291
  /**
285
292
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
286
- * @internal
287
293
  */
288
294
  processCore(message, local, localOpMetadata) {
289
295
  if (message.type === MessageType.Operation) {
@@ -292,10 +298,9 @@ export class SharedMap extends SharedObject {
292
298
  }
293
299
  /**
294
300
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
295
- * @internal
296
- */
301
+ */
297
302
  rollback(content, localOpMetadata) {
298
303
  this.kernel.rollback(content, localOpMetadata);
299
304
  }
300
305
  }
301
- //# sourceMappingURL=map.js.map
306
+ //# sourceMappingURL=map.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.mjs","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;GAGG;;OAEI,EAA6B,WAAW,EAAE,MAAM,sCAAsC;OAStF,EAAE,YAAY,EAAE,MAAM,8BAA8B;OACpD,EAAoB,YAAY,EAAE,MAAM,oCAAoC;OAC5E,EAAE,kBAAkB,EAAE,MAAM,+BAA+B;OAE3D,EAA6C,SAAS,EAAE;OACxD,EAAE,UAAU,EAAE;AAOrB,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IAetB;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,UAAU,CAAC,IAAI,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,UAAU,CAAC,UAAU,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACnD,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzB,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;QAC9D,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,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBACnC,MAAM,OAAO,GAAG,MAAM,YAAY,CAA6B,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC/E,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;YAC/C,CAAC,CAAC,CACF,CAAC;SACF;aAAM;YACN,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAkC,CAAC,CAAC;SACzE;IACF,CAAC;IAED;;OAEG;IACO,YAAY,KAAU,CAAC;IAEjC;;OAEG;IACO,YAAY,CAAC,OAAgB,EAAE,eAAwB;QAChE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAwB,EAAE,eAAe,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,OAAgB;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAwB,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACO,WAAW,CACpB,OAAkC,EAClC,KAAc,EACd,eAAwB;QAExB,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,EAAE;YAC3C,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAC5B,OAAO,CAAC,QAAyB,EACjC,KAAK,EACL,eAAe,CACf,CAAC;SACF;IACF,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QAC5D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CACD","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\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelServices,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { ISharedMap, ISharedMapEvents } from \"./interfaces\";\nimport { IMapDataObjectSerializable, IMapOperation, MapKernel } from \"./mapKernel\";\nimport { pkgVersion } from \"./packageVersion\";\n\ninterface IMapSerializationFormat {\n\tblobs?: string[];\n\tcontent: IMapDataObjectSerializable;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.\n *\n * @sealed\n * @alpha\n */\nexport class MapFactory implements IChannelFactory {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/map\";\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: MapFactory.Type,\n\t\tsnapshotFormatVersion: \"0.2\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn MapFactory.Type;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn MapFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedMap> {\n\t\tconst map = new SharedMap(id, runtime, attributes);\n\t\tawait map.load(services);\n\n\t\treturn map;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): ISharedMap {\n\t\tconst map = new SharedMap(id, runtime, MapFactory.Attributes);\n\t\tmap.initializeLocal();\n\n\t\treturn map;\n\t}\n}\n\n/**\n * {@inheritDoc ISharedMap}\n * @public\n */\nexport class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {\n\t/**\n\t * Create a new shared map.\n\t * @param runtime - The data store runtime that the new shared map belongs to.\n\t * @param id - Optional name of the shared map.\n\t * @returns Newly created shared map.\n\t *\n\t * @example\n\t * To create a `SharedMap`, call the static create method:\n\t *\n\t * ```typescript\n\t * const myMap = SharedMap.create(this.runtime, id);\n\t * ```\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedMap {\n\t\treturn runtime.createChannel(id, MapFactory.Type) as SharedMap;\n\t}\n\n\t/**\n\t * Get a factory for SharedMap to register with the data store.\n\t * @returns A factory that creates SharedMaps and loads them from storage.\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new MapFactory();\n\t}\n\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 of Object.keys(data)) {\n\t\t\tconst value = data[key];\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:\n\t\t\t\t\t\tvalue.value === undefined\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (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 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): unknown {\n\t\treturn this.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\tif (message.type === MessageType.Operation) {\n\t\t\tthis.kernel.tryProcessMessage(\n\t\t\t\tmessage.contents as IMapOperation,\n\t\t\t\tlocal,\n\t\t\t\tlocalOpMetadata,\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 rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.rollback(content, localOpMetadata);\n\t}\n}\n"]}
@@ -4,62 +4,31 @@
4
4
  */
5
5
  import { IFluidHandle } from "@fluidframework/core-interfaces";
6
6
  import { IFluidSerializer } from "@fluidframework/shared-object-base";
7
- import { TypedEventEmitter } from "@fluidframework/common-utils";
8
- import { ISerializableValue, ISerializedValue, ISharedMapEvents } from "./interfaces";
9
- /**
10
- * Operation indicating a value should be set for a key.
11
- */
12
- export interface IMapSetOperation {
13
- /**
14
- * String identifier of the operation type.
15
- */
16
- type: "set";
17
- /**
18
- * Map key being modified.
19
- */
20
- key: string;
21
- /**
22
- * Value to be set on the key.
23
- */
24
- value: ISerializableValue;
25
- }
26
- /**
27
- * Operation indicating a key should be deleted from the map.
28
- */
29
- export interface IMapDeleteOperation {
30
- /**
31
- * String identifier of the operation type.
32
- */
33
- type: "delete";
34
- /**
35
- * Map key being modified.
36
- */
37
- key: string;
38
- }
7
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
8
+ import { ISerializableValue, ISerializedValue, ISharedMapEvents } from "./interfaces.mjs";
9
+ import { IMapSetOperation, IMapDeleteOperation, IMapClearOperation } from "./internalInterfaces.mjs";
39
10
  /**
40
11
  * Map key operations are one of several types.
41
12
  */
42
- export declare type IMapKeyOperation = IMapSetOperation | IMapDeleteOperation;
43
- /**
44
- * Operation indicating the map should be cleared.
45
- */
46
- export interface IMapClearOperation {
47
- /**
48
- * String identifier of the operation type.
49
- */
50
- type: "clear";
51
- }
13
+ export type IMapKeyOperation = IMapSetOperation | IMapDeleteOperation;
52
14
  /**
53
15
  * Description of a map delta operation
54
16
  */
55
- export declare type IMapOperation = IMapKeyOperation | IMapClearOperation;
17
+ export type IMapOperation = IMapKeyOperation | IMapClearOperation;
56
18
  /**
57
19
  * Defines the in-memory object structure to be used for the conversion to/from serialized.
58
- * Directly used in JSON.stringify, direct result from JSON.parse
20
+ *
21
+ * @remarks Directly used in
22
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
23
+ * | JSON.stringify}, direct result from
24
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.
59
25
  */
60
26
  export interface IMapDataObjectSerializable {
61
27
  [key: string]: ISerializableValue;
62
28
  }
29
+ /**
30
+ * Serialized key/value data.
31
+ */
63
32
  export interface IMapDataObjectSerialized {
64
33
  [key: string]: ISerializedValue;
65
34
  }
@@ -109,7 +78,7 @@ export declare class MapKernel {
109
78
  * @param valueTypes - The value types to register
110
79
  * @param eventEmitter - The object that will emit map events
111
80
  */
112
- 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>);
113
82
  /**
114
83
  * Get an iterator over the keys in this map.
115
84
  * @returns The iterator
@@ -134,7 +103,7 @@ export declare class MapKernel {
134
103
  * Executes the given callback on each entry in the map.
135
104
  * @param callbackFn - Callback function
136
105
  */
137
- 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;
138
107
  /**
139
108
  * {@inheritDoc ISharedMap.get}
140
109
  */
@@ -148,7 +117,7 @@ export declare class MapKernel {
148
117
  /**
149
118
  * {@inheritDoc ISharedMap.set}
150
119
  */
151
- set(key: string, value: any): void;
120
+ set(key: string, value: unknown): void;
152
121
  /**
153
122
  * Delete a key from the map.
154
123
  * @param key - Key to delete
@@ -181,8 +150,8 @@ export declare class MapKernel {
181
150
  * also sent if we are asked to resubmit the message.
182
151
  * @returns True if the operation was submitted, false otherwise.
183
152
  */
184
- trySubmitMessage(op: any, localOpMetadata: unknown): boolean;
185
- tryGetStashedOpLocalMetadata(op: any): unknown;
153
+ trySubmitMessage(op: IMapOperation, localOpMetadata: unknown): boolean;
154
+ tryApplyStashedOp(op: IMapOperation): unknown;
186
155
  /**
187
156
  * Process the given op if a handler is registered.
188
157
  * @param op - The message to process
@@ -0,0 +1 @@
1
+ {"version":3,"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