@fluidframework/map 2.0.0-internal.2.2.0 → 2.0.0-internal.2.3.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 +4 -1
- package/dist/directory.d.ts +5 -4
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +26 -11
- package/dist/directory.js.map +1 -1
- package/dist/interfaces.d.ts +3 -4
- 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 +4 -4
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +11 -0
- 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 +25 -11
- 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 +5 -4
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +26 -11
- package/lib/directory.js.map +1 -1
- package/lib/interfaces.d.ts +3 -4
- 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 +4 -4
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +11 -0
- 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 +25 -11
- 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 +17 -16
- package/src/directory.ts +85 -54
- package/src/interfaces.ts +19 -9
- package/src/internalInterfaces.ts +45 -0
- package/src/localValues.ts +18 -7
- package/src/map.ts +28 -17
- package/src/mapKernel.ts +50 -32
- package/src/packageVersion.ts +1 -1
package/dist/mapKernel.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.MapKernel = void 0;
|
|
|
8
8
|
const shared_object_base_1 = require("@fluidframework/shared-object-base");
|
|
9
9
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
10
10
|
const localValues_1 = require("./localValues");
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
|
|
11
12
|
function isMapKeyLocalOpMetadata(metadata) {
|
|
12
13
|
return metadata !== undefined && typeof metadata.pendingMessageId === "number" &&
|
|
13
14
|
(metadata.type === "add" || metadata.type === "edit");
|
|
@@ -19,6 +20,7 @@ function isMapLocalOpMetadata(metadata) {
|
|
|
19
20
|
return metadata !== undefined && typeof metadata.pendingMessageId === "number" &&
|
|
20
21
|
(metadata.type === "add" || metadata.type === "edit" || metadata.type === "clear");
|
|
21
22
|
}
|
|
23
|
+
/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
|
|
22
24
|
function createClearLocalOpMetadata(op, pendingClearMessageId, previousMap) {
|
|
23
25
|
const localMetadata = {
|
|
24
26
|
type: "clear",
|
|
@@ -91,6 +93,8 @@ class MapKernel {
|
|
|
91
93
|
* Get an iterator over the entries in this map.
|
|
92
94
|
* @returns The iterator
|
|
93
95
|
*/
|
|
96
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
98
|
entries() {
|
|
95
99
|
const localEntriesIterator = this.data.entries();
|
|
96
100
|
const iterator = {
|
|
@@ -111,6 +115,8 @@ class MapKernel {
|
|
|
111
115
|
* Get an iterator over the values in this map.
|
|
112
116
|
* @returns The iterator
|
|
113
117
|
*/
|
|
118
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
120
|
values() {
|
|
115
121
|
const localValuesIterator = this.data.values();
|
|
116
122
|
const iterator = {
|
|
@@ -131,6 +137,8 @@ class MapKernel {
|
|
|
131
137
|
* Get an iterator over the entries in this map.
|
|
132
138
|
* @returns The iterator
|
|
133
139
|
*/
|
|
140
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
142
|
[Symbol.iterator]() {
|
|
135
143
|
return this.entries();
|
|
136
144
|
}
|
|
@@ -139,6 +147,7 @@ class MapKernel {
|
|
|
139
147
|
* @param callbackFn - Callback function
|
|
140
148
|
*/
|
|
141
149
|
forEach(callbackFn) {
|
|
150
|
+
// eslint-disable-next-line unicorn/no-array-for-each
|
|
142
151
|
this.data.forEach((localValue, key, m) => {
|
|
143
152
|
callbackFn(localValue.value, key, m);
|
|
144
153
|
});
|
|
@@ -146,6 +155,8 @@ class MapKernel {
|
|
|
146
155
|
/**
|
|
147
156
|
* {@inheritDoc ISharedMap.get}
|
|
148
157
|
*/
|
|
158
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
160
|
get(key) {
|
|
150
161
|
const localValue = this.data.get(key);
|
|
151
162
|
return localValue === undefined ? undefined : localValue.value;
|
|
@@ -224,16 +235,16 @@ class MapKernel {
|
|
|
224
235
|
*/
|
|
225
236
|
getSerializedStorage(serializer) {
|
|
226
237
|
const serializableMapData = {};
|
|
227
|
-
this.data.
|
|
238
|
+
for (const [key, localValue] of this.data.entries()) {
|
|
228
239
|
serializableMapData[key] = localValue.makeSerialized(serializer, this.handle);
|
|
229
|
-
}
|
|
240
|
+
}
|
|
230
241
|
return serializableMapData;
|
|
231
242
|
}
|
|
232
243
|
getSerializableStorage(serializer) {
|
|
233
244
|
const serializableMapData = {};
|
|
234
|
-
this.data.
|
|
245
|
+
for (const [key, localValue] of this.data.entries()) {
|
|
235
246
|
serializableMapData[key] = (0, localValues_1.makeSerializable)(localValue, serializer, this.handle);
|
|
236
|
-
}
|
|
247
|
+
}
|
|
237
248
|
return serializableMapData;
|
|
238
249
|
}
|
|
239
250
|
serialize(serializer) {
|
|
@@ -294,11 +305,13 @@ class MapKernel {
|
|
|
294
305
|
handler.process(op, local, localOpMetadata);
|
|
295
306
|
return true;
|
|
296
307
|
}
|
|
308
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
297
309
|
/**
|
|
298
310
|
* Rollback a local op
|
|
299
311
|
* @param op - The operation to rollback
|
|
300
312
|
* @param localOpMetadata - The local metadata associated with the op.
|
|
301
313
|
*/
|
|
314
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
302
315
|
rollback(op, localOpMetadata) {
|
|
303
316
|
if (!isMapLocalOpMetadata(localOpMetadata)) {
|
|
304
317
|
throw new Error("Invalid localOpMetadata");
|
|
@@ -307,9 +320,9 @@ class MapKernel {
|
|
|
307
320
|
if (localOpMetadata.previousMap === undefined) {
|
|
308
321
|
throw new Error("Cannot rollback without previous map");
|
|
309
322
|
}
|
|
310
|
-
localOpMetadata.previousMap.
|
|
323
|
+
for (const [key, localValue] of localOpMetadata.previousMap.entries()) {
|
|
311
324
|
this.setCore(key, localValue, true);
|
|
312
|
-
}
|
|
325
|
+
}
|
|
313
326
|
const lastPendingClearId = this.pendingClearMessageIds.pop();
|
|
314
327
|
if (lastPendingClearId === undefined || lastPendingClearId !== localOpMetadata.pendingMessageId) {
|
|
315
328
|
throw new Error("Rollback op does match last clear");
|
|
@@ -338,6 +351,7 @@ class MapKernel {
|
|
|
338
351
|
throw new Error("Unsupported op for rollback");
|
|
339
352
|
}
|
|
340
353
|
}
|
|
354
|
+
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
|
|
341
355
|
/**
|
|
342
356
|
* Set implementation used for both locally sourced sets as well as incoming remote sets.
|
|
343
357
|
* @param key - The key being set
|
|
@@ -382,14 +396,14 @@ class MapKernel {
|
|
|
382
396
|
// Assuming the pendingKeys is small and the map is large
|
|
383
397
|
// we will get the value for the pendingKeys and clear the map
|
|
384
398
|
const temp = new Map();
|
|
385
|
-
this.pendingKeys.
|
|
399
|
+
for (const key of this.pendingKeys.keys()) {
|
|
386
400
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
387
401
|
temp.set(key, this.data.get(key));
|
|
388
|
-
}
|
|
402
|
+
}
|
|
389
403
|
this.clearCore(false);
|
|
390
|
-
temp.
|
|
404
|
+
for (const [key, value] of temp.entries()) {
|
|
391
405
|
this.setCore(key, value, true);
|
|
392
|
-
}
|
|
406
|
+
}
|
|
393
407
|
}
|
|
394
408
|
/**
|
|
395
409
|
* The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will
|
|
@@ -459,7 +473,7 @@ class MapKernel {
|
|
|
459
473
|
(0, common_utils_1.assert)(pendingClearMessageId === localOpMetadata.pendingMessageId, 0x2fb /* pendingMessageId does not match */);
|
|
460
474
|
return;
|
|
461
475
|
}
|
|
462
|
-
if (this.pendingKeys.size
|
|
476
|
+
if (this.pendingKeys.size > 0) {
|
|
463
477
|
this.clearExceptPendingKeys();
|
|
464
478
|
return;
|
|
465
479
|
}
|
package/dist/mapKernel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapKernel.js","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAAiF;AACjF,+DAAyE;AAczE,+CAIuB;AA6DvB,SAAS,uBAAuB,CAAC,QAAa;IAC1C,OAAO,QAAQ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CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;SACnC;QAED,kFAAkF;QAClF,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACrD,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;YACnD,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,CAAC,aAAa,EAAE,CAAC,CAAC;YAClF,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAC1C,CAAC;CACJ;AA5mBD,8BA4mBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer, ValueType } from \"@fluidframework/shared-object-base\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n ISerializableValue,\n ISerializedValue,\n ISharedMapEvents,\n} from \"./interfaces\";\nimport {\n IMapSetOperation,\n IMapDeleteOperation,\n IMapClearOperation,\n IMapKeyEditLocalOpMetadata,\n IMapKeyAddLocalOpMetadata,\n IMapClearLocalOpMetadata,\n} from \"./internalInterfaces\";\nimport {\n ILocalValue,\n LocalValueMaker,\n makeSerializable,\n} from \"./localValues\";\n\n/**\n * Defines the means to process and submit a given op on a map.\n */\ninterface IMapMessageHandler {\n /**\n * Apply the given operation.\n * @param op - The map operation to apply\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n process(\n op: IMapOperation,\n local: boolean,\n localOpMetadata: MapLocalOpMetadata,\n ): void;\n\n /**\n * Communicate the operation to remote clients.\n * @param op - The map operation to submit\n * @param localOpMetadata - The metadata to be submitted with the message.\n */\n submit(op: IMapOperation, localOpMetadata: MapLocalOpMetadata): void;\n\n applyStashedOp(op: IMapOperation): MapLocalOpMetadata;\n}\n\n/**\n * Map key operations are one of several types.\n */\nexport type IMapKeyOperation = IMapSetOperation | IMapDeleteOperation;\n\n/**\n * Description of a map delta operation\n */\nexport type IMapOperation = IMapKeyOperation | IMapClearOperation;\n\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n *\n * @remarks Directly used in\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\n * | JSON.stringify}, direct result from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.\n */\nexport interface IMapDataObjectSerializable {\n [key: string]: ISerializableValue;\n}\n\n/**\n * Serialized key/value data.\n */\nexport interface IMapDataObjectSerialized {\n [key: string]: ISerializedValue;\n}\n\ntype MapKeyLocalOpMetadata = IMapKeyEditLocalOpMetadata | IMapKeyAddLocalOpMetadata;\ntype MapLocalOpMetadata = IMapClearLocalOpMetadata | MapKeyLocalOpMetadata;\n\nfunction isMapKeyLocalOpMetadata(metadata: any): metadata is MapKeyLocalOpMetadata {\n return metadata !== undefined && typeof metadata.pendingMessageId === \"number\" &&\n (metadata.type === \"add\" || metadata.type === \"edit\");\n}\n\nfunction isClearLocalOpMetadata(metadata: any): metadata is IMapClearLocalOpMetadata {\n return metadata !== undefined && metadata.type === \"clear\" && typeof metadata.pendingMessageId === \"number\";\n}\n\nfunction isMapLocalOpMetadata(metadata: any): metadata is MapLocalOpMetadata {\n return metadata !== undefined && typeof metadata.pendingMessageId === \"number\" &&\n (metadata.type === \"add\" || metadata.type === \"edit\" || metadata.type === \"clear\");\n}\n\nfunction createClearLocalOpMetadata(op: IMapClearOperation,\n pendingClearMessageId: number, previousMap?: Map<string, ILocalValue>): IMapClearLocalOpMetadata {\n const localMetadata: IMapClearLocalOpMetadata = {\n type: \"clear\",\n pendingMessageId: pendingClearMessageId, previousMap,\n };\n return localMetadata;\n}\n\nfunction createKeyLocalOpMetadata(op: IMapKeyOperation,\n pendingMessageId: number, previousValue?: ILocalValue): MapKeyLocalOpMetadata {\n const localMetadata: MapKeyLocalOpMetadata = previousValue ?\n { type: \"edit\", pendingMessageId, previousValue } :\n { type: \"add\", pendingMessageId };\n return localMetadata;\n}\n\n/**\n * A SharedMap is a map-like distributed data structure.\n */\nexport class MapKernel {\n /**\n * The number of key/value pairs stored in the map.\n */\n public get size(): number {\n return this.data.size;\n }\n\n /**\n * Mapping of op types to message handlers.\n */\n private readonly messageHandlers: ReadonlyMap<string, IMapMessageHandler> = new Map();\n\n /**\n * The in-memory data the map is storing.\n */\n private readonly data = new Map<string, ILocalValue>();\n\n /**\n * Keys that have been modified locally but not yet ack'd from the server.\n */\n private readonly pendingKeys: Map<string, number[]> = new Map();\n\n /**\n * This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.\n */\n private pendingMessageId: number = -1;\n\n /**\n * The pending ids of any clears that have been performed locally but not yet ack'd from the server\n */\n private readonly pendingClearMessageIds: number[] = [];\n\n /**\n * Object to create encapsulations of the values stored in the map.\n */\n private readonly localValueMaker: LocalValueMaker;\n\n /**\n * Create a new shared map kernel.\n * @param serializer - The serializer to serialize / parse handles\n * @param handle - The handle of the shared object using the kernel\n * @param submitMessage - A callback to submit a message through the shared object\n * @param isAttached - To query whether the shared object should generate ops\n * @param valueTypes - The value types to register\n * @param eventEmitter - The object that will emit map events\n */\n constructor(\n private readonly serializer: IFluidSerializer,\n private readonly handle: IFluidHandle,\n private readonly submitMessage: (op: any, localOpMetadata: unknown) => void,\n private readonly isAttached: () => boolean,\n private readonly eventEmitter: TypedEventEmitter<ISharedMapEvents>,\n ) {\n this.localValueMaker = new LocalValueMaker(serializer);\n this.messageHandlers = this.getMessageHandlers();\n }\n\n /**\n * Get an iterator over the keys in this map.\n * @returns The iterator\n */\n public keys(): IterableIterator<string> {\n return this.data.keys();\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n public entries(): IterableIterator<[string, any]> {\n const localEntriesIterator = this.data.entries();\n const iterator = {\n next(): IteratorResult<[string, any]> {\n const nextVal = localEntriesIterator.next();\n return nextVal.done\n ? { value: undefined, done: true }\n // Unpack the stored value\n : { value: [nextVal.value[0], nextVal.value[1].value], done: false };\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the values in this map.\n * @returns The iterator\n */\n public values(): IterableIterator<any> {\n const localValuesIterator = this.data.values();\n const iterator = {\n next(): IteratorResult<any> {\n const nextVal = localValuesIterator.next();\n return nextVal.done\n ? { value: undefined, done: true }\n // Unpack the stored value\n : { value: nextVal.value.value, done: false };\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n public [Symbol.iterator](): IterableIterator<[string, any]> {\n return this.entries();\n }\n\n /**\n * Executes the given callback on each entry in the map.\n * @param callbackFn - Callback function\n */\n public forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n this.data.forEach((localValue, key, m) => {\n callbackFn(localValue.value, key, m);\n });\n }\n\n /**\n * {@inheritDoc ISharedMap.get}\n */\n public get<T = any>(key: string): T | undefined {\n const localValue = this.data.get(key);\n return localValue === undefined ? undefined : localValue.value as T;\n }\n\n /**\n * Check if a key exists in the map.\n * @param key - The key to check\n * @returns True if the key exists, false otherwise\n */\n public has(key: string): boolean {\n return this.data.has(key);\n }\n\n /**\n * {@inheritDoc ISharedMap.set}\n */\n public set(key: string, value: any) {\n // Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.\n if (key === undefined || key === null) {\n throw new Error(\"Undefined and null keys are not supported\");\n }\n\n // Create a local value and serialize it.\n const localValue = this.localValueMaker.fromInMemory(value);\n const serializableValue = makeSerializable(\n localValue,\n this.serializer,\n this.handle);\n\n // Set the value locally.\n const previousValue = this.setCore(\n key,\n localValue,\n true,\n );\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return;\n }\n\n const op: IMapSetOperation = {\n key,\n type: \"set\",\n value: serializableValue,\n };\n this.submitMapKeyMessage(op, previousValue);\n }\n\n /**\n * Delete a key from the map.\n * @param key - Key to delete\n * @returns True if the key existed and was deleted, false if it did not exist\n */\n public delete(key: string): boolean {\n // Delete the key locally first.\n const previousValue = this.deleteCore(key, true);\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return previousValue !== undefined;\n }\n\n const op: IMapDeleteOperation = {\n key,\n type: \"delete\",\n };\n this.submitMapKeyMessage(op, previousValue);\n\n return previousValue !== undefined;\n }\n\n /**\n * Clear all data from the map.\n */\n public clear(): void {\n const copy = this.isAttached() ? new Map<string, ILocalValue>(this.data) : undefined;\n\n // Clear the data locally first.\n this.clearCore(true);\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return;\n }\n\n const op: IMapClearOperation = {\n type: \"clear\",\n };\n this.submitMapClearMessage(op, copy);\n }\n\n /**\n * Serializes the data stored in the shared map to a JSON string\n * @param serializer - The serializer to use to serialize handles in its values.\n * @returns A JSON string containing serialized map data\n */\n public getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {\n const serializableMapData: IMapDataObjectSerialized = {};\n this.data.forEach((localValue, key) => {\n serializableMapData[key] = localValue.makeSerialized(serializer, this.handle);\n });\n return serializableMapData;\n }\n\n public getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {\n const serializableMapData: IMapDataObjectSerializable = {};\n this.data.forEach((localValue, key) => {\n serializableMapData[key] = makeSerializable(localValue, serializer, this.handle);\n });\n return serializableMapData;\n }\n\n public serialize(serializer: IFluidSerializer): string {\n return JSON.stringify(this.getSerializableStorage(serializer));\n }\n\n /**\n * Populate the kernel with the given map data.\n * @param data - A JSON string containing serialized map data\n */\n public populateFromSerializable(json: IMapDataObjectSerializable): void {\n for (const [key, serializable] of Object.entries(json)) {\n const localValue = {\n key,\n value: this.makeLocal(key, serializable),\n };\n\n this.data.set(localValue.key, localValue.value);\n }\n }\n\n public populate(json: string): void {\n this.populateFromSerializable(JSON.parse(json) as IMapDataObjectSerializable);\n }\n\n /**\n * Submit the given op if a handler is registered.\n * @param op - The operation to attempt to submit\n * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n * and not sent to the server. This will be sent back when this message is received back from the server. This is\n * also sent if we are asked to resubmit the message.\n * @returns True if the operation was submitted, false otherwise.\n */\n public trySubmitMessage(op: any, localOpMetadata: unknown): boolean {\n const handler = this.messageHandlers.get(op.type);\n if (handler === undefined) {\n return false;\n }\n handler.submit(op as IMapOperation, localOpMetadata as MapLocalOpMetadata);\n return true;\n }\n\n public tryApplyStashedOp(op: any): unknown {\n const handler = this.messageHandlers.get(op.type);\n if (handler === undefined) {\n throw new Error(\"no apply stashed op handler\");\n }\n return handler.applyStashedOp(op as IMapOperation);\n }\n\n /**\n * Process the given op if a handler is registered.\n * @param op - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @returns True if the operation was processed, false otherwise.\n */\n public tryProcessMessage(\n op: IMapOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): boolean {\n const handler = this.messageHandlers.get(op.type);\n if (handler === undefined) {\n return false;\n }\n handler.process(op, local, localOpMetadata as MapLocalOpMetadata);\n return true;\n }\n\n /**\n * Rollback a local op\n * @param op - The operation to rollback\n * @param localOpMetadata - The local metadata associated with the op.\n */\n public rollback(op: any, localOpMetadata: unknown) {\n if (!isMapLocalOpMetadata(localOpMetadata)) {\n throw new Error(\"Invalid localOpMetadata\");\n }\n\n if (op.type === \"clear\" && localOpMetadata.type === \"clear\") {\n if (localOpMetadata.previousMap === undefined) {\n throw new Error(\"Cannot rollback without previous map\");\n }\n localOpMetadata.previousMap.forEach((localValue, key) => {\n this.setCore(key, localValue, true);\n });\n\n const lastPendingClearId = this.pendingClearMessageIds.pop();\n if (lastPendingClearId === undefined || lastPendingClearId !== localOpMetadata.pendingMessageId) {\n throw new Error(\"Rollback op does match last clear\");\n }\n } else if (op.type === \"delete\" || op.type === \"set\") {\n if (localOpMetadata.type === \"add\") {\n this.deleteCore(op.key, true);\n } else if (localOpMetadata.type === \"edit\" && localOpMetadata.previousValue !== undefined) {\n this.setCore(op.key, localOpMetadata.previousValue, true);\n } else {\n throw new Error(\"Cannot rollback without previous value\");\n }\n\n const pendingMessageIds = this.pendingKeys.get(op.key);\n const lastPendingMessageId = pendingMessageIds?.pop();\n if (!pendingMessageIds || lastPendingMessageId !== localOpMetadata.pendingMessageId) {\n throw new Error(\"Rollback op does not match last pending\");\n }\n if (pendingMessageIds.length === 0) {\n this.pendingKeys.delete(op.key);\n }\n } else {\n throw new Error(\"Unsupported op for rollback\");\n }\n }\n\n /**\n * Set implementation used for both locally sourced sets as well as incoming remote sets.\n * @param key - The key being set\n * @param value - The value being set\n * @param local - Whether the message originated from the local client\n * @returns Previous local value of the key, if any\n */\n private setCore(key: string, value: ILocalValue, local: boolean): ILocalValue | undefined {\n const previousLocalValue = this.data.get(key);\n const previousValue = previousLocalValue?.value;\n this.data.set(key, value);\n this.eventEmitter.emit(\"valueChanged\", { key, previousValue }, local, this.eventEmitter);\n return previousLocalValue;\n }\n\n /**\n * Clear implementation used for both locally sourced clears as well as incoming remote clears.\n * @param local - Whether the message originated from the local client\n */\n private clearCore(local: boolean): void {\n this.data.clear();\n this.eventEmitter.emit(\"clear\", local, this.eventEmitter);\n }\n\n /**\n * Delete implementation used for both locally sourced deletes as well as incoming remote deletes.\n * @param key - The key being deleted\n * @param local - Whether the message originated from the local client\n * @returns Previous local value of the key if it existed, undefined if it did not exist\n */\n private deleteCore(key: string, local: boolean): ILocalValue | undefined {\n const previousLocalValue = this.data.get(key);\n const previousValue = previousLocalValue?.value;\n const successfullyRemoved = this.data.delete(key);\n if (successfullyRemoved) {\n this.eventEmitter.emit(\"valueChanged\", { key, previousValue }, local, this.eventEmitter);\n }\n return previousLocalValue;\n }\n\n /**\n * Clear all keys in memory in response to a remote clear, but retain keys we have modified but not yet been ack'd.\n */\n private clearExceptPendingKeys(): void {\n // Assuming the pendingKeys is small and the map is large\n // we will get the value for the pendingKeys and clear the map\n const temp = new Map<string, ILocalValue>();\n this.pendingKeys.forEach((value, key) => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n temp.set(key, this.data.get(key)!);\n });\n this.clearCore(false);\n temp.forEach((value, key) => {\n this.setCore(key, value, true);\n });\n }\n\n /**\n * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will\n * have the information we need to create a real object, but will not be the real object yet. For example,\n * we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's\n * job is to convert that information into a real object for local usage.\n * @param key - The key that the caller intends to store the local value into (used for ops later). But\n * doesn't actually store the local value into that key. So better not lie!\n * @param serializable - The remote information that we can convert into a real object\n * @returns The local value that was produced\n */\n private makeLocal(key: string, serializable: ISerializableValue): ILocalValue {\n if (serializable.type === ValueType[ValueType.Plain] || serializable.type === ValueType[ValueType.Shared]) {\n return this.localValueMaker.fromSerializable(serializable);\n } else {\n throw new Error(\"Unknown local value type\");\n }\n }\n\n /**\n * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should\n * not process the incoming operation.\n * @param op - Operation to check\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @returns True if the operation should be processed, false otherwise\n */\n private needProcessKeyOperation(\n op: IMapKeyOperation,\n local: boolean,\n localOpMetadata: MapLocalOpMetadata,\n ): boolean {\n if (this.pendingClearMessageIds.length > 0) {\n if (local) {\n assert(localOpMetadata !== undefined && isMapKeyLocalOpMetadata(localOpMetadata) &&\n localOpMetadata.pendingMessageId < this.pendingClearMessageIds[0],\n 0x013 /* \"Received out of order op when there is an unackd clear message\" */);\n }\n // If we have an unack'd clear, we can ignore all ops.\n return false;\n }\n\n const pendingKeyMessageId = this.pendingKeys.get(op.key);\n if (pendingKeyMessageId !== undefined) {\n // Found an unack'd op. Clear it from the map if the pendingMessageId in the map matches this message's\n // and don't process the op.\n if (local) {\n assert(localOpMetadata !== undefined && isMapKeyLocalOpMetadata(localOpMetadata),\n 0x014 /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageIds = this.pendingKeys.get(op.key);\n assert(pendingMessageIds !== undefined && pendingMessageIds[0] === localOpMetadata.pendingMessageId,\n 0x2fa /* Unexpected pending message received */);\n pendingMessageIds.shift();\n if (pendingMessageIds.length === 0) {\n this.pendingKeys.delete(op.key);\n }\n }\n return false;\n }\n\n // If we don't have a NACK op on the key, we need to process the remote ops.\n return !local;\n }\n\n /**\n * Get the message handlers for the map.\n * @returns A map of string op names to IMapMessageHandlers for those ops\n */\n private getMessageHandlers() {\n const messageHandlers = new Map<string, IMapMessageHandler>();\n messageHandlers.set(\n \"clear\",\n {\n process: (op: IMapClearOperation, local, localOpMetadata) => {\n if (local) {\n assert(isClearLocalOpMetadata(localOpMetadata),\n 0x015 /* \"pendingMessageId is missing from the local client's clear operation\" */);\n const pendingClearMessageId = this.pendingClearMessageIds.shift();\n assert(pendingClearMessageId === localOpMetadata.pendingMessageId,\n 0x2fb /* pendingMessageId does not match */);\n return;\n }\n if (this.pendingKeys.size !== 0) {\n this.clearExceptPendingKeys();\n return;\n }\n this.clearCore(local);\n },\n submit: (op: IMapClearOperation, localOpMetadata: IMapClearLocalOpMetadata) => {\n assert(isClearLocalOpMetadata(localOpMetadata), 0x2fc /* Invalid localOpMetadata for clear */);\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const pendingClearMessageId = this.pendingClearMessageIds.shift();\n assert(pendingClearMessageId === localOpMetadata.pendingMessageId,\n 0x2fd /* pendingMessageId does not match */);\n this.submitMapClearMessage(op, localOpMetadata.previousMap);\n },\n applyStashedOp: (op: IMapClearOperation) => {\n const copy = new Map<string, ILocalValue>(this.data);\n this.clearCore(true);\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n return createClearLocalOpMetadata(op, this.getMapClearMessageId(), copy);\n },\n });\n messageHandlers.set(\n \"delete\",\n {\n process: (op: IMapDeleteOperation, local, localOpMetadata) => {\n if (!this.needProcessKeyOperation(op, local, localOpMetadata)) {\n return;\n }\n this.deleteCore(op.key, local);\n },\n submit: (op: IMapDeleteOperation, localOpMetadata: MapKeyLocalOpMetadata) => {\n this.resubmitMapKeyMessage(op, localOpMetadata);\n },\n applyStashedOp: (op: IMapDeleteOperation) => {\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const previousValue = this.deleteCore(op.key, true);\n return createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);\n },\n });\n messageHandlers.set(\n \"set\",\n {\n process: (op: IMapSetOperation, local, localOpMetadata) => {\n if (!this.needProcessKeyOperation(op, local, localOpMetadata)) {\n return;\n }\n\n // needProcessKeyOperation should have returned false if local is true\n const context = this.makeLocal(op.key, op.value);\n this.setCore(op.key, context, local);\n },\n submit: (op: IMapSetOperation, localOpMetadata: MapKeyLocalOpMetadata) => {\n this.resubmitMapKeyMessage(op, localOpMetadata);\n },\n applyStashedOp: (op: IMapSetOperation) => {\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const context = this.makeLocal(op.key, op.value);\n const previousValue = this.setCore(op.key, context, true);\n return createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);\n },\n });\n\n return messageHandlers;\n }\n\n private getMapClearMessageId(): number {\n const pendingMessageId = ++this.pendingMessageId;\n this.pendingClearMessageIds.push(pendingMessageId);\n return pendingMessageId;\n }\n\n /**\n * Submit a clear message to remote clients.\n * @param op - The clear message\n */\n private submitMapClearMessage(op: IMapClearOperation, previousMap?: Map<string, ILocalValue>): void {\n const metadata = createClearLocalOpMetadata(op, this.getMapClearMessageId(), previousMap);\n this.submitMessage(op, metadata);\n }\n\n private getMapKeyMessageId(op: IMapKeyOperation): number {\n const pendingMessageId = ++this.pendingMessageId;\n const pendingMessageIds = this.pendingKeys.get(op.key);\n if (pendingMessageIds !== undefined) {\n pendingMessageIds.push(pendingMessageId);\n } else {\n this.pendingKeys.set(op.key, [pendingMessageId]);\n }\n return pendingMessageId;\n }\n\n /**\n * Submit a map key message to remote clients.\n * @param op - The map key message\n * @param previousValue - The value of the key before this op\n */\n private submitMapKeyMessage(op: IMapKeyOperation, previousValue?: ILocalValue): void {\n const localMetadata = createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);\n this.submitMessage(op, localMetadata);\n }\n\n /**\n * Submit a map key message to remote clients based on a previous submit.\n * @param op - The map key message\n * @param localOpMetadata - Metadata from the previous submit\n */\n private resubmitMapKeyMessage(op: IMapKeyOperation, localOpMetadata: MapLocalOpMetadata): void {\n assert(isMapKeyLocalOpMetadata(localOpMetadata), 0x2fe /* Invalid localOpMetadata in submit */);\n\n // clear the old pending message id\n const pendingMessageIds = this.pendingKeys.get(op.key);\n assert(pendingMessageIds !== undefined && pendingMessageIds[0] === localOpMetadata.pendingMessageId,\n 0x2ff /* Unexpected pending message received */);\n pendingMessageIds.shift();\n if (pendingMessageIds.length === 0) {\n this.pendingKeys.delete(op.key);\n }\n\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const pendingMessageId = this.getMapKeyMessageId(op);\n const localMetadata = localOpMetadata.type === \"edit\" ?\n { type: \"edit\", pendingMessageId, previousValue: localOpMetadata.previousValue } :\n { type: \"add\", pendingMessageId };\n this.submitMessage(op, localMetadata);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mapKernel.js","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAAiF;AACjF,+DAAyE;AAczE,+CAIuB;AA6DvB,mGAAmG;AAEnG,SAAS,uBAAuB,CAAC,QAAa;IAC1C,OAAO,QAAQ,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,gBAAgB,KAAK,QAAQ;QAC1E,CAAC,QAAQ,CAAC,IAAI,KAAK,KAAK,IAAI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AAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;SACnC;QAED,kFAAkF;QAClF,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACrD,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;YACnD,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,CAAC,aAAa,EAAE,CAAC,CAAC;YAClF,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAC1C,CAAC;CACJ;AA1nBD,8BA0nBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer, ValueType } from \"@fluidframework/shared-object-base\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n ISerializableValue,\n ISerializedValue,\n ISharedMapEvents,\n} from \"./interfaces\";\nimport {\n IMapSetOperation,\n IMapDeleteOperation,\n IMapClearOperation,\n IMapKeyEditLocalOpMetadata,\n IMapKeyAddLocalOpMetadata,\n IMapClearLocalOpMetadata,\n} from \"./internalInterfaces\";\nimport {\n ILocalValue,\n LocalValueMaker,\n makeSerializable,\n} from \"./localValues\";\n\n/**\n * Defines the means to process and submit a given op on a map.\n */\ninterface IMapMessageHandler {\n /**\n * Apply the given operation.\n * @param op - The map operation to apply\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n process(\n op: IMapOperation,\n local: boolean,\n localOpMetadata: MapLocalOpMetadata,\n ): void;\n\n /**\n * Communicate the operation to remote clients.\n * @param op - The map operation to submit\n * @param localOpMetadata - The metadata to be submitted with the message.\n */\n submit(op: IMapOperation, localOpMetadata: MapLocalOpMetadata): void;\n\n applyStashedOp(op: IMapOperation): MapLocalOpMetadata;\n}\n\n/**\n * Map key operations are one of several types.\n */\nexport type IMapKeyOperation = IMapSetOperation | IMapDeleteOperation;\n\n/**\n * Description of a map delta operation\n */\nexport type IMapOperation = IMapKeyOperation | IMapClearOperation;\n\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n *\n * @remarks Directly used in\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\n * | JSON.stringify}, direct result from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.\n */\nexport interface IMapDataObjectSerializable {\n [key: string]: ISerializableValue;\n}\n\n/**\n * Serialized key/value data.\n */\nexport interface IMapDataObjectSerialized {\n [key: string]: ISerializedValue;\n}\n\ntype MapKeyLocalOpMetadata = IMapKeyEditLocalOpMetadata | IMapKeyAddLocalOpMetadata;\ntype MapLocalOpMetadata = IMapClearLocalOpMetadata | MapKeyLocalOpMetadata;\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\nfunction isMapKeyLocalOpMetadata(metadata: any): metadata is MapKeyLocalOpMetadata {\n return metadata !== undefined && typeof metadata.pendingMessageId === \"number\" &&\n (metadata.type === \"add\" || metadata.type === \"edit\");\n}\n\nfunction isClearLocalOpMetadata(metadata: any): metadata is IMapClearLocalOpMetadata {\n return metadata !== undefined && metadata.type === \"clear\" && typeof metadata.pendingMessageId === \"number\";\n}\n\nfunction isMapLocalOpMetadata(metadata: any): metadata is MapLocalOpMetadata {\n return metadata !== undefined && typeof metadata.pendingMessageId === \"number\" &&\n (metadata.type === \"add\" || metadata.type === \"edit\" || metadata.type === \"clear\");\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */\n\nfunction createClearLocalOpMetadata(op: IMapClearOperation,\n pendingClearMessageId: number, previousMap?: Map<string, ILocalValue>): IMapClearLocalOpMetadata {\n const localMetadata: IMapClearLocalOpMetadata = {\n type: \"clear\",\n pendingMessageId: pendingClearMessageId, previousMap,\n };\n return localMetadata;\n}\n\nfunction createKeyLocalOpMetadata(op: IMapKeyOperation,\n pendingMessageId: number, previousValue?: ILocalValue): MapKeyLocalOpMetadata {\n const localMetadata: MapKeyLocalOpMetadata = previousValue ?\n { type: \"edit\", pendingMessageId, previousValue } :\n { type: \"add\", pendingMessageId };\n return localMetadata;\n}\n\n/**\n * A SharedMap is a map-like distributed data structure.\n */\nexport class MapKernel {\n /**\n * The number of key/value pairs stored in the map.\n */\n public get size(): number {\n return this.data.size;\n }\n\n /**\n * Mapping of op types to message handlers.\n */\n private readonly messageHandlers: ReadonlyMap<string, IMapMessageHandler> = new Map();\n\n /**\n * The in-memory data the map is storing.\n */\n private readonly data = new Map<string, ILocalValue>();\n\n /**\n * Keys that have been modified locally but not yet ack'd from the server.\n */\n private readonly pendingKeys: Map<string, number[]> = new Map();\n\n /**\n * This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.\n */\n private pendingMessageId: number = -1;\n\n /**\n * The pending ids of any clears that have been performed locally but not yet ack'd from the server\n */\n private readonly pendingClearMessageIds: number[] = [];\n\n /**\n * Object to create encapsulations of the values stored in the map.\n */\n private readonly localValueMaker: LocalValueMaker;\n\n /**\n * Create a new shared map kernel.\n * @param serializer - The serializer to serialize / parse handles\n * @param handle - The handle of the shared object using the kernel\n * @param submitMessage - A callback to submit a message through the shared object\n * @param isAttached - To query whether the shared object should generate ops\n * @param valueTypes - The value types to register\n * @param eventEmitter - The object that will emit map events\n */\n public constructor(\n private readonly serializer: IFluidSerializer,\n private readonly handle: IFluidHandle,\n private readonly submitMessage: (op: unknown, localOpMetadata: unknown) => void,\n private readonly isAttached: () => boolean,\n private readonly eventEmitter: TypedEventEmitter<ISharedMapEvents>,\n ) {\n this.localValueMaker = new LocalValueMaker(serializer);\n this.messageHandlers = this.getMessageHandlers();\n }\n\n /**\n * Get an iterator over the keys in this map.\n * @returns The iterator\n */\n public keys(): IterableIterator<string> {\n return this.data.keys();\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public entries(): IterableIterator<[string, any]> {\n const localEntriesIterator = this.data.entries();\n const iterator = {\n next(): IteratorResult<[string, unknown]> {\n const nextVal = localEntriesIterator.next();\n return nextVal.done\n ? { value: undefined, done: true }\n // Unpack the stored value\n : { value: [nextVal.value[0], nextVal.value[1].value], done: false };\n },\n [Symbol.iterator](): IterableIterator<[string, unknown]> {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the values in this map.\n * @returns The iterator\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public values(): IterableIterator<any> {\n const localValuesIterator = this.data.values();\n const iterator = {\n next(): IteratorResult<unknown> {\n const nextVal = localValuesIterator.next();\n return nextVal.done\n ? { value: undefined, done: true }\n // Unpack the stored value\n : { value: nextVal.value.value as unknown, done: false };\n },\n [Symbol.iterator](): IterableIterator<unknown> {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public [Symbol.iterator](): IterableIterator<[string, any]> {\n return this.entries();\n }\n\n /**\n * Executes the given callback on each entry in the map.\n * @param callbackFn - Callback function\n */\n public forEach(callbackFn: (value: unknown, key: string, map: Map<string, unknown>) => void): void {\n // eslint-disable-next-line unicorn/no-array-for-each\n this.data.forEach((localValue, key, m) => {\n callbackFn(localValue.value, key, m);\n });\n }\n\n /**\n * {@inheritDoc ISharedMap.get}\n */\n // TODO: Use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public get<T = any>(key: string): T | undefined {\n const localValue = this.data.get(key);\n return localValue === undefined ? undefined : localValue.value as T;\n }\n\n /**\n * Check if a key exists in the map.\n * @param key - The key to check\n * @returns True if the key exists, false otherwise\n */\n public has(key: string): boolean {\n return this.data.has(key);\n }\n\n /**\n * {@inheritDoc ISharedMap.set}\n */\n public set(key: string, value: unknown): void {\n // Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.\n if (key === undefined || key === null) {\n throw new Error(\"Undefined and null keys are not supported\");\n }\n\n // Create a local value and serialize it.\n const localValue = this.localValueMaker.fromInMemory(value);\n const serializableValue = makeSerializable(\n localValue,\n this.serializer,\n this.handle);\n\n // Set the value locally.\n const previousValue = this.setCore(\n key,\n localValue,\n true,\n );\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return;\n }\n\n const op: IMapSetOperation = {\n key,\n type: \"set\",\n value: serializableValue,\n };\n this.submitMapKeyMessage(op, previousValue);\n }\n\n /**\n * Delete a key from the map.\n * @param key - Key to delete\n * @returns True if the key existed and was deleted, false if it did not exist\n */\n public delete(key: string): boolean {\n // Delete the key locally first.\n const previousValue = this.deleteCore(key, true);\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return previousValue !== undefined;\n }\n\n const op: IMapDeleteOperation = {\n key,\n type: \"delete\",\n };\n this.submitMapKeyMessage(op, previousValue);\n\n return previousValue !== undefined;\n }\n\n /**\n * Clear all data from the map.\n */\n public clear(): void {\n const copy = this.isAttached() ? new Map<string, ILocalValue>(this.data) : undefined;\n\n // Clear the data locally first.\n this.clearCore(true);\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return;\n }\n\n const op: IMapClearOperation = {\n type: \"clear\",\n };\n this.submitMapClearMessage(op, copy);\n }\n\n /**\n * Serializes the data stored in the shared map to a JSON string\n * @param serializer - The serializer to use to serialize handles in its values.\n * @returns A JSON string containing serialized map data\n */\n public getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {\n const serializableMapData: IMapDataObjectSerialized = {};\n for (const [key, localValue] of this.data.entries()) {\n serializableMapData[key] = localValue.makeSerialized(serializer, this.handle);\n }\n return serializableMapData;\n }\n\n public getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {\n const serializableMapData: IMapDataObjectSerializable = {};\n for (const [key, localValue] of this.data.entries()) {\n serializableMapData[key] = makeSerializable(localValue, serializer, this.handle);\n }\n return serializableMapData;\n }\n\n public serialize(serializer: IFluidSerializer): string {\n return JSON.stringify(this.getSerializableStorage(serializer));\n }\n\n /**\n * Populate the kernel with the given map data.\n * @param data - A JSON string containing serialized map data\n */\n public populateFromSerializable(json: IMapDataObjectSerializable): void {\n for (const [key, serializable] of Object.entries(json)) {\n const localValue = {\n key,\n value: this.makeLocal(key, serializable),\n };\n\n this.data.set(localValue.key, localValue.value);\n }\n }\n\n public populate(json: string): void {\n this.populateFromSerializable(JSON.parse(json) as IMapDataObjectSerializable);\n }\n\n /**\n * Submit the given op if a handler is registered.\n * @param op - The operation to attempt to submit\n * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n * and not sent to the server. This will be sent back when this message is received back from the server. This is\n * also sent if we are asked to resubmit the message.\n * @returns True if the operation was submitted, false otherwise.\n */\n public trySubmitMessage(op: IMapOperation, localOpMetadata: unknown): boolean {\n const handler = this.messageHandlers.get(op.type);\n if (handler === undefined) {\n return false;\n }\n handler.submit(op, localOpMetadata as MapLocalOpMetadata);\n return true;\n }\n\n public tryApplyStashedOp(op: IMapOperation): unknown {\n const handler = this.messageHandlers.get(op.type);\n if (handler === undefined) {\n throw new Error(\"no apply stashed op handler\");\n }\n return handler.applyStashedOp(op);\n }\n\n /**\n * Process the given op if a handler is registered.\n * @param op - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @returns True if the operation was processed, false otherwise.\n */\n public tryProcessMessage(\n op: IMapOperation,\n local: boolean,\n localOpMetadata: unknown,\n ): boolean {\n const handler = this.messageHandlers.get(op.type);\n if (handler === undefined) {\n return false;\n }\n handler.process(op, local, localOpMetadata as MapLocalOpMetadata);\n return true;\n }\n\n /* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\n /**\n * Rollback a local op\n * @param op - The operation to rollback\n * @param localOpMetadata - The local metadata associated with the op.\n */\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n public rollback(op: any, localOpMetadata: unknown): void {\n if (!isMapLocalOpMetadata(localOpMetadata)) {\n throw new Error(\"Invalid localOpMetadata\");\n }\n\n if (op.type === \"clear\" && localOpMetadata.type === \"clear\") {\n if (localOpMetadata.previousMap === undefined) {\n throw new Error(\"Cannot rollback without previous map\");\n }\n for (const [key, localValue] of localOpMetadata.previousMap.entries()) {\n this.setCore(key, localValue, true);\n }\n\n const lastPendingClearId = this.pendingClearMessageIds.pop();\n if (lastPendingClearId === undefined || lastPendingClearId !== localOpMetadata.pendingMessageId) {\n throw new Error(\"Rollback op does match last clear\");\n }\n } else if (op.type === \"delete\" || op.type === \"set\") {\n if (localOpMetadata.type === \"add\") {\n this.deleteCore(op.key as string, true);\n } else if (localOpMetadata.type === \"edit\" && localOpMetadata.previousValue !== undefined) {\n this.setCore(op.key as string, localOpMetadata.previousValue, true);\n } else {\n throw new Error(\"Cannot rollback without previous value\");\n }\n\n const pendingMessageIds = this.pendingKeys.get(op.key as string);\n const lastPendingMessageId = pendingMessageIds?.pop();\n if (!pendingMessageIds || lastPendingMessageId !== localOpMetadata.pendingMessageId) {\n throw new Error(\"Rollback op does not match last pending\");\n }\n if (pendingMessageIds.length === 0) {\n this.pendingKeys.delete(op.key as string);\n }\n } else {\n throw new Error(\"Unsupported op for rollback\");\n }\n }\n\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n\n /**\n * Set implementation used for both locally sourced sets as well as incoming remote sets.\n * @param key - The key being set\n * @param value - The value being set\n * @param local - Whether the message originated from the local client\n * @returns Previous local value of the key, if any\n */\n private setCore(key: string, value: ILocalValue, local: boolean): ILocalValue | undefined {\n const previousLocalValue = this.data.get(key);\n const previousValue: unknown = previousLocalValue?.value;\n this.data.set(key, value);\n this.eventEmitter.emit(\"valueChanged\", { key, previousValue }, local, this.eventEmitter);\n return previousLocalValue;\n }\n\n /**\n * Clear implementation used for both locally sourced clears as well as incoming remote clears.\n * @param local - Whether the message originated from the local client\n */\n private clearCore(local: boolean): void {\n this.data.clear();\n this.eventEmitter.emit(\"clear\", local, this.eventEmitter);\n }\n\n /**\n * Delete implementation used for both locally sourced deletes as well as incoming remote deletes.\n * @param key - The key being deleted\n * @param local - Whether the message originated from the local client\n * @returns Previous local value of the key if it existed, undefined if it did not exist\n */\n private deleteCore(key: string, local: boolean): ILocalValue | undefined {\n const previousLocalValue = this.data.get(key);\n const previousValue: unknown = previousLocalValue?.value;\n const successfullyRemoved = this.data.delete(key);\n if (successfullyRemoved) {\n this.eventEmitter.emit(\"valueChanged\", { key, previousValue }, local, this.eventEmitter);\n }\n return previousLocalValue;\n }\n\n /**\n * Clear all keys in memory in response to a remote clear, but retain keys we have modified but not yet been ack'd.\n */\n private clearExceptPendingKeys(): void {\n // Assuming the pendingKeys is small and the map is large\n // we will get the value for the pendingKeys and clear the map\n const temp = new Map<string, ILocalValue>();\n for (const key of this.pendingKeys.keys()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n temp.set(key, this.data.get(key)!);\n }\n this.clearCore(false);\n for (const [key, value] of temp.entries()) {\n this.setCore(key, value, true);\n }\n }\n\n /**\n * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will\n * have the information we need to create a real object, but will not be the real object yet. For example,\n * we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's\n * job is to convert that information into a real object for local usage.\n * @param key - The key that the caller intends to store the local value into (used for ops later). But\n * doesn't actually store the local value into that key. So better not lie!\n * @param serializable - The remote information that we can convert into a real object\n * @returns The local value that was produced\n */\n private makeLocal(key: string, serializable: ISerializableValue): ILocalValue {\n if (serializable.type === ValueType[ValueType.Plain] || serializable.type === ValueType[ValueType.Shared]) {\n return this.localValueMaker.fromSerializable(serializable);\n } else {\n throw new Error(\"Unknown local value type\");\n }\n }\n\n /**\n * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should\n * not process the incoming operation.\n * @param op - Operation to check\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @returns True if the operation should be processed, false otherwise\n */\n private needProcessKeyOperation(\n op: IMapKeyOperation,\n local: boolean,\n localOpMetadata: MapLocalOpMetadata,\n ): boolean {\n if (this.pendingClearMessageIds.length > 0) {\n if (local) {\n assert(localOpMetadata !== undefined && isMapKeyLocalOpMetadata(localOpMetadata) &&\n localOpMetadata.pendingMessageId < this.pendingClearMessageIds[0],\n 0x013 /* \"Received out of order op when there is an unackd clear message\" */);\n }\n // If we have an unack'd clear, we can ignore all ops.\n return false;\n }\n\n const pendingKeyMessageId = this.pendingKeys.get(op.key);\n if (pendingKeyMessageId !== undefined) {\n // Found an unack'd op. Clear it from the map if the pendingMessageId in the map matches this message's\n // and don't process the op.\n if (local) {\n assert(localOpMetadata !== undefined && isMapKeyLocalOpMetadata(localOpMetadata),\n 0x014 /* pendingMessageId is missing from the local client's operation */);\n const pendingMessageIds = this.pendingKeys.get(op.key);\n assert(pendingMessageIds !== undefined && pendingMessageIds[0] === localOpMetadata.pendingMessageId,\n 0x2fa /* Unexpected pending message received */);\n pendingMessageIds.shift();\n if (pendingMessageIds.length === 0) {\n this.pendingKeys.delete(op.key);\n }\n }\n return false;\n }\n\n // If we don't have a NACK op on the key, we need to process the remote ops.\n return !local;\n }\n\n /**\n * Get the message handlers for the map.\n * @returns A map of string op names to IMapMessageHandlers for those ops\n */\n private getMessageHandlers(): Map<string, IMapMessageHandler> {\n const messageHandlers = new Map<string, IMapMessageHandler>();\n messageHandlers.set(\n \"clear\",\n {\n process: (op: IMapClearOperation, local, localOpMetadata) => {\n if (local) {\n assert(isClearLocalOpMetadata(localOpMetadata),\n 0x015 /* \"pendingMessageId is missing from the local client's clear operation\" */);\n const pendingClearMessageId = this.pendingClearMessageIds.shift();\n assert(pendingClearMessageId === localOpMetadata.pendingMessageId,\n 0x2fb /* pendingMessageId does not match */);\n return;\n }\n if (this.pendingKeys.size > 0) {\n this.clearExceptPendingKeys();\n return;\n }\n this.clearCore(local);\n },\n submit: (op: IMapClearOperation, localOpMetadata: IMapClearLocalOpMetadata) => {\n assert(isClearLocalOpMetadata(localOpMetadata), 0x2fc /* Invalid localOpMetadata for clear */);\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const pendingClearMessageId = this.pendingClearMessageIds.shift();\n assert(pendingClearMessageId === localOpMetadata.pendingMessageId,\n 0x2fd /* pendingMessageId does not match */);\n this.submitMapClearMessage(op, localOpMetadata.previousMap);\n },\n applyStashedOp: (op: IMapClearOperation) => {\n const copy = new Map<string, ILocalValue>(this.data);\n this.clearCore(true);\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n return createClearLocalOpMetadata(op, this.getMapClearMessageId(), copy);\n },\n });\n messageHandlers.set(\n \"delete\",\n {\n process: (op: IMapDeleteOperation, local, localOpMetadata) => {\n if (!this.needProcessKeyOperation(op, local, localOpMetadata)) {\n return;\n }\n this.deleteCore(op.key, local);\n },\n submit: (op: IMapDeleteOperation, localOpMetadata: MapKeyLocalOpMetadata) => {\n this.resubmitMapKeyMessage(op, localOpMetadata);\n },\n applyStashedOp: (op: IMapDeleteOperation) => {\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const previousValue = this.deleteCore(op.key, true);\n return createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);\n },\n });\n messageHandlers.set(\n \"set\",\n {\n process: (op: IMapSetOperation, local, localOpMetadata) => {\n if (!this.needProcessKeyOperation(op, local, localOpMetadata)) {\n return;\n }\n\n // needProcessKeyOperation should have returned false if local is true\n const context = this.makeLocal(op.key, op.value);\n this.setCore(op.key, context, local);\n },\n submit: (op: IMapSetOperation, localOpMetadata: MapKeyLocalOpMetadata) => {\n this.resubmitMapKeyMessage(op, localOpMetadata);\n },\n applyStashedOp: (op: IMapSetOperation) => {\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const context = this.makeLocal(op.key, op.value);\n const previousValue = this.setCore(op.key, context, true);\n return createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);\n },\n });\n\n return messageHandlers;\n }\n\n private getMapClearMessageId(): number {\n const pendingMessageId = ++this.pendingMessageId;\n this.pendingClearMessageIds.push(pendingMessageId);\n return pendingMessageId;\n }\n\n /**\n * Submit a clear message to remote clients.\n * @param op - The clear message\n */\n private submitMapClearMessage(op: IMapClearOperation, previousMap?: Map<string, ILocalValue>): void {\n const metadata = createClearLocalOpMetadata(op, this.getMapClearMessageId(), previousMap);\n this.submitMessage(op, metadata);\n }\n\n private getMapKeyMessageId(op: IMapKeyOperation): number {\n const pendingMessageId = ++this.pendingMessageId;\n const pendingMessageIds = this.pendingKeys.get(op.key);\n if (pendingMessageIds !== undefined) {\n pendingMessageIds.push(pendingMessageId);\n } else {\n this.pendingKeys.set(op.key, [pendingMessageId]);\n }\n return pendingMessageId;\n }\n\n /**\n * Submit a map key message to remote clients.\n * @param op - The map key message\n * @param previousValue - The value of the key before this op\n */\n private submitMapKeyMessage(op: IMapKeyOperation, previousValue?: ILocalValue): void {\n const localMetadata = createKeyLocalOpMetadata(op, this.getMapKeyMessageId(op), previousValue);\n this.submitMessage(op, localMetadata);\n }\n\n /**\n * Submit a map key message to remote clients based on a previous submit.\n * @param op - The map key message\n * @param localOpMetadata - Metadata from the previous submit\n */\n private resubmitMapKeyMessage(op: IMapKeyOperation, localOpMetadata: MapLocalOpMetadata): void {\n assert(isMapKeyLocalOpMetadata(localOpMetadata), 0x2fe /* Invalid localOpMetadata in submit */);\n\n // clear the old pending message id\n const pendingMessageIds = this.pendingKeys.get(op.key);\n assert(pendingMessageIds !== undefined && pendingMessageIds[0] === localOpMetadata.pendingMessageId,\n 0x2ff /* Unexpected pending message received */);\n pendingMessageIds.shift();\n if (pendingMessageIds.length === 0) {\n this.pendingKeys.delete(op.key);\n }\n\n // We don't reuse the metadata pendingMessageId but send a new one on each submit.\n const pendingMessageId = this.getMapKeyMessageId(op);\n const localMetadata = localOpMetadata.type === \"edit\" ?\n { type: \"edit\", pendingMessageId, previousValue: localOpMetadata.previousValue } :\n { type: \"add\", pendingMessageId };\n this.submitMessage(op, localMetadata);\n }\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/map";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.2.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.2.3.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/map";
|
|
11
|
-
exports.pkgVersion = "2.0.0-internal.2.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.2.3.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qBAAqB,CAAC;AAChC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/map\";\nexport const pkgVersion = \"2.0.0-internal.2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qBAAqB,CAAC;AAChC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/map\";\nexport const pkgVersion = \"2.0.0-internal.2.3.0\";\n"]}
|
package/lib/directory.d.ts
CHANGED
|
@@ -239,7 +239,7 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
239
239
|
/**
|
|
240
240
|
* {@inheritDoc IDirectory.set}
|
|
241
241
|
*/
|
|
242
|
-
set<T =
|
|
242
|
+
set<T = unknown>(key: string, value: T): this;
|
|
243
243
|
dispose(error?: Error): void;
|
|
244
244
|
get disposed(): boolean;
|
|
245
245
|
/**
|
|
@@ -337,7 +337,7 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
337
337
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
338
338
|
* @internal
|
|
339
339
|
*/
|
|
340
|
-
protected reSubmitCore(content:
|
|
340
|
+
protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
|
|
341
341
|
/**
|
|
342
342
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
343
343
|
* @internal
|
|
@@ -358,7 +358,7 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
358
358
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
359
359
|
* @internal
|
|
360
360
|
*/
|
|
361
|
-
protected rollback(content:
|
|
361
|
+
protected rollback(content: unknown, localOpMetadata: unknown): void;
|
|
362
362
|
/**
|
|
363
363
|
* Converts the given relative path to absolute against the root.
|
|
364
364
|
* @param relativePath - The path to convert
|
|
@@ -380,9 +380,10 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
380
380
|
*/
|
|
381
381
|
private setMessageHandlers;
|
|
382
382
|
/**
|
|
383
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
383
384
|
* @internal
|
|
384
385
|
*/
|
|
385
|
-
protected applyStashedOp(op:
|
|
386
|
+
protected applyStashedOp(op: unknown): unknown;
|
|
386
387
|
private serializeDirectory;
|
|
387
388
|
}
|
|
388
389
|
//# sourceMappingURL=directory.d.ts.map
|
package/lib/directory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACH,yBAAyB,EAE5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAa,MAAM,oCAAoC,CAAC;AAG/F,OAAO,EACH,UAAU,EAGV,kBAAkB,EAElB,gBAAgB,EAChB,sBAAsB,EAEzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEH,eAAe,EAElB,MAAM,eAAe,CAAC;AAoCvB;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,EA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AG,SAAS;IAiBxE;;;OAGG;IACH,SAAS,CAAC,aAAa,CACnB,UAAU,EAAE,gBAAgB,EAC5B,gBAAgB,CAAC,EAAE,iBAAiB,GACrC,qBAAqB;IAIxB;;;;;;OAMG;IACI,sBAAsB,CAAC,EAAE,EAAE,mBAAmB,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAItF;;;OAGG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAOxE;;;OAGG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAmCpD;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IASzG;;;MAGE;IACF,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAQpE;;;OAGG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;;;;;;OASG;IACH,OAAO,CAAC,SAAS;IAYjB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA4H1B;;;OAGG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO;IAQ9C,OAAO,CAAC,kBAAkB;CAgE7B"}
|
package/lib/directory.js
CHANGED
|
@@ -137,6 +137,8 @@ export class SharedDirectory extends SharedObject {
|
|
|
137
137
|
/**
|
|
138
138
|
* {@inheritDoc IDirectory.get}
|
|
139
139
|
*/
|
|
140
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
142
|
get(key) {
|
|
141
143
|
return this.root.get(key);
|
|
142
144
|
}
|
|
@@ -185,13 +187,18 @@ export class SharedDirectory extends SharedObject {
|
|
|
185
187
|
* Issue a callback on each entry under this IDirectory.
|
|
186
188
|
* @param callback - Callback to issue
|
|
187
189
|
*/
|
|
190
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
188
192
|
forEach(callback) {
|
|
193
|
+
// eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference
|
|
189
194
|
this.root.forEach(callback);
|
|
190
195
|
}
|
|
191
196
|
/**
|
|
192
197
|
* Get an iterator over the entries under this IDirectory.
|
|
193
198
|
* @returns The iterator
|
|
194
199
|
*/
|
|
200
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
195
202
|
[(_a = Symbol.toStringTag, Symbol.iterator)]() {
|
|
196
203
|
return this.root[Symbol.iterator]();
|
|
197
204
|
}
|
|
@@ -199,6 +206,8 @@ export class SharedDirectory extends SharedObject {
|
|
|
199
206
|
* Get an iterator over the entries under this IDirectory.
|
|
200
207
|
* @returns The iterator
|
|
201
208
|
*/
|
|
209
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
211
|
entries() {
|
|
203
212
|
return this.root.entries();
|
|
204
213
|
}
|
|
@@ -219,6 +228,8 @@ export class SharedDirectory extends SharedObject {
|
|
|
219
228
|
* Get an iterator over the values under this IDirectory.
|
|
220
229
|
* @returns The iterator
|
|
221
230
|
*/
|
|
231
|
+
// TODO: Use `unknown` instead (breaking change).
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
222
233
|
values() {
|
|
223
234
|
return this.root.values();
|
|
224
235
|
}
|
|
@@ -261,7 +272,7 @@ export class SharedDirectory extends SharedObject {
|
|
|
261
272
|
return this.root;
|
|
262
273
|
}
|
|
263
274
|
let currentSubDir = this.root;
|
|
264
|
-
const subdirs = absolutePath.
|
|
275
|
+
const subdirs = absolutePath.slice(1).split(posix.sep);
|
|
265
276
|
for (const subdir of subdirs) {
|
|
266
277
|
currentSubDir = currentSubDir.getSubDirectory(subdir);
|
|
267
278
|
if (!currentSubDir) {
|
|
@@ -475,7 +486,6 @@ export class SharedDirectory extends SharedObject {
|
|
|
475
486
|
parentSubdir.resubmitSubDirectoryMessage(op, localOpMetadata);
|
|
476
487
|
}
|
|
477
488
|
},
|
|
478
|
-
// eslint-disable-next-line max-len
|
|
479
489
|
applyStashedOp: (op) => {
|
|
480
490
|
const parentSubdir = this.getWorkingDirectory(op.path);
|
|
481
491
|
if (parentSubdir) {
|
|
@@ -497,7 +507,6 @@ export class SharedDirectory extends SharedObject {
|
|
|
497
507
|
parentSubdir.resubmitSubDirectoryMessage(op, localOpMetadata);
|
|
498
508
|
}
|
|
499
509
|
},
|
|
500
|
-
// eslint-disable-next-line max-len
|
|
501
510
|
applyStashedOp: (op) => {
|
|
502
511
|
const parentSubdir = this.getWorkingDirectory(op.path);
|
|
503
512
|
if (parentSubdir) {
|
|
@@ -507,6 +516,7 @@ export class SharedDirectory extends SharedObject {
|
|
|
507
516
|
});
|
|
508
517
|
}
|
|
509
518
|
/**
|
|
519
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
510
520
|
* @internal
|
|
511
521
|
*/
|
|
512
522
|
applyStashedOp(op) {
|
|
@@ -533,14 +543,13 @@ export class SharedDirectory extends SharedObject {
|
|
|
533
543
|
}
|
|
534
544
|
const result = {
|
|
535
545
|
type: value.type,
|
|
536
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
537
546
|
value: value.value && JSON.parse(value.value),
|
|
538
547
|
};
|
|
539
548
|
if (value.value && value.value.length >= MinValueSizeSeparateSnapshotBlob) {
|
|
540
549
|
const extraContent = {};
|
|
541
550
|
let largeContent = extraContent;
|
|
542
551
|
if (currentSubDir.absolutePath !== posix.sep) {
|
|
543
|
-
for (const dir of currentSubDir.absolutePath.
|
|
552
|
+
for (const dir of currentSubDir.absolutePath.slice(1).split(posix.sep)) {
|
|
544
553
|
const subDataObject = {};
|
|
545
554
|
largeContent.subdirectories = { [dir]: subDataObject };
|
|
546
555
|
largeContent = subDataObject;
|
|
@@ -573,6 +582,7 @@ export class SharedDirectory extends SharedObject {
|
|
|
573
582
|
return builder.getSummaryTree();
|
|
574
583
|
}
|
|
575
584
|
}
|
|
585
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
|
|
576
586
|
function isKeyEditLocalOpMetadata(metadata) {
|
|
577
587
|
return metadata !== undefined && typeof metadata.pendingMessageId === "number" && metadata.type === "edit";
|
|
578
588
|
}
|
|
@@ -591,6 +601,7 @@ function isDirectoryLocalOpMetadata(metadata) {
|
|
|
591
601
|
(metadata.type === "clear" && typeof metadata.previousStorage === "object") ||
|
|
592
602
|
(metadata.type === "createSubDir" && typeof metadata.previouslyExisted === "boolean"));
|
|
593
603
|
}
|
|
604
|
+
/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
|
|
594
605
|
/**
|
|
595
606
|
* Node of the directory tree.
|
|
596
607
|
* @sealed
|
|
@@ -830,6 +841,7 @@ class SubDirectory extends TypedEventEmitter {
|
|
|
830
841
|
*/
|
|
831
842
|
forEach(callback) {
|
|
832
843
|
this.throwIfDisposed();
|
|
844
|
+
// eslint-disable-next-line unicorn/no-array-for-each
|
|
833
845
|
this._storage.forEach((localValue, key, map) => {
|
|
834
846
|
callback(localValue.value, key, map);
|
|
835
847
|
});
|
|
@@ -1252,19 +1264,21 @@ class SubDirectory extends TypedEventEmitter {
|
|
|
1252
1264
|
map.delete(key);
|
|
1253
1265
|
}
|
|
1254
1266
|
}
|
|
1267
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
1255
1268
|
/**
|
|
1256
1269
|
* Rollback a local op
|
|
1257
1270
|
* @param op - The operation to rollback
|
|
1258
1271
|
* @param localOpMetadata - The local metadata associated with the op.
|
|
1259
1272
|
*/
|
|
1273
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1260
1274
|
rollback(op, localOpMetadata) {
|
|
1261
1275
|
if (!isDirectoryLocalOpMetadata(localOpMetadata)) {
|
|
1262
1276
|
throw new Error("Invalid localOpMetadata");
|
|
1263
1277
|
}
|
|
1264
1278
|
if (op.type === "clear" && localOpMetadata.type === "clear") {
|
|
1265
|
-
localOpMetadata.previousStorage.
|
|
1279
|
+
for (const [key, localValue] of localOpMetadata.previousStorage.entries()) {
|
|
1266
1280
|
this.setCore(key, localValue, true);
|
|
1267
|
-
}
|
|
1281
|
+
}
|
|
1268
1282
|
const lastPendingClearId = this.pendingClearMessageIds.pop();
|
|
1269
1283
|
if (lastPendingClearId === undefined || lastPendingClearId !== localOpMetadata.pendingMessageId) {
|
|
1270
1284
|
throw new Error("Rollback op does match last clear");
|
|
@@ -1298,6 +1312,7 @@ class SubDirectory extends TypedEventEmitter {
|
|
|
1298
1312
|
throw new Error("Unsupported op for rollback");
|
|
1299
1313
|
}
|
|
1300
1314
|
}
|
|
1315
|
+
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
|
|
1301
1316
|
/**
|
|
1302
1317
|
* Converts the given relative path into an absolute path.
|
|
1303
1318
|
* @param path - Relative path to convert
|
|
@@ -1375,14 +1390,14 @@ class SubDirectory extends TypedEventEmitter {
|
|
|
1375
1390
|
// Assuming the pendingKeys is small and the map is large
|
|
1376
1391
|
// we will get the value for the pendingKeys and clear the map
|
|
1377
1392
|
const temp = new Map();
|
|
1378
|
-
|
|
1393
|
+
for (const [key] of this.pendingKeys) {
|
|
1379
1394
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1380
1395
|
temp.set(key, this._storage.get(key));
|
|
1381
|
-
}
|
|
1396
|
+
}
|
|
1382
1397
|
this.clearCore(local);
|
|
1383
|
-
|
|
1398
|
+
for (const [key, value] of temp.entries()) {
|
|
1384
1399
|
this.setCore(key, value, true);
|
|
1385
|
-
}
|
|
1400
|
+
}
|
|
1386
1401
|
}
|
|
1387
1402
|
/**
|
|
1388
1403
|
* Clear implementation used for both locally sourced clears as well as incoming remote clears.
|