@fluid-experimental/tree 0.59.3003 → 0.59.4000

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.
Files changed (54) hide show
  1. package/dist/Forest.js +1 -1
  2. package/dist/Forest.js.map +1 -1
  3. package/dist/id-compressor/IdCompressor.d.ts +19 -45
  4. package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
  5. package/dist/id-compressor/IdCompressor.js +151 -151
  6. package/dist/id-compressor/IdCompressor.js.map +1 -1
  7. package/dist/id-compressor/SessionIdNormalizer.d.ts +1 -16
  8. package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
  9. package/dist/id-compressor/SessionIdNormalizer.js +23 -21
  10. package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
  11. package/dist/id-compressor/persisted-types/0.0.1.d.ts +23 -4
  12. package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  13. package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
  14. package/lib/Forest.js +1 -1
  15. package/lib/Forest.js.map +1 -1
  16. package/lib/id-compressor/IdCompressor.d.ts +19 -45
  17. package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
  18. package/lib/id-compressor/IdCompressor.js +152 -152
  19. package/lib/id-compressor/IdCompressor.js.map +1 -1
  20. package/lib/id-compressor/SessionIdNormalizer.d.ts +1 -16
  21. package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
  22. package/lib/id-compressor/SessionIdNormalizer.js +23 -21
  23. package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
  24. package/lib/id-compressor/persisted-types/0.0.1.d.ts +23 -4
  25. package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  26. package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
  27. package/lib/test/IdCompressor.perf.tests.js +47 -67
  28. package/lib/test/IdCompressor.perf.tests.js.map +1 -1
  29. package/lib/test/IdCompressor.tests.js +196 -101
  30. package/lib/test/IdCompressor.tests.js.map +1 -1
  31. package/lib/test/Summary.tests.d.ts +0 -1
  32. package/lib/test/Summary.tests.d.ts.map +1 -1
  33. package/lib/test/Summary.tests.js +0 -3
  34. package/lib/test/Summary.tests.js.map +1 -1
  35. package/lib/test/Virtualization.tests.js +0 -4
  36. package/lib/test/Virtualization.tests.js.map +1 -1
  37. package/lib/test/utilities/IdCompressorTestUtilities.d.ts +14 -7
  38. package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
  39. package/lib/test/utilities/IdCompressorTestUtilities.js +40 -20
  40. package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
  41. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  42. package/lib/test/utilities/SharedTreeTests.js +0 -1
  43. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  44. package/lib/test/utilities/SummaryLoadPerfTests.js +1 -1
  45. package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
  46. package/lib/test/utilities/TestCommon.d.ts +4 -0
  47. package/lib/test/utilities/TestCommon.d.ts.map +1 -1
  48. package/lib/test/utilities/TestCommon.js +6 -0
  49. package/lib/test/utilities/TestCommon.js.map +1 -1
  50. package/package.json +24 -19
  51. package/src/Forest.ts +1 -1
  52. package/src/id-compressor/IdCompressor.ts +171 -198
  53. package/src/id-compressor/SessionIdNormalizer.ts +29 -41
  54. package/src/id-compressor/persisted-types/0.0.1.ts +25 -4
package/dist/Forest.js CHANGED
@@ -298,7 +298,7 @@ class Forest {
298
298
  const parent = this.get(node.parentId);
299
299
  const trait = parent.traits.get(node.traitParent);
300
300
  (0, Common_1.assert)(trait !== undefined);
301
- (0, Common_1.assert)(trait.indexOf(node.identifier) >= 0, 'node is parented incorrectly');
301
+ (0, Common_1.assert)(trait.includes(node.identifier), 'node is parented incorrectly');
302
302
  }
