@fluidframework/matrix 2.0.0-dev.5.2.0.169897 → 2.0.0-dev.5.3.2.178189

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @fluidframework/matrix
2
2
 
3
+ ## 2.0.0-internal.5.3.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.0.0-internal.5.2.0
8
+
9
+ Dependency updates only.
10
+
11
+ ## 2.0.0-internal.5.1.0
12
+
13
+ Dependency updates only.
14
+
3
15
  ## 2.0.0-internal.5.0.0
4
16
 
5
17
  Dependency updates only.
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/matrix";
8
- export declare const pkgVersion = "2.0.0-dev.5.2.0.169897";
8
+ export declare const pkgVersion = "2.0.0-dev.5.3.2.178189";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/matrix";
11
- exports.pkgVersion = "2.0.0-dev.5.2.0.169897";
11
+ exports.pkgVersion = "2.0.0-dev.5.3.2.178189";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,wBAAwB,CAAC;AACnC,QAAA,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-dev.5.2.0.169897\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,wBAAwB,CAAC;AACnC,QAAA,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-dev.5.3.2.178189\";\n"]}
@@ -3,9 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
6
- import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
7
6
  import { BaseSegment, ISegment, Client, IJSONSegment } from "@fluidframework/merge-tree";
8
- import { IFluidHandle } from "@fluidframework/core-interfaces";
7
+ import { ITelemetryBaseLogger, IFluidHandle } from "@fluidframework/core-interfaces";
9
8
  import { IFluidSerializer } from "@fluidframework/shared-object-base";
10
9
  import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
