@fluidframework/map 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191457

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 (47) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +4 -3
  3. package/dist/directory.d.ts +2 -1
  4. package/dist/directory.d.ts.map +1 -1
  5. package/dist/directory.js +50 -39
  6. package/dist/directory.js.map +1 -1
  7. package/dist/interfaces.d.ts +1 -2
  8. package/dist/interfaces.d.ts.map +1 -1
  9. package/dist/interfaces.js.map +1 -1
  10. package/dist/internalInterfaces.d.ts.map +1 -1
  11. package/dist/internalInterfaces.js.map +1 -1
  12. package/dist/localValues.d.ts.map +1 -1
  13. package/dist/localValues.js +1 -0
  14. package/dist/localValues.js.map +1 -1
  15. package/dist/mapKernel.d.ts +1 -1
  16. package/dist/mapKernel.d.ts.map +1 -1
  17. package/dist/mapKernel.js +13 -12
  18. package/dist/mapKernel.js.map +1 -1
  19. package/dist/packageVersion.d.ts +1 -1
  20. package/dist/packageVersion.js +1 -1
  21. package/dist/packageVersion.js.map +1 -1
  22. package/lib/directory.d.ts +2 -1
  23. package/lib/directory.d.ts.map +1 -1
  24. package/lib/directory.js +32 -21
  25. package/lib/directory.js.map +1 -1
  26. package/lib/interfaces.d.ts +1 -2
  27. package/lib/interfaces.d.ts.map +1 -1
  28. package/lib/interfaces.js.map +1 -1
  29. package/lib/internalInterfaces.d.ts.map +1 -1
  30. package/lib/internalInterfaces.js.map +1 -1
  31. package/lib/localValues.d.ts.map +1 -1
  32. package/lib/localValues.js +1 -0
  33. package/lib/localValues.js.map +1 -1
  34. package/lib/mapKernel.d.ts +1 -1
  35. package/lib/mapKernel.d.ts.map +1 -1
  36. package/lib/mapKernel.js +5 -4
  37. package/lib/mapKernel.js.map +1 -1
  38. package/lib/packageVersion.d.ts +1 -1
  39. package/lib/packageVersion.js +1 -1
  40. package/lib/packageVersion.js.map +1 -1
  41. package/package.json +25 -27
  42. package/src/directory.ts +32 -8
  43. package/src/interfaces.ts +6 -2
  44. package/src/internalInterfaces.ts +2 -0
  45. package/src/localValues.ts +3 -0
  46. package/src/mapKernel.ts +5 -1
  47. package/src/packageVersion.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/map",
3
- "version": "2.0.0-dev.5.3.2.178189",
3
+ "version": "2.0.0-dev.6.4.0.191457",
4
4
  "description": "Distributed map",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "main": "dist/index.js",
15
15
  "module": "lib/index.js",
16
16
  "types": "dist/index.d.ts",
17
- "nyc": {
17
+ "c8": {
18
18
  "all": true,
19
19
  "cache-dir": "nyc/.cache",
20
20
  "exclude": [
@@ -35,34 +35,34 @@
35
35
  "temp-directory": "nyc/.nyc_output"
36
36
  },
37
37
  "dependencies": {
38
- "@fluidframework/common-definitions": "^0.20.1",
39
- "@fluidframework/common-utils": "^1.1.1",
40
- "@fluidframework/container-utils": "2.0.0-dev.5.3.2.178189",
41
- "@fluidframework/core-interfaces": "2.0.0-dev.5.3.2.178189",
42
- "@fluidframework/datastore-definitions": "2.0.0-dev.5.3.2.178189",
43
- "@fluidframework/driver-utils": "2.0.0-dev.5.3.2.178189",
38
+ "@fluid-internal/client-utils": "2.0.0-dev.6.4.0.191457",
39
+ "@fluidframework/core-interfaces": "2.0.0-dev.6.4.0.191457",
40
+ "@fluidframework/core-utils": "2.0.0-dev.6.4.0.191457",
41
+ "@fluidframework/datastore-definitions": "2.0.0-dev.6.4.0.191457",
42
+ "@fluidframework/driver-utils": "2.0.0-dev.6.4.0.191457",
44
43
  "@fluidframework/protocol-definitions": "^1.1.0",
45
- "@fluidframework/runtime-definitions": "2.0.0-dev.5.3.2.178189",
46
- "@fluidframework/runtime-utils": "2.0.0-dev.5.3.2.178189",
47
- "@fluidframework/shared-object-base": "2.0.0-dev.5.3.2.178189",
44
+ "@fluidframework/runtime-definitions": "2.0.0-dev.6.4.0.191457",
45
+ "@fluidframework/runtime-utils": "2.0.0-dev.6.4.0.191457",
46
+ "@fluidframework/shared-object-base": "2.0.0-dev.6.4.0.191457",
47
+ "@fluidframework/telemetry-utils": "2.0.0-dev.6.4.0.191457",
48
48
  "path-browserify": "^1.0.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@fluid-internal/stochastic-test-utils": "2.0.0-dev.5.3.2.178189",
52
- "@fluid-internal/test-dds-utils": "2.0.0-dev.5.3.2.178189",
51
+ "@fluid-internal/stochastic-test-utils": "2.0.0-dev.6.4.0.191457",
52
+ "@fluid-internal/test-dds-utils": "2.0.0-dev.6.4.0.191457",
53
53
  "@fluid-tools/benchmark": "^0.48.0",
54
- "@fluid-tools/build-cli": "^0.21.0",
55
- "@fluidframework/build-common": "^1.2.0",
56
- "@fluidframework/build-tools": "^0.21.0",
57
- "@fluidframework/eslint-config-fluid": "^2.0.0",
58
- "@fluidframework/map-previous": "npm:@fluidframework/map@2.0.0-internal.5.2.0",
59
- "@fluidframework/mocha-test-setup": "2.0.0-dev.5.3.2.178189",
60
- "@fluidframework/test-runtime-utils": "2.0.0-dev.5.3.2.178189",
54
+ "@fluid-tools/build-cli": "^0.22.0",
55
+ "@fluidframework/build-common": "^2.0.0",
56
+ "@fluidframework/build-tools": "^0.22.0",
57
+ "@fluidframework/eslint-config-fluid": "^2.1.0",
58
+ "@fluidframework/map-previous": "npm:@fluidframework/map@2.0.0-internal.6.3.0",
59
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.6.4.0.191457",
60
+ "@fluidframework/test-runtime-utils": "2.0.0-dev.6.4.0.191457",
61
61
  "@microsoft/api-extractor": "^7.34.4",
62
62
  "@types/mocha": "^9.1.1",
63
- "@types/node": "^14.18.38",
63
+ "@types/node": "^16.18.38",
64
64
  "@types/path-browserify": "^1.0.0",
65
- "concurrently": "^7.6.0",
65
+ "c8": "^7.7.1",
66
66
  "copyfiles": "^2.4.1",
67
67
  "cross-env": "^7.0.3",
68
68
  "eslint": "~8.6.0",
@@ -70,7 +70,6 @@
70
70
  "mocha-json-output-reporter": "^2.0.1",
71
71
  "mocha-multi-reporters": "^1.5.1",
72
72
  "moment": "^2.21.0",
73
- "nyc": "^15.1.0",
74
73
  "prettier": "~2.6.2",
75
74
  "rimraf": "^4.4.0",
76
75
  "typescript": "~4.5.5"
@@ -87,7 +86,7 @@
87
86
  "build:genver": "gen-version",
88
87
  "build:test": "tsc --project ./src/test/tsconfig.json",
89
88
  "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
90
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
89
+ "clean": "rimraf --glob 'dist' 'lib' '*.tsbuildinfo' '*.build.log' '_api-extractor-temp' 'nyc'",
91
90
  "eslint": "eslint --format stylish src",
92
91
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
93
92
  "format": "npm run prettier:fix",
@@ -96,11 +95,10 @@
96
95
  "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
97
96
  "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
98
97
  "test": "npm run test:mocha",
99
- "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
98
+ "test:coverage": "c8 npm test",
100
99
  "test:memory": "mocha --config ./src/test/memory/.mocharc.js",
101
100
  "test:memory-profiling:report": "mocha --config ./src/test/memory/.mocharc.js",
102
- "test:mocha": "mocha --unhandled-rejections=strict --recursive 'dist/test/mocha/**/*.spec.js' -r node_modules/@fluidframework/mocha-test-setup --exit",
103
- "test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
101
+ "test:mocha": "mocha --recursive 'dist/test/mocha/**/*.spec.js' -r node_modules/@fluidframework/mocha-test-setup --exit",
104
102
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
105
103
  "tsc": "tsc",
106
104
  "typetests:gen": "fluid-type-test-generator",
package/src/directory.ts CHANGED
@@ -3,8 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert, TypedEventEmitter } from "@fluidframework/common-utils";
7
- import { UsageError } from "@fluidframework/container-utils";
6
+ import { assert } from "@fluidframework/core-utils";
7
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
8
+ import { UsageError } from "@fluidframework/telemetry-utils";
8
9
  import { readAndParse } from "@fluidframework/driver-utils";
9
10
  import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
10
11
  import {
@@ -22,6 +23,7 @@ import {
22
23
  IDirectory,
23
24
  IDirectoryEvents,
24
25
  IDirectoryValueChanged,
26
+ // eslint-disable-next-line import/no-deprecated
25
27
  ISerializableValue,
26
28
  ISerializedValue,
27
29
  ISharedDirectory,
@@ -88,6 +90,7 @@ export interface IDirectorySetOperation {
88
90
  /**
89
91
  * Value to be set on the key.
90
92
  */
93
+ // eslint-disable-next-line import/no-deprecated
91
94
  value: ISerializableValue;
92
95
  }
93
96
 
@@ -215,6 +218,7 @@ export interface IDirectoryDataObject {
215
218
  /**
216
219
  * Key/value date set by the user.
217
220
  */
221
+ // eslint-disable-next-line import/no-deprecated
218
222
  storage?: { [key: string]: ISerializableValue };
219
223
 
220
224
  /**
@@ -313,6 +317,7 @@ export class DirectoryFactory implements IChannelFactory {
313
317
  * {@inheritDoc ISharedDirectory}
314
318
  *
315
319
  * @example
320
+ *
316
321
  * ```typescript
317
322
  * mySharedDirectory.createSubDirectory("a").createSubDirectory("b").createSubDirectory("c").set("foo", val1);
318
323
  * const mySubDir = mySharedDirectory.getWorkingDirectory("/a/b/c");
@@ -735,6 +740,7 @@ export class SharedDirectory
735
740
  private makeLocal(
736
741
  key: string,
737
742
  absolutePath: string,
743
+ // eslint-disable-next-line import/no-deprecated
738
744
  serializable: ISerializableValue,
739
745
  ): ILocalValue {
740
746
  assert(
@@ -748,7 +754,7 @@ export class SharedDirectory
748
754
  /**
749
755
  * This checks if there is pending delete op for local delete for a any subdir in the relative path.
750
756
  * @param relativePath - path of sub directory.
751
- * @returns - true if there is pending delete.
757
+ * @returns `true` if there is pending delete, `false` otherwise.
752
758
  */
753
759
  private isSubDirectoryDeletePending(relativePath: string): boolean {
754
760
  const absolutePath = this.makeAbsolute(relativePath);
@@ -960,6 +966,7 @@ export class SharedDirectory
960
966
  if (!currentSubDirObject.storage) {
961
967
  currentSubDirObject.storage = {};
962
968
  }
969
+ // eslint-disable-next-line import/no-deprecated
963
970
  const result: ISerializableValue = {
964
971
  type: value.type,
965
972
  value: value.value && (JSON.parse(value.value) as object),
@@ -1250,7 +1257,7 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1250
1257
  const isNew = this.createSubDirectoryCore(
1251
1258
  subdirName,
1252
1259
  true,
1253
- -1,
1260
+ this.getLocalSeq(),
1254
1261
  this.runtime.clientId ?? "detached",
1255
1262
  );
1256
1263
  const subDir = this._subdirectories.get(subdirName);
@@ -1274,6 +1281,17 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1274
1281
  return subDir;
1275
1282
  }
1276
1283
 
1284
+ /**
1285
+ * @returns A sequenceNumber which should be used for local changes.
1286
+ * @remarks While detached, 0 is used rather than -1 to represent a change which should be universally known (as opposed to known
1287
+ * only by the local client). This ensures that if the directory is later attached, none of its data needs to be updated (the values
1288
+ * last set while detached will now be known to any new client, until they are changed).
1289
+ * TODO: Convert these conventions to named constants. The semantics used here match those for merge-tree.
1290
+ */
1291
+ private getLocalSeq(): number {
1292
+ return this.directory.isAttached() ? -1 : 0;
1293
+ }
1294
+
1277
1295
  /**
1278
1296
  * {@inheritDoc IDirectory.getSubDirectory}
1279
1297
  */
@@ -1335,7 +1353,7 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1335
1353
  /**
1336
1354
  * This checks if there is pending delete op for local delete for a given child subdirectory.
1337
1355
  * @param subDirName - directory name.
1338
- * @returns - true if there is pending delete.
1356
+ * @returns true if there is pending delete.
1339
1357
  */
1340
1358
  public isSubDirectoryDeletePending(subDirName: string): boolean {
1341
1359
  if (this.pendingDeleteSubDirectoriesTracker.has(subDirName)) {
@@ -1661,7 +1679,12 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1661
1679
  ): ICreateSubDirLocalOpMetadata {
1662
1680
  this.throwIfDisposed();
1663
1681
  // Create the sub directory locally first.
1664
- this.createSubDirectoryCore(op.subdirName, true, -1, this.runtime.clientId ?? "detached");
1682
+ this.createSubDirectoryCore(
1683
+ op.subdirName,
1684
+ true,
1685
+ this.getLocalSeq(),
1686
+ this.runtime.clientId ?? "detached",
1687
+ );
1665
1688
  this.updatePendingSubDirMessageCount(op);
1666
1689
 
1667
1690
  const localOpMetadata: ICreateSubDirLocalOpMetadata = {
@@ -2232,7 +2255,8 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
2232
2255
  if (op.type === "createSubDirectory") {
2233
2256
  const dir = this._subdirectories.get(op.subdirName);
2234
2257
  // Child sub directory create seq number can't be lower than the parent subdirectory.
2235
- if (this.sequenceNumber !== -1 && this.sequenceNumber < msg.sequenceNumber) {
2258
+ // The sequence number for multiple ops can be the same when multiple createSubDirectory occurs with grouped batching enabled, thus <= and not just <.
2259
+ if (this.sequenceNumber !== -1 && this.sequenceNumber <= msg.sequenceNumber) {
2236
2260
  if (dir?.sequenceNumber === -1) {
2237
2261
  // Only set the seq on the first message, could be more
2238
2262
  dir.sequenceNumber = msg.sequenceNumber;
@@ -2328,7 +2352,7 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
2328
2352
  * @param local - Whether the message originated from the local client
2329
2353
  * @param seq - Sequence number at which this directory is created
2330
2354
  * @param clientId - Id of client which created this directory.
2331
- * @returns - True if is newly created, false if it already existed.
2355
+ * @returns True if is newly created, false if it already existed.
2332
2356
  */
2333
2357
  private createSubDirectoryCore(
2334
2358
  subdirName: string,
package/src/interfaces.ts CHANGED
@@ -4,8 +4,12 @@
4
4
  */
5
5
 
6
6
  import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
7
- import { IEvent, IEventProvider, IEventThisPlaceHolder } from "@fluidframework/common-definitions";
8
- import { IDisposable } from "@fluidframework/core-interfaces";
7
+ import {
8
+ IDisposable,
9
+ IEvent,
10
+ IEventProvider,
11
+ IEventThisPlaceHolder,
12
+ } from "@fluidframework/core-interfaces";
9
13
 
10
14
  /**
11
15
  * Type of "valueChanged" event parameter.
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ // eslint-disable-next-line import/no-deprecated
6
7
  import { ISerializableValue } from "./interfaces";
7
8
  import { ILocalValue } from "./localValues";
8
9
 
@@ -23,6 +24,7 @@ export interface IMapSetOperation {
23
24
  /**
24
25
  * Value to be set on the key.
25
26
  */
27
+ // eslint-disable-next-line import/no-deprecated
26
28
  value: ISerializableValue;
27
29
  }
28
30
 
@@ -11,6 +11,7 @@ import {
11
11
  serializeHandles,
12
12
  ValueType,
13
13
  } from "@fluidframework/shared-object-base";
14
+ // eslint-disable-next-line import/no-deprecated
14
15
  import { ISerializableValue, ISerializedValue } from "./interfaces";
15
16
 
16
17
  /**
@@ -51,6 +52,7 @@ export function makeSerializable(
51
52
  localValue: ILocalValue,
52
53
  serializer: IFluidSerializer,
53
54
  bind: IFluidHandle,
55
+ // eslint-disable-next-line import/no-deprecated
54
56
  ): ISerializableValue {
55
57
  const value = localValue.makeSerialized(serializer, bind);
56
58
  return {
@@ -107,6 +109,7 @@ export class LocalValueMaker {
107
109
  * Create a new local value from an incoming serialized value.
108
110
  * @param serializable - The serializable value to make local
109
111
  */
112
+ // eslint-disable-next-line import/no-deprecated
110
113
  public fromSerializable(serializable: ISerializableValue): ILocalValue {
111
114
  // Migrate from old shared value to handles
112
115
  if (serializable.type === ValueType[ValueType.Shared]) {
package/src/mapKernel.ts CHANGED
@@ -5,7 +5,9 @@
5
5
 
6
6
  import { IFluidHandle } from "@fluidframework/core-interfaces";
7
7
  import { IFluidSerializer, ValueType } from "@fluidframework/shared-object-base";
8
- import { assert, TypedEventEmitter } from "@fluidframework/common-utils";
8
+ import { assert } from "@fluidframework/core-utils";
9
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
10
+ // eslint-disable-next-line import/no-deprecated
9
11
  import { ISerializableValue, ISerializedValue, ISharedMapEvents } from "./interfaces";
10
12
  import {
11
13
  IMapSetOperation,
@@ -59,6 +61,7 @@ export type IMapOperation = IMapKeyOperation | IMapClearOperation;
59
61
  * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.
60
62
  */
61
63
  export interface IMapDataObjectSerializable {
64
+ // eslint-disable-next-line import/no-deprecated
62
65
  [key: string]: ISerializableValue;
63
66
  }
64
67
 
@@ -572,6 +575,7 @@ export class MapKernel {
572
575
  * @param serializable - The remote information that we can convert into a real object
573
576
  * @returns The local value that was produced
574
577
  */
578
+ // eslint-disable-next-line import/no-deprecated
575
579
  private makeLocal(key: string, serializable: ISerializableValue): ILocalValue {
576
580
  if (
577
581
  serializable.type === ValueType[ValueType.Plain] ||
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/map";
9
- export const pkgVersion = "2.0.0-dev.5.3.2.178189";
9
+ export const pkgVersion = "2.0.0-dev.6.4.0.191457";