303
303
  for (const trait of node.traits.values()) {
304
304
  (0, Common_1.assert)(trait.length > 0, 'trait is present but empty');
@@ -1 +1 @@
1
- {"version":3,"file":"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;IAED,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU,EAAE;QAC1C,OAAO,KAAK,CAAC;KACb;IAED,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU,EAAE;QAC1C,OAAO,KAAK,CAAC;KACb;IAED,IAAI,CAAC,IAAA,kCAAe,EAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;QACnD,OAAO,KAAK,CAAC;KACb;IAED,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;QAC5C,OAAO,KAAK,CAAC;KACb;IAED,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE;QAClC,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,MAAM,CAAC;QAC5C,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,aAAa,EAAE;YACnB,OAAO,KAAK,CAAC;SACb;QAED,IAAI,aAAa,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,EAAE;YAClD,OAAO,KAAK,CAAC;SACb;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAI,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,EAAE;gBAC1C,OAAO,KAAK,CAAC;aACb;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAxCD,gDAwCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport BTree from 'sorted-btree';\nimport { fail, assert, copyPropertyIfDefined, compareBtrees, compareFiniteNumbers } from './Common';\nimport { NodeId, TraitLabel } from './Identifiers';\nimport { comparePayloads } from './PayloadUtilities';\nimport { NodeData, Payload } from './persisted-types';\n\n/**\n * A node that can be contained within a Forest\n *\n * @public\n */\nexport interface ForestNode extends NodeData<NodeId> {\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\n}\n\n/**\n * A node within a Forest that has a parent (and is therefore not the root node)\n *\n * @public\n */\nexport interface ParentedForestNode extends ForestNode, ParentData {}\n\n/**\n * Check whether or not the given node in a forest is parented\n *\n * @public\n */\nexport function isParentedForestNode(node: ForestNode): node is ParentedForestNode {\n\tconst parentedNode = node as ForestNode & Partial<ParentedForestNode>;\n\tconst hasParent = parentedNode.parentId !== undefined;\n\tconst hasTraitParent = parentedNode.traitParent !== undefined;\n\tassert(hasParent === hasTraitParent, 'node must have either both parent and traitParent set or neither');\n\treturn hasParent;\n}\n\n/**\n * Information about a ForestNode's parent\n *\n * @public\n */\nexport interface ParentData {\n\treadonly parentId: NodeId;\n\treadonly traitParent: TraitLabel;\n}\n\n/**\n * Differences from one forest to another.\n */\nexport interface Delta<NodeId> {\n\t/**\n\t * Nodes whose content changed.\n\t */\n\treadonly changed: readonly NodeId[];\n\t/**\n\t * Nodes that were added.\n\t */\n\treadonly added: readonly NodeId[];\n\t/**\n\t * Nodes that were removed.\n\t */\n\treadonly removed: readonly NodeId[];\n}\n\ninterface ForestState {\n\tnodes: BTree<NodeId, ForestNode>;\n\texpensiveValidation: boolean;\n}\n\n/**\n * An immutable forest of ForestNode.\n * Enforces single parenting, and allows querying the parent.\n *\n * @public\n */\nexport class Forest {\n\t/**\n\t * Contains the nodes in the forest.\n\t * Used as an immutable data-structure: must not be modified.\n\t */\n\tprivate readonly nodes: BTree<NodeId, ForestNode>;\n\n\t/**\n\t * If true, consistency checks will be applied after forest operations.\n\t */\n\tprivate readonly expensiveValidation: boolean;\n\n\t/**\n\t * Caller must ensure provided BTrees are not modified.\n\t * Will not modify the BTrees.\n\t */\n\tprivate constructor(data: ForestState);\n\n\t/**\n\t * Construct a new forest without reusing nodes from a previous one.\n\t */\n\tprivate constructor(expensiveValidation: boolean);\n\n\tprivate constructor(data?: ForestState | boolean) {\n\t\tif (typeof data === 'object') {\n\t\t\tthis.nodes = data.nodes;\n\t\t\tthis.expensiveValidation = data.expensiveValidation;\n\t\t} else {\n\t\t\tthis.nodes = new BTree<NodeId, ForestNode>(undefined, compareFiniteNumbers);\n\t\t\tthis.expensiveValidation = data ?? false;\n\t\t}\n\t\tif (this.expensiveValidation) {\n\t\t\tthis.assertConsistent();\n\t\t}\n\t}\n\n\t/**\n\t * Creates a new Forest.\n\t */\n\tpublic static create(expensiveValidation = false): Forest {\n\t\treturn new Forest(expensiveValidation);\n\t}\n\n\t/**\n\t * Returns the number of nodes in the forest.\n\t */\n\tpublic get size(): number {\n\t\treturn this.nodes.size;\n\t}\n\n\t/**\n\t * Adds the supplied nodes to the forest. The nodes' IDs must be unique in the forest.\n\t * @param nodes - the sequence of nodes to add to the forest. If any of them have children which exist in the forest already, those\n\t * children will be parented. Any trait arrays present in a node must be non-empty. The nodes may be provided in any order.\n\t */\n\tpublic add(nodes: Iterable<ForestNode>): Forest {\n\t\tconst newNodes = [...nodes];\n\t\tconst mutableNodes = this.nodes.clone();\n\n\t\t// This method iterates through the supplied nodes in two passes, first looking only at children and second actually adding the\n\t\t// nodes. This allows nodes to be passed in any order, e.g. a parent followed by a child or a child followed by a parent.\n\n\t\tconst childToParent = new Map<NodeId, ParentData>(); // Temporarily records the parentage of children that don't exist yet\n\n\t\t// First, inspect the children of each node. If the child is already in the forest, update its parentage. If it is not in the\n\t\t// forest, it may be about to be added in the second loop below so record its parentage temporarily for when that happens.\n\t\tfor (const node of newNodes) {\n\t\t\tconst { identifier } = node;\n\t\t\tfor (const [traitLabel, trait] of node.traits) {\n\t\t\t\tassert(trait.length > 0, 'any trait arrays present in a node must be non-empty');\n\t\t\t\tfor (const childId of trait) {\n\t\t\t\t\tconst child = mutableNodes.get(childId);\n\t\t\t\t\tif (child !== undefined) {\n\t\t\t\t\t\t// A child already exists in the forest, and its parent is now being added\n\t\t\t\t\t\tassert(!isParentedForestNode(child), 'can not give a child multiple parents');\n\t\t\t\t\t\tconst parentedChild = {\n\t\t\t\t\t\t\tdefinition: child.definition,\n\t\t\t\t\t\t\tidentifier: child.identifier,\n\t\t\t\t\t\t\ttraits: child.traits,\n\t\t\t\t\t\t\tparentId: identifier,\n\t\t\t\t\t\t\ttraitParent: traitLabel,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcopyPropertyIfDefined(child, parentedChild, 'payload');\n\t\t\t\t\t\t// Overwrite the existing child with its parented version\n\t\t\t\t\t\tmutableNodes.set(childId, parentedChild);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// The child hasn't been added yet, so record its parentage to use when it is added below\n\t\t\t\t\t\tchildToParent.set(childId, { parentId: identifier, traitParent: traitLabel });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Now add each node to the forest and apply any parentage information that was recorded above\n\t\tfor (const node of newNodes) {\n\t\t\tconst parentData = childToParent.get(node.identifier);\n\t\t\tassert(!mutableNodes.has(node.identifier), 'can not add node with already existing id');\n\t\t\tif (parentData !== undefined) {\n\t\t\t\t// This is a child whom we haven't added yet, but whose parent we already added above. Supply the recorded parentage info.\n\t\t\t\tconst child = {\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\tidentifier: node.identifier,\n\t\t\t\t\ttraits: node.traits,\n\t\t\t\t\t...parentData,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, child, 'payload');\n\t\t\t\tmutableNodes.set(node.identifier, child);\n\t\t\t} else {\n\t\t\t\t// This is a node that has no parent. Add it with no parentage information.\n\t\t\t\tmutableNodes.set(node.identifier, node);\n\t\t\t}\n\t\t}\n\n\t\treturn new Forest({\n\t\t\tnodes: mutableNodes,\n\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t});\n\t}\n\n\t/**\n\t * Parents a set of nodes already in the forest at a specified location within a trait.\n\t * @param parentId - the id of the parent under which to insert the new nodes\n\t * @param label - the label of the trait under which to insert the new nodes\n\t * @param index - the index in the trait after which to insert the new nodes\n\t * @param childIds - the ids of the nodes to insert\n\t */\n\tpublic attachRangeOfChildren(\n\t\tparentId: NodeId,\n\t\tlabel: TraitLabel,\n\t\tindex: number,\n\t\tchildIds: readonly NodeId[]\n\t): Forest {\n\t\tassert(index >= 0, 'invalid attach index');\n\t\tconst parentNode = this.nodes.get(parentId);\n\t\tassert(parentNode, 'can not insert children under node that does not exist');\n\t\tconst mutableNodes = this.nodes.clone();\n\t\tconst traits = new Map(parentNode.traits);\n\t\tconst trait = traits.get(label) ?? [];\n\t\tassert(index <= trait.length, 'invalid attach index');\n\n\t\t// If there is nothing to insert, return early.\n\t\t// This is good for performance, but also avoids an edge case where an empty trait could be created (which is an error).\n\t\tif (childIds.length === 0) {\n\t\t\treturn this;\n\t\t}\n\t\tconst newChildren = [...trait.slice(0, index), ...childIds, ...trait.slice(index)];\n\t\ttraits.set(label, newChildren);\n\t\tmutableNodes.set(parentId, { ...parentNode, traits });\n\n\t\tfor (const childId of childIds) {\n\t\t\tmutableNodes.editRange(childId, childId, true, (_, n) => {\n\t\t\t\tassert(!isParentedForestNode(n), 'can not attach node that already has a parent');\n\t\t\t\tconst breakVal: { value: ParentedForestNode } = {\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\t...n,\n\t\t\t\t\t\tparentId,\n\t\t\t\t\t\ttraitParent: label,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn breakVal;\n\t\t\t});\n\t\t}\n\n\t\treturn new Forest({\n\t\t\tnodes: mutableNodes,\n\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t});\n\t}\n\n\t/**\n\t * Detaches a range of nodes from their parent. The detached nodes remain in the `Forest`.\n\t * @param parentId - the id of the parent from which to detach the nodes\n\t * @param label - the label of the trait from which to detach the nodes\n\t * @param startIndex - the index of the first node in the range to detach\n\t * @param endIndex - the index after the last node in the range to detach\n\t * @returns a new `Forest` with the nodes detached, and a list of the ids of the nodes that were detached\n\t */\n\tpublic detachRangeOfChildren(\n\t\tparentId: NodeId,\n\t\tlabel: TraitLabel,\n\t\tstartIndex: number,\n\t\tendIndex: number\n\t): { forest: Forest; detached: readonly NodeId[] } {\n\t\tassert(startIndex >= 0 && endIndex >= startIndex, 'invalid detach index range');\n\t\tconst parentNode = this.nodes.get(parentId);\n\t\tassert(parentNode, 'can not detach children under node that does not exist');\n\t\tif (startIndex === endIndex) {\n\t\t\treturn { forest: this, detached: [] };\n\t\t}\n\n\t\tconst mutableNodes = this.nodes.clone();\n\t\tconst traits = new Map(parentNode.traits);\n\t\tconst trait = traits.get(label) ?? [];\n\t\tassert(endIndex <= trait.length, 'invalid detach index range');\n\t\tconst detached: NodeId[] = trait.slice(startIndex, endIndex);\n\t\tconst newChildren = [...trait.slice(0, startIndex), ...trait.slice(endIndex)];\n\t\tconst deleteTrait = newChildren.length === 0;\n\t\tif (deleteTrait) {\n\t\t\ttraits.delete(label);\n\t\t} else {\n\t\t\ttraits.set(label, newChildren);\n\t\t}\n\n\t\tmutableNodes.set(parentId, { ...parentNode, traits });\n\t\tfor (const childId of detached) {\n\t\t\tmutableNodes.editRange(childId, childId, true, (_, n) => {\n\t\t\t\tconst breakVal: { value: ForestNode } = {\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tdefinition: n.definition,\n\t\t\t\t\t\tidentifier: n.identifier,\n\t\t\t\t\t\ttraits: n.traits,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(n, breakVal.value, 'payload');\n\t\t\t\treturn breakVal;\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tforest: new Forest({\n\t\t\t\tnodes: mutableNodes,\n\t\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t\t}),\n\t\t\tdetached,\n\t\t};\n\t}\n\n\t/**\n\t * Replaces a node's value. The node must exist in this `Forest`.\n\t * @param nodeId - the id of the node\n\t * @param value - the new value\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic setValue(nodeId: NodeId, value: Payload | null): Forest {\n\t\tconst node = this.nodes.get(nodeId);\n\t\tassert(node, 'can not replace payload for node that does not exist');\n\t\tconst mutableNodes = this.nodes.clone();\n\t\tconst newNode = { ...node };\n\t\tif (value !== null) {\n\t\t\tnewNode.payload = value;\n\t\t} else {\n\t\t\tdelete newNode.payload;\n\t\t}\n\t\tmutableNodes.set(nodeId, newNode);\n\t\treturn new Forest({\n\t\t\tnodes: mutableNodes,\n\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t});\n\t}\n\n\t/**\n\t * @returns true if the node associated with `id` exists in this forest, otherwise false\n\t */\n\tpublic has(id: NodeId): boolean {\n\t\treturn this.nodes.has(id);\n\t}\n\n\t/**\n\t * @returns the node associated with `id`. Should not be used if there is no node with the provided id.\n\t */\n\tpublic get(id: NodeId): ForestNode {\n\t\treturn this.nodes.get(id) ?? fail('NodeId not found');\n\t}\n\n\t/**\n\t * @returns the node associated with `id`, or undefined if there is none\n\t */\n\tpublic tryGet(id: NodeId): ForestNode | undefined {\n\t\treturn this.nodes.get(id);\n\t}\n\n\t/**\n\t * Deletes every node in ids (each of which must be unparented)\n\t * @param ids - The IDs of the nodes to delete.\n\t * @param deleteChildren - If true, recursively deletes descendants. Otherwise, leaves children unparented.\n\t */\n\tpublic delete(ids: Iterable<NodeId>, deleteChildren: boolean): Forest {\n\t\tconst mutableNodes = this.nodes.clone();\n\t\tfor (const id of ids) {\n\t\t\tthis.deleteRecursive(mutableNodes, id, deleteChildren);\n\t\t}\n\n\t\treturn new Forest({\n\t\t\tnodes: mutableNodes,\n\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t});\n\t}\n\n\tprivate deleteRecursive(mutableNodes: BTree<NodeId, ForestNode>, id: NodeId, deleteChildren: boolean): void {\n\t\tconst node = mutableNodes.get(id) ?? fail('node to delete must exist');\n\t\tassert(!isParentedForestNode(node), 'deleted nodes must be unparented');\n\t\tmutableNodes.delete(id);\n\t\tfor (const trait of node.traits.values()) {\n\t\t\tfor (const childId of trait) {\n\t\t\t\tmutableNodes.editRange(childId, childId, true, (_, n) => {\n\t\t\t\t\tconst breakVal: { value: ForestNode } = {\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tdefinition: n.definition,\n\t\t\t\t\t\t\tidentifier: n.identifier,\n\t\t\t\t\t\t\ttraits: n.traits,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tcopyPropertyIfDefined(n, breakVal.value, 'payload');\n\t\t\t\t\treturn breakVal;\n\t\t\t\t});\n\n\t\t\t\tif (deleteChildren) {\n\t\t\t\t\tthis.deleteRecursive(mutableNodes, childId, deleteChildren);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks that the metadata is correct, and the items form a forest.\n\t * This is an expensive O(map size) operation.\n\t */\n\tpublic assertConsistent(): void {\n\t\tconst checkedChildren = new Set<NodeId>([]);\n\t\tfor (const [nodeId, node] of this.nodes.entries(undefined, [])) {\n\t\t\tif (isParentedForestNode(node)) {\n\t\t\t\tconst parent = this.get(node.parentId);\n\t\t\t\tconst trait = parent.traits.get(node.traitParent);\n\t\t\t\tassert(trait !== undefined);\n\t\t\t\tassert(trait.indexOf(node.identifier) >= 0, 'node is parented incorrectly');\n\t\t\t}\n\n\t\t\tfor (const trait of node.traits.values()) {\n\t\t\t\tassert(trait.length > 0, 'trait is present but empty');\n\t\t\t\tfor (const childId of trait) {\n\t\t\t\t\tconst child = this.nodes.get(childId);\n\t\t\t\t\tassert(child, 'child in trait is not in forest');\n\t\t\t\t\tassert(isParentedForestNode(child), 'child is not parented');\n\t\t\t\t\tassert(child.parentId === node.identifier, 'child parent pointer is incorrect');\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!checkedChildren.has(childId),\n\t\t\t\t\t\t'the item tree tree must not contain cycles or multi-parented nodes'\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t(child.parentId ?? fail('each node must have associated metadata')) === nodeId,\n\t\t\t\t\t\t'cached parent is incorrect'\n\t\t\t\t\t);\n\t\t\t\t\tcheckedChildren.add(childId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @returns the parent of `id`. Should not be used if there is no node with id or if id refers to the root node.\n\t */\n\tpublic getParent(id: NodeId): ParentData {\n\t\tconst child = this.nodes.get(id);\n\t\tif (child === undefined) {\n\t\t\tfail('NodeId not found');\n\t\t}\n\n\t\tassert(isParentedForestNode(child), 'Node is not parented');\n\t\treturn { parentId: child.parentId, traitParent: child.traitParent };\n\t}\n\n\t/**\n\t * @returns undefined iff root, otherwise the parent of `id`.\n\t */\n\tpublic tryGetParent(id: NodeId): ParentData | undefined {\n\t\tconst child = this.nodes.get(id);\n\t\tif (child === undefined || !isParentedForestNode(child)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tparentId: child.parentId,\n\t\t\ttraitParent: child.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * Compares two forests for equality.\n\t * @param forest - the other forest to compare to this one\n\t * @param comparator - a function which returns true if two objects of type ForestNode are equivalent, false otherwise\n\t * @returns true iff the forests are equal.\n\t */\n\tpublic equals(forest: Forest): boolean {\n\t\tif (this === forest || this.nodes === forest.nodes) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (forest.size !== this.size) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn compareBtrees(this.nodes, forest.nodes, compareForestNodes);\n\t}\n\n\t/**\n\t * Calculate the difference between two forests.\n\t * @param forest - the other forest to compare to this one\n\t * @param comparator - a function which returns true if two objects of type ForestNode are equivalent, false otherwise\n\t * @returns A {@link Delta} listing which nodes must be changed, added, and removed to get from `this` to `forest`.\n\t */\n\tpublic delta(forest: Forest): Delta<NodeId> {\n\t\tconst changed: NodeId[] = [];\n\t\tconst removed: NodeId[] = [];\n\t\tconst added: NodeId[] = [];\n\t\tthis.nodes.diffAgainst(\n\t\t\tforest.nodes,\n\t\t\t(id) => {\n\t\t\t\tremoved.push(id);\n\t\t\t},\n\t\t\t(id) => {\n\t\t\t\tadded.push(id);\n\t\t\t},\n\t\t\t(id, nodeThis, nodeOther) => {\n\t\t\t\tif (!compareForestNodes(nodeThis, nodeOther)) {\n\t\t\t\t\tchanged.push(id);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\treturn {\n\t\t\tchanged,\n\t\t\tadded,\n\t\t\tremoved,\n\t\t};\n\t}\n}\n\n/**\n * @returns true iff two `ForestNodes` are equivalent.\n * May return false for nodes they contain equivalent payloads encoded differently.\n */\nexport function compareForestNodes(nodeA: ForestNode, nodeB: ForestNode): boolean {\n\tif (nodeA === nodeB) {\n\t\treturn true;\n\t}\n\n\tif (nodeA.identifier !== nodeB.identifier) {\n\t\treturn false;\n\t}\n\n\tif (nodeA.definition !== nodeB.definition) {\n\t\treturn false;\n\t}\n\n\tif (!comparePayloads(nodeA.payload, nodeB.payload)) {\n\t\treturn false;\n\t}\n\n\tif (nodeA.traits.size !== nodeB.traits.size) {\n\t\treturn false;\n\t}\n\n\tfor (const traitA of nodeA.traits) {\n\t\tconst [traitLabelA, nodeSequenceA] = traitA;\n\t\tconst nodeSequenceB = nodeB.traits.get(traitLabelA);\n\t\tif (!nodeSequenceB) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (nodeSequenceA.length !== nodeSequenceB.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (let i = 0; i < nodeSequenceA.length; i++) {\n\t\t\tif (nodeSequenceA[i] !== nodeSequenceB[i]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n"]}
1
+ {"version":3,"file":"Forest.js","sourceRoot":"","sources":["../src/Forest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,gEAAiC;AACjC,qCAAoG;AAEpG,yDAAqD;AAmBrD;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,IAAgB;IACpD,MAAM,YAAY,GAAG,IAAgD,CAAC;IACtE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AK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;QACnD,OAAO,KAAK,CAAC;KACb;IAED,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;QAC5C,OAAO,KAAK,CAAC;KACb;IAED,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE;QAClC,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,MAAM,CAAC;QAC5C,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,aAAa,EAAE;YACnB,OAAO,KAAK,CAAC;SACb;QAED,IAAI,aAAa,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,EAAE;YAClD,OAAO,KAAK,CAAC;SACb;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAI,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,EAAE;gBAC1C,OAAO,KAAK,CAAC;aACb;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAxCD,gDAwCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport BTree from 'sorted-btree';\nimport { fail, assert, copyPropertyIfDefined, compareBtrees, compareFiniteNumbers } from './Common';\nimport { NodeId, TraitLabel } from './Identifiers';\nimport { comparePayloads } from './PayloadUtilities';\nimport { NodeData, Payload } from './persisted-types';\n\n/**\n * A node that can be contained within a Forest\n *\n * @public\n */\nexport interface ForestNode extends NodeData<NodeId> {\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\n}\n\n/**\n * A node within a Forest that has a parent (and is therefore not the root node)\n *\n * @public\n */\nexport interface ParentedForestNode extends ForestNode, ParentData {}\n\n/**\n * Check whether or not the given node in a forest is parented\n *\n * @public\n */\nexport function isParentedForestNode(node: ForestNode): node is ParentedForestNode {\n\tconst parentedNode = node as ForestNode & Partial<ParentedForestNode>;\n\tconst hasParent = parentedNode.parentId !== undefined;\n\tconst hasTraitParent = parentedNode.traitParent !== undefined;\n\tassert(hasParent === hasTraitParent, 'node must have either both parent and traitParent set or neither');\n\treturn hasParent;\n}\n\n/**\n * Information about a ForestNode's parent\n *\n * @public\n */\nexport interface ParentData {\n\treadonly parentId: NodeId;\n\treadonly traitParent: TraitLabel;\n}\n\n/**\n * Differences from one forest to another.\n */\nexport interface Delta<NodeId> {\n\t/**\n\t * Nodes whose content changed.\n\t */\n\treadonly changed: readonly NodeId[];\n\t/**\n\t * Nodes that were added.\n\t */\n\treadonly added: readonly NodeId[];\n\t/**\n\t * Nodes that were removed.\n\t */\n\treadonly removed: readonly NodeId[];\n}\n\ninterface ForestState {\n\tnodes: BTree<NodeId, ForestNode>;\n\texpensiveValidation: boolean;\n}\n\n/**\n * An immutable forest of ForestNode.\n * Enforces single parenting, and allows querying the parent.\n *\n * @public\n */\nexport class Forest {\n\t/**\n\t * Contains the nodes in the forest.\n\t * Used as an immutable data-structure: must not be modified.\n\t */\n\tprivate readonly nodes: BTree<NodeId, ForestNode>;\n\n\t/**\n\t * If true, consistency checks will be applied after forest operations.\n\t */\n\tprivate readonly expensiveValidation: boolean;\n\n\t/**\n\t * Caller must ensure provided BTrees are not modified.\n\t * Will not modify the BTrees.\n\t */\n\tprivate constructor(data: ForestState);\n\n\t/**\n\t * Construct a new forest without reusing nodes from a previous one.\n\t */\n\tprivate constructor(expensiveValidation: boolean);\n\n\tprivate constructor(data?: ForestState | boolean) {\n\t\tif (typeof data === 'object') {\n\t\t\tthis.nodes = data.nodes;\n\t\t\tthis.expensiveValidation = data.expensiveValidation;\n\t\t} else {\n\t\t\tthis.nodes = new BTree<NodeId, ForestNode>(undefined, compareFiniteNumbers);\n\t\t\tthis.expensiveValidation = data ?? false;\n\t\t}\n\t\tif (this.expensiveValidation) {\n\t\t\tthis.assertConsistent();\n\t\t}\n\t}\n\n\t/**\n\t * Creates a new Forest.\n\t */\n\tpublic static create(expensiveValidation = false): Forest {\n\t\treturn new Forest(expensiveValidation);\n\t}\n\n\t/**\n\t * Returns the number of nodes in the forest.\n\t */\n\tpublic get size(): number {\n\t\treturn this.nodes.size;\n\t}\n\n\t/**\n\t * Adds the supplied nodes to the forest. The nodes' IDs must be unique in the forest.\n\t * @param nodes - the sequence of nodes to add to the forest. If any of them have children which exist in the forest already, those\n\t * children will be parented. Any trait arrays present in a node must be non-empty. The nodes may be provided in any order.\n\t */\n\tpublic add(nodes: Iterable<ForestNode>): Forest {\n\t\tconst newNodes = [...nodes];\n\t\tconst mutableNodes = this.nodes.clone();\n\n\t\t// This method iterates through the supplied nodes in two passes, first looking only at children and second actually adding the\n\t\t// nodes. This allows nodes to be passed in any order, e.g. a parent followed by a child or a child followed by a parent.\n\n\t\tconst childToParent = new Map<NodeId, ParentData>(); // Temporarily records the parentage of children that don't exist yet\n\n\t\t// First, inspect the children of each node. If the child is already in the forest, update its parentage. If it is not in the\n\t\t// forest, it may be about to be added in the second loop below so record its parentage temporarily for when that happens.\n\t\tfor (const node of newNodes) {\n\t\t\tconst { identifier } = node;\n\t\t\tfor (const [traitLabel, trait] of node.traits) {\n\t\t\t\tassert(trait.length > 0, 'any trait arrays present in a node must be non-empty');\n\t\t\t\tfor (const childId of trait) {\n\t\t\t\t\tconst child = mutableNodes.get(childId);\n\t\t\t\t\tif (child !== undefined) {\n\t\t\t\t\t\t// A child already exists in the forest, and its parent is now being added\n\t\t\t\t\t\tassert(!isParentedForestNode(child), 'can not give a child multiple parents');\n\t\t\t\t\t\tconst parentedChild = {\n\t\t\t\t\t\t\tdefinition: child.definition,\n\t\t\t\t\t\t\tidentifier: child.identifier,\n\t\t\t\t\t\t\ttraits: child.traits,\n\t\t\t\t\t\t\tparentId: identifier,\n\t\t\t\t\t\t\ttraitParent: traitLabel,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcopyPropertyIfDefined(child, parentedChild, 'payload');\n\t\t\t\t\t\t// Overwrite the existing child with its parented version\n\t\t\t\t\t\tmutableNodes.set(childId, parentedChild);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// The child hasn't been added yet, so record its parentage to use when it is added below\n\t\t\t\t\t\tchildToParent.set(childId, { parentId: identifier, traitParent: traitLabel });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Now add each node to the forest and apply any parentage information that was recorded above\n\t\tfor (const node of newNodes) {\n\t\t\tconst parentData = childToParent.get(node.identifier);\n\t\t\tassert(!mutableNodes.has(node.identifier), 'can not add node with already existing id');\n\t\t\tif (parentData !== undefined) {\n\t\t\t\t// This is a child whom we haven't added yet, but whose parent we already added above. Supply the recorded parentage info.\n\t\t\t\tconst child = {\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\tidentifier: node.identifier,\n\t\t\t\t\ttraits: node.traits,\n\t\t\t\t\t...parentData,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, child, 'payload');\n\t\t\t\tmutableNodes.set(node.identifier, child);\n\t\t\t} else {\n\t\t\t\t// This is a node that has no parent. Add it with no parentage information.\n\t\t\t\tmutableNodes.set(node.identifier, node);\n\t\t\t}\n\t\t}\n\n\t\treturn new Forest({\n\t\t\tnodes: mutableNodes,\n\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t});\n\t}\n\n\t/**\n\t * Parents a set of nodes already in the forest at a specified location within a trait.\n\t * @param parentId - the id of the parent under which to insert the new nodes\n\t * @param label - the label of the trait under which to insert the new nodes\n\t * @param index - the index in the trait after which to insert the new nodes\n\t * @param childIds - the ids of the nodes to insert\n\t */\n\tpublic attachRangeOfChildren(\n\t\tparentId: NodeId,\n\t\tlabel: TraitLabel,\n\t\tindex: number,\n\t\tchildIds: readonly NodeId[]\n\t): Forest {\n\t\tassert(index >= 0, 'invalid attach index');\n\t\tconst parentNode = this.nodes.get(parentId);\n\t\tassert(parentNode, 'can not insert children under node that does not exist');\n\t\tconst mutableNodes = this.nodes.clone();\n\t\tconst traits = new Map(parentNode.traits);\n\t\tconst trait = traits.get(label) ?? [];\n\t\tassert(index <= trait.length, 'invalid attach index');\n\n\t\t// If there is nothing to insert, return early.\n\t\t// This is good for performance, but also avoids an edge case where an empty trait could be created (which is an error).\n\t\tif (childIds.length === 0) {\n\t\t\treturn this;\n\t\t}\n\t\tconst newChildren = [...trait.slice(0, index), ...childIds, ...trait.slice(index)];\n\t\ttraits.set(label, newChildren);\n\t\tmutableNodes.set(parentId, { ...parentNode, traits });\n\n\t\tfor (const childId of childIds) {\n\t\t\tmutableNodes.editRange(childId, childId, true, (_, n) => {\n\t\t\t\tassert(!isParentedForestNode(n), 'can not attach node that already has a parent');\n\t\t\t\tconst breakVal: { value: ParentedForestNode } = {\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\t...n,\n\t\t\t\t\t\tparentId,\n\t\t\t\t\t\ttraitParent: label,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn breakVal;\n\t\t\t});\n\t\t}\n\n\t\treturn new Forest({\n\t\t\tnodes: mutableNodes,\n\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t});\n\t}\n\n\t/**\n\t * Detaches a range of nodes from their parent. The detached nodes remain in the `Forest`.\n\t * @param parentId - the id of the parent from which to detach the nodes\n\t * @param label - the label of the trait from which to detach the nodes\n\t * @param startIndex - the index of the first node in the range to detach\n\t * @param endIndex - the index after the last node in the range to detach\n\t * @returns a new `Forest` with the nodes detached, and a list of the ids of the nodes that were detached\n\t */\n\tpublic detachRangeOfChildren(\n\t\tparentId: NodeId,\n\t\tlabel: TraitLabel,\n\t\tstartIndex: number,\n\t\tendIndex: number\n\t): { forest: Forest; detached: readonly NodeId[] } {\n\t\tassert(startIndex >= 0 && endIndex >= startIndex, 'invalid detach index range');\n\t\tconst parentNode = this.nodes.get(parentId);\n\t\tassert(parentNode, 'can not detach children under node that does not exist');\n\t\tif (startIndex === endIndex) {\n\t\t\treturn { forest: this, detached: [] };\n\t\t}\n\n\t\tconst mutableNodes = this.nodes.clone();\n\t\tconst traits = new Map(parentNode.traits);\n\t\tconst trait = traits.get(label) ?? [];\n\t\tassert(endIndex <= trait.length, 'invalid detach index range');\n\t\tconst detached: NodeId[] = trait.slice(startIndex, endIndex);\n\t\tconst newChildren = [...trait.slice(0, startIndex), ...trait.slice(endIndex)];\n\t\tconst deleteTrait = newChildren.length === 0;\n\t\tif (deleteTrait) {\n\t\t\ttraits.delete(label);\n\t\t} else {\n\t\t\ttraits.set(label, newChildren);\n\t\t}\n\n\t\tmutableNodes.set(parentId, { ...parentNode, traits });\n\t\tfor (const childId of detached) {\n\t\t\tmutableNodes.editRange(childId, childId, true, (_, n) => {\n\t\t\t\tconst breakVal: { value: ForestNode } = {\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tdefinition: n.definition,\n\t\t\t\t\t\tidentifier: n.identifier,\n\t\t\t\t\t\ttraits: n.traits,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(n, breakVal.value, 'payload');\n\t\t\t\treturn breakVal;\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tforest: new Forest({\n\t\t\t\tnodes: mutableNodes,\n\t\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t\t}),\n\t\t\tdetached,\n\t\t};\n\t}\n\n\t/**\n\t * Replaces a node's value. The node must exist in this `Forest`.\n\t * @param nodeId - the id of the node\n\t * @param value - the new value\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic setValue(nodeId: NodeId, value: Payload | null): Forest {\n\t\tconst node = this.nodes.get(nodeId);\n\t\tassert(node, 'can not replace payload for node that does not exist');\n\t\tconst mutableNodes = this.nodes.clone();\n\t\tconst newNode = { ...node };\n\t\tif (value !== null) {\n\t\t\tnewNode.payload = value;\n\t\t} else {\n\t\t\tdelete newNode.payload;\n\t\t}\n\t\tmutableNodes.set(nodeId, newNode);\n\t\treturn new Forest({\n\t\t\tnodes: mutableNodes,\n\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t});\n\t}\n\n\t/**\n\t * @returns true if the node associated with `id` exists in this forest, otherwise false\n\t */\n\tpublic has(id: NodeId): boolean {\n\t\treturn this.nodes.has(id);\n\t}\n\n\t/**\n\t * @returns the node associated with `id`. Should not be used if there is no node with the provided id.\n\t */\n\tpublic get(id: NodeId): ForestNode {\n\t\treturn this.nodes.get(id) ?? fail('NodeId not found');\n\t}\n\n\t/**\n\t * @returns the node associated with `id`, or undefined if there is none\n\t */\n\tpublic tryGet(id: NodeId): ForestNode | undefined {\n\t\treturn this.nodes.get(id);\n\t}\n\n\t/**\n\t * Deletes every node in ids (each of which must be unparented)\n\t * @param ids - The IDs of the nodes to delete.\n\t * @param deleteChildren - If true, recursively deletes descendants. Otherwise, leaves children unparented.\n\t */\n\tpublic delete(ids: Iterable<NodeId>, deleteChildren: boolean): Forest {\n\t\tconst mutableNodes = this.nodes.clone();\n\t\tfor (const id of ids) {\n\t\t\tthis.deleteRecursive(mutableNodes, id, deleteChildren);\n\t\t}\n\n\t\treturn new Forest({\n\t\t\tnodes: mutableNodes,\n\t\t\texpensiveValidation: this.expensiveValidation,\n\t\t});\n\t}\n\n\tprivate deleteRecursive(mutableNodes: BTree<NodeId, ForestNode>, id: NodeId, deleteChildren: boolean): void {\n\t\tconst node = mutableNodes.get(id) ?? fail('node to delete must exist');\n\t\tassert(!isParentedForestNode(node), 'deleted nodes must be unparented');\n\t\tmutableNodes.delete(id);\n\t\tfor (const trait of node.traits.values()) {\n\t\t\tfor (const childId of trait) {\n\t\t\t\tmutableNodes.editRange(childId, childId, true, (_, n) => {\n\t\t\t\t\tconst breakVal: { value: ForestNode } = {\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tdefinition: n.definition,\n\t\t\t\t\t\t\tidentifier: n.identifier,\n\t\t\t\t\t\t\ttraits: n.traits,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tcopyPropertyIfDefined(n, breakVal.value, 'payload');\n\t\t\t\t\treturn breakVal;\n\t\t\t\t});\n\n\t\t\t\tif (deleteChildren) {\n\t\t\t\t\tthis.deleteRecursive(mutableNodes, childId, deleteChildren);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks that the metadata is correct, and the items form a forest.\n\t * This is an expensive O(map size) operation.\n\t */\n\tpublic assertConsistent(): void {\n\t\tconst checkedChildren = new Set<NodeId>([]);\n\t\tfor (const [nodeId, node] of this.nodes.entries(undefined, [])) {\n\t\t\tif (isParentedForestNode(node)) {\n\t\t\t\tconst parent = this.get(node.parentId);\n\t\t\t\tconst trait = parent.traits.get(node.traitParent);\n\t\t\t\tassert(trait !== undefined);\n\t\t\t\tassert(trait.includes(node.identifier), 'node is parented incorrectly');\n\t\t\t}\n\n\t\t\tfor (const trait of node.traits.values()) {\n\t\t\t\tassert(trait.length > 0, 'trait is present but empty');\n\t\t\t\tfor (const childId of trait) {\n\t\t\t\t\tconst child = this.nodes.get(childId);\n\t\t\t\t\tassert(child, 'child in trait is not in forest');\n\t\t\t\t\tassert(isParentedForestNode(child), 'child is not parented');\n\t\t\t\t\tassert(child.parentId === node.identifier, 'child parent pointer is incorrect');\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!checkedChildren.has(childId),\n\t\t\t\t\t\t'the item tree tree must not contain cycles or multi-parented nodes'\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t(child.parentId ?? fail('each node must have associated metadata')) === nodeId,\n\t\t\t\t\t\t'cached parent is incorrect'\n\t\t\t\t\t);\n\t\t\t\t\tcheckedChildren.add(childId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @returns the parent of `id`. Should not be used if there is no node with id or if id refers to the root node.\n\t */\n\tpublic getParent(id: NodeId): ParentData {\n\t\tconst child = this.nodes.get(id);\n\t\tif (child === undefined) {\n\t\t\tfail('NodeId not found');\n\t\t}\n\n\t\tassert(isParentedForestNode(child), 'Node is not parented');\n\t\treturn { parentId: child.parentId, traitParent: child.traitParent };\n\t}\n\n\t/**\n\t * @returns undefined iff root, otherwise the parent of `id`.\n\t */\n\tpublic tryGetParent(id: NodeId): ParentData | undefined {\n\t\tconst child = this.nodes.get(id);\n\t\tif (child === undefined || !isParentedForestNode(child)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tparentId: child.parentId,\n\t\t\ttraitParent: child.traitParent,\n\t\t};\n\t}\n\n\t/**\n\t * Compares two forests for equality.\n\t * @param forest - the other forest to compare to this one\n\t * @param comparator - a function which returns true if two objects of type ForestNode are equivalent, false otherwise\n\t * @returns true iff the forests are equal.\n\t */\n\tpublic equals(forest: Forest): boolean {\n\t\tif (this === forest || this.nodes === forest.nodes) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (forest.size !== this.size) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn compareBtrees(this.nodes, forest.nodes, compareForestNodes);\n\t}\n\n\t/**\n\t * Calculate the difference between two forests.\n\t * @param forest - the other forest to compare to this one\n\t * @param comparator - a function which returns true if two objects of type ForestNode are equivalent, false otherwise\n\t * @returns A {@link Delta} listing which nodes must be changed, added, and removed to get from `this` to `forest`.\n\t */\n\tpublic delta(forest: Forest): Delta<NodeId> {\n\t\tconst changed: NodeId[] = [];\n\t\tconst removed: NodeId[] = [];\n\t\tconst added: NodeId[] = [];\n\t\tthis.nodes.diffAgainst(\n\t\t\tforest.nodes,\n\t\t\t(id) => {\n\t\t\t\tremoved.push(id);\n\t\t\t},\n\t\t\t(id) => {\n\t\t\t\tadded.push(id);\n\t\t\t},\n\t\t\t(id, nodeThis, nodeOther) => {\n\t\t\t\tif (!compareForestNodes(nodeThis, nodeOther)) {\n\t\t\t\t\tchanged.push(id);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\treturn {\n\t\t\tchanged,\n\t\t\tadded,\n\t\t\tremoved,\n\t\t};\n\t}\n}\n\n/**\n * @returns true iff two `ForestNodes` are equivalent.\n * May return false for nodes they contain equivalent payloads encoded differently.\n */\nexport function compareForestNodes(nodeA: ForestNode, nodeB: ForestNode): boolean {\n\tif (nodeA === nodeB) {\n\t\treturn true;\n\t}\n\n\tif (nodeA.identifier !== nodeB.identifier) {\n\t\treturn false;\n\t}\n\n\tif (nodeA.definition !== nodeB.definition) {\n\t\treturn false;\n\t}\n\n\tif (!comparePayloads(nodeA.payload, nodeB.payload)) {\n\t\treturn false;\n\t}\n\n\tif (nodeA.traits.size !== nodeB.traits.size) {\n\t\treturn false;\n\t}\n\n\tfor (const traitA of nodeA.traits) {\n\t\tconst [traitLabelA, nodeSequenceA] = traitA;\n\t\tconst nodeSequenceB = nodeB.traits.get(traitLabelA);\n\t\tif (!nodeSequenceB) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (nodeSequenceA.length !== nodeSequenceB.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (let i = 0; i < nodeSequenceA.length; i++) {\n\t\t\tif (nodeSequenceA[i] !== nodeSequenceB[i]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n"]}
@@ -22,28 +22,6 @@ export declare function isFinalId(id: CompressedId): id is FinalCompressedId;
22
22
  * @returns true if the supplied ID is a local ID.
