@fluid-experimental/tree 0.56.5 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/Common.d.ts.map +1 -1
  3. package/dist/Common.js +1 -2
  4. package/dist/Common.js.map +1 -1
  5. package/dist/Forest.d.ts.map +1 -1
  6. package/dist/Forest.js +0 -1
  7. package/dist/Forest.js.map +1 -1
  8. package/dist/RevisionValueCache.d.ts.map +1 -1
  9. package/dist/RevisionValueCache.js +0 -2
  10. package/dist/RevisionValueCache.js.map +1 -1
  11. package/dist/Snapshot.d.ts.map +1 -1
  12. package/dist/Snapshot.js.map +1 -1
  13. package/dist/TreeNodeHandle.d.ts.map +1 -1
  14. package/dist/TreeNodeHandle.js +0 -1
  15. package/dist/TreeNodeHandle.js.map +1 -1
  16. package/dist/default-edits/HistoryEditFactory.d.ts.map +1 -1
  17. package/dist/default-edits/HistoryEditFactory.js +1 -1
  18. package/dist/default-edits/HistoryEditFactory.js.map +1 -1
  19. package/dist/default-edits/PersistedTypes.d.ts.map +1 -1
  20. package/dist/default-edits/PersistedTypes.js +0 -1
  21. package/dist/default-edits/PersistedTypes.js.map +1 -1
  22. package/dist/default-edits/Transaction.d.ts.map +1 -1
  23. package/dist/default-edits/Transaction.js.map +1 -1
  24. package/dist/default-edits/UndoRedoHandler.d.ts +1 -1
  25. package/dist/default-edits/UndoRedoHandler.d.ts.map +1 -1
  26. package/dist/default-edits/UndoRedoHandler.js +0 -4
  27. package/dist/default-edits/UndoRedoHandler.js.map +1 -1
  28. package/dist/generic/GenericSharedTree.d.ts +0 -4
  29. package/dist/generic/GenericSharedTree.d.ts.map +1 -1
  30. package/dist/generic/GenericSharedTree.js +0 -6
  31. package/dist/generic/GenericSharedTree.js.map +1 -1
  32. package/dist/generic/GenericTransaction.js +0 -1
  33. package/dist/generic/GenericTransaction.js.map +1 -1
  34. package/lib/Common.d.ts.map +1 -1
  35. package/lib/Common.js +1 -2
  36. package/lib/Common.js.map +1 -1
  37. package/lib/Forest.d.ts.map +1 -1
  38. package/lib/Forest.js +0 -1
  39. package/lib/Forest.js.map +1 -1
  40. package/lib/RevisionValueCache.d.ts.map +1 -1
  41. package/lib/RevisionValueCache.js +0 -2
  42. package/lib/RevisionValueCache.js.map +1 -1
  43. package/lib/Snapshot.d.ts.map +1 -1
  44. package/lib/Snapshot.js.map +1 -1
  45. package/lib/TreeNodeHandle.d.ts.map +1 -1
  46. package/lib/TreeNodeHandle.js +0 -1
  47. package/lib/TreeNodeHandle.js.map +1 -1
  48. package/lib/default-edits/HistoryEditFactory.d.ts.map +1 -1
  49. package/lib/default-edits/HistoryEditFactory.js +1 -1
  50. package/lib/default-edits/HistoryEditFactory.js.map +1 -1
  51. package/lib/default-edits/PersistedTypes.d.ts.map +1 -1
  52. package/lib/default-edits/PersistedTypes.js +0 -1
  53. package/lib/default-edits/PersistedTypes.js.map +1 -1
  54. package/lib/default-edits/Transaction.d.ts.map +1 -1
  55. package/lib/default-edits/Transaction.js.map +1 -1
  56. package/lib/default-edits/UndoRedoHandler.d.ts +1 -1
  57. package/lib/default-edits/UndoRedoHandler.d.ts.map +1 -1
  58. package/lib/default-edits/UndoRedoHandler.js +0 -4
  59. package/lib/default-edits/UndoRedoHandler.js.map +1 -1
  60. package/lib/generic/GenericSharedTree.d.ts +0 -4
  61. package/lib/generic/GenericSharedTree.d.ts.map +1 -1
  62. package/lib/generic/GenericSharedTree.js +0 -6
  63. package/lib/generic/GenericSharedTree.js.map +1 -1
  64. package/lib/generic/GenericTransaction.js +0 -1
  65. package/lib/generic/GenericTransaction.js.map +1 -1
  66. package/lib/test/SnapshotUtilities.tests.js +0 -3
  67. package/lib/test/SnapshotUtilities.tests.js.map +1 -1
  68. package/lib/test/undoRedoStackManager.d.ts.map +1 -1
  69. package/lib/test/undoRedoStackManager.js +0 -1
  70. package/lib/test/undoRedoStackManager.js.map +1 -1
  71. package/package.json +13 -13
  72. package/src/Common.ts +1 -2
  73. package/src/Forest.ts +0 -1
  74. package/src/RevisionValueCache.ts +0 -2
  75. package/src/Snapshot.ts +1 -0
  76. package/src/TreeNodeHandle.ts +0 -1
  77. package/src/default-edits/HistoryEditFactory.ts +1 -1
  78. package/src/default-edits/PersistedTypes.ts +0 -1
  79. package/src/default-edits/Transaction.ts +1 -0
  80. package/src/default-edits/UndoRedoHandler.ts +1 -5
  81. package/src/generic/GenericSharedTree.ts +0 -7
  82. package/src/generic/GenericTransaction.ts +1 -1
package/.eslintrc.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- extends: ['@fluidframework/eslint-config-fluid/eslint7'],
7
+ extends: ['@fluidframework/eslint-config-fluid'],
8
8
  root: true,
