@fluidframework/matrix 0.59.2001 → 0.59.3000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bspSet.d.ts +2 -2
- package/dist/bspSet.js +1 -1
- package/dist/bspSet.js.map +1 -1
- package/dist/handlecache.d.ts +1 -1
- package/dist/handlecache.js +4 -4
- package/dist/handlecache.js.map +1 -1
- package/dist/handletable.js.map +1 -1
- package/dist/matrix.d.ts +4 -1
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +57 -22
- package/dist/matrix.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/permutationvector.js +10 -10
- package/dist/permutationvector.js.map +1 -1
- package/dist/productSet.js +10 -10
- package/dist/productSet.js.map +1 -1
- package/dist/range.d.ts +1 -1
- package/dist/range.js +1 -1
- package/dist/range.js.map +1 -1
- package/dist/serialization.js +1 -1
- package/dist/serialization.js.map +1 -1
- package/dist/undoprovider.d.ts.map +1 -1
- package/dist/undoprovider.js +3 -3
- package/dist/undoprovider.js.map +1 -1
- package/lib/bspSet.d.ts +2 -2
- package/lib/handlecache.d.ts +1 -1
- package/lib/handlecache.js +1 -1
- package/lib/handlecache.js.map +1 -1
- package/lib/handletable.js.map +1 -1
- package/lib/matrix.d.ts +4 -1
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +39 -4
- package/lib/matrix.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/productSet.js.map +1 -1
- package/lib/range.d.ts +1 -1
- package/lib/range.js +1 -1
- package/lib/range.js.map +1 -1
- package/lib/undoprovider.d.ts.map +1 -1
- package/lib/undoprovider.js.map +1 -1
- package/package.json +16 -15
- package/src/handlecache.ts +1 -1
- package/src/matrix.ts +60 -13
- package/src/packageVersion.ts +1 -1
- package/src/productSet.ts +1 -1
- package/src/range.ts +1 -1
- package/src/undoprovider.ts +1 -1
package/lib/undoprovider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undoprovider.js","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAmD,MAAM,4BAA4B,CAAC;AAE5G,OAAO,EAAU,aAAa,EAAE,MAAM,eAAe,CAAC;AAItD,MAAM,OAAO,kBAAkB;IAO3B,YACqB,OAAsB,EACtB,UAAiD,EACjD,UAAiD;QAFjD,YAAO,GAAP,OAAO,CAAe;QACtB,eAAU,GAAV,UAAU,CAAuC;QACjD,eAAU,GAAV,UAAU,CAAuC;IAClE,CAAC;IAEE,MAAM,CAAC,SAAsC,EAAE,MAAyC;;QAC3F,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,yFAAyF;YACzF,4FAA4F;YAC5F,EAAE;YACF,0FAA0F;YAC1F,4FAA4F;YAC5F,0BAA0B;YAC1B,EAAE;YACF,6FAA6F;YAC7F,oEAAoE;YAEpE,8FAA8F;YAC9F,4FAA4F;YAC5F,wCAAwC;YACxC,MAAM,aAAa,SAAG,IAAI,CAAC,YAAY,mCAAI,IAAI,aAAa,EAAE,CAAC;YAC/D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBACxB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aACrC;YAED,+EAA+E;YAC/E,8EAA8E;YAC9E,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAC/D,KAAK,CAAC,0DAA0D,CAAC,CAAC;YAEtE,QAAQ,SAAS,EAAE;gBACf;oBACI,IAAI,IAAI,CAAC,SAAS,mBAA8B,EAAE;wBAC9C,IAAI,CAAC,cAAc,CAA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C;IACN,CAAC;IAED,OAAO,CAAC,SAAiB,EAAE,SAAiB,EAAE,QAAuB;QACjE,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,EACvD,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAEpE,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC7B,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;gBACjC,MAAM,EAAE,GAAG,EAAE;oBACT,IAAI,CAAC,MAAM,CAAC,OAAO,CACf,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,QAAQ,CAAC,CAAC;gBAClB,CAAC;gBACD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;aACpB,CAAC,CAAC;SACN;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { TrackingGroup, MergeTreeDeltaOperationType, MergeTreeDeltaType } from \"@fluidframework/merge-tree\";\nimport { MatrixItem, SharedMatrix } from \"./matrix\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationSegment, PermutationVector } from \"./permutationvector\";\nimport { IUndoConsumer } from \"./types\";\n\nexport class VectorUndoProvider {\n // 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce\n // the recorded into a single IRevertable / tracking group as they move between the undo <->\n // redo stacks.\n private currentGroup?: TrackingGroup;\n private currentOp?: MergeTreeDeltaType;\n\n constructor(\n private readonly manager: IUndoConsumer,\n private readonly undoInsert: (segment: PermutationSegment) => void,\n private readonly undoRemove: (segment: PermutationSegment) => void,\n ) { }\n\n public record(operation: MergeTreeDeltaOperationType, ranges: { segment: PermutationSegment }[]) {\n if (ranges.length > 0) {\n // Link each segment to a new TrackingGroup. A TrackingGroup keeps track of the original\n // set of linked segments, including any fragmentatiton that occurs due to future splitting.\n //\n // A TrackingGroup also prevents removed segments from being unlinked from the tree during\n // Zamboni and guarantees segments will not be merged/coalesced with segments outside of the\n // current tracking group.\n //\n // These properties allow us to rely on MergeTree.getPosition() to find the locations/lengths\n // of all content contained within the tracking group in the future.\n\n // If we are in the process of reverting, the `IRevertible.revert()` will provide the tracking\n // group so that we can preserve the original segment ranges as a single op/group as we move\n // ops between the undo <-> redo stacks.\n const trackingGroup = this.currentGroup ?? new TrackingGroup();\n for (const range of ranges) {\n trackingGroup.link(range.segment);\n }\n\n // For SharedMatrix, each IRevertibles always holds a single row/col operation.\n // Therefore, 'currentOp' must either be undefined or equal to the current op.\n assert(this.currentOp === undefined || this.currentOp === operation,\n 0x02a /* \"On vector undo, unexpected 'currentOp' type/state!\" */);\n\n switch (operation) {\n case MergeTreeDeltaType.INSERT:\n if (this.currentOp !== MergeTreeDeltaType.INSERT) {\n this.pushRevertible(trackingGroup, this.undoInsert);\n }\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n if (this.currentOp !== MergeTreeDeltaType.REMOVE) {\n this.pushRevertible(trackingGroup, this.undoRemove);\n }\n break;\n }\n\n default:\n throw new Error(\"operation type not revertible\");\n }\n\n // If we are in the process of reverting, set 'currentOp' to remind ourselves not to push\n // another revertible until `IRevertable.revert()` finishes the current op and clears this\n // field.\n if (this.currentGroup !== undefined) {\n this.currentOp = operation;\n }\n }\n }\n\n private pushRevertible(trackingGroup: TrackingGroup, callback: (segment: PermutationSegment) => void) {\n const revertible = {\n revert: () => {\n assert(this.currentGroup === undefined && this.currentOp === undefined,\n 0x02b /* \"Must not nest calls to IRevertible.revert()\" */);\n\n this.currentGroup = new TrackingGroup();\n\n try {\n while (trackingGroup.size > 0) {\n const segment = trackingGroup.segments[0] as PermutationSegment;\n\n // Unlink 'segment' from the current tracking group before invoking the callback\n // to exclude the current undo/redo segment from those copied to the replacement\n // segment (if any). (See 'PermutationSegment.transferToReplacement()')\n segment.trackingCollection.unlink(trackingGroup);\n\n callback(segment);\n }\n } finally {\n this.currentOp = undefined;\n this.currentGroup = undefined;\n }\n },\n discard: () => {\n while (trackingGroup.size > 0) {\n trackingGroup.unlink(trackingGroup.segments[0]);\n }\n },\n };\n\n this.manager.pushToCurrentOperation(revertible);\n\n return revertible;\n }\n}\n\nexport class MatrixUndoProvider<T> {\n constructor(\n private readonly consumer: IUndoConsumer,\n private readonly matrix: SharedMatrix<T>,\n private readonly rows: PermutationVector,\n private readonly cols: PermutationVector,\n ) {\n rows.undo = new VectorUndoProvider(\n consumer,\n /* undoInsert: */ (segment: PermutationSegment) => {\n const start = this.rows.getPosition(segment);\n this.matrix.removeRows(start, segment.cachedLength);\n },\n /* undoRemove: */ (segment: PermutationSegment) => {\n this.matrix._undoRemoveRows(segment);\n },\n );\n cols.undo = new VectorUndoProvider(\n consumer,\n /* undoInsert: */ (segment: PermutationSegment) => {\n const start = this.cols.getPosition(segment);\n this.matrix.removeCols(start, segment.cachedLength);\n },\n /* undoRemove: */ (segment: PermutationSegment) => {\n this.matrix._undoRemoveCols(segment);\n },\n );\n }\n\n cellSet(rowHandle: Handle, colHandle: Handle, oldValue: MatrixItem<T>) {\n assert(isHandleValid(rowHandle) && isHandleValid(colHandle),\n 0x02c /* \"On cellSet(), invalid row and/or column handles!\" */);\n\n if (this.consumer !== undefined) {\n this.consumer.pushToCurrentOperation({\n revert: () => {\n this.matrix.setCell(\n this.rows.handleToPosition(rowHandle),\n this.cols.handleToPosition(colHandle),\n oldValue);\n },\n discard: () => {},\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"undoprovider.js","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAmD,MAAM,4BAA4B,CAAC;AAE5G,OAAO,EAAU,aAAa,EAAE,MAAM,eAAe,CAAC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AO,CACf,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,QAAQ,CAAC,CAAC;gBAClB,CAAC;gBACD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;aACpB,CAAC,CAAC;SACN;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { TrackingGroup, MergeTreeDeltaOperationType, MergeTreeDeltaType } from \"@fluidframework/merge-tree\";\nimport { MatrixItem, SharedMatrix } from \"./matrix\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationSegment, PermutationVector } from \"./permutationvector\";\nimport { IUndoConsumer } from \"./types\";\n\nexport class VectorUndoProvider {\n // 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce\n // the recorded into a single IRevertable / tracking group as they move between the undo <->\n // redo stacks.\n private currentGroup?: TrackingGroup;\n private currentOp?: MergeTreeDeltaType;\n\n constructor(\n private readonly manager: IUndoConsumer,\n private readonly undoInsert: (segment: PermutationSegment) => void,\n private readonly undoRemove: (segment: PermutationSegment) => void,\n ) { }\n\n public record(operation: MergeTreeDeltaOperationType, ranges: { segment: PermutationSegment; }[]) {\n if (ranges.length > 0) {\n // Link each segment to a new TrackingGroup. A TrackingGroup keeps track of the original\n // set of linked segments, including any fragmentatiton that occurs due to future splitting.\n //\n // A TrackingGroup also prevents removed segments from being unlinked from the tree during\n // Zamboni and guarantees segments will not be merged/coalesced with segments outside of the\n // current tracking group.\n //\n // These properties allow us to rely on MergeTree.getPosition() to find the locations/lengths\n // of all content contained within the tracking group in the future.\n\n // If we are in the process of reverting, the `IRevertible.revert()` will provide the tracking\n // group so that we can preserve the original segment ranges as a single op/group as we move\n // ops between the undo <-> redo stacks.\n const trackingGroup = this.currentGroup ?? new TrackingGroup();\n for (const range of ranges) {\n trackingGroup.link(range.segment);\n }\n\n // For SharedMatrix, each IRevertibles always holds a single row/col operation.\n // Therefore, 'currentOp' must either be undefined or equal to the current op.\n assert(this.currentOp === undefined || this.currentOp === operation,\n 0x02a /* \"On vector undo, unexpected 'currentOp' type/state!\" */);\n\n switch (operation) {\n case MergeTreeDeltaType.INSERT:\n if (this.currentOp !== MergeTreeDeltaType.INSERT) {\n this.pushRevertible(trackingGroup, this.undoInsert);\n }\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n if (this.currentOp !== MergeTreeDeltaType.REMOVE) {\n this.pushRevertible(trackingGroup, this.undoRemove);\n }\n break;\n }\n\n default:\n throw new Error(\"operation type not revertible\");\n }\n\n // If we are in the process of reverting, set 'currentOp' to remind ourselves not to push\n // another revertible until `IRevertable.revert()` finishes the current op and clears this\n // field.\n if (this.currentGroup !== undefined) {\n this.currentOp = operation;\n }\n }\n }\n\n private pushRevertible(trackingGroup: TrackingGroup, callback: (segment: PermutationSegment) => void) {\n const revertible = {\n revert: () => {\n assert(this.currentGroup === undefined && this.currentOp === undefined,\n 0x02b /* \"Must not nest calls to IRevertible.revert()\" */);\n\n this.currentGroup = new TrackingGroup();\n\n try {\n while (trackingGroup.size > 0) {\n const segment = trackingGroup.segments[0] as PermutationSegment;\n\n // Unlink 'segment' from the current tracking group before invoking the callback\n // to exclude the current undo/redo segment from those copied to the replacement\n // segment (if any). (See 'PermutationSegment.transferToReplacement()')\n segment.trackingCollection.unlink(trackingGroup);\n\n callback(segment);\n }\n } finally {\n this.currentOp = undefined;\n this.currentGroup = undefined;\n }\n },\n discard: () => {\n while (trackingGroup.size > 0) {\n trackingGroup.unlink(trackingGroup.segments[0]);\n }\n },\n };\n\n this.manager.pushToCurrentOperation(revertible);\n\n return revertible;\n }\n}\n\nexport class MatrixUndoProvider<T> {\n constructor(\n private readonly consumer: IUndoConsumer,\n private readonly matrix: SharedMatrix<T>,\n private readonly rows: PermutationVector,\n private readonly cols: PermutationVector,\n ) {\n rows.undo = new VectorUndoProvider(\n consumer,\n /* undoInsert: */ (segment: PermutationSegment) => {\n const start = this.rows.getPosition(segment);\n this.matrix.removeRows(start, segment.cachedLength);\n },\n /* undoRemove: */ (segment: PermutationSegment) => {\n this.matrix._undoRemoveRows(segment);\n },\n );\n cols.undo = new VectorUndoProvider(\n consumer,\n /* undoInsert: */ (segment: PermutationSegment) => {\n const start = this.cols.getPosition(segment);\n this.matrix.removeCols(start, segment.cachedLength);\n },\n /* undoRemove: */ (segment: PermutationSegment) => {\n this.matrix._undoRemoveCols(segment);\n },\n );\n }\n\n cellSet(rowHandle: Handle, colHandle: Handle, oldValue: MatrixItem<T>) {\n assert(isHandleValid(rowHandle) && isHandleValid(colHandle),\n 0x02c /* \"On cellSet(), invalid row and/or column handles!\" */);\n\n if (this.consumer !== undefined) {\n this.consumer.pushToCurrentOperation({\n revert: () => {\n this.matrix.setCell(\n this.rows.handleToPosition(rowHandle),\n this.cols.handleToPosition(colHandle),\n oldValue);\n },\n discard: () => {},\n });\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/matrix",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.3000",
|
|
4
4
|
"description": "Distributed matrix",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -62,24 +62,25 @@
|
|
|
62
62
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
63
63
|
"@fluidframework/common-utils": "^0.32.1",
|
|
64
64
|
"@fluidframework/core-interfaces": "^0.43.1000",
|
|
65
|
-
"@fluidframework/datastore-definitions": "^0.59.
|
|
66
|
-
"@fluidframework/merge-tree": "^0.59.
|
|
67
|
-
"@fluidframework/protocol-base": "^0.1036.
|
|
65
|
+
"@fluidframework/datastore-definitions": "^0.59.3000",
|
|
66
|
+
"@fluidframework/merge-tree": "^0.59.3000",
|
|
67
|
+
"@fluidframework/protocol-base": "^0.1036.3000",
|
|
68
68
|
"@fluidframework/protocol-definitions": "^0.1028.1000",
|
|
69
|
-
"@fluidframework/runtime-definitions": "^0.59.
|
|
70
|
-
"@fluidframework/runtime-utils": "^0.59.
|
|
71
|
-
"@fluidframework/shared-object-base": "^0.59.
|
|
72
|
-
"@fluidframework/telemetry-utils": "^0.59.
|
|
69
|
+
"@fluidframework/runtime-definitions": "^0.59.3000",
|
|
70
|
+
"@fluidframework/runtime-utils": "^0.59.3000",
|
|
71
|
+
"@fluidframework/shared-object-base": "^0.59.3000",
|
|
72
|
+
"@fluidframework/telemetry-utils": "^0.59.3000",
|
|
73
73
|
"@tiny-calc/nano": "0.0.0-alpha.5",
|
|
74
74
|
"tslib": "^1.10.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@fluid-internal/test-dds-utils": "^0.59.
|
|
77
|
+
"@fluid-internal/test-dds-utils": "^0.59.3000",
|
|
78
78
|
"@fluidframework/build-common": "^0.23.0",
|
|
79
|
-
"@fluidframework/
|
|
80
|
-
"@fluidframework/
|
|
81
|
-
"@fluidframework/
|
|
82
|
-
"@fluidframework/test-
|
|
79
|
+
"@fluidframework/build-tools": "^0.2.66793",
|
|
80
|
+
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
81
|
+
"@fluidframework/matrix-previous": "npm:@fluidframework/matrix@0.59.2000",
|
|
82
|
+
"@fluidframework/mocha-test-setup": "^0.59.3000",
|
|
83
|
+
"@fluidframework/test-runtime-utils": "^0.59.3000",
|
|
83
84
|
"@microsoft/api-extractor": "^7.22.2",
|
|
84
85
|
"@rushstack/eslint-config": "^2.5.1",
|
|
85
86
|
"@tiny-calc/micro": "0.0.0-alpha.5",
|
|
@@ -106,12 +107,12 @@
|
|
|
106
107
|
"rimraf": "^2.6.2",
|
|
107
108
|
"source-map-support": "^0.5.16",
|
|
108
109
|
"ts-node": "^7.0.1",
|
|
109
|
-
"typescript": "~4.
|
|
110
|
+
"typescript": "~4.5.5",
|
|
110
111
|
"typescript-formatter": "7.1.0",
|
|
111
112
|
"uuid": "^8.3.1"
|
|
112
113
|
},
|
|
113
114
|
"typeValidation": {
|
|
114
|
-
"version": "0.59.
|
|
115
|
+
"version": "0.59.3000",
|
|
115
116
|
"broken": {}
|
|
116
117
|
}
|
|
117
118
|
}
|
package/src/handlecache.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { PermutationVector, PermutationSegment } from "./permutationvector";
|
|
|
12
12
|
import { ensureRange } from "./range";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Used by PermutationVector to cache position
|
|
15
|
+
* Used by PermutationVector to cache position -\> handle lookups.
|
|
16
16
|
*
|
|
17
17
|
* Perf: Possibly, this should eventually be inlined into PermutationVector itself, but
|
|
18
18
|
* so far there's no measurable perf penalty for being a separate object (node 12 x64)
|
package/src/matrix.ts
CHANGED
|
@@ -44,16 +44,16 @@ const enum SnapshotPath {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
interface ISetOp<T> {
|
|
47
|
-
type: MatrixOp.set
|
|
48
|
-
row: number
|
|
49
|
-
col: number
|
|
50
|
-
value: MatrixItem<T
|
|
47
|
+
type: MatrixOp.set;
|
|
48
|
+
row: number;
|
|
49
|
+
col: number;
|
|
50
|
+
value: MatrixItem<T>;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
interface ISetOpMetadata {
|
|
54
|
-
rowHandle: Handle
|
|
55
|
-
colHandle: Handle
|
|
56
|
-
localSeq: number
|
|
54
|
+
rowHandle: Handle;
|
|
55
|
+
colHandle: Handle;
|
|
56
|
+
localSeq: number;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
@@ -78,8 +78,7 @@ export class SharedMatrix<T = any>
|
|
|
78
78
|
extends SharedObject
|
|
79
79
|
implements IMatrixProducer<MatrixItem<T>>,
|
|
80
80
|
IMatrixReader<MatrixItem<T>>,
|
|
81
|
-
IMatrixWriter<MatrixItem<T>>
|
|
82
|
-
{
|
|
81
|
+
IMatrixWriter<MatrixItem<T>> {
|
|
83
82
|
private readonly consumers = new Set<IMatrixConsumer<MatrixItem<T>>>();
|
|
84
83
|
|
|
85
84
|
public static getFactory() { return new SharedMatrixFactory(); }
|
|
@@ -564,10 +563,10 @@ export class SharedMatrix<T = any>
|
|
|
564
563
|
|
|
565
564
|
switch (contents.target) {
|
|
566
565
|
case SnapshotPath.cols:
|
|
567
|
-
this.cols.applyMsg(msg);
|
|
566
|
+
this.cols.applyMsg(msg, local);
|
|
568
567
|
break;
|
|
569
568
|
case SnapshotPath.rows:
|
|
570
|
-
this.rows.applyMsg(msg);
|
|
569
|
+
this.rows.applyMsg(msg, local);
|
|
571
570
|
break;
|
|
572
571
|
default: {
|
|
573
572
|
assert(contents.type === MatrixOp.set,
|
|
@@ -687,7 +686,55 @@ export class SharedMatrix<T = any>
|
|
|
687
686
|
return `${s}\n`;
|
|
688
687
|
}
|
|
689
688
|
|
|
690
|
-
|
|
691
|
-
|
|
689
|
+
/**
|
|
690
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
691
|
+
*/
|
|
692
|
+
protected applyStashedOp(content: any): unknown {
|
|
693
|
+
if (content.target === SnapshotPath.cols || content.target === SnapshotPath.rows) {
|
|
694
|
+
const op = content as IMergeTreeOp;
|
|
695
|
+
const currentVector = content.target === SnapshotPath.cols ? this.cols : this.rows;
|
|
696
|
+
const oppositeVector = content.target === SnapshotPath.cols ? this.rows : this.cols;
|
|
697
|
+
const metadata = currentVector.applyStashedOp(op);
|
|
698
|
+
const localSeq = currentVector.getCollabWindow().localSeq;
|
|
699
|
+
const oppositeWindow = oppositeVector.getCollabWindow();
|
|
700
|
+
|
|
701
|
+
assert(
|
|
702
|
+
localSeq > oppositeWindow.localSeq,
|
|
703
|
+
0x2d9,
|
|
704
|
+
/* "The 'localSeq' of the vector applying stashed op must > the 'localSeq' of the other vector." */
|
|
705
|
+
);
|
|
706
|
+
|
|
707
|
+
oppositeWindow.localSeq = localSeq;
|
|
708
|
+
|
|
709
|
+
return metadata;
|
|
710
|
+
} else {
|
|
711
|
+
assert(content.type === MatrixOp.set, 0x2da /* "Unknown SharedMatrix 'op' type." */);
|
|
712
|
+
|
|
713
|
+
const setOp = content as ISetOp<T>;
|
|
714
|
+
const rowHandle = this.rows.getAllocatedHandle(setOp.row);
|
|
715
|
+
const colHandle = this.cols.getAllocatedHandle(setOp.col);
|
|
716
|
+
if (this.undo !== undefined) {
|
|
717
|
+
let oldValue = this.cells.getCell(rowHandle, colHandle);
|
|
718
|
+
if (oldValue === null) {
|
|
719
|
+
oldValue = undefined;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
this.undo.cellSet(
|
|
723
|
+
rowHandle,
|
|
724
|
+
colHandle,
|
|
725
|
+
oldValue);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
this.cells.setCell(rowHandle, colHandle, setOp.value);
|
|
729
|
+
const localSeq = this.nextLocalSeq();
|
|
730
|
+
const metadata: ISetOpMetadata = {
|
|
731
|
+
rowHandle,
|
|
732
|
+
colHandle,
|
|
733
|
+
localSeq,
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
this.pending.setCell(rowHandle, colHandle, localSeq);
|
|
737
|
+
return metadata;
|
|
738
|
+
}
|
|
692
739
|
}
|
|
693
740
|
}
|
package/src/packageVersion.ts
CHANGED
package/src/productSet.ts
CHANGED
|
@@ -298,7 +298,7 @@ function compareSubspace<T>(
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
const tryUnionSubspaces = (() => {
|
|
301
|
-
const cache: { left?: unknown; right?: unknown; res?: unknown } = {};
|
|
301
|
+
const cache: { left?: unknown; right?: unknown; res?: unknown; } = {};
|
|
302
302
|
return <T>(
|
|
303
303
|
productOperations: ProductOperations<T>,
|
|
304
304
|
left: Subspace<T>,
|
package/src/range.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Ensures that 0
|
|
7
|
+
* Ensures that 0 \<= 'value' \< 'limit'. Throws a RangeError otherwise.
|
|
8
8
|
*/
|
|
9
9
|
export function ensureRange(value: number, limit: number) {
|
|
10
10
|
// Coerce 'value' to Uint32 so that we can range check with a single branch.
|
package/src/undoprovider.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class VectorUndoProvider {
|
|
|
23
23
|
private readonly undoRemove: (segment: PermutationSegment) => void,
|
|
24
24
|
) { }
|
|
25
25
|
|
|
26
|
-
public record(operation: MergeTreeDeltaOperationType, ranges: { segment: PermutationSegment }[]) {
|
|
26
|
+
public record(operation: MergeTreeDeltaOperationType, ranges: { segment: PermutationSegment; }[]) {
|
|
27
27
|
if (ranges.length > 0) {
|
|
28
28
|
// Link each segment to a new TrackingGroup. A TrackingGroup keeps track of the original
|
|
29
29
|
// set of linked segments, including any fragmentatiton that occurs due to future splitting.
|