@fluidframework/sequence 2.0.0-internal.7.2.2 → 2.0.0-internal.7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-extractor.json +4 -1
  3. package/dist/intervalCollection.d.ts +2 -2
  4. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  5. package/dist/intervals/intervalUtils.js +1 -0
  6. package/dist/intervals/intervalUtils.js.map +1 -1
  7. package/dist/packageVersion.d.ts +1 -1
  8. package/dist/packageVersion.js +1 -1
  9. package/dist/packageVersion.js.map +1 -1
  10. package/dist/revertibles.d.ts.map +1 -1
  11. package/dist/revertibles.js +34 -12
  12. package/dist/revertibles.js.map +1 -1
  13. package/dist/sequence-alpha.d.ts +1587 -0
  14. package/dist/sequence-beta.d.ts +1507 -0
  15. package/dist/sequence-public.d.ts +1507 -0
  16. package/dist/sequence-untrimmed.d.ts +1759 -0
  17. package/dist/sequence.d.ts.map +1 -1
  18. package/dist/sequence.js +3 -4
  19. package/dist/sequence.js.map +1 -1
  20. package/dist/sequenceDeltaEvent.d.ts.map +1 -1
  21. package/dist/sequenceDeltaEvent.js +1 -0
  22. package/dist/sequenceDeltaEvent.js.map +1 -1
  23. package/dist/tsdoc-metadata.json +1 -1
  24. package/lib/intervalCollection.d.ts +2 -2
  25. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  26. package/lib/intervals/intervalUtils.js +1 -0
  27. package/lib/intervals/intervalUtils.js.map +1 -1
  28. package/lib/packageVersion.d.ts +1 -1
  29. package/lib/packageVersion.js +1 -1
  30. package/lib/packageVersion.js.map +1 -1
  31. package/lib/revertibles.d.ts.map +1 -1
  32. package/lib/revertibles.js +34 -12
  33. package/lib/revertibles.js.map +1 -1
  34. package/lib/sequence-alpha.d.ts +1587 -0
  35. package/lib/sequence-beta.d.ts +1507 -0
  36. package/lib/sequence-public.d.ts +1507 -0
  37. package/lib/sequence-untrimmed.d.ts +1759 -0
  38. package/lib/sequence.d.ts.map +1 -1
  39. package/lib/sequence.js +2 -7
  40. package/lib/sequence.js.map +1 -1
  41. package/lib/sequenceDeltaEvent.d.ts.map +1 -1
  42. package/lib/sequenceDeltaEvent.js +1 -0
  43. package/lib/sequenceDeltaEvent.js.map +1 -1
  44. package/package.json +35 -23
  45. package/src/intervals/intervalUtils.ts +1 -0
  46. package/src/packageVersion.ts +1 -1
  47. package/src/revertibles.ts +86 -9
  48. package/src/sequence.ts +3 -4
  49. package/src/sequenceDeltaEvent.ts +2 -0
  50. package/tsconfig.esnext.json +1 -2
  51. package/tsconfig.json +5 -3
@@ -1 +1 @@
1
- {"version":3,"file":"sequence.d.ts","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAU,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,MAAM,EAMN,YAAY,EACZ,YAAY,EAGZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,sBAAsB,EAItB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EAEzB,iBAAiB,EACjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACN,gBAAgB,EAGhB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAG/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACN,mBAAmB,EA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EAC5B,gBAAgB,CAAC,EAAE,iBAAiB,GAClC,qBAAqB;IAcxB;;;OAGG;IACH,SAAS,CAAC,iBAAiB,CAAC,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;IA6DxD;;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;AA4BD;;GAEG;AACH,wBAAgB,yBAAyB,SAExC"}
package/lib/sequence.js CHANGED
@@ -2,15 +2,12 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /* eslint-disable import/no-deprecated */
5
6
  import { assert, Deferred } from "@fluidframework/core-utils";
6
7
  import { bufferToString } from "@fluid-internal/client-utils";
7
8
  import { LoggingError, createChildLogger } from "@fluidframework/telemetry-utils";
8
9
  import { MessageType } from "@fluidframework/protocol-definitions";
9
- import { Client, createAnnotateRangeOp,
10
- // eslint-disable-next-line import/no-deprecated
11
- createGroupOp, createInsertOp, createRemoveRangeOp,
12
- // eslint-disable-next-line import/no-deprecated
13
- matchProperties, MergeTreeDeltaType, } from "@fluidframework/merge-tree";
10
+ import { Client, createAnnotateRangeOp, createGroupOp, createInsertOp, createRemoveRangeOp, matchProperties, MergeTreeDeltaType, } from "@fluidframework/merge-tree";
14
11
  import { ObjectStoragePartition, SummaryTreeBuilder } from "@fluidframework/runtime-utils";
