@fluidframework/matrix 0.59.2001 → 0.59.3000

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/bspSet.d.ts +2 -2
  2. package/dist/bspSet.js +1 -1
  3. package/dist/bspSet.js.map +1 -1
  4. package/dist/handlecache.d.ts +1 -1
  5. package/dist/handlecache.js +4 -4
  6. package/dist/handlecache.js.map +1 -1
  7. package/dist/handletable.js.map +1 -1
  8. package/dist/matrix.d.ts +4 -1
  9. package/dist/matrix.d.ts.map +1 -1
  10. package/dist/matrix.js +57 -22
  11. package/dist/matrix.js.map +1 -1
  12. package/dist/packageVersion.d.ts +1 -1
  13. package/dist/packageVersion.js +1 -1
  14. package/dist/packageVersion.js.map +1 -1
  15. package/dist/permutationvector.js +10 -10
  16. package/dist/permutationvector.js.map +1 -1
  17. package/dist/productSet.js +10 -10
  18. package/dist/productSet.js.map +1 -1
  19. package/dist/range.d.ts +1 -1
  20. package/dist/range.js +1 -1
  21. package/dist/range.js.map +1 -1
  22. package/dist/serialization.js +1 -1
  23. package/dist/serialization.js.map +1 -1
  24. package/dist/undoprovider.d.ts.map +1 -1
  25. package/dist/undoprovider.js +3 -3
  26. package/dist/undoprovider.js.map +1 -1
  27. package/lib/bspSet.d.ts +2 -2
  28. package/lib/handlecache.d.ts +1 -1
  29. package/lib/handlecache.js +1 -1
  30. package/lib/handlecache.js.map +1 -1
  31. package/lib/handletable.js.map +1 -1
  32. package/lib/matrix.d.ts +4 -1
  33. package/lib/matrix.d.ts.map +1 -1
  34. package/lib/matrix.js +39 -4
  35. package/lib/matrix.js.map +1 -1
  36. package/lib/packageVersion.d.ts +1 -1
  37. package/lib/packageVersion.js +1 -1
  38. package/lib/packageVersion.js.map +1 -1
  39. package/lib/productSet.js.map +1 -1
  40. package/lib/range.d.ts +1 -1
  41. package/lib/range.js +1 -1
  42. package/lib/range.js.map +1 -1
  43. package/lib/undoprovider.d.ts.map +1 -1
  44. package/lib/undoprovider.js.map +1 -1
  45. package/package.json +16 -15
  46. package/src/handlecache.ts +1 -1
  47. package/src/matrix.ts +60 -13
  48. package/src/packageVersion.ts +1 -1
  49. package/src/productSet.ts +1 -1
  50. package/src/range.ts +1 -1
  51. package/src/undoprovider.ts +1 -1
package/dist/bspSet.d.ts CHANGED
@@ -117,8 +117,8 @@ export declare function except<Key extends Cachable<Key>, Id>(left: BspSet<Key,
117
117
  export declare function combineCmp(left: -1 | 0 | 1 | undefined, right: -1 | 0 | 1 | undefined): 0 | 1 | -1 | undefined;
118
118
  export declare function compareUntyped<Key extends Cachable<Key>, Id>(setOperations: SetOperations<Key, Id>, left: UntypedBspSet<Key>, right: UntypedBspSet<Key>): -1 | 0 | 1 | undefined;
119
119
  export declare function compare<Key extends Cachable<Key>, Id>(left: BspSet<Key, Id>, right: BspSet<Key, Id>): 0 | 1 | -1 | undefined;
120
- export declare const symmetricDiff: <Key extends Disjoint<keyof Key, "depth" | "split">, Id>(left: BspSet<Key, Id>, right: BspSet<Key, Id>) => BspSet<Key, Id>;
121
- export declare const complement: <Key extends Disjoint<keyof Key, "depth" | "split">, Id>(set: BspSet<Key, Id>) => BspSet<Key, Id>;
120
+ export declare const symmetricDiff: <Key extends Disjoint<keyof Key, keyof KeyCache<T>>, Id>(left: BspSet<Key, Id>, right: BspSet<Key, Id>) => BspSet<Key, Id>;
121
+ export declare const complement: <Key extends Disjoint<keyof Key, keyof KeyCache<T>>, Id>(set: BspSet<Key, Id>) => BspSet<Key, Id>;
122
122
  export declare function getNodeCount<Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>): number;
123
123
  export declare function forEachKey<Key extends Cachable<Key>, Id>(set: Empty | Sparse<Key, Id>, f: (key: Key) => boolean): boolean;
124
124
  export {};
package/dist/bspSet.js CHANGED
@@ -68,7 +68,7 @@ function lazy(setOperations, pathKey, key) {
68
68
  }
69
69
  exports.lazy = lazy;
70
70
  function createFromKey(uncachedSetOperations) {
71
- const setOperations = Object.assign(Object.assign({}, uncachedSetOperations), { split: exports.cacheKeySplitting(uncachedSetOperations.split, uncachedSetOperations.top) });
71
+ const setOperations = Object.assign(Object.assign({}, uncachedSetOperations), { split: (0, exports.cacheKeySplitting)(uncachedSetOperations.split, uncachedSetOperations.top) });
72
72
  return (key) => fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));
73
73
  }
74
74
  exports.createFromKey = createFromKey;
