@fluidframework/map 2.42.0 → 2.43.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/CHANGELOG.md +4 -0
- package/dist/directory.d.ts +2 -16
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +21 -38
- package/dist/directory.js.map +1 -1
- package/dist/localValues.d.ts +10 -58
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js +29 -83
- package/dist/localValues.js.map +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +4 -4
- package/dist/map.js.map +1 -1
- package/dist/mapKernel.d.ts +5 -22
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +14 -57
- 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 +2 -16
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +22 -39
- package/lib/directory.js.map +1 -1
- package/lib/localValues.d.ts +10 -58
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js +26 -79
- package/lib/localValues.js.map +1 -1
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +4 -4
- package/lib/map.js.map +1 -1
- package/lib/mapKernel.d.ts +5 -22
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +15 -58
- 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 +20 -20
- package/src/directory.ts +30 -59
- package/src/localValues.ts +33 -106
- package/src/map.ts +7 -5
- package/src/mapKernel.ts +24 -74
- package/src/packageVersion.ts +1 -1
package/lib/localValues.d.ts
CHANGED
|
@@ -9,70 +9,22 @@ import type { ISerializableValue, ISerializedValue } from "./internalInterfaces.
|
|
|
9
9
|
* A local value to be stored in a container type Distributed Data Store (DDS).
|
|
10
10
|
*/
|
|
11
11
|
export interface ILocalValue {
|
|
12
|
-
/**
|
|
13
|
-
* Type indicator of the value stored within.
|
|
14
|
-
*/
|
|
15
|
-
readonly type: string;
|
|
16
12
|
/**
|
|
17
13
|
* The in-memory value stored within.
|
|
18
14
|
*/
|
|
19
|
-
readonly value:
|
|
20
|
-
/**
|
|
21
|
-
* Retrieve the serialized form of the value stored within.
|
|
22
|
-
* @param serializer - Data store runtime's serializer
|
|
23
|
-
* @param bind - Container type's handle
|
|
24
|
-
* @returns The serialized form of the contained value
|
|
25
|
-
*/
|
|
26
|
-
makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;
|
|
15
|
+
readonly value: unknown;
|
|
27
16
|
}
|
|
28
17
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @param localValue - The value to serialize.
|
|
32
|
-
* @param serializer - Data store runtime's serializer.
|
|
33
|
-
* @param bind - Container type's handle.
|
|
34
|
-
*
|
|
35
|
-
* @see {@link ILocalValue.makeSerialized}
|
|
18
|
+
* Convert a value to its serialized form, i.e. to be used in ops and summaries.
|
|
36
19
|
*/
|
|
37
|
-
export declare
|
|
20
|
+
export declare const serializeValue: (value: unknown, serializer: IFluidSerializer, bind: IFluidHandle) => ISerializedValue;
|
|
38
21
|
/**
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* @param value - The value to store, which may contain shared object handles
|
|
46
|
-
*/
|
|
47
|
-
constructor(value: unknown);
|
|
48
|
-
/**
|
|
49
|
-
* {@inheritDoc ILocalValue."type"}
|
|
50
|
-
*/
|
|
51
|
-
get type(): string;
|
|
52
|
-
/**
|
|
53
|
-
* {@inheritDoc ILocalValue.makeSerialized}
|
|
54
|
-
*/
|
|
55
|
-
makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Enables a container type {@link https://fluidframework.com/docs/build/dds/ | DDS} to produce and store local
|
|
59
|
-
* values with minimal awareness of how those objects are stored, serialized, and deserialized.
|
|
22
|
+
* Very old versions of Fluid permitted a different type of stored value, which represented a
|
|
23
|
+
* SharedObject held directly. This functionality has since been replaced with handles.
|
|
24
|
+
*
|
|
25
|
+
* If the passed serializable is one of these old values, this function will mutate it to a modern
|
|
26
|
+
* value with a handle. Otherwise it does nothing.
|
|
27
|
+
* @param serializable - The serializable value to potentially convert.
|
|
60
28
|
*/
|
|
61
|
-
export declare
|
|
62
|
-
/**
|
|
63
|
-
* Create a new LocalValueMaker.
|
|
64
|
-
*/
|
|
65
|
-
constructor();
|
|
66
|
-
/**
|
|
67
|
-
* Create a new local value from an incoming serialized value.
|
|
68
|
-
* @param serializable - The serializable value to make local
|
|
69
|
-
*/
|
|
70
|
-
fromSerializable(serializable: ISerializableValue, serializer: IFluidSerializer, bind: IFluidHandle): ILocalValue;
|
|
71
|
-
/**
|
|
72
|
-
* Create a new local value containing a given plain object.
|
|
73
|
-
* @param value - The value to store
|
|
74
|
-
* @returns An ILocalValue containing the value
|
|
75
|
-
*/
|
|
76
|
-
fromInMemory(value: unknown): ILocalValue;
|
|
77
|
-
}
|
|
29
|
+
export declare const migrateIfSharedSerializable: (serializable: ISerializableValue, serializer: IFluidSerializer, bind: IFluidHandle) => void;
|
|
78
30
|
//# sourceMappingURL=localValues.d.ts.map
|
package/lib/localValues.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localValues.d.ts","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAQpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"localValues.d.ts","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAQpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,UACnB,OAAO,cACF,gBAAgB,QACtB,YAAY,KAChB,gBAOF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,iBAEzB,kBAAkB,cACpB,gBAAgB,QACtB,YAAY,KAChB,IAaF,CAAC"}
|
package/lib/localValues.js
CHANGED
|
@@ -4,90 +4,37 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ValueType, parseHandles, serializeHandles, } from "@fluidframework/shared-object-base/internal";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param localValue - The value to serialize.
|
|
10
|
-
* @param serializer - Data store runtime's serializer.
|
|
11
|
-
* @param bind - Container type's handle.
|
|
12
|
-
*
|
|
13
|
-
* @see {@link ILocalValue.makeSerialized}
|
|
7
|
+
* Convert a value to its serialized form, i.e. to be used in ops and summaries.
|
|
14
8
|
*/
|
|
15
|
-
export
|
|
16
|
-
const
|
|
9
|
+
export const serializeValue = (value, serializer, bind) => {
|
|
10
|
+
const serializedValue = serializeHandles(value, serializer, bind);
|
|
17
11
|
return {
|
|
18
|
-
type:
|
|
19
|
-
|
|
20
|
-
value: value.value && JSON.parse(value.value),
|
|
12
|
+
type: ValueType[ValueType.Plain],
|
|
13
|
+
value: serializedValue,
|
|
21
14
|
};
|
|
22
|
-
}
|
|
15
|
+
};
|
|
23
16
|
/**
|
|
24
|
-
*
|
|
17
|
+
* Very old versions of Fluid permitted a different type of stored value, which represented a
|
|
18
|
+
* SharedObject held directly. This functionality has since been replaced with handles.
|
|
19
|
+
*
|
|
20
|
+
* If the passed serializable is one of these old values, this function will mutate it to a modern
|
|
21
|
+
* value with a handle. Otherwise it does nothing.
|
|
22
|
+
* @param serializable - The serializable value to potentially convert.
|
|
25
23
|
*/
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* {@inheritDoc ILocalValue."type"}
|
|
36
|
-
*/
|
|
37
|
-
get type() {
|
|
38
|
-
return ValueType[ValueType.Plain];
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* {@inheritDoc ILocalValue.makeSerialized}
|
|
42
|
-
*/
|
|
43
|
-
makeSerialized(serializer, bind) {
|
|
44
|
-
// Stringify to convert to the serialized handle values - and then parse in order to create
|
|
45
|
-
// a POJO for the op
|
|
46
|
-
const value = serializeHandles(this.value, serializer, bind);
|
|
47
|
-
return {
|
|
48
|
-
type: this.type,
|
|
49
|
-
value,
|
|
24
|
+
export const migrateIfSharedSerializable = (
|
|
25
|
+
// eslint-disable-next-line import/no-deprecated
|
|
26
|
+
serializable, serializer, bind) => {
|
|
27
|
+
// Migrate from old shared value to handles
|
|
28
|
+
if (serializable.type === ValueType[ValueType.Shared]) {
|
|
29
|
+
serializable.type = ValueType[ValueType.Plain];
|
|
30
|
+
const handle = {
|
|
31
|
+
type: "__fluid_handle__",
|
|
32
|
+
url: serializable.value,
|
|
50
33
|
};
|
|
34
|
+
// NOTE: here we require the use of `parseHandles` because the roundtrip
|
|
35
|
+
// through a string is necessary to resolve the absolute path of
|
|
36
|
+
// legacy handles (`ValueType.Shared`)
|
|
37
|
+
serializable.value = serializer.encode(parseHandles(handle, serializer), bind);
|
|
51
38
|
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Enables a container type {@link https://fluidframework.com/docs/build/dds/ | DDS} to produce and store local
|
|
55
|
-
* values with minimal awareness of how those objects are stored, serialized, and deserialized.
|
|
56
|
-
*/
|
|
57
|
-
export class LocalValueMaker {
|
|
58
|
-
/**
|
|
59
|
-
* Create a new LocalValueMaker.
|
|
60
|
-
*/
|
|
61
|
-
constructor() { }
|
|
62
|
-
/**
|
|
63
|
-
* Create a new local value from an incoming serialized value.
|
|
64
|
-
* @param serializable - The serializable value to make local
|
|
65
|
-
*/
|
|
66
|
-
fromSerializable(
|
|
67
|
-
// eslint-disable-next-line import/no-deprecated
|
|
68
|
-
serializable, serializer, bind) {
|
|
69
|
-
// Migrate from old shared value to handles
|
|
70
|
-
if (serializable.type === ValueType[ValueType.Shared]) {
|
|
71
|
-
serializable.type = ValueType[ValueType.Plain];
|
|
72
|
-
const handle = {
|
|
73
|
-
type: "__fluid_handle__",
|
|
74
|
-
url: serializable.value,
|
|
75
|
-
};
|
|
76
|
-
// NOTE: here we require the use of `parseHandles` because the roundtrip
|
|
77
|
-
// through a string is necessary to resolve the absolute path of
|
|
78
|
-
// legacy handles (`ValueType.Shared`)
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
80
|
-
serializable.value = serializer.encode(parseHandles(handle, serializer), bind);
|
|
81
|
-
}
|
|
82
|
-
return new PlainLocalValue(serializable.value);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Create a new local value containing a given plain object.
|
|
86
|
-
* @param value - The value to store
|
|
87
|
-
* @returns An ILocalValue containing the value
|
|
88
|
-
*/
|
|
89
|
-
fromInMemory(value) {
|
|
90
|
-
return new PlainLocalValue(value);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
39
|
+
};
|
|
93
40
|
//# sourceMappingURL=localValues.js.map
|
package/lib/localValues.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localValues.js","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,SAAS,EACT,YAAY,EACZ,gBAAgB,GAChB,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"localValues.js","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,SAAS,EACT,YAAY,EACZ,gBAAgB,GAChB,MAAM,6CAA6C,CAAC;AAerD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,KAAc,EACd,UAA4B,EAC5B,IAAkB,EACC,EAAE;IACrB,MAAM,eAAe,GAAG,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAElE,OAAO;QACN,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC;QAChC,KAAK,EAAE,eAAe;KACtB,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;AAC1C,gDAAgD;AAChD,YAAgC,EAChC,UAA4B,EAC5B,IAAkB,EACX,EAAE;IACT,2CAA2C;IAC3C,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,YAAY,CAAC,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAsB;YACjC,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,YAAY,CAAC,KAAe;SACjC,CAAC;QACF,wEAAwE;QACxE,gEAAgE;QAChE,sCAAsC;QACtC,YAAY,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;AACF,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { ISerializedHandle } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tValueType,\n\tparseHandles,\n\tserializeHandles,\n} from \"@fluidframework/shared-object-base/internal\";\n\n// eslint-disable-next-line import/no-deprecated\nimport type { ISerializableValue, ISerializedValue } from \"./internalInterfaces.js\";\n\n/**\n * A local value to be stored in a container type Distributed Data Store (DDS).\n */\nexport interface ILocalValue {\n\t/**\n\t * The in-memory value stored within.\n\t */\n\treadonly value: unknown;\n}\n\n/**\n * Convert a value to its serialized form, i.e. to be used in ops and summaries.\n */\nexport const serializeValue = (\n\tvalue: unknown,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): ISerializedValue => {\n\tconst serializedValue = serializeHandles(value, serializer, bind);\n\n\treturn {\n\t\ttype: ValueType[ValueType.Plain],\n\t\tvalue: serializedValue,\n\t};\n};\n\n/**\n * Very old versions of Fluid permitted a different type of stored value, which represented a\n * SharedObject held directly. This functionality has since been replaced with handles.\n *\n * If the passed serializable is one of these old values, this function will mutate it to a modern\n * value with a handle. Otherwise it does nothing.\n * @param serializable - The serializable value to potentially convert.\n */\nexport const migrateIfSharedSerializable = (\n\t// eslint-disable-next-line import/no-deprecated\n\tserializable: ISerializableValue,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): void => {\n\t// Migrate from old shared value to handles\n\tif (serializable.type === ValueType[ValueType.Shared]) {\n\t\tserializable.type = ValueType[ValueType.Plain];\n\t\tconst handle: ISerializedHandle = {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: serializable.value as string,\n\t\t};\n\t\t// NOTE: here we require the use of `parseHandles` because the roundtrip\n\t\t// through a string is necessary to resolve the absolute path of\n\t\t// legacy handles (`ValueType.Shared`)\n\t\tserializable.value = serializer.encode(parseH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AgB,CAAC,EAAE,iBAAiB,GAClC,qBAAqB;IAqExB;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBxE;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;OAEG;cACgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAIjF;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIhD;;OAEG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAcP;;OAEG;cACgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAG7E"}
|
package/lib/map.js
CHANGED
|
@@ -188,10 +188,10 @@ export class SharedMap extends SharedObject {
|
|
|
188
188
|
const newFormat = json;
|
|
189
189
|
if (Array.isArray(newFormat.blobs)) {
|
|
190
190
|
this.kernel.populateFromSerializable(newFormat.content);
|
|
191
|
-
await Promise.all(newFormat.blobs.map(async (
|
|
192
|
-
|
|
193
|
-
this.kernel.populateFromSerializable(
|
|
194
|
-
}
|
|
191
|
+
const blobContents = await Promise.all(newFormat.blobs.map(async (blobName) => readAndParse(storage, blobName)));
|
|
192
|
+
for (const blobContent of blobContents) {
|
|
193
|
+
this.kernel.populateFromSerializable(blobContent);
|
|
194
|
+
}
|
|
195
195
|
}
|
|
196
196
|
else {
|
|
197
197
|
this.kernel.populateFromSerializable(json);
|
package/lib/map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EACN,WAAW,GAEX,M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C,CAAC,CAAC,CACF,CAAC;QACH,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAkC,CAAC,CAAC;QAC1E,CAAC;IACF,CAAC;IAED;;OAEG;IACO,YAAY,KAAU,CAAC;IAEjC;;OAEG;IACgB,YAAY,CAAC,OAAgB,EAAE,eAAwB;QACzE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAwB,EAAE,eAAe,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,OAAgB;QACxC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAwB,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACO,WAAW,CACpB,OAAkC,EAClC,KAAc,EACd,eAAwB;QAExB,wEAAwE;QACxE,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,EAAE,CAAC;YAC5C,MAAM,CACL,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAC5B,OAAO,CAAC,QAAyB,EACjC,KAAK,EACL,eAAe,CACf,EACD,KAAK,CAAC,oEAAoE,CAC1E,CAAC;QACH,CAAC;IACF,CAAC;IAED;;OAEG;IACgB,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QACrE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tMessageType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedMap, ISharedMapEvents } from \"./interfaces.js\";\nimport {\n\ttype IMapDataObjectSerializable,\n\ttype IMapOperation,\n\tMapKernel,\n} from \"./mapKernel.js\";\n\ninterface IMapSerializationFormat {\n\tblobs?: string[];\n\tcontent: IMapDataObjectSerializable;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedMap}\n */\nexport class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {\n\t/**\n\t * String representation for the class.\n\t */\n\tpublic readonly [Symbol.toStringTag]: string = \"SharedMap\";\n\n\t/**\n\t * MapKernel which manages actual map operations.\n\t */\n\tprivate readonly kernel: MapKernel;\n\n\t/**\n\t * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.\n\t *\n\t * @param id - String identifier.\n\t * @param runtime - Data store runtime.\n\t * @param attributes - The attributes for the map.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_map_\");\n\t\tthis.kernel = new MapKernel(\n\t\t\tthis.serializer,\n\t\t\tthis.handle,\n\t\t\t(op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n\t\t\t() => this.isAttached(),\n\t\t\tthis,\n\t\t);\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.kernel.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic entries(): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic values(): IterableIterator<any> {\n\t\treturn this.kernel.values();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic [Symbol.iterator](): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.kernel.size;\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n\t\t// eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference\n\t\tthis.kernel.forEach(callbackFn);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get<T = any>(key: string): T | undefined {\n\t\treturn this.kernel.get<T>(key);\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.kernel.has(key);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.set}\n\t */\n\tpublic set(key: string, value: unknown): this {\n\t\tthis.kernel.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Delete a key from the map.\n\t * @param key - Key to delete\n\t * @returns True if the key existed and was deleted, false if it did not exist\n\t */\n\tpublic delete(key: string): boolean {\n\t\treturn this.kernel.delete(key);\n\t}\n\n\t/**\n\t * Clear all data from the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.kernel.clear();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tlet currentSize = 0;\n\t\tlet counter = 0;\n\t\tlet headerBlob: IMapDataObjectSerializable = {};\n\t\tconst blobs: string[] = [];\n\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\tconst data = this.kernel.getSerializedStorage(serializer);\n\n\t\t// If single property exceeds this size, it goes into its own blob\n\t\tconst MinValueSizeSeparateSnapshotBlob = 8 * 1024;\n\n\t\t// Maximum blob size for multiple map properties\n\t\t// Should be bigger than MinValueSizeSeparateSnapshotBlob\n\t\tconst MaxSnapshotBlobSize = 16 * 1024;\n\n\t\t// Partitioning algorithm:\n\t\t// 1) Split large (over MinValueSizeSeparateSnapshotBlob = 8K) properties into their own blobs.\n\t\t// Naming (across snapshots) of such blob does not have to be stable across snapshots,\n\t\t// As de-duping process (in driver) should not care about paths, only content.\n\t\t// 2) Split remaining properties into blobs of MaxSnapshotBlobSize (16K) size.\n\t\t// This process does not produce stable partitioning. This means\n\t\t// modification (including addition / deletion) of property can shift properties across blobs\n\t\t// and result in non-incremental snapshot.\n\t\t// This can be improved in the future, without being format breaking change, as loading sequence\n\t\t// loads all blobs at once and partitioning schema has no impact on that process.\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {\n\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\tcounter++;\n\t\t\t\tblobs.push(blobName);\n\t\t\t\tconst content: IMapDataObjectSerializable = {\n\t\t\t\t\t[key]: {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tvalue: JSON.parse(value.value) as unknown,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(content));\n\t\t\t} else {\n\t\t\t\tcurrentSize += value.type.length + 21; // Approximation cost of property header\n\t\t\t\tif (value.value) {\n\t\t\t\t\tcurrentSize += value.value.length;\n\t\t\t\t}\n\n\t\t\t\tif (currentSize > MaxSnapshotBlobSize) {\n\t\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\t\tcounter++;\n\t\t\t\t\tblobs.push(blobName);\n\t\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(headerBlob));\n\t\t\t\t\theaderBlob = {};\n\t\t\t\t\tcurrentSize = 0;\n\t\t\t\t}\n\t\t\t\theaderBlob[key] = {\n\t\t\t\t\ttype: value.type,\n\t\t\t\t\tvalue: value.value === undefined ? undefined : (JSON.parse(value.value) as unknown),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst header: IMapSerializationFormat = {\n\t\t\tblobs,\n\t\t\tcontent: headerBlob,\n\t\t};\n\t\tbuilder.addBlob(snapshotFileName, JSON.stringify(header));\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst json = await readAndParse<object>(storage, snapshotFileName);\n\t\tconst newFormat = json as IMapSerializationFormat;\n\t\tif (Array.isArray(newFormat.blobs)) {\n\t\t\tthis.kernel.populateFromSerializable(newFormat.content);\n\t\t\tawait Promise.all(\n\t\t\t\tnewFormat.blobs.map(async (value) => {\n\t\t\t\t\tconst content = await readAndParse<IMapDataObjectSerializable>(storage, value);\n\t\t\t\t\tthis.kernel.populateFromSerializable(content);\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\tthis.kernel.populateFromSerializable(json as IMapDataObjectSerializable);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n\t */\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.trySubmitMessage(content as IMapOperation, localOpMetadata);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(content: unknown): void {\n\t\tthis.kernel.tryApplyStashedOp(content as IMapOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tassert(\n\t\t\t\tthis.kernel.tryProcessMessage(\n\t\t\t\t\tmessage.contents as IMapOperation,\n\t\t\t\t\tlocal,\n\t\t\t\t\tlocalOpMetadata,\n\t\t\t\t),\n\t\t\t\t0xab2 /* Map received an unrecognized op, possibly from a newer version */,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t */\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.rollback(content, localOpMetadata);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EACN,WAAW,GAEX,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAKrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAG3E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IACO,YAAY,KAAU,CAAC;IAEjC;;OAEG;IACgB,YAAY,CAAC,OAAgB,EAAE,eAAwB;QACzE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAwB,EAAE,eAAe,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,OAAgB;QACxC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAwB,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACO,WAAW,CACpB,OAAkC,EAClC,KAAc,EACd,eAAwB;QAExB,wEAAwE;QACxE,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,EAAE,CAAC;YAC5C,MAAM,CACL,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAC5B,OAAO,CAAC,QAAyB,EACjC,KAAK,EACL,eAAe,CACf,EACD,KAAK,CAAC,oEAAoE,CAC1E,CAAC;QACH,CAAC;IACF,CAAC;IAED;;OAEG;IACgB,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QACrE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tMessageType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedMap, ISharedMapEvents } from \"./interfaces.js\";\nimport {\n\ttype IMapDataObjectSerializable,\n\ttype IMapOperation,\n\tMapKernel,\n} from \"./mapKernel.js\";\n\ninterface IMapSerializationFormat {\n\tblobs?: string[];\n\tcontent: IMapDataObjectSerializable;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedMap}\n */\nexport class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {\n\t/**\n\t * String representation for the class.\n\t */\n\tpublic readonly [Symbol.toStringTag]: string = \"SharedMap\";\n\n\t/**\n\t * MapKernel which manages actual map operations.\n\t */\n\tprivate readonly kernel: MapKernel;\n\n\t/**\n\t * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.\n\t *\n\t * @param id - String identifier.\n\t * @param runtime - Data store runtime.\n\t * @param attributes - The attributes for the map.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_map_\");\n\t\tthis.kernel = new MapKernel(\n\t\t\tthis.serializer,\n\t\t\tthis.handle,\n\t\t\t(op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n\t\t\t() => this.isAttached(),\n\t\t\tthis,\n\t\t);\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.kernel.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic entries(): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic values(): IterableIterator<any> {\n\t\treturn this.kernel.values();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic [Symbol.iterator](): IterableIterator<[string, any]> {\n\t\treturn this.kernel.entries();\n\t}\n\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.kernel.size;\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n\t\t// eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference\n\t\tthis.kernel.forEach(callbackFn);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\t// TODO: Use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get<T = any>(key: string): T | undefined {\n\t\treturn this.kernel.get<T>(key);\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.kernel.has(key);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.set}\n\t */\n\tpublic set(key: string, value: unknown): this {\n\t\tthis.kernel.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Delete a key from the map.\n\t * @param key - Key to delete\n\t * @returns True if the key existed and was deleted, false if it did not exist\n\t */\n\tpublic delete(key: string): boolean {\n\t\treturn this.kernel.delete(key);\n\t}\n\n\t/**\n\t * Clear all data from the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.kernel.clear();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tlet currentSize = 0;\n\t\tlet counter = 0;\n\t\tlet headerBlob: IMapDataObjectSerializable = {};\n\t\tconst blobs: string[] = [];\n\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\tconst data = this.kernel.getSerializedStorage(serializer);\n\n\t\t// If single property exceeds this size, it goes into its own blob\n\t\tconst MinValueSizeSeparateSnapshotBlob = 8 * 1024;\n\n\t\t// Maximum blob size for multiple map properties\n\t\t// Should be bigger than MinValueSizeSeparateSnapshotBlob\n\t\tconst MaxSnapshotBlobSize = 16 * 1024;\n\n\t\t// Partitioning algorithm:\n\t\t// 1) Split large (over MinValueSizeSeparateSnapshotBlob = 8K) properties into their own blobs.\n\t\t// Naming (across snapshots) of such blob does not have to be stable across snapshots,\n\t\t// As de-duping process (in driver) should not care about paths, only content.\n\t\t// 2) Split remaining properties into blobs of MaxSnapshotBlobSize (16K) size.\n\t\t// This process does not produce stable partitioning. This means\n\t\t// modification (including addition / deletion) of property can shift properties across blobs\n\t\t// and result in non-incremental snapshot.\n\t\t// This can be improved in the future, without being format breaking change, as loading sequence\n\t\t// loads all blobs at once and partitioning schema has no impact on that process.\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {\n\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\tcounter++;\n\t\t\t\tblobs.push(blobName);\n\t\t\t\tconst content: IMapDataObjectSerializable = {\n\t\t\t\t\t[key]: {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tvalue: JSON.parse(value.value) as unknown,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(content));\n\t\t\t} else {\n\t\t\t\tcurrentSize += value.type.length + 21; // Approximation cost of property header\n\t\t\t\tif (value.value) {\n\t\t\t\t\tcurrentSize += value.value.length;\n\t\t\t\t}\n\n\t\t\t\tif (currentSize > MaxSnapshotBlobSize) {\n\t\t\t\t\tconst blobName = `blob${counter}`;\n\t\t\t\t\tcounter++;\n\t\t\t\t\tblobs.push(blobName);\n\t\t\t\t\tbuilder.addBlob(blobName, JSON.stringify(headerBlob));\n\t\t\t\t\theaderBlob = {};\n\t\t\t\t\tcurrentSize = 0;\n\t\t\t\t}\n\t\t\t\theaderBlob[key] = {\n\t\t\t\t\ttype: value.type,\n\t\t\t\t\tvalue: value.value === undefined ? undefined : (JSON.parse(value.value) as unknown),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst header: IMapSerializationFormat = {\n\t\t\tblobs,\n\t\t\tcontent: headerBlob,\n\t\t};\n\t\tbuilder.addBlob(snapshotFileName, JSON.stringify(header));\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst json = await readAndParse<object>(storage, snapshotFileName);\n\t\tconst newFormat = json as IMapSerializationFormat;\n\t\tif (Array.isArray(newFormat.blobs)) {\n\t\t\tthis.kernel.populateFromSerializable(newFormat.content);\n\t\t\tconst blobContents = await Promise.all(\n\t\t\t\tnewFormat.blobs.map(async (blobName) =>\n\t\t\t\t\treadAndParse<IMapDataObjectSerializable>(storage, blobName),\n\t\t\t\t),\n\t\t\t);\n\t\t\tfor (const blobContent of blobContents) {\n\t\t\t\tthis.kernel.populateFromSerializable(blobContent);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.kernel.populateFromSerializable(json as IMapDataObjectSerializable);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n\t */\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.trySubmitMessage(content as IMapOperation, localOpMetadata);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(content: unknown): void {\n\t\tthis.kernel.tryApplyStashedOp(content as IMapOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tassert(\n\t\t\t\tthis.kernel.tryProcessMessage(\n\t\t\t\t\tmessage.contents as IMapOperation,\n\t\t\t\t\tlocal,\n\t\t\t\t\tlocalOpMetadata,\n\t\t\t\t),\n\t\t\t\t0xab2 /* Map received an unrecognized op, possibly from a newer version */,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t */\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.kernel.rollback(content, localOpMetadata);\n\t}\n}\n"]}
|
package/lib/mapKernel.d.ts
CHANGED
|
@@ -56,15 +56,11 @@ export declare class MapKernel {
|
|
|
56
56
|
/**
|
|
57
57
|
* This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.
|
|
58
58
|
*/
|
|
59
|
-
private
|
|
59
|
+
private nextPendingMessageId;
|
|
60
60
|
/**
|
|
61
61
|
* The pending ids of any clears that have been performed locally but not yet ack'd from the server
|
|
62
62
|
*/
|
|
63
63
|
private readonly pendingClearMessageIds;
|
|
64
|
-
/**
|
|
65
|
-
* Object to create encapsulations of the values stored in the map.
|
|
66
|
-
*/
|
|
67
|
-
private readonly localValueMaker;
|
|
68
64
|
/**
|
|
69
65
|
* Create a new shared map kernel.
|
|
70
66
|
* @param serializer - The serializer to serialize / parse handles
|
|
@@ -84,17 +80,17 @@ export declare class MapKernel {
|
|
|
84
80
|
* Get an iterator over the entries in this map.
|
|
85
81
|
* @returns The iterator
|
|
86
82
|
*/
|
|
87
|
-
entries(): IterableIterator<[string,
|
|
83
|
+
entries(): IterableIterator<[string, unknown]>;
|
|
88
84
|
/**
|
|
89
85
|
* Get an iterator over the values in this map.
|
|
90
86
|
* @returns The iterator
|
|
91
87
|
*/
|
|
92
|
-
values(): IterableIterator<
|
|
88
|
+
values(): IterableIterator<unknown>;
|
|
93
89
|
/**
|
|
94
90
|
* Get an iterator over the entries in this map.
|
|
95
91
|
* @returns The iterator
|
|
96
92
|
*/
|
|
97
|
-
[Symbol.iterator](): IterableIterator<[string,
|
|
93
|
+
[Symbol.iterator](): IterableIterator<[string, unknown]>;
|
|
98
94
|
/**
|
|
99
95
|
* Executes the given callback on each entry in the map.
|
|
100
96
|
* @param callbackFn - Callback function
|
|
@@ -103,7 +99,7 @@ export declare class MapKernel {
|
|
|
103
99
|
/**
|
|
104
100
|
* {@inheritDoc ISharedMap.get}
|
|
105
101
|
*/
|
|
106
|
-
get<T =
|
|
102
|
+
get<T = unknown>(key: string): T | undefined;
|
|
107
103
|
/**
|
|
108
104
|
* Check if a key exists in the map.
|
|
109
105
|
* @param key - The key to check
|
|
@@ -130,8 +126,6 @@ export declare class MapKernel {
|
|
|
130
126
|
* @returns A JSON string containing serialized map data
|
|
131
127
|
*/
|
|
132
128
|
getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized;
|
|
133
|
-
getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable;
|
|
134
|
-
serialize(serializer: IFluidSerializer): string;
|
|
135
129
|
/**
|
|
136
130
|
* Populate the kernel with the given map data.
|
|
137
131
|
* @param data - A JSON string containing serialized map data
|
|
@@ -193,17 +187,6 @@ export declare class MapKernel {
|
|
|
193
187
|
* Clear all keys in memory in response to a remote clear, but retain keys we have modified but not yet been ack'd.
|
|
194
188
|
*/
|
|
195
189
|
private clearExceptPendingKeys;
|
|
196
|
-
/**
|
|
197
|
-
* The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will
|
|
198
|
-
* have the information we need to create a real object, but will not be the real object yet. For example,
|
|
199
|
-
* we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's
|
|
200
|
-
* job is to convert that information into a real object for local usage.
|
|
201
|
-
* @param key - The key that the caller intends to store the local value into (used for ops later). But
|
|
202
|
-
* doesn't actually store the local value into that key. So better not lie!
|
|
203
|
-
* @param serializable - The remote information that we can convert into a real object
|
|
204
|
-
* @returns The local value that was produced
|
|
205
|
-
*/
|
|
206
|
-
private makeLocal;
|
|
207
190
|
/**
|
|
208
191
|
* If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should
|
|
209
192
|
* not process the incoming operation.
|
package/lib/mapKernel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapKernel.d.ts","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAGpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAEX,kBAAkB,EAClB,mBAAmB,EAGnB,gBAAgB,EAEhB,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"mapKernel.d.ts","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAA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AAG,IAAI;IAqBjD;;;;;;;;;;;;;;OAcG;IACI,iBAAiB,CACvB,EAAE,EAAE,aAAa,EACjB,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,OAAO;IAWV;;;;OAIG;IAEI,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IA+CxD;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAQf;;;OAGG;IACH,OAAO,CAAC,SAAS;IAKjB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAUlB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAiB9B;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;IA2C/B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAiE1B,OAAO,CAAC,oBAAoB;IAM5B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,kBAAkB;IAW1B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;CAiC7B"}
|
package/lib/mapKernel.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
6
6
|
import { ValueType } from "@fluidframework/shared-object-base/internal";
|
|
7
|
-
import {
|
|
7
|
+
import { serializeValue, migrateIfSharedSerializable, } from "./localValues.js";
|
|
8
8
|
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
|
|
9
9
|
function isMapKeyLocalOpMetadata(metadata) {
|
|
10
10
|
return (metadata !== undefined &&
|
|
@@ -76,12 +76,11 @@ export class MapKernel {
|
|
|
76
76
|
/**
|
|
77
77
|
* This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.
|
|
78
78
|
*/
|
|
79
|
-
this.
|
|
79
|
+
this.nextPendingMessageId = 0;
|
|
80
80
|
/**
|
|
81
81
|
* The pending ids of any clears that have been performed locally but not yet ack'd from the server
|
|
82
82
|
*/
|
|
83
83
|
this.pendingClearMessageIds = [];
|
|
84
|
-
this.localValueMaker = new LocalValueMaker();
|
|
85
84
|
this.messageHandlers = this.getMessageHandlers();
|
|
86
85
|
}
|
|
87
86
|
/**
|
|
@@ -95,8 +94,6 @@ export class MapKernel {
|
|
|
95
94
|
* Get an iterator over the entries in this map.
|
|
96
95
|
* @returns The iterator
|
|
97
96
|
*/
|
|
98
|
-
// TODO: Use `unknown` instead (breaking change).
|
|
99
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
97
|
entries() {
|
|
101
98
|
const localEntriesIterator = this.data.entries();
|
|
102
99
|
const iterator = {
|
|
@@ -117,8 +114,6 @@ export class MapKernel {
|
|
|
117
114
|
* Get an iterator over the values in this map.
|
|
118
115
|
* @returns The iterator
|
|
119
116
|
*/
|
|
120
|
-
// TODO: Use `unknown` instead (breaking change).
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
117
|
values() {
|
|
123
118
|
const localValuesIterator = this.data.values();
|
|
124
119
|
const iterator = {
|
|
@@ -139,8 +134,6 @@ export class MapKernel {
|
|
|
139
134
|
* Get an iterator over the entries in this map.
|
|
140
135
|
* @returns The iterator
|
|
141
136
|
*/
|
|
142
|
-
// TODO: Use `unknown` instead (breaking change).
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
137
|
[Symbol.iterator]() {
|
|
145
138
|
return this.entries();
|
|
146
139
|
}
|
|
@@ -157,8 +150,6 @@ export class MapKernel {
|
|
|
157
150
|
/**
|
|
158
151
|
* {@inheritDoc ISharedMap.get}
|
|
159
152
|
*/
|
|
160
|
-
// TODO: Use `unknown` instead (breaking change).
|
|
161
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
153
|
get(key) {
|
|
163
154
|
const localValue = this.data.get(key);
|
|
164
155
|
return localValue === undefined ? undefined : localValue.value;
|
|
@@ -179,10 +170,8 @@ export class MapKernel {
|
|
|
179
170
|
if (key === undefined || key === null) {
|
|
180
171
|
throw new Error("Undefined and null keys are not supported");
|
|
181
172
|
}
|
|
182
|
-
// Create a local value and serialize it.
|
|
183
|
-
const localValue = this.localValueMaker.fromInMemory(value);
|
|
184
173
|
// Set the value locally.
|
|
185
|
-
const previousValue = this.setCore(key,
|
|
174
|
+
const previousValue = this.setCore(key, { value }, true);
|
|
186
175
|
// If we are not attached, don't submit the op.
|
|
187
176
|
if (!this.isAttached()) {
|
|
188
177
|
return;
|
|
@@ -190,7 +179,7 @@ export class MapKernel {
|
|
|
190
179
|
const op = {
|
|
191
180
|
key,
|
|
192
181
|
type: "set",
|
|
193
|
-
value: { type:
|
|
182
|
+
value: { type: ValueType[ValueType.Plain], value },
|
|
194
183
|
};
|
|
195
184
|
this.submitMapKeyMessage(op, previousValue);
|
|
196
185
|
}
|
|
@@ -237,21 +226,11 @@ export class MapKernel {
|
|
|
237
226
|
* @returns A JSON string containing serialized map data
|
|
238
227
|
*/
|
|
239
228
|
getSerializedStorage(serializer) {
|
|
240
|
-
const
|
|
229
|
+
const serializedMapData = {};
|
|
241
230
|
for (const [key, localValue] of this.data.entries()) {
|
|
242
|
-
|
|
231
|
+
serializedMapData[key] = serializeValue(localValue.value, serializer, this.handle);
|
|
243
232
|
}
|
|
244
|
-
return
|
|
245
|
-
}
|
|
246
|
-
getSerializableStorage(serializer) {
|
|
247
|
-
const serializableMapData = {};
|
|
248
|
-
for (const [key, localValue] of this.data.entries()) {
|
|
249
|
-
serializableMapData[key] = makeSerializable(localValue, serializer, this.handle);
|
|
250
|
-
}
|
|
251
|
-
return serializableMapData;
|
|
252
|
-
}
|
|
253
|
-
serialize(serializer) {
|
|
254
|
-
return JSON.stringify(this.getSerializableStorage(serializer));
|
|
233
|
+
return serializedMapData;
|
|
255
234
|
}
|
|
256
235
|
/**
|
|
257
236
|
* Populate the kernel with the given map data.
|
|
@@ -259,11 +238,8 @@ export class MapKernel {
|
|
|
259
238
|
*/
|
|
260
239
|
populateFromSerializable(json) {
|
|
261
240
|
for (const [key, serializable] of Object.entries(this.serializer.decode(json))) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
value: this.makeLocal(key, serializable),
|
|
265
|
-
};
|
|
266
|
-
this.data.set(localValue.key, localValue.value);
|
|
241
|
+
migrateIfSharedSerializable(serializable, this.serializer, this.handle);
|
|
242
|
+
this.data.set(key, { value: serializable.value });
|
|
267
243
|
}
|
|
268
244
|
}
|
|
269
245
|
/**
|
|
@@ -293,7 +269,8 @@ export class MapKernel {
|
|
|
293
269
|
break;
|
|
294
270
|
}
|
|
295
271
|
case "set": {
|
|
296
|
-
|
|
272
|
+
migrateIfSharedSerializable(op.value, this.serializer, this.handle);
|
|
273
|
+
this.set(op.key, op.value.value);
|
|
297
274
|
break;
|
|
298
275
|
}
|
|
299
276
|
default: {
|
|
@@ -429,26 +406,6 @@ export class MapKernel {
|
|
|
429
406
|
this.setCore(key, value, true);
|
|
430
407
|
}
|
|
431
408
|
}
|
|
432
|
-
/**
|
|
433
|
-
* The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will
|
|
434
|
-
* have the information we need to create a real object, but will not be the real object yet. For example,
|
|
435
|
-
* we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's
|
|
436
|
-
* job is to convert that information into a real object for local usage.
|
|
437
|
-
* @param key - The key that the caller intends to store the local value into (used for ops later). But
|
|
438
|
-
* doesn't actually store the local value into that key. So better not lie!
|
|
439
|
-
* @param serializable - The remote information that we can convert into a real object
|
|
440
|
-
* @returns The local value that was produced
|
|
441
|
-
*/
|
|
442
|
-
// eslint-disable-next-line import/no-deprecated
|
|
443
|
-
makeLocal(key, serializable) {
|
|
444
|
-
if (serializable.type === ValueType[ValueType.Plain] ||
|
|
445
|
-
serializable.type === ValueType[ValueType.Shared]) {
|
|
446
|
-
return this.localValueMaker.fromSerializable(serializable, this.serializer, this.handle);
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
throw new Error("Unknown local value type");
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
409
|
/**
|
|
453
410
|
* If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should
|
|
454
411
|
* not process the incoming operation.
|
|
@@ -530,8 +487,8 @@ export class MapKernel {
|
|
|
530
487
|
return;
|
|
531
488
|
}
|
|
532
489
|
// needProcessKeyOperation should have returned false if local is true
|
|
533
|
-
|
|
534
|
-
this.setCore(op.key,
|
|
490
|
+
migrateIfSharedSerializable(op.value, this.serializer, this.handle);
|
|
491
|
+
this.setCore(op.key, { value: op.value.value }, local);
|
|
535
492
|
},
|
|
536
493
|
submit: (op, localOpMetadata) => {
|
|
537
494
|
this.resubmitMapKeyMessage(op, localOpMetadata);
|
|
@@ -540,7 +497,7 @@ export class MapKernel {
|
|
|
540
497
|
return messageHandlers;
|
|
541
498
|
}
|
|
542
499
|
getMapClearMessageId() {
|
|
543
|
-
const pendingMessageId =
|
|
500
|
+
const pendingMessageId = this.nextPendingMessageId++;
|
|
544
501
|
this.pendingClearMessageIds.push(pendingMessageId);
|
|
545
502
|
return pendingMessageId;
|
|
546
503
|
}
|
|
@@ -553,7 +510,7 @@ export class MapKernel {
|
|
|
553
510
|
this.submitMessage(op, metadata);
|
|
554
511
|
}
|
|
555
512
|
getMapKeyMessageId(op) {
|
|
556
|
-
const pendingMessageId =
|
|
513
|
+
const pendingMessageId = this.nextPendingMessageId++;
|
|
557
514
|
const pendingMessageIds = this.pendingKeys.get(op.key);
|
|
558
515
|
if (pendingMessageIds === undefined) {
|
|
559
516
|
this.pendingKeys.set(op.key, [pendingMessageId]);
|