15
12
  import { makeHandlesSerializable, parseHandles, SharedObject, } from "@fluidframework/shared-object-base";
16
13
  import { DefaultMap } from "./defaultMap";
@@ -37,7 +34,6 @@ export class SharedSegmentSequence extends SharedObject {
37
34
  }
38
35
  if (lastAnnotate &&
39
36
  lastAnnotate.pos2 === r.position &&
40
- // eslint-disable-next-line import/no-deprecated
41
37
  matchProperties(lastAnnotate.props, props)) {
42
38
  lastAnnotate.pos2 += r.segment.cachedLength;
43
39
  }
@@ -483,7 +479,6 @@ export class SharedSegmentSequence extends SharedObject {
483
479
  stashMessage = {
484
480
  ...message,
485
481
  referenceSequenceNumber: stashMessage.sequenceNumber - 1,
486
- // eslint-disable-next-line import/no-deprecated
487
482
  contents: ops.length !== 1 ? createGroupOp(...ops) : ops[0],
488
483
  };
489
484
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAM9F,OAAO,EACN,MAAM,EACN,qBAAqB;AACrB,gDAAgD;AAChD,aAAa,EACb,cAAc,EACd,mBAAmB;AAYnB,gDAAgD;AAChD,eAAe,EACf,kBAAkB,GAQl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UAAU,yBAAyB;IACxC,mBAAmB,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,sBAAsB,GAAG,2CAA2C,CAAC;AAC3E,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,EAAE;IACxD,MAAM,IAAI,YAAY,CAAC,sBAAsB,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert, Deferred } from \"@fluidframework/core-utils\";\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { LoggingError, 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\t// eslint-disable-next-line import/no-deprecated\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\t// eslint-disable-next-line import/no-deprecated\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/core-interfaces\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\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 * @public\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\n/**\n * @public\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\t/**\n\t * This is a safeguard to avoid problematic reentrancy of local ops. This type of scenario occurs if the user of SharedString subscribes\n\t * to the `sequenceDelta` event and uses the callback for a local op to submit further local ops.\n\t * Historically (before 2.0.0-internal.6.1.0), doing so would result in eventual consistency issues or a corrupted document.\n\t * These issues were fixed in #16815 which makes such reentrancy no different from applying the ops in order but not from within the change events,\n\t * but there is still little test coverage for reentrant scenarios.\n\t * Additionally, applications submitting ops from inside change events need to take extreme care that their data models also support reentrancy.\n\t * Since this is likely not the case, by default SharedString throws when encountering reentrant ops.\n\t *\n\t * An application using SharedString which explicitly wants to opt in to allowing reentrancy anyway can set `sharedStringPreventReentrancy`\n\t * on the data store options to `false`.\n\t * @internal\n\t */\n\tprotected guardReentrancy: <TRet>(callback: () => TRet) => TRet;\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\t// eslint-disable-next-line import/no-deprecated\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.guardReentrancy =\n\t\t\tdataStoreRuntime.options.sharedStringPreventReentrancy ?? true\n\t\t\t\t? ensureNoReentrancy\n\t\t\t\t: createReentrancyDetector((depth) => {\n\t\t\t\t\t\tif (totalReentrancyLogs > 0) {\n\t\t\t\t\t\t\ttotalReentrancyLogs--;\n\t\t\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t\t\t{ eventName: \"LocalOpReentry\", depth },\n\t\t\t\t\t\t\t\tnew LoggingError(reentrancyErrorMessage),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t });\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.guardReentrancy(() => 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.guardReentrancy(() => this.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.guardReentrancy(() => this.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\tcanSlideToEndpoint?: boolean,\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\tcanSlideToEndpoint,\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\t/**\n\t * @deprecated this functionality is no longer supported and will be removed\n\t */\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.guardReentrancy(() => this.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.guardReentrancy(() => this.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 *\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\t// sequenceNumber could be the same if messages are part of a grouped batch\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(parseHandles(content, this.serializer));\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\t// eslint-disable-next-line import/no-deprecated\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\nfunction createReentrancyDetector(\n\tonReentrancy: (depth: number) => void,\n): <T>(callback: () => T) => T {\n\tlet depth = 0;\n\tfunction detectReentrancy<T>(callback: () => T): T {\n\t\tif (depth > 0) {\n\t\t\tonReentrancy(depth);\n\t\t}\n\t\tdepth++;\n\t\ttry {\n\t\t\treturn callback();\n\t\t} finally {\n\t\t\tdepth--;\n\t\t}\n\t}\n\n\treturn detectReentrancy;\n}\n\n/**\n * Apps which generate reentrant behavior may do so at a high frequency.\n * Logging even per-SharedSegmentSequence instance might be too noisy, and having a few logs from a session\n * is likely enough.\n */\nlet totalReentrancyLogs = 3;\n\n/**\n * Resets the reentrancy log counter. Test-only API.\n */\nexport function resetReentrancyLogCounter() {\n\ttotalReentrancyLogs = 3;\n}\n\nconst reentrancyErrorMessage = \"Reentrancy detected in sequence local ops\";\nconst ensureNoReentrancy = createReentrancyDetector(() => {\n\tthrow new LoggingError(reentrancyErrorMessage);\n});\n"]}
1
+ {"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yCAAyC;AAEzC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAM9F,OAAO,EACN,MAAM,EACN,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,mBAAmB,EAYnB,eAAe,EACf,kBAAkB,GAQlB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBA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B,GAAG,2CAA2C,CAAC;AAC3E,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,EAAE;IACxD,MAAM,IAAI,YAAY,CAAC,sBAAsB,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils\";\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { LoggingError, 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/core-interfaces\";\nimport { ISummaryTreeWithStats, ITelemetryContext } from \"@fluidframework/runtime-definitions\";\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 * @public\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\n/**\n * @public\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\t/**\n\t * This is a safeguard to avoid problematic reentrancy of local ops. This type of scenario occurs if the user of SharedString subscribes\n\t * to the `sequenceDelta` event and uses the callback for a local op to submit further local ops.\n\t * Historically (before 2.0.0-internal.6.1.0), doing so would result in eventual consistency issues or a corrupted document.\n\t * These issues were fixed in #16815 which makes such reentrancy no different from applying the ops in order but not from within the change events,\n\t * but there is still little test coverage for reentrant scenarios.\n\t * Additionally, applications submitting ops from inside change events need to take extreme care that their data models also support reentrancy.\n\t * Since this is likely not the case, by default SharedString throws when encountering reentrant ops.\n\t *\n\t * An application using SharedString which explicitly wants to opt in to allowing reentrancy anyway can set `sharedStringPreventReentrancy`\n\t * on the data store options to `false`.\n\t * @internal\n\t */\n\tprotected guardReentrancy: <TRet>(callback: () => TRet) => TRet;\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.guardReentrancy =\n\t\t\tdataStoreRuntime.options.sharedStringPreventReentrancy ?? true\n\t\t\t\t? ensureNoReentrancy\n\t\t\t\t: createReentrancyDetector((depth) => {\n\t\t\t\t\t\tif (totalReentrancyLogs > 0) {\n\t\t\t\t\t\t\ttotalReentrancyLogs--;\n\t\t\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t\t\t{ eventName: \"LocalOpReentry\", depth },\n\t\t\t\t\t\t\t\tnew LoggingError(reentrancyErrorMessage),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t });\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.guardReentrancy(() => 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.guardReentrancy(() => this.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.guardReentrancy(() => this.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\tcanSlideToEndpoint?: boolean,\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\tcanSlideToEndpoint,\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\t/**\n\t * @deprecated this functionality is no longer supported and will be removed\n\t */\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.guardReentrancy(() => this.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.guardReentrancy(() => this.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 *\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\t// sequenceNumber could be the same if messages are part of a grouped batch\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(parseHandles(content, this.serializer));\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\nfunction createReentrancyDetector(\n\tonReentrancy: (depth: number) => void,\n): <T>(callback: () => T) => T {\n\tlet depth = 0;\n\tfunction detectReentrancy<T>(callback: () => T): T {\n\t\tif (depth > 0) {\n\t\t\tonReentrancy(depth);\n\t\t}\n\t\tdepth++;\n\t\ttry {\n\t\t\treturn callback();\n\t\t} finally {\n\t\t\tdepth--;\n\t\t}\n\t}\n\n\treturn detectReentrancy;\n}\n\n/**\n * Apps which generate reentrant behavior may do so at a high frequency.\n * Logging even per-SharedSegmentSequence instance might be too noisy, and having a few logs from a session\n * is likely enough.\n */\nlet totalReentrancyLogs = 3;\n\n/**\n * Resets the reentrancy log counter. Test-only API.\n */\nexport function resetReentrancyLogCounter() {\n\ttotalReentrancyLogs = 3;\n}\n\nconst reentrancyErrorMessage = \"Reentrancy detected in sequence local ops\";\nconst ensureNoReentrancy = createReentrancyDetector(() => {\n\tthrow new LoggingError(reentrancyErrorMessage);\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceDeltaEvent.d.ts","sourceRoot":"","sources":["../src/sequenceDeltaEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,MAAM,EACN,2BAA2B,EAC3B,qBAAqB,EACrB,iCAAiC,EACjC,QAAQ,EACR,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,WAAW,EAEX,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;GAOG;AACH,8BAAsB,aAAa,CAClC,UAAU,SAAS,4BAA4B,GAAG,4BAA4B;aAQ7D,SAAS,EAAE,2BAA2B,CAAC,UAAU,CAAC;IAClE,OAAO,CAAC,QAAQ,CAAC,eAAe;IAPjC,SAAgB,cAAc,EAAE,UAAU,CAAC;IAC3C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0D;IACvF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwC;gBAG7C,SAAS,EAAE,2BAA2B,CAAC,UAAU,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BAAqB,GAAG,SAAS;gBAAzC,MAAM,EAAE,qBAAqB,GAAG,SAAS,EACzD,SAAS,EAAE,iCAAiC,EAC5C,eAAe,EAAE,MAAM;CAIxB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CACnC,UAAU,SAAS,4BAA4B,GAAG,4BAA4B;IAE9E;;;;;OAKG;IACH,SAAS,EAAE,UAAU,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC;IAElB;;;;;;;;;;;;OAYG;IACH,cAAc,EAAE,WAAW,CAAC;CAC5B"}
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /* eslint-disable import/no-deprecated */
5
6
  import { assert } from "@fluidframework/core-utils";
6
7
  import { SortedSegmentSet, } from "@fluidframework/merge-tree";
7
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceDeltaEvent.js","sourceRoot":"","sources":["../src/sequenceDeltaEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAUN,gBAAgB,GAChB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,OAAgB,aAAa;IAQlC,YACiB,SAAkD,EACjD,eAAuB;QADxB,cAAS,GAAT,SAAS,CAAyC;QACjD,oBAAe,GAAf,eAAe,CAAQ;QAExC,MAAM,CACL,SAAS,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAClC,KAAK,CAAC,iDAAiD,CACvD,CAAC;QACF,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC;QAE1C,IAAI,CAAC,YAAY,GAAG,IAAI,IAAI,CAAoD,GAAG,EAAE;YACpF,MAAM,GAAG,GAAG,IAAI,gBAAgB,EAAmC,CAAC;YACpE,IAAI,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B,MAA6B,EAC7C,SAAsC,EACtC,eAAuB;QAEvB,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAJlB,WAAM,GAAN,MAAM,CAAuB;QAK7C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,gBAAgB,KAAK,SAAS,CAAC;IACtD,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,wBAAyB,SAAQ,aAAuC;IACpF,YACiB,MAAyC,EACzD,SAA4C,EAC5C,eAAuB;QAEvB,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAJlB,WAAM,GAAN,MAAM,CAAmC;IAK1D,CAAC;CACD;AA2CD,MAAM,IAAI;IAGT,YAA6B,cAAuB;QAAvB,mBAAc,GAAd,cAAc,CAAS;QACnD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IACzB,CAAC;IAED,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,IAAW,KAAK;QACf,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;SACpC;QACD,OAAO,IAAI,CAAC,MAAW,CAAC;IACzB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tClient,\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tISegment,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaOperationTypes,\n\tMergeTreeMaintenanceType,\n\tPropertySet,\n\tSortedSegmentSet,\n} from \"@fluidframework/merge-tree\";\n\n/**\n * Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.\n *\n * The properties of this object and its sub-objects represent the state of the sequence at the\n * point in time at which the operation was applied.\n * They will not take into any future modifications performed to the underlying sequence and merge tree.\n * @public\n */\nexport abstract class SequenceEvent<\n\tTOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes,\n> {\n\tpublic readonly deltaOperation: TOperation;\n\tprivate readonly sortedRanges: Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>;\n\tprivate readonly pFirst: Lazy<ISequenceDeltaRange<TOperation>>;\n\tprivate readonly pLast: Lazy<ISequenceDeltaRange<TOperation>>;\n\n\tconstructor(\n\t\tpublic readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>,\n\t\tprivate readonly mergeTreeClient: Client,\n\t) {\n\t\tassert(\n\t\t\tdeltaArgs.deltaSegments.length > 0,\n\t\t\t0x2d8 /* \"Empty change event should not be emitted.\" */,\n\t\t);\n\t\tthis.deltaOperation = deltaArgs.operation;\n\n\t\tthis.sortedRanges = new Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>(() => {\n\t\t\tconst set = new SortedSegmentSet<ISequenceDeltaRange<TOperation>>();\n\t\t\tthis.deltaArgs.deltaSegments.forEach((delta) => {\n\t\t\t\tconst newRange: ISequenceDeltaRange<TOperation> = {\n\t\t\t\t\toperation: this.deltaArgs.operation,\n\t\t\t\t\tposition: this.mergeTreeClient.getPosition(delta.segment),\n\t\t\t\t\tpropertyDeltas: delta.propertyDeltas ?? {},\n\t\t\t\t\tsegment: delta.segment,\n\t\t\t\t};\n\t\t\t\tset.addOrUpdate(newRange);\n\t\t\t});\n\t\t\treturn set;\n\t\t});\n\n\t\tthis.pFirst = new Lazy<ISequenceDeltaRange<TOperation>>(\n\t\t\t() => this.sortedRanges.value.items[0],\n\t\t);\n\n\t\tthis.pLast = new Lazy<ISequenceDeltaRange<TOperation>>(\n\t\t\t() => this.sortedRanges.value.items[this.sortedRanges.value.size - 1],\n\t\t);\n\t}\n\n\t/**\n\t * The in-order ranges affected by this delta.\n\t * These may not be continuous.\n\t */\n\tpublic get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[] {\n\t\treturn this.sortedRanges.value.items;\n\t}\n\n\t/**\n\t * The client id of the client that made the change which caused the delta event\n\t */\n\tpublic get clientId(): string | undefined {\n\t\treturn this.mergeTreeClient.longClientId;\n\t}\n\n\t/**\n\t * The first of the modified ranges.\n\t */\n\tpublic get first(): Readonly<ISequenceDeltaRange<TOperation>> {\n\t\treturn this.pFirst.value;\n\t}\n\n\t/**\n\t * The last of the modified ranges.\n\t */\n\tpublic get last(): Readonly<ISequenceDeltaRange<TOperation>> {\n\t\treturn this.pLast.value;\n\t}\n}\n\n/**\n * The event object returned on sequenceDelta events.\n *\n * The properties of this object and its sub-objects represent the state of the sequence at the\n * point in time at which the operation was applied.\n * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.\n *\n * For group ops, each op will get its own event, and the group op property will be set on the op args.\n *\n * Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.\n * @public\n */\nexport class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationType> {\n\t/**\n\t * Whether the event was caused by a locally-made change.\n\t */\n\tpublic readonly isLocal: boolean;\n\n\tconstructor(\n\t\tpublic readonly opArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t\tmergeTreeClient: Client,\n\t) {\n\t\tsuper(deltaArgs, mergeTreeClient);\n\t\tthis.isLocal = opArgs.sequencedMessage === undefined;\n\t}\n}\n\n/**\n * The event object returned on maintenance events.\n *\n * The properties of this object and its sub-objects represent the state of the sequence at the\n * point in time at which the operation was applied.\n * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.\n * @public\n */\nexport class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {\n\tconstructor(\n\t\tpublic readonly opArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\tdeltaArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\tmergeTreeClient: Client,\n\t) {\n\t\tsuper(deltaArgs, mergeTreeClient);\n\t}\n}\n\n/**\n * A range that has changed corresponding to a segment modification.\n * @public\n */\nexport interface ISequenceDeltaRange<\n\tTOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes,\n> {\n\t/**\n\t * The type of operation that changed this range.\n\t *\n\t * @remarks Consuming code should typically compare this to the enum values defined in\n\t * `MergeTreeDeltaOperationTypes`.\n\t */\n\toperation: TOperation;\n\n\t/**\n\t * The index of the start of the range.\n\t */\n\tposition: number;\n\n\t/**\n\t * The segment that corresponds to the range.\n\t */\n\tsegment: ISegment;\n\n\t/**\n\t * Deltas object which contains all modified properties with their previous values.\n\t * Since `undefined` doesn't survive a round-trip through JSON serialization, the old value being absent\n\t * is instead encoded with `null`.\n\t *\n\t * @remarks This object is motivated by undo/redo scenarios, and provides a convenient \"inverse op\" to apply to\n\t * undo a property change.\n\t *\n\t * @example\n\t *\n\t * If a segment initially had properties `{ foo: \"1\", bar: 2 }` and it was annotated with\n\t * `{ foo: 3, baz: 5 }`, the corresponding event would have a `propertyDeltas` of `{ foo: \"1\", baz: null }`.\n\t */\n\tpropertyDeltas: PropertySet;\n}\n\nclass Lazy<T> {\n\tprivate pValue: T | undefined;\n\tprivate pEvaluated: boolean;\n\tconstructor(private readonly valueGenerator: () => T) {\n\t\tthis.pEvaluated = false;\n\t}\n\n\tpublic get evaluated(): boolean {\n\t\treturn this.pEvaluated;\n\t}\n\n\tpublic get value(): T {\n\t\tif (!this.pEvaluated) {\n\t\t\tthis.pEvaluated = true;\n\t\t\tthis.pValue = this.valueGenerator();\n\t\t}\n\t\treturn this.pValue as T;\n\t}\n}\n"]}
1
+ {"version":3,"file":"sequenceDeltaEvent.js","sourceRoot":"","sources":["../src/sequenceDeltaEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yCAAyC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAUN,gBAAgB,GAChB,MAAM,4BAA4B,CAAC;A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CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tClient,\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tISegment,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaOperationTypes,\n\tMergeTreeMaintenanceType,\n\tPropertySet,\n\tSortedSegmentSet,\n} from \"@fluidframework/merge-tree\";\n\n/**\n * Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.\n *\n * The properties of this object and its sub-objects represent the state of the sequence at the\n * point in time at which the operation was applied.\n * They will not take into any future modifications performed to the underlying sequence and merge tree.\n * @public\n */\nexport abstract class SequenceEvent<\n\tTOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes,\n> {\n\tpublic readonly deltaOperation: TOperation;\n\tprivate readonly sortedRanges: Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>;\n\tprivate readonly pFirst: Lazy<ISequenceDeltaRange<TOperation>>;\n\tprivate readonly pLast: Lazy<ISequenceDeltaRange<TOperation>>;\n\n\tconstructor(\n\t\tpublic readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>,\n\t\tprivate readonly mergeTreeClient: Client,\n\t) {\n\t\tassert(\n\t\t\tdeltaArgs.deltaSegments.length > 0,\n\t\t\t0x2d8 /* \"Empty change event should not be emitted.\" */,\n\t\t);\n\t\tthis.deltaOperation = deltaArgs.operation;\n\n\t\tthis.sortedRanges = new Lazy<SortedSegmentSet<ISequenceDeltaRange<TOperation>>>(() => {\n\t\t\tconst set = new SortedSegmentSet<ISequenceDeltaRange<TOperation>>();\n\t\t\tthis.deltaArgs.deltaSegments.forEach((delta) => {\n\t\t\t\tconst newRange: ISequenceDeltaRange<TOperation> = {\n\t\t\t\t\toperation: this.deltaArgs.operation,\n\t\t\t\t\tposition: this.mergeTreeClient.getPosition(delta.segment),\n\t\t\t\t\tpropertyDeltas: delta.propertyDeltas ?? {},\n\t\t\t\t\tsegment: delta.segment,\n\t\t\t\t};\n\t\t\t\tset.addOrUpdate(newRange);\n\t\t\t});\n\t\t\treturn set;\n\t\t});\n\n\t\tthis.pFirst = new Lazy<ISequenceDeltaRange<TOperation>>(\n\t\t\t() => this.sortedRanges.value.items[0],\n\t\t);\n\n\t\tthis.pLast = new Lazy<ISequenceDeltaRange<TOperation>>(\n\t\t\t() => this.sortedRanges.value.items[this.sortedRanges.value.size - 1],\n\t\t);\n\t}\n\n\t/**\n\t * The in-order ranges affected by this delta.\n\t * These may not be continuous.\n\t */\n\tpublic get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[] {\n\t\treturn this.sortedRanges.value.items;\n\t}\n\n\t/**\n\t * The client id of the client that made the change which caused the delta event\n\t */\n\tpublic get clientId(): string | undefined {\n\t\treturn this.mergeTreeClient.longClientId;\n\t}\n\n\t/**\n\t * The first of the modified ranges.\n\t */\n\tpublic get first(): Readonly<ISequenceDeltaRange<TOperation>> {\n\t\treturn this.pFirst.value;\n\t}\n\n\t/**\n\t * The last of the modified ranges.\n\t */\n\tpublic get last(): Readonly<ISequenceDeltaRange<TOperation>> {\n\t\treturn this.pLast.value;\n\t}\n}\n\n/**\n * The event object returned on sequenceDelta events.\n *\n * The properties of this object and its sub-objects represent the state of the sequence at the\n * point in time at which the operation was applied.\n * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.\n *\n * For group ops, each op will get its own event, and the group op property will be set on the op args.\n *\n * Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.\n * @public\n */\nexport class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationType> {\n\t/**\n\t * Whether the event was caused by a locally-made change.\n\t */\n\tpublic readonly isLocal: boolean;\n\n\tconstructor(\n\t\tpublic readonly opArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t\tmergeTreeClient: Client,\n\t) {\n\t\tsuper(deltaArgs, mergeTreeClient);\n\t\tthis.isLocal = opArgs.sequencedMessage === undefined;\n\t}\n}\n\n/**\n * The event object returned on maintenance events.\n *\n * The properties of this object and its sub-objects represent the state of the sequence at the\n * point in time at which the operation was applied.\n * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.\n * @public\n */\nexport class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {\n\tconstructor(\n\t\tpublic readonly opArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\tdeltaArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\tmergeTreeClient: Client,\n\t) {\n\t\tsuper(deltaArgs, mergeTreeClient);\n\t}\n}\n\n/**\n * A range that has changed corresponding to a segment modification.\n * @public\n */\nexport interface ISequenceDeltaRange<\n\tTOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes,\n> {\n\t/**\n\t * The type of operation that changed this range.\n\t *\n\t * @remarks Consuming code should typically compare this to the enum values defined in\n\t * `MergeTreeDeltaOperationTypes`.\n\t */\n\toperation: TOperation;\n\n\t/**\n\t * The index of the start of the range.\n\t */\n\tposition: number;\n\n\t/**\n\t * The segment that corresponds to the range.\n\t */\n\tsegment: ISegment;\n\n\t/**\n\t * Deltas object which contains all modified properties with their previous values.\n\t * Since `undefined` doesn't survive a round-trip through JSON serialization, the old value being absent\n\t * is instead encoded with `null`.\n\t *\n\t * @remarks This object is motivated by undo/redo scenarios, and provides a convenient \"inverse op\" to apply to\n\t * undo a property change.\n\t *\n\t * @example\n\t *\n\t * If a segment initially had properties `{ foo: \"1\", bar: 2 }` and it was annotated with\n\t * `{ foo: 3, baz: 5 }`, the corresponding event would have a `propertyDeltas` of `{ foo: \"1\", baz: null }`.\n\t */\n\tpropertyDeltas: PropertySet;\n}\n\nclass Lazy<T> {\n\tprivate pValue: T | undefined;\n\tprivate pEvaluated: boolean;\n\tconstructor(private readonly valueGenerator: () => T) {\n\t\tthis.pEvaluated = false;\n\t}\n\n\tpublic get evaluated(): boolean {\n\t\treturn this.pEvaluated;\n\t}\n\n\tpublic get value(): T {\n\t\tif (!this.pEvaluated) {\n\t\t\tthis.pEvaluated = true;\n\t\t\tthis.pValue = this.valueGenerator();\n\t\t}\n\t\treturn this.pValue as T;\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/sequence",
3
- "version": "2.0.0-internal.7.2.2",
3
+ "version": "2.0.0-internal.7.3.0",
4
4
  "description": "Distributed sequence",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -35,35 +35,36 @@
35
35
  "temp-directory": "nyc/.nyc_output"
36
36
  },
37
37
  "dependencies": {
38
- "@fluid-internal/client-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
39
- "@fluidframework/core-interfaces": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
40
- "@fluidframework/core-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
41
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
42
- "@fluidframework/merge-tree": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
38
+ "@fluid-internal/client-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
39
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
40
+ "@fluidframework/core-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
41
+ "@fluidframework/datastore-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
42
+ "@fluidframework/merge-tree": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
43
43
  "@fluidframework/protocol-definitions": "^3.0.0",
44
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
45
- "@fluidframework/runtime-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
46
- "@fluidframework/shared-object-base": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
47
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
44
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
45
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
46
+ "@fluidframework/shared-object-base": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
47
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
48
48
  "uuid": "^9.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
52
- "@fluid-internal/test-dds-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
51
+ "@fluid-private/stochastic-test-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
52
+ "@fluid-private/test-dds-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
53
53
  "@fluid-tools/benchmark": "^0.48.0",
54
- "@fluid-tools/build-cli": "^0.26.1",
54
+ "@fluid-tools/build-cli": "^0.28.0",
55
55
  "@fluidframework/build-common": "^2.0.3",
56
- "@fluidframework/build-tools": "^0.26.1",
57
- "@fluidframework/eslint-config-fluid": "^3.0.0",
58
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
59
- "@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.0.0-internal.7.2.1",
60
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.2.2 <2.0.0-internal.7.3.0",
61
- "@microsoft/api-extractor": "^7.37.0",
56
+ "@fluidframework/build-tools": "^0.28.0",
57
+ "@fluidframework/eslint-config-fluid": "^3.1.0",
58
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
59
+ "@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.0.0-internal.7.2.0",
60
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
61
+ "@microsoft/api-extractor": "^7.38.3",
62
62
  "@types/diff": "^3.5.1",
63
63
  "@types/mocha": "^9.1.1",
64
64
  "@types/node": "^16.18.38",
65
65
  "@types/random-js": "^1.0.31",
66
66
  "c8": "^7.7.1",
67
+ "copyfiles": "^2.4.1",
67
68
  "cross-env": "^7.0.3",
68
69
  "diff": "^3.5.0",
69
70
  "eslint": "~8.50.0",
@@ -78,6 +79,14 @@
78
79
  },
79
80
  "fluidBuild": {
80
81
  "tasks": {
82
+ "build:docs": {
83
+ "dependsOn": [
84
+ "...",
85
+ "api-extractor:commonjs",
86
+ "api-extractor:esnext"
87
+ ],
88
+ "script": false
89
+ },
81
90
  "build:test": [
82
91
  "...",
83
92
  "@fluidframework/merge-tree#build:test"
@@ -88,15 +97,18 @@
88
97
  "broken": {}
89
98
  },
90
99
  "scripts": {
100
+ "api": "fluid-build . --task api",
101
+ "api-extractor:commonjs": "api-extractor run --local",
102
+ "api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
91
103
  "build": "fluid-build . --task build",
92
104
  "build:commonjs": "fluid-build . --task commonjs",
93
105
  "build:compile": "fluid-build . --task compile",
94
- "build:docs": "api-extractor run --local",
106
+ "build:docs": "fluid-build . --task api",
95
107
  "build:esnext": "tsc --project ./tsconfig.esnext.json",
96
108
  "build:genver": "gen-version",
97
109
  "build:test": "tsc --project ./src/test/tsconfig.json",
98
110
  "ci:build:docs": "api-extractor run",
99
- "clean": "rimraf --glob dist lib \"*.tsbuildinfo\" \"*.build.log\" _api-extractor-temp nyc",
111
+ "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
100
112
  "eslint": "eslint --format stylish src",
101
113
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
102
114
  "format": "npm run prettier:fix",
@@ -111,10 +123,10 @@
111
123
  "test:coverage": "c8 npm test",
112
124
  "test:memory": "mocha --config src/test/memory/.mocharc.js",
113
125
  "test:memory-profiling:report": "mocha --config src/test/memory/.mocharc.js",
114
- "test:mocha": "mocha --ignore 'dist/test/memory/**/*' --recursive 'dist/test/**/*.spec.js' -r node_modules/@fluidframework/mocha-test-setup",
126
+ "test:mocha": "mocha --ignore \"dist/test/memory/**/*\" --recursive \"dist/test/**/*.spec.js\" -r node_modules/@fluidframework/mocha-test-setup",
115
127
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
116
128
  "test:newsnapfiles": "node dist/test/createSnapshotFiles.js",
117
- "test:stress": "cross-env FUZZ_TEST_COUNT=100 FUZZ_STRESS_RUN=true mocha --ignore 'dist/test/memory/**/*' --recursive 'dist/test/**/*.fuzz.spec.js' -r @fluidframework/mocha-test-setup",
129
+ "test:stress": "cross-env FUZZ_TEST_COUNT=100 FUZZ_STRESS_RUN=true mocha --ignore \"dist/test/memory/**/*\" --recursive \"dist/test/**/*.fuzz.spec.js\" -r @fluidframework/mocha-test-setup",
118
130
  "testfarm": "node dist/test/testFarm.js",
119
131
  "tsc": "tsc",
120
132
  "typetests:gen": "fluid-type-test-generator",
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ /* eslint-disable import/no-deprecated */
6
7
  /* eslint-disable no-bitwise */
7
8
 
8
9
  import {
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/sequence";
9
- export const pkgVersion = "2.0.0-internal.7.2.2";
9
+ export const pkgVersion = "2.0.0-internal.7.3.0";