@fluidframework/sequence 2.0.0-internal.6.0.0 → 2.0.0-internal.6.0.2

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.
@@ -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 = "2.0.0-internal.6.0.0";
8
+ export declare const pkgVersion = "2.0.0-internal.6.0.2";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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 = "2.0.0-internal.6.0.0";
11
+ exports.pkgVersion = "2.0.0-internal.6.0.2";
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,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-internal.6.0.0\";\n"]}
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,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-internal.6.0.2\";\n"]}
@@ -71,6 +71,9 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
71
71
  * @param end - The exclusive end of the range to remove
72
72
  */
73
73
  removeRange(start: number, end: number): IMergeTreeRemoveMsg;
74
+ /**
75
+ * @deprecated - The ability to create group ops will be removed in an upcoming release, as group ops are redundant with the native batching capabilities of the runtime
76
+ */
74
77
  groupOperation(groupOp: IMergeTreeGroupMsg): void;
75
78
  /**
76
79
  * Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.
@@ -138,6 +141,9 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
138
141
  * @param remoteClientId - The client id of the remote client
139
142
  */
140
143
  resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
144
+ /**
145
+ * @deprecated - This method will no longer be public in an upcoming release as it is not safe to use outside of this class
146
+ */
141
147
  submitSequenceMessage(message: IMergeTreeOp): void;
142
148
  /**
143
149
  * Given a position specified relative to a marker id, lookup the marker
@@ -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,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,MAAM,EAKN,YAAY,EACZ,YAAY,EAGZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,sBAAsB,EAGtB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EAEzB,iBAAiB,EACj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UAAU,EAAE,iBAAiB;IAQzD;;;;;;;;OAQG;IACH,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;IAapE;;OAEG;IACH,SAAS,CAAC,SAAS;IAKnB;;OAEG;IACH,SAAS,CAAC,YAAY;IAEtB;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAgB7D;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB;IA4DxD;;OAEG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO;IA0BzB;;OAEG;IACH,SAAS,CAAC,SAAS;IAQnB;;OAEG;IACH,SAAS,CAAC,mBAAmB;IAK7B;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAI/C,OAAO,CAAC,kBAAkB;IAsB1B,OAAO,CAAC,mBAAmB;IAyC3B,OAAO,CAAC,+BAA+B;IAYvC,OAAO,CAAC,YAAY;IA6BpB,OAAO,CAAC,6BAA6B;CAuBrC"}
package/dist/sequence.js CHANGED
@@ -37,8 +37,12 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
37
37
  logger: this.logger,
38
38
  namespace: "SharedSegmentSequence.MergeTreeClient",
39
39
  }), dataStoreRuntime.options);
40
- this.client.on("delta", (opArgs, deltaArgs) => {
41
- this.emit("sequenceDelta", new sequenceDeltaEvent_1.SequenceDeltaEvent(opArgs, deltaArgs, this.client), this);
40
+ this.client.prependListener("delta", (opArgs, deltaArgs) => {
41
+ const event = new sequenceDeltaEvent_1.SequenceDeltaEvent(opArgs, deltaArgs, this.client);
42
+ if (opArgs.stashed !== true && event.isLocal) {
43
+ this.submitSequenceMessage(opArgs.op);
44
+ }
45
+ this.emit("sequenceDelta", event, this);
42
46
  });
43
47
  this.client.on("maintenance", (args, opArgs) => {
44
48
  this.emit("maintenance", new sequenceDeltaEvent_1.SequenceMaintenanceEvent(opArgs, args, this.client), this);
@@ -92,13 +96,13 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
92
96
  * @param end - The exclusive end of the range to remove
93
97
  */
94
98
  removeRange(start, end) {
95
- const removeOp = this.client.removeRangeLocal(start, end);
96
- this.submitSequenceMessage(removeOp);
97
- return removeOp;
99
+ return this.client.removeRangeLocal(start, end);
98
100
  }
101
+ /**
102
+ * @deprecated - The ability to create group ops will be removed in an upcoming release, as group ops are redundant with the native batching capabilities of the runtime
103
+ */
99
104
  groupOperation(groupOp) {
100
105
  this.client.localTransaction(groupOp);
101
- this.submitSequenceMessage(groupOp);
102
106
  }
103
107
  /**
104
108
  * Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.
@@ -132,10 +136,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
132
136
  *
133
137
  */
134
138
  annotateRange(start, end, props, combiningOp) {
135
- const annotateOp = this.client.annotateRangeLocal(start, end, props, combiningOp);
136
- if (annotateOp) {
137
- this.submitSequenceMessage(annotateOp);
138
- }
139
+ this.client.annotateRangeLocal(start, end, props, combiningOp);
139
140
  }
