@fluidframework/map 2.1.0-276985 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +53 -10
  3. package/api-extractor/api-extractor.current.json +5 -0
  4. package/api-extractor/api-extractor.legacy.json +1 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/map.legacy.alpha.api.md +6 -8
  7. package/api-report/map.legacy.public.api.md +41 -0
  8. package/dist/directory.d.ts.map +1 -1
  9. package/dist/directory.js +14 -5
  10. package/dist/directory.js.map +1 -1
  11. package/dist/interfaces.d.ts +12 -4
  12. package/dist/interfaces.d.ts.map +1 -1
  13. package/dist/interfaces.js.map +1 -1
  14. package/dist/legacy.d.ts +13 -1
  15. package/dist/map.d.ts.map +1 -1
  16. package/dist/map.js +9 -10
  17. package/dist/map.js.map +1 -1
  18. package/dist/mapKernel.d.ts.map +1 -1
  19. package/dist/mapKernel.js +2 -0
  20. package/dist/mapKernel.js.map +1 -1
  21. package/dist/packageVersion.d.ts +1 -1
  22. package/dist/packageVersion.d.ts.map +1 -1
  23. package/dist/packageVersion.js +1 -1
  24. package/dist/packageVersion.js.map +1 -1
  25. package/dist/public.d.ts +12 -2
  26. package/internal.d.ts +1 -1
  27. package/legacy.d.ts +1 -1
  28. package/lib/directory.d.ts.map +1 -1
  29. package/lib/directory.js +14 -5
  30. package/lib/directory.js.map +1 -1
  31. package/lib/interfaces.d.ts +12 -4
  32. package/lib/interfaces.d.ts.map +1 -1
  33. package/lib/interfaces.js.map +1 -1
  34. package/lib/legacy.d.ts +13 -1
  35. package/lib/map.d.ts.map +1 -1
  36. package/lib/map.js +9 -10
  37. package/lib/map.js.map +1 -1
  38. package/lib/mapKernel.d.ts.map +1 -1
  39. package/lib/mapKernel.js +2 -0
  40. package/lib/mapKernel.js.map +1 -1
  41. package/lib/packageVersion.d.ts +1 -1
  42. package/lib/packageVersion.d.ts.map +1 -1
  43. package/lib/packageVersion.js +1 -1
  44. package/lib/packageVersion.js.map +1 -1
  45. package/lib/public.d.ts +12 -2
  46. package/package.json +39 -30
  47. package/src/directory.ts +15 -6
  48. package/src/interfaces.ts +12 -4
  49. package/src/map.ts +9 -10
  50. package/src/mapKernel.ts +3 -1
  51. package/src/packageVersion.ts +1 -1
  52. package/tsconfig.json +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/map",
3
- "version": "2.1.0-276985",
3
+ "version": "2.1.0",
4
4
  "description": "Distributed map",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -67,33 +67,33 @@
67
67
  "temp-directory": "nyc/.nyc_output"
68
68
  },
