@fluidframework/sequence 0.59.2000 → 0.59.3000-67119
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/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +7 -7
- package/dist/intervalCollection.js.map +1 -1
- package/dist/localValues.js +4 -4
- package/dist/localValues.js.map +1 -1
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +9 -9
- package/dist/mapKernel.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sequence.d.ts +21 -3
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +39 -20
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.js +1 -1
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sharedIntervalCollection.js +5 -3
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sparsematrix.js +8 -8
- package/dist/sparsematrix.js.map +1 -1
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +1 -1
- package/lib/intervalCollection.js.map +1 -1
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sequence.d.ts +21 -3
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +26 -7
- package/lib/sequence.js.map +1 -1
- package/lib/sharedIntervalCollection.js +3 -1
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/lib/sparsematrix.js.map +1 -1
- package/package.json +72 -18
- package/src/intervalCollection.ts +11 -19
- package/src/mapKernel.ts +8 -8
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +42 -11
- package/src/sharedIntervalCollection.ts +1 -1
- package/src/sparsematrix.ts +1 -1
package/dist/mapKernel.js
CHANGED
|
@@ -180,7 +180,7 @@ class MapKernel {
|
|
|
180
180
|
}
|
|
181
181
|
// Create a local value and serialize it.
|
|
182
182
|
const localValue = this.localValueMaker.fromInMemory(value);
|
|
183
|
-
const serializableValue = localValues_1.makeSerializable(localValue, this.serializer, this.handle);
|
|
183
|
+
const serializableValue = (0, localValues_1.makeSerializable)(localValue, this.serializer, this.handle);
|
|
184
184
|
// Set the value locally.
|
|
185
185
|
this.setCore(key, localValue, true, undefined);
|
|
186
186
|
// If we are not attached, don't submit the op.
|
|
@@ -203,7 +203,7 @@ class MapKernel {
|
|
|
203
203
|
// TODO ideally we could use makeSerialized in this case as well. But the interval
|
|
204
204
|
// collection has assumptions of attach being called prior. Given the IFluidSerializer it
|
|
205
205
|
// may be possible to remove custom value type serialization entirely.
|
|
206
|
-
const transformedValue = shared_object_base_1.makeHandlesSerializable(params, this.serializer, this.handle);
|
|
206
|
+
const transformedValue = (0, shared_object_base_1.makeHandlesSerializable)(params, this.serializer, this.handle);
|
|
207
207
|
// Set the value locally.
|
|
208
208
|
this.setCore(key, localValue, true, undefined);
|
|
209
209
|
// If we are not attached, don't submit the op.
|
|
@@ -270,7 +270,7 @@ class MapKernel {
|
|
|
270
270
|
getSerializableStorage(serializer) {
|
|
271
271
|
const serializableMapData = {};
|
|
272
272
|
this.data.forEach((localValue, key) => {
|
|
273
|
-
serializableMapData[key] = localValues_1.makeSerializable(localValue, serializer, this.handle);
|
|
273
|
+
serializableMapData[key] = (0, localValues_1.makeSerializable)(localValue, serializer, this.handle);
|
|
274
274
|
});
|
|
275
275
|
return serializableMapData;
|
|
276
276
|
}
|
|
@@ -430,7 +430,7 @@ class MapKernel {
|
|
|
430
430
|
needProcessKeyOperation(op, local, localOpMetadata) {
|
|
431
431
|
if (this.pendingClearMessageId !== -1) {
|
|
432
432
|
if (local) {
|
|
433
|
-
common_utils_1.assert((localOpMetadata === null || localOpMetadata === void 0 ? void 0 : localOpMetadata.pendingClearMessageId) !== undefined
|
|
433
|
+
(0, common_utils_1.assert)((localOpMetadata === null || localOpMetadata === void 0 ? void 0 : localOpMetadata.pendingClearMessageId) !== undefined
|
|
434
434
|
&& localOpMetadata.pendingClearMessageId < this.pendingClearMessageId, 0x1f1 /* "Received out of order op when there is an unacked clear message" */);
|
|
435
435
|
}
|
|
436
436
|
// If we have an unacked clear, we can ignore all ops.
|
|
@@ -440,7 +440,7 @@ class MapKernel {
|
|
|
440
440
|
// Found an unacked op. Clear it from the map if the pendingMessageId in the map matches this message's
|
|
441
441
|
// and don't process the op.
|
|
442
442
|
if (local) {
|
|
443
|
-
common_utils_1.assert(localOpMetadata !== undefined, 0x1f2 /* `pendingMessageId is missing from the local client's ${op.type} operation` */);
|
|
443
|
+
(0, common_utils_1.assert)(localOpMetadata !== undefined, 0x1f2 /* `pendingMessageId is missing from the local client's ${op.type} operation` */);
|
|
444
444
|
const pendingMessageId = localOpMetadata.pendingMessageId;
|
|
445
445
|
const pendingKeyMessageId = this.pendingKeys.get(op.key);
|
|
446
446
|
if (pendingKeyMessageId === pendingMessageId) {
|
|
@@ -461,7 +461,7 @@ class MapKernel {
|
|
|
461
461
|
messageHandlers.set("clear", {
|
|
462
462
|
process: (op, local, message, localOpMetadata) => {
|
|
463
463
|
if (local) {
|
|
464
|
-
common_utils_1.assert(localOpMetadata !== undefined, 0x1f3 /* "pendingMessageId is missing from the local client's clear operation" */);
|
|
464
|
+
(0, common_utils_1.assert)(localOpMetadata !== undefined, 0x1f3 /* "pendingMessageId is missing from the local client's clear operation" */);
|
|
465
465
|
const pendingMessageId = localOpMetadata === null || localOpMetadata === void 0 ? void 0 : localOpMetadata.pendingMessageId;
|
|
466
466
|
if (this.pendingClearMessageId === pendingMessageId) {
|
|
467
467
|
this.pendingClearMessageId = -1;
|
|
@@ -530,7 +530,7 @@ class MapKernel {
|
|
|
530
530
|
}
|
|
531
531
|
const handler = localValue.getOpHandler(op.value.opName);
|
|
532
532
|
const previousValue = localValue.value;
|
|
533
|
-
const translatedValue = shared_object_base_1.parseHandles(op.value.value, this.serializer);
|
|
533
|
+
const translatedValue = (0, shared_object_base_1.parseHandles)(op.value.value, this.serializer);
|
|
534
534
|
handler.process(previousValue, translatedValue, local, message);
|
|
535
535
|
const event = { key: op.key, previousValue };
|
|
536
536
|
this.eventEmitter.emit("valueChanged", event, local, message, this.eventEmitter);
|
|
@@ -539,7 +539,7 @@ class MapKernel {
|
|
|
539
539
|
this.submitMessage(op, { lastProcessedSeq: this.lastProcessedSeq });
|
|
540
540
|
},
|
|
541
541
|
getStashedOpLocalMetadata: (op) => {
|
|
542
|
-
common_utils_1.assert(false, 0x016 /* "apply stashed op not implemented for custom value type ops" */);
|
|
542
|
+
(0, common_utils_1.assert)(false, 0x016 /* "apply stashed op not implemented for custom value type ops" */);
|
|
543
543
|
},
|
|
544
544
|
});
|
|
545
545
|
return messageHandlers;
|
|
@@ -578,7 +578,7 @@ class MapKernel {
|
|
|
578
578
|
*/
|
|
579
579
|
makeMapValueOpEmitter(key) {
|
|
580
580
|
const emit = (opName, previousValue, params) => {
|
|
581
|
-
const translatedParams = shared_object_base_1.makeHandlesSerializable(params, this.serializer, this.handle);
|
|
581
|
+
const translatedParams = (0, shared_object_base_1.makeHandlesSerializable)(params, this.serializer, this.handle);
|
|
582
582
|
const op = {
|
|
583
583
|
key,
|
|
584
584
|
type: "act",
|
package/dist/mapKernel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapKernel.js","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2EAAwH;AACxH,+DAAyE;AACzE,+CAKuB;AAuIvB;;GAEG;AACH,MAAa,SAAS;IAyClB;;;;;;;;OAQG;IACH,YACqB,UAA4B,EAC5B,MAAoB,EACpB,aAA2E,EAC3E,UAAyB,EAC1C,UAAuC,EACvB,eAAe,IAAI,gCAAiB,EAAoB;QALvD,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AAE,GAA2B;gBAC/B,GAAG;gBACH,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE;oBACH,MAAM;oBACN,KAAK,EAAE,gBAAgB;iBAC1B;aACJ,CAAC;YACF,6EAA6E;YAC7E,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,EAAC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAC,CAAC,CAAC;YAElE,MAAM,KAAK,GAAkB,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YACpD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjF,CAAC,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC;IACpB,CAAC;CACJ;AAzrBD,8BAyrBC","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 { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IFluidSerializer, makeHandlesSerializable, parseHandles, ValueType } from \"@fluidframework/shared-object-base\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n ILocalValue,\n LocalValueMaker,\n makeSerializable,\n ValueTypeLocalValue,\n} from \"./localValues\";\nimport {\n ISerializableValue,\n ISerializedValue,\n IValueChanged,\n IValueOpEmitter,\n IValueType,\n IValueTypeCreator,\n IValueTypeOperationValue,\n ISharedMapEvents,\n} from \"./mapKernelInterfaces\";\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 message - The full message. Not provided for stashed ops.\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 message: ISequencedDocumentMessage | undefined,\n localOpMetadata: IMapMessageLocalMetadata,\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): void;\n\n getStashedOpLocalMetadata(op: IMapOperation): unknown;\n}\n\ninterface IMapMessageLocalMetadata{\n pendingClearMessageId?: number,\n pendingMessageId?: number,\n lastProcessedSeq: number\n}\n\n/**\n * Describes an operation specific to a value type.\n */\nexport interface IMapValueTypeOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"act\";\n\n /**\n * Map key being modified.\n */\n key: string;\n\n /**\n * Value of the operation, specific to the value type.\n * @alpha\n */\n value: IValueTypeOperationValue;\n}\n\n/**\n * Operation indicating a value should be set for a key.\n */\nexport interface IMapSetOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"set\";\n\n /**\n * Map key being modified.\n */\n key: string;\n\n /**\n * Value to be set on the key.\n */\n value: ISerializableValue;\n}\n\n/**\n * Operation indicating a key should be deleted from the map.\n */\nexport interface IMapDeleteOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"delete\";\n\n /**\n * Map key being modified.\n */\n key: string;\n}\n\n/**\n * Map key operations are one of several types.\n */\nexport type IMapKeyOperation = IMapValueTypeOperation | IMapSetOperation | IMapDeleteOperation;\n\n/**\n * Operation indicating the map should be cleared.\n */\nexport interface IMapClearOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"clear\";\n}\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 * Directly used in JSON.stringify, direct result from JSON.parse\n */\nexport interface IMapDataObjectSerializable {\n [key: string]: ISerializableValue;\n}\n\nexport interface IMapDataObjectSerialized {\n [key: string]: ISerializedValue;\n}\n\n/**\n * A SharedMap is a map-like distributed data structure.\n */\nexport class MapKernel implements IValueTypeCreator {\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 unacked ops.\n */\n private pendingMessageId: number = -1;\n\n /**\n * If a clear has been performed locally but not yet ack'd from the server, then this stores the pending id\n * of that clear operation. Otherwise, is -1.\n */\n private pendingClearMessageId: number = -1;\n\n /**\n * Object to create encapsulations of the values stored in the map.\n */\n private readonly localValueMaker: LocalValueMaker;\n\n private lastProcessedSeq: number = -1;\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: IMapMessageLocalMetadata) => void,\n private readonly isAttached: () => boolean,\n valueTypes: Readonly<IValueType<any>[]>,\n public readonly eventEmitter = new TypedEventEmitter<ISharedMapEvents>(),\n ) {\n this.localValueMaker = new LocalValueMaker(serializer);\n this.messageHandlers = this.getMessageHandlers();\n for (const type of valueTypes) {\n this.localValueMaker.registerValueType(type);\n }\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 if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: [nextVal.value[0], nextVal.value[1].value], done: false };\n }\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 if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: nextVal.value.value, done: false };\n }\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 if (!this.data.has(key)) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const localValue = this.data.get(key)!;\n\n return localValue.value as T;\n }\n\n /**\n * {@inheritDoc ISharedMap.wait}\n */\n public async wait<T = any>(key: string): Promise<T> {\n // Return immediately if the value already exists\n if (this.has(key)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.get<T>(key)!;\n }\n\n // Otherwise subscribe to changes\n return new Promise<T>((resolve) => {\n const callback = (changed: IValueChanged) => {\n if (key === changed.key) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n resolve(this.get<T>(changed.key)!);\n this.eventEmitter.removeListener(\"create\", callback);\n }\n };\n\n this.eventEmitter.on(\"create\", callback);\n });\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 this.setCore(\n key,\n localValue,\n true,\n undefined,\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);\n }\n\n /**\n * {@inheritDoc IValueTypeCreator.createValueType}\n */\n public createValueType(key: string, type: string, params: any) {\n // Create a local value and serialize it.\n const localValue = this.localValueMaker.makeValueType(type, this.makeMapValueOpEmitter(key), params);\n\n // TODO ideally we could use makeSerialized in this case as well. But the interval\n // collection has assumptions of attach being called prior. Given the IFluidSerializer it\n // may be possible to remove custom value type serialization entirely.\n const transformedValue = makeHandlesSerializable(\n params,\n this.serializer,\n this.handle);\n\n // Set the value locally.\n this.setCore(\n key,\n localValue,\n true,\n undefined,\n );\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return this;\n }\n\n // This is a special form of serialized valuetype only used for set, containing info for initialization.\n // After initialization, the serialized form will need to come from the .store of the value type's factory.\n const serializableValue = { type, value: transformedValue };\n const op: IMapSetOperation = {\n key,\n type: \"set\",\n value: serializableValue,\n };\n this.submitMapKeyMessage(op);\n return this;\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 successfullyRemoved = this.deleteCore(key, true, undefined);\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return successfullyRemoved;\n }\n\n const op: IMapDeleteOperation = {\n key,\n type: \"delete\",\n };\n this.submitMapKeyMessage(op);\n\n return successfullyRemoved;\n }\n\n /**\n * Clear all data from the map.\n */\n public clear(): void {\n // Clear the data locally first.\n this.clearCore(true, undefined);\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);\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 type: string = op.type;\n if (this.messageHandlers.has(type)) {\n const mapLocalMetadata: Partial<IMapMessageLocalMetadata> = localOpMetadata;\n // we don't know how to rebase these operations, so if any other op has come in\n // we will fail.\n if(this.lastProcessedSeq !== mapLocalMetadata?.lastProcessedSeq) {\n throw new Error(\"SharedInterval does not support reconnect in presence of external changes\");\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.messageHandlers.get(type)!.submit(op as IMapOperation);\n return true;\n }\n return false;\n }\n\n public tryGetStashedOpLocalMetadata(op: any): unknown {\n const type: string = op.type;\n if (this.messageHandlers.has(type)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op as IMapOperation);\n }\n throw new Error(\"no apply stashed op handler\");\n }\n\n /**\n * Process the given op if a handler is registered.\n * @param message - 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 message: ISequencedDocumentMessage | undefined,\n localOpMetadata: unknown,\n ): boolean {\n // track the seq of every incoming message, so we can detect if any\n // changes happened during a resubmit\n this.lastProcessedSeq = message.sequenceNumber;\n if (this.messageHandlers.has(op.type)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.messageHandlers\n .get(op.type)!\n .process(op, local, message, localOpMetadata as IMapMessageLocalMetadata);\n return true;\n }\n return false;\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 * @param op - The message if from a remote set, or null if from a local set\n */\n private setCore(key: string, value: ILocalValue, local: boolean, op: ISequencedDocumentMessage | undefined): void {\n const previousValue = this.get(key);\n this.data.set(key, value);\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"create\", event, local, op, this.eventEmitter);\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 * @param op - The message if from a remote clear, or null if from a local clear\n */\n private clearCore(local: boolean, op: ISequencedDocumentMessage | undefined): void {\n this.data.clear();\n this.eventEmitter.emit(\"clear\", local, op, 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 * @param op - The message if from a remote delete, or null if from a local delete\n * @returns True if the key existed and was deleted, false if it did not exist\n */\n private deleteCore(key: string, local: boolean, op: ISequencedDocumentMessage | undefined): boolean {\n const previousValue = this.get(key);\n const successfullyRemoved = this.data.delete(key);\n if (successfullyRemoved) {\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, local, op, this.eventEmitter);\n }\n return successfullyRemoved;\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.data.clear();\n temp.forEach((value, key) => {\n this.data.set(key, value);\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 return this.localValueMaker.fromSerializableValueType(\n serializable,\n this.makeMapValueOpEmitter(key),\n );\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 message - The message\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: IMapMessageLocalMetadata,\n ): boolean {\n if (this.pendingClearMessageId !== -1) {\n if (local) {\n assert(localOpMetadata?.pendingClearMessageId !== undefined\n && localOpMetadata.pendingClearMessageId < this.pendingClearMessageId,\n 0x1f1 /* \"Received out of order op when there is an unacked clear message\" */);\n }\n // If we have an unacked clear, we can ignore all ops.\n return false;\n }\n\n if (this.pendingKeys.has(op.key)) {\n // Found an unacked 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,\n 0x1f2 /* `pendingMessageId is missing from the local client's ${op.type} operation` */);\n const pendingMessageId = localOpMetadata.pendingMessageId;\n const pendingKeyMessageId = this.pendingKeys.get(op.key);\n if (pendingKeyMessageId === pendingMessageId) {\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, message, localOpMetadata) => {\n if (local) {\n assert(localOpMetadata !== undefined,\n 0x1f3 /* \"pendingMessageId is missing from the local client's clear operation\" */);\n const pendingMessageId = localOpMetadata?.pendingMessageId;\n if (this.pendingClearMessageId === pendingMessageId) {\n this.pendingClearMessageId = -1;\n }\n return;\n }\n if (this.pendingKeys.size !== 0) {\n this.clearExceptPendingKeys();\n return;\n }\n this.clearCore(local, message);\n },\n submit: (op: IMapClearOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n this.submitMapClearMessage(op);\n },\n getStashedOpLocalMetadata: (op: IMapClearOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n return this.getMapClearMessageLocalMetadata(op);\n },\n });\n messageHandlers.set(\n \"delete\",\n {\n process: (op: IMapDeleteOperation, local, message, localOpMetadata) => {\n if (!this.needProcessKeyOperation(op, local, localOpMetadata)) {\n return;\n }\n this.deleteCore(op.key, local, message);\n },\n submit: (op: IMapDeleteOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n this.submitMapKeyMessage(op);\n },\n getStashedOpLocalMetadata: (op: IMapDeleteOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n return this.getMapKeyMessageLocalMetadata(op);\n },\n });\n messageHandlers.set(\n \"set\",\n {\n process: (op: IMapSetOperation, local, message, 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, message);\n },\n submit: (op: IMapSetOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n this.submitMapKeyMessage(op);\n },\n getStashedOpLocalMetadata: (op: IMapSetOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n return this.getMapKeyMessageLocalMetadata(op);\n },\n });\n\n // Ops with type \"act\" describe actions taken by custom value type handlers of whatever item is\n // being addressed. These custom handlers can be retrieved from the ValueTypeLocalValue which has\n // stashed its valueType (and therefore its handlers). We also emit a valueChanged for anyone\n // watching for manipulations of that item.\n messageHandlers.set(\n \"act\",\n {\n process: (op: IMapValueTypeOperation, local, message, localOpMetadata) => {\n // Local value might not exist if we deleted it\n const localValue = this.data.get(op.key) as ValueTypeLocalValue;\n if (!localValue) {\n return;\n }\n\n const handler = localValue.getOpHandler(op.value.opName);\n const previousValue = localValue.value;\n const translatedValue = parseHandles(\n op.value.value,\n this.serializer);\n handler.process(previousValue, translatedValue, local, message);\n const event: IValueChanged = { key: op.key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, local, message, this.eventEmitter);\n },\n submit: (op: IMapValueTypeOperation) => {\n this.submitMessage(op, {lastProcessedSeq: this.lastProcessedSeq});\n },\n getStashedOpLocalMetadata: (op: IMapValueTypeOperation) => {\n assert(false, 0x016 /* \"apply stashed op not implemented for custom value type ops\" */);\n },\n });\n\n return messageHandlers;\n }\n\n private getMapClearMessageLocalMetadata(op: IMapClearOperation): number {\n const pendingMessageId = ++this.pendingMessageId;\n this.pendingClearMessageId = 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): void {\n const pendingClearMessageId = this.getMapClearMessageLocalMetadata(op);\n this.submitMessage(op, {pendingClearMessageId, lastProcessedSeq: this.lastProcessedSeq});\n }\n\n private getMapKeyMessageLocalMetadata(op: IMapKeyOperation): number {\n const pendingMessageId = ++this.pendingMessageId;\n this.pendingKeys.set(op.key, pendingMessageId);\n return pendingMessageId;\n }\n\n /**\n * Submit a map key message to remote clients.\n * @param op - The map key message\n */\n private submitMapKeyMessage(op: IMapKeyOperation): void {\n const pendingMessageId = this.getMapKeyMessageLocalMetadata(op);\n this.submitMessage(op, {pendingMessageId, lastProcessedSeq: this.lastProcessedSeq});\n }\n\n /**\n * Create an emitter for a value type to emit ops from the given key.\n * @alpha\n * @param key - The key of the map that the value type will be stored on\n * @returns A value op emitter for the given key\n */\n private makeMapValueOpEmitter(key: string): IValueOpEmitter {\n const emit = (opName: string, previousValue: any, params: any) => {\n const translatedParams = makeHandlesSerializable(\n params,\n this.serializer,\n this.handle);\n\n const op: IMapValueTypeOperation = {\n key,\n type: \"act\",\n value: {\n opName,\n value: translatedParams,\n },\n };\n // Send the localOpMetadata as undefined because we don't care about the ack.\n this.submitMessage(op, {lastProcessedSeq: this.lastProcessedSeq});\n\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, true, null, this.eventEmitter);\n };\n\n return { emit };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mapK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EAAE,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC1F,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,GAAW;QACrC,MAAM,IAAI,GAAG,CAAC,MAAc,EAAE,aAAkB,EAAE,MAAW,EAAE,EAAE;YAC7D,MAAM,gBAAgB,GAAG,IAAA,4CAAuB,EAC5C,MAAM,EACN,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,MAAM,CAAC,CAAC;YAEjB,MAAM,EAAE,GAA2B;gBAC/B,GAAG;gBACH,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE;oBACH,MAAM;oBACN,KAAK,EAAE,gBAAgB;iBAC1B;aACJ,CAAC;YACF,6EAA6E;YAC7E,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;YAEpE,MAAM,KAAK,GAAkB,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YACpD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjF,CAAC,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC;IACpB,CAAC;CACJ;AAzrBD,8BAyrBC","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 { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IFluidSerializer, makeHandlesSerializable, parseHandles, ValueType } from \"@fluidframework/shared-object-base\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n ILocalValue,\n LocalValueMaker,\n makeSerializable,\n ValueTypeLocalValue,\n} from \"./localValues\";\nimport {\n ISerializableValue,\n ISerializedValue,\n IValueChanged,\n IValueOpEmitter,\n IValueType,\n IValueTypeCreator,\n IValueTypeOperationValue,\n ISharedMapEvents,\n} from \"./mapKernelInterfaces\";\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 message - The full message. Not provided for stashed ops.\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 message: ISequencedDocumentMessage | undefined,\n localOpMetadata: IMapMessageLocalMetadata,\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): void;\n\n getStashedOpLocalMetadata(op: IMapOperation): unknown;\n}\n\ninterface IMapMessageLocalMetadata{\n pendingClearMessageId?: number;\n pendingMessageId?: number;\n lastProcessedSeq: number;\n}\n\n/**\n * Describes an operation specific to a value type.\n */\nexport interface IMapValueTypeOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"act\";\n\n /**\n * Map key being modified.\n */\n key: string;\n\n /**\n * Value of the operation, specific to the value type.\n * @alpha\n */\n value: IValueTypeOperationValue;\n}\n\n/**\n * Operation indicating a value should be set for a key.\n */\nexport interface IMapSetOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"set\";\n\n /**\n * Map key being modified.\n */\n key: string;\n\n /**\n * Value to be set on the key.\n */\n value: ISerializableValue;\n}\n\n/**\n * Operation indicating a key should be deleted from the map.\n */\nexport interface IMapDeleteOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"delete\";\n\n /**\n * Map key being modified.\n */\n key: string;\n}\n\n/**\n * Map key operations are one of several types.\n */\nexport type IMapKeyOperation = IMapValueTypeOperation | IMapSetOperation | IMapDeleteOperation;\n\n/**\n * Operation indicating the map should be cleared.\n */\nexport interface IMapClearOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"clear\";\n}\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 * Directly used in JSON.stringify, direct result from JSON.parse\n */\nexport interface IMapDataObjectSerializable {\n [key: string]: ISerializableValue;\n}\n\nexport interface IMapDataObjectSerialized {\n [key: string]: ISerializedValue;\n}\n\n/**\n * A SharedMap is a map-like distributed data structure.\n */\nexport class MapKernel implements IValueTypeCreator {\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 unacked ops.\n */\n private pendingMessageId: number = -1;\n\n /**\n * If a clear has been performed locally but not yet ack'd from the server, then this stores the pending id\n * of that clear operation. Otherwise, is -1.\n */\n private pendingClearMessageId: number = -1;\n\n /**\n * Object to create encapsulations of the values stored in the map.\n */\n private readonly localValueMaker: LocalValueMaker;\n\n private lastProcessedSeq: number = -1;\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: IMapMessageLocalMetadata) => void,\n private readonly isAttached: () => boolean,\n valueTypes: Readonly<IValueType<any>[]>,\n public readonly eventEmitter = new TypedEventEmitter<ISharedMapEvents>(),\n ) {\n this.localValueMaker = new LocalValueMaker(serializer);\n this.messageHandlers = this.getMessageHandlers();\n for (const type of valueTypes) {\n this.localValueMaker.registerValueType(type);\n }\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 if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: [nextVal.value[0], nextVal.value[1].value], done: false };\n }\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 if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: nextVal.value.value, done: false };\n }\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 if (!this.data.has(key)) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const localValue = this.data.get(key)!;\n\n return localValue.value as T;\n }\n\n /**\n * {@inheritDoc ISharedMap.wait}\n */\n public async wait<T = any>(key: string): Promise<T> {\n // Return immediately if the value already exists\n if (this.has(key)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.get<T>(key)!;\n }\n\n // Otherwise subscribe to changes\n return new Promise<T>((resolve) => {\n const callback = (changed: IValueChanged) => {\n if (key === changed.key) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n resolve(this.get<T>(changed.key)!);\n this.eventEmitter.removeListener(\"create\", callback);\n }\n };\n\n this.eventEmitter.on(\"create\", callback);\n });\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 this.setCore(\n key,\n localValue,\n true,\n undefined,\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);\n }\n\n /**\n * {@inheritDoc IValueTypeCreator.createValueType}\n */\n public createValueType(key: string, type: string, params: any) {\n // Create a local value and serialize it.\n const localValue = this.localValueMaker.makeValueType(type, this.makeMapValueOpEmitter(key), params);\n\n // TODO ideally we could use makeSerialized in this case as well. But the interval\n // collection has assumptions of attach being called prior. Given the IFluidSerializer it\n // may be possible to remove custom value type serialization entirely.\n const transformedValue = makeHandlesSerializable(\n params,\n this.serializer,\n this.handle);\n\n // Set the value locally.\n this.setCore(\n key,\n localValue,\n true,\n undefined,\n );\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return this;\n }\n\n // This is a special form of serialized valuetype only used for set, containing info for initialization.\n // After initialization, the serialized form will need to come from the .store of the value type's factory.\n const serializableValue = { type, value: transformedValue };\n const op: IMapSetOperation = {\n key,\n type: \"set\",\n value: serializableValue,\n };\n this.submitMapKeyMessage(op);\n return this;\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 successfullyRemoved = this.deleteCore(key, true, undefined);\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return successfullyRemoved;\n }\n\n const op: IMapDeleteOperation = {\n key,\n type: \"delete\",\n };\n this.submitMapKeyMessage(op);\n\n return successfullyRemoved;\n }\n\n /**\n * Clear all data from the map.\n */\n public clear(): void {\n // Clear the data locally first.\n this.clearCore(true, undefined);\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);\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 type: string = op.type;\n if (this.messageHandlers.has(type)) {\n const mapLocalMetadata: Partial<IMapMessageLocalMetadata> = localOpMetadata;\n // we don't know how to rebase these operations, so if any other op has come in\n // we will fail.\n if (this.lastProcessedSeq !== mapLocalMetadata?.lastProcessedSeq) {\n throw new Error(\"SharedInterval does not support reconnect in presence of external changes\");\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.messageHandlers.get(type)!.submit(op as IMapOperation);\n return true;\n }\n return false;\n }\n\n public tryGetStashedOpLocalMetadata(op: any): unknown {\n const type: string = op.type;\n if (this.messageHandlers.has(type)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op as IMapOperation);\n }\n throw new Error(\"no apply stashed op handler\");\n }\n\n /**\n * Process the given op if a handler is registered.\n * @param message - 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 message: ISequencedDocumentMessage | undefined,\n localOpMetadata: unknown,\n ): boolean {\n // track the seq of every incoming message, so we can detect if any\n // changes happened during a resubmit\n this.lastProcessedSeq = message.sequenceNumber;\n if (this.messageHandlers.has(op.type)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.messageHandlers\n .get(op.type)!\n .process(op, local, message, localOpMetadata as IMapMessageLocalMetadata);\n return true;\n }\n return false;\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 * @param op - The message if from a remote set, or null if from a local set\n */\n private setCore(key: string, value: ILocalValue, local: boolean, op: ISequencedDocumentMessage | undefined): void {\n const previousValue = this.get(key);\n this.data.set(key, value);\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"create\", event, local, op, this.eventEmitter);\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 * @param op - The message if from a remote clear, or null if from a local clear\n */\n private clearCore(local: boolean, op: ISequencedDocumentMessage | undefined): void {\n this.data.clear();\n this.eventEmitter.emit(\"clear\", local, op, 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 * @param op - The message if from a remote delete, or null if from a local delete\n * @returns True if the key existed and was deleted, false if it did not exist\n */\n private deleteCore(key: string, local: boolean, op: ISequencedDocumentMessage | undefined): boolean {\n const previousValue = this.get(key);\n const successfullyRemoved = this.data.delete(key);\n if (successfullyRemoved) {\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, local, op, this.eventEmitter);\n }\n return successfullyRemoved;\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.data.clear();\n temp.forEach((value, key) => {\n this.data.set(key, value);\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 return this.localValueMaker.fromSerializableValueType(\n serializable,\n this.makeMapValueOpEmitter(key),\n );\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 message - The message\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: IMapMessageLocalMetadata,\n ): boolean {\n if (this.pendingClearMessageId !== -1) {\n if (local) {\n assert(localOpMetadata?.pendingClearMessageId !== undefined\n && localOpMetadata.pendingClearMessageId < this.pendingClearMessageId,\n 0x1f1 /* \"Received out of order op when there is an unacked clear message\" */);\n }\n // If we have an unacked clear, we can ignore all ops.\n return false;\n }\n\n if (this.pendingKeys.has(op.key)) {\n // Found an unacked 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,\n 0x1f2 /* `pendingMessageId is missing from the local client's ${op.type} operation` */);\n const pendingMessageId = localOpMetadata.pendingMessageId;\n const pendingKeyMessageId = this.pendingKeys.get(op.key);\n if (pendingKeyMessageId === pendingMessageId) {\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, message, localOpMetadata) => {\n if (local) {\n assert(localOpMetadata !== undefined,\n 0x1f3 /* \"pendingMessageId is missing from the local client's clear operation\" */);\n const pendingMessageId = localOpMetadata?.pendingMessageId;\n if (this.pendingClearMessageId === pendingMessageId) {\n this.pendingClearMessageId = -1;\n }\n return;\n }\n if (this.pendingKeys.size !== 0) {\n this.clearExceptPendingKeys();\n return;\n }\n this.clearCore(local, message);\n },\n submit: (op: IMapClearOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n this.submitMapClearMessage(op);\n },\n getStashedOpLocalMetadata: (op: IMapClearOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n return this.getMapClearMessageLocalMetadata(op);\n },\n });\n messageHandlers.set(\n \"delete\",\n {\n process: (op: IMapDeleteOperation, local, message, localOpMetadata) => {\n if (!this.needProcessKeyOperation(op, local, localOpMetadata)) {\n return;\n }\n this.deleteCore(op.key, local, message);\n },\n submit: (op: IMapDeleteOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n this.submitMapKeyMessage(op);\n },\n getStashedOpLocalMetadata: (op: IMapDeleteOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n return this.getMapKeyMessageLocalMetadata(op);\n },\n });\n messageHandlers.set(\n \"set\",\n {\n process: (op: IMapSetOperation, local, message, 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, message);\n },\n submit: (op: IMapSetOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n this.submitMapKeyMessage(op);\n },\n getStashedOpLocalMetadata: (op: IMapSetOperation) => {\n // We don't reuse the metadata but send a new one on each submit.\n return this.getMapKeyMessageLocalMetadata(op);\n },\n });\n\n // Ops with type \"act\" describe actions taken by custom value type handlers of whatever item is\n // being addressed. These custom handlers can be retrieved from the ValueTypeLocalValue which has\n // stashed its valueType (and therefore its handlers). We also emit a valueChanged for anyone\n // watching for manipulations of that item.\n messageHandlers.set(\n \"act\",\n {\n process: (op: IMapValueTypeOperation, local, message, localOpMetadata) => {\n // Local value might not exist if we deleted it\n const localValue = this.data.get(op.key) as ValueTypeLocalValue;\n if (!localValue) {\n return;\n }\n\n const handler = localValue.getOpHandler(op.value.opName);\n const previousValue = localValue.value;\n const translatedValue = parseHandles(\n op.value.value,\n this.serializer);\n handler.process(previousValue, translatedValue, local, message);\n const event: IValueChanged = { key: op.key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, local, message, this.eventEmitter);\n },\n submit: (op: IMapValueTypeOperation) => {\n this.submitMessage(op, { lastProcessedSeq: this.lastProcessedSeq });\n },\n getStashedOpLocalMetadata: (op: IMapValueTypeOperation) => {\n assert(false, 0x016 /* \"apply stashed op not implemented for custom value type ops\" */);\n },\n });\n\n return messageHandlers;\n }\n\n private getMapClearMessageLocalMetadata(op: IMapClearOperation): number {\n const pendingMessageId = ++this.pendingMessageId;\n this.pendingClearMessageId = 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): void {\n const pendingClearMessageId = this.getMapClearMessageLocalMetadata(op);\n this.submitMessage(op, { pendingClearMessageId, lastProcessedSeq: this.lastProcessedSeq });\n }\n\n private getMapKeyMessageLocalMetadata(op: IMapKeyOperation): number {\n const pendingMessageId = ++this.pendingMessageId;\n this.pendingKeys.set(op.key, pendingMessageId);\n return pendingMessageId;\n }\n\n /**\n * Submit a map key message to remote clients.\n * @param op - The map key message\n */\n private submitMapKeyMessage(op: IMapKeyOperation): void {\n const pendingMessageId = this.getMapKeyMessageLocalMetadata(op);\n this.submitMessage(op, { pendingMessageId, lastProcessedSeq: this.lastProcessedSeq });\n }\n\n /**\n * Create an emitter for a value type to emit ops from the given key.\n * @alpha\n * @param key - The key of the map that the value type will be stored on\n * @returns A value op emitter for the given key\n */\n private makeMapValueOpEmitter(key: string): IValueOpEmitter {\n const emit = (opName: string, previousValue: any, params: any) => {\n const translatedParams = makeHandlesSerializable(\n params,\n this.serializer,\n this.handle);\n\n const op: IMapValueTypeOperation = {\n key,\n type: \"act\",\n value: {\n opName,\n value: translatedParams,\n },\n };\n // Send the localOpMetadata as undefined because we don't care about the ack.\n this.submitMessage(op, { lastProcessedSeq: this.lastProcessedSeq });\n\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, true, null, this.eventEmitter);\n };\n\n return { emit };\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/sequence";
|
|
8
|
-
export declare const pkgVersion = "0.59.
|
|
8
|
+
export declare const pkgVersion = "0.59.3000-67119";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,6BAA6B,CAAC;AAClD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,6BAA6B,CAAC;AAClD,eAAO,MAAM,UAAU,oBAAoB,CAAC"}
|
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/sequence";
|
|
11
|
-
exports.pkgVersion = "0.59.
|
|
11
|
+
exports.pkgVersion = "0.59.3000-67119";
|
|
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,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,iBAAiB,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/sequence\";\nexport const pkgVersion = \"0.59.3000-67119\";\n"]}
|
package/dist/sequence.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Deferred } from "@fluidframework/common-utils";
|
|
6
6
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
|
|
8
|
-
import { Client, ICombiningOp, IJSONSegment, IMergeTreeGroupMsg, IMergeTreeOp, IMergeTreeRemoveMsg, IRelativePosition, ISegment, ISegmentAction, LocalReference, PropertySet, RangeStackMap, ReferencePosition, ReferenceType
|
|
8
|
+
import { Client, ICombiningOp, IJSONSegment, IMergeTreeGroupMsg, IMergeTreeOp, IMergeTreeRemoveMsg, IRelativePosition, ISegment, ISegmentAction, LocalReference, PropertySet, RangeStackMap, ReferencePosition, ReferenceType } from "@fluidframework/merge-tree";
|
|
9
9
|
import { IFluidSerializer, SharedObject, ISharedObjectEvents, SummarySerializer } from "@fluidframework/shared-object-base";
|
|
10
10
|
import { IEventThisPlaceHolder } from "@fluidframework/common-definitions";
|
|
11
11
|
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
@@ -95,8 +95,16 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
95
95
|
posStart: number;
|
|
96
96
|
posAfterEnd: number;
|
|
97
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated - use createLocalReferencePosition
|
|
100
|
+
*/
|
|
98
101
|
createPositionReference(segment: T, offset: number, refType: ReferenceType): LocalReference;
|
|
102
|
+
createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined): ReferencePosition;
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated - use localReferencePositionToPosition
|
|
105
|
+
*/
|
|
99
106
|
localRefToPos(localRef: LocalReference): number;
|
|
107
|
+
localReferencePositionToPosition(lref: ReferencePosition): number;
|
|
100
108
|
/**
|
|
101
109
|
* Resolves a remote client's position against the local sequence
|
|
102
110
|
* and returns the remote client's position relative to the local
|
|
@@ -113,8 +121,15 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
113
121
|
*/
|
|
114
122
|
resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number;
|
|
115
123
|
submitSequenceMessage(message: IMergeTreeOp): void;
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated - use createLocalReferencePosition
|
|
126
|
+
*/
|
|
116
127
|
addLocalReference(lref: LocalReference): void;
|
|
117
|
-
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated - use removeLocalReferencePosition
|
|
130
|
+
*/
|
|
131
|
+
removeLocalReference(lref: LocalReference): ReferencePosition;
|
|
132
|
+
removeLocalReferencePosition(lref: ReferencePosition): ReferencePosition;
|
|
118
133
|
/**
|
|
119
134
|
* Given a position specified relative to a marker id, lookup the marker
|
|
120
135
|
* and convert the position to a character position.
|
|
@@ -175,7 +190,10 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
175
190
|
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
176
191
|
protected didAttach(): void;
|
|
177
192
|
protected initializeLocalCore(): void;
|
|
178
|
-
|
|
193
|
+
/**
|
|
194
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
195
|
+
*/
|
|
196
|
+
protected applyStashedOp(content: any): unknown;
|
|
179
197
|
private summarizeMergeTree;
|
|
180
198
|
private processMergeTreeMsg;
|
|
181
199
|
private getIntervalCollectionPath;
|
package/dist/sequence.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.d.ts","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAA0B,MAAM,8BAA8B,CAAC;AAEhF,OAAO,EACH,yBAAyB,EAE5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,MAAM,EAKN,YAAY,EACZ,YAAY,EAGZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,cAAc,EAGd,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,aAAa,
|
|
1
|
+
{"version":3,"file":"sequence.d.ts","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAA0B,MAAM,8BAA8B,CAAC;AAEhF,OAAO,EACH,yBAAyB,EAE5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,MAAM,EAKN,YAAY,EACZ,YAAY,EAGZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,cAAc,EA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AM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;IAgBpE,SAAS,CAAC,SAAS;IAKnB,SAAS,CAAC,YAAY;IAEtB,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAS7D;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB;IAwDxD,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;IAiBlG,SAAS,CAAC,SAAS;IAQnB,SAAS,CAAC,mBAAmB;IAK7B;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAI/C,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,mBAAmB;IAuC3B,OAAO,CAAC,yBAAyB;IAIjC,OAAO,CAAC,+BAA+B;IAYvC,OAAO,CAAC,YAAY;IA2BpB,OAAO,CAAC,6BAA6B;CAiBxC"}
|
package/dist/sequence.js
CHANGED
|
@@ -86,16 +86,16 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
86
86
|
r.segment.properties[key] === undefined ? null : r.segment.properties[key];
|
|
87
87
|
}
|
|
88
88
|
if (lastAnnotate && lastAnnotate.pos2 === r.position &&
|
|
89
|
-
merge_tree_1.matchProperties(lastAnnotate.props, props)) {
|
|
89
|
+
(0, merge_tree_1.matchProperties)(lastAnnotate.props, props)) {
|
|
90
90
|
lastAnnotate.pos2 += r.segment.cachedLength;
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
|
-
ops.push(merge_tree_1.createAnnotateRangeOp(r.position, r.position + r.segment.cachedLength, props, undefined));
|
|
93
|
+
ops.push((0, merge_tree_1.createAnnotateRangeOp)(r.position, r.position + r.segment.cachedLength, props, undefined));
|
|
94
94
|
}
|
|
95
95
|
break;
|
|
96
96
|
}
|
|
97
97
|
case 0 /* INSERT */:
|
|
98
|
-
ops.push(merge_tree_1.createInsertOp(r.position, r.segment.clone().toJSONObject()));
|
|
98
|
+
ops.push((0, merge_tree_1.createInsertOp)(r.position, r.segment.clone().toJSONObject()));
|
|
99
99
|
break;
|
|
100
100
|
case 1 /* REMOVE */: {
|
|
101
101
|
const lastRem = ops[ops.length - 1];
|
|
@@ -103,7 +103,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
103
103
|
lastRem.pos2 += r.segment.cachedLength;
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
106
|
-
ops.push(merge_tree_1.createRemoveRangeOp(r.position, r.position + r.segment.cachedLength));
|
|
106
|
+
ops.push((0, merge_tree_1.createRemoveRangeOp)(r.position, r.position + r.segment.cachedLength));
|
|
107
107
|
}
|
|
108
108
|
break;
|
|
109
109
|
}
|
|
@@ -165,6 +165,9 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
165
165
|
getRangeExtentsOfPosition(pos) {
|
|
166
166
|
return this.client.getRangeExtentsOfPosition(pos);
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated - use createLocalReferencePosition
|
|
170
|
+
*/
|
|
168
171
|
createPositionReference(segment, offset, refType) {
|
|
169
172
|
const lref = new merge_tree_1.LocalReference(this.client, segment, offset, refType);
|
|
170
173
|
if (refType !== merge_tree_1.ReferenceType.Transient) {
|
|
@@ -172,13 +175,17 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
172
175
|
}
|
|
173
176
|
return lref;
|
|
174
177
|
}
|
|
178
|
+
createLocalReferencePosition(segment, offset, refType, properties) {
|
|
179
|
+
return this.client.createLocalReferencePosition(segment, offset, refType, properties);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* @deprecated - use localReferencePositionToPosition
|
|
183
|
+
*/
|
|
175
184
|
localRefToPos(localRef) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return -1;
|
|
181
|
-
}
|
|
185
|
+
return this.client.localReferencePositionToPosition(localRef);
|
|
186
|
+
}
|
|
187
|
+
localReferencePositionToPosition(lref) {
|
|
188
|
+
return this.client.localReferencePositionToPosition(lref);
|
|
182
189
|
}
|
|
183
190
|
/**
|
|
184
191
|
* Resolves a remote client's position against the local sequence
|
|
@@ -201,7 +208,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
201
208
|
if (!this.isAttached()) {
|
|
202
209
|
return;
|
|
203
210
|
}
|
|
204
|
-
const translated = shared_object_base_1.makeHandlesSerializable(message, this.serializer, this.handle);
|
|
211
|
+
const translated = (0, shared_object_base_1.makeHandlesSerializable)(message, this.serializer, this.handle);
|
|
205
212
|
const metadata = this.client.peekPendingSegmentGroups(message.type === 3 /* GROUP */ ? message.ops.length : 1);
|
|
206
213
|
// if loading isn't complete, we need to cache
|
|
207
214
|
// local ops until loading is complete, and then
|
|
@@ -213,11 +220,20 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
213
220
|
this.submitLocalMessage(translated, metadata);
|
|
214
221
|
}
|
|
215
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* @deprecated - use createLocalReferencePosition
|
|
225
|
+
*/
|
|
216
226
|
addLocalReference(lref) {
|
|
217
227
|
return this.client.addLocalReference(lref);
|
|
218
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated - use removeLocalReferencePosition
|
|
231
|
+
*/
|
|
219
232
|
removeLocalReference(lref) {
|
|
220
|
-
return this.client.
|
|
233
|
+
return this.client.removeLocalReferencePosition(lref);
|
|
234
|
+
}
|
|
235
|
+
removeLocalReferencePosition(lref) {
|
|
236
|
+
return this.client.removeLocalReferencePosition(lref);
|
|
221
237
|
}
|
|
222
238
|
/**
|
|
223
239
|
* Given a position specified relative to a marker id, lookup the marker
|
|
@@ -315,7 +331,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
315
331
|
if (insert) {
|
|
316
332
|
if (start < end) {
|
|
317
333
|
const remove = this.client.removeRangeLocal(start, end);
|
|
318
|
-
this.submitSequenceMessage(merge_tree_1.createGroupOp(insert, remove));
|
|
334
|
+
this.submitSequenceMessage((0, merge_tree_1.createGroupOp)(insert, remove));
|
|
319
335
|
}
|
|
320
336
|
else {
|
|
321
337
|
this.submitSequenceMessage(insert);
|
|
@@ -339,7 +355,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
339
355
|
var _a;
|
|
340
356
|
if (await storage.contains(snapshotFileName)) {
|
|
341
357
|
const blob = await storage.readBlob(snapshotFileName);
|
|
342
|
-
const header = common_utils_1.bufferToString(blob, "utf8");
|
|
358
|
+
const header = (0, common_utils_1.bufferToString)(blob, "utf8");
|
|
343
359
|
this.intervalMapKernel.populate(header);
|
|
344
360
|
}
|
|
345
361
|
try {
|
|
@@ -390,11 +406,11 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
390
406
|
// if loading isn't complete, we need to cache all
|
|
391
407
|
// incoming ops to be applied after loading is complete
|
|
392
408
|
if (this.deferIncomingOps) {
|
|
393
|
-
common_utils_1.assert(!local, 0x072 /* "Unexpected local op when loading not finished" */);
|
|
409
|
+
(0, common_utils_1.assert)(!local, 0x072 /* "Unexpected local op when loading not finished" */);
|
|
394
410
|
this.loadedDeferredIncomingOps.push(message);
|
|
395
411
|
}
|
|
396
412
|
else {
|
|
397
|
-
common_utils_1.assert(message.type === protocol_definitions_1.MessageType.Operation, 0x073 /* "Sequence message not operation" */);
|
|
413
|
+
(0, common_utils_1.assert)(message.type === protocol_definitions_1.MessageType.Operation, 0x073 /* "Sequence message not operation" */);
|
|
398
414
|
const handled = this.intervalMapKernel.tryProcessMessage(message.contents, local, message, localOpMetadata);
|
|
399
415
|
if (!handled) {
|
|
400
416
|
this.processMergeTreeMsg(message, local);
|
|
@@ -413,12 +429,15 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
413
429
|
super.initializeLocalCore();
|
|
414
430
|
this.loadFinished();
|
|
415
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
434
|
+
*/
|
|
416
435
|
applyStashedOp(content) {
|
|
417
436
|
return this.client.applyStashedOp(content);
|
|
418
437
|
}
|
|
419
438
|
summarizeMergeTree(serializer) {
|
|
420
439
|
// Are we fully loaded? If not, things will go south
|
|
421
|
-
common_utils_1.assert(this.loadedDeferred.isCompleted, 0x074 /* "Snapshot called when not fully loaded" */);
|
|
440
|
+
(0, common_utils_1.assert)(this.loadedDeferred.isCompleted, 0x074 /* "Snapshot called when not fully loaded" */);
|
|
422
441
|
const minSeq = this.runtime.deltaManager.minimumSequenceNumber;
|
|
423
442
|
this.processMinSequenceNumberChanged(minSeq);
|
|
424
443
|
this.messagesSinceMSNChange.forEach((m) => { m.minimumSequenceNumber = minSeq; });
|
|
@@ -426,7 +445,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
426
445
|
}
|
|
427
446
|
processMergeTreeMsg(rawMessage, local) {
|
|
428
447
|
var _a, _b;
|
|
429
|
-
const message = shared_object_base_1.parseHandles(rawMessage, this.serializer);
|
|
448
|
+
const message = (0, shared_object_base_1.parseHandles)(rawMessage, this.serializer);
|
|
430
449
|
const ops = [];
|
|
431
450
|
function transformOps(event) {
|
|
432
451
|
ops.push(...SharedSegmentSequence.createOpsFromDelta(event));
|
|
@@ -444,7 +463,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
444
463
|
this.removeListener("sequenceDelta", transformOps);
|
|
445
464
|
// shallow clone the message as we only overwrite top level properties,
|
|
446
465
|
// like referenceSequenceNumber and content only
|
|
447
|
-
stashMessage = Object.assign(Object.assign({}, message), { referenceSequenceNumber: stashMessage.sequenceNumber - 1, contents: ops.length !== 1 ? merge_tree_1.createGroupOp(...ops) : ops[0] });
|
|
466
|
+
stashMessage = Object.assign(Object.assign({}, message), { referenceSequenceNumber: stashMessage.sequenceNumber - 1, contents: ops.length !== 1 ? (0, merge_tree_1.createGroupOp)(...ops) : ops[0] });
|
|
448
467
|
}
|
|
449
468
|
this.messagesSinceMSNChange.push(stashMessage);
|
|
450
469
|
// Do GC every once in a while...
|
|
@@ -501,7 +520,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
501
520
|
if (!intervalCollection.attached) {
|
|
502
521
|
intervalCollection.attachGraph(this.client, ev.key);
|
|
503
522
|
}
|
|
504
|
-
common_utils_1.assert(ev.previousValue === undefined, 0x2c1 /* "Creating an interval that already exists?" */);
|
|
523
|
+
(0, common_utils_1.assert)(ev.previousValue === undefined, 0x2c1 /* "Creating an interval that already exists?" */);
|
|
505
524
|
this.emit("createIntervalCollection", ev.key, local, this);
|
|
506
525
|
});
|
|
507
526
|
// Initialize existing SharedIntervalCollections
|