9
9
  rules: {
10
10
  // TODO: Recover "noUnusedLocals" behavior as part of linting. (This rule seems to be broken in the Fluid repo.)
@@ -1 +1 @@
1
- {"version":3,"file":"Common.d.ts","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,wBAAwB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,6BAA8B,SAAQ,2BAA2B;IACjF,iBAAiB,EAAE,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAErE;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAgF/D;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,SA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CAAC,CAGjH;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAQ7F;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EACjC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,EACtB,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,EACtB,iBAAiB,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAmB,GACpD,OAAO,CAET;AA+BD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC9B,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,iBAAiB,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAmB,GACpD,OAAO,CAYT;AAED;;GAEG;AACH,wBAAgB,IAAI,IAAI,IAAI,CAE3B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAK7G;AAED;;;GAGG;AACH,oBAAY,WAAW,GAAG,MAAM,CAAC"}
package/dist/Common.js CHANGED
@@ -85,7 +85,6 @@ function comparePayloads(a, b) {
85
85
  // null is of type object, and needs to be treated as distinct from the empty object.
86
86
  // Handling it early also avoids type errors trying to access its keys.
87
87
  // Rationale: 'undefined' payloads are reserved for future use (see 'SetValue' interface).
88
- // eslint-disable-next-line no-null/no-null
89
88
  if (a === null || b === null) {
90
89
  return false;
91
90
  }
@@ -149,7 +148,6 @@ exports.comparePayloads = comparePayloads;
149
148
  * @param containsPII - boolean flag for whether the message passed in contains personally identifying information (PII).
150
149
  */
151
150
  function assert(condition, message, containsPII = false) {
152
- // Rationale: Assert condition is permitted to be truthy.
153
151
  // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
154
152
  if (!condition) {
155
153
  fail(message, containsPII);
@@ -164,6 +162,7 @@ exports.assert = assert;
164
162
  */
165
163
  function fail(message = defaultFailMessage, containsPII = false) {
166
164
  if (process.env.NODE_ENV !== 'production') {
165
+ // eslint-disable-next-line no-debugger
167
166
  debugger;
168
167
  console.error(message);
169
168
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Common.js","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAE9C;;;;;;;;GAQG;AACU,QAAA,4BAA4B,GAAG,qBAAqB,CAAC;AASlE;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA0B;IAC3D,OAAQ,KAAkD,CAAC,iBAAiB,KAAK,IAAI,CAAC;AACvF,CAAC;AAFD,8CAEC;AAED;;GAEG;AACH,MAAM,wBAAyB,SAAQ,KAAK;IAG3C,YAAmB,OAAe;;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHA,cAAS,GAAG,oCAA4B,CAAC;QAIxD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,MAAA,KAAK,CAAC,iBAAiB,+CAAvB,KAAK,EAAqB,IAAI,EAAE;IACjC,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,eAAe,CAAC,CAAU,EAAE,CAAU;IACrD,iFAAiF;IACjF,sCAAsC;IACtC,0DAA0D;IAC1D,mFAAmF;IACnF,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC;KACZ;IAED,2HAA2H;IAC3H,IAAI,OAAO,CAAC,KA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KAC/E,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,6CAA6C;MACvF;QACD,mDAAmD;QACnD,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE;YACzC,OAAO,KAAK,CAAC;SACb;KACD;IAED,2EAA2E;IAC3E,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAC5B,MAAoB,EACpB,MAAoB,EACpB,oBAA6C,MAAM,CAAC,EAAE;IAEtD,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE;QACpC,OAAO,KAAK,CAAC;KACb;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;YAC7C,OAAO,KAAK,CAAC;SACb;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAhBD,sCAgBC;AAED;;GAEG;AACH,SAAgB,IAAI;IACnB,OAAO;AACR,CAAC;AAFD,oBAEC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAa,MAAY,EAAE,WAAiB,EAAE,QAAoB;IACtG,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,WAAmB,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;KACvC;AACF,CAAC;AALD,sDAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerPropertyBag } from '@fluidframework/telemetry-utils';\nimport { ITelemetryBaseEvent } from '@fluidframework/common-definitions';\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { Payload } from './generic';\n\nconst defaultFailMessage = 'Assertion failed';\n\n/**\n * Assertion failures in SharedTree will throw an exception containing this value as an `errorType`. The Fluid runtime propagates this field\n * in its handlings of errors thrown by containers. See\n * https://github.com/microsoft/FluidFramework/blob/main/packages/loader/container-utils/src/error.ts\n *\n * Exporting this enables users to safely filter telemetry handling of errors based on their type.\n *\n * @public\n */\nexport const sharedTreeAssertionErrorType = 'SharedTreeAssertion';\n\n/**\n * Telemetry properties decorated on all SharedTree events.\n */\nexport interface SharedTreeTelemetryProperties extends ITelemetryLoggerPropertyBag {\n\tisSharedTreeEvent: true;\n}\n\n/**\n * Returns if the supplied event is a SharedTree telemetry event.\n */\nexport function isSharedTreeEvent(event: ITelemetryBaseEvent): boolean {\n\treturn (event as unknown as SharedTreeTelemetryProperties).isSharedTreeEvent === true;\n}\n\n/**\n * Error object thrown by assertion failures in `SharedTree`.\n */\nclass SharedTreeAssertionError extends Error {\n\tpublic readonly errorType = sharedTreeAssertionErrorType;\n\n\tpublic constructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'Assertion error';\n\t\tError.captureStackTrace?.(this);\n\t}\n}\n\n/**\n * @returns true if two `Payloads` are identical.\n * May return false for equivalent payloads encoded differently.\n *\n * Object field order and object identity are not considered significant, and are ignored by this function.\n * (This is because they may not be preserved through roundtrip).\n *\n * For other information which Fluid would lose on serialization round trip,\n * behavior is unspecified other than this this function is reflective (all payloads are equal to themselves)\n * and commutative (argument order does not matter).\n *\n * This means that any Payload is equal to itself and a deep clone of itself.\n *\n * Payloads might not be equal to a version of themselves that has been serialized then deserialized.\n * If they are serialized then deserialized again, the two deserialized objects will compare equal,\n * however the serialized strings may be unequal (due to field order for objects being unspecified).\n *\n * Fluid will cause lossy operations due to use of JSON.stringify().\n * This includes:\n * - Loss of object identity\n * - Loss of field order (may be ordered arbitrarily)\n * - -0 becomes +0\n * - NaN, Infinity, -Infinity all become null\n * - custom toJSON functions may cause arbitrary behavior\n * - functions become undefined or null\n * - non enumerable properties (including prototype) are lost\n * - more (this is not a complete list)\n *\n * Inputs must not contain cyclic references other than fields set to their immediate parent (for the JavaScript feature detection pattern).\n *\n * IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.\n *\n * TODO:#54095: Is there a better way to do this comparison?\n * @public\n */\nexport function comparePayloads(a: Payload, b: Payload): boolean {\n\t// === is not reflective because of how NaN is handled, so use Object.is instead.\n\t// This treats -0 and +0 as different.\n\t// Since -0 is not preserved in serialization round trips,\n\t// it can be handed in any way that is reflective and commutative, so this is fine.\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\n\t// Primitives which are equal would have early returned above, so now if the values are not both objects, they are unequal.\n\tif (typeof a !== 'object' || typeof b !== 'object') {\n\t\treturn false;\n\t}\n\n\t// null is of type object, and needs to be treated as distinct from the empty object.\n\t// Handling it early also avoids type errors trying to access its keys.\n\t// Rationale: 'undefined' payloads are reserved for future use (see 'SetValue' interface).\n\t// eslint-disable-next-line no-null/no-null\n\tif (a === null || b === null) {\n\t\treturn false;\n\t}\n\n\t// Special case IFluidHandles, comparing them only by their absolutePath\n\t// Detect them using JavaScript feature detection pattern: they have a `IFluidHandle` field that is set to the parent object.\n\t{\n\t\tconst aHandle = a as IFluidHandle;\n\t\tconst bHandle = b as IFluidHandle;\n\t\tif (aHandle.IFluidHandle === a) {\n\t\t\tif (bHandle.IFluidHandle !== b) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn a.absolutePath === b.absolutePath;\n\t\t}\n\t}\n\n\t// Fluid Serialization (like Json) only keeps enumerable properties, so we can ignore non-enumerable ones.\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\n\tif (aKeys.length !== bKeys.length) {\n\t\treturn false;\n\t}\n\n\t// make sure objects with numeric keys (or no keys) compare unequal to arrays.\n\tif (Array.isArray(a) !== Array.isArray(b)) {\n\t\treturn false;\n\t}\n\n\t// Fluid Serialization (like Json) orders object fields arbitrarily, so reordering fields is not considered considered a change.\n\t// Therefor the keys arrays must be sorted here.\n\tif (!Array.isArray(a)) {\n\t\taKeys.sort();\n\t\tbKeys.sort();\n\t}\n\n\t// First check keys are equal.\n\t// This will often early exit, and thus is worth doing as a separate pass than recursive check.\n\tif (!compareArrays(aKeys, bKeys)) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < aKeys.length; i++) {\n\t\tconst aItem: Payload = a[aKeys[i]];\n\t\tconst bItem: Payload = b[bKeys[i]];\n\n\t\t// The JavaScript feature detection pattern, used for IFluidHandle, uses a field that is set to the parent object.\n\t\t// Detect this pattern and special case it to avoid infinite recursion.\n\t\tconst aSelf = Object.is(aItem, a);\n\t\tconst bSelf = Object.is(bItem, b);\n\t\tif (aSelf !== bSelf) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!aSelf) {\n\t\t\tif (!comparePayloads(aItem, bItem)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Asserts against a boolean condition. Throws an Error if the assertion failed. Will run and throw in release builds.\n * Use when violations are logic errors in the program.\n * @param condition - A condition to assert is truthy\n * @param message - Message to be printed if assertion fails. Will print \"Assertion failed\" by default\n * @param containsPII - boolean flag for whether the message passed in contains personally identifying information (PII).\n */\nexport function assert(condition: unknown, message?: string, containsPII = false): asserts condition {\n\t// Rationale: Assert condition is permitted to be truthy.\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (!condition) {\n\t\tfail(message, containsPII);\n\t}\n}\n\n/**\n * Fails an assertion. Throws an Error that the assertion failed.\n * Use when violations are logic errors in the program.\n * @param message - Message to be printed if assertion fails. Will print \"Assertion failed\" by default\n * @param containsPII - boolean flag for whether the message passed in contains personally identifying information (PII).\n */\nexport function fail(message: string = defaultFailMessage, containsPII = false): never {\n\tif (process.env.NODE_ENV !== 'production') {\n\t\tdebugger;\n\t\tconsole.error(message);\n\t}\n\n\tthrow new SharedTreeAssertionError(containsPII ? 'Assertion failed' : message);\n}\n\n/**\n * Asserts a value is not undefined, and returns the value.\n * Use when violations are logic errors in the program.\n * @param value - Value to assert against is non undefined.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertNotUndefined<T>(value: T | undefined, message = 'value must not be undefined'): T {\n\tassert(value !== undefined, message);\n\treturn value;\n}\n\n/**\n * Asserts an array contains a single value and returns the value.\n * @param array - array to assert contains a single value.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertArrayOfOne<T>(array: readonly T[], message = 'array value must contain exactly one item'): T {\n\tassert(array.length === 1, message);\n\treturn array[0];\n}\n\n/**\n * Redefine a property to have the given value. This is simply a type-safe wrapper around\n * `Object.defineProperty`, but it is useful for caching public getters on first read.\n * @example\n * ```\n * // `randomOnce()` will return a random number, but always the same random number.\n * {\n * get randomOnce(): number {\n * return memoizeGetter(this, 'randomOnce', random(100))\n * }\n * }\n * ```\n * @param object - the object containing the property\n * @param propName - the name of the property on the object\n * @param value - the value of the property\n */\nexport function memoizeGetter<T, K extends keyof T>(object: T, propName: K, value: T[K]): T[K] {\n\tObject.defineProperty(object, propName, {\n\t\tvalue,\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t});\n\n\treturn value;\n}\n\n/**\n * Iterate through two iterables and return true if they yield equivalent elements in the same order.\n * @param iterableA - the first iterable to compare\n * @param iterableB - the second iterable to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nexport function compareIterables<T>(\n\titerableA: Iterable<T>,\n\titerableB: Iterable<T>,\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\treturn compareIterators<T>(iterableA[Symbol.iterator](), iterableB[Symbol.iterator](), elementComparator);\n}\n\n/**\n * Iterate through two iterators and return true if they yield equivalent elements in the same order.\n * @param iteratorA - the first iterator to compare\n * @param iteratorB - the second iterator to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nfunction compareIterators<T, TReturn extends T = T>(\n\titeratorA: Iterator<T, TReturn>,\n\titeratorB: Iterator<T, TReturn>,\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\tlet a: IteratorResult<T, TReturn>;\n\tlet b: IteratorResult<T, TReturn>;\n\tfor (\n\t\ta = iteratorA.next(), b = iteratorB.next(); // Given two iterators...\n\t\ta.done !== true && b.done !== true; // ...while both have elements remaining...\n\t\ta = iteratorA.next(), b = iteratorB.next() // ...take one element at a time from each...\n\t) {\n\t\t// ...and ensure that their elements are equivalent\n\t\tif (!elementComparator(a.value, b.value)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// If one iterator is done, but not the other, then they are not equivalent\n\treturn a.done === b.done;\n}\n\n/**\n * Compare two arrays and return true if their elements are equivalent and in the same order.\n * @param arrayA - the first array to compare\n * @param arrayB - the second array to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nexport function compareArrays<T>(\n\tarrayA: readonly T[],\n\tarrayB: readonly T[],\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\tif (arrayA.length !== arrayB.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < arrayA.length; i++) {\n\t\tif (!elementComparator(arrayA[i], arrayB[i])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Function which does nothing (no-ops).\n */\nexport function noop(): void {\n\t// noop\n}\n\n/**\n * Copies a property in such a way that it is only set on `destination` if it is present on `source`.\n * This avoids having explicit undefined values under properties that would cause `Object.hasOwnProperty` to return true.\n */\nexport function copyPropertyIfDefined<TSrc, TDst>(source: TSrc, destination: TDst, property: keyof TSrc): void {\n\tconst value = source[property];\n\tif (value !== undefined) {\n\t\t(destination as any)[property] = value;\n\t}\n}\n\n/**\n * A developer facing (non-localized) error message.\n * TODO: better error system.\n */\nexport type Er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AAoB,EACpB,MAAoB,EACpB,oBAA6C,MAAM,CAAC,EAAE;IAEtD,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE;QACpC,OAAO,KAAK,CAAC;KACb;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;YAC7C,OAAO,KAAK,CAAC;SACb;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAhBD,sCAgBC;AAED;;GAEG;AACH,SAAgB,IAAI;IACnB,OAAO;AACR,CAAC;AAFD,oBAEC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAa,MAAY,EAAE,WAAiB,EAAE,QAAoB;IACtG,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,WAAmB,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;KACvC;AACF,CAAC;AALD,sDAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerPropertyBag } from '@fluidframework/telemetry-utils';\nimport { ITelemetryBaseEvent } from '@fluidframework/common-definitions';\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { Payload } from './generic';\n\nconst defaultFailMessage = 'Assertion failed';\n\n/**\n * Assertion failures in SharedTree will throw an exception containing this value as an `errorType`. The Fluid runtime propagates this field\n * in its handlings of errors thrown by containers. See\n * https://github.com/microsoft/FluidFramework/blob/main/packages/loader/container-utils/src/error.ts\n *\n * Exporting this enables users to safely filter telemetry handling of errors based on their type.\n *\n * @public\n */\nexport const sharedTreeAssertionErrorType = 'SharedTreeAssertion';\n\n/**\n * Telemetry properties decorated on all SharedTree events.\n */\nexport interface SharedTreeTelemetryProperties extends ITelemetryLoggerPropertyBag {\n\tisSharedTreeEvent: true;\n}\n\n/**\n * Returns if the supplied event is a SharedTree telemetry event.\n */\nexport function isSharedTreeEvent(event: ITelemetryBaseEvent): boolean {\n\treturn (event as unknown as SharedTreeTelemetryProperties).isSharedTreeEvent === true;\n}\n\n/**\n * Error object thrown by assertion failures in `SharedTree`.\n */\nclass SharedTreeAssertionError extends Error {\n\tpublic readonly errorType = sharedTreeAssertionErrorType;\n\n\tpublic constructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'Assertion error';\n\t\tError.captureStackTrace?.(this);\n\t}\n}\n\n/**\n * @returns true if two `Payloads` are identical.\n * May return false for equivalent payloads encoded differently.\n *\n * Object field order and object identity are not considered significant, and are ignored by this function.\n * (This is because they may not be preserved through roundtrip).\n *\n * For other information which Fluid would lose on serialization round trip,\n * behavior is unspecified other than this this function is reflective (all payloads are equal to themselves)\n * and commutative (argument order does not matter).\n *\n * This means that any Payload is equal to itself and a deep clone of itself.\n *\n * Payloads might not be equal to a version of themselves that has been serialized then deserialized.\n * If they are serialized then deserialized again, the two deserialized objects will compare equal,\n * however the serialized strings may be unequal (due to field order for objects being unspecified).\n *\n * Fluid will cause lossy operations due to use of JSON.stringify().\n * This includes:\n * - Loss of object identity\n * - Loss of field order (may be ordered arbitrarily)\n * - -0 becomes +0\n * - NaN, Infinity, -Infinity all become null\n * - custom toJSON functions may cause arbitrary behavior\n * - functions become undefined or null\n * - non enumerable properties (including prototype) are lost\n * - more (this is not a complete list)\n *\n * Inputs must not contain cyclic references other than fields set to their immediate parent (for the JavaScript feature detection pattern).\n *\n * IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.\n *\n * TODO:#54095: Is there a better way to do this comparison?\n * @public\n */\nexport function comparePayloads(a: Payload, b: Payload): boolean {\n\t// === is not reflective because of how NaN is handled, so use Object.is instead.\n\t// This treats -0 and +0 as different.\n\t// Since -0 is not preserved in serialization round trips,\n\t// it can be handed in any way that is reflective and commutative, so this is fine.\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\n\t// Primitives which are equal would have early returned above, so now if the values are not both objects, they are unequal.\n\tif (typeof a !== 'object' || typeof b !== 'object') {\n\t\treturn false;\n\t}\n\n\t// null is of type object, and needs to be treated as distinct from the empty object.\n\t// Handling it early also avoids type errors trying to access its keys.\n\t// Rationale: 'undefined' payloads are reserved for future use (see 'SetValue' interface).\n\tif (a === null || b === null) {\n\t\treturn false;\n\t}\n\n\t// Special case IFluidHandles, comparing them only by their absolutePath\n\t// Detect them using JavaScript feature detection pattern: they have a `IFluidHandle` field that is set to the parent object.\n\t{\n\t\tconst aHandle = a as IFluidHandle;\n\t\tconst bHandle = b as IFluidHandle;\n\t\tif (aHandle.IFluidHandle === a) {\n\t\t\tif (bHandle.IFluidHandle !== b) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn a.absolutePath === b.absolutePath;\n\t\t}\n\t}\n\n\t// Fluid Serialization (like Json) only keeps enumerable properties, so we can ignore non-enumerable ones.\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\n\tif (aKeys.length !== bKeys.length) {\n\t\treturn false;\n\t}\n\n\t// make sure objects with numeric keys (or no keys) compare unequal to arrays.\n\tif (Array.isArray(a) !== Array.isArray(b)) {\n\t\treturn false;\n\t}\n\n\t// Fluid Serialization (like Json) orders object fields arbitrarily, so reordering fields is not considered considered a change.\n\t// Therefor the keys arrays must be sorted here.\n\tif (!Array.isArray(a)) {\n\t\taKeys.sort();\n\t\tbKeys.sort();\n\t}\n\n\t// First check keys are equal.\n\t// This will often early exit, and thus is worth doing as a separate pass than recursive check.\n\tif (!compareArrays(aKeys, bKeys)) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < aKeys.length; i++) {\n\t\tconst aItem: Payload = a[aKeys[i]];\n\t\tconst bItem: Payload = b[bKeys[i]];\n\n\t\t// The JavaScript feature detection pattern, used for IFluidHandle, uses a field that is set to the parent object.\n\t\t// Detect this pattern and special case it to avoid infinite recursion.\n\t\tconst aSelf = Object.is(aItem, a);\n\t\tconst bSelf = Object.is(bItem, b);\n\t\tif (aSelf !== bSelf) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!aSelf) {\n\t\t\tif (!comparePayloads(aItem, bItem)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Asserts against a boolean condition. Throws an Error if the assertion failed. Will run and throw in release builds.\n * Use when violations are logic errors in the program.\n * @param condition - A condition to assert is truthy\n * @param message - Message to be printed if assertion fails. Will print \"Assertion failed\" by default\n * @param containsPII - boolean flag for whether the message passed in contains personally identifying information (PII).\n */\nexport function assert(condition: unknown, message?: string, containsPII = false): asserts condition {\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (!condition) {\n\t\tfail(message, containsPII);\n\t}\n}\n\n/**\n * Fails an assertion. Throws an Error that the assertion failed.\n * Use when violations are logic errors in the program.\n * @param message - Message to be printed if assertion fails. Will print \"Assertion failed\" by default\n * @param containsPII - boolean flag for whether the message passed in contains personally identifying information (PII).\n */\nexport function fail(message: string = defaultFailMessage, containsPII = false): never {\n\tif (process.env.NODE_ENV !== 'production') {\n\t\t// eslint-disable-next-line no-debugger\n\t\tdebugger;\n\t\tconsole.error(message);\n\t}\n\n\tthrow new SharedTreeAssertionError(containsPII ? 'Assertion failed' : message);\n}\n\n/**\n * Asserts a value is not undefined, and returns the value.\n * Use when violations are logic errors in the program.\n * @param value - Value to assert against is non undefined.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertNotUndefined<T>(value: T | undefined, message = 'value must not be undefined'): T {\n\tassert(value !== undefined, message);\n\treturn value;\n}\n\n/**\n * Asserts an array contains a single value and returns the value.\n * @param array - array to assert contains a single value.\n * @param message - Message to be printed if assertion fails.\n */\nexport function assertArrayOfOne<T>(array: readonly T[], message = 'array value must contain exactly one item'): T {\n\tassert(array.length === 1, message);\n\treturn array[0];\n}\n\n/**\n * Redefine a property to have the given value. This is simply a type-safe wrapper around\n * `Object.defineProperty`, but it is useful for caching public getters on first read.\n * @example\n * ```\n * // `randomOnce()` will return a random number, but always the same random number.\n * {\n * get randomOnce(): number {\n * return memoizeGetter(this, 'randomOnce', random(100))\n * }\n * }\n * ```\n * @param object - the object containing the property\n * @param propName - the name of the property on the object\n * @param value - the value of the property\n */\nexport function memoizeGetter<T, K extends keyof T>(object: T, propName: K, value: T[K]): T[K] {\n\tObject.defineProperty(object, propName, {\n\t\tvalue,\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t});\n\n\treturn value;\n}\n\n/**\n * Iterate through two iterables and return true if they yield equivalent elements in the same order.\n * @param iterableA - the first iterable to compare\n * @param iterableB - the second iterable to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nexport function compareIterables<T>(\n\titerableA: Iterable<T>,\n\titerableB: Iterable<T>,\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\treturn compareIterators<T>(iterableA[Symbol.iterator](), iterableB[Symbol.iterator](), elementComparator);\n}\n\n/**\n * Iterate through two iterators and return true if they yield equivalent elements in the same order.\n * @param iteratorA - the first iterator to compare\n * @param iteratorB - the second iterator to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nfunction compareIterators<T, TReturn extends T = T>(\n\titeratorA: Iterator<T, TReturn>,\n\titeratorB: Iterator<T, TReturn>,\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\tlet a: IteratorResult<T, TReturn>;\n\tlet b: IteratorResult<T, TReturn>;\n\tfor (\n\t\ta = iteratorA.next(), b = iteratorB.next(); // Given two iterators...\n\t\ta.done !== true && b.done !== true; // ...while both have elements remaining...\n\t\ta = iteratorA.next(), b = iteratorB.next() // ...take one element at a time from each...\n\t) {\n\t\t// ...and ensure that their elements are equivalent\n\t\tif (!elementComparator(a.value, b.value)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// If one iterator is done, but not the other, then they are not equivalent\n\treturn a.done === b.done;\n}\n\n/**\n * Compare two arrays and return true if their elements are equivalent and in the same order.\n * @param arrayA - the first array to compare\n * @param arrayB - the second array to compare\n * @param elementComparator - the function used to check if two `T`s are equivalent.\n * Defaults to `Object.is()` equality (a shallow compare)\n */\nexport function compareArrays<T>(\n\tarrayA: readonly T[],\n\tarrayB: readonly T[],\n\telementComparator: (a: T, b: T) => boolean = Object.is\n): boolean {\n\tif (arrayA.length !== arrayB.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < arrayA.length; i++) {\n\t\tif (!elementComparator(arrayA[i], arrayB[i])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Function which does nothing (no-ops).\n */\nexport function noop(): void {\n\t// noop\n}\n\n/**\n * Copies a property in such a way that it is only set on `destination` if it is present on `source`.\n * This avoids having explicit undefined values under properties that would cause `Object.hasOwnProperty` to return true.\n */\nexport function copyPropertyIfDefined<TSrc, TDst>(source: TSrc, destination: TDst, property: keyof TSrc): void {\n\tconst value = source[property];\n\tif (value !== undefined) {\n\t\t(destination as any)[property] = value;\n\t}\n}\n\n/**\n * A developer facing (non-localized) error message.\n * TODO: better error system.\n */\nexport type ErrorString = string;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Forest.d.ts","sourceRoot":"","sources":["../src/Forest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAOnD;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;CAC5D;AAMD;;GAEG;AACH,MA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M,GAAG,UAAU,GAAG,SAAS;IAIjD;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM;IAYrE,OAAO,CAAC,eAAe;IA4BvB;;;OAGG;IACI,gBAAgB,IAAI,IAAI;IAmC/B;;OAEG;IACI,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAYxC;;OAEG;IACI,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAgBvD,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAIhC;;;;;OAKG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAwBtC;;;;;OAKG;IACI,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;CAwB3C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAwChF"}
package/dist/Forest.js CHANGED
@@ -188,7 +188,6 @@ class Forest {
188
188
  Common_1.assert(node, 'can not replace payload for node that does not exist');
189
189
  const mutableNodes = this.nodes.clone();
190
190
  const newNode = Object.assign({}, node);
191
- /* eslint-disable-next-line no-null/no-null */
192
191
  if (value !== null) {
193
192
  newNode.payload = value;
194
193
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Forest.js","sourceRoot":"","sources":["../src/Forest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,gEAAiC;AACjC,qCAAgF;AAGhF,2DAAqD;AAgDrD;;;GAGG;AACH,MAAa,MAAM;IAuBlB,YAAoB,IAA4B;QAC/C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YACxB,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;SACpD;aAAM;YACN,IAAI,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AAC,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, comparePayloads, copyPropertyIfDefined } from './Common';\nimport { NodeData, Payload } from './generic';\nimport { NodeId, TraitLabel } from './Identifiers';\nimport { compareStrings } from './SnapshotUtilities';\n\ntype Optional<T> = {\n\t[P in keyof T]: T[P] | undefined;\n};\n\n/**\n * A node that can be contained within a Forest.\n */\nexport interface ForestNode extends NodeData {\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\n}\n\ninterface ForestNodeWithParentage extends ForestNode, Optional<ParentData> {\n\treadonly _brand: unique symbol;\n}\n\n/**\n * Information about a ForestNode's parent\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, ForestNodeWithParentage>;\n\texpensiveValidation: boolean;\n}\n\n/**\n * An immutable forest of ForestNode.\n * Enforces single parenting, and allows querying the parent.\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, ForestNodeWithParentage>;\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, ForestNodeWithParentage>(undefined, compareStrings);\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 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.\n\t */\n\tpublic add(nodes: Iterable<ForestNode>): Forest {\n\t\tconst newNodes = [...nodes];\n\t\tconst childToParent = new Map<NodeId, ParentData>();\n\t\tconst mutableNodes = this.nodes.clone();\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\tassert(child.parentId === undefined, 'can not give a child multiple parents');\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\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\tmutableNodes.set(childId, parentedChild as ForestNodeWithParentage);\n\t\t\t\t\t} else {\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\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// A parent and child have both been added for the first time\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 as ForestNodeWithParentage);\n\t\t\t} else {\n\t\t\t\t// A root node (no parent) has been added to the forest\n\t\t\t\tmutableNodes.set(node.identifier, node as ForestNodeWithParentage);\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(n.parentId === undefined, 'can not attach node that already has a parent');\n\t\t\t\tconst breakVal: { value: ForestNodeWithParentage } = {\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: ForestNodeWithParentage } = {\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\t...n,\n\t\t\t\t\t\tparentId: undefined,\n\t\t\t\t\t\ttraitParent: undefined,\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 {\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\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\t/* eslint-disable-next-line no-null/no-null */\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 as ForestNodeWithParentage);\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 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(\n\t\tmutableNodes: BTree<NodeId, ForestNodeWithParentage>,\n\t\tid: NodeId,\n\t\tdeleteChildren: boolean\n\t): void {\n\t\tconst node = mutableNodes.get(id) ?? fail('node to delete must exist');\n\t\tassert(node.parentId === undefined && node.traitParent === undefined, '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: ForestNodeWithParentage } = {\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t...n,\n\t\t\t\t\t\t\tparentId: undefined,\n\t\t\t\t\t\t\ttraitParent: undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\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\tassert(\n\t\t\t\t(node.parentId === undefined) === (node.traitParent === undefined),\n\t\t\t\t'node must have either both parent and traitParent set or neither'\n\t\t\t);\n\n\t\t\tif (node.parentId !== undefined && node.traitParent !== undefined) {\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(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\treturn {\n\t\t\tparentId: child.parentId ?? fail('Node is not parented'),\n\t\t\ttraitParent: child.traitParent ?? fail('Node is not parented'),\n\t\t};\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) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (child.parentId === undefined || child.traitParent === undefined) {\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\tprivate static breakOnDifference(): { break: boolean } {\n\t\treturn { break: true };\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\tconst diff = this.nodes.diffAgainst(\n\t\t\tforest.nodes,\n\t\t\tForest.breakOnDifference,\n\t\t\tForest.breakOnDifference,\n\t\t\t(_, nodeThis, nodeOther) => {\n\t\t\t\tif (!compareForestNodes(nodeThis, nodeOther)) {\n\t\t\t\t\treturn { break: true };\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t);\n\n\t\treturn diff === undefined;\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 `SnapshotNodes` 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,qCAAgF;AAGhF,2DAAqD;AAgDrD;;;GAGG;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ACpD,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, comparePayloads, copyPropertyIfDefined } from './Common';\nimport { NodeData, Payload } from './generic';\nimport { NodeId, TraitLabel } from './Identifiers';\nimport { compareStrings } from './SnapshotUtilities';\n\ntype Optional<T> = {\n\t[P in keyof T]: T[P] | undefined;\n};\n\n/**\n * A node that can be contained within a Forest.\n */\nexport interface ForestNode extends NodeData {\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\n}\n\ninterface ForestNodeWithParentage extends ForestNode, Optional<ParentData> {\n\treadonly _brand: unique symbol;\n}\n\n/**\n * Information about a ForestNode's parent\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, ForestNodeWithParentage>;\n\texpensiveValidation: boolean;\n}\n\n/**\n * An immutable forest of ForestNode.\n * Enforces single parenting, and allows querying the parent.\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, ForestNodeWithParentage>;\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, ForestNodeWithParentage>(undefined, compareStrings);\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 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.\n\t */\n\tpublic add(nodes: Iterable<ForestNode>): Forest {\n\t\tconst newNodes = [...nodes];\n\t\tconst childToParent = new Map<NodeId, ParentData>();\n\t\tconst mutableNodes = this.nodes.clone();\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\tassert(child.parentId === undefined, 'can not give a child multiple parents');\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\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\tmutableNodes.set(childId, parentedChild as ForestNodeWithParentage);\n\t\t\t\t\t} else {\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\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// A parent and child have both been added for the first time\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 as ForestNodeWithParentage);\n\t\t\t} else {\n\t\t\t\t// A root node (no parent) has been added to the forest\n\t\t\t\tmutableNodes.set(node.identifier, node as ForestNodeWithParentage);\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(n.parentId === undefined, 'can not attach node that already has a parent');\n\t\t\t\tconst breakVal: { value: ForestNodeWithParentage } = {\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: ForestNodeWithParentage } = {\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\t...n,\n\t\t\t\t\t\tparentId: undefined,\n\t\t\t\t\t\ttraitParent: undefined,\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 {\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\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 as ForestNodeWithParentage);\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 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(\n\t\tmutableNodes: BTree<NodeId, ForestNodeWithParentage>,\n\t\tid: NodeId,\n\t\tdeleteChildren: boolean\n\t): void {\n\t\tconst node = mutableNodes.get(id) ?? fail('node to delete must exist');\n\t\tassert(node.parentId === undefined && node.traitParent === undefined, '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: ForestNodeWithParentage } = {\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t...n,\n\t\t\t\t\t\t\tparentId: undefined,\n\t\t\t\t\t\t\ttraitParent: undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\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\tassert(\n\t\t\t\t(node.parentId === undefined) === (node.traitParent === undefined),\n\t\t\t\t'node must have either both parent and traitParent set or neither'\n\t\t\t);\n\n\t\t\tif (node.parentId !== undefined && node.traitParent !== undefined) {\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(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\treturn {\n\t\t\tparentId: child.parentId ?? fail('Node is not parented'),\n\t\t\ttraitParent: child.traitParent ?? fail('Node is not parented'),\n\t\t};\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) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (child.parentId === undefined || child.traitParent === undefined) {\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\tprivate static breakOnDifference(): { break: boolean } {\n\t\treturn { break: true };\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\tconst diff = this.nodes.diffAgainst(\n\t\t\tforest.nodes,\n\t\t\tForest.breakOnDifference,\n\t\t\tForest.breakOnDifference,\n\t\t\t(_, nodeThis, nodeOther) => {\n\t\t\t\tif (!compareForestNodes(nodeThis, nodeOther)) {\n\t\t\t\t\treturn { break: true };\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t);\n\n\t\treturn diff === undefined;\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 `SnapshotNodes` 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 +1 @@
1
- {"version":3,"file":"RevisionValueCache.d.ts","sourceRoot":"","sources":["../src/RevisionValueCache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC;;;;;;;;GAQG;AACH,qBAAa,kBAAkB,CAAC,MAAM;IAyBpC;;;OAGG;IAGH,OAAO,CAAC,oBAAoB;IA9B7B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgE;IAE9F;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAwB;IAE3D;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAuB;;IAGxD;;OAEG;IACH,aAAa,EAAE,MAAM;IACrB;;;OAGG;IAGK,oBAAoB,EAAE,QAAQ;IACtC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;IAqBvC;;OAEG;IACI,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAI3D;;;OAGG;IACI,qBAAqB,CAAC,uBAAuB,EAAE,QAAQ,GAAG,IAAI;IAwBrE;;OAEG;IACI,eAAe,CAAC,iBAAiB,EAAE,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS;IAQpG;;OAEG;IACI,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlE;;;;;;OAMG;IACI,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAS1D"}
1
+ {"version":3,"file":"RevisionValueCache.d.ts","sourceRoot":"","sources":["../src/RevisionValueCache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC;;;;;;;;GAQG;AACH,qBAAa,kBAAkB,CAAC,MAAM;IAyBpC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA5B7B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgE;IAE9F;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAwB;IAE3D;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAuB;;IAGxD;;OAEG;IACH,aAAa,EAAE,MAAM;IACrB;;;OAGG;IACK,oBAAoB,EAAE,QAAQ;IACtC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;IAqBvC;;OAEG;IACI,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAI3D;;;OAGG;IACI,qBAAqB,CAAC,uBAAuB,EAAE,QAAQ,GAAG,IAAI;IAwBrE;;OAEG;IACI,eAAe,CAAC,iBAAiB,EAAE,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS;IAQpG;;OAEG;IACI,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlE;;;;;;OAMG;IACI,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAS1D"}
@@ -31,8 +31,6 @@ class RevisionValueCache {
31
31
  * The first revision within the retention window. All entries with revisions >= retentionWindowStart will be retained.
32
32
  * Must be >= 0.
33
33
  */
34
- // False positive
35
- // eslint-disable-next-line @typescript-eslint/prefer-readonly
36
34
  retentionWindowStart,
37
35
  /**
38
36
  * Optional list of entries to permanently retain.
@@ -1 +1 @@
1
- {"version":3,"file":"RevisionValueCache.js","sourceRoot":"","sources":["../src/RevisionValueCache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,gEAAiC;AACjC,0DAA4B;AAC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,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,QAAkB,EAAE,KAAa;QAClD,IAAI,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACzC,OAAO;SACP;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,QAAQ,GAAG,IAAI,CAAC,oBAAoB,EAAE;YACzC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SAC7C;IACF,CAAC;CACD;AA9HD,gDA8HC","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 LRU from 'lru-cache';\nimport { assert, fail } from './Common';\nimport { Revision } from './LogViewer';\nimport { compareFiniteNumbers } from './SnapshotUtilities';\n\n/**\n * A cache of `TValue`s corresponding to `Revision`s.\n *\n * A value is kept in cache if it meets any of the following criteria:\n * - The revision is >= `retentionWindowStart`\n * - The value has been used recently, meaning getClosestEntry or cacheValue was called with its revision. Note that being returned\n * \t\twhen a large revision was passed to getClosestEntry does not count.\n * - The value is `retained` meaning it was provided to to constructor in retainedEntries or passed to `cacheRetainedValue`\n */\nexport class RevisionValueCache<TValue> {\n\t/**\n\t * A cache of entries for revisions.\n\t * This is sorted to allow efficient access to the nearest preceding entry (see getClosestEntry).\n\t * Contains all cached values, regardless of why they are cached (retained, LRU or window).\n\t */\n\tprivate readonly sortedEntries = new BTree<Revision, TValue>(undefined, compareFiniteNumbers);\n\n\t/**\n\t * Least recently used cache of evictable entries.\n\t * Subset of 'sortedValues` eligible for eviction:\n\t * All entries are also in `sortedValues`, and are removed from `sortedValues` when evicted from this cache.\n\t */\n\tprivate readonly evictableRevisions: LRU<Revision, TValue>;\n\n\t/**\n\t * Set of all revisions that should never be evicted.\n\t */\n\tprivate readonly retainedRevisions = new Set<Revision>();\n\n\tpublic constructor(\n\t\t/**\n\t\t * Maximum capacity for evictable cache entries (those neither marked as retained nor within the retention window).\n\t\t */\n\t\tevictableSize: number,\n\t\t/**\n\t\t * The first revision within the retention window. All entries with revisions >= retentionWindowStart will be retained.\n\t\t * Must be >= 0.\n\t\t */\n\t\t// False positive\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-readonly\n\t\tprivate retentionWindowStart: Revision,\n\t\t/**\n\t\t * Optional list of entries to permanently retain.\n\t\t */\n\t\tretainedEntries?: [Revision, TValue][]\n\t) {\n\t\tassert(retentionWindowStart >= 0, 'retentionWindowStart must be initialized >= 0');\n\t\tthis.evictableRevisions = new LRU({\n\t\t\tmax: evictableSize,\n\t\t\tnoDisposeOnSet: true,\n\t\t\tdispose: (revision) => {\n\t\t\t\tif (revision >= this.retentionWindowStart) {\n\t\t\t\t\tfail('Entries in retention window should never be evicted.');\n\t\t\t\t}\n\t\t\t\tif (this.retainedRevisions.has(revision)) {\n\t\t\t\t\tfail('Retained entries should not be evicted');\n\t\t\t\t}\n\t\t\t\tthis.sortedEntries.delete(revision);\n\t\t\t},\n\t\t});\n\t\tif (retainedEntries !== undefined) {\n\t\t\tretainedEntries.forEach(([revision, entry]) => this.cacheRetainedValue(revision, entry));\n\t\t}\n\t}\n\n\t/**\n\t * @returns if the supplied revision is within the retention window.\n\t */\n\tpublic isWithinRetentionWindow(revision: Revision): boolean {\n\t\treturn revision >= this.retentionWindowStart;\n\t}\n\n\t/**\n\t * Sets the new retention window.\n\t * @param newRetentionWindowStart - defines the trailing edge (inclusive) of the new retention window.\n\t */\n\tpublic updateRetentionWindow(newRetentionWindowStart: Revision): void {\n\t\tif (newRetentionWindowStart < this.retentionWindowStart) {\n\t\t\tfail('retention window boundary must not move backwards');\n\t\t}\n\t\tconst prevRetentionWindowStart = this.retentionWindowStart;\n\t\tthis.retentionWindowStart = newRetentionWindowStart;\n\t\tconst oldWindowEntries: [Revision, TValue][] = [];\n\t\tthis.sortedEntries.forRange(\n\t\t\tprevRetentionWindowStart,\n\t\t\tthis.retentionWindowStart,\n\t\t\tfalse,\n\t\t\t(windowRevision, windowEntry) => {\n\t\t\t\tif (!this.retainedRevisions.has(windowRevision)) {\n\t\t\t\t\t// Adding to the LRU can cause eviction which in turn mutates the b-tree we are enumerating. Thus, store list of\n\t\t\t\t\t// old window entries separately.\n\t\t\t\t\toldWindowEntries.push([windowRevision, windowEntry]);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\toldWindowEntries.forEach(([revision, value]) => {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t});\n\t}\n\n\t/**\n\t * @returns a [cachedRevision, value] where cachedRevision <= requestedRevision, or undefined if no such revision is cached.\n\t */\n\tpublic getClosestEntry(requestedRevision: Revision): [revision: Revision, value: TValue] | undefined {\n\t\tconst fromLRU = this.evictableRevisions.get(requestedRevision);\n\t\tif (fromLRU !== undefined) {\n\t\t\treturn [requestedRevision, fromLRU];\n\t\t}\n\t\treturn this.sortedEntries.nextLowerPair(requestedRevision + 1) ?? undefined;\n\t}\n\n\t/**\n\t * Caches the supplied value and guarantees it will never be evicted.\n\t */\n\tpublic cacheRetainedValue(revision: Revision, value: TValue): void {\n\t\tthis.retainedRevisions.add(revision);\n\t\tthis.sortedEntries.set(revision, value);\n\t}\n\n\t/**\n\t * Caches the supplied value.\n\t * The cached value is subject to eviction unless it is within the retention window or was previously added\n\t * via `cacheRetainedValue`.\n\t * Note that if a non-retained entry starts out within the retention window and passes outside of it due to a call to\n\t * updateRetentionWindow it is then subject to eviction.\n\t */\n\tpublic cacheValue(revision: Revision, value: TValue): void {\n\t\tif (this.retainedRevisions.has(revision)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.sortedEntries.set(revision, value);\n\t\tif (revision < this.retentionWindowStart) {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"R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a;QAC1D,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,QAAkB,EAAE,KAAa;QAClD,IAAI,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACzC,OAAO;SACP;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,QAAQ,GAAG,IAAI,CAAC,oBAAoB,EAAE;YACzC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SAC7C;IACF,CAAC;CACD;AA5HD,gDA4HC","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 LRU from 'lru-cache';\nimport { assert, fail } from './Common';\nimport { Revision } from './LogViewer';\nimport { compareFiniteNumbers } from './SnapshotUtilities';\n\n/**\n * A cache of `TValue`s corresponding to `Revision`s.\n *\n * A value is kept in cache if it meets any of the following criteria:\n * - The revision is >= `retentionWindowStart`\n * - The value has been used recently, meaning getClosestEntry or cacheValue was called with its revision. Note that being returned\n * \t\twhen a large revision was passed to getClosestEntry does not count.\n * - The value is `retained` meaning it was provided to to constructor in retainedEntries or passed to `cacheRetainedValue`\n */\nexport class RevisionValueCache<TValue> {\n\t/**\n\t * A cache of entries for revisions.\n\t * This is sorted to allow efficient access to the nearest preceding entry (see getClosestEntry).\n\t * Contains all cached values, regardless of why they are cached (retained, LRU or window).\n\t */\n\tprivate readonly sortedEntries = new BTree<Revision, TValue>(undefined, compareFiniteNumbers);\n\n\t/**\n\t * Least recently used cache of evictable entries.\n\t * Subset of 'sortedValues` eligible for eviction:\n\t * All entries are also in `sortedValues`, and are removed from `sortedValues` when evicted from this cache.\n\t */\n\tprivate readonly evictableRevisions: LRU<Revision, TValue>;\n\n\t/**\n\t * Set of all revisions that should never be evicted.\n\t */\n\tprivate readonly retainedRevisions = new Set<Revision>();\n\n\tpublic constructor(\n\t\t/**\n\t\t * Maximum capacity for evictable cache entries (those neither marked as retained nor within the retention window).\n\t\t */\n\t\tevictableSize: number,\n\t\t/**\n\t\t * The first revision within the retention window. All entries with revisions >= retentionWindowStart will be retained.\n\t\t * Must be >= 0.\n\t\t */\n\t\tprivate retentionWindowStart: Revision,\n\t\t/**\n\t\t * Optional list of entries to permanently retain.\n\t\t */\n\t\tretainedEntries?: [Revision, TValue][]\n\t) {\n\t\tassert(retentionWindowStart >= 0, 'retentionWindowStart must be initialized >= 0');\n\t\tthis.evictableRevisions = new LRU({\n\t\t\tmax: evictableSize,\n\t\t\tnoDisposeOnSet: true,\n\t\t\tdispose: (revision) => {\n\t\t\t\tif (revision >= this.retentionWindowStart) {\n\t\t\t\t\tfail('Entries in retention window should never be evicted.');\n\t\t\t\t}\n\t\t\t\tif (this.retainedRevisions.has(revision)) {\n\t\t\t\t\tfail('Retained entries should not be evicted');\n\t\t\t\t}\n\t\t\t\tthis.sortedEntries.delete(revision);\n\t\t\t},\n\t\t});\n\t\tif (retainedEntries !== undefined) {\n\t\t\tretainedEntries.forEach(([revision, entry]) => this.cacheRetainedValue(revision, entry));\n\t\t}\n\t}\n\n\t/**\n\t * @returns if the supplied revision is within the retention window.\n\t */\n\tpublic isWithinRetentionWindow(revision: Revision): boolean {\n\t\treturn revision >= this.retentionWindowStart;\n\t}\n\n\t/**\n\t * Sets the new retention window.\n\t * @param newRetentionWindowStart - defines the trailing edge (inclusive) of the new retention window.\n\t */\n\tpublic updateRetentionWindow(newRetentionWindowStart: Revision): void {\n\t\tif (newRetentionWindowStart < this.retentionWindowStart) {\n\t\t\tfail('retention window boundary must not move backwards');\n\t\t}\n\t\tconst prevRetentionWindowStart = this.retentionWindowStart;\n\t\tthis.retentionWindowStart = newRetentionWindowStart;\n\t\tconst oldWindowEntries: [Revision, TValue][] = [];\n\t\tthis.sortedEntries.forRange(\n\t\t\tprevRetentionWindowStart,\n\t\t\tthis.retentionWindowStart,\n\t\t\tfalse,\n\t\t\t(windowRevision, windowEntry) => {\n\t\t\t\tif (!this.retainedRevisions.has(windowRevision)) {\n\t\t\t\t\t// Adding to the LRU can cause eviction which in turn mutates the b-tree we are enumerating. Thus, store list of\n\t\t\t\t\t// old window entries separately.\n\t\t\t\t\toldWindowEntries.push([windowRevision, windowEntry]);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\toldWindowEntries.forEach(([revision, value]) => {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t});\n\t}\n\n\t/**\n\t * @returns a [cachedRevision, value] where cachedRevision <= requestedRevision, or undefined if no such revision is cached.\n\t */\n\tpublic getClosestEntry(requestedRevision: Revision): [revision: Revision, value: TValue] | undefined {\n\t\tconst fromLRU = this.evictableRevisions.get(requestedRevision);\n\t\tif (fromLRU !== undefined) {\n\t\t\treturn [requestedRevision, fromLRU];\n\t\t}\n\t\treturn this.sortedEntries.nextLowerPair(requestedRevision + 1) ?? undefined;\n\t}\n\n\t/**\n\t * Caches the supplied value and guarantees it will never be evicted.\n\t */\n\tpublic cacheRetainedValue(revision: Revision, value: TValue): void {\n\t\tthis.retainedRevisions.add(revision);\n\t\tthis.sortedEntries.set(revision, value);\n\t}\n\n\t/**\n\t * Caches the supplied value.\n\t * The cached value is subject to eviction unless it is within the retention window or was previously added\n\t * via `cacheRetainedValue`.\n\t * Note that if a non-retained entry starts out within the retention window and passes outside of it due to a call to\n\t * updateRetentionWindow it is then subject to eviction.\n\t */\n\tpublic cacheValue(revision: Revision, value: TValue): void {\n\t\tif (this.retainedRevisions.has(revision)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.sortedEntries.set(revision, value);\n\t\tif (revision < this.retentionWindowStart) {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t}\n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,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;CACD;AArQD,4BAqQC;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 { getChangeNodeFromSnapshot } from './SnapshotUtilities';\nimport { Delta, Forest } from './Forest';\nimport { ChangeNode, NodeData, Payload, TraitLocation } from './generic';\n\n/**\n * An immutable view of a distributed tree node.\n * @public\n */\nexport interface SnapshotNode extends NodeData {\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\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 `Snapshot` 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 SnapshotPlace {\n\treadonly sibling?: NodeId;\n\treadonly side: Side;\n\treadonly trait: TraitLocation;\n}\n\n/**\n * Defines a place relative to sibling.\n * The \"outside\" of a trait is the `undefined` sibling,\n * so After `undefined` is the beginning of the trait, and before `undefined` is the end.\n *\n * For this purpose, traits look like:\n *\n * `{undefined} - {Node 0} - {Node 1} - ... - {Node N} - {undefined}`\n *\n * Each `{value}` in the diagram is a possible sibling, which is either a Node or undefined.\n * Each `-` in the above diagram is a `Place`, and can be describe as being `After` a particular `{sibling}` or `Before` it.\n * This means that `After` `{undefined}` means the same `Place` as before the first node\n * and `Before` `{undefined}` means the `Place` after the last Node.\n *\n * Each place can be specified, (aka 'anchored') in two ways (relative to the sibling before or after):\n * the choice of which way to anchor a place only matters when the kept across an edit, and thus evaluated in multiple contexts where the\n * two place description may no longer evaluate to the same place.\n * @public\n */\nexport enum Side {\n\tBefore = 0,\n\tAfter = 1,\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait within a particular `Snapshot`.\n * Valid iff start and end are valid and are withing the same trait.\n * @public\n */\nexport interface SnapshotRange {\n\treadonly start: SnapshotPlace;\n\treadonly end: SnapshotPlace;\n}\n\n/**\n * An immutable view of a distributed tree.\n * @public\n */\nexport class Snapshot {\n\tpublic readonly root: NodeId;\n\tprivate readonly forest: Forest;\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 snapshots; initialized to empty each time a Snapshot is created.\n\t */\n\tprivate traitIndicesCache?: Map<NodeId, TraitNodeIndex>;\n\n\t/**\n\t * Constructs a Snapshot using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the `Snapshot`\n\t */\n\tpublic static fromTree(root: ChangeNode, expensiveValidation = false): Snapshot {\n\t\tfunction insertNodeRecursive(node: ChangeNode, newSnapshotNodes: Map<NodeId, SnapshotNode>): NodeId {\n\t\t\tconst { identifier, definition } = node;\n\t\t\tconst traits: Map<TraitLabel, readonly NodeId[]> = new Map();\n\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\tfor (const key in node.traits) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(node.traits, key)) {\n\t\t\t\t\tconst element = node.traits[key];\n\t\t\t\t\tif (element.length > 0) {\n\t\t\t\t\t\ttraits.set(\n\t\t\t\t\t\t\tkey as TraitLabel,\n\t\t\t\t\t\t\telement.map((n) => insertNodeRecursive(n, newSnapshotNodes))\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst snapshotNode: SnapshotNode = { identifier, definition, traits };\n\t\t\tcopyPropertyIfDefined(node, snapshotNode, 'payload');\n\t\t\tassert(\n\t\t\t\t!newSnapshotNodes.has(identifier),\n\t\t\t\t`duplicate node in tree for snapshot: { identifier: ${identifier}, definition: ${definition}`\n\t\t\t);\n\t\t\tnewSnapshotNodes.set(snapshotNode.identifier, snapshotNode);\n\t\t\treturn snapshotNode.identifier;\n\t\t}\n\n\t\tconst map = new Map<NodeId, SnapshotNode>();\n\t\treturn new Snapshot(insertNodeRecursive(root, map), Forest.create(expensiveValidation).add(map.values()));\n\t}\n\n\tprivate constructor(root: NodeId, forest: Forest) {\n\t\tthis.root = root;\n\t\tthis.forest = forest;\n\t}\n\n\t/** Return a tree of JSON-compatible `ChangeNode`s representing the current state of this `Snapshot` */\n\tpublic getChangeNodeTree(): ChangeNode {\n\t\treturn getChangeNodeFromSnapshot(this, this.root);\n\t}\n\n\t/**\n\t * Returns the number of nodes in this `Snapshot`\n\t */\n\tpublic get size(): number {\n\t\treturn this.forest.size;\n\t}\n\n\t/**\n\t * @returns true iff the nodeId exists.\n\t */\n\tpublic hasNode(id: NodeId): boolean {\n\t\treturn this.forest.tryGet(id) !== undefined;\n\t}\n\n\t/**\n\t * @returns a `ChangeNode` derived from the `SnapshotNode` in this snapshot with the given `NodeId`.\n\t */\n\tpublic getChangeNode(id: NodeId): ChangeNode {\n\t\treturn getChangeNodeFromSnapshot(this, id);\n\t}\n\n\t/**\n\t * @returns the `ChangeNode`s derived from the `SnapshotNode`s in this snapshot with the given `NodeId`s.\n\t */\n\tpublic getChangeNodes(nodeIds: readonly NodeId[]): ChangeNode[] {\n\t\treturn nodeIds.map((id) => this.getChangeNode(id));\n\t}\n\n\t/**\n\t * Asserts the forest is in a consistent state.\n\t */\n\tpublic assertConsistent(): void {\n\t\tthis.forest.assertConsistent();\n\t}\n\n\t/**\n\t * Inserts all nodes in a NodeSequence into the forest.\n\t */\n\tpublic addNodes(sequence: Iterable<SnapshotNode>): Snapshot {\n\t\treturn new Snapshot(this.root, this.forest.add(sequence));\n\t}\n\n\t/**\n\t * Remove all nodes with the given ids from the forest\n\t */\n\tpublic deleteNodes(nodes: Iterable<NodeId>): Snapshot {\n\t\treturn new Snapshot(this.root, this.forest.delete(nodes, true));\n\t}\n\n\t/**\n\t * Parents a set of detached nodes at a specified place.\n\t * @param nodesToAttach - the nodes to parent in the specified place. The nodes must already be present in the Snapshot.\n\t * @param place - the location to insert the nodes.\n\t */\n\tpublic attachRange(nodesToAttach: readonly NodeId[], place: SnapshotPlace): Snapshot {\n\t\tconst { parent, label } = place.trait;\n\t\tconst index = this.findIndexWithinTrait(place);\n\t\treturn new Snapshot(this.root, this.forest.attachRangeOfChildren(parent, label, index, nodesToAttach));\n\t}\n\n\t/**\n\t * Detaches a range of nodes from their parent. The detached nodes remain in the Snapshot.\n\t * @param rangeToDetach - the range of nodes to detach\n\t */\n\tpublic detachRange(rangeToDetach: SnapshotRange): { snapshot: Snapshot; detached: readonly NodeId[] } {\n\t\tconst { start, end } = rangeToDetach;\n\t\tconst { trait: traitLocation } = start;\n\t\tconst { parent, label } = traitLocation;\n\t\tconst startIndex = this.findIndexWithinTrait(start);\n\t\tconst endIndex = this.findIndexWithinTrait(end);\n\t\tconst { forest, detached } = this.forest.detachRangeOfChildren(parent, label, startIndex, endIndex);\n\t\treturn { snapshot: new Snapshot(this.root, forest), detached };\n\t}\n\n\t/**\n\t * Sets a node's value. The node must exist in this `Snapshot`.\n\t * @param nodeId - the id of the node\n\t * @param value - the new value\n\t */\n\tpublic setNodeValue(nodeId: NodeId, value: Payload): Snapshot {\n\t\treturn new Snapshot(this.root, this.forest.setValue(nodeId, value));\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: SnapshotPlace): 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/**\n\t * Returns the node associated with `id` in this `Snapshot`.\n\t */\n\tpublic getSnapshotNode(id: NodeId): SnapshotNode {\n\t\treturn this.forest.get(id);\n\t}\n\n\t/**\n\t * Returns the label of the trait that a node is under. Returns undefined if the node is not present or if it is the root node.\n\t */\n\tpublic getTraitLabel(id: NodeId): TraitLabel | undefined {\n\t\treturn this.forest.tryGetParent(id)?.traitParent;\n\t}\n\n\t/**\n\t * Returns the parent of a node. Returns undefined if the node does not exist in the snapshot or if it does not have a parent.\n\t */\n\tpublic getParentSnapshotNode(id: NodeId): SnapshotNode | 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.getSnapshotNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @param node - must have a parent.\n\t */\n\tpublic getTraitLocation(node: NodeId): TraitLocation {\n\t\tconst parentData = this.forest.getParent(node);\n\t\tassert(parentData !== undefined, 'node must have parent');\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 * @param node - must have a parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic getIndexInTrait(node: NodeId): TraitNodeIndex {\n\t\tif (this.traitIndicesCache === undefined) {\n\t\t\tthis.traitIndicesCache = new Map();\n\t\t} else {\n\t\t\tconst cached = this.traitIndicesCache.get(node);\n\t\t\tif (cached !== undefined) {\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t}\n\t\tconst parentData = this.forest.getParent(node);\n\t\tconst parent = this.forest.get(parentData.parentId);\n\t\tconst traitParent =\n\t\t\tparent.traits.get(parentData.traitParent) ?? fail('invalid parentData: trait parent not found.');\n\t\tlet foundIndex = -1 as TraitNodeIndex;\n\t\tfor (let i = 0; i < traitParent.length; i++) {\n\t\t\tconst nodeInTrait = traitParent[i];\n\t\t\tconst index = i as TraitNodeIndex;\n\t\t\tthis.traitIndicesCache.set(nodeInTrait, index);\n\t\t\tif (nodeInTrait === node) {\n\t\t\t\tfoundIndex = index;\n\t\t\t}\n\t\t}\n\t\treturn foundIndex !== -1 ? foundIndex : fail('invalidParentData: node not found in specified trait');\n\t}\n\n\t/**\n\t * Return a trait given its location\n\t * @param traitLocation - the location of the trait\n\t */\n\tpublic getTrait(traitLocation: TraitLocation): readonly NodeId[] {\n\t\treturn this.getSnapshotNode(traitLocation.parent).traits.get(traitLocation.label) ?? [];\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/** Compares this snapshot to another for equality. */\n\tpublic equals(snapshot: Snapshot): boolean {\n\t\tif (this.root !== snapshot.root) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// TODO:#49100:Perf: make this faster and/or remove use by PrefetchingCheckout.\n\t\treturn this.forest.equals(snapshot.forest);\n\t}\n\n\tprivate *iterateNodeDescendants(nodeId: NodeId): IterableIterator<SnapshotNode> {\n\t\tconst node = this.getSnapshotNode(nodeId);\n\t\tyield node;\n\t\tfor (const trait of node.traits.values()) {\n\t\t\tfor (const childId of trait) {\n\t\t\t\tyield* this.iterateNodeDescendants(childId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Calculate the difference between two `Snapshot`s\n\t * @param snapshot - the other snapshot to compare to this one\n\t * @returns A {@link Delta} which nodes must be changed, added, and removed to get from `this` to `snapshot`.\n\t * The snapshots must share a root.\n\t */\n\tpublic delta(snapshot: Snapshot): Delta<NodeId> {\n\t\tassert(this.root === snapshot.root, 'Delta can only be calculated between snapshots that share a root');\n\t\treturn this.forest.delta(snapshot.forest);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<SnapshotNode> {\n\t\treturn this.iterateNodeDescendants(this.root);\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\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"]}
1
+ {"version":3,"file":"Snapshot.js","sourceRoot":"","sources":["../src/Snapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAA+D;AAE/D,2DAAgE;AAChE,qCAAyC;AAwCzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,IAAY,IAGX;AAHD,WAAY,IAAI;IACf,mCAAU,CAAA;IACV,iCAAS,CAAA;AACV,CAAC,EAHW,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAGf;AAYD;;;GAGG;AACH,MAAa,QAAQ;IA8CpB,YAAoB,IAAY,EAAE,MAAc;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAtCD;;;OAGG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAgB,EAAE,mBAAmB,GAAG,KAAK;QACnE,SAAS,mBAAmB,CAAC,IAAgB,EAAE,gBAA2C;YACzF,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;YACxC,MAAM,MAAM,GAAuC,IAAI,GAAG,EAAE,CAAC;YAE7D,gDAAgD;YAChD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC9B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;oBAC3D,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBACjC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;wBACvB,MAAM,CAAC,GAAG,CAC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eAAM,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE,kEAAkE,CAAC,CAAC;QACxG,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;CACD;AAtQD,4BAsQC;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 { getChangeNodeFromSnapshot } from './SnapshotUtilities';\nimport { Delta, Forest } from './Forest';\nimport { ChangeNode, NodeData, Payload, TraitLocation } from './generic';\n\n/**\n * An immutable view of a distributed tree node.\n * @public\n */\nexport interface SnapshotNode extends NodeData {\n\treadonly traits: ReadonlyMap<TraitLabel, readonly NodeId[]>;\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 `Snapshot` 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 SnapshotPlace {\n\treadonly sibling?: NodeId;\n\treadonly side: Side;\n\treadonly trait: TraitLocation;\n}\n\n/**\n * Defines a place relative to sibling.\n * The \"outside\" of a trait is the `undefined` sibling,\n * so After `undefined` is the beginning of the trait, and before `undefined` is the end.\n *\n * For this purpose, traits look like:\n *\n * `{undefined} - {Node 0} - {Node 1} - ... - {Node N} - {undefined}`\n *\n * Each `{value}` in the diagram is a possible sibling, which is either a Node or undefined.\n * Each `-` in the above diagram is a `Place`, and can be describe as being `After` a particular `{sibling}` or `Before` it.\n * This means that `After` `{undefined}` means the same `Place` as before the first node\n * and `Before` `{undefined}` means the `Place` after the last Node.\n *\n * Each place can be specified, (aka 'anchored') in two ways (relative to the sibling before or after):\n * the choice of which way to anchor a place only matters when the kept across an edit, and thus evaluated in multiple contexts where the\n * two place description may no longer evaluate to the same place.\n * @public\n */\nexport enum Side {\n\tBefore = 0,\n\tAfter = 1,\n}\n\n/**\n * Specifies the range of nodes from `start` to `end` within a trait within a particular `Snapshot`.\n * Valid iff start and end are valid and are withing the same trait.\n * @public\n */\nexport interface SnapshotRange {\n\treadonly start: SnapshotPlace;\n\treadonly end: SnapshotPlace;\n}\n\n/**\n * An immutable view of a distributed tree.\n * @public\n */\nexport class Snapshot {\n\tpublic readonly root: NodeId;\n\tprivate readonly forest: Forest;\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 snapshots; initialized to empty each time a Snapshot is created.\n\t */\n\tprivate traitIndicesCache?: Map<NodeId, TraitNodeIndex>;\n\n\t/**\n\t * Constructs a Snapshot using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the `Snapshot`\n\t */\n\tpublic static fromTree(root: ChangeNode, expensiveValidation = false): Snapshot {\n\t\tfunction insertNodeRecursive(node: ChangeNode, newSnapshotNodes: Map<NodeId, SnapshotNode>): NodeId {\n\t\t\tconst { identifier, definition } = node;\n\t\t\tconst traits: Map<TraitLabel, readonly NodeId[]> = new Map();\n\n\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\tfor (const key in node.traits) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(node.traits, key)) {\n\t\t\t\t\tconst element = node.traits[key];\n\t\t\t\t\tif (element.length > 0) {\n\t\t\t\t\t\ttraits.set(\n\t\t\t\t\t\t\tkey as TraitLabel,\n\t\t\t\t\t\t\telement.map((n) => insertNodeRecursive(n, newSnapshotNodes))\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst snapshotNode: SnapshotNode = { identifier, definition, traits };\n\t\t\tcopyPropertyIfDefined(node, snapshotNode, 'payload');\n\t\t\tassert(\n\t\t\t\t!newSnapshotNodes.has(identifier),\n\t\t\t\t`duplicate node in tree for snapshot: { identifier: ${identifier}, definition: ${definition}`\n\t\t\t);\n\t\t\tnewSnapshotNodes.set(snapshotNode.identifier, snapshotNode);\n\t\t\treturn snapshotNode.identifier;\n\t\t}\n\n\t\tconst map = new Map<NodeId, SnapshotNode>();\n\t\treturn new Snapshot(insertNodeRecursive(root, map), Forest.create(expensiveValidation).add(map.values()));\n\t}\n\n\tprivate constructor(root: NodeId, forest: Forest) {\n\t\tthis.root = root;\n\t\tthis.forest = forest;\n\t}\n\n\t/** Return a tree of JSON-compatible `ChangeNode`s representing the current state of this `Snapshot` */\n\tpublic getChangeNodeTree(): ChangeNode {\n\t\treturn getChangeNodeFromSnapshot(this, this.root);\n\t}\n\n\t/**\n\t * Returns the number of nodes in this `Snapshot`\n\t */\n\tpublic get size(): number {\n\t\treturn this.forest.size;\n\t}\n\n\t/**\n\t * @returns true iff the nodeId exists.\n\t */\n\tpublic hasNode(id: NodeId): boolean {\n\t\treturn this.forest.tryGet(id) !== undefined;\n\t}\n\n\t/**\n\t * @returns a `ChangeNode` derived from the `SnapshotNode` in this snapshot with the given `NodeId`.\n\t */\n\tpublic getChangeNode(id: NodeId): ChangeNode {\n\t\treturn getChangeNodeFromSnapshot(this, id);\n\t}\n\n\t/**\n\t * @returns the `ChangeNode`s derived from the `SnapshotNode`s in this snapshot with the given `NodeId`s.\n\t */\n\tpublic getChangeNodes(nodeIds: readonly NodeId[]): ChangeNode[] {\n\t\treturn nodeIds.map((id) => this.getChangeNode(id));\n\t}\n\n\t/**\n\t * Asserts the forest is in a consistent state.\n\t */\n\tpublic assertConsistent(): void {\n\t\tthis.forest.assertConsistent();\n\t}\n\n\t/**\n\t * Inserts all nodes in a NodeSequence into the forest.\n\t */\n\tpublic addNodes(sequence: Iterable<SnapshotNode>): Snapshot {\n\t\treturn new Snapshot(this.root, this.forest.add(sequence));\n\t}\n\n\t/**\n\t * Remove all nodes with the given ids from the forest\n\t */\n\tpublic deleteNodes(nodes: Iterable<NodeId>): Snapshot {\n\t\treturn new Snapshot(this.root, this.forest.delete(nodes, true));\n\t}\n\n\t/**\n\t * Parents a set of detached nodes at a specified place.\n\t * @param nodesToAttach - the nodes to parent in the specified place. The nodes must already be present in the Snapshot.\n\t * @param place - the location to insert the nodes.\n\t */\n\tpublic attachRange(nodesToAttach: readonly NodeId[], place: SnapshotPlace): Snapshot {\n\t\tconst { parent, label } = place.trait;\n\t\tconst index = this.findIndexWithinTrait(place);\n\t\treturn new Snapshot(this.root, this.forest.attachRangeOfChildren(parent, label, index, nodesToAttach));\n\t}\n\n\t/**\n\t * Detaches a range of nodes from their parent. The detached nodes remain in the Snapshot.\n\t * @param rangeToDetach - the range of nodes to detach\n\t */\n\tpublic detachRange(rangeToDetach: SnapshotRange): { snapshot: Snapshot; detached: readonly NodeId[] } {\n\t\tconst { start, end } = rangeToDetach;\n\t\tconst { trait: traitLocation } = start;\n\t\tconst { parent, label } = traitLocation;\n\t\tconst startIndex = this.findIndexWithinTrait(start);\n\t\tconst endIndex = this.findIndexWithinTrait(end);\n\t\tconst { forest, detached } = this.forest.detachRangeOfChildren(parent, label, startIndex, endIndex);\n\t\treturn { snapshot: new Snapshot(this.root, forest), detached };\n\t}\n\n\t/**\n\t * Sets a node's value. The node must exist in this `Snapshot`.\n\t * @param nodeId - the id of the node\n\t * @param value - the new value\n\t */\n\tpublic setNodeValue(nodeId: NodeId, value: Payload): Snapshot {\n\t\treturn new Snapshot(this.root, this.forest.setValue(nodeId, value));\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: SnapshotPlace): 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/**\n\t * Returns the node associated with `id` in this `Snapshot`.\n\t */\n\tpublic getSnapshotNode(id: NodeId): SnapshotNode {\n\t\treturn this.forest.get(id);\n\t}\n\n\t/**\n\t * Returns the label of the trait that a node is under. Returns undefined if the node is not present or if it is the root node.\n\t */\n\tpublic getTraitLabel(id: NodeId): TraitLabel | undefined {\n\t\treturn this.forest.tryGetParent(id)?.traitParent;\n\t}\n\n\t/**\n\t * Returns the parent of a node. Returns undefined if the node does not exist in the snapshot or if it does not have a parent.\n\t */\n\tpublic getParentSnapshotNode(id: NodeId): SnapshotNode | 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.getSnapshotNode(parentInfo.parentId);\n\t}\n\n\t/**\n\t * @param node - must have a parent.\n\t */\n\tpublic getTraitLocation(node: NodeId): TraitLocation {\n\t\tconst parentData = this.forest.getParent(node);\n\t\tassert(parentData !== undefined, 'node must have parent');\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 * @param node - must have a parent.\n\t * Performance note: this is O(siblings in trait).\n\t */\n\tpublic getIndexInTrait(node: NodeId): TraitNodeIndex {\n\t\tif (this.traitIndicesCache === undefined) {\n\t\t\tthis.traitIndicesCache = new Map();\n\t\t} else {\n\t\t\tconst cached = this.traitIndicesCache.get(node);\n\t\t\tif (cached !== undefined) {\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t}\n\t\tconst parentData = this.forest.getParent(node);\n\t\tconst parent = this.forest.get(parentData.parentId);\n\t\tconst traitParent =\n\t\t\tparent.traits.get(parentData.traitParent) ?? fail('invalid parentData: trait parent not found.');\n\t\tlet foundIndex = -1 as TraitNodeIndex;\n\t\tfor (let i = 0; i < traitParent.length; i++) {\n\t\t\tconst nodeInTrait = traitParent[i];\n\t\t\tconst index = i as TraitNodeIndex;\n\t\t\tthis.traitIndicesCache.set(nodeInTrait, index);\n\t\t\tif (nodeInTrait === node) {\n\t\t\t\tfoundIndex = index;\n\t\t\t}\n\t\t}\n\t\treturn foundIndex !== -1 ? foundIndex : fail('invalidParentData: node not found in specified trait');\n\t}\n\n\t/**\n\t * Return a trait given its location\n\t * @param traitLocation - the location of the trait\n\t */\n\tpublic getTrait(traitLocation: TraitLocation): readonly NodeId[] {\n\t\treturn this.getSnapshotNode(traitLocation.parent).traits.get(traitLocation.label) ?? [];\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/** Compares this snapshot to another for equality. */\n\tpublic equals(snapshot: Snapshot): boolean {\n\t\tif (this.root !== snapshot.root) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// TODO:#49100:Perf: make this faster and/or remove use by PrefetchingCheckout.\n\t\treturn this.forest.equals(snapshot.forest);\n\t}\n\n\tprivate *iterateNodeDescendants(nodeId: NodeId): IterableIterator<SnapshotNode> {\n\t\tconst node = this.getSnapshotNode(nodeId);\n\t\tyield node;\n\t\tfor (const trait of node.traits.values()) {\n\t\t\tfor (const childId of trait) {\n\t\t\t\tyield* this.iterateNodeDescendants(childId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Calculate the difference between two `Snapshot`s\n\t * @param snapshot - the other snapshot to compare to this one\n\t * @returns A {@link Delta} which nodes must be changed, added, and removed to get from `this` to `snapshot`.\n\t * The snapshots must share a root.\n\t */\n\tpublic delta(snapshot: Snapshot): Delta<NodeId> {\n\t\tassert(this.root === snapshot.root, 'Delta can only be calculated between snapshots that share a root');\n\t\treturn this.forest.delta(snapshot.forest);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<SnapshotNode> {\n\t\treturn this.iterateNodeDescendants(this.root);\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\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeHandle.d.ts","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,QAAQ,CAAC,cAAc,CAAC;IAC9D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,6FAA6F;gBAC1E,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM;IAKrD,IAAW,OAAO,IAAI,OAAO,GAAG,SAAS,CAGxC;IAED,IAAW,UAAU,IAAI,UAAU,CAElC;IAED,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED,IAAW,MAAM,IAAI,QAAQ,CAAC,cAAc,CAAC,CAgB5C;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,UAAU,CAE5B;IAED;;;OAGG;IACI,UAAU,IAAI,UAAU;IAIxB,QAAQ,IAAI,MAAM;CAGzB"}
1
+ {"version":3,"file":"TreeNodeHandle.d.ts","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,QAAQ,CAAC,cAAc,CAAC;IAC9D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,6FAA6F;gBAC1E,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM;IAKrD,IAAW,OAAO,IAAI,OAAO,GAAG,SAAS,CAExC;IAED,IAAW,UAAU,IAAI,UAAU,CAElC;IAED,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED,IAAW,MAAM,IAAI,QAAQ,CAAC,cAAc,CAAC,CAgB5C;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,UAAU,CAE5B;IAED;;;OAGG;IACI,UAAU,IAAI,UAAU;IAIxB,QAAQ,IAAI,MAAM;CAGzB"}
@@ -20,7 +20,6 @@ class TreeNodeHandle {
20
20
  this.nodeId = nodeId;
21
21
  }
22
22
  get payload() {
23
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
24
23
  return this.node.payload;
25
24
  }
26
25
  get definition() {
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeHandle.js","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,qCAAyC;AACzC,2DAAgE;AAEhE;;;;;GAKG;AACH,MAAa,cAAc;IAI1B,6FAA6F;IAC7F,YAAmB,QAAkB,EAAE,MAA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AGG;IACI,UAAU;QAChB,OAAO,6CAAyB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;CACD;AA3DD,wCA2DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Definition, NodeId } from './Identifiers';\nimport { ChangeNode, Payload, TraitMap, TreeNode } from './generic';\nimport { Snapshot } from './Snapshot';\nimport { memoizeGetter } from './Common';\nimport { getChangeNodeFromSnapshot } from './SnapshotUtilities';\n\n/**\n * A handle to a `TreeNode` that exists within a specific `Snapshot`. This type provides a convenient\n * API for traversing trees of nodes in a Snapshot and is not designed to provide maximum runtime\n * performance; if performance is a concern, consider using the Snapshot and SnapshotNode APIs directly.\n * @public\n */\nexport class TreeNodeHandle implements TreeNode<TreeNodeHandle> {\n\tprivate readonly snapshot: Snapshot;\n\tprivate readonly nodeId: NodeId;\n\n\t/** Construct a handle which references the node with the given id in the given `Snapshot` */\n\tpublic constructor(snapshot: Snapshot, nodeId: NodeId) {\n\t\tthis.snapshot = snapshot;\n\t\tthis.nodeId = nodeId;\n\t}\n\n\tpublic get payload(): Payload | undefined {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.node.payload;\n\t}\n\n\tpublic get definition(): Definition {\n\t\treturn this.node.definition;\n\t}\n\n\tpublic get identifier(): NodeId {\n\t\treturn this.node.identifier;\n\t}\n\n\tpublic get traits(): TraitMap<TreeNodeHandle> {\n\t\t// Construct a new trait map that wraps each node in each trait in a handle\n\t\tconst traitMap: TraitMap<TreeNodeHandle> = {};\n\t\tconst { snapshot } = this;\n\t\tfor (const [label, trait] of Object.entries(this.node.traits)) {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tget() {\n\t\t\t\t\tconst handleTrait = trait.map((node) => new TreeNodeHandle(snapshot, node.identifier));\n\t\t\t\t\treturn memoizeGetter(this as TraitMap<TreeNodeHandle>, label, handleTrait);\n\t\t\t\t},\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\n\t\treturn memoizeGetter(this, 'traits', traitMap);\n\t}\n\n\t/**\n\t * Get a `ChangeNode` for the snapshot node that this handle references\n\t */\n\tpublic get node(): ChangeNode {\n\t\treturn memoizeGetter(this, 'node', getChangeNodeFromSnapshot(this.snapshot, this.nodeId, true));\n\t}\n\n\t/**\n\t * Generate a new `ChangeNode` for the snapshot node that this handle references. The returned node will be fully\n\t * demanded, i.e. will contain no lazy/virtualized subtrees.\n\t */\n\tpublic demandTree(): ChangeNode {\n\t\treturn getChangeNodeFromSnapshot(this.snapshot, this.nodeId, false);\n\t}\n\n\tpublic toString(): string {\n\t\treturn JSON.stringify(this.demandTree());\n\t}\n}\n"]}
1
+ {"version":3,"file":"TreeNodeHandle.js","sourceRoot":"","sources":["../src/TreeNodeHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,qCAAyC;AACzC,2DAAgE;AAEhE;;;;;GAKG;AACH,MAAa,cAAc;IAI1B,6FAA6F;IAC7F,YAAmB,QAAkB,EAAE,MAAc;QACpD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC7B,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC7B,CAAC;IAED,IAAW,MAAM;QAChB,2EAA2E;QAC3E,MAAM,QAAQ,GAA6B,EAAE,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YAC9D,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE;gBACtC,GAAG;oBACF,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;oBACvF,OAAO,sBAAa,CAAC,IAAgC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;gBAC5E,CAAC;gBACD,YAAY,EAAE,IAAI;gBAClB,UAAU,EAAE,IAAI;aAChB,CAAC,CAAC;SACH;QAED,OAAO,sBAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,sBAAa,CAAC,IAAI,EAAE,MAAM,EAAE,6CAAyB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IACjG,CAAC;IAED;;;OAGG;IACI,UAAU;QAChB,OAAO,6CAAyB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;CACD;AA1DD,wCA0DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Definition, NodeId } from './Identifiers';\nimport { ChangeNode, Payload, TraitMap, TreeNode } from './generic';\nimport { Snapshot } from './Snapshot';\nimport { memoizeGetter } from './Common';\nimport { getChangeNodeFromSnapshot } from './SnapshotUtilities';\n\n/**\n * A handle to a `TreeNode` that exists within a specific `Snapshot`. This type provides a convenient\n * API for traversing trees of nodes in a Snapshot and is not designed to provide maximum runtime\n * performance; if performance is a concern, consider using the Snapshot and SnapshotNode APIs directly.\n * @public\n */\nexport class TreeNodeHandle implements TreeNode<TreeNodeHandle> {\n\tprivate readonly snapshot: Snapshot;\n\tprivate readonly nodeId: NodeId;\n\n\t/** Construct a handle which references the node with the given id in the given `Snapshot` */\n\tpublic constructor(snapshot: Snapshot, nodeId: NodeId) {\n\t\tthis.snapshot = snapshot;\n\t\tthis.nodeId = nodeId;\n\t}\n\n\tpublic get payload(): Payload | undefined {\n\t\treturn this.node.payload;\n\t}\n\n\tpublic get definition(): Definition {\n\t\treturn this.node.definition;\n\t}\n\n\tpublic get identifier(): NodeId {\n\t\treturn this.node.identifier;\n\t}\n\n\tpublic get traits(): TraitMap<TreeNodeHandle> {\n\t\t// Construct a new trait map that wraps each node in each trait in a handle\n\t\tconst traitMap: TraitMap<TreeNodeHandle> = {};\n\t\tconst { snapshot } = this;\n\t\tfor (const [label, trait] of Object.entries(this.node.traits)) {\n\t\t\tObject.defineProperty(traitMap, label, {\n\t\t\t\tget() {\n\t\t\t\t\tconst handleTrait = trait.map((node) => new TreeNodeHandle(snapshot, node.identifier));\n\t\t\t\t\treturn memoizeGetter(this as TraitMap<TreeNodeHandle>, label, handleTrait);\n\t\t\t\t},\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t});\n\t\t}\n\n\t\treturn memoizeGetter(this, 'traits', traitMap);\n\t}\n\n\t/**\n\t * Get a `ChangeNode` for the snapshot node that this handle references\n\t */\n\tpublic get node(): ChangeNode {\n\t\treturn memoizeGetter(this, 'node', getChangeNodeFromSnapshot(this.snapshot, this.nodeId, true));\n\t}\n\n\t/**\n\t * Generate a new `ChangeNode` for the snapshot node that this handle references. The returned node will be fully\n\t * demanded, i.e. will contain no lazy/virtualized subtrees.\n\t */\n\tpublic demandTree(): ChangeNode {\n\t\treturn getChangeNodeFromSnapshot(this.snapshot, this.nodeId, false);\n\t}\n\n\tpublic toString(): string {\n\t\treturn JSON.stringify(this.demandTree());\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"HistoryEditFactory.d.ts","sourceRoot":"","sources":["../../src/default-edits/HistoryEditFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAQ,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAkE,MAAM,kBAAkB,CAAC;AAI1G;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,CA2E7E"}
1
+ {"version":3,"file":"HistoryEditFactory.d.ts","sourceRoot":"","sources":["../../src/default-edits/HistoryEditFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAQ,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAkE,MAAM,kBAAkB,CAAC;AAI1G;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,CA4E7E"}
@@ -73,6 +73,7 @@ function revert(changes, before) {
73
73
  case PersistedTypes_1.ChangeType.Constraint:
74
74
  // TODO:#46759: Support Constraint in reverts
75
75
  Common_1.fail('Revert currently does not support Constraints');
76
+ break;
76
77
  default:
77
78
  Common_1.fail('Revert does not support the change type.');
78
79
  }
@@ -178,7 +179,6 @@ function createInvertedSetValue(setValue, revisionBeforeEdit) {
178
179
  const { nodeToModify } = setValue;
179
180
  const oldPayload = revisionBeforeEdit.getSnapshotNode(nodeToModify).payload;
180
181
  // Rationale: 'undefined' is reserved for future use (see 'SetValue' interface)
181
- // eslint-disable-next-line no-null/no-null
182
182
  if (oldPayload !== null) {
183
183
  return [PersistedTypes_1.Change.setPayload(nodeToModify, oldPayload)];
184
184
  }