@fluidframework/matrix 2.70.0-361248 → 2.70.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/matrix
2
2
 
3
+ ## 2.70.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.63.0
4
8
 
5
9
  Dependency updates only.
package/dist/matrix.d.ts CHANGED
@@ -4,9 +4,8 @@
4
4
  */
5
5
  import type { IEvent, IEventThisPlaceHolder, IEventProvider } from "@fluidframework/core-interfaces";
6
6
  import type { IChannelAttributes, IFluidDataStoreRuntime, IChannel, IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
7
- import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
8
7
  import { type IJSONSegment } from "@fluidframework/merge-tree/internal";
9
- import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
8
+ import type { ISummaryTreeWithStats, IRuntimeMessageCollection } from "@fluidframework/runtime-definitions/internal";
10
9
  import { type IFluidSerializer, type ISharedObjectEvents, SharedObject } from "@fluidframework/shared-object-base/internal";
11
10
  import type { IMatrixConsumer, IMatrixProducer, IMatrixReader, IMatrixWriter } from "@tiny-calc/nano";
12
11
  import { type MatrixItem } from "./ops.js";
@@ -214,7 +213,11 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
214
213
  * we are in FWW mode.
215
214
  */
216
215
  private shouldSetCellBasedOnFWW;
217
- protected processCore(msg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
216
+ /**
217
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}
218
+ */
219
+ protected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void;
220
+ private processMessage;
218
221
  private readonly onRowDelta;
219
222
  private readonly onColDelta;
220
223
  private readonly onRowHandlesRecycled;
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.d.ts","sourceRo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||
576
576
  message.referenceSequenceNumber >= lastCellModificationDetails.seqNum);
577
577
  }
