@fluidframework/matrix 2.0.0-rc.2.0.5 → 2.0.0-rc.2.0.7

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.
@@ -64,7 +64,7 @@ export type MatrixItem<T> = Serializable<Exclude<T, null>> | undefined;
64
64
  // @alpha
65
65
  export class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T> & ISharedObjectEvents> implements ISharedMatrix<T> {
66
66
  constructor(runtime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, _isSetCellConflictResolutionPolicyFWW?: boolean);
67
- protected applyStashedOp(_content: unknown): void;
67
+ protected applyStashedOp(content: unknown): void;
68
68
  // (undocumented)
69
69
  closeMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): void;
70
70
  // (undocumented)
@@ -95,7 +95,7 @@ export class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T> &
95
95
  openMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): IMatrixReader<MatrixItem<T>>;
96
96
  openUndo(consumer: IUndoConsumer): void;
97
97
  // (undocumented)
98
- protected processCore(msg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
98
+ protected processCore(rawMessage: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
99
99
  protected processGCDataCore(serializer: IFluidSerializer): void;
100
100
  // (undocumented)
101
101
  removeCols(colStart: number, count: number): void;
@@ -129,7 +129,7 @@ export class SharedMatrixFactory implements IChannelFactory {
129
129
  // (undocumented)
130
130
  get attributes(): IChannelAttributes;
131
131
  // (undocumented)
132
- create(document: IFluidDataStoreRuntime, id: string): SharedMatrix;
132
+ create(document: IFluidDataStoreRuntime, id: string): IChannel;
133
133
  load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IChannel>;
134
134
  // (undocumented)
135
135
  static Type: string;
@@ -190,7 +190,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
190
190
  * we are in FWW mode.
191
191
  */
192
192
  private shouldSetCellBasedOnFWW;
193
- protected processCore(msg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
193
+ protected processCore(rawMessage: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
194
194
  private readonly onRowDelta;
195
195
  private readonly onColDelta;
196
196
  private readonly onRowHandlesRecycled;
@@ -213,7 +213,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
213
213
  /**
214
214
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
215
215
  */
216
- protected applyStashedOp(_content: unknown): void;
216
+ protected applyStashedOp(content: unknown): void;
217
217
  }
218
218
 
219
219
  /**
@@ -229,7 +229,7 @@ export declare class SharedMatrixFactory implements IChannelFactory {
229
229
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
230
230
  */
231
231
  load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IChannel>;
232
- create(document: IFluidDataStoreRuntime, id: string): SharedMatrix;
232
+ create(document: IFluidDataStoreRuntime, id: string): IChannel;
233
233
  }
234
234
 
235
235
  export { }
@@ -190,7 +190,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
190
190
  * we are in FWW mode.
191
191
  */
192
192
  private shouldSetCellBasedOnFWW;
193
- protected processCore(msg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
193
+ protected processCore(rawMessage: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
194
194
  private readonly onRowDelta;
195
195
  private readonly onColDelta;
196
196
  private readonly onRowHandlesRecycled;
@@ -213,7 +213,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
213
213
  /**
214
214
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
215
215
  */
216
- protected applyStashedOp(_content: unknown): void;
216
+ protected applyStashedOp(content: unknown): void;
217
217
  }
218
218
 
219
219
  /**
@@ -229,7 +229,7 @@ export declare class SharedMatrixFactory implements IChannelFactory {
229
229
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
230
230
  */
231
231
  load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IChannel>;
232
- create(document: IFluidDataStoreRuntime, id: string): SharedMatrix;
232
+ create(document: IFluidDataStoreRuntime, id: string): IChannel;
233
233
  }
234
234
 
235
235
  export { }
package/dist/matrix.d.ts CHANGED
@@ -159,7 +159,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
159
159
  * we are in FWW mode.
160
160
  */
161
161
  private shouldSetCellBasedOnFWW;
162
- protected processCore(msg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
162
+ protected processCore(rawMessage: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
163
163
  private readonly onRowDelta;
164
164
  private readonly onColDelta;
165
165
  private readonly onRowHandlesRecycled;
@@ -182,6 +182,6 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
182
182
  /**
183
183
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
184
184
  */
185
- protected applyStashedOp(_content: unknown): void;
185
+ protected applyStashedOp(content: unknown): void;
186
186
  }
187
187
  //# sourceMappingURL=matrix.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,MAAM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AS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IA2B5E;;;OAGG;IACH,SAAS,CAAC,iBAAiB,CAAC,UAAU,EAAE,gBAAgB;IAQxD;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAUpB,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,GAAG;IAqBhE,SAAS,CAAC,SAAS;IASnB,SAAS,CAAC,SAAS;IAWnB,OAAO,CAAC,cAAc;IAsBtB,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;IAiElE,SAAS,CAAC,YAAY;IAEtB;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB;IA8BxD;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAoB/B,SAAS,CAAC,WAAW,CACpB,UAAU,EAAE,yBAAyB,EACrC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO;IAsIzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAQzB;IAGF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAQzB;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAMnC;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAMnC;IAEF;;;OAGG;IACI,mBAAmB;IAU1B;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAiBrB,QAAQ;IAoBf;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAkBhD"}
package/dist/matrix.js CHANGED
@@ -404,7 +404,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
404
404
  // (See https://github.com/microsoft/FluidFramework/issues/2559)
405
405
  (0, core_utils_1.assert)(this.isAttached() === true, 0x01d /* "Trying to submit message to runtime while detached!" */);
406
406
  this.inFlightRefSeqs.push(this.runtime.deltaManager.lastSequenceNumber);
407
- super.submitLocalMessage(message, localOpMetadata);
407
+ super.submitLocalMessage((0, shared_object_base_1.makeHandlesSerializable)(message, this.serializer, this.handle), localOpMetadata);
408
408
  // Ensure that row/col 'localSeq' are synchronized (see 'nextLocalSeq()').
409
409
  (0, core_utils_1.assert)(this.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq, 0x01e /* "Row and col collab window 'localSeq' desynchronized!" */);
410
410
  }
@@ -514,7 +514,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
514
514
  lastCellModificationDetails.clientId === message.clientId ||
515
515
  message.referenceSequenceNumber >= lastCellModificationDetails.seqNum);
516
516
  }
517
- processCore(msg, local, localOpMetadata) {
517
+ processCore(rawMessage, local, localOpMetadata) {
518
518
  if (local) {
519
519
  const recordedRefSeq = this.inFlightRefSeqs.shift();
520
520
  (0, core_utils_1.assert)(recordedRefSeq !== undefined, 0x8ba /* No pending recorded refSeq found */);
@@ -526,6 +526,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
526
526
  // See "handles stashed ops created on top of sequenced local ops" for one such test case.
527
527
  // assert(recordedRefSeq <= message.referenceSequenceNumber, "RefSeq mismatch");
528
528
  }
529
+ const msg = (0, shared_object_base_1.parseHandles)(rawMessage, this.serializer);
529
530
  const contents = msg.contents;
530
531
  const target = contents.target;
531
532
  switch (target) {
@@ -541,9 +542,9 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
541
542
  const isPreviousSetCellPolicyModeFWW = this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1;
542
543
  // If this is the first op notifying us of the policy change, then set the policy change seq number.
543
544
  if (this.setCellLwwToFwwPolicySwitchOpSeqNumber === -1 && fwwMode === true) {
544
- this.setCellLwwToFwwPolicySwitchOpSeqNumber = msg.sequenceNumber;
545
+ this.setCellLwwToFwwPolicySwitchOpSeqNumber = rawMessage.sequenceNumber;
545
546
  }
546
- (0, core_utils_1.assert)(msg.clientId !== null, 0x861 /* clientId should not be null!! */);
547
+ (0, core_utils_1.assert)(rawMessage.clientId !== null, 0x861 /* clientId should not be null!! */);
547
548
  if (local) {
548
549
  // We are receiving the ACK for a local pending set operation.
549
550
  const { rowHandle, colHandle, localSeq, rowsRef, colsRef } = localOpMetadata;
@@ -553,11 +554,11 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
553
554
  // If policy is switched and cell should be modified too based on policy, then update the tracker.
554
555
  // If policy is not switched, then also update the tracker in case it is the latest.
555
556
  if ((this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1 &&
556
- this.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)) ||
557
+ this.shouldSetCellBasedOnFWW(rowHandle, colHandle, rawMessage)) ||
557
558
  (this.setCellLwwToFwwPolicySwitchOpSeqNumber === -1 && isLatestPendingOp)) {
558
559
  this.cellLastWriteTracker.setCell(rowHandle, colHandle, {
559
- seqNum: msg.sequenceNumber,
560
- clientId: msg.clientId,
560
+ seqNum: rawMessage.sequenceNumber,
561
+ clientId: rawMessage.clientId,
561
562
  });
562
563
  }
563
564
  if (isLatestPendingOp) {
@@ -565,9 +566,9 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
565
566
  }
566
567
  }
567
568
  else {
568
- const adjustedRow = this.rows.adjustPosition(row, msg);
569
+ const adjustedRow = this.rows.adjustPosition(row, rawMessage);
569
570
  if (adjustedRow !== undefined) {
570
- const adjustedCol = this.cols.adjustPosition(col, msg);
571
+ const adjustedCol = this.cols.adjustPosition(col, rawMessage);
571
572
  if (adjustedCol !== undefined) {
572
573
  const rowHandle = this.rows.getAllocatedHandle(adjustedRow);
573
574
  const colHandle = this.cols.getAllocatedHandle(adjustedCol);
@@ -577,12 +578,12 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
577
578
  // same client tried to modify the cell or if the previous mode was LWW, then we need to still
578
579
  // overwrite the cell and raise conflict if we have pending changes as our change is going to be lost.
579
580
  if (!isPreviousSetCellPolicyModeFWW ||
580
- this.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)) {
581
+ this.shouldSetCellBasedOnFWW(rowHandle, colHandle, rawMessage)) {
581
582
  const previousValue = this.cells.getCell(rowHandle, colHandle);
582
583
  this.cells.setCell(rowHandle, colHandle, value);
583
584
  this.cellLastWriteTracker.setCell(rowHandle, colHandle, {
584
- seqNum: msg.sequenceNumber,
585
- clientId: msg.clientId,
585
+ seqNum: rawMessage.sequenceNumber,
586
+ clientId: rawMessage.clientId,
586
587
  });
587
588
  for (const consumer of this.consumers.values()) {
588
589
  consumer.cellsChanged(adjustedRow, adjustedCol, 1, 1, this);
@@ -602,8 +603,8 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
602
603
  // since it "happened before" the pending write.
603
604
  this.cells.setCell(rowHandle, colHandle, value);
604
605
  this.cellLastWriteTracker.setCell(rowHandle, colHandle, {
605
- seqNum: msg.sequenceNumber,
606
- clientId: msg.clientId,
606
+ seqNum: rawMessage.sequenceNumber,
607
+ clientId: rawMessage.clientId,
607
608
  });
608
609
  for (const consumer of this.consumers.values()) {
609
610
  consumer.cellsChanged(adjustedRow, adjustedCol, 1, 1, this);
@@ -668,22 +669,22 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
668
669
  /**
669
670
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
670
671
  */
671
- applyStashedOp(_content) {
672
- const content = _content;
673
- if (content.type === ops_js_1.MatrixOp.set && content.target === undefined) {
674
- if (content.fwwMode === true) {
672
+ applyStashedOp(content) {
673
+ const parsedContent = (0, shared_object_base_1.parseHandles)(content, this.serializer);
674
+ if (parsedContent.type === ops_js_1.MatrixOp.set && parsedContent.target === undefined) {
675
+ if (parsedContent.fwwMode === true) {
675
676
  this.switchSetCellPolicy();
676
677
  }
677
- this.setCell(content.row, content.col, content.value);
678
+ this.setCell(parsedContent.row, parsedContent.col, parsedContent.value);
678
679
  }
679
680
  else {
680
- const vector = content.target === ops_js_1.SnapshotPath.cols ? this.cols : this.rows;
681
- vector.applyStashedOp(content);
682
- if (content.target === ops_js_1.SnapshotPath.cols) {
683
- this.submitColMessage(content);
681
+ const vector = parsedContent.target === ops_js_1.SnapshotPath.cols ? this.cols : this.rows;
682
+ vector.applyStashedOp(parsedContent);
683
+ if (parsedContent.target === ops_js_1.SnapshotPath.cols) {
684
+ this.submitColMessage(parsedContent);
684
685
  }
685
686
  else {
686
- this.submitRowMessage(content);
687
+ this.submitRowMessage(parsedContent);
687
688
  }
688
689
  }
689
690
  }
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4EAAuC;AACvC,2DAAqE;AAQrE,2EAI4C;AAE5C,iEAA2F;AAE3F,2DASoC;AACpC,qEAA6D;AAC7D,iEAAsF;AACtF,yDAAmD;AACnD,6CAAmD;AACnD,qDAAyD;AACzD,yDAAqD;AACrD,yCAAyC;AAEzC,uDAAuD;AACvD,qCAOkB;AAqElB;;;;;;;;;;;;GAYG;AACH,MAAa,YACZ,SAAQ,iCAA0D;IAK3D,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,gCAAmB,EAAE,CAAC;IAClC,CAAC;IA0BD;;;;;;;OAOG;IACH,YACC,OAA+B,EACxB,EAAU,EACjB,UAA8B,EAC9B,qCAA+C;QAE/C,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;QAJzC,OAAE,GAAF,EAAE,CAAQ;QAxCD,cAAS,GAAG,IAAI,GAAG,EAAkC,CAAC;QAMvE;;;;;;;;WAQG;QACc,oBAAe,GAAG,IAAI,4BAAK,EAAU,CAAC;QAK/C,UAAK,GAAG,IAAI,gCAAa,EAAiB,CAAC,CAAC,sBAAsB;QACzD,YAAO,GAAG,IAAI,gCAAa,EAAU,CAAC,CAAC,yBAAyB;QACzE,yBAAoB,GAAG,IAAI,gCAAa,EAA4B,CAAC,CAAC,6DAA6D;QAGnI,8BAAyB,GAAG,KAAK,CAAC,CAAC,gDAAgD;QAE3F,4DAA4D;QACpD,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AAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;SACtD;aAAM;YACN,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;gBACzC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;aAC/B;iBAAM;gBACN,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;aAC/B;SACD;IACF,CAAC;CACD;AAh6BD,oCAg6BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport Deque from \"double-ended-queue\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { IEventThisPlaceHolder, IEventProvider, IEvent } from \"@fluidframework/core-interfaces\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelAttributes,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidSerializer,\n\tISharedObjectEvents,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { IMatrixProducer, IMatrixConsumer, IMatrixReader, IMatrixWriter } from \"@tiny-calc/nano\";\nimport {\n\tMergeTreeDeltaType,\n\tIMergeTreeOp,\n\tSegmentGroup,\n\t// eslint-disable-next-line import/no-deprecated\n\tClient,\n\tIJSONSegment,\n\tReferenceType,\n\ttype LocalReferencePosition,\n} from \"@fluidframework/merge-tree\";\nimport { UsageError } from \"@fluidframework/telemetry-utils\";\nimport { PermutationVector, reinsertSegmentIntoVector } from \"./permutationvector.js\";\nimport { SparseArray2D } from \"./sparsearray2d.js\";\nimport { SharedMatrixFactory } from \"./runtime.js\";\nimport { Handle, isHandleValid } from \"./handletable.js\";\nimport { deserializeBlob } from \"./serialization.js\";\nimport { ensureRange } from \"./range.js\";\nimport { IUndoConsumer } from \"./types.js\";\nimport { MatrixUndoProvider } from \"./undoprovider.js\";\nimport {\n\tMatrixOp,\n\tMatrixItem,\n\tSnapshotPath,\n\tISetOp,\n\tVectorOp,\n\tMatrixSetOrVectorOp,\n} from \"./ops.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 * @alpha\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 SharedMatrix} 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/** @alpha */\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\tinsertCols(colStart: number, count: number): void;\n\tremoveCols(colStart: number, count: number): void;\n\tinsertRows(rowStart: number, count: number): void;\n\tremoveRows(rowStart: number, count: number): void;\n\n\topenUndo(consumer: IUndoConsumer): void;\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 * @alpha\n */\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\tpublic static getFactory() {\n\t\treturn new SharedMatrixFactory();\n\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\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<number>(); // Tracks pending writes.\n\tprivate cellLastWriteTracker = new SparseArray2D<CellLastWriteTrackerItem>(); // Tracks last writes sequence number and clientId in a cell.\n\t// Tracks the seq number of Op at which policy switch happens from Last Write Win to First Write Win.\n\tprivate setCellLwwToFwwPolicySwitchOpSeqNumber: number;\n\tprivate userSwitchedSetCellPolicy = false; // Set to true when the user calls switchPolicy.\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\t_isSetCellConflictResolutionPolicyFWW?: boolean,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_matrix_\");\n\n\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber =\n\t\t\t_isSetCellConflictResolutionPolicyFWW === true ? 0 : -1;\n\t\tconst getMinInFlightRefSeq = () => this.inFlightRefSeqs.get(0);\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\tgetMinInFlightRefSeq,\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\tgetMinInFlightRefSeq,\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) {\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() {\n\t\treturn this.rows.handleCache;\n\t}\n\tprivate get colHandles() {\n\t\treturn this.cols.handleCache;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic static create<T>(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedMatrixFactory.Type) as SharedMatrix<T>;\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() {\n\t\treturn this.rows.getLength();\n\t}\n\tpublic get colCount() {\n\t\treturn this.cols.getLength();\n\t}\n\n\tpublic isSetCellConflictResolutionPolicyFWW() {\n\t\treturn this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1 || this.userSwitchedSetCellPolicy;\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>) {\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) {\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) {\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tif (this.undo !== undefined) {\n\t\t\t\tlet oldValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (oldValue === null) {\n\t\t\t\t\toldValue = undefined;\n\t\t\t\t}\n\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()) {\n\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\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(vector: PermutationVector, pos: number, localSeq: number) {\n\t\tconst segoff = vector.getContainingSegment(pos, undefined, localSeq);\n\t\tassert(\n\t\t\tsegoff.segment !== undefined && segoff.offset !== undefined,\n\t\t\t0x8b3 /* expected valid position */,\n\t\t);\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) {\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:\n\t\t\t\tthis.userSwitchedSetCellPolicy || this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1,\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.runtime.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, metadata);\n\t\tthis.pending.setCell(rowHandle, colHandle, localSeq);\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) {\n\t\tassert(this.reentrantCount === 0, 0x85d /* reentrant code */);\n\t\tthis.reentrantCount++;\n\t\tcallback();\n\t\tthis.reentrantCount--;\n\t\tassert(this.reentrantCount === 0, 0x85e /* reentrant code on exit */);\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) {\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) {\n\t\tthis.submitVectorMessage(this.cols, this.rows, SnapshotPath.cols, message);\n\t}\n\n\tpublic insertCols(colStart: number, count: number) {\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) {\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) {\n\t\tthis.submitVectorMessage(this.rows, this.cols, SnapshotPath.rows, message);\n\t}\n\n\tpublic insertRows(rowStart: number, count: number) {\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) {\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) {\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) {\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\tthis.cells.snapshot(),\n\t\t\tthis.pending.snapshot(),\n\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber,\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.setCellLwwToFwwPolicySwitchOpSeqNumber > -1) {\n\t\t\tartifactsToSummarize.push(this.cellLastWriteTracker.snapshot());\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) {\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() {\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: any, localOpMetadata?: any) {\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.runtime.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() {\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() {\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\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t\tref: LocalReferencePosition,\n\t\tlocalSeq: number,\n\t): number | undefined {\n\t\tconst segment = 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 || segment.removedSeq !== undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\tsegment.localRemovedSeq === undefined ||\n\t\t\t\t(segment.localRemovedSeq !== undefined && segment.localRemovedSeq > localSeq),\n\t\t\t0x8b8 /* Attempted to set a cell which was removed locally before the original op applied. */,\n\t\t);\n\n\t\treturn client.findReconnectionPosition(segment, localSeq) + offset;\n\t}\n\n\tprotected reSubmitCore(incoming: unknown, localOpMetadata: unknown) {\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\t\t\tif (row !== undefined && col !== undefined && row >= 0 && col >= 0) {\n\t\t\t\tconst lastCellModificationDetails = this.cellLastWriteTracker.getCell(\n\t\t\t\t\trowHandle,\n\t\t\t\t\tcolHandle,\n\t\t\t\t);\n\t\t\t\t// 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\tif (\n\t\t\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber === -1 ||\n\t\t\t\t\tlastCellModificationDetails === undefined ||\n\t\t\t\t\treferenceSeqNumber >= lastCellModificationDetails.seqNum\n\t\t\t\t) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, setOp.value, rowHandle, colHandle, localSeq);\n\t\t\t\t} else if (this.pending.getCell(rowHandle, colHandle) !== undefined) {\n\t\t\t\t\t// Clear the pending changes if any as we are not sending the op.\n\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\n\t\t\t\t}\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(\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SnapshotPath.rows:\n\t\t\t\t\tthis.submitRowMessage(\n\t\t\t\t\t\tthis.rows.regeneratePendingOp(\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\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 onDisconnect() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService) {\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] = await deserializeBlob(storage, SnapshotPath.cells, this.serializer);\n\n\t\t\tthis.cells = SparseArray2D.load(cellData);\n\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber =\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber ?? -1;\n\t\t\tif (cellLastWriteTracker !== undefined) {\n\t\t\t\tthis.cellLastWriteTracker = SparseArray2D.load(cellLastWriteTracker);\n\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) {\n\t\tassert(\n\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber > -1,\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.cellLastWriteTracker.getCell(rowHandle, colHandle);\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) {\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\tcase SnapshotPath.rows:\n\t\t\t\tthis.rows.applyMsg(msg, local);\n\t\t\t\tbreak;\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\tconst isPreviousSetCellPolicyModeFWW =\n\t\t\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber > -1;\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 (this.setCellLwwToFwwPolicySwitchOpSeqNumber === -1 && fwwMode === true) {\n\t\t\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber = msg.sequenceNumber;\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\tconst isLatestPendingOp = this.isLatestPendingWrite(\n\t\t\t\t\t\trowHandle,\n\t\t\t\t\t\tcolHandle,\n\t\t\t\t\t\tlocalSeq,\n\t\t\t\t\t);\n\t\t\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\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\t(this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1 &&\n\t\t\t\t\t\t\tthis.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)) ||\n\t\t\t\t\t\t(this.setCellLwwToFwwPolicySwitchOpSeqNumber === -1 && isLatestPendingOp)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.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\n\t\t\t\t\tif (isLatestPendingOp) {\n\t\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\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\tif (adjustedRow !== undefined) {\n\t\t\t\t\t\tconst adjustedCol = this.cols.adjustPosition(col, msg);\n\n\t\t\t\t\t\tif (adjustedCol !== undefined) {\n\t\t\t\t\t\t\tconst rowHandle = this.rows.getAllocatedHandle(adjustedRow);\n\t\t\t\t\t\t\tconst colHandle = this.cols.getAllocatedHandle(adjustedCol);\n\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t\t\t\t\t\t0x022 /* \"SharedMatrix row and/or col handles are invalid!\" */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1) {\n\t\t\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\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\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\t\t\tif (\n\t\t\t\t\t\t\t\t\t!isPreviousSetCellPolicyModeFWW ||\n\t\t\t\t\t\t\t\t\tthis.shouldSetCellBasedOnFWW(rowHandle, colHandle, msg)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst previousValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\t\t\tthis.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow, adjustedCol, 1, 1, this);\n\t\t\t\t\t\t\t\t\t}\n\t\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\t\tif (this.pending.getCell(rowHandle, colHandle) !== undefined) {\n\t\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\t// to raise conflict event for that op also.\n\t\t\t\t\t\t\t\t\t\tthis.emit(\n\t\t\t\t\t\t\t\t\t\t\t\"conflict\",\n\t\t\t\t\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\t\t\t\t\tcol,\n\t\t\t\t\t\t\t\t\t\t\tvalue, // Current value\n\t\t\t\t\t\t\t\t\t\t\tpreviousValue, // Ignored local value\n\t\t\t\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\t\t\t);\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} else if (this.pending.getCell(rowHandle, colHandle) === undefined) {\n\t\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\t// since it \"happened before\" the pending write.\n\t\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\t\tthis.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\t\t\tseqNum: msg.sequenceNumber,\n\t\t\t\t\t\t\t\t\tclientId: msg.clientId,\n\t\t\t\t\t\t\t\t});\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, adjustedCol, 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}\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}\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) => {\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) => {\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[]) => {\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\tthis.cellLastWriteTracker.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t}\n\t};\n\n\tprivate readonly onColHandlesRecycled = (colHandles: Handle[]) => {\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\tthis.cellLastWriteTracker.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t}\n\t};\n\n\t/**\n\t * Api to switch Set Op policy from Last Writer Win to First Writer Win. It only switches from LWW to FWW\n\t * and not from FWW to LWW. The next SetOp which is sent will communicate this policy to other clients.\n\t */\n\tpublic switchSetCellPolicy() {\n\t\tif (this.setCellLwwToFwwPolicySwitchOpSeqNumber === -1) {\n\t\t\tif (this.isAttached()) {\n\t\t\t\tthis.userSwitchedSetCellPolicy = true;\n\t\t\t} else {\n\t\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns true if the latest pending write to the cell indicated by the given row/col handles\n\t * matches the given 'localSeq'.\n\t *\n\t * A return value of `true` indicates that there are no later local operations queued that will\n\t * clobber the write op at the given 'localSeq'. This includes later ops that overwrite the cell\n\t * with a different value as well as row/col removals that might recycled the given row/col handles.\n\t */\n\tprivate isLatestPendingWrite(rowHandle: Handle, colHandle: Handle, localSeq: number) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst pendingLocalSeq = this.pending.getCell(rowHandle, colHandle)!;\n\n\t\t// Note while we're awaiting the ACK for a local set, it's possible for the row/col to be\n\t\t// locally removed and the row/col handles recycled. If this happens, the pendingLocalSeq will\n\t\t// be 'undefined' or > 'localSeq'.\n\t\tassert(\n\t\t\t!(pendingLocalSeq < localSeq),\n\t\t\t0x023 /* \"The 'localSeq' of pending write (if any) must be <= the localSeq of the currently processed op.\" */,\n\t\t);\n\n\t\t// If this is the most recent write to the cell by the local client, the stored localSeq\n\t\t// will be an exact match for the given 'localSeq'.\n\t\treturn pendingLocalSeq === localSeq;\n\t}\n\n\tpublic toString() {\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;;;;;;AAEH,4EAAuC;AACvC,2DAAqE;AAQrE,2EAM4C;AAE5C,iEAA2F;AAE3F,2DASoC;AACpC,qEAA6D;AAC7D,iEAAsF;AACtF,yDAAmD;AACnD,6CAAmD;AACnD,qDAAyD;AACzD,yDAAqD;AACrD,yCAAyC;AAEzC,uDAAuD;AACvD,qCAOkB;AAqElB;;;;;;;;;;;;GAYG;AACH,MAAa,YACZ,SAAQ,iCAA0D;IAK3D,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,gCAAmB,EAAE,CAAC;IAClC,CAAC;IA0BD;;;;;;;OAOG;IACH,YACC,OAA+B,EACxB,EAAU,EACjB,UAA8B,EAC9B,qCAA+C;QAE/C,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;QAJzC,OAAE,GAAF,EAAE,CAAQ;QAxCD,cAAS,GAAG,IAAI,GAAG,EAAkC,CAAC;QAMvE;;;;;;;;WAQG;QACc,oBAAe,GAAG,IAAI,4BAAK,EAAU,CAAC;QAK/C,UAAK,GAAG,IAAI,gCAAa,EAAiB,CAAC,CAAC,sBAAsB;QACzD,YAAO,GAAG,IAAI,gCAAa,EAAU,CAAC,CAAC,yBAAyB;QAC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jB,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,OAAgB;QACxC,MAAM,aAAa,GAA2B,IAAA,iCAAY,EAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAErF,IAAI,aAAa,CAAC,IAAI,KAAK,iBAAQ,CAAC,GAAG,IAAI,aAAa,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9E,IAAI,aAAa,CAAC,OAAO,KAAK,IAAI,EAAE;gBACnC,IAAI,CAAC,mBAAmB,EAAE,CAAC;aAC3B;YACD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;SACxE;aAAM;YACN,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,KAAK,qBAAY,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAClF,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YACrC,IAAI,aAAa,CAAC,MAAM,KAAK,qBAAY,CAAC,IAAI,EAAE;gBAC/C,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;aACrC;iBAAM;gBACN,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;aACrC;SACD;IACF,CAAC;CACD;AAr6BD,oCAq6BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport Deque from \"double-ended-queue\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { IEventThisPlaceHolder, IEventProvider, IEvent } from \"@fluidframework/core-interfaces\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelAttributes,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidSerializer,\n\tISharedObjectEvents,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { IMatrixProducer, IMatrixConsumer, IMatrixReader, IMatrixWriter } from \"@tiny-calc/nano\";\nimport {\n\tMergeTreeDeltaType,\n\tIMergeTreeOp,\n\tSegmentGroup,\n\t// eslint-disable-next-line import/no-deprecated\n\tClient,\n\tIJSONSegment,\n\tReferenceType,\n\ttype LocalReferencePosition,\n} from \"@fluidframework/merge-tree\";\nimport { UsageError } from \"@fluidframework/telemetry-utils\";\nimport { PermutationVector, reinsertSegmentIntoVector } from \"./permutationvector.js\";\nimport { SparseArray2D } from \"./sparsearray2d.js\";\nimport { SharedMatrixFactory } from \"./runtime.js\";\nimport { Handle, isHandleValid } from \"./handletable.js\";\nimport { deserializeBlob } from \"./serialization.js\";\nimport { ensureRange } from \"./range.js\";\nimport { IUndoConsumer } from \"./types.js\";\nimport { MatrixUndoProvider } from \"./undoprovider.js\";\nimport {\n\tMatrixOp,\n\tMatrixItem,\n\tSnapshotPath,\n\tISetOp,\n\tVectorOp,\n\tMatrixSetOrVectorOp,\n} from \"./ops.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 * @alpha\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 SharedMatrix} 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/** @alpha */\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\tinsertCols(colStart: number, count: number): void;\n\tremoveCols(colStart: number, count: number): void;\n\tinsertRows(rowStart: number, count: number): void;\n\tremoveRows(rowStart: number, count: number): void;\n\n\topenUndo(consumer: IUndoConsumer): void;\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 * @alpha\n */\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\tpublic static getFactory() {\n\t\treturn new SharedMatrixFactory();\n\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\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<number>(); // Tracks pending writes.\n\tprivate cellLastWriteTracker = new SparseArray2D<CellLastWriteTrackerItem>(); // Tracks last writes sequence number and clientId in a cell.\n\t// Tracks the seq number of Op at which policy switch happens from Last Write Win to First Write Win.\n\tprivate setCellLwwToFwwPolicySwitchOpSeqNumber: number;\n\tprivate userSwitchedSetCellPolicy = false; // Set to true when the user calls switchPolicy.\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\t_isSetCellConflictResolutionPolicyFWW?: boolean,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_matrix_\");\n\n\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber =\n\t\t\t_isSetCellConflictResolutionPolicyFWW === true ? 0 : -1;\n\t\tconst getMinInFlightRefSeq = () => this.inFlightRefSeqs.get(0);\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\tgetMinInFlightRefSeq,\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\tgetMinInFlightRefSeq,\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) {\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() {\n\t\treturn this.rows.handleCache;\n\t}\n\tprivate get colHandles() {\n\t\treturn this.cols.handleCache;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic static create<T>(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedMatrixFactory.Type) as SharedMatrix<T>;\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() {\n\t\treturn this.rows.getLength();\n\t}\n\tpublic get colCount() {\n\t\treturn this.cols.getLength();\n\t}\n\n\tpublic isSetCellConflictResolutionPolicyFWW() {\n\t\treturn this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1 || this.userSwitchedSetCellPolicy;\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>) {\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) {\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) {\n\t\tthis.protectAgainstReentrancy(() => {\n\t\t\tif (this.undo !== undefined) {\n\t\t\t\tlet oldValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (oldValue === null) {\n\t\t\t\t\toldValue = undefined;\n\t\t\t\t}\n\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()) {\n\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\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(vector: PermutationVector, pos: number, localSeq: number) {\n\t\tconst segoff = vector.getContainingSegment(pos, undefined, localSeq);\n\t\tassert(\n\t\t\tsegoff.segment !== undefined && segoff.offset !== undefined,\n\t\t\t0x8b3 /* expected valid position */,\n\t\t);\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) {\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:\n\t\t\t\tthis.userSwitchedSetCellPolicy || this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1,\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.runtime.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, metadata);\n\t\tthis.pending.setCell(rowHandle, colHandle, localSeq);\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) {\n\t\tassert(this.reentrantCount === 0, 0x85d /* reentrant code */);\n\t\tthis.reentrantCount++;\n\t\tcallback();\n\t\tthis.reentrantCount--;\n\t\tassert(this.reentrantCount === 0, 0x85e /* reentrant code on exit */);\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) {\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) {\n\t\tthis.submitVectorMessage(this.cols, this.rows, SnapshotPath.cols, message);\n\t}\n\n\tpublic insertCols(colStart: number, count: number) {\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) {\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) {\n\t\tthis.submitVectorMessage(this.rows, this.cols, SnapshotPath.rows, message);\n\t}\n\n\tpublic insertRows(rowStart: number, count: number) {\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) {\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) {\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) {\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\tthis.cells.snapshot(),\n\t\t\tthis.pending.snapshot(),\n\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber,\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.setCellLwwToFwwPolicySwitchOpSeqNumber > -1) {\n\t\t\tartifactsToSummarize.push(this.cellLastWriteTracker.snapshot());\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) {\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() {\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: any, localOpMetadata?: any) {\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.runtime.deltaManager.lastSequenceNumber);\n\t\tsuper.submitLocalMessage(\n\t\t\tmakeHandlesSerializable(message, this.serializer, this.handle),\n\t\t\tlocalOpMetadata,\n\t\t);\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() {\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() {\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\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t\tref: LocalReferencePosition,\n\t\tlocalSeq: number,\n\t): number | undefined {\n\t\tconst segment = 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 || segment.removedSeq !== undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\tsegment.localRemovedSeq === undefined ||\n\t\t\t\t(segment.localRemovedSeq !== undefined && segment.localRemovedSeq > localSeq),\n\t\t\t0x8b8 /* Attempted to set a cell which was removed locally before the original op applied. */,\n\t\t);\n\n\t\treturn client.findReconnectionPosition(segment, localSeq) + offset;\n\t}\n\n\tprotected reSubmitCore(incoming: unknown, localOpMetadata: unknown) {\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\t\t\tif (row !== undefined && col !== undefined && row >= 0 && col >= 0) {\n\t\t\t\tconst lastCellModificationDetails = this.cellLastWriteTracker.getCell(\n\t\t\t\t\trowHandle,\n\t\t\t\t\tcolHandle,\n\t\t\t\t);\n\t\t\t\t// 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\tif (\n\t\t\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber === -1 ||\n\t\t\t\t\tlastCellModificationDetails === undefined ||\n\t\t\t\t\treferenceSeqNumber >= lastCellModificationDetails.seqNum\n\t\t\t\t) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, setOp.value, rowHandle, colHandle, localSeq);\n\t\t\t\t} else if (this.pending.getCell(rowHandle, colHandle) !== undefined) {\n\t\t\t\t\t// Clear the pending changes if any as we are not sending the op.\n\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\n\t\t\t\t}\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(\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SnapshotPath.rows:\n\t\t\t\t\tthis.submitRowMessage(\n\t\t\t\t\t\tthis.rows.regeneratePendingOp(\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\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 onDisconnect() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService) {\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] = await deserializeBlob(storage, SnapshotPath.cells, this.serializer);\n\n\t\t\tthis.cells = SparseArray2D.load(cellData);\n\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber =\n\t\t\t\tsetCellLwwToFwwPolicySwitchOpSeqNumber ?? -1;\n\t\t\tif (cellLastWriteTracker !== undefined) {\n\t\t\t\tthis.cellLastWriteTracker = SparseArray2D.load(cellLastWriteTracker);\n\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) {\n\t\tassert(\n\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber > -1,\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.cellLastWriteTracker.getCell(rowHandle, colHandle);\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\trawMessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\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\t\tconst msg = parseHandles(rawMessage, this.serializer);\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\tcase SnapshotPath.rows:\n\t\t\t\tthis.rows.applyMsg(msg, local);\n\t\t\t\tbreak;\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\tconst isPreviousSetCellPolicyModeFWW =\n\t\t\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber > -1;\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 (this.setCellLwwToFwwPolicySwitchOpSeqNumber === -1 && fwwMode === true) {\n\t\t\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber = rawMessage.sequenceNumber;\n\t\t\t\t}\n\n\t\t\t\tassert(rawMessage.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\tconst isLatestPendingOp = this.isLatestPendingWrite(\n\t\t\t\t\t\trowHandle,\n\t\t\t\t\t\tcolHandle,\n\t\t\t\t\t\tlocalSeq,\n\t\t\t\t\t);\n\t\t\t\t\tthis.rows.removeLocalReferencePosition(rowsRef);\n\t\t\t\t\tthis.cols.removeLocalReferencePosition(colsRef);\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\t(this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1 &&\n\t\t\t\t\t\t\tthis.shouldSetCellBasedOnFWW(rowHandle, colHandle, rawMessage)) ||\n\t\t\t\t\t\t(this.setCellLwwToFwwPolicySwitchOpSeqNumber === -1 && isLatestPendingOp)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\tseqNum: rawMessage.sequenceNumber,\n\t\t\t\t\t\t\tclientId: rawMessage.clientId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isLatestPendingOp) {\n\t\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst adjustedRow = this.rows.adjustPosition(row, rawMessage);\n\t\t\t\t\tif (adjustedRow !== undefined) {\n\t\t\t\t\t\tconst adjustedCol = this.cols.adjustPosition(col, rawMessage);\n\n\t\t\t\t\t\tif (adjustedCol !== undefined) {\n\t\t\t\t\t\t\tconst rowHandle = this.rows.getAllocatedHandle(adjustedRow);\n\t\t\t\t\t\t\tconst colHandle = this.cols.getAllocatedHandle(adjustedCol);\n\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t\t\t\t\t\t0x022 /* \"SharedMatrix row and/or col handles are invalid!\" */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1) {\n\t\t\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\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\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\t\t\tif (\n\t\t\t\t\t\t\t\t\t!isPreviousSetCellPolicyModeFWW ||\n\t\t\t\t\t\t\t\t\tthis.shouldSetCellBasedOnFWW(rowHandle, colHandle, rawMessage)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst previousValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\t\t\tthis.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\t\t\t\tseqNum: rawMessage.sequenceNumber,\n\t\t\t\t\t\t\t\t\t\tclientId: rawMessage.clientId,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow, adjustedCol, 1, 1, this);\n\t\t\t\t\t\t\t\t\t}\n\t\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\t\tif (this.pending.getCell(rowHandle, colHandle) !== undefined) {\n\t\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\t// to raise conflict event for that op also.\n\t\t\t\t\t\t\t\t\t\tthis.emit(\n\t\t\t\t\t\t\t\t\t\t\t\"conflict\",\n\t\t\t\t\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\t\t\t\t\tcol,\n\t\t\t\t\t\t\t\t\t\t\tvalue, // Current value\n\t\t\t\t\t\t\t\t\t\t\tpreviousValue, // Ignored local value\n\t\t\t\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\t\t\t);\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} else if (this.pending.getCell(rowHandle, colHandle) === undefined) {\n\t\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\t// since it \"happened before\" the pending write.\n\t\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\t\t\t\t\t\t\t\tthis.cellLastWriteTracker.setCell(rowHandle, colHandle, {\n\t\t\t\t\t\t\t\t\tseqNum: rawMessage.sequenceNumber,\n\t\t\t\t\t\t\t\t\tclientId: rawMessage.clientId,\n\t\t\t\t\t\t\t\t});\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, adjustedCol, 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}\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}\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) => {\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) => {\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[]) => {\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\tthis.cellLastWriteTracker.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t}\n\t};\n\n\tprivate readonly onColHandlesRecycled = (colHandles: Handle[]) => {\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\tthis.cellLastWriteTracker.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t}\n\t};\n\n\t/**\n\t * Api to switch Set Op policy from Last Writer Win to First Writer Win. It only switches from LWW to FWW\n\t * and not from FWW to LWW. The next SetOp which is sent will communicate this policy to other clients.\n\t */\n\tpublic switchSetCellPolicy() {\n\t\tif (this.setCellLwwToFwwPolicySwitchOpSeqNumber === -1) {\n\t\t\tif (this.isAttached()) {\n\t\t\t\tthis.userSwitchedSetCellPolicy = true;\n\t\t\t} else {\n\t\t\t\tthis.setCellLwwToFwwPolicySwitchOpSeqNumber = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns true if the latest pending write to the cell indicated by the given row/col handles\n\t * matches the given 'localSeq'.\n\t *\n\t * A return value of `true` indicates that there are no later local operations queued that will\n\t * clobber the write op at the given 'localSeq'. This includes later ops that overwrite the cell\n\t * with a different value as well as row/col removals that might recycled the given row/col handles.\n\t */\n\tprivate isLatestPendingWrite(rowHandle: Handle, colHandle: Handle, localSeq: number) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst pendingLocalSeq = this.pending.getCell(rowHandle, colHandle)!;\n\n\t\t// Note while we're awaiting the ACK for a local set, it's possible for the row/col to be\n\t\t// locally removed and the row/col handles recycled. If this happens, the pendingLocalSeq will\n\t\t// be 'undefined' or > 'localSeq'.\n\t\tassert(\n\t\t\t!(pendingLocalSeq < localSeq),\n\t\t\t0x023 /* \"The 'localSeq' of pending write (if any) must be <= the localSeq of the currently processed op.\" */,\n\t\t);\n\n\t\t// If this is the most recent write to the cell by the local client, the stored localSeq\n\t\t// will be an exact match for the given 'localSeq'.\n\t\treturn pendingLocalSeq === localSeq;\n\t}\n\n\tpublic toString() {\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 parsedContent: MatrixSetOrVectorOp<T> = parseHandles(content, this.serializer);\n\n\t\tif (parsedContent.type === MatrixOp.set && parsedContent.target === undefined) {\n\t\t\tif (parsedContent.fwwMode === true) {\n\t\t\t\tthis.switchSetCellPolicy();\n\t\t\t}\n\t\t\tthis.setCell(parsedContent.row, parsedContent.col, parsedContent.value);\n\t\t} else {\n\t\t\tconst vector = parsedContent.target === SnapshotPath.cols ? this.cols : this.rows;\n\t\t\tvector.applyStashedOp(parsedContent);\n\t\t\tif (parsedContent.target === SnapshotPath.cols) {\n\t\t\t\tthis.submitColMessage(parsedContent);\n\t\t\t} else {\n\t\t\t\tthis.submitRowMessage(parsedContent);\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.0.0-rc.2.0.5";
8
+ export declare const pkgVersion = "2.0.0-rc.2.0.7";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/matrix";
11
- exports.pkgVersion = "2.0.0-rc.2.0.5";
11
+ exports.pkgVersion = "2.0.0-rc.2.0.7";
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,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-rc.2.0.5\";\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,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-rc.2.0.7\";\n"]}
package/dist/runtime.d.ts CHANGED
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IChannelAttributes, IFluidDataStoreRuntime, IChannelServices, IChannel, IChannelFactory } from "@fluidframework/datastore-definitions";
6
- import { SharedMatrix } from "./matrix.js";
7
6
  /**
8
7
  * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMatrix}.
9
8
  * @alpha
@@ -17,6 +16,6 @@ export declare class SharedMatrixFactory implements IChannelFactory {
17
16
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
18
17
  */
19
18
  load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IChannel>;
20
- create(document: IFluidDataStoreRuntime, id: string): SharedMatrix;
19
+ create(document: IFluidDataStoreRuntime, id: string): IChannel;
21
20
  }
22
21
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IAC1D,OAAc,IAAI,SAAoD;IAEtE,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,WAEd;IAED,IAAW,UAAU,uBAEpB;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,QAAQ,CAAC;IAMb,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,YAAY;CAKzE"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,MAAM,uCAAuC,CAAC;AAI/C;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IAC1D,OAAc,IAAI,SAAoD;IAEtE,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,WAEd;IAED,IAAW,UAAU,uBAEpB;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,QAAQ,CAAC;IAMb,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,QAAQ;CAKrE"}