@fluid-experimental/tree 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/.eslintrc.js +2 -0
- package/.vscode/SharedTree.code-workspace +15 -0
- package/.vscode/settings.json +6 -0
- package/dist/ChangeCompression.js +9 -9
- package/dist/ChangeCompression.js.map +1 -1
- package/dist/ChangeTypes.d.ts +1 -6
- package/dist/ChangeTypes.d.ts.map +1 -1
- package/dist/ChangeTypes.js +5 -5
- package/dist/ChangeTypes.js.map +1 -1
- package/dist/Checkout.js +14 -14
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts +21 -3
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js +29 -4
- package/dist/Common.js.map +1 -1
- package/dist/EditLog.js +26 -25
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.js +17 -17
- package/dist/EditUtilities.js.map +1 -1
- package/dist/Forest.js +31 -31
- package/dist/Forest.js.map +1 -1
- package/dist/HistoryEditFactory.js +9 -9
- package/dist/HistoryEditFactory.js.map +1 -1
- package/dist/IdConversion.js +9 -9
- package/dist/IdConversion.js.map +1 -1
- package/dist/Identifiers.d.ts +4 -0
- package/dist/Identifiers.d.ts.map +1 -1
- package/dist/Identifiers.js.map +1 -1
- package/dist/LogViewer.d.ts +1 -5
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +11 -19
- package/dist/LogViewer.js.map +1 -1
- package/dist/MergeHealth.js +2 -2
- package/dist/MergeHealth.js.map +1 -1
- package/dist/NodeIdUtilities.js +2 -2
- package/dist/NodeIdUtilities.js.map +1 -1
- package/dist/PayloadUtilities.js +1 -1
- package/dist/PayloadUtilities.js.map +1 -1
- package/dist/RevisionValueCache.d.ts +13 -10
- package/dist/RevisionValueCache.d.ts.map +1 -1
- package/dist/RevisionValueCache.js +14 -11
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/RevisionView.js +4 -4
- package/dist/RevisionView.js.map +1 -1
- package/dist/SerializationUtilities.js +4 -4
- package/dist/SerializationUtilities.js.map +1 -1
- package/dist/SharedTree.d.ts +93 -31
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +160 -131
- package/dist/SharedTree.js.map +1 -1
- package/dist/SharedTreeEncoder.d.ts +3 -3
- package/dist/SharedTreeEncoder.d.ts.map +1 -1
- package/dist/SharedTreeEncoder.js +36 -36
- package/dist/SharedTreeEncoder.js.map +1 -1
- package/dist/StringInterner.js +1 -1
- package/dist/StringInterner.js.map +1 -1
- package/dist/Summary.js +1 -1
- package/dist/Summary.js.map +1 -1
- package/dist/SummaryBackCompatibility.js +8 -8
- package/dist/SummaryBackCompatibility.js.map +1 -1
- package/dist/Transaction.js +1 -1
- package/dist/Transaction.js.map +1 -1
- package/dist/TransactionInternal.js +17 -17
- package/dist/TransactionInternal.js.map +1 -1
- package/dist/TreeCompressor.d.ts.map +1 -1
- package/dist/TreeCompressor.js +6 -8
- package/dist/TreeCompressor.js.map +1 -1
- package/dist/TreeNodeHandle.js +4 -4
- package/dist/TreeNodeHandle.js.map +1 -1
- package/dist/TreeView.js +7 -7
- package/dist/TreeView.js.map +1 -1
- package/dist/TreeViewUtilities.js +2 -2
- package/dist/TreeViewUtilities.js.map +1 -1
- package/dist/UndoRedoHandler.js +1 -1
- package/dist/UndoRedoHandler.js.map +1 -1
- package/dist/UuidUtilities.d.ts +30 -0
- package/dist/UuidUtilities.d.ts.map +1 -0
- package/dist/UuidUtilities.js +106 -0
- package/dist/UuidUtilities.js.map +1 -0
- package/dist/id-compressor/AppendOnlySortedMap.d.ts +52 -28
- package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
- package/dist/id-compressor/AppendOnlySortedMap.js +167 -90
- package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/dist/id-compressor/IdCompressor.d.ts +43 -42
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +179 -177
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/id-compressor/IdRange.js +1 -1
- package/dist/id-compressor/IdRange.js.map +1 -1
- package/dist/id-compressor/NumericUuid.d.ts +6 -14
- package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
- package/dist/id-compressor/NumericUuid.js +15 -76
- package/dist/id-compressor/NumericUuid.js.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.d.ts +122 -0
- package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
- package/dist/id-compressor/SessionIdNormalizer.js +418 -0
- package/dist/id-compressor/SessionIdNormalizer.js.map +1 -0
- package/dist/id-compressor/persisted-types/0.0.1.d.ts +6 -13
- package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
- package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/persisted-types/0.1.1.d.ts +1 -6
- package/dist/persisted-types/0.1.1.d.ts.map +1 -1
- package/dist/persisted-types/0.1.1.js +3 -3
- package/dist/persisted-types/0.1.1.js.map +1 -1
- package/lib/ChangeTypes.d.ts +1 -6
- package/lib/ChangeTypes.d.ts.map +1 -1
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts +21 -3
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +25 -3
- package/lib/Common.js.map +1 -1
- package/lib/EditLog.js +2 -1
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.js.map +1 -1
- package/lib/Forest.js.map +1 -1
- package/lib/HistoryEditFactory.js.map +1 -1
- package/lib/Identifiers.d.ts +4 -0
- package/lib/Identifiers.d.ts.map +1 -1
- package/lib/Identifiers.js.map +1 -1
- package/lib/LogViewer.d.ts +1 -5
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +5 -13
- package/lib/LogViewer.js.map +1 -1
- package/lib/MergeHealth.js.map +1 -1
- package/lib/NodeIdUtilities.js.map +1 -1
- package/lib/RevisionValueCache.d.ts +13 -10
- package/lib/RevisionValueCache.d.ts.map +1 -1
- package/lib/RevisionValueCache.js +10 -7
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/RevisionView.js.map +1 -1
- package/lib/SharedTree.d.ts +93 -31
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +107 -78
- package/lib/SharedTree.js.map +1 -1
- package/lib/SharedTreeEncoder.d.ts +3 -3
- package/lib/SharedTreeEncoder.d.ts.map +1 -1
- package/lib/SharedTreeEncoder.js +4 -4
- package/lib/SharedTreeEncoder.js.map +1 -1
- package/lib/StringInterner.js.map +1 -1
- package/lib/Summary.js.map +1 -1
- package/lib/TreeCompressor.d.ts.map +1 -1
- package/lib/TreeCompressor.js +1 -3
- package/lib/TreeCompressor.js.map +1 -1
- package/lib/TreeNodeHandle.js.map +1 -1
- package/lib/TreeView.js.map +1 -1
- package/lib/TreeViewUtilities.js.map +1 -1
- package/lib/UuidUtilities.d.ts +30 -0
- package/lib/UuidUtilities.d.ts.map +1 -0
- package/lib/UuidUtilities.js +98 -0
- package/lib/UuidUtilities.js.map +1 -0
- package/lib/id-compressor/AppendOnlySortedMap.d.ts +52 -28
- package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
- package/lib/id-compressor/AppendOnlySortedMap.js +165 -88
- package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts +43 -42
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +97 -95
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/id-compressor/NumericUuid.d.ts +6 -14
- package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
- package/lib/id-compressor/NumericUuid.js +11 -70
- package/lib/id-compressor/NumericUuid.js.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.d.ts +122 -0
- package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
- package/lib/id-compressor/SessionIdNormalizer.js +414 -0
- package/lib/id-compressor/SessionIdNormalizer.js.map +1 -0
- package/lib/id-compressor/persisted-types/0.0.1.d.ts +6 -13
- package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/persisted-types/0.1.1.d.ts +1 -6
- package/lib/persisted-types/0.1.1.d.ts.map +1 -1
- package/lib/persisted-types/0.1.1.js.map +1 -1
- package/lib/test/AppendOnlySortedMap.perf.tests.d.ts +6 -0
- package/lib/test/AppendOnlySortedMap.perf.tests.d.ts.map +1 -0
- package/lib/test/AppendOnlySortedMap.perf.tests.js +49 -0
- package/lib/test/AppendOnlySortedMap.perf.tests.js.map +1 -0
- package/lib/test/AppendOnlySortedMap.tests.js +56 -14
- package/lib/test/AppendOnlySortedMap.tests.js.map +1 -1
- package/lib/test/Checkout.tests.js +2 -2
- package/lib/test/Checkout.tests.js.map +1 -1
- package/lib/test/Forest.tests.js.map +1 -1
- package/lib/test/IdCompressor.perf.tests.js +8 -2
- package/lib/test/IdCompressor.perf.tests.js.map +1 -1
- package/lib/test/IdCompressor.tests.js +75 -24
- package/lib/test/IdCompressor.tests.js.map +1 -1
- package/lib/test/LogViewer.tests.js +3 -5
- package/lib/test/LogViewer.tests.js.map +1 -1
- package/lib/test/NumericUuid.perf.tests.js +4 -4
- package/lib/test/NumericUuid.perf.tests.js.map +1 -1
- package/lib/test/NumericUuid.tests.js +5 -4
- package/lib/test/NumericUuid.tests.js.map +1 -1
- package/lib/test/RevisionValueCache.tests.js.map +1 -1
- package/lib/test/RevisionView.tests.js.map +1 -1
- package/lib/test/SessionIdNormalizer.tests.d.ts +6 -0
- package/lib/test/SessionIdNormalizer.tests.d.ts.map +1 -0
- package/lib/test/SessionIdNormalizer.tests.js +299 -0
- package/lib/test/SessionIdNormalizer.tests.js.map +1 -0
- package/lib/test/Summary.tests.js +1 -1
- package/lib/test/Summary.tests.js.map +1 -1
- package/lib/test/TreeCompression.tests.js +1 -1
- package/lib/test/TreeCompression.tests.js.map +1 -1
- package/lib/test/Virtualization.tests.js +1 -1
- package/lib/test/Virtualization.tests.js.map +1 -1
- package/lib/test/fuzz/Generators.d.ts +3 -14
- package/lib/test/fuzz/Generators.d.ts.map +1 -1
- package/lib/test/fuzz/Generators.js +60 -151
- package/lib/test/fuzz/Generators.js.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +10 -7
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +94 -104
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
- package/lib/test/fuzz/Types.d.ts +2 -9
- package/lib/test/fuzz/Types.d.ts.map +1 -1
- package/lib/test/fuzz/Types.js +1 -1
- package/lib/test/fuzz/Types.js.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts +57 -11
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.js +112 -98
- package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.js +2 -1
- package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +30 -1
- package/lib/test/utilities/SharedTreeTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.js +20 -0
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
- package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +1 -1
- package/lib/test/utilities/SummaryLoadPerfTests.js +6 -3
- package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
- package/lib/test/utilities/TestNode.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts +9 -1
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +27 -13
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/package.json +19 -17
- package/src/Common.ts +42 -4
- package/src/EditLog.ts +1 -1
- package/src/Identifiers.ts +5 -0
- package/src/LogViewer.ts +4 -20
- package/src/RevisionValueCache.ts +11 -8
- package/src/SharedTree.ts +222 -75
- package/src/SharedTreeEncoder.ts +17 -11
- package/src/TreeCompressor.ts +2 -4
- package/src/UuidUtilities.ts +123 -0
- package/src/id-compressor/AppendOnlySortedMap.ts +183 -94
- package/src/id-compressor/IdCompressor.ts +144 -132
- package/src/id-compressor/NumericUuid.ts +11 -80
- package/src/id-compressor/SessionIdNormalizer.ts +497 -0
- package/src/id-compressor/persisted-types/0.0.1.ts +12 -15
- package/src/index.ts +5 -0
package/dist/TreeView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../src/TreeView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAA+D;AAE/D,qCAA+D;AAC/D,uDAAmD;AAsEnD;;;GAGG;AACH,MAAsB,QAAQ;IAY7B,YAAsB,IAAY,EAAE,MAAc;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,gDAAgD;IAChD,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,qEAAqE;IAC9D,OAAO,CAAC,EAAU;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;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AA4B;QAC9D,OAAO,IAAI,KAAK,sBAAI,CAAC,KAAK,CAAC,CAAC,CAAE,CAAgB,CAAC,CAAC,CAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,MAAqB,CAAC;IACtG,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAc;QAC1B,eAAM,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,8DAA8D,CAAC,CAAC;QAChG,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;CACD;AA1OD,4BA0OC;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,KAAqB;IAClD,qEAAqE;IACrE,OAAO,CAAC,IAAI,GAAG,KAAK,CAAe,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, copyPropertyIfDefined, fail } from './Common';\nimport { NodeId, TraitLabel } from './Identifiers';\nimport { Delta, Forest, isParentedForestNode } from './Forest';\nimport { NodeData, Side } from './persisted-types';\n\n/**\n * Specifies the location of a trait (a labeled sequence of nodes) within the tree.\n * @public\n */\nexport interface TraitLocation {\n\treadonly parent: NodeId;\n\treadonly label: TraitLabel;\n}\n\n/**\n * An immutable view of a distributed tree node.\n * @public\n */\nexport interface TreeViewNode extends NodeData<NodeId> {\n\t/** The IDs of the children under this node */\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\n\t/** The parent and trait under which this node resides. Undefined iff this is the root node of the tree (i.e. {@link initialTree}). */\n\treadonly parentage?: TraitLocation;\n}\n\n/**\n * Index of a place within a trait.\n * 0 = before all nodes,\n * 1 = after first node,\n * etc.\n * @public\n */\nexport type PlaceIndex = number & { readonly PlaceIndex: unique symbol };\n\n/**\n * Index of a node within a trait.\n * 0 = first node,\n * 1 = second node,\n * etc.\n * @public\n */\nexport type TraitNodeIndex = number & { readonly TraitNodeIndex: unique symbol };\n\n/**\n * A place within a particular `TreeView` that is anchored relative to a specific node in the tree, or relative to the outside of the trait.\n * Valid iff 'trait' is valid and, if provided, sibling is in the Location specified by 'trait'.\n * @public\n */\nexport interface TreeViewPlace {\n\treadonly sibling?: NodeId;\n\treadonly side: Side;\n\treadonly trait: TraitLocation;\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait within a particular `TreeView`.\n * Valid iff start and end are valid and are within the same trait.\n * @public\n */\nexport interface TreeViewRange {\n\treadonly start: TreeViewPlace;\n\treadonly end: TreeViewPlace;\n}\n\n/**\n * Contains some redundant information. Use only in computations between edits. Do not store.\n * @public\n */\nexport interface NodeInTrait {\n\treadonly trait: TraitLocation;\n\treadonly index: TraitNodeIndex;\n}\n\n/**\n * A view of a distributed tree.\n * @public\n */\nexport abstract class TreeView {\n\tpublic readonly root: NodeId;\n\tprotected readonly forest: Forest;\n\tprivate readonly rootNode: TreeViewNode;\n\n\t/**\n\t * A cache of node's index within their parent trait.\n\t * Used to avoid redundant linear scans of traits.\n\t * Not shared across views; initialized to empty each time a TreeView is created.\n\t */\n\tprivate traitIndicesCache?: Map<NodeId, TraitNodeIndex>;\n\n\tprotected constructor(root: NodeId, forest: Forest) {\n\t\tthis.root = root;\n\t\tthis.forest = forest;\n\t\tthis.rootNode = this.getViewNode(root);\n\t}\n\n\t/** @returns the number of nodes in this view */\n\tpublic get size(): number {\n\t\treturn this.forest.size;\n\t}\n\n\t/** @returns true iff a node with the given id exists in this view */\n\tpublic hasNode(id: NodeId): boolean {\n\t\treturn this.forest.has(id);\n\t}\n\n\t/**\n\t * @returns the index just after place (which specifies a location between items).\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic findIndexWithinTrait(place: TreeViewPlace): PlaceIndex {\n\t\tif (place.sibling === undefined) {\n\t\t\treturn this.getIndexOfSide(place.side, place.trait);\n\t\t}\n\t\treturn getIndex(place.side, this.getIndexInTrait(place.sibling));\n\t}\n\n\t/** @returns the node associated with the given id in this view. Fails if the node does not exist in this view. */\n\tpublic getViewNode(id: NodeId): TreeViewNode {\n\t\treturn this.tryGetViewNode(id) ?? fail('NodeId not found');\n\t}\n\n\t/** @returns the node associated with the given id in this view, or undefined if the node does not exist in this view */\n\tpublic tryGetViewNode(id: NodeId): TreeViewNode | undefined {\n\t\tconst forestNode = this.forest.tryGet(id);\n\t\tif (forestNode !== undefined && isParentedForestNode(forestNode)) {\n\t\t\tconst viewNode: TreeViewNode = {\n\t\t\t\tdefinition: forestNode.definition,\n\t\t\t\tidentifier: forestNode.identifier,\n\t\t\t\ttraits: forestNode.traits,\n\t\t\t\tparentage: {\n\t\t\t\t\tlabel: forestNode.traitParent,\n\t\t\t\t\tparent: forestNode.parentId,\n\t\t\t\t},\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(forestNode, viewNode, 'payload');\n\t\t\treturn viewNode;\n\t\t}\n\n\t\treturn forestNode;\n\t}\n\n\t/**\n\t * @returns the label of the trait under which a node with the given id resides. Fails if the node does not exist in this view or if\n\t * it is the root node.\n\t */\n\tpublic getTraitLabel(id: NodeId): TraitLabel {\n\t\treturn this.forest.getParent(id).traitParent;\n\t}\n\n\t/**\n\t * @returns the label of the trait under which a node with the given id resides, or undefined if the node is not present in this\n\t * view or if it is the root node\n\t */\n\tpublic tryGetTraitLabel(id: NodeId): TraitLabel | undefined {\n\t\treturn this.forest.tryGetParent(id)?.traitParent;\n\t}\n\n\t/**\n\t * @returns the parent of the node with the given id. Fails if the node does not exist in this view or if it is the root node.\n\t */\n\tpublic getParentViewNode(id: NodeId): TreeViewNode {\n\t\tconst parentInfo = this.forest.getParent(id);\n\t\treturn this.getViewNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @returns the parent of the node with the given id. Returns undefined if the node does not exist in this view or if it is the root\n\t * node.\n\t */\n\tpublic tryGetParentViewNode(id: NodeId): TreeViewNode | undefined {\n\t\tconst parentInfo = this.forest.tryGetParent(id);\n\t\tif (parentInfo === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.getViewNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @returns the trait location of the node with the given id. Fails if the node does not exist in this view or of it is the root\n\t * node\n\t */\n\tpublic getTraitLocation(id: NodeId): TraitLocation {\n\t\tconst parentData = this.forest.getParent(id);\n\t\treturn {\n\t\t\tparent: parentData.parentId,\n\t\t\tlabel: parentData.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * @returns the trait location of the node with the given id, or undefined if the node does not exist in this view or if it is the root\n\t * node\n\t */\n\tpublic tryGetTraitLocation(id: NodeId): TraitLocation | undefined {\n\t\tconst parentData = this.forest.tryGetParent(id);\n\t\tif (parentData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\tparent: parentData.parentId,\n\t\t\tlabel: parentData.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * @returns the index within the trait under which the node with the given id resides. The node must exist in this view and must have a\n\t * parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic getIndexInTrait(id: NodeId): TraitNodeIndex {\n\t\tconst index = this.tryGetIndexInTrait(id);\n\t\treturn index ?? fail('ID does not exist in the forest.');\n\t}\n\n\t/**\n\t * @returns the index within the trait under which the node with the given id resides, or undefined if the node does not exist in this\n\t * view or does not have a parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic tryGetIndexInTrait(id: NodeId): TraitNodeIndex | undefined {\n\t\tconst cachedIndex = this.traitIndicesCache?.get(id);\n\t\tif (cachedIndex !== undefined) {\n\t\t\treturn cachedIndex;\n\t\t}\n\n\t\tconst parentData = this.forest.tryGetParent(id);\n\t\tif (parentData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parent = this.forest.tryGet(parentData.parentId);\n\t\tif (parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst trait = parent.traits.get(parentData.traitParent) ?? fail('inconsistent forest: trait parent not found');\n\t\tlet foundIndex: TraitNodeIndex | undefined;\n\t\tif (trait.length === 0) {\n\t\t\treturn foundIndex;\n\t\t}\n\n\t\tthis.traitIndicesCache ??= new Map();\n\t\tfor (let i = 0; i < trait.length; i++) {\n\t\t\tconst nodeInTrait = trait[i];\n\t\t\tconst index = i as TraitNodeIndex;\n\t\t\tthis.traitIndicesCache.set(nodeInTrait, index);\n\t\t\tif (nodeInTrait === id) {\n\t\t\t\tfoundIndex = index;\n\t\t\t}\n\t\t}\n\n\t\treturn foundIndex;\n\t}\n\n\t/**\n\t * @returns the trait at the given location. If no such trait exists, returns an empty trait.\n\t */\n\tpublic getTrait(traitLocation: TraitLocation): readonly NodeId[] {\n\t\treturn this.getViewNode(traitLocation.parent).traits.get(traitLocation.label) ?? [];\n\t}\n\n\t/** Asserts that the view's internal state is consistent. Useful for testing/validation. */\n\tpublic assertConsistent(): void {\n\t\tthis.forest.assertConsistent();\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<TreeViewNode> {\n\t\treturn this.iterateNodeDescendants(this.rootNode);\n\t}\n\n\t/** @returns true iff the given view is equal to this view */\n\tpublic abstract equals(view: TreeView): boolean;\n\n\t/**\n\t * @returns true iff the given view's forest of nodes is equivalent to this view's forest of nodes\n\t * @param strict - if true, the views' forests must be the same object, otherwise they must merely be equivalent\n\t */\n\tpublic hasEqualForest(view: TreeView, strict = false): boolean {\n\t\tif (this.root === view.root) {\n\t\t\t// TODO:#49100:Perf: make this faster and/or remove use by PrefetchingCheckout.\n\t\t\treturn strict ? this.forest === view.forest : this.forest.equals(view.forest);\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate *iterateNodeDescendants(node: TreeViewNode): IterableIterator<TreeViewNode> {\n\t\tyield node;\n\t\tfor (const label of [...node.traits.keys()].sort()) {\n\t\t\tconst trait = node.traits.get(label);\n\t\t\tfor (const childId of trait ?? fail('Expected trait with label')) {\n\t\t\t\tconst child = this.getViewNode(childId);\n\t\t\t\tyield* this.iterateNodeDescendants(child);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getIndexOfSide(side: Side, traitLocation: TraitLocation): PlaceIndex {\n\t\treturn side === Side.After ? (0 as PlaceIndex) : (this.getTrait(traitLocation).length as PlaceIndex);\n\t}\n\n\t/**\n\t * Calculate the difference between two `TreeView`s\n\t * @param view - the other view to compare to this one\n\t * @returns A {@link Delta} which nodes must be changed, added, and removed to get from `this` to `view`.\n\t * The views must share a root.\n\t */\n\tpublic delta(view: TreeView): Delta<NodeId> {\n\t\tassert(this.root === view.root, 'Delta can only be calculated between views that share a root');\n\t\treturn this.forest.delta(view.forest);\n\t}\n}\n\nfunction getIndex(side: Side, index: TraitNodeIndex): PlaceIndex {\n\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n\treturn (side + index) as PlaceIndex;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../src/TreeView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAA+D;AAE/D,qCAA+D;AAC/D,uDAAmD;AAsEnD;;;GAGG;AACH,MAAsB,QAAQ;IAY7B,YAAsB,IAAY,EAAE,MAAc;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,gDAAgD;IAChD,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,qEAAqE;IAC9D,OAAO,CAAC,EAAU;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,oBAAoB,CAAC,KAAoB;QAC/C,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,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AAC,aAAa,CAAC,CAAC,MAAqB,CAAC;IACtG,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAc;QAC1B,IAAA,eAAM,EAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,8DAA8D,CAAC,CAAC;QAChG,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;CACD;AA1OD,4BA0OC;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,KAAqB;IAClD,qEAAqE;IACrE,OAAO,CAAC,IAAI,GAAG,KAAK,CAAe,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, copyPropertyIfDefined, fail } from './Common';\nimport { NodeId, TraitLabel } from './Identifiers';\nimport { Delta, Forest, isParentedForestNode } from './Forest';\nimport { NodeData, Side } from './persisted-types';\n\n/**\n * Specifies the location of a trait (a labeled sequence of nodes) within the tree.\n * @public\n */\nexport interface TraitLocation {\n\treadonly parent: NodeId;\n\treadonly label: TraitLabel;\n}\n\n/**\n * An immutable view of a distributed tree node.\n * @public\n */\nexport interface TreeViewNode extends NodeData<NodeId> {\n\t/** The IDs of the children under this node */\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\n\t/** The parent and trait under which this node resides. Undefined iff this is the root node of the tree (i.e. {@link initialTree}). */\n\treadonly parentage?: TraitLocation;\n}\n\n/**\n * Index of a place within a trait.\n * 0 = before all nodes,\n * 1 = after first node,\n * etc.\n * @public\n */\nexport type PlaceIndex = number & { readonly PlaceIndex: unique symbol };\n\n/**\n * Index of a node within a trait.\n * 0 = first node,\n * 1 = second node,\n * etc.\n * @public\n */\nexport type TraitNodeIndex = number & { readonly TraitNodeIndex: unique symbol };\n\n/**\n * A place within a particular `TreeView` that is anchored relative to a specific node in the tree, or relative to the outside of the trait.\n * Valid iff 'trait' is valid and, if provided, sibling is in the Location specified by 'trait'.\n * @public\n */\nexport interface TreeViewPlace {\n\treadonly sibling?: NodeId;\n\treadonly side: Side;\n\treadonly trait: TraitLocation;\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait within a particular `TreeView`.\n * Valid iff start and end are valid and are within the same trait.\n * @public\n */\nexport interface TreeViewRange {\n\treadonly start: TreeViewPlace;\n\treadonly end: TreeViewPlace;\n}\n\n/**\n * Contains some redundant information. Use only in computations between edits. Do not store.\n * @public\n */\nexport interface NodeInTrait {\n\treadonly trait: TraitLocation;\n\treadonly index: TraitNodeIndex;\n}\n\n/**\n * A view of a distributed tree.\n * @public\n */\nexport abstract class TreeView {\n\tpublic readonly root: NodeId;\n\tprotected readonly forest: Forest;\n\tprivate readonly rootNode: TreeViewNode;\n\n\t/**\n\t * A cache of node's index within their parent trait.\n\t * Used to avoid redundant linear scans of traits.\n\t * Not shared across views; initialized to empty each time a TreeView is created.\n\t */\n\tprivate traitIndicesCache?: Map<NodeId, TraitNodeIndex>;\n\n\tprotected constructor(root: NodeId, forest: Forest) {\n\t\tthis.root = root;\n\t\tthis.forest = forest;\n\t\tthis.rootNode = this.getViewNode(root);\n\t}\n\n\t/** @returns the number of nodes in this view */\n\tpublic get size(): number {\n\t\treturn this.forest.size;\n\t}\n\n\t/** @returns true iff a node with the given id exists in this view */\n\tpublic hasNode(id: NodeId): boolean {\n\t\treturn this.forest.has(id);\n\t}\n\n\t/**\n\t * @returns the index just after place (which specifies a location between items).\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic findIndexWithinTrait(place: TreeViewPlace): PlaceIndex {\n\t\tif (place.sibling === undefined) {\n\t\t\treturn this.getIndexOfSide(place.side, place.trait);\n\t\t}\n\t\treturn getIndex(place.side, this.getIndexInTrait(place.sibling));\n\t}\n\n\t/** @returns the node associated with the given id in this view. Fails if the node does not exist in this view. */\n\tpublic getViewNode(id: NodeId): TreeViewNode {\n\t\treturn this.tryGetViewNode(id) ?? fail('NodeId not found');\n\t}\n\n\t/** @returns the node associated with the given id in this view, or undefined if the node does not exist in this view */\n\tpublic tryGetViewNode(id: NodeId): TreeViewNode | undefined {\n\t\tconst forestNode = this.forest.tryGet(id);\n\t\tif (forestNode !== undefined && isParentedForestNode(forestNode)) {\n\t\t\tconst viewNode: TreeViewNode = {\n\t\t\t\tdefinition: forestNode.definition,\n\t\t\t\tidentifier: forestNode.identifier,\n\t\t\t\ttraits: forestNode.traits,\n\t\t\t\tparentage: {\n\t\t\t\t\tlabel: forestNode.traitParent,\n\t\t\t\t\tparent: forestNode.parentId,\n\t\t\t\t},\n\t\t\t};\n\t\t\tcopyPropertyIfDefined(forestNode, viewNode, 'payload');\n\t\t\treturn viewNode;\n\t\t}\n\n\t\treturn forestNode;\n\t}\n\n\t/**\n\t * @returns the label of the trait under which a node with the given id resides. Fails if the node does not exist in this view or if\n\t * it is the root node.\n\t */\n\tpublic getTraitLabel(id: NodeId): TraitLabel {\n\t\treturn this.forest.getParent(id).traitParent;\n\t}\n\n\t/**\n\t * @returns the label of the trait under which a node with the given id resides, or undefined if the node is not present in this\n\t * view or if it is the root node\n\t */\n\tpublic tryGetTraitLabel(id: NodeId): TraitLabel | undefined {\n\t\treturn this.forest.tryGetParent(id)?.traitParent;\n\t}\n\n\t/**\n\t * @returns the parent of the node with the given id. Fails if the node does not exist in this view or if it is the root node.\n\t */\n\tpublic getParentViewNode(id: NodeId): TreeViewNode {\n\t\tconst parentInfo = this.forest.getParent(id);\n\t\treturn this.getViewNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @returns the parent of the node with the given id. Returns undefined if the node does not exist in this view or if it is the root\n\t * node.\n\t */\n\tpublic tryGetParentViewNode(id: NodeId): TreeViewNode | undefined {\n\t\tconst parentInfo = this.forest.tryGetParent(id);\n\t\tif (parentInfo === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.getViewNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @returns the trait location of the node with the given id. Fails if the node does not exist in this view or of it is the root\n\t * node\n\t */\n\tpublic getTraitLocation(id: NodeId): TraitLocation {\n\t\tconst parentData = this.forest.getParent(id);\n\t\treturn {\n\t\t\tparent: parentData.parentId,\n\t\t\tlabel: parentData.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * @returns the trait location of the node with the given id, or undefined if the node does not exist in this view or if it is the root\n\t * node\n\t */\n\tpublic tryGetTraitLocation(id: NodeId): TraitLocation | undefined {\n\t\tconst parentData = this.forest.tryGetParent(id);\n\t\tif (parentData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\tparent: parentData.parentId,\n\t\t\tlabel: parentData.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * @returns the index within the trait under which the node with the given id resides. The node must exist in this view and must have a\n\t * parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic getIndexInTrait(id: NodeId): TraitNodeIndex {\n\t\tconst index = this.tryGetIndexInTrait(id);\n\t\treturn index ?? fail('ID does not exist in the forest.');\n\t}\n\n\t/**\n\t * @returns the index within the trait under which the node with the given id resides, or undefined if the node does not exist in this\n\t * view or does not have a parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic tryGetIndexInTrait(id: NodeId): TraitNodeIndex | undefined {\n\t\tconst cachedIndex = this.traitIndicesCache?.get(id);\n\t\tif (cachedIndex !== undefined) {\n\t\t\treturn cachedIndex;\n\t\t}\n\n\t\tconst parentData = this.forest.tryGetParent(id);\n\t\tif (parentData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parent = this.forest.tryGet(parentData.parentId);\n\t\tif (parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst trait = parent.traits.get(parentData.traitParent) ?? fail('inconsistent forest: trait parent not found');\n\t\tlet foundIndex: TraitNodeIndex | undefined;\n\t\tif (trait.length === 0) {\n\t\t\treturn foundIndex;\n\t\t}\n\n\t\tthis.traitIndicesCache ??= new Map();\n\t\tfor (let i = 0; i < trait.length; i++) {\n\t\t\tconst nodeInTrait = trait[i];\n\t\t\tconst index = i as TraitNodeIndex;\n\t\t\tthis.traitIndicesCache.set(nodeInTrait, index);\n\t\t\tif (nodeInTrait === id) {\n\t\t\t\tfoundIndex = index;\n\t\t\t}\n\t\t}\n\n\t\treturn foundIndex;\n\t}\n\n\t/**\n\t * @returns the trait at the given location. If no such trait exists, returns an empty trait.\n\t */\n\tpublic getTrait(traitLocation: TraitLocation): readonly NodeId[] {\n\t\treturn this.getViewNode(traitLocation.parent).traits.get(traitLocation.label) ?? [];\n\t}\n\n\t/** Asserts that the view's internal state is consistent. Useful for testing/validation. */\n\tpublic assertConsistent(): void {\n\t\tthis.forest.assertConsistent();\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<TreeViewNode> {\n\t\treturn this.iterateNodeDescendants(this.rootNode);\n\t}\n\n\t/** @returns true iff the given view is equal to this view */\n\tpublic abstract equals(view: TreeView): boolean;\n\n\t/**\n\t * @returns true iff the given view's forest of nodes is equivalent to this view's forest of nodes\n\t * @param strict - if true, the views' forests must be the same object, otherwise they must merely be equivalent\n\t */\n\tpublic hasEqualForest(view: TreeView, strict = false): boolean {\n\t\tif (this.root === view.root) {\n\t\t\t// TODO:#49100:Perf: make this faster and/or remove use by PrefetchingCheckout.\n\t\t\treturn strict ? this.forest === view.forest : this.forest.equals(view.forest);\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate *iterateNodeDescendants(node: TreeViewNode): IterableIterator<TreeViewNode> {\n\t\tyield node;\n\t\tfor (const label of [...node.traits.keys()].sort()) {\n\t\t\tconst trait = node.traits.get(label);\n\t\t\tfor (const childId of trait ?? fail('Expected trait with label')) {\n\t\t\t\tconst child = this.getViewNode(childId);\n\t\t\t\tyield* this.iterateNodeDescendants(child);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getIndexOfSide(side: Side, traitLocation: TraitLocation): PlaceIndex {\n\t\treturn side === Side.After ? (0 as PlaceIndex) : (this.getTrait(traitLocation).length as PlaceIndex);\n\t}\n\n\t/**\n\t * Calculate the difference between two `TreeView`s\n\t * @param view - the other view to compare to this one\n\t * @returns A {@link Delta} which nodes must be changed, added, and removed to get from `this` to `view`.\n\t * The views must share a root.\n\t */\n\tpublic delta(view: TreeView): Delta<NodeId> {\n\t\tassert(this.root === view.root, 'Delta can only be calculated between views that share a root');\n\t\treturn this.forest.delta(view.forest);\n\t}\n}\n\nfunction getIndex(side: Side, index: TraitNodeIndex): PlaceIndex {\n\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n\treturn (side + index) as PlaceIndex;\n}\n"]}
|
|
@@ -24,7 +24,7 @@ exports.rangeFromStableRange = rangeFromStableRange;
|
|
|
24
24
|
function placeFromStablePlace(view, stablePlace) {
|
|
25
25
|
const { side } = stablePlace;
|
|
26
26
|
if (stablePlace.referenceSibling === undefined) {
|
|
27
|
-
Common_1.assert(stablePlace.referenceTrait !== undefined);
|
|
27
|
+
(0, Common_1.assert)(stablePlace.referenceTrait !== undefined);
|
|
28
28
|
return {
|
|
29
29
|
trait: stablePlace.referenceTrait,
|
|
30
30
|
side,
|
|
@@ -48,7 +48,7 @@ function getTraitLocationOfRange(view, range) {
|
|
|
48
48
|
if (referenceTrait) {
|
|
49
49
|
return referenceTrait;
|
|
50
50
|
}
|
|
51
|
-
const sibling = (_c = (_b = range.start.referenceSibling) !== null && _b !== void 0 ? _b : range.end.referenceSibling) !== null && _c !== void 0 ? _c : Common_1.fail('malformed range does not indicate trait');
|
|
51
|
+
const sibling = (_c = (_b = range.start.referenceSibling) !== null && _b !== void 0 ? _b : range.end.referenceSibling) !== null && _c !== void 0 ? _c : (0, Common_1.fail)('malformed range does not indicate trait');
|
|
52
52
|
return view.getTraitLocation(sibling);
|
|
53
53
|
}
|
|
54
54
|
exports.getTraitLocationOfRange = getTraitLocationOfRange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeViewUtilities.js","sourceRoot":"","sources":["../src/TreeViewUtilities.ts"],"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Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StablePlace, StableRange } from './ChangeTypes';\nimport { assert, fail } from './Common';\nimport { TraitLocation, TreeView, TreeViewPlace, TreeViewRange } from './TreeView';\n\n/**\n * Express the given {@link (StableRange:interface)} as a {@link TreeViewRange}\n */\nexport function rangeFromStableRange(view: TreeView, range: StableRange): TreeViewRange {\n\tconst location = getTraitLocationOfRange(view, range);\n\t// This can be optimized for better constant factors.\n\treturn {\n\t\tstart: sideOfRange(range, SideOfRange.Start, location),\n\t\tend: sideOfRange(range, SideOfRange.End, location),\n\t};\n}\n\n/**\n * Express the given {@link (StablePlace:interface)} as a {@link TreeViewPlace}\n */\nexport function placeFromStablePlace(view: TreeView, stablePlace: StablePlace): TreeViewPlace {\n\tconst { side } = stablePlace;\n\tif (stablePlace.referenceSibling === undefined) {\n\t\tassert(stablePlace.referenceTrait !== undefined);\n\t\treturn {\n\t\t\ttrait: stablePlace.referenceTrait,\n\t\t\tside,\n\t\t};\n\t}\n\treturn {\n\t\ttrait: view.getTraitLocation(stablePlace.referenceSibling),\n\t\tside: stablePlace.side,\n\t\tsibling: stablePlace.referenceSibling,\n\t};\n}\n\n/**\n * Return the trait under which the given range resides\n * @param view - the {@link TreeView} within which to retrieve the trait location\n * @param range - must be well formed and valid\n */\nexport function getTraitLocationOfRange(view: TreeView, range: StableRange): TraitLocation {\n\tconst referenceTrait = range.start.referenceTrait ?? range.end.referenceTrait;\n\tif (referenceTrait) {\n\t\treturn referenceTrait;\n\t}\n\tconst sibling =\n\t\trange.start.referenceSibling ?? range.end.referenceSibling ?? fail('malformed range does not indicate trait');\n\treturn view.getTraitLocation(sibling);\n}\n\nfunction sideOfRange(range: StableRange, sideOfRange: SideOfRange, trait: TraitLocation): TreeViewPlace {\n\tconst siblingRelative = sideOfRange === SideOfRange.Start ? range.start : range.end;\n\treturn {\n\t\ttrait,\n\t\tside: siblingRelative.side,\n\t\tsibling: siblingRelative.referenceSibling,\n\t};\n}\n\n/**\n * Denotes either the start or end of a range\n */\nenum SideOfRange {\n\t/**\n\t * The start of the range\n\t */\n\tStart = 0,\n\t/**\n\t * The end of the range\n\t */\n\tEnd = 1,\n}\n"]}
|
package/dist/UndoRedoHandler.js
CHANGED
|
@@ -17,7 +17,7 @@ class SharedTreeUndoRedoHandler {
|
|
|
17
17
|
this.treeDeltaHandler = (eventArguments) => {
|
|
18
18
|
const { editId, local, tree } = eventArguments;
|
|
19
19
|
if (local) {
|
|
20
|
-
this.stackManager.pushToCurrentOperation(new SharedTreeRevertible(editId, Common_1.assertNotUndefined(tree, 'An edit committed event for a revertible edit should include the target SharedTree in its arguments.')));
|
|
20
|
+
this.stackManager.pushToCurrentOperation(new SharedTreeRevertible(editId, (0, Common_1.assertNotUndefined)(tree, 'An edit committed event for a revertible edit should include the target SharedTree in its arguments.')));
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UndoRedoHandler.js","sourceRoot":"","sources":["../src/UndoRedoHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAA8C;AAC9C,6CAA+C;AAgB/C;;;GAGG;AACH,MAAa,yBAAyB;IACrC,YAA6B,YAA2B;QAA3B,iBAAY,GAAZ,YAAY,CAAe;QASvC,qBAAgB,GAAG,CAAC,cAA2C,EAAE,EAAE;YACnF,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;YAE/C,IAAI,KAAK,EAAE;gBACV,IAAI,CAAC,YAAY,CAAC,sBAAsB,CACvC,IAAI,oBAAoB,CACvB,MAAM,EACN,2BAAkB,
|
|
1
|
+
{"version":3,"file":"UndoRedoHandler.js","sourceRoot":"","sources":["../src/UndoRedoHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAA8C;AAC9C,6CAA+C;AAgB/C;;;GAGG;AACH,MAAa,yBAAyB;IACrC,YAA6B,YAA2B;QAA3B,iBAAY,GAAZ,YAAY,CAAe;QASvC,qBAAgB,GAAG,CAAC,cAA2C,EAAE,EAAE;YACnF,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;YAE/C,IAAI,KAAK,EAAE;gBACV,IAAI,CAAC,YAAY,CAAC,sBAAsB,CACvC,IAAI,oBAAoB,CACvB,MAAM,EACN,IAAA,2BAAkB,EACjB,IAAI,EACJ,sGAAsG,CACtG,CACD,CACD,CAAC;aACF;QACF,CAAC,CAAC;IAvByD,CAAC;IAErD,UAAU,CAAC,IAAgB;QACjC,IAAI,CAAC,EAAE,CAAC,4BAAe,CAAC,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC;IACM,UAAU,CAAC,IAAgB;QACjC,IAAI,CAAC,GAAG,CAAC,4BAAe,CAAC,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChE,CAAC;CAiBD;AAzBD,8DAyBC;AAED;;GAEG;AACH,MAAa,oBAAoB;IAChC,YAA6B,MAAc,EAAmB,IAAgB;QAAjD,WAAM,GAAN,MAAM,CAAQ;QAAmB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAE3E,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAEM,OAAO;QACb,OAAO;IACR,CAAC;CACD;AAVD,oDAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assertNotUndefined } from './Common';\nimport { SharedTreeEvent } from './EventTypes';\nimport { EditId } from './Identifiers';\nimport { EditCommittedEventArguments, SharedTree } from './SharedTree';\n\n// TODO: We temporarily duplicate these contracts from 'framework/undo-redo' to unblock development\n// while we decide on the correct layering for undo.\n\nexport interface IRevertible {\n\trevert();\n\tdiscard();\n}\n\nexport interface IUndoConsumer {\n\tpushToCurrentOperation(revertible: IRevertible);\n}\n\n/**\n * A shared tree undo redo handler that will add revertible local tree changes to the provided\n * undo redo stack manager\n */\nexport class SharedTreeUndoRedoHandler {\n\tconstructor(private readonly stackManager: IUndoConsumer) {}\n\n\tpublic attachTree(tree: SharedTree) {\n\t\ttree.on(SharedTreeEvent.EditCommitted, this.treeDeltaHandler);\n\t}\n\tpublic detachTree(tree: SharedTree) {\n\t\ttree.off(SharedTreeEvent.EditCommitted, this.treeDeltaHandler);\n\t}\n\n\tprivate readonly treeDeltaHandler = (eventArguments: EditCommittedEventArguments) => {\n\t\tconst { editId, local, tree } = eventArguments;\n\n\t\tif (local) {\n\t\t\tthis.stackManager.pushToCurrentOperation(\n\t\t\t\tnew SharedTreeRevertible(\n\t\t\t\t\teditId,\n\t\t\t\t\tassertNotUndefined(\n\t\t\t\t\t\ttree,\n\t\t\t\t\t\t'An edit committed event for a revertible edit should include the target SharedTree in its arguments.'\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * Tracks a change on a shared tree and allows reverting it\n */\nexport class SharedTreeRevertible implements IRevertible {\n\tconstructor(private readonly editId: EditId, private readonly tree: SharedTree) {}\n\n\tpublic revert() {\n\t\tthis.tree.revert(this.editId);\n\t}\n\n\tpublic discard() {\n\t\treturn;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { StableId, UuidString } from './Identifiers';
|
|
6
|
+
/** The null (lowest/all-zeros) UUID */
|
|
7
|
+
export declare const nilUuid: UuidString;
|
|
8
|
+
/**
|
|
9
|
+
* Asserts that the given string is a UUID
|
|
10
|
+
*/
|
|
11
|
+
export declare function assertIsUuidString(uuidString: string): UuidString;
|
|
12
|
+
/**
|
|
13
|
+
* Returns true iff the given string is a valid UUID-like string of hexadecimal characters
|
|
14
|
+
* 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
|
15
|
+
*/
|
|
16
|
+
export declare function isUuidString(str: string): str is UuidString;
|
|
17
|
+
/**
|
|
18
|
+
* Generate a random stable ID
|
|
19
|
+
*/
|
|
20
|
+
export declare function generateStableId(): StableId;
|
|
21
|
+
/**
|
|
22
|
+
* Asserts that the given string is a stable ID.
|
|
23
|
+
*/
|
|
24
|
+
export declare function assertIsStableId(stableId: string): StableId;
|
|
25
|
+
/**
|
|
26
|
+
* Returns true iff the given string is a valid Version 4, variant 2 UUID
|
|
27
|
+
* 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'
|
|
28
|
+
*/
|
|
29
|
+
export declare function isStableId(str: string): str is StableId;
|
|
30
|
+
//# sourceMappingURL=UuidUtilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UuidUtilities.d.ts","sourceRoot":"","sources":["../src/UuidUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAmBrD,uCAAuC;AACvC,eAAO,MAAM,OAAO,YAA0B,CAAC;AAE/C;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAGjE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,UAAU,CAqB3D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,QAAQ,CAE3C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAG3D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,QAAQ,CAuCvD"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.isStableId = exports.assertIsStableId = exports.generateStableId = exports.isUuidString = exports.assertIsUuidString = exports.nilUuid = void 0;
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
const Common_1 = require("./Common");
|
|
10
|
+
const hexadecimalCharCodes = Array.from('09afAF').map((c) => c.charCodeAt(0));
|
|
11
|
+
function isHexadecimalCharacter(charCode) {
|
|
12
|
+
return ((charCode >= hexadecimalCharCodes[0] && charCode <= hexadecimalCharCodes[1]) ||
|
|
13
|
+
(charCode >= hexadecimalCharCodes[2] && charCode <= hexadecimalCharCodes[3]) ||
|
|
14
|
+
(charCode >= hexadecimalCharCodes[4] && charCode <= hexadecimalCharCodes[5]));
|
|
15
|
+
}
|
|
16
|
+
/** The null (lowest/all-zeros) UUID */
|
|
17
|
+
exports.nilUuid = assertIsUuidString(uuid_1.NIL);
|
|
18
|
+
/**
|
|
19
|
+
* Asserts that the given string is a UUID
|
|
20
|
+
*/
|
|
21
|
+
function assertIsUuidString(uuidString) {
|
|
22
|
+
(0, Common_1.assert)(isUuidString(uuidString), `${uuidString} is not an UuidString`);
|
|
23
|
+
return uuidString;
|
|
24
|
+
}
|
|
25
|
+
exports.assertIsUuidString = assertIsUuidString;
|
|
26
|
+
/**
|
|
27
|
+
* Returns true iff the given string is a valid UUID-like string of hexadecimal characters
|
|
28
|
+
* 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
|
29
|
+
*/
|
|
30
|
+
function isUuidString(str) {
|
|
31
|
+
for (let i = 0; i < str.length; i++) {
|
|
32
|
+
switch (i) {
|
|
33
|
+
case 8:
|
|
34
|
+
case 13:
|
|
35
|
+
case 18:
|
|
36
|
+
case 23:
|
|
37
|
+
if (str.charAt(i) !== '-') {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
if (!isHexadecimalCharacter(str.charCodeAt(i))) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
exports.isUuidString = isUuidString;
|
|
51
|
+
/**
|
|
52
|
+
* Generate a random stable ID
|
|
53
|
+
*/
|
|
54
|
+
function generateStableId() {
|
|
55
|
+
return assertIsStableId((0, uuid_1.v4)());
|
|
56
|
+
}
|
|
57
|
+
exports.generateStableId = generateStableId;
|
|
58
|
+
/**
|
|
59
|
+
* Asserts that the given string is a stable ID.
|
|
60
|
+
*/
|
|
61
|
+
function assertIsStableId(stableId) {
|
|
62
|
+
(0, Common_1.assert)(isStableId(stableId), `${stableId} is not a StableId.`);
|
|
63
|
+
return stableId;
|
|
64
|
+
}
|
|
65
|
+
exports.assertIsStableId = assertIsStableId;
|
|
66
|
+
/**
|
|
67
|
+
* Returns true iff the given string is a valid Version 4, variant 2 UUID
|
|
68
|
+
* 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'
|
|
69
|
+
*/
|
|
70
|
+
function isStableId(str) {
|
|
71
|
+
if (str.length !== 36) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
for (let i = 0; i < str.length; i++) {
|
|
75
|
+
switch (i) {
|
|
76
|
+
case 8:
|
|
77
|
+
case 13:
|
|
78
|
+
case 18:
|
|
79
|
+
case 23:
|
|
80
|
+
if (str.charAt(i) !== '-') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case 14:
|
|
85
|
+
if (str.charAt(i) !== '4') {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case 19: {
|
|
90
|
+
const char = str.charAt(i);
|
|
91
|
+
if (char !== '8' && char !== '9' && char !== 'a' && char !== 'b') {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
default:
|
|
97
|
+
if (!isHexadecimalCharacter(str.charCodeAt(i))) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
exports.isStableId = isStableId;
|
|
106
|
+
//# sourceMappingURL=UuidUtilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UuidUtilities.js","sourceRoot":"","sources":["../src/UuidUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAC/B,qCAAkC;AAGlC,MAAM,oBAAoB,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAO3E,CAAC;AAEF,SAAS,sBAAsB,CAAC,QAAgB;IAC/C,OAAO,CACN,CAAC,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC5E,CAAC;AACH,CAAC;AAED,uCAAuC;AAC1B,QAAA,OAAO,GAAG,kBAAkB,CAAC,UAAG,CAAC,CAAC;AAE/C;;GAEG;AACH,SAAgB,kBAAkB,CAAC,UAAkB;IACpD,IAAA,eAAM,EAAC,YAAY,CAAC,UAAU,CAAC,EAAE,GAAG,UAAU,uBAAuB,CAAC,CAAC;IACvE,OAA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AAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;oBAC1B,OAAO,KAAK,CAAC;iBACb;gBACD,MAAM;YAEP,KAAK,EAAE;gBACN,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;oBAC1B,OAAO,KAAK,CAAC;iBACb;gBACD,MAAM;YAEP,KAAK,EAAE,CAAC,CAAC;gBACR,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC3B,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE;oBACjE,OAAO,KAAK,CAAC;iBACb;gBACD,MAAM;aACN;YAED;gBACC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;oBAC/C,OAAO,KAAK,CAAC;iBACb;gBACD,MAAM;SACP;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAvCD,gCAuCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4, NIL } from 'uuid';\nimport { assert } from './Common';\nimport { StableId, UuidString } from './Identifiers';\n\nconst hexadecimalCharCodes = Array.from('09afAF').map((c) => c.charCodeAt(0)) as [\n\tzero: number,\n\tnine: number,\n\ta: number,\n\tf: number,\n\tA: number,\n\tF: number\n];\n\nfunction isHexadecimalCharacter(charCode: number): boolean {\n\treturn (\n\t\t(charCode >= hexadecimalCharCodes[0] && charCode <= hexadecimalCharCodes[1]) ||\n\t\t(charCode >= hexadecimalCharCodes[2] && charCode <= hexadecimalCharCodes[3]) ||\n\t\t(charCode >= hexadecimalCharCodes[4] && charCode <= hexadecimalCharCodes[5])\n\t);\n}\n\n/** The null (lowest/all-zeros) UUID */\nexport const nilUuid = assertIsUuidString(NIL);\n\n/**\n * Asserts that the given string is a UUID\n */\nexport function assertIsUuidString(uuidString: string): UuidString {\n\tassert(isUuidString(uuidString), `${uuidString} is not an UuidString`);\n\treturn uuidString;\n}\n\n/**\n * Returns true iff the given string is a valid UUID-like string of hexadecimal characters\n * 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'\n */\nexport function isUuidString(str: string): str is UuidString {\n\tfor (let i = 0; i < str.length; i++) {\n\t\tswitch (i) {\n\t\t\tcase 8:\n\t\t\tcase 13:\n\t\t\tcase 18:\n\t\t\tcase 23:\n\t\t\t\tif (str.charAt(i) !== '-') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tif (!isHexadecimalCharacter(str.charCodeAt(i))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Generate a random stable ID\n */\nexport function generateStableId(): StableId {\n\treturn assertIsStableId(v4());\n}\n\n/**\n * Asserts that the given string is a stable ID.\n */\nexport function assertIsStableId(stableId: string): StableId {\n\tassert(isStableId(stableId), `${stableId} is not a StableId.`);\n\treturn stableId;\n}\n\n/**\n * Returns true iff the given string is a valid Version 4, variant 2 UUID\n * 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'\n */\nexport function isStableId(str: string): str is StableId {\n\tif (str.length !== 36) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tswitch (i) {\n\t\t\tcase 8:\n\t\t\tcase 13:\n\t\t\tcase 18:\n\t\t\tcase 23:\n\t\t\t\tif (str.charAt(i) !== '-') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 14:\n\t\t\t\tif (str.charAt(i) !== '4') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 19: {\n\t\t\t\tconst char = str.charAt(i);\n\t\t\t\tif (char !== '8' && char !== '9' && char !== 'a' && char !== 'b') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tif (!isHexadecimalCharacter(str.charCodeAt(i))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn true;\n}\n"]}
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class AppendOnlySortedMap<K, V> {
|
|
10
10
|
protected readonly comparator: (a: K, b: K) => number;
|
|
11
|
-
protected readonly elements:
|
|
11
|
+
protected readonly elements: (K | V)[];
|
|
12
12
|
/**
|
|
13
|
-
* @param comparator a comparator for keys
|
|
13
|
+
* @param comparator - a comparator for keys
|
|
14
14
|
*/
|
|
15
15
|
constructor(comparator: (a: K, b: K) => number);
|
|
16
16
|
/**
|
|
@@ -25,6 +25,26 @@ export declare class AppendOnlySortedMap<K, V> {
|
|
|
25
25
|
* @returns the max key in the map.
|
|
26
26
|
*/
|
|
27
27
|
maxKey(): K | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* @returns the min value in the map.
|
|
30
|
+
*/
|
|
31
|
+
minValue(): V | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* @returns the min value in the map.
|
|
34
|
+
*/
|
|
35
|
+
maxValue(): V | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* @returns the min key in the map.
|
|
38
|
+
*/
|
|
39
|
+
first(): [K, V] | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* @returns the max key in the map.
|
|
42
|
+
*/
|
|
43
|
+
last(): [K, V] | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the element at the insertion index.
|
|
46
|
+
*/
|
|
47
|
+
getAtIndex(index: number): [K, V] | undefined;
|
|
28
48
|
/**
|
|
29
49
|
* @returns an iterable of the entries in the map.
|
|
30
50
|
*/
|
|
@@ -42,25 +62,24 @@ export declare class AppendOnlySortedMap<K, V> {
|
|
|
42
62
|
*/
|
|
43
63
|
entriesReversed(): IterableIterator<readonly [K, V]>;
|
|
44
64
|
/**
|
|
45
|
-
* Adds a new key/value pair to the map. `key` must be
|
|
46
|
-
* @param key the key to add.
|
|
47
|
-
* @param value the value to add.
|
|
65
|
+
* Adds a new key/value pair to the map. `key` must be \> to all keys in the map.
|
|
66
|
+
* @param key - the key to add.
|
|
67
|
+
* @param value - the value to add.
|
|
48
68
|
*/
|
|
49
69
|
append(key: K, value: V): void;
|
|
50
|
-
private readonly compareKeys;
|
|
51
70
|
/**
|
|
52
|
-
* @param key the key to lookup.
|
|
71
|
+
* @param key - the key to lookup.
|
|
53
72
|
* @returns the value associated with `key` if such an entry exists, and undefined otherwise.
|
|
54
73
|
*/
|
|
55
74
|
get(key: K): V | undefined;
|
|
56
75
|
/**
|
|
57
|
-
* @param key the key to lookup.
|
|
76
|
+
* @param key - the key to lookup.
|
|
58
77
|
* @returns the entry associated with `key` if such an entry exists, the entry associated with the next lower key if such an entry
|
|
59
78
|
* exists, and undefined otherwise.
|
|
60
79
|
*/
|
|
61
80
|
getPairOrNextLower(key: K): readonly [K, V] | undefined;
|
|
62
81
|
/**
|
|
63
|
-
* @param key the key to lookup.
|
|
82
|
+
* @param key - the key to lookup.
|
|
64
83
|
* @returns the entry associated with `key` if such an entry exists, the entry associated with the next higher key if such an entry
|
|
65
84
|
* exists, and undefined otherwise.
|
|
66
85
|
*/
|
|
@@ -69,30 +88,31 @@ export declare class AppendOnlySortedMap<K, V> {
|
|
|
69
88
|
* Compares two `AppendOnlySortedMap`s.
|
|
70
89
|
*/
|
|
71
90
|
equals(other: AppendOnlySortedMap<K, V>, compareValues: (a: V, b: V) => boolean): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Test-only expensive assertions to check the internal validity of the data structure.
|
|
93
|
+
*/
|
|
94
|
+
assertValid(): void;
|
|
72
95
|
/**
|
|
73
96
|
* Queries a range of entries.
|
|
74
|
-
* @param from the key to start the range query at, inclusive.
|
|
75
|
-
* @param to the key to end the range query at, inclusive.
|
|
97
|
+
* @param from - the key to start the range query at, inclusive.
|
|
98
|
+
* @param to - the key to end the range query at, inclusive.
|
|
76
99
|
* @returns the range of entries.
|
|
77
100
|
*/
|
|
78
101
|
getRange(from: K, to: K): IterableIterator<readonly [K, V]>;
|
|
79
|
-
protected getPairOrNextLowerBy<T>(search: T, comparator: (search: T,
|
|
80
|
-
private
|
|
81
|
-
protected getPairOrNextHigherBy<T>(search: T, comparator: (search: T,
|
|
82
|
-
private
|
|
102
|
+
protected getPairOrNextLowerBy<T>(search: T, comparator: (search: T, key: K, value: V) => number): readonly [K, V] | undefined;
|
|
103
|
+
private getKeyIndexOfOrNextLower;
|
|
104
|
+
protected getPairOrNextHigherBy<T>(search: T, comparator: (search: T, key: K, value: V) => number): readonly [K, V] | undefined;
|
|
105
|
+
private getKeyIndexOfOrNextHigher;
|
|
83
106
|
/**
|
|
84
107
|
* The value xor'd with the result index when a search fails.
|
|
85
108
|
*/
|
|
86
109
|
static readonly failureXor = -1;
|
|
87
110
|
/**
|
|
88
111
|
* Performs a binary search on the sorted array.
|
|
89
|
-
* @
|
|
90
|
-
*
|
|
91
|
-
* @param comparator
|
|
92
|
-
* @returns the index of `search`, or (if not present) the index it would have been inserted into xor'd with `failureXor`. Note that
|
|
93
|
-
* negating is not an adequate solution as that could result in -0.
|
|
112
|
+
* @returns the index of the key for `search`, or (if not present) the index it would have been inserted into xor'd
|
|
113
|
+
* with `failureXor`. Note that negating is not an adequate solution as that could result in -0.
|
|
94
114
|
*/
|
|
95
|
-
static
|
|
115
|
+
static keyIndexOf<T, K, V>(elements: readonly (K | V)[], search: T, comparator: (search: T, key: K, value: V) => number): number;
|
|
96
116
|
}
|
|
97
117
|
/**
|
|
98
118
|
* A map in which entries are always added in both key-sorted and value-sorted order.
|
|
@@ -101,27 +121,31 @@ export declare class AppendOnlySortedMap<K, V> {
|
|
|
101
121
|
export declare class AppendOnlyDoublySortedMap<K, V, S> extends AppendOnlySortedMap<K, V> {
|
|
102
122
|
private readonly extractSearchValue;
|
|
103
123
|
private readonly valueComparator;
|
|
104
|
-
constructor(keyComparator: (a: K, b: K) => number, extractSearchValue: (value: V) => S, valueComparator: (search: S, value:
|
|
124
|
+
constructor(keyComparator: (a: K, b: K) => number, extractSearchValue: (value: V) => S, valueComparator: (search: S, value: S) => number);
|
|
105
125
|
append(key: K, value: V): void;
|
|
106
126
|
private readonly compareValues;
|
|
107
127
|
/**
|
|
108
|
-
* @param value the value to lookup.
|
|
128
|
+
* @param value - the value to lookup.
|
|
109
129
|
* @returns the key associated with `value` if such an entry exists, and undefined otherwise.
|
|
110
130
|
*/
|
|
111
131
|
getByValue(value: S): K | undefined;
|
|
112
132
|
/**
|
|
113
|
-
* @param searchValue the search value to lookup.
|
|
114
|
-
* @returns the entry who's value, when run through the extractor provided to the constructor, matches
|
|
115
|
-
* exists, this method returns the next lower entry as determined by the value
|
|
116
|
-
* exists, this method returns undefined.
|
|
133
|
+
* @param searchValue - the search value to lookup.
|
|
134
|
+
* @returns the entry who's value, when run through the extractor provided to the constructor, matches
|
|
135
|
+
* `searchValue`. If no such entry exists, this method returns the next lower entry as determined by the value
|
|
136
|
+
* comparator provided to the constructor. If no such entry exists, this method returns undefined.
|
|
117
137
|
*/
|
|
118
138
|
getPairOrNextLowerByValue(searchValue: S): readonly [K, V] | undefined;
|
|
119
139
|
/**
|
|
120
|
-
* @param searchValue the search value to lookup.
|
|
140
|
+
* @param searchValue - the search value to lookup.
|
|
121
141
|
* @returns the entry who's value, when run through the extractor provided to the constructor, matches `searchValue`. If no such entry
|
|
122
142
|
* exists, this method returns the next higher entry as determined by the value comparator provided to the constructor. If no such entry
|
|
123
143
|
* exists, this method returns undefined.
|
|
124
144
|
*/
|
|
125
145
|
getPairOrNextHigherByValue(searchValue: S): readonly [K, V] | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Test-only expensive assertions to check the internal validity of the data structure.
|
|
148
|
+
*/
|
|
149
|
+
assertValid(): void;
|
|
126
150
|
}
|
|
127
151
|
//# sourceMappingURL=AppendOnlySortedMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppendOnlySortedMap.d.ts","sourceRoot":"","sources":["../../src/id-compressor/AppendOnlySortedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;GAGG;AACH,qBAAa,mBAAmB,CAAC,CAAC,EAAE,CAAC;IAMjB,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM;IALxE,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"AppendOnlySortedMap.d.ts","sourceRoot":"","sources":["../../src/id-compressor/AppendOnlySortedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;GAGG;AACH,qBAAa,mBAAmB,CAAC,CAAC,EAAE,CAAC;IAMjB,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM;IALxE,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAM;IAE5C;;OAEG;gBACmC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM;IAExE;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACI,MAAM,IAAI,CAAC,GAAG,SAAS;IAI9B;;OAEG;IACI,MAAM,IAAI,CAAC,GAAG,SAAS;IAI9B;;OAEG;IACI,QAAQ,IAAI,CAAC,GAAG,SAAS;IAIhC;;OAEG;IACI,QAAQ,IAAI,CAAC,GAAG,SAAS;IAIhC;;OAEG;IACI,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS;IASlC;;O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