23
23
  */
24
24
  export declare function isLocalId(id: CompressedId): id is LocalCompressedId;
25
- /**
26
- * A object for retrieving the session-space IDs for a range of IDs.
27
- * Optimized to avoid allocating an array of IDs.
28
- */
29
- export interface IdRange {
30
- /**
31
- * The length of the ID range.
32
- */
33
- readonly length: number;
34
- /**
35
- * Returns the ID in range at the provided index.
36
- */
37
- get(index: number): SessionSpaceCompressedId;
38
- }
39
- /**
40
- * A serializable descriptor of a range of session-space IDs.
41
- * The contained IDs must be retrieved by calling `getIdsFromRange`, which returns an `IdRange`.
42
- */
43
- export interface IdRangeDescriptor<TId extends LocalCompressedId | OpSpaceCompressedId> {
44
- readonly first: TId;
45
- readonly count: number;
46
- }
47
25
  /**
48
26
  * A distributed UUID generator and compressor.
49
27
  *
@@ -156,11 +134,21 @@ export declare class IdCompressor {
156
134
  */
157
135
  private readonly localOverrides;
158
136
  /**
159
- * Maps local IDs to the cluster they belong to (if any). This can be used to efficiently convert a local ID to a
160
- * final ID by finding an entry \<= a given local ID (to find the cluster it is associated with) and checking
161
- * it against `numFinalizedLocalIds`.
162
- */
163
- private readonly localIdToCluster;
137
+ * Maps local IDs to the final ID they are associated with (if any), and maps final IDs to the corresponding local ID (if any).
138
+ * This is used to efficiently compute normalization. This map can be thought of as mapping ranges of "optimistic uncertainty"
139
+ * (local IDs) to the result of consensus (reserved ranges of final IDs, a.k.a. clusters). Any given range of local IDs
140
+ * does not necessarily span an entire cluster, as some session-space IDs may be allocated *after* a cluster has been allocated
141
+ * but before it is full. In this case, there is no uncertainty, as the range of final IDs was reserved when the cluster was created.
142
+ * However, there is always a range of local IDs with size \>= 1 associated with the beginning of every cluster, as clusters are only
143
+ * created *after* they are needed and thus there is some period of uncertainty after local IDs have been handed out but before the
144
+ * range containing them has been finalized. There may also be ranges of local IDs that do not start at the beginning of a
145
+ * cluster; this happens when a cluster is expanded instead of allocating a new one.
146
+ * Additionally, session space IDs associated with an override string will also always be local IDs, because there is uncertainty as
147
+ * to whether another client simultaneously allocated the same override and could get sequenced first (a.k.a. unification) and its
148
+ * final ID would be associated with that override.
149
+ * See `SessionIdNormalizer` for more.
150
+ */
151
+ private sessionIdNormalizer;
164
152
  /**
165
153
  * Contains entries for cluster base UUIDs and override strings (both local and final).
166
154
  * As a performance optimization, entries for finalized strings also include the containing cluster object.
@@ -175,10 +163,6 @@ export declare class IdCompressor {
175
163
  * Can be searched in O(log n) to determine clusters for any final ID.
176
164
  */
