@fluidframework/map 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
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 +12 -14
- package/.mocharc.js +2 -2
- package/README.md +3 -3
- package/api-extractor.json +2 -2
- package/dist/directory.d.ts +38 -5
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +285 -88
- package/dist/directory.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +27 -17
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/internalInterfaces.d.ts +39 -0
- package/dist/internalInterfaces.d.ts.map +1 -1
- package/dist/internalInterfaces.js.map +1 -1
- package/dist/localValues.d.ts +12 -3
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js +10 -0
- package/dist/localValues.js.map +1 -1
- package/dist/map.d.ts +5 -5
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +15 -2
- package/dist/map.js.map +1 -1
- package/dist/mapKernel.d.ts +5 -5
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +58 -33
- 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 +38 -5
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +287 -90
- package/lib/directory.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +27 -17
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/internalInterfaces.d.ts +39 -0
- package/lib/internalInterfaces.d.ts.map +1 -1
- package/lib/internalInterfaces.js.map +1 -1
- package/lib/localValues.d.ts +12 -3
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js +10 -0
- package/lib/localValues.js.map +1 -1
- package/lib/map.d.ts +5 -5
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +16 -3
- package/lib/map.js.map +1 -1
- package/lib/mapKernel.d.ts +5 -5
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +59 -34
- 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 +60 -59
- package/prettier.config.cjs +1 -1
- package/src/directory.ts +2207 -1848
- package/src/index.ts +1 -0
- package/src/interfaces.ts +309 -288
- package/src/internalInterfaces.ts +83 -38
- package/src/localValues.ts +95 -93
- package/src/map.ts +364 -345
- package/src/mapKernel.ts +729 -676
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +5 -5
- package/tsconfig.json +9 -15
|
@@ -9,64 +9,109 @@ 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
|
+
/**
|
|
55
|
+
* Metadata for an local `edit` operation.
|
|
56
|
+
*/
|
|
54
57
|
export interface IMapKeyEditLocalOpMetadata {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
72
|
}
|
|
59
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Metadata for an local `add` operation.
|
|
76
|
+
*/
|
|
60
77
|
export interface IMapKeyAddLocalOpMetadata {
|
|
61
|
-
|
|
62
|
-
|
|
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;
|
|
63
87
|
}
|
|
64
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Metadata for an local `clear` operation.
|
|
91
|
+
*/
|
|
65
92
|
export interface IMapClearLocalOpMetadata {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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>;
|
|
69
107
|
}
|
|
70
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Metadata for a local operation associated with a specific key entry in the map.
|
|
111
|
+
*/
|
|
71
112
|
export type MapKeyLocalOpMetadata = IMapKeyEditLocalOpMetadata | IMapKeyAddLocalOpMetadata;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Metadata for a local operation.
|
|
116
|
+
*/
|
|
72
117
|
export type MapLocalOpMetadata = IMapClearLocalOpMetadata | MapKeyLocalOpMetadata;
|
package/src/localValues.ts
CHANGED
|
@@ -5,88 +5,91 @@
|
|
|
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
|
-
|
|
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;
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
serializer: IFluidSerializer,
|
|
41
|
-
bind: IFluidHandle,
|
|
42
|
-
): 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;
|
|
43
39
|
}
|
|
44
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Converts the provided `localValue` to its serialized form.
|
|
43
|
+
*
|
|
44
|
+
* @param localValue - The value to serialize.
|
|
45
|
+
* @param serializer - Data store runtime's serializer.
|
|
46
|
+
* @param bind - Container type's handle.
|
|
47
|
+
*
|
|
48
|
+
* @see {@link ILocalValue.makeSerialized}
|
|
49
|
+
*/
|
|
45
50
|
export function makeSerializable(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
localValue: ILocalValue,
|
|
52
|
+
serializer: IFluidSerializer,
|
|
53
|
+
bind: IFluidHandle,
|
|
54
|
+
): ISerializableValue {
|
|
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
|
+
};
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
/**
|
|
57
64
|
* Manages a contained plain value. May also contain shared object handles.
|
|
58
65
|
*/
|
|
59
66
|
export class PlainLocalValue implements ILocalValue {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
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) {}
|
|
66
72
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
/**
|
|
74
|
+
* {@inheritDoc ILocalValue."type"}
|
|
75
|
+
*/
|
|
76
|
+
public get type(): string {
|
|
77
|
+
return ValueType[ValueType.Plain];
|
|
78
|
+
}
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// Stringify to convert to the serialized handle values - and then parse in order to create
|
|
82
|
-
// a POJO for the op
|
|
83
|
-
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);
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
return {
|
|
89
|
+
type: this.type,
|
|
90
|
+
value,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
/**
|
|
@@ -94,39 +97,38 @@ export class PlainLocalValue implements ILocalValue {
|
|
|
94
97
|
* values with minimal awareness of how those objects are stored, serialized, and deserialized.
|
|
95
98
|
*/
|
|
96
99
|
export class LocalValueMaker {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a new LocalValueMaker.
|
|
102
|
+
* @param serializer - The serializer to serialize / parse handles.
|
|
103
|
+
*/
|
|
104
|
+
public constructor(private readonly serializer: IFluidSerializer) {}
|
|
103
105
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
}
|
|
118
120
|
|
|
119
|
-
|
|
121
|
+
const translatedValue: unknown = parseHandles(serializable.value, this.serializer);
|
|
120
122
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
return new PlainLocalValue(translatedValue);
|
|
124
|
+
}
|
|
123
125
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
+
}
|
|
132
134
|
}
|