140
141
  getPropertiesAtPosition(pos) {
141
142
  return this.client.getPropertiesAtPosition(pos);
@@ -183,6 +184,9 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
183
184
  resolveRemoteClientPosition(remoteClientPosition, remoteClientRefSeq, remoteClientId) {
184
185
  return this.client.resolveRemoteClientPosition(remoteClientPosition, remoteClientRefSeq, remoteClientId);
185
186
  }
187
+ /**
188
+ * @deprecated - This method will no longer be public in an upcoming release as it is not safe to use outside of this class
189
+ */
186
190
  submitSequenceMessage(message) {
187
191
  if (!this.isAttached()) {
188
192
  return;
@@ -239,10 +243,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
239
243
  * @param segment - The segment to insert
240
244
  */
241
245
  insertAtReferencePosition(pos, segment) {
242
- const insertOp = this.client.insertAtReferencePositionLocal(pos, segment);
243
- if (insertOp) {
244
- this.submitSequenceMessage(insertOp);
245
- }
246
+ this.client.insertAtReferencePositionLocal(pos, segment);
246
247
  }
247
248
  /**
248
249
  * Inserts a segment
@@ -251,10 +252,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
251
252
  */
252
253
  insertFromSpec(pos, spec) {
253
254
  const segment = this.segmentFromSpec(spec);
254
- const insertOp = this.client.insertSegmentLocal(pos, segment);
255
- if (insertOp) {
256
- this.submitSequenceMessage(insertOp);
257
- }
255
+ this.client.insertSegmentLocal(pos, segment);
258
256
  }
259
257
  /**
260
258
  * Retrieves the interval collection keyed on `label`. If no such interval collection exists,
@@ -316,12 +314,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
316
314
  const insert = this.client.insertSegmentLocal(insertIndex, segment);
317
315
  if (insert) {
318
316
  if (start < end) {
319
- const remove = this.client.removeRangeLocal(start, end);
320
- const op = remove ? (0, merge_tree_1.createGroupOp)(insert, remove) : insert;
321
- this.submitSequenceMessage(op);
322
- }
323
- else {
324
- this.submitSequenceMessage(insert);
317
+ this.client.removeRangeLocal(start, end);
325
318
  }
326
319
  }
327
320
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAAgF;AAChF,qEAAoE;AACpE,+EAA8F;AAM9F,2DA0BoC;AACpC,iEAA2F;AAC3F,2EAO4C;AAI5C,6CAAyD;AAGzD,6DAI8B;AAC9B,6DAAoF;AAGpF,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAClC,MAAM,WAAW,GAAG,SAAS,CAAC;AAkD9B,MAAsB,qBACrB,SAAQ,iCAA0C;IA0ElD,YACkB,gBAAwC,EAClD,EAAU,EACjB,UAA8B,EACd,eAAiD;QAEjE,KAAK,CAAC,EAAE,EAAE,gBAAgB,EAAE,UAAU,EAAE,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AAM,EAAE,GAAG,CAAC,CAAC;SACjD;IACF,CAAC;CACD;AA7rBD,sDA6rBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { Deferred, bufferToString, assert } from \"@fluidframework/common-utils\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\tClient,\n\tcreateAnnotateRangeOp,\n\tcreateGroupOp,\n\tcreateInsertOp,\n\tcreateRemoveRangeOp,\n\tICombiningOp,\n\tIJSONSegment,\n\tIMergeTreeAnnotateMsg,\n\tIMergeTreeDeltaOp,\n\tIMergeTreeGroupMsg,\n\tIMergeTreeOp,\n\tIMergeTreeRemoveMsg,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tLocalReferencePosition,\n\tmatchProperties,\n\tMergeTreeDeltaType,\n\tPropertySet,\n\tRangeStackMap,\n\tReferencePosition,\n\tReferenceType,\n\tMergeTreeRevertibleDriver,\n\tSegmentGroup,\n\tSlidingPreference,\n} from \"@fluidframework/merge-tree\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport {\n\tIFluidSerializer,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tSharedObject,\n\tISharedObjectEvents,\n\tSummarySerializer,\n} from \"@fluidframework/shared-object-base\";\nimport { IEventThisPlaceHolder } from \"@fluidframework/common-definitions\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\n\nimport { DefaultMap, IMapOperation } from \"./defaultMap\";\nimport { IMapMessageLocalMetadata, IValueChanged } from \"./defaultMapInterfaces\";\nimport { SequenceInterval } from \"./intervals\";\nimport {\n\tIIntervalCollection,\n\tIntervalCollection,\n\tSequenceIntervalCollectionValueType,\n} from \"./intervalCollection\";\nimport { SequenceDeltaEvent, SequenceMaintenanceEvent } from \"./sequenceDeltaEvent\";\nimport { ISharedIntervalCollection } from \"./sharedIntervalCollection\";\n\nconst snapshotFileName = \"header\";\nconst contentPath = \"content\";\n\n/**\n * Events emitted in response to changes to the sequence data.\n *\n * @remarks\n *\n * The following is the list of events emitted.\n *\n * ### \"sequenceDelta\"\n *\n * The sequenceDelta event is emitted when segments are inserted, annotated, or removed.\n *\n * #### Listener signature\n *\n * ```typescript\n * (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void\n * ```\n * - `event` - Various information on the segments that were modified.\n *\n * - `target` - The sequence itself.\n *\n * ### \"maintenance\"\n *\n * The maintenance event is emitted when segments are modified during merge-tree maintenance.\n *\n * #### Listener signature\n *\n * ```typescript\n * (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void\n * ```\n * - `event` - Various information on the segments that were modified.\n *\n * - `target` - The sequence itself.\n */\nexport interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"createIntervalCollection\",\n\t\tlistener: (label: string, local: boolean, target: IEventThisPlaceHolder) => void,\n\t);\n\t(\n\t\tevent: \"sequenceDelta\",\n\t\tlistener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void,\n\t);\n\t(\n\t\tevent: \"maintenance\",\n\t\tlistener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void,\n\t);\n}\n\nexport abstract class SharedSegmentSequence<T extends ISegment>\n\textends SharedObject<ISharedSegmentSequenceEvents>\n\timplements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver\n{\n\tget loaded(): Promise<void> {\n\t\treturn this.loadedDeferred.promise;\n\t}\n\n\tprivate static createOpsFromDelta(event: SequenceDeltaEvent): IMergeTreeDeltaOp[] {\n\t\tconst ops: IMergeTreeDeltaOp[] = [];\n\t\tfor (const r of event.ranges) {\n\t\t\tswitch (event.deltaOperation) {\n\t\t\t\tcase MergeTreeDeltaType.ANNOTATE: {\n\t\t\t\t\tconst lastAnnotate = ops[ops.length - 1] as IMergeTreeAnnotateMsg;\n\t\t\t\t\tconst props = {};\n\t\t\t\t\tfor (const key of Object.keys(r.propertyDeltas)) {\n\t\t\t\t\t\tprops[key] = r.segment.properties?.[key] ?? null;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tlastAnnotate &&\n\t\t\t\t\t\tlastAnnotate.pos2 === r.position &&\n\t\t\t\t\t\tmatchProperties(lastAnnotate.props, props)\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastAnnotate.pos2 += r.segment.cachedLength;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tops.push(\n\t\t\t\t\t\t\tcreateAnnotateRangeOp(\n\t\t\t\t\t\t\t\tr.position,\n\t\t\t\t\t\t\t\tr.position + r.segment.cachedLength,\n\t\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase MergeTreeDeltaType.INSERT:\n\t\t\t\t\tops.push(createInsertOp(r.position, r.segment.clone().toJSONObject()));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t\tconst lastRem = ops[ops.length - 1] as IMergeTreeRemoveMsg;\n\t\t\t\t\tif (lastRem?.pos1 === r.position) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tlastRem.pos2 !== undefined,\n\t\t\t\t\t\t\t0x3ff /* pos2 should not be undefined here */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlastRem.pos2 += r.segment.cachedLength;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tops.push(\n\t\t\t\t\t\t\tcreateRemoveRangeOp(r.position, r.position + r.segment.cachedLength),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t}\n\t\t}\n\t\treturn ops;\n\t}\n\n\tprotected client: Client;\n\t/** `Deferred` that triggers once the object is loaded */\n\tprotected loadedDeferred = new Deferred<void>();\n\t// cache out going ops created when partial loading\n\tprivate readonly loadedDeferredOutgoingOps: [IMergeTreeOp, SegmentGroup | SegmentGroup[]][] =\n\t\t[];\n\t// cache incoming ops that arrive when partial loading\n\tprivate deferIncomingOps = true;\n\tprivate readonly loadedDeferredIncomingOps: ISequencedDocumentMessage[] = [];\n\n\tprivate messagesSinceMSNChange: ISequencedDocumentMessage[] = [];\n\tprivate readonly intervalCollections: DefaultMap<IntervalCollection<SequenceInterval>>;\n\tconstructor(\n\t\tprivate readonly dataStoreRuntime: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t\tpublic readonly segmentFromSpec: (spec: IJSONSegment) => ISegment,\n\t) {\n\t\tsuper(id, dataStoreRuntime, attributes, \"fluid_sequence_\");\n\n\t\tthis.loadedDeferred.promise.catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"SequenceLoadFailed\" }, error);\n\t\t});\n\n\t\tthis.client = new Client(\n\t\t\tsegmentFromSpec,\n\t\t\tcreateChildLogger({\n\t\t\t\tlogger: this.logger,\n\t\t\t\tnamespace: \"SharedSegmentSequence.MergeTreeClient\",\n\t\t\t}),\n\t\t\tdataStoreRuntime.options,\n\t\t);\n\n\t\tthis.client.on(\"delta\", (opArgs, deltaArgs) => {\n\t\t\tthis.emit(\n\t\t\t\t\"sequenceDelta\",\n\t\t\t\tnew SequenceDeltaEvent(opArgs, deltaArgs, this.client),\n\t\t\t\tthis,\n\t\t\t);\n\t\t});\n\n\t\tthis.client.on(\"maintenance\", (args, opArgs) => {\n\t\t\tthis.emit(\"maintenance\", new SequenceMaintenanceEvent(opArgs, args, this.client), this);\n\t\t});\n\n\t\tthis.intervalCollections = new DefaultMap(\n\t\t\tthis.serializer,\n\t\t\tthis.handle,\n\t\t\t(op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n\t\t\tnew SequenceIntervalCollectionValueType(),\n\t\t\tdataStoreRuntime.options,\n\t\t);\n\t}\n\n\t/**\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to remove\n\t */\n\tpublic removeRange(start: number, end: number): IMergeTreeRemoveMsg {\n\t\tconst removeOp = this.client.removeRangeLocal(start, end);\n\t\tthis.submitSequenceMessage(removeOp);\n\t\treturn removeOp;\n\t}\n\n\tpublic groupOperation(groupOp: IMergeTreeGroupMsg) {\n\t\tthis.client.localTransaction(groupOp);\n\t\tthis.submitSequenceMessage(groupOp);\n\t}\n\n\t/**\n\t * Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.\n\t * If the position is past the end of the string, `segment` and `offset` on the returned object may be undefined.\n\t * @param pos - Character position (index) into the current local view of the SharedString.\n\t */\n\tpublic getContainingSegment(pos: number): {\n\t\tsegment: T | undefined;\n\t\toffset: number | undefined;\n\t} {\n\t\treturn this.client.getContainingSegment<T>(pos);\n\t}\n\n\t/**\n\t * Returns the length of the current sequence for the client\n\t */\n\tpublic getLength() {\n\t\treturn this.client.getLength();\n\t}\n\n\t/**\n\t * Returns the current position of a segment, and -1 if the segment\n\t * does not exist in this sequence\n\t * @param segment - The segment to get the position of\n\t */\n\tpublic getPosition(segment: ISegment): number {\n\t\treturn this.client.getPosition(segment);\n\t}\n\n\t/**\n\t * Annotates the range with the provided properties\n\t *\n\t * @param start - The inclusive start position of the range to annotate\n\t * @param end - The exclusive end position of the range to annotate\n\t * @param props - The properties to annotate the range with\n\t * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n\t *\n\t */\n\tpublic annotateRange(\n\t\tstart: number,\n\t\tend: number,\n\t\tprops: PropertySet,\n\t\tcombiningOp?: ICombiningOp,\n\t) {\n\t\tconst annotateOp = this.client.annotateRangeLocal(start, end, props, combiningOp);\n\t\tif (annotateOp) {\n\t\t\tthis.submitSequenceMessage(annotateOp);\n\t\t}\n\t}\n\n\tpublic getPropertiesAtPosition(pos: number) {\n\t\treturn this.client.getPropertiesAtPosition(pos);\n\t}\n\n\tpublic getRangeExtentsOfPosition(pos: number) {\n\t\treturn this.client.getRangeExtentsOfPosition(pos);\n\t}\n\n\t/**\n\t * Creates a `LocalReferencePosition` on this SharedString. If the refType does not include\n\t * ReferenceType.Transient, the returned reference will be added to the localRefs on the provided segment.\n\t * @param segment - Segment to add the local reference on\n\t * @param offset - Offset on the segment at which to place the local reference\n\t * @param refType - ReferenceType for the created local reference\n\t * @param properties - PropertySet to place on the created local reference\n\t */\n\tpublic createLocalReferencePosition(\n\t\tsegment: T,\n\t\toffset: number,\n\t\trefType: ReferenceType,\n\t\tproperties: PropertySet | undefined,\n\t\tslidingPreference?: SlidingPreference,\n\t): LocalReferencePosition {\n\t\treturn this.client.createLocalReferencePosition(\n\t\t\tsegment,\n\t\t\toffset,\n\t\t\trefType,\n\t\t\tproperties,\n\t\t\tslidingPreference,\n\t\t);\n\t}\n\n\t/**\n\t * Resolves a `ReferencePosition` into a character position using this client's perspective.\n\t */\n\tpublic localReferencePositionToPosition(lref: ReferencePosition): number {\n\t\treturn this.client.localReferencePositionToPosition(lref);\n\t}\n\n\t/**\n\t * Removes a `LocalReferencePosition` from this SharedString.\n\t */\n\tpublic removeLocalReferencePosition(lref: LocalReferencePosition) {\n\t\treturn this.client.removeLocalReferencePosition(lref);\n\t}\n\n\t/**\n\t * Resolves a remote client's position against the local sequence\n\t * and returns the remote client's position relative to the local\n\t * sequence. The client ref seq must be above the minimum sequence number\n\t * or the return value will be undefined.\n\t * Generally this method is used in conjunction with signals which provide\n\t * point in time values for the below parameters, and is useful for things\n\t * like displaying user position. It should not be used with persisted values\n\t * as persisted values will quickly become invalid as the remoteClientRefSeq\n\t * moves below the minimum sequence number\n\t * @param remoteClientPosition - The remote client's position to resolve\n\t * @param remoteClientRefSeq - The reference sequence number of the remote client\n\t * @param remoteClientId - The client id of the remote client\n\t */\n\tpublic resolveRemoteClientPosition(\n\t\tremoteClientPosition: number,\n\t\tremoteClientRefSeq: number,\n\t\tremoteClientId: string,\n\t): number | undefined {\n\t\treturn this.client.resolveRemoteClientPosition(\n\t\t\tremoteClientPosition,\n\t\t\tremoteClientRefSeq,\n\t\t\tremoteClientId,\n\t\t);\n\t}\n\n\tpublic submitSequenceMessage(message: IMergeTreeOp) {\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\t\tconst translated = makeHandlesSerializable(message, this.serializer, this.handle);\n\t\tconst metadata = this.client.peekPendingSegmentGroups(\n\t\t\tmessage.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1,\n\t\t);\n\n\t\t// if loading isn't complete, we need to cache\n\t\t// local ops until loading is complete, and then\n\t\t// they will be resent\n\t\tif (!this.loadedDeferred.isCompleted) {\n\t\t\tthis.loadedDeferredOutgoingOps.push(metadata ? [translated, metadata] : translated);\n\t\t} else {\n\t\t\tthis.submitLocalMessage(translated, metadata);\n\t\t}\n\t}\n\n\t/**\n\t * Given a position specified relative to a marker id, lookup the marker\n\t * and convert the position to a character position.\n\t * @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.\n\t */\n\tpublic posFromRelativePos(relativePos: IRelativePosition) {\n\t\treturn this.client.posFromRelativePos(relativePos);\n\t}\n\n\t/**\n\t * Walk the underlying segments of the sequence.\n\t * The walked segments may extend beyond the range\n\t * if the segments cross the ranges start or end boundaries.\n\t * Set split range to true to ensure only segments within the\n\t * range are walked.\n\t *\n\t * @param handler - The function to handle each segment\n\t * @param start - Optional. The start of range walk.\n\t * @param end - Optional. The end of range walk\n\t * @param accum - Optional. An object that will be passed to the handler for accumulation\n\t * @param splitRange - Optional. Splits boundary segments on the range boundaries\n\t */\n\tpublic walkSegments<TClientData>(\n\t\thandler: ISegmentAction<TClientData>,\n\t\tstart?: number,\n\t\tend?: number,\n\t\taccum?: TClientData,\n\t\tsplitRange: boolean = false,\n\t): void {\n\t\tthis.client.walkSegments(handler, start, end, accum as TClientData, splitRange);\n\t}\n\n\tpublic getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap {\n\t\treturn this.client.getStackContext(startPos, rangeLabels);\n\t}\n\n\t/**\n\t * @returns - The most recent sequence number which has been acked by the server and processed by this\n\t * SharedSegmentSequence.\n\t */\n\tpublic getCurrentSeq() {\n\t\treturn this.client.getCurrentSeq();\n\t}\n\n\t/**\n\t * Inserts a segment directly before a `ReferencePosition`.\n\t * @param refPos - The reference position to insert the segment at\n\t * @param segment - The segment to insert\n\t */\n\tpublic insertAtReferencePosition(pos: ReferencePosition, segment: T) {\n\t\tconst insertOp = this.client.insertAtReferencePositionLocal(pos, segment);\n\t\tif (insertOp) {\n\t\t\tthis.submitSequenceMessage(insertOp);\n\t\t}\n\t}\n\t/**\n\t * Inserts a segment\n\t * @param start - The position to insert the segment at\n\t * @param spec - The segment to inserts spec\n\t */\n\tpublic insertFromSpec(pos: number, spec: IJSONSegment) {\n\t\tconst segment = this.segmentFromSpec(spec);\n\t\tconst insertOp = this.client.insertSegmentLocal(pos, segment);\n\t\tif (insertOp) {\n\t\t\tthis.submitSequenceMessage(insertOp);\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the interval collection keyed on `label`. If no such interval collection exists,\n\t * creates one.\n\t */\n\tpublic getIntervalCollection(label: string): IIntervalCollection<SequenceInterval> {\n\t\treturn this.intervalCollections.get(label);\n\t}\n\n\t/**\n\t * @returns An iterable object that enumerates the IntervalCollection labels.\n\t *\n\t * @example\n\t * ```typescript\n\t * const iter = this.getIntervalCollectionKeys();\n\t * for (key of iter)\n\t * const collection = this.getIntervalCollection(key);\n\t * ...\n\t * ```\n\t */\n\tpublic getIntervalCollectionLabels(): IterableIterator<string> {\n\t\treturn this.intervalCollections.keys();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\t// conditionally write the interval collection blob\n\t\t// only if it has entries\n\t\tif (this.intervalCollections.size > 0) {\n\t\t\tbuilder.addBlob(snapshotFileName, this.intervalCollections.serialize(serializer));\n\t\t}\n\n\t\tbuilder.addWithStats(contentPath, this.summarizeMergeTree(serializer));\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Runs serializer over the GC data for this SharedMatrix.\n\t * All the IFluidHandle's represent routes to other objects.\n\t */\n\tprotected processGCDataCore(serializer: SummarySerializer) {\n\t\tif (this.intervalCollections.size > 0) {\n\t\t\tthis.intervalCollections.serialize(serializer);\n\t\t}\n\n\t\tthis.client.serializeGCData(this.handle, serializer);\n\t}\n\n\t/**\n\t * Replace the range specified from start to end with the provided segment\n\t * This is done by inserting the segment at the end of the range, followed\n\t * by removing the contents of the range\n\t * For a zero or reverse range (start \\>= end), insert at end do not remove anything\n\t * @param start - The start of the range to replace\n\t * @param end - The end of the range to replace\n\t * @param segment - The segment that will replace the range\n\t */\n\tprotected replaceRange(start: number, end: number, segment: ISegment) {\n\t\t// Insert at the max end of the range when start > end, but still remove the range later\n\t\tconst insertIndex: number = Math.max(start, end);\n\n\t\t// Insert first, so local references can slide to the inserted seg if any\n\t\tconst insert = this.client.insertSegmentLocal(insertIndex, segment);\n\t\tif (insert) {\n\t\t\tif (start < end) {\n\t\t\t\tconst remove = this.client.removeRangeLocal(start, end);\n\t\t\t\tconst op = remove ? createGroupOp(insert, remove) : insert;\n\t\t\t\tthis.submitSequenceMessage(op);\n\t\t\t} else {\n\t\t\t\tthis.submitSequenceMessage(insert);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}\n\t */\n\tprotected onConnect() {\n\t\t// Update merge tree collaboration information with new client ID and then resend pending ops\n\t\tthis.client.startOrUpdateCollaboration(this.runtime.clientId);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n\t */\n\tprotected reSubmitCore(content: any, localOpMetadata: unknown) {\n\t\tif (\n\t\t\t!this.intervalCollections.tryResubmitMessage(\n\t\t\t\tcontent,\n\t\t\t\tlocalOpMetadata as IMapMessageLocalMetadata,\n\t\t\t)\n\t\t) {\n\t\t\tthis.submitSequenceMessage(\n\t\t\t\tthis.client.regeneratePendingOp(\n\t\t\t\t\tcontent as IMergeTreeOp,\n\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService) {\n\t\tif (await storage.contains(snapshotFileName)) {\n\t\t\tconst blob = await storage.readBlob(snapshotFileName);\n\t\t\tconst header = bufferToString(blob, \"utf8\");\n\t\t\tthis.intervalCollections.populate(header);\n\t\t}\n\n\t\ttry {\n\t\t\t// this will load the header, and return a promise\n\t\t\t// that will resolve when the body is loaded\n\t\t\t// and the catchup ops are available.\n\t\t\tconst { catchupOpsP } = await this.client.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, contentPath),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\n\t\t\t// setup a promise to process the\n\t\t\t// catch up ops, and finishing the loading process\n\t\t\tconst loadCatchUpOps = catchupOpsP\n\t\t\t\t.then((msgs) => {\n\t\t\t\t\tmsgs.forEach((m) => {\n\t\t\t\t\t\tconst collabWindow = this.client.getCollabWindow();\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tm.minimumSequenceNumber < collabWindow.minSeq ||\n\t\t\t\t\t\t\tm.referenceSequenceNumber < collabWindow.minSeq ||\n\t\t\t\t\t\t\tm.sequenceNumber <= collabWindow.minSeq ||\n\t\t\t\t\t\t\tm.sequenceNumber <= collabWindow.currentSeq\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Invalid catchup operations in snapshot: ${JSON.stringify({\n\t\t\t\t\t\t\t\t\top: {\n\t\t\t\t\t\t\t\t\t\tseq: m.sequenceNumber,\n\t\t\t\t\t\t\t\t\t\tminSeq: m.minimumSequenceNumber,\n\t\t\t\t\t\t\t\t\t\trefSeq: m.referenceSequenceNumber,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tcollabWindow: {\n\t\t\t\t\t\t\t\t\t\tseq: collabWindow.currentSeq,\n\t\t\t\t\t\t\t\t\t\tminSeq: collabWindow.minSeq,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t})}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.processMergeTreeMsg(m);\n\t\t\t\t\t});\n\t\t\t\t\tthis.loadFinished();\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.loadFinished(error);\n\t\t\t\t});\n\t\t\tif (this.dataStoreRuntime.options?.sequenceInitializeFromHeaderOnly !== true) {\n\t\t\t\t// if we not doing partial load, await the catch up ops,\n\t\t\t\t// and the finalization of the load\n\t\t\t\tawait loadCatchUpOps;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.loadFinished(error);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\t// if loading isn't complete, we need to cache all\n\t\t// incoming ops to be applied after loading is complete\n\t\tif (this.deferIncomingOps) {\n\t\t\tassert(!local, 0x072 /* \"Unexpected local op when loading not finished\" */);\n\t\t\tthis.loadedDeferredIncomingOps.push(message);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tmessage.type === MessageType.Operation,\n\t\t\t\t0x073 /* \"Sequence message not operation\" */,\n\t\t\t);\n\n\t\t\tconst handled = this.intervalCollections.tryProcessMessage(\n\t\t\t\tmessage.contents as IMapOperation,\n\t\t\t\tlocal,\n\t\t\t\tmessage,\n\t\t\t\tlocalOpMetadata,\n\t\t\t);\n\n\t\t\tif (!handled) {\n\t\t\t\tthis.processMergeTreeMsg(message, local);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.didAttach}\n\t */\n\tprotected didAttach() {\n\t\t// If we are not local, and we've attached we need to start generating and sending ops\n\t\t// so start collaboration and provide a default client id incase we are not connected\n\t\tif (this.isAttached()) {\n\t\t\tthis.client.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.initializeLocalCore}\n\t */\n\tprotected initializeLocalCore() {\n\t\tsuper.initializeLocalCore();\n\t\tthis.loadFinished();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(content: any): unknown {\n\t\treturn this.client.applyStashedOp(content);\n\t}\n\n\tprivate summarizeMergeTree(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Are we fully loaded? If not, things will go south\n\t\tassert(\n\t\t\tthis.loadedDeferred.isCompleted,\n\t\t\t0x074 /* \"Snapshot called when not fully loaded\" */,\n\t\t);\n\t\tconst minSeq = this.runtime.deltaManager.minimumSequenceNumber;\n\n\t\tthis.processMinSequenceNumberChanged(minSeq);\n\n\t\tthis.messagesSinceMSNChange.forEach((m) => {\n\t\t\tm.minimumSequenceNumber = minSeq;\n\t\t});\n\n\t\treturn this.client.summarize(\n\t\t\tthis.runtime,\n\t\t\tthis.handle,\n\t\t\tserializer,\n\t\t\tthis.messagesSinceMSNChange,\n\t\t);\n\t}\n\n\tprivate processMergeTreeMsg(rawMessage: ISequencedDocumentMessage, local?: boolean) {\n\t\tconst message = parseHandles(rawMessage, this.serializer);\n\n\t\tconst ops: IMergeTreeDeltaOp[] = [];\n\t\tfunction transformOps(event: SequenceDeltaEvent) {\n\t\t\tops.push(...SharedSegmentSequence.createOpsFromDelta(event));\n\t\t}\n\t\tconst needsTransformation = message.referenceSequenceNumber !== message.sequenceNumber - 1;\n\t\tlet stashMessage: Readonly<ISequencedDocumentMessage> = message;\n\t\tif (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {\n\t\t\tif (needsTransformation) {\n\t\t\t\tthis.on(\"sequenceDelta\", transformOps);\n\t\t\t}\n\t\t}\n\n\t\tthis.client.applyMsg(message, local);\n\n\t\tif (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {\n\t\t\tif (needsTransformation) {\n\t\t\t\tthis.removeListener(\"sequenceDelta\", transformOps);\n\t\t\t\t// shallow clone the message as we only overwrite top level properties,\n\t\t\t\t// like referenceSequenceNumber and content only\n\t\t\t\tstashMessage = {\n\t\t\t\t\t...message,\n\t\t\t\t\treferenceSequenceNumber: stashMessage.sequenceNumber - 1,\n\t\t\t\t\tcontents: ops.length !== 1 ? createGroupOp(...ops) : ops[0],\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthis.messagesSinceMSNChange.push(stashMessage);\n\n\t\t\t// Do GC every once in a while...\n\t\t\tif (\n\t\t\t\tthis.messagesSinceMSNChange.length > 20 &&\n\t\t\t\tthis.messagesSinceMSNChange[20].sequenceNumber < message.minimumSequenceNumber\n\t\t\t) {\n\t\t\t\tthis.processMinSequenceNumberChanged(message.minimumSequenceNumber);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processMinSequenceNumberChanged(minSeq: number) {\n\t\tlet index = 0;\n\t\tfor (; index < this.messagesSinceMSNChange.length; index++) {\n\t\t\tif (this.messagesSinceMSNChange[index].sequenceNumber > minSeq) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (index !== 0) {\n\t\t\tthis.messagesSinceMSNChange = this.messagesSinceMSNChange.slice(index);\n\t\t}\n\t}\n\n\tprivate loadFinished(error?: any) {\n\t\tif (!this.loadedDeferred.isCompleted) {\n\t\t\t// Initialize the interval collections\n\t\t\tthis.initializeIntervalCollections();\n\t\t\tif (error) {\n\t\t\t\tthis.loadedDeferred.reject(error);\n\t\t\t\tthrow error;\n\t\t\t} else {\n\t\t\t\t// it is important this series remains synchronous\n\t\t\t\t// first we stop deferring incoming ops, and apply then all\n\t\t\t\tthis.deferIncomingOps = false;\n\t\t\t\tfor (const message of this.loadedDeferredIncomingOps) {\n\t\t\t\t\tthis.processCore(message, false, undefined);\n\t\t\t\t}\n\t\t\t\tthis.loadedDeferredIncomingOps.length = 0;\n\n\t\t\t\t// then resolve the loaded promise\n\t\t\t\t// and resubmit all the outstanding ops, as the snapshot\n\t\t\t\t// is fully loaded, and all outstanding ops are applied\n\t\t\t\tthis.loadedDeferred.resolve();\n\n\t\t\t\tfor (const [messageContent, opMetadata] of this.loadedDeferredOutgoingOps) {\n\t\t\t\t\tthis.reSubmitCore(messageContent, opMetadata);\n\t\t\t\t}\n\t\t\t\tthis.loadedDeferredOutgoingOps.length = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate initializeIntervalCollections() {\n\t\t// Listen and initialize new SharedIntervalCollections\n\t\tthis.intervalCollections.eventEmitter.on(\n\t\t\t\"create\",\n\t\t\t({ key, previousValue }: IValueChanged, local: boolean) => {\n\t\t\t\tconst intervalCollection = this.intervalCollections.get(key);\n\t\t\t\tif (!intervalCollection.attached) {\n\t\t\t\t\tintervalCollection.attachGraph(this.client, key);\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tpreviousValue === undefined,\n\t\t\t\t\t0x2c1 /* \"Creating an interval collection that already exists?\" */,\n\t\t\t\t);\n\t\t\t\tthis.emit(\"createIntervalCollection\", key, local, this);\n\t\t\t},\n\t\t);\n\n\t\t// Initialize existing SharedIntervalCollections\n\t\tfor (const key of this.intervalCollections.keys()) {\n\t\t\tconst intervalCollection = this.intervalCollections.get(key);\n\t\t\tintervalCollection.attachGraph(this.client, key);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAAgF;AAChF,qEAAoE;AACpE,+EAA8F;AAM9F,2DA0BoC;AACpC,iEAA2F;AAC3F,2EAO4C;AAI5C,6CAAyD;AAGzD,6DAI8B;AAC9B,6DAAoF;AAGpF,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAClC,MAAM,WAAW,GAAG,SAAS,CAAC;AAkD9B,MAAsB,qBACrB,SAAQ,iCAA0C;IA0ElD,YACkB,gBAAwC,EAClD,EAAU,EACjB,UAA8B,EACd,eAAiD;QAEjE,KAAK,CAAC,EAAE,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;QAL1C,qBAAgB,GAAhB,gBAAgB,CAAwB;QAClD,OAAE,GAAF,EAAE,CAAQ;QAED,oBAAe,GAAf,eAAe,CAAkC;QAflE,yDAAyD;QAC/C,mBAAc,GAAG,IAAI,uBAAQ,EAAQ,CAAC;QAChD,mDAAmD;QAClC,8BAAyB,GACzC,EAAE,CAAC;QACJ,sDAAsD;QAC9C,qBAAgB,GAAG,IAAI,CAAC;QACf,8BAAyB,GAAgC,EAAE,CAAC;QAErE,2BAAsB,GAAgC,EAAE,CAAC;QAUhE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAC3C,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,EAAE,KAAK,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAM,CACvB,eAAe,EACf,IAAA,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MAAM,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7D,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACjD;IACF,CAAC;CACD;AAnrBD,sDAmrBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { Deferred, bufferToString, assert } from \"@fluidframework/common-utils\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\tClient,\n\tcreateAnnotateRangeOp,\n\tcreateGroupOp,\n\tcreateInsertOp,\n\tcreateRemoveRangeOp,\n\tICombiningOp,\n\tIJSONSegment,\n\tIMergeTreeAnnotateMsg,\n\tIMergeTreeDeltaOp,\n\tIMergeTreeGroupMsg,\n\tIMergeTreeOp,\n\tIMergeTreeRemoveMsg,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tLocalReferencePosition,\n\tmatchProperties,\n\tMergeTreeDeltaType,\n\tPropertySet,\n\tRangeStackMap,\n\tReferencePosition,\n\tReferenceType,\n\tMergeTreeRevertibleDriver,\n\tSegmentGroup,\n\tSlidingPreference,\n} from \"@fluidframework/merge-tree\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport {\n\tIFluidSerializer,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tSharedObject,\n\tISharedObjectEvents,\n\tSummarySerializer,\n} from \"@fluidframework/shared-object-base\";\nimport { IEventThisPlaceHolder } from \"@fluidframework/common-definitions\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\n\nimport { DefaultMap, IMapOperation } from \"./defaultMap\";\nimport { IMapMessageLocalMetadata, IValueChanged } from \"./defaultMapInterfaces\";\nimport { SequenceInterval } from \"./intervals\";\nimport {\n\tIIntervalCollection,\n\tIntervalCollection,\n\tSequenceIntervalCollectionValueType,\n} from \"./intervalCollection\";\nimport { SequenceDeltaEvent, SequenceMaintenanceEvent } from \"./sequenceDeltaEvent\";\nimport { ISharedIntervalCollection } from \"./sharedIntervalCollection\";\n\nconst snapshotFileName = \"header\";\nconst contentPath = \"content\";\n\n/**\n * Events emitted in response to changes to the sequence data.\n *\n * @remarks\n *\n * The following is the list of events emitted.\n *\n * ### \"sequenceDelta\"\n *\n * The sequenceDelta event is emitted when segments are inserted, annotated, or removed.\n *\n * #### Listener signature\n *\n * ```typescript\n * (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void\n * ```\n * - `event` - Various information on the segments that were modified.\n *\n * - `target` - The sequence itself.\n *\n * ### \"maintenance\"\n *\n * The maintenance event is emitted when segments are modified during merge-tree maintenance.\n *\n * #### Listener signature\n *\n * ```typescript\n * (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void\n * ```\n * - `event` - Various information on the segments that were modified.\n *\n * - `target` - The sequence itself.\n */\nexport interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"createIntervalCollection\",\n\t\tlistener: (label: string, local: boolean, target: IEventThisPlaceHolder) => void,\n\t);\n\t(\n\t\tevent: \"sequenceDelta\",\n\t\tlistener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void,\n\t);\n\t(\n\t\tevent: \"maintenance\",\n\t\tlistener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void,\n\t);\n}\n\nexport abstract class SharedSegmentSequence<T extends ISegment>\n\textends SharedObject<ISharedSegmentSequenceEvents>\n\timplements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver\n{\n\tget loaded(): Promise<void> {\n\t\treturn this.loadedDeferred.promise;\n\t}\n\n\tprivate static createOpsFromDelta(event: SequenceDeltaEvent): IMergeTreeDeltaOp[] {\n\t\tconst ops: IMergeTreeDeltaOp[] = [];\n\t\tfor (const r of event.ranges) {\n\t\t\tswitch (event.deltaOperation) {\n\t\t\t\tcase MergeTreeDeltaType.ANNOTATE: {\n\t\t\t\t\tconst lastAnnotate = ops[ops.length - 1] as IMergeTreeAnnotateMsg;\n\t\t\t\t\tconst props = {};\n\t\t\t\t\tfor (const key of Object.keys(r.propertyDeltas)) {\n\t\t\t\t\t\tprops[key] = r.segment.properties?.[key] ?? null;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tlastAnnotate &&\n\t\t\t\t\t\tlastAnnotate.pos2 === r.position &&\n\t\t\t\t\t\tmatchProperties(lastAnnotate.props, props)\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastAnnotate.pos2 += r.segment.cachedLength;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tops.push(\n\t\t\t\t\t\t\tcreateAnnotateRangeOp(\n\t\t\t\t\t\t\t\tr.position,\n\t\t\t\t\t\t\t\tr.position + r.segment.cachedLength,\n\t\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase MergeTreeDeltaType.INSERT:\n\t\t\t\t\tops.push(createInsertOp(r.position, r.segment.clone().toJSONObject()));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t\tconst lastRem = ops[ops.length - 1] as IMergeTreeRemoveMsg;\n\t\t\t\t\tif (lastRem?.pos1 === r.position) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tlastRem.pos2 !== undefined,\n\t\t\t\t\t\t\t0x3ff /* pos2 should not be undefined here */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlastRem.pos2 += r.segment.cachedLength;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tops.push(\n\t\t\t\t\t\t\tcreateRemoveRangeOp(r.position, r.position + r.segment.cachedLength),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t}\n\t\t}\n\t\treturn ops;\n\t}\n\n\tprotected client: Client;\n\t/** `Deferred` that triggers once the object is loaded */\n\tprotected loadedDeferred = new Deferred<void>();\n\t// cache out going ops created when partial loading\n\tprivate readonly loadedDeferredOutgoingOps: [IMergeTreeOp, SegmentGroup | SegmentGroup[]][] =\n\t\t[];\n\t// cache incoming ops that arrive when partial loading\n\tprivate deferIncomingOps = true;\n\tprivate readonly loadedDeferredIncomingOps: ISequencedDocumentMessage[] = [];\n\n\tprivate messagesSinceMSNChange: ISequencedDocumentMessage[] = [];\n\tprivate readonly intervalCollections: DefaultMap<IntervalCollection<SequenceInterval>>;\n\tconstructor(\n\t\tprivate readonly dataStoreRuntime: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t\tpublic readonly segmentFromSpec: (spec: IJSONSegment) => ISegment,\n\t) {\n\t\tsuper(id, dataStoreRuntime, attributes, \"fluid_sequence_\");\n\n\t\tthis.loadedDeferred.promise.catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"SequenceLoadFailed\" }, error);\n\t\t});\n\n\t\tthis.client = new Client(\n\t\t\tsegmentFromSpec,\n\t\t\tcreateChildLogger({\n\t\t\t\tlogger: this.logger,\n\t\t\t\tnamespace: \"SharedSegmentSequence.MergeTreeClient\",\n\t\t\t}),\n\t\t\tdataStoreRuntime.options,\n\t\t);\n\n\t\tthis.client.prependListener(\"delta\", (opArgs, deltaArgs) => {\n\t\t\tconst event = new SequenceDeltaEvent(opArgs, deltaArgs, this.client);\n\t\t\tif (opArgs.stashed !== true && event.isLocal) {\n\t\t\t\tthis.submitSequenceMessage(opArgs.op);\n\t\t\t}\n\t\t\tthis.emit(\"sequenceDelta\", event, this);\n\t\t});\n\n\t\tthis.client.on(\"maintenance\", (args, opArgs) => {\n\t\t\tthis.emit(\"maintenance\", new SequenceMaintenanceEvent(opArgs, args, this.client), this);\n\t\t});\n\n\t\tthis.intervalCollections = new DefaultMap(\n\t\t\tthis.serializer,\n\t\t\tthis.handle,\n\t\t\t(op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n\t\t\tnew SequenceIntervalCollectionValueType(),\n\t\t\tdataStoreRuntime.options,\n\t\t);\n\t}\n\n\t/**\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to remove\n\t */\n\tpublic removeRange(start: number, end: number): IMergeTreeRemoveMsg {\n\t\treturn this.client.removeRangeLocal(start, end);\n\t}\n\n\t/**\n\t * @deprecated - The ability to create group ops will be removed in an upcoming release, as group ops are redundant with the native batching capabilities of the runtime\n\t */\n\tpublic groupOperation(groupOp: IMergeTreeGroupMsg) {\n\t\tthis.client.localTransaction(groupOp);\n\t}\n\n\t/**\n\t * Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.\n\t * If the position is past the end of the string, `segment` and `offset` on the returned object may be undefined.\n\t * @param pos - Character position (index) into the current local view of the SharedString.\n\t */\n\tpublic getContainingSegment(pos: number): {\n\t\tsegment: T | undefined;\n\t\toffset: number | undefined;\n\t} {\n\t\treturn this.client.getContainingSegment<T>(pos);\n\t}\n\n\t/**\n\t * Returns the length of the current sequence for the client\n\t */\n\tpublic getLength() {\n\t\treturn this.client.getLength();\n\t}\n\n\t/**\n\t * Returns the current position of a segment, and -1 if the segment\n\t * does not exist in this sequence\n\t * @param segment - The segment to get the position of\n\t */\n\tpublic getPosition(segment: ISegment): number {\n\t\treturn this.client.getPosition(segment);\n\t}\n\n\t/**\n\t * Annotates the range with the provided properties\n\t *\n\t * @param start - The inclusive start position of the range to annotate\n\t * @param end - The exclusive end position of the range to annotate\n\t * @param props - The properties to annotate the range with\n\t * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n\t *\n\t */\n\tpublic annotateRange(\n\t\tstart: number,\n\t\tend: number,\n\t\tprops: PropertySet,\n\t\tcombiningOp?: ICombiningOp,\n\t) {\n\t\tthis.client.annotateRangeLocal(start, end, props, combiningOp);\n\t}\n\n\tpublic getPropertiesAtPosition(pos: number) {\n\t\treturn this.client.getPropertiesAtPosition(pos);\n\t}\n\n\tpublic getRangeExtentsOfPosition(pos: number) {\n\t\treturn this.client.getRangeExtentsOfPosition(pos);\n\t}\n\n\t/**\n\t * Creates a `LocalReferencePosition` on this SharedString. If the refType does not include\n\t * ReferenceType.Transient, the returned reference will be added to the localRefs on the provided segment.\n\t * @param segment - Segment to add the local reference on\n\t * @param offset - Offset on the segment at which to place the local reference\n\t * @param refType - ReferenceType for the created local reference\n\t * @param properties - PropertySet to place on the created local reference\n\t */\n\tpublic createLocalReferencePosition(\n\t\tsegment: T,\n\t\toffset: number,\n\t\trefType: ReferenceType,\n\t\tproperties: PropertySet | undefined,\n\t\tslidingPreference?: SlidingPreference,\n\t): LocalReferencePosition {\n\t\treturn this.client.createLocalReferencePosition(\n\t\t\tsegment,\n\t\t\toffset,\n\t\t\trefType,\n\t\t\tproperties,\n\t\t\tslidingPreference,\n\t\t);\n\t}\n\n\t/**\n\t * Resolves a `ReferencePosition` into a character position using this client's perspective.\n\t */\n\tpublic localReferencePositionToPosition(lref: ReferencePosition): number {\n\t\treturn this.client.localReferencePositionToPosition(lref);\n\t}\n\n\t/**\n\t * Removes a `LocalReferencePosition` from this SharedString.\n\t */\n\tpublic removeLocalReferencePosition(lref: LocalReferencePosition) {\n\t\treturn this.client.removeLocalReferencePosition(lref);\n\t}\n\n\t/**\n\t * Resolves a remote client's position against the local sequence\n\t * and returns the remote client's position relative to the local\n\t * sequence. The client ref seq must be above the minimum sequence number\n\t * or the return value will be undefined.\n\t * Generally this method is used in conjunction with signals which provide\n\t * point in time values for the below parameters, and is useful for things\n\t * like displaying user position. It should not be used with persisted values\n\t * as persisted values will quickly become invalid as the remoteClientRefSeq\n\t * moves below the minimum sequence number\n\t * @param remoteClientPosition - The remote client's position to resolve\n\t * @param remoteClientRefSeq - The reference sequence number of the remote client\n\t * @param remoteClientId - The client id of the remote client\n\t */\n\tpublic resolveRemoteClientPosition(\n\t\tremoteClientPosition: number,\n\t\tremoteClientRefSeq: number,\n\t\tremoteClientId: string,\n\t): number | undefined {\n\t\treturn this.client.resolveRemoteClientPosition(\n\t\t\tremoteClientPosition,\n\t\t\tremoteClientRefSeq,\n\t\t\tremoteClientId,\n\t\t);\n\t}\n\n\t/**\n\t * @deprecated - This method will no longer be public in an upcoming release as it is not safe to use outside of this class\n\t */\n\tpublic submitSequenceMessage(message: IMergeTreeOp) {\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\t\tconst translated = makeHandlesSerializable(message, this.serializer, this.handle);\n\t\tconst metadata = this.client.peekPendingSegmentGroups(\n\t\t\tmessage.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1,\n\t\t);\n\n\t\t// if loading isn't complete, we need to cache\n\t\t// local ops until loading is complete, and then\n\t\t// they will be resent\n\t\tif (!this.loadedDeferred.isCompleted) {\n\t\t\tthis.loadedDeferredOutgoingOps.push(metadata ? [translated, metadata] : translated);\n\t\t} else {\n\t\t\tthis.submitLocalMessage(translated, metadata);\n\t\t}\n\t}\n\n\t/**\n\t * Given a position specified relative to a marker id, lookup the marker\n\t * and convert the position to a character position.\n\t * @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.\n\t */\n\tpublic posFromRelativePos(relativePos: IRelativePosition) {\n\t\treturn this.client.posFromRelativePos(relativePos);\n\t}\n\n\t/**\n\t * Walk the underlying segments of the sequence.\n\t * The walked segments may extend beyond the range\n\t * if the segments cross the ranges start or end boundaries.\n\t * Set split range to true to ensure only segments within the\n\t * range are walked.\n\t *\n\t * @param handler - The function to handle each segment\n\t * @param start - Optional. The start of range walk.\n\t * @param end - Optional. The end of range walk\n\t * @param accum - Optional. An object that will be passed to the handler for accumulation\n\t * @param splitRange - Optional. Splits boundary segments on the range boundaries\n\t */\n\tpublic walkSegments<TClientData>(\n\t\thandler: ISegmentAction<TClientData>,\n\t\tstart?: number,\n\t\tend?: number,\n\t\taccum?: TClientData,\n\t\tsplitRange: boolean = false,\n\t): void {\n\t\tthis.client.walkSegments(handler, start, end, accum as TClientData, splitRange);\n\t}\n\n\tpublic getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap {\n\t\treturn this.client.getStackContext(startPos, rangeLabels);\n\t}\n\n\t/**\n\t * @returns - The most recent sequence number which has been acked by the server and processed by this\n\t * SharedSegmentSequence.\n\t */\n\tpublic getCurrentSeq() {\n\t\treturn this.client.getCurrentSeq();\n\t}\n\n\t/**\n\t * Inserts a segment directly before a `ReferencePosition`.\n\t * @param refPos - The reference position to insert the segment at\n\t * @param segment - The segment to insert\n\t */\n\tpublic insertAtReferencePosition(pos: ReferencePosition, segment: T) {\n\t\tthis.client.insertAtReferencePositionLocal(pos, segment);\n\t}\n\t/**\n\t * Inserts a segment\n\t * @param start - The position to insert the segment at\n\t * @param spec - The segment to inserts spec\n\t */\n\tpublic insertFromSpec(pos: number, spec: IJSONSegment) {\n\t\tconst segment = this.segmentFromSpec(spec);\n\t\tthis.client.insertSegmentLocal(pos, segment);\n\t}\n\n\t/**\n\t * Retrieves the interval collection keyed on `label`. If no such interval collection exists,\n\t * creates one.\n\t */\n\tpublic getIntervalCollection(label: string): IIntervalCollection<SequenceInterval> {\n\t\treturn this.intervalCollections.get(label);\n\t}\n\n\t/**\n\t * @returns An iterable object that enumerates the IntervalCollection labels.\n\t *\n\t * @example\n\t * ```typescript\n\t * const iter = this.getIntervalCollectionKeys();\n\t * for (key of iter)\n\t * const collection = this.getIntervalCollection(key);\n\t * ...\n\t * ```\n\t */\n\tpublic getIntervalCollectionLabels(): IterableIterator<string> {\n\t\treturn this.intervalCollections.keys();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\t// conditionally write the interval collection blob\n\t\t// only if it has entries\n\t\tif (this.intervalCollections.size > 0) {\n\t\t\tbuilder.addBlob(snapshotFileName, this.intervalCollections.serialize(serializer));\n\t\t}\n\n\t\tbuilder.addWithStats(contentPath, this.summarizeMergeTree(serializer));\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Runs serializer over the GC data for this SharedMatrix.\n\t * All the IFluidHandle's represent routes to other objects.\n\t */\n\tprotected processGCDataCore(serializer: SummarySerializer) {\n\t\tif (this.intervalCollections.size > 0) {\n\t\t\tthis.intervalCollections.serialize(serializer);\n\t\t}\n\n\t\tthis.client.serializeGCData(this.handle, serializer);\n\t}\n\n\t/**\n\t * Replace the range specified from start to end with the provided segment\n\t * This is done by inserting the segment at the end of the range, followed\n\t * by removing the contents of the range\n\t * For a zero or reverse range (start \\>= end), insert at end do not remove anything\n\t * @param start - The start of the range to replace\n\t * @param end - The end of the range to replace\n\t * @param segment - The segment that will replace the range\n\t */\n\tprotected replaceRange(start: number, end: number, segment: ISegment) {\n\t\t// Insert at the max end of the range when start > end, but still remove the range later\n\t\tconst insertIndex: number = Math.max(start, end);\n\n\t\t// Insert first, so local references can slide to the inserted seg if any\n\t\tconst insert = this.client.insertSegmentLocal(insertIndex, segment);\n\t\tif (insert) {\n\t\t\tif (start < end) {\n\t\t\t\tthis.client.removeRangeLocal(start, end);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}\n\t */\n\tprotected onConnect() {\n\t\t// Update merge tree collaboration information with new client ID and then resend pending ops\n\t\tthis.client.startOrUpdateCollaboration(this.runtime.clientId);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}\n\t */\n\tprotected reSubmitCore(content: any, localOpMetadata: unknown) {\n\t\tif (\n\t\t\t!this.intervalCollections.tryResubmitMessage(\n\t\t\t\tcontent,\n\t\t\t\tlocalOpMetadata as IMapMessageLocalMetadata,\n\t\t\t)\n\t\t) {\n\t\t\tthis.submitSequenceMessage(\n\t\t\t\tthis.client.regeneratePendingOp(\n\t\t\t\t\tcontent as IMergeTreeOp,\n\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService) {\n\t\tif (await storage.contains(snapshotFileName)) {\n\t\t\tconst blob = await storage.readBlob(snapshotFileName);\n\t\t\tconst header = bufferToString(blob, \"utf8\");\n\t\t\tthis.intervalCollections.populate(header);\n\t\t}\n\n\t\ttry {\n\t\t\t// this will load the header, and return a promise\n\t\t\t// that will resolve when the body is loaded\n\t\t\t// and the catchup ops are available.\n\t\t\tconst { catchupOpsP } = await this.client.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, contentPath),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\n\t\t\t// setup a promise to process the\n\t\t\t// catch up ops, and finishing the loading process\n\t\t\tconst loadCatchUpOps = catchupOpsP\n\t\t\t\t.then((msgs) => {\n\t\t\t\t\tmsgs.forEach((m) => {\n\t\t\t\t\t\tconst collabWindow = this.client.getCollabWindow();\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tm.minimumSequenceNumber < collabWindow.minSeq ||\n\t\t\t\t\t\t\tm.referenceSequenceNumber < collabWindow.minSeq ||\n\t\t\t\t\t\t\tm.sequenceNumber <= collabWindow.minSeq ||\n\t\t\t\t\t\t\tm.sequenceNumber <= collabWindow.currentSeq\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Invalid catchup operations in snapshot: ${JSON.stringify({\n\t\t\t\t\t\t\t\t\top: {\n\t\t\t\t\t\t\t\t\t\tseq: m.sequenceNumber,\n\t\t\t\t\t\t\t\t\t\tminSeq: m.minimumSequenceNumber,\n\t\t\t\t\t\t\t\t\t\trefSeq: m.referenceSequenceNumber,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tcollabWindow: {\n\t\t\t\t\t\t\t\t\t\tseq: collabWindow.currentSeq,\n\t\t\t\t\t\t\t\t\t\tminSeq: collabWindow.minSeq,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t})}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.processMergeTreeMsg(m);\n\t\t\t\t\t});\n\t\t\t\t\tthis.loadFinished();\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.loadFinished(error);\n\t\t\t\t});\n\t\t\tif (this.dataStoreRuntime.options?.sequenceInitializeFromHeaderOnly !== true) {\n\t\t\t\t// if we not doing partial load, await the catch up ops,\n\t\t\t\t// and the finalization of the load\n\t\t\t\tawait loadCatchUpOps;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.loadFinished(error);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\t// if loading isn't complete, we need to cache all\n\t\t// incoming ops to be applied after loading is complete\n\t\tif (this.deferIncomingOps) {\n\t\t\tassert(!local, 0x072 /* \"Unexpected local op when loading not finished\" */);\n\t\t\tthis.loadedDeferredIncomingOps.push(message);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tmessage.type === MessageType.Operation,\n\t\t\t\t0x073 /* \"Sequence message not operation\" */,\n\t\t\t);\n\n\t\t\tconst handled = this.intervalCollections.tryProcessMessage(\n\t\t\t\tmessage.contents as IMapOperation,\n\t\t\t\tlocal,\n\t\t\t\tmessage,\n\t\t\t\tlocalOpMetadata,\n\t\t\t);\n\n\t\t\tif (!handled) {\n\t\t\t\tthis.processMergeTreeMsg(message, local);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.didAttach}\n\t */\n\tprotected didAttach() {\n\t\t// If we are not local, and we've attached we need to start generating and sending ops\n\t\t// so start collaboration and provide a default client id incase we are not connected\n\t\tif (this.isAttached()) {\n\t\t\tthis.client.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.initializeLocalCore}\n\t */\n\tprotected initializeLocalCore() {\n\t\tsuper.initializeLocalCore();\n\t\tthis.loadFinished();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(content: any): unknown {\n\t\treturn this.client.applyStashedOp(content);\n\t}\n\n\tprivate summarizeMergeTree(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Are we fully loaded? If not, things will go south\n\t\tassert(\n\t\t\tthis.loadedDeferred.isCompleted,\n\t\t\t0x074 /* \"Snapshot called when not fully loaded\" */,\n\t\t);\n\t\tconst minSeq = this.runtime.deltaManager.minimumSequenceNumber;\n\n\t\tthis.processMinSequenceNumberChanged(minSeq);\n\n\t\tthis.messagesSinceMSNChange.forEach((m) => {\n\t\t\tm.minimumSequenceNumber = minSeq;\n\t\t});\n\n\t\treturn this.client.summarize(\n\t\t\tthis.runtime,\n\t\t\tthis.handle,\n\t\t\tserializer,\n\t\t\tthis.messagesSinceMSNChange,\n\t\t);\n\t}\n\n\tprivate processMergeTreeMsg(rawMessage: ISequencedDocumentMessage, local?: boolean) {\n\t\tconst message = parseHandles(rawMessage, this.serializer);\n\n\t\tconst ops: IMergeTreeDeltaOp[] = [];\n\t\tfunction transformOps(event: SequenceDeltaEvent) {\n\t\t\tops.push(...SharedSegmentSequence.createOpsFromDelta(event));\n\t\t}\n\t\tconst needsTransformation = message.referenceSequenceNumber !== message.sequenceNumber - 1;\n\t\tlet stashMessage: Readonly<ISequencedDocumentMessage> = message;\n\t\tif (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {\n\t\t\tif (needsTransformation) {\n\t\t\t\tthis.on(\"sequenceDelta\", transformOps);\n\t\t\t}\n\t\t}\n\n\t\tthis.client.applyMsg(message, local);\n\n\t\tif (this.runtime.options?.newMergeTreeSnapshotFormat !== true) {\n\t\t\tif (needsTransformation) {\n\t\t\t\tthis.removeListener(\"sequenceDelta\", transformOps);\n\t\t\t\t// shallow clone the message as we only overwrite top level properties,\n\t\t\t\t// like referenceSequenceNumber and content only\n\t\t\t\tstashMessage = {\n\t\t\t\t\t...message,\n\t\t\t\t\treferenceSequenceNumber: stashMessage.sequenceNumber - 1,\n\t\t\t\t\tcontents: ops.length !== 1 ? createGroupOp(...ops) : ops[0],\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthis.messagesSinceMSNChange.push(stashMessage);\n\n\t\t\t// Do GC every once in a while...\n\t\t\tif (\n\t\t\t\tthis.messagesSinceMSNChange.length > 20 &&\n\t\t\t\tthis.messagesSinceMSNChange[20].sequenceNumber < message.minimumSequenceNumber\n\t\t\t) {\n\t\t\t\tthis.processMinSequenceNumberChanged(message.minimumSequenceNumber);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processMinSequenceNumberChanged(minSeq: number) {\n\t\tlet index = 0;\n\t\tfor (; index < this.messagesSinceMSNChange.length; index++) {\n\t\t\tif (this.messagesSinceMSNChange[index].sequenceNumber > minSeq) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (index !== 0) {\n\t\t\tthis.messagesSinceMSNChange = this.messagesSinceMSNChange.slice(index);\n\t\t}\n\t}\n\n\tprivate loadFinished(error?: any) {\n\t\tif (!this.loadedDeferred.isCompleted) {\n\t\t\t// Initialize the interval collections\n\t\t\tthis.initializeIntervalCollections();\n\t\t\tif (error) {\n\t\t\t\tthis.loadedDeferred.reject(error);\n\t\t\t\tthrow error;\n\t\t\t} else {\n\t\t\t\t// it is important this series remains synchronous\n\t\t\t\t// first we stop deferring incoming ops, and apply then all\n\t\t\t\tthis.deferIncomingOps = false;\n\t\t\t\tfor (const message of this.loadedDeferredIncomingOps) {\n\t\t\t\t\tthis.processCore(message, false, undefined);\n\t\t\t\t}\n\t\t\t\tthis.loadedDeferredIncomingOps.length = 0;\n\n\t\t\t\t// then resolve the loaded promise\n\t\t\t\t// and resubmit all the outstanding ops, as the snapshot\n\t\t\t\t// is fully loaded, and all outstanding ops are applied\n\t\t\t\tthis.loadedDeferred.resolve();\n\n\t\t\t\tfor (const [messageContent, opMetadata] of this.loadedDeferredOutgoingOps) {\n\t\t\t\t\tthis.reSubmitCore(messageContent, opMetadata);\n\t\t\t\t}\n\t\t\t\tthis.loadedDeferredOutgoingOps.length = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate initializeIntervalCollections() {\n\t\t// Listen and initialize new SharedIntervalCollections\n\t\tthis.intervalCollections.eventEmitter.on(\n\t\t\t\"create\",\n\t\t\t({ key, previousValue }: IValueChanged, local: boolean) => {\n\t\t\t\tconst intervalCollection = this.intervalCollections.get(key);\n\t\t\t\tif (!intervalCollection.attached) {\n\t\t\t\t\tintervalCollection.attachGraph(this.client, key);\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tpreviousValue === undefined,\n\t\t\t\t\t0x2c1 /* \"Creating an interval collection that already exists?\" */,\n\t\t\t\t);\n\t\t\t\tthis.emit(\"createIntervalCollection\", key, local, this);\n\t\t\t},\n\t\t);\n\n\t\t// Initialize existing SharedIntervalCollections\n\t\tfor (const key of this.intervalCollections.keys()) {\n\t\t\tconst intervalCollection = this.intervalCollections.get(key);\n\t\t\tintervalCollection.attachGraph(this.client, key);\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedSequence.d.ts","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAInD,MAAM,WAAW,eAAe,CAAC,CAAC,CAAE,SAAQ,YAAY;IACvD,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CACzB;AAED,qBAAa,WAAW,CAAC,CAAC,CAAE,SAAQ,WAAW;IAkB3B,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE;IAjB3C,gBAAuB,UAAU,EAAE,MAAM,CAAiB;WAC5C,EAAE,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,IAAI,WAAW,CAAC,GAAG,CAAC;WAGlD,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY;IAWlD,SAAgB,IAAI,SAA0B;gBAE3B,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE;IAKpC,YAAY;IAMZ,KAAK,CAAC,KAAK,SAAI,EAAE,GAAG,CAAC,EAAE,MAAM;IAO7B,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAOrC,QAAQ;IAIR,MAAM,CAAC,OAAO,EAAE,QAAQ;IAQxB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAc7C,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM;CAS1C;AAED,qBAAa,cAAc,CAAC,CAAC,CAAE,SAAQ,qBAAqB,CAAC,WAA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C,EAAE,IAAI,EAAE,YAAY;IAWlD,SAAgB,IAAI,SAA0B;gBAE3B,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE;IAKpC,YAAY;IAMZ,KAAK,CAAC,KAAK,SAAI,EAAE,GAAG,CAAC,EAAE,MAAM;IAO7B,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAOrC,QAAQ;IAIR,MAAM,CAAC,OAAO,EAAE,QAAQ;IAQxB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAc7C,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM;CAS1C;AAED,qBAAa,cAAc,CAAC,CAAC,CAAE,SAAQ,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAGnE,EAAE,EAAE,MAAM;gBADjB,QAAQ,EAAE,sBAAsB,EACzB,EAAE,EAAE,MAAM,EACjB,UAAU,EAAE,kBAAkB,EAC9B,aAAa,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,QAAQ;IAKhD;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,WAAW;IAQxE;;;OAGG;IACI,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAIxC;;OAEG;IACI,YAAY,IAAI,MAAM;IAI7B;;;;;OAKG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE;CAoC/D"}
@@ -94,10 +94,7 @@ class SharedSequence extends sequence_1.SharedSegmentSequence {
94
94
  if (props) {
95
95
  segment.addProperties(props);
96
96
  }
97
- const insertOp = this.client.insertSegmentLocal(pos, segment);
98
- if (insertOp) {
99
- this.submitSequenceMessage(insertOp);
100
- }
97
+ this.client.insertSegmentLocal(pos, segment);
101
98
  }
102
99
  /**
103
100
  * @param start - The inclusive start of the range to remove
@@ -1 +1 @@
1
- {"version":3,"file":"sharedSequence.js","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,2DAA8F;AAM9F,yCAAmD;AAEnD,MAAM,MAAM,GAAG,GAAG,CAAC;AAMnB,MAAa,WAAe,SAAQ,wBAAW;IAkB9C,YAAmB,KAAwB;QAC1C,KAAK,EAAE,CAAC;QADU,UAAK,GAAL,KAAK,CAAmB;QAF3B,SAAI,GAAG,WAAW,CAAC,UAAU,CAAC;QAI7C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;IAClC,CAAC;IAnBM,MAAM,CAAC,EAAE,CAAC,OAAiB;QACjC,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAC;IAChD,CAAC;IACM,MAAM,CAAC,cAAc,CAAI,IAAkB;QACjD,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,EAAE;YACxD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAI,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,IAAI,CAAC,KAAK,EAAE;gBACf,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAClC;YACD,OAAO,OAAO,CAAC;SACf;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IASM,YAAY;QAClB,MAAM,GAAG,GAAuB,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QACtD,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,GAAG,CAAC;IACZ,CAAC;IAEM,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,GAAY;QACnC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACjD,M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,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,YAAY;QAClB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,KAAa,EAAE,GAAY;QAC1C,MAAM,KAAK,GAAsB,EAAE,CAAC;QACpC,IAAI,YAAkC,CAAC;QAEvC,oCAAoC;QACpC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,IAAI,KAAK,EAAE;YACtC,OAAO,KAAK,CAAC;SACb;QAED,IAAI,CAAC,YAAY,CAChB,CAAC,OAAiB,EAAE,EAAE;YACrB,IAAI,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;gBAC5B,IAAI,YAAY,KAAK,SAAS,EAAE;oBAC/B,YAAY,GAAG,OAAO,CAAC;iBACvB;gBACD,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;aAC7B;YACD,OAAO,IAAI,CAAC;QACb,CAAC,EACD,KAAK,EACL,GAAG,CACH,CAAC;QAEF,kEAAkE;QAClE,gEAAgE;QAChE,+DAA+D;QAC/D,iEAAiE;QACjE,aAAa;QACb,IAAI,YAAY,KAAK,SAAS,EAAE;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;SACxD;QACD,IAAI,GAAG,KAAK,SAAS,EAAE;YACtB,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;SAC1B;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAnFD,wCAmFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { BaseSegment, IJSONSegment, ISegment, PropertySet } from \"@fluidframework/merge-tree\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\n\nconst MaxRun = 128;\n\nexport interface IJSONRunSegment<T> extends IJSONSegment {\n\titems: Serializable<T>[];\n}\n\nexport class SubSequence<T> extends BaseSegment {\n\tpublic static readonly typeString: string = \"SubSequence\";\n\tpublic static is(segment: ISegment): segment is SubSequence<any> {\n\t\treturn segment.type === SubSequence.typeString;\n\t}\n\tpublic static fromJSONObject<U>(spec: Serializable) {\n\t\tif (spec && typeof spec === \"object\" && \"items\" in spec) {\n\t\t\tconst segment = new SubSequence<U>(spec.items);\n\t\t\tif (spec.props) {\n\t\t\t\tsegment.addProperties(spec.props);\n\t\t\t}\n\t\t\treturn segment;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic readonly type = SubSequence.typeString;\n\n\tconstructor(public items: Serializable<T>[]) {\n\t\tsuper();\n\t\tthis.cachedLength = items.length;\n\t}\n\n\tpublic toJSONObject() {\n\t\tconst obj: IJSONRunSegment<T> = { items: this.items };\n\t\tsuper.addSerializedProps(obj);\n\t\treturn obj;\n\t}\n\n\tpublic clone(start = 0, end?: number) {\n\t\tconst clonedItems = this.items.slice(start, end);\n\t\tconst b = new SubSequence(clonedItems);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\treturn (\n\t\t\tSubSequence.is(segment) &&\n\t\t\t(this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun)\n\t\t);\n\t}\n\n\tpublic toString() {\n\t\treturn this.items.toString();\n\t}\n\n\tpublic append(segment: ISegment) {\n\t\tassert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);\n\t\tsuper.append(segment);\n\t\tthis.items = this.items.concat(segment.items);\n\t}\n\n\t// TODO: retain removed items for undo\n\t// returns true if entire run removed\n\tpublic removeRange(start: number, end: number) {\n\t\tlet remnantItems: Serializable<T>[] = [];\n\t\tconst len = this.items.length;\n\t\tif (start > 0) {\n\t\t\tremnantItems = remnantItems.concat(this.items.slice(0, start));\n\t\t}\n\t\tif (end < len) {\n\t\t\tremnantItems = remnantItems.concat(this.items.slice(end));\n\t\t}\n\t\tthis.items = remnantItems;\n\t\tthis.cachedLength = this.items.length;\n\t\treturn this.items.length === 0;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number) {\n\t\tif (pos > 0) {\n\t\t\tconst remainingItems = this.items.slice(pos);\n\t\t\tthis.items = this.items.slice(0, pos);\n\t\t\tthis.cachedLength = this.items.length;\n\t\t\tconst leafSegment = new SubSequence(remainingItems);\n\t\t\treturn leafSegment;\n\t\t}\n\t}\n}\n\nexport class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t\tspecToSegment: (spec: IJSONSegment) => ISegment,\n\t) {\n\t\tsuper(document, id, attributes, specToSegment);\n\t}\n\n\t/**\n\t * @param pos - The position to insert the items at.\n\t * @param items - The items to insert.\n\t * @param props - Optional. Properties to set on the inserted items.\n\t */\n\tpublic insert(pos: number, items: Serializable<T>[], props?: PropertySet) {\n\t\tconst segment = new SubSequence<T>(items);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\t\tconst insertOp = this.client.insertSegmentLocal(pos, segment);\n\t\tif (insertOp) {\n\t\t\tthis.submitSequenceMessage(insertOp);\n\t\t}\n\t}\n\n\t/**\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to remove\n\t */\n\tpublic remove(start: number, end: number) {\n\t\tthis.removeRange(start, end);\n\t}\n\n\t/**\n\t * Returns the total count of items in the sequence\n\t */\n\tpublic getItemCount(): number {\n\t\treturn this.getLength();\n\t}\n\n\t/**\n\t * Gets the items in the specified range\n\t *\n\t * @param start - The inclusive start of the range\n\t * @param end - The exclusive end of the range\n\t */\n\tpublic getItems(start: number, end?: number): Serializable<T>[] {\n\t\tconst items: Serializable<T>[] = [];\n\t\tlet firstSegment: ISegment | undefined;\n\n\t\t// Return if the range is incorrect.\n\t\tif (end !== undefined && end <= start) {\n\t\t\treturn items;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment: ISegment) => {\n\t\t\t\tif (SubSequence.is(segment)) {\n\t\t\t\t\tif (firstSegment === undefined) {\n\t\t\t\t\t\tfirstSegment = segment;\n\t\t\t\t\t}\n\t\t\t\t\titems.push(...segment.items);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\n\t\t// The above call to walkSegments adds all the items in the walked\n\t\t// segments. However, we only want items beginning at |start| in\n\t\t// the first segment. Similarly, if |end| is passed in, we only\n\t\t// want items until |end| in the last segment. Remove the rest of\n\t\t// the items.\n\t\tif (firstSegment !== undefined) {\n\t\t\titems.splice(0, start - this.getPosition(firstSegment));\n\t\t}\n\t\tif (end !== undefined) {\n\t\t\titems.splice(end - start);\n\t\t}\n\t\treturn items;\n\t}\n}\n"]}
1
+ {"version":3,"file":"sharedSequence.js","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,2DAA8F;AAM9F,yCAAmD;AAEnD,MAAM,MAAM,GAAG,GAAG,CAAC;AAMnB,MAAa,WAAe,SAAQ,wBAAW;IAkB9C,YAAmB,KAAwB;QAC1C,KAAK,EAAE,CAAC;QADU,UAAK,GAAL,KAAK,CAAmB;QAF3B,SAAI,GAAG,WAAW,CAAC,UAAU,CAAC;QAI7C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;IAClC,CAAC;IAnBM,MAAM,CAAC,EAAE,CAAC,OAAiB;QACjC,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAC;IAChD,CAAC;IACM,MAAM,CAAC,cAAc,CAAI,IAAkB;QACjD,IAAI,IAAI,IAAI,OAA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iEAAiE;QACjE,aAAa;QACb,IAAI,YAAY,KAAK,SAAS,EAAE;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;SACxD;QACD,IAAI,GAAG,KAAK,SAAS,EAAE;YACtB,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;SAC1B;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAhFD,wCAgFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { BaseSegment, IJSONSegment, ISegment, PropertySet } from \"@fluidframework/merge-tree\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\n\nconst MaxRun = 128;\n\nexport interface IJSONRunSegment<T> extends IJSONSegment {\n\titems: Serializable<T>[];\n}\n\nexport class SubSequence<T> extends BaseSegment {\n\tpublic static readonly typeString: string = \"SubSequence\";\n\tpublic static is(segment: ISegment): segment is SubSequence<any> {\n\t\treturn segment.type === SubSequence.typeString;\n\t}\n\tpublic static fromJSONObject<U>(spec: Serializable) {\n\t\tif (spec && typeof spec === \"object\" && \"items\" in spec) {\n\t\t\tconst segment = new SubSequence<U>(spec.items);\n\t\t\tif (spec.props) {\n\t\t\t\tsegment.addProperties(spec.props);\n\t\t\t}\n\t\t\treturn segment;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic readonly type = SubSequence.typeString;\n\n\tconstructor(public items: Serializable<T>[]) {\n\t\tsuper();\n\t\tthis.cachedLength = items.length;\n\t}\n\n\tpublic toJSONObject() {\n\t\tconst obj: IJSONRunSegment<T> = { items: this.items };\n\t\tsuper.addSerializedProps(obj);\n\t\treturn obj;\n\t}\n\n\tpublic clone(start = 0, end?: number) {\n\t\tconst clonedItems = this.items.slice(start, end);\n\t\tconst b = new SubSequence(clonedItems);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\treturn (\n\t\t\tSubSequence.is(segment) &&\n\t\t\t(this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun)\n\t\t);\n\t}\n\n\tpublic toString() {\n\t\treturn this.items.toString();\n\t}\n\n\tpublic append(segment: ISegment) {\n\t\tassert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);\n\t\tsuper.append(segment);\n\t\tthis.items = this.items.concat(segment.items);\n\t}\n\n\t// TODO: retain removed items for undo\n\t// returns true if entire run removed\n\tpublic removeRange(start: number, end: number) {\n\t\tlet remnantItems: Serializable<T>[] = [];\n\t\tconst len = this.items.length;\n\t\tif (start > 0) {\n\t\t\tremnantItems = remnantItems.concat(this.items.slice(0, start));\n\t\t}\n\t\tif (end < len) {\n\t\t\tremnantItems = remnantItems.concat(this.items.slice(end));\n\t\t}\n\t\tthis.items = remnantItems;\n\t\tthis.cachedLength = this.items.length;\n\t\treturn this.items.length === 0;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number) {\n\t\tif (pos > 0) {\n\t\t\tconst remainingItems = this.items.slice(pos);\n\t\t\tthis.items = this.items.slice(0, pos);\n\t\t\tthis.cachedLength = this.items.length;\n\t\t\tconst leafSegment = new SubSequence(remainingItems);\n\t\t\treturn leafSegment;\n\t\t}\n\t}\n}\n\nexport class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t\tspecToSegment: (spec: IJSONSegment) => ISegment,\n\t) {\n\t\tsuper(document, id, attributes, specToSegment);\n\t}\n\n\t/**\n\t * @param pos - The position to insert the items at.\n\t * @param items - The items to insert.\n\t * @param props - Optional. Properties to set on the inserted items.\n\t */\n\tpublic insert(pos: number, items: Serializable<T>[], props?: PropertySet) {\n\t\tconst segment = new SubSequence<T>(items);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\t\tthis.client.insertSegmentLocal(pos, segment);\n\t}\n\n\t/**\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to remove\n\t */\n\tpublic remove(start: number, end: number) {\n\t\tthis.removeRange(start, end);\n\t}\n\n\t/**\n\t * Returns the total count of items in the sequence\n\t */\n\tpublic getItemCount(): number {\n\t\treturn this.getLength();\n\t}\n\n\t/**\n\t * Gets the items in the specified range\n\t *\n\t * @param start - The inclusive start of the range\n\t * @param end - The exclusive end of the range\n\t */\n\tpublic getItems(start: number, end?: number): Serializable<T>[] {\n\t\tconst items: Serializable<T>[] = [];\n\t\tlet firstSegment: ISegment | undefined;\n\n\t\t// Return if the range is incorrect.\n\t\tif (end !== undefined && end <= start) {\n\t\t\treturn items;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment: ISegment) => {\n\t\t\t\tif (SubSequence.is(segment)) {\n\t\t\t\t\tif (firstSegment === undefined) {\n\t\t\t\t\t\tfirstSegment = segment;\n\t\t\t\t\t}\n\t\t\t\t\titems.push(...segment.items);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\n\t\t// The above call to walkSegments adds all the items in the walked\n\t\t// segments. However, we only want items beginning at |start| in\n\t\t// the first segment. Similarly, if |end| is passed in, we only\n\t\t// want items until |end| in the last segment. Remove the rest of\n\t\t// the items.\n\t\tif (firstSegment !== undefined) {\n\t\t\titems.splice(0, start - this.getPosition(firstSegment));\n\t\t}\n\t\tif (end !== undefined) {\n\t\t\titems.splice(end - start);\n\t\t}\n\t\treturn items;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedString.d.ts","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,YAAY,EAC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ACI,6BAA6B,CACnC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI;IAK9B;;;;;OAKG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,YAAY;IAIpF;;;;;;;OAOG;IACI,QAAQ,CACd,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,UAAO,GAEd;QACA,IAAI,EAAE,iBAAiB,CAAC;QACxB,GAAG,EAAE,MAAM,CAAC;KACX,GACD,SAAS;IAIZ;;;;;OAKG;IACI,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAW3C;;OAEG;IACI,uBAAuB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAWpD,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAWzD;;;OAGG;IACI,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIxD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAOhE;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,GACV;IACF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC1B,CAWA"}
@@ -55,10 +55,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
55
55
  segment.addProperties(props);
56
56
  }
57
57
  const pos = this.posFromRelativePos(relativePos1);
58
- const insertOp = this.client.insertSegmentLocal(pos, segment);
59
- if (insertOp) {
60
- this.submitSequenceMessage(insertOp);
61
- }
58
+ this.client.insertSegmentLocal(pos, segment);
62
59
  }
63
60
  /**
64
61
  * {@inheritDoc ISharedString.insertMarker}
@@ -68,11 +65,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
68
65
  if (props) {
69
66
  segment.addProperties(props);
70
67
  }
71
- const insertOp = this.client.insertSegmentLocal(pos, segment);
72
- if (insertOp) {
73
- this.submitSequenceMessage(insertOp);
74
- }
75
- return insertOp;
68
+ return this.client.insertSegmentLocal(pos, segment);
76
69
  }
77
70
  /**
78
71
  * Inserts the text at the position.
@@ -86,10 +79,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
86
79
  segment.addProperties(props);
87
80
  }
88
81
  const pos = this.posFromRelativePos(relativePos1);
89
- const insertOp = this.client.insertSegmentLocal(pos, segment);
90
- if (insertOp) {
91
- this.submitSequenceMessage(insertOp);
92
- }
82
+ this.client.insertSegmentLocal(pos, segment);
93
83
  }
94
84
  /**
95
85
  * {@inheritDoc ISharedString.insertText}
@@ -99,10 +89,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
99
89
  if (props) {
100
90
  segment.addProperties(props);
101
91
  }
102
- const insertOp = this.client.insertSegmentLocal(pos, segment);
103
- if (insertOp) {
104
- this.submitSequenceMessage(insertOp);
105
- }
92
+ this.client.insertSegmentLocal(pos, segment);
106
93
  }
107
94
  /**
108
95
  * Replaces a range with the provided text.
@@ -130,10 +117,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
130
117
  * @param consensusCallback - The callback called when consensus is reached
131
118
  */
132
119
  annotateMarkerNotifyConsensus(marker, props, callback) {
133
- const annotateOp = this.client.annotateMarkerNotifyConsensus(marker, props, callback);
134
- if (annotateOp) {
135
- this.submitSequenceMessage(annotateOp);
136
- }
120
+ this.client.annotateMarkerNotifyConsensus(marker, props, callback);
137
121
  }
138
122
  /**
139
123
  * Annotates the marker with the provided properties.
@@ -142,10 +126,7 @@ class SharedString extends sequence_1.SharedSegmentSequence {
142
126
  * @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
143
127
  */
144
128
  annotateMarker(marker, props, combiningOp) {
145
- const annotateOp = this.client.annotateMarker(marker, props, combiningOp);
146
- if (annotateOp) {
147
- this.submitSequenceMessage(annotateOp);
148
- }
129
+ this.client.annotateMarker(marker, props, combiningOp);
149
130
  }
150
131
  /**
151
132
  * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.