@fluidframework/matrix 2.0.0-internal.3.0.1 → 2.0.0-internal.3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +20 -21
- package/.mocharc.js +2 -2
- package/README.md +21 -21
- package/api-extractor.json +2 -2
- package/bench/bsp-set-optimizations.md +5 -5
- package/bench/src/index.ts +38 -20
- package/bench/src/read/map.ts +16 -10
- package/bench/src/read/nativearray.ts +16 -10
- package/bench/src/read/test.ts +17 -19
- package/bench/src/read/tiled.ts +240 -181
- package/bench/src/util.ts +19 -18
- package/bench/tsconfig.json +8 -13
- package/dist/bspSet.d.ts.map +1 -1
- package/dist/bspSet.js.map +1 -1
- package/dist/handlecache.d.ts.map +1 -1
- package/dist/handlecache.js +1 -3
- package/dist/handlecache.js.map +1 -1
- package/dist/handletable.d.ts.map +1 -1
- package/dist/handletable.js +7 -3
- package/dist/handletable.js.map +1 -1
- package/dist/matrix.d.ts +1 -1
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +28 -19
- package/dist/matrix.js.map +1 -1
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.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.d.ts.map +1 -1
- package/dist/permutationvector.js +15 -8
- package/dist/permutationvector.js.map +1 -1
- package/dist/productSet.d.ts.map +1 -1
- package/dist/productSet.js +6 -3
- package/dist/productSet.js.map +1 -1
- package/dist/range.d.ts.map +1 -1
- package/dist/range.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js.map +1 -1
- package/dist/sparsearray2d.d.ts.map +1 -1
- package/dist/sparsearray2d.js +12 -12
- package/dist/sparsearray2d.js.map +1 -1
- package/dist/split.d.ts.map +1 -1
- package/dist/split.js +5 -3
- package/dist/split.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/undoprovider.d.ts.map +1 -1
- package/dist/undoprovider.js.map +1 -1
- package/lib/bspSet.d.ts.map +1 -1
- package/lib/bspSet.js.map +1 -1
- package/lib/handlecache.d.ts.map +1 -1
- package/lib/handlecache.js +1 -3
- package/lib/handlecache.js.map +1 -1
- package/lib/handletable.d.ts.map +1 -1
- package/lib/handletable.js +7 -3
- package/lib/handletable.js.map +1 -1
- package/lib/matrix.d.ts +1 -1
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +29 -20
- package/lib/matrix.js.map +1 -1
- package/lib/ops.d.ts.map +1 -1
- package/lib/ops.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/permutationvector.d.ts.map +1 -1
- package/lib/permutationvector.js +15 -8
- package/lib/permutationvector.js.map +1 -1
- package/lib/productSet.d.ts.map +1 -1
- package/lib/productSet.js +6 -3
- package/lib/productSet.js.map +1 -1
- package/lib/range.d.ts.map +1 -1
- package/lib/range.js.map +1 -1
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/serialization.d.ts.map +1 -1
- package/lib/serialization.js.map +1 -1
- package/lib/sparsearray2d.d.ts.map +1 -1
- package/lib/sparsearray2d.js +12 -12
- package/lib/sparsearray2d.js.map +1 -1
- package/lib/split.d.ts.map +1 -1
- package/lib/split.js +5 -3
- package/lib/split.js.map +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/undoprovider.d.ts.map +1 -1
- package/lib/undoprovider.js +1 -1
- package/lib/undoprovider.js.map +1 -1
- package/package.json +117 -116
- package/prettier.config.cjs +1 -1
- package/src/bspSet.ts +507 -434
- package/src/handlecache.ts +114 -112
- package/src/handletable.ts +66 -62
- package/src/matrix.ts +781 -710
- package/src/ops.ts +11 -11
- package/src/packageVersion.ts +1 -1
- package/src/permutationvector.ts +425 -368
- package/src/productSet.ts +852 -788
- package/src/range.ts +8 -8
- package/src/runtime.ts +35 -35
- package/src/serialization.ts +13 -9
- package/src/sparsearray2d.ts +196 -192
- package/src/split.ts +111 -90
- package/src/types.ts +3 -3
- package/src/undoprovider.ts +161 -144
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/dist/undoprovider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undoprovider.js","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,2DAA4G;AAE5G,+CAAsD;AAItD,MAAa,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,MAA0C;;QAC5F,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,GAAG,MAAA,IAAI,CAAC,YAAY,mCAAI,IAAI,0BAAa,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,IAAA,qBAAM,EAAC,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAC/D,KAAK,CAAC,0DAA0D,CAAC,CAAC;YAEtE,QA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AC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QACxD,CAAC;QACD,iBAAiB,CAAC,CAAC,OAA2B,EAAE,EAAE;YAC9C,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CACJ,CAAC;IACN,CAAC;IAED,OAAO,CAAC,SAAiB,EAAE,SAAiB,EAAE,QAAuB;QACjE,IAAA,qBAAM,EAAC,IAAA,2BAAa,EAAC,SAAS,CAAC,IAAI,IAAA,2BAAa,EAAC,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;AA7CD,gDA6CC","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
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CAAC,IAAI,IAAA,2BAAa,EAAC,SAAS,CAAC,EACpD,KAAK,CAAC,wDAAwD,CAC9D,CAAC;QAEF,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;gBACpC,MAAM,EAAE,GAAG,EAAE;oBACZ,IAAI,CAAC,MAAM,CAAC,OAAO,CAClB,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,QAAQ,CACR,CAAC;gBACH,CAAC;gBACD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;aACjB,CAAC,CAAC;SACH;IACF,CAAC;CACD;AAhDD,gDAgDC","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 {\n\tTrackingGroup,\n\tMergeTreeDeltaOperationType,\n\tMergeTreeDeltaType,\n} 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\t// 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce\n\t// the recorded into a single IRevertable / tracking group as they move between the undo <->\n\t// redo stacks.\n\tprivate currentGroup?: TrackingGroup;\n\tprivate currentOp?: MergeTreeDeltaType;\n\n\tconstructor(\n\t\tprivate readonly manager: IUndoConsumer,\n\t\tprivate readonly undoInsert: (segment: PermutationSegment) => void,\n\t\tprivate readonly undoRemove: (segment: PermutationSegment) => void,\n\t) {}\n\n\tpublic record(\n\t\toperation: MergeTreeDeltaOperationType,\n\t\tranges: { segment: PermutationSegment }[],\n\t) {\n\t\tif (ranges.length > 0) {\n\t\t\t// Link each segment to a new TrackingGroup. A TrackingGroup keeps track of the original\n\t\t\t// set of linked segments, including any fragmentatiton that occurs due to future splitting.\n\t\t\t//\n\t\t\t// A TrackingGroup also prevents removed segments from being unlinked from the tree during\n\t\t\t// Zamboni and guarantees segments will not be merged/coalesced with segments outside of the\n\t\t\t// current tracking group.\n\t\t\t//\n\t\t\t// These properties allow us to rely on MergeTree.getPosition() to find the locations/lengths\n\t\t\t// of all content contained within the tracking group in the future.\n\n\t\t\t// If we are in the process of reverting, the `IRevertible.revert()` will provide the tracking\n\t\t\t// group so that we can preserve the original segment ranges as a single op/group as we move\n\t\t\t// ops between the undo <-> redo stacks.\n\t\t\tconst trackingGroup = this.currentGroup ?? new TrackingGroup();\n\t\t\tfor (const range of ranges) {\n\t\t\t\ttrackingGroup.link(range.segment);\n\t\t\t}\n\n\t\t\t// For SharedMatrix, each IRevertibles always holds a single row/col operation.\n\t\t\t// Therefore, 'currentOp' must either be undefined or equal to the current op.\n\t\t\tassert(\n\t\t\t\tthis.currentOp === undefined || this.currentOp === operation,\n\t\t\t\t0x02a /* \"On vector undo, unexpected 'currentOp' type/state!\" */,\n\t\t\t);\n\n\t\t\tswitch (operation) {\n\t\t\t\tcase MergeTreeDeltaType.INSERT:\n\t\t\t\t\tif (this.currentOp !== MergeTreeDeltaType.INSERT) {\n\t\t\t\t\t\tthis.pushRevertible(trackingGroup, this.undoInsert);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t\tif (this.currentOp !== MergeTreeDeltaType.REMOVE) {\n\t\t\t\t\t\tthis.pushRevertible(trackingGroup, this.undoRemove);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(\"operation type not revertible\");\n\t\t\t}\n\n\t\t\t// If we are in the process of reverting, set 'currentOp' to remind ourselves not to push\n\t\t\t// another revertible until `IRevertable.revert()` finishes the current op and clears this\n\t\t\t// field.\n\t\t\tif (this.currentGroup !== undefined) {\n\t\t\t\tthis.currentOp = operation;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate pushRevertible(\n\t\ttrackingGroup: TrackingGroup,\n\t\tcallback: (segment: PermutationSegment) => void,\n\t) {\n\t\tconst revertible = {\n\t\t\trevert: () => {\n\t\t\t\tassert(\n\t\t\t\t\tthis.currentGroup === undefined && this.currentOp === undefined,\n\t\t\t\t\t0x02b /* \"Must not nest calls to IRevertible.revert()\" */,\n\t\t\t\t);\n\n\t\t\t\tthis.currentGroup = new TrackingGroup();\n\n\t\t\t\ttry {\n\t\t\t\t\twhile (trackingGroup.size > 0) {\n\t\t\t\t\t\tconst segment = trackingGroup.segments[0] as PermutationSegment;\n\n\t\t\t\t\t\t// Unlink 'segment' from the current tracking group before invoking the callback\n\t\t\t\t\t\t// to exclude the current undo/redo segment from those copied to the replacement\n\t\t\t\t\t\t// segment (if any). (See 'PermutationSegment.transferToReplacement()')\n\t\t\t\t\t\tsegment.trackingCollection.unlink(trackingGroup);\n\n\t\t\t\t\t\tcallback(segment);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tthis.currentOp = undefined;\n\t\t\t\t\tthis.currentGroup = undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdiscard: () => {\n\t\t\t\twhile (trackingGroup.size > 0) {\n\t\t\t\t\ttrackingGroup.unlink(trackingGroup.segments[0]);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\n\t\tthis.manager.pushToCurrentOperation(revertible);\n\n\t\treturn revertible;\n\t}\n}\n\nexport class MatrixUndoProvider<T> {\n\tconstructor(\n\t\tprivate readonly consumer: IUndoConsumer,\n\t\tprivate readonly matrix: SharedMatrix<T>,\n\t\tprivate readonly rows: PermutationVector,\n\t\tprivate readonly cols: PermutationVector,\n\t) {\n\t\trows.undo = new VectorUndoProvider(\n\t\t\tconsumer,\n\t\t\t/* undoInsert: */ (segment: PermutationSegment) => {\n\t\t\t\tconst start = this.rows.getPosition(segment);\n\t\t\t\tthis.matrix.removeRows(start, segment.cachedLength);\n\t\t\t},\n\t\t\t/* undoRemove: */ (segment: PermutationSegment) => {\n\t\t\t\tthis.matrix._undoRemoveRows(segment);\n\t\t\t},\n\t\t);\n\t\tcols.undo = new VectorUndoProvider(\n\t\t\tconsumer,\n\t\t\t/* undoInsert: */ (segment: PermutationSegment) => {\n\t\t\t\tconst start = this.cols.getPosition(segment);\n\t\t\t\tthis.matrix.removeCols(start, segment.cachedLength);\n\t\t\t},\n\t\t\t/* undoRemove: */ (segment: PermutationSegment) => {\n\t\t\t\tthis.matrix._undoRemoveCols(segment);\n\t\t\t},\n\t\t);\n\t}\n\n\tcellSet(rowHandle: Handle, colHandle: Handle, oldValue: MatrixItem<T>) {\n\t\tassert(\n\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t0x02c /* \"On cellSet(), invalid row and/or column handles!\" */,\n\t\t);\n\n\t\tif (this.consumer !== undefined) {\n\t\t\tthis.consumer.pushToCurrentOperation({\n\t\t\t\trevert: () => {\n\t\t\t\t\tthis.matrix.setCell(\n\t\t\t\t\t\tthis.rows.handleToPosition(rowHandle),\n\t\t\t\t\t\tthis.cols.handleToPosition(colHandle),\n\t\t\t\t\t\toldValue,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tdiscard: () => {},\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
package/lib/bspSet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bspSet.d.ts","sourceRoot":"","sources":["../src/bspSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,oDAAoD;AACpD,oBAAY,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7C,eAAO,MAAM,IAAI,6CAA6D,CAAC;AAK/E,oBAAY,OAAO;
|
|
1
|
+
{"version":3,"file":"b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AC,CAAC,OAAO,CAAC,CAAC;SAAE;QAC/C,IAAI,SAAS,CAAC,OAAO,EAAE;YAAE,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAAE;QAEnD,MAAM,MAAM,GAAG,WAAW,CAAU,aAAa,EAAE,SAAS,CAAC,CAAC;QAC9D,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,UAAU,CACtB,GAA4B,EAC5B,CAAwB;IAExB,IAAI,GAAG,KAAK,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;KAAE;IACnC,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { __assign } from \"tslib\";\n/** An interface for representing a readonly pair */\nexport type Pair<S, T = S> = readonly [S, T];\n\nexport const pair = <S, T = S>(left: S, right: T): Pair<S, T> => [left, right];\n\n// using this polyfill, because `Object.assign` is not supported in IE.\nconst ObjectAssign: typeof Object.assign = __assign;\n\nexport enum SetKind {\n Dense,\n Empty,\n}\n\ninterface TreeNode<Left, Right> {\n readonly left: Left;\n readonly right: Right;\n}\n\ninterface KeyNode<Key, Exact> {\n readonly key: Key;\n readonly pathKey: Key;\n readonly isExact: Exact;\n}\n\nexport type Empty = SetKind.Empty;\n\n/** The term *Dense* means that a given subset contains all the elements of its particular\n * bounds. E.g. the whole set would be dense w.r.t. the bounds of the whole space. Or\n * if a set represents an interval [a, b), then it would be dense, if there are no holes in it,\n * i.e. the set is represented exactly using the current bounds.\n */\nexport type Dense = SetKind.Dense;\n\nexport const dense = SetKind.Dense;\nexport const empty = SetKind.Empty;\n\ntype KeyUnexact<Key> = KeyNode<Key, false>;\n\n/** In the BSP-set, each node carries with it implicit bounds just by the position in the tree.\n * Furthermore, it can carry around a key. The key can either be an approximation, i.e. an upper bound\n * or it can be *exact*. Exact means, that the whole set can be exactly represented in terms of just the key.\n *\n * One might wonder, why we don't prune the tree at this point. This has to do with the fact that we are\n * representing arbitrary sets and so even though one of two sets could be represented exactly the other\n * might not be able to yet. In this case we need to unfold the key by splitting further. In order to avoid\n * excessive splitting and pruning, we just carry around the key but allow the tree to also be materialized, on-demand.\n */\ntype KeyExact<Key> = KeyNode<Key, true>;\n\ntype KeyUndefined = KeyNode<undefined, false>;\ntype KeyDefined<Key> = KeyUnexact<Key> | KeyExact<Key>;\n\ntype BalancePropertyHelper<Key, Left, Right> = TreeNode<UntypedSparse<Key> | Left, UntypedSparse<Key> | Right>;\n\ntype TreeDefined<Key> =\n | BalancePropertyHelper<Key, Empty, Dense>\n | BalancePropertyHelper<Key, Dense, Empty>;\ntype TreeUndefined = TreeNode<undefined, undefined>;\n\ntype KeyDefinednessProperty<Key> = KeyDefined<Key> | KeyUndefined;\n\nexport type UntypedSparse<Key> =\n | (KeyDefinednessProperty<Key> & TreeDefined<Key>)\n | (KeyDefined<Key> & TreeUndefined);\n/** The term *untyped* refers to the tree representation of a BSP set. Because BSP set trees are only compared in terms\n * of their structure, we need to ensure that cuts occur at the same exact points across all possible sets. This is\n * enforced by the fact, that at construction time, we attach an `Id` to each BSP set and only allow operations to\n * occur on sets with the same `Id`.\n *\n * The BSP set becomes *untyped*, when we drop that `Id`; now it is possible to operate on sets that are incompatible.\n * Doing this, however, allows us to store the set operations only once per set as opposed to carrying them around with\n * every node.\n */\nexport type UntypedBspSet<Key> = Empty | Dense | UntypedSparse<Key>;\n\n/** A set is considred *sparse*, if we know that w.r.t. to it's bounds it is neither empty, nor dense. */\ninterface Sparse<Key extends Cachable<Key>, Id> {\n setOperations: SetOperations<Key, Id>;\n root: UntypedSparse<Key>;\n}\nexport type BspSet<Key extends Cachable<Key>, Id> =\n | Empty\n | Dense\n | Sparse<Key, Id>;\n\nexport interface KeyCache<T> {\n depth?: number;\n split?: Pair<Pair<CachedKey<T>, number>>;\n}\nexport type CachedKey<T> = T & KeyCache<T>;\nexport type Cachable<T> = Disjoint<keyof T, keyof KeyCache<T>>;\n\nexport type Disjoint<T, U> = [T, U] extends [Exclude<T, U>, Exclude<U, T>]\n ? any\n : never;\nexport type RequireAtLeastOne<T> = {\n [K in keyof T]-?: Required<Pick<T, K>> &\n Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n\n/** This is a concrete set operations implementation, tagged with an arbitrary id. */\nexport interface SetOperations<Key extends Cachable<Key>, Id> {\n /** Id here is just a phantom type, so that we can associate the various set instances together */\n readonly id: Id;\n\n /** Split the key into two. This will only be called when the current key is incomparable with an element.\n * E.g. this would never be called if the key is already a 1x1 rectangle. */\n readonly split: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>;\n\n /** Tells, if a given key can be split further */\n readonly canSplit: (key: CachedKey<Key>) => boolean;\n\n /** Tells if two keys overlap at all. */\n readonly meets: (key1: Key, key2: Key) => boolean;\n\n /** Intersect the keys, if it is possible to exactly respresent their intersection.\n * An implementation is never required to compute the intersection as this is just an optimization.\n * Precondition: It is guaranteed that the keys meet and that they are incomparable.\n */\n readonly intersect: (key1: Key, key2: Key) => Key | undefined;\n\n /** Unions the keys, if it is possible to exactly represent their union.\n * An implementation is never required to compute the union as this is just an optimization.\n * Precondition: It is guaranteed that the keys are incomparable.\n */\n readonly union: (key1: Key, key2: Key) => Key | undefined;\n\n /** Computes the set difference between two keys, if it is possible to exactly represent their set difference.\n * An implementation is never required to compute the difference as this is just an optimization.\n * Precondition: It is guaranteed that the keys meet.\n */\n readonly except: (key1: Key, key2: Key) => Key | undefined;\n\n /** Compare two keys */\n readonly compare: (key1: Key, key2: Key) => -1 | 0 | 1 | undefined;\n\n /** The top element of the set. */\n readonly top: Key;\n}\n\nexport const cacheKeySplitting = <Key>(\n splitFunction: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>,\n top: CachedKey<Key>,\n maxDepth: number = 10,\n) => (key: CachedKey<Key>) => {\n if (key.split !== undefined) {\n return key.split;\n }\n\n const split = splitFunction(key);\n const depth = key === top ? 0 : key.depth;\n if (depth !== undefined && depth < maxDepth) {\n key.split = split;\n split[0][0].depth = depth + 1;\n split[1][0].depth = depth + 1;\n }\n\n return split;\n};\n\nexport function fromUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n root: UntypedBspSet<Key>,\n): BspSet<Key, Id> {\n if (root === empty || root === dense) { return root; }\n return { setOperations, root };\n}\n\nconst sparse = <Key, Exact, Left, Right>(\n left: Left,\n right: Right,\n pathKey: Key,\n key: Key,\n isExact: Exact,\n) => ({ key, pathKey, left, right, isExact });\n\nfunction fromKey<Key>(\n pathKey: Key,\n key: Key,\n isExact: boolean,\n): UntypedSparse<Key> {\n if (isExact) {\n return sparse(undefined, undefined, pathKey, key, true as const);\n }\n\n return sparse(undefined, undefined, pathKey, key, false as const);\n}\n\nexport function lazy<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n pathKey: Key,\n key: Key,\n): UntypedBspSet<Key> {\n if (!setOperations.meets(pathKey, key)) { return empty; }\n const cmp = setOperations.compare(pathKey, key);\n if (cmp !== undefined) {\n if (cmp <= 0) { return dense; }\n\n return fromKey(pathKey, key, true);\n }\n\n // this is not exactly necessary, but increases the amount of exact nodes and thus we can often\n // prune earlier.\n // Also, having intersect always work guarantees exact nodes, thus allowing for more efficient\n // storage and computation.\n const newKey = setOperations.intersect(pathKey, key);\n\n if (newKey !== undefined) {\n return fromKey(pathKey, newKey, true);\n }\n\n return fromKey(pathKey, key, false);\n}\n\nexport function createFromKey<Key extends Cachable<Key>, Id>(\n uncachedSetOperations: SetOperations<Key, Id>,\n) {\n const setOperations = {\n ...uncachedSetOperations,\n split: cacheKeySplitting(\n uncachedSetOperations.split,\n uncachedSetOperations.top,\n ),\n };\n return (key: Key) =>\n fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));\n}\n\nfunction unionExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key> & KeyExact<Key>,\n right: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n const cmp = setOperations.compare(leftKey, rightKey);\n if (cmp !== undefined) {\n return cmp < 0 ? right : left;\n }\n\n const combinedKey = setOperations.union(leftKey, rightKey);\n if (combinedKey !== undefined) {\n const combinedCmp = setOperations.compare(combinedKey, pathKey);\n if (combinedCmp !== undefined && combinedCmp === 0) { return dense; }\n return fromKey(pathKey, combinedKey, true);\n }\n return undefined;\n}\n\n/** This is an local combination, not a proper union. We use it to have simpler code elsewhere */\nfunction combineChildren<Key>(\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): Empty | Dense | (UntypedSparse<Key> & TreeDefined<Key>) {\n if (left === empty) {\n if (right === empty) {\n return empty;\n }\n\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n if (right === empty) {\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n if (left === dense) {\n if (right === dense) {\n return dense;\n }\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n return sparse(left, right, undefined, undefined, false as const);\n}\n\nfunction materialize<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n set: UntypedSparse<Key>,\n): UntypedSparse<Key> & TreeDefined<Key> {\n if (set.left !== undefined) {\n return set;\n }\n\n const [[left], [right]] = setOperations.split(set.pathKey);\n const lChild = lazy(setOperations, left, set.key);\n const rChild = lazy(setOperations, right, set.key);\n\n const res = combineChildren<Key>(lChild, rChild);\n\n if (res === empty || res === dense) {\n throw new Error(\"incorrect set operations implementation\");\n }\n\n // first check, that res actually has the desired type\n const typeCheck: TreeDefined<Key> = res;\n\n const setAlias: UntypedSparse<Key> = set;\n return ObjectAssign(setAlias, {\n left: typeCheck.left,\n right: typeCheck.right,\n });\n}\n\nexport function unionUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (right === empty) { return left; }\n if (right === dense) { return right; }\n if (left === empty) { return right; }\n if (left === dense) { return left; }\n\n if (left.isExact && right.isExact) {\n const res = unionExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = unionUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = unionUntyped(setOperations, newLeft.right, newRight.right);\n\n return combineChildren(lChild, rChild);\n}\n\nexport function union<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (right === empty) { return left; }\n if (right === dense) { return right; }\n if (left === empty) { return right; }\n if (left === dense) { return left; }\n\n return fromUntyped(\n left.setOperations,\n unionUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nfunction intersectExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key> & KeyExact<Key>,\n right: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n if (!setOperations.meets(leftKey, rightKey)) {\n return empty;\n }\n\n const cmp = setOperations.compare(leftKey, rightKey);\n if (cmp !== undefined) {\n return cmp < 0 ? left : right;\n }\n\n const combinedKey = setOperations.intersect(leftKey, rightKey);\n if (combinedKey !== undefined) {\n return fromKey(pathKey, combinedKey, true);\n }\n\n return undefined;\n}\n\nexport function intersectUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (left === empty) { return left; }\n if (right === empty) { return right; }\n if (left === dense) { return right; }\n if (right === dense) { return left; }\n\n if (left.isExact && right.isExact) {\n const res = intersectExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = intersectUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = intersectUntyped(\n setOperations,\n newLeft.right,\n newRight.right,\n );\n\n return combineChildren(lChild, rChild);\n}\n\nexport function intersect<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (left === empty) { return left; }\n if (right === empty) { return right; }\n if (left === dense) { return right; }\n if (right === dense) { return left; }\n\n return fromUntyped(\n left.setOperations,\n intersectUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nexport function meetsUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): boolean {\n if (left === empty || right === empty) { return false; }\n if (left === dense || right === dense) { return true; }\n if (left.isExact && right.isExact) { return setOperations.meets(left.key, right.key); }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n return (\n meetsUntyped(setOperations, newLeft.left, newRight.left) ||\n meetsUntyped(setOperations, newLeft.right, newRight.right)\n );\n}\n\nexport function meets<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): boolean {\n if (left === empty || right === empty) { return false; }\n if (left === dense || right === dense) { return true; }\n return meetsUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nfunction exceptExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedSparse<Key> & KeyExact<Key>,\n right: KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n if (!setOperations.meets(leftKey, rightKey)) {\n return left;\n }\n\n const combinedKey = setOperations.except(leftKey, rightKey);\n if (combinedKey !== undefined) {\n return fromKey(pathKey, combinedKey, true);\n }\n\n return undefined;\n}\n\nexport function exceptUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (left === empty) { return left; }\n if (right === empty) { return left; }\n if (right === dense) { return empty; }\n if (left === dense) {\n const newRight_inner = materialize<Key, Id>(setOperations, right);\n const lChild_inner = exceptUntyped(setOperations, dense, newRight_inner.left);\n const rChild_inner = exceptUntyped(setOperations, dense, newRight_inner.right);\n return combineChildren(lChild_inner, rChild_inner);\n }\n if (left.isExact && right.isExact) {\n const res = exceptExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = exceptUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = exceptUntyped(setOperations, newLeft.right, newRight.right);\n\n return combineChildren(lChild, rChild);\n}\n\nexport function except<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (left === empty) { return left; }\n if (right === empty) { return left; }\n if (right === dense) { return empty; }\n if (left === dense) {\n return fromUntyped(\n right.setOperations,\n exceptUntyped<Key, Id>(right.setOperations, left, right.root),\n );\n }\n\n return fromUntyped(\n left.setOperations,\n exceptUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nconst compareExact = <Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: KeyExact<Key>,\n right: KeyExact<Key>,\n) => setOperations.compare(left.key, right.key);\n\nexport function combineCmp(\n left: -1 | 0 | 1 | undefined,\n right: -1 | 0 | 1 | undefined,\n) {\n if (left === undefined || right === undefined) { return undefined; }\n if (left === 0) { return right; }\n if (right === 0) { return left; }\n return left === right ? left : undefined;\n}\n\nexport function compareUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): -1 | 0 | 1 | undefined {\n if (left === right) { return 0; }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n if (left.isExact && right.isExact) {\n return compareExact(setOperations, left, right);\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n const lCmp = compareUntyped(setOperations, newLeft.left, newRight.left);\n if (lCmp === undefined) { return undefined; }\n\n const rCmp = compareUntyped(setOperations, newLeft.right, newRight.right);\n\n if (rCmp === undefined) { return undefined; }\n\n return combineCmp(lCmp, rCmp);\n}\n\nexport function compare<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n) {\n if (left === right) { return 0; }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n return compareUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nexport const symmetricDiff = <Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n) => union(except(left, right), except(right, left));\n\nexport const complement = <Key extends Cachable<Key>, Id>(\n set: BspSet<Key, Id>,\n) => except(dense, set);\n\nfunction getNodeCountUntyped<T>(set: UntypedBspSet<T> | undefined): number {\n if (set === undefined || set === empty || set === dense) {\n return 0;\n }\n\n return getNodeCountUntyped(set.left) + getNodeCountUntyped(set.right) + 1;\n}\n\nexport function getNodeCount<Key extends Cachable<Key>, Id>(\n set: BspSet<Key, Id>,\n) {\n if (set === empty || set === dense) { return 0; }\n return getNodeCountUntyped(set.root);\n}\n\nfunction forEachKeyUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n set: UntypedBspSet<Key>,\n f: (key: Key) => boolean,\n): boolean {\n function loop(pathKey: Key, set_inner: UntypedBspSet<Key>): boolean {\n if (set_inner === empty) { return true; }\n if (set_inner === dense) { return f(pathKey); }\n if (set_inner.isExact) { return f(set_inner.key); }\n\n const newSet = materialize<Key, Id>(setOperations, set_inner);\n const [[left], [right]] = setOperations.split(pathKey);\n return loop(left, newSet.left) && loop(right, newSet.right);\n }\n\n return loop(setOperations.top, set);\n}\n\nexport function forEachKey<Key extends Cachable<Key>, Id>(\n set: Empty | Sparse<Key, Id>,\n f: (key: Key) => boolean,\n): boolean {\n if (set === empty) { return true; }\n return forEachKeyUntyped(set.setOperations, set.root, f);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bspSet.js","sourceRoot":"","sources":["../src/bspSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAW,IAAO,EAAE,KAAQ,EAAc,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAE/E,uEAAuE;AACvE,MAAM,YAAY,GAAyB,QAAQ,CAAC;AAEpD,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IAClB,uCAAK,CAAA;IACL,uCAAK,CAAA;AACN,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAsBD,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AACnC,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,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AAS,KAAK,KAAK,EAAE;YACxB,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,SAAS,KAAK,KAAK,EAAE;YACxB,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;SAClB;QACD,IAAI,SAAS,CAAC,OAAO,EAAE;YACtB,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SACxB;QAED,MAAM,MAAM,GAAG,WAAW,CAAU,aAAa,EAAE,SAAS,CAAC,CAAC;QAC9D,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CACzB,GAA4B,EAC5B,CAAwB;IAExB,IAAI,GAAG,KAAK,KAAK,EAAE;QAClB,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { __assign } from \"tslib\";\n/** An interface for representing a readonly pair */\nexport type Pair<S, T = S> = readonly [S, T];\n\nexport const pair = <S, T = S>(left: S, right: T): Pair<S, T> => [left, right];\n\n// using this polyfill, because `Object.assign` is not supported in IE.\nconst ObjectAssign: typeof Object.assign = __assign;\n\nexport enum SetKind {\n\tDense,\n\tEmpty,\n}\n\ninterface TreeNode<Left, Right> {\n\treadonly left: Left;\n\treadonly right: Right;\n}\n\ninterface KeyNode<Key, Exact> {\n\treadonly key: Key;\n\treadonly pathKey: Key;\n\treadonly isExact: Exact;\n}\n\nexport type Empty = SetKind.Empty;\n\n/** The term *Dense* means that a given subset contains all the elements of its particular\n * bounds. E.g. the whole set would be dense w.r.t. the bounds of the whole space. Or\n * if a set represents an interval [a, b), then it would be dense, if there are no holes in it,\n * i.e. the set is represented exactly using the current bounds.\n */\nexport type Dense = SetKind.Dense;\n\nexport const dense = SetKind.Dense;\nexport const empty = SetKind.Empty;\n\ntype KeyUnexact<Key> = KeyNode<Key, false>;\n\n/** In the BSP-set, each node carries with it implicit bounds just by the position in the tree.\n * Furthermore, it can carry around a key. The key can either be an approximation, i.e. an upper bound\n * or it can be *exact*. Exact means, that the whole set can be exactly represented in terms of just the key.\n *\n * One might wonder, why we don't prune the tree at this point. This has to do with the fact that we are\n * representing arbitrary sets and so even though one of two sets could be represented exactly the other\n * might not be able to yet. In this case we need to unfold the key by splitting further. In order to avoid\n * excessive splitting and pruning, we just carry around the key but allow the tree to also be materialized, on-demand.\n */\ntype KeyExact<Key> = KeyNode<Key, true>;\n\ntype KeyUndefined = KeyNode<undefined, false>;\ntype KeyDefined<Key> = KeyUnexact<Key> | KeyExact<Key>;\n\ntype BalancePropertyHelper<Key, Left, Right> = TreeNode<\n\tUntypedSparse<Key> | Left,\n\tUntypedSparse<Key> | Right\n>;\n\ntype TreeDefined<Key> =\n\t| BalancePropertyHelper<Key, Empty, Dense>\n\t| BalancePropertyHelper<Key, Dense, Empty>;\ntype TreeUndefined = TreeNode<undefined, undefined>;\n\ntype KeyDefinednessProperty<Key> = KeyDefined<Key> | KeyUndefined;\n\nexport type UntypedSparse<Key> =\n\t| (KeyDefinednessProperty<Key> & TreeDefined<Key>)\n\t| (KeyDefined<Key> & TreeUndefined);\n/** The term *untyped* refers to the tree representation of a BSP set. Because BSP set trees are only compared in terms\n * of their structure, we need to ensure that cuts occur at the same exact points across all possible sets. This is\n * enforced by the fact, that at construction time, we attach an `Id` to each BSP set and only allow operations to\n * occur on sets with the same `Id`.\n *\n * The BSP set becomes *untyped*, when we drop that `Id`; now it is possible to operate on sets that are incompatible.\n * Doing this, however, allows us to store the set operations only once per set as opposed to carrying them around with\n * every node.\n */\nexport type UntypedBspSet<Key> = Empty | Dense | UntypedSparse<Key>;\n\n/** A set is considred *sparse*, if we know that w.r.t. to it's bounds it is neither empty, nor dense. */\ninterface Sparse<Key extends Cachable<Key>, Id> {\n\tsetOperations: SetOperations<Key, Id>;\n\troot: UntypedSparse<Key>;\n}\nexport type BspSet<Key extends Cachable<Key>, Id> = Empty | Dense | Sparse<Key, Id>;\n\nexport interface KeyCache<T> {\n\tdepth?: number;\n\tsplit?: Pair<Pair<CachedKey<T>, number>>;\n}\nexport type CachedKey<T> = T & KeyCache<T>;\nexport type Cachable<T> = Disjoint<keyof T, keyof KeyCache<T>>;\n\nexport type Disjoint<T, U> = [T, U] extends [Exclude<T, U>, Exclude<U, T>] ? any : never;\nexport type RequireAtLeastOne<T> = {\n\t[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n\n/** This is a concrete set operations implementation, tagged with an arbitrary id. */\nexport interface SetOperations<Key extends Cachable<Key>, Id> {\n\t/** Id here is just a phantom type, so that we can associate the various set instances together */\n\treadonly id: Id;\n\n\t/** Split the key into two. This will only be called when the current key is incomparable with an element.\n\t * E.g. this would never be called if the key is already a 1x1 rectangle. */\n\treadonly split: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>;\n\n\t/** Tells, if a given key can be split further */\n\treadonly canSplit: (key: CachedKey<Key>) => boolean;\n\n\t/** Tells if two keys overlap at all. */\n\treadonly meets: (key1: Key, key2: Key) => boolean;\n\n\t/** Intersect the keys, if it is possible to exactly respresent their intersection.\n\t * An implementation is never required to compute the intersection as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys meet and that they are incomparable.\n\t */\n\treadonly intersect: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Unions the keys, if it is possible to exactly represent their union.\n\t * An implementation is never required to compute the union as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys are incomparable.\n\t */\n\treadonly union: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Computes the set difference between two keys, if it is possible to exactly represent their set difference.\n\t * An implementation is never required to compute the difference as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys meet.\n\t */\n\treadonly except: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Compare two keys */\n\treadonly compare: (key1: Key, key2: Key) => -1 | 0 | 1 | undefined;\n\n\t/** The top element of the set. */\n\treadonly top: Key;\n}\n\nexport const cacheKeySplitting =\n\t<Key>(\n\t\tsplitFunction: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>,\n\t\ttop: CachedKey<Key>,\n\t\tmaxDepth: number = 10,\n\t) =>\n\t(key: CachedKey<Key>) => {\n\t\tif (key.split !== undefined) {\n\t\t\treturn key.split;\n\t\t}\n\n\t\tconst split = splitFunction(key);\n\t\tconst depth = key === top ? 0 : key.depth;\n\t\tif (depth !== undefined && depth < maxDepth) {\n\t\t\tkey.split = split;\n\t\t\tsplit[0][0].depth = depth + 1;\n\t\t\tsplit[1][0].depth = depth + 1;\n\t\t}\n\n\t\treturn split;\n\t};\n\nexport function fromUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\troot: UntypedBspSet<Key>,\n): BspSet<Key, Id> {\n\tif (root === empty || root === dense) {\n\t\treturn root;\n\t}\n\treturn { setOperations, root };\n}\n\nconst sparse = <Key, Exact, Left, Right>(\n\tleft: Left,\n\tright: Right,\n\tpathKey: Key,\n\tkey: Key,\n\tisExact: Exact,\n) => ({ key, pathKey, left, right, isExact });\n\nfunction fromKey<Key>(pathKey: Key, key: Key, isExact: boolean): UntypedSparse<Key> {\n\tif (isExact) {\n\t\treturn sparse(undefined, undefined, pathKey, key, true as const);\n\t}\n\n\treturn sparse(undefined, undefined, pathKey, key, false as const);\n}\n\nexport function lazy<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tpathKey: Key,\n\tkey: Key,\n): UntypedBspSet<Key> {\n\tif (!setOperations.meets(pathKey, key)) {\n\t\treturn empty;\n\t}\n\tconst cmp = setOperations.compare(pathKey, key);\n\tif (cmp !== undefined) {\n\t\tif (cmp <= 0) {\n\t\t\treturn dense;\n\t\t}\n\n\t\treturn fromKey(pathKey, key, true);\n\t}\n\n\t// this is not exactly necessary, but increases the amount of exact nodes and thus we can often\n\t// prune earlier.\n\t// Also, having intersect always work guarantees exact nodes, thus allowing for more efficient\n\t// storage and computation.\n\tconst newKey = setOperations.intersect(pathKey, key);\n\n\tif (newKey !== undefined) {\n\t\treturn fromKey(pathKey, newKey, true);\n\t}\n\n\treturn fromKey(pathKey, key, false);\n}\n\nexport function createFromKey<Key extends Cachable<Key>, Id>(\n\tuncachedSetOperations: SetOperations<Key, Id>,\n) {\n\tconst setOperations = {\n\t\t...uncachedSetOperations,\n\t\tsplit: cacheKeySplitting(uncachedSetOperations.split, uncachedSetOperations.top),\n\t};\n\treturn (key: Key) => fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));\n}\n\nfunction unionExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key> & KeyExact<Key>,\n\tright: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tconst cmp = setOperations.compare(leftKey, rightKey);\n\tif (cmp !== undefined) {\n\t\treturn cmp < 0 ? right : left;\n\t}\n\n\tconst combinedKey = setOperations.union(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\tconst combinedCmp = setOperations.compare(combinedKey, pathKey);\n\t\tif (combinedCmp !== undefined && combinedCmp === 0) {\n\t\t\treturn dense;\n\t\t}\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\treturn undefined;\n}\n\n/** This is an local combination, not a proper union. We use it to have simpler code elsewhere */\nfunction combineChildren<Key>(\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): Empty | Dense | (UntypedSparse<Key> & TreeDefined<Key>) {\n\tif (left === empty) {\n\t\tif (right === empty) {\n\t\t\treturn empty;\n\t\t}\n\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\tif (right === empty) {\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn dense;\n\t\t}\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\treturn sparse(left, right, undefined, undefined, false as const);\n}\n\nfunction materialize<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tset: UntypedSparse<Key>,\n): UntypedSparse<Key> & TreeDefined<Key> {\n\tif (set.left !== undefined) {\n\t\treturn set;\n\t}\n\n\tconst [[left], [right]] = setOperations.split(set.pathKey);\n\tconst lChild = lazy(setOperations, left, set.key);\n\tconst rChild = lazy(setOperations, right, set.key);\n\n\tconst res = combineChildren<Key>(lChild, rChild);\n\n\tif (res === empty || res === dense) {\n\t\tthrow new Error(\"incorrect set operations implementation\");\n\t}\n\n\t// first check, that res actually has the desired type\n\tconst typeCheck: TreeDefined<Key> = res;\n\n\tconst setAlias: UntypedSparse<Key> = set;\n\treturn ObjectAssign(setAlias, {\n\t\tleft: typeCheck.left,\n\t\tright: typeCheck.right,\n\t});\n}\n\nexport function unionUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn right;\n\t}\n\tif (left === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn left;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\tconst res = unionExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = unionUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = unionUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function union<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn right;\n\t}\n\tif (left === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn left;\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\tunionUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nfunction intersectExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key> & KeyExact<Key>,\n\tright: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tif (!setOperations.meets(leftKey, rightKey)) {\n\t\treturn empty;\n\t}\n\n\tconst cmp = setOperations.compare(leftKey, rightKey);\n\tif (cmp !== undefined) {\n\t\treturn cmp < 0 ? left : right;\n\t}\n\n\tconst combinedKey = setOperations.intersect(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\n\treturn undefined;\n}\n\nexport function intersectUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn right;\n\t}\n\tif (right === dense) {\n\t\treturn left;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\tconst res = intersectExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = intersectUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = intersectUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function intersect<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn right;\n\t}\n\tif (right === dense) {\n\t\treturn left;\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\tintersectUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nexport function meetsUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): boolean {\n\tif (left === empty || right === empty) {\n\t\treturn false;\n\t}\n\tif (left === dense || right === dense) {\n\t\treturn true;\n\t}\n\tif (left.isExact && right.isExact) {\n\t\treturn setOperations.meets(left.key, right.key);\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\treturn (\n\t\tmeetsUntyped(setOperations, newLeft.left, newRight.left) ||\n\t\tmeetsUntyped(setOperations, newLeft.right, newRight.right)\n\t);\n}\n\nexport function meets<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): boolean {\n\tif (left === empty || right === empty) {\n\t\treturn false;\n\t}\n\tif (left === dense || right === dense) {\n\t\treturn true;\n\t}\n\treturn meetsUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nfunction exceptExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedSparse<Key> & KeyExact<Key>,\n\tright: KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tif (!setOperations.meets(leftKey, rightKey)) {\n\t\treturn left;\n\t}\n\n\tconst combinedKey = setOperations.except(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\n\treturn undefined;\n}\n\nexport function exceptUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn empty;\n\t}\n\tif (left === dense) {\n\t\tconst newRight_inner = materialize<Key, Id>(setOperations, right);\n\t\tconst lChild_inner = exceptUntyped(setOperations, dense, newRight_inner.left);\n\t\tconst rChild_inner = exceptUntyped(setOperations, dense, newRight_inner.right);\n\t\treturn combineChildren(lChild_inner, rChild_inner);\n\t}\n\tif (left.isExact && right.isExact) {\n\t\tconst res = exceptExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = exceptUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = exceptUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function except<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn empty;\n\t}\n\tif (left === dense) {\n\t\treturn fromUntyped(\n\t\t\tright.setOperations,\n\t\t\texceptUntyped<Key, Id>(right.setOperations, left, right.root),\n\t\t);\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\texceptUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nconst compareExact = <Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: KeyExact<Key>,\n\tright: KeyExact<Key>,\n) => setOperations.compare(left.key, right.key);\n\nexport function combineCmp(left: -1 | 0 | 1 | undefined, right: -1 | 0 | 1 | undefined) {\n\tif (left === undefined || right === undefined) {\n\t\treturn undefined;\n\t}\n\tif (left === 0) {\n\t\treturn right;\n\t}\n\tif (right === 0) {\n\t\treturn left;\n\t}\n\treturn left === right ? left : undefined;\n}\n\nexport function compareUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): -1 | 0 | 1 | undefined {\n\tif (left === right) {\n\t\treturn 0;\n\t}\n\n\tif (left === empty) {\n\t\treturn -1;\n\t}\n\n\tif (right === empty) {\n\t\treturn 1;\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif (right === dense) {\n\t\treturn -1;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\treturn compareExact(setOperations, left, right);\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\tconst lCmp = compareUntyped(setOperations, newLeft.left, newRight.left);\n\tif (lCmp === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst rCmp = compareUntyped(setOperations, newLeft.right, newRight.right);\n\n\tif (rCmp === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn combineCmp(lCmp, rCmp);\n}\n\nexport function compare<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n) {\n\tif (left === right) {\n\t\treturn 0;\n\t}\n\n\tif (left === empty) {\n\t\treturn -1;\n\t}\n\n\tif (right === empty) {\n\t\treturn 1;\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif (right === dense) {\n\t\treturn -1;\n\t}\n\n\treturn compareUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nexport const symmetricDiff = <Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n) => union(except(left, right), except(right, left));\n\nexport const complement = <Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>) =>\n\texcept(dense, set);\n\nfunction getNodeCountUntyped<T>(set: UntypedBspSet<T> | undefined): number {\n\tif (set === undefined || set === empty || set === dense) {\n\t\treturn 0;\n\t}\n\n\treturn getNodeCountUntyped(set.left) + getNodeCountUntyped(set.right) + 1;\n}\n\nexport function getNodeCount<Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>) {\n\tif (set === empty || set === dense) {\n\t\treturn 0;\n\t}\n\treturn getNodeCountUntyped(set.root);\n}\n\nfunction forEachKeyUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tset: UntypedBspSet<Key>,\n\tf: (key: Key) => boolean,\n): boolean {\n\tfunction loop(pathKey: Key, set_inner: UntypedBspSet<Key>): boolean {\n\t\tif (set_inner === empty) {\n\t\t\treturn true;\n\t\t}\n\t\tif (set_inner === dense) {\n\t\t\treturn f(pathKey);\n\t\t}\n\t\tif (set_inner.isExact) {\n\t\t\treturn f(set_inner.key);\n\t\t}\n\n\t\tconst newSet = materialize<Key, Id>(setOperations, set_inner);\n\t\tconst [[left], [right]] = setOperations.split(pathKey);\n\t\treturn loop(left, newSet.left) && loop(right, newSet.right);\n\t}\n\n\treturn loop(setOperations.top, set);\n}\n\nexport function forEachKey<Key extends Cachable<Key>, Id>(\n\tset: Empty | Sparse<Key, Id>,\n\tf: (key: Key) => boolean,\n): boolean {\n\tif (set === empty) {\n\t\treturn true;\n\t}\n\treturn forEachKeyUntyped(set.setOperations, set.root, f);\n}\n"]}
|
package/lib/handlecache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlecache.d.ts","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAsB,MAAM,qBAAqB,CAAC;AAG5E;;;;;GAKG;AACH,qBAAa,WAAY,YAAW,eAAe,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"handlecache.d.ts","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAsB,MAAM,qBAAqB,CAAC;AAG5E;;;;;GAKG;AACH,qBAAa,WAAY,YAAW,eAAe,CAAC,MAAM,CAAC;aAI9B,MAAM,EAAE,iBAAiB;IAHrD,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,KAAK,CAAK;gBAEU,MAAM,EAAE,iBAAiB;IAErD;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;;;OAOG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM;IAajC,8EAA8E;IACvE,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAajD,0EAA0E;IAC1E,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,SAAS;IA4BjB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;CAoB9E"}
|
package/lib/handlecache.js
CHANGED
|
@@ -40,9 +40,7 @@ export class HandleCache {
|
|
|
40
40
|
// Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer
|
|
41
41
|
// checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an
|
|
42
42
|
// ~40% speedup when the position is in the cache (node v12 x64).
|
|
43
|
-
return index < this.handles.length
|
|
44
|
-
? this.handles[index]
|
|
45
|
-
: this.cacheMiss(position);
|
|
43
|
+
return index < this.handles.length ? this.handles[index] : this.cacheMiss(position);
|
|
46
44
|
}
|
|
47
45
|
/** Update the cache when a handle has been allocated for a given position. */
|
|
48
46
|
addHandle(position, handle) {
|
package/lib/handlecache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAU,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,OAAO,WAAW;
|
|
1
|
+
{"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAU,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAIvB,YAA4B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAH7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E,6EAA6E;QAC7E,aAAa;QACb,EAAE;QACF,4EAA4E;QAC5E,wBAAwB;QACxB,EAAE;QACF,6FAA6F;QAC7F,2EAA2E;QAC3E,EAAE;QACF,gFAAgF;QAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAChC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SAC5B;IACF,CAAC;CAGD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationVector, PermutationSegment } from \"./permutationvector\";\nimport { ensureRange } from \"./range\";\n\n/**\n * Used by PermutationVector to cache position -\\> handle lookups.\n *\n * Perf: Possibly, this should eventually be inlined into PermutationVector itself, but\n * so far there's no measurable perf penalty for being a separate object (node 12 x64)\n */\nexport class HandleCache implements IVectorConsumer<Handle> {\n\tprivate handles: Handle[] = [];\n\tprivate start = 0;\n\n\tconstructor(public readonly vector: PermutationVector) {}\n\n\t/**\n\t * Returns the index of the given position in the 'handles' array as a Uint32.\n\t * (If the position is not in the array, returns an integer greater than 'handles.length').\n\t */\n\tprivate getIndex(position: number) {\n\t\treturn (position - this.start) >>> 0;\n\t}\n\n\t/**\n\t * Returns the handle currently assigned to the given 'position' (if any). Check\n\t * the result with 'isValidHandle(..)' to see if a handle has been allocated for\n\t * the given position.\n\t *\n\t * Throws a 'RangeError' if the provided 'position' is out-of-bounds wrt. the\n\t * PermutationVector's length.\n\t */\n\tpublic getHandle(position: number) {\n\t\tconst index = this.getIndex(position);\n\n\t\t// Perf: To encourage inlining, handling of the 'cacheMiss(..)' case has been extracted\n\t\t// to a separate method.\n\n\t\t// Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer\n\t\t// checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an\n\t\t// ~40% speedup when the position is in the cache (node v12 x64).\n\n\t\treturn index < this.handles.length ? this.handles[index] : this.cacheMiss(position);\n\t}\n\n\t/** Update the cache when a handle has been allocated for a given position. */\n\tpublic addHandle(position: number, handle: Handle) {\n\t\tassert(isHandleValid(handle), 0x017 /* \"Trying to add invalid handle!\" */);\n\n\t\tconst index = this.getIndex(position);\n\t\tif (index < this.handles.length) {\n\t\t\tassert(\n\t\t\t\t!isHandleValid(this.handles[index]),\n\t\t\t\t0x018 /* \"Trying to insert handle into position with already valid handle!\" */,\n\t\t\t);\n\t\t\tthis.handles[index] = handle;\n\t\t}\n\t}\n\n\t/** Used by 'CacheMiss()' to retrieve handles for a range of positions. */\n\tprivate getHandles(start: number, end: number) {\n\t\t// TODO: This can be accelerated substantially using 'walkSegments()'. The only catch\n\t\t// is that\n\n\t\tconst handles: Handle[] = [];\n\t\tconst { vector } = this;\n\n\t\tfor (let pos = start; pos < end; pos++) {\n\t\t\tconst { segment, offset } = vector.getContainingSegment(pos);\n\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\thandles.push(asPerm.start + offset!);\n\t\t}\n\n\t\treturn handles;\n\t}\n\n\tprivate cacheMiss(position: number) {\n\t\t// Coercing 'position' to an Uint32 allows us to handle a negative 'position' value\n\t\t// with the same logic that handles 'position' >= length.\n\t\tconst _position = position >>> 0;\n\n\t\t// TODO: To bound memory usage, there should be a limit on the maximum size of\n\t\t// handle[].\n\n\t\t// TODO: To reduce MergeTree lookups, this code should opportunistically grow\n\t\t// the cache to the next MergeTree segment boundary (within the limits of\n\t\t// the handle cache).\n\n\t\tif (_position < this.start) {\n\t\t\tthis.handles = this.getHandles(_position, this.start).concat(this.handles);\n\t\t\tthis.start = _position;\n\t\t\treturn this.handles[0];\n\t\t} else {\n\t\t\tensureRange(_position, this.vector.getLength());\n\n\t\t\tthis.handles = this.handles.concat(\n\t\t\t\tthis.getHandles(this.start + this.handles.length, _position + 1),\n\t\t\t);\n\t\t\treturn this.handles[this.handles.length - 1];\n\t\t}\n\t}\n\n\t// #region IVectorConsumer\n\n\titemsChanged(start: number, removedCount: number, insertedCount: number): void {\n\t\t// If positions were inserted/removed, our current policy is to trim the array\n\t\t// at the beginning of the invalidate range and lazily repopulate the handles\n\t\t// on demand.\n\t\t//\n\t\t// Some alternatives to consider that preserve the previously cached handles\n\t\t// that are still valid:\n\t\t//\n\t\t// * Eagerly populate the 'handles[]' with the newly insert values (currently guaranteed\n\t\t// to be Handle.unallocated, so we don't even need to look them up.)\n\t\t//\n\t\t// * Use a sentinel value or other mechanism to allow \"holes\" in the cache.\n\n\t\tconst index = this.getIndex(start);\n\t\tif (index < this.handles.length) {\n\t\t\tthis.handles.length = index;\n\t\t}\n\t}\n\n\t// #endregion IVectorConsumer\n}\n"]}
|
package/lib/handletable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handletable.d.ts","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0BAAkB,MAAM;
|
|
1
|
+
{"version":3,"file":"handletable.d.ts","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0BAAkB,MAAM;IACvB,4BAA4B;IAC5B,KAAK,IAAI;IAET,mDAAmD;IACnD,WAAW,cAAc;CACzB;AAED,eAAO,MAAM,aAAa,WAAY,MAAM,YAA2B,CAAC;AAExE;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC;IAIN,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,GAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAQ;IAE1D,KAAK;IAOZ;;OAEG;IACI,QAAQ,IAAI,MAAM;IAOzB;;OAEG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM;IAQjC;;OAEG;IACI,IAAI,CAAC,MAAM,EAAE,MAAM;IAK1B;;OAEG;IACI,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC;IAI7B;;OAEG;IACI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAMnC,OAAO,KAAK,IAAI,GAEf;IACD,OAAO,KAAK,IAAI,QAEf;IAEM,iBAAiB;WAIV,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;CAG1C"}
|
package/lib/handletable.js
CHANGED
|
@@ -25,7 +25,7 @@ export class HandleTable {
|
|
|
25
25
|
allocate() {
|
|
26
26
|
var _a;
|
|
27
27
|
const free = this.next;
|
|
28
|
-
this.next = (_a = this.handles[free]) !== null && _a !== void 0 ? _a :
|
|
28
|
+
this.next = (_a = this.handles[free]) !== null && _a !== void 0 ? _a : free + 1;
|
|
29
29
|
this.handles[free] = 0;
|
|
30
30
|
return free;
|
|
31
31
|
}
|
|
@@ -60,8 +60,12 @@ export class HandleTable {
|
|
|
60
60
|
}
|
|
61
61
|
// Private helpers to get/set the head of the free list, which is stored in the 0th slot
|
|
62
62
|
// of the handle array.
|
|
63
|
-
get next() {
|
|
64
|
-
|
|
63
|
+
get next() {
|
|
64
|
+
return this.handles[0];
|
|
65
|
+
}
|
|
66
|
+
set next(handle) {
|
|
67
|
+
this.handles[0] = handle;
|
|
68
|
+
}
|
|
65
69
|
getSummaryContent() {
|
|
66
70
|
return this.handles;
|
|
67
71
|
}
|
package/lib/handletable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handletable.js","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,iBAAgB,CAAC;AAExE;;GAEG;AACH,MAAM,OAAO,WAAW;
|
|
1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AED;;OAEG;IACI,GAAG,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,MAAc,EAAE,KAAQ;QAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,wFAAwF;IACxF,uBAAuB;IACvB,IAAY,IAAI;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAW,CAAC;IAClC,CAAC;IACD,IAAY,IAAI,CAAC,MAAc;QAC9B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC1B,CAAC;IAEM,iBAAiB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAoB;QACzC,OAAO,IAAI,WAAW,CAAI,IAAI,CAAC,CAAC;IACjC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const enum Handle {\n\t/** Minimum valid handle. */\n\tvalid = 1,\n\n\t/** Sentinel representing an unallocated Handle. */\n\tunallocated = -0x80000000,\n}\n\nexport const isHandleValid = (handle: Handle) => handle >= Handle.valid;\n\n/**\n * A handle table provides a fast mapping from an integer `handle` to a value `T`.\n */\nexport class HandleTable<T> {\n\t// Note: the first slot of the 'handles' array is reserved to store the pointer to the first\n\t// free handle. We initialize this slot with a pointer to slot '1', which will cause\n\t// us to delay allocate the following slot in the array on the first allocation.\n\tpublic constructor(private readonly handles: (Handle | T)[] = [1]) {}\n\n\tpublic clear() {\n\t\t// Restore the HandleTable's initial state by deleting all items in the handles array\n\t\t// and then re-inserting the value '1' in the 0th slot. (See comment at `handles` decl\n\t\t// for explanation.)\n\t\tthis.handles.splice(0, this.handles.length, 1);\n\t}\n\n\t/**\n\t * Allocates and returns the next available handle. Note that freed handles are recycled.\n\t */\n\tpublic allocate(): Handle {\n\t\tconst free = this.next;\n\t\tthis.next = (this.handles[free] as Handle) ?? free + 1;\n\t\tthis.handles[free] = 0;\n\t\treturn free;\n\t}\n\n\t/**\n\t * Allocates and returns the next available `count` handles.\n\t */\n\tpublic allocateMany(count: Handle) {\n\t\tconst handles = new Uint32Array(count);\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\thandles[i] = this.allocate();\n\t\t}\n\t\treturn handles;\n\t}\n\n\t/**\n\t * Returns the given handle to the free list.\n\t */\n\tpublic free(handle: Handle) {\n\t\tthis.handles[handle] = this.next;\n\t\tthis.next = handle;\n\t}\n\n\t/**\n\t * Get the value `T` associated with the given handle, if any.\n\t */\n\tpublic get(handle: Handle): T {\n\t\treturn this.handles[handle] as T;\n\t}\n\n\t/**\n\t * Set the value `T` associated with the given handle.\n\t */\n\tpublic set(handle: Handle, value: T) {\n\t\tthis.handles[handle] = value;\n\t}\n\n\t// Private helpers to get/set the head of the free list, which is stored in the 0th slot\n\t// of the handle array.\n\tprivate get next() {\n\t\treturn this.handles[0] as Handle;\n\t}\n\tprivate set next(handle: Handle) {\n\t\tthis.handles[0] = handle;\n\t}\n\n\tpublic getSummaryContent() {\n\t\treturn this.handles;\n\t}\n\n\tpublic static load<T>(data: (Handle | T)[]) {\n\t\treturn new HandleTable<T>(data);\n\t}\n}\n"]}
|
package/lib/matrix.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare class SharedMatrix<T = any> extends SharedObject implements IMatr
|
|
|
54
54
|
getCell(row: number, col: number): MatrixItem<T>;
|
|
55
55
|
get matrixProducer(): IMatrixProducer<MatrixItem<T>>;
|
|
56
56
|
setCell(row: number, col: number, value: MatrixItem<T>): void;
|
|
57
|
-
setCells(rowStart: number, colStart: number, colCount: number, values: readonly
|
|
57
|
+
setCells(rowStart: number, colStart: number, colCount: number, values: readonly MatrixItem<T>[]): void;
|
|
58
58
|
private setCellCore;
|
|
59
59
|
private sendSetCellOp;
|
|
60
60
|
private submitVectorMessage;
|
package/lib/matrix.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,gBAAgB,EAGhB,YAAY,EACZ,iBAAiB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAIN,QAAQ,EAER,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAIhD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAwBxC;;;GAGG;AACH,oBAAY,UAAU,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY,CAAC,CAAC,GAAG,GAAG,CAChC,SAAQ,YACR,YACC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAC9B,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAC5B,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAgBrB,EAAE,EAAE,MAAM;IAdlB,OAAO,CAAC,QAAQ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OAOG;IACH,OAAO,CAAC,oBAAoB;IAiBrB,QAAQ;IAoBf;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;CAiD/C"}
|
package/lib/matrix.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { assert } from "@fluidframework/common-utils";
|
|
6
6
|
import { makeHandlesSerializable, parseHandles, SharedObject, } from "@fluidframework/shared-object-base";
|
|
7
7
|
import { ObjectStoragePartition, SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
8
|
-
import { MergeTreeDeltaType } from "@fluidframework/merge-tree";
|
|
8
|
+
import { MergeTreeDeltaType, } from "@fluidframework/merge-tree";
|
|
9
9
|
import { MatrixOp } from "./ops";
|
|
10
10
|
import { PermutationVector } from "./permutationvector";
|
|
11
11
|
import { SparseArray2D } from "./sparsearray2d";
|
|
@@ -60,7 +60,9 @@ export class SharedMatrix extends SharedObject {
|
|
|
60
60
|
this.rows = new PermutationVector("rows" /* rows */, this.logger, runtime, this.onRowDelta, this.onRowHandlesRecycled);
|
|
61
61
|
this.cols = new PermutationVector("cols" /* cols */, this.logger, runtime, this.onColDelta, this.onColHandlesRecycled);
|
|
62
62
|
}
|
|
63
|
-
static getFactory() {
|
|
63
|
+
static getFactory() {
|
|
64
|
+
return new SharedMatrixFactory();
|
|
65
|
+
}
|
|
64
66
|
/**
|
|
65
67
|
* Subscribes the given IUndoConsumer to the matrix.
|
|
66
68
|
*/
|
|
@@ -69,8 +71,12 @@ export class SharedMatrix extends SharedObject {
|
|
|
69
71
|
this.undo = new MatrixUndoProvider(consumer, this, this.rows, this.cols);
|
|
70
72
|
}
|
|
71
73
|
// TODO: closeUndo()?
|
|
72
|
-
get rowHandles() {
|
|
73
|
-
|
|
74
|
+
get rowHandles() {
|
|
75
|
+
return this.rows.handleCache;
|
|
76
|
+
}
|
|
77
|
+
get colHandles() {
|
|
78
|
+
return this.cols.handleCache;
|
|
79
|
+
}
|
|
74
80
|
/**
|
|
75
81
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
76
82
|
*/
|
|
@@ -87,8 +93,12 @@ export class SharedMatrix extends SharedObject {
|
|
|
87
93
|
}
|
|
88
94
|
// #endregion IMatrixProducer
|
|
89
95
|
// #region IMatrixReader
|
|
90
|
-
get rowCount() {
|
|
91
|
-
|
|
96
|
+
get rowCount() {
|
|
97
|
+
return this.rows.getLength();
|
|
98
|
+
}
|
|
99
|
+
get colCount() {
|
|
100
|
+
return this.cols.getLength();
|
|
101
|
+
}
|
|
92
102
|
getCell(row, col) {
|
|
93
103
|
// Perf: When possible, bounds checking is performed inside the implementation for
|
|
94
104
|
// 'getHandle()' so that it can be elided in the case of a cache hit. This
|
|
@@ -108,11 +118,12 @@ export class SharedMatrix extends SharedObject {
|
|
|
108
118
|
}
|
|
109
119
|
return undefined;
|
|
110
120
|
}
|
|
111
|
-
get matrixProducer() {
|
|
121
|
+
get matrixProducer() {
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
112
124
|
// #endregion IMatrixReader
|
|
113
125
|
setCell(row, col, value) {
|
|
114
|
-
assert(0 <= row && row < this.rowCount
|
|
115
|
-
&& 0 <= col && col < this.colCount, 0x01a /* "Trying to set out-of-bounds cell!" */);
|
|
126
|
+
assert(0 <= row && row < this.rowCount && 0 <= col && col < this.colCount, 0x01a /* "Trying to set out-of-bounds cell!" */);
|
|
116
127
|
this.setCellCore(row, col, value);
|
|
117
128
|
// Avoid reentrancy by raising change notifications after the op is queued.
|
|
118
129
|
for (const consumer of this.consumers.values()) {
|
|
@@ -121,10 +132,13 @@ export class SharedMatrix extends SharedObject {
|
|
|
121
132
|
}
|
|
122
133
|
setCells(rowStart, colStart, colCount, values) {
|
|
123
134
|
const rowCount = Math.ceil(values.length / colCount);
|
|
124
|
-
assert(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
135
|
+
assert(0 <= rowStart &&
|
|
136
|
+
rowStart < this.rowCount &&
|
|
137
|
+
0 <= colStart &&
|
|
138
|
+
colStart < this.colCount &&
|
|
139
|
+
1 <= colCount &&
|
|
140
|
+
colCount <= this.colCount - colStart &&
|
|
141
|
+
rowCount <= this.rowCount - rowStart, 0x01b /* "Trying to set multiple out-of-bounds cells!" */);
|
|
128
142
|
const endCol = colStart + colCount;
|
|
129
143
|
let r = rowStart;
|
|
130
144
|
let c = colStart;
|
|
@@ -186,9 +200,7 @@ export class SharedMatrix extends SharedObject {
|
|
|
186
200
|
if (this.isAttached()) {
|
|
187
201
|
// Record whether this `op` targets rows or cols. (See dispatch in `processCore()`)
|
|
188
202
|
message.target = dimension;
|
|
189
|
-
this.submitLocalMessage(message, currentVector.peekPendingSegmentGroups(message.type === MergeTreeDeltaType.GROUP
|
|
190
|
-
? message.ops.length
|
|
191
|
-
: 1));
|
|
203
|
+
this.submitLocalMessage(message, currentVector.peekPendingSegmentGroups(message.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1));
|
|
192
204
|
}
|
|
193
205
|
}
|
|
194
206
|
submitColMessage(message) {
|
|
@@ -275,10 +287,7 @@ export class SharedMatrix extends SharedObject {
|
|
|
275
287
|
const builder = new SummaryTreeBuilder();
|
|
276
288
|
builder.addWithStats("rows" /* rows */, this.rows.summarize(this.runtime, this.handle, serializer));
|
|
277
289
|
builder.addWithStats("cols" /* cols */, this.cols.summarize(this.runtime, this.handle, serializer));
|
|
278
|
-
builder.addBlob("cells" /* cells */, serializer.stringify([
|
|
279
|
-
this.cells.snapshot(),
|
|
280
|
-
this.pending.snapshot(),
|
|
281
|
-
], this.handle));
|
|
290
|
+
builder.addBlob("cells" /* cells */, serializer.stringify([this.cells.snapshot(), this.pending.snapshot()], this.handle));
|
|
282
291
|
return builder.getSummaryTree();
|
|
283
292
|
}
|
|
284
293
|
/**
|