@fluidframework/matrix 1.2.1 → 2.0.0-internal.1.0.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.
@@ -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 = "1.2.1";
8
+ export declare const pkgVersion = "2.0.0-internal.1.0.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,UAAU,UAAU,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,UAAU,yBAAyB,CAAC"}
@@ -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 = "1.2.1";
11
+ exports.pkgVersion = "2.0.0-internal.1.0.0";
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,OAAO,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 = \"1.2.1\";\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,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-internal.1.0.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"permutationvector.d.ts","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACH,WAAW,EACX,QAAQ,EAER,MAAM,EAQT,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,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;IAC/C,gBAAuB,UAAU,EAAE,MAAM,CAAwB;IACjE,OAAO,CAAC,MAAM,CAAsB;WAEtB,cAAc,CAAC,IAAI,EAAE,GAAG;IAKtC,SAAgB,IAAI,SAAiC;gBAEzC,MAAM,EAAE,MAAM,EAAE,KA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,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,GAChG,qBAAqB;IAOZ,IAAI,CACb,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,gBAAgB;;;IAShC,OAAO,CAAC,QAAQ,CAAC,OAAO,CA2DtB;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAyB5B;IAEK,QAAQ;CAUlB"}
@@ -183,7 +183,7 @@ class PermutationVector extends merge_tree_1.Client {
183
183
  insertRelative(segment, length) {
184
184
  const inserted = new PermutationSegment(length);
185
185
  return {
186
- op: this.insertAtReferencePositionLocal(new merge_tree_1.LocalReference(this, segment, /* offset: */ 0, merge_tree_1.ReferenceType.Transient), inserted),
186
+ op: this.insertAtReferencePositionLocal(this.createLocalReferencePosition(segment, 0, merge_tree_1.ReferenceType.Transient, undefined), inserted),
187
187
  inserted,
188
188
  };
189
189
  }
@@ -1 +1 @@
1
- {"version":3,"file":"permutationvector.js","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,qEAA8D;AAG9D,2DAYoC;AAIpC,iEAA2F;AAC3F,+CAAmE;AACnE,mDAAkD;AAClD,+CAA4C;AAU5C,MAAa,kBAAmB,SAAQ,wBAAW;IAW/C,YAAY,MAAc,EAAE,KAAK,gCAAqB;QAClD,KAAK,EAAE,CAAC;QAVJ,WAAM,iCAAsB;QAOpB,SAAI,GAAG,kBAAkB,CAAC,UAAU,CAAC;QAIjD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;IAC/B,CAAC;IAXM,MAAM,CAAC,cAAc,CAAC,IAAS;QAClC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAA8B,CAAC;QACvD,OAAO,IAAI,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC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,CAAC;QAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;CACJ;AAtQD,8CAsQC","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 { IFluidDataStoreRuntime, IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport {\n BaseSegment,\n ISegment,\n LocalReferenceCollection,\n Client,\n IMergeTreeDeltaOpArgs,\n IMergeTreeDeltaCallbackArgs,\n MergeTreeDeltaType,\n IMergeTreeMaintenanceCallbackArgs,\n MergeTreeMaintenanceType,\n LocalReference,\n ReferenceType,\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 { HandleTable, Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { HandleCache } from \"./handlecache\";\nimport { VectorUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n segments = \"segments\",\n handleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n public static readonly typeString: string = \"PermutationSegment\";\n private _start = Handle.unallocated;\n\n public static fromJSONObject(spec: any) {\n const [length, start] = spec as PermutationSegmentSpec;\n return new PermutationSegment(length, start);\n }\n\n public readonly type = PermutationSegment.typeString;\n\n constructor(length: number, start = Handle.unallocated) {\n super();\n this._start = start;\n this.cachedLength = length;\n }\n\n public get start() { return this._start; }\n public set start(value: Handle) {\n assert(this._start === Handle.unallocated, 0x024 /* \"Start of PermutationSegment already allocated!\" */);\n assert(isHandleValid(value), 0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */);\n\n this._start = value;\n }\n\n /**\n * Invoked by '_undoRow/ColRemove' to prepare the newly inserted destination\n * segment to serve as the replacement for this removed segment. This moves handle\n * allocations from this segment to the replacement as well as maintains tracking\n * groups for the undo/redo stack.\n */\n public transferToReplacement(destination: PermutationSegment) {\n // When this segment was removed, it may have been split from a larger original\n // segment. In this case, it will have been added to an undo/redo tracking group\n // that associates all of the fragments from the original insertion.\n //\n // Move this association from the this removed segment to its replacement so that\n // it is included if the undo stack continues to unwind to the original insertion.\n //\n // Out of paranoia we link and unlink in separate loops to avoid mutating the underlying\n // set during enumeration. In practice, this is unlikely to matter since there should be\n // exactly 0 or 1 items in the enumeration.\n for (const group of this.trackingCollection.trackingGroups) {\n group.link(destination);\n }\n for (const group of this.trackingCollection.trackingGroups) {\n group.unlink(this);\n }\n\n // Move handle allocations from this segment to its replacement.\n destination._start = this._start;\n this.reset();\n }\n\n public reset() {\n this._start = Handle.unallocated;\n }\n\n public toJSONObject() {\n return [this.cachedLength, this.start];\n }\n\n public clone(start = 0, end = this.cachedLength) {\n const b = new PermutationSegment(\n /* length: */ end - start,\n /* start: */ this.start + start);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment) {\n const asPerm = segment as PermutationSegment;\n\n return this.start === Handle.unallocated\n ? asPerm.start === Handle.unallocated\n : asPerm.start === this.start + this.cachedLength;\n }\n\n public append(segment: ISegment) {\n // Note: Must call 'LocalReferenceCollection.append(..)' before modifying this segment's length as\n // 'this.cachedLength' is used to adjust the offsets of the local refs.\n LocalReferenceCollection.append(this, segment);\n\n this.cachedLength += segment.cachedLength;\n }\n\n protected createSplitSegmentAt(pos: number) {\n assert(0 < pos && pos < this.cachedLength, 0x026 /* \"Trying to split segment at out-of-bounds position!\" */);\n\n const leafSegment = new PermutationSegment(\n /* length: */ this.cachedLength - pos,\n /* start: */ this.start === Handle.unallocated\n ? Handle.unallocated\n : this.start + pos);\n\n this.cachedLength = pos;\n\n return leafSegment;\n }\n\n public toString() {\n return this.start === Handle.unallocated\n ? `<${this.cachedLength} empty>`\n : `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n }\n}\n\nexport class PermutationVector extends Client {\n private handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n public readonly handleCache = new HandleCache(this);\n public undo: VectorUndoProvider | undefined;\n\n constructor(\n path: string,\n logger: ITelemetryBaseLogger,\n runtime: IFluidDataStoreRuntime,\n private readonly deltaCallback: (position: number, numRemoved: number, numInserted: number) => void,\n private readonly handlesRecycledCallback: (handles: Handle[]) => void,\n ) {\n super(\n PermutationSegment.fromJSONObject,\n ChildLogger.create(logger, `Matrix.${path}.MergeTreeClient`), {\n ...runtime.options,\n newMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.\n }); // (See https://github.com/microsoft/FluidFramework/issues/84)\n\n this.mergeTreeDeltaCallback = this.onDelta;\n this.mergeTreeMaintenanceCallback = this.onMaintenance;\n }\n\n public insert(start: number, length: number) {\n return this.insertSegmentLocal(\n start,\n new PermutationSegment(length));\n }\n\n public insertRelative(segment: ISegment, length: number) {\n const inserted = new PermutationSegment(length);\n\n return {\n op: this.insertAtReferencePositionLocal(\n new LocalReference(this, segment, /* offset: */ 0, ReferenceType.Transient),\n inserted),\n inserted,\n };\n }\n\n public remove(start: number, length: number) {\n return this.removeRangeLocal(start, start + length);\n }\n\n public getMaybeHandle(pos: number): Handle {\n assert(0 <= pos && pos < this.getLength(), 0x027 /* \"Trying to get handle of out-of-bounds position!\" */);\n\n return this.handleCache.getHandle(pos);\n }\n\n public getAllocatedHandle(pos: number): Handle {\n let handle = this.getMaybeHandle(pos);\n if (isHandleValid(handle)) {\n return handle;\n }\n\n this.walkSegments(\n (segment) => {\n const asPerm = segment as PermutationSegment;\n asPerm.start = handle = this.handleTable.allocate();\n return true;\n },\n pos,\n pos + 1,\n /* accum: */ undefined,\n /* splitRange: */ true);\n\n this.handleCache.addHandle(pos, handle);\n\n return handle;\n }\n\n public adjustPosition(pos: number, fromSeq: number, clientId: number) {\n const { segment, offset } = this.mergeTree.getContainingSegment(pos, fromSeq, clientId);\n\n // Note that until the MergeTree GCs, the segment is still reachable via `getContainingSegment()` with\n // a `refSeq` in the past. Prevent remote ops from accidentally allocating or using recycled handles\n // by checking for the presence of 'removedSeq'.\n if (segment === undefined || segment.removedSeq !== undefined) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.getPosition(segment) + offset!;\n }\n\n public handleToPosition(handle: Handle, localSeq = this.mergeTree.collabWindow.localSeq) {\n assert(localSeq <= this.mergeTree.collabWindow.localSeq,\n 0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */);\n\n // TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n // the original operation to the current position for resubmitting. This is probably the\n // ideal solution, as we would no longer need to store row/col handles in the op metadata.\n //\n // Failing that, we could avoid the O(n) search below by building a temporary map in the\n // opposite direction from the handle to either it's current position or segment + offset\n // and reuse it for the duration of resubmission. (Ideally, we would know when resubmission\n // ended so we could discard this map.)\n //\n // If we find that we frequently need a reverse handle -> position lookup, we could maintain\n // one using the Tiny-Calc adjust tree.\n let containingSegment!: PermutationSegment;\n let containingOffset: number;\n\n this.mergeTree.walkAllSegments(\n this.mergeTree.root,\n (segment) => {\n const { start, cachedLength } = segment as PermutationSegment;\n\n // If the segment is unallocated, skip it.\n if (!isHandleValid(start)) {\n return true;\n }\n\n const end = start + cachedLength;\n\n if (start <= handle && handle < end) {\n containingSegment = segment as PermutationSegment;\n containingOffset = handle - start;\n return false;\n }\n\n return true;\n });\n\n // We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n // row/col has been removed, because handles are not recycled until the containing segment\n // is unlinked from the MergeTree.\n //\n // Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n // ops that reference the stale handle, or the removal is unACKed, in which case the handle\n // has not yet been recycled.\n\n assert(isHandleValid(containingSegment.start), 0x029 /* \"Invalid handle at start of containing segment!\" */);\n\n // Once we know the current position of the handle, we can use the MergeTree to get the segment\n // containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n // have not yet been submitted.\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n }\n\n // Constructs an ISummaryTreeWithStats for the cell data.\n public summarize(runtime: IFluidDataStoreRuntime, handle: IFluidHandle, serializer: IFluidSerializer):\n ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n builder.addWithStats(SnapshotPath.segments, super.summarize(runtime, handle, serializer, /* catchUpMsgs: */[]));\n builder.addBlob(SnapshotPath.handleTable, serializer.stringify(this.handleTable.getSummaryContent(), handle));\n return builder.getSummaryTree();\n }\n\n public async load(\n runtime: IFluidDataStoreRuntime,\n storage: IChannelStorageService,\n serializer: IFluidSerializer,\n ) {\n const handleTableData = await deserializeBlob(storage, SnapshotPath.handleTable, serializer);\n\n this.handleTable = HandleTable.load<never>(handleTableData);\n\n return super.load(runtime, new ObjectStoragePartition(storage, SnapshotPath.segments), serializer);\n }\n\n private readonly onDelta = (\n opArgs: IMergeTreeDeltaOpArgs,\n { operation, deltaSegments }: IMergeTreeDeltaCallbackArgs,\n ) => {\n // Apply deltas in descending order to prevent positions from shifting.\n const ranges = deltaSegments\n .map(({ segment }) => ({\n segment: segment as PermutationSegment,\n position: this.getPosition(segment),\n }))\n .sort((left, right) => left.position - right.position);\n\n const isLocal = opArgs.sequencedMessage === undefined;\n\n // Notify the undo provider, if any is attached.\n if (this.undo !== undefined && isLocal) {\n this.undo.record(operation, ranges);\n }\n\n switch (operation) {\n case MergeTreeDeltaType.INSERT:\n // Pass 1: Perform any internal maintenance first to avoid reentrancy.\n for (const { segment, position } of ranges) {\n // HACK: We need to include the allocated handle in the segment's JSON representation\n // for snapshots, but need to ignore the remote client's handle allocations when\n // processing remote ops.\n segment.reset();\n\n this.handleCache.itemsChanged(\n position,\n /* deleteCount: */ 0,\n /* insertCount: */ segment.cachedLength);\n }\n\n // Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n for (const { segment, position } of ranges) {\n this.deltaCallback(position, /* numRemoved: */ 0, /* numInserted: */ segment.cachedLength);\n }\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n // Pass 1: Perform any internal maintenance first to avoid reentrancy.\n for (const { segment, position } of ranges) {\n this.handleCache.itemsChanged(\n position, /* deleteCount: */\n segment.cachedLength,\n /* insertCount: */ 0);\n }\n\n // Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n for (const { segment, position } of ranges) {\n this.deltaCallback(position, /* numRemoved: */ segment.cachedLength, /* numInsert: */ 0);\n }\n break;\n }\n\n default:\n throw new Error(\"Unhandled MergeTreeDeltaType\");\n }\n };\n\n private readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs) => {\n if (args.operation === MergeTreeMaintenanceType.UNLINK) {\n let freed: number[] = [];\n\n for (const { segment } of args.deltaSegments) {\n const asPerm = segment as PermutationSegment;\n if (isHandleValid(asPerm.start)) {\n // Note: Using the spread operator with `.splice()` can exhaust the stack.\n freed = freed.concat(\n new Array(asPerm.cachedLength)\n .fill(0)\n .map((value, index) => index + asPerm.start),\n );\n }\n }\n\n // Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n // the rows/cols prior to free to ensure recycled row/cols are initially empty.\n this.handlesRecycledCallback(freed);\n\n // Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n for (const handle of freed) {\n this.handleTable.free(handle);\n }\n }\n };\n\n public toString() {\n const s: string[] = [];\n\n this.walkSegments((segment) => {\n s.push(`${segment}`);\n return true;\n });\n\n return s.join(\"\");\n }\n}\n"]}
1
+ {"version":3,"file":"permutationvector.js","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,qEAA8D;AAG9D,2DAWoC;AAIp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,GAAG,MAAM,IAAA,+BAAe,EAAC,OAAO,mCAA4B,UAAU,CAAC,CAAC;QAE7F,IAAI,CAAC,WAAW,GAAG,yBAAW,CAAC,IAAI,CAAQ,eAAe,CAAC,CAAC;QAE5D,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,sCAAsB,CAAC,OAAO,4BAAwB,EAAE,UAAU,CAAC,CAAC;IACvG,CAAC;IA0FM,QAAQ;QACX,MAAM,CAAC,GAAa,EAAE,CAAC;QAEvB,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;CACJ;AAtQD,8CAsQC","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 { IFluidDataStoreRuntime, IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport {\n BaseSegment,\n ISegment,\n LocalReferenceCollection,\n Client,\n IMergeTreeDeltaOpArgs,\n IMergeTreeDeltaCallbackArgs,\n MergeTreeDeltaType,\n IMergeTreeMaintenanceCallbackArgs,\n MergeTreeMaintenanceType,\n ReferenceType,\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 { HandleTable, Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { HandleCache } from \"./handlecache\";\nimport { VectorUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n segments = \"segments\",\n handleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n public static readonly typeString: string = \"PermutationSegment\";\n private _start = Handle.unallocated;\n\n public static fromJSONObject(spec: any) {\n const [length, start] = spec as PermutationSegmentSpec;\n return new PermutationSegment(length, start);\n }\n\n public readonly type = PermutationSegment.typeString;\n\n constructor(length: number, start = Handle.unallocated) {\n super();\n this._start = start;\n this.cachedLength = length;\n }\n\n public get start() { return this._start; }\n public set start(value: Handle) {\n assert(this._start === Handle.unallocated, 0x024 /* \"Start of PermutationSegment already allocated!\" */);\n assert(isHandleValid(value), 0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */);\n\n this._start = value;\n }\n\n /**\n * Invoked by '_undoRow/ColRemove' to prepare the newly inserted destination\n * segment to serve as the replacement for this removed segment. This moves handle\n * allocations from this segment to the replacement as well as maintains tracking\n * groups for the undo/redo stack.\n */\n public transferToReplacement(destination: PermutationSegment) {\n // When this segment was removed, it may have been split from a larger original\n // segment. In this case, it will have been added to an undo/redo tracking group\n // that associates all of the fragments from the original insertion.\n //\n // Move this association from the this removed segment to its replacement so that\n // it is included if the undo stack continues to unwind to the original insertion.\n //\n // Out of paranoia we link and unlink in separate loops to avoid mutating the underlying\n // set during enumeration. In practice, this is unlikely to matter since there should be\n // exactly 0 or 1 items in the enumeration.\n for (const group of this.trackingCollection.trackingGroups) {\n group.link(destination);\n }\n for (const group of this.trackingCollection.trackingGroups) {\n group.unlink(this);\n }\n\n // Move handle allocations from this segment to its replacement.\n destination._start = this._start;\n this.reset();\n }\n\n public reset() {\n this._start = Handle.unallocated;\n }\n\n public toJSONObject() {\n return [this.cachedLength, this.start];\n }\n\n public clone(start = 0, end = this.cachedLength) {\n const b = new PermutationSegment(\n /* length: */ end - start,\n /* start: */ this.start + start);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment) {\n const asPerm = segment as PermutationSegment;\n\n return this.start === Handle.unallocated\n ? asPerm.start === Handle.unallocated\n : asPerm.start === this.start + this.cachedLength;\n }\n\n public append(segment: ISegment) {\n // Note: Must call 'LocalReferenceCollection.append(..)' before modifying this segment's length as\n // 'this.cachedLength' is used to adjust the offsets of the local refs.\n LocalReferenceCollection.append(this, segment);\n\n this.cachedLength += segment.cachedLength;\n }\n\n protected createSplitSegmentAt(pos: number) {\n assert(0 < pos && pos < this.cachedLength, 0x026 /* \"Trying to split segment at out-of-bounds position!\" */);\n\n const leafSegment = new PermutationSegment(\n /* length: */ this.cachedLength - pos,\n /* start: */ this.start === Handle.unallocated\n ? Handle.unallocated\n : this.start + pos);\n\n this.cachedLength = pos;\n\n return leafSegment;\n }\n\n public toString() {\n return this.start === Handle.unallocated\n ? `<${this.cachedLength} empty>`\n : `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n }\n}\n\nexport class PermutationVector extends Client {\n private handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n public readonly handleCache = new HandleCache(this);\n public undo: VectorUndoProvider | undefined;\n\n constructor(\n path: string,\n logger: ITelemetryBaseLogger,\n runtime: IFluidDataStoreRuntime,\n private readonly deltaCallback: (position: number, numRemoved: number, numInserted: number) => void,\n private readonly handlesRecycledCallback: (handles: Handle[]) => void,\n ) {\n super(\n PermutationSegment.fromJSONObject,\n ChildLogger.create(logger, `Matrix.${path}.MergeTreeClient`), {\n ...runtime.options,\n newMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.\n }); // (See https://github.com/microsoft/FluidFramework/issues/84)\n\n this.mergeTreeDeltaCallback = this.onDelta;\n this.mergeTreeMaintenanceCallback = this.onMaintenance;\n }\n\n public insert(start: number, length: number) {\n return this.insertSegmentLocal(\n start,\n new PermutationSegment(length));\n }\n\n public insertRelative(segment: ISegment, length: number) {\n const inserted = new PermutationSegment(length);\n\n return {\n op: this.insertAtReferencePositionLocal(\n this.createLocalReferencePosition(segment, 0, ReferenceType.Transient, undefined),\n inserted),\n inserted,\n };\n }\n\n public remove(start: number, length: number) {\n return this.removeRangeLocal(start, start + length);\n }\n\n public getMaybeHandle(pos: number): Handle {\n assert(0 <= pos && pos < this.getLength(), 0x027 /* \"Trying to get handle of out-of-bounds position!\" */);\n\n return this.handleCache.getHandle(pos);\n }\n\n public getAllocatedHandle(pos: number): Handle {\n let handle = this.getMaybeHandle(pos);\n if (isHandleValid(handle)) {\n return handle;\n }\n\n this.walkSegments(\n (segment) => {\n const asPerm = segment as PermutationSegment;\n asPerm.start = handle = this.handleTable.allocate();\n return true;\n },\n pos,\n pos + 1,\n /* accum: */ undefined,\n /* splitRange: */ true);\n\n this.handleCache.addHandle(pos, handle);\n\n return handle;\n }\n\n public adjustPosition(pos: number, fromSeq: number, clientId: number) {\n const { segment, offset } = this.mergeTree.getContainingSegment(pos, fromSeq, clientId);\n\n // Note that until the MergeTree GCs, the segment is still reachable via `getContainingSegment()` with\n // a `refSeq` in the past. Prevent remote ops from accidentally allocating or using recycled handles\n // by checking for the presence of 'removedSeq'.\n if (segment === undefined || segment.removedSeq !== undefined) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.getPosition(segment) + offset!;\n }\n\n public handleToPosition(handle: Handle, localSeq = this.mergeTree.collabWindow.localSeq) {\n assert(localSeq <= this.mergeTree.collabWindow.localSeq,\n 0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */);\n\n // TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n // the original operation to the current position for resubmitting. This is probably the\n // ideal solution, as we would no longer need to store row/col handles in the op metadata.\n //\n // Failing that, we could avoid the O(n) search below by building a temporary map in the\n // opposite direction from the handle to either it's current position or segment + offset\n // and reuse it for the duration of resubmission. (Ideally, we would know when resubmission\n // ended so we could discard this map.)\n //\n // If we find that we frequently need a reverse handle -> position lookup, we could maintain\n // one using the Tiny-Calc adjust tree.\n let containingSegment!: PermutationSegment;\n let containingOffset: number;\n\n this.mergeTree.walkAllSegments(\n this.mergeTree.root,\n (segment) => {\n const { start, cachedLength } = segment as PermutationSegment;\n\n // If the segment is unallocated, skip it.\n if (!isHandleValid(start)) {\n return true;\n }\n\n const end = start + cachedLength;\n\n if (start <= handle && handle < end) {\n containingSegment = segment as PermutationSegment;\n containingOffset = handle - start;\n return false;\n }\n\n return true;\n });\n\n // We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n // row/col has been removed, because handles are not recycled until the containing segment\n // is unlinked from the MergeTree.\n //\n // Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n // ops that reference the stale handle, or the removal is unACKed, in which case the handle\n // has not yet been recycled.\n\n assert(isHandleValid(containingSegment.start), 0x029 /* \"Invalid handle at start of containing segment!\" */);\n\n // Once we know the current position of the handle, we can use the MergeTree to get the segment\n // containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n // have not yet been submitted.\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n }\n\n // Constructs an ISummaryTreeWithStats for the cell data.\n public summarize(runtime: IFluidDataStoreRuntime, handle: IFluidHandle, serializer: IFluidSerializer):\n ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n builder.addWithStats(SnapshotPath.segments, super.summarize(runtime, handle, serializer, /* catchUpMsgs: */[]));\n builder.addBlob(SnapshotPath.handleTable, serializer.stringify(this.handleTable.getSummaryContent(), handle));\n return builder.getSummaryTree();\n }\n\n public async load(\n runtime: IFluidDataStoreRuntime,\n storage: IChannelStorageService,\n serializer: IFluidSerializer,\n ) {\n const handleTableData = await deserializeBlob(storage, SnapshotPath.handleTable, serializer);\n\n this.handleTable = HandleTable.load<never>(handleTableData);\n\n return super.load(runtime, new ObjectStoragePartition(storage, SnapshotPath.segments), serializer);\n }\n\n private readonly onDelta = (\n opArgs: IMergeTreeDeltaOpArgs,\n { operation, deltaSegments }: IMergeTreeDeltaCallbackArgs,\n ) => {\n // Apply deltas in descending order to prevent positions from shifting.\n const ranges = deltaSegments\n .map(({ segment }) => ({\n segment: segment as PermutationSegment,\n position: this.getPosition(segment),\n }))\n .sort((left, right) => left.position - right.position);\n\n const isLocal = opArgs.sequencedMessage === undefined;\n\n // Notify the undo provider, if any is attached.\n if (this.undo !== undefined && isLocal) {\n this.undo.record(operation, ranges);\n }\n\n switch (operation) {\n case MergeTreeDeltaType.INSERT:\n // Pass 1: Perform any internal maintenance first to avoid reentrancy.\n for (const { segment, position } of ranges) {\n // HACK: We need to include the allocated handle in the segment's JSON representation\n // for snapshots, but need to ignore the remote client's handle allocations when\n // processing remote ops.\n segment.reset();\n\n this.handleCache.itemsChanged(\n position,\n /* deleteCount: */ 0,\n /* insertCount: */ segment.cachedLength);\n }\n\n // Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n for (const { segment, position } of ranges) {\n this.deltaCallback(position, /* numRemoved: */ 0, /* numInserted: */ segment.cachedLength);\n }\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n // Pass 1: Perform any internal maintenance first to avoid reentrancy.\n for (const { segment, position } of ranges) {\n this.handleCache.itemsChanged(\n position, /* deleteCount: */\n segment.cachedLength,\n /* insertCount: */ 0);\n }\n\n // Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n for (const { segment, position } of ranges) {\n this.deltaCallback(position, /* numRemoved: */ segment.cachedLength, /* numInsert: */ 0);\n }\n break;\n }\n\n default:\n throw new Error(\"Unhandled MergeTreeDeltaType\");\n }\n };\n\n private readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs) => {\n if (args.operation === MergeTreeMaintenanceType.UNLINK) {\n let freed: number[] = [];\n\n for (const { segment } of args.deltaSegments) {\n const asPerm = segment as PermutationSegment;\n if (isHandleValid(asPerm.start)) {\n // Note: Using the spread operator with `.splice()` can exhaust the stack.\n freed = freed.concat(\n new Array(asPerm.cachedLength)\n .fill(0)\n .map((value, index) => index + asPerm.start),\n );\n }\n }\n\n // Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n // the rows/cols prior to free to ensure recycled row/cols are initially empty.\n this.handlesRecycledCallback(freed);\n\n // Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n for (const handle of freed) {\n this.handleTable.free(handle);\n }\n }\n };\n\n public toString() {\n const s: string[] = [];\n\n this.walkSegments((segment) => {\n s.push(`${segment}`);\n return true;\n });\n\n return s.join(\"\");\n }\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 = "1.2.1";
8
+ export declare const pkgVersion = "2.0.0-internal.1.0.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,UAAU,UAAU,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,UAAU,yBAAyB,CAAC"}
@@ -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 = "1.2.1";
8
+ export const pkgVersion = "2.0.0-internal.1.0.0";
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,OAAO,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 = \"1.2.1\";\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,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-internal.1.0.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"permutationvector.d.ts","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACH,WAAW,EACX,QAAQ,EAER,MAAM,EAQT,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,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,kBAA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EAAE,MAAM,GAAG,MAAM;IAMnC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAsBvC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAc7D,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAuC;IA0DhF,SAAS,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,GAChG,qBAAqB;IAOZ,IAAI,CACb,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,gBAAgB;;;IAShC,OAAO,CAAC,QAAQ,CAAC,OAAO,CA2DtB;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAyB5B;IAEK,QAAQ;CAUlB"}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { assert } from "@fluidframework/common-utils";
6
6
  import { ChildLogger } from "@fluidframework/telemetry-utils";