11
10
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
@@ -1 +1 @@
1
- {"version":3,"file":"permutationvector.d.ts","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACN,WAAW,EACX,QAAQ,EACR,MAAM,EAMN,YAAY,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MA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OAAO,4BAAwB,EAC1D,UAAU,CACV,CAAC;IACH,CAAC;IAoGM,QAAQ;QACd,MAAM,CAAC,GAAa,EAAE,CAAC;QAEvB,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACb,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;CACD;AArSD,8CAqSC;AAED,SAAgB,yBAAyB,CACxC,MAAyB,EACzB,GAAW,EACX,IAAkB;IAElB,MAAM,QAAQ,GAAG,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAEzD,kEAAkE;IAClE,MAAM,EAAE,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,OAA6B,CAAC;IAEhF,oCAAoC;IACpC,wDAAwD;IACxD,IAAI,IAAA,2BAAa,EAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAClC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;KAChC;IAED,+EAA+E;IAC/E,8DAA8D;IAC9D,MAAM,CAAC,WAAW,CAAC,YAAY,CAC9B,GAAG;IACH,mBAAmB,CAAC,CAAC;IACrB,oBAAoB,CAAC,QAAQ,CAAC,YAAY,CAC1C,CAAC;IACF,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AACzB,CAAC;AAzBD,8DAyBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport {\n\tBaseSegment,\n\tISegment,\n\tClient,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeDeltaCallbackArgs,\n\tMergeTreeDeltaType,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tMergeTreeMaintenanceType,\n\tIJSONSegment,\n} from \"@fluidframework/merge-tree\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { HandleTable, Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { HandleCache } from \"./handlecache\";\nimport { VectorUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n\tsegments = \"segments\",\n\thandleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n\tpublic static readonly typeString: string = \"PermutationSegment\";\n\tprivate _start = Handle.unallocated;\n\n\tpublic static fromJSONObject(spec: any) {\n\t\tconst [length, start] = spec as PermutationSegmentSpec;\n\t\treturn new PermutationSegment(length, start);\n\t}\n\n\tpublic readonly type = PermutationSegment.typeString;\n\n\tconstructor(length: number, start = Handle.unallocated) {\n\t\tsuper();\n\t\tthis._start = start;\n\t\tthis.cachedLength = length;\n\t}\n\n\tpublic get start() {\n\t\treturn this._start;\n\t}\n\tpublic set start(value: Handle) {\n\t\tassert(\n\t\t\tthis._start === Handle.unallocated,\n\t\t\t0x024 /* \"Start of PermutationSegment already allocated!\" */,\n\t\t);\n\t\tassert(\n\t\t\tisHandleValid(value),\n\t\t\t0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */,\n\t\t);\n\n\t\tthis._start = value;\n\t}\n\n\tpublic reset() {\n\t\tthis._start = Handle.unallocated;\n\t}\n\n\tpublic toJSONObject() {\n\t\treturn [this.cachedLength, this.start];\n\t}\n\n\tpublic clone(start = 0, end = this.cachedLength) {\n\t\tconst b = new PermutationSegment(\n\t\t\t/* length: */ end - start,\n\t\t\t/* start: */ this.start + start,\n\t\t);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment) {\n\t\tconst asPerm = segment as PermutationSegment;\n\n\t\treturn this.start === Handle.unallocated\n\t\t\t? asPerm.start === Handle.unallocated\n\t\t\t: asPerm.start === this.start + this.cachedLength;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number) {\n\t\tassert(\n\t\t\t0 < pos && pos < this.cachedLength,\n\t\t\t0x026 /* \"Trying to split segment at out-of-bounds position!\" */,\n\t\t);\n\n\t\tconst leafSegment = new PermutationSegment(\n\t\t\t/* length: */ this.cachedLength - pos,\n\t\t\t/* start: */ this.start === Handle.unallocated ? Handle.unallocated : this.start + pos,\n\t\t);\n\n\t\tthis.cachedLength = pos;\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic toString() {\n\t\treturn this.start === Handle.unallocated\n\t\t\t? `<${this.cachedLength} empty>`\n\t\t\t: `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n\t}\n}\n\nexport class PermutationVector extends Client {\n\tprivate handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n\tpublic readonly handleCache = new HandleCache(this);\n\tpublic undo: VectorUndoProvider | undefined;\n\n\tconstructor(\n\t\tpath: string,\n\t\tlogger: ITelemetryBaseLogger,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tprivate readonly deltaCallback: (\n\t\t\tposition: number,\n\t\t\tnumRemoved: number,\n\t\t\tnumInserted: number,\n\t\t) => void,\n\t\tprivate readonly handlesRecycledCallback: (handles: Handle[]) => void,\n\t) {\n\t\tsuper(\n\t\t\tPermutationSegment.fromJSONObject,\n\t\t\tChildLogger.create(logger, `Matrix.${path}.MergeTreeClient`),\n\t\t\t{\n\t\t\t\t...runtime.options,\n\t\t\t\tnewMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.\n\t\t\t\tmergeTreeUseNewLengthCalculations: true,\n\t\t\t},\n\t\t); // (See https://github.com/microsoft/FluidFramework/issues/84)\n\n\t\tthis.on(\"delta\", this.onDelta);\n\t\tthis.on(\"maintenance\", this.onMaintenance);\n\t}\n\n\tpublic insert(start: number, length: number) {\n\t\treturn this.insertSegmentLocal(start, new PermutationSegment(length));\n\t}\n\n\tpublic remove(start: number, length: number) {\n\t\treturn this.removeRangeLocal(start, start + length);\n\t}\n\n\tpublic getMaybeHandle(pos: number): Handle {\n\t\tassert(\n\t\t\t0 <= pos && pos < this.getLength(),\n\t\t\t0x027 /* \"Trying to get handle of out-of-bounds position!\" */,\n\t\t);\n\n\t\treturn this.handleCache.getHandle(pos);\n\t}\n\n\tpublic getAllocatedHandle(pos: number): Handle {\n\t\tlet handle = this.getMaybeHandle(pos);\n\t\tif (isHandleValid(handle)) {\n\t\t\treturn handle;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment) => {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tasPerm.start = handle = this.handleTable.allocate();\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tpos,\n\t\t\tpos + 1,\n\t\t\t/* accum: */ undefined,\n\t\t\t/* splitRange: */ true,\n\t\t);\n\n\t\tthis.handleCache.addHandle(pos, handle);\n\n\t\treturn handle;\n\t}\n\n\tpublic adjustPosition(pos: number, op: ISequencedDocumentMessage) {\n\t\tconst { segment, offset } = this.getContainingSegment(pos, {\n\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\tclientId: op.clientId,\n\t\t});\n\n\t\t// Note that until the MergeTree GCs, the segment is still reachable via `getContainingSegment()` with\n\t\t// a `refSeq` in the past. Prevent remote ops from accidentally allocating or using recycled handles\n\t\t// by checking for the presence of 'removedSeq'.\n\t\tif (segment === undefined || segment.removedSeq !== undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.getPosition(segment) + offset!;\n\t}\n\n\tpublic handleToPosition(handle: Handle, localSeq = this.getCollabWindow().localSeq) {\n\t\tassert(\n\t\t\tlocalSeq <= this.getCollabWindow().localSeq,\n\t\t\t0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */,\n\t\t);\n\n\t\t// TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n\t\t// the original operation to the current position for undo/redo scenarios. This is probably the\n\t\t// ideal solution, as we would no longer need to store row/col handles in the op metadata.\n\t\t//\n\t\t// Failing that, we could avoid the O(n) search below by building a temporary map in the\n\t\t// opposite direction from the handle to either it's current position or segment + offset\n\t\t// and reuse it for the duration of undo/redo. (Ideally, we would know when the undo/redo\n\t\t// ended so we could discard this map.)\n\t\t//\n\t\t// If we find that we frequently need a reverse handle -> position lookup, we could maintain\n\t\t// one using the Tiny-Calc adjust tree.\n\t\tlet containingSegment!: PermutationSegment;\n\t\tlet containingOffset: number;\n\n\t\tthis.walkAllSegments((segment) => {\n\t\t\tconst { start, cachedLength } = segment as PermutationSegment;\n\n\t\t\t// If the segment is unallocated, skip it.\n\t\t\tif (!isHandleValid(start)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst end = start + cachedLength;\n\n\t\t\tif (start <= handle && handle < end) {\n\t\t\t\tcontainingSegment = segment as PermutationSegment;\n\t\t\t\tcontainingOffset = handle - start;\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\n\t\t// We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n\t\t// row/col has been removed, because handles are not recycled until the containing segment\n\t\t// is unlinked from the MergeTree.\n\t\t//\n\t\t// Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n\t\t// ops that reference the stale handle, or the removal is unACKed, in which case the handle\n\t\t// has not yet been recycled.\n\n\t\tassert(\n\t\t\tisHandleValid(containingSegment.start),\n\t\t\t0x029 /* \"Invalid handle at start of containing segment!\" */,\n\t\t);\n\n\t\t// Once we know the current position of the handle, we can use the MergeTree to get the segment\n\t\t// containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n\t\t// have not yet been submitted.\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n\t}\n\n\t// Constructs an ISummaryTreeWithStats for the cell data.\n\tpublic summarize(\n\t\truntime: IFluidDataStoreRuntime,\n\t\thandle: IFluidHandle,\n\t\tserializer: IFluidSerializer,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.segments,\n\t\t\tsuper.summarize(runtime, handle, serializer, /* catchUpMsgs: */ []),\n\t\t);\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer.stringify(this.handleTable.getSummaryContent(), handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tstorage: IChannelStorageService,\n\t\tserializer: IFluidSerializer,\n\t) {\n\t\tconst handleTableData = await deserializeBlob(\n\t\t\tstorage,\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer,\n\t\t);\n\n\t\tthis.handleTable = HandleTable.load<never>(handleTableData);\n\n\t\treturn super.load(\n\t\t\truntime,\n\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.segments),\n\t\t\tserializer,\n\t\t);\n\t}\n\n\tprivate readonly onDelta = (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t) => {\n\t\t// Apply deltas in descending order to prevent positions from shifting.\n\t\tconst ranges = deltaArgs.deltaSegments\n\t\t\t.map(({ segment }) => ({\n\t\t\t\tsegment: segment as PermutationSegment,\n\t\t\t\tposition: this.getPosition(segment),\n\t\t\t}))\n\t\t\t.sort((left, right) => left.position - right.position);\n\n\t\tconst isLocal = opArgs.sequencedMessage === undefined;\n\n\t\t// Notify the undo provider, if any is attached.\n\t\tif (this.undo !== undefined && isLocal) {\n\t\t\tthis.undo.record(deltaArgs);\n\t\t}\n\n\t\tswitch (deltaArgs.operation) {\n\t\t\tcase MergeTreeDeltaType.INSERT:\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\t// HACK: We need to include the allocated handle in the segment's JSON representation\n\t\t\t\t\t// for snapshots, but need to ignore the remote client's handle allocations when\n\t\t\t\t\t// processing remote ops.\n\t\t\t\t\tsegment.reset();\n\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* deleteCount: */ 0,\n\t\t\t\t\t\t/* insertCount: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ 0,\n\t\t\t\t\t\t/* numInserted: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition /* deleteCount: */,\n\t\t\t\t\t\tsegment.cachedLength,\n\t\t\t\t\t\t/* insertCount: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ segment.cachedLength,\n\t\t\t\t\t\t/* numInsert: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unhandled MergeTreeDeltaType\");\n\t\t}\n\t};\n\n\tprivate readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs) => {\n\t\tif (args.operation === MergeTreeMaintenanceType.UNLINK) {\n\t\t\tlet freed: number[] = [];\n\n\t\t\tfor (const { segment } of args.deltaSegments) {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tif (isHandleValid(asPerm.start)) {\n\t\t\t\t\t// Note: Using the spread operator with `.splice()` can exhaust the stack.\n\t\t\t\t\tfreed = freed.concat(\n\t\t\t\t\t\tnew Array(asPerm.cachedLength)\n\t\t\t\t\t\t\t.fill(0)\n\t\t\t\t\t\t\t.map((value, index) => index + asPerm.start),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n\t\t\t// the rows/cols prior to free to ensure recycled row/cols are initially empty.\n\t\t\tthis.handlesRecycledCallback(freed);\n\n\t\t\t// Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n\t\t\tfor (const handle of freed) {\n\t\t\t\tthis.handleTable.free(handle);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic toString() {\n\t\tconst s: string[] = [];\n\n\t\tthis.walkSegments((segment) => {\n\t\t\ts.push(`${segment}`);\n\t\t\treturn true;\n\t\t});\n\n\t\treturn s.join(\"\");\n\t}\n}\n\nexport function reinsertSegmentIntoVector(\n\tvector: PermutationVector,\n\tpos: number,\n\tspec: IJSONSegment,\n) {\n\tconst original = PermutationSegment.fromJSONObject(spec);\n\n\t// (Re)insert the removed number of rows at the original position.\n\tconst op = vector.insertSegmentLocal(pos, original);\n\tconst inserted = vector.getContainingSegment(pos).segment as PermutationSegment;\n\n\t// we reuse the original handle here\n\t// so if cells exist, they can be found, and re-inserted\n\tif (isHandleValid(original.start)) {\n\t\tinserted.start = original.start;\n\t}\n\n\t// Invalidate the handleCache in case it was populated during the 'rowsChanged'\n\t// callback, which occurs before the handle span is populated.\n\tvector.handleCache.itemsChanged(\n\t\tpos,\n\t\t/* removedCount: */ 0,\n\t\t/* insertedCount: */ inserted.cachedLength,\n\t);\n\treturn { op, inserted };\n}\n"]}
1
+ {"version":3,"file":"permutationvector.js","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,qEAA8D;AAK9D,2DAUoC;AAIpC,iEAA2F;AAE3F,+CAAmE;AACnE,mDAAkD;AAClD,+CAA4C;AAU5C,MAAa,kBAAmB,SAAQ,wBAAW;IAWlD,YAAY,MAAc,EAAE,KAAK,gCAAqB;QACrD,KAAK,EAAE,CAAC;QAVD,WAAM,iCAAsB;QAOpB,SAAI,GAAG,kBAAkB,CAAC,UAAU,CAAC;QAIpD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;IAC5B,CAAC;IAXM,MAAM,CAAC,cAAc,CAAC,IAAS;QACrC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAA8B,CAAC;QACvD,OAAO,IAAI,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAUD,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,IAAW,KAAK,CAAC,KAAa;QAC7B,IAAA,qBAAM,EACL,IAAI,CAAC,MAAM,kCAAuB,EAClC,KAAK,CAAC,sDAAsD,CAC5D,CAAC;QACF,IAAA,qBAAM,EACL,IAAA,2BAAa,EAAC,KAA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AE,CAAC,CAAC;IACnB,CAAC;CACD;AArSD,8CAqSC;AAED,SAAgB,yBAAyB,CACxC,MAAyB,EACzB,GAAW,EACX,IAAkB;IAElB,MAAM,QAAQ,GAAG,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAEzD,kEAAkE;IAClE,MAAM,EAAE,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,OAA6B,CAAC;IAEhF,oCAAoC;IACpC,wDAAwD;IACxD,IAAI,IAAA,2BAAa,EAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAClC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;KAChC;IAED,+EAA+E;IAC/E,8DAA8D;IAC9D,MAAM,CAAC,WAAW,CAAC,YAAY,CAC9B,GAAG;IACH,mBAAmB,CAAC,CAAC;IACrB,oBAAoB,CAAC,QAAQ,CAAC,YAAY,CAC1C,CAAC;IACF,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AACzB,CAAC;AAzBD,8DAyBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\tBaseSegment,\n\tISegment,\n\tClient,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeDeltaCallbackArgs,\n\tMergeTreeDeltaType,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tMergeTreeMaintenanceType,\n\tIJSONSegment,\n} from \"@fluidframework/merge-tree\";\nimport { ITelemetryBaseLogger, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { HandleTable, Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { HandleCache } from \"./handlecache\";\nimport { VectorUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n\tsegments = \"segments\",\n\thandleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n\tpublic static readonly typeString: string = \"PermutationSegment\";\n\tprivate _start = Handle.unallocated;\n\n\tpublic static fromJSONObject(spec: any) {\n\t\tconst [length, start] = spec as PermutationSegmentSpec;\n\t\treturn new PermutationSegment(length, start);\n\t}\n\n\tpublic readonly type = PermutationSegment.typeString;\n\n\tconstructor(length: number, start = Handle.unallocated) {\n\t\tsuper();\n\t\tthis._start = start;\n\t\tthis.cachedLength = length;\n\t}\n\n\tpublic get start() {\n\t\treturn this._start;\n\t}\n\tpublic set start(value: Handle) {\n\t\tassert(\n\t\t\tthis._start === Handle.unallocated,\n\t\t\t0x024 /* \"Start of PermutationSegment already allocated!\" */,\n\t\t);\n\t\tassert(\n\t\t\tisHandleValid(value),\n\t\t\t0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */,\n\t\t);\n\n\t\tthis._start = value;\n\t}\n\n\tpublic reset() {\n\t\tthis._start = Handle.unallocated;\n\t}\n\n\tpublic toJSONObject() {\n\t\treturn [this.cachedLength, this.start];\n\t}\n\n\tpublic clone(start = 0, end = this.cachedLength) {\n\t\tconst b = new PermutationSegment(\n\t\t\t/* length: */ end - start,\n\t\t\t/* start: */ this.start + start,\n\t\t);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment) {\n\t\tconst asPerm = segment as PermutationSegment;\n\n\t\treturn this.start === Handle.unallocated\n\t\t\t? asPerm.start === Handle.unallocated\n\t\t\t: asPerm.start === this.start + this.cachedLength;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number) {\n\t\tassert(\n\t\t\t0 < pos && pos < this.cachedLength,\n\t\t\t0x026 /* \"Trying to split segment at out-of-bounds position!\" */,\n\t\t);\n\n\t\tconst leafSegment = new PermutationSegment(\n\t\t\t/* length: */ this.cachedLength - pos,\n\t\t\t/* start: */ this.start === Handle.unallocated ? Handle.unallocated : this.start + pos,\n\t\t);\n\n\t\tthis.cachedLength = pos;\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic toString() {\n\t\treturn this.start === Handle.unallocated\n\t\t\t? `<${this.cachedLength} empty>`\n\t\t\t: `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n\t}\n}\n\nexport class PermutationVector extends Client {\n\tprivate handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n\tpublic readonly handleCache = new HandleCache(this);\n\tpublic undo: VectorUndoProvider | undefined;\n\n\tconstructor(\n\t\tpath: string,\n\t\tlogger: ITelemetryBaseLogger,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tprivate readonly deltaCallback: (\n\t\t\tposition: number,\n\t\t\tnumRemoved: number,\n\t\t\tnumInserted: number,\n\t\t) => void,\n\t\tprivate readonly handlesRecycledCallback: (handles: Handle[]) => void,\n\t) {\n\t\tsuper(\n\t\t\tPermutationSegment.fromJSONObject,\n\t\t\tChildLogger.create(logger, `Matrix.${path}.MergeTreeClient`),\n\t\t\t{\n\t\t\t\t...runtime.options,\n\t\t\t\tnewMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.\n\t\t\t\tmergeTreeUseNewLengthCalculations: true,\n\t\t\t},\n\t\t); // (See https://github.com/microsoft/FluidFramework/issues/84)\n\n\t\tthis.on(\"delta\", this.onDelta);\n\t\tthis.on(\"maintenance\", this.onMaintenance);\n\t}\n\n\tpublic insert(start: number, length: number) {\n\t\treturn this.insertSegmentLocal(start, new PermutationSegment(length));\n\t}\n\n\tpublic remove(start: number, length: number) {\n\t\treturn this.removeRangeLocal(start, start + length);\n\t}\n\n\tpublic getMaybeHandle(pos: number): Handle {\n\t\tassert(\n\t\t\t0 <= pos && pos < this.getLength(),\n\t\t\t0x027 /* \"Trying to get handle of out-of-bounds position!\" */,\n\t\t);\n\n\t\treturn this.handleCache.getHandle(pos);\n\t}\n\n\tpublic getAllocatedHandle(pos: number): Handle {\n\t\tlet handle = this.getMaybeHandle(pos);\n\t\tif (isHandleValid(handle)) {\n\t\t\treturn handle;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment) => {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tasPerm.start = handle = this.handleTable.allocate();\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tpos,\n\t\t\tpos + 1,\n\t\t\t/* accum: */ undefined,\n\t\t\t/* splitRange: */ true,\n\t\t);\n\n\t\tthis.handleCache.addHandle(pos, handle);\n\n\t\treturn handle;\n\t}\n\n\tpublic adjustPosition(pos: number, op: ISequencedDocumentMessage) {\n\t\tconst { segment, offset } = this.getContainingSegment(pos, {\n\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\tclientId: op.clientId,\n\t\t});\n\n\t\t// Note that until the MergeTree GCs, the segment is still reachable via `getContainingSegment()` with\n\t\t// a `refSeq` in the past. Prevent remote ops from accidentally allocating or using recycled handles\n\t\t// by checking for the presence of 'removedSeq'.\n\t\tif (segment === undefined || segment.removedSeq !== undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.getPosition(segment) + offset!;\n\t}\n\n\tpublic handleToPosition(handle: Handle, localSeq = this.getCollabWindow().localSeq) {\n\t\tassert(\n\t\t\tlocalSeq <= this.getCollabWindow().localSeq,\n\t\t\t0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */,\n\t\t);\n\n\t\t// TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n\t\t// the original operation to the current position for undo/redo scenarios. This is probably the\n\t\t// ideal solution, as we would no longer need to store row/col handles in the op metadata.\n\t\t//\n\t\t// Failing that, we could avoid the O(n) search below by building a temporary map in the\n\t\t// opposite direction from the handle to either it's current position or segment + offset\n\t\t// and reuse it for the duration of undo/redo. (Ideally, we would know when the undo/redo\n\t\t// ended so we could discard this map.)\n\t\t//\n\t\t// If we find that we frequently need a reverse handle -> position lookup, we could maintain\n\t\t// one using the Tiny-Calc adjust tree.\n\t\tlet containingSegment!: PermutationSegment;\n\t\tlet containingOffset: number;\n\n\t\tthis.walkAllSegments((segment) => {\n\t\t\tconst { start, cachedLength } = segment as PermutationSegment;\n\n\t\t\t// If the segment is unallocated, skip it.\n\t\t\tif (!isHandleValid(start)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst end = start + cachedLength;\n\n\t\t\tif (start <= handle && handle < end) {\n\t\t\t\tcontainingSegment = segment as PermutationSegment;\n\t\t\t\tcontainingOffset = handle - start;\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\n\t\t// We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n\t\t// row/col has been removed, because handles are not recycled until the containing segment\n\t\t// is unlinked from the MergeTree.\n\t\t//\n\t\t// Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n\t\t// ops that reference the stale handle, or the removal is unACKed, in which case the handle\n\t\t// has not yet been recycled.\n\n\t\tassert(\n\t\t\tisHandleValid(containingSegment.start),\n\t\t\t0x029 /* \"Invalid handle at start of containing segment!\" */,\n\t\t);\n\n\t\t// Once we know the current position of the handle, we can use the MergeTree to get the segment\n\t\t// containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n\t\t// have not yet been submitted.\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n\t}\n\n\t// Constructs an ISummaryTreeWithStats for the cell data.\n\tpublic summarize(\n\t\truntime: IFluidDataStoreRuntime,\n\t\thandle: IFluidHandle,\n\t\tserializer: IFluidSerializer,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.segments,\n\t\t\tsuper.summarize(runtime, handle, serializer, /* catchUpMsgs: */ []),\n\t\t);\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer.stringify(this.handleTable.getSummaryContent(), handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tstorage: IChannelStorageService,\n\t\tserializer: IFluidSerializer,\n\t) {\n\t\tconst handleTableData = await deserializeBlob(\n\t\t\tstorage,\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer,\n\t\t);\n\n\t\tthis.handleTable = HandleTable.load<never>(handleTableData);\n\n\t\treturn super.load(\n\t\t\truntime,\n\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.segments),\n\t\t\tserializer,\n\t\t);\n\t}\n\n\tprivate readonly onDelta = (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t) => {\n\t\t// Apply deltas in descending order to prevent positions from shifting.\n\t\tconst ranges = deltaArgs.deltaSegments\n\t\t\t.map(({ segment }) => ({\n\t\t\t\tsegment: segment as PermutationSegment,\n\t\t\t\tposition: this.getPosition(segment),\n\t\t\t}))\n\t\t\t.sort((left, right) => left.position - right.position);\n\n\t\tconst isLocal = opArgs.sequencedMessage === undefined;\n\n\t\t// Notify the undo provider, if any is attached.\n\t\tif (this.undo !== undefined && isLocal) {\n\t\t\tthis.undo.record(deltaArgs);\n\t\t}\n\n\t\tswitch (deltaArgs.operation) {\n\t\t\tcase MergeTreeDeltaType.INSERT:\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\t// HACK: We need to include the allocated handle in the segment's JSON representation\n\t\t\t\t\t// for snapshots, but need to ignore the remote client's handle allocations when\n\t\t\t\t\t// processing remote ops.\n\t\t\t\t\tsegment.reset();\n\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* deleteCount: */ 0,\n\t\t\t\t\t\t/* insertCount: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ 0,\n\t\t\t\t\t\t/* numInserted: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition /* deleteCount: */,\n\t\t\t\t\t\tsegment.cachedLength,\n\t\t\t\t\t\t/* insertCount: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ segment.cachedLength,\n\t\t\t\t\t\t/* numInsert: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unhandled MergeTreeDeltaType\");\n\t\t}\n\t};\n\n\tprivate readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs) => {\n\t\tif (args.operation === MergeTreeMaintenanceType.UNLINK) {\n\t\t\tlet freed: number[] = [];\n\n\t\t\tfor (const { segment } of args.deltaSegments) {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tif (isHandleValid(asPerm.start)) {\n\t\t\t\t\t// Note: Using the spread operator with `.splice()` can exhaust the stack.\n\t\t\t\t\tfreed = freed.concat(\n\t\t\t\t\t\tnew Array(asPerm.cachedLength)\n\t\t\t\t\t\t\t.fill(0)\n\t\t\t\t\t\t\t.map((value, index) => index + asPerm.start),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n\t\t\t// the rows/cols prior to free to ensure recycled row/cols are initially empty.\n\t\t\tthis.handlesRecycledCallback(freed);\n\n\t\t\t// Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n\t\t\tfor (const handle of freed) {\n\t\t\t\tthis.handleTable.free(handle);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic toString() {\n\t\tconst s: string[] = [];\n\n\t\tthis.walkSegments((segment) => {\n\t\t\ts.push(`${segment}`);\n\t\t\treturn true;\n\t\t});\n\n\t\treturn s.join(\"\");\n\t}\n}\n\nexport function reinsertSegmentIntoVector(\n\tvector: PermutationVector,\n\tpos: number,\n\tspec: IJSONSegment,\n) {\n\tconst original = PermutationSegment.fromJSONObject(spec);\n\n\t// (Re)insert the removed number of rows at the original position.\n\tconst op = vector.insertSegmentLocal(pos, original);\n\tconst inserted = vector.getContainingSegment(pos).segment as PermutationSegment;\n\n\t// we reuse the original handle here\n\t// so if cells exist, they can be found, and re-inserted\n\tif (isHandleValid(original.start)) {\n\t\tinserted.start = original.start;\n\t}\n\n\t// Invalidate the handleCache in case it was populated during the 'rowsChanged'\n\t// callback, which occurs before the handle span is populated.\n\tvector.handleCache.itemsChanged(\n\t\tpos,\n\t\t/* removedCount: */ 0,\n\t\t/* insertedCount: */ inserted.cachedLength,\n\t);\n\treturn { op, inserted };\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/matrix";
8
- export declare const pkgVersion = "2.0.0-dev.5.2.0.169897";
8
+ export declare const pkgVersion = "2.0.0-dev.5.3.2.178189";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/matrix";
8
- export const pkgVersion = "2.0.0-dev.5.2.0.169897";
8
+ export const pkgVersion = "2.0.0-dev.5.3.2.178189";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAChD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-dev.5.2.0.169897\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAChD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-dev.5.3.2.178189\";\n"]}
@@ -3,9 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
6
- import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
7
6
  import { BaseSegment, ISegment, Client, IJSONSegment } from "@fluidframework/merge-tree";
