@fluidframework/matrix 2.0.0-internal.5.3.2 → 2.0.0-internal.6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/bspSet.js +4 -1
- package/dist/bspSet.js.map +1 -1
- package/dist/handletable.js +1 -2
- package/dist/handletable.js.map +1 -1
- package/dist/matrix.js +2 -3
- package/dist/matrix.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/permutationvector.d.ts.map +1 -1
- package/dist/permutationvector.js +4 -1
- package/dist/permutationvector.js.map +1 -1
- package/dist/productSet.js +25 -24
- package/dist/productSet.js.map +1 -1
- package/dist/undoprovider.js +4 -5
- package/dist/undoprovider.js.map +1 -1
- package/lib/bspSet.js +4 -1
- package/lib/bspSet.js.map +1 -1
- package/lib/handletable.js +1 -2
- package/lib/handletable.js.map +1 -1
- package/lib/matrix.js +2 -3
- package/lib/matrix.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/permutationvector.d.ts.map +1 -1
- package/lib/permutationvector.js +5 -2
- package/lib/permutationvector.js.map +1 -1
- package/lib/productSet.js +25 -24
- package/lib/productSet.js.map +1 -1
- package/lib/undoprovider.js +4 -5
- package/lib/undoprovider.js.map +1 -1
- package/package.json +15 -15
- package/src/packageVersion.ts +1 -1
- package/src/permutationvector.ts +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @fluidframework/matrix
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.6.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
8
|
+
|
|
9
|
+
Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
|
|
10
|
+
|
|
11
|
+
## 2.0.0-internal.5.4.0
|
|
12
|
+
|
|
13
|
+
Dependency updates only.
|
|
14
|
+
|
|
3
15
|
## 2.0.0-internal.5.3.0
|
|
4
16
|
|
|
5
17
|
Dependency updates only.
|
package/dist/bspSet.js
CHANGED
|
@@ -68,7 +68,10 @@ function lazy(setOperations, pathKey, key) {
|
|
|
68
68
|
}
|
|
69
69
|
exports.lazy = lazy;
|
|
70
70
|
function createFromKey(uncachedSetOperations) {
|
|
71
|
-
const setOperations =
|
|
71
|
+
const setOperations = {
|
|
72
|
+
...uncachedSetOperations,
|
|
73
|
+
split: (0, exports.cacheKeySplitting)(uncachedSetOperations.split, uncachedSetOperations.top),
|
|
74
|
+
};
|
|
72
75
|
return (key) => fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));
|
|
73
76
|
}
|
|
74
77
|
exports.createFromKey = createFromKey;
|
package/dist/bspSet.js.map
CHANGED
|
@@ -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;IAClB,uCAAK,CAAA;IACL,uCAAK,CAAA;AACN,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,Q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,GAAoB;IAC/E,IAAI,GAAG,KAAK,aAAK,IAAI,GAAG,KAAK,aAAK,EAAE;QACnC,OAAO,CAAC,CAAC;KACT;IACD,OAAO,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AALD,oCAKC;AAED,SAAS,iBAAiB,CACzB,aAAqC,EACrC,GAAuB,EACvB,CAAwB;IAExB,SAAS,IAAI,CAAC,OAAY,EAAE,SAA6B;QACxD,IAAI,SAAS,KAAK,aAAK,EAAE;YACxB,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,SAAS,KAAK,aAAK,EAAE;YACxB,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;SAClB;QACD,IAAI,SAAS,CAAC,OAAO,EAAE;YACtB,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SACxB;QAED,MAAM,MAAM,GAAG,WAAW,CAAU,aAAa,EAAE,SAAS,CAAC,CAAC;QAC9D,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,UAAU,CACzB,GAA4B,EAC5B,CAAwB;IAExB,IAAI,GAAG,KAAK,aAAK,EAAE;QAClB,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AARD,gCAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { __assign } from \"tslib\";\n/** An interface for representing a readonly pair */\nexport type Pair<S, T = S> = readonly [S, T];\n\nexport const pair = <S, T = S>(left: S, right: T): Pair<S, T> => [left, right];\n\n// using this polyfill, because `Object.assign` is not supported in IE.\nconst ObjectAssign: typeof Object.assign = __assign;\n\nexport enum SetKind {\n\tDense,\n\tEmpty,\n}\n\ninterface TreeNode<Left, Right> {\n\treadonly left: Left;\n\treadonly right: Right;\n}\n\ninterface KeyNode<Key, Exact> {\n\treadonly key: Key;\n\treadonly pathKey: Key;\n\treadonly isExact: Exact;\n}\n\nexport type Empty = SetKind.Empty;\n\n/** The term *Dense* means that a given subset contains all the elements of its particular\n * bounds. E.g. the whole set would be dense w.r.t. the bounds of the whole space. Or\n * if a set represents an interval [a, b), then it would be dense, if there are no holes in it,\n * i.e. the set is represented exactly using the current bounds.\n */\nexport type Dense = SetKind.Dense;\n\nexport const dense = SetKind.Dense;\nexport const empty = SetKind.Empty;\n\ntype KeyUnexact<Key> = KeyNode<Key, false>;\n\n/** In the BSP-set, each node carries with it implicit bounds just by the position in the tree.\n * Furthermore, it can carry around a key. The key can either be an approximation, i.e. an upper bound\n * or it can be *exact*. Exact means, that the whole set can be exactly represented in terms of just the key.\n *\n * One might wonder, why we don't prune the tree at this point. This has to do with the fact that we are\n * representing arbitrary sets and so even though one of two sets could be represented exactly the other\n * might not be able to yet. In this case we need to unfold the key by splitting further. In order to avoid\n * excessive splitting and pruning, we just carry around the key but allow the tree to also be materialized, on-demand.\n */\ntype KeyExact<Key> = KeyNode<Key, true>;\n\ntype KeyUndefined = KeyNode<undefined, false>;\ntype KeyDefined<Key> = KeyUnexact<Key> | KeyExact<Key>;\n\ntype BalancePropertyHelper<Key, Left, Right> = TreeNode<\n\tUntypedSparse<Key> | Left,\n\tUntypedSparse<Key> | Right\n>;\n\ntype TreeDefined<Key> =\n\t| BalancePropertyHelper<Key, Empty, Dense>\n\t| BalancePropertyHelper<Key, Dense, Empty>;\ntype TreeUndefined = TreeNode<undefined, undefined>;\n\ntype KeyDefinednessProperty<Key> = KeyDefined<Key> | KeyUndefined;\n\nexport type UntypedSparse<Key> =\n\t| (KeyDefinednessProperty<Key> & TreeDefined<Key>)\n\t| (KeyDefined<Key> & TreeUndefined);\n/** The term *untyped* refers to the tree representation of a BSP set. Because BSP set trees are only compared in terms\n * of their structure, we need to ensure that cuts occur at the same exact points across all possible sets. This is\n * enforced by the fact, that at construction time, we attach an `Id` to each BSP set and only allow operations to\n * occur on sets with the same `Id`.\n *\n * The BSP set becomes *untyped*, when we drop that `Id`; now it is possible to operate on sets that are incompatible.\n * Doing this, however, allows us to store the set operations only once per set as opposed to carrying them around with\n * every node.\n */\nexport type UntypedBspSet<Key> = Empty | Dense | UntypedSparse<Key>;\n\n/** A set is considred *sparse*, if we know that w.r.t. to it's bounds it is neither empty, nor dense. */\ninterface Sparse<Key extends Cachable<Key>, Id> {\n\tsetOperations: SetOperations<Key, Id>;\n\troot: UntypedSparse<Key>;\n}\nexport type BspSet<Key extends Cachable<Key>, Id> = Empty | Dense | Sparse<Key, Id>;\n\nexport interface KeyCache<T> {\n\tdepth?: number;\n\tsplit?: Pair<Pair<CachedKey<T>, number>>;\n}\nexport type CachedKey<T> = T & KeyCache<T>;\nexport type Cachable<T> = Disjoint<keyof T, keyof KeyCache<T>>;\n\nexport type Disjoint<T, U> = [T, U] extends [Exclude<T, U>, Exclude<U, T>] ? any : never;\nexport type RequireAtLeastOne<T> = {\n\t[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n\n/** This is a concrete set operations implementation, tagged with an arbitrary id. */\nexport interface SetOperations<Key extends Cachable<Key>, Id> {\n\t/** Id here is just a phantom type, so that we can associate the various set instances together */\n\treadonly id: Id;\n\n\t/** Split the key into two. This will only be called when the current key is incomparable with an element.\n\t * E.g. this would never be called if the key is already a 1x1 rectangle. */\n\treadonly split: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>;\n\n\t/** Tells, if a given key can be split further */\n\treadonly canSplit: (key: CachedKey<Key>) => boolean;\n\n\t/** Tells if two keys overlap at all. */\n\treadonly meets: (key1: Key, key2: Key) => boolean;\n\n\t/** Intersect the keys, if it is possible to exactly respresent their intersection.\n\t * An implementation is never required to compute the intersection as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys meet and that they are incomparable.\n\t */\n\treadonly intersect: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Unions the keys, if it is possible to exactly represent their union.\n\t * An implementation is never required to compute the union as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys are incomparable.\n\t */\n\treadonly union: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Computes the set difference between two keys, if it is possible to exactly represent their set difference.\n\t * An implementation is never required to compute the difference as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys meet.\n\t */\n\treadonly except: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Compare two keys */\n\treadonly compare: (key1: Key, key2: Key) => -1 | 0 | 1 | undefined;\n\n\t/** The top element of the set. */\n\treadonly top: Key;\n}\n\nexport const cacheKeySplitting =\n\t<Key>(\n\t\tsplitFunction: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>,\n\t\ttop: CachedKey<Key>,\n\t\tmaxDepth: number = 10,\n\t) =>\n\t(key: CachedKey<Key>) => {\n\t\tif (key.split !== undefined) {\n\t\t\treturn key.split;\n\t\t}\n\n\t\tconst split = splitFunction(key);\n\t\tconst depth = key === top ? 0 : key.depth;\n\t\tif (depth !== undefined && depth < maxDepth) {\n\t\t\tkey.split = split;\n\t\t\tsplit[0][0].depth = depth + 1;\n\t\t\tsplit[1][0].depth = depth + 1;\n\t\t}\n\n\t\treturn split;\n\t};\n\nexport function fromUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\troot: UntypedBspSet<Key>,\n): BspSet<Key, Id> {\n\tif (root === empty || root === dense) {\n\t\treturn root;\n\t}\n\treturn { setOperations, root };\n}\n\nconst sparse = <Key, Exact, Left, Right>(\n\tleft: Left,\n\tright: Right,\n\tpathKey: Key,\n\tkey: Key,\n\tisExact: Exact,\n) => ({ key, pathKey, left, right, isExact });\n\nfunction fromKey<Key>(pathKey: Key, key: Key, isExact: boolean): UntypedSparse<Key> {\n\tif (isExact) {\n\t\treturn sparse(undefined, undefined, pathKey, key, true as const);\n\t}\n\n\treturn sparse(undefined, undefined, pathKey, key, false as const);\n}\n\nexport function lazy<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tpathKey: Key,\n\tkey: Key,\n): UntypedBspSet<Key> {\n\tif (!setOperations.meets(pathKey, key)) {\n\t\treturn empty;\n\t}\n\tconst cmp = setOperations.compare(pathKey, key);\n\tif (cmp !== undefined) {\n\t\tif (cmp <= 0) {\n\t\t\treturn dense;\n\t\t}\n\n\t\treturn fromKey(pathKey, key, true);\n\t}\n\n\t// this is not exactly necessary, but increases the amount of exact nodes and thus we can often\n\t// prune earlier.\n\t// Also, having intersect always work guarantees exact nodes, thus allowing for more efficient\n\t// storage and computation.\n\tconst newKey = setOperations.intersect(pathKey, key);\n\n\tif (newKey !== undefined) {\n\t\treturn fromKey(pathKey, newKey, true);\n\t}\n\n\treturn fromKey(pathKey, key, false);\n}\n\nexport function createFromKey<Key extends Cachable<Key>, Id>(\n\tuncachedSetOperations: SetOperations<Key, Id>,\n) {\n\tconst setOperations = {\n\t\t...uncachedSetOperations,\n\t\tsplit: cacheKeySplitting(uncachedSetOperations.split, uncachedSetOperations.top),\n\t};\n\treturn (key: Key) => fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));\n}\n\nfunction unionExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key> & KeyExact<Key>,\n\tright: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tconst cmp = setOperations.compare(leftKey, rightKey);\n\tif (cmp !== undefined) {\n\t\treturn cmp < 0 ? right : left;\n\t}\n\n\tconst combinedKey = setOperations.union(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\tconst combinedCmp = setOperations.compare(combinedKey, pathKey);\n\t\tif (combinedCmp !== undefined && combinedCmp === 0) {\n\t\t\treturn dense;\n\t\t}\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\treturn undefined;\n}\n\n/** This is an local combination, not a proper union. We use it to have simpler code elsewhere */\nfunction combineChildren<Key>(\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): Empty | Dense | (UntypedSparse<Key> & TreeDefined<Key>) {\n\tif (left === empty) {\n\t\tif (right === empty) {\n\t\t\treturn empty;\n\t\t}\n\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\tif (right === empty) {\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn dense;\n\t\t}\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\treturn sparse(left, right, undefined, undefined, false as const);\n}\n\nfunction materialize<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tset: UntypedSparse<Key>,\n): UntypedSparse<Key> & TreeDefined<Key> {\n\tif (set.left !== undefined) {\n\t\treturn set;\n\t}\n\n\tconst [[left], [right]] = setOperations.split(set.pathKey);\n\tconst lChild = lazy(setOperations, left, set.key);\n\tconst rChild = lazy(setOperations, right, set.key);\n\n\tconst res = combineChildren<Key>(lChild, rChild);\n\n\tif (res === empty || res === dense) {\n\t\tthrow new Error(\"incorrect set operations implementation\");\n\t}\n\n\t// first check, that res actually has the desired type\n\tconst typeCheck: TreeDefined<Key> = res;\n\n\tconst setAlias: UntypedSparse<Key> = set;\n\treturn ObjectAssign(setAlias, {\n\t\tleft: typeCheck.left,\n\t\tright: typeCheck.right,\n\t});\n}\n\nexport function unionUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn right;\n\t}\n\tif (left === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn left;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\tconst res = unionExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = unionUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = unionUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function union<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn right;\n\t}\n\tif (left === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn left;\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\tunionUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nfunction intersectExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key> & KeyExact<Key>,\n\tright: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tif (!setOperations.meets(leftKey, rightKey)) {\n\t\treturn empty;\n\t}\n\n\tconst cmp = setOperations.compare(leftKey, rightKey);\n\tif (cmp !== undefined) {\n\t\treturn cmp < 0 ? left : right;\n\t}\n\n\tconst combinedKey = setOperations.intersect(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\n\treturn undefined;\n}\n\nexport function intersectUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn right;\n\t}\n\tif (right === dense) {\n\t\treturn left;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\tconst res = intersectExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = intersectUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = intersectUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function intersect<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn right;\n\t}\n\tif (right === dense) {\n\t\treturn left;\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\tintersectUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nexport function meetsUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): boolean {\n\tif (left === empty || right === empty) {\n\t\treturn false;\n\t}\n\tif (left === dense || right === dense) {\n\t\treturn true;\n\t}\n\tif (left.isExact && right.isExact) {\n\t\treturn setOperations.meets(left.key, right.key);\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\treturn (\n\t\tmeetsUntyped(setOperations, newLeft.left, newRight.left) ||\n\t\tmeetsUntyped(setOperations, newLeft.right, newRight.right)\n\t);\n}\n\nexport function meets<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): boolean {\n\tif (left === empty || right === empty) {\n\t\treturn false;\n\t}\n\tif (left === dense || right === dense) {\n\t\treturn true;\n\t}\n\treturn meetsUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nfunction exceptExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedSparse<Key> & KeyExact<Key>,\n\tright: KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tif (!setOperations.meets(leftKey, rightKey)) {\n\t\treturn left;\n\t}\n\n\tconst combinedKey = setOperations.except(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\n\treturn undefined;\n}\n\nexport function exceptUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn empty;\n\t}\n\tif (left === dense) {\n\t\tconst newRight_inner = materialize<Key, Id>(setOperations, right);\n\t\tconst lChild_inner = exceptUntyped(setOperations, dense, newRight_inner.left);\n\t\tconst rChild_inner = exceptUntyped(setOperations, dense, newRight_inner.right);\n\t\treturn combineChildren(lChild_inner, rChild_inner);\n\t}\n\tif (left.isExact && right.isExact) {\n\t\tconst res = exceptExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = exceptUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = exceptUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function except<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn empty;\n\t}\n\tif (left === dense) {\n\t\treturn fromUntyped(\n\t\t\tright.setOperations,\n\t\t\texceptUntyped<Key, Id>(right.setOperations, left, right.root),\n\t\t);\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\texceptUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nconst compareExact = <Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: KeyExact<Key>,\n\tright: KeyExact<Key>,\n) => setOperations.compare(left.key, right.key);\n\nexport function combineCmp(left: -1 | 0 | 1 | undefined, right: -1 | 0 | 1 | undefined) {\n\tif (left === undefined || right === undefined) {\n\t\treturn undefined;\n\t}\n\tif (left === 0) {\n\t\treturn right;\n\t}\n\tif (right === 0) {\n\t\treturn left;\n\t}\n\treturn left === right ? left : undefined;\n}\n\nexport function compareUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): -1 | 0 | 1 | undefined {\n\tif (left === right) {\n\t\treturn 0;\n\t}\n\n\tif (left === empty) {\n\t\treturn -1;\n\t}\n\n\tif (right === empty) {\n\t\treturn 1;\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif (right === dense) {\n\t\treturn -1;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\treturn compareExact(setOperations, left, right);\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\tconst lCmp = compareUntyped(setOperations, newLeft.left, newRight.left);\n\tif (lCmp === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst rCmp = compareUntyped(setOperations, newLeft.right, newRight.right);\n\n\tif (rCmp === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn combineCmp(lCmp, rCmp);\n}\n\nexport function compare<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n) {\n\tif (left === right) {\n\t\treturn 0;\n\t}\n\n\tif (left === empty) {\n\t\treturn -1;\n\t}\n\n\tif (right === empty) {\n\t\treturn 1;\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif (right === dense) {\n\t\treturn -1;\n\t}\n\n\treturn compareUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nexport const symmetricDiff = <Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n) => union(except(left, right), except(right, left));\n\nexport const complement = <Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>) =>\n\texcept(dense, set);\n\nfunction getNodeCountUntyped<T>(set: UntypedBspSet<T> | undefined): number {\n\tif (set === undefined || set === empty || set === dense) {\n\t\treturn 0;\n\t}\n\n\treturn getNodeCountUntyped(set.left) + getNodeCountUntyped(set.right) + 1;\n}\n\nexport function getNodeCount<Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>) {\n\tif (set === empty || set === dense) {\n\t\treturn 0;\n\t}\n\treturn getNodeCountUntyped(set.root);\n}\n\nfunction forEachKeyUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tset: UntypedBspSet<Key>,\n\tf: (key: Key) => boolean,\n): boolean {\n\tfunction loop(pathKey: Key, set_inner: UntypedBspSet<Key>): boolean {\n\t\tif (set_inner === empty) {\n\t\t\treturn true;\n\t\t}\n\t\tif (set_inner === dense) {\n\t\t\treturn f(pathKey);\n\t\t}\n\t\tif (set_inner.isExact) {\n\t\t\treturn f(set_inner.key);\n\t\t}\n\n\t\tconst newSet = materialize<Key, Id>(setOperations, set_inner);\n\t\tconst [[left], [right]] = setOperations.split(pathKey);\n\t\treturn loop(left, newSet.left) && loop(right, newSet.right);\n\t}\n\n\treturn loop(setOperations.top, set);\n}\n\nexport function forEachKey<Key extends Cachable<Key>, Id>(\n\tset: Empty | Sparse<Key, Id>,\n\tf: (key: Key) => boolean,\n): boolean {\n\tif (set === empty) {\n\t\treturn true;\n\t}\n\treturn forEachKeyUntyped(set.setOperations, set.root, f);\n}\n"]}
|
|
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;IAClB,uCAAK,CAAA;IACL,uCAAK,CAAA;AACN,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAsBY,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AACtB,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AAuG5B,MAAM,iBAAiB,GAC7B,CACC,aAA0E,EAC1E,GAAmB,EACnB,WAAmB,EAAE,EACpB,EAAE,CACJ,CAAC,GAAmB,EAAE,EAAE;IACvB,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE;QAC5B,OAAO,GAAG,CAAC,KAAK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AI,SAAS,KAAK,aAAK,EAAE;YACxB,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,SAAS,KAAK,aAAK,EAAE;YACxB,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;SAClB;QACD,IAAI,SAAS,CAAC,OAAO,EAAE;YACtB,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SACxB;QAED,MAAM,MAAM,GAAG,WAAW,CAAU,aAAa,EAAE,SAAS,CAAC,CAAC;QAC9D,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,UAAU,CACzB,GAA4B,EAC5B,CAAwB;IAExB,IAAI,GAAG,KAAK,aAAK,EAAE;QAClB,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AARD,gCAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { __assign } from \"tslib\";\n/** An interface for representing a readonly pair */\nexport type Pair<S, T = S> = readonly [S, T];\n\nexport const pair = <S, T = S>(left: S, right: T): Pair<S, T> => [left, right];\n\n// using this polyfill, because `Object.assign` is not supported in IE.\nconst ObjectAssign: typeof Object.assign = __assign;\n\nexport enum SetKind {\n\tDense,\n\tEmpty,\n}\n\ninterface TreeNode<Left, Right> {\n\treadonly left: Left;\n\treadonly right: Right;\n}\n\ninterface KeyNode<Key, Exact> {\n\treadonly key: Key;\n\treadonly pathKey: Key;\n\treadonly isExact: Exact;\n}\n\nexport type Empty = SetKind.Empty;\n\n/** The term *Dense* means that a given subset contains all the elements of its particular\n * bounds. E.g. the whole set would be dense w.r.t. the bounds of the whole space. Or\n * if a set represents an interval [a, b), then it would be dense, if there are no holes in it,\n * i.e. the set is represented exactly using the current bounds.\n */\nexport type Dense = SetKind.Dense;\n\nexport const dense = SetKind.Dense;\nexport const empty = SetKind.Empty;\n\ntype KeyUnexact<Key> = KeyNode<Key, false>;\n\n/** In the BSP-set, each node carries with it implicit bounds just by the position in the tree.\n * Furthermore, it can carry around a key. The key can either be an approximation, i.e. an upper bound\n * or it can be *exact*. Exact means, that the whole set can be exactly represented in terms of just the key.\n *\n * One might wonder, why we don't prune the tree at this point. This has to do with the fact that we are\n * representing arbitrary sets and so even though one of two sets could be represented exactly the other\n * might not be able to yet. In this case we need to unfold the key by splitting further. In order to avoid\n * excessive splitting and pruning, we just carry around the key but allow the tree to also be materialized, on-demand.\n */\ntype KeyExact<Key> = KeyNode<Key, true>;\n\ntype KeyUndefined = KeyNode<undefined, false>;\ntype KeyDefined<Key> = KeyUnexact<Key> | KeyExact<Key>;\n\ntype BalancePropertyHelper<Key, Left, Right> = TreeNode<\n\tUntypedSparse<Key> | Left,\n\tUntypedSparse<Key> | Right\n>;\n\ntype TreeDefined<Key> =\n\t| BalancePropertyHelper<Key, Empty, Dense>\n\t| BalancePropertyHelper<Key, Dense, Empty>;\ntype TreeUndefined = TreeNode<undefined, undefined>;\n\ntype KeyDefinednessProperty<Key> = KeyDefined<Key> | KeyUndefined;\n\nexport type UntypedSparse<Key> =\n\t| (KeyDefinednessProperty<Key> & TreeDefined<Key>)\n\t| (KeyDefined<Key> & TreeUndefined);\n/** The term *untyped* refers to the tree representation of a BSP set. Because BSP set trees are only compared in terms\n * of their structure, we need to ensure that cuts occur at the same exact points across all possible sets. This is\n * enforced by the fact, that at construction time, we attach an `Id` to each BSP set and only allow operations to\n * occur on sets with the same `Id`.\n *\n * The BSP set becomes *untyped*, when we drop that `Id`; now it is possible to operate on sets that are incompatible.\n * Doing this, however, allows us to store the set operations only once per set as opposed to carrying them around with\n * every node.\n */\nexport type UntypedBspSet<Key> = Empty | Dense | UntypedSparse<Key>;\n\n/** A set is considred *sparse*, if we know that w.r.t. to it's bounds it is neither empty, nor dense. */\ninterface Sparse<Key extends Cachable<Key>, Id> {\n\tsetOperations: SetOperations<Key, Id>;\n\troot: UntypedSparse<Key>;\n}\nexport type BspSet<Key extends Cachable<Key>, Id> = Empty | Dense | Sparse<Key, Id>;\n\nexport interface KeyCache<T> {\n\tdepth?: number;\n\tsplit?: Pair<Pair<CachedKey<T>, number>>;\n}\nexport type CachedKey<T> = T & KeyCache<T>;\nexport type Cachable<T> = Disjoint<keyof T, keyof KeyCache<T>>;\n\nexport type Disjoint<T, U> = [T, U] extends [Exclude<T, U>, Exclude<U, T>] ? any : never;\nexport type RequireAtLeastOne<T> = {\n\t[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n\n/** This is a concrete set operations implementation, tagged with an arbitrary id. */\nexport interface SetOperations<Key extends Cachable<Key>, Id> {\n\t/** Id here is just a phantom type, so that we can associate the various set instances together */\n\treadonly id: Id;\n\n\t/** Split the key into two. This will only be called when the current key is incomparable with an element.\n\t * E.g. this would never be called if the key is already a 1x1 rectangle. */\n\treadonly split: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>;\n\n\t/** Tells, if a given key can be split further */\n\treadonly canSplit: (key: CachedKey<Key>) => boolean;\n\n\t/** Tells if two keys overlap at all. */\n\treadonly meets: (key1: Key, key2: Key) => boolean;\n\n\t/** Intersect the keys, if it is possible to exactly respresent their intersection.\n\t * An implementation is never required to compute the intersection as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys meet and that they are incomparable.\n\t */\n\treadonly intersect: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Unions the keys, if it is possible to exactly represent their union.\n\t * An implementation is never required to compute the union as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys are incomparable.\n\t */\n\treadonly union: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Computes the set difference between two keys, if it is possible to exactly represent their set difference.\n\t * An implementation is never required to compute the difference as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys meet.\n\t */\n\treadonly except: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Compare two keys */\n\treadonly compare: (key1: Key, key2: Key) => -1 | 0 | 1 | undefined;\n\n\t/** The top element of the set. */\n\treadonly top: Key;\n}\n\nexport const cacheKeySplitting =\n\t<Key>(\n\t\tsplitFunction: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>,\n\t\ttop: CachedKey<Key>,\n\t\tmaxDepth: number = 10,\n\t) =>\n\t(key: CachedKey<Key>) => {\n\t\tif (key.split !== undefined) {\n\t\t\treturn key.split;\n\t\t}\n\n\t\tconst split = splitFunction(key);\n\t\tconst depth = key === top ? 0 : key.depth;\n\t\tif (depth !== undefined && depth < maxDepth) {\n\t\t\tkey.split = split;\n\t\t\tsplit[0][0].depth = depth + 1;\n\t\t\tsplit[1][0].depth = depth + 1;\n\t\t}\n\n\t\treturn split;\n\t};\n\nexport function fromUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\troot: UntypedBspSet<Key>,\n): BspSet<Key, Id> {\n\tif (root === empty || root === dense) {\n\t\treturn root;\n\t}\n\treturn { setOperations, root };\n}\n\nconst sparse = <Key, Exact, Left, Right>(\n\tleft: Left,\n\tright: Right,\n\tpathKey: Key,\n\tkey: Key,\n\tisExact: Exact,\n) => ({ key, pathKey, left, right, isExact });\n\nfunction fromKey<Key>(pathKey: Key, key: Key, isExact: boolean): UntypedSparse<Key> {\n\tif (isExact) {\n\t\treturn sparse(undefined, undefined, pathKey, key, true as const);\n\t}\n\n\treturn sparse(undefined, undefined, pathKey, key, false as const);\n}\n\nexport function lazy<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tpathKey: Key,\n\tkey: Key,\n): UntypedBspSet<Key> {\n\tif (!setOperations.meets(pathKey, key)) {\n\t\treturn empty;\n\t}\n\tconst cmp = setOperations.compare(pathKey, key);\n\tif (cmp !== undefined) {\n\t\tif (cmp <= 0) {\n\t\t\treturn dense;\n\t\t}\n\n\t\treturn fromKey(pathKey, key, true);\n\t}\n\n\t// this is not exactly necessary, but increases the amount of exact nodes and thus we can often\n\t// prune earlier.\n\t// Also, having intersect always work guarantees exact nodes, thus allowing for more efficient\n\t// storage and computation.\n\tconst newKey = setOperations.intersect(pathKey, key);\n\n\tif (newKey !== undefined) {\n\t\treturn fromKey(pathKey, newKey, true);\n\t}\n\n\treturn fromKey(pathKey, key, false);\n}\n\nexport function createFromKey<Key extends Cachable<Key>, Id>(\n\tuncachedSetOperations: SetOperations<Key, Id>,\n) {\n\tconst setOperations = {\n\t\t...uncachedSetOperations,\n\t\tsplit: cacheKeySplitting(uncachedSetOperations.split, uncachedSetOperations.top),\n\t};\n\treturn (key: Key) => fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));\n}\n\nfunction unionExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key> & KeyExact<Key>,\n\tright: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tconst cmp = setOperations.compare(leftKey, rightKey);\n\tif (cmp !== undefined) {\n\t\treturn cmp < 0 ? right : left;\n\t}\n\n\tconst combinedKey = setOperations.union(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\tconst combinedCmp = setOperations.compare(combinedKey, pathKey);\n\t\tif (combinedCmp !== undefined && combinedCmp === 0) {\n\t\t\treturn dense;\n\t\t}\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\treturn undefined;\n}\n\n/** This is an local combination, not a proper union. We use it to have simpler code elsewhere */\nfunction combineChildren<Key>(\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): Empty | Dense | (UntypedSparse<Key> & TreeDefined<Key>) {\n\tif (left === empty) {\n\t\tif (right === empty) {\n\t\t\treturn empty;\n\t\t}\n\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\tif (right === empty) {\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn dense;\n\t\t}\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\treturn sparse(left, right, undefined, undefined, false as const);\n}\n\nfunction materialize<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tset: UntypedSparse<Key>,\n): UntypedSparse<Key> & TreeDefined<Key> {\n\tif (set.left !== undefined) {\n\t\treturn set;\n\t}\n\n\tconst [[left], [right]] = setOperations.split(set.pathKey);\n\tconst lChild = lazy(setOperations, left, set.key);\n\tconst rChild = lazy(setOperations, right, set.key);\n\n\tconst res = combineChildren<Key>(lChild, rChild);\n\n\tif (res === empty || res === dense) {\n\t\tthrow new Error(\"incorrect set operations implementation\");\n\t}\n\n\t// first check, that res actually has the desired type\n\tconst typeCheck: TreeDefined<Key> = res;\n\n\tconst setAlias: UntypedSparse<Key> = set;\n\treturn ObjectAssign(setAlias, {\n\t\tleft: typeCheck.left,\n\t\tright: typeCheck.right,\n\t});\n}\n\nexport function unionUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn right;\n\t}\n\tif (left === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn left;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\tconst res = unionExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = unionUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = unionUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function union<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn right;\n\t}\n\tif (left === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn left;\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\tunionUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nfunction intersectExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key> & KeyExact<Key>,\n\tright: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tif (!setOperations.meets(leftKey, rightKey)) {\n\t\treturn empty;\n\t}\n\n\tconst cmp = setOperations.compare(leftKey, rightKey);\n\tif (cmp !== undefined) {\n\t\treturn cmp < 0 ? left : right;\n\t}\n\n\tconst combinedKey = setOperations.intersect(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\n\treturn undefined;\n}\n\nexport function intersectUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn right;\n\t}\n\tif (right === dense) {\n\t\treturn left;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\tconst res = intersectExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = intersectUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = intersectUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function intersect<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn right;\n\t}\n\tif (right === dense) {\n\t\treturn left;\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\tintersectUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nexport function meetsUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): boolean {\n\tif (left === empty || right === empty) {\n\t\treturn false;\n\t}\n\tif (left === dense || right === dense) {\n\t\treturn true;\n\t}\n\tif (left.isExact && right.isExact) {\n\t\treturn setOperations.meets(left.key, right.key);\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\treturn (\n\t\tmeetsUntyped(setOperations, newLeft.left, newRight.left) ||\n\t\tmeetsUntyped(setOperations, newLeft.right, newRight.right)\n\t);\n}\n\nexport function meets<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): boolean {\n\tif (left === empty || right === empty) {\n\t\treturn false;\n\t}\n\tif (left === dense || right === dense) {\n\t\treturn true;\n\t}\n\treturn meetsUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nfunction exceptExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedSparse<Key> & KeyExact<Key>,\n\tright: KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tif (!setOperations.meets(leftKey, rightKey)) {\n\t\treturn left;\n\t}\n\n\tconst combinedKey = setOperations.except(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\n\treturn undefined;\n}\n\nexport function exceptUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn empty;\n\t}\n\tif (left === dense) {\n\t\tconst newRight_inner = materialize<Key, Id>(setOperations, right);\n\t\tconst lChild_inner = exceptUntyped(setOperations, dense, newRight_inner.left);\n\t\tconst rChild_inner = exceptUntyped(setOperations, dense, newRight_inner.right);\n\t\treturn combineChildren(lChild_inner, rChild_inner);\n\t}\n\tif (left.isExact && right.isExact) {\n\t\tconst res = exceptExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = exceptUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = exceptUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function except<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn empty;\n\t}\n\tif (left === dense) {\n\t\treturn fromUntyped(\n\t\t\tright.setOperations,\n\t\t\texceptUntyped<Key, Id>(right.setOperations, left, right.root),\n\t\t);\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\texceptUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nconst compareExact = <Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: KeyExact<Key>,\n\tright: KeyExact<Key>,\n) => setOperations.compare(left.key, right.key);\n\nexport function combineCmp(left: -1 | 0 | 1 | undefined, right: -1 | 0 | 1 | undefined) {\n\tif (left === undefined || right === undefined) {\n\t\treturn undefined;\n\t}\n\tif (left === 0) {\n\t\treturn right;\n\t}\n\tif (right === 0) {\n\t\treturn left;\n\t}\n\treturn left === right ? left : undefined;\n}\n\nexport function compareUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): -1 | 0 | 1 | undefined {\n\tif (left === right) {\n\t\treturn 0;\n\t}\n\n\tif (left === empty) {\n\t\treturn -1;\n\t}\n\n\tif (right === empty) {\n\t\treturn 1;\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif (right === dense) {\n\t\treturn -1;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\treturn compareExact(setOperations, left, right);\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\tconst lCmp = compareUntyped(setOperations, newLeft.left, newRight.left);\n\tif (lCmp === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst rCmp = compareUntyped(setOperations, newLeft.right, newRight.right);\n\n\tif (rCmp === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn combineCmp(lCmp, rCmp);\n}\n\nexport function compare<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n) {\n\tif (left === right) {\n\t\treturn 0;\n\t}\n\n\tif (left === empty) {\n\t\treturn -1;\n\t}\n\n\tif (right === empty) {\n\t\treturn 1;\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif (right === dense) {\n\t\treturn -1;\n\t}\n\n\treturn compareUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nexport const symmetricDiff = <Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n) => union(except(left, right), except(right, left));\n\nexport const complement = <Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>) =>\n\texcept(dense, set);\n\nfunction getNodeCountUntyped<T>(set: UntypedBspSet<T> | undefined): number {\n\tif (set === undefined || set === empty || set === dense) {\n\t\treturn 0;\n\t}\n\n\treturn getNodeCountUntyped(set.left) + getNodeCountUntyped(set.right) + 1;\n}\n\nexport function getNodeCount<Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>) {\n\tif (set === empty || set === dense) {\n\t\treturn 0;\n\t}\n\treturn getNodeCountUntyped(set.root);\n}\n\nfunction forEachKeyUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tset: UntypedBspSet<Key>,\n\tf: (key: Key) => boolean,\n): boolean {\n\tfunction loop(pathKey: Key, set_inner: UntypedBspSet<Key>): boolean {\n\t\tif (set_inner === empty) {\n\t\t\treturn true;\n\t\t}\n\t\tif (set_inner === dense) {\n\t\t\treturn f(pathKey);\n\t\t}\n\t\tif (set_inner.isExact) {\n\t\t\treturn f(set_inner.key);\n\t\t}\n\n\t\tconst newSet = materialize<Key, Id>(setOperations, set_inner);\n\t\tconst [[left], [right]] = setOperations.split(pathKey);\n\t\treturn loop(left, newSet.left) && loop(right, newSet.right);\n\t}\n\n\treturn loop(setOperations.top, set);\n}\n\nexport function forEachKey<Key extends Cachable<Key>, Id>(\n\tset: Empty | Sparse<Key, Id>,\n\tf: (key: Key) => boolean,\n): boolean {\n\tif (set === empty) {\n\t\treturn true;\n\t}\n\treturn forEachKeyUntyped(set.setOperations, set.root, f);\n}\n"]}
|
package/dist/handletable.js
CHANGED
|
@@ -27,9 +27,8 @@ class HandleTable {
|
|
|
27
27
|
* Allocates and returns the next available handle. Note that freed handles are recycled.
|
|
28
28
|
*/
|
|
29
29
|
allocate() {
|
|
30
|
-
var _a;
|
|
31
30
|
const free = this.next;
|
|
32
|
-
this.next =
|
|
31
|
+
this.next = this.handles[free] ?? free + 1;
|
|
33
32
|
this.handles[free] = 0;
|
|
34
33
|
return free;
|
|
35
34
|
}
|
package/dist/handletable.js.map
CHANGED
|
@@ -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;IACvB,4FAA4F;IAC5F,2FAA2F;IAC3F,sFAAsF;IACtF,YAAoC,UAA0B,CAAC,CAAC,CAAC;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAG,CAAC;IAE9D,KAAK;QACX,qFAAqF;QACrF,uFAAuF;QACvF,oBAAoB;QACpB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,QAAQ
|
|
1
|
+
{"version":3,"file":"handletable.js","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUI,MAAM,aAAa,GAAG,CAAC,MA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ACI,GAAG,CAAC,MAAc,EAAE,KAAQ;QAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,wFAAwF;IACxF,uBAAuB;IACvB,IAAY,IAAI;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAW,CAAC;IAClC,CAAC;IACD,IAAY,IAAI,CAAC,MAAc;QAC9B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC1B,CAAC;IAEM,iBAAiB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAoB;QACzC,OAAO,IAAI,WAAW,CAAI,IAAI,CAAC,CAAC;IACjC,CAAC;CACD;AAxED,kCAwEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const enum Handle {\n\t/** Minimum valid handle. */\n\tvalid = 1,\n\n\t/** Sentinel representing an unallocated Handle. */\n\tunallocated = -0x80000000,\n}\n\nexport const isHandleValid = (handle: Handle) => handle >= Handle.valid;\n\n/**\n * A handle table provides a fast mapping from an integer `handle` to a value `T`.\n */\nexport class HandleTable<T> {\n\t// Note: the first slot of the 'handles' array is reserved to store the pointer to the first\n\t// free handle. We initialize this slot with a pointer to slot '1', which will cause\n\t// us to delay allocate the following slot in the array on the first allocation.\n\tpublic constructor(private readonly handles: (Handle | T)[] = [1]) {}\n\n\tpublic clear() {\n\t\t// Restore the HandleTable's initial state by deleting all items in the handles array\n\t\t// and then re-inserting the value '1' in the 0th slot. (See comment at `handles` decl\n\t\t// for explanation.)\n\t\tthis.handles.splice(0, this.handles.length, 1);\n\t}\n\n\t/**\n\t * Allocates and returns the next available handle. Note that freed handles are recycled.\n\t */\n\tpublic allocate(): Handle {\n\t\tconst free = this.next;\n\t\tthis.next = (this.handles[free] as Handle) ?? free + 1;\n\t\tthis.handles[free] = 0;\n\t\treturn free;\n\t}\n\n\t/**\n\t * Allocates and returns the next available `count` handles.\n\t */\n\tpublic allocateMany(count: Handle) {\n\t\tconst handles = new Uint32Array(count);\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\thandles[i] = this.allocate();\n\t\t}\n\t\treturn handles;\n\t}\n\n\t/**\n\t * Returns the given handle to the free list.\n\t */\n\tpublic free(handle: Handle) {\n\t\tthis.handles[handle] = this.next;\n\t\tthis.next = handle;\n\t}\n\n\t/**\n\t * Get the value `T` associated with the given handle, if any.\n\t */\n\tpublic get(handle: Handle): T {\n\t\treturn this.handles[handle] as T;\n\t}\n\n\t/**\n\t * Set the value `T` associated with the given handle.\n\t */\n\tpublic set(handle: Handle, value: T) {\n\t\tthis.handles[handle] = value;\n\t}\n\n\t// Private helpers to get/set the head of the free list, which is stored in the 0th slot\n\t// of the handle array.\n\tprivate get next() {\n\t\treturn this.handles[0] as Handle;\n\t}\n\tprivate set next(handle: Handle) {\n\t\tthis.handles[0] = handle;\n\t}\n\n\tpublic getSummaryContent() {\n\t\treturn this.handles;\n\t}\n\n\tpublic static load<T>(data: (Handle | T)[]) {\n\t\treturn new HandleTable<T>(data);\n\t}\n}\n"]}
|
package/dist/matrix.js
CHANGED
|
@@ -305,12 +305,11 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
305
305
|
(0, common_utils_1.assert)(this.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq, 0x01e /* "Row and col collab window 'localSeq' desynchronized!" */);
|
|
306
306
|
}
|
|
307
307
|
didAttach() {
|
|
308
|
-
var _a, _b;
|
|
309
308
|
// We've attached we need to start generating and sending ops.
|
|
310
309
|
// so start collaboration and provide a default client id incase we are not connected
|
|
311
310
|
if (this.isAttached()) {
|
|
312
|
-
this.rows.startOrUpdateCollaboration(
|
|
313
|
-
this.cols.startOrUpdateCollaboration(
|
|
311
|
+
this.rows.startOrUpdateCollaboration(this.runtime.clientId ?? "attached");
|
|
312
|
+
this.cols.startOrUpdateCollaboration(this.runtime.clientId ?? "attached");
|
|
314
313
|
}
|
|
315
314
|
}
|
|
316
315
|
onConnect() {
|
package/dist/matrix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.js","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAQtD,2EAM4C;AAE5C,iEAA2F;AAE3F,2DAMoC;AACpC,+BAAiC;AACjC,2DAAmF;AACnF,mDAAgD;AAChD,uCAAgD;AAChD,+CAAsD;AACtD,mDAAkD;AAClD,mCAAsC;AAEtC,iDAAoD;AA6BpD;;;;;;;;;;;GAWG;AACH,MAAa,YACZ,SAAQ,iCAAY;IAkBpB,YACC,OAA+B,EACxB,EAAU,EACjB,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;QAHzC,OAAE,GAAF,EAAE,CAAQ;QAdD,cAAS,GAAG,IAAI,GAAG,EAAkC,CAAC;QAS/D,UAAK,GAAG,IAAI,6BAAa,EAAiB,CAAC,CAAC,sBAAsB;QAClE,YAAO,GAAG,IAAI,6BAAa,EAAU,CAAC,CAAC,yBAAyB;QA4jBxE,sFAAsF;QACrE,eAAU,GAAG,CAC7B,QAAgB,EAChB,YAAoB,EACpB,aAAqB,EACpB,EAAE;YACH,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;gBACtC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;aAClE;QACF,CAAC,CAAC;QAEF,sFAAsF;QACrE,eAAU,GAAG,CAC7B,QAAgB,EAChB,YAAoB,EACpB,aAAqB,EACpB,EAAE;YACH,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;gBACtC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,C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F,CAAC;CACD;AAltBD,oCAktBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tSerializable,\n\tIChannelAttributes,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidSerializer,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tSharedObject,\n\tSummarySerializer,\n} from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { IMatrixProducer, IMatrixConsumer, IMatrixReader, IMatrixWriter } from \"@tiny-calc/nano\";\nimport {\n\tMergeTreeDeltaType,\n\tIMergeTreeOp,\n\tSegmentGroup,\n\tClient,\n\tIJSONSegment,\n} from \"@fluidframework/merge-tree\";\nimport { MatrixOp } from \"./ops\";\nimport { PermutationVector, reinsertSegmentIntoVector } from \"./permutationvector\";\nimport { SparseArray2D } from \"./sparsearray2d\";\nimport { SharedMatrixFactory } from \"./runtime\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { ensureRange } from \"./range\";\nimport { IUndoConsumer } from \"./types\";\nimport { MatrixUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n\trows = \"rows\",\n\tcols = \"cols\",\n\tcells = \"cells\",\n}\n\ninterface ISetOp<T> {\n\ttype: MatrixOp.set;\n\trow: number;\n\tcol: number;\n\tvalue: MatrixItem<T>;\n}\n\ninterface ISetOpMetadata {\n\trowHandle: Handle;\n\tcolHandle: Handle;\n\tlocalSeq: number;\n\trowsRefSeq: number;\n\tcolsRefSeq: number;\n}\n\n/**\n * A matrix cell value may be undefined (indicating an empty cell) or any serializable type,\n * excluding null. (However, nulls may be embedded inside objects and arrays.)\n */\nexport type MatrixItem<T> = Serializable<Exclude<T, null>> | undefined;\n\n/**\n * A SharedMatrix holds a rectangular 2D array of values. Supported operations\n * include setting values and inserting/removing rows and columns.\n *\n * Matrix values may be any Fluid serializable type, which is the set of JSON\n * serializable types extended to include IFluidHandles.\n *\n * Fluid's SharedMatrix implementation works equally well for dense and sparse\n * matrix data and physically stores data in Z-order to leverage CPU caches and\n * prefetching when reading in either row or column major order. (See README.md\n * for more details.)\n */\nexport class SharedMatrix<T = any>\n\textends SharedObject\n\timplements\n\t\tIMatrixProducer<MatrixItem<T>>,\n\t\tIMatrixReader<MatrixItem<T>>,\n\t\tIMatrixWriter<MatrixItem<T>>\n{\n\tprivate readonly consumers = new Set<IMatrixConsumer<MatrixItem<T>>>();\n\n\tpublic static getFactory() {\n\t\treturn new SharedMatrixFactory();\n\t}\n\n\tprivate readonly rows: PermutationVector; // Map logical row to storage handle (if any)\n\tprivate readonly cols: PermutationVector; // Map logical col to storage handle (if any)\n\n\tprivate cells = new SparseArray2D<MatrixItem<T>>(); // Stores cell values.\n\tprivate pending = new SparseArray2D<number>(); // Tracks pending writes.\n\n\tconstructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_matrix_\");\n\n\t\tthis.rows = new PermutationVector(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onRowDelta,\n\t\t\tthis.onRowHandlesRecycled,\n\t\t);\n\n\t\tthis.cols = new PermutationVector(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onColDelta,\n\t\t\tthis.onColHandlesRecycled,\n\t\t);\n\t}\n\n\tprivate undo?: MatrixUndoProvider<T>;\n\n\t/**\n\t * Subscribes the given IUndoConsumer to the matrix.\n\t */\n\tpublic openUndo(consumer: IUndoConsumer) {\n\t\tassert(\n\t\t\tthis.undo === undefined,\n\t\t\t0x019 /* \"SharedMatrix.openUndo() supports at most a single IUndoConsumer.\" */,\n\t\t);\n\n\t\tthis.undo = new MatrixUndoProvider(consumer, this, this.rows, this.cols);\n\t}\n\n\t// TODO: closeUndo()?\n\n\tprivate get rowHandles() {\n\t\treturn this.rows.handleCache;\n\t}\n\tprivate get colHandles() {\n\t\treturn this.cols.handleCache;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic static create<T>(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedMatrixFactory.Type) as SharedMatrix<T>;\n\t}\n\n\t// #region IMatrixProducer\n\n\topenMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): IMatrixReader<MatrixItem<T>> {\n\t\tthis.consumers.add(consumer);\n\t\treturn this;\n\t}\n\n\tcloseMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): void {\n\t\tthis.consumers.delete(consumer);\n\t}\n\n\t// #endregion IMatrixProducer\n\n\t// #region IMatrixReader\n\n\tpublic get rowCount() {\n\t\treturn this.rows.getLength();\n\t}\n\tpublic get colCount() {\n\t\treturn this.cols.getLength();\n\t}\n\n\tpublic getCell(row: number, col: number): MatrixItem<T> {\n\t\t// Perf: When possible, bounds checking is performed inside the implementation for\n\t\t// 'getHandle()' so that it can be elided in the case of a cache hit. This\n\t\t// yields an ~40% improvement in the case of a cache hit (node v12 x64)\n\n\t\t// Map the logical (row, col) to associated storage handles.\n\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\tif (isHandleValid(rowHandle)) {\n\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\tif (isHandleValid(colHandle)) {\n\t\t\t\treturn this.cells.getCell(rowHandle, colHandle);\n\t\t\t}\n\t\t} else {\n\t\t\t// If we early exit because the given rowHandle is unallocated, we still need to\n\t\t\t// bounds-check the 'col' parameter.\n\t\t\tensureRange(col, this.cols.getLength());\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<MatrixItem<T>> {\n\t\treturn this;\n\t}\n\n\t// #endregion IMatrixReader\n\n\tpublic setCell(row: number, col: number, value: MatrixItem<T>) {\n\t\tassert(\n\t\t\t0 <= row && row < this.rowCount && 0 <= col && col < this.colCount,\n\t\t\t0x01a /* \"Trying to set out-of-bounds cell!\" */,\n\t\t);\n\n\t\tthis.setCellCore(row, col, value);\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(row, col, 1, 1, this);\n\t\t}\n\t}\n\n\tpublic setCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t) {\n\t\tconst rowCount = Math.ceil(values.length / colCount);\n\n\t\tassert(\n\t\t\t0 <= rowStart &&\n\t\t\t\trowStart < this.rowCount &&\n\t\t\t\t0 <= colStart &&\n\t\t\t\tcolStart < this.colCount &&\n\t\t\t\t1 <= colCount &&\n\t\t\t\tcolCount <= this.colCount - colStart &&\n\t\t\t\trowCount <= this.rowCount - rowStart,\n\t\t\t0x01b /* \"Trying to set multiple out-of-bounds cells!\" */,\n\t\t);\n\n\t\tconst endCol = colStart + colCount;\n\t\tlet r = rowStart;\n\t\tlet c = colStart;\n\n\t\tfor (const value of values) {\n\t\t\tthis.setCellCore(r, c, value);\n\n\t\t\tif (++c === endCol) {\n\t\t\t\tc = colStart;\n\t\t\t\tr++;\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(rowStart, colStart, rowCount, colCount, this);\n\t\t}\n\t}\n\n\tprivate setCellCore(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle = this.rows.getAllocatedHandle(row),\n\t\tcolHandle = this.cols.getAllocatedHandle(col),\n\t) {\n\t\tif (this.undo !== undefined) {\n\t\t\tlet oldValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\tif (oldValue === null) {\n\t\t\t\toldValue = undefined;\n\t\t\t}\n\n\t\t\tthis.undo.cellSet(rowHandle, colHandle, oldValue);\n\t\t}\n\n\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\n\t\tif (this.isAttached()) {\n\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t}\n\t}\n\n\tprivate sendSetCellOp(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tlocalSeq = this.nextLocalSeq(),\n\t\trowsRefSeq = this.rows.getCollabWindow().currentSeq,\n\t\tcolsRefSeq = this.cols.getCollabWindow().currentSeq,\n\t) {\n\t\tassert(\n\t\t\tthis.isAttached(),\n\t\t\t0x1e2 /* \"Caller must ensure 'isAttached()' before calling 'sendSetCellOp'.\" */,\n\t\t);\n\n\t\tconst op: ISetOp<T> = {\n\t\t\ttype: MatrixOp.set,\n\t\t\trow,\n\t\t\tcol,\n\t\t\tvalue,\n\t\t};\n\n\t\tconst metadata: ISetOpMetadata = {\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t\tlocalSeq,\n\t\t\trowsRefSeq,\n\t\t\tcolsRefSeq,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, metadata);\n\t\tthis.pending.setCell(rowHandle, colHandle, localSeq);\n\t}\n\n\tprivate submitVectorMessage(\n\t\tcurrentVector: PermutationVector,\n\t\toppositeVector: PermutationVector,\n\t\tdimension: SnapshotPath.rows | SnapshotPath.cols,\n\t\tmessage: any,\n\t) {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally advance each MergeTree's 'localSeq' counter\n\t\t// for each submitted op it not aware of to keep them synchronized.\n\t\tconst localSeq = currentVector.getCollabWindow().localSeq;\n\t\tconst oppositeWindow = oppositeVector.getCollabWindow();\n\n\t\t// Note that the comparison is '>=' because, in the case the MergeTree is regenerating ops for reconnection,\n\t\t// the MergeTree submits the op with the original 'localSeq'.\n\t\tassert(\n\t\t\tlocalSeq >= oppositeWindow.localSeq,\n\t\t\t0x01c /* \"The 'localSeq' of the vector submitting an op must >= the 'localSeq' of the other vector.\" */,\n\t\t);\n\n\t\toppositeWindow.localSeq = localSeq;\n\n\t\t// If the SharedMatrix is local, it's state will be submitted via a Snapshot when initially connected.\n\t\t// Do not queue a message or track the pending op, as there will never be an ACK, etc.\n\t\tif (this.isAttached()) {\n\t\t\t// Record whether this `op` targets rows or cols. (See dispatch in `processCore()`)\n\t\t\tmessage.target = dimension;\n\n\t\t\tthis.submitLocalMessage(\n\t\t\t\tmessage,\n\t\t\t\tcurrentVector.peekPendingSegmentGroups(\n\t\t\t\t\tmessage.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate submitColMessage(message: any) {\n\t\tthis.submitVectorMessage(this.cols, this.rows, SnapshotPath.cols, message);\n\t}\n\n\tpublic insertCols(colStart: number, count: number) {\n\t\tthis.submitColMessage(this.cols.insert(colStart, count));\n\t}\n\n\tpublic removeCols(colStart: number, count: number) {\n\t\tthis.submitColMessage(this.cols.remove(colStart, count));\n\t}\n\n\tprivate submitRowMessage(message: any) {\n\t\tthis.submitVectorMessage(this.rows, this.cols, SnapshotPath.rows, message);\n\t}\n\n\tpublic insertRows(rowStart: number, count: number) {\n\t\tthis.submitRowMessage(this.rows.insert(rowStart, count));\n\t}\n\n\tpublic removeRows(rowStart: number, count: number) {\n\t\tthis.submitRowMessage(this.rows.remove(rowStart, count));\n\t}\n\n\t/** @internal */ public _undoRemoveRows(rowStart: number, spec: IJSONSegment) {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.rows, rowStart, spec);\n\t\tthis.submitRowMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted rows.\n\t\tlet rowHandle = inserted.start;\n\t\tconst rowCount = inserted.cachedLength;\n\t\tfor (let row = rowStart; row < rowStart + rowCount; row++, rowHandle++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(rowStart, /* colStart: */ 0, rowCount, this.colCount, this);\n\t\t}\n\t}\n\n\t/** @internal */ public _undoRemoveCols(colStart: number, spec: IJSONSegment) {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.cols, colStart, spec);\n\t\tthis.submitColMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted cols.\n\t\tlet colHandle = inserted.start;\n\t\tconst colCount = inserted.cachedLength;\n\t\tfor (let col = colStart; col < colStart + colCount; col++, colHandle++) {\n\t\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(/* rowStart: */ 0, colStart, this.rowCount, colCount, this);\n\t\t}\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.rows.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.cols.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.cells,\n\t\t\tserializer.stringify([this.cells.snapshot(), this.pending.snapshot()], this.handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Runs serializer on the GC data for this SharedMatrix.\n\t * All the IFluidHandle's stored in the cells represent routes to other objects.\n\t */\n\tprotected processGCDataCore(serializer: SummarySerializer) {\n\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tserializer.stringify(this.getCell(row, col), this.handle);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Advances the 'localSeq' counter for the cell data operation currently being queued.\n\t *\n\t * Do not use with 'submitColMessage()/submitRowMessage()' as these helpers + the MergeTree will\n\t * automatically advance 'localSeq'.\n\t */\n\tprivate nextLocalSeq() {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally bump each MergeTree's 'localSeq' counter\n\t\t// for SharedMatrix ops it's not aware of to keep them synchronized. (For cell data operations, we\n\t\t// need to bump both counters.)\n\n\t\tthis.cols.getCollabWindow().localSeq++;\n\t\treturn ++this.rows.getCollabWindow().localSeq;\n\t}\n\n\tprotected submitLocalMessage(message: any, localOpMetadata?: any) {\n\t\t// TODO: Recommend moving this assertion into SharedObject\n\t\t// (See https://github.com/microsoft/FluidFramework/issues/2559)\n\t\tassert(\n\t\t\tthis.isAttached() === true,\n\t\t\t0x01d /* \"Trying to submit message to runtime while detached!\" */,\n\t\t);\n\n\t\tsuper.submitLocalMessage(\n\t\t\tmakeHandlesSerializable(message, this.serializer, this.handle),\n\t\t\tlocalOpMetadata,\n\t\t);\n\n\t\t// Ensure that row/col 'localSeq' are synchronized (see 'nextLocalSeq()').\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq,\n\t\t\t0x01e /* \"Row and col collab window 'localSeq' desynchronized!\" */,\n\t\t);\n\t}\n\n\tprotected didAttach() {\n\t\t// We've attached we need to start generating and sending ops.\n\t\t// so start collaboration and provide a default client id incase we are not connected\n\t\tif (this.isAttached()) {\n\t\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t}\n\t}\n\n\tprotected onConnect() {\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().collaborating === this.cols.getCollabWindow().collaborating,\n\t\t\t0x01f /* \"Row and col collab window 'collaborating' status desynchronized!\" */,\n\t\t);\n\n\t\t// Update merge tree collaboration information with new client ID and then resend pending ops\n\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t}\n\n\tprivate rebasePosition(\n\t\tclient: Client,\n\t\tpos: number,\n\t\treferenceSequenceNumber: number,\n\t\tlocalSeq: number,\n\t): number | undefined {\n\t\tconst { clientId } = client.getCollabWindow();\n\t\tconst { segment, offset } = client.getContainingSegment(\n\t\t\tpos,\n\t\t\t{ referenceSequenceNumber, clientId: client.getLongClientId(clientId) },\n\t\t\tlocalSeq,\n\t\t);\n\t\tif (segment === undefined || offset === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn client.findReconnectionPosition(segment, localSeq) + offset;\n\t}\n\n\tprotected reSubmitCore(content: any, localOpMetadata: unknown) {\n\t\tswitch (content.target) {\n\t\t\tcase SnapshotPath.cols:\n\t\t\t\tthis.submitColMessage(\n\t\t\t\t\tthis.cols.regeneratePendingOp(\n\t\t\t\t\t\tcontent as IMergeTreeOp,\n\t\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase SnapshotPath.rows:\n\t\t\t\tthis.submitRowMessage(\n\t\t\t\t\tthis.rows.regeneratePendingOp(\n\t\t\t\t\t\tcontent as IMergeTreeOp,\n\t\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tassert(\n\t\t\t\t\tcontent.type === MatrixOp.set,\n\t\t\t\t\t0x020 /* \"Unknown SharedMatrix 'op' type.\" */,\n\t\t\t\t);\n\n\t\t\t\tconst setOp = content as ISetOp<T>;\n\t\t\t\tconst { rowHandle, colHandle, localSeq, rowsRefSeq, colsRefSeq } =\n\t\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\n\t\t\t\t// If there are more pending local writes to the same row/col handle, it is important\n\t\t\t\t// to skip resubmitting this op since it is possible the row/col handle has been recycled\n\t\t\t\t// and now refers to a different position than when this op was originally submitted.\n\t\t\t\tif (this.isLatestPendingWrite(rowHandle, colHandle, localSeq)) {\n\t\t\t\t\tconst row = this.rebasePosition(this.rows, setOp.row, rowsRefSeq, localSeq);\n\t\t\t\t\tconst col = this.rebasePosition(this.cols, setOp.col, colsRefSeq, localSeq);\n\n\t\t\t\t\tif (row !== undefined && col !== undefined && row >= 0 && col >= 0) {\n\t\t\t\t\t\tthis.sendSetCellOp(\n\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\tcol,\n\t\t\t\t\t\t\tsetOp.value,\n\t\t\t\t\t\t\trowHandle,\n\t\t\t\t\t\t\tcolHandle,\n\t\t\t\t\t\t\tlocalSeq,\n\t\t\t\t\t\t\trowsRefSeq,\n\t\t\t\t\t\t\tcolsRefSeq,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onDisconnect() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService) {\n\t\ttry {\n\t\t\tawait this.rows.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.rows),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tawait this.cols.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.cols),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tconst [cellData, pendingCliSeqData] = await deserializeBlob(\n\t\t\t\tstorage,\n\t\t\t\tSnapshotPath.cells,\n\t\t\t\tthis.serializer,\n\t\t\t);\n\n\t\t\tthis.cells = SparseArray2D.load(cellData);\n\t\t\tthis.pending = SparseArray2D.load(pendingCliSeqData);\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"MatrixLoadFailed\" }, error);\n\t\t}\n\t}\n\n\tprotected processCore(\n\t\trawMessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\tconst msg = parseHandles(rawMessage, this.serializer);\n\n\t\tconst contents = msg.contents;\n\n\t\tswitch (contents.target) {\n\t\t\tcase SnapshotPath.cols:\n\t\t\t\tthis.cols.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\tcase SnapshotPath.rows:\n\t\t\t\tthis.rows.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tassert(\n\t\t\t\t\tcontents.type === MatrixOp.set,\n\t\t\t\t\t0x021 /* \"SharedMatrix message contents have unexpected type!\" */,\n\t\t\t\t);\n\n\t\t\t\tconst { row, col } = contents;\n\n\t\t\t\tif (local) {\n\t\t\t\t\t// We are receiving the ACK for a local pending set operation.\n\t\t\t\t\tconst { rowHandle, colHandle, localSeq } = localOpMetadata as ISetOpMetadata;\n\n\t\t\t\t\t// If this is the most recent write to the cell by the local client, remove our\n\t\t\t\t\t// entry from 'pendingCliSeqs' to resume allowing remote writes.\n\t\t\t\t\tif (this.isLatestPendingWrite(rowHandle, colHandle, localSeq)) {\n\t\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst adjustedRow = this.rows.adjustPosition(row, rawMessage);\n\n\t\t\t\t\tif (adjustedRow !== undefined) {\n\t\t\t\t\t\tconst adjustedCol = this.cols.adjustPosition(col, rawMessage);\n\n\t\t\t\t\t\tif (adjustedCol !== undefined) {\n\t\t\t\t\t\t\tconst rowHandle = this.rows.getAllocatedHandle(adjustedRow);\n\t\t\t\t\t\t\tconst colHandle = this.cols.getAllocatedHandle(adjustedCol);\n\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t\t\t\t\t\t0x022 /* \"SharedMatrix row and/or col handles are invalid!\" */,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// If there is a pending (unACKed) local write to the same cell, skip the current op\n\t\t\t\t\t\t\t// since it \"happened before\" the pending write.\n\t\t\t\t\t\t\tif (this.pending.getCell(rowHandle, colHandle) === undefined) {\n\t\t\t\t\t\t\t\tconst { value } = contents;\n\t\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow, adjustedCol, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\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}\n\t}\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of row insertion/deletions.\n\tprivate readonly onRowDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t) => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.rowsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of col insertion/deletions.\n\tprivate readonly onColDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t) => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.colsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\tprivate readonly onRowHandlesRecycled = (rowHandles: Handle[]) => {\n\t\tfor (const rowHandle of rowHandles) {\n\t\t\tthis.cells.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tthis.pending.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t}\n\t};\n\n\tprivate readonly onColHandlesRecycled = (colHandles: Handle[]) => {\n\t\tfor (const colHandle of colHandles) {\n\t\t\tthis.cells.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tthis.pending.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t}\n\t};\n\n\t/**\n\t * Returns true if the latest pending write to the cell indicated by the given row/col handles\n\t * matches the given 'localSeq'.\n\t *\n\t * A return value of `true` indicates that there are no later local operations queued that will\n\t * clobber the write op at the given 'localSeq'. This includes later ops that overwrite the cell\n\t * with a different value as well as row/col removals that might recycled the given row/col handles.\n\t */\n\tprivate isLatestPendingWrite(rowHandle: Handle, colHandle: Handle, localSeq: number) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst pendingLocalSeq = this.pending.getCell(rowHandle, colHandle)!;\n\n\t\t// Note while we're awaiting the ACK for a local set, it's possible for the row/col to be\n\t\t// locally removed and the row/col handles recycled. If this happens, the pendingLocalSeq will\n\t\t// be 'undefined' or > 'localSeq'.\n\t\tassert(\n\t\t\t!(pendingLocalSeq < localSeq),\n\t\t\t0x023 /* \"The 'localSeq' of pending write (if any) must be <= the localSeq of the currently processed op.\" */,\n\t\t);\n\n\t\t// If this is the most recent write to the cell by the local client, the stored localSeq\n\t\t// will be an exact match for the given 'localSeq'.\n\t\treturn pendingLocalSeq === localSeq;\n\t}\n\n\tpublic toString() {\n\t\tlet s = `client:${\n\t\t\tthis.runtime.clientId\n\t\t}\\nrows: ${this.rows.toString()}\\ncols: ${this.cols.toString()}\\n\\n`;\n\n\t\tfor (let r = 0; r < this.rowCount; r++) {\n\t\t\ts += ` [`;\n\t\t\tfor (let c = 0; c < this.colCount; c++) {\n\t\t\t\tif (c > 0) {\n\t\t\t\t\ts += \", \";\n\t\t\t\t}\n\n\t\t\t\ts += `${this.serializer.stringify(this.getCell(r, c), this.handle)}`;\n\t\t\t}\n\t\t\ts += \"]\\n\";\n\t\t}\n\n\t\treturn `${s}\\n`;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(content: any): unknown {\n\t\tif (content.target === SnapshotPath.cols || content.target === SnapshotPath.rows) {\n\t\t\tconst op = content as IMergeTreeOp;\n\t\t\tconst currentVector = content.target === SnapshotPath.cols ? this.cols : this.rows;\n\t\t\tconst oppositeVector = content.target === SnapshotPath.cols ? this.rows : this.cols;\n\t\t\tconst metadata = currentVector.applyStashedOp(op);\n\t\t\tconst localSeq = currentVector.getCollabWindow().localSeq;\n\t\t\tconst oppositeWindow = oppositeVector.getCollabWindow();\n\n\t\t\tassert(\n\t\t\t\tlocalSeq > oppositeWindow.localSeq,\n\t\t\t\t0x2d9,\n\t\t\t\t/* \"The 'localSeq' of the vector applying stashed op must > the 'localSeq' of the other vector.\" */\n\t\t\t);\n\n\t\t\toppositeWindow.localSeq = localSeq;\n\n\t\t\treturn metadata;\n\t\t} else {\n\t\t\tassert(content.type === MatrixOp.set, 0x2da /* \"Unknown SharedMatrix 'op' type.\" */);\n\n\t\t\tconst setOp = content as ISetOp<T>;\n\t\t\tconst rowHandle = this.rows.getAllocatedHandle(setOp.row);\n\t\t\tconst colHandle = this.cols.getAllocatedHandle(setOp.col);\n\t\t\tconst rowsRefSeq = this.rows.getCollabWindow().currentSeq;\n\t\t\tconst colsRefSeq = this.cols.getCollabWindow().currentSeq;\n\t\t\tif (this.undo !== undefined) {\n\t\t\t\tlet oldValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (oldValue === null) {\n\t\t\t\t\toldValue = undefined;\n\t\t\t\t}\n\n\t\t\t\tthis.undo.cellSet(rowHandle, colHandle, oldValue);\n\t\t\t}\n\n\t\t\tthis.cells.setCell(rowHandle, colHandle, setOp.value);\n\t\t\tconst localSeq = this.nextLocalSeq();\n\t\t\tconst metadata: ISetOpMetadata = {\n\t\t\t\trowHandle,\n\t\t\t\tcolHandle,\n\t\t\t\tlocalSeq,\n\t\t\t\trowsRefSeq,\n\t\t\t\tcolsRefSeq,\n\t\t\t};\n\n\t\t\tthis.pending.setCell(rowHandle, colHandle, localSeq);\n\t\t\treturn metadata;\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"matrix.js","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAQtD,2EAM4C;AAE5C,iEAA2F;AAE3F,2DAMoC;AACpC,+BAAiC;AACjC,2DAAmF;AACnF,mDAAgD;AAChD,uCAAgD;AAChD,+CAAsD;AACtD,mDAAkD;AAClD,mCAAsC;AAEtC,iDAAoD;AA6BpD;;;;;;;;;;;GAWG;AACH,MAAa,YACZ,SAAQ,iCAAY;IAkBpB,YACC,OAA+B,EACxB,EAAU,EACjB,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;QAHzC,OAAE,GAAF,EAAE,CAAQ;QAdD,cAAS,GAAG,IAAI,GAAG,EAAkC,CAAC;QAS/D,UAAK,GAAG,IAAI,6BAAa,EAAiB,CAAC,CAAC,sBAAsB;QAClE,YAAO,GAAG,IAAI,6BAA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AG,SAAS,CAAC;iBACrB;gBAED,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;aAClD;YAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YACrC,MAAM,QAAQ,GAAmB;gBAChC,SAAS;gBACT,SAAS;gBACT,QAAQ;gBACR,UAAU;gBACV,UAAU;aACV,CAAC;YAEF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YACrD,OAAO,QAAQ,CAAC;SAChB;IACF,CAAC;CACD;AAltBD,oCAktBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tSerializable,\n\tIChannelAttributes,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidSerializer,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tSharedObject,\n\tSummarySerializer,\n} from \"@fluidframework/shared-object-base\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ObjectStoragePartition, SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { IMatrixProducer, IMatrixConsumer, IMatrixReader, IMatrixWriter } from \"@tiny-calc/nano\";\nimport {\n\tMergeTreeDeltaType,\n\tIMergeTreeOp,\n\tSegmentGroup,\n\tClient,\n\tIJSONSegment,\n} from \"@fluidframework/merge-tree\";\nimport { MatrixOp } from \"./ops\";\nimport { PermutationVector, reinsertSegmentIntoVector } from \"./permutationvector\";\nimport { SparseArray2D } from \"./sparsearray2d\";\nimport { SharedMatrixFactory } from \"./runtime\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { deserializeBlob } from \"./serialization\";\nimport { ensureRange } from \"./range\";\nimport { IUndoConsumer } from \"./types\";\nimport { MatrixUndoProvider } from \"./undoprovider\";\n\nconst enum SnapshotPath {\n\trows = \"rows\",\n\tcols = \"cols\",\n\tcells = \"cells\",\n}\n\ninterface ISetOp<T> {\n\ttype: MatrixOp.set;\n\trow: number;\n\tcol: number;\n\tvalue: MatrixItem<T>;\n}\n\ninterface ISetOpMetadata {\n\trowHandle: Handle;\n\tcolHandle: Handle;\n\tlocalSeq: number;\n\trowsRefSeq: number;\n\tcolsRefSeq: number;\n}\n\n/**\n * A matrix cell value may be undefined (indicating an empty cell) or any serializable type,\n * excluding null. (However, nulls may be embedded inside objects and arrays.)\n */\nexport type MatrixItem<T> = Serializable<Exclude<T, null>> | undefined;\n\n/**\n * A SharedMatrix holds a rectangular 2D array of values. Supported operations\n * include setting values and inserting/removing rows and columns.\n *\n * Matrix values may be any Fluid serializable type, which is the set of JSON\n * serializable types extended to include IFluidHandles.\n *\n * Fluid's SharedMatrix implementation works equally well for dense and sparse\n * matrix data and physically stores data in Z-order to leverage CPU caches and\n * prefetching when reading in either row or column major order. (See README.md\n * for more details.)\n */\nexport class SharedMatrix<T = any>\n\textends SharedObject\n\timplements\n\t\tIMatrixProducer<MatrixItem<T>>,\n\t\tIMatrixReader<MatrixItem<T>>,\n\t\tIMatrixWriter<MatrixItem<T>>\n{\n\tprivate readonly consumers = new Set<IMatrixConsumer<MatrixItem<T>>>();\n\n\tpublic static getFactory() {\n\t\treturn new SharedMatrixFactory();\n\t}\n\n\tprivate readonly rows: PermutationVector; // Map logical row to storage handle (if any)\n\tprivate readonly cols: PermutationVector; // Map logical col to storage handle (if any)\n\n\tprivate cells = new SparseArray2D<MatrixItem<T>>(); // Stores cell values.\n\tprivate pending = new SparseArray2D<number>(); // Tracks pending writes.\n\n\tconstructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_matrix_\");\n\n\t\tthis.rows = new PermutationVector(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onRowDelta,\n\t\t\tthis.onRowHandlesRecycled,\n\t\t);\n\n\t\tthis.cols = new PermutationVector(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.logger,\n\t\t\truntime,\n\t\t\tthis.onColDelta,\n\t\t\tthis.onColHandlesRecycled,\n\t\t);\n\t}\n\n\tprivate undo?: MatrixUndoProvider<T>;\n\n\t/**\n\t * Subscribes the given IUndoConsumer to the matrix.\n\t */\n\tpublic openUndo(consumer: IUndoConsumer) {\n\t\tassert(\n\t\t\tthis.undo === undefined,\n\t\t\t0x019 /* \"SharedMatrix.openUndo() supports at most a single IUndoConsumer.\" */,\n\t\t);\n\n\t\tthis.undo = new MatrixUndoProvider(consumer, this, this.rows, this.cols);\n\t}\n\n\t// TODO: closeUndo()?\n\n\tprivate get rowHandles() {\n\t\treturn this.rows.handleCache;\n\t}\n\tprivate get colHandles() {\n\t\treturn this.cols.handleCache;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic static create<T>(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedMatrixFactory.Type) as SharedMatrix<T>;\n\t}\n\n\t// #region IMatrixProducer\n\n\topenMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): IMatrixReader<MatrixItem<T>> {\n\t\tthis.consumers.add(consumer);\n\t\treturn this;\n\t}\n\n\tcloseMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): void {\n\t\tthis.consumers.delete(consumer);\n\t}\n\n\t// #endregion IMatrixProducer\n\n\t// #region IMatrixReader\n\n\tpublic get rowCount() {\n\t\treturn this.rows.getLength();\n\t}\n\tpublic get colCount() {\n\t\treturn this.cols.getLength();\n\t}\n\n\tpublic getCell(row: number, col: number): MatrixItem<T> {\n\t\t// Perf: When possible, bounds checking is performed inside the implementation for\n\t\t// 'getHandle()' so that it can be elided in the case of a cache hit. This\n\t\t// yields an ~40% improvement in the case of a cache hit (node v12 x64)\n\n\t\t// Map the logical (row, col) to associated storage handles.\n\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\tif (isHandleValid(rowHandle)) {\n\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\tif (isHandleValid(colHandle)) {\n\t\t\t\treturn this.cells.getCell(rowHandle, colHandle);\n\t\t\t}\n\t\t} else {\n\t\t\t// If we early exit because the given rowHandle is unallocated, we still need to\n\t\t\t// bounds-check the 'col' parameter.\n\t\t\tensureRange(col, this.cols.getLength());\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<MatrixItem<T>> {\n\t\treturn this;\n\t}\n\n\t// #endregion IMatrixReader\n\n\tpublic setCell(row: number, col: number, value: MatrixItem<T>) {\n\t\tassert(\n\t\t\t0 <= row && row < this.rowCount && 0 <= col && col < this.colCount,\n\t\t\t0x01a /* \"Trying to set out-of-bounds cell!\" */,\n\t\t);\n\n\t\tthis.setCellCore(row, col, value);\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(row, col, 1, 1, this);\n\t\t}\n\t}\n\n\tpublic setCells(\n\t\trowStart: number,\n\t\tcolStart: number,\n\t\tcolCount: number,\n\t\tvalues: readonly MatrixItem<T>[],\n\t) {\n\t\tconst rowCount = Math.ceil(values.length / colCount);\n\n\t\tassert(\n\t\t\t0 <= rowStart &&\n\t\t\t\trowStart < this.rowCount &&\n\t\t\t\t0 <= colStart &&\n\t\t\t\tcolStart < this.colCount &&\n\t\t\t\t1 <= colCount &&\n\t\t\t\tcolCount <= this.colCount - colStart &&\n\t\t\t\trowCount <= this.rowCount - rowStart,\n\t\t\t0x01b /* \"Trying to set multiple out-of-bounds cells!\" */,\n\t\t);\n\n\t\tconst endCol = colStart + colCount;\n\t\tlet r = rowStart;\n\t\tlet c = colStart;\n\n\t\tfor (const value of values) {\n\t\t\tthis.setCellCore(r, c, value);\n\n\t\t\tif (++c === endCol) {\n\t\t\t\tc = colStart;\n\t\t\t\tr++;\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(rowStart, colStart, rowCount, colCount, this);\n\t\t}\n\t}\n\n\tprivate setCellCore(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle = this.rows.getAllocatedHandle(row),\n\t\tcolHandle = this.cols.getAllocatedHandle(col),\n\t) {\n\t\tif (this.undo !== undefined) {\n\t\t\tlet oldValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\tif (oldValue === null) {\n\t\t\t\toldValue = undefined;\n\t\t\t}\n\n\t\t\tthis.undo.cellSet(rowHandle, colHandle, oldValue);\n\t\t}\n\n\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\n\t\tif (this.isAttached()) {\n\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t}\n\t}\n\n\tprivate sendSetCellOp(\n\t\trow: number,\n\t\tcol: number,\n\t\tvalue: MatrixItem<T>,\n\t\trowHandle: Handle,\n\t\tcolHandle: Handle,\n\t\tlocalSeq = this.nextLocalSeq(),\n\t\trowsRefSeq = this.rows.getCollabWindow().currentSeq,\n\t\tcolsRefSeq = this.cols.getCollabWindow().currentSeq,\n\t) {\n\t\tassert(\n\t\t\tthis.isAttached(),\n\t\t\t0x1e2 /* \"Caller must ensure 'isAttached()' before calling 'sendSetCellOp'.\" */,\n\t\t);\n\n\t\tconst op: ISetOp<T> = {\n\t\t\ttype: MatrixOp.set,\n\t\t\trow,\n\t\t\tcol,\n\t\t\tvalue,\n\t\t};\n\n\t\tconst metadata: ISetOpMetadata = {\n\t\t\trowHandle,\n\t\t\tcolHandle,\n\t\t\tlocalSeq,\n\t\t\trowsRefSeq,\n\t\t\tcolsRefSeq,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, metadata);\n\t\tthis.pending.setCell(rowHandle, colHandle, localSeq);\n\t}\n\n\tprivate submitVectorMessage(\n\t\tcurrentVector: PermutationVector,\n\t\toppositeVector: PermutationVector,\n\t\tdimension: SnapshotPath.rows | SnapshotPath.cols,\n\t\tmessage: any,\n\t) {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally advance each MergeTree's 'localSeq' counter\n\t\t// for each submitted op it not aware of to keep them synchronized.\n\t\tconst localSeq = currentVector.getCollabWindow().localSeq;\n\t\tconst oppositeWindow = oppositeVector.getCollabWindow();\n\n\t\t// Note that the comparison is '>=' because, in the case the MergeTree is regenerating ops for reconnection,\n\t\t// the MergeTree submits the op with the original 'localSeq'.\n\t\tassert(\n\t\t\tlocalSeq >= oppositeWindow.localSeq,\n\t\t\t0x01c /* \"The 'localSeq' of the vector submitting an op must >= the 'localSeq' of the other vector.\" */,\n\t\t);\n\n\t\toppositeWindow.localSeq = localSeq;\n\n\t\t// If the SharedMatrix is local, it's state will be submitted via a Snapshot when initially connected.\n\t\t// Do not queue a message or track the pending op, as there will never be an ACK, etc.\n\t\tif (this.isAttached()) {\n\t\t\t// Record whether this `op` targets rows or cols. (See dispatch in `processCore()`)\n\t\t\tmessage.target = dimension;\n\n\t\t\tthis.submitLocalMessage(\n\t\t\t\tmessage,\n\t\t\t\tcurrentVector.peekPendingSegmentGroups(\n\t\t\t\t\tmessage.type === MergeTreeDeltaType.GROUP ? message.ops.length : 1,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate submitColMessage(message: any) {\n\t\tthis.submitVectorMessage(this.cols, this.rows, SnapshotPath.cols, message);\n\t}\n\n\tpublic insertCols(colStart: number, count: number) {\n\t\tthis.submitColMessage(this.cols.insert(colStart, count));\n\t}\n\n\tpublic removeCols(colStart: number, count: number) {\n\t\tthis.submitColMessage(this.cols.remove(colStart, count));\n\t}\n\n\tprivate submitRowMessage(message: any) {\n\t\tthis.submitVectorMessage(this.rows, this.cols, SnapshotPath.rows, message);\n\t}\n\n\tpublic insertRows(rowStart: number, count: number) {\n\t\tthis.submitRowMessage(this.rows.insert(rowStart, count));\n\t}\n\n\tpublic removeRows(rowStart: number, count: number) {\n\t\tthis.submitRowMessage(this.rows.remove(rowStart, count));\n\t}\n\n\t/** @internal */ public _undoRemoveRows(rowStart: number, spec: IJSONSegment) {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.rows, rowStart, spec);\n\t\tthis.submitRowMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted rows.\n\t\tlet rowHandle = inserted.start;\n\t\tconst rowCount = inserted.cachedLength;\n\t\tfor (let row = rowStart; row < rowStart + rowCount; row++, rowHandle++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tconst colHandle = this.colHandles.getHandle(col);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(rowStart, /* colStart: */ 0, rowCount, this.colCount, this);\n\t\t}\n\t}\n\n\t/** @internal */ public _undoRemoveCols(colStart: number, spec: IJSONSegment) {\n\t\tconst { op, inserted } = reinsertSegmentIntoVector(this.cols, colStart, spec);\n\t\tthis.submitColMessage(op);\n\n\t\t// Generate setCell ops for each populated cell in the reinserted cols.\n\t\tlet colHandle = inserted.start;\n\t\tconst colCount = inserted.cachedLength;\n\t\tfor (let col = colStart; col < colStart + colCount; col++, colHandle++) {\n\t\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\t\tconst rowHandle = this.rowHandles.getHandle(row);\n\t\t\t\tconst value = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (this.isAttached() && value !== undefined && value !== null) {\n\t\t\t\t\tthis.sendSetCellOp(row, col, value, rowHandle, colHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Avoid reentrancy by raising change notifications after the op is queued.\n\t\tfor (const consumer of this.consumers.values()) {\n\t\t\tconsumer.cellsChanged(/* rowStart: */ 0, colStart, this.rowCount, colCount, this);\n\t\t}\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.rows,\n\t\t\tthis.rows.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.cols,\n\t\t\tthis.cols.summarize(this.runtime, this.handle, serializer),\n\t\t);\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.cells,\n\t\t\tserializer.stringify([this.cells.snapshot(), this.pending.snapshot()], this.handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\t/**\n\t * Runs serializer on the GC data for this SharedMatrix.\n\t * All the IFluidHandle's stored in the cells represent routes to other objects.\n\t */\n\tprotected processGCDataCore(serializer: SummarySerializer) {\n\t\tfor (let row = 0; row < this.rowCount; row++) {\n\t\t\tfor (let col = 0; col < this.colCount; col++) {\n\t\t\t\tserializer.stringify(this.getCell(row, col), this.handle);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Advances the 'localSeq' counter for the cell data operation currently being queued.\n\t *\n\t * Do not use with 'submitColMessage()/submitRowMessage()' as these helpers + the MergeTree will\n\t * automatically advance 'localSeq'.\n\t */\n\tprivate nextLocalSeq() {\n\t\t// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors\n\t\t// and the SharedMatrix's cell data. Instead, we externally bump each MergeTree's 'localSeq' counter\n\t\t// for SharedMatrix ops it's not aware of to keep them synchronized. (For cell data operations, we\n\t\t// need to bump both counters.)\n\n\t\tthis.cols.getCollabWindow().localSeq++;\n\t\treturn ++this.rows.getCollabWindow().localSeq;\n\t}\n\n\tprotected submitLocalMessage(message: any, localOpMetadata?: any) {\n\t\t// TODO: Recommend moving this assertion into SharedObject\n\t\t// (See https://github.com/microsoft/FluidFramework/issues/2559)\n\t\tassert(\n\t\t\tthis.isAttached() === true,\n\t\t\t0x01d /* \"Trying to submit message to runtime while detached!\" */,\n\t\t);\n\n\t\tsuper.submitLocalMessage(\n\t\t\tmakeHandlesSerializable(message, this.serializer, this.handle),\n\t\t\tlocalOpMetadata,\n\t\t);\n\n\t\t// Ensure that row/col 'localSeq' are synchronized (see 'nextLocalSeq()').\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq,\n\t\t\t0x01e /* \"Row and col collab window 'localSeq' desynchronized!\" */,\n\t\t);\n\t}\n\n\tprotected didAttach() {\n\t\t// We've attached we need to start generating and sending ops.\n\t\t// so start collaboration and provide a default client id incase we are not connected\n\t\tif (this.isAttached()) {\n\t\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId ?? \"attached\");\n\t\t}\n\t}\n\n\tprotected onConnect() {\n\t\tassert(\n\t\t\tthis.rows.getCollabWindow().collaborating === this.cols.getCollabWindow().collaborating,\n\t\t\t0x01f /* \"Row and col collab window 'collaborating' status desynchronized!\" */,\n\t\t);\n\n\t\t// Update merge tree collaboration information with new client ID and then resend pending ops\n\t\tthis.rows.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t\tthis.cols.startOrUpdateCollaboration(this.runtime.clientId as string);\n\t}\n\n\tprivate rebasePosition(\n\t\tclient: Client,\n\t\tpos: number,\n\t\treferenceSequenceNumber: number,\n\t\tlocalSeq: number,\n\t): number | undefined {\n\t\tconst { clientId } = client.getCollabWindow();\n\t\tconst { segment, offset } = client.getContainingSegment(\n\t\t\tpos,\n\t\t\t{ referenceSequenceNumber, clientId: client.getLongClientId(clientId) },\n\t\t\tlocalSeq,\n\t\t);\n\t\tif (segment === undefined || offset === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn client.findReconnectionPosition(segment, localSeq) + offset;\n\t}\n\n\tprotected reSubmitCore(content: any, localOpMetadata: unknown) {\n\t\tswitch (content.target) {\n\t\t\tcase SnapshotPath.cols:\n\t\t\t\tthis.submitColMessage(\n\t\t\t\t\tthis.cols.regeneratePendingOp(\n\t\t\t\t\t\tcontent as IMergeTreeOp,\n\t\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase SnapshotPath.rows:\n\t\t\t\tthis.submitRowMessage(\n\t\t\t\t\tthis.rows.regeneratePendingOp(\n\t\t\t\t\t\tcontent as IMergeTreeOp,\n\t\t\t\t\t\tlocalOpMetadata as SegmentGroup | SegmentGroup[],\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tassert(\n\t\t\t\t\tcontent.type === MatrixOp.set,\n\t\t\t\t\t0x020 /* \"Unknown SharedMatrix 'op' type.\" */,\n\t\t\t\t);\n\n\t\t\t\tconst setOp = content as ISetOp<T>;\n\t\t\t\tconst { rowHandle, colHandle, localSeq, rowsRefSeq, colsRefSeq } =\n\t\t\t\t\tlocalOpMetadata as ISetOpMetadata;\n\n\t\t\t\t// If there are more pending local writes to the same row/col handle, it is important\n\t\t\t\t// to skip resubmitting this op since it is possible the row/col handle has been recycled\n\t\t\t\t// and now refers to a different position than when this op was originally submitted.\n\t\t\t\tif (this.isLatestPendingWrite(rowHandle, colHandle, localSeq)) {\n\t\t\t\t\tconst row = this.rebasePosition(this.rows, setOp.row, rowsRefSeq, localSeq);\n\t\t\t\t\tconst col = this.rebasePosition(this.cols, setOp.col, colsRefSeq, localSeq);\n\n\t\t\t\t\tif (row !== undefined && col !== undefined && row >= 0 && col >= 0) {\n\t\t\t\t\t\tthis.sendSetCellOp(\n\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\tcol,\n\t\t\t\t\t\t\tsetOp.value,\n\t\t\t\t\t\t\trowHandle,\n\t\t\t\t\t\t\tcolHandle,\n\t\t\t\t\t\t\tlocalSeq,\n\t\t\t\t\t\t\trowsRefSeq,\n\t\t\t\t\t\t\tcolsRefSeq,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onDisconnect() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService) {\n\t\ttry {\n\t\t\tawait this.rows.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.rows),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tawait this.cols.load(\n\t\t\t\tthis.runtime,\n\t\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.cols),\n\t\t\t\tthis.serializer,\n\t\t\t);\n\t\t\tconst [cellData, pendingCliSeqData] = await deserializeBlob(\n\t\t\t\tstorage,\n\t\t\t\tSnapshotPath.cells,\n\t\t\t\tthis.serializer,\n\t\t\t);\n\n\t\t\tthis.cells = SparseArray2D.load(cellData);\n\t\t\tthis.pending = SparseArray2D.load(pendingCliSeqData);\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"MatrixLoadFailed\" }, error);\n\t\t}\n\t}\n\n\tprotected processCore(\n\t\trawMessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\tconst msg = parseHandles(rawMessage, this.serializer);\n\n\t\tconst contents = msg.contents;\n\n\t\tswitch (contents.target) {\n\t\t\tcase SnapshotPath.cols:\n\t\t\t\tthis.cols.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\tcase SnapshotPath.rows:\n\t\t\t\tthis.rows.applyMsg(msg, local);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tassert(\n\t\t\t\t\tcontents.type === MatrixOp.set,\n\t\t\t\t\t0x021 /* \"SharedMatrix message contents have unexpected type!\" */,\n\t\t\t\t);\n\n\t\t\t\tconst { row, col } = contents;\n\n\t\t\t\tif (local) {\n\t\t\t\t\t// We are receiving the ACK for a local pending set operation.\n\t\t\t\t\tconst { rowHandle, colHandle, localSeq } = localOpMetadata as ISetOpMetadata;\n\n\t\t\t\t\t// If this is the most recent write to the cell by the local client, remove our\n\t\t\t\t\t// entry from 'pendingCliSeqs' to resume allowing remote writes.\n\t\t\t\t\tif (this.isLatestPendingWrite(rowHandle, colHandle, localSeq)) {\n\t\t\t\t\t\tthis.pending.setCell(rowHandle, colHandle, undefined);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst adjustedRow = this.rows.adjustPosition(row, rawMessage);\n\n\t\t\t\t\tif (adjustedRow !== undefined) {\n\t\t\t\t\t\tconst adjustedCol = this.cols.adjustPosition(col, rawMessage);\n\n\t\t\t\t\t\tif (adjustedCol !== undefined) {\n\t\t\t\t\t\t\tconst rowHandle = this.rows.getAllocatedHandle(adjustedRow);\n\t\t\t\t\t\t\tconst colHandle = this.cols.getAllocatedHandle(adjustedCol);\n\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t\t\t\t\t\t0x022 /* \"SharedMatrix row and/or col handles are invalid!\" */,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// If there is a pending (unACKed) local write to the same cell, skip the current op\n\t\t\t\t\t\t\t// since it \"happened before\" the pending write.\n\t\t\t\t\t\t\tif (this.pending.getCell(rowHandle, colHandle) === undefined) {\n\t\t\t\t\t\t\t\tconst { value } = contents;\n\t\t\t\t\t\t\t\tthis.cells.setCell(rowHandle, colHandle, value);\n\n\t\t\t\t\t\t\t\tfor (const consumer of this.consumers.values()) {\n\t\t\t\t\t\t\t\t\tconsumer.cellsChanged(adjustedRow, adjustedCol, 1, 1, this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\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}\n\t}\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of row insertion/deletions.\n\tprivate readonly onRowDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t) => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.rowsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\t// Invoked by PermutationVector to notify IMatrixConsumers of col insertion/deletions.\n\tprivate readonly onColDelta = (\n\t\tposition: number,\n\t\tremovedCount: number,\n\t\tinsertedCount: number,\n\t) => {\n\t\tfor (const consumer of this.consumers) {\n\t\t\tconsumer.colsChanged(position, removedCount, insertedCount, this);\n\t\t}\n\t};\n\n\tprivate readonly onRowHandlesRecycled = (rowHandles: Handle[]) => {\n\t\tfor (const rowHandle of rowHandles) {\n\t\t\tthis.cells.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t\tthis.pending.clearRows(/* rowStart: */ rowHandle, /* rowCount: */ 1);\n\t\t}\n\t};\n\n\tprivate readonly onColHandlesRecycled = (colHandles: Handle[]) => {\n\t\tfor (const colHandle of colHandles) {\n\t\t\tthis.cells.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t\tthis.pending.clearCols(/* colStart: */ colHandle, /* colCount: */ 1);\n\t\t}\n\t};\n\n\t/**\n\t * Returns true if the latest pending write to the cell indicated by the given row/col handles\n\t * matches the given 'localSeq'.\n\t *\n\t * A return value of `true` indicates that there are no later local operations queued that will\n\t * clobber the write op at the given 'localSeq'. This includes later ops that overwrite the cell\n\t * with a different value as well as row/col removals that might recycled the given row/col handles.\n\t */\n\tprivate isLatestPendingWrite(rowHandle: Handle, colHandle: Handle, localSeq: number) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst pendingLocalSeq = this.pending.getCell(rowHandle, colHandle)!;\n\n\t\t// Note while we're awaiting the ACK for a local set, it's possible for the row/col to be\n\t\t// locally removed and the row/col handles recycled. If this happens, the pendingLocalSeq will\n\t\t// be 'undefined' or > 'localSeq'.\n\t\tassert(\n\t\t\t!(pendingLocalSeq < localSeq),\n\t\t\t0x023 /* \"The 'localSeq' of pending write (if any) must be <= the localSeq of the currently processed op.\" */,\n\t\t);\n\n\t\t// If this is the most recent write to the cell by the local client, the stored localSeq\n\t\t// will be an exact match for the given 'localSeq'.\n\t\treturn pendingLocalSeq === localSeq;\n\t}\n\n\tpublic toString() {\n\t\tlet s = `client:${\n\t\t\tthis.runtime.clientId\n\t\t}\\nrows: ${this.rows.toString()}\\ncols: ${this.cols.toString()}\\n\\n`;\n\n\t\tfor (let r = 0; r < this.rowCount; r++) {\n\t\t\ts += ` [`;\n\t\t\tfor (let c = 0; c < this.colCount; c++) {\n\t\t\t\tif (c > 0) {\n\t\t\t\t\ts += \", \";\n\t\t\t\t}\n\n\t\t\t\ts += `${this.serializer.stringify(this.getCell(r, c), this.handle)}`;\n\t\t\t}\n\t\t\ts += \"]\\n\";\n\t\t}\n\n\t\treturn `${s}\\n`;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(content: any): unknown {\n\t\tif (content.target === SnapshotPath.cols || content.target === SnapshotPath.rows) {\n\t\t\tconst op = content as IMergeTreeOp;\n\t\t\tconst currentVector = content.target === SnapshotPath.cols ? this.cols : this.rows;\n\t\t\tconst oppositeVector = content.target === SnapshotPath.cols ? this.rows : this.cols;\n\t\t\tconst metadata = currentVector.applyStashedOp(op);\n\t\t\tconst localSeq = currentVector.getCollabWindow().localSeq;\n\t\t\tconst oppositeWindow = oppositeVector.getCollabWindow();\n\n\t\t\tassert(\n\t\t\t\tlocalSeq > oppositeWindow.localSeq,\n\t\t\t\t0x2d9,\n\t\t\t\t/* \"The 'localSeq' of the vector applying stashed op must > the 'localSeq' of the other vector.\" */\n\t\t\t);\n\n\t\t\toppositeWindow.localSeq = localSeq;\n\n\t\t\treturn metadata;\n\t\t} else {\n\t\t\tassert(content.type === MatrixOp.set, 0x2da /* \"Unknown SharedMatrix 'op' type.\" */);\n\n\t\t\tconst setOp = content as ISetOp<T>;\n\t\t\tconst rowHandle = this.rows.getAllocatedHandle(setOp.row);\n\t\t\tconst colHandle = this.cols.getAllocatedHandle(setOp.col);\n\t\t\tconst rowsRefSeq = this.rows.getCollabWindow().currentSeq;\n\t\t\tconst colsRefSeq = this.cols.getCollabWindow().currentSeq;\n\t\t\tif (this.undo !== undefined) {\n\t\t\t\tlet oldValue = this.cells.getCell(rowHandle, colHandle);\n\t\t\t\tif (oldValue === null) {\n\t\t\t\t\toldValue = undefined;\n\t\t\t\t}\n\n\t\t\t\tthis.undo.cellSet(rowHandle, colHandle, oldValue);\n\t\t\t}\n\n\t\t\tthis.cells.setCell(rowHandle, colHandle, setOp.value);\n\t\t\tconst localSeq = this.nextLocalSeq();\n\t\t\tconst metadata: ISetOpMetadata = {\n\t\t\t\trowHandle,\n\t\t\t\tcolHandle,\n\t\t\t\tlocalSeq,\n\t\t\t\trowsRefSeq,\n\t\t\t\tcolsRefSeq,\n\t\t\t};\n\n\t\t\tthis.pending.setCell(rowHandle, colHandle, localSeq);\n\t\t\treturn metadata;\n\t\t}\n\t}\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/matrix";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.6.0.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/matrix";
|
|
11
|
-
exports.pkgVersion = "2.0.0-internal.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.6.0.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,wBAAwB,CAAC;AACnC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-internal.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,wBAAwB,CAAC;AACnC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/matrix\";\nexport const pkgVersion = \"2.0.0-internal.6.0.0\";\n"]}
|
|
@@ -1 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/B,UAAU,EAAE,gBAAgB;;;IAiB7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAqEtB;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAyB5B;IAEK,QAAQ;CAUf;AAED,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,YAAY;;;EAsBlB"}
|
|
@@ -69,7 +69,10 @@ exports.PermutationSegment = PermutationSegment;
|
|
|
69
69
|
PermutationSegment.typeString = "PermutationSegment";
|
|
70
70
|
class PermutationVector extends merge_tree_1.Client {
|
|
71
71
|
constructor(path, logger, runtime, deltaCallback, handlesRecycledCallback) {
|
|
72
|
-
super(PermutationSegment.fromJSONObject, telemetry_utils_1.
|
|
72
|
+
super(PermutationSegment.fromJSONObject, (0, telemetry_utils_1.createChildLogger)({ logger, namespace: `Matrix.${path}.MergeTreeClient` }), {
|
|
73
|
+
...runtime.options,
|
|
74
|
+
newMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.
|
|
75
|
+
}); // (See https://github.com/microsoft/FluidFramework/issues/84)
|
|
73
76
|
this.deltaCallback = deltaCallback;
|
|
74
77
|
this.handlesRecycledCallback = handlesRecycledCallback;
|
|
75
78
|
this.handleTable = new handletable_1.HandleTable(); // Tracks available storage handles for rows.
|