@fluidframework/sequence 2.0.0-internal.5.4.2 → 2.0.0-internal.6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/defaultMap.js +3 -5
- package/dist/defaultMap.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +0 -9
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +33 -68
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalIndex/intervalIndexUtils.js +2 -3
- package/dist/intervalIndex/intervalIndexUtils.js.map +1 -1
- package/dist/intervalTree.d.ts +1 -9
- package/dist/intervalTree.d.ts.map +1 -1
- package/dist/intervalTree.js +2 -11
- package/dist/intervalTree.js.map +1 -1
- package/dist/intervals/interval.d.ts +4 -4
- package/dist/intervals/interval.js +7 -9
- package/dist/intervals/interval.js.map +1 -1
- package/dist/intervals/sequenceInterval.d.ts +4 -4
- package/dist/intervals/sequenceInterval.js +6 -8
- package/dist/intervals/sequenceInterval.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/dist/revertibles.js +6 -20
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence.js +11 -11
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.js +1 -2
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sharedString.js +3 -4
- package/dist/sharedString.js.map +1 -1
- package/lib/defaultMap.js +3 -5
- package/lib/defaultMap.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +0 -9
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +33 -68
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalIndex/intervalIndexUtils.js +2 -3
- package/lib/intervalIndex/intervalIndexUtils.js.map +1 -1
- package/lib/intervalTree.d.ts +1 -9
- package/lib/intervalTree.d.ts.map +1 -1
- package/lib/intervalTree.js +2 -11
- package/lib/intervalTree.js.map +1 -1
- package/lib/intervals/interval.d.ts +4 -4
- package/lib/intervals/interval.js +7 -9
- package/lib/intervals/interval.js.map +1 -1
- package/lib/intervals/sequenceInterval.d.ts +4 -4
- package/lib/intervals/sequenceInterval.js +6 -8
- package/lib/intervals/sequenceInterval.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/lib/revertibles.js +6 -20
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence.js +11 -11
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.js +1 -2
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sharedString.js +3 -4
- package/lib/sharedString.js.map +1 -1
- package/package.json +23 -18
- package/src/index.ts +0 -1
- package/src/intervalCollection.ts +0 -14
- package/src/intervalTree.ts +2 -21
- package/src/intervals/interval.ts +4 -4
- package/src/intervals/sequenceInterval.ts +4 -4
- package/src/packageVersion.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @fluidframework/sequence
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.6.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- IntervalConflictResolver removed [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
8
|
+
|
|
9
|
+
IntervalConflictResolver has been removed. Any lingering usages in application code can be removed as well. This change also marks APIs deprecated in #14318 as internal.
|
|
10
|
+
|
|
11
|
+
- Remove ISegment.parent [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
12
|
+
|
|
13
|
+
This change removed the parent property on the ISegment interface. The property will still exist, but should not generally be used by outside consumers.
|
|
14
|
+
|
|
15
|
+
There are some circumstances where a consumer may wish to know if a segment is still in the underlying tree and were using the parent property to determine that.
|
|
16
|
+
|
|
17
|
+
Please change those checks to use the following `"parent" in segment && segment.parent !== undefined`
|
|
18
|
+
|
|
19
|
+
- Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
20
|
+
|
|
21
|
+
Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
|
|
22
|
+
|
|
3
23
|
## 2.0.0-internal.5.4.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/dist/defaultMap.js
CHANGED
|
@@ -112,8 +112,7 @@ class DefaultMap {
|
|
|
112
112
|
* {@inheritDoc ISharedMap.get}
|
|
113
113
|
*/
|
|
114
114
|
get(key) {
|
|
115
|
-
|
|
116
|
-
const localValue = (_a = this.data.get(key)) !== null && _a !== void 0 ? _a : this.createCore(key, true);
|
|
115
|
+
const localValue = this.data.get(key) ?? this.createCore(key, true);
|
|
117
116
|
return localValue.value;
|
|
118
117
|
}
|
|
119
118
|
/**
|
|
@@ -257,8 +256,7 @@ class DefaultMap {
|
|
|
257
256
|
// watching for manipulations of that item.
|
|
258
257
|
messageHandlers.set("act", {
|
|
259
258
|
process: (op, local, message, localOpMetadata) => {
|
|
260
|
-
|
|
261
|
-
const localValue = (_a = this.data.get(op.key)) !== null && _a !== void 0 ? _a : this.createCore(op.key, local);
|
|
259
|
+
const localValue = this.data.get(op.key) ?? this.createCore(op.key, local);
|
|
262
260
|
const handler = localValue.getOpHandler(op.value.opName);
|
|
263
261
|
const previousValue = localValue.value;
|
|
264
262
|
const translatedValue = (0, shared_object_base_1.parseHandles)(op.value.value, this.serializer);
|
|
@@ -274,7 +272,7 @@ class DefaultMap {
|
|
|
274
272
|
(0, common_utils_1.assert)(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);
|
|
275
273
|
const handler = localValue.getOpHandler(op.value.opName);
|
|
276
274
|
const { rebasedOp, rebasedLocalOpMetadata } = handler.rebase(localValue.value, op.value, localOpMetadata);
|
|
277
|
-
this.submitMessage(
|
|
275
|
+
this.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);
|
|
278
276
|
},
|
|
279
277
|
getStashedOpLocalMetadata: (op) => {
|
|
280
278
|
(0, common_utils_1.assert)(false, 0x016 /* "apply stashed op not implemented for custom value type ops" */);
|
package/dist/defaultMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultMap.js","sourceRoot":"","sources":["../src/defaultMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2EAK4C;AAC5C,+DAAyE;AACzE,+CAAsE;AAiFtE;;;;;;GAMG;AACH,MAAa,UAAU;IAkBtB;;;;;;;OAOG;IACH,YACkB,UAA4B,EAC5B,MAAoB,EACpB,aAGR,EACQ,IAAmB,EACnB,OAAkC,EACnC,eAAe,IAAI,gCAAiB,EAA2B;QAR9D,eAAU,GAAV,UAAU,CAAkB;QAC5B,WAAM,GAAN,MAAM,CAAc;QACpB,kBAAa,GAAb,aAAa,CAGrB;QACQ,SAAI,GAAJ,IAAI,CAAe;QACnB,YAAO,GAAP,OAAO,CAA2B;QACnC,iBAAY,GAAZ,YAAY,CAAmD;QA3BhF;;WAEG;QACc,oBAAe,GAA4C,IAAI,GAAG,EAAE,CAAC;QAEtF;;WAEG;QACc,SAAI,GAAG,IAAI,GAAG,EAAkC,CAAC;QAqBjE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAClD,CAAC;IAr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MAAM,CAAC,CAAC;gBACzD,MAAM,EAAE,SAAS,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,MAAM,CAC3D,UAAU,CAAC,KAAK,EAChB,EAAE,CAAC,KAAK,EACR,eAAe,CACf,CAAC;gBACF,IAAI,CAAC,aAAa,iCAAM,EAAE,KAAE,KAAK,EAAE,SAAS,KAAI,sBAAsB,CAAC,CAAC;YACzE,CAAC;YACD,yBAAyB,EAAE,CAAC,EAA0B,EAAE,EAAE;gBACzD,IAAA,qBAAM,EACL,KAAK,EACL,KAAK,CAAC,kEAAkE,CACxE,CAAC;YACH,CAAC;SACD,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,GAAW;QACxC,MAAM,IAAI,GAAG,CACZ,MAAc,EACd,aAAkB,EAClB,MAAW,EACX,eAAyC,EACxC,EAAE;YACH,MAAM,gBAAgB,GAAG,IAAA,4CAAuB,EAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAEvF,MAAM,EAAE,GAA2B;gBAClC,GAAG;gBACH,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE;oBACN,MAAM;oBACN,KAAK,EAAE,gBAAgB;iBACvB;aACD,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;YAExC,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;QAC9E,CAAC,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC;IACjB,CAAC;CACD;AAnWD,gCAmWC","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 {\n\tIFluidSerializer,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tValueType,\n} from \"@fluidframework/shared-object-base\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { makeSerializable, ValueTypeLocalValue } from \"./localValues\";\nimport {\n\tISerializableValue,\n\tISerializedValue,\n\tIValueChanged,\n\tIValueOpEmitter,\n\tIValueType,\n\tIValueTypeOperationValue,\n\tISharedDefaultMapEvents,\n\tIMapMessageLocalMetadata,\n\tSequenceOptions,\n} from \"./defaultMapInterfaces\";\n\n/**\n * Defines the means to process and submit a given op on a map.\n */\ninterface IMapMessageHandler {\n\t/**\n\t * Apply the given operation.\n\t * @param op - The map operation to apply\n\t * @param local - Whether the message originated from the local client\n\t * @param message - The full message. Not provided for stashed ops.\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprocess(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t): void;\n\n\t/**\n\t * Communicate the operation to remote clients.\n\t * @param op - The map operation to submit\n\t */\n\tsubmit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;\n\n\tresubmit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;\n\n\tgetStashedOpLocalMetadata(op: IMapOperation): unknown;\n}\n\n/**\n * Describes an operation specific to a value type.\n */\nexport interface IMapValueTypeOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"act\";\n\n\t/**\n\t * Map key being modified.\n\t */\n\tkey: string;\n\n\t/**\n\t * Value of the operation, specific to the value type.\n\t * @alpha\n\t */\n\tvalue: IValueTypeOperationValue;\n}\n\n/**\n * Description of a map delta operation\n */\nexport type IMapOperation = IMapValueTypeOperation;\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\t[key: string]: ISerializableValue;\n}\n\nexport interface IMapDataObjectSerialized {\n\t[key: string]: ISerializedValue;\n}\n\n/**\n * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by\n * string key locations.\n *\n * Creation of values is implicit on access (either via `get` or a remote op application referring to\n * a collection that wasn't previously known)\n */\nexport class DefaultMap<T> {\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.data.size;\n\t}\n\n\t/**\n\t * Mapping of op types to message handlers.\n\t */\n\tprivate readonly messageHandlers: ReadonlyMap<string, IMapMessageHandler> = new Map();\n\n\t/**\n\t * The in-memory data the map is storing.\n\t */\n\tprivate readonly data = new Map<string, ValueTypeLocalValue<T>>();\n\n\t/**\n\t * Create a new default map.\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param handle - The handle of the shared object using the kernel\n\t * @param submitMessage - A callback to submit a message through the shared object\n\t * @param type - The value type to create at values of this map\n\t * @param eventEmitter - The object that will emit map events\n\t */\n\tconstructor(\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tprivate readonly handle: IFluidHandle,\n\t\tprivate readonly submitMessage: (\n\t\t\top: any,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => void,\n\t\tprivate readonly type: IValueType<T>,\n\t\tprivate readonly options?: Partial<SequenceOptions>,\n\t\tpublic readonly eventEmitter = new TypedEventEmitter<ISharedDefaultMapEvents>(),\n\t) {\n\t\tthis.messageHandlers = this.getMessageHandlers();\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.data.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic entries(): IterableIterator<[string, any]> {\n\t\tconst localEntriesIterator = this.data.entries();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<[string, any]> {\n\t\t\t\tconst nextVal = localEntriesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: [nextVal.value[0], nextVal.value[1].value], done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<any> {\n\t\tconst localValuesIterator = this.data.values();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<any> {\n\t\t\t\tconst nextVal = localValuesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: nextVal.value.value, done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic [Symbol.iterator](): IterableIterator<[string, any]> {\n\t\treturn this.entries();\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\tpublic forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n\t\tthis.data.forEach((localValue, key, m) => {\n\t\t\tcallbackFn(localValue.value, key, m);\n\t\t});\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\tpublic get(key: string): T {\n\t\tconst localValue = this.data.get(key) ?? this.createCore(key, true);\n\n\t\treturn localValue.value;\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.data.has(key);\n\t}\n\n\t/**\n\t * Serializes the data stored in the shared map to a JSON string\n\t * @param serializer - The serializer to use to serialize handles in its values.\n\t * @returns A JSON string containing serialized map data\n\t */\n\tpublic getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {\n\t\tconst serializableMapData: IMapDataObjectSerialized = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = localValue.makeSerialized(serializer, this.handle);\n\t\t});\n\t\treturn serializableMapData;\n\t}\n\n\tpublic getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {\n\t\tconst serializableMapData: IMapDataObjectSerializable = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = makeSerializable(localValue, serializer, this.handle);\n\t\t});\n\t\treturn serializableMapData;\n\t}\n\n\tpublic serialize(serializer: IFluidSerializer): string {\n\t\treturn JSON.stringify(this.getSerializableStorage(serializer));\n\t}\n\n\t/**\n\t * Populate the kernel with the given map data.\n\t * @param data - A JSON string containing serialized map data\n\t */\n\tpublic populateFromSerializable(json: IMapDataObjectSerializable): void {\n\t\tfor (const [key, serializable] of Object.entries(json)) {\n\t\t\t// Back-compat: legacy documents may have handles to an intervalCollection map kernel.\n\t\t\t// These collections should be empty, and ValueTypes are no longer supported.\n\t\t\tif (\n\t\t\t\tserializable.type === ValueType[ValueType.Plain] ||\n\t\t\t\tserializable.type === ValueType[ValueType.Shared]\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Back-compat: Sequence previously arbitrarily prefixed all interval collection keys with\n\t\t\t// \"intervalCollections/\". This would burden users trying to iterate the collection and\n\t\t\t// access its value, as well as those trying to match a create message to its underlying\n\t\t\t// collection. See https://github.com/microsoft/FluidFramework/issues/10557 for more context.\n\t\t\tconst normalizedKey = key.startsWith(\"intervalCollections/\") ? key.substring(20) : key;\n\n\t\t\tconst localValue = {\n\t\t\t\tkey: normalizedKey,\n\t\t\t\tvalue: this.makeLocal(key, serializable),\n\t\t\t};\n\n\t\t\tthis.data.set(localValue.key, localValue.value);\n\t\t}\n\t}\n\n\tpublic populate(json: string): void {\n\t\tthis.populateFromSerializable(JSON.parse(json) as IMapDataObjectSerializable);\n\t}\n\n\t/**\n\t * Submit the given op if a handler is registered.\n\t * @param op - The operation to attempt to submit\n\t * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t * @returns True if the operation was submitted, false otherwise.\n\t */\n\tpublic tryResubmitMessage(op: any, localOpMetadata: IMapMessageLocalMetadata): boolean {\n\t\tconst type: string = op.type;\n\t\tconst handler = this.messageHandlers.get(type);\n\t\tif (handler !== undefined) {\n\t\t\thandler.resubmit(op as IMapOperation, localOpMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryGetStashedOpLocalMetadata(op: any): unknown {\n\t\tconst type: string = op.type;\n\t\tif (this.messageHandlers.has(type)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op as IMapOperation);\n\t\t}\n\t\tthrow new Error(\"no apply stashed op handler\");\n\t}\n\n\t/**\n\t * Process the given op if a handler is registered.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation was processed, false otherwise.\n\t */\n\tpublic tryProcessMessage(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tconst handler = this.messageHandlers.get(op.type);\n\t\tif (handler !== undefined) {\n\t\t\thandler.process(op, local, message, localOpMetadata as IMapMessageLocalMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Initializes a default ValueType at the provided key.\n\t * Should be used when a map operation incurs creation.\n\t * @param key - The key being initialized\n\t * @param local - Whether the message originated from the local client\n\t */\n\tprivate createCore(key: string, local: boolean): ValueTypeLocalValue<T> {\n\t\tconst localValue = new ValueTypeLocalValue(\n\t\t\tthis.type.factory.load(this.makeMapValueOpEmitter(key), undefined, this.options),\n\t\t\tthis.type,\n\t\t);\n\t\tconst previousValue = this.data.get(key);\n\t\tthis.data.set(key, localValue);\n\t\tconst event: IValueChanged = { key, previousValue };\n\t\tthis.eventEmitter.emit(\"create\", event, local, this.eventEmitter);\n\t\treturn localValue;\n\t}\n\n\t/**\n\t * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will\n\t * have the information we need to create a real object, but will not be the real object yet. For example,\n\t * 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\t * job is to convert that information into a real object for local usage.\n\t * @param key - The key that the caller intends to store the local value into (used for ops later). But\n\t * doesn't actually store the local value into that key. So better not lie!\n\t * @param serializable - The remote information that we can convert into a real object\n\t * @returns The local value that was produced\n\t */\n\tprivate makeLocal(key: string, serializable: ISerializableValue): ValueTypeLocalValue<T> {\n\t\tassert(\n\t\t\tserializable.type !== ValueType[ValueType.Plain] &&\n\t\t\t\tserializable.type !== ValueType[ValueType.Shared],\n\t\t\t0x2e1 /* \"Support for plain value types removed.\" */,\n\t\t);\n\n\t\tserializable.value = parseHandles(serializable.value, this.serializer);\n\t\tconst localValue = this.type.factory.load(\n\t\t\tthis.makeMapValueOpEmitter(key),\n\t\t\tserializable.value,\n\t\t\tthis.options,\n\t\t);\n\t\treturn new ValueTypeLocalValue(localValue, this.type);\n\t}\n\n\t/**\n\t * Get the message handlers for the map.\n\t * @returns A map of string op names to IMapMessageHandlers for those ops\n\t */\n\tprivate getMessageHandlers() {\n\t\tconst messageHandlers = new Map<string, IMapMessageHandler>();\n\t\t// Ops with type \"act\" describe actions taken by custom value type handlers of whatever item is\n\t\t// being addressed. These custom handlers can be retrieved from the ValueTypeLocalValue which has\n\t\t// stashed its valueType (and therefore its handlers). We also emit a valueChanged for anyone\n\t\t// watching for manipulations of that item.\n\t\tmessageHandlers.set(\"act\", {\n\t\t\tprocess: (op: IMapValueTypeOperation, local, message, localOpMetadata) => {\n\t\t\t\tconst localValue = this.data.get(op.key) ?? this.createCore(op.key, local);\n\t\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\t\tconst previousValue = localValue.value;\n\t\t\t\tconst translatedValue = parseHandles(op.value.value, this.serializer);\n\t\t\t\thandler.process(previousValue, translatedValue, local, message, localOpMetadata);\n\t\t\t\tconst event: IValueChanged = { key: op.key, previousValue };\n\t\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, local, message, this.eventEmitter);\n\t\t\t},\n\t\t\tsubmit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t\t},\n\t\t\tresubmit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\t\tconst localValue = this.data.get(op.key);\n\n\t\t\t\tassert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);\n\n\t\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\t\tconst { rebasedOp, rebasedLocalOpMetadata } = handler.rebase(\n\t\t\t\t\tlocalValue.value,\n\t\t\t\t\top.value,\n\t\t\t\t\tlocalOpMetadata,\n\t\t\t\t);\n\t\t\t\tthis.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);\n\t\t\t},\n\t\t\tgetStashedOpLocalMetadata: (op: IMapValueTypeOperation) => {\n\t\t\t\tassert(\n\t\t\t\t\tfalse,\n\t\t\t\t\t0x016 /* \"apply stashed op not implemented for custom value type ops\" */,\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\treturn messageHandlers;\n\t}\n\n\t/**\n\t * Create an emitter for a value type to emit ops from the given key.\n\t * @alpha\n\t * @param key - The key of the map that the value type will be stored on\n\t * @returns A value op emitter for the given key\n\t */\n\tprivate makeMapValueOpEmitter(key: string): IValueOpEmitter {\n\t\tconst emit = (\n\t\t\topName: string,\n\t\t\tpreviousValue: any,\n\t\t\tparams: any,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => {\n\t\t\tconst translatedParams = makeHandlesSerializable(params, this.serializer, this.handle);\n\n\t\t\tconst op: IMapValueTypeOperation = {\n\t\t\t\tkey,\n\t\t\t\ttype: \"act\",\n\t\t\t\tvalue: {\n\t\t\t\t\topName,\n\t\t\t\t\tvalue: translatedParams,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tthis.submitMessage(op, localOpMetadata);\n\n\t\t\tconst event: IValueChanged = { key, previousValue };\n\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, true, null, this.eventEmitter);\n\t\t};\n\n\t\treturn { emit };\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"defaultMap.js","sourceRoot":"","sources":["../src/defaultMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2EAK4C;AAC5C,+DAAyE;AACzE,+CAAsE;AAiFtE;;;;;;GAMG;AACH,MAAa,UAAU;IAkBtB;;;;;;;OAOG;IACH,YACkB,UAA4B,EAC5B,MAAoB,EACpB,aAGR,EACQ,IAAmB,EACnB,OAAkC,EACnC,eAAe,IAAI,gCAAiB,EAA2B;QAR9D,eAAU,GAAV,UAAU,CAAkB;QAC5B,WAAM,GAAN,MAAM,CAAc;QACpB,kBAAa,GAAb,aAAa,CAGrB;QACQ,SAAI,GAAJ,IAAI,CAAe;QACnB,YAAO,GAAP,OAAO,CAA2B;QACnC,iBAAY,GAAZ,YAAY,CAAmD;QA3BhF;;WAEG;QACc,oBAAe,GAA4C,IAAI,GAAG,EAAE,CAAC;QAEtF;;WAEG;QACc,SAAI,GAAG,IAAI,GAAG,EAAkC,CAAC;QAqBjE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAClD,CAAC;IArCD;;OAEG;IACH,IAAW,IAAI;QACd,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sBAAsB,EAAE,GAAG,OAAO,CAAC,MAAM,CAC3D,UAAU,CAAC,KAAK,EAChB,EAAE,CAAC,KAAK,EACR,eAAe,CACf,CAAC;gBACF,IAAI,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,sBAAsB,CAAC,CAAC;YACzE,CAAC;YACD,yBAAyB,EAAE,CAAC,EAA0B,EAAE,EAAE;gBACzD,IAAA,qBAAM,EACL,KAAK,EACL,KAAK,CAAC,kEAAkE,CACxE,CAAC;YACH,CAAC;SACD,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,GAAW;QACxC,MAAM,IAAI,GAAG,CACZ,MAAc,EACd,aAAkB,EAClB,MAAW,EACX,eAAyC,EACxC,EAAE;YACH,MAAM,gBAAgB,GAAG,IAAA,4CAAuB,EAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAEvF,MAAM,EAAE,GAA2B;gBAClC,GAAG;gBACH,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE;oBACN,MAAM;oBACN,KAAK,EAAE,gBAAgB;iBACvB;aACD,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;YAExC,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;QAC9E,CAAC,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC;IACjB,CAAC;CACD;AAnWD,gCAmWC","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 {\n\tIFluidSerializer,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tValueType,\n} from \"@fluidframework/shared-object-base\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { makeSerializable, ValueTypeLocalValue } from \"./localValues\";\nimport {\n\tISerializableValue,\n\tISerializedValue,\n\tIValueChanged,\n\tIValueOpEmitter,\n\tIValueType,\n\tIValueTypeOperationValue,\n\tISharedDefaultMapEvents,\n\tIMapMessageLocalMetadata,\n\tSequenceOptions,\n} from \"./defaultMapInterfaces\";\n\n/**\n * Defines the means to process and submit a given op on a map.\n */\ninterface IMapMessageHandler {\n\t/**\n\t * Apply the given operation.\n\t * @param op - The map operation to apply\n\t * @param local - Whether the message originated from the local client\n\t * @param message - The full message. Not provided for stashed ops.\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprocess(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t): void;\n\n\t/**\n\t * Communicate the operation to remote clients.\n\t * @param op - The map operation to submit\n\t */\n\tsubmit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;\n\n\tresubmit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;\n\n\tgetStashedOpLocalMetadata(op: IMapOperation): unknown;\n}\n\n/**\n * Describes an operation specific to a value type.\n */\nexport interface IMapValueTypeOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"act\";\n\n\t/**\n\t * Map key being modified.\n\t */\n\tkey: string;\n\n\t/**\n\t * Value of the operation, specific to the value type.\n\t * @alpha\n\t */\n\tvalue: IValueTypeOperationValue;\n}\n\n/**\n * Description of a map delta operation\n */\nexport type IMapOperation = IMapValueTypeOperation;\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\t[key: string]: ISerializableValue;\n}\n\nexport interface IMapDataObjectSerialized {\n\t[key: string]: ISerializedValue;\n}\n\n/**\n * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by\n * string key locations.\n *\n * Creation of values is implicit on access (either via `get` or a remote op application referring to\n * a collection that wasn't previously known)\n */\nexport class DefaultMap<T> {\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.data.size;\n\t}\n\n\t/**\n\t * Mapping of op types to message handlers.\n\t */\n\tprivate readonly messageHandlers: ReadonlyMap<string, IMapMessageHandler> = new Map();\n\n\t/**\n\t * The in-memory data the map is storing.\n\t */\n\tprivate readonly data = new Map<string, ValueTypeLocalValue<T>>();\n\n\t/**\n\t * Create a new default map.\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param handle - The handle of the shared object using the kernel\n\t * @param submitMessage - A callback to submit a message through the shared object\n\t * @param type - The value type to create at values of this map\n\t * @param eventEmitter - The object that will emit map events\n\t */\n\tconstructor(\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tprivate readonly handle: IFluidHandle,\n\t\tprivate readonly submitMessage: (\n\t\t\top: any,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => void,\n\t\tprivate readonly type: IValueType<T>,\n\t\tprivate readonly options?: Partial<SequenceOptions>,\n\t\tpublic readonly eventEmitter = new TypedEventEmitter<ISharedDefaultMapEvents>(),\n\t) {\n\t\tthis.messageHandlers = this.getMessageHandlers();\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.data.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic entries(): IterableIterator<[string, any]> {\n\t\tconst localEntriesIterator = this.data.entries();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<[string, any]> {\n\t\t\t\tconst nextVal = localEntriesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: [nextVal.value[0], nextVal.value[1].value], done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<any> {\n\t\tconst localValuesIterator = this.data.values();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<any> {\n\t\t\t\tconst nextVal = localValuesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: nextVal.value.value, done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic [Symbol.iterator](): IterableIterator<[string, any]> {\n\t\treturn this.entries();\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\tpublic forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n\t\tthis.data.forEach((localValue, key, m) => {\n\t\t\tcallbackFn(localValue.value, key, m);\n\t\t});\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\tpublic get(key: string): T {\n\t\tconst localValue = this.data.get(key) ?? this.createCore(key, true);\n\n\t\treturn localValue.value;\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.data.has(key);\n\t}\n\n\t/**\n\t * Serializes the data stored in the shared map to a JSON string\n\t * @param serializer - The serializer to use to serialize handles in its values.\n\t * @returns A JSON string containing serialized map data\n\t */\n\tpublic getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {\n\t\tconst serializableMapData: IMapDataObjectSerialized = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = localValue.makeSerialized(serializer, this.handle);\n\t\t});\n\t\treturn serializableMapData;\n\t}\n\n\tpublic getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {\n\t\tconst serializableMapData: IMapDataObjectSerializable = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = makeSerializable(localValue, serializer, this.handle);\n\t\t});\n\t\treturn serializableMapData;\n\t}\n\n\tpublic serialize(serializer: IFluidSerializer): string {\n\t\treturn JSON.stringify(this.getSerializableStorage(serializer));\n\t}\n\n\t/**\n\t * Populate the kernel with the given map data.\n\t * @param data - A JSON string containing serialized map data\n\t */\n\tpublic populateFromSerializable(json: IMapDataObjectSerializable): void {\n\t\tfor (const [key, serializable] of Object.entries(json)) {\n\t\t\t// Back-compat: legacy documents may have handles to an intervalCollection map kernel.\n\t\t\t// These collections should be empty, and ValueTypes are no longer supported.\n\t\t\tif (\n\t\t\t\tserializable.type === ValueType[ValueType.Plain] ||\n\t\t\t\tserializable.type === ValueType[ValueType.Shared]\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Back-compat: Sequence previously arbitrarily prefixed all interval collection keys with\n\t\t\t// \"intervalCollections/\". This would burden users trying to iterate the collection and\n\t\t\t// access its value, as well as those trying to match a create message to its underlying\n\t\t\t// collection. See https://github.com/microsoft/FluidFramework/issues/10557 for more context.\n\t\t\tconst normalizedKey = key.startsWith(\"intervalCollections/\") ? key.substring(20) : key;\n\n\t\t\tconst localValue = {\n\t\t\t\tkey: normalizedKey,\n\t\t\t\tvalue: this.makeLocal(key, serializable),\n\t\t\t};\n\n\t\t\tthis.data.set(localValue.key, localValue.value);\n\t\t}\n\t}\n\n\tpublic populate(json: string): void {\n\t\tthis.populateFromSerializable(JSON.parse(json) as IMapDataObjectSerializable);\n\t}\n\n\t/**\n\t * Submit the given op if a handler is registered.\n\t * @param op - The operation to attempt to submit\n\t * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t * @returns True if the operation was submitted, false otherwise.\n\t */\n\tpublic tryResubmitMessage(op: any, localOpMetadata: IMapMessageLocalMetadata): boolean {\n\t\tconst type: string = op.type;\n\t\tconst handler = this.messageHandlers.get(type);\n\t\tif (handler !== undefined) {\n\t\t\thandler.resubmit(op as IMapOperation, localOpMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryGetStashedOpLocalMetadata(op: any): unknown {\n\t\tconst type: string = op.type;\n\t\tif (this.messageHandlers.has(type)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op as IMapOperation);\n\t\t}\n\t\tthrow new Error(\"no apply stashed op handler\");\n\t}\n\n\t/**\n\t * Process the given op if a handler is registered.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation was processed, false otherwise.\n\t */\n\tpublic tryProcessMessage(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tconst handler = this.messageHandlers.get(op.type);\n\t\tif (handler !== undefined) {\n\t\t\thandler.process(op, local, message, localOpMetadata as IMapMessageLocalMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Initializes a default ValueType at the provided key.\n\t * Should be used when a map operation incurs creation.\n\t * @param key - The key being initialized\n\t * @param local - Whether the message originated from the local client\n\t */\n\tprivate createCore(key: string, local: boolean): ValueTypeLocalValue<T> {\n\t\tconst localValue = new ValueTypeLocalValue(\n\t\t\tthis.type.factory.load(this.makeMapValueOpEmitter(key), undefined, this.options),\n\t\t\tthis.type,\n\t\t);\n\t\tconst previousValue = this.data.get(key);\n\t\tthis.data.set(key, localValue);\n\t\tconst event: IValueChanged = { key, previousValue };\n\t\tthis.eventEmitter.emit(\"create\", event, local, this.eventEmitter);\n\t\treturn localValue;\n\t}\n\n\t/**\n\t * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will\n\t * have the information we need to create a real object, but will not be the real object yet. For example,\n\t * 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\t * job is to convert that information into a real object for local usage.\n\t * @param key - The key that the caller intends to store the local value into (used for ops later). But\n\t * doesn't actually store the local value into that key. So better not lie!\n\t * @param serializable - The remote information that we can convert into a real object\n\t * @returns The local value that was produced\n\t */\n\tprivate makeLocal(key: string, serializable: ISerializableValue): ValueTypeLocalValue<T> {\n\t\tassert(\n\t\t\tserializable.type !== ValueType[ValueType.Plain] &&\n\t\t\t\tserializable.type !== ValueType[ValueType.Shared],\n\t\t\t0x2e1 /* \"Support for plain value types removed.\" */,\n\t\t);\n\n\t\tserializable.value = parseHandles(serializable.value, this.serializer);\n\t\tconst localValue = this.type.factory.load(\n\t\t\tthis.makeMapValueOpEmitter(key),\n\t\t\tserializable.value,\n\t\t\tthis.options,\n\t\t);\n\t\treturn new ValueTypeLocalValue(localValue, this.type);\n\t}\n\n\t/**\n\t * Get the message handlers for the map.\n\t * @returns A map of string op names to IMapMessageHandlers for those ops\n\t */\n\tprivate getMessageHandlers() {\n\t\tconst messageHandlers = new Map<string, IMapMessageHandler>();\n\t\t// Ops with type \"act\" describe actions taken by custom value type handlers of whatever item is\n\t\t// being addressed. These custom handlers can be retrieved from the ValueTypeLocalValue which has\n\t\t// stashed its valueType (and therefore its handlers). We also emit a valueChanged for anyone\n\t\t// watching for manipulations of that item.\n\t\tmessageHandlers.set(\"act\", {\n\t\t\tprocess: (op: IMapValueTypeOperation, local, message, localOpMetadata) => {\n\t\t\t\tconst localValue = this.data.get(op.key) ?? this.createCore(op.key, local);\n\t\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\t\tconst previousValue = localValue.value;\n\t\t\t\tconst translatedValue = parseHandles(op.value.value, this.serializer);\n\t\t\t\thandler.process(previousValue, translatedValue, local, message, localOpMetadata);\n\t\t\t\tconst event: IValueChanged = { key: op.key, previousValue };\n\t\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, local, message, this.eventEmitter);\n\t\t\t},\n\t\t\tsubmit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t\t},\n\t\t\tresubmit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\t\tconst localValue = this.data.get(op.key);\n\n\t\t\t\tassert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);\n\n\t\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\t\tconst { rebasedOp, rebasedLocalOpMetadata } = handler.rebase(\n\t\t\t\t\tlocalValue.value,\n\t\t\t\t\top.value,\n\t\t\t\t\tlocalOpMetadata,\n\t\t\t\t);\n\t\t\t\tthis.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);\n\t\t\t},\n\t\t\tgetStashedOpLocalMetadata: (op: IMapValueTypeOperation) => {\n\t\t\t\tassert(\n\t\t\t\t\tfalse,\n\t\t\t\t\t0x016 /* \"apply stashed op not implemented for custom value type ops\" */,\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\treturn messageHandlers;\n\t}\n\n\t/**\n\t * Create an emitter for a value type to emit ops from the given key.\n\t * @alpha\n\t * @param key - The key of the map that the value type will be stored on\n\t * @returns A value op emitter for the given key\n\t */\n\tprivate makeMapValueOpEmitter(key: string): IValueOpEmitter {\n\t\tconst emit = (\n\t\t\topName: string,\n\t\t\tpreviousValue: any,\n\t\t\tparams: any,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => {\n\t\t\tconst translatedParams = makeHandlesSerializable(params, this.serializer, this.handle);\n\n\t\t\tconst op: IMapValueTypeOperation = {\n\t\t\t\tkey,\n\t\t\t\ttype: \"act\",\n\t\t\t\tvalue: {\n\t\t\t\t\topName,\n\t\t\t\t\tvalue: translatedParams,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tthis.submitMessage(op, localOpMetadata);\n\n\t\t\tconst event: IValueChanged = { key, previousValue };\n\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, true, null, this.eventEmitter);\n\t\t};\n\n\t\treturn { emit };\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
export { IMapMessageLocalMetadata, IValueOpEmitter, SequenceOptions } from "./defaultMapInterfaces";
|
|
18
18
|
export { IInterval, Interval, IIntervalHelpers, IntervalOpType, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, SerializedIntervalDelta, IntervalStickiness, sequenceIntervalHelpers, } from "./intervals";
|
|
19
19
|
export { DeserializeCallback, IIntervalCollectionEvent, IIntervalCollection, IntervalLocator, intervalLocatorFromEndpoint, } from "./intervalCollection";
|
|
20
|
-
export { IntervalConflictResolver } from "./intervalTree";
|
|
21
20
|
export { IntervalIndex, SequenceIntervalIndexes, IOverlappingIntervalsIndex, createOverlappingIntervalsIndex, createOverlappingSequenceIntervalsIndex, IEndpointInRangeIndex, IStartpointInRangeIndex, createEndpointInRangeIndex, createStartpointInRangeIndex, IIdIntervalIndex, createIdIntervalIndex, IEndpointIndex, createEndpointIndex, } from "./intervalIndex";
|
|
22
21
|
export { appendAddIntervalToRevertibles, appendChangeIntervalToRevertibles, appendDeleteIntervalToRevertibles, appendIntervalPropertyChangedToRevertibles, appendSharedStringDeltaToRevertibles, discardSharedStringRevertibles, IntervalRevertible, revertSharedStringRevertibles, SharedStringRevertible, } from "./revertibles";
|
|
23
22
|
export { ISharedSegmentSequenceEvents, SharedSegmentSequence } from "./sequence";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,EACN,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,EACN,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,aAAa,EACb,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,EAC/B,uCAAuC,EACvC,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,4BAA4B,EAC5B,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,mBAAmB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,8BAA8B,EAC9B,iCAAiC,EACjC,iCAAiC,EACjC,0CAA0C,EAC1C,oCAAoC,EACpC,8BAA8B,EAC9B,kBAAkB,EAClB,6BAA6B,EAC7B,sBAAsB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EACN,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,wBAAwB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,yBAAyB,EACzB,wBAAwB,EACxB,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH,yCAYqB;AAVpB,qGAAA,QAAQ,OAAA;AAER,2GAAA,cAAc,OAAA;AACd,yGAAA,YAAY,OAAA;AAGZ,6GAAA,gBAAgB,OAAA;AAEhB,+GAAA,kBAAkB,OAAA;AAClB,oHAAA,uBAAuB,OAAA;AAExB,2DAM8B;AAD7B,iIAAA,2BAA2B,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH,yCAYqB;AAVpB,qGAAA,QAAQ,OAAA;AAER,2GAAA,cAAc,OAAA;AACd,yGAAA,YAAY,OAAA;AAGZ,6GAAA,gBAAgB,OAAA;AAEhB,+GAAA,kBAAkB,OAAA;AAClB,oHAAA,uBAAuB,OAAA;AAExB,2DAM8B;AAD7B,iIAAA,2BAA2B,OAAA;AAE5B,iDAcyB;AAVxB,gIAAA,+BAA+B,OAAA;AAC/B,wIAAA,uCAAuC,OAAA;AAGvC,2HAAA,0BAA0B,OAAA;AAC1B,6HAAA,4BAA4B,OAAA;AAE5B,sHAAA,qBAAqB,OAAA;AAErB,oHAAA,mBAAmB,OAAA;AAEpB,6CAUuB;AATtB,6HAAA,8BAA8B,OAAA;AAC9B,gIAAA,iCAAiC,OAAA;AACjC,gIAAA,iCAAiC,OAAA;AACjC,yIAAA,0CAA0C,OAAA;AAC1C,mIAAA,oCAAoC,OAAA;AACpC,6HAAA,8BAA8B,OAAA;AAE9B,4HAAA,6BAA6B,OAAA;AAG9B,uCAAiF;AAA1C,iHAAA,qBAAqB,OAAA;AAC5D,2DAK8B;AAH7B,wHAAA,kBAAkB,OAAA;AAClB,mHAAA,aAAa,OAAA;AACb,8HAAA,wBAAwB,OAAA;AAEzB,qDAAwD;AAA/C,sHAAA,mBAAmB,OAAA;AAC5B,+CAKwB;AAJvB,iHAAA,iBAAiB,OAAA;AAEjB,4GAAA,YAAY,OAAA;AAGb,uEAIoC;AAFnC,oIAAA,wBAAwB,OAAA;AACxB,2IAAA,+BAA+B,OAAA;AAEhC,mDAAgF;AAAtD,gHAAA,cAAc,OAAA;AAAE,6GAAA,WAAW,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Supports distributed data structures which are list-like.\n *\n * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of\n * text.\n *\n * See the package's README for a high-level introduction to `SharedString`'s feature set.\n * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for\n * working with text.\n *\n * @packageDocumentation\n */\nexport { IMapMessageLocalMetadata, IValueOpEmitter, SequenceOptions } from \"./defaultMapInterfaces\";\nexport {\n\tIInterval,\n\tInterval,\n\tIIntervalHelpers,\n\tIntervalOpType,\n\tIntervalType,\n\tISerializableInterval,\n\tISerializedInterval,\n\tSequenceInterval,\n\tSerializedIntervalDelta,\n\tIntervalStickiness,\n\tsequenceIntervalHelpers,\n} from \"./intervals\";\nexport {\n\tDeserializeCallback,\n\tIIntervalCollectionEvent,\n\tIIntervalCollection,\n\tIntervalLocator,\n\tintervalLocatorFromEndpoint,\n} from \"./intervalCollection\";\nexport {\n\tIntervalIndex,\n\tSequenceIntervalIndexes,\n\tIOverlappingIntervalsIndex,\n\tcreateOverlappingIntervalsIndex,\n\tcreateOverlappingSequenceIntervalsIndex,\n\tIEndpointInRangeIndex,\n\tIStartpointInRangeIndex,\n\tcreateEndpointInRangeIndex,\n\tcreateStartpointInRangeIndex,\n\tIIdIntervalIndex,\n\tcreateIdIntervalIndex,\n\tIEndpointIndex,\n\tcreateEndpointIndex,\n} from \"./intervalIndex\";\nexport {\n\tappendAddIntervalToRevertibles,\n\tappendChangeIntervalToRevertibles,\n\tappendDeleteIntervalToRevertibles,\n\tappendIntervalPropertyChangedToRevertibles,\n\tappendSharedStringDeltaToRevertibles,\n\tdiscardSharedStringRevertibles,\n\tIntervalRevertible,\n\trevertSharedStringRevertibles,\n\tSharedStringRevertible,\n} from \"./revertibles\";\nexport { ISharedSegmentSequenceEvents, SharedSegmentSequence } from \"./sequence\";\nexport {\n\tISequenceDeltaRange,\n\tSequenceDeltaEvent,\n\tSequenceEvent,\n\tSequenceMaintenanceEvent,\n} from \"./sequenceDeltaEvent\";\nexport { SharedStringFactory } from \"./sequenceFactory\";\nexport {\n\tgetTextAndMarkers,\n\tISharedString,\n\tSharedString,\n\tSharedStringSegment,\n} from \"./sharedString\";\nexport {\n\tISharedIntervalCollection,\n\tSharedIntervalCollection,\n\tSharedIntervalCollectionFactory,\n} from \"./sharedIntervalCollection\";\nexport { IJSONRunSegment, SharedSequence, SubSequence } from \"./sharedSequence\";\n"]}
|
|
@@ -7,7 +7,6 @@ import { IEvent } from "@fluidframework/common-definitions";
|
|
|
7
7
|
import { Client, PropertySet, LocalReferencePosition } from "@fluidframework/merge-tree";
|
|
8
8
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
9
9
|
import { IMapMessageLocalMetadata, IValueFactory, IValueOpEmitter, IValueOperation, IValueType, SequenceOptions } from "./defaultMapInterfaces";
|
|
10
|
-
import { IntervalConflictResolver } from "./intervalTree";
|
|
11
10
|
import { CompressedSerializedInterval, IIntervalHelpers, Interval, IntervalStickiness, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, SerializedIntervalDelta } from "./intervals";
|
|
12
11
|
import { IEndpointIndex, IIdIntervalIndex, IOverlappingIntervalsIndex, IntervalIndex } from "./intervalIndex";
|
|
13
12
|
export interface ISerializedIntervalCollectionV2 {
|
|
@@ -302,14 +301,6 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
302
301
|
private hasPendingChangeEnd;
|
|
303
302
|
/** @internal */
|
|
304
303
|
ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IMapMessageLocalMetadata | undefined): void;
|
|
305
|
-
/**
|
|
306
|
-
* @deprecated - This functionality was useful when adding two intervals at the same start/end positions resulted
|
|
307
|
-
* in a conflict. This is no longer the case (as of PR#6407), as interval collections support multiple intervals
|
|
308
|
-
* at the same location and gives each interval a unique id.
|
|
309
|
-
*
|
|
310
|
-
* As such, the conflict resolver is never invoked and unnecessary. This API will be removed in an upcoming release.
|
|
311
|
-
*/
|
|
312
|
-
addConflictResolver(_: IntervalConflictResolver<TInterval>): void;
|
|
313
304
|
/**
|
|
314
305
|
* {@inheritdoc IIntervalCollection.attachDeserializer}
|
|
315
306
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,OAAO,EAEN,MAAM,EAKN,WAAW,EACX,sBAAsB,EAMtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF,OAAO,EACN,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,eAAe,EACf,UAAU,EAEV,eAAe,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,OAAO,EAEN,MAAM,EAKN,WAAW,EACX,sBAAsB,EAMtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF,OAAO,EACN,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,eAAe,EACf,UAAU,EAEV,eAAe,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,4BAA4B,EAC5B,gBAAgB,EAChB,QAAQ,EAER,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EAMvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,0BAA0B,EAC1B,aAAa,EAIb,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,+BAA+B;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,4BAA4B,EAAE,CAAC;CAC1C;AA4CD,wBAAgB,mBAAm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M,GACnB,0BAA0B,CAAC,SAAS,CAAC;IAKxC;;;;OAIG;IACI,uCAAuC,CAC7C,aAAa,EAAE,MAAM,GACnB,0BAA0B,CAAC,SAAS,CAAC;IAKxC;;;;OAIG;IACI,oCAAoC,CAC1C,WAAW,EAAE,MAAM,GACjB,0BAA0B,CAAC,SAAS,CAAC;IAUxC;;;;OAIG;IACI,qCAAqC,CAC3C,WAAW,EAAE,MAAM,GACjB,0BAA0B,CAAC,SAAS,CAAC;IAUxC;;;;OAIG;IACI,sBAAsB,CAC5B,OAAO,EAAE,SAAS,EAAE,EACpB,eAAe,EAAE,OAAO,EACxB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM;IAcb;;;;OAIG;IACI,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE;IAWxF;;OAEG;IACI,GAAG,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI;IAU5C;;;;;OAKG;IACI,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAQ3D;;;;;OAKG;IACI,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;CAOvD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAC1C,iBAAiB,EAAE,sBAAsB,GACvC,eAAe,GAAG,SAAS,CAM7B"}
|
|
@@ -3,17 +3,6 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
7
|
-
var t = {};
|
|
8
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
9
|
-
t[p] = s[p];
|
|
10
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
11
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
12
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
13
|
-
t[p[i]] = s[p[i]];
|
|
14
|
-
}
|
|
15
|
-
return t;
|
|
16
|
-
};
|
|
17
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
7
|
exports.intervalLocatorFromEndpoint = exports.IntervalCollection = exports.makeOpsMap = exports.IntervalCollectionValueType = exports.SequenceIntervalCollectionValueType = exports.LocalIntervalCollection = exports.createIntervalIndex = void 0;
|
|
19
8
|
/* eslint-disable no-bitwise */
|
|
@@ -35,7 +24,7 @@ function decompressInterval(interval, label) {
|
|
|
35
24
|
end: interval[1],
|
|
36
25
|
sequenceNumber: interval[2],
|
|
37
26
|
intervalType: interval[3],
|
|
38
|
-
properties:
|
|
27
|
+
properties: { ...interval[4], [merge_tree_1.reservedRangeLabelsKey]: [label] },
|
|
39
28
|
stickiness: interval[5],
|
|
40
29
|
};
|
|
41
30
|
}
|
|
@@ -50,7 +39,9 @@ function compressInterval(interval) {
|
|
|
50
39
|
end,
|
|
51
40
|
sequenceNumber,
|
|
52
41
|
intervalType,
|
|
53
|
-
|
|
42
|
+
// remove the `referenceRangeLabels` property as it is already stored
|
|
43
|
+
// in the `label` field of the summary
|
|
44
|
+
{ ...properties, [merge_tree_1.reservedRangeLabelsKey]: undefined },
|
|
54
45
|
];
|
|
55
46
|
if (interval.stickiness !== undefined && interval.stickiness !== intervals_1.IntervalStickiness.END) {
|
|
56
47
|
base.push(interval.stickiness);
|
|
@@ -96,8 +87,7 @@ class LocalIntervalCollection {
|
|
|
96
87
|
* @returns The interval's existing or newly created id
|
|
97
88
|
*/
|
|
98
89
|
ensureSerializedId(serializedInterval) {
|
|
99
|
-
|
|
100
|
-
let id = (_a = serializedInterval.properties) === null || _a === void 0 ? void 0 : _a[reservedIntervalIdKey];
|
|
90
|
+
let id = serializedInterval.properties?.[reservedIntervalIdKey];
|
|
101
91
|
if (id === undefined) {
|
|
102
92
|
// Back-compat: 0.39 and earlier did not have IDs on intervals. If an interval from such a client
|
|
103
93
|
// comes over the wire, create a non-unique one based on start/end.
|
|
@@ -136,7 +126,6 @@ class LocalIntervalCollection {
|
|
|
136
126
|
}
|
|
137
127
|
addInterval(start, end, intervalType, props, op, stickiness = intervals_1.IntervalStickiness.END) {
|
|
138
128
|
var _a;
|
|
139
|
-
var _b;
|
|
140
129
|
const interval = this.createInterval(start, end, intervalType, op, stickiness);
|
|
141
130
|
if (interval) {
|
|
142
131
|
if (!interval.properties) {
|
|
@@ -152,7 +141,7 @@ class LocalIntervalCollection {
|
|
|
152
141
|
}
|
|
153
142
|
interval.addProperties(props);
|
|
154
143
|
}
|
|
155
|
-
(_a =
|
|
144
|
+
(_a = interval.properties)[reservedIntervalIdKey] ?? (_a[reservedIntervalIdKey] = (0, uuid_1.v4)());
|
|
156
145
|
this.add(interval);
|
|
157
146
|
}
|
|
158
147
|
return interval;
|
|
@@ -212,12 +201,11 @@ class LocalIntervalCollection {
|
|
|
212
201
|
this.removeIntervalFromIndexes(interval);
|
|
213
202
|
}
|
|
214
203
|
}, () => {
|
|
215
|
-
var _a;
|
|
216
204
|
(0, common_utils_1.assert)(previousInterval !== undefined, 0x3fa /* Invalid interleaving of before/after slide */);
|
|
217
205
|
pendingChanges--;
|
|
218
206
|
if (pendingChanges === 0) {
|
|
219
207
|
this.addIntervalToIndexes(interval);
|
|
220
|
-
|
|
208
|
+
this.onPositionChange?.(interval, previousInterval);
|
|
221
209
|
previousInterval = undefined;
|
|
222
210
|
}
|
|
223
211
|
});
|
|
@@ -287,7 +275,7 @@ function makeOpsMap() {
|
|
|
287
275
|
const rebase = (collection, op, localOpMetadata) => {
|
|
288
276
|
const { localSeq } = localOpMetadata;
|
|
289
277
|
const rebasedValue = collection.rebaseLocalInterval(op.opName, op.value, localSeq);
|
|
290
|
-
const rebasedOp =
|
|
278
|
+
const rebasedOp = { ...op, value: rebasedValue };
|
|
291
279
|
return { rebasedOp, rebasedLocalOpMetadata: localOpMetadata };
|
|
292
280
|
};
|
|
293
281
|
return new Map([
|
|
@@ -382,25 +370,23 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
382
370
|
* {@inheritdoc IIntervalCollection.attachIndex}
|
|
383
371
|
*/
|
|
384
372
|
attachIndex(index) {
|
|
385
|
-
var _a;
|
|
386
373
|
if (!this.attached) {
|
|
387
374
|
throw new telemetry_utils_1.LoggingError("The local interval collection must exist");
|
|
388
375
|
}
|
|
389
376
|
for (const interval of this) {
|
|
390
377
|
index.add(interval);
|
|
391
378
|
}
|
|
392
|
-
|
|
379
|
+
this.localCollection?.appendIndex(index);
|
|
393
380
|
}
|
|
394
381
|
/**
|
|
395
382
|
* {@inheritdoc IIntervalCollection.detachIndex}
|
|
396
383
|
*/
|
|
397
384
|
detachIndex(index) {
|
|
398
|
-
var _a;
|
|
399
385
|
if (!this.attached) {
|
|
400
386
|
throw new telemetry_utils_1.LoggingError("The local interval collection must exist");
|
|
401
387
|
}
|
|
402
388
|
// Avoid removing intervals if the index does not exist
|
|
403
|
-
if (!
|
|
389
|
+
if (!this.localCollection?.removeIndex(index)) {
|
|
404
390
|
return false;
|
|
405
391
|
}
|
|
406
392
|
for (const interval of this) {
|
|
@@ -409,7 +395,6 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
409
395
|
return true;
|
|
410
396
|
}
|
|
411
397
|
rebasePositionWithSegmentSlide(pos, seqNumberFrom, localSeq) {
|
|
412
|
-
var _a;
|
|
413
398
|
if (!this.client) {
|
|
414
399
|
throw new telemetry_utils_1.LoggingError("mergeTree client must exist");
|
|
415
400
|
}
|
|
@@ -420,7 +405,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
420
405
|
}, localSeq);
|
|
421
406
|
// if segment is undefined, it slid off the string
|
|
422
407
|
(0, common_utils_1.assert)(segment !== undefined, 0x54e /* No segment found */);
|
|
423
|
-
const segoff = (
|
|
408
|
+
const segoff = (0, merge_tree_1.getSlideToSegoff)({ segment, offset }) ?? segment;
|
|
424
409
|
// case happens when rebasing op, but concurrently entire string has been deleted
|
|
425
410
|
if (segoff.segment === undefined || segoff.offset === undefined) {
|
|
426
411
|
return merge_tree_1.DetachedReferencePosition;
|
|
@@ -432,7 +417,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
432
417
|
(0, common_utils_1.assert)(this.client !== undefined, 0x550 /* Client should be defined when computing rebased position */);
|
|
433
418
|
const original = this.localSeqToSerializedInterval.get(localSeq);
|
|
434
419
|
(0, common_utils_1.assert)(original !== undefined, 0x551 /* Failed to store pending serialized interval info for this localSeq. */);
|
|
435
|
-
const rebased =
|
|
420
|
+
const rebased = { ...original };
|
|
436
421
|
const { start, end, sequenceNumber } = original;
|
|
437
422
|
if (start !== undefined) {
|
|
438
423
|
rebased.start = this.rebasePositionWithSegmentSlide(start, sequenceNumber, localSeq);
|
|
@@ -514,7 +499,6 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
514
499
|
* {@inheritdoc IIntervalCollection.add}
|
|
515
500
|
*/
|
|
516
501
|
add(start, end, intervalType, props, stickiness = intervals_1.IntervalStickiness.END) {
|
|
517
|
-
var _a, _b;
|
|
518
502
|
if (!this.localCollection) {
|
|
519
503
|
throw new telemetry_utils_1.LoggingError("attach must be called prior to adding intervals");
|
|
520
504
|
}
|
|
@@ -530,7 +514,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
530
514
|
end,
|
|
531
515
|
intervalType,
|
|
532
516
|
properties: interval.properties,
|
|
533
|
-
sequenceNumber:
|
|
517
|
+
sequenceNumber: this.client?.getCurrentSeq() ?? 0,
|
|
534
518
|
start,
|
|
535
519
|
stickiness,
|
|
536
520
|
};
|
|
@@ -662,9 +646,8 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
662
646
|
entries.push(serializedInterval);
|
|
663
647
|
}
|
|
664
648
|
removePendingChange(serializedInterval) {
|
|
665
|
-
var _a;
|
|
666
649
|
// Change ops always have an ID.
|
|
667
|
-
const id =
|
|
650
|
+
const id = serializedInterval.properties?.[reservedIntervalIdKey];
|
|
668
651
|
if (serializedInterval.start !== undefined) {
|
|
669
652
|
this.removePendingChangeHelper(id, this.pendingChangesStart, serializedInterval);
|
|
670
653
|
}
|
|
@@ -679,8 +662,8 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
679
662
|
if (entries.length === 0) {
|
|
680
663
|
pendingChanges.delete(id);
|
|
681
664
|
}
|
|
682
|
-
if (
|
|
683
|
-
|
|
665
|
+
if (pendingChange?.start !== serializedInterval.start ||
|
|
666
|
+
pendingChange?.end !== serializedInterval.end) {
|
|
684
667
|
throw new telemetry_utils_1.LoggingError("Mismatch in pending changes");
|
|
685
668
|
}
|
|
686
669
|
}
|
|
@@ -695,20 +678,19 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
695
678
|
}
|
|
696
679
|
/** @internal */
|
|
697
680
|
ackChange(serializedInterval, local, op, localOpMetadata) {
|
|
698
|
-
var _a, _b, _c, _d;
|
|
699
681
|
if (!this.localCollection) {
|
|
700
682
|
throw new telemetry_utils_1.LoggingError("Attach must be called before accessing intervals");
|
|
701
683
|
}
|
|
702
684
|
if (local) {
|
|
703
685
|
(0, common_utils_1.assert)(localOpMetadata !== undefined, 0x552 /* op metadata should be defined for local op */);
|
|
704
|
-
this.localSeqToSerializedInterval.delete(localOpMetadata
|
|
686
|
+
this.localSeqToSerializedInterval.delete(localOpMetadata?.localSeq);
|
|
705
687
|
// This is an ack from the server. Remove the pending change.
|
|
706
688
|
this.removePendingChange(serializedInterval);
|
|
707
689
|
}
|
|
708
690
|
// Note that the ID is in the property bag only to allow us to find the interval.
|
|
709
691
|
// This API cannot change the ID, and writing to the ID property will result in an exception. So we
|
|
710
692
|
// strip it out of the properties here.
|
|
711
|
-
const
|
|
693
|
+
const { [reservedIntervalIdKey]: id, ...newProps } = serializedInterval.properties ?? {};
|
|
712
694
|
(0, common_utils_1.assert)(id !== undefined, 0x3fe /* id must exist on the interval */);
|
|
713
695
|
const interval = this.getIntervalById(id);
|
|
714
696
|
if (!interval) {
|
|
@@ -717,9 +699,9 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
717
699
|
}
|
|
718
700
|
if (local) {
|
|
719
701
|
// Let the propertyManager prune its pending change-properties set.
|
|
720
|
-
|
|
702
|
+
interval.propertyManager?.ackPendingProperties({
|
|
721
703
|
type: merge_tree_1.MergeTreeDeltaType.ANNOTATE,
|
|
722
|
-
props:
|
|
704
|
+
props: serializedInterval.properties ?? {},
|
|
723
705
|
});
|
|
724
706
|
this.ackInterval(interval, op);
|
|
725
707
|
}
|
|
@@ -740,7 +722,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
740
722
|
// If changeInterval gives us a new interval, work with that one. Otherwise keep working with
|
|
741
723
|
// the one we originally found in the tree.
|
|
742
724
|
newInterval =
|
|
743
|
-
|
|
725
|
+
this.localCollection.changeInterval(interval, start, end, op) ?? interval;
|
|
744
726
|
}
|
|
745
727
|
const deltaProps = newInterval.addProperties(newProps, true, op.sequenceNumber);
|
|
746
728
|
if (this.onDeserialize) {
|
|
@@ -755,18 +737,6 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
755
737
|
}
|
|
756
738
|
}
|
|
757
739
|
}
|
|
758
|
-
/**
|
|
759
|
-
* @deprecated - This functionality was useful when adding two intervals at the same start/end positions resulted
|
|
760
|
-
* in a conflict. This is no longer the case (as of PR#6407), as interval collections support multiple intervals
|
|
761
|
-
* at the same location and gives each interval a unique id.
|
|
762
|
-
*
|
|
763
|
-
* As such, the conflict resolver is never invoked and unnecessary. This API will be removed in an upcoming release.
|
|
764
|
-
*/
|
|
765
|
-
addConflictResolver(_) {
|
|
766
|
-
if (!this.localCollection) {
|
|
767
|
-
throw new telemetry_utils_1.LoggingError("attachSequence must be called");
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
740
|
/**
|
|
771
741
|
* {@inheritdoc IIntervalCollection.attachDeserializer}
|
|
772
742
|
*/
|
|
@@ -790,7 +760,6 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
790
760
|
* @internal
|
|
791
761
|
*/
|
|
792
762
|
rebaseLocalInterval(opName, serializedInterval, localSeq) {
|
|
793
|
-
var _a, _b, _c, _d, _e, _f;
|
|
794
763
|
if (!this.client) {
|
|
795
764
|
// If there's no associated mergeTree client, the originally submitted op is still correct.
|
|
796
765
|
return serializedInterval;
|
|
@@ -799,14 +768,14 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
799
768
|
throw new telemetry_utils_1.LoggingError("attachSequence must be called");
|
|
800
769
|
}
|
|
801
770
|
const { intervalType, properties } = serializedInterval;
|
|
802
|
-
const { start: startRebased, end: endRebased } =
|
|
803
|
-
const intervalId = properties
|
|
804
|
-
const localInterval =
|
|
771
|
+
const { start: startRebased, end: endRebased } = this.localSeqToRebasedInterval.get(localSeq) ?? this.computeRebasedPositions(localSeq);
|
|
772
|
+
const intervalId = properties?.[reservedIntervalIdKey];
|
|
773
|
+
const localInterval = this.localCollection?.idIntervalIndex.getIntervalById(intervalId);
|
|
805
774
|
const rebased = {
|
|
806
775
|
start: startRebased,
|
|
807
776
|
end: endRebased,
|
|
808
777
|
intervalType,
|
|
809
|
-
sequenceNumber:
|
|
778
|
+
sequenceNumber: this.client?.getCurrentSeq() ?? 0,
|
|
810
779
|
properties,
|
|
811
780
|
};
|
|
812
781
|
if (opName === "change" &&
|
|
@@ -818,7 +787,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
818
787
|
if (startRebased === merge_tree_1.DetachedReferencePosition ||
|
|
819
788
|
endRebased === merge_tree_1.DetachedReferencePosition) {
|
|
820
789
|
if (localInterval) {
|
|
821
|
-
|
|
790
|
+
this.localCollection?.removeExistingInterval(localInterval);
|
|
822
791
|
}
|
|
823
792
|
return undefined;
|
|
824
793
|
}
|
|
@@ -827,17 +796,16 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
827
796
|
(0, common_utils_1.assert)(localInterval instanceof intervals_1.SequenceInterval, 0x3a0 /* localInterval must be `SequenceInterval` when used with client */);
|
|
828
797
|
// The rebased op may place this interval's endpoints on different segments. Calling `changeInterval` here
|
|
829
798
|
// updates the local client's state to be consistent with the emitted op.
|
|
830
|
-
|
|
799
|
+
this.localCollection?.changeInterval(localInterval, startRebased, endRebased, undefined, localSeq);
|
|
831
800
|
}
|
|
832
801
|
return rebased;
|
|
833
802
|
}
|
|
834
803
|
getSlideToSegment(lref) {
|
|
835
|
-
var _a, _b;
|
|
836
804
|
if (!this.client) {
|
|
837
805
|
throw new telemetry_utils_1.LoggingError("client does not exist");
|
|
838
806
|
}
|
|
839
807
|
const segoff = { segment: lref.getSegment(), offset: lref.getOffset() };
|
|
840
|
-
if (
|
|
808
|
+
if (segoff.segment?.localRefs?.has(lref) !== true) {
|
|
841
809
|
return undefined;
|
|
842
810
|
}
|
|
843
811
|
const newSegoff = (0, merge_tree_1.getSlideToSegoff)(segoff);
|
|
@@ -853,7 +821,6 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
853
821
|
lref.refType = refType;
|
|
854
822
|
}
|
|
855
823
|
ackInterval(interval, op) {
|
|
856
|
-
var _a, _b;
|
|
857
824
|
// Only SequenceIntervals need potential sliding
|
|
858
825
|
if (!(interval instanceof intervals_1.SequenceInterval)) {
|
|
859
826
|
return;
|
|
@@ -898,7 +865,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
898
865
|
// remove and rebuild start interval as transient for event
|
|
899
866
|
this.client.removeLocalReferencePosition(oldInterval.start);
|
|
900
867
|
oldInterval.start.refType = merge_tree_1.ReferenceType.Transient;
|
|
901
|
-
|
|
868
|
+
oldSeg?.localRefs?.addLocalRef(oldInterval.start, oldInterval.start.getOffset());
|
|
902
869
|
}
|
|
903
870
|
if (needsEndUpdate) {
|
|
904
871
|
const props = interval.end.properties;
|
|
@@ -910,7 +877,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
910
877
|
const oldSeg = oldInterval.end.getSegment();
|
|
911
878
|
this.client.removeLocalReferencePosition(oldInterval.end);
|
|
912
879
|
oldInterval.end.refType = merge_tree_1.ReferenceType.Transient;
|
|
913
|
-
|
|
880
|
+
oldSeg?.localRefs?.addLocalRef(oldInterval.end, oldInterval.end.getOffset());
|
|
914
881
|
}
|
|
915
882
|
this.localCollection.add(interval);
|
|
916
883
|
this.emitChange(interval, oldInterval, true, true, op);
|
|
@@ -918,11 +885,10 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
918
885
|
}
|
|
919
886
|
/** @internal */
|
|
920
887
|
ackAdd(serializedInterval, local, op, localOpMetadata) {
|
|
921
|
-
var _a;
|
|
922
888
|
if (local) {
|
|
923
889
|
(0, common_utils_1.assert)(localOpMetadata !== undefined, 0x553 /* op metadata should be defined for local op */);
|
|
924
890
|
this.localSeqToSerializedInterval.delete(localOpMetadata.localSeq);
|
|
925
|
-
const id =
|
|
891
|
+
const id = serializedInterval.properties?.[reservedIntervalIdKey];
|
|
926
892
|
const localInterval = this.getIntervalById(id);
|
|
927
893
|
if (localInterval) {
|
|
928
894
|
this.ackInterval(localInterval, op);
|
|
@@ -1077,9 +1043,8 @@ exports.IntervalCollection = IntervalCollection;
|
|
|
1077
1043
|
* endpoint is a part of.
|
|
1078
1044
|
*/
|
|
1079
1045
|
function intervalLocatorFromEndpoint(potentialEndpoint) {
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
return interval && (collectionNameArray === null || collectionNameArray === void 0 ? void 0 : collectionNameArray.length) === 1
|
|
1046
|
+
const { interval, [merge_tree_1.reservedRangeLabelsKey]: collectionNameArray } = potentialEndpoint.properties ?? {};
|
|
1047
|
+
return interval && collectionNameArray?.length === 1
|
|
1083
1048
|
? { label: collectionNameArray[0], interval }
|
|
1084
1049
|
: undefined;
|
|
1085
1050
|
}
|