578
- processCore(msg, local, localOpMetadata) {
578
+ /**
579
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}
580
+ */
581
+ processMessagesCore(messagesCollection) {
582
+ const { envelope, local, messagesContent } = messagesCollection;
583
+ for (const messageContent of messagesContent) {
584
+ this.processMessage(envelope, messageContent, local);
585
+ }
586
+ }
587
+ processMessage(messageEnvelope, messageContent, local) {
588
+ // Reconstruct the ISequencedDocumentMessage which is needed by merge tree client.
589
+ const msg = {
590
+ ...messageEnvelope,
591
+ contents: messageContent.contents,
592
+ clientSequenceNumber: messageContent.clientSequenceNumber,
593
+ };
594
+ const localOpMetadata = messageContent.localOpMetadata;
579
595
  if (local) {
580
596
  const recordedRefSeq = this.inFlightRefSeqs.shift();
581
597
  (0, internal_1.assert)(recordedRefSeq !== undefined, 0x8ba /* No pending recorded refSeq found */);
@@ -587,7 +603,7 @@ class SharedMatrix extends internal_4.SharedObject {
587
603
  // See "handles stashed ops created on top of sequenced local ops" for one such test case.
588
604
  // assert(recordedRefSeq <= message.referenceSequenceNumber, "RefSeq mismatch");
589
605
  }
590
- const contents = msg.contents;
606
+ const contents = messageContent.contents;
591
607
  const target = contents.target;
592
608
  switch (target) {
593
609
  case ops_js_1.SnapshotPath.cols: {
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAOH,kEAA8E;AAQ9E,kEAS6C;AAE7C,qEAGgD;AAChD,0EAIqD;AACrD,uEAAsE;AAOtE,4EAAuC;AAGvC,qDAA8D;AAC9D,qCAOkB;AAClB,iEAAsF;AACtF,yCAAyC;AACzC,yDAAqD;AACrD,yDAAoE;AAEpE,uDAAuD;AAuKvD;;;;;;;;;;;;GAYG;AACH,yDAAyD;AACzD,+DAA+D;AAC/D,8DAA8D;AAC9D,MAAa,YACZ,SAAQ,uBAA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;YACnE,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;gBAC9B,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC5B,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,KAAK,qBAAY,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5E,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAC/B,IAAI,OAAO,CAAC,MAAM,KAAK,qBAAY,CAAC,IAAI,EAAE,CAAC;gBAC1C,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAl+BD,oCAk+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIEvent,\n\tIEventThisPlaceHolder,\n\tIEventProvider,\n} from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannel,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype Client,\n\ttype IJSONSegment,\n\ttype IMergeTreeOp,\n\ttype ISegmentInternal,\n\ttype LocalReferencePosition,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\tsegmentIsRemoved,\n} from \"@fluidframework/merge-tree/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tObjectStoragePartition,\n\tSummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\ttype ISharedObjectEvents,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type {\n\tIMatrixConsumer,\n\tIMatrixProducer,\n\tIMatrixReader,\n\tIMatrixWriter,\n} from \"@tiny-calc/nano\";\nimport Deque from \"double-ended-queue\";\n\nimport type { HandleCache } from \"./handlecache.js\";\nimport { type Handle, isHandleValid } from \"./handletable.js\";\nimport {\n\ttype ISetOp,\n\ttype MatrixItem,\n\tMatrixOp,\n\ttype MatrixSetOrVectorOp,\n\tSnapshotPath,\n\ttype VectorOp,\n} from \"./ops.js\";\nimport { PermutationVector, reinsertSegmentIntoVector } from \"./permutationvector.js\";\nimport { ensureRange } from \"./range.js\";\nimport { deserializeBlob } from \"./serialization.js\";\nimport { SparseArray2D, type RecurArray } from \"./sparsearray2d.js\";\nimport type { IUndoConsumer } from \"./types.js\";\nimport { MatrixUndoProvider } from \"./undoprovider.js\";\n\ninterface ISetOpMetadata {\n\trowHandle: Handle;\n\tcolHandle: Handle;\n\tlocalSeq: number;\n\trowsRef: LocalReferencePosition;\n\tcolsRef: LocalReferencePosition;\n\treferenceSeqNumber: number;\n}\n\n/**\n * Events emitted by Shared Matrix.\n * @legacy @beta\n */\nexport interface ISharedMatrixEvents<T> extends IEvent {\n\t/**\n\t * This event is only emitted when the SetCell Resolution Policy is First Write Win(FWW).\n\t * This is emitted when two clients race and send changes without observing each other changes,\n\t * the changes that gets sequenced last would be rejected, and only client who's changes rejected\n\t * would be notified via this event, with expectation that it will merge its changes back by\n\t * accounting new information (state from winner of the race).\n\t *\n\t * @remarks Listener parameters:\n\t *\n\t * - `row` - Row number at which conflict happened.\n\t *\n\t * - `col` - Col number at which conflict happened.\n\t *\n\t * - `currentValue` - The current value of the cell.\n\t *\n\t * - `conflictingValue` - The value that this client tried to set in the cell and got ignored due to conflict.\n\t *\n\t * - `target` - The {@link ISharedMatrix} itself.\n\t */\n\t(\n\t\tevent: \"conflict\",\n\t\tlistener: (\n\t\t\trow: number,\n\t\t\tcol: number,\n\t\t\tcurrentValue: MatrixItem<T>,\n\t\t\tconflictingValue: MatrixItem<T>,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t): void;\n}\n\n/**\n * This represents the item which is used to track the client which modified the cell last.\n */\ninterface CellLastWriteTrackerItem {\n\tseqNum: number; // Seq number of op which last modified this cell\n\tclientId: string; // clientId of the client which last modified this cell\n}\n\n/**\n * @legacy @beta\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition ISharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ISharedMatrix<T = any>\n\textends IEventProvider<ISharedMatrixEvents<T>>,\n\t\tIMatrixProducer<MatrixItem<T>>,\n\t\tIMatrixReader<MatrixItem<T>>,\n\t\tIMatrixWriter<MatrixItem<T>>,\n\t\tIChannel {\n\t/**\n\t * Inserts columns into the matrix.\n\t * @param colStart - Index of the first column to insert.\n\t * @param count - Number of columns to insert.\n\t * @remarks\n\t * Inserting 0 columns is a noop.\n\t */\n\tinsertCols(colStart: number, count: number): void;\n\t/**\n\t * Removes columns from the matrix.\n\t * @param colStart - Index of the first column to remove.\n\t * @param count - Number of columns to remove.\n\t * @remarks\n\t * Removing 0 columns is a noop.\n\t */\n\tremoveCols(colStart: number, count: number): void;\n\t/**\n\t * Inserts rows into the matrix.\n\t * @param rowStart - Index of the first row to insert.\n\t * @param count - Number of rows to insert.\n\t * @remarks\n\t * Inserting 0 rows is a noop.\n\t */\n\tinsertRows(rowStart: number, count: number): void;\n\t/**\n\t * Removes rows from the matrix.\n\t * @param rowStart - Index of the first row to remove.\n\t * @param count - Number of rows to remove.\n\t * @remarks\n\t * Removing 0 rows is a noop.\n\t */\n\tremoveRows(rowStart: number, count: number): void;\n\n\t/**\n\t * Sets a range of cells in the matrix.\n\t * Cells are set in consecutive columns between `colStart` and `colStart + colCount - 1`.\n\t * When `values` has larger size than `colCount`, the extra values are inserted in subsequent rows\n\t * a la text-wrapping.\n\t * @param rowStart - Index of the row to start setting cells.\n\t * @param colStart - Index of the column to start setting cells.\n\t * @param colCount - Number of columns to set before wrapping to subsequent rows (if `values` has more items)\n\t * @param values - Values to insert.\n\t * @remarks\n\t * This is not currently more efficient than calling `setCell` for each cell.\n\t */\n\tsetCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t): void;\n\n\t/**\n\t * Attach an {@link IUndoConsumer} to the matrix.\n\t * @param consumer - Undo consumer which will receive revertibles from the matrix.\n\t */\n\topenUndo(consumer: IUndoConsumer): void;\n\n\t/**\n\t * Whether the current conflict resolution policy is first-write win (FWW).\n\t * See {@link ISharedMatrix.switchSetCellPolicy} for more details.\n\t */\n\tisSetCellConflictResolutionPolicyFWW(): boolean;\n\n\t/**\n\t * Change the conflict resolution policy for setCell operations to first-write win (FWW).\n\t *\n\t * This API only switches from LWW to FWW and not from FWW to LWW.\n\t *\n\t * @privateRemarks\n\t * The next SetOp which is sent will communicate this policy to other clients.\n\t */\n\tswitchSetCellPolicy(): void;\n}\n\ntype FirstWriterWinsPolicy =\n\t| { state: \"off\" }\n\t| { state: \"local\" }\n\t| {\n\t\t\tstate: \"on\";\n\t\t\tswitchOpSeqNumber: number;\n\t\t\tcellLastWriteTracker: SparseArray2D<CellLastWriteTrackerItem>;\n\t };\n\n/**\n * Tracks pending local changes for a cell.\n */\ninterface PendingCellChanges<T> {\n\t/**\n\t * The local changes including the local seq, and the value set at that local seq.\n\t */\n\tlocal: { localSeq: number; value: MatrixItem<T> }[];\n\t/**\n\t * The latest consensus value across all clients.\n\t * this will either be a remote value or ack'd local\n\t * value.\n\t */\n\tconsensus?: MatrixItem<T>;\n}\n\n/**\n * A SharedMatrix holds a rectangular 2D array of values. Supported operations\n * include setting values and inserting/removing rows and columns.\n *\n * Matrix values may be any Fluid serializable type, which is the set of JSON\n * serializable types extended to include IFluidHandles.\n *\n * Fluid's SharedMatrix implementation works equally well for dense and sparse\n * matrix data and physically stores data in Z-order to leverage CPU caches and\n * prefetching when reading in either row or column major order. (See README.md\n * for more details.)\n * @legacy @beta\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition SharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class SharedMatrix<T = any>\n\textends SharedObject<ISharedMatrixEvents<T> & ISharedObjectEvents>\n\timplements ISharedMatrix<T>\n{\n\tprivate readonly consumers = new Set<IMatrixConsumer<MatrixItem<T>>>();\n\n\t/**\n\t * Note: this field only provides a lower-bound on the reference sequence numbers for in-flight ops.\n\t * The exact reason isn't understood, but some e2e tests suggest that the runtime may sometimes process\n\t * incoming leave/join ops before putting an op that this DDS submits over the wire.\n\t *\n\t * E.g. SharedMatrix submits an op while deltaManager has lastSequenceNumber = 10, but before the runtime\n\t * puts this op over the wire, it processes a client join/leave op with sequence number 11, so the referenceSequenceNumber\n\t * on the SharedMatrix op is 11.\n\t */\n\tprivate readonly inFlightRefSeqs = new Deque<number>();\n\treadonly getMinInFlightRefSeq = (): number | undefined => this.inFlightRefSeqs.get(0);\n\n\tprivate readonly rows: PermutationVector; // Map logical row to storage handle (if any)\n\tprivate readonly cols: PermutationVector; // Map logical col to storage handle (if any)\n\n\tprivate cells = new SparseArray2D<MatrixItem<T>>(); // Stores cell values.\n\tprivate readonly pending = new SparseArray2D<PendingCellChanges<T>>(); // Tracks pending writes.\n\n\tprivate fwwPolicy: FirstWriterWinsPolicy = {\n\t\tstate: \"off\",\n\t};\n\n\t// Used to track if there is any reentrancy in setCell code.\n\tprivate reentrantCount: number = 0;\n\n\t/**\n\t * Constructor for the Shared Matrix\n\t * @param runtime - DataStore runtime.\n\t * @param id - id of the dds\n\t * @param attributes - channel attributes\n\t * @param _isSetCellConflictResolutionPolicyFWW - Conflict resolution for Matrix set op is First Writer Win in case of\n\t * race condition. Client can still overwrite values in case of no race.\n\t */\n\tconstructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_matrix_\");\n\n\t\tthis.rows = new PermutationVector(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onRowDelta,\n\t\t\tthis.onRowHandlesRecycled,\n\t\t\tthis.getMinInFlightRefSeq,\n\t\t);\n\n\t\tthis.cols = new PermutationVector(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onColDelta,\n\t\t\tthis.onColHandlesRecycled,\n\t\t\tthis.getMinInFlightRefSeq,\n\t\t);\n\t}\n\n\tprivate undo?: MatrixUndoProvider<T>;\n\n\t/**\n\t * Subscribes the given IUndoConsumer to the matrix.\n\t */\n\tpublic openUndo(consumer: IUndoConsumer): void {\n\t\tassert(\n\t\t\tthis.undo === undefined,\n\t\t\t0x019 /* \"SharedMatrix.openUndo() supports at most a single IUndoConsumer.\" */,\n\t\t);\n\n\t\tthis.undo = new MatrixUndoProvider(consumer, this, this.rows, this.cols);\n\t}\n\n\t// TODO: closeUndo()?\n\n\tprivate get rowHandles(): HandleCache {\n\t\treturn this.rows.handleCache;\n\t}\n\tprivate get colHandles(): HandleCache {\n\t\treturn this.cols.handleCache;\n\t}\n\n\t// #region IMatrixProducer\n\n\topenMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): IMatrixReader<MatrixItem<T>> {\n\t\tthis.consumers.add(consumer);\n\t\treturn this;\n\t}\n\n\tcloseMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): void {\n\t\tthis.consumers.delete(consumer);\n\t}\n\n\t// #endregion IMatrixProducer\n\n\t// #region IMatrixReader\n\n\tpublic get rowCount(): number {\n\t\treturn this.rows.getLength();\n\t}\n\tpublic get colCount(): number {\n\t\treturn this.cols.getLength();\n\t}\n\n\tpublic isSetCellConflictResolutionPolicyFWW(): boolean {\n\t\treturn this.fwwPolicy.state !== \"off\";\n\t}\n\n\tpublic getCell(row: number, col: number): MatrixItem<T> {\n\t\t// Perf: When possible, bounds checking is performed inside the implementation for\n\t\t// 'getHandle()' so that it can be elided in the case of a cache hit. This\n\t\t// yields an ~40% improvement in the case of a cache hit (node v12 x64)\n\n\t\t// Map the logical (row, col) to associated storage handles.\n\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\tif (isHandleValid(rowHandle)) {\n\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\tif (isHandleValid(colHandle)) {\n\t\t\t\treturn this.cells.getCell(rowHandle, colHandle);\n\t\t\t}\n\t\t} else {\n\t\t\t// If we early exit because the given rowHandle is unallocated, we still need to\n\t\t\t// bounds-check the 'col' parameter.\n\t\t\tensureRange(col, this.cols.getLength());\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<MatrixItem<T>> {\n\t\treturn this;\n\t}\n\n\t// #endregion IMatrixReader\n\n\tpublic setCell(row: number, col: number, value: MatrixItem<T>): void {\n\t\tif (row < 0 || row >= this.rowCount || col < 0 || col >= this.colCount) {\n\t\t\tthrow new UsageError(\"Trying to set out-of-bounds cell.\");\n\t\t}\n\n\t\tthis.setCellCore(row, col, value);\n\t}\n\n\tpublic setCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t): void {\n\t\tconst rowCount = Math.ceil(values.length / colCount);\n\n\t\tassert(\n\t\t\t0 <= rowStart &&\n\t\t\t\trowStart < this.rowCount &&\n\t\t\t\t0 <= colStart &&\n\t\t\t\tcolStart < this.colCount &&\n\t\t\t\t1 <= colCount &&\n\t\t\t\tcolCount <= this.colCount - colStart &&\n\t\t\t\trowCount <= this.rowCount - rowStart,\n\t\t\t0x01b /* \"Trying to set multiple out-of-bounds cells!\" */,\n\t\t);\n\n\t\tconst endCol = colStart + colCount;\n\t\tlet r = rowStart;\n\t\tlet c = colStart;\n\n\t\tfor (const value of values) {\n\t\t\tthis.setCellCore(r, c, value);\n\n\t\t\tif (++c === endCol) {\n\t\t\t\tc = colStart;\n\t\t\t\tr++;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setCellCore(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle = this.rows.getAllocatedHandle(row),\n\t\tcolHandle = this.cols.getAllocatedHandle(col),\n\t\trollback?: boolean,\n\t): void {\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst oldValue = this.cells.getCell(rowHandle, colHandle) ?? undefined;\n\n\t\t\tif (this.undo !== undefined) {\n\t\t\t\tthis.undo.cellSet(rowHandle, colHandle, oldValue);\n\t\t\t}\n\n\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\n\t\t\tif (this.isAttached() && rollback !== true) {\n\t\t\t\tconst pending = this.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\tif (pending.local.length === 1) {\n\t\t\t\t\tpending.consensus ??= oldValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\tconsumer.cellsChanged(row, col, 1, 1, this);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate createOpMetadataLocalRef(\n\t\tvector: PermutationVector,\n\t\tpos: number,\n\t\tlocalSeq: number,\n\t): LocalReferencePosition {\n\t\tconst segoff = vector.getContainingSegment(pos, undefined, localSeq);\n\t\tassert(segoff !== undefined, 0x8b3 /* expected valid position */);\n\t\treturn vector.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\tReferenceType.StayOnRemove,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\tprivate sendSetCellOp(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tlocalSeq = this.nextLocalSeq(),\n\t): PendingCellChanges<T> {\n\t\tassert(\n\t\t\tthis.isAttached(),\n\t\t\t0x1e2 /* \"Caller must ensure 'isAttached()' before calling 'sendSetCellOp'.\" */,\n\t\t);\n\n\t\tconst op: ISetOp<T> = {\n\t\t\ttype: MatrixOp.set,\n\t\t\trow,\n\t\t\tcol,\n\t\t\tvalue,\n\t\t\tfwwMode: this.fwwPolicy.state !== \"off\",\n\t\t};\n\n\t\tconst rowsRef = this.createOpMetadataLocalRef(this.rows, row, localSeq);\n\t\tconst colsRef = this.createOpMetadataLocalRef(this.cols, col, localSeq);\n\t\tconst metadata: ISetOpMetadata = {\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t\tlocalSeq,\n\t\t\trowsRef,\n\t\t\tcolsRef,\n\t\t\treferenceSeqNumber: this.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, metadata);\n\t\tconst pendingCell: PendingCellChanges<T> = this.pending.getCell(rowHandle, colHandle) ?? {\n\t\t\tlocal: [],\n\t\t};\n\t\tpendingCell.local.push({ localSeq, value });\n\t\tthis.pending.setCell(rowHandle, colHandle, pendingCell);\n\t\treturn pendingCell;\n\t}\n\n\t/**\n\t * This makes sure that the code inside the callback is not reentrant. We need to do that because we raise notifications\n\t * to the consumers telling about these changes and they can try to change the matrix while listening to those notifications\n\t * which can make the shared matrix to be in bad state. For example, we are raising notification for a setCell changes and\n\t * a consumer tries to delete that row/col on receiving that notification which can lead to this matrix trying to setCell in\n\t * a deleted row/col.\n\t * @param callback - code that needs to protected against reentrancy.\n\t */\n\tprivate protectAgainstReentrancy(callback: () => void): void {\n\t\tif (this.reentrantCount !== 0) {\n\t\t\t// Validate that applications don't submit edits in response to matrix change notifications. This is unsupported.\n\t\t\tthrow new UsageError(\"Reentrancy detected in SharedMatrix.\");\n\t\t}\n\t\tthis.reentrantCount++;\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\tthis.reentrantCount--;\n\t\t}\n\t\tassert(\n\t\t\tthis.reentrantCount === 0,\n\t\t\t0x85e /* indicates a problem with the reentrancy tracking code. */,\n\t\t);\n\t}\n\n\tprivate submitVectorMessage(\n\t\tcurrentVector: PermutationVector,\n\t\toppositeVector: PermutationVector,\n\t\ttarget: SnapshotPath.rows | SnapshotPath.cols,\n\t\tmessage: IMergeTreeOp,\n\t): void {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally advance each MergeTree's 'localSeq' counter\n\t\t// for each submitted op it not aware of to keep them synchronized.\n\t\tconst localSeq = currentVector.getCollabWindow().localSeq;\n\t\tconst oppositeWindow = oppositeVector.getCollabWindow();\n\n\t\t// Note that the comparison is '>=' because, in the case the MergeTree is regenerating ops for reconnection,\n\t\t// the MergeTree submits the op with the original 'localSeq'.\n\t\tassert(\n\t\t\tlocalSeq >= oppositeWindow.localSeq,\n\t\t\t0x01c /* \"The 'localSeq' of the vector submitting an op must >= the 'localSeq' of the other vector.\" */,\n\t\t);\n\n\t\toppositeWindow.localSeq = localSeq;\n\n\t\t// If the SharedMatrix is local, it's state will be submitted via a Snapshot when initially connected.\n\t\t// Do not queue a message or track the pending op, as there will never be an ACK, etc.\n\t\tif (this.isAttached()) {\n\t\t\t// Record whether this `op` targets rows or cols. (See dispatch in `processCore()`)\n\t\t\tconst targetedMessage: VectorOp = { ...message, target };\n\n\t\t\tthis.submitLocalMessage(\n\t\t\t\ttargetedMessage,\n\t\t\t\tcurrentVector.peekPendingSegmentGroups(\n\t\t\t\t\tmessage.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate submitColMessage(message: IMergeTreeOp): void {\n\t\tthis.submitVectorMessage(this.cols, this.rows, SnapshotPath.cols, message);\n\t}\n\n\tpublic insertCols(colStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (colStart > this.colCount) {\n\t\t\tthrow new UsageError(\"insertCols: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst message = this.cols.insert(colStart, count);\n\t\t\tassert(message !== undefined, 0x8b4 /* must be defined */);\n\t\t\tthis.submitColMessage(message);\n\t\t});\n\t}\n\n\tpublic removeCols(colStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (colStart > this.colCount) {\n\t\t\tthrow new UsageError(\"removeCols: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() =>\n\t\t\tthis.submitColMessage(this.cols.remove(colStart, count)),\n\t\t);\n\t}\n\n\tprivate submitRowMessage(message: IMergeTreeOp): void {\n\t\tthis.submitVectorMessage(this.rows, this.cols, SnapshotPath.rows, message);\n\t}\n\n\tpublic insertRows(rowStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (rowStart > this.rowCount) {\n\t\t\tthrow new UsageError(\"insertRows: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst message = this.rows.insert(rowStart, count);\n\t\t\tassert(message !== undefined, 0x8b5 /* must be defined */);\n\t\t\tthis.submitRowMessage(message);\n\t\t});\n\t}\n\n\tpublic removeRows(rowStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (rowStart > this.rowCount) {\n\t\t\tthrow new UsageError(\"removeRows: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() =>\n\t\t\tthis.submitRowMessage(this.rows.remove(rowStart, count)),\n\t\t);\n\t}\n\n\tpublic _undoRemoveRows(rowStart: number, spec: IJSONSegment): void {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.rows, rowStart, spec);\n\t\tassert(op !== undefined, 0x8b6 /* must be defined */);\n\t\tthis.submitRowMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted rows.\n\t\tlet rowHandle = inserted.start;\n\t\tconst rowCount = inserted.cachedLength;\n\t\tfor (let row = rowStart; row < rowStart + rowCount; row++, rowHandle++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(rowStart, /* colStart: */ 0, rowCount, this.colCount, this);\n\t\t}\n\t}\n\n\t/***/ public _undoRemoveCols(colStart: number, spec: IJSONSegment): void {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.cols, colStart, spec);\n\t\tassert(op !== undefined, 0x8b7 /* must be defined */);\n\t\tthis.submitColMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted cols.\n\t\tlet colHandle = inserted.start;\n\t\tconst colCount = inserted.cachedLength;\n\t\tfor (let col = colStart; col < colStart + colCount; col++, colHandle++) {\n\t\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(/* rowStart: */ 0, colStart, this.rowCount, colCount, this);\n\t\t}\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.rows.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.cols.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tconst artifactsToSummarize: (\n\t\t\t| undefined\n\t\t\t| number\n\t\t\t| ReturnType<SparseArray2D<MatrixItem<T> | number>[\"snapshot\"]>\n\t\t)[] = [\n\t\t\tthis.cells.snapshot(),\n\t\t\t/**\n\t\t\t * we used to write this.pending.snapshot(). this should have never been done, as pending is only for local\n\t\t\t * changes, and there should never be local changes in the summarizer. This was also never used on load\n\t\t\t * as there is no way to understand a previous clients pending changes. so we just set this to a constant\n\t\t\t * which matches an empty this.pending.snapshot() for back-compat in terms of the array length\n\t\t\t */\n\t\t\t[undefined],\n\t\t];\n\n\t\t// Only need to store it in the snapshot if we have switched the policy already.\n\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\tartifactsToSummarize.push(\n\t\t\t\tthis.fwwPolicy.switchOpSeqNumber,\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.snapshot(),\n\t\t\t);\n\t\t} else {\n\t\t\t// back-compat: used -1 for disabled\n\t\t\tartifactsToSummarize.push(\n\t\t\t\t-1,\n\t\t\t\t/*\n\t\t\t\t * we should set undefined in place of cellLastWriteTracker to ensure the number of array entries is consistent.\n\t\t\t\t * Doing that currently breaks snapshot tests. Its is probably fine, but if new elements are ever added, we need\n\t\t\t\t * ensure undefined is also set.\n\t\t\t\t */\n\t\t\t\t// undefined\n\t\t\t);\n\t\t}\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.cells,\n\t\t\tserializer.stringify(artifactsToSummarize, this.handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Runs serializer on the GC data for this SharedMatrix.\n\t * All the IFluidHandle's stored in the cells represent routes to other objects.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer): void {\n\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tserializer.stringify(this.getCell(row, col), this.handle);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Advances the 'localSeq' counter for the cell data operation currently being queued.\n\t *\n\t * Do not use with 'submitColMessage()/submitRowMessage()' as these helpers + the MergeTree will\n\t * automatically advance 'localSeq'.\n\t */\n\tprivate nextLocalSeq(): number {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally bump each MergeTree's 'localSeq' counter\n\t\t// for SharedMatrix ops it's not aware of to keep them synchronized. (For cell data operations, we\n\t\t// need to bump both counters.)\n\n\t\tthis.cols.getCollabWindow().localSeq++;\n\t\treturn ++this.rows.getCollabWindow().localSeq;\n\t}\n\n\tprotected submitLocalMessage(message: unknown, localOpMetadata?: unknown): void {\n\t\t// TODO: Recommend moving this assertion into SharedObject\n\t\t// (See https://github.com/microsoft/FluidFramework/issues/2559)\n\t\tassert(\n\t\t\tthis.isAttached() === true,\n\t\t\t0x01d /* \"Trying to submit message to runtime while detached!\" */,\n\t\t);\n\n\t\tthis.inFlightRefSeqs.push(this.deltaManager.lastSequenceNumber);\n\t\tsuper.submitLocalMessage(message, localOpMetadata);\n\n\t\t// Ensure that row/col 'localSeq' are synchronized (see 'nextLocalSeq()').\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq,\n\t\t\t0x01e /* \"Row and col collab window 'localSeq' desynchronized!\" */,\n\t\t);\n\t}\n\n\tprotected didAttach(): void {\n\t\t// We've attached we need to start generating and sending ops.\n\t\t// so start collaboration and provide a default client id incase we are not connected\n\t\tif (this.isAttached()) {\n\t\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t}\n\t}\n\n\tprotected onConnect(): void {\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().collaborating === this.cols.getCollabWindow().collaborating,\n\t\t\t0x01f /* \"Row and col collab window 'collaborating' status desynchronized!\" */,\n\t\t);\n\n\t\t// Update merge tree collaboration information with new client ID and then resend pending ops\n\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t}\n\n\tprivate rebasePosition(\n\t\tclient: Client,\n\t\tref: LocalReferencePosition,\n\t\tlocalSeq: number,\n\t): number | undefined {\n\t\tconst segment: ISegmentInternal | undefined = ref.getSegment();\n\t\tconst offset = ref.getOffset();\n\t\t// If the segment that contains the position is removed, then this setCell op should do nothing.\n\t\tif (segment === undefined || offset === undefined || segmentIsRemoved(segment)) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn client.findReconnectionPosition(segment, localSeq) + offset;\n\t}\n\n\tprotected reSubmitCore(incoming: unknown, localOpMetadata: unknown): void {\n\t\tconst originalRefSeq = this.inFlightRefSeqs.shift();\n\t\tassert(\n\t\t\toriginalRefSeq !== undefined,\n\t\t\t0x8b9 /* Expected a recorded refSeq when resubmitting an op */,\n\t\t);\n\t\tconst content = incoming as MatrixSetOrVectorOp<T>;\n\n\t\tif (content.type === MatrixOp.set && content.target === undefined) {\n\t\t\tconst setOp = content;\n\t\t\tconst { rowHandle, colHandle, localSeq, rowsRef, colsRef, referenceSeqNumber } =\n\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\n\t\t\t// If after rebasing the op, we get a valid row/col number, that means the row/col\n\t\t\t// handles have not been recycled and we can safely use them.\n\t\t\tconst row = this.rebasePosition(this.rows, rowsRef, localSeq);\n\t\t\tconst col = this.rebasePosition(this.cols, colsRef, localSeq);\n\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\n\n\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\tassert(pendingCell !== undefined, 0xba4 /* local operation must have a pending array */);\n\t\t\tconst { local } = pendingCell;\n\t\t\tassert(local !== undefined, 0xba5 /* local operation must have a pending array */);\n\t\t\tconst localSeqIndex = local.findIndex((p) => p.localSeq === localSeq);\n\t\t\tassert(localSeqIndex >= 0, 0xba6 /* local operation must have a pending entry */);\n\t\t\tconst [change] = local.splice(localSeqIndex, 1);\n\t\t\tassert(change.localSeq === localSeq, 0xba7 /* must match */);\n\n\t\t\tif (\n\t\t\t\trow !== undefined &&\n\t\t\t\tcol !== undefined &&\n\t\t\t\trow >= 0 &&\n\t\t\t\tcol >= 0 && // If the mode is LWW, then send the op.\n\t\t\t\t// Otherwise if the current mode is FWW and if we generated this op, after seeing the\n\t\t\t\t// last set op, or it is the first set op for the cell, then regenerate the op,\n\t\t\t\t// otherwise raise conflict. We want to check the current mode here and not that\n\t\t\t\t// whether op was made in FWW or not.\n\t\t\t\t(this.fwwPolicy.state !== \"on\" ||\n\t\t\t\t\treferenceSeqNumber >=\n\t\t\t\t\t\t(this.fwwPolicy.cellLastWriteTracker.getCell(rowHandle, colHandle)?.seqNum ?? 0))\n\t\t\t) {\n\t\t\t\tthis.sendSetCellOp(row, col, setOp.value, rowHandle, colHandle, localSeq);\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (content.target) {\n\t\t\t\tcase SnapshotPath.cols: {\n\t\t\t\t\tthis.submitColMessage(\n\t\t\t\t\t\tthis.cols.regeneratePendingOp(content, localOpMetadata, false),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SnapshotPath.rows: {\n\t\t\t\t\tthis.submitRowMessage(\n\t\t\t\t\t\tthis.rows.regeneratePendingOp(content, localOpMetadata, false),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(content);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tconst contents = content as MatrixSetOrVectorOp<T>;\n\t\tconst target = contents.target;\n\n\t\tswitch (target) {\n\t\t\tcase SnapshotPath.cols: {\n\t\t\t\tthis.cols.rollback(content, localOpMetadata);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SnapshotPath.rows: {\n\t\t\t\tthis.rows.rollback(content, localOpMetadata);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase undefined: {\n\t\t\t\tassert(contents.type === MatrixOp.set, 0xba8 /* only sets supported */);\n\t\t\t\tconst setMetadata = localOpMetadata as ISetOpMetadata;\n\n\t\t\t\tconst pendingCell = this.pending.getCell(setMetadata.rowHandle, setMetadata.colHandle);\n\t\t\t\tassert(pendingCell !== undefined, 0xba9 /* must have pending */);\n\n\t\t\t\tconst change = pendingCell.local.pop();\n\t\t\t\tassert(change?.localSeq === setMetadata.localSeq, 0xbaa /* must have change */);\n\n\t\t\t\tconst previous =\n\t\t\t\t\tpendingCell.local.length > 0\n\t\t\t\t\t\t? pendingCell.local[pendingCell.local.length - 1].value\n\t\t\t\t\t\t: pendingCell.consensus;\n\n\t\t\t\tthis.setCellCore(\n\t\t\t\t\tcontents.row,\n\t\t\t\t\tcontents.col,\n\t\t\t\t\tprevious,\n\t\t\t\t\tsetMetadata.rowHandle,\n\t\t\t\t\tsetMetadata.colHandle,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\ttry {\n\t\t\tawait this.rows.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.rows),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tawait this.cols.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.cols),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tconst [\n\t\t\t\tcellData,\n\t\t\t\t_pendingCliSeqData,\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber,\n\t\t\t\tcellLastWriteTracker,\n\t\t\t\t// Cast is needed since the (de)serializer returns content of type `any`.\n\t\t\t] = (await deserializeBlob(storage, SnapshotPath.cells, this.serializer)) as [\n\t\t\t\tRecurArray<MatrixItem<T>>,\n\t\t\t\tunknown,\n\t\t\t\tnumber,\n\t\t\t\tRecurArray<CellLastWriteTrackerItem>,\n\t\t\t];\n\n\t\t\tthis.cells = SparseArray2D.load(cellData);\n\t\t\t// back-compat: used -1 for disabled, also may not exist\n\t\t\tconst switchOpSeqNumber =\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber === -1\n\t\t\t\t\t? undefined\n\t\t\t\t\t: (setCellLwwToFwwPolicySwitchOpSeqNumber ?? undefined);\n\t\t\tthis.fwwPolicy =\n\t\t\t\tswitchOpSeqNumber === undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstate: \"off\",\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\t\tswitchOpSeqNumber,\n\t\t\t\t\t\t\tcellLastWriteTracker: SparseArray2D.load(cellLastWriteTracker),\n\t\t\t\t\t\t};\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"MatrixLoadFailed\" }, error);\n\t\t}\n\t}\n\n\t/**\n\t * Tells whether the setCell op should be applied or not based on First Write Win policy. It assumes\n\t * we are in FWW mode.\n\t */\n\tprivate shouldSetCellBasedOnFWW(\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tmessage: ISequencedDocumentMessage,\n\t): boolean {\n\t\tassert(\n\t\t\tthis.fwwPolicy.state === \"on\",\n\t\t\t0x85f /* should be in Fww mode when calling this method */,\n\t\t);\n\t\tassert(message.clientId !== null, 0x860 /* clientId should not be null */);\n\t\tconst lastCellModificationDetails = this.fwwPolicy.cellLastWriteTracker.getCell(\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t);\n\t\t// If someone tried to Overwrite the cell value or first write on this cell or\n\t\t// same client tried to modify the cell.\n\t\treturn (\n\t\t\tlastCellModificationDetails === undefined ||\n\t\t\tlastCellModificationDetails.clientId === message.clientId ||\n\t\t\tmessage.referenceSequenceNumber >= lastCellModificationDetails.seqNum\n\t\t);\n\t}\n\n\tprotected processCore(\n\t\tmsg: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tif (local) {\n\t\t\tconst recordedRefSeq = this.inFlightRefSeqs.shift();\n\t\t\tassert(recordedRefSeq !== undefined, 0x8ba /* No pending recorded refSeq found */);\n\t\t\t// TODO: AB#7076: Some equivalent assert should be enabled. This fails some e2e stashed op tests because\n\t\t\t// the deltaManager may have seen more messages than the runtime has processed while amidst the stashed op\n\t\t\t// flow, so e.g. when `applyStashedOp` is called and the DDS is put in a state where it expects an ack for\n\t\t\t// one of its messages, the delta manager has actually already seen subsequent messages from collaborators\n\t\t\t// which the in-flight message is concurrent to.\n\t\t\t// See \"handles stashed ops created on top of sequenced local ops\" for one such test case.\n\t\t\t// assert(recordedRefSeq <= message.referenceSequenceNumber, \"RefSeq mismatch\");\n\t\t}\n\n\t\tconst contents = msg.contents as MatrixSetOrVectorOp<T>;\n\t\tconst target = contents.target;\n\n\t\tswitch (target) {\n\t\t\tcase SnapshotPath.cols: {\n\t\t\t\tthis.cols.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SnapshotPath.rows: {\n\t\t\t\tthis.rows.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase undefined: {\n\t\t\t\tassert(\n\t\t\t\t\tcontents.type === MatrixOp.set,\n\t\t\t\t\t0x021 /* \"SharedMatrix message contents have unexpected type!\" */,\n\t\t\t\t);\n\n\t\t\t\tconst { row, col, value, fwwMode } = contents;\n\t\t\t\t// If this is the first op notifying us of the policy change, then set the policy change seq number.\n\t\t\t\tif (fwwMode === true && this.fwwPolicy.state !== \"on\") {\n\t\t\t\t\tthis.fwwPolicy = {\n\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\tswitchOpSeqNumber: msg.sequenceNumber,\n\t\t\t\t\t\tcellLastWriteTracker: new SparseArray2D(),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tassert(msg.clientId !== null, 0x861 /* clientId should not be null!! */);\n\t\t\t\tif (local) {\n\t\t\t\t\t// We are receiving the ACK for a local pending set operation.\n\t\t\t\t\tconst { rowHandle, colHandle, localSeq, rowsRef, colsRef } =\n\t\t\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\t\t\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\n\n\t\t\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\t\t\tconst ackedChange = pendingCell?.local.shift();\n\t\t\t\t\tassert(ackedChange?.localSeq === localSeq, 0xbab /* must match */);\n\t\t\t\t\tif (pendingCell?.local.length === 0) {\n\t\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If policy is switched and cell should be modified too based on policy, then update the tracker.\n\t\t\t\t\t// If policy is not switched, then also update the tracker in case it is the latest.\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.fwwPolicy.state === \"on\" &&\n\t\t\t\t\t\tthis.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tpendingCell!.consensus = ackedChange.value;\n\t\t\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst adjustedRow = this.rows.adjustPosition(row, msg);\n\t\t\t\t\tconst adjustedCol = this.cols.adjustPosition(col, msg);\n\n\t\t\t\t\tconst rowHandle = adjustedRow.handle;\n\t\t\t\t\tconst colHandle = adjustedCol.handle;\n\n\t\t\t\t\tassert(\n\t\t\t\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t\t\t\t0x022 /* \"SharedMatrix row and/or col handles are invalid!\" */,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\t\t\t// If someone tried to Overwrite the cell value or first write on this cell or\n\t\t\t\t\t\t// same client tried to modify the cell or if the previous mode was LWW, then we need to still\n\t\t\t\t\t\t// overwrite the cell and raise conflict if we have pending changes as our change is going to be lost.\n\t\t\t\t\t\tif (this.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)) {\n\t\t\t\t\t\t\tconst previousValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (pendingCell !== undefined) {\n\t\t\t\t\t\t\t\tpendingCell.consensus = value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (adjustedRow.pos !== undefined && adjustedCol.pos !== undefined) {\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow.pos, adjustedCol.pos, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Check is there are any pending changes, which will be rejected. If so raise conflict.\n\t\t\t\t\t\t\t\tif (pendingCell !== undefined && pendingCell.local.length > 0) {\n\t\t\t\t\t\t\t\t\t// Don't reset the pending value yet, as there maybe more fww op from same client, so we want\n\t\t\t\t\t\t\t\t\t// to raise conflict event for that op also.\n\t\t\t\t\t\t\t\t\tthis.emit(\n\t\t\t\t\t\t\t\t\t\t\"conflict\",\n\t\t\t\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\t\t\t\tcol,\n\t\t\t\t\t\t\t\t\t\tvalue, // Current value\n\t\t\t\t\t\t\t\t\t\tpreviousValue, // Ignored local value\n\t\t\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (pendingCell === undefined || pendingCell.local.length === 0) {\n\t\t\t\t\t\t\t// If there is a pending (unACKed) local write to the same cell, skip the current op\n\t\t\t\t\t\t\t// since it \"happened before\" the pending write.\n\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\tif (adjustedRow.pos !== undefined && adjustedCol.pos !== undefined) {\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow.pos, adjustedCol.pos, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpendingCell.consensus = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(target, \"unknown target\");\n\t\t\t}\n\t\t}\n\t}\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of row insertion/deletions.\n\tprivate readonly onRowDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t): void => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.rowsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of col insertion/deletions.\n\tprivate readonly onColDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t): void => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.colsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\tprivate readonly onRowHandlesRecycled = (rowHandles: Handle[]): void => {\n\t\tfor (const rowHandle of rowHandles) {\n\t\t\tthis.cells.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tthis.pending.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker?.clearRows(\n\t\t\t\t\t/* rowStart: */ rowHandle,\n\t\t\t\t\t/* rowCount: */ 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate readonly onColHandlesRecycled = (colHandles: Handle[]): void => {\n\t\tfor (const colHandle of colHandles) {\n\t\t\tthis.cells.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tthis.pending.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker?.clearCols(\n\t\t\t\t\t/* colStart: */ colHandle,\n\t\t\t\t\t/* colCount: */ 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic switchSetCellPolicy(): void {\n\t\tif (this.fwwPolicy.state === \"off\") {\n\t\t\tthis.fwwPolicy = this.isAttached()\n\t\t\t\t? { state: \"local\" }\n\t\t\t\t: {\n\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\tswitchOpSeqNumber: 0,\n\t\t\t\t\t\tcellLastWriteTracker: new SparseArray2D(),\n\t\t\t\t\t};\n\t\t}\n\t}\n\n\tpublic toString(): string {\n\t\tlet s = `client:${\n\t\t\tthis.runtime.clientId\n\t\t}\\nrows: ${this.rows.toString()}\\ncols: ${this.cols.toString()}\\n\\n`;\n\n\t\tfor (let r = 0; r < this.rowCount; r++) {\n\t\t\ts += ` [`;\n\t\t\tfor (let c = 0; c < this.colCount; c++) {\n\t\t\t\tif (c > 0) {\n\t\t\t\t\ts += \", \";\n\t\t\t\t}\n\n\t\t\t\ts += `${this.serializer.stringify(this.getCell(r, c), this.handle)}`;\n\t\t\t}\n\t\t\ts += \"]\\n\";\n\t\t}\n\n\t\treturn `${s}\\n`;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(_content: unknown): void {\n\t\tconst content = _content as MatrixSetOrVectorOp<T>;\n\t\tif (content.type === MatrixOp.set && content.target === undefined) {\n\t\t\tif (content.fwwMode === true) {\n\t\t\t\tthis.switchSetCellPolicy();\n\t\t\t}\n\t\t\tthis.setCell(content.row, content.col, content.value);\n\t\t} else {\n\t\t\tconst vector = content.target === SnapshotPath.cols ? this.cols : this.rows;\n\t\t\tvector.applyStashedOp(content);\n\t\t\tif (content.target === SnapshotPath.cols) {\n\t\t\t\tthis.submitColMessage(content);\n\t\t\t} else {\n\t\t\t\tthis.submitRowMessage(content);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAOH,kEAA8E;AAQ9E,kEAS6C;AAO7C,qEAGgD;AAChD,0EAIqD;AACrD,uEAAsE;AAOtE,4EAAuC;AAGv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iBAAM,CAAC;gBACP,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAn/BD,oCAm/BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIEvent,\n\tIEventThisPlaceHolder,\n\tIEventProvider,\n} from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannel,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype Client,\n\ttype IJSONSegment,\n\ttype IMergeTreeOp,\n\ttype ISegmentInternal,\n\ttype LocalReferencePosition,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\tsegmentIsRemoved,\n} from \"@fluidframework/merge-tree/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tObjectStoragePartition,\n\tSummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\ttype ISharedObjectEvents,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type {\n\tIMatrixConsumer,\n\tIMatrixProducer,\n\tIMatrixReader,\n\tIMatrixWriter,\n} from \"@tiny-calc/nano\";\nimport Deque from \"double-ended-queue\";\n\nimport type { HandleCache } from \"./handlecache.js\";\nimport { type Handle, isHandleValid } from \"./handletable.js\";\nimport {\n\ttype ISetOp,\n\ttype MatrixItem,\n\tMatrixOp,\n\ttype MatrixSetOrVectorOp,\n\tSnapshotPath,\n\ttype VectorOp,\n} from \"./ops.js\";\nimport { PermutationVector, reinsertSegmentIntoVector } from \"./permutationvector.js\";\nimport { ensureRange } from \"./range.js\";\nimport { deserializeBlob } from \"./serialization.js\";\nimport { SparseArray2D, type RecurArray } from \"./sparsearray2d.js\";\nimport type { IUndoConsumer } from \"./types.js\";\nimport { MatrixUndoProvider } from \"./undoprovider.js\";\n\ninterface ISetOpMetadata {\n\trowHandle: Handle;\n\tcolHandle: Handle;\n\tlocalSeq: number;\n\trowsRef: LocalReferencePosition;\n\tcolsRef: LocalReferencePosition;\n\treferenceSeqNumber: number;\n}\n\n/**\n * Events emitted by Shared Matrix.\n * @legacy @beta\n */\nexport interface ISharedMatrixEvents<T> extends IEvent {\n\t/**\n\t * This event is only emitted when the SetCell Resolution Policy is First Write Win(FWW).\n\t * This is emitted when two clients race and send changes without observing each other changes,\n\t * the changes that gets sequenced last would be rejected, and only client who's changes rejected\n\t * would be notified via this event, with expectation that it will merge its changes back by\n\t * accounting new information (state from winner of the race).\n\t *\n\t * @remarks Listener parameters:\n\t *\n\t * - `row` - Row number at which conflict happened.\n\t *\n\t * - `col` - Col number at which conflict happened.\n\t *\n\t * - `currentValue` - The current value of the cell.\n\t *\n\t * - `conflictingValue` - The value that this client tried to set in the cell and got ignored due to conflict.\n\t *\n\t * - `target` - The {@link ISharedMatrix} itself.\n\t */\n\t(\n\t\tevent: \"conflict\",\n\t\tlistener: (\n\t\t\trow: number,\n\t\t\tcol: number,\n\t\t\tcurrentValue: MatrixItem<T>,\n\t\t\tconflictingValue: MatrixItem<T>,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t): void;\n}\n\n/**\n * This represents the item which is used to track the client which modified the cell last.\n */\ninterface CellLastWriteTrackerItem {\n\tseqNum: number; // Seq number of op which last modified this cell\n\tclientId: string; // clientId of the client which last modified this cell\n}\n\n/**\n * @legacy @beta\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition ISharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ISharedMatrix<T = any>\n\textends IEventProvider<ISharedMatrixEvents<T>>,\n\t\tIMatrixProducer<MatrixItem<T>>,\n\t\tIMatrixReader<MatrixItem<T>>,\n\t\tIMatrixWriter<MatrixItem<T>>,\n\t\tIChannel {\n\t/**\n\t * Inserts columns into the matrix.\n\t * @param colStart - Index of the first column to insert.\n\t * @param count - Number of columns to insert.\n\t * @remarks\n\t * Inserting 0 columns is a noop.\n\t */\n\tinsertCols(colStart: number, count: number): void;\n\t/**\n\t * Removes columns from the matrix.\n\t * @param colStart - Index of the first column to remove.\n\t * @param count - Number of columns to remove.\n\t * @remarks\n\t * Removing 0 columns is a noop.\n\t */\n\tremoveCols(colStart: number, count: number): void;\n\t/**\n\t * Inserts rows into the matrix.\n\t * @param rowStart - Index of the first row to insert.\n\t * @param count - Number of rows to insert.\n\t * @remarks\n\t * Inserting 0 rows is a noop.\n\t */\n\tinsertRows(rowStart: number, count: number): void;\n\t/**\n\t * Removes rows from the matrix.\n\t * @param rowStart - Index of the first row to remove.\n\t * @param count - Number of rows to remove.\n\t * @remarks\n\t * Removing 0 rows is a noop.\n\t */\n\tremoveRows(rowStart: number, count: number): void;\n\n\t/**\n\t * Sets a range of cells in the matrix.\n\t * Cells are set in consecutive columns between `colStart` and `colStart + colCount - 1`.\n\t * When `values` has larger size than `colCount`, the extra values are inserted in subsequent rows\n\t * a la text-wrapping.\n\t * @param rowStart - Index of the row to start setting cells.\n\t * @param colStart - Index of the column to start setting cells.\n\t * @param colCount - Number of columns to set before wrapping to subsequent rows (if `values` has more items)\n\t * @param values - Values to insert.\n\t * @remarks\n\t * This is not currently more efficient than calling `setCell` for each cell.\n\t */\n\tsetCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t): void;\n\n\t/**\n\t * Attach an {@link IUndoConsumer} to the matrix.\n\t * @param consumer - Undo consumer which will receive revertibles from the matrix.\n\t */\n\topenUndo(consumer: IUndoConsumer): void;\n\n\t/**\n\t * Whether the current conflict resolution policy is first-write win (FWW).\n\t * See {@link ISharedMatrix.switchSetCellPolicy} for more details.\n\t */\n\tisSetCellConflictResolutionPolicyFWW(): boolean;\n\n\t/**\n\t * Change the conflict resolution policy for setCell operations to first-write win (FWW).\n\t *\n\t * This API only switches from LWW to FWW and not from FWW to LWW.\n\t *\n\t * @privateRemarks\n\t * The next SetOp which is sent will communicate this policy to other clients.\n\t */\n\tswitchSetCellPolicy(): void;\n}\n\ntype FirstWriterWinsPolicy =\n\t| { state: \"off\" }\n\t| { state: \"local\" }\n\t| {\n\t\t\tstate: \"on\";\n\t\t\tswitchOpSeqNumber: number;\n\t\t\tcellLastWriteTracker: SparseArray2D<CellLastWriteTrackerItem>;\n\t };\n\n/**\n * Tracks pending local changes for a cell.\n */\ninterface PendingCellChanges<T> {\n\t/**\n\t * The local changes including the local seq, and the value set at that local seq.\n\t */\n\tlocal: { localSeq: number; value: MatrixItem<T> }[];\n\t/**\n\t * The latest consensus value across all clients.\n\t * this will either be a remote value or ack'd local\n\t * value.\n\t */\n\tconsensus?: MatrixItem<T>;\n}\n\n/**\n * A SharedMatrix holds a rectangular 2D array of values. Supported operations\n * include setting values and inserting/removing rows and columns.\n *\n * Matrix values may be any Fluid serializable type, which is the set of JSON\n * serializable types extended to include IFluidHandles.\n *\n * Fluid's SharedMatrix implementation works equally well for dense and sparse\n * matrix data and physically stores data in Z-order to leverage CPU caches and\n * prefetching when reading in either row or column major order. (See README.md\n * for more details.)\n * @legacy @beta\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition SharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class SharedMatrix<T = any>\n\textends SharedObject<ISharedMatrixEvents<T> & ISharedObjectEvents>\n\timplements ISharedMatrix<T>\n{\n\tprivate readonly consumers = new Set<IMatrixConsumer<MatrixItem<T>>>();\n\n\t/**\n\t * Note: this field only provides a lower-bound on the reference sequence numbers for in-flight ops.\n\t * The exact reason isn't understood, but some e2e tests suggest that the runtime may sometimes process\n\t * incoming leave/join ops before putting an op that this DDS submits over the wire.\n\t *\n\t * E.g. SharedMatrix submits an op while deltaManager has lastSequenceNumber = 10, but before the runtime\n\t * puts this op over the wire, it processes a client join/leave op with sequence number 11, so the referenceSequenceNumber\n\t * on the SharedMatrix op is 11.\n\t */\n\tprivate readonly inFlightRefSeqs = new Deque<number>();\n\treadonly getMinInFlightRefSeq = (): number | undefined => this.inFlightRefSeqs.get(0);\n\n\tprivate readonly rows: PermutationVector; // Map logical row to storage handle (if any)\n\tprivate readonly cols: PermutationVector; // Map logical col to storage handle (if any)\n\n\tprivate cells = new SparseArray2D<MatrixItem<T>>(); // Stores cell values.\n\tprivate readonly pending = new SparseArray2D<PendingCellChanges<T>>(); // Tracks pending writes.\n\n\tprivate fwwPolicy: FirstWriterWinsPolicy = {\n\t\tstate: \"off\",\n\t};\n\n\t// Used to track if there is any reentrancy in setCell code.\n\tprivate reentrantCount: number = 0;\n\n\t/**\n\t * Constructor for the Shared Matrix\n\t * @param runtime - DataStore runtime.\n\t * @param id - id of the dds\n\t * @param attributes - channel attributes\n\t * @param _isSetCellConflictResolutionPolicyFWW - Conflict resolution for Matrix set op is First Writer Win in case of\n\t * race condition. Client can still overwrite values in case of no race.\n\t */\n\tconstructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_matrix_\");\n\n\t\tthis.rows = new PermutationVector(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onRowDelta,\n\t\t\tthis.onRowHandlesRecycled,\n\t\t\tthis.getMinInFlightRefSeq,\n\t\t);\n\n\t\tthis.cols = new PermutationVector(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onColDelta,\n\t\t\tthis.onColHandlesRecycled,\n\t\t\tthis.getMinInFlightRefSeq,\n\t\t);\n\t}\n\n\tprivate undo?: MatrixUndoProvider<T>;\n\n\t/**\n\t * Subscribes the given IUndoConsumer to the matrix.\n\t */\n\tpublic openUndo(consumer: IUndoConsumer): void {\n\t\tassert(\n\t\t\tthis.undo === undefined,\n\t\t\t0x019 /* \"SharedMatrix.openUndo() supports at most a single IUndoConsumer.\" */,\n\t\t);\n\n\t\tthis.undo = new MatrixUndoProvider(consumer, this, this.rows, this.cols);\n\t}\n\n\t// TODO: closeUndo()?\n\n\tprivate get rowHandles(): HandleCache {\n\t\treturn this.rows.handleCache;\n\t}\n\tprivate get colHandles(): HandleCache {\n\t\treturn this.cols.handleCache;\n\t}\n\n\t// #region IMatrixProducer\n\n\topenMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): IMatrixReader<MatrixItem<T>> {\n\t\tthis.consumers.add(consumer);\n\t\treturn this;\n\t}\n\n\tcloseMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): void {\n\t\tthis.consumers.delete(consumer);\n\t}\n\n\t// #endregion IMatrixProducer\n\n\t// #region IMatrixReader\n\n\tpublic get rowCount(): number {\n\t\treturn this.rows.getLength();\n\t}\n\tpublic get colCount(): number {\n\t\treturn this.cols.getLength();\n\t}\n\n\tpublic isSetCellConflictResolutionPolicyFWW(): boolean {\n\t\treturn this.fwwPolicy.state !== \"off\";\n\t}\n\n\tpublic getCell(row: number, col: number): MatrixItem<T> {\n\t\t// Perf: When possible, bounds checking is performed inside the implementation for\n\t\t// 'getHandle()' so that it can be elided in the case of a cache hit. This\n\t\t// yields an ~40% improvement in the case of a cache hit (node v12 x64)\n\n\t\t// Map the logical (row, col) to associated storage handles.\n\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\tif (isHandleValid(rowHandle)) {\n\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\tif (isHandleValid(colHandle)) {\n\t\t\t\treturn this.cells.getCell(rowHandle, colHandle);\n\t\t\t}\n\t\t} else {\n\t\t\t// If we early exit because the given rowHandle is unallocated, we still need to\n\t\t\t// bounds-check the 'col' parameter.\n\t\t\tensureRange(col, this.cols.getLength());\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<MatrixItem<T>> {\n\t\treturn this;\n\t}\n\n\t// #endregion IMatrixReader\n\n\tpublic setCell(row: number, col: number, value: MatrixItem<T>): void {\n\t\tif (row < 0 || row >= this.rowCount || col < 0 || col >= this.colCount) {\n\t\t\tthrow new UsageError(\"Trying to set out-of-bounds cell.\");\n\t\t}\n\n\t\tthis.setCellCore(row, col, value);\n\t}\n\n\tpublic setCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t): void {\n\t\tconst rowCount = Math.ceil(values.length / colCount);\n\n\t\tassert(\n\t\t\t0 <= rowStart &&\n\t\t\t\trowStart < this.rowCount &&\n\t\t\t\t0 <= colStart &&\n\t\t\t\tcolStart < this.colCount &&\n\t\t\t\t1 <= colCount &&\n\t\t\t\tcolCount <= this.colCount - colStart &&\n\t\t\t\trowCount <= this.rowCount - rowStart,\n\t\t\t0x01b /* \"Trying to set multiple out-of-bounds cells!\" */,\n\t\t);\n\n\t\tconst endCol = colStart + colCount;\n\t\tlet r = rowStart;\n\t\tlet c = colStart;\n\n\t\tfor (const value of values) {\n\t\t\tthis.setCellCore(r, c, value);\n\n\t\t\tif (++c === endCol) {\n\t\t\t\tc = colStart;\n\t\t\t\tr++;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setCellCore(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle = this.rows.getAllocatedHandle(row),\n\t\tcolHandle = this.cols.getAllocatedHandle(col),\n\t\trollback?: boolean,\n\t): void {\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst oldValue = this.cells.getCell(rowHandle, colHandle) ?? undefined;\n\n\t\t\tif (this.undo !== undefined) {\n\t\t\t\tthis.undo.cellSet(rowHandle, colHandle, oldValue);\n\t\t\t}\n\n\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\n\t\t\tif (this.isAttached() && rollback !== true) {\n\t\t\t\tconst pending = this.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\tif (pending.local.length === 1) {\n\t\t\t\t\tpending.consensus ??= oldValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\tconsumer.cellsChanged(row, col, 1, 1, this);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate createOpMetadataLocalRef(\n\t\tvector: PermutationVector,\n\t\tpos: number,\n\t\tlocalSeq: number,\n\t): LocalReferencePosition {\n\t\tconst segoff = vector.getContainingSegment(pos, undefined, localSeq);\n\t\tassert(segoff !== undefined, 0x8b3 /* expected valid position */);\n\t\treturn vector.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\tReferenceType.StayOnRemove,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\tprivate sendSetCellOp(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tlocalSeq = this.nextLocalSeq(),\n\t): PendingCellChanges<T> {\n\t\tassert(\n\t\t\tthis.isAttached(),\n\t\t\t0x1e2 /* \"Caller must ensure 'isAttached()' before calling 'sendSetCellOp'.\" */,\n\t\t);\n\n\t\tconst op: ISetOp<T> = {\n\t\t\ttype: MatrixOp.set,\n\t\t\trow,\n\t\t\tcol,\n\t\t\tvalue,\n\t\t\tfwwMode: this.fwwPolicy.state !== \"off\",\n\t\t};\n\n\t\tconst rowsRef = this.createOpMetadataLocalRef(this.rows, row, localSeq);\n\t\tconst colsRef = this.createOpMetadataLocalRef(this.cols, col, localSeq);\n\t\tconst metadata: ISetOpMetadata = {\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t\tlocalSeq,\n\t\t\trowsRef,\n\t\t\tcolsRef,\n\t\t\treferenceSeqNumber: this.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, metadata);\n\t\tconst pendingCell: PendingCellChanges<T> = this.pending.getCell(rowHandle, colHandle) ?? {\n\t\t\tlocal: [],\n\t\t};\n\t\tpendingCell.local.push({ localSeq, value });\n\t\tthis.pending.setCell(rowHandle, colHandle, pendingCell);\n\t\treturn pendingCell;\n\t}\n\n\t/**\n\t * This makes sure that the code inside the callback is not reentrant. We need to do that because we raise notifications\n\t * to the consumers telling about these changes and they can try to change the matrix while listening to those notifications\n\t * which can make the shared matrix to be in bad state. For example, we are raising notification for a setCell changes and\n\t * a consumer tries to delete that row/col on receiving that notification which can lead to this matrix trying to setCell in\n\t * a deleted row/col.\n\t * @param callback - code that needs to protected against reentrancy.\n\t */\n\tprivate protectAgainstReentrancy(callback: () => void): void {\n\t\tif (this.reentrantCount !== 0) {\n\t\t\t// Validate that applications don't submit edits in response to matrix change notifications. This is unsupported.\n\t\t\tthrow new UsageError(\"Reentrancy detected in SharedMatrix.\");\n\t\t}\n\t\tthis.reentrantCount++;\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\tthis.reentrantCount--;\n\t\t}\n\t\tassert(\n\t\t\tthis.reentrantCount === 0,\n\t\t\t0x85e /* indicates a problem with the reentrancy tracking code. */,\n\t\t);\n\t}\n\n\tprivate submitVectorMessage(\n\t\tcurrentVector: PermutationVector,\n\t\toppositeVector: PermutationVector,\n\t\ttarget: SnapshotPath.rows | SnapshotPath.cols,\n\t\tmessage: IMergeTreeOp,\n\t): void {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally advance each MergeTree's 'localSeq' counter\n\t\t// for each submitted op it not aware of to keep them synchronized.\n\t\tconst localSeq = currentVector.getCollabWindow().localSeq;\n\t\tconst oppositeWindow = oppositeVector.getCollabWindow();\n\n\t\t// Note that the comparison is '>=' because, in the case the MergeTree is regenerating ops for reconnection,\n\t\t// the MergeTree submits the op with the original 'localSeq'.\n\t\tassert(\n\t\t\tlocalSeq >= oppositeWindow.localSeq,\n\t\t\t0x01c /* \"The 'localSeq' of the vector submitting an op must >= the 'localSeq' of the other vector.\" */,\n\t\t);\n\n\t\toppositeWindow.localSeq = localSeq;\n\n\t\t// If the SharedMatrix is local, it's state will be submitted via a Snapshot when initially connected.\n\t\t// Do not queue a message or track the pending op, as there will never be an ACK, etc.\n\t\tif (this.isAttached()) {\n\t\t\t// Record whether this `op` targets rows or cols. (See dispatch in `processCore()`)\n\t\t\tconst targetedMessage: VectorOp = { ...message, target };\n\n\t\t\tthis.submitLocalMessage(\n\t\t\t\ttargetedMessage,\n\t\t\t\tcurrentVector.peekPendingSegmentGroups(\n\t\t\t\t\tmessage.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate submitColMessage(message: IMergeTreeOp): void {\n\t\tthis.submitVectorMessage(this.cols, this.rows, SnapshotPath.cols, message);\n\t}\n\n\tpublic insertCols(colStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (colStart > this.colCount) {\n\t\t\tthrow new UsageError(\"insertCols: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst message = this.cols.insert(colStart, count);\n\t\t\tassert(message !== undefined, 0x8b4 /* must be defined */);\n\t\t\tthis.submitColMessage(message);\n\t\t});\n\t}\n\n\tpublic removeCols(colStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (colStart > this.colCount) {\n\t\t\tthrow new UsageError(\"removeCols: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() =>\n\t\t\tthis.submitColMessage(this.cols.remove(colStart, count)),\n\t\t);\n\t}\n\n\tprivate submitRowMessage(message: IMergeTreeOp): void {\n\t\tthis.submitVectorMessage(this.rows, this.cols, SnapshotPath.rows, message);\n\t}\n\n\tpublic insertRows(rowStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (rowStart > this.rowCount) {\n\t\t\tthrow new UsageError(\"insertRows: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst message = this.rows.insert(rowStart, count);\n\t\t\tassert(message !== undefined, 0x8b5 /* must be defined */);\n\t\t\tthis.submitRowMessage(message);\n\t\t});\n\t}\n\n\tpublic removeRows(rowStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (rowStart > this.rowCount) {\n\t\t\tthrow new UsageError(\"removeRows: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() =>\n\t\t\tthis.submitRowMessage(this.rows.remove(rowStart, count)),\n\t\t);\n\t}\n\n\tpublic _undoRemoveRows(rowStart: number, spec: IJSONSegment): void {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.rows, rowStart, spec);\n\t\tassert(op !== undefined, 0x8b6 /* must be defined */);\n\t\tthis.submitRowMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted rows.\n\t\tlet rowHandle = inserted.start;\n\t\tconst rowCount = inserted.cachedLength;\n\t\tfor (let row = rowStart; row < rowStart + rowCount; row++, rowHandle++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(rowStart, /* colStart: */ 0, rowCount, this.colCount, this);\n\t\t}\n\t}\n\n\t/***/ public _undoRemoveCols(colStart: number, spec: IJSONSegment): void {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.cols, colStart, spec);\n\t\tassert(op !== undefined, 0x8b7 /* must be defined */);\n\t\tthis.submitColMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted cols.\n\t\tlet colHandle = inserted.start;\n\t\tconst colCount = inserted.cachedLength;\n\t\tfor (let col = colStart; col < colStart + colCount; col++, colHandle++) {\n\t\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(/* rowStart: */ 0, colStart, this.rowCount, colCount, this);\n\t\t}\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.rows.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.cols.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tconst artifactsToSummarize: (\n\t\t\t| undefined\n\t\t\t| number\n\t\t\t| ReturnType<SparseArray2D<MatrixItem<T> | number>[\"snapshot\"]>\n\t\t)[] = [\n\t\t\tthis.cells.snapshot(),\n\t\t\t/**\n\t\t\t * we used to write this.pending.snapshot(). this should have never been done, as pending is only for local\n\t\t\t * changes, and there should never be local changes in the summarizer. This was also never used on load\n\t\t\t * as there is no way to understand a previous clients pending changes. so we just set this to a constant\n\t\t\t * which matches an empty this.pending.snapshot() for back-compat in terms of the array length\n\t\t\t */\n\t\t\t[undefined],\n\t\t];\n\n\t\t// Only need to store it in the snapshot if we have switched the policy already.\n\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\tartifactsToSummarize.push(\n\t\t\t\tthis.fwwPolicy.switchOpSeqNumber,\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.snapshot(),\n\t\t\t);\n\t\t} else {\n\t\t\t// back-compat: used -1 for disabled\n\t\t\tartifactsToSummarize.push(\n\t\t\t\t-1,\n\t\t\t\t/*\n\t\t\t\t * we should set undefined in place of cellLastWriteTracker to ensure the number of array entries is consistent.\n\t\t\t\t * Doing that currently breaks snapshot tests. Its is probably fine, but if new elements are ever added, we need\n\t\t\t\t * ensure undefined is also set.\n\t\t\t\t */\n\t\t\t\t// undefined\n\t\t\t);\n\t\t}\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.cells,\n\t\t\tserializer.stringify(artifactsToSummarize, this.handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Runs serializer on the GC data for this SharedMatrix.\n\t * All the IFluidHandle's stored in the cells represent routes to other objects.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer): void {\n\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tserializer.stringify(this.getCell(row, col), this.handle);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Advances the 'localSeq' counter for the cell data operation currently being queued.\n\t *\n\t * Do not use with 'submitColMessage()/submitRowMessage()' as these helpers + the MergeTree will\n\t * automatically advance 'localSeq'.\n\t */\n\tprivate nextLocalSeq(): number {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally bump each MergeTree's 'localSeq' counter\n\t\t// for SharedMatrix ops it's not aware of to keep them synchronized. (For cell data operations, we\n\t\t// need to bump both counters.)\n\n\t\tthis.cols.getCollabWindow().localSeq++;\n\t\treturn ++this.rows.getCollabWindow().localSeq;\n\t}\n\n\tprotected submitLocalMessage(message: unknown, localOpMetadata?: unknown): void {\n\t\t// TODO: Recommend moving this assertion into SharedObject\n\t\t// (See https://github.com/microsoft/FluidFramework/issues/2559)\n\t\tassert(\n\t\t\tthis.isAttached() === true,\n\t\t\t0x01d /* \"Trying to submit message to runtime while detached!\" */,\n\t\t);\n\n\t\tthis.inFlightRefSeqs.push(this.deltaManager.lastSequenceNumber);\n\t\tsuper.submitLocalMessage(message, localOpMetadata);\n\n\t\t// Ensure that row/col 'localSeq' are synchronized (see 'nextLocalSeq()').\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq,\n\t\t\t0x01e /* \"Row and col collab window 'localSeq' desynchronized!\" */,\n\t\t);\n\t}\n\n\tprotected didAttach(): void {\n\t\t// We've attached we need to start generating and sending ops.\n\t\t// so start collaboration and provide a default client id incase we are not connected\n\t\tif (this.isAttached()) {\n\t\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t}\n\t}\n\n\tprotected onConnect(): void {\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().collaborating === this.cols.getCollabWindow().collaborating,\n\t\t\t0x01f /* \"Row and col collab window 'collaborating' status desynchronized!\" */,\n\t\t);\n\n\t\t// Update merge tree collaboration information with new client ID and then resend pending ops\n\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t}\n\n\tprivate rebasePosition(\n\t\tclient: Client,\n\t\tref: LocalReferencePosition,\n\t\tlocalSeq: number,\n\t): number | undefined {\n\t\tconst segment: ISegmentInternal | undefined = ref.getSegment();\n\t\tconst offset = ref.getOffset();\n\t\t// If the segment that contains the position is removed, then this setCell op should do nothing.\n\t\tif (segment === undefined || offset === undefined || segmentIsRemoved(segment)) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn client.findReconnectionPosition(segment, localSeq) + offset;\n\t}\n\n\tprotected reSubmitCore(incoming: unknown, localOpMetadata: unknown): void {\n\t\tconst originalRefSeq = this.inFlightRefSeqs.shift();\n\t\tassert(\n\t\t\toriginalRefSeq !== undefined,\n\t\t\t0x8b9 /* Expected a recorded refSeq when resubmitting an op */,\n\t\t);\n\t\tconst content = incoming as MatrixSetOrVectorOp<T>;\n\n\t\tif (content.type === MatrixOp.set && content.target === undefined) {\n\t\t\tconst setOp = content;\n\t\t\tconst { rowHandle, colHandle, localSeq, rowsRef, colsRef, referenceSeqNumber } =\n\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\n\t\t\t// If after rebasing the op, we get a valid row/col number, that means the row/col\n\t\t\t// handles have not been recycled and we can safely use them.\n\t\t\tconst row = this.rebasePosition(this.rows, rowsRef, localSeq);\n\t\t\tconst col = this.rebasePosition(this.cols, colsRef, localSeq);\n\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\n\n\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\tassert(pendingCell !== undefined, 0xba4 /* local operation must have a pending array */);\n\t\t\tconst { local } = pendingCell;\n\t\t\tassert(local !== undefined, 0xba5 /* local operation must have a pending array */);\n\t\t\tconst localSeqIndex = local.findIndex((p) => p.localSeq === localSeq);\n\t\t\tassert(localSeqIndex >= 0, 0xba6 /* local operation must have a pending entry */);\n\t\t\tconst [change] = local.splice(localSeqIndex, 1);\n\t\t\tassert(change.localSeq === localSeq, 0xba7 /* must match */);\n\n\t\t\tif (\n\t\t\t\trow !== undefined &&\n\t\t\t\tcol !== undefined &&\n\t\t\t\trow >= 0 &&\n\t\t\t\tcol >= 0 && // If the mode is LWW, then send the op.\n\t\t\t\t// Otherwise if the current mode is FWW and if we generated this op, after seeing the\n\t\t\t\t// last set op, or it is the first set op for the cell, then regenerate the op,\n\t\t\t\t// otherwise raise conflict. We want to check the current mode here and not that\n\t\t\t\t// whether op was made in FWW or not.\n\t\t\t\t(this.fwwPolicy.state !== \"on\" ||\n\t\t\t\t\treferenceSeqNumber >=\n\t\t\t\t\t\t(this.fwwPolicy.cellLastWriteTracker.getCell(rowHandle, colHandle)?.seqNum ?? 0))\n\t\t\t) {\n\t\t\t\tthis.sendSetCellOp(row, col, setOp.value, rowHandle, colHandle, localSeq);\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (content.target) {\n\t\t\t\tcase SnapshotPath.cols: {\n\t\t\t\t\tthis.submitColMessage(\n\t\t\t\t\t\tthis.cols.regeneratePendingOp(content, localOpMetadata, false),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SnapshotPath.rows: {\n\t\t\t\t\tthis.submitRowMessage(\n\t\t\t\t\t\tthis.rows.regeneratePendingOp(content, localOpMetadata, false),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(content);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tconst contents = content as MatrixSetOrVectorOp<T>;\n\t\tconst target = contents.target;\n\n\t\tswitch (target) {\n\t\t\tcase SnapshotPath.cols: {\n\t\t\t\tthis.cols.rollback(content, localOpMetadata);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SnapshotPath.rows: {\n\t\t\t\tthis.rows.rollback(content, localOpMetadata);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase undefined: {\n\t\t\t\tassert(contents.type === MatrixOp.set, 0xba8 /* only sets supported */);\n\t\t\t\tconst setMetadata = localOpMetadata as ISetOpMetadata;\n\n\t\t\t\tconst pendingCell = this.pending.getCell(setMetadata.rowHandle, setMetadata.colHandle);\n\t\t\t\tassert(pendingCell !== undefined, 0xba9 /* must have pending */);\n\n\t\t\t\tconst change = pendingCell.local.pop();\n\t\t\t\tassert(change?.localSeq === setMetadata.localSeq, 0xbaa /* must have change */);\n\n\t\t\t\tconst previous =\n\t\t\t\t\tpendingCell.local.length > 0\n\t\t\t\t\t\t? pendingCell.local[pendingCell.local.length - 1].value\n\t\t\t\t\t\t: pendingCell.consensus;\n\n\t\t\t\tthis.setCellCore(\n\t\t\t\t\tcontents.row,\n\t\t\t\t\tcontents.col,\n\t\t\t\t\tprevious,\n\t\t\t\t\tsetMetadata.rowHandle,\n\t\t\t\t\tsetMetadata.colHandle,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\ttry {\n\t\t\tawait this.rows.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.rows),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tawait this.cols.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.cols),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tconst [\n\t\t\t\tcellData,\n\t\t\t\t_pendingCliSeqData,\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber,\n\t\t\t\tcellLastWriteTracker,\n\t\t\t\t// Cast is needed since the (de)serializer returns content of type `any`.\n\t\t\t] = (await deserializeBlob(storage, SnapshotPath.cells, this.serializer)) as [\n\t\t\t\tRecurArray<MatrixItem<T>>,\n\t\t\t\tunknown,\n\t\t\t\tnumber,\n\t\t\t\tRecurArray<CellLastWriteTrackerItem>,\n\t\t\t];\n\n\t\t\tthis.cells = SparseArray2D.load(cellData);\n\t\t\t// back-compat: used -1 for disabled, also may not exist\n\t\t\tconst switchOpSeqNumber =\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber === -1\n\t\t\t\t\t? undefined\n\t\t\t\t\t: (setCellLwwToFwwPolicySwitchOpSeqNumber ?? undefined);\n\t\t\tthis.fwwPolicy =\n\t\t\t\tswitchOpSeqNumber === undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstate: \"off\",\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\t\tswitchOpSeqNumber,\n\t\t\t\t\t\t\tcellLastWriteTracker: SparseArray2D.load(cellLastWriteTracker),\n\t\t\t\t\t\t};\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"MatrixLoadFailed\" }, error);\n\t\t}\n\t}\n\n\t/**\n\t * Tells whether the setCell op should be applied or not based on First Write Win policy. It assumes\n\t * we are in FWW mode.\n\t */\n\tprivate shouldSetCellBasedOnFWW(\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tmessage: ISequencedDocumentMessage,\n\t): boolean {\n\t\tassert(\n\t\t\tthis.fwwPolicy.state === \"on\",\n\t\t\t0x85f /* should be in Fww mode when calling this method */,\n\t\t);\n\t\tassert(message.clientId !== null, 0x860 /* clientId should not be null */);\n\t\tconst lastCellModificationDetails = this.fwwPolicy.cellLastWriteTracker.getCell(\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t);\n\t\t// If someone tried to Overwrite the cell value or first write on this cell or\n\t\t// same client tried to modify the cell.\n\t\treturn (\n\t\t\tlastCellModificationDetails === undefined ||\n\t\t\tlastCellModificationDetails.clientId === message.clientId ||\n\t\t\tmessage.referenceSequenceNumber >= lastCellModificationDetails.seqNum\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// Reconstruct the ISequencedDocumentMessage which is needed by merge tree client.\n\t\tconst msg: ISequencedDocumentMessage = {\n\t\t\t...messageEnvelope,\n\t\t\tcontents: messageContent.contents,\n\t\t\tclientSequenceNumber: messageContent.clientSequenceNumber,\n\t\t};\n\t\tconst localOpMetadata = messageContent.localOpMetadata;\n\t\tif (local) {\n\t\t\tconst recordedRefSeq = this.inFlightRefSeqs.shift();\n\t\t\tassert(recordedRefSeq !== undefined, 0x8ba /* No pending recorded refSeq found */);\n\t\t\t// TODO: AB#7076: Some equivalent assert should be enabled. This fails some e2e stashed op tests because\n\t\t\t// the deltaManager may have seen more messages than the runtime has processed while amidst the stashed op\n\t\t\t// flow, so e.g. when `applyStashedOp` is called and the DDS is put in a state where it expects an ack for\n\t\t\t// one of its messages, the delta manager has actually already seen subsequent messages from collaborators\n\t\t\t// which the in-flight message is concurrent to.\n\t\t\t// See \"handles stashed ops created on top of sequenced local ops\" for one such test case.\n\t\t\t// assert(recordedRefSeq <= message.referenceSequenceNumber, \"RefSeq mismatch\");\n\t\t}\n\n\t\tconst contents = messageContent.contents as MatrixSetOrVectorOp<T>;\n\t\tconst target = contents.target;\n\n\t\tswitch (target) {\n\t\t\tcase SnapshotPath.cols: {\n\t\t\t\tthis.cols.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SnapshotPath.rows: {\n\t\t\t\tthis.rows.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase undefined: {\n\t\t\t\tassert(\n\t\t\t\t\tcontents.type === MatrixOp.set,\n\t\t\t\t\t0x021 /* \"SharedMatrix message contents have unexpected type!\" */,\n\t\t\t\t);\n\n\t\t\t\tconst { row, col, value, fwwMode } = contents;\n\t\t\t\t// If this is the first op notifying us of the policy change, then set the policy change seq number.\n\t\t\t\tif (fwwMode === true && this.fwwPolicy.state !== \"on\") {\n\t\t\t\t\tthis.fwwPolicy = {\n\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\tswitchOpSeqNumber: msg.sequenceNumber,\n\t\t\t\t\t\tcellLastWriteTracker: new SparseArray2D(),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tassert(msg.clientId !== null, 0x861 /* clientId should not be null!! */);\n\t\t\t\tif (local) {\n\t\t\t\t\t// We are receiving the ACK for a local pending set operation.\n\t\t\t\t\tconst { rowHandle, colHandle, localSeq, rowsRef, colsRef } =\n\t\t\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\t\t\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\n\n\t\t\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\t\t\tconst ackedChange = pendingCell?.local.shift();\n\t\t\t\t\tassert(ackedChange?.localSeq === localSeq, 0xbab /* must match */);\n\t\t\t\t\tif (pendingCell?.local.length === 0) {\n\t\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If policy is switched and cell should be modified too based on policy, then update the tracker.\n\t\t\t\t\t// If policy is not switched, then also update the tracker in case it is the latest.\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.fwwPolicy.state === \"on\" &&\n\t\t\t\t\t\tthis.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tpendingCell!.consensus = ackedChange.value;\n\t\t\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst adjustedRow = this.rows.adjustPosition(row, msg);\n\t\t\t\t\tconst adjustedCol = this.cols.adjustPosition(col, msg);\n\n\t\t\t\t\tconst rowHandle = adjustedRow.handle;\n\t\t\t\t\tconst colHandle = adjustedCol.handle;\n\n\t\t\t\t\tassert(\n\t\t\t\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t\t\t\t0x022 /* \"SharedMatrix row and/or col handles are invalid!\" */,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\t\t\t// If someone tried to Overwrite the cell value or first write on this cell or\n\t\t\t\t\t\t// same client tried to modify the cell or if the previous mode was LWW, then we need to still\n\t\t\t\t\t\t// overwrite the cell and raise conflict if we have pending changes as our change is going to be lost.\n\t\t\t\t\t\tif (this.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)) {\n\t\t\t\t\t\t\tconst previousValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (pendingCell !== undefined) {\n\t\t\t\t\t\t\t\tpendingCell.consensus = value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (adjustedRow.pos !== undefined && adjustedCol.pos !== undefined) {\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow.pos, adjustedCol.pos, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Check is there are any pending changes, which will be rejected. If so raise conflict.\n\t\t\t\t\t\t\t\tif (pendingCell !== undefined && pendingCell.local.length > 0) {\n\t\t\t\t\t\t\t\t\t// Don't reset the pending value yet, as there maybe more fww op from same client, so we want\n\t\t\t\t\t\t\t\t\t// to raise conflict event for that op also.\n\t\t\t\t\t\t\t\t\tthis.emit(\n\t\t\t\t\t\t\t\t\t\t\"conflict\",\n\t\t\t\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\t\t\t\tcol,\n\t\t\t\t\t\t\t\t\t\tvalue, // Current value\n\t\t\t\t\t\t\t\t\t\tpreviousValue, // Ignored local value\n\t\t\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (pendingCell === undefined || pendingCell.local.length === 0) {\n\t\t\t\t\t\t\t// If there is a pending (unACKed) local write to the same cell, skip the current op\n\t\t\t\t\t\t\t// since it \"happened before\" the pending write.\n\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\tif (adjustedRow.pos !== undefined && adjustedCol.pos !== undefined) {\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow.pos, adjustedCol.pos, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpendingCell.consensus = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(target, \"unknown target\");\n\t\t\t}\n\t\t}\n\t}\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of row insertion/deletions.\n\tprivate readonly onRowDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t): void => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.rowsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of col insertion/deletions.\n\tprivate readonly onColDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t): void => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.colsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\tprivate readonly onRowHandlesRecycled = (rowHandles: Handle[]): void => {\n\t\tfor (const rowHandle of rowHandles) {\n\t\t\tthis.cells.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tthis.pending.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker?.clearRows(\n\t\t\t\t\t/* rowStart: */ rowHandle,\n\t\t\t\t\t/* rowCount: */ 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate readonly onColHandlesRecycled = (colHandles: Handle[]): void => {\n\t\tfor (const colHandle of colHandles) {\n\t\t\tthis.cells.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tthis.pending.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker?.clearCols(\n\t\t\t\t\t/* colStart: */ colHandle,\n\t\t\t\t\t/* colCount: */ 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic switchSetCellPolicy(): void {\n\t\tif (this.fwwPolicy.state === \"off\") {\n\t\t\tthis.fwwPolicy = this.isAttached()\n\t\t\t\t? { state: \"local\" }\n\t\t\t\t: {\n\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\tswitchOpSeqNumber: 0,\n\t\t\t\t\t\tcellLastWriteTracker: new SparseArray2D(),\n\t\t\t\t\t};\n\t\t}\n\t}\n\n\tpublic toString(): string {\n\t\tlet s = `client:${\n\t\t\tthis.runtime.clientId\n\t\t}\\nrows: ${this.rows.toString()}\\ncols: ${this.cols.toString()}\\n\\n`;\n\n\t\tfor (let r = 0; r < this.rowCount; r++) {\n\t\t\ts += ` [`;\n\t\t\tfor (let c = 0; c < this.colCount; c++) {\n\t\t\t\tif (c > 0) {\n\t\t\t\t\ts += \", \";\n\t\t\t\t}\n\n\t\t\t\ts += `${this.serializer.stringify(this.getCell(r, c), this.handle)}`;\n\t\t\t}\n\t\t\ts += \"]\\n\";\n\t\t}\n\n\t\treturn `${s}\\n`;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(_content: unknown): void {\n\t\tconst content = _content as MatrixSetOrVectorOp<T>;\n\t\tif (content.type === MatrixOp.set && content.target === undefined) {\n\t\t\tif (content.fwwMode === true) {\n\t\t\t\tthis.switchSetCellPolicy();\n\t\t\t}\n\t\t\tthis.setCell(content.row, content.col, content.value);\n\t\t} else {\n\t\t\tconst vector = content.target === SnapshotPath.cols ? this.cols : this.rows;\n\t\t\tvector.applyStashedOp(content);\n\t\t\tif (content.target === SnapshotPath.cols) {\n\t\t\t\tthis.submitColMessage(content);\n\t\t\t} else {\n\t\t\t\tthis.submitRowMessage(content);\n\t\t\t}\n\t\t}\n\t}\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.70.0-361248";
8
+ export declare const pkgVersion = "2.70.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,kBAAkB,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,WAAW,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 = "2.70.0-361248";
11
+ exports.pkgVersion = "2.70.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,eAAe,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.70.0-361248\";\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,QAAQ,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.70.0\";\n"]}
package/lib/matrix.d.ts CHANGED
@@ -4,9 +4,8 @@
4
4
  */
5
5
  import type { IEvent, IEventThisPlaceHolder, IEventProvider } from "@fluidframework/core-interfaces";
6
6
  import type { IChannelAttributes, IFluidDataStoreRuntime, IChannel, IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
7
- import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
8
7
  import { type IJSONSegment } from "@fluidframework/merge-tree/internal";
9
- import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
8
+ import type { ISummaryTreeWithStats, IRuntimeMessageCollection } from "@fluidframework/runtime-definitions/internal";
10
9
  import { type IFluidSerializer, type ISharedObjectEvents, SharedObject } from "@fluidframework/shared-object-base/internal";
11
10
  import type { IMatrixConsumer, IMatrixProducer, IMatrixReader, IMatrixWriter } from "@tiny-calc/nano";
12
11
  import { type MatrixItem } from "./ops.js";
@@ -214,7 +213,11 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
214
213
  * we are in FWW mode.
215
214
  */
216
215
  private shouldSetCellBasedOnFWW;
217
- protected processCore(msg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
216
+ /**
217
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}
218
+ */
219
+ protected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void;
220
+ private processMessage;
218
221
  private readonly onRowDelta;
219
222
  private readonly onColDelta;
220
223
  private readonly onRowHandlesRecycled;
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,MAAM,EACN,qBAAqB,EACrB,cAAc,EACd,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,EACR,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO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,EAAE,OAAO,GAAG,IAAI;IAkB/E,SAAS,CAAC,SAAS,IAAI,IAAI;IAS3B,SAAS,CAAC,SAAS,IAAI,IAAI;IAW3B,OAAO,CAAC,cAAc;IAetB,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAiEzE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAyCpE,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8CxE;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAuB/B;;OAEG;IACH,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,IAAI;IAOlF,OAAO,CAAC,cAAc;IAqJtB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAQzB;IAGF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAQzB;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAWnC;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAWnC;IAEK,mBAAmB,IAAI,IAAI;IAY3B,QAAQ,IAAI,MAAM;IAoBzB;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;CAiBjD"}
package/lib/matrix.js CHANGED
@@ -569,7 +569,23 @@ export class SharedMatrix extends SharedObject {
569
569
  lastCellModificationDetails.clientId === message.clientId ||
570
570
  message.referenceSequenceNumber >= lastCellModificationDetails.seqNum);
571
571
  }
572
- processCore(msg, local, localOpMetadata) {
572
+ /**
573
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}
574
+ */
575
+ processMessagesCore(messagesCollection) {
576
+ const { envelope, local, messagesContent } = messagesCollection;
577
+ for (const messageContent of messagesContent) {
578
+ this.processMessage(envelope, messageContent, local);
579
+ }
580
+ }
581
+ processMessage(messageEnvelope, messageContent, local) {
582
+ // Reconstruct the ISequencedDocumentMessage which is needed by merge tree client.
583
+ const msg = {
584
+ ...messageEnvelope,
585
+ contents: messageContent.contents,
586
+ clientSequenceNumber: messageContent.clientSequenceNumber,
587
+ };
588
+ const localOpMetadata = messageContent.localOpMetadata;
573
589
  if (local) {
574
590
  const recordedRefSeq = this.inFlightRefSeqs.shift();
575
591
  assert(recordedRefSeq !== undefined, 0x8ba /* No pending recorded refSeq found */);
@@ -581,7 +597,7 @@ export class SharedMatrix extends SharedObject {
581
597
  // See "handles stashed ops created on top of sequenced local ops" for one such test case.
582
598
  // assert(recordedRefSeq <= message.referenceSequenceNumber, "RefSeq mismatch");
583
599
  }
584
- const contents = msg.contents;
600
+ const contents = messageContent.contents;
585
601
  const target = contents.target;
586
602
  switch (target) {
587
603
  case SnapshotPath.cols: {
package/lib/matrix.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAQ9E,OAAO,EAMN,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GAChB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACN,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAGN,YAAY,GACZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAOtE,OAAO,KAAK,MAAM,oBAAoB,CAAC;AAGvC,OAAO,EAAe,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAGN,QAAQ,EAER,YAAY,GAEZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,W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AO,KAAK,IAAI,EAAE,CAAC;gBAC9B,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC5B,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5E,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAC/B,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,CAAC,IAAI,EAAE,CAAC;gBAC1C,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIEvent,\n\tIEventThisPlaceHolder,\n\tIEventProvider,\n} from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannel,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype Client,\n\ttype IJSONSegment,\n\ttype IMergeTreeOp,\n\ttype ISegmentInternal,\n\ttype LocalReferencePosition,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\tsegmentIsRemoved,\n} from \"@fluidframework/merge-tree/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tObjectStoragePartition,\n\tSummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\ttype ISharedObjectEvents,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type {\n\tIMatrixConsumer,\n\tIMatrixProducer,\n\tIMatrixReader,\n\tIMatrixWriter,\n} from \"@tiny-calc/nano\";\nimport Deque from \"double-ended-queue\";\n\nimport type { HandleCache } from \"./handlecache.js\";\nimport { type Handle, isHandleValid } from \"./handletable.js\";\nimport {\n\ttype ISetOp,\n\ttype MatrixItem,\n\tMatrixOp,\n\ttype MatrixSetOrVectorOp,\n\tSnapshotPath,\n\ttype VectorOp,\n} from \"./ops.js\";\nimport { PermutationVector, reinsertSegmentIntoVector } from \"./permutationvector.js\";\nimport { ensureRange } from \"./range.js\";\nimport { deserializeBlob } from \"./serialization.js\";\nimport { SparseArray2D, type RecurArray } from \"./sparsearray2d.js\";\nimport type { IUndoConsumer } from \"./types.js\";\nimport { MatrixUndoProvider } from \"./undoprovider.js\";\n\ninterface ISetOpMetadata {\n\trowHandle: Handle;\n\tcolHandle: Handle;\n\tlocalSeq: number;\n\trowsRef: LocalReferencePosition;\n\tcolsRef: LocalReferencePosition;\n\treferenceSeqNumber: number;\n}\n\n/**\n * Events emitted by Shared Matrix.\n * @legacy @beta\n */\nexport interface ISharedMatrixEvents<T> extends IEvent {\n\t/**\n\t * This event is only emitted when the SetCell Resolution Policy is First Write Win(FWW).\n\t * This is emitted when two clients race and send changes without observing each other changes,\n\t * the changes that gets sequenced last would be rejected, and only client who's changes rejected\n\t * would be notified via this event, with expectation that it will merge its changes back by\n\t * accounting new information (state from winner of the race).\n\t *\n\t * @remarks Listener parameters:\n\t *\n\t * - `row` - Row number at which conflict happened.\n\t *\n\t * - `col` - Col number at which conflict happened.\n\t *\n\t * - `currentValue` - The current value of the cell.\n\t *\n\t * - `conflictingValue` - The value that this client tried to set in the cell and got ignored due to conflict.\n\t *\n\t * - `target` - The {@link ISharedMatrix} itself.\n\t */\n\t(\n\t\tevent: \"conflict\",\n\t\tlistener: (\n\t\t\trow: number,\n\t\t\tcol: number,\n\t\t\tcurrentValue: MatrixItem<T>,\n\t\t\tconflictingValue: MatrixItem<T>,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t): void;\n}\n\n/**\n * This represents the item which is used to track the client which modified the cell last.\n */\ninterface CellLastWriteTrackerItem {\n\tseqNum: number; // Seq number of op which last modified this cell\n\tclientId: string; // clientId of the client which last modified this cell\n}\n\n/**\n * @legacy @beta\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition ISharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ISharedMatrix<T = any>\n\textends IEventProvider<ISharedMatrixEvents<T>>,\n\t\tIMatrixProducer<MatrixItem<T>>,\n\t\tIMatrixReader<MatrixItem<T>>,\n\t\tIMatrixWriter<MatrixItem<T>>,\n\t\tIChannel {\n\t/**\n\t * Inserts columns into the matrix.\n\t * @param colStart - Index of the first column to insert.\n\t * @param count - Number of columns to insert.\n\t * @remarks\n\t * Inserting 0 columns is a noop.\n\t */\n\tinsertCols(colStart: number, count: number): void;\n\t/**\n\t * Removes columns from the matrix.\n\t * @param colStart - Index of the first column to remove.\n\t * @param count - Number of columns to remove.\n\t * @remarks\n\t * Removing 0 columns is a noop.\n\t */\n\tremoveCols(colStart: number, count: number): void;\n\t/**\n\t * Inserts rows into the matrix.\n\t * @param rowStart - Index of the first row to insert.\n\t * @param count - Number of rows to insert.\n\t * @remarks\n\t * Inserting 0 rows is a noop.\n\t */\n\tinsertRows(rowStart: number, count: number): void;\n\t/**\n\t * Removes rows from the matrix.\n\t * @param rowStart - Index of the first row to remove.\n\t * @param count - Number of rows to remove.\n\t * @remarks\n\t * Removing 0 rows is a noop.\n\t */\n\tremoveRows(rowStart: number, count: number): void;\n\n\t/**\n\t * Sets a range of cells in the matrix.\n\t * Cells are set in consecutive columns between `colStart` and `colStart + colCount - 1`.\n\t * When `values` has larger size than `colCount`, the extra values are inserted in subsequent rows\n\t * a la text-wrapping.\n\t * @param rowStart - Index of the row to start setting cells.\n\t * @param colStart - Index of the column to start setting cells.\n\t * @param colCount - Number of columns to set before wrapping to subsequent rows (if `values` has more items)\n\t * @param values - Values to insert.\n\t * @remarks\n\t * This is not currently more efficient than calling `setCell` for each cell.\n\t */\n\tsetCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t): void;\n\n\t/**\n\t * Attach an {@link IUndoConsumer} to the matrix.\n\t * @param consumer - Undo consumer which will receive revertibles from the matrix.\n\t */\n\topenUndo(consumer: IUndoConsumer): void;\n\n\t/**\n\t * Whether the current conflict resolution policy is first-write win (FWW).\n\t * See {@link ISharedMatrix.switchSetCellPolicy} for more details.\n\t */\n\tisSetCellConflictResolutionPolicyFWW(): boolean;\n\n\t/**\n\t * Change the conflict resolution policy for setCell operations to first-write win (FWW).\n\t *\n\t * This API only switches from LWW to FWW and not from FWW to LWW.\n\t *\n\t * @privateRemarks\n\t * The next SetOp which is sent will communicate this policy to other clients.\n\t */\n\tswitchSetCellPolicy(): void;\n}\n\ntype FirstWriterWinsPolicy =\n\t| { state: \"off\" }\n\t| { state: \"local\" }\n\t| {\n\t\t\tstate: \"on\";\n\t\t\tswitchOpSeqNumber: number;\n\t\t\tcellLastWriteTracker: SparseArray2D<CellLastWriteTrackerItem>;\n\t };\n\n/**\n * Tracks pending local changes for a cell.\n */\ninterface PendingCellChanges<T> {\n\t/**\n\t * The local changes including the local seq, and the value set at that local seq.\n\t */\n\tlocal: { localSeq: number; value: MatrixItem<T> }[];\n\t/**\n\t * The latest consensus value across all clients.\n\t * this will either be a remote value or ack'd local\n\t * value.\n\t */\n\tconsensus?: MatrixItem<T>;\n}\n\n/**\n * A SharedMatrix holds a rectangular 2D array of values. Supported operations\n * include setting values and inserting/removing rows and columns.\n *\n * Matrix values may be any Fluid serializable type, which is the set of JSON\n * serializable types extended to include IFluidHandles.\n *\n * Fluid's SharedMatrix implementation works equally well for dense and sparse\n * matrix data and physically stores data in Z-order to leverage CPU caches and\n * prefetching when reading in either row or column major order. (See README.md\n * for more details.)\n * @legacy @beta\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition SharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class SharedMatrix<T = any>\n\textends SharedObject<ISharedMatrixEvents<T> & ISharedObjectEvents>\n\timplements ISharedMatrix<T>\n{\n\tprivate readonly consumers = new Set<IMatrixConsumer<MatrixItem<T>>>();\n\n\t/**\n\t * Note: this field only provides a lower-bound on the reference sequence numbers for in-flight ops.\n\t * The exact reason isn't understood, but some e2e tests suggest that the runtime may sometimes process\n\t * incoming leave/join ops before putting an op that this DDS submits over the wire.\n\t *\n\t * E.g. SharedMatrix submits an op while deltaManager has lastSequenceNumber = 10, but before the runtime\n\t * puts this op over the wire, it processes a client join/leave op with sequence number 11, so the referenceSequenceNumber\n\t * on the SharedMatrix op is 11.\n\t */\n\tprivate readonly inFlightRefSeqs = new Deque<number>();\n\treadonly getMinInFlightRefSeq = (): number | undefined => this.inFlightRefSeqs.get(0);\n\n\tprivate readonly rows: PermutationVector; // Map logical row to storage handle (if any)\n\tprivate readonly cols: PermutationVector; // Map logical col to storage handle (if any)\n\n\tprivate cells = new SparseArray2D<MatrixItem<T>>(); // Stores cell values.\n\tprivate readonly pending = new SparseArray2D<PendingCellChanges<T>>(); // Tracks pending writes.\n\n\tprivate fwwPolicy: FirstWriterWinsPolicy = {\n\t\tstate: \"off\",\n\t};\n\n\t// Used to track if there is any reentrancy in setCell code.\n\tprivate reentrantCount: number = 0;\n\n\t/**\n\t * Constructor for the Shared Matrix\n\t * @param runtime - DataStore runtime.\n\t * @param id - id of the dds\n\t * @param attributes - channel attributes\n\t * @param _isSetCellConflictResolutionPolicyFWW - Conflict resolution for Matrix set op is First Writer Win in case of\n\t * race condition. Client can still overwrite values in case of no race.\n\t */\n\tconstructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_matrix_\");\n\n\t\tthis.rows = new PermutationVector(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onRowDelta,\n\t\t\tthis.onRowHandlesRecycled,\n\t\t\tthis.getMinInFlightRefSeq,\n\t\t);\n\n\t\tthis.cols = new PermutationVector(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onColDelta,\n\t\t\tthis.onColHandlesRecycled,\n\t\t\tthis.getMinInFlightRefSeq,\n\t\t);\n\t}\n\n\tprivate undo?: MatrixUndoProvider<T>;\n\n\t/**\n\t * Subscribes the given IUndoConsumer to the matrix.\n\t */\n\tpublic openUndo(consumer: IUndoConsumer): void {\n\t\tassert(\n\t\t\tthis.undo === undefined,\n\t\t\t0x019 /* \"SharedMatrix.openUndo() supports at most a single IUndoConsumer.\" */,\n\t\t);\n\n\t\tthis.undo = new MatrixUndoProvider(consumer, this, this.rows, this.cols);\n\t}\n\n\t// TODO: closeUndo()?\n\n\tprivate get rowHandles(): HandleCache {\n\t\treturn this.rows.handleCache;\n\t}\n\tprivate get colHandles(): HandleCache {\n\t\treturn this.cols.handleCache;\n\t}\n\n\t// #region IMatrixProducer\n\n\topenMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): IMatrixReader<MatrixItem<T>> {\n\t\tthis.consumers.add(consumer);\n\t\treturn this;\n\t}\n\n\tcloseMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): void {\n\t\tthis.consumers.delete(consumer);\n\t}\n\n\t// #endregion IMatrixProducer\n\n\t// #region IMatrixReader\n\n\tpublic get rowCount(): number {\n\t\treturn this.rows.getLength();\n\t}\n\tpublic get colCount(): number {\n\t\treturn this.cols.getLength();\n\t}\n\n\tpublic isSetCellConflictResolutionPolicyFWW(): boolean {\n\t\treturn this.fwwPolicy.state !== \"off\";\n\t}\n\n\tpublic getCell(row: number, col: number): MatrixItem<T> {\n\t\t// Perf: When possible, bounds checking is performed inside the implementation for\n\t\t// 'getHandle()' so that it can be elided in the case of a cache hit. This\n\t\t// yields an ~40% improvement in the case of a cache hit (node v12 x64)\n\n\t\t// Map the logical (row, col) to associated storage handles.\n\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\tif (isHandleValid(rowHandle)) {\n\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\tif (isHandleValid(colHandle)) {\n\t\t\t\treturn this.cells.getCell(rowHandle, colHandle);\n\t\t\t}\n\t\t} else {\n\t\t\t// If we early exit because the given rowHandle is unallocated, we still need to\n\t\t\t// bounds-check the 'col' parameter.\n\t\t\tensureRange(col, this.cols.getLength());\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<MatrixItem<T>> {\n\t\treturn this;\n\t}\n\n\t// #endregion IMatrixReader\n\n\tpublic setCell(row: number, col: number, value: MatrixItem<T>): void {\n\t\tif (row < 0 || row >= this.rowCount || col < 0 || col >= this.colCount) {\n\t\t\tthrow new UsageError(\"Trying to set out-of-bounds cell.\");\n\t\t}\n\n\t\tthis.setCellCore(row, col, value);\n\t}\n\n\tpublic setCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t): void {\n\t\tconst rowCount = Math.ceil(values.length / colCount);\n\n\t\tassert(\n\t\t\t0 <= rowStart &&\n\t\t\t\trowStart < this.rowCount &&\n\t\t\t\t0 <= colStart &&\n\t\t\t\tcolStart < this.colCount &&\n\t\t\t\t1 <= colCount &&\n\t\t\t\tcolCount <= this.colCount - colStart &&\n\t\t\t\trowCount <= this.rowCount - rowStart,\n\t\t\t0x01b /* \"Trying to set multiple out-of-bounds cells!\" */,\n\t\t);\n\n\t\tconst endCol = colStart + colCount;\n\t\tlet r = rowStart;\n\t\tlet c = colStart;\n\n\t\tfor (const value of values) {\n\t\t\tthis.setCellCore(r, c, value);\n\n\t\t\tif (++c === endCol) {\n\t\t\t\tc = colStart;\n\t\t\t\tr++;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setCellCore(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle = this.rows.getAllocatedHandle(row),\n\t\tcolHandle = this.cols.getAllocatedHandle(col),\n\t\trollback?: boolean,\n\t): void {\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst oldValue = this.cells.getCell(rowHandle, colHandle) ?? undefined;\n\n\t\t\tif (this.undo !== undefined) {\n\t\t\t\tthis.undo.cellSet(rowHandle, colHandle, oldValue);\n\t\t\t}\n\n\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\n\t\t\tif (this.isAttached() && rollback !== true) {\n\t\t\t\tconst pending = this.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\tif (pending.local.length === 1) {\n\t\t\t\t\tpending.consensus ??= oldValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\tconsumer.cellsChanged(row, col, 1, 1, this);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate createOpMetadataLocalRef(\n\t\tvector: PermutationVector,\n\t\tpos: number,\n\t\tlocalSeq: number,\n\t): LocalReferencePosition {\n\t\tconst segoff = vector.getContainingSegment(pos, undefined, localSeq);\n\t\tassert(segoff !== undefined, 0x8b3 /* expected valid position */);\n\t\treturn vector.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\tReferenceType.StayOnRemove,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\tprivate sendSetCellOp(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tlocalSeq = this.nextLocalSeq(),\n\t): PendingCellChanges<T> {\n\t\tassert(\n\t\t\tthis.isAttached(),\n\t\t\t0x1e2 /* \"Caller must ensure 'isAttached()' before calling 'sendSetCellOp'.\" */,\n\t\t);\n\n\t\tconst op: ISetOp<T> = {\n\t\t\ttype: MatrixOp.set,\n\t\t\trow,\n\t\t\tcol,\n\t\t\tvalue,\n\t\t\tfwwMode: this.fwwPolicy.state !== \"off\",\n\t\t};\n\n\t\tconst rowsRef = this.createOpMetadataLocalRef(this.rows, row, localSeq);\n\t\tconst colsRef = this.createOpMetadataLocalRef(this.cols, col, localSeq);\n\t\tconst metadata: ISetOpMetadata = {\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t\tlocalSeq,\n\t\t\trowsRef,\n\t\t\tcolsRef,\n\t\t\treferenceSeqNumber: this.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, metadata);\n\t\tconst pendingCell: PendingCellChanges<T> = this.pending.getCell(rowHandle, colHandle) ?? {\n\t\t\tlocal: [],\n\t\t};\n\t\tpendingCell.local.push({ localSeq, value });\n\t\tthis.pending.setCell(rowHandle, colHandle, pendingCell);\n\t\treturn pendingCell;\n\t}\n\n\t/**\n\t * This makes sure that the code inside the callback is not reentrant. We need to do that because we raise notifications\n\t * to the consumers telling about these changes and they can try to change the matrix while listening to those notifications\n\t * which can make the shared matrix to be in bad state. For example, we are raising notification for a setCell changes and\n\t * a consumer tries to delete that row/col on receiving that notification which can lead to this matrix trying to setCell in\n\t * a deleted row/col.\n\t * @param callback - code that needs to protected against reentrancy.\n\t */\n\tprivate protectAgainstReentrancy(callback: () => void): void {\n\t\tif (this.reentrantCount !== 0) {\n\t\t\t// Validate that applications don't submit edits in response to matrix change notifications. This is unsupported.\n\t\t\tthrow new UsageError(\"Reentrancy detected in SharedMatrix.\");\n\t\t}\n\t\tthis.reentrantCount++;\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\tthis.reentrantCount--;\n\t\t}\n\t\tassert(\n\t\t\tthis.reentrantCount === 0,\n\t\t\t0x85e /* indicates a problem with the reentrancy tracking code. */,\n\t\t);\n\t}\n\n\tprivate submitVectorMessage(\n\t\tcurrentVector: PermutationVector,\n\t\toppositeVector: PermutationVector,\n\t\ttarget: SnapshotPath.rows | SnapshotPath.cols,\n\t\tmessage: IMergeTreeOp,\n\t): void {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally advance each MergeTree's 'localSeq' counter\n\t\t// for each submitted op it not aware of to keep them synchronized.\n\t\tconst localSeq = currentVector.getCollabWindow().localSeq;\n\t\tconst oppositeWindow = oppositeVector.getCollabWindow();\n\n\t\t// Note that the comparison is '>=' because, in the case the MergeTree is regenerating ops for reconnection,\n\t\t// the MergeTree submits the op with the original 'localSeq'.\n\t\tassert(\n\t\t\tlocalSeq >= oppositeWindow.localSeq,\n\t\t\t0x01c /* \"The 'localSeq' of the vector submitting an op must >= the 'localSeq' of the other vector.\" */,\n\t\t);\n\n\t\toppositeWindow.localSeq = localSeq;\n\n\t\t// If the SharedMatrix is local, it's state will be submitted via a Snapshot when initially connected.\n\t\t// Do not queue a message or track the pending op, as there will never be an ACK, etc.\n\t\tif (this.isAttached()) {\n\t\t\t// Record whether this `op` targets rows or cols. (See dispatch in `processCore()`)\n\t\t\tconst targetedMessage: VectorOp = { ...message, target };\n\n\t\t\tthis.submitLocalMessage(\n\t\t\t\ttargetedMessage,\n\t\t\t\tcurrentVector.peekPendingSegmentGroups(\n\t\t\t\t\tmessage.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate submitColMessage(message: IMergeTreeOp): void {\n\t\tthis.submitVectorMessage(this.cols, this.rows, SnapshotPath.cols, message);\n\t}\n\n\tpublic insertCols(colStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (colStart > this.colCount) {\n\t\t\tthrow new UsageError(\"insertCols: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst message = this.cols.insert(colStart, count);\n\t\t\tassert(message !== undefined, 0x8b4 /* must be defined */);\n\t\t\tthis.submitColMessage(message);\n\t\t});\n\t}\n\n\tpublic removeCols(colStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (colStart > this.colCount) {\n\t\t\tthrow new UsageError(\"removeCols: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() =>\n\t\t\tthis.submitColMessage(this.cols.remove(colStart, count)),\n\t\t);\n\t}\n\n\tprivate submitRowMessage(message: IMergeTreeOp): void {\n\t\tthis.submitVectorMessage(this.rows, this.cols, SnapshotPath.rows, message);\n\t}\n\n\tpublic insertRows(rowStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (rowStart > this.rowCount) {\n\t\t\tthrow new UsageError(\"insertRows: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst message = this.rows.insert(rowStart, count);\n\t\t\tassert(message !== undefined, 0x8b5 /* must be defined */);\n\t\t\tthis.submitRowMessage(message);\n\t\t});\n\t}\n\n\tpublic removeRows(rowStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (rowStart > this.rowCount) {\n\t\t\tthrow new UsageError(\"removeRows: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() =>\n\t\t\tthis.submitRowMessage(this.rows.remove(rowStart, count)),\n\t\t);\n\t}\n\n\tpublic _undoRemoveRows(rowStart: number, spec: IJSONSegment): void {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.rows, rowStart, spec);\n\t\tassert(op !== undefined, 0x8b6 /* must be defined */);\n\t\tthis.submitRowMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted rows.\n\t\tlet rowHandle = inserted.start;\n\t\tconst rowCount = inserted.cachedLength;\n\t\tfor (let row = rowStart; row < rowStart + rowCount; row++, rowHandle++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(rowStart, /* colStart: */ 0, rowCount, this.colCount, this);\n\t\t}\n\t}\n\n\t/***/ public _undoRemoveCols(colStart: number, spec: IJSONSegment): void {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.cols, colStart, spec);\n\t\tassert(op !== undefined, 0x8b7 /* must be defined */);\n\t\tthis.submitColMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted cols.\n\t\tlet colHandle = inserted.start;\n\t\tconst colCount = inserted.cachedLength;\n\t\tfor (let col = colStart; col < colStart + colCount; col++, colHandle++) {\n\t\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(/* rowStart: */ 0, colStart, this.rowCount, colCount, this);\n\t\t}\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.rows.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.cols.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tconst artifactsToSummarize: (\n\t\t\t| undefined\n\t\t\t| number\n\t\t\t| ReturnType<SparseArray2D<MatrixItem<T> | number>[\"snapshot\"]>\n\t\t)[] = [\n\t\t\tthis.cells.snapshot(),\n\t\t\t/**\n\t\t\t * we used to write this.pending.snapshot(). this should have never been done, as pending is only for local\n\t\t\t * changes, and there should never be local changes in the summarizer. This was also never used on load\n\t\t\t * as there is no way to understand a previous clients pending changes. so we just set this to a constant\n\t\t\t * which matches an empty this.pending.snapshot() for back-compat in terms of the array length\n\t\t\t */\n\t\t\t[undefined],\n\t\t];\n\n\t\t// Only need to store it in the snapshot if we have switched the policy already.\n\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\tartifactsToSummarize.push(\n\t\t\t\tthis.fwwPolicy.switchOpSeqNumber,\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.snapshot(),\n\t\t\t);\n\t\t} else {\n\t\t\t// back-compat: used -1 for disabled\n\t\t\tartifactsToSummarize.push(\n\t\t\t\t-1,\n\t\t\t\t/*\n\t\t\t\t * we should set undefined in place of cellLastWriteTracker to ensure the number of array entries is consistent.\n\t\t\t\t * Doing that currently breaks snapshot tests. Its is probably fine, but if new elements are ever added, we need\n\t\t\t\t * ensure undefined is also set.\n\t\t\t\t */\n\t\t\t\t// undefined\n\t\t\t);\n\t\t}\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.cells,\n\t\t\tserializer.stringify(artifactsToSummarize, this.handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Runs serializer on the GC data for this SharedMatrix.\n\t * All the IFluidHandle's stored in the cells represent routes to other objects.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer): void {\n\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tserializer.stringify(this.getCell(row, col), this.handle);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Advances the 'localSeq' counter for the cell data operation currently being queued.\n\t *\n\t * Do not use with 'submitColMessage()/submitRowMessage()' as these helpers + the MergeTree will\n\t * automatically advance 'localSeq'.\n\t */\n\tprivate nextLocalSeq(): number {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally bump each MergeTree's 'localSeq' counter\n\t\t// for SharedMatrix ops it's not aware of to keep them synchronized. (For cell data operations, we\n\t\t// need to bump both counters.)\n\n\t\tthis.cols.getCollabWindow().localSeq++;\n\t\treturn ++this.rows.getCollabWindow().localSeq;\n\t}\n\n\tprotected submitLocalMessage(message: unknown, localOpMetadata?: unknown): void {\n\t\t// TODO: Recommend moving this assertion into SharedObject\n\t\t// (See https://github.com/microsoft/FluidFramework/issues/2559)\n\t\tassert(\n\t\t\tthis.isAttached() === true,\n\t\t\t0x01d /* \"Trying to submit message to runtime while detached!\" */,\n\t\t);\n\n\t\tthis.inFlightRefSeqs.push(this.deltaManager.lastSequenceNumber);\n\t\tsuper.submitLocalMessage(message, localOpMetadata);\n\n\t\t// Ensure that row/col 'localSeq' are synchronized (see 'nextLocalSeq()').\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq,\n\t\t\t0x01e /* \"Row and col collab window 'localSeq' desynchronized!\" */,\n\t\t);\n\t}\n\n\tprotected didAttach(): void {\n\t\t// We've attached we need to start generating and sending ops.\n\t\t// so start collaboration and provide a default client id incase we are not connected\n\t\tif (this.isAttached()) {\n\t\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t}\n\t}\n\n\tprotected onConnect(): void {\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().collaborating === this.cols.getCollabWindow().collaborating,\n\t\t\t0x01f /* \"Row and col collab window 'collaborating' status desynchronized!\" */,\n\t\t);\n\n\t\t// Update merge tree collaboration information with new client ID and then resend pending ops\n\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t}\n\n\tprivate rebasePosition(\n\t\tclient: Client,\n\t\tref: LocalReferencePosition,\n\t\tlocalSeq: number,\n\t): number | undefined {\n\t\tconst segment: ISegmentInternal | undefined = ref.getSegment();\n\t\tconst offset = ref.getOffset();\n\t\t// If the segment that contains the position is removed, then this setCell op should do nothing.\n\t\tif (segment === undefined || offset === undefined || segmentIsRemoved(segment)) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn client.findReconnectionPosition(segment, localSeq) + offset;\n\t}\n\n\tprotected reSubmitCore(incoming: unknown, localOpMetadata: unknown): void {\n\t\tconst originalRefSeq = this.inFlightRefSeqs.shift();\n\t\tassert(\n\t\t\toriginalRefSeq !== undefined,\n\t\t\t0x8b9 /* Expected a recorded refSeq when resubmitting an op */,\n\t\t);\n\t\tconst content = incoming as MatrixSetOrVectorOp<T>;\n\n\t\tif (content.type === MatrixOp.set && content.target === undefined) {\n\t\t\tconst setOp = content;\n\t\t\tconst { rowHandle, colHandle, localSeq, rowsRef, colsRef, referenceSeqNumber } =\n\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\n\t\t\t// If after rebasing the op, we get a valid row/col number, that means the row/col\n\t\t\t// handles have not been recycled and we can safely use them.\n\t\t\tconst row = this.rebasePosition(this.rows, rowsRef, localSeq);\n\t\t\tconst col = this.rebasePosition(this.cols, colsRef, localSeq);\n\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\n\n\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\tassert(pendingCell !== undefined, 0xba4 /* local operation must have a pending array */);\n\t\t\tconst { local } = pendingCell;\n\t\t\tassert(local !== undefined, 0xba5 /* local operation must have a pending array */);\n\t\t\tconst localSeqIndex = local.findIndex((p) => p.localSeq === localSeq);\n\t\t\tassert(localSeqIndex >= 0, 0xba6 /* local operation must have a pending entry */);\n\t\t\tconst [change] = local.splice(localSeqIndex, 1);\n\t\t\tassert(change.localSeq === localSeq, 0xba7 /* must match */);\n\n\t\t\tif (\n\t\t\t\trow !== undefined &&\n\t\t\t\tcol !== undefined &&\n\t\t\t\trow >= 0 &&\n\t\t\t\tcol >= 0 && // If the mode is LWW, then send the op.\n\t\t\t\t// Otherwise if the current mode is FWW and if we generated this op, after seeing the\n\t\t\t\t// last set op, or it is the first set op for the cell, then regenerate the op,\n\t\t\t\t// otherwise raise conflict. We want to check the current mode here and not that\n\t\t\t\t// whether op was made in FWW or not.\n\t\t\t\t(this.fwwPolicy.state !== \"on\" ||\n\t\t\t\t\treferenceSeqNumber >=\n\t\t\t\t\t\t(this.fwwPolicy.cellLastWriteTracker.getCell(rowHandle, colHandle)?.seqNum ?? 0))\n\t\t\t) {\n\t\t\t\tthis.sendSetCellOp(row, col, setOp.value, rowHandle, colHandle, localSeq);\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (content.target) {\n\t\t\t\tcase SnapshotPath.cols: {\n\t\t\t\t\tthis.submitColMessage(\n\t\t\t\t\t\tthis.cols.regeneratePendingOp(content, localOpMetadata, false),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SnapshotPath.rows: {\n\t\t\t\t\tthis.submitRowMessage(\n\t\t\t\t\t\tthis.rows.regeneratePendingOp(content, localOpMetadata, false),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(content);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tconst contents = content as MatrixSetOrVectorOp<T>;\n\t\tconst target = contents.target;\n\n\t\tswitch (target) {\n\t\t\tcase SnapshotPath.cols: {\n\t\t\t\tthis.cols.rollback(content, localOpMetadata);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SnapshotPath.rows: {\n\t\t\t\tthis.rows.rollback(content, localOpMetadata);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase undefined: {\n\t\t\t\tassert(contents.type === MatrixOp.set, 0xba8 /* only sets supported */);\n\t\t\t\tconst setMetadata = localOpMetadata as ISetOpMetadata;\n\n\t\t\t\tconst pendingCell = this.pending.getCell(setMetadata.rowHandle, setMetadata.colHandle);\n\t\t\t\tassert(pendingCell !== undefined, 0xba9 /* must have pending */);\n\n\t\t\t\tconst change = pendingCell.local.pop();\n\t\t\t\tassert(change?.localSeq === setMetadata.localSeq, 0xbaa /* must have change */);\n\n\t\t\t\tconst previous =\n\t\t\t\t\tpendingCell.local.length > 0\n\t\t\t\t\t\t? pendingCell.local[pendingCell.local.length - 1].value\n\t\t\t\t\t\t: pendingCell.consensus;\n\n\t\t\t\tthis.setCellCore(\n\t\t\t\t\tcontents.row,\n\t\t\t\t\tcontents.col,\n\t\t\t\t\tprevious,\n\t\t\t\t\tsetMetadata.rowHandle,\n\t\t\t\t\tsetMetadata.colHandle,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\ttry {\n\t\t\tawait this.rows.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.rows),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tawait this.cols.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.cols),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tconst [\n\t\t\t\tcellData,\n\t\t\t\t_pendingCliSeqData,\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber,\n\t\t\t\tcellLastWriteTracker,\n\t\t\t\t// Cast is needed since the (de)serializer returns content of type `any`.\n\t\t\t] = (await deserializeBlob(storage, SnapshotPath.cells, this.serializer)) as [\n\t\t\t\tRecurArray<MatrixItem<T>>,\n\t\t\t\tunknown,\n\t\t\t\tnumber,\n\t\t\t\tRecurArray<CellLastWriteTrackerItem>,\n\t\t\t];\n\n\t\t\tthis.cells = SparseArray2D.load(cellData);\n\t\t\t// back-compat: used -1 for disabled, also may not exist\n\t\t\tconst switchOpSeqNumber =\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber === -1\n\t\t\t\t\t? undefined\n\t\t\t\t\t: (setCellLwwToFwwPolicySwitchOpSeqNumber ?? undefined);\n\t\t\tthis.fwwPolicy =\n\t\t\t\tswitchOpSeqNumber === undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstate: \"off\",\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\t\tswitchOpSeqNumber,\n\t\t\t\t\t\t\tcellLastWriteTracker: SparseArray2D.load(cellLastWriteTracker),\n\t\t\t\t\t\t};\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"MatrixLoadFailed\" }, error);\n\t\t}\n\t}\n\n\t/**\n\t * Tells whether the setCell op should be applied or not based on First Write Win policy. It assumes\n\t * we are in FWW mode.\n\t */\n\tprivate shouldSetCellBasedOnFWW(\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tmessage: ISequencedDocumentMessage,\n\t): boolean {\n\t\tassert(\n\t\t\tthis.fwwPolicy.state === \"on\",\n\t\t\t0x85f /* should be in Fww mode when calling this method */,\n\t\t);\n\t\tassert(message.clientId !== null, 0x860 /* clientId should not be null */);\n\t\tconst lastCellModificationDetails = this.fwwPolicy.cellLastWriteTracker.getCell(\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t);\n\t\t// If someone tried to Overwrite the cell value or first write on this cell or\n\t\t// same client tried to modify the cell.\n\t\treturn (\n\t\t\tlastCellModificationDetails === undefined ||\n\t\t\tlastCellModificationDetails.clientId === message.clientId ||\n\t\t\tmessage.referenceSequenceNumber >= lastCellModificationDetails.seqNum\n\t\t);\n\t}\n\n\tprotected processCore(\n\t\tmsg: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tif (local) {\n\t\t\tconst recordedRefSeq = this.inFlightRefSeqs.shift();\n\t\t\tassert(recordedRefSeq !== undefined, 0x8ba /* No pending recorded refSeq found */);\n\t\t\t// TODO: AB#7076: Some equivalent assert should be enabled. This fails some e2e stashed op tests because\n\t\t\t// the deltaManager may have seen more messages than the runtime has processed while amidst the stashed op\n\t\t\t// flow, so e.g. when `applyStashedOp` is called and the DDS is put in a state where it expects an ack for\n\t\t\t// one of its messages, the delta manager has actually already seen subsequent messages from collaborators\n\t\t\t// which the in-flight message is concurrent to.\n\t\t\t// See \"handles stashed ops created on top of sequenced local ops\" for one such test case.\n\t\t\t// assert(recordedRefSeq <= message.referenceSequenceNumber, \"RefSeq mismatch\");\n\t\t}\n\n\t\tconst contents = msg.contents as MatrixSetOrVectorOp<T>;\n\t\tconst target = contents.target;\n\n\t\tswitch (target) {\n\t\t\tcase SnapshotPath.cols: {\n\t\t\t\tthis.cols.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SnapshotPath.rows: {\n\t\t\t\tthis.rows.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase undefined: {\n\t\t\t\tassert(\n\t\t\t\t\tcontents.type === MatrixOp.set,\n\t\t\t\t\t0x021 /* \"SharedMatrix message contents have unexpected type!\" */,\n\t\t\t\t);\n\n\t\t\t\tconst { row, col, value, fwwMode } = contents;\n\t\t\t\t// If this is the first op notifying us of the policy change, then set the policy change seq number.\n\t\t\t\tif (fwwMode === true && this.fwwPolicy.state !== \"on\") {\n\t\t\t\t\tthis.fwwPolicy = {\n\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\tswitchOpSeqNumber: msg.sequenceNumber,\n\t\t\t\t\t\tcellLastWriteTracker: new SparseArray2D(),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tassert(msg.clientId !== null, 0x861 /* clientId should not be null!! */);\n\t\t\t\tif (local) {\n\t\t\t\t\t// We are receiving the ACK for a local pending set operation.\n\t\t\t\t\tconst { rowHandle, colHandle, localSeq, rowsRef, colsRef } =\n\t\t\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\t\t\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\n\n\t\t\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\t\t\tconst ackedChange = pendingCell?.local.shift();\n\t\t\t\t\tassert(ackedChange?.localSeq === localSeq, 0xbab /* must match */);\n\t\t\t\t\tif (pendingCell?.local.length === 0) {\n\t\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If policy is switched and cell should be modified too based on policy, then update the tracker.\n\t\t\t\t\t// If policy is not switched, then also update the tracker in case it is the latest.\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.fwwPolicy.state === \"on\" &&\n\t\t\t\t\t\tthis.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tpendingCell!.consensus = ackedChange.value;\n\t\t\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst adjustedRow = this.rows.adjustPosition(row, msg);\n\t\t\t\t\tconst adjustedCol = this.cols.adjustPosition(col, msg);\n\n\t\t\t\t\tconst rowHandle = adjustedRow.handle;\n\t\t\t\t\tconst colHandle = adjustedCol.handle;\n\n\t\t\t\t\tassert(\n\t\t\t\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t\t\t\t0x022 /* \"SharedMatrix row and/or col handles are invalid!\" */,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\t\t\t// If someone tried to Overwrite the cell value or first write on this cell or\n\t\t\t\t\t\t// same client tried to modify the cell or if the previous mode was LWW, then we need to still\n\t\t\t\t\t\t// overwrite the cell and raise conflict if we have pending changes as our change is going to be lost.\n\t\t\t\t\t\tif (this.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)) {\n\t\t\t\t\t\t\tconst previousValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (pendingCell !== undefined) {\n\t\t\t\t\t\t\t\tpendingCell.consensus = value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (adjustedRow.pos !== undefined && adjustedCol.pos !== undefined) {\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow.pos, adjustedCol.pos, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Check is there are any pending changes, which will be rejected. If so raise conflict.\n\t\t\t\t\t\t\t\tif (pendingCell !== undefined && pendingCell.local.length > 0) {\n\t\t\t\t\t\t\t\t\t// Don't reset the pending value yet, as there maybe more fww op from same client, so we want\n\t\t\t\t\t\t\t\t\t// to raise conflict event for that op also.\n\t\t\t\t\t\t\t\t\tthis.emit(\n\t\t\t\t\t\t\t\t\t\t\"conflict\",\n\t\t\t\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\t\t\t\tcol,\n\t\t\t\t\t\t\t\t\t\tvalue, // Current value\n\t\t\t\t\t\t\t\t\t\tpreviousValue, // Ignored local value\n\t\t\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (pendingCell === undefined || pendingCell.local.length === 0) {\n\t\t\t\t\t\t\t// If there is a pending (unACKed) local write to the same cell, skip the current op\n\t\t\t\t\t\t\t// since it \"happened before\" the pending write.\n\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\tif (adjustedRow.pos !== undefined && adjustedCol.pos !== undefined) {\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow.pos, adjustedCol.pos, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpendingCell.consensus = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(target, \"unknown target\");\n\t\t\t}\n\t\t}\n\t}\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of row insertion/deletions.\n\tprivate readonly onRowDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t): void => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.rowsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of col insertion/deletions.\n\tprivate readonly onColDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t): void => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.colsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\tprivate readonly onRowHandlesRecycled = (rowHandles: Handle[]): void => {\n\t\tfor (const rowHandle of rowHandles) {\n\t\t\tthis.cells.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tthis.pending.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker?.clearRows(\n\t\t\t\t\t/* rowStart: */ rowHandle,\n\t\t\t\t\t/* rowCount: */ 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate readonly onColHandlesRecycled = (colHandles: Handle[]): void => {\n\t\tfor (const colHandle of colHandles) {\n\t\t\tthis.cells.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tthis.pending.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker?.clearCols(\n\t\t\t\t\t/* colStart: */ colHandle,\n\t\t\t\t\t/* colCount: */ 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic switchSetCellPolicy(): void {\n\t\tif (this.fwwPolicy.state === \"off\") {\n\t\t\tthis.fwwPolicy = this.isAttached()\n\t\t\t\t? { state: \"local\" }\n\t\t\t\t: {\n\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\tswitchOpSeqNumber: 0,\n\t\t\t\t\t\tcellLastWriteTracker: new SparseArray2D(),\n\t\t\t\t\t};\n\t\t}\n\t}\n\n\tpublic toString(): string {\n\t\tlet s = `client:${\n\t\t\tthis.runtime.clientId\n\t\t}\\nrows: ${this.rows.toString()}\\ncols: ${this.cols.toString()}\\n\\n`;\n\n\t\tfor (let r = 0; r < this.rowCount; r++) {\n\t\t\ts += ` [`;\n\t\t\tfor (let c = 0; c < this.colCount; c++) {\n\t\t\t\tif (c > 0) {\n\t\t\t\t\ts += \", \";\n\t\t\t\t}\n\n\t\t\t\ts += `${this.serializer.stringify(this.getCell(r, c), this.handle)}`;\n\t\t\t}\n\t\t\ts += \"]\\n\";\n\t\t}\n\n\t\treturn `${s}\\n`;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(_content: unknown): void {\n\t\tconst content = _content as MatrixSetOrVectorOp<T>;\n\t\tif (content.type === MatrixOp.set && content.target === undefined) {\n\t\t\tif (content.fwwMode === true) {\n\t\t\t\tthis.switchSetCellPolicy();\n\t\t\t}\n\t\t\tthis.setCell(content.row, content.col, content.value);\n\t\t} else {\n\t\t\tconst vector = content.target === SnapshotPath.cols ? this.cols : this.rows;\n\t\t\tvector.applyStashedOp(content);\n\t\t\tif (content.target === SnapshotPath.cols) {\n\t\t\t\tthis.submitColMessage(content);\n\t\t\t} else {\n\t\t\t\tthis.submitRowMessage(content);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAQ9E,OAAO,EAMN,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GAChB,MAAM,qCAAqC,CAAC;AAO7C,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,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAC/B,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,CAAC,IAAI,EAAE,CAAC;gBAC1C,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIEvent,\n\tIEventThisPlaceHolder,\n\tIEventProvider,\n} from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannel,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype Client,\n\ttype IJSONSegment,\n\ttype IMergeTreeOp,\n\ttype ISegmentInternal,\n\ttype LocalReferencePosition,\n\tMergeTreeDeltaType,\n\tReferenceType,\n\tsegmentIsRemoved,\n} from \"@fluidframework/merge-tree/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tObjectStoragePartition,\n\tSummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\ttype ISharedObjectEvents,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type {\n\tIMatrixConsumer,\n\tIMatrixProducer,\n\tIMatrixReader,\n\tIMatrixWriter,\n} from \"@tiny-calc/nano\";\nimport Deque from \"double-ended-queue\";\n\nimport type { HandleCache } from \"./handlecache.js\";\nimport { type Handle, isHandleValid } from \"./handletable.js\";\nimport {\n\ttype ISetOp,\n\ttype MatrixItem,\n\tMatrixOp,\n\ttype MatrixSetOrVectorOp,\n\tSnapshotPath,\n\ttype VectorOp,\n} from \"./ops.js\";\nimport { PermutationVector, reinsertSegmentIntoVector } from \"./permutationvector.js\";\nimport { ensureRange } from \"./range.js\";\nimport { deserializeBlob } from \"./serialization.js\";\nimport { SparseArray2D, type RecurArray } from \"./sparsearray2d.js\";\nimport type { IUndoConsumer } from \"./types.js\";\nimport { MatrixUndoProvider } from \"./undoprovider.js\";\n\ninterface ISetOpMetadata {\n\trowHandle: Handle;\n\tcolHandle: Handle;\n\tlocalSeq: number;\n\trowsRef: LocalReferencePosition;\n\tcolsRef: LocalReferencePosition;\n\treferenceSeqNumber: number;\n}\n\n/**\n * Events emitted by Shared Matrix.\n * @legacy @beta\n */\nexport interface ISharedMatrixEvents<T> extends IEvent {\n\t/**\n\t * This event is only emitted when the SetCell Resolution Policy is First Write Win(FWW).\n\t * This is emitted when two clients race and send changes without observing each other changes,\n\t * the changes that gets sequenced last would be rejected, and only client who's changes rejected\n\t * would be notified via this event, with expectation that it will merge its changes back by\n\t * accounting new information (state from winner of the race).\n\t *\n\t * @remarks Listener parameters:\n\t *\n\t * - `row` - Row number at which conflict happened.\n\t *\n\t * - `col` - Col number at which conflict happened.\n\t *\n\t * - `currentValue` - The current value of the cell.\n\t *\n\t * - `conflictingValue` - The value that this client tried to set in the cell and got ignored due to conflict.\n\t *\n\t * - `target` - The {@link ISharedMatrix} itself.\n\t */\n\t(\n\t\tevent: \"conflict\",\n\t\tlistener: (\n\t\t\trow: number,\n\t\t\tcol: number,\n\t\t\tcurrentValue: MatrixItem<T>,\n\t\t\tconflictingValue: MatrixItem<T>,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t): void;\n}\n\n/**\n * This represents the item which is used to track the client which modified the cell last.\n */\ninterface CellLastWriteTrackerItem {\n\tseqNum: number; // Seq number of op which last modified this cell\n\tclientId: string; // clientId of the client which last modified this cell\n}\n\n/**\n * @legacy @beta\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition ISharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ISharedMatrix<T = any>\n\textends IEventProvider<ISharedMatrixEvents<T>>,\n\t\tIMatrixProducer<MatrixItem<T>>,\n\t\tIMatrixReader<MatrixItem<T>>,\n\t\tIMatrixWriter<MatrixItem<T>>,\n\t\tIChannel {\n\t/**\n\t * Inserts columns into the matrix.\n\t * @param colStart - Index of the first column to insert.\n\t * @param count - Number of columns to insert.\n\t * @remarks\n\t * Inserting 0 columns is a noop.\n\t */\n\tinsertCols(colStart: number, count: number): void;\n\t/**\n\t * Removes columns from the matrix.\n\t * @param colStart - Index of the first column to remove.\n\t * @param count - Number of columns to remove.\n\t * @remarks\n\t * Removing 0 columns is a noop.\n\t */\n\tremoveCols(colStart: number, count: number): void;\n\t/**\n\t * Inserts rows into the matrix.\n\t * @param rowStart - Index of the first row to insert.\n\t * @param count - Number of rows to insert.\n\t * @remarks\n\t * Inserting 0 rows is a noop.\n\t */\n\tinsertRows(rowStart: number, count: number): void;\n\t/**\n\t * Removes rows from the matrix.\n\t * @param rowStart - Index of the first row to remove.\n\t * @param count - Number of rows to remove.\n\t * @remarks\n\t * Removing 0 rows is a noop.\n\t */\n\tremoveRows(rowStart: number, count: number): void;\n\n\t/**\n\t * Sets a range of cells in the matrix.\n\t * Cells are set in consecutive columns between `colStart` and `colStart + colCount - 1`.\n\t * When `values` has larger size than `colCount`, the extra values are inserted in subsequent rows\n\t * a la text-wrapping.\n\t * @param rowStart - Index of the row to start setting cells.\n\t * @param colStart - Index of the column to start setting cells.\n\t * @param colCount - Number of columns to set before wrapping to subsequent rows (if `values` has more items)\n\t * @param values - Values to insert.\n\t * @remarks\n\t * This is not currently more efficient than calling `setCell` for each cell.\n\t */\n\tsetCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t): void;\n\n\t/**\n\t * Attach an {@link IUndoConsumer} to the matrix.\n\t * @param consumer - Undo consumer which will receive revertibles from the matrix.\n\t */\n\topenUndo(consumer: IUndoConsumer): void;\n\n\t/**\n\t * Whether the current conflict resolution policy is first-write win (FWW).\n\t * See {@link ISharedMatrix.switchSetCellPolicy} for more details.\n\t */\n\tisSetCellConflictResolutionPolicyFWW(): boolean;\n\n\t/**\n\t * Change the conflict resolution policy for setCell operations to first-write win (FWW).\n\t *\n\t * This API only switches from LWW to FWW and not from FWW to LWW.\n\t *\n\t * @privateRemarks\n\t * The next SetOp which is sent will communicate this policy to other clients.\n\t */\n\tswitchSetCellPolicy(): void;\n}\n\ntype FirstWriterWinsPolicy =\n\t| { state: \"off\" }\n\t| { state: \"local\" }\n\t| {\n\t\t\tstate: \"on\";\n\t\t\tswitchOpSeqNumber: number;\n\t\t\tcellLastWriteTracker: SparseArray2D<CellLastWriteTrackerItem>;\n\t };\n\n/**\n * Tracks pending local changes for a cell.\n */\ninterface PendingCellChanges<T> {\n\t/**\n\t * The local changes including the local seq, and the value set at that local seq.\n\t */\n\tlocal: { localSeq: number; value: MatrixItem<T> }[];\n\t/**\n\t * The latest consensus value across all clients.\n\t * this will either be a remote value or ack'd local\n\t * value.\n\t */\n\tconsensus?: MatrixItem<T>;\n}\n\n/**\n * A SharedMatrix holds a rectangular 2D array of values. Supported operations\n * include setting values and inserting/removing rows and columns.\n *\n * Matrix values may be any Fluid serializable type, which is the set of JSON\n * serializable types extended to include IFluidHandles.\n *\n * Fluid's SharedMatrix implementation works equally well for dense and sparse\n * matrix data and physically stores data in Z-order to leverage CPU caches and\n * prefetching when reading in either row or column major order. (See README.md\n * for more details.)\n * @legacy @beta\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition SharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class SharedMatrix<T = any>\n\textends SharedObject<ISharedMatrixEvents<T> & ISharedObjectEvents>\n\timplements ISharedMatrix<T>\n{\n\tprivate readonly consumers = new Set<IMatrixConsumer<MatrixItem<T>>>();\n\n\t/**\n\t * Note: this field only provides a lower-bound on the reference sequence numbers for in-flight ops.\n\t * The exact reason isn't understood, but some e2e tests suggest that the runtime may sometimes process\n\t * incoming leave/join ops before putting an op that this DDS submits over the wire.\n\t *\n\t * E.g. SharedMatrix submits an op while deltaManager has lastSequenceNumber = 10, but before the runtime\n\t * puts this op over the wire, it processes a client join/leave op with sequence number 11, so the referenceSequenceNumber\n\t * on the SharedMatrix op is 11.\n\t */\n\tprivate readonly inFlightRefSeqs = new Deque<number>();\n\treadonly getMinInFlightRefSeq = (): number | undefined => this.inFlightRefSeqs.get(0);\n\n\tprivate readonly rows: PermutationVector; // Map logical row to storage handle (if any)\n\tprivate readonly cols: PermutationVector; // Map logical col to storage handle (if any)\n\n\tprivate cells = new SparseArray2D<MatrixItem<T>>(); // Stores cell values.\n\tprivate readonly pending = new SparseArray2D<PendingCellChanges<T>>(); // Tracks pending writes.\n\n\tprivate fwwPolicy: FirstWriterWinsPolicy = {\n\t\tstate: \"off\",\n\t};\n\n\t// Used to track if there is any reentrancy in setCell code.\n\tprivate reentrantCount: number = 0;\n\n\t/**\n\t * Constructor for the Shared Matrix\n\t * @param runtime - DataStore runtime.\n\t * @param id - id of the dds\n\t * @param attributes - channel attributes\n\t * @param _isSetCellConflictResolutionPolicyFWW - Conflict resolution for Matrix set op is First Writer Win in case of\n\t * race condition. Client can still overwrite values in case of no race.\n\t */\n\tconstructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_matrix_\");\n\n\t\tthis.rows = new PermutationVector(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onRowDelta,\n\t\t\tthis.onRowHandlesRecycled,\n\t\t\tthis.getMinInFlightRefSeq,\n\t\t);\n\n\t\tthis.cols = new PermutationVector(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onColDelta,\n\t\t\tthis.onColHandlesRecycled,\n\t\t\tthis.getMinInFlightRefSeq,\n\t\t);\n\t}\n\n\tprivate undo?: MatrixUndoProvider<T>;\n\n\t/**\n\t * Subscribes the given IUndoConsumer to the matrix.\n\t */\n\tpublic openUndo(consumer: IUndoConsumer): void {\n\t\tassert(\n\t\t\tthis.undo === undefined,\n\t\t\t0x019 /* \"SharedMatrix.openUndo() supports at most a single IUndoConsumer.\" */,\n\t\t);\n\n\t\tthis.undo = new MatrixUndoProvider(consumer, this, this.rows, this.cols);\n\t}\n\n\t// TODO: closeUndo()?\n\n\tprivate get rowHandles(): HandleCache {\n\t\treturn this.rows.handleCache;\n\t}\n\tprivate get colHandles(): HandleCache {\n\t\treturn this.cols.handleCache;\n\t}\n\n\t// #region IMatrixProducer\n\n\topenMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): IMatrixReader<MatrixItem<T>> {\n\t\tthis.consumers.add(consumer);\n\t\treturn this;\n\t}\n\n\tcloseMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): void {\n\t\tthis.consumers.delete(consumer);\n\t}\n\n\t// #endregion IMatrixProducer\n\n\t// #region IMatrixReader\n\n\tpublic get rowCount(): number {\n\t\treturn this.rows.getLength();\n\t}\n\tpublic get colCount(): number {\n\t\treturn this.cols.getLength();\n\t}\n\n\tpublic isSetCellConflictResolutionPolicyFWW(): boolean {\n\t\treturn this.fwwPolicy.state !== \"off\";\n\t}\n\n\tpublic getCell(row: number, col: number): MatrixItem<T> {\n\t\t// Perf: When possible, bounds checking is performed inside the implementation for\n\t\t// 'getHandle()' so that it can be elided in the case of a cache hit. This\n\t\t// yields an ~40% improvement in the case of a cache hit (node v12 x64)\n\n\t\t// Map the logical (row, col) to associated storage handles.\n\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\tif (isHandleValid(rowHandle)) {\n\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\tif (isHandleValid(colHandle)) {\n\t\t\t\treturn this.cells.getCell(rowHandle, colHandle);\n\t\t\t}\n\t\t} else {\n\t\t\t// If we early exit because the given rowHandle is unallocated, we still need to\n\t\t\t// bounds-check the 'col' parameter.\n\t\t\tensureRange(col, this.cols.getLength());\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<MatrixItem<T>> {\n\t\treturn this;\n\t}\n\n\t// #endregion IMatrixReader\n\n\tpublic setCell(row: number, col: number, value: MatrixItem<T>): void {\n\t\tif (row < 0 || row >= this.rowCount || col < 0 || col >= this.colCount) {\n\t\t\tthrow new UsageError(\"Trying to set out-of-bounds cell.\");\n\t\t}\n\n\t\tthis.setCellCore(row, col, value);\n\t}\n\n\tpublic setCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t): void {\n\t\tconst rowCount = Math.ceil(values.length / colCount);\n\n\t\tassert(\n\t\t\t0 <= rowStart &&\n\t\t\t\trowStart < this.rowCount &&\n\t\t\t\t0 <= colStart &&\n\t\t\t\tcolStart < this.colCount &&\n\t\t\t\t1 <= colCount &&\n\t\t\t\tcolCount <= this.colCount - colStart &&\n\t\t\t\trowCount <= this.rowCount - rowStart,\n\t\t\t0x01b /* \"Trying to set multiple out-of-bounds cells!\" */,\n\t\t);\n\n\t\tconst endCol = colStart + colCount;\n\t\tlet r = rowStart;\n\t\tlet c = colStart;\n\n\t\tfor (const value of values) {\n\t\t\tthis.setCellCore(r, c, value);\n\n\t\t\tif (++c === endCol) {\n\t\t\t\tc = colStart;\n\t\t\t\tr++;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setCellCore(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle = this.rows.getAllocatedHandle(row),\n\t\tcolHandle = this.cols.getAllocatedHandle(col),\n\t\trollback?: boolean,\n\t): void {\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst oldValue = this.cells.getCell(rowHandle, colHandle) ?? undefined;\n\n\t\t\tif (this.undo !== undefined) {\n\t\t\t\tthis.undo.cellSet(rowHandle, colHandle, oldValue);\n\t\t\t}\n\n\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\n\t\t\tif (this.isAttached() && rollback !== true) {\n\t\t\t\tconst pending = this.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\tif (pending.local.length === 1) {\n\t\t\t\t\tpending.consensus ??= oldValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\tconsumer.cellsChanged(row, col, 1, 1, this);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate createOpMetadataLocalRef(\n\t\tvector: PermutationVector,\n\t\tpos: number,\n\t\tlocalSeq: number,\n\t): LocalReferencePosition {\n\t\tconst segoff = vector.getContainingSegment(pos, undefined, localSeq);\n\t\tassert(segoff !== undefined, 0x8b3 /* expected valid position */);\n\t\treturn vector.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\tReferenceType.StayOnRemove,\n\t\t\tundefined,\n\t\t);\n\t}\n\n\tprivate sendSetCellOp(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tlocalSeq = this.nextLocalSeq(),\n\t): PendingCellChanges<T> {\n\t\tassert(\n\t\t\tthis.isAttached(),\n\t\t\t0x1e2 /* \"Caller must ensure 'isAttached()' before calling 'sendSetCellOp'.\" */,\n\t\t);\n\n\t\tconst op: ISetOp<T> = {\n\t\t\ttype: MatrixOp.set,\n\t\t\trow,\n\t\t\tcol,\n\t\t\tvalue,\n\t\t\tfwwMode: this.fwwPolicy.state !== \"off\",\n\t\t};\n\n\t\tconst rowsRef = this.createOpMetadataLocalRef(this.rows, row, localSeq);\n\t\tconst colsRef = this.createOpMetadataLocalRef(this.cols, col, localSeq);\n\t\tconst metadata: ISetOpMetadata = {\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t\tlocalSeq,\n\t\t\trowsRef,\n\t\t\tcolsRef,\n\t\t\treferenceSeqNumber: this.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, metadata);\n\t\tconst pendingCell: PendingCellChanges<T> = this.pending.getCell(rowHandle, colHandle) ?? {\n\t\t\tlocal: [],\n\t\t};\n\t\tpendingCell.local.push({ localSeq, value });\n\t\tthis.pending.setCell(rowHandle, colHandle, pendingCell);\n\t\treturn pendingCell;\n\t}\n\n\t/**\n\t * This makes sure that the code inside the callback is not reentrant. We need to do that because we raise notifications\n\t * to the consumers telling about these changes and they can try to change the matrix while listening to those notifications\n\t * which can make the shared matrix to be in bad state. For example, we are raising notification for a setCell changes and\n\t * a consumer tries to delete that row/col on receiving that notification which can lead to this matrix trying to setCell in\n\t * a deleted row/col.\n\t * @param callback - code that needs to protected against reentrancy.\n\t */\n\tprivate protectAgainstReentrancy(callback: () => void): void {\n\t\tif (this.reentrantCount !== 0) {\n\t\t\t// Validate that applications don't submit edits in response to matrix change notifications. This is unsupported.\n\t\t\tthrow new UsageError(\"Reentrancy detected in SharedMatrix.\");\n\t\t}\n\t\tthis.reentrantCount++;\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\tthis.reentrantCount--;\n\t\t}\n\t\tassert(\n\t\t\tthis.reentrantCount === 0,\n\t\t\t0x85e /* indicates a problem with the reentrancy tracking code. */,\n\t\t);\n\t}\n\n\tprivate submitVectorMessage(\n\t\tcurrentVector: PermutationVector,\n\t\toppositeVector: PermutationVector,\n\t\ttarget: SnapshotPath.rows | SnapshotPath.cols,\n\t\tmessage: IMergeTreeOp,\n\t): void {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally advance each MergeTree's 'localSeq' counter\n\t\t// for each submitted op it not aware of to keep them synchronized.\n\t\tconst localSeq = currentVector.getCollabWindow().localSeq;\n\t\tconst oppositeWindow = oppositeVector.getCollabWindow();\n\n\t\t// Note that the comparison is '>=' because, in the case the MergeTree is regenerating ops for reconnection,\n\t\t// the MergeTree submits the op with the original 'localSeq'.\n\t\tassert(\n\t\t\tlocalSeq >= oppositeWindow.localSeq,\n\t\t\t0x01c /* \"The 'localSeq' of the vector submitting an op must >= the 'localSeq' of the other vector.\" */,\n\t\t);\n\n\t\toppositeWindow.localSeq = localSeq;\n\n\t\t// If the SharedMatrix is local, it's state will be submitted via a Snapshot when initially connected.\n\t\t// Do not queue a message or track the pending op, as there will never be an ACK, etc.\n\t\tif (this.isAttached()) {\n\t\t\t// Record whether this `op` targets rows or cols. (See dispatch in `processCore()`)\n\t\t\tconst targetedMessage: VectorOp = { ...message, target };\n\n\t\t\tthis.submitLocalMessage(\n\t\t\t\ttargetedMessage,\n\t\t\t\tcurrentVector.peekPendingSegmentGroups(\n\t\t\t\t\tmessage.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate submitColMessage(message: IMergeTreeOp): void {\n\t\tthis.submitVectorMessage(this.cols, this.rows, SnapshotPath.cols, message);\n\t}\n\n\tpublic insertCols(colStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (colStart > this.colCount) {\n\t\t\tthrow new UsageError(\"insertCols: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst message = this.cols.insert(colStart, count);\n\t\t\tassert(message !== undefined, 0x8b4 /* must be defined */);\n\t\t\tthis.submitColMessage(message);\n\t\t});\n\t}\n\n\tpublic removeCols(colStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (colStart > this.colCount) {\n\t\t\tthrow new UsageError(\"removeCols: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() =>\n\t\t\tthis.submitColMessage(this.cols.remove(colStart, count)),\n\t\t);\n\t}\n\n\tprivate submitRowMessage(message: IMergeTreeOp): void {\n\t\tthis.submitVectorMessage(this.rows, this.cols, SnapshotPath.rows, message);\n\t}\n\n\tpublic insertRows(rowStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (rowStart > this.rowCount) {\n\t\t\tthrow new UsageError(\"insertRows: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tconst message = this.rows.insert(rowStart, count);\n\t\t\tassert(message !== undefined, 0x8b5 /* must be defined */);\n\t\t\tthis.submitRowMessage(message);\n\t\t});\n\t}\n\n\tpublic removeRows(rowStart: number, count: number): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (rowStart > this.rowCount) {\n\t\t\tthrow new UsageError(\"removeRows: out of bounds\");\n\t\t}\n\t\tthis.protectAgainstReentrancy(() =>\n\t\t\tthis.submitRowMessage(this.rows.remove(rowStart, count)),\n\t\t);\n\t}\n\n\tpublic _undoRemoveRows(rowStart: number, spec: IJSONSegment): void {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.rows, rowStart, spec);\n\t\tassert(op !== undefined, 0x8b6 /* must be defined */);\n\t\tthis.submitRowMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted rows.\n\t\tlet rowHandle = inserted.start;\n\t\tconst rowCount = inserted.cachedLength;\n\t\tfor (let row = rowStart; row < rowStart + rowCount; row++, rowHandle++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(rowStart, /* colStart: */ 0, rowCount, this.colCount, this);\n\t\t}\n\t}\n\n\t/***/ public _undoRemoveCols(colStart: number, spec: IJSONSegment): void {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.cols, colStart, spec);\n\t\tassert(op !== undefined, 0x8b7 /* must be defined */);\n\t\tthis.submitColMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted cols.\n\t\tlet colHandle = inserted.start;\n\t\tconst colCount = inserted.cachedLength;\n\t\tfor (let col = colStart; col < colStart + colCount; col++, colHandle++) {\n\t\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(/* rowStart: */ 0, colStart, this.rowCount, colCount, this);\n\t\t}\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.rows.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.cols.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tconst artifactsToSummarize: (\n\t\t\t| undefined\n\t\t\t| number\n\t\t\t| ReturnType<SparseArray2D<MatrixItem<T> | number>[\"snapshot\"]>\n\t\t)[] = [\n\t\t\tthis.cells.snapshot(),\n\t\t\t/**\n\t\t\t * we used to write this.pending.snapshot(). this should have never been done, as pending is only for local\n\t\t\t * changes, and there should never be local changes in the summarizer. This was also never used on load\n\t\t\t * as there is no way to understand a previous clients pending changes. so we just set this to a constant\n\t\t\t * which matches an empty this.pending.snapshot() for back-compat in terms of the array length\n\t\t\t */\n\t\t\t[undefined],\n\t\t];\n\n\t\t// Only need to store it in the snapshot if we have switched the policy already.\n\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\tartifactsToSummarize.push(\n\t\t\t\tthis.fwwPolicy.switchOpSeqNumber,\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.snapshot(),\n\t\t\t);\n\t\t} else {\n\t\t\t// back-compat: used -1 for disabled\n\t\t\tartifactsToSummarize.push(\n\t\t\t\t-1,\n\t\t\t\t/*\n\t\t\t\t * we should set undefined in place of cellLastWriteTracker to ensure the number of array entries is consistent.\n\t\t\t\t * Doing that currently breaks snapshot tests. Its is probably fine, but if new elements are ever added, we need\n\t\t\t\t * ensure undefined is also set.\n\t\t\t\t */\n\t\t\t\t// undefined\n\t\t\t);\n\t\t}\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.cells,\n\t\t\tserializer.stringify(artifactsToSummarize, this.handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Runs serializer on the GC data for this SharedMatrix.\n\t * All the IFluidHandle's stored in the cells represent routes to other objects.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer): void {\n\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tserializer.stringify(this.getCell(row, col), this.handle);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Advances the 'localSeq' counter for the cell data operation currently being queued.\n\t *\n\t * Do not use with 'submitColMessage()/submitRowMessage()' as these helpers + the MergeTree will\n\t * automatically advance 'localSeq'.\n\t */\n\tprivate nextLocalSeq(): number {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally bump each MergeTree's 'localSeq' counter\n\t\t// for SharedMatrix ops it's not aware of to keep them synchronized. (For cell data operations, we\n\t\t// need to bump both counters.)\n\n\t\tthis.cols.getCollabWindow().localSeq++;\n\t\treturn ++this.rows.getCollabWindow().localSeq;\n\t}\n\n\tprotected submitLocalMessage(message: unknown, localOpMetadata?: unknown): void {\n\t\t// TODO: Recommend moving this assertion into SharedObject\n\t\t// (See https://github.com/microsoft/FluidFramework/issues/2559)\n\t\tassert(\n\t\t\tthis.isAttached() === true,\n\t\t\t0x01d /* \"Trying to submit message to runtime while detached!\" */,\n\t\t);\n\n\t\tthis.inFlightRefSeqs.push(this.deltaManager.lastSequenceNumber);\n\t\tsuper.submitLocalMessage(message, localOpMetadata);\n\n\t\t// Ensure that row/col 'localSeq' are synchronized (see 'nextLocalSeq()').\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq,\n\t\t\t0x01e /* \"Row and col collab window 'localSeq' desynchronized!\" */,\n\t\t);\n\t}\n\n\tprotected didAttach(): void {\n\t\t// We've attached we need to start generating and sending ops.\n\t\t// so start collaboration and provide a default client id incase we are not connected\n\t\tif (this.isAttached()) {\n\t\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t}\n\t}\n\n\tprotected onConnect(): void {\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().collaborating === this.cols.getCollabWindow().collaborating,\n\t\t\t0x01f /* \"Row and col collab window 'collaborating' status desynchronized!\" */,\n\t\t);\n\n\t\t// Update merge tree collaboration information with new client ID and then resend pending ops\n\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t}\n\n\tprivate rebasePosition(\n\t\tclient: Client,\n\t\tref: LocalReferencePosition,\n\t\tlocalSeq: number,\n\t): number | undefined {\n\t\tconst segment: ISegmentInternal | undefined = ref.getSegment();\n\t\tconst offset = ref.getOffset();\n\t\t// If the segment that contains the position is removed, then this setCell op should do nothing.\n\t\tif (segment === undefined || offset === undefined || segmentIsRemoved(segment)) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn client.findReconnectionPosition(segment, localSeq) + offset;\n\t}\n\n\tprotected reSubmitCore(incoming: unknown, localOpMetadata: unknown): void {\n\t\tconst originalRefSeq = this.inFlightRefSeqs.shift();\n\t\tassert(\n\t\t\toriginalRefSeq !== undefined,\n\t\t\t0x8b9 /* Expected a recorded refSeq when resubmitting an op */,\n\t\t);\n\t\tconst content = incoming as MatrixSetOrVectorOp<T>;\n\n\t\tif (content.type === MatrixOp.set && content.target === undefined) {\n\t\t\tconst setOp = content;\n\t\t\tconst { rowHandle, colHandle, localSeq, rowsRef, colsRef, referenceSeqNumber } =\n\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\n\t\t\t// If after rebasing the op, we get a valid row/col number, that means the row/col\n\t\t\t// handles have not been recycled and we can safely use them.\n\t\t\tconst row = this.rebasePosition(this.rows, rowsRef, localSeq);\n\t\t\tconst col = this.rebasePosition(this.cols, colsRef, localSeq);\n\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\n\n\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\tassert(pendingCell !== undefined, 0xba4 /* local operation must have a pending array */);\n\t\t\tconst { local } = pendingCell;\n\t\t\tassert(local !== undefined, 0xba5 /* local operation must have a pending array */);\n\t\t\tconst localSeqIndex = local.findIndex((p) => p.localSeq === localSeq);\n\t\t\tassert(localSeqIndex >= 0, 0xba6 /* local operation must have a pending entry */);\n\t\t\tconst [change] = local.splice(localSeqIndex, 1);\n\t\t\tassert(change.localSeq === localSeq, 0xba7 /* must match */);\n\n\t\t\tif (\n\t\t\t\trow !== undefined &&\n\t\t\t\tcol !== undefined &&\n\t\t\t\trow >= 0 &&\n\t\t\t\tcol >= 0 && // If the mode is LWW, then send the op.\n\t\t\t\t// Otherwise if the current mode is FWW and if we generated this op, after seeing the\n\t\t\t\t// last set op, or it is the first set op for the cell, then regenerate the op,\n\t\t\t\t// otherwise raise conflict. We want to check the current mode here and not that\n\t\t\t\t// whether op was made in FWW or not.\n\t\t\t\t(this.fwwPolicy.state !== \"on\" ||\n\t\t\t\t\treferenceSeqNumber >=\n\t\t\t\t\t\t(this.fwwPolicy.cellLastWriteTracker.getCell(rowHandle, colHandle)?.seqNum ?? 0))\n\t\t\t) {\n\t\t\t\tthis.sendSetCellOp(row, col, setOp.value, rowHandle, colHandle, localSeq);\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (content.target) {\n\t\t\t\tcase SnapshotPath.cols: {\n\t\t\t\t\tthis.submitColMessage(\n\t\t\t\t\t\tthis.cols.regeneratePendingOp(content, localOpMetadata, false),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SnapshotPath.rows: {\n\t\t\t\t\tthis.submitRowMessage(\n\t\t\t\t\t\tthis.rows.regeneratePendingOp(content, localOpMetadata, false),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(content);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tconst contents = content as MatrixSetOrVectorOp<T>;\n\t\tconst target = contents.target;\n\n\t\tswitch (target) {\n\t\t\tcase SnapshotPath.cols: {\n\t\t\t\tthis.cols.rollback(content, localOpMetadata);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SnapshotPath.rows: {\n\t\t\t\tthis.rows.rollback(content, localOpMetadata);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase undefined: {\n\t\t\t\tassert(contents.type === MatrixOp.set, 0xba8 /* only sets supported */);\n\t\t\t\tconst setMetadata = localOpMetadata as ISetOpMetadata;\n\n\t\t\t\tconst pendingCell = this.pending.getCell(setMetadata.rowHandle, setMetadata.colHandle);\n\t\t\t\tassert(pendingCell !== undefined, 0xba9 /* must have pending */);\n\n\t\t\t\tconst change = pendingCell.local.pop();\n\t\t\t\tassert(change?.localSeq === setMetadata.localSeq, 0xbaa /* must have change */);\n\n\t\t\t\tconst previous =\n\t\t\t\t\tpendingCell.local.length > 0\n\t\t\t\t\t\t? pendingCell.local[pendingCell.local.length - 1].value\n\t\t\t\t\t\t: pendingCell.consensus;\n\n\t\t\t\tthis.setCellCore(\n\t\t\t\t\tcontents.row,\n\t\t\t\t\tcontents.col,\n\t\t\t\t\tprevious,\n\t\t\t\t\tsetMetadata.rowHandle,\n\t\t\t\t\tsetMetadata.colHandle,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t}\n\t\t\tdefault:\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\ttry {\n\t\t\tawait this.rows.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.rows),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tawait this.cols.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.cols),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tconst [\n\t\t\t\tcellData,\n\t\t\t\t_pendingCliSeqData,\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber,\n\t\t\t\tcellLastWriteTracker,\n\t\t\t\t// Cast is needed since the (de)serializer returns content of type `any`.\n\t\t\t] = (await deserializeBlob(storage, SnapshotPath.cells, this.serializer)) as [\n\t\t\t\tRecurArray<MatrixItem<T>>,\n\t\t\t\tunknown,\n\t\t\t\tnumber,\n\t\t\t\tRecurArray<CellLastWriteTrackerItem>,\n\t\t\t];\n\n\t\t\tthis.cells = SparseArray2D.load(cellData);\n\t\t\t// back-compat: used -1 for disabled, also may not exist\n\t\t\tconst switchOpSeqNumber =\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber === -1\n\t\t\t\t\t? undefined\n\t\t\t\t\t: (setCellLwwToFwwPolicySwitchOpSeqNumber ?? undefined);\n\t\t\tthis.fwwPolicy =\n\t\t\t\tswitchOpSeqNumber === undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstate: \"off\",\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\t\tswitchOpSeqNumber,\n\t\t\t\t\t\t\tcellLastWriteTracker: SparseArray2D.load(cellLastWriteTracker),\n\t\t\t\t\t\t};\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"MatrixLoadFailed\" }, error);\n\t\t}\n\t}\n\n\t/**\n\t * Tells whether the setCell op should be applied or not based on First Write Win policy. It assumes\n\t * we are in FWW mode.\n\t */\n\tprivate shouldSetCellBasedOnFWW(\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tmessage: ISequencedDocumentMessage,\n\t): boolean {\n\t\tassert(\n\t\t\tthis.fwwPolicy.state === \"on\",\n\t\t\t0x85f /* should be in Fww mode when calling this method */,\n\t\t);\n\t\tassert(message.clientId !== null, 0x860 /* clientId should not be null */);\n\t\tconst lastCellModificationDetails = this.fwwPolicy.cellLastWriteTracker.getCell(\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t);\n\t\t// If someone tried to Overwrite the cell value or first write on this cell or\n\t\t// same client tried to modify the cell.\n\t\treturn (\n\t\t\tlastCellModificationDetails === undefined ||\n\t\t\tlastCellModificationDetails.clientId === message.clientId ||\n\t\t\tmessage.referenceSequenceNumber >= lastCellModificationDetails.seqNum\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// Reconstruct the ISequencedDocumentMessage which is needed by merge tree client.\n\t\tconst msg: ISequencedDocumentMessage = {\n\t\t\t...messageEnvelope,\n\t\t\tcontents: messageContent.contents,\n\t\t\tclientSequenceNumber: messageContent.clientSequenceNumber,\n\t\t};\n\t\tconst localOpMetadata = messageContent.localOpMetadata;\n\t\tif (local) {\n\t\t\tconst recordedRefSeq = this.inFlightRefSeqs.shift();\n\t\t\tassert(recordedRefSeq !== undefined, 0x8ba /* No pending recorded refSeq found */);\n\t\t\t// TODO: AB#7076: Some equivalent assert should be enabled. This fails some e2e stashed op tests because\n\t\t\t// the deltaManager may have seen more messages than the runtime has processed while amidst the stashed op\n\t\t\t// flow, so e.g. when `applyStashedOp` is called and the DDS is put in a state where it expects an ack for\n\t\t\t// one of its messages, the delta manager has actually already seen subsequent messages from collaborators\n\t\t\t// which the in-flight message is concurrent to.\n\t\t\t// See \"handles stashed ops created on top of sequenced local ops\" for one such test case.\n\t\t\t// assert(recordedRefSeq <= message.referenceSequenceNumber, \"RefSeq mismatch\");\n\t\t}\n\n\t\tconst contents = messageContent.contents as MatrixSetOrVectorOp<T>;\n\t\tconst target = contents.target;\n\n\t\tswitch (target) {\n\t\t\tcase SnapshotPath.cols: {\n\t\t\t\tthis.cols.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SnapshotPath.rows: {\n\t\t\t\tthis.rows.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase undefined: {\n\t\t\t\tassert(\n\t\t\t\t\tcontents.type === MatrixOp.set,\n\t\t\t\t\t0x021 /* \"SharedMatrix message contents have unexpected type!\" */,\n\t\t\t\t);\n\n\t\t\t\tconst { row, col, value, fwwMode } = contents;\n\t\t\t\t// If this is the first op notifying us of the policy change, then set the policy change seq number.\n\t\t\t\tif (fwwMode === true && this.fwwPolicy.state !== \"on\") {\n\t\t\t\t\tthis.fwwPolicy = {\n\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\tswitchOpSeqNumber: msg.sequenceNumber,\n\t\t\t\t\t\tcellLastWriteTracker: new SparseArray2D(),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tassert(msg.clientId !== null, 0x861 /* clientId should not be null!! */);\n\t\t\t\tif (local) {\n\t\t\t\t\t// We are receiving the ACK for a local pending set operation.\n\t\t\t\t\tconst { rowHandle, colHandle, localSeq, rowsRef, colsRef } =\n\t\t\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\t\t\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\n\n\t\t\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\t\t\tconst ackedChange = pendingCell?.local.shift();\n\t\t\t\t\tassert(ackedChange?.localSeq === localSeq, 0xbab /* must match */);\n\t\t\t\t\tif (pendingCell?.local.length === 0) {\n\t\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If policy is switched and cell should be modified too based on policy, then update the tracker.\n\t\t\t\t\t// If policy is not switched, then also update the tracker in case it is the latest.\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.fwwPolicy.state === \"on\" &&\n\t\t\t\t\t\tthis.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tpendingCell!.consensus = ackedChange.value;\n\t\t\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst adjustedRow = this.rows.adjustPosition(row, msg);\n\t\t\t\t\tconst adjustedCol = this.cols.adjustPosition(col, msg);\n\n\t\t\t\t\tconst rowHandle = adjustedRow.handle;\n\t\t\t\t\tconst colHandle = adjustedCol.handle;\n\n\t\t\t\t\tassert(\n\t\t\t\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t\t\t\t0x022 /* \"SharedMatrix row and/or col handles are invalid!\" */,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingCell = this.pending.getCell(rowHandle, colHandle);\n\t\t\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\t\t\t// If someone tried to Overwrite the cell value or first write on this cell or\n\t\t\t\t\t\t// same client tried to modify the cell or if the previous mode was LWW, then we need to still\n\t\t\t\t\t\t// overwrite the cell and raise conflict if we have pending changes as our change is going to be lost.\n\t\t\t\t\t\tif (this.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)) {\n\t\t\t\t\t\t\tconst previousValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\tthis.fwwPolicy.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (pendingCell !== undefined) {\n\t\t\t\t\t\t\t\tpendingCell.consensus = value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (adjustedRow.pos !== undefined && adjustedCol.pos !== undefined) {\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow.pos, adjustedCol.pos, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Check is there are any pending changes, which will be rejected. If so raise conflict.\n\t\t\t\t\t\t\t\tif (pendingCell !== undefined && pendingCell.local.length > 0) {\n\t\t\t\t\t\t\t\t\t// Don't reset the pending value yet, as there maybe more fww op from same client, so we want\n\t\t\t\t\t\t\t\t\t// to raise conflict event for that op also.\n\t\t\t\t\t\t\t\t\tthis.emit(\n\t\t\t\t\t\t\t\t\t\t\"conflict\",\n\t\t\t\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\t\t\t\tcol,\n\t\t\t\t\t\t\t\t\t\tvalue, // Current value\n\t\t\t\t\t\t\t\t\t\tpreviousValue, // Ignored local value\n\t\t\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (pendingCell === undefined || pendingCell.local.length === 0) {\n\t\t\t\t\t\t\t// If there is a pending (unACKed) local write to the same cell, skip the current op\n\t\t\t\t\t\t\t// since it \"happened before\" the pending write.\n\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\tif (adjustedRow.pos !== undefined && adjustedCol.pos !== undefined) {\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow.pos, adjustedCol.pos, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpendingCell.consensus = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(target, \"unknown target\");\n\t\t\t}\n\t\t}\n\t}\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of row insertion/deletions.\n\tprivate readonly onRowDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t): void => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.rowsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of col insertion/deletions.\n\tprivate readonly onColDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t): void => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.colsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\tprivate readonly onRowHandlesRecycled = (rowHandles: Handle[]): void => {\n\t\tfor (const rowHandle of rowHandles) {\n\t\t\tthis.cells.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tthis.pending.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker?.clearRows(\n\t\t\t\t\t/* rowStart: */ rowHandle,\n\t\t\t\t\t/* rowCount: */ 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate readonly onColHandlesRecycled = (colHandles: Handle[]): void => {\n\t\tfor (const colHandle of colHandles) {\n\t\t\tthis.cells.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tthis.pending.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tif (this.fwwPolicy.state === \"on\") {\n\t\t\t\tthis.fwwPolicy.cellLastWriteTracker?.clearCols(\n\t\t\t\t\t/* colStart: */ colHandle,\n\t\t\t\t\t/* colCount: */ 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic switchSetCellPolicy(): void {\n\t\tif (this.fwwPolicy.state === \"off\") {\n\t\t\tthis.fwwPolicy = this.isAttached()\n\t\t\t\t? { state: \"local\" }\n\t\t\t\t: {\n\t\t\t\t\t\tstate: \"on\",\n\t\t\t\t\t\tswitchOpSeqNumber: 0,\n\t\t\t\t\t\tcellLastWriteTracker: new SparseArray2D(),\n\t\t\t\t\t};\n\t\t}\n\t}\n\n\tpublic toString(): string {\n\t\tlet s = `client:${\n\t\t\tthis.runtime.clientId\n\t\t}\\nrows: ${this.rows.toString()}\\ncols: ${this.cols.toString()}\\n\\n`;\n\n\t\tfor (let r = 0; r < this.rowCount; r++) {\n\t\t\ts += ` [`;\n\t\t\tfor (let c = 0; c < this.colCount; c++) {\n\t\t\t\tif (c > 0) {\n\t\t\t\t\ts += \", \";\n\t\t\t\t}\n\n\t\t\t\ts += `${this.serializer.stringify(this.getCell(r, c), this.handle)}`;\n\t\t\t}\n\t\t\ts += \"]\\n\";\n\t\t}\n\n\t\treturn `${s}\\n`;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(_content: unknown): void {\n\t\tconst content = _content as MatrixSetOrVectorOp<T>;\n\t\tif (content.type === MatrixOp.set && content.target === undefined) {\n\t\t\tif (content.fwwMode === true) {\n\t\t\t\tthis.switchSetCellPolicy();\n\t\t\t}\n\t\t\tthis.setCell(content.row, content.col, content.value);\n\t\t} else {\n\t\t\tconst vector = content.target === SnapshotPath.cols ? this.cols : this.rows;\n\t\t\tvector.applyStashedOp(content);\n\t\t\tif (content.target === SnapshotPath.cols) {\n\t\t\t\tthis.submitColMessage(content);\n\t\t\t} else {\n\t\t\t\tthis.submitRowMessage(content);\n\t\t\t}\n\t\t}\n\t}\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.70.0-361248";
8
+ export declare const pkgVersion = "2.70.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,kBAAkB,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,WAAW,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 = "2.70.0-361248";
8
+ export const pkgVersion = "2.70.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,eAAe,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.70.0-361248\";\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,QAAQ,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.70.0\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/matrix",
3
- "version": "2.70.0-361248",
3
+ "version": "2.70.0",
4
4
  "description": "Distributed matrix",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -81,17 +81,17 @@
81
81
  "temp-directory": "nyc/.nyc_output"
82
82
  },
83
83
  "dependencies": {
84
- "@fluid-internal/client-utils": "2.70.0-361248",
85
- "@fluidframework/core-interfaces": "2.70.0-361248",
86
- "@fluidframework/core-utils": "2.70.0-361248",
87
- "@fluidframework/datastore-definitions": "2.70.0-361248",
88
- "@fluidframework/driver-definitions": "2.70.0-361248",
89
- "@fluidframework/driver-utils": "2.70.0-361248",
90
- "@fluidframework/merge-tree": "2.70.0-361248",
91
- "@fluidframework/runtime-definitions": "2.70.0-361248",
92
- "@fluidframework/runtime-utils": "2.70.0-361248",
93
- "@fluidframework/shared-object-base": "2.70.0-361248",
94
- "@fluidframework/telemetry-utils": "2.70.0-361248",
84
+ "@fluid-internal/client-utils": "~2.70.0",
85
+ "@fluidframework/core-interfaces": "~2.70.0",
86
+ "@fluidframework/core-utils": "~2.70.0",
87
+ "@fluidframework/datastore-definitions": "~2.70.0",
88
+ "@fluidframework/driver-definitions": "~2.70.0",
89
+ "@fluidframework/driver-utils": "~2.70.0",
90
+ "@fluidframework/merge-tree": "~2.70.0",
91
+ "@fluidframework/runtime-definitions": "~2.70.0",
92
+ "@fluidframework/runtime-utils": "~2.70.0",
93
+ "@fluidframework/shared-object-base": "~2.70.0",
94
+ "@fluidframework/telemetry-utils": "~2.70.0",
95
95
  "@tiny-calc/nano": "0.0.0-alpha.5",
96
96
  "double-ended-queue": "^2.1.0-0",
97
97
  "tslib": "^1.10.0"
@@ -99,17 +99,17 @@
99
99
  "devDependencies": {
100
100
  "@arethetypeswrong/cli": "^0.17.1",
101
101
  "@biomejs/biome": "~1.9.3",
102
- "@fluid-internal/mocha-test-setup": "2.70.0-361248",
103
- "@fluid-private/stochastic-test-utils": "2.70.0-361248",
104
- "@fluid-private/test-dds-utils": "2.70.0-361248",
102
+ "@fluid-internal/mocha-test-setup": "~2.70.0",
103
+ "@fluid-private/stochastic-test-utils": "~2.70.0",
104
+ "@fluid-private/test-dds-utils": "~2.70.0",
105
105
  "@fluid-tools/benchmark": "^0.51.0",
106
106
  "@fluid-tools/build-cli": "^0.58.3",
107
107
  "@fluidframework/build-common": "^2.0.3",
108
108
  "@fluidframework/build-tools": "^0.58.3",
109
- "@fluidframework/container-definitions": "2.70.0-361248",
109
+ "@fluidframework/container-definitions": "~2.70.0",
110
110
  "@fluidframework/eslint-config-fluid": "^6.1.0",
111
111
  "@fluidframework/matrix-previous": "npm:@fluidframework/matrix@2.63.0",
112
- "@fluidframework/test-runtime-utils": "2.70.0-361248",
112
+ "@fluidframework/test-runtime-utils": "~2.70.0",
113
113
  "@microsoft/api-extractor": "7.52.11",
114
114
  "@tiny-calc/micro": "0.0.0-alpha.5",
115
115
  "@types/double-ended-queue": "^2.1.0",
package/src/matrix.ts CHANGED
@@ -26,7 +26,12 @@ import {
26
26
  ReferenceType,
27
27
  segmentIsRemoved,
28
28
  } from "@fluidframework/merge-tree/internal";
29
- import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
29
+ import type {
30
+ ISummaryTreeWithStats,
31
+ IRuntimeMessageCollection,
32
+ IRuntimeMessagesContent,
33
+ ISequencedMessageEnvelope,
34
+ } from "@fluidframework/runtime-definitions/internal";
30
35
  import {
31
36
  ObjectStoragePartition,
32
37
  SummaryTreeBuilder,
@@ -996,11 +1001,28 @@ export class SharedMatrix<T = any>
996
1001
  );
997
1002
  }
998
1003
 
999
- protected processCore(
1000
- msg: ISequencedDocumentMessage,
1004
+ /**
1005
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}
1006
+ */
1007
+ protected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {
1008
+ const { envelope, local, messagesContent } = messagesCollection;
1009
+ for (const messageContent of messagesContent) {
1010
+ this.processMessage(envelope, messageContent, local);
1011
+ }
1012
+ }
1013
+
1014
+ private processMessage(
1015
+ messageEnvelope: ISequencedMessageEnvelope,
1016
+ messageContent: IRuntimeMessagesContent,
1001
1017
  local: boolean,
1002
- localOpMetadata: unknown,
1003
1018
  ): void {
1019
+ // Reconstruct the ISequencedDocumentMessage which is needed by merge tree client.
1020
+ const msg: ISequencedDocumentMessage = {
1021
+ ...messageEnvelope,
1022
+ contents: messageContent.contents,
1023
+ clientSequenceNumber: messageContent.clientSequenceNumber,
1024
+ };
1025
+ const localOpMetadata = messageContent.localOpMetadata;
1004
1026
  if (local) {
1005
1027
  const recordedRefSeq = this.inFlightRefSeqs.shift();
1006
1028
  assert(recordedRefSeq !== undefined, 0x8ba /* No pending recorded refSeq found */);
@@ -1013,7 +1035,7 @@ export class SharedMatrix<T = any>
1013
1035
  // assert(recordedRefSeq <= message.referenceSequenceNumber, "RefSeq mismatch");
1014
1036
  }
1015
1037
 
1016
- const contents = msg.contents as MatrixSetOrVectorOp<T>;
1038
+ const contents = messageContent.contents as MatrixSetOrVectorOp<T>;
1017
1039
  const target = contents.target;
1018
1040
 
1019
1041
  switch (target) {
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/matrix";
9
- export const pkgVersion = "2.70.0-361248";
9
+ export const pkgVersion = "2.70.0";