69
69
  "dependencies": {
70
- "@fluid-internal/client-utils": "2.1.0-276985",
71
- "@fluidframework/core-interfaces": "2.1.0-276985",
72
- "@fluidframework/core-utils": "2.1.0-276985",
73
- "@fluidframework/datastore-definitions": "2.1.0-276985",
74
- "@fluidframework/driver-definitions": "2.1.0-276985",
75
- "@fluidframework/driver-utils": "2.1.0-276985",
76
- "@fluidframework/merge-tree": "2.1.0-276985",
77
- "@fluidframework/runtime-definitions": "2.1.0-276985",
78
- "@fluidframework/runtime-utils": "2.1.0-276985",
79
- "@fluidframework/shared-object-base": "2.1.0-276985",
80
- "@fluidframework/telemetry-utils": "2.1.0-276985",
70
+ "@fluid-internal/client-utils": "~2.1.0",
71
+ "@fluidframework/core-interfaces": "~2.1.0",
72
+ "@fluidframework/core-utils": "~2.1.0",
73
+ "@fluidframework/datastore-definitions": "~2.1.0",
74
+ "@fluidframework/driver-definitions": "~2.1.0",
75
+ "@fluidframework/driver-utils": "~2.1.0",
76
+ "@fluidframework/merge-tree": "~2.1.0",
77
+ "@fluidframework/runtime-definitions": "~2.1.0",
78
+ "@fluidframework/runtime-utils": "~2.1.0",
79
+ "@fluidframework/shared-object-base": "~2.1.0",
80
+ "@fluidframework/telemetry-utils": "~2.1.0",
81
81
  "path-browserify": "^1.0.1"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@arethetypeswrong/cli": "^0.15.2",
85
- "@biomejs/biome": "^1.7.3",
86
- "@fluid-internal/mocha-test-setup": "2.1.0-276985",
87
- "@fluid-private/stochastic-test-utils": "2.1.0-276985",
88
- "@fluid-private/test-dds-utils": "2.1.0-276985",
85
+ "@biomejs/biome": "~1.8.3",
86
+ "@fluid-internal/mocha-test-setup": "~2.1.0",
87
+ "@fluid-private/stochastic-test-utils": "~2.1.0",
88
+ "@fluid-private/test-dds-utils": "~2.1.0",
89
89
  "@fluid-tools/benchmark": "^0.48.0",
90
- "@fluid-tools/build-cli": "^0.39.0",
90
+ "@fluid-tools/build-cli": "^0.41.0",
91
91
  "@fluidframework/build-common": "^2.0.3",
92
- "@fluidframework/build-tools": "^0.39.0",
93
- "@fluidframework/container-definitions": "2.1.0-276985",
92
+ "@fluidframework/build-tools": "^0.41.0",
93
+ "@fluidframework/container-definitions": "~2.1.0",
94
94
  "@fluidframework/eslint-config-fluid": "^5.3.0",
95
- "@fluidframework/map-previous": "npm:@fluidframework/map@2.0.0-rc.5.0.0",
96
- "@fluidframework/test-runtime-utils": "2.1.0-276985",
95
+ "@fluidframework/map-previous": "npm:@fluidframework/map@2.0.0",
96
+ "@fluidframework/test-runtime-utils": "~2.1.0",
97
97
  "@microsoft/api-extractor": "^7.45.1",
98
98
  "@types/mocha": "^9.1.1",
99
99
  "@types/node": "^18.19.0",
@@ -113,25 +113,33 @@
113
113
  "typescript": "~5.4.5"
114
114
  },
115
115
  "typeValidation": {
116
- "broken": {}
116
+ "broken": {
117
+ "Variable_SharedMap": {
118
+ "forwardCompat": false
119
+ },
120
+ "Variable_SharedDirectory": {
121
+ "forwardCompat": false
122
+ }
123
+ }
117
124
  },