7
- import { BaseSegment, LocalReferenceCollection, Client, MergeTreeDeltaType, MergeTreeMaintenanceType, LocalReference, ReferenceType, } from "@fluidframework/merge-tree";
7
+ import { BaseSegment, LocalReferenceCollection, Client, MergeTreeDeltaType, MergeTreeMaintenanceType, ReferenceType, } from "@fluidframework/merge-tree";
8
8
  import { ObjectStoragePartition, SummaryTreeBuilder } from "@fluidframework/runtime-utils";
9
9
  import { HandleTable, isHandleValid } from "./handletable";
10
10
  import { deserializeBlob } from "./serialization";
@@ -179,7 +179,7 @@ export class PermutationVector extends Client {
179
179
  insertRelative(segment, length) {
180
180
  const inserted = new PermutationSegment(length);
181
181
  return {
182
- op: this.insertAtReferencePositionLocal(new LocalReference(this, segment, /* offset: */ 0, ReferenceType.Transient), inserted),
182
+ op: this.insertAtReferencePositionLocal(this.createLocalReferencePosition(segment, 0, ReferenceType.Transient, undefined), inserted),
183
183
  inserted,
184
184
  };
185
185
  }
@@ -1 +1 @@
1
- {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C;QACzC,OAAO,CAAC,YAAY,4BAAwB,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,CAAA,EAAE,CAAC,CAAC,CAAC;QAChH,OAAO,CAAC,OAAO,kCAA2B,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;QAC9G,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,IAAI,CACb,OAA+B,EAC/B,OAA+B,EAC/B,UAA4B;QAE5B,MAAM,eAAe,GAAG,MAAM,eAAe,CAAC,OAAO,mCAA4B,UAAU,CAAC,CAAC;QAE7F,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,IAAI,CAAQ,eAAe,CAAC,CAAC;QAE5D,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,sBAAsB,CAAC,OAAO,4BAAwB,EAAE,UAAU,CAAC,CAAC;IACvG,CAAC;IA0FM,QAAQ;QACX,MAAM,CAAC,GAAa,EAAE,CAAC;QAEvB,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;CACJ","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 { IFluidDataStoreRuntime, IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport {\n BaseSegment,\n ISegment,\n LocalReferenceCollection,\n Client,\n IMergeTreeDeltaOpArgs,\n IMergeTreeDeltaCallbackArgs,\n MergeTreeDeltaType,\n IMergeTreeMaintenanceCallbackArgs,\n MergeTreeMaintenanceType,\n LocalReference,\n ReferenceType,\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 { HandleTable, Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { HandleCache } from \"./handlecache\";\nimport { VectorUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n segments = \"segments\",\n handleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n public static readonly typeString: string = \"PermutationSegment\";\n private _start = Handle.unallocated;\n\n public static fromJSONObject(spec: any) {\n const [length, start] = spec as PermutationSegmentSpec;\n return new PermutationSegment(length, start);\n }\n\n public readonly type = PermutationSegment.typeString;\n\n constructor(length: number, start = Handle.unallocated) {\n super();\n this._start = start;\n this.cachedLength = length;\n }\n\n public get start() { return this._start; }\n public set start(value: Handle) {\n assert(this._start === Handle.unallocated, 0x024 /* \"Start of PermutationSegment already allocated!\" */);\n assert(isHandleValid(value), 0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */);\n\n this._start = value;\n }\n\n /**\n * Invoked by '_undoRow/ColRemove' to prepare the newly inserted destination\n * segment to serve as the replacement for this removed segment. This moves handle\n * allocations from this segment to the replacement as well as maintains tracking\n * groups for the undo/redo stack.\n */\n public transferToReplacement(destination: PermutationSegment) {\n // When this segment was removed, it may have been split from a larger original\n // segment. In this case, it will have been added to an undo/redo tracking group\n // that associates all of the fragments from the original insertion.\n //\n // Move this association from the this removed segment to its replacement so that\n // it is included if the undo stack continues to unwind to the original insertion.\n //\n // Out of paranoia we link and unlink in separate loops to avoid mutating the underlying\n // set during enumeration. In practice, this is unlikely to matter since there should be\n // exactly 0 or 1 items in the enumeration.\n for (const group of this.trackingCollection.trackingGroups) {\n group.link(destination);\n }\n for (const group of this.trackingCollection.trackingGroups) {\n group.unlink(this);\n }\n\n // Move handle allocations from this segment to its replacement.\n destination._start = this._start;\n this.reset();\n }\n\n public reset() {\n this._start = Handle.unallocated;\n }\n\n public toJSONObject() {\n return [this.cachedLength, this.start];\n }\n\n public clone(start = 0, end = this.cachedLength) {\n const b = new PermutationSegment(\n /* length: */ end - start,\n /* start: */ this.start + start);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment) {\n const asPerm = segment as PermutationSegment;\n\n return this.start === Handle.unallocated\n ? asPerm.start === Handle.unallocated\n : asPerm.start === this.start + this.cachedLength;\n }\n\n public append(segment: ISegment) {\n // Note: Must call 'LocalReferenceCollection.append(..)' before modifying this segment's length as\n // 'this.cachedLength' is used to adjust the offsets of the local refs.\n LocalReferenceCollection.append(this, segment);\n\n this.cachedLength += segment.cachedLength;\n }\n\n protected createSplitSegmentAt(pos: number) {\n assert(0 < pos && pos < this.cachedLength, 0x026 /* \"Trying to split segment at out-of-bounds position!\" */);\n\n const leafSegment = new PermutationSegment(\n /* length: */ this.cachedLength - pos,\n /* start: */ this.start === Handle.unallocated\n ? Handle.unallocated\n : this.start + pos);\n\n this.cachedLength = pos;\n\n return leafSegment;\n }\n\n public toString() {\n return this.start === Handle.unallocated\n ? `<${this.cachedLength} empty>`\n : `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n }\n}\n\nexport class PermutationVector extends Client {\n private handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n public readonly handleCache = new HandleCache(this);\n public undo: VectorUndoProvider | undefined;\n\n constructor(\n path: string,\n logger: ITelemetryBaseLogger,\n runtime: IFluidDataStoreRuntime,\n private readonly deltaCallback: (position: number, numRemoved: number, numInserted: number) => void,\n private readonly handlesRecycledCallback: (handles: Handle[]) => void,\n ) {\n super(\n PermutationSegment.fromJSONObject,\n ChildLogger.create(logger, `Matrix.${path}.MergeTreeClient`), {\n ...runtime.options,\n newMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.\n }); // (See https://github.com/microsoft/FluidFramework/issues/84)\n\n this.mergeTreeDeltaCallback = this.onDelta;\n this.mergeTreeMaintenanceCallback = this.onMaintenance;\n }\n\n public insert(start: number, length: number) {\n return this.insertSegmentLocal(\n start,\n new PermutationSegment(length));\n }\n\n public insertRelative(segment: ISegment, length: number) {\n const inserted = new PermutationSegment(length);\n\n return {\n op: this.insertAtReferencePositionLocal(\n new LocalReference(this, segment, /* offset: */ 0, ReferenceType.Transient),\n inserted),\n inserted,\n };\n }\n\n public remove(start: number, length: number) {\n return this.removeRangeLocal(start, start + length);\n }\n\n public getMaybeHandle(pos: number): Handle {\n assert(0 <= pos && pos < this.getLength(), 0x027 /* \"Trying to get handle of out-of-bounds position!\" */);\n\n return this.handleCache.getHandle(pos);\n }\n\n public getAllocatedHandle(pos: number): Handle {\n let handle = this.getMaybeHandle(pos);\n if (isHandleValid(handle)) {\n return handle;\n }\n\n this.walkSegments(\n (segment) => {\n const asPerm = segment as PermutationSegment;\n asPerm.start = handle = this.handleTable.allocate();\n return true;\n },\n pos,\n pos + 1,\n /* accum: */ undefined,\n /* splitRange: */ true);\n\n this.handleCache.addHandle(pos, handle);\n\n return handle;\n }\n\n public adjustPosition(pos: number, fromSeq: number, clientId: number) {\n const { segment, offset } = this.mergeTree.getContainingSegment(pos, fromSeq, clientId);\n\n // Note that until the MergeTree GCs, the segment is still reachable via `getContainingSegment()` with\n // a `refSeq` in the past. Prevent remote ops from accidentally allocating or using recycled handles\n // by checking for the presence of 'removedSeq'.\n if (segment === undefined || segment.removedSeq !== undefined) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.getPosition(segment) + offset!;\n }\n\n public handleToPosition(handle: Handle, localSeq = this.mergeTree.collabWindow.localSeq) {\n assert(localSeq <= this.mergeTree.collabWindow.localSeq,\n 0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */);\n\n // TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n // the original operation to the current position for resubmitting. This is probably the\n // ideal solution, as we would no longer need to store row/col handles in the op metadata.\n //\n // Failing that, we could avoid the O(n) search below by building a temporary map in the\n // opposite direction from the handle to either it's current position or segment + offset\n // and reuse it for the duration of resubmission. (Ideally, we would know when resubmission\n // ended so we could discard this map.)\n //\n // If we find that we frequently need a reverse handle -> position lookup, we could maintain\n // one using the Tiny-Calc adjust tree.\n let containingSegment!: PermutationSegment;\n let containingOffset: number;\n\n this.mergeTree.walkAllSegments(\n this.mergeTree.root,\n (segment) => {\n const { start, cachedLength } = segment as PermutationSegment;\n\n // If the segment is unallocated, skip it.\n if (!isHandleValid(start)) {\n return true;\n }\n\n const end = start + cachedLength;\n\n if (start <= handle && handle < end) {\n containingSegment = segment as PermutationSegment;\n containingOffset = handle - start;\n return false;\n }\n\n return true;\n });\n\n // We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n // row/col has been removed, because handles are not recycled until the containing segment\n // is unlinked from the MergeTree.\n //\n // Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n // ops that reference the stale handle, or the removal is unACKed, in which case the handle\n // has not yet been recycled.\n\n assert(isHandleValid(containingSegment.start), 0x029 /* \"Invalid handle at start of containing segment!\" */);\n\n // Once we know the current position of the handle, we can use the MergeTree to get the segment\n // containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n // have not yet been submitted.\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n }\n\n // Constructs an ISummaryTreeWithStats for the cell data.\n public summarize(runtime: IFluidDataStoreRuntime, handle: IFluidHandle, serializer: IFluidSerializer):\n ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n builder.addWithStats(SnapshotPath.segments, super.summarize(runtime, handle, serializer, /* catchUpMsgs: */[]));\n builder.addBlob(SnapshotPath.handleTable, serializer.stringify(this.handleTable.getSummaryContent(), handle));\n return builder.getSummaryTree();\n }\n\n public async load(\n runtime: IFluidDataStoreRuntime,\n storage: IChannelStorageService,\n serializer: IFluidSerializer,\n ) {\n const handleTableData = await deserializeBlob(storage, SnapshotPath.handleTable, serializer);\n\n this.handleTable = HandleTable.load<never>(handleTableData);\n\n return super.load(runtime, new ObjectStoragePartition(storage, SnapshotPath.segments), serializer);\n }\n\n private readonly onDelta = (\n opArgs: IMergeTreeDeltaOpArgs,\n { operation, deltaSegments }: IMergeTreeDeltaCallbackArgs,\n ) => {\n // Apply deltas in descending order to prevent positions from shifting.\n const ranges = deltaSegments\n .map(({ segment }) => ({\n segment: segment as PermutationSegment,\n position: this.getPosition(segment),\n }))\n .sort((left, right) => left.position - right.position);\n\n const isLocal = opArgs.sequencedMessage === undefined;\n\n // Notify the undo provider, if any is attached.\n if (this.undo !== undefined && isLocal) {\n this.undo.record(operation, ranges);\n }\n\n switch (operation) {\n case MergeTreeDeltaType.INSERT:\n // Pass 1: Perform any internal maintenance first to avoid reentrancy.\n for (const { segment, position } of ranges) {\n // HACK: We need to include the allocated handle in the segment's JSON representation\n // for snapshots, but need to ignore the remote client's handle allocations when\n // processing remote ops.\n segment.reset();\n\n this.handleCache.itemsChanged(\n position,\n /* deleteCount: */ 0,\n /* insertCount: */ segment.cachedLength);\n }\n\n // Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n for (const { segment, position } of ranges) {\n this.deltaCallback(position, /* numRemoved: */ 0, /* numInserted: */ segment.cachedLength);\n }\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n // Pass 1: Perform any internal maintenance first to avoid reentrancy.\n for (const { segment, position } of ranges) {\n this.handleCache.itemsChanged(\n position, /* deleteCount: */\n segment.cachedLength,\n /* insertCount: */ 0);\n }\n\n // Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n for (const { segment, position } of ranges) {\n this.deltaCallback(position, /* numRemoved: */ segment.cachedLength, /* numInsert: */ 0);\n }\n break;\n }\n\n default:\n throw new Error(\"Unhandled MergeTreeDeltaType\");\n }\n };\n\n private readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs) => {\n if (args.operation === MergeTreeMaintenanceType.UNLINK) {\n let freed: number[] = [];\n\n for (const { segment } of args.deltaSegments) {\n const asPerm = segment as PermutationSegment;\n if (isHandleValid(asPerm.start)) {\n // Note: Using the spread operator with `.splice()` can exhaust the stack.\n freed = freed.concat(\n new Array(asPerm.cachedLength)\n .fill(0)\n .map((value, index) => index + asPerm.start),\n );\n }\n }\n\n // Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n // the rows/cols prior to free to ensure recycled row/cols are initially empty.\n this.handlesRecycledCallback(freed);\n\n // Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n for (const handle of freed) {\n this.handleTable.free(handle);\n }\n }\n };\n\n public toString() {\n const s: string[] = [];\n\n this.walkSegments((segment) => {\n s.push(`${segment}`);\n return true;\n });\n\n return s.join(\"\");\n }\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;AAG9D,OAAO,EACH,WAAW,EAEX,wBAAwB,EACxB,MAAM,EAGN,kBAAkB,EAElB,wBAAwB,EACxB,aAAa,GAChB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAU,aAAa,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,C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AAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,sBAAsB,CAAC,OAAO,4BAAwB,EAAE,UAAU,CAAC,CAAC;IACvG,CAAC;IA0FM,QAAQ;QACX,MAAM,CAAC,GAAa,EAAE,CAAC;QAEvB,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;CACJ","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 { IFluidDataStoreRuntime, IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport {\n BaseSegment,\n ISegment,\n LocalReferenceCollection,\n Client,\n IMergeTreeDeltaOpArgs,\n IMergeTreeDeltaCallbackArgs,\n MergeTreeDeltaType,\n IMergeTreeMaintenanceCallbackArgs,\n MergeTreeMaintenanceType,\n ReferenceType,\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 { HandleTable, Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { HandleCache } from \"./handlecache\";\nimport { VectorUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n segments = \"segments\",\n handleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n public static readonly typeString: string = \"PermutationSegment\";\n private _start = Handle.unallocated;\n\n public static fromJSONObject(spec: any) {\n const [length, start] = spec as PermutationSegmentSpec;\n return new PermutationSegment(length, start);\n }\n\n public readonly type = PermutationSegment.typeString;\n\n constructor(length: number, start = Handle.unallocated) {\n super();\n this._start = start;\n this.cachedLength = length;\n }\n\n public get start() { return this._start; }\n public set start(value: Handle) {\n assert(this._start === Handle.unallocated, 0x024 /* \"Start of PermutationSegment already allocated!\" */);\n assert(isHandleValid(value), 0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */);\n\n this._start = value;\n }\n\n /**\n * Invoked by '_undoRow/ColRemove' to prepare the newly inserted destination\n * segment to serve as the replacement for this removed segment. This moves handle\n * allocations from this segment to the replacement as well as maintains tracking\n * groups for the undo/redo stack.\n */\n public transferToReplacement(destination: PermutationSegment) {\n // When this segment was removed, it may have been split from a larger original\n // segment. In this case, it will have been added to an undo/redo tracking group\n // that associates all of the fragments from the original insertion.\n //\n // Move this association from the this removed segment to its replacement so that\n // it is included if the undo stack continues to unwind to the original insertion.\n //\n // Out of paranoia we link and unlink in separate loops to avoid mutating the underlying\n // set during enumeration. In practice, this is unlikely to matter since there should be\n // exactly 0 or 1 items in the enumeration.\n for (const group of this.trackingCollection.trackingGroups) {\n group.link(destination);\n }\n for (const group of this.trackingCollection.trackingGroups) {\n group.unlink(this);\n }\n\n // Move handle allocations from this segment to its replacement.\n destination._start = this._start;\n this.reset();\n }\n\n public reset() {\n this._start = Handle.unallocated;\n }\n\n public toJSONObject() {\n return [this.cachedLength, this.start];\n }\n\n public clone(start = 0, end = this.cachedLength) {\n const b = new PermutationSegment(\n /* length: */ end - start,\n /* start: */ this.start + start);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment) {\n const asPerm = segment as PermutationSegment;\n\n return this.start === Handle.unallocated\n ? asPerm.start === Handle.unallocated\n : asPerm.start === this.start + this.cachedLength;\n }\n\n public append(segment: ISegment) {\n // Note: Must call 'LocalReferenceCollection.append(..)' before modifying this segment's length as\n // 'this.cachedLength' is used to adjust the offsets of the local refs.\n LocalReferenceCollection.append(this, segment);\n\n this.cachedLength += segment.cachedLength;\n }\n\n protected createSplitSegmentAt(pos: number) {\n assert(0 < pos && pos < this.cachedLength, 0x026 /* \"Trying to split segment at out-of-bounds position!\" */);\n\n const leafSegment = new PermutationSegment(\n /* length: */ this.cachedLength - pos,\n /* start: */ this.start === Handle.unallocated\n ? Handle.unallocated\n : this.start + pos);\n\n this.cachedLength = pos;\n\n return leafSegment;\n }\n\n public toString() {\n return this.start === Handle.unallocated\n ? `<${this.cachedLength} empty>`\n : `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n }\n}\n\nexport class PermutationVector extends Client {\n private handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n public readonly handleCache = new HandleCache(this);\n public undo: VectorUndoProvider | undefined;\n\n constructor(\n path: string,\n logger: ITelemetryBaseLogger,\n runtime: IFluidDataStoreRuntime,\n private readonly deltaCallback: (position: number, numRemoved: number, numInserted: number) => void,\n private readonly handlesRecycledCallback: (handles: Handle[]) => void,\n ) {\n super(\n PermutationSegment.fromJSONObject,\n ChildLogger.create(logger, `Matrix.${path}.MergeTreeClient`), {\n ...runtime.options,\n newMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.\n }); // (See https://github.com/microsoft/FluidFramework/issues/84)\n\n this.mergeTreeDeltaCallback = this.onDelta;\n this.mergeTreeMaintenanceCallback = this.onMaintenance;\n }\n\n public insert(start: number, length: number) {\n return this.insertSegmentLocal(\n start,\n new PermutationSegment(length));\n }\n\n public insertRelative(segment: ISegment, length: number) {\n const inserted = new PermutationSegment(length);\n\n return {\n op: this.insertAtReferencePositionLocal(\n this.createLocalReferencePosition(segment, 0, ReferenceType.Transient, undefined),\n inserted),\n inserted,\n };\n }\n\n public remove(start: number, length: number) {\n return this.removeRangeLocal(start, start + length);\n }\n\n public getMaybeHandle(pos: number): Handle {\n assert(0 <= pos && pos < this.getLength(), 0x027 /* \"Trying to get handle of out-of-bounds position!\" */);\n\n return this.handleCache.getHandle(pos);\n }\n\n public getAllocatedHandle(pos: number): Handle {\n let handle = this.getMaybeHandle(pos);\n if (isHandleValid(handle)) {\n return handle;\n }\n\n this.walkSegments(\n (segment) => {\n const asPerm = segment as PermutationSegment;\n asPerm.start = handle = this.handleTable.allocate();\n return true;\n },\n pos,\n pos + 1,\n /* accum: */ undefined,\n /* splitRange: */ true);\n\n this.handleCache.addHandle(pos, handle);\n\n return handle;\n }\n\n public adjustPosition(pos: number, fromSeq: number, clientId: number) {\n const { segment, offset } = this.mergeTree.getContainingSegment(pos, fromSeq, clientId);\n\n // Note that until the MergeTree GCs, the segment is still reachable via `getContainingSegment()` with\n // a `refSeq` in the past. Prevent remote ops from accidentally allocating or using recycled handles\n // by checking for the presence of 'removedSeq'.\n if (segment === undefined || segment.removedSeq !== undefined) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.getPosition(segment) + offset!;\n }\n\n public handleToPosition(handle: Handle, localSeq = this.mergeTree.collabWindow.localSeq) {\n assert(localSeq <= this.mergeTree.collabWindow.localSeq,\n 0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */);\n\n // TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n // the original operation to the current position for resubmitting. This is probably the\n // ideal solution, as we would no longer need to store row/col handles in the op metadata.\n //\n // Failing that, we could avoid the O(n) search below by building a temporary map in the\n // opposite direction from the handle to either it's current position or segment + offset\n // and reuse it for the duration of resubmission. (Ideally, we would know when resubmission\n // ended so we could discard this map.)\n //\n // If we find that we frequently need a reverse handle -> position lookup, we could maintain\n // one using the Tiny-Calc adjust tree.\n let containingSegment!: PermutationSegment;\n let containingOffset: number;\n\n this.mergeTree.walkAllSegments(\n this.mergeTree.root,\n (segment) => {\n const { start, cachedLength } = segment as PermutationSegment;\n\n // If the segment is unallocated, skip it.\n if (!isHandleValid(start)) {\n return true;\n }\n\n const end = start + cachedLength;\n\n if (start <= handle && handle < end) {\n containingSegment = segment as PermutationSegment;\n containingOffset = handle - start;\n return false;\n }\n\n return true;\n });\n\n // We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n // row/col has been removed, because handles are not recycled until the containing segment\n // is unlinked from the MergeTree.\n //\n // Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n // ops that reference the stale handle, or the removal is unACKed, in which case the handle\n // has not yet been recycled.\n\n assert(isHandleValid(containingSegment.start), 0x029 /* \"Invalid handle at start of containing segment!\" */);\n\n // Once we know the current position of the handle, we can use the MergeTree to get the segment\n // containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n // have not yet been submitted.\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n }\n\n // Constructs an ISummaryTreeWithStats for the cell data.\n public summarize(runtime: IFluidDataStoreRuntime, handle: IFluidHandle, serializer: IFluidSerializer):\n ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n builder.addWithStats(SnapshotPath.segments, super.summarize(runtime, handle, serializer, /* catchUpMsgs: */[]));\n builder.addBlob(SnapshotPath.handleTable, serializer.stringify(this.handleTable.getSummaryContent(), handle));\n return builder.getSummaryTree();\n }\n\n public async load(\n runtime: IFluidDataStoreRuntime,\n storage: IChannelStorageService,\n serializer: IFluidSerializer,\n ) {\n const handleTableData = await deserializeBlob(storage, SnapshotPath.handleTable, serializer);\n\n this.handleTable = HandleTable.load<never>(handleTableData);\n\n return super.load(runtime, new ObjectStoragePartition(storage, SnapshotPath.segments), serializer);\n }\n\n private readonly onDelta = (\n opArgs: IMergeTreeDeltaOpArgs,\n { operation, deltaSegments }: IMergeTreeDeltaCallbackArgs,\n ) => {\n // Apply deltas in descending order to prevent positions from shifting.\n const ranges = deltaSegments\n .map(({ segment }) => ({\n segment: segment as PermutationSegment,\n position: this.getPosition(segment),\n }))\n .sort((left, right) => left.position - right.position);\n\n const isLocal = opArgs.sequencedMessage === undefined;\n\n // Notify the undo provider, if any is attached.\n if (this.undo !== undefined && isLocal) {\n this.undo.record(operation, ranges);\n }\n\n switch (operation) {\n case MergeTreeDeltaType.INSERT:\n // Pass 1: Perform any internal maintenance first to avoid reentrancy.\n for (const { segment, position } of ranges) {\n // HACK: We need to include the allocated handle in the segment's JSON representation\n // for snapshots, but need to ignore the remote client's handle allocations when\n // processing remote ops.\n segment.reset();\n\n this.handleCache.itemsChanged(\n position,\n /* deleteCount: */ 0,\n /* insertCount: */ segment.cachedLength);\n }\n\n // Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n for (const { segment, position } of ranges) {\n this.deltaCallback(position, /* numRemoved: */ 0, /* numInserted: */ segment.cachedLength);\n }\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n // Pass 1: Perform any internal maintenance first to avoid reentrancy.\n for (const { segment, position } of ranges) {\n this.handleCache.itemsChanged(\n position, /* deleteCount: */\n segment.cachedLength,\n /* insertCount: */ 0);\n }\n\n // Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n for (const { segment, position } of ranges) {\n this.deltaCallback(position, /* numRemoved: */ segment.cachedLength, /* numInsert: */ 0);\n }\n break;\n }\n\n default:\n throw new Error(\"Unhandled MergeTreeDeltaType\");\n }\n };\n\n private readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs) => {\n if (args.operation === MergeTreeMaintenanceType.UNLINK) {\n let freed: number[] = [];\n\n for (const { segment } of args.deltaSegments) {\n const asPerm = segment as PermutationSegment;\n if (isHandleValid(asPerm.start)) {\n // Note: Using the spread operator with `.splice()` can exhaust the stack.\n freed = freed.concat(\n new Array(asPerm.cachedLength)\n .fill(0)\n .map((value, index) => index + asPerm.start),\n );\n }\n }\n\n // Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n // the rows/cols prior to free to ensure recycled row/cols are initially empty.\n this.handlesRecycledCallback(freed);\n\n // Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n for (const handle of freed) {\n this.handleTable.free(handle);\n }\n }\n };\n\n public toString() {\n const s: string[] = [];\n\n this.walkSegments((segment) => {\n s.push(`${segment}`);\n return true;\n });\n\n return s.join(\"\");\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/matrix",
3
- "version": "1.2.1",
3
+ "version": "2.0.0-internal.1.0.0",
4
4
  "description": "Distributed matrix",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -60,27 +60,27 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@fluidframework/common-definitions": "^0.20.1",
63
- "@fluidframework/common-utils": "^0.32.1",
64
- "@fluidframework/core-interfaces": "^1.2.1",
65
- "@fluidframework/datastore-definitions": "^1.2.1",
66
- "@fluidframework/merge-tree": "^1.2.1",
67
- "@fluidframework/protocol-base": "^0.1036.5000",
68
- "@fluidframework/protocol-definitions": "^0.1028.2000",
69
- "@fluidframework/runtime-definitions": "^1.2.1",
70
- "@fluidframework/runtime-utils": "^1.2.1",
71
- "@fluidframework/shared-object-base": "^1.2.1",
72
- "@fluidframework/telemetry-utils": "^1.2.1",
63
+ "@fluidframework/common-utils": "^1.0.0",
64
+ "@fluidframework/core-interfaces": "^2.0.0-internal.1.0.0",
65
+ "@fluidframework/datastore-definitions": "^2.0.0-internal.1.0.0",
66
+ "@fluidframework/merge-tree": "^2.0.0-internal.1.0.0",
67
+ "@fluidframework/protocol-base": "^0.1037.1000",
68
+ "@fluidframework/protocol-definitions": "^1.0.0",
69
+ "@fluidframework/runtime-definitions": "^2.0.0-internal.1.0.0",
70
+ "@fluidframework/runtime-utils": "^2.0.0-internal.1.0.0",
71
+ "@fluidframework/shared-object-base": "^2.0.0-internal.1.0.0",
72
+ "@fluidframework/telemetry-utils": "^2.0.0-internal.1.0.0",
73
73
  "@tiny-calc/nano": "0.0.0-alpha.5",
74
74
  "tslib": "^1.10.0"
75
75
  },
76
76
  "devDependencies": {
77
- "@fluid-internal/test-dds-utils": "^1.2.1",
77
+ "@fluid-internal/test-dds-utils": "^2.0.0-internal.1.0.0",
78
78
  "@fluidframework/build-common": "^0.24.0",
79
- "@fluidframework/build-tools": "^0.2.74327",
79
+ "@fluidframework/build-tools": "^0.3.1000",
80
80
  "@fluidframework/eslint-config-fluid": "^0.28.2000",
81
- "@fluidframework/matrix-previous": "npm:@fluidframework/matrix@1.2.0",
82
- "@fluidframework/mocha-test-setup": "^1.2.1",
83
- "@fluidframework/test-runtime-utils": "^1.2.1",
81
+ "@fluidframework/matrix-previous": "npm:@fluidframework/matrix@^1.0.0",
82
+ "@fluidframework/mocha-test-setup": "^2.0.0-internal.1.0.0",
83
+ "@fluidframework/test-runtime-utils": "^2.0.0-internal.1.0.0",
84
84
  "@microsoft/api-extractor": "^7.22.2",
85
85
  "@rushstack/eslint-config": "^2.5.1",
86
86
  "@tiny-calc/micro": "0.0.0-alpha.5",
@@ -101,7 +101,7 @@
101
101
  "uuid": "^8.3.1"
102
102
  },
103
103
  "typeValidation": {
104
- "version": "1.2.1",
104
+ "version": "2.0.0",
105
105
  "broken": {}
106
106
  }
107
107
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/matrix";
9
- export const pkgVersion = "1.2.1";
9
+ export const pkgVersion = "2.0.0-internal.1.0.0";
@@ -17,7 +17,6 @@ import {
17
17
  MergeTreeDeltaType,
18
18
  IMergeTreeMaintenanceCallbackArgs,
19
19
  MergeTreeMaintenanceType,
20
- LocalReference,
21
20
  ReferenceType,
22
21
  } from "@fluidframework/merge-tree";
23
22
  import { IFluidHandle } from "@fluidframework/core-interfaces";
@@ -177,7 +176,7 @@ export class PermutationVector extends Client {
177
176
 
178
177
  return {
179
178
  op: this.insertAtReferencePositionLocal(
180
- new LocalReference(this, segment, /* offset: */ 0, ReferenceType.Transient),
179
+ this.createLocalReferencePosition(segment, 0, ReferenceType.Transient, undefined),
181
180
  inserted),
182
181
  inserted,
183
182
  };