177
165
  private readonly finalIdToCluster;
178
- /**
179
- * Helper comparator for searching append-only sorted maps.
180
- */
181
- private static overrideComparator;
182
166
  /**
183
167
  * @param localSessionId - the `IdCompressor`'s current local session ID.
184
168
  * @param reservedIdCount - the number of IDs that will be known by this compressor without relying on consensus.
@@ -211,11 +195,6 @@ export declare class IdCompressor {
211
195
  * Returns the attribution ID associated with the compressor that created the ID
212
196
  */
213
197
  attributeId(id: SessionSpaceCompressedId): AttributionId;
214
- /**
215
- * Provides the session-space IDs corresponding to a range of IDs.
216
- * See `IdRange` for more details.
217
- */
218
- getIdsFromRange(rangeDescriptor: IdRangeDescriptor<SessionSpaceCompressedId>, sessionId: SessionId): IdRange;
219
198
  /**
220
199
  * Returns a range of local IDs created by this session in a format for sending to the server for finalizing.
221
200
  * The range will include all local IDs generated via calls to `generateCompressedId` since the last time this method was called.
@@ -255,14 +234,6 @@ export declare class IdCompressor {
255
234
  * @returns an existing ID if one already exists for `override`, and a new local ID otherwise. The returned ID is in session space.
256
235
  */