118
125
  "scripts": {
119
126
  "api": "fluid-build . --task api",
120
127
  "api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
121
128
  "api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
122
129
  "build": "fluid-build . --task build",
130
+ "build:api-reports": "concurrently \"npm:build:api-reports:*\"",
131
+ "build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
132
+ "build:api-reports:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
123
133
  "build:commonjs": "fluid-build . --task commonjs",
124
134
  "build:compile": "fluid-build . --task compile",
125
- "build:docs": "concurrently \"npm:build:docs:*\"",
126
- "build:docs:current": "api-extractor run --local",
127
- "build:docs:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
135
+ "build:docs": "api-extractor run --local",
128
136
  "build:esnext": "tsc --project ./tsconfig.json",
129
137
  "build:genver": "gen-version",
130
138
  "build:test": "npm run build:test:esm && npm run build:test:cjs",
131
139
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
132
140
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
133
141
  "check:are-the-types-wrong": "attw --pack .",
134
- "check:biome": "biome check . --formatter-enabled=true",
142
+ "check:biome": "biome check .",
135
143
  "check:exports": "concurrently \"npm:check:exports:*\"",
136
144
  "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
137
145
  "check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
@@ -140,14 +148,15 @@
140
148
  "check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
141
149
  "check:format": "npm run check:biome",
142
150
  "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
143
- "ci:build:docs": "concurrently \"npm:ci:build:docs:*\"",
144
- "ci:build:docs:current": "api-extractor run",
145
- "ci:build:docs:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
151
+ "ci:build:api-reports": "concurrently \"npm:ci:build:api-reports:*\"",
152
+ "ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
153
+ "ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
154
+ "ci:build:docs": "api-extractor run",
146
155
  "clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
147
156
  "eslint": "eslint --format stylish src",
148
157
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
149
158
  "format": "npm run format:biome",
150
- "format:biome": "biome check . --formatter-enabled=true --apply",
159
+ "format:biome": "biome check . --write",
151
160
  "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
152
161
  "lint": "fluid-build . --task lint",
153
162
  "lint:fix": "fluid-build . --task eslint:fix --task format",
package/src/directory.ts CHANGED
@@ -867,7 +867,9 @@ export class SharedDirectory
867
867
  const nodeList = absolutePath.split(posix.sep);
868
868
  let start = 1;
869
869
  while (start < nodeList.length) {
870
- const subDirName = nodeList[start];
870
+ // Non null asserting, this loop only runs while start in in the bounds of the array
871
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
872
+ const subDirName = nodeList[start]!;
871
873
  if (currentParent.isSubDirectoryDeletePending(subDirName)) {
872
874
  return true;
873
875
  }
@@ -1492,7 +1494,10 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1492
1494
  dirs: this._subdirectories,
1493
1495
  next(): IteratorResult<[string, IDirectory]> {
1494
1496
  if (this.index < subdirNames.length) {
1495
- const subdirName = subdirNames[this.index++];
1497
+ // Non null asserting, we've checked that the index is inside the bounds of the array.
1498
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1499
+ const subdirName = subdirNames[this.index]!;
1500
+ this.index++;
1496
1501
  const subdir = this.dirs.get(subdirName);
1497
1502
  assert(subdir !== undefined, 0x8ac /* Could not find expected sub-directory. */);
1498
1503
  return { value: [subdirName, subdir], done: false };
@@ -2183,18 +2188,22 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
2183
2188
  ): boolean {
2184
2189
  if (this.pendingClearMessageIds.length > 0) {
2185
2190
  if (local) {
2191
+ // Remove all pendingMessageIds lower than first pendingClearMessageId.
2192
+ // Non null asserting, because of pendingClearMessageIds length check above
2193
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2194
+ const firstPendingClearMessageId = this.pendingClearMessageIds[0]!;
2186
2195
  assert(
2187
2196
  localOpMetadata !== undefined &&
2188
2197
  isKeyEditLocalOpMetadata(localOpMetadata) &&
2189
- localOpMetadata.pendingMessageId < this.pendingClearMessageIds[0],
2198
+ localOpMetadata.pendingMessageId < firstPendingClearMessageId,
2190
2199
  0x010 /* "Received out of order storage op when there is an unackd clear message" */,
2191
2200
  );
2192
- // Remove all pendingMessageIds lower than first pendingClearMessageId.
2193
- const lowestPendingClearMessageId = this.pendingClearMessageIds[0];
2194
2201
  const pendingKeyMessageIdArray = this.pendingKeys.get(op.key);
2195
2202
  if (pendingKeyMessageIdArray !== undefined) {
2196
2203
  let index = 0;
2197
- while (pendingKeyMessageIdArray[index] < lowestPendingClearMessageId) {
2204
+ // Non-null asserting because we maintain that the pendingKeyMessageIdArray will only exist if it is non-empty.
2205
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2206
+ while (pendingKeyMessageIdArray[index]! < firstPendingClearMessageId) {
2198
2207
  index += 1;
2199
2208
  }
2200
2209
  const newPendingKeyMessageId = pendingKeyMessageIdArray.splice(index);
package/src/interfaces.ts CHANGED
@@ -18,7 +18,7 @@ import type {
18
18
  * Type of "valueChanged" event parameter.
19
19
  * @sealed
20
20
  * @legacy
21
- * @alpha
21
+ * @public
22
22
  */
23
23
  export interface IValueChanged {
24
24
  /**
@@ -38,8 +38,9 @@ export interface IValueChanged {
38
38
  * Interface describing actions on a directory.
39
39
  *
40
40
  * @remarks When used as a Map, operates on its keys.
41
+ * @sealed
41
42
  * @legacy
42
- * @alpha
43
+ * @public
43
44
  */
44
45
  export interface IDirectory
45
46
  // TODO: Use `unknown` instead (breaking change).
@@ -123,6 +124,7 @@ export interface IDirectory
123
124
  *
124
125
  * @remarks
125
126
  * These events only emit on the {@link ISharedDirectory} itself, and not on subdirectories.
127
+ * @sealed
126
128
  * @legacy
127
129
  * @alpha
128
130
  */
@@ -197,8 +199,9 @@ export interface ISharedDirectoryEvents extends ISharedObjectEvents {
197
199
 
198
200
  /**
199
201
  * Events emitted in response to changes to the directory data.
202
+ * @sealed
200
203
  * @legacy
201
- * @alpha
204
+ * @public
202
205
  */
203
206
  export interface IDirectoryEvents extends IEvent {
204
207
  /**
@@ -279,6 +282,7 @@ export interface IDirectoryEvents extends IEvent {
279
282
  * Provides a hierarchical organization of map-like data structures as SubDirectories.
280
283
  * The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.
281
284
  * SubDirectories can be retrieved for use as working directories.
285
+ * @sealed
282
286
  * @legacy
283
287
  * @alpha
284
288
  */
@@ -295,12 +299,16 @@ export interface ISharedDirectory
295
299
 
296
300
  /**
297
301
  * Type of "valueChanged" event parameter for {@link ISharedDirectory}.
302
+ * @sealed
298
303
  * @legacy
299
- * @alpha
304
+ * @public
300
305
  */
301
306
  export interface IDirectoryValueChanged extends IValueChanged {
302
307
  /**
303
308
  * The absolute path to the IDirectory storing the key which changed.
309
+ * @readonly
310
+ * @privateRemarks
311
+ * When breaking changes can be made, `readonly` should be added.
304
312
  */
305
313
  path: string;
306
314
  }
package/src/map.ts CHANGED
@@ -202,23 +202,22 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
202
202
  // and result in non-incremental snapshot.
203
203
  // This can be improved in the future, without being format breaking change, as loading sequence
204
204
  // loads all blobs at once and partitioning schema has no impact on that process.
205
- for (const key of Object.keys(data)) {
206
- const value = data[key];
207
- if (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {
205
+ for (const [key, { value, type }] of Object.entries(data)) {
206
+ if (value && value.length >= MinValueSizeSeparateSnapshotBlob) {
208
207
  const blobName = `blob${counter}`;
209
208
  counter++;
210
209
  blobs.push(blobName);
211
210
  const content: IMapDataObjectSerializable = {
212
211
  [key]: {
213
- type: value.type,
214
- value: JSON.parse(value.value) as unknown,
212
+ type,
213
+ value: JSON.parse(value) as unknown,
215
214
  },
216
215
  };
217
216
  builder.addBlob(blobName, JSON.stringify(content));
218
217
  } else {
219
- currentSize += value.type.length + 21; // Approximation cost of property header
220
- if (value.value) {
221
- currentSize += value.value.length;
218
+ currentSize += type.length + 21; // Approximation cost of property header
219
+ if (value) {
220
+ currentSize += value.length;
222
221
  }
223
222
 
224
223
  if (currentSize > MaxSnapshotBlobSize) {
@@ -230,8 +229,8 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
230
229
  currentSize = 0;
231
230
  }
232
231
  headerBlob[key] = {
233
- type: value.type,
234
- value: value.value === undefined ? undefined : (JSON.parse(value.value) as unknown),
232
+ type,
233
+ value: value === undefined ? undefined : (JSON.parse(value) as unknown),
235
234
  };
236
235
  }
237
236
  }
package/src/mapKernel.ts CHANGED
@@ -612,7 +612,9 @@ export class MapKernel {
612
612
  assert(
613
613
  localOpMetadata !== undefined &&
614
614
  isMapKeyLocalOpMetadata(localOpMetadata) &&
615
- localOpMetadata.pendingMessageId < this.pendingClearMessageIds[0],
615
+ // Non null asserting, above we checked that the length is greater than 0.
616
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
617
+ localOpMetadata.pendingMessageId < this.pendingClearMessageIds[0]!,
616
618
  0x013 /* "Received out of order op when there is an unackd clear message" */,
617
619
  );
618
620
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/map";
9
- export const pkgVersion = "2.1.0-276985";
9
+ export const pkgVersion = "2.1.0";
package/tsconfig.json CHANGED
@@ -5,7 +5,6 @@
5
5
  "compilerOptions": {
6
6
  "rootDir": "./src",
7
7
  "outDir": "./lib",
8
- "noUncheckedIndexedAccess": false,
9
8
  "exactOptionalPropertyTypes": false,
10
9
  },
11
10
  }