@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.
- package/.eslintrc.js +11 -16
- package/.mocharc.js +2 -2
- package/README.md +3 -3
- package/api-extractor.json +2 -2
- package/dist/directory.d.ts +1 -1
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +40 -18
- package/dist/directory.js.map +1 -1
- package/dist/interfaces.d.ts +12 -12
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/internalInterfaces.d.ts.map +1 -1
- package/dist/internalInterfaces.js.map +1 -1
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js.map +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +4 -2
- package/dist/map.js.map +1 -1
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +33 -22
- package/dist/mapKernel.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/directory.d.ts +1 -1
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +42 -20
- package/lib/directory.js.map +1 -1
- package/lib/interfaces.d.ts +12 -12
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/internalInterfaces.d.ts.map +1 -1
- package/lib/internalInterfaces.js.map +1 -1
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js.map +1 -1
- package/lib/map.d.ts +1 -1
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +5 -3
- package/lib/map.js.map +1 -1
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +34 -23
- package/lib/mapKernel.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +50 -50
- package/prettier.config.cjs +1 -1
- package/src/directory.ts +1952 -1875
- package/src/interfaces.ts +303 -306
- package/src/internalInterfaces.ts +67 -67
- package/src/localValues.ts +85 -94
- package/src/map.ts +363 -355
- package/src/mapKernel.ts +725 -690
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +5 -5
- 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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
/**
|
package/src/localValues.ts
CHANGED
|
@@ -5,43 +5,37 @@
|
|
|
5
5
|
|
|
6
6
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Type indicator of the value stored within.
|
|
22
|
+
*/
|
|
23
|
+
readonly type: string;
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
localValue: ILocalValue,
|
|
52
|
+
serializer: IFluidSerializer,
|
|
53
|
+
bind: IFluidHandle,
|
|
60
54
|
): ISerializableValue {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
/**
|
|
74
|
+
* {@inheritDoc ILocalValue."type"}
|
|
75
|
+
*/
|
|
76
|
+
public get type(): string {
|
|
77
|
+
return ValueType[ValueType.Plain];
|
|
78
|
+
}
|
|
85
79
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
121
|
+
const translatedValue: unknown = parseHandles(serializable.value, this.serializer);
|
|
131
122
|
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
return new PlainLocalValue(translatedValue);
|
|
124
|
+
}
|
|
134
125
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
}
|