257
236
  generateCompressedId(override?: string): SessionSpaceCompressedId;
258
- /**
259
- * Generates a range of compressed IDs.
260
- * This should ONLY be called to generate IDs for local operations.
261
- * @param count - the number of IDs to generate, must be \> 0.
262
- * @returns a persistable descriptor of the ID range.
263
- */
264
- generateCompressedIdRange(count: number): IdRangeDescriptor<LocalCompressedId>;
265
- private generateNextLocalId;
266
237
  /**
267
238
  * Decompresses a previously compressed ID into a UUID or override string.
268
239
  * @param id - the compressed ID to be decompressed.
@@ -335,7 +306,10 @@ export declare class IdCompressor {
335
306
  * session-space ID corresponding to A0000000-0000-0000-0000-000000000000 (with override X0000000-0000-0000-0000-000000000000).
336
307
  */
337
308
  private compressNumericUuid;
338
- private getLocalIdForStableId;
309
+ /**
310
+ * Returns a compressed ID for the supplied stable ID if it was created by the local session, and undefined otherwise.
311
+ */
312
+ private getCompressedIdForStableId;
339
313
  private getClusterForFinalId;
340
314
  /**
341
315
  * @returns if `other` is equal to this `IdCompressor`. The equality check includes local session state only if specified.
@@ -1 +1 @@
1
- {"version":3,"file":"IdCompressor.d.ts","sourceRoot":"","sources":["../../src/id-compressor/IdCompressor.ts"],"names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