8
- import { IFluidHandle } from "@fluidframework/core-interfaces";
7
+ import { ITelemetryBaseLogger, IFluidHandle } from "@fluidframework/core-interfaces";
9
8
  import { IFluidSerializer } from "@fluidframework/shared-object-base";
10
9
  import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
11
10
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
@@ -1 +1 @@
1
- {"version":3,"file":"permutationvector.d.ts","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACN,WAAW,EACX,QAAQ,EACR,MAAM,EAMN,YAAY,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAe,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AASpD,qBAAa,kBAAmB,SAAQ,WAAW;IAClD,gBAAuB,UAAU,E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YAAY,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACb,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;CACD;AAED,MAAM,UAAU,yBAAyB,CACxC,MAAyB,EACzB,GAAW,EACX,IAAkB;IAElB,MAAM,QAAQ,GAAG,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAEzD,kEAAkE;IAClE,MAAM,EAAE,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,OAA6B,CAAC;IAEhF,oCAAoC;IACpC,wDAAwD;IACxD,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAClC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;KAChC;IAED,+EAA+E;IAC/E,8DAA8D;IAC9D,MAAM,CAAC,WAAW,CAAC,YAAY,CAC9B,GAAG;IACH,mBAAmB,CAAC,CAAC;IACrB,oBAAoB,CAAC,QAAQ,CAAC,YAAY,CAC1C,CAAC;IACF,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport {\n\tBaseSegment,\n\tISegment,\n\tClient,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeDeltaCallbackArgs,\n\tMergeTreeDeltaType,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tMergeTreeMaintenanceType,\n\tIJSONSegment,\n} from \"@fluidframework/merge-tree\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { HandleTable, Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { HandleCache } from \"./handlecache\";\nimport { VectorUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n\tsegments = \"segments\",\n\thandleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n\tpublic static readonly typeString: string = \"PermutationSegment\";\n\tprivate _start = Handle.unallocated;\n\n\tpublic static fromJSONObject(spec: any) {\n\t\tconst [length, start] = spec as PermutationSegmentSpec;\n\t\treturn new PermutationSegment(length, start);\n\t}\n\n\tpublic readonly type = PermutationSegment.typeString;\n\n\tconstructor(length: number, start = Handle.unallocated) {\n\t\tsuper();\n\t\tthis._start = start;\n\t\tthis.cachedLength = length;\n\t}\n\n\tpublic get start() {\n\t\treturn this._start;\n\t}\n\tpublic set start(value: Handle) {\n\t\tassert(\n\t\t\tthis._start === Handle.unallocated,\n\t\t\t0x024 /* \"Start of PermutationSegment already allocated!\" */,\n\t\t);\n\t\tassert(\n\t\t\tisHandleValid(value),\n\t\t\t0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */,\n\t\t);\n\n\t\tthis._start = value;\n\t}\n\n\tpublic reset() {\n\t\tthis._start = Handle.unallocated;\n\t}\n\n\tpublic toJSONObject() {\n\t\treturn [this.cachedLength, this.start];\n\t}\n\n\tpublic clone(start = 0, end = this.cachedLength) {\n\t\tconst b = new PermutationSegment(\n\t\t\t/* length: */ end - start,\n\t\t\t/* start: */ this.start + start,\n\t\t);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment) {\n\t\tconst asPerm = segment as PermutationSegment;\n\n\t\treturn this.start === Handle.unallocated\n\t\t\t? asPerm.start === Handle.unallocated\n\t\t\t: asPerm.start === this.start + this.cachedLength;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number) {\n\t\tassert(\n\t\t\t0 < pos && pos < this.cachedLength,\n\t\t\t0x026 /* \"Trying to split segment at out-of-bounds position!\" */,\n\t\t);\n\n\t\tconst leafSegment = new PermutationSegment(\n\t\t\t/* length: */ this.cachedLength - pos,\n\t\t\t/* start: */ this.start === Handle.unallocated ? Handle.unallocated : this.start + pos,\n\t\t);\n\n\t\tthis.cachedLength = pos;\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic toString() {\n\t\treturn this.start === Handle.unallocated\n\t\t\t? `<${this.cachedLength} empty>`\n\t\t\t: `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n\t}\n}\n\nexport class PermutationVector extends Client {\n\tprivate handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n\tpublic readonly handleCache = new HandleCache(this);\n\tpublic undo: VectorUndoProvider | undefined;\n\n\tconstructor(\n\t\tpath: string,\n\t\tlogger: ITelemetryBaseLogger,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tprivate readonly deltaCallback: (\n\t\t\tposition: number,\n\t\t\tnumRemoved: number,\n\t\t\tnumInserted: number,\n\t\t) => void,\n\t\tprivate readonly handlesRecycledCallback: (handles: Handle[]) => void,\n\t) {\n\t\tsuper(\n\t\t\tPermutationSegment.fromJSONObject,\n\t\t\tChildLogger.create(logger, `Matrix.${path}.MergeTreeClient`),\n\t\t\t{\n\t\t\t\t...runtime.options,\n\t\t\t\tnewMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.\n\t\t\t\tmergeTreeUseNewLengthCalculations: true,\n\t\t\t},\n\t\t); // (See https://github.com/microsoft/FluidFramework/issues/84)\n\n\t\tthis.on(\"delta\", this.onDelta);\n\t\tthis.on(\"maintenance\", this.onMaintenance);\n\t}\n\n\tpublic insert(start: number, length: number) {\n\t\treturn this.insertSegmentLocal(start, new PermutationSegment(length));\n\t}\n\n\tpublic remove(start: number, length: number) {\n\t\treturn this.removeRangeLocal(start, start + length);\n\t}\n\n\tpublic getMaybeHandle(pos: number): Handle {\n\t\tassert(\n\t\t\t0 <= pos && pos < this.getLength(),\n\t\t\t0x027 /* \"Trying to get handle of out-of-bounds position!\" */,\n\t\t);\n\n\t\treturn this.handleCache.getHandle(pos);\n\t}\n\n\tpublic getAllocatedHandle(pos: number): Handle {\n\t\tlet handle = this.getMaybeHandle(pos);\n\t\tif (isHandleValid(handle)) {\n\t\t\treturn handle;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment) => {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tasPerm.start = handle = this.handleTable.allocate();\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tpos,\n\t\t\tpos + 1,\n\t\t\t/* accum: */ undefined,\n\t\t\t/* splitRange: */ true,\n\t\t);\n\n\t\tthis.handleCache.addHandle(pos, handle);\n\n\t\treturn handle;\n\t}\n\n\tpublic adjustPosition(pos: number, op: ISequencedDocumentMessage) {\n\t\tconst { segment, offset } = this.getContainingSegment(pos, {\n\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\tclientId: op.clientId,\n\t\t});\n\n\t\t// Note that until the MergeTree GCs, the segment is still reachable via `getContainingSegment()` with\n\t\t// a `refSeq` in the past. Prevent remote ops from accidentally allocating or using recycled handles\n\t\t// by checking for the presence of 'removedSeq'.\n\t\tif (segment === undefined || segment.removedSeq !== undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.getPosition(segment) + offset!;\n\t}\n\n\tpublic handleToPosition(handle: Handle, localSeq = this.getCollabWindow().localSeq) {\n\t\tassert(\n\t\t\tlocalSeq <= this.getCollabWindow().localSeq,\n\t\t\t0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */,\n\t\t);\n\n\t\t// TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n\t\t// the original operation to the current position for undo/redo scenarios. This is probably the\n\t\t// ideal solution, as we would no longer need to store row/col handles in the op metadata.\n\t\t//\n\t\t// Failing that, we could avoid the O(n) search below by building a temporary map in the\n\t\t// opposite direction from the handle to either it's current position or segment + offset\n\t\t// and reuse it for the duration of undo/redo. (Ideally, we would know when the undo/redo\n\t\t// ended so we could discard this map.)\n\t\t//\n\t\t// If we find that we frequently need a reverse handle -> position lookup, we could maintain\n\t\t// one using the Tiny-Calc adjust tree.\n\t\tlet containingSegment!: PermutationSegment;\n\t\tlet containingOffset: number;\n\n\t\tthis.walkAllSegments((segment) => {\n\t\t\tconst { start, cachedLength } = segment as PermutationSegment;\n\n\t\t\t// If the segment is unallocated, skip it.\n\t\t\tif (!isHandleValid(start)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst end = start + cachedLength;\n\n\t\t\tif (start <= handle && handle < end) {\n\t\t\t\tcontainingSegment = segment as PermutationSegment;\n\t\t\t\tcontainingOffset = handle - start;\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\n\t\t// We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n\t\t// row/col has been removed, because handles are not recycled until the containing segment\n\t\t// is unlinked from the MergeTree.\n\t\t//\n\t\t// Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n\t\t// ops that reference the stale handle, or the removal is unACKed, in which case the handle\n\t\t// has not yet been recycled.\n\n\t\tassert(\n\t\t\tisHandleValid(containingSegment.start),\n\t\t\t0x029 /* \"Invalid handle at start of containing segment!\" */,\n\t\t);\n\n\t\t// Once we know the current position of the handle, we can use the MergeTree to get the segment\n\t\t// containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n\t\t// have not yet been submitted.\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n\t}\n\n\t// Constructs an ISummaryTreeWithStats for the cell data.\n\tpublic summarize(\n\t\truntime: IFluidDataStoreRuntime,\n\t\thandle: IFluidHandle,\n\t\tserializer: IFluidSerializer,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.segments,\n\t\t\tsuper.summarize(runtime, handle, serializer, /* catchUpMsgs: */ []),\n\t\t);\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer.stringify(this.handleTable.getSummaryContent(), handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tstorage: IChannelStorageService,\n\t\tserializer: IFluidSerializer,\n\t) {\n\t\tconst handleTableData = await deserializeBlob(\n\t\t\tstorage,\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer,\n\t\t);\n\n\t\tthis.handleTable = HandleTable.load<never>(handleTableData);\n\n\t\treturn super.load(\n\t\t\truntime,\n\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.segments),\n\t\t\tserializer,\n\t\t);\n\t}\n\n\tprivate readonly onDelta = (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t) => {\n\t\t// Apply deltas in descending order to prevent positions from shifting.\n\t\tconst ranges = deltaArgs.deltaSegments\n\t\t\t.map(({ segment }) => ({\n\t\t\t\tsegment: segment as PermutationSegment,\n\t\t\t\tposition: this.getPosition(segment),\n\t\t\t}))\n\t\t\t.sort((left, right) => left.position - right.position);\n\n\t\tconst isLocal = opArgs.sequencedMessage === undefined;\n\n\t\t// Notify the undo provider, if any is attached.\n\t\tif (this.undo !== undefined && isLocal) {\n\t\t\tthis.undo.record(deltaArgs);\n\t\t}\n\n\t\tswitch (deltaArgs.operation) {\n\t\t\tcase MergeTreeDeltaType.INSERT:\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\t// HACK: We need to include the allocated handle in the segment's JSON representation\n\t\t\t\t\t// for snapshots, but need to ignore the remote client's handle allocations when\n\t\t\t\t\t// processing remote ops.\n\t\t\t\t\tsegment.reset();\n\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* deleteCount: */ 0,\n\t\t\t\t\t\t/* insertCount: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ 0,\n\t\t\t\t\t\t/* numInserted: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition /* deleteCount: */,\n\t\t\t\t\t\tsegment.cachedLength,\n\t\t\t\t\t\t/* insertCount: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ segment.cachedLength,\n\t\t\t\t\t\t/* numInsert: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unhandled MergeTreeDeltaType\");\n\t\t}\n\t};\n\n\tprivate readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs) => {\n\t\tif (args.operation === MergeTreeMaintenanceType.UNLINK) {\n\t\t\tlet freed: number[] = [];\n\n\t\t\tfor (const { segment } of args.deltaSegments) {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tif (isHandleValid(asPerm.start)) {\n\t\t\t\t\t// Note: Using the spread operator with `.splice()` can exhaust the stack.\n\t\t\t\t\tfreed = freed.concat(\n\t\t\t\t\t\tnew Array(asPerm.cachedLength)\n\t\t\t\t\t\t\t.fill(0)\n\t\t\t\t\t\t\t.map((value, index) => index + asPerm.start),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n\t\t\t// the rows/cols prior to free to ensure recycled row/cols are initially empty.\n\t\t\tthis.handlesRecycledCallback(freed);\n\n\t\t\t// Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n\t\t\tfor (const handle of freed) {\n\t\t\t\tthis.handleTable.free(handle);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic toString() {\n\t\tconst s: string[] = [];\n\n\t\tthis.walkSegments((segment) => {\n\t\t\ts.push(`${segment}`);\n\t\t\treturn true;\n\t\t});\n\n\t\treturn s.join(\"\");\n\t}\n}\n\nexport function reinsertSegmentIntoVector(\n\tvector: PermutationVector,\n\tpos: number,\n\tspec: IJSONSegment,\n) {\n\tconst original = PermutationSegment.fromJSONObject(spec);\n\n\t// (Re)insert the removed number of rows at the original position.\n\tconst op = vector.insertSegmentLocal(pos, original);\n\tconst inserted = vector.getContainingSegment(pos).segment as PermutationSegment;\n\n\t// we reuse the original handle here\n\t// so if cells exist, they can be found, and re-inserted\n\tif (isHandleValid(original.start)) {\n\t\tinserted.start = original.start;\n\t}\n\n\t// Invalidate the handleCache in case it was populated during the 'rowsChanged'\n\t// callback, which occurs before the handle span is populated.\n\tvector.handleCache.itemsChanged(\n\t\tpos,\n\t\t/* removedCount: */ 0,\n\t\t/* insertedCount: */ inserted.cachedLength,\n\t);\n\treturn { op, inserted };\n}\n"]}
1
+ {"version":3,"file":"permutationvector.js","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAK9D,OAAO,EACN,WAAW,EAEX,MAAM,EAGN,kBAAkB,EAElB,wBAAwB,GAExB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,WAAW,EAAU,aAAa,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAU5C,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IAWlD,YAAY,MAAc,EAAE,KAAK,gCAAqB;QACrD,KAAK,EAAE,CAAC;QAVD,WAAM,iCAAsB;QAOpB,SAAI,GAAG,kBAAkB,CAAC,UAAU,CAAC;QAIpD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;IAC5B,CAAC;IAXM,MAAM,CAAC,cAAc,CAAC,IAAS;QACrC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAA8B,CAAC;QACvD,OAAO,IAAI,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAUD,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAA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AAC;QACb,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;CACD;AAED,MAAM,UAAU,yBAAyB,CACxC,MAAyB,EACzB,GAAW,EACX,IAAkB;IAElB,MAAM,QAAQ,GAAG,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAEzD,kEAAkE;IAClE,MAAM,EAAE,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,OAA6B,CAAC;IAEhF,oCAAoC;IACpC,wDAAwD;IACxD,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAClC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;KAChC;IAED,+EAA+E;IAC/E,8DAA8D;IAC9D,MAAM,CAAC,WAAW,CAAC,YAAY,CAC9B,GAAG;IACH,mBAAmB,CAAC,CAAC;IACrB,oBAAoB,CAAC,QAAQ,CAAC,YAAY,CAC1C,CAAC;IACF,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\tBaseSegment,\n\tISegment,\n\tClient,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeDeltaCallbackArgs,\n\tMergeTreeDeltaType,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tMergeTreeMaintenanceType,\n\tIJSONSegment,\n} from \"@fluidframework/merge-tree\";\nimport { ITelemetryBaseLogger, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { HandleTable, Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { HandleCache } from \"./handlecache\";\nimport { VectorUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n\tsegments = \"segments\",\n\thandleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n\tpublic static readonly typeString: string = \"PermutationSegment\";\n\tprivate _start = Handle.unallocated;\n\n\tpublic static fromJSONObject(spec: any) {\n\t\tconst [length, start] = spec as PermutationSegmentSpec;\n\t\treturn new PermutationSegment(length, start);\n\t}\n\n\tpublic readonly type = PermutationSegment.typeString;\n\n\tconstructor(length: number, start = Handle.unallocated) {\n\t\tsuper();\n\t\tthis._start = start;\n\t\tthis.cachedLength = length;\n\t}\n\n\tpublic get start() {\n\t\treturn this._start;\n\t}\n\tpublic set start(value: Handle) {\n\t\tassert(\n\t\t\tthis._start === Handle.unallocated,\n\t\t\t0x024 /* \"Start of PermutationSegment already allocated!\" */,\n\t\t);\n\t\tassert(\n\t\t\tisHandleValid(value),\n\t\t\t0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */,\n\t\t);\n\n\t\tthis._start = value;\n\t}\n\n\tpublic reset() {\n\t\tthis._start = Handle.unallocated;\n\t}\n\n\tpublic toJSONObject() {\n\t\treturn [this.cachedLength, this.start];\n\t}\n\n\tpublic clone(start = 0, end = this.cachedLength) {\n\t\tconst b = new PermutationSegment(\n\t\t\t/* length: */ end - start,\n\t\t\t/* start: */ this.start + start,\n\t\t);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment) {\n\t\tconst asPerm = segment as PermutationSegment;\n\n\t\treturn this.start === Handle.unallocated\n\t\t\t? asPerm.start === Handle.unallocated\n\t\t\t: asPerm.start === this.start + this.cachedLength;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number) {\n\t\tassert(\n\t\t\t0 < pos && pos < this.cachedLength,\n\t\t\t0x026 /* \"Trying to split segment at out-of-bounds position!\" */,\n\t\t);\n\n\t\tconst leafSegment = new PermutationSegment(\n\t\t\t/* length: */ this.cachedLength - pos,\n\t\t\t/* start: */ this.start === Handle.unallocated ? Handle.unallocated : this.start + pos,\n\t\t);\n\n\t\tthis.cachedLength = pos;\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic toString() {\n\t\treturn this.start === Handle.unallocated\n\t\t\t? `<${this.cachedLength} empty>`\n\t\t\t: `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n\t}\n}\n\nexport class PermutationVector extends Client {\n\tprivate handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n\tpublic readonly handleCache = new HandleCache(this);\n\tpublic undo: VectorUndoProvider | undefined;\n\n\tconstructor(\n\t\tpath: string,\n\t\tlogger: ITelemetryBaseLogger,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tprivate readonly deltaCallback: (\n\t\t\tposition: number,\n\t\t\tnumRemoved: number,\n\t\t\tnumInserted: number,\n\t\t) => void,\n\t\tprivate readonly handlesRecycledCallback: (handles: Handle[]) => void,\n\t) {\n\t\tsuper(\n\t\t\tPermutationSegment.fromJSONObject,\n\t\t\tChildLogger.create(logger, `Matrix.${path}.MergeTreeClient`),\n\t\t\t{\n\t\t\t\t...runtime.options,\n\t\t\t\tnewMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.\n\t\t\t\tmergeTreeUseNewLengthCalculations: true,\n\t\t\t},\n\t\t); // (See https://github.com/microsoft/FluidFramework/issues/84)\n\n\t\tthis.on(\"delta\", this.onDelta);\n\t\tthis.on(\"maintenance\", this.onMaintenance);\n\t}\n\n\tpublic insert(start: number, length: number) {\n\t\treturn this.insertSegmentLocal(start, new PermutationSegment(length));\n\t}\n\n\tpublic remove(start: number, length: number) {\n\t\treturn this.removeRangeLocal(start, start + length);\n\t}\n\n\tpublic getMaybeHandle(pos: number): Handle {\n\t\tassert(\n\t\t\t0 <= pos && pos < this.getLength(),\n\t\t\t0x027 /* \"Trying to get handle of out-of-bounds position!\" */,\n\t\t);\n\n\t\treturn this.handleCache.getHandle(pos);\n\t}\n\n\tpublic getAllocatedHandle(pos: number): Handle {\n\t\tlet handle = this.getMaybeHandle(pos);\n\t\tif (isHandleValid(handle)) {\n\t\t\treturn handle;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment) => {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tasPerm.start = handle = this.handleTable.allocate();\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tpos,\n\t\t\tpos + 1,\n\t\t\t/* accum: */ undefined,\n\t\t\t/* splitRange: */ true,\n\t\t);\n\n\t\tthis.handleCache.addHandle(pos, handle);\n\n\t\treturn handle;\n\t}\n\n\tpublic adjustPosition(pos: number, op: ISequencedDocumentMessage) {\n\t\tconst { segment, offset } = this.getContainingSegment(pos, {\n\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\tclientId: op.clientId,\n\t\t});\n\n\t\t// Note that until the MergeTree GCs, the segment is still reachable via `getContainingSegment()` with\n\t\t// a `refSeq` in the past. Prevent remote ops from accidentally allocating or using recycled handles\n\t\t// by checking for the presence of 'removedSeq'.\n\t\tif (segment === undefined || segment.removedSeq !== undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.getPosition(segment) + offset!;\n\t}\n\n\tpublic handleToPosition(handle: Handle, localSeq = this.getCollabWindow().localSeq) {\n\t\tassert(\n\t\t\tlocalSeq <= this.getCollabWindow().localSeq,\n\t\t\t0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */,\n\t\t);\n\n\t\t// TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n\t\t// the original operation to the current position for undo/redo scenarios. This is probably the\n\t\t// ideal solution, as we would no longer need to store row/col handles in the op metadata.\n\t\t//\n\t\t// Failing that, we could avoid the O(n) search below by building a temporary map in the\n\t\t// opposite direction from the handle to either it's current position or segment + offset\n\t\t// and reuse it for the duration of undo/redo. (Ideally, we would know when the undo/redo\n\t\t// ended so we could discard this map.)\n\t\t//\n\t\t// If we find that we frequently need a reverse handle -> position lookup, we could maintain\n\t\t// one using the Tiny-Calc adjust tree.\n\t\tlet containingSegment!: PermutationSegment;\n\t\tlet containingOffset: number;\n\n\t\tthis.walkAllSegments((segment) => {\n\t\t\tconst { start, cachedLength } = segment as PermutationSegment;\n\n\t\t\t// If the segment is unallocated, skip it.\n\t\t\tif (!isHandleValid(start)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst end = start + cachedLength;\n\n\t\t\tif (start <= handle && handle < end) {\n\t\t\t\tcontainingSegment = segment as PermutationSegment;\n\t\t\t\tcontainingOffset = handle - start;\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\n\t\t// We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n\t\t// row/col has been removed, because handles are not recycled until the containing segment\n\t\t// is unlinked from the MergeTree.\n\t\t//\n\t\t// Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n\t\t// ops that reference the stale handle, or the removal is unACKed, in which case the handle\n\t\t// has not yet been recycled.\n\n\t\tassert(\n\t\t\tisHandleValid(containingSegment.start),\n\t\t\t0x029 /* \"Invalid handle at start of containing segment!\" */,\n\t\t);\n\n\t\t// Once we know the current position of the handle, we can use the MergeTree to get the segment\n\t\t// containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n\t\t// have not yet been submitted.\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n\t}\n\n\t// Constructs an ISummaryTreeWithStats for the cell data.\n\tpublic summarize(\n\t\truntime: IFluidDataStoreRuntime,\n\t\thandle: IFluidHandle,\n\t\tserializer: IFluidSerializer,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.segments,\n\t\t\tsuper.summarize(runtime, handle, serializer, /* catchUpMsgs: */ []),\n\t\t);\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer.stringify(this.handleTable.getSummaryContent(), handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tstorage: IChannelStorageService,\n\t\tserializer: IFluidSerializer,\n\t) {\n\t\tconst handleTableData = await deserializeBlob(\n\t\t\tstorage,\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer,\n\t\t);\n\n\t\tthis.handleTable = HandleTable.load<never>(handleTableData);\n\n\t\treturn super.load(\n\t\t\truntime,\n\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.segments),\n\t\t\tserializer,\n\t\t);\n\t}\n\n\tprivate readonly onDelta = (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t) => {\n\t\t// Apply deltas in descending order to prevent positions from shifting.\n\t\tconst ranges = deltaArgs.deltaSegments\n\t\t\t.map(({ segment }) => ({\n\t\t\t\tsegment: segment as PermutationSegment,\n\t\t\t\tposition: this.getPosition(segment),\n\t\t\t}))\n\t\t\t.sort((left, right) => left.position - right.position);\n\n\t\tconst isLocal = opArgs.sequencedMessage === undefined;\n\n\t\t// Notify the undo provider, if any is attached.\n\t\tif (this.undo !== undefined && isLocal) {\n\t\t\tthis.undo.record(deltaArgs);\n\t\t}\n\n\t\tswitch (deltaArgs.operation) {\n\t\t\tcase MergeTreeDeltaType.INSERT:\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\t// HACK: We need to include the allocated handle in the segment's JSON representation\n\t\t\t\t\t// for snapshots, but need to ignore the remote client's handle allocations when\n\t\t\t\t\t// processing remote ops.\n\t\t\t\t\tsegment.reset();\n\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* deleteCount: */ 0,\n\t\t\t\t\t\t/* insertCount: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ 0,\n\t\t\t\t\t\t/* numInserted: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition /* deleteCount: */,\n\t\t\t\t\t\tsegment.cachedLength,\n\t\t\t\t\t\t/* insertCount: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ segment.cachedLength,\n\t\t\t\t\t\t/* numInsert: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unhandled MergeTreeDeltaType\");\n\t\t}\n\t};\n\n\tprivate readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs) => {\n\t\tif (args.operation === MergeTreeMaintenanceType.UNLINK) {\n\t\t\tlet freed: number[] = [];\n\n\t\t\tfor (const { segment } of args.deltaSegments) {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tif (isHandleValid(asPerm.start)) {\n\t\t\t\t\t// Note: Using the spread operator with `.splice()` can exhaust the stack.\n\t\t\t\t\tfreed = freed.concat(\n\t\t\t\t\t\tnew Array(asPerm.cachedLength)\n\t\t\t\t\t\t\t.fill(0)\n\t\t\t\t\t\t\t.map((value, index) => index + asPerm.start),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n\t\t\t// the rows/cols prior to free to ensure recycled row/cols are initially empty.\n\t\t\tthis.handlesRecycledCallback(freed);\n\n\t\t\t// Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n\t\t\tfor (const handle of freed) {\n\t\t\t\tthis.handleTable.free(handle);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic toString() {\n\t\tconst s: string[] = [];\n\n\t\tthis.walkSegments((segment) => {\n\t\t\ts.push(`${segment}`);\n\t\t\treturn true;\n\t\t});\n\n\t\treturn s.join(\"\");\n\t}\n}\n\nexport function reinsertSegmentIntoVector(\n\tvector: PermutationVector,\n\tpos: number,\n\tspec: IJSONSegment,\n) {\n\tconst original = PermutationSegment.fromJSONObject(spec);\n\n\t// (Re)insert the removed number of rows at the original position.\n\tconst op = vector.insertSegmentLocal(pos, original);\n\tconst inserted = vector.getContainingSegment(pos).segment as PermutationSegment;\n\n\t// we reuse the original handle here\n\t// so if cells exist, they can be found, and re-inserted\n\tif (isHandleValid(original.start)) {\n\t\tinserted.start = original.start;\n\t}\n\n\t// Invalidate the handleCache in case it was populated during the 'rowsChanged'\n\t// callback, which occurs before the handle span is populated.\n\tvector.handleCache.itemsChanged(\n\t\tpos,\n\t\t/* removedCount: */ 0,\n\t\t/* insertedCount: */ inserted.cachedLength,\n\t);\n\treturn { op, inserted };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/matrix",
3
- "version": "2.0.0-dev.5.2.0.169897",
3
+ "version": "2.0.0-dev.5.3.2.178189",
4
4
  "description": "Distributed matrix",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -33,29 +33,29 @@
33
33
  "dependencies": {
34
34
  "@fluidframework/common-definitions": "^0.20.1",
35
35
  "@fluidframework/common-utils": "^1.1.1",
36
- "@fluidframework/core-interfaces": "2.0.0-dev.5.2.0.169897",
37
- "@fluidframework/datastore-definitions": "2.0.0-dev.5.2.0.169897",
38
- "@fluidframework/driver-utils": "2.0.0-dev.5.2.0.169897",
39
- "@fluidframework/merge-tree": "2.0.0-dev.5.2.0.169897",
36
+ "@fluidframework/core-interfaces": "2.0.0-dev.5.3.2.178189",
37
+ "@fluidframework/datastore-definitions": "2.0.0-dev.5.3.2.178189",
38
+ "@fluidframework/driver-utils": "2.0.0-dev.5.3.2.178189",
39
+ "@fluidframework/merge-tree": "2.0.0-dev.5.3.2.178189",
40
40
  "@fluidframework/protocol-definitions": "^1.1.0",
41
- "@fluidframework/runtime-definitions": "2.0.0-dev.5.2.0.169897",
42
- "@fluidframework/runtime-utils": "2.0.0-dev.5.2.0.169897",
43
- "@fluidframework/shared-object-base": "2.0.0-dev.5.2.0.169897",
44
- "@fluidframework/telemetry-utils": "2.0.0-dev.5.2.0.169897",
41
+ "@fluidframework/runtime-definitions": "2.0.0-dev.5.3.2.178189",
42
+ "@fluidframework/runtime-utils": "2.0.0-dev.5.3.2.178189",
43
+ "@fluidframework/shared-object-base": "2.0.0-dev.5.3.2.178189",
44
+ "@fluidframework/telemetry-utils": "2.0.0-dev.5.3.2.178189",
45
45
  "@tiny-calc/nano": "0.0.0-alpha.5",
46
46
  "events": "^3.1.0",
47
47
  "tslib": "^1.10.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@fluid-internal/test-dds-utils": "2.0.0-dev.5.2.0.169897",
51
- "@fluid-tools/benchmark": "^0.47.0",
52
- "@fluid-tools/build-cli": "^0.20.0-169245",
50
+ "@fluid-internal/test-dds-utils": "2.0.0-dev.5.3.2.178189",
51
+ "@fluid-tools/benchmark": "^0.48.0",
52
+ "@fluid-tools/build-cli": "^0.21.0",
53
53
  "@fluidframework/build-common": "^1.2.0",
54
- "@fluidframework/build-tools": "^0.20.0-169245",
54
+ "@fluidframework/build-tools": "^0.21.0",
55
55
  "@fluidframework/eslint-config-fluid": "^2.0.0",
56
- "@fluidframework/matrix-previous": "npm:@fluidframework/matrix@2.0.0-internal.5.0.0",
57
- "@fluidframework/mocha-test-setup": "2.0.0-dev.5.2.0.169897",
58
- "@fluidframework/test-runtime-utils": "2.0.0-dev.5.2.0.169897",
56
+ "@fluidframework/matrix-previous": "npm:@fluidframework/matrix@2.0.0-internal.5.2.0",
57
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.5.3.2.178189",
58
+ "@fluidframework/test-runtime-utils": "2.0.0-dev.5.3.2.178189",
59
59
  "@microsoft/api-extractor": "^7.34.4",
60
60
  "@tiny-calc/micro": "0.0.0-alpha.5",
61
61
  "@types/mocha": "^9.1.1",
@@ -110,6 +110,6 @@
110
110
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
111
111
  "tsc": "tsc",
112
112
  "typetests:gen": "fluid-type-test-generator",
113
- "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
113
+ "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
114
114
  }
115
115
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/matrix";
9
- export const pkgVersion = "2.0.0-dev.5.2.0.169897";
9
+ export const pkgVersion = "2.0.0-dev.5.3.2.178189";
@@ -9,7 +9,6 @@ import {
9
9
  IFluidDataStoreRuntime,
10
10
  IChannelStorageService,
11
11
  } from "@fluidframework/datastore-definitions";
12
- import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
13
12
  import {
14
13
  BaseSegment,
15
14
  ISegment,
@@ -21,7 +20,7 @@ import {
21
20
  MergeTreeMaintenanceType,
22
21
  IJSONSegment,
23
22
  } from "@fluidframework/merge-tree";
24
- import { IFluidHandle } from "@fluidframework/core-interfaces";
23
+ import { ITelemetryBaseLogger, IFluidHandle } from "@fluidframework/core-interfaces";
25
24
  import { IFluidSerializer } from "@fluidframework/shared-object-base";
26
25
  import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
27
26
  import { ObjectStoragePartition, SummaryTreeBuilder } from "@fluidframework/runtime-utils";