@@ -1 +1 @@
1
- {"version":3,"file":"bspSet.js","sourceRoot":"","sources":["../src/bspSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iCAAiC;AAI1B,MAAM,IAAI,GAAG,CAAW,IAAO,EAAE,KAAQ,EAAc,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAAlE,QAAA,IAAI,QAA8D;AAE/E,uEAAuE;AACvE,MAAM,YAAY,GAAyB,gBAAQ,CAAC;AAEpD,IAAY,OAGX;AAHD,WAAY,OAAO;IACf,uCAAK,CAAA;IACL,uCAAK,CAAA;AACT,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAsBY,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AACtB,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AA0G5B,MAAM,iBAAiB,GAAG,CAC7B,aAA0E,EAC1E,GAAmB,EACnB,WAAmB,EAAE,EACvB,EAAE,CAAC,CAAC,GAAmB,EAAE,EAAE;IACzB,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE;QACzB,OAAO,GAAG,CAAC,KAAK,CAAC;KACpB;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAC1C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,GAAG,QAAQ,EAAE;QACzC,GAAG,CA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OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAAE;QAEnD,MAAM,MAAM,GAAG,WAAW,CAAU,aAAa,EAAE,SAAS,CAAC,CAAC;QAC9D,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,SAAgB,UAAU,CACtB,GAA4B,EAC5B,CAAwB;IAExB,IAAI,GAAG,KAAK,aAAK,EAAE;QAAE,OAAO,IAAI,CAAC;KAAE;IACnC,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC;AAND,gCAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { __assign } from \"tslib\";\n/** An interface for representing a readonly pair */\nexport type Pair<S, T = S> = readonly [S, T];\n\nexport const pair = <S, T = S>(left: S, right: T): Pair<S, T> => [left, right];\n\n// using this polyfill, because `Object.assign` is not supported in IE.\nconst ObjectAssign: typeof Object.assign = __assign;\n\nexport enum SetKind {\n Dense,\n Empty,\n}\n\ninterface TreeNode<Left, Right> {\n readonly left: Left;\n readonly right: Right;\n}\n\ninterface KeyNode<Key, Exact> {\n readonly key: Key;\n readonly pathKey: Key;\n readonly isExact: Exact;\n}\n\nexport type Empty = SetKind.Empty;\n\n/** The term *Dense* means that a given subset contains all the elements of its particular\n * bounds. E.g. the whole set would be dense w.r.t. the bounds of the whole space. Or\n * if a set represents an interval [a, b), then it would be dense, if there are no holes in it,\n * i.e. the set is represented exactly using the current bounds.\n */\nexport type Dense = SetKind.Dense;\n\nexport const dense = SetKind.Dense;\nexport const empty = SetKind.Empty;\n\ntype KeyUnexact<Key> = KeyNode<Key, false>;\n\n/** In the BSP-set, each node carries with it implicit bounds just by the position in the tree.\n * Furthermore, it can carry around a key. The key can either be an approximation, i.e. an upper bound\n * or it can be *exact*. Exact means, that the whole set can be exactly represented in terms of just the key.\n *\n * One might wonder, why we don't prune the tree at this point. This has to do with the fact that we are\n * representing arbitrary sets and so even though one of two sets could be represented exactly the other\n * might not be able to yet. In this case we need to unfold the key by splitting further. In order to avoid\n * excessive splitting and pruning, we just carry around the key but allow the tree to also be materialized, on-demand.\n */\ntype KeyExact<Key> = KeyNode<Key, true>;\n\ntype KeyUndefined = KeyNode<undefined, false>;\ntype KeyDefined<Key> = KeyUnexact<Key> | KeyExact<Key>;\n\ntype BalancePropertyHelper<Key, Left, Right> = TreeNode<UntypedSparse<Key> | Left, UntypedSparse<Key> | Right>;\n\ntype TreeDefined<Key> =\n | BalancePropertyHelper<Key, Empty, Dense>\n | BalancePropertyHelper<Key, Dense, Empty>;\ntype TreeUndefined = TreeNode<undefined, undefined>;\n\ntype KeyDefinednessProperty<Key> = KeyDefined<Key> | KeyUndefined;\n\nexport type UntypedSparse<Key> =\n | (KeyDefinednessProperty<Key> & TreeDefined<Key>)\n | (KeyDefined<Key> & TreeUndefined);\n/** The term *untyped* refers to the tree representation of a BSP set. Because BSP set trees are only compared in terms\n * of their structure, we need to ensure that cuts occur at the same exact points across all possible sets. This is\n * enforced by the fact, that at construction time, we attach an `Id` to each BSP set and only allow operations to\n * occur on sets with the same `Id`.\n *\n * The BSP set becomes *untyped*, when we drop that `Id`; now it is possible to operate on sets that are incompatible.\n * Doing this, however, allows us to store the set operations only once per set as opposed to carrying them around with\n * every node.\n */\nexport type UntypedBspSet<Key> = Empty | Dense | UntypedSparse<Key>;\n\n/** A set is considred *sparse*, if we know that w.r.t. to it's bounds it is neither empty, nor dense. */\ninterface Sparse<Key extends Cachable<Key>, Id> {\n setOperations: SetOperations<Key, Id>;\n root: UntypedSparse<Key>;\n}\nexport type BspSet<Key extends Cachable<Key>, Id> =\n | Empty\n | Dense\n | Sparse<Key, Id>;\n\nexport interface KeyCache<T> {\n depth?: number;\n split?: Pair<Pair<CachedKey<T>, number>>;\n}\nexport type CachedKey<T> = T & KeyCache<T>;\nexport type Cachable<T> = Disjoint<keyof T, keyof KeyCache<T>>;\n\nexport type Disjoint<T, U> = [T, U] extends [Exclude<T, U>, Exclude<U, T>]\n ? any\n : never;\nexport type RequireAtLeastOne<T> = {\n [K in keyof T]-?: Required<Pick<T, K>> &\n Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n\n/** This is a concrete set operations implementation, tagged with an arbitrary id. */\nexport interface SetOperations<Key extends Cachable<Key>, Id> {\n /** Id here is just a phantom type, so that we can associate the various set instances together */\n readonly id: Id;\n\n /** Split the key into two. This will only be called when the current key is incomparable with an element.\n * E.g. this would never be called if the key is already a 1x1 rectangle. */\n readonly split: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>;\n\n /** Tells, if a given key can be split further */\n readonly canSplit: (key: CachedKey<Key>) => boolean;\n\n /** Tells if two keys overlap at all. */\n readonly meets: (key1: Key, key2: Key) => boolean;\n\n /** Intersect the keys, if it is possible to exactly respresent their intersection.\n * An implementation is never required to compute the intersection as this is just an optimization.\n * Precondition: It is guaranteed that the keys meet and that they are incomparable.\n */\n readonly intersect: (key1: Key, key2: Key) => Key | undefined;\n\n /** Unions the keys, if it is possible to exactly represent their union.\n * An implementation is never required to compute the union as this is just an optimization.\n * Precondition: It is guaranteed that the keys are incomparable.\n */\n readonly union: (key1: Key, key2: Key) => Key | undefined;\n\n /** Computes the set difference between two keys, if it is possible to exactly represent their set difference.\n * An implementation is never required to compute the difference as this is just an optimization.\n * Precondition: It is guaranteed that the keys meet.\n */\n readonly except: (key1: Key, key2: Key) => Key | undefined;\n\n /** Compare two keys */\n readonly compare: (key1: Key, key2: Key) => -1 | 0 | 1 | undefined;\n\n /** The top element of the set. */\n readonly top: Key;\n}\n\nexport const cacheKeySplitting = <Key>(\n splitFunction: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>,\n top: CachedKey<Key>,\n maxDepth: number = 10,\n) => (key: CachedKey<Key>) => {\n if (key.split !== undefined) {\n return key.split;\n }\n\n const split = splitFunction(key);\n const depth = key === top ? 0 : key.depth;\n if (depth !== undefined && depth < maxDepth) {\n key.split = split;\n split[0][0].depth = depth + 1;\n split[1][0].depth = depth + 1;\n }\n\n return split;\n};\n\nexport function fromUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n root: UntypedBspSet<Key>,\n): BspSet<Key, Id> {\n if (root === empty || root === dense) { return root; }\n return { setOperations, root };\n}\n\nconst sparse = <Key, Exact, Left, Right>(\n left: Left,\n right: Right,\n pathKey: Key,\n key: Key,\n isExact: Exact,\n) => ({ key, pathKey, left, right, isExact });\n\nfunction fromKey<Key>(\n pathKey: Key,\n key: Key,\n isExact: boolean,\n): UntypedSparse<Key> {\n if (isExact) {\n return sparse(undefined, undefined, pathKey, key, true as const);\n }\n\n return sparse(undefined, undefined, pathKey, key, false as const);\n}\n\nexport function lazy<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n pathKey: Key,\n key: Key,\n): UntypedBspSet<Key> {\n if (!setOperations.meets(pathKey, key)) { return empty; }\n const cmp = setOperations.compare(pathKey, key);\n if (cmp !== undefined) {\n if (cmp <= 0) { return dense; }\n\n return fromKey(pathKey, key, true);\n }\n\n // this is not exactly necessary, but increases the amount of exact nodes and thus we can often\n // prune earlier.\n // Also, having intersect always work guarantees exact nodes, thus allowing for more efficient\n // storage and computation.\n const newKey = setOperations.intersect(pathKey, key);\n\n if (newKey !== undefined) {\n return fromKey(pathKey, newKey, true);\n }\n\n return fromKey(pathKey, key, false);\n}\n\nexport function createFromKey<Key extends Cachable<Key>, Id>(\n uncachedSetOperations: SetOperations<Key, Id>,\n) {\n const setOperations = {\n ...uncachedSetOperations,\n split: cacheKeySplitting(\n uncachedSetOperations.split,\n uncachedSetOperations.top,\n ),\n };\n return (key: Key) =>\n fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));\n}\n\nfunction unionExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key> & KeyExact<Key>,\n right: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n const cmp = setOperations.compare(leftKey, rightKey);\n if (cmp !== undefined) {\n return cmp < 0 ? right : left;\n }\n\n const combinedKey = setOperations.union(leftKey, rightKey);\n if (combinedKey !== undefined) {\n const combinedCmp = setOperations.compare(combinedKey, pathKey);\n if (combinedCmp !== undefined && combinedCmp === 0) { return dense; }\n return fromKey(pathKey, combinedKey, true);\n }\n return undefined;\n}\n\n/** This is an local combination, not a proper union. We use it to have simpler code elsewhere */\nfunction combineChildren<Key>(\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): Empty | Dense | (UntypedSparse<Key> & TreeDefined<Key>) {\n if (left === empty) {\n if (right === empty) {\n return empty;\n }\n\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n if (right === empty) {\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n if (left === dense) {\n if (right === dense) {\n return dense;\n }\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n return sparse(left, right, undefined, undefined, false as const);\n}\n\nfunction materialize<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n set: UntypedSparse<Key>,\n): UntypedSparse<Key> & TreeDefined<Key> {\n if (set.left !== undefined) {\n return set;\n }\n\n const [[left], [right]] = setOperations.split(set.pathKey);\n const lChild = lazy(setOperations, left, set.key);\n const rChild = lazy(setOperations, right, set.key);\n\n const res = combineChildren<Key>(lChild, rChild);\n\n if (res === empty || res === dense) {\n throw new Error(\"incorrect set operations implementation\");\n }\n\n // first check, that res actually has the desired type\n const typeCheck: TreeDefined<Key> = res;\n\n const setAlias: UntypedSparse<Key> = set;\n return ObjectAssign(setAlias, {\n left: typeCheck.left,\n right: typeCheck.right,\n });\n}\n\nexport function unionUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (right === empty) { return left; }\n if (right === dense) { return right; }\n if (left === empty) { return right; }\n if (left === dense) { return left; }\n\n if (left.isExact && right.isExact) {\n const res = unionExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = unionUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = unionUntyped(setOperations, newLeft.right, newRight.right);\n\n return combineChildren(lChild, rChild);\n}\n\nexport function union<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (right === empty) { return left; }\n if (right === dense) { return right; }\n if (left === empty) { return right; }\n if (left === dense) { return left; }\n\n return fromUntyped(\n left.setOperations,\n unionUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nfunction intersectExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key> & KeyExact<Key>,\n right: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n if (!setOperations.meets(leftKey, rightKey)) {\n return empty;\n }\n\n const cmp = setOperations.compare(leftKey, rightKey);\n if (cmp !== undefined) {\n return cmp < 0 ? left : right;\n }\n\n const combinedKey = setOperations.intersect(leftKey, rightKey);\n if (combinedKey !== undefined) {\n return fromKey(pathKey, combinedKey, true);\n }\n\n return undefined;\n}\n\nexport function intersectUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (left === empty) { return left; }\n if (right === empty) { return right; }\n if (left === dense) { return right; }\n if (right === dense) { return left; }\n\n if (left.isExact && right.isExact) {\n const res = intersectExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = intersectUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = intersectUntyped(\n setOperations,\n newLeft.right,\n newRight.right,\n );\n\n return combineChildren(lChild, rChild);\n}\n\nexport function intersect<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (left === empty) { return left; }\n if (right === empty) { return right; }\n if (left === dense) { return right; }\n if (right === dense) { return left; }\n\n return fromUntyped(\n left.setOperations,\n intersectUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nexport function meetsUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): boolean {\n if (left === empty || right === empty) { return false; }\n if (left === dense || right === dense) { return true; }\n if (left.isExact && right.isExact) { return setOperations.meets(left.key, right.key); }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n return (\n meetsUntyped(setOperations, newLeft.left, newRight.left) ||\n meetsUntyped(setOperations, newLeft.right, newRight.right)\n );\n}\n\nexport function meets<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): boolean {\n if (left === empty || right === empty) { return false; }\n if (left === dense || right === dense) { return true; }\n return meetsUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nfunction exceptExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedSparse<Key> & KeyExact<Key>,\n right: KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n if (!setOperations.meets(leftKey, rightKey)) {\n return left;\n }\n\n const combinedKey = setOperations.except(leftKey, rightKey);\n if (combinedKey !== undefined) {\n return fromKey(pathKey, combinedKey, true);\n }\n\n return undefined;\n}\n\nexport function exceptUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (left === empty) { return left; }\n if (right === empty) { return left; }\n if (right === dense) { return empty; }\n if (left === dense) {\n const newRight_inner = materialize<Key, Id>(setOperations, right);\n const lChild_inner = exceptUntyped(setOperations, dense, newRight_inner.left);\n const rChild_inner = exceptUntyped(setOperations, dense, newRight_inner.right);\n return combineChildren(lChild_inner, rChild_inner);\n }\n if (left.isExact && right.isExact) {\n const res = exceptExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = exceptUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = exceptUntyped(setOperations, newLeft.right, newRight.right);\n\n return combineChildren(lChild, rChild);\n}\n\nexport function except<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (left === empty) { return left; }\n if (right === empty) { return left; }\n if (right === dense) { return empty; }\n if (left === dense) {\n return fromUntyped(\n right.setOperations,\n exceptUntyped<Key, Id>(right.setOperations, left, right.root),\n );\n }\n\n return fromUntyped(\n left.setOperations,\n exceptUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nconst compareExact = <Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: KeyExact<Key>,\n right: KeyExact<Key>,\n) => setOperations.compare(left.key, right.key);\n\nexport function combineCmp(\n left: -1 | 0 | 1 | undefined,\n right: -1 | 0 | 1 | undefined,\n) {\n if (left === undefined || right === undefined) { return undefined; }\n if (left === 0) { return right; }\n if (right === 0) { return left; }\n return left === right ? left : undefined;\n}\n\nexport function compareUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): -1 | 0 | 1 | undefined {\n if (left === right) { return 0; }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n if (left.isExact && right.isExact) {\n return compareExact(setOperations, left, right);\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n const lCmp = compareUntyped(setOperations, newLeft.left, newRight.left);\n if (lCmp === undefined) { return undefined; }\n\n const rCmp = compareUntyped(setOperations, newLeft.right, newRight.right);\n\n if (rCmp === undefined) { return undefined; }\n\n return combineCmp(lCmp, rCmp);\n}\n\nexport function compare<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n) {\n if (left === right) { return 0; }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n return compareUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nexport const symmetricDiff = <Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n) => union(except(left, right), except(right, left));\n\nexport const complement = <Key extends Cachable<Key>, Id>(\n set: BspSet<Key, Id>,\n) => except(dense, set);\n\nfunction getNodeCountUntyped<T>(set: UntypedBspSet<T> | undefined): number {\n if (set === undefined || set === empty || set === dense) {\n return 0;\n }\n\n return getNodeCountUntyped(set.left) + getNodeCountUntyped(set.right) + 1;\n}\n\nexport function getNodeCount<Key extends Cachable<Key>, Id>(\n set: BspSet<Key, Id>,\n) {\n if (set === empty || set === dense) { return 0; }\n return getNodeCountUntyped(set.root);\n}\n\nfunction forEachKeyUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n set: UntypedBspSet<Key>,\n f: (key: Key) => boolean,\n): boolean {\n function loop(pathKey: Key, set_inner: UntypedBspSet<Key>): boolean {\n if (set_inner === empty) { return true; }\n if (set_inner === dense) { return f(pathKey); }\n if (set_inner.isExact) { return f(set_inner.key); }\n\n const newSet = materialize<Key, Id>(setOperations, set_inner);\n const [[left], [right]] = setOperations.split(pathKey);\n return loop(left, newSet.left) && loop(right, newSet.right);\n }\n\n return loop(setOperations.top, set);\n}\n\nexport function forEachKey<Key extends Cachable<Key>, Id>(\n set: Empty | Sparse<Key, Id>,\n f: (key: Key) => boolean,\n): boolean {\n if (set === empty) { return true; }\n return forEachKeyUntyped(set.setOperations, set.root, f);\n}\n"]}
1
+ {"version":3,"file":"bspSet.js","sourceRoot":"","sources":["../src/bspSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iCAAiC;AAI1B,MAAM,IAAI,GAAG,CAAW,IAAO,EAAE,KAAQ,EAAc,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAAlE,QAAA,IAAI,QAA8D;AAE/E,uEAAuE;AACvE,MAAM,YAAY,GAAyB,gBAAQ,CAAC;AAEpD,IAAY,OAGX;AAHD,WAAY,OAAO;IACf,uCAAK,CAAA;IACL,uCAAK,CAAA;AACT,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAsBY,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AACtB,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AA0G5B,MAAM,iBAAiB,GAAG,CAC7B,aAA0E,EAC1E,GAAmB,EACnB,WAAmB,EAAE,EACvB,EAAE,CAAC,CAAC,GAAmB,EAAE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AC,IAAI,CAAC,CAAC;AACzC,CAAC;AALD,oCAKC;AAED,SAAS,iBAAiB,CACtB,aAAqC,EACrC,GAAuB,EACvB,CAAwB;IAExB,SAAS,IAAI,CAAC,OAAY,EAAE,SAA6B;QACrD,IAAI,SAAS,KAAK,aAAK,EAAE;YAAE,OAAO,IAAI,CAAC;SAAE;QACzC,IAAI,SAAS,KAAK,aAAK,EAAE;YAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;SAAE;QAC/C,IAAI,SAAS,CAAC,OAAO,EAAE;YAAE,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAAE;QAEnD,MAAM,MAAM,GAAG,WAAW,CAAU,aAAa,EAAE,SAAS,CAAC,CAAC;QAC9D,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,SAAgB,UAAU,CACtB,GAA4B,EAC5B,CAAwB;IAExB,IAAI,GAAG,KAAK,aAAK,EAAE;QAAE,OAAO,IAAI,CAAC;KAAE;IACnC,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC;AAND,gCAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { __assign } from \"tslib\";\n/** An interface for representing a readonly pair */\nexport type Pair<S, T = S> = readonly [S, T];\n\nexport const pair = <S, T = S>(left: S, right: T): Pair<S, T> => [left, right];\n\n// using this polyfill, because `Object.assign` is not supported in IE.\nconst ObjectAssign: typeof Object.assign = __assign;\n\nexport enum SetKind {\n Dense,\n Empty,\n}\n\ninterface TreeNode<Left, Right> {\n readonly left: Left;\n readonly right: Right;\n}\n\ninterface KeyNode<Key, Exact> {\n readonly key: Key;\n readonly pathKey: Key;\n readonly isExact: Exact;\n}\n\nexport type Empty = SetKind.Empty;\n\n/** The term *Dense* means that a given subset contains all the elements of its particular\n * bounds. E.g. the whole set would be dense w.r.t. the bounds of the whole space. Or\n * if a set represents an interval [a, b), then it would be dense, if there are no holes in it,\n * i.e. the set is represented exactly using the current bounds.\n */\nexport type Dense = SetKind.Dense;\n\nexport const dense = SetKind.Dense;\nexport const empty = SetKind.Empty;\n\ntype KeyUnexact<Key> = KeyNode<Key, false>;\n\n/** In the BSP-set, each node carries with it implicit bounds just by the position in the tree.\n * Furthermore, it can carry around a key. The key can either be an approximation, i.e. an upper bound\n * or it can be *exact*. Exact means, that the whole set can be exactly represented in terms of just the key.\n *\n * One might wonder, why we don't prune the tree at this point. This has to do with the fact that we are\n * representing arbitrary sets and so even though one of two sets could be represented exactly the other\n * might not be able to yet. In this case we need to unfold the key by splitting further. In order to avoid\n * excessive splitting and pruning, we just carry around the key but allow the tree to also be materialized, on-demand.\n */\ntype KeyExact<Key> = KeyNode<Key, true>;\n\ntype KeyUndefined = KeyNode<undefined, false>;\ntype KeyDefined<Key> = KeyUnexact<Key> | KeyExact<Key>;\n\ntype BalancePropertyHelper<Key, Left, Right> = TreeNode<UntypedSparse<Key> | Left, UntypedSparse<Key> | Right>;\n\ntype TreeDefined<Key> =\n | BalancePropertyHelper<Key, Empty, Dense>\n | BalancePropertyHelper<Key, Dense, Empty>;\ntype TreeUndefined = TreeNode<undefined, undefined>;\n\ntype KeyDefinednessProperty<Key> = KeyDefined<Key> | KeyUndefined;\n\nexport type UntypedSparse<Key> =\n | (KeyDefinednessProperty<Key> & TreeDefined<Key>)\n | (KeyDefined<Key> & TreeUndefined);\n/** The term *untyped* refers to the tree representation of a BSP set. Because BSP set trees are only compared in terms\n * of their structure, we need to ensure that cuts occur at the same exact points across all possible sets. This is\n * enforced by the fact, that at construction time, we attach an `Id` to each BSP set and only allow operations to\n * occur on sets with the same `Id`.\n *\n * The BSP set becomes *untyped*, when we drop that `Id`; now it is possible to operate on sets that are incompatible.\n * Doing this, however, allows us to store the set operations only once per set as opposed to carrying them around with\n * every node.\n */\nexport type UntypedBspSet<Key> = Empty | Dense | UntypedSparse<Key>;\n\n/** A set is considred *sparse*, if we know that w.r.t. to it's bounds it is neither empty, nor dense. */\ninterface Sparse<Key extends Cachable<Key>, Id> {\n setOperations: SetOperations<Key, Id>;\n root: UntypedSparse<Key>;\n}\nexport type BspSet<Key extends Cachable<Key>, Id> =\n | Empty\n | Dense\n | Sparse<Key, Id>;\n\nexport interface KeyCache<T> {\n depth?: number;\n split?: Pair<Pair<CachedKey<T>, number>>;\n}\nexport type CachedKey<T> = T & KeyCache<T>;\nexport type Cachable<T> = Disjoint<keyof T, keyof KeyCache<T>>;\n\nexport type Disjoint<T, U> = [T, U] extends [Exclude<T, U>, Exclude<U, T>]\n ? any\n : never;\nexport type RequireAtLeastOne<T> = {\n [K in keyof T]-?: Required<Pick<T, K>> &\n Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n\n/** This is a concrete set operations implementation, tagged with an arbitrary id. */\nexport interface SetOperations<Key extends Cachable<Key>, Id> {\n /** Id here is just a phantom type, so that we can associate the various set instances together */\n readonly id: Id;\n\n /** Split the key into two. This will only be called when the current key is incomparable with an element.\n * E.g. this would never be called if the key is already a 1x1 rectangle. */\n readonly split: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>;\n\n /** Tells, if a given key can be split further */\n readonly canSplit: (key: CachedKey<Key>) => boolean;\n\n /** Tells if two keys overlap at all. */\n readonly meets: (key1: Key, key2: Key) => boolean;\n\n /** Intersect the keys, if it is possible to exactly respresent their intersection.\n * An implementation is never required to compute the intersection as this is just an optimization.\n * Precondition: It is guaranteed that the keys meet and that they are incomparable.\n */\n readonly intersect: (key1: Key, key2: Key) => Key | undefined;\n\n /** Unions the keys, if it is possible to exactly represent their union.\n * An implementation is never required to compute the union as this is just an optimization.\n * Precondition: It is guaranteed that the keys are incomparable.\n */\n readonly union: (key1: Key, key2: Key) => Key | undefined;\n\n /** Computes the set difference between two keys, if it is possible to exactly represent their set difference.\n * An implementation is never required to compute the difference as this is just an optimization.\n * Precondition: It is guaranteed that the keys meet.\n */\n readonly except: (key1: Key, key2: Key) => Key | undefined;\n\n /** Compare two keys */\n readonly compare: (key1: Key, key2: Key) => -1 | 0 | 1 | undefined;\n\n /** The top element of the set. */\n readonly top: Key;\n}\n\nexport const cacheKeySplitting = <Key>(\n splitFunction: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>,\n top: CachedKey<Key>,\n maxDepth: number = 10,\n) => (key: CachedKey<Key>) => {\n if (key.split !== undefined) {\n return key.split;\n }\n\n const split = splitFunction(key);\n const depth = key === top ? 0 : key.depth;\n if (depth !== undefined && depth < maxDepth) {\n key.split = split;\n split[0][0].depth = depth + 1;\n split[1][0].depth = depth + 1;\n }\n\n return split;\n};\n\nexport function fromUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n root: UntypedBspSet<Key>,\n): BspSet<Key, Id> {\n if (root === empty || root === dense) { return root; }\n return { setOperations, root };\n}\n\nconst sparse = <Key, Exact, Left, Right>(\n left: Left,\n right: Right,\n pathKey: Key,\n key: Key,\n isExact: Exact,\n) => ({ key, pathKey, left, right, isExact });\n\nfunction fromKey<Key>(\n pathKey: Key,\n key: Key,\n isExact: boolean,\n): UntypedSparse<Key> {\n if (isExact) {\n return sparse(undefined, undefined, pathKey, key, true as const);\n }\n\n return sparse(undefined, undefined, pathKey, key, false as const);\n}\n\nexport function lazy<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n pathKey: Key,\n key: Key,\n): UntypedBspSet<Key> {\n if (!setOperations.meets(pathKey, key)) { return empty; }\n const cmp = setOperations.compare(pathKey, key);\n if (cmp !== undefined) {\n if (cmp <= 0) { return dense; }\n\n return fromKey(pathKey, key, true);\n }\n\n // this is not exactly necessary, but increases the amount of exact nodes and thus we can often\n // prune earlier.\n // Also, having intersect always work guarantees exact nodes, thus allowing for more efficient\n // storage and computation.\n const newKey = setOperations.intersect(pathKey, key);\n\n if (newKey !== undefined) {\n return fromKey(pathKey, newKey, true);\n }\n\n return fromKey(pathKey, key, false);\n}\n\nexport function createFromKey<Key extends Cachable<Key>, Id>(\n uncachedSetOperations: SetOperations<Key, Id>,\n) {\n const setOperations = {\n ...uncachedSetOperations,\n split: cacheKeySplitting(\n uncachedSetOperations.split,\n uncachedSetOperations.top,\n ),\n };\n return (key: Key) =>\n fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));\n}\n\nfunction unionExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key> & KeyExact<Key>,\n right: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n const cmp = setOperations.compare(leftKey, rightKey);\n if (cmp !== undefined) {\n return cmp < 0 ? right : left;\n }\n\n const combinedKey = setOperations.union(leftKey, rightKey);\n if (combinedKey !== undefined) {\n const combinedCmp = setOperations.compare(combinedKey, pathKey);\n if (combinedCmp !== undefined && combinedCmp === 0) { return dense; }\n return fromKey(pathKey, combinedKey, true);\n }\n return undefined;\n}\n\n/** This is an local combination, not a proper union. We use it to have simpler code elsewhere */\nfunction combineChildren<Key>(\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): Empty | Dense | (UntypedSparse<Key> & TreeDefined<Key>) {\n if (left === empty) {\n if (right === empty) {\n return empty;\n }\n\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n if (right === empty) {\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n if (left === dense) {\n if (right === dense) {\n return dense;\n }\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n return sparse(left, right, undefined, undefined, false as const);\n}\n\nfunction materialize<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n set: UntypedSparse<Key>,\n): UntypedSparse<Key> & TreeDefined<Key> {\n if (set.left !== undefined) {\n return set;\n }\n\n const [[left], [right]] = setOperations.split(set.pathKey);\n const lChild = lazy(setOperations, left, set.key);\n const rChild = lazy(setOperations, right, set.key);\n\n const res = combineChildren<Key>(lChild, rChild);\n\n if (res === empty || res === dense) {\n throw new Error(\"incorrect set operations implementation\");\n }\n\n // first check, that res actually has the desired type\n const typeCheck: TreeDefined<Key> = res;\n\n const setAlias: UntypedSparse<Key> = set;\n return ObjectAssign(setAlias, {\n left: typeCheck.left,\n right: typeCheck.right,\n });\n}\n\nexport function unionUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (right === empty) { return left; }\n if (right === dense) { return right; }\n if (left === empty) { return right; }\n if (left === dense) { return left; }\n\n if (left.isExact && right.isExact) {\n const res = unionExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = unionUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = unionUntyped(setOperations, newLeft.right, newRight.right);\n\n return combineChildren(lChild, rChild);\n}\n\nexport function union<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (right === empty) { return left; }\n if (right === dense) { return right; }\n if (left === empty) { return right; }\n if (left === dense) { return left; }\n\n return fromUntyped(\n left.setOperations,\n unionUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nfunction intersectExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key> & KeyExact<Key>,\n right: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n if (!setOperations.meets(leftKey, rightKey)) {\n return empty;\n }\n\n const cmp = setOperations.compare(leftKey, rightKey);\n if (cmp !== undefined) {\n return cmp < 0 ? left : right;\n }\n\n const combinedKey = setOperations.intersect(leftKey, rightKey);\n if (combinedKey !== undefined) {\n return fromKey(pathKey, combinedKey, true);\n }\n\n return undefined;\n}\n\nexport function intersectUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (left === empty) { return left; }\n if (right === empty) { return right; }\n if (left === dense) { return right; }\n if (right === dense) { return left; }\n\n if (left.isExact && right.isExact) {\n const res = intersectExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = intersectUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = intersectUntyped(\n setOperations,\n newLeft.right,\n newRight.right,\n );\n\n return combineChildren(lChild, rChild);\n}\n\nexport function intersect<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (left === empty) { return left; }\n if (right === empty) { return right; }\n if (left === dense) { return right; }\n if (right === dense) { return left; }\n\n return fromUntyped(\n left.setOperations,\n intersectUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nexport function meetsUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): boolean {\n if (left === empty || right === empty) { return false; }\n if (left === dense || right === dense) { return true; }\n if (left.isExact && right.isExact) { return setOperations.meets(left.key, right.key); }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n return (\n meetsUntyped(setOperations, newLeft.left, newRight.left) ||\n meetsUntyped(setOperations, newLeft.right, newRight.right)\n );\n}\n\nexport function meets<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): boolean {\n if (left === empty || right === empty) { return false; }\n if (left === dense || right === dense) { return true; }\n return meetsUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nfunction exceptExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedSparse<Key> & KeyExact<Key>,\n right: KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n if (!setOperations.meets(leftKey, rightKey)) {\n return left;\n }\n\n const combinedKey = setOperations.except(leftKey, rightKey);\n if (combinedKey !== undefined) {\n return fromKey(pathKey, combinedKey, true);\n }\n\n return undefined;\n}\n\nexport function exceptUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (left === empty) { return left; }\n if (right === empty) { return left; }\n if (right === dense) { return empty; }\n if (left === dense) {\n const newRight_inner = materialize<Key, Id>(setOperations, right);\n const lChild_inner = exceptUntyped(setOperations, dense, newRight_inner.left);\n const rChild_inner = exceptUntyped(setOperations, dense, newRight_inner.right);\n return combineChildren(lChild_inner, rChild_inner);\n }\n if (left.isExact && right.isExact) {\n const res = exceptExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = exceptUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = exceptUntyped(setOperations, newLeft.right, newRight.right);\n\n return combineChildren(lChild, rChild);\n}\n\nexport function except<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (left === empty) { return left; }\n if (right === empty) { return left; }\n if (right === dense) { return empty; }\n if (left === dense) {\n return fromUntyped(\n right.setOperations,\n exceptUntyped<Key, Id>(right.setOperations, left, right.root),\n );\n }\n\n return fromUntyped(\n left.setOperations,\n exceptUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nconst compareExact = <Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: KeyExact<Key>,\n right: KeyExact<Key>,\n) => setOperations.compare(left.key, right.key);\n\nexport function combineCmp(\n left: -1 | 0 | 1 | undefined,\n right: -1 | 0 | 1 | undefined,\n) {\n if (left === undefined || right === undefined) { return undefined; }\n if (left === 0) { return right; }\n if (right === 0) { return left; }\n return left === right ? left : undefined;\n}\n\nexport function compareUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): -1 | 0 | 1 | undefined {\n if (left === right) { return 0; }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n if (left.isExact && right.isExact) {\n return compareExact(setOperations, left, right);\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n const lCmp = compareUntyped(setOperations, newLeft.left, newRight.left);\n if (lCmp === undefined) { return undefined; }\n\n const rCmp = compareUntyped(setOperations, newLeft.right, newRight.right);\n\n if (rCmp === undefined) { return undefined; }\n\n return combineCmp(lCmp, rCmp);\n}\n\nexport function compare<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n) {\n if (left === right) { return 0; }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n return compareUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nexport const symmetricDiff = <Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n) => union(except(left, right), except(right, left));\n\nexport const complement = <Key extends Cachable<Key>, Id>(\n set: BspSet<Key, Id>,\n) => except(dense, set);\n\nfunction getNodeCountUntyped<T>(set: UntypedBspSet<T> | undefined): number {\n if (set === undefined || set === empty || set === dense) {\n return 0;\n }\n\n return getNodeCountUntyped(set.left) + getNodeCountUntyped(set.right) + 1;\n}\n\nexport function getNodeCount<Key extends Cachable<Key>, Id>(\n set: BspSet<Key, Id>,\n) {\n if (set === empty || set === dense) { return 0; }\n return getNodeCountUntyped(set.root);\n}\n\nfunction forEachKeyUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n set: UntypedBspSet<Key>,\n f: (key: Key) => boolean,\n): boolean {\n function loop(pathKey: Key, set_inner: UntypedBspSet<Key>): boolean {\n if (set_inner === empty) { return true; }\n if (set_inner === dense) { return f(pathKey); }\n if (set_inner.isExact) { return f(set_inner.key); }\n\n const newSet = materialize<Key, Id>(setOperations, set_inner);\n const [[left], [right]] = setOperations.split(pathKey);\n return loop(left, newSet.left) && loop(right, newSet.right);\n }\n\n return loop(setOperations.top, set);\n}\n\nexport function forEachKey<Key extends Cachable<Key>, Id>(\n set: Empty | Sparse<Key, Id>,\n f: (key: Key) => boolean,\n): boolean {\n if (set === empty) { return true; }\n return forEachKeyUntyped(set.setOperations, set.root, f);\n}\n"]}
@@ -6,7 +6,7 @@ import { IVectorConsumer } from "@tiny-calc/nano";
6
6
  import { Handle } from "./handletable";
7
7
  import { PermutationVector } from "./permutationvector";
8
8
  /**
9
- * Used by PermutationVector to cache position -> handle lookups.
9
+ * Used by PermutationVector to cache position -\> handle lookups.
10
10
  *
11
11
  * Perf: Possibly, this should eventually be inlined into PermutationVector itself, but
12
12
  * so far there's no measurable perf penalty for being a separate object (node 12 x64)
@@ -10,7 +10,7 @@ const common_utils_1 = require("@fluidframework/common-utils");
10
10
  const handletable_1 = require("./handletable");
11
11
  const range_1 = require("./range");
12
12
  /**
13
- * Used by PermutationVector to cache position -> handle lookups.
13
+ * Used by PermutationVector to cache position -\> handle lookups.
14
14
  *
15
15
  * Perf: Possibly, this should eventually be inlined into PermutationVector itself, but
16
16
  * so far there's no measurable perf penalty for being a separate object (node 12 x64)
@@ -49,10 +49,10 @@ class HandleCache {
49
49
  }
50
50
  /** Update the cache when a handle has been allocated for a given position. */
51
51
  addHandle(position, handle) {
52
- common_utils_1.assert(handletable_1.isHandleValid(handle), 0x017 /* "Trying to add invalid handle!" */);
52
+ (0, common_utils_1.assert)((0, handletable_1.isHandleValid)(handle), 0x017 /* "Trying to add invalid handle!" */);
53
53
  const index = this.getIndex(position);
54
54
  if (index < this.handles.length) {
55
- common_utils_1.assert(!handletable_1.isHandleValid(this.handles[index]), 0x018 /* "Trying to insert handle into position with already valid handle!" */);
55
+ (0, common_utils_1.assert)(!(0, handletable_1.isHandleValid)(this.handles[index]), 0x018 /* "Trying to insert handle into position with already valid handle!" */);
56
56
  this.handles[index] = handle;
57
57
  }
58
58
  }
@@ -85,7 +85,7 @@ class HandleCache {
85
85
  return this.handles[0];
86
86
  }
87
87
  else {
88
- range_1.ensureRange(_position, this.vector.getLength());
88
+ (0, range_1.ensureRange)(_position, this.vector.getLength());
89
89
  this.handles = this.handles.concat(this.getHandles(this.start + this.handles.length, _position + 1));
90
90
  return this.handles[this.handles.length - 1];
91
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,+DAAsD;AAEtD,+CAAsD;AAEtD,mCAAsC;AAEtC;;;;;GAKG;AACH,MAAa,WAAW;IAIpB,YAA4B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAH7C,YAAO,GAAa,EAAE,CAAC;QACvB,UAAK,GA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EAAE;QACF,4EAA4E;QAC5E,wBAAwB;QACxB,EAAE;QACF,6FAA6F;QAC7F,2EAA2E;QAC3E,EAAE;QACF,gFAAgF;QAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SAC/B;IACL,CAAC;CAGJ;AAjHD,kCAiHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationVector, PermutationSegment } from \"./permutationvector\";\nimport { ensureRange } from \"./range\";\n\n/**\n * Used by PermutationVector to cache position -> handle lookups.\n *\n * Perf: Possibly, this should eventually be inlined into PermutationVector itself, but\n * so far there's no measurable perf penalty for being a separate object (node 12 x64)\n */\nexport class HandleCache implements IVectorConsumer<Handle> {\n private handles: Handle[] = [];\n private start = 0;\n\n constructor(public readonly vector: PermutationVector) { }\n\n /**\n * Returns the index of the given position in the 'handles' array as a Uint32.\n * (If the position is not in the array, returns an integer greater than 'handles.length').\n */\n private getIndex(position: number) {\n return (position - this.start) >>> 0;\n }\n\n /**\n * Returns the handle currently assigned to the given 'position' (if any). Check\n * the result with 'isValidHandle(..)' to see if a handle has been allocated for\n * the given position.\n *\n * Throws a 'RangeError' if the provided 'position' is out-of-bounds wrt. the\n * PermutationVector's length.\n */\n public getHandle(position: number) {\n const index = this.getIndex(position);\n\n // Perf: To encourage inlining, handling of the 'cacheMiss(..)' case has been extracted\n // to a separate method.\n\n // Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer\n // checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an\n // ~40% speedup when the position is in the cache (node v12 x64).\n\n return index < this.handles.length\n ? this.handles[index]\n : this.cacheMiss(position);\n }\n\n /** Update the cache when a handle has been allocated for a given position. */\n public addHandle(position: number, handle: Handle) {\n assert(isHandleValid(handle), 0x017 /* \"Trying to add invalid handle!\" */);\n\n const index = this.getIndex(position);\n if (index < this.handles.length) {\n assert(!isHandleValid(this.handles[index]),\n 0x018 /* \"Trying to insert handle into position with already valid handle!\" */);\n this.handles[index] = handle;\n }\n }\n\n /** Used by 'CacheMiss()' to retrieve handles for a range of positions. */\n private getHandles(start: number, end: number) {\n // TODO: This can be accelerated substantially using 'walkSegments()'. The only catch\n // is that\n\n const handles: Handle[] = [];\n const { vector } = this;\n\n for (let pos = start; pos < end; pos++) {\n const { segment, offset } = vector.getContainingSegment(pos);\n const asPerm = segment as PermutationSegment;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n handles.push(asPerm.start + offset!);\n }\n\n return handles;\n }\n\n private cacheMiss(position: number) {\n // Coercing 'position' to an Uint32 allows us to handle a negative 'position' value\n // with the same logic that handles 'position' >= length.\n const _position = position >>> 0;\n\n // TODO: To bound memory usage, there should be a limit on the maximum size of\n // handle[].\n\n // TODO: To reduce MergeTree lookups, this code should opportunistically grow\n // the cache to the next MergeTree segment boundary (within the limits of\n // the handle cache).\n\n if (_position < this.start) {\n this.handles = this.getHandles(_position, this.start).concat(this.handles);\n this.start = _position;\n return this.handles[0];\n } else {\n ensureRange(_position, this.vector.getLength());\n\n this.handles = this.handles.concat(this.getHandles(this.start + this.handles.length, _position + 1));\n return this.handles[this.handles.length - 1];\n }\n }\n\n // #region IVectorConsumer\n\n itemsChanged(start: number, removedCount: number, insertedCount: number): void {\n // If positions were inserted/removed, our current policy is to trim the array\n // at the beginning of the invalidate range and lazily repopulate the handles\n // on demand.\n //\n // Some alternatives to consider that preserve the previously cached handles\n // that are still valid:\n //\n // * Eagerly populate the 'handles[]' with the newly insert values (currently guaranteed\n // to be Handle.unallocated, so we don't even need to look them up.)\n //\n // * Use a sentinel value or other mechanism to allow \"holes\" in the cache.\n\n const index = this.getIndex(start);\n if (index < this.handles.length) {\n this.handles.length = index;\n }\n }\n\n // #endregion IVectorConsumer\n}\n"]}
1
+ {"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,+DAAsD;AAEtD,+CAAsD;AAEtD,mCAAsC;AAEtC;;;;;GAKG;AACH,MAAa,WAAW;IAIpB,YAA4B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAH7C,YAAO,GAAa,EAAE,CAAC;QACvB,UAAK,GAAG,CAAC,CAAC;IAEuC,CAAC;IAE1D;;;OAGG;IACK,QAAQ,CAAC,QAAgB;QAC7B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;;OAOG;IACI,SAAS,CAAC,QAAgB;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEtC,uFAAuF;QACvF,8BAA8B;QAE9B,oFAAoF;QACpF,qFAAqF;QACrF,uEAAuE;QAEvE,OAAO,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;YAC9B,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,8EAA8E;IACvE,SAAS,CAAC,QAAgB,EAAE,MAAc;QAC7C,IAAA,qBAAM,EAAC,IAAA,2BAAa,EAAC,MAAM,CAAC,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAE3E,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAC7B,IAAA,qBAA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M,CAAC,SAAS,EAAE,CAAC,CAAC;YAEhD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC;YACrG,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAChD;IACL,CAAC;IAED,0BAA0B;IAE1B,YAAY,CAAC,KAAa,EAAE,YAAoB,EAAE,aAAqB;QACnE,8EAA8E;QAC9E,6EAA6E;QAC7E,aAAa;QACb,EAAE;QACF,4EAA4E;QAC5E,wBAAwB;QACxB,EAAE;QACF,6FAA6F;QAC7F,2EAA2E;QAC3E,EAAE;QACF,gFAAgF;QAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SAC/B;IACL,CAAC;CAGJ;AAjHD,kCAiHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationVector, PermutationSegment } from \"./permutationvector\";\nimport { ensureRange } from \"./range\";\n\n/**\n * Used by PermutationVector to cache position -\\> handle lookups.\n *\n * Perf: Possibly, this should eventually be inlined into PermutationVector itself, but\n * so far there's no measurable perf penalty for being a separate object (node 12 x64)\n */\nexport class HandleCache implements IVectorConsumer<Handle> {\n private handles: Handle[] = [];\n private start = 0;\n\n constructor(public readonly vector: PermutationVector) { }\n\n /**\n * Returns the index of the given position in the 'handles' array as a Uint32.\n * (If the position is not in the array, returns an integer greater than 'handles.length').\n */\n private getIndex(position: number) {\n return (position - this.start) >>> 0;\n }\n\n /**\n * Returns the handle currently assigned to the given 'position' (if any). Check\n * the result with 'isValidHandle(..)' to see if a handle has been allocated for\n * the given position.\n *\n * Throws a 'RangeError' if the provided 'position' is out-of-bounds wrt. the\n * PermutationVector's length.\n */\n public getHandle(position: number) {\n const index = this.getIndex(position);\n\n // Perf: To encourage inlining, handling of the 'cacheMiss(..)' case has been extracted\n // to a separate method.\n\n // Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer\n // checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an\n // ~40% speedup when the position is in the cache (node v12 x64).\n\n return index < this.handles.length\n ? this.handles[index]\n : this.cacheMiss(position);\n }\n\n /** Update the cache when a handle has been allocated for a given position. */\n public addHandle(position: number, handle: Handle) {\n assert(isHandleValid(handle), 0x017 /* \"Trying to add invalid handle!\" */);\n\n const index = this.getIndex(position);\n if (index < this.handles.length) {\n assert(!isHandleValid(this.handles[index]),\n 0x018 /* \"Trying to insert handle into position with already valid handle!\" */);\n this.handles[index] = handle;\n }\n }\n\n /** Used by 'CacheMiss()' to retrieve handles for a range of positions. */\n private getHandles(start: number, end: number) {\n // TODO: This can be accelerated substantially using 'walkSegments()'. The only catch\n // is that\n\n const handles: Handle[] = [];\n const { vector } = this;\n\n for (let pos = start; pos < end; pos++) {\n const { segment, offset } = vector.getContainingSegment(pos);\n const asPerm = segment as PermutationSegment;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n handles.push(asPerm.start + offset!);\n }\n\n return handles;\n }\n\n private cacheMiss(position: number) {\n // Coercing 'position' to an Uint32 allows us to handle a negative 'position' value\n // with the same logic that handles 'position' >= length.\n const _position = position >>> 0;\n\n // TODO: To bound memory usage, there should be a limit on the maximum size of\n // handle[].\n\n // TODO: To reduce MergeTree lookups, this code should opportunistically grow\n // the cache to the next MergeTree segment boundary (within the limits of\n // the handle cache).\n\n if (_position < this.start) {\n this.handles = this.getHandles(_position, this.start).concat(this.handles);\n this.start = _position;\n return this.handles[0];\n } else {\n ensureRange(_position, this.vector.getLength());\n\n this.handles = this.handles.concat(this.getHandles(this.start + this.handles.length, _position + 1));\n return this.handles[this.handles.length - 1];\n }\n }\n\n // #region IVectorConsumer\n\n itemsChanged(start: number, removedCount: number, insertedCount: number): void {\n // If positions were inserted/removed, our current policy is to trim the array\n // at the beginning of the invalidate range and lazily repopulate the handles\n // on demand.\n //\n // Some alternatives to consider that preserve the previously cached handles\n // that are still valid:\n //\n // * Eagerly populate the 'handles[]' with the newly insert values (currently guaranteed\n // to be Handle.unallocated, so we don't even need to look them up.)\n //\n // * Use a sentinel value or other mechanism to allow \"holes\" in the cache.\n\n const index = this.getIndex(start);\n if (index < this.handles.length) {\n this.handles.length = index;\n }\n }\n\n // #endregion IVectorConsumer\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"handletable.js","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUI,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,iBAAgB,CAAC;AAA3D,QAAA,aAAa,iBAA8C;AAExE;;GAEG;AACH,MAAa,WAAW;IACpB,4FAA4F;IAC5F,2FAA2F;IAC3F,sFAAsF;IACtF,YAAoC,UAA0B,CAAC,CAAC,CAAC;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAI,CAAC;IAE/D,KAAK;QACR,qFAAqF;QACrF,uFAAuF;QACvF,oBAAoB;QACpB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACI,QAAQ;;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,IAAI,SAAI,IAAI,CAAC,OAAO,CAAC,I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\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const enum Handle {\n /** Minimum valid handle. */\n valid = 1,\n\n /** Sentinel representing an unallocated Handle. */\n unallocated = -0x80000000,\n}\n\nexport const isHandleValid = (handle: Handle) => handle >= Handle.valid;\n\n/**\n * A handle table provides a fast mapping from an integer `handle` to a value `T`.\n */\nexport class HandleTable<T> {\n // Note: the first slot of the 'handles' array is reserved to store the pointer to the first\n // free handle. We initialize this slot with a pointer to slot '1', which will cause\n // us to delay allocate the following slot in the array on the first allocation.\n public constructor(private readonly handles: (Handle | T)[] = [1]) { }\n\n public clear() {\n // Restore the HandleTable's initial state by deleting all items in the handles array\n // and then re-inserting the value '1' in the 0th slot. (See comment at `handles` decl\n // for explanation.)\n this.handles.splice(0, this.handles.length, 1);\n }\n\n /**\n * Allocates and returns the next available handle. Note that freed handles are recycled.\n */\n public allocate(): Handle {\n const free = this.next;\n this.next = (this.handles[free] as Handle) ?? (free + 1);\n this.handles[free] = 0;\n return free;\n }\n\n /**\n * Allocates and returns the next available `count` handles.\n */\n public allocateMany(count: Handle) {\n const handles = new Uint32Array(count);\n for (let i = 0; i < count; i++) {\n handles[i] = this.allocate();\n }\n return handles;\n }\n\n /**\n * Returns the given handle to the free list.\n */\n public free(handle: Handle) {\n this.handles[handle] = this.next;\n this.next = handle;\n }\n\n /**\n * Get the value `T` associated with the given handle, if any.\n */\n public get(handle: Handle): T {\n return this.handles[handle] as T;\n }\n\n /**\n * Set the value `T` associated with the given handle.\n */\n public set(handle: Handle, value: T) {\n this.handles[handle] = value;\n }\n\n // Private helpers to get/set the head of the free list, which is stored in the 0th slot\n // of the handle array.\n private get next() { return this.handles[0] as Handle; }\n private set next(handle: Handle) { this.handles[0] = handle; }\n\n public getSummaryContent() {\n return this.handles;\n }\n\n public static load<T>(data: (Handle | T)[]) {\n return new HandleTable<T>(data);\n }\n}\n"]}
1
+ {"version":3,"file":"handletable.js","sourceRoot":"","sources":["../src/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G,CAAC,MAAc;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,MAAc,EAAE,KAAQ;QAC/B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IACjC,CAAC;IAED,wFAAwF;IACxF,uBAAuB;IACvB,IAAY,IAAI,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAW,CAAC,CAAC,CAAC;IACxD,IAAY,IAAI,CAAC,MAAc,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAEvD,iBAAiB;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAoB;QACtC,OAAO,IAAI,WAAW,CAAI,IAAI,CAAC,CAAC;IACpC,CAAC;CACJ;AApED,kCAoEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const enum Handle {\n /** Minimum valid handle. */\n valid = 1,\n\n /** Sentinel representing an unallocated Handle. */\n unallocated = -0x80000000,\n}\n\nexport const isHandleValid = (handle: Handle) => handle >= Handle.valid;\n\n/**\n * A handle table provides a fast mapping from an integer `handle` to a value `T`.\n */\nexport class HandleTable<T> {\n // Note: the first slot of the 'handles' array is reserved to store the pointer to the first\n // free handle. We initialize this slot with a pointer to slot '1', which will cause\n // us to delay allocate the following slot in the array on the first allocation.\n public constructor(private readonly handles: (Handle | T)[] = [1]) { }\n\n public clear() {\n // Restore the HandleTable's initial state by deleting all items in the handles array\n // and then re-inserting the value '1' in the 0th slot. (See comment at `handles` decl\n // for explanation.)\n this.handles.splice(0, this.handles.length, 1);\n }\n\n /**\n * Allocates and returns the next available handle. Note that freed handles are recycled.\n */\n public allocate(): Handle {\n const free = this.next;\n this.next = (this.handles[free] as Handle) ?? (free + 1);\n this.handles[free] = 0;\n return free;\n }\n\n /**\n * Allocates and returns the next available `count` handles.\n */\n public allocateMany(count: Handle) {\n const handles = new Uint32Array(count);\n for (let i = 0; i < count; i++) {\n handles[i] = this.allocate();\n }\n return handles;\n }\n\n /**\n * Returns the given handle to the free list.\n */\n public free(handle: Handle) {\n this.handles[handle] = this.next;\n this.next = handle;\n }\n\n /**\n * Get the value `T` associated with the given handle, if any.\n */\n public get(handle: Handle): T {\n return this.handles[handle] as T;\n }\n\n /**\n * Set the value `T` associated with the given handle.\n */\n public set(handle: Handle, value: T) {\n this.handles[handle] = value;\n }\n\n // Private helpers to get/set the head of the free list, which is stored in the 0th slot\n // of the handle array.\n private get next() { return this.handles[0] as Handle; }\n private set next(handle: Handle) { this.handles[0] = handle; }\n\n public getSummaryContent() {\n return this.handles;\n }\n\n public static load<T>(data: (Handle | T)[]) {\n return new HandleTable<T>(data);\n }\n}\n"]}
package/dist/matrix.d.ts CHANGED
@@ -103,6 +103,9 @@ export declare class SharedMatrix<T = any> extends SharedObject implements IMatr
103
103
  */
104
104
  private isLatestPendingWrite;
105
105
  toString(): string;
106
- protected applyStashedOp(): void;
106
+ /**
107
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
108
+ */
109
+ protected applyStashedOp(content: any): unknown;
107
110
  }
108
111
  //# sourceMappingURL=matrix.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,gBAAgB,EAGhB,YAAY,EACZ,iBAAiB,EACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E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AS;IASnB,SAAS,CAAC,SAAS;IASnB,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAyC7D,SAAS,CAAC,YAAY;IAEtB;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB;IAmBxD,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;IA6DrG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAIzB;IAGF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAIzB;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAKnC;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAKnC;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAgBrB,QAAQ;IAkBf;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;CAgDlD"}
package/dist/matrix.js CHANGED
@@ -67,7 +67,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
67
67
  * Subscribes the given IUndoConsumer to the matrix.
68
68
  */
69
69
  openUndo(consumer) {
70
- common_utils_1.assert(this.undo === undefined, 0x019 /* "SharedMatrix.openUndo() supports at most a single IUndoConsumer." */);
70
+ (0, common_utils_1.assert)(this.undo === undefined, 0x019 /* "SharedMatrix.openUndo() supports at most a single IUndoConsumer." */);
71
71
  this.undo = new undoprovider_1.MatrixUndoProvider(consumer, this, this.rows, this.cols);
72
72
  }
73
73
  // TODO: closeUndo()?
@@ -97,23 +97,23 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
97
97
  // yields an ~40% improvement in the case of a cache hit (node v12 x64)
98
98
  // Map the logical (row, col) to associated storage handles.
99
99
  const rowHandle = this.rowHandles.getHandle(row);
100
- if (handletable_1.isHandleValid(rowHandle)) {
100
+ if ((0, handletable_1.isHandleValid)(rowHandle)) {
101
101
  const colHandle = this.colHandles.getHandle(col);
102
- if (handletable_1.isHandleValid(colHandle)) {
102
+ if ((0, handletable_1.isHandleValid)(colHandle)) {
103
103
  return this.cells.getCell(rowHandle, colHandle);
104
104
  }
105
105
  }
106
106
  else {
107
107
  // If we early exit because the given rowHandle is unallocated, we still need to
108
108
  // bounds-check the 'col' parameter.
109
- range_1.ensureRange(col, this.cols.getLength());
109
+ (0, range_1.ensureRange)(col, this.cols.getLength());
110
110
  }
111
111
  return undefined;
112
112
  }
113
113
  get matrixProducer() { return this; }
114
114
  // #endregion IMatrixReader
115
115
  setCell(row, col, value) {
116
- common_utils_1.assert(0 <= row && row < this.rowCount
116
+ (0, common_utils_1.assert)(0 <= row && row < this.rowCount
117
117
  && 0 <= col && col < this.colCount, 0x01a /* "Trying to set out-of-bounds cell!" */);
118
118
  this.setCellCore(row, col, value);
119
119
  // Avoid reentrancy by raising change notifications after the op is queued.
@@ -123,7 +123,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
123
123
  }
124
124
  setCells(rowStart, colStart, colCount, values) {
125
125
  const rowCount = Math.ceil(values.length / colCount);
126
- common_utils_1.assert((0 <= rowStart && rowStart < this.rowCount)
126
+ (0, common_utils_1.assert)((0 <= rowStart && rowStart < this.rowCount)
127
127
  && (0 <= colStart && colStart < this.colCount)
128
128
  && (1 <= colCount && colCount <= (this.colCount - colStart))
129
129
  && (rowCount <= (this.rowCount - rowStart)), 0x01b /* "Trying to set multiple out-of-bounds cells!" */);
@@ -156,7 +156,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
156
156
  }
157
157
  }
158
158
  sendSetCellOp(row, col, value, rowHandle, colHandle, localSeq = this.nextLocalSeq()) {
159
- common_utils_1.assert(this.isAttached(), 0x1e2 /* "Caller must ensure 'isAttached()' before calling 'sendSetCellOp'." */);
159
+ (0, common_utils_1.assert)(this.isAttached(), 0x1e2 /* "Caller must ensure 'isAttached()' before calling 'sendSetCellOp'." */);
160
160
  const op = {
161
161
  type: ops_1.MatrixOp.set,
162
162
  row,
@@ -179,7 +179,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
179
179
  const oppositeWindow = oppositeVector.getCollabWindow();
180
180
  // Note that the comparison is '>=' because, in the case the MergeTree is regenerating ops for reconnection,
181
181
  // the MergeTree submits the op with the original 'localSeq'.
182
- common_utils_1.assert(localSeq >= oppositeWindow.localSeq, 0x01c /* "The 'localSeq' of the vector submitting an op must >= the 'localSeq' of the other vector." */);
182
+ (0, common_utils_1.assert)(localSeq >= oppositeWindow.localSeq, 0x01c /* "The 'localSeq' of the vector submitting an op must >= the 'localSeq' of the other vector." */);
183
183
  oppositeWindow.localSeq = localSeq;
184
184
  // If the SharedMatrix is local, it's state will be submitted via a Snapshot when initially connected.
185
185
  // Do not queue a message or track the pending op, as there will never be an ACK, etc.
@@ -309,10 +309,10 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
309
309
  submitLocalMessage(message, localOpMetadata) {
310
310
  // TODO: Recommend moving this assertion into SharedObject
311
311
  // (See https://github.com/microsoft/FluidFramework/issues/2559)
312
- common_utils_1.assert(this.isAttached() === true, 0x01d /* "Trying to submit message to runtime while detached!" */);
313
- super.submitLocalMessage(shared_object_base_1.makeHandlesSerializable(message, this.serializer, this.handle), localOpMetadata);
312
+ (0, common_utils_1.assert)(this.isAttached() === true, 0x01d /* "Trying to submit message to runtime while detached!" */);
313
+ super.submitLocalMessage((0, shared_object_base_1.makeHandlesSerializable)(message, this.serializer, this.handle), localOpMetadata);
314
314
  // Ensure that row/col 'localSeq' are synchronized (see 'nextLocalSeq()').
315
- common_utils_1.assert(this.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq, 0x01e /* "Row and col collab window 'localSeq' desynchronized!" */);
315
+ (0, common_utils_1.assert)(this.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq, 0x01e /* "Row and col collab window 'localSeq' desynchronized!" */);
316
316
  }
317
317
  didAttach() {
318
318
  var _a, _b;
@@ -324,7 +324,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
324
324
  }
325
325
  }
326
326
  onConnect() {
327
- common_utils_1.assert(this.rows.getCollabWindow().collaborating === this.cols.getCollabWindow().collaborating, 0x01f /* "Row and col collab window 'collaborating' status desynchronized!" */);
327
+ (0, common_utils_1.assert)(this.rows.getCollabWindow().collaborating === this.cols.getCollabWindow().collaborating, 0x01f /* "Row and col collab window 'collaborating' status desynchronized!" */);
328
328
  // Update merge tree collaboration information with new client ID and then resend pending ops
329
329
  this.rows.startOrUpdateCollaboration(this.runtime.clientId);
330
330
  this.cols.startOrUpdateCollaboration(this.runtime.clientId);
@@ -338,7 +338,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
338
338
  this.submitRowMessage(this.rows.regeneratePendingOp(content, localOpMetadata));
339
339
  break;
340
340
  default: {
341
- common_utils_1.assert(content.type === ops_1.MatrixOp.set, 0x020 /* "Unknown SharedMatrix 'op' type." */);
341
+ (0, common_utils_1.assert)(content.type === ops_1.MatrixOp.set, 0x020 /* "Unknown SharedMatrix 'op' type." */);
342
342
  const setOp = content;
343
343
  const { rowHandle, colHandle, localSeq } = localOpMetadata;
344
344
  // If there are more pending local writes to the same row/col handle, it is important
@@ -363,7 +363,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
363
363
  try {
364
364
  await this.rows.load(this.runtime, new runtime_utils_1.ObjectStoragePartition(storage, "rows" /* rows */), this.serializer);
365
365
  await this.cols.load(this.runtime, new runtime_utils_1.ObjectStoragePartition(storage, "cols" /* cols */), this.serializer);
366
- const [cellData, pendingCliSeqData] = await serialization_1.deserializeBlob(storage, "cells" /* cells */, this.serializer);
366
+ const [cellData, pendingCliSeqData] = await (0, serialization_1.deserializeBlob)(storage, "cells" /* cells */, this.serializer);
367
367
  this.cells = sparsearray2d_1.SparseArray2D.load(cellData);
368
368
  this.pending = sparsearray2d_1.SparseArray2D.load(pendingCliSeqData);
369
369
  }
@@ -372,17 +372,17 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
372
372
  }
373
373
  }
374
374
  processCore(rawMessage, local, localOpMetadata) {
375
- const msg = shared_object_base_1.parseHandles(rawMessage, this.serializer);
375
+ const msg = (0, shared_object_base_1.parseHandles)(rawMessage, this.serializer);
376
376
  const contents = msg.contents;
377
377
  switch (contents.target) {
378
378
  case "cols" /* cols */:
379
- this.cols.applyMsg(msg);
379
+ this.cols.applyMsg(msg, local);
380
380
  break;
381
381
  case "rows" /* rows */:
382
- this.rows.applyMsg(msg);
382
+ this.rows.applyMsg(msg, local);
383
383
  break;
384
384
  default: {
385
- common_utils_1.assert(contents.type === ops_1.MatrixOp.set, 0x021 /* "SharedMatrix message contents have unexpected type!" */);
385
+ (0, common_utils_1.assert)(contents.type === ops_1.MatrixOp.set, 0x021 /* "SharedMatrix message contents have unexpected type!" */);
386
386
  const { referenceSequenceNumber: refSeq, clientId } = rawMessage;
387
387
  const { row, col } = contents;
388
388
  if (local) {
@@ -403,7 +403,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
403
403
  if (adjustedCol !== undefined) {
404
404
  const rowHandle = this.rows.getAllocatedHandle(adjustedRow);
405
405
  const colHandle = this.cols.getAllocatedHandle(adjustedCol);
406
- common_utils_1.assert(handletable_1.isHandleValid(rowHandle) && handletable_1.isHandleValid(colHandle), 0x022 /* "SharedMatrix row and/or col handles are invalid!" */);
406
+ (0, common_utils_1.assert)((0, handletable_1.isHandleValid)(rowHandle) && (0, handletable_1.isHandleValid)(colHandle), 0x022 /* "SharedMatrix row and/or col handles are invalid!" */);
407
407
  // If there is a pending (unACKed) local write to the same cell, skip the current op
408
408
  // since it "happened before" the pending write.
409
409
  if (this.pending.getCell(rowHandle, colHandle) === undefined) {
@@ -433,7 +433,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
433
433
  // Note while we're awaiting the ACK for a local set, it's possible for the row/col to be
434
434
  // locally removed and the row/col handles recycled. If this happens, the pendingLocalSeq will
435
435
  // be 'undefined' or > 'localSeq'.
436
- common_utils_1.assert(!(pendingLocalSeq < localSeq),
436
+ (0, common_utils_1.assert)(!(pendingLocalSeq < localSeq),
437
437
  // eslint-disable-next-line max-len
438
438
  0x023 /* "The 'localSeq' of pending write (if any) must be <= the localSeq of the currently processed op." */);
439
439
  // If this is the most recent write to the cell by the local client, the stored localSeq
@@ -454,8 +454,43 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
454
454
  }
455
455
  return `${s}\n`;
456
456
  }
457
- applyStashedOp() {
458
- throw new Error("not implemented");
457
+ /**
458
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
459
+ */
460
+ applyStashedOp(content) {
461
+ if (content.target === "cols" /* cols */ || content.target === "rows" /* rows */) {
462
+ const op = content;
463
+ const currentVector = content.target === "cols" /* cols */ ? this.cols : this.rows;
464
+ const oppositeVector = content.target === "cols" /* cols */ ? this.rows : this.cols;
465
+ const metadata = currentVector.applyStashedOp(op);
466
+ const localSeq = currentVector.getCollabWindow().localSeq;
467
+ const oppositeWindow = oppositeVector.getCollabWindow();
468
+ (0, common_utils_1.assert)(localSeq > oppositeWindow.localSeq, 0x2d9);
469
+ oppositeWindow.localSeq = localSeq;
470
+ return metadata;
471
+ }
472
+ else {
473
+ (0, common_utils_1.assert)(content.type === ops_1.MatrixOp.set, 0x2da /* "Unknown SharedMatrix 'op' type." */);
474
+ const setOp = content;
475
+ const rowHandle = this.rows.getAllocatedHandle(setOp.row);
476
+ const colHandle = this.cols.getAllocatedHandle(setOp.col);
477
+ if (this.undo !== undefined) {
478
+ let oldValue = this.cells.getCell(rowHandle, colHandle);
479
+ if (oldValue === null) {
480
+ oldValue = undefined;
481
+ }
482
+ this.undo.cellSet(rowHandle, colHandle, oldValue);
483
+ }
484
+ this.cells.setCell(rowHandle, colHandle, setOp.value);
485
+ const localSeq = this.nextLocalSeq();
486
+ const metadata = {
487
+ rowHandle,
488
+ colHandle,
489
+ localSeq,
490
+ };
491
+ this.pending.setCell(rowHandle, colHandle, localSeq);
492
+ return metadata;
493
+ }
459
494
  }
460
495
  }
461
496
  exports.SharedMatrix = SharedMatrix;