@fluidframework/map 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.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 (57) hide show
  1. package/.eslintrc.js +11 -16
  2. package/.mocharc.js +2 -2
  3. package/README.md +3 -3
  4. package/api-extractor.json +2 -2
  5. package/dist/directory.d.ts +1 -1
  6. package/dist/directory.d.ts.map +1 -1
  7. package/dist/directory.js +40 -18
  8. package/dist/directory.js.map +1 -1
  9. package/dist/interfaces.d.ts +12 -12
  10. package/dist/interfaces.d.ts.map +1 -1
  11. package/dist/interfaces.js.map +1 -1
  12. package/dist/internalInterfaces.d.ts.map +1 -1
  13. package/dist/internalInterfaces.js.map +1 -1
  14. package/dist/localValues.d.ts.map +1 -1
  15. package/dist/localValues.js.map +1 -1
  16. package/dist/map.d.ts +1 -1
  17. package/dist/map.d.ts.map +1 -1
  18. package/dist/map.js +4 -2
  19. package/dist/map.js.map +1 -1
  20. package/dist/mapKernel.d.ts.map +1 -1
  21. package/dist/mapKernel.js +33 -22
  22. package/dist/mapKernel.js.map +1 -1
  23. package/dist/packageVersion.d.ts +1 -1
  24. package/dist/packageVersion.js +1 -1
  25. package/dist/packageVersion.js.map +1 -1
  26. package/lib/directory.d.ts +1 -1
  27. package/lib/directory.d.ts.map +1 -1
  28. package/lib/directory.js +42 -20
  29. package/lib/directory.js.map +1 -1
  30. package/lib/interfaces.d.ts +12 -12
  31. package/lib/interfaces.d.ts.map +1 -1
  32. package/lib/interfaces.js.map +1 -1
  33. package/lib/internalInterfaces.d.ts.map +1 -1
  34. package/lib/internalInterfaces.js.map +1 -1
  35. package/lib/localValues.d.ts.map +1 -1
  36. package/lib/localValues.js.map +1 -1
  37. package/lib/map.d.ts +1 -1
  38. package/lib/map.d.ts.map +1 -1
  39. package/lib/map.js +5 -3
  40. package/lib/map.js.map +1 -1
  41. package/lib/mapKernel.d.ts.map +1 -1
  42. package/lib/mapKernel.js +34 -23
  43. package/lib/mapKernel.js.map +1 -1
  44. package/lib/packageVersion.d.ts +1 -1
  45. package/lib/packageVersion.js +1 -1
  46. package/lib/packageVersion.js.map +1 -1
  47. package/package.json +50 -50
  48. package/prettier.config.cjs +1 -1
  49. package/src/directory.ts +1952 -1875
  50. package/src/interfaces.ts +303 -306
  51. package/src/internalInterfaces.ts +67 -67
  52. package/src/localValues.ts +85 -94
  53. package/src/map.ts +363 -355
  54. package/src/mapKernel.ts +725 -690
  55. package/src/packageVersion.ts +1 -1
  56. package/tsconfig.esnext.json +5 -5
  57. package/tsconfig.json +9 -15
@@ -9,101 +9,101 @@ import { ILocalValue } from "./localValues";
9
9
  /**
10
10
  * Operation indicating a value should be set for a key.
11
11
  */
12
- export interface IMapSetOperation {
13
- /**
14
- * String identifier of the operation type.
15
- */
16
- type: "set";
17
-
18
- /**
19
- * Map key being modified.
20
- */
21
- key: string;
22
-
23
- /**
24
- * Value to be set on the key.
25
- */
26
- value: ISerializableValue;
12
+ export interface IMapSetOperation {
13
+ /**
14
+ * String identifier of the operation type.
15
+ */
16
+ type: "set";
17
+
18
+ /**
19
+ * Map key being modified.
20
+ */
21
+ key: string;
22
+
23
+ /**
24
+ * Value to be set on the key.
25
+ */
26
+ value: ISerializableValue;
27
27
  }
28
28
 
29
29
  /**
30
30
  * Operation indicating the map should be cleared.
31
31
  */
32
- export interface IMapClearOperation {
33
- /**
34
- * String identifier of the operation type.
35
- */
36
- type: "clear";
32
+ export interface IMapClearOperation {
33
+ /**
34
+ * String identifier of the operation type.
35
+ */
36
+ type: "clear";
37
37
  }
38
38
 
39
39
  /**
40
40
  * Operation indicating a key should be deleted from the map.
41
41
  */
42
- export interface IMapDeleteOperation {
43
- /**
44
- * String identifier of the operation type.
45
- */
46
- type: "delete";
47
-
48
- /**
49
- * Map key being modified.
50
- */
51
- key: string;
42
+ export interface IMapDeleteOperation {
43
+ /**
44
+ * String identifier of the operation type.
45
+ */
46
+ type: "delete";
47
+
48
+ /**
49
+ * Map key being modified.
50
+ */
51
+ key: string;
52
52
  }
53
53
 
54
54
  /**
55
55
  * Metadata for an local `edit` operation.
56
56
  */
57
57
  export interface IMapKeyEditLocalOpMetadata {
58
- /**
59
- * String identifier of the operation type.
60
- */
61
- type: "edit";
62
-
63
- /**
64
- * Unique identifier for the local operation.
65
- */
66
- pendingMessageId: number;
67
-
68
- /**
69
- * Local value prior to the edit.
70
- */
71
- previousValue: ILocalValue;
58
+ /**
59
+ * String identifier of the operation type.
60
+ */
61
+ type: "edit";
62
+
63
+ /**
64
+ * Unique identifier for the local operation.
65
+ */
66
+ pendingMessageId: number;
67
+
68
+ /**
69
+ * Local value prior to the edit.
70
+ */
71
+ previousValue: ILocalValue;
72
72
  }
73
73
 
74
74
  /**
75
75
  * Metadata for an local `add` operation.
76
76
  */
77
77
  export interface IMapKeyAddLocalOpMetadata {
78
- /**
79
- * String identifier of the operation type.
80
- */
81
- type: "add";
82
-
83
- /**
84
- * Unique identifier for the local operation.
85
- */
86
- pendingMessageId: number;
78
+ /**
79
+ * String identifier of the operation type.
80
+ */
81
+ type: "add";
82
+
83
+ /**
84
+ * Unique identifier for the local operation.
85
+ */
86
+ pendingMessageId: number;
87
87
  }
88
88
 
89
89
  /**
90
90
  * Metadata for an local `clear` operation.
91
91
  */
92
92
  export interface IMapClearLocalOpMetadata {
93
- /**
94
- * String identifier of the operation type.
95
- */
96
- type: "clear";
97
-
98
- /**
99
- * Unique identifier for the local operation.
100
- */
101
- pendingMessageId: number;
102
-
103
- /**
104
- * Local map contents prior to clearing it.
105
- */
106
- previousMap?: Map<string, ILocalValue>;
93
+ /**
94
+ * String identifier of the operation type.
95
+ */
96
+ type: "clear";
97
+
98
+ /**
99
+ * Unique identifier for the local operation.
100
+ */
101
+ pendingMessageId: number;
102
+
103
+ /**
104
+ * Local map contents prior to clearing it.
105
+ */
106
+ previousMap?: Map<string, ILocalValue>;
107
107
  }
108
108
 
109
109
  /**
@@ -5,43 +5,37 @@
5
5
 
6
6
  import { IFluidHandle } from "@fluidframework/core-interfaces";
7
7
  import {
8
- IFluidSerializer,
9
- ISerializedHandle,
10
- parseHandles,
11
- serializeHandles,
12
- ValueType,
8
+ IFluidSerializer,
9
+ ISerializedHandle,
10
+ parseHandles,
11
+ serializeHandles,
12
+ ValueType,
13
13
  } from "@fluidframework/shared-object-base";
14
- import {
15
- ISerializableValue,
16
- ISerializedValue,
17
- } from "./interfaces";
14
+ import { ISerializableValue, ISerializedValue } from "./interfaces";
18
15
 
19
16
  /**
20
17
  * A local value to be stored in a container type Distributed Data Store (DDS).
21
18
  */
22
19
  export interface ILocalValue {
23
- /**
24
- * Type indicator of the value stored within.
25
- */
26
- readonly type: string;
20
+ /**
21
+ * Type indicator of the value stored within.
22
+ */
23
+ readonly type: string;
27
24
 
28
- /**
29
- * The in-memory value stored within.
30
- */
31
- // TODO: Use `unknown` instead (breaking change).
32
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
- readonly value: any;
25
+ /**
26
+ * The in-memory value stored within.
27
+ */
28
+ // TODO: Use `unknown` instead (breaking change).
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ readonly value: any;
34
31
 
35
- /**
36
- * Retrieve the serialized form of the value stored within.
37
- * @param serializer - Data store runtime's serializer
38
- * @param bind - Container type's handle
39
- * @returns The serialized form of the contained value
40
- */
41
- makeSerialized(
42
- serializer: IFluidSerializer,
43
- bind: IFluidHandle,
44
- ): ISerializedValue;
32
+ /**
33
+ * Retrieve the serialized form of the value stored within.
34
+ * @param serializer - Data store runtime's serializer
35
+ * @param bind - Container type's handle
36
+ * @returns The serialized form of the contained value
37
+ */
38
+ makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;
45
39
  }
46
40
 
47
41
  /**
@@ -54,51 +48,48 @@ export interface ILocalValue {
54
48
  * @see {@link ILocalValue.makeSerialized}
55
49
  */
56
50
  export function makeSerializable(
57
- localValue: ILocalValue,
58
- serializer: IFluidSerializer,
59
- bind: IFluidHandle,
51
+ localValue: ILocalValue,
52
+ serializer: IFluidSerializer,
53
+ bind: IFluidHandle,
60
54
  ): ISerializableValue {
61
- const value = localValue.makeSerialized(serializer, bind);
62
- return {
63
- type: value.type,
64
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
65
- value: value.value && JSON.parse(value.value),
66
- };
55
+ const value = localValue.makeSerialized(serializer, bind);
56
+ return {
57
+ type: value.type,
58
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
59
+ value: value.value && JSON.parse(value.value),
60
+ };
67
61
  }
68
62
 
69
63
  /**
70
64
  * Manages a contained plain value. May also contain shared object handles.
71
65
  */
72
66
  export class PlainLocalValue implements ILocalValue {
73
- /**
74
- * Create a new PlainLocalValue.
75
- * @param value - The value to store, which may contain shared object handles
76
- */
77
- public constructor(public readonly value: unknown) { }
67
+ /**
68
+ * Create a new PlainLocalValue.
69
+ * @param value - The value to store, which may contain shared object handles
70
+ */
71
+ public constructor(public readonly value: unknown) {}
78
72
 
79
- /**
80
- * {@inheritDoc ILocalValue."type"}
81
- */
82
- public get type(): string {
83
- return ValueType[ValueType.Plain];
84
- }
73
+ /**
74
+ * {@inheritDoc ILocalValue."type"}
75
+ */
76
+ public get type(): string {
77
+ return ValueType[ValueType.Plain];
78
+ }
85
79
 
86
- /**
87
- * {@inheritDoc ILocalValue.makeSerialized}
88
- */
89
- public makeSerialized(
90
- serializer: IFluidSerializer,
91
- bind: IFluidHandle,
92
- ): ISerializedValue {
93
- // Stringify to convert to the serialized handle values - and then parse in order to create
94
- // a POJO for the op
95
- const value = serializeHandles(this.value, serializer, bind);
80
+ /**
81
+ * {@inheritDoc ILocalValue.makeSerialized}
82
+ */
83
+ public makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue {
84
+ // Stringify to convert to the serialized handle values - and then parse in order to create
85
+ // a POJO for the op
86
+ const value = serializeHandles(this.value, serializer, bind);
96
87
 
97
- return {
98
- type: this.type,
99
- value,
100
- };
101
- }
88
+ return {
89
+ type: this.type,
90
+ value,
91
+ };
92
+ }
102
93
  }
103
94
 
104
95
  /**
@@ -106,38 +97,38 @@ export class PlainLocalValue implements ILocalValue {
106
97
  * values with minimal awareness of how those objects are stored, serialized, and deserialized.
107
98
  */
108
99
  export class LocalValueMaker {
109
- /**
110
- * Create a new LocalValueMaker.
111
- * @param serializer - The serializer to serialize / parse handles.
112
- */
113
- public constructor(private readonly serializer: IFluidSerializer) { }
100
+ /**
101
+ * Create a new LocalValueMaker.
102
+ * @param serializer - The serializer to serialize / parse handles.
103
+ */
104
+ public constructor(private readonly serializer: IFluidSerializer) {}
114
105
 
115
- /**
116
- * Create a new local value from an incoming serialized value.
117
- * @param serializable - The serializable value to make local
118
- */
119
- public fromSerializable(serializable: ISerializableValue): ILocalValue {
120
- // Migrate from old shared value to handles
121
- if (serializable.type === ValueType[ValueType.Shared]) {
122
- serializable.type = ValueType[ValueType.Plain];
123
- const handle: ISerializedHandle = {
124
- type: "__fluid_handle__",
125
- url: serializable.value as string,
126
- };
127
- serializable.value = handle;
128
- }
106
+ /**
107
+ * Create a new local value from an incoming serialized value.
108
+ * @param serializable - The serializable value to make local
109
+ */
110
+ public fromSerializable(serializable: ISerializableValue): ILocalValue {
111
+ // Migrate from old shared value to handles
112
+ if (serializable.type === ValueType[ValueType.Shared]) {
113
+ serializable.type = ValueType[ValueType.Plain];
114
+ const handle: ISerializedHandle = {
115
+ type: "__fluid_handle__",
116
+ url: serializable.value as string,
117
+ };
118
+ serializable.value = handle;
119
+ }
129
120
 
130
- const translatedValue: unknown = parseHandles(serializable.value, this.serializer);
121
+ const translatedValue: unknown = parseHandles(serializable.value, this.serializer);
131
122
 
132
- return new PlainLocalValue(translatedValue);
133
- }
123
+ return new PlainLocalValue(translatedValue);
124
+ }
134
125
 
135
- /**
136
- * Create a new local value containing a given plain object.
137
- * @param value - The value to store
138
- * @returns An ILocalValue containing the value
139
- */
140
- public fromInMemory(value: unknown): ILocalValue {
141
- return new PlainLocalValue(value);
142
- }
126
+ /**
127
+ * Create a new local value containing a given plain object.
128
+ * @param value - The value to store
129
+ * @returns An ILocalValue containing the value
130
+ */
131
+ public fromInMemory(value: unknown): ILocalValue {
132
+ return new PlainLocalValue(value);
133
+ }
143
134
  }