@fluidframework/matrix 0.59.2001 → 0.59.3000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bspSet.d.ts +2 -2
- package/dist/bspSet.js +1 -1
- package/dist/bspSet.js.map +1 -1
- package/dist/handlecache.d.ts +1 -1
- package/dist/handlecache.js +4 -4
- package/dist/handlecache.js.map +1 -1
- package/dist/handletable.js.map +1 -1
- package/dist/matrix.d.ts +4 -1
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +57 -22
- 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.js +10 -10
- package/dist/permutationvector.js.map +1 -1
- package/dist/productSet.js +10 -10
- package/dist/productSet.js.map +1 -1
- package/dist/range.d.ts +1 -1
- package/dist/range.js +1 -1
- package/dist/range.js.map +1 -1
- package/dist/serialization.js +1 -1
- package/dist/serialization.js.map +1 -1
- package/dist/undoprovider.d.ts.map +1 -1
- package/dist/undoprovider.js +3 -3
- package/dist/undoprovider.js.map +1 -1
- package/lib/bspSet.d.ts +2 -2
- package/lib/handlecache.d.ts +1 -1
- package/lib/handlecache.js +1 -1
- package/lib/handlecache.js.map +1 -1
- package/lib/handletable.js.map +1 -1
- package/lib/matrix.d.ts +4 -1
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +39 -4
- 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/productSet.js.map +1 -1
- package/lib/range.d.ts +1 -1
- package/lib/range.js +1 -1
- package/lib/range.js.map +1 -1
- package/lib/undoprovider.d.ts.map +1 -1
- package/lib/undoprovider.js.map +1 -1
- package/package.json +16 -15
- package/src/handlecache.ts +1 -1
- package/src/matrix.ts +60 -13
- package/src/packageVersion.ts +1 -1
- package/src/productSet.ts +1 -1
- package/src/range.ts +1 -1
- package/src/undoprovider.ts +1 -1
package/dist/productSet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"productSet.js","sourceRoot":"","sources":["../src/productSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AAEH,qCAmBkB;AA6DlB,MAAM,IAAI,GAAyC,EAAE,CAAC;AACtD,MAAM,GAAG,GAAG,CAAI,iBAAuC,EAAU,EAAE;IAC/D,MAAM,IAAI,GAAqD,EAAE,CAAC;IAClE,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;QACjD,MAAM,GAAG,GAAG,MAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC/C;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,IAAI,OAAO,KAAK,SAAS,EAAE;QACvB,OAAO,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;KACzB;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,SAAS,QAAQ,CAAI,MAAyB;IAC1C,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACnC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;YACnD,OAAO,GAAG,KAAK,CAAC;YAChB,MAAM;SACT;KACJ;IACD,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AG,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACrC,IAAI,MAAM,KAAK,cAAK,EAAE;QAClB,OAAO,IAAI,CAAC;KACf;IACD,IAAI,MAAM,KAAK,cAAK,EAAE;QAClB,OAAO,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;KACvC;IAED,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAE3C,SAAS,IAAI,CAAC,UAAmC;QAC7C,IAAI,UAAU,CAAC,UAAU,EAAE;YACvB,OAAO,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;SACnF;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC;AAvBD,wCAuBC;AAED,SAAgB,gBAAgB,CAAI,GAAkB;IAClD,IAAI,GAAG,KAAK,cAAK,IAAI,GAAG,KAAK,cAAK,EAAE;QAChC,OAAO,CAAC,CAAC;KACZ;IACD,OAAO,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AALD,4CAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n BspSet,\n empty,\n dense,\n Empty,\n Dense,\n combineCmp,\n SetOperations,\n intersectUntyped,\n compareUntyped,\n Cachable,\n UntypedBspSet,\n unionUntyped,\n exceptUntyped,\n lazy,\n UntypedSparse,\n fromUntyped,\n meetsUntyped,\n Pair,\n} from \"./bspSet\";\n\ntype Restrict<T, Props extends (keyof T)[]> = { [Prop in Props[number]]: T[Prop] };\n\nexport type Product<T> = { readonly [dim in keyof T]: T[dim] extends BspSet<infer _TKey, infer _TId> ? T[dim] : never };\n\ntype UntypedProduct<T> = {\n readonly [dim in keyof T]?: T[dim] extends BspSet<infer TKey, infer _TId> ? UntypedSparse<TKey> : never;\n};\n\ntype Probabilities<T> = { readonly [dim in keyof T]?: number };\n\ntype ProductOperations<T> = {\n readonly [dim in keyof T]: T[dim] extends BspSet<infer TKey, infer TId> ? SetOperations<TKey, TId> : never;\n};\n\n/** Given a cartesian product, a subspace is a subset of said space, such that it is also a cartesian product\n * and all the dimensions form subsets of the original cartesian product.\n *\n * This is a generalized notion of something like hyper-rectangles. Examples include:\n * - Rectangles\n * - Individual cells in a grid\n * - Rectangular ranges with missing rows and/or columns\n *\n * For the actual definition and properties, please read the document about *Operations on Cartesian Products*.\n */\ninterface Subspace<T> {\n readonly isSubspace: true;\n // isCoSubspace: boolean;\n readonly bounds: UntypedProduct<T>;\n}\n\n// type CoSubspace<T> = {\n// isSubspace: boolean;\n// isCoSubspace: true;\n// subspace: Product<T>;\n// };\n\ninterface Union<T> {\n readonly isSubspace: false;\n // readonly isCoSubspace: false;\n readonly left: UntypedSparseProduct<T>;\n readonly right: UntypedSparseProduct<T>;\n readonly bounds: UntypedProduct<T>;\n readonly subspaceCount: number;\n}\n\ntype UntypedSparseProduct<T> = Subspace<T> | Union<T>; // | CoSubspace<T>;\n\ninterface SparseProduct<T> {\n readonly productOperations: ProductOperations<T>;\n readonly root: UntypedSparseProduct<T>;\n}\n\ninterface Box<T> {\n box: UntypedProduct<T>;\n probabilities: Probabilities<T>;\n children?: Pair<Box<T>>;\n depth: number;\n}\n\nconst tops: { [poKey in string]?: Box<unknown> } = {};\nconst top = <T>(productOperations: ProductOperations<T>): Box<T> => {\n const dims: [keyof T, ProductOperations<T>[keyof T][\"id\"]][] = [];\n for (const dimStr of Object.keys(productOperations)) {\n const dim = dimStr as keyof T;\n dims.push([dim, productOperations[dim].id]);\n }\n\n const poKey = JSON.stringify(dims.sort());\n let currTop = tops[poKey];\n if (currTop === undefined) {\n currTop = { box: {}, probabilities: {}, depth: 1 };\n tops[poKey] = currTop;\n }\n\n return currTop;\n};\n\nfunction subspace<T>(bounds: UntypedProduct<T>): Subspace<T> | Dense {\n let isDense = true;\n for (const dim of Object.keys(bounds)) {\n if (Object.prototype.hasOwnProperty.call(bounds, dim)) {\n isDense = false;\n break;\n }\n }\n if (isDense) {\n return dense;\n }\n return { isSubspace: true as const, bounds };\n}\n\nfunction getUntypedSubspaceCount<T>(set: UntypedSparseProduct<T>) {\n if (set.isSubspace) {\n return 1;\n }\n return set.subspaceCount;\n}\n\nconst union = <T>(\n left: UntypedSparseProduct<T>,\n right: UntypedSparseProduct<T>,\n bounds: UntypedProduct<T>,\n): Union<T> => ({\n isSubspace: false as const,\n left,\n right,\n bounds,\n subspaceCount: getUntypedSubspaceCount(left) + getUntypedSubspaceCount(right),\n});\n\nfunction sparseProduct<T>(\n productOperations: ProductOperations<T>,\n root: UntypedSparseProduct<T> | Dense,\n): SparseProduct<T> | Dense {\n if (root === dense) {\n return root;\n }\n if (root.isSubspace) {\n let hasSparseDimensions = false;\n for (const dim of Object.keys(root.bounds)) {\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n hasSparseDimensions = true;\n break;\n }\n }\n if (!hasSparseDimensions) {\n return dense;\n }\n }\n return { productOperations, root };\n}\n\ntype UntypedProductSet<T> = Empty | Dense | UntypedSparseProduct<T>;\nexport type ProductSet<T> = Empty | Dense | SparseProduct<T>;\n\nfunction toBspSet<T>(set: UntypedBspSet<T> | undefined) {\n if (set === undefined) {\n return dense;\n }\n return set;\n}\n\n/** An object that contains all downcasts. The operations in here are generally of the kind that need dynamic\n * features, i.e. iterate over the object properties somehow. Their *usage* can be considered safe, but they warrant\n * more careful review whenever a change occurs, because we get less support from the type system and we are\n * downcasting. */\nconst unsafe = {\n unzip<T>(product: Product<T>): ProductSet<T> {\n const productOperations: { [dim in keyof T]?: SetOperations<unknown, unknown> } = {};\n const root: { [dim in keyof T]?: UntypedSparse<unknown> } = {};\n for (const dimStr of Object.keys(product)) {\n const dim = dimStr as keyof T;\n if (Object.prototype.hasOwnProperty.call(product, dim)) {\n const set: BspSet<unknown, unknown> = product[dim];\n if (set === empty) {\n return empty;\n }\n if (set === dense) {\n continue;\n }\n\n productOperations[dim] = set.setOperations;\n root[dim] = set.root;\n }\n }\n\n return sparseProduct(productOperations as ProductOperations<T>, subspace(root as UntypedProduct<T>));\n },\n\n combineProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProduct<T>,\n right: UntypedProduct<T>,\n combineFunc: <Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>\n ) => UntypedBspSet<Key>,\n ) {\n const res: { [dim in keyof T]?: UntypedSparse<unknown> } = {};\n for (const dimStr of Object.keys(productOperations)) {\n const dim = dimStr as keyof T;\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const combined = combineFunc<unknown, unknown>(\n productOperations[dim],\n toBspSet(left[dim]),\n toBspSet(right[dim]),\n );\n if (combined === empty) {\n return combined;\n }\n if (combined === dense) {\n continue;\n }\n res[dim] = combined;\n }\n }\n\n return res as UntypedProduct<T>;\n },\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n restrict<T extends object, Props extends (keyof T)[]>(object: T, ...props: Props) {\n const res: Partial<Restrict<T, Props>> = {};\n for (const key of props) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n const prop = object[key];\n res[key] = prop;\n }\n }\n\n return res as Restrict<T, Props>;\n },\n\n fromUntypedProduct<T, Props extends (keyof T)[]>(\n productOperations: ProductOperations<Restrict<T, Props>>,\n bounds: UntypedProduct<Restrict<T, Props>>,\n dims: Props,\n ) {\n const product: { [dim in Props[number]]?: BspSet<unknown, unknown> } = {};\n for (const dim of dims) {\n const bound: UntypedSparse<unknown> | undefined = bounds[dim];\n product[dim] = fromUntyped(productOperations[dim], bound !== undefined ? bound : dense);\n }\n return product as Product<Restrict<T, Props>>;\n },\n\n denseProduct<T, Props extends (keyof T)[]>(dims: Props): Product<Restrict<T, Props>> {\n const top_inner: { [dim in Props[number]]?: Dense } = {};\n for (const dim of dims) {\n top_inner[dim] = dense;\n }\n return top_inner as Product<Restrict<T, Props>>;\n },\n};\n\nexport const createFromProduct = unsafe.unzip.bind(unsafe);\n\ntype Compatible<T, U> = { [dim in keyof T & keyof U]: T[dim] };\n\nfunction joinBounds<T>(productOperations: ProductOperations<T>, left: UntypedProduct<T>, right: UntypedProduct<T>) {\n const join = unsafe.combineProduct(productOperations, left, right, unionUntyped);\n if (join === empty) {\n throw new Error(\"broken invariant: the union of two non-empty products cannot be empty\");\n }\n\n return join;\n}\n\nfunction compareSubspace<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProduct<T>,\n right: UntypedProduct<T>,\n) {\n let cmp: ReturnType<typeof combineCmp> = 0;\n for (const dimStr of Object.keys(productOperations)) {\n const dim = dimStr as keyof T;\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const lProj = toBspSet(left[dim]);\n const rProj = toBspSet(right[dim]);\n const setOperations = productOperations[dim];\n\n cmp = combineCmp(cmp, compareUntyped<unknown, unknown>(setOperations, lProj, rProj));\n\n if (cmp === undefined) {\n return undefined;\n }\n }\n }\n\n return cmp;\n}\n\nconst tryUnionSubspaces = (() => {\n const cache: { left?: unknown; right?: unknown; res?: unknown } = {};\n return <T>(\n productOperations: ProductOperations<T>,\n left: Subspace<T>,\n right: Subspace<T>,\n ): Subspace<T> | Dense | Empty | undefined => {\n if (left === cache.left && right === cache.right) {\n return cache.res as ReturnType<typeof tryUnionSubspaces>;\n }\n cache.left = left;\n cache.right = right;\n\n const cmp = compareSubspace(productOperations, left.bounds, right.bounds);\n if (cmp !== undefined) {\n return (cache.res = cmp <= 0 ? right : left);\n }\n let differentDimension: keyof T | undefined;\n\n // because Object.keys only returns string[], we need to downcast\n const po_keys = Object.keys(productOperations) as (keyof T)[];\n for (const dim of po_keys) {\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const cmp_inner = compareUntyped<unknown, unknown>(\n productOperations[dim],\n toBspSet(left.bounds[dim]),\n toBspSet(right.bounds[dim]),\n );\n if (cmp_inner !== 0) {\n if (differentDimension !== undefined) {\n return (cache.res = undefined);\n }\n\n differentDimension = dim;\n }\n }\n }\n\n if (differentDimension !== undefined) {\n const newDim = unionUntyped<unknown, unknown>(\n productOperations[differentDimension],\n toBspSet(left.bounds[differentDimension]),\n toBspSet(right.bounds[differentDimension]),\n );\n if (newDim === empty) {\n return (cache.res = empty);\n }\n if (newDim === dense) {\n // we are actually deleting the `differentDimension`, so the variable\n // `deleted` must be there. Hence disabling the rule here.\n const { [differentDimension]: deleted, ...leftBoundsWithoutDifferentDimension } = left.bounds;\n return (cache.res = subspace<unknown>(leftBoundsWithoutDifferentDimension));\n }\n\n const newBounds: UntypedProduct<T> = {\n ...left.bounds,\n [differentDimension]: newDim,\n };\n return (cache.res = subspace(newBounds));\n }\n\n return (cache.res = undefined);\n };\n})();\n\nfunction combineChildren<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n): UntypedProductSet<T> {\n if (right === empty) {\n return left;\n }\n if (right === dense) {\n return right;\n }\n if (left === empty) {\n return right;\n }\n if (left === dense) {\n return left;\n }\n\n if (!left.isSubspace || !right.isSubspace) {\n return union<T>(left, right, joinBounds(productOperations, left.bounds, right.bounds));\n }\n\n const combinedSubspace = tryUnionSubspaces<T>(productOperations, left, right);\n\n if (combinedSubspace !== undefined) {\n return combinedSubspace;\n }\n return union(left, right, joinBounds(productOperations, left.bounds, right.bounds));\n}\n\nfunction projectUntyped<T, Props extends (keyof T)[]>(\n productOperations: ProductOperations<T>,\n set: UntypedSparseProduct<T>,\n ...dims: Props\n): UntypedProductSet<Restrict<T, Props>> {\n const bounds = unsafe.restrict(set.bounds, ...dims);\n if (set.isSubspace) {\n return subspace(bounds);\n }\n\n const lChild = projectUntyped(productOperations, set.left, ...dims);\n if (lChild === dense) {\n return dense;\n }\n const rChild = projectUntyped(productOperations, set.right, ...dims);\n return combineChildren(productOperations, lChild, rChild);\n}\n\nexport function project<T, Props extends (keyof T)[]>(\n set: ProductSet<T>,\n ...dims: Props\n): ProductSet<Restrict<T, Props>> {\n if (set === dense || set === empty) {\n return set;\n }\n const productOperations = unsafe.restrict(set.productOperations, ...dims);\n const root = projectUntyped(productOperations, set.root, ...dims);\n if (root === empty) {\n return root;\n }\n return sparseProduct(productOperations, root);\n}\n\nfunction splitBox<T>(productOperations: ProductOperations<T>, currentBox: Box<T>): Pair<Box<T>> {\n if (currentBox.children !== undefined) { return currentBox.children; }\n const { box, probabilities } = currentBox;\n let biggestDim: keyof T | undefined;\n let biggestDimKey;\n let currentProb = 0;\n // because Object.keys only returns string[], we need to downcast\n const po_keys = Object.keys(productOperations) as (keyof T)[];\n for (const dim of po_keys) {\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const prob: number | undefined = probabilities[dim];\n const setOperations_inner = productOperations[dim];\n if (prob === undefined) {\n biggestDim = dim;\n biggestDimKey = setOperations_inner.top;\n break;\n }\n\n if (prob > currentProb) {\n const dimensionSet = toBspSet(box[dim]);\n if (dimensionSet === empty) {\n throw new Error(\"the key split can never return empty\");\n }\n let key = setOperations_inner.top;\n if (dimensionSet !== dense) {\n if (!dimensionSet.isExact) {\n throw new Error(\"the key can always be represented exactly\");\n }\n\n key = dimensionSet.key;\n }\n if (!setOperations_inner.canSplit(key)) {\n continue;\n }\n biggestDim = dim;\n currentProb = prob;\n biggestDimKey = key;\n }\n }\n }\n\n if (biggestDim === undefined || biggestDimKey === undefined) {\n throw new Error(\"there has to be at least one dimension\");\n }\n\n const setOperations = productOperations[biggestDim];\n\n const [[leftDim, leftProb], [rightDim, rightProb]] = setOperations.split(biggestDimKey);\n const res: ReturnType<typeof splitBox> = [\n {\n box: { ...box, [biggestDim]: lazy<unknown, unknown>(setOperations, setOperations.top, leftDim) },\n probabilities: { ...probabilities, [biggestDim]: leftProb },\n depth: currentBox.depth + 1,\n },\n {\n box: { ...box, [biggestDim]: lazy<unknown, unknown>(setOperations, setOperations.top, rightDim) },\n probabilities: { ...probabilities, [biggestDim]: rightProb },\n depth: currentBox.depth + 1,\n },\n ];\n if (currentBox.depth < 10) {\n currentBox.children = res;\n }\n return res;\n}\n\nfunction restrictByBounds<T>(\n productOperations: ProductOperations<T>,\n set: UntypedProductSet<T>,\n leftBounds: UntypedProduct<T>,\n rightBounds: UntypedProduct<T>,\n): Pair<UntypedProductSet<T>> {\n if (set === empty) {\n return [empty, empty];\n }\n if (set === dense) {\n return [subspace(leftBounds), subspace(rightBounds)];\n }\n const cmp = compareSubspace(productOperations, set.bounds, leftBounds);\n\n // the set is fully contained in the left half, i.e. we know the pair.\n if (cmp !== undefined && cmp <= 0) {\n return [set, empty];\n }\n\n const newLeftBounds = unsafe.combineProduct(productOperations, set.bounds, leftBounds, intersectUntyped);\n\n // if we know, that the left set is completely empty, then the whole set is in the right bounds.\n if (newLeftBounds === empty) {\n return [empty, set];\n }\n\n const newRightBounds = unsafe.combineProduct(productOperations, set.bounds, rightBounds, intersectUntyped);\n if (set.isSubspace) {\n return [subspace(newLeftBounds), newRightBounds === empty ? empty : subspace(newRightBounds)];\n }\n\n const [ll, lr] = restrictByBounds(productOperations, set.left, leftBounds, rightBounds);\n const [rl, rr] = restrictByBounds(productOperations, set.right, leftBounds, rightBounds);\n return [combineChildren(productOperations, ll, rl), combineChildren(productOperations, lr, rr)];\n}\n\nconst splitByBox = <T>(\n productOperations: ProductOperations<T>,\n set: UntypedProductSet<T>,\n { box: leftBounds }: Box<T>,\n { box: rightBounds }: Box<T>,\n): Pair<UntypedProductSet<T>, UntypedProductSet<T>> => {\n return restrictByBounds(productOperations, set, leftBounds, rightBounds);\n};\n\nfunction recurse<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n currentBox: Box<T>,\n visitFunc: (\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n box: Box<T>\n ) => UntypedProductSet<T>,\n) {\n const [leftBox, rightBox] = splitBox(productOperations, currentBox);\n const [ll, lr] = splitByBox(productOperations, left, leftBox, rightBox);\n const [rl, rr] = splitByBox(productOperations, right, leftBox, rightBox);\n\n const lChild = visitFunc(productOperations, ll, rl, leftBox);\n if (lChild === dense) {\n return dense;\n }\n const rChild = visitFunc(productOperations, lr, rr, rightBox);\n return combineChildren(productOperations, lChild, rChild);\n}\n\nfunction unionUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n currentBox: Box<T>,\n): UntypedProductSet<T> {\n if (right === empty) {\n return left;\n }\n if (left === empty) {\n return right;\n }\n if (left === dense) {\n return left;\n }\n if (right === dense) {\n return right;\n }\n if (left.isSubspace && right.isSubspace) {\n const combinedSubspace = tryUnionSubspaces(productOperations, left, right);\n if (combinedSubspace !== undefined) {\n return combinedSubspace;\n }\n }\n\n return recurse(productOperations, left, right, currentBox, unionUntypedProduct);\n}\n\nexport function unionProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n): ProductSet<T & U> {\n if (right === empty) {\n return left;\n }\n if (right === dense) {\n return right;\n }\n if (left === empty) {\n return right;\n }\n if (left === dense) {\n return left;\n }\n const productOperations = { ...left.productOperations, ...right.productOperations };\n const res = unionUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n if (res === empty) {\n return res;\n }\n return sparseProduct(productOperations, res);\n}\n\nfunction intersectUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n currentBox: Box<T>,\n): UntypedProductSet<T> {\n if (left === empty || right === empty) {\n return empty;\n }\n if (left === dense) {\n return right;\n }\n if (right === dense) {\n return left;\n }\n if (left.isSubspace && right.isSubspace) {\n const res = unsafe.combineProduct(productOperations, left.bounds, right.bounds, intersectUntyped);\n if (res === empty) {\n return empty;\n }\n return subspace(res);\n }\n\n return recurse(productOperations, left, right, currentBox, intersectUntypedProduct);\n}\n\nexport function intersectProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n): ProductSet<T & U> {\n if (left === empty) {\n return left;\n }\n if (right === empty) {\n return right;\n }\n if (left === dense) {\n return right;\n }\n if (right === dense) {\n return left;\n }\n\n const productOperations = { ...left.productOperations, ...right.productOperations };\n const res = intersectUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n if (res === empty) {\n return res;\n }\n return sparseProduct(productOperations, res);\n}\n\nfunction tryExceptSubspaces<T>(\n productOperations: ProductOperations<T>,\n left: Subspace<T>,\n right: Subspace<T>,\n): Subspace<T> | Dense | Empty | undefined {\n const cmp = compareSubspace(productOperations, left.bounds, right.bounds);\n if (cmp === 0 || cmp === -1) {\n return empty;\n }\n let notContainedDimension: keyof T | undefined;\n // because Object.keys only returns string[], we need to downcast\n const po_keys = Object.keys(productOperations) as (keyof T)[];\n for (const dim of po_keys) {\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const cmp_inner = compareUntyped<unknown, unknown>(\n productOperations[dim],\n toBspSet(left.bounds[dim]),\n toBspSet(right.bounds[dim]),\n );\n if (cmp_inner === undefined || cmp_inner > 0) {\n if (notContainedDimension !== undefined) {\n return undefined;\n }\n\n notContainedDimension = dim;\n }\n }\n }\n\n if (notContainedDimension !== undefined) {\n const newDim = exceptUntyped<unknown, unknown>(\n productOperations[notContainedDimension],\n toBspSet(left.bounds[notContainedDimension]),\n toBspSet(right.bounds[notContainedDimension]),\n );\n\n if (newDim === empty) {\n return empty;\n }\n if (newDim === dense) {\n // we are actually deleting the `differentDimension`, so the variable\n // `deleted` must be there. Hence disabling the rule here.\n const { [notContainedDimension]: deleted, ...leftBoundsWithoutDifferentDimension } = left.bounds;\n return subspace<unknown>(leftBoundsWithoutDifferentDimension);\n }\n const newBounds: UntypedProduct<T> = {\n ...left.bounds,\n [notContainedDimension]: newDim,\n };\n return subspace(newBounds);\n }\n\n return undefined;\n}\n\nfunction exceptUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n currentBox: Box<T>,\n): UntypedProductSet<T> {\n if (left === empty) {\n return left;\n }\n if (right === dense) {\n return empty;\n }\n if (right === empty) {\n return left;\n }\n\n if (left === dense) {\n return recurse(productOperations, left, right, currentBox, exceptUntypedProduct);\n }\n\n if (left.isSubspace && right.isSubspace) {\n const combinedSubspace = tryExceptSubspaces(productOperations, left, right);\n if (combinedSubspace !== undefined) {\n return combinedSubspace;\n }\n }\n\n return recurse(productOperations, left, right, currentBox, exceptUntypedProduct);\n}\n\nexport function exceptProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n): ProductSet<T & U> {\n if (left === empty) {\n return left;\n }\n if (right === empty) {\n return left;\n }\n if (right === dense) {\n return empty;\n }\n if (left === dense) {\n const res_inner =\n exceptUntypedProduct(right.productOperations, dense, right.root, top(right.productOperations));\n if (res_inner === empty) {\n return res_inner;\n }\n return sparseProduct(right.productOperations, res_inner);\n }\n\n const productOperations = { ...left.productOperations, ...right.productOperations };\n const res = exceptUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n if (res === empty) {\n return res;\n }\n return sparseProduct(productOperations, res);\n}\n\nfunction compareUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n boundingBox: Box<T>,\n): -1 | 0 | 1 | undefined {\n if (left === right) {\n return 0;\n }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n if (left.isSubspace) {\n if (right.isSubspace) {\n return compareSubspace(productOperations, left.bounds, right.bounds);\n }\n }\n\n const [leftBox, rightBox] = splitBox(productOperations, boundingBox);\n const [ll, lr] = splitByBox(productOperations, left, leftBox, rightBox);\n const [rl, rr] = splitByBox(productOperations, right, leftBox, rightBox);\n\n const leftCmp = compareUntypedProduct(productOperations, ll, rl, leftBox);\n if (leftCmp === undefined) {\n return undefined;\n }\n return combineCmp(leftCmp, compareUntypedProduct(productOperations, lr, rr, rightBox));\n}\n\nexport function compareProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n) {\n if (left === right) {\n return 0;\n }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n const productOperations = { ...left.productOperations, ...right.productOperations };\n return compareUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n}\n\nfunction meetsSubspace<T>(productOperations: ProductOperations<T>, left: UntypedProduct<T>, right: UntypedProduct<T>) {\n for (const dimStr of Object.keys(productOperations)) {\n const dim = dimStr as keyof T;\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const lProj = toBspSet(left[dim]);\n const rProj = toBspSet(right[dim]);\n const setOperations = productOperations[dim];\n if (!meetsUntyped<unknown, unknown>(setOperations, lProj, rProj)) {\n return false;\n }\n }\n }\n\n return true;\n}\n\nfunction meetsUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n boundingBox: Box<T>,\n): boolean {\n if (left === empty || right === empty) {\n return false;\n }\n if (left === dense || right === dense) {\n return true;\n }\n if (!meetsSubspace(productOperations, left.bounds, right.bounds)) {\n return false;\n }\n if (left.isSubspace && right.isSubspace) {\n return true;\n }\n\n const [leftBox, rightBox] = splitBox(productOperations, boundingBox);\n const [ll, lr] = splitByBox(productOperations, left, leftBox, rightBox);\n const [rl, rr] = splitByBox(productOperations, right, leftBox, rightBox);\n\n return (\n meetsUntypedProduct(productOperations, ll, rl, leftBox)\n || meetsUntypedProduct(productOperations, lr, rr, rightBox)\n );\n}\n\nexport function meetsProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n) {\n if (left === empty || right === empty) {\n return false;\n }\n if (left === dense || right === dense) {\n return true;\n }\n\n const productOperations = { ...left.productOperations, ...right.productOperations };\n return meetsUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n}\n\nexport const complementProduct = <T>(set: ProductSet<T>) => exceptProduct(dense, set);\n\nexport const symmetricDiffProduct = <T>(left: ProductSet<T>, right: ProductSet<T>) =>\n unionProduct(exceptProduct(left, right), exceptProduct(right, left));\n\nexport function getSubspaces<T>(set: ProductSet<T>) {\n if (set === empty || set === dense) {\n return [];\n }\n const res: UntypedProduct<T>[] = [];\n function loop(root: UntypedSparseProduct<T>) {\n if (root.isSubspace) {\n res.push(root.bounds);\n return;\n }\n\n loop(root.left);\n loop(root.right);\n }\n\n loop(set.root);\n return res;\n}\n\nexport function forEachProduct<T, Props extends (keyof T)[]>(\n set: ProductSet<T>,\n f: (product: Product<Restrict<T, Props>>) => boolean,\n ...dims: Props\n): boolean {\n const newSet = project(set, ...dims);\n if (newSet === empty) {\n return true;\n }\n if (newSet === dense) {\n return f(unsafe.denseProduct(dims));\n }\n\n const { productOperations, root } = newSet;\n\n function loop(root_inner: UntypedSparseProduct<T>): boolean {\n if (root_inner.isSubspace) {\n return f(unsafe.fromUntypedProduct(productOperations, root_inner.bounds, dims));\n }\n return loop(root_inner.left) && loop(root_inner.right);\n }\n\n return loop(root);\n}\n\nexport function getSubspaceCount<T>(set: ProductSet<T>) {\n if (set === empty || set === dense) {\n return 0;\n }\n return getUntypedSubspaceCount(set.root);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"productSet.js","sourceRoot":"","sources":["../src/productSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AAEH,qCAmBkB;AA6DlB,MAAM,IAAI,GAA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C,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;KACvC;IAED,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAE3C,SAAS,IAAI,CAAC,UAAmC;QAC7C,IAAI,UAAU,CAAC,UAAU,EAAE;YACvB,OAAO,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;SACnF;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC;AAvBD,wCAuBC;AAED,SAAgB,gBAAgB,CAAI,GAAkB;IAClD,IAAI,GAAG,KAAK,cAAK,IAAI,GAAG,KAAK,cAAK,EAAE;QAChC,OAAO,CAAC,CAAC;KACZ;IACD,OAAO,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AALD,4CAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n BspSet,\n empty,\n dense,\n Empty,\n Dense,\n combineCmp,\n SetOperations,\n intersectUntyped,\n compareUntyped,\n Cachable,\n UntypedBspSet,\n unionUntyped,\n exceptUntyped,\n lazy,\n UntypedSparse,\n fromUntyped,\n meetsUntyped,\n Pair,\n} from \"./bspSet\";\n\ntype Restrict<T, Props extends (keyof T)[]> = { [Prop in Props[number]]: T[Prop] };\n\nexport type Product<T> = { readonly [dim in keyof T]: T[dim] extends BspSet<infer _TKey, infer _TId> ? T[dim] : never };\n\ntype UntypedProduct<T> = {\n readonly [dim in keyof T]?: T[dim] extends BspSet<infer TKey, infer _TId> ? UntypedSparse<TKey> : never;\n};\n\ntype Probabilities<T> = { readonly [dim in keyof T]?: number };\n\ntype ProductOperations<T> = {\n readonly [dim in keyof T]: T[dim] extends BspSet<infer TKey, infer TId> ? SetOperations<TKey, TId> : never;\n};\n\n/** Given a cartesian product, a subspace is a subset of said space, such that it is also a cartesian product\n * and all the dimensions form subsets of the original cartesian product.\n *\n * This is a generalized notion of something like hyper-rectangles. Examples include:\n * - Rectangles\n * - Individual cells in a grid\n * - Rectangular ranges with missing rows and/or columns\n *\n * For the actual definition and properties, please read the document about *Operations on Cartesian Products*.\n */\ninterface Subspace<T> {\n readonly isSubspace: true;\n // isCoSubspace: boolean;\n readonly bounds: UntypedProduct<T>;\n}\n\n// type CoSubspace<T> = {\n// isSubspace: boolean;\n// isCoSubspace: true;\n// subspace: Product<T>;\n// };\n\ninterface Union<T> {\n readonly isSubspace: false;\n // readonly isCoSubspace: false;\n readonly left: UntypedSparseProduct<T>;\n readonly right: UntypedSparseProduct<T>;\n readonly bounds: UntypedProduct<T>;\n readonly subspaceCount: number;\n}\n\ntype UntypedSparseProduct<T> = Subspace<T> | Union<T>; // | CoSubspace<T>;\n\ninterface SparseProduct<T> {\n readonly productOperations: ProductOperations<T>;\n readonly root: UntypedSparseProduct<T>;\n}\n\ninterface Box<T> {\n box: UntypedProduct<T>;\n probabilities: Probabilities<T>;\n children?: Pair<Box<T>>;\n depth: number;\n}\n\nconst tops: { [poKey in string]?: Box<unknown> } = {};\nconst top = <T>(productOperations: ProductOperations<T>): Box<T> => {\n const dims: [keyof T, ProductOperations<T>[keyof T][\"id\"]][] = [];\n for (const dimStr of Object.keys(productOperations)) {\n const dim = dimStr as keyof T;\n dims.push([dim, productOperations[dim].id]);\n }\n\n const poKey = JSON.stringify(dims.sort());\n let currTop = tops[poKey];\n if (currTop === undefined) {\n currTop = { box: {}, probabilities: {}, depth: 1 };\n tops[poKey] = currTop;\n }\n\n return currTop;\n};\n\nfunction subspace<T>(bounds: UntypedProduct<T>): Subspace<T> | Dense {\n let isDense = true;\n for (const dim of Object.keys(bounds)) {\n if (Object.prototype.hasOwnProperty.call(bounds, dim)) {\n isDense = false;\n break;\n }\n }\n if (isDense) {\n return dense;\n }\n return { isSubspace: true as const, bounds };\n}\n\nfunction getUntypedSubspaceCount<T>(set: UntypedSparseProduct<T>) {\n if (set.isSubspace) {\n return 1;\n }\n return set.subspaceCount;\n}\n\nconst union = <T>(\n left: UntypedSparseProduct<T>,\n right: UntypedSparseProduct<T>,\n bounds: UntypedProduct<T>,\n): Union<T> => ({\n isSubspace: false as const,\n left,\n right,\n bounds,\n subspaceCount: getUntypedSubspaceCount(left) + getUntypedSubspaceCount(right),\n});\n\nfunction sparseProduct<T>(\n productOperations: ProductOperations<T>,\n root: UntypedSparseProduct<T> | Dense,\n): SparseProduct<T> | Dense {\n if (root === dense) {\n return root;\n }\n if (root.isSubspace) {\n let hasSparseDimensions = false;\n for (const dim of Object.keys(root.bounds)) {\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n hasSparseDimensions = true;\n break;\n }\n }\n if (!hasSparseDimensions) {\n return dense;\n }\n }\n return { productOperations, root };\n}\n\ntype UntypedProductSet<T> = Empty | Dense | UntypedSparseProduct<T>;\nexport type ProductSet<T> = Empty | Dense | SparseProduct<T>;\n\nfunction toBspSet<T>(set: UntypedBspSet<T> | undefined) {\n if (set === undefined) {\n return dense;\n }\n return set;\n}\n\n/** An object that contains all downcasts. The operations in here are generally of the kind that need dynamic\n * features, i.e. iterate over the object properties somehow. Their *usage* can be considered safe, but they warrant\n * more careful review whenever a change occurs, because we get less support from the type system and we are\n * downcasting. */\nconst unsafe = {\n unzip<T>(product: Product<T>): ProductSet<T> {\n const productOperations: { [dim in keyof T]?: SetOperations<unknown, unknown> } = {};\n const root: { [dim in keyof T]?: UntypedSparse<unknown> } = {};\n for (const dimStr of Object.keys(product)) {\n const dim = dimStr as keyof T;\n if (Object.prototype.hasOwnProperty.call(product, dim)) {\n const set: BspSet<unknown, unknown> = product[dim];\n if (set === empty) {\n return empty;\n }\n if (set === dense) {\n continue;\n }\n\n productOperations[dim] = set.setOperations;\n root[dim] = set.root;\n }\n }\n\n return sparseProduct(productOperations as ProductOperations<T>, subspace(root as UntypedProduct<T>));\n },\n\n combineProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProduct<T>,\n right: UntypedProduct<T>,\n combineFunc: <Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>\n ) => UntypedBspSet<Key>,\n ) {\n const res: { [dim in keyof T]?: UntypedSparse<unknown> } = {};\n for (const dimStr of Object.keys(productOperations)) {\n const dim = dimStr as keyof T;\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const combined = combineFunc<unknown, unknown>(\n productOperations[dim],\n toBspSet(left[dim]),\n toBspSet(right[dim]),\n );\n if (combined === empty) {\n return combined;\n }\n if (combined === dense) {\n continue;\n }\n res[dim] = combined;\n }\n }\n\n return res as UntypedProduct<T>;\n },\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n restrict<T extends object, Props extends (keyof T)[]>(object: T, ...props: Props) {\n const res: Partial<Restrict<T, Props>> = {};\n for (const key of props) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n const prop = object[key];\n res[key] = prop;\n }\n }\n\n return res as Restrict<T, Props>;\n },\n\n fromUntypedProduct<T, Props extends (keyof T)[]>(\n productOperations: ProductOperations<Restrict<T, Props>>,\n bounds: UntypedProduct<Restrict<T, Props>>,\n dims: Props,\n ) {\n const product: { [dim in Props[number]]?: BspSet<unknown, unknown> } = {};\n for (const dim of dims) {\n const bound: UntypedSparse<unknown> | undefined = bounds[dim];\n product[dim] = fromUntyped(productOperations[dim], bound !== undefined ? bound : dense);\n }\n return product as Product<Restrict<T, Props>>;\n },\n\n denseProduct<T, Props extends (keyof T)[]>(dims: Props): Product<Restrict<T, Props>> {\n const top_inner: { [dim in Props[number]]?: Dense } = {};\n for (const dim of dims) {\n top_inner[dim] = dense;\n }\n return top_inner as Product<Restrict<T, Props>>;\n },\n};\n\nexport const createFromProduct = unsafe.unzip.bind(unsafe);\n\ntype Compatible<T, U> = { [dim in keyof T & keyof U]: T[dim] };\n\nfunction joinBounds<T>(productOperations: ProductOperations<T>, left: UntypedProduct<T>, right: UntypedProduct<T>) {\n const join = unsafe.combineProduct(productOperations, left, right, unionUntyped);\n if (join === empty) {\n throw new Error(\"broken invariant: the union of two non-empty products cannot be empty\");\n }\n\n return join;\n}\n\nfunction compareSubspace<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProduct<T>,\n right: UntypedProduct<T>,\n) {\n let cmp: ReturnType<typeof combineCmp> = 0;\n for (const dimStr of Object.keys(productOperations)) {\n const dim = dimStr as keyof T;\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const lProj = toBspSet(left[dim]);\n const rProj = toBspSet(right[dim]);\n const setOperations = productOperations[dim];\n\n cmp = combineCmp(cmp, compareUntyped<unknown, unknown>(setOperations, lProj, rProj));\n\n if (cmp === undefined) {\n return undefined;\n }\n }\n }\n\n return cmp;\n}\n\nconst tryUnionSubspaces = (() => {\n const cache: { left?: unknown; right?: unknown; res?: unknown; } = {};\n return <T>(\n productOperations: ProductOperations<T>,\n left: Subspace<T>,\n right: Subspace<T>,\n ): Subspace<T> | Dense | Empty | undefined => {\n if (left === cache.left && right === cache.right) {\n return cache.res as ReturnType<typeof tryUnionSubspaces>;\n }\n cache.left = left;\n cache.right = right;\n\n const cmp = compareSubspace(productOperations, left.bounds, right.bounds);\n if (cmp !== undefined) {\n return (cache.res = cmp <= 0 ? right : left);\n }\n let differentDimension: keyof T | undefined;\n\n // because Object.keys only returns string[], we need to downcast\n const po_keys = Object.keys(productOperations) as (keyof T)[];\n for (const dim of po_keys) {\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const cmp_inner = compareUntyped<unknown, unknown>(\n productOperations[dim],\n toBspSet(left.bounds[dim]),\n toBspSet(right.bounds[dim]),\n );\n if (cmp_inner !== 0) {\n if (differentDimension !== undefined) {\n return (cache.res = undefined);\n }\n\n differentDimension = dim;\n }\n }\n }\n\n if (differentDimension !== undefined) {\n const newDim = unionUntyped<unknown, unknown>(\n productOperations[differentDimension],\n toBspSet(left.bounds[differentDimension]),\n toBspSet(right.bounds[differentDimension]),\n );\n if (newDim === empty) {\n return (cache.res = empty);\n }\n if (newDim === dense) {\n // we are actually deleting the `differentDimension`, so the variable\n // `deleted` must be there. Hence disabling the rule here.\n const { [differentDimension]: deleted, ...leftBoundsWithoutDifferentDimension } = left.bounds;\n return (cache.res = subspace<unknown>(leftBoundsWithoutDifferentDimension));\n }\n\n const newBounds: UntypedProduct<T> = {\n ...left.bounds,\n [differentDimension]: newDim,\n };\n return (cache.res = subspace(newBounds));\n }\n\n return (cache.res = undefined);\n };\n})();\n\nfunction combineChildren<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n): UntypedProductSet<T> {\n if (right === empty) {\n return left;\n }\n if (right === dense) {\n return right;\n }\n if (left === empty) {\n return right;\n }\n if (left === dense) {\n return left;\n }\n\n if (!left.isSubspace || !right.isSubspace) {\n return union<T>(left, right, joinBounds(productOperations, left.bounds, right.bounds));\n }\n\n const combinedSubspace = tryUnionSubspaces<T>(productOperations, left, right);\n\n if (combinedSubspace !== undefined) {\n return combinedSubspace;\n }\n return union(left, right, joinBounds(productOperations, left.bounds, right.bounds));\n}\n\nfunction projectUntyped<T, Props extends (keyof T)[]>(\n productOperations: ProductOperations<T>,\n set: UntypedSparseProduct<T>,\n ...dims: Props\n): UntypedProductSet<Restrict<T, Props>> {\n const bounds = unsafe.restrict(set.bounds, ...dims);\n if (set.isSubspace) {\n return subspace(bounds);\n }\n\n const lChild = projectUntyped(productOperations, set.left, ...dims);\n if (lChild === dense) {\n return dense;\n }\n const rChild = projectUntyped(productOperations, set.right, ...dims);\n return combineChildren(productOperations, lChild, rChild);\n}\n\nexport function project<T, Props extends (keyof T)[]>(\n set: ProductSet<T>,\n ...dims: Props\n): ProductSet<Restrict<T, Props>> {\n if (set === dense || set === empty) {\n return set;\n }\n const productOperations = unsafe.restrict(set.productOperations, ...dims);\n const root = projectUntyped(productOperations, set.root, ...dims);\n if (root === empty) {\n return root;\n }\n return sparseProduct(productOperations, root);\n}\n\nfunction splitBox<T>(productOperations: ProductOperations<T>, currentBox: Box<T>): Pair<Box<T>> {\n if (currentBox.children !== undefined) { return currentBox.children; }\n const { box, probabilities } = currentBox;\n let biggestDim: keyof T | undefined;\n let biggestDimKey;\n let currentProb = 0;\n // because Object.keys only returns string[], we need to downcast\n const po_keys = Object.keys(productOperations) as (keyof T)[];\n for (const dim of po_keys) {\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const prob: number | undefined = probabilities[dim];\n const setOperations_inner = productOperations[dim];\n if (prob === undefined) {\n biggestDim = dim;\n biggestDimKey = setOperations_inner.top;\n break;\n }\n\n if (prob > currentProb) {\n const dimensionSet = toBspSet(box[dim]);\n if (dimensionSet === empty) {\n throw new Error(\"the key split can never return empty\");\n }\n let key = setOperations_inner.top;\n if (dimensionSet !== dense) {\n if (!dimensionSet.isExact) {\n throw new Error(\"the key can always be represented exactly\");\n }\n\n key = dimensionSet.key;\n }\n if (!setOperations_inner.canSplit(key)) {\n continue;\n }\n biggestDim = dim;\n currentProb = prob;\n biggestDimKey = key;\n }\n }\n }\n\n if (biggestDim === undefined || biggestDimKey === undefined) {\n throw new Error(\"there has to be at least one dimension\");\n }\n\n const setOperations = productOperations[biggestDim];\n\n const [[leftDim, leftProb], [rightDim, rightProb]] = setOperations.split(biggestDimKey);\n const res: ReturnType<typeof splitBox> = [\n {\n box: { ...box, [biggestDim]: lazy<unknown, unknown>(setOperations, setOperations.top, leftDim) },\n probabilities: { ...probabilities, [biggestDim]: leftProb },\n depth: currentBox.depth + 1,\n },\n {\n box: { ...box, [biggestDim]: lazy<unknown, unknown>(setOperations, setOperations.top, rightDim) },\n probabilities: { ...probabilities, [biggestDim]: rightProb },\n depth: currentBox.depth + 1,\n },\n ];\n if (currentBox.depth < 10) {\n currentBox.children = res;\n }\n return res;\n}\n\nfunction restrictByBounds<T>(\n productOperations: ProductOperations<T>,\n set: UntypedProductSet<T>,\n leftBounds: UntypedProduct<T>,\n rightBounds: UntypedProduct<T>,\n): Pair<UntypedProductSet<T>> {\n if (set === empty) {\n return [empty, empty];\n }\n if (set === dense) {\n return [subspace(leftBounds), subspace(rightBounds)];\n }\n const cmp = compareSubspace(productOperations, set.bounds, leftBounds);\n\n // the set is fully contained in the left half, i.e. we know the pair.\n if (cmp !== undefined && cmp <= 0) {\n return [set, empty];\n }\n\n const newLeftBounds = unsafe.combineProduct(productOperations, set.bounds, leftBounds, intersectUntyped);\n\n // if we know, that the left set is completely empty, then the whole set is in the right bounds.\n if (newLeftBounds === empty) {\n return [empty, set];\n }\n\n const newRightBounds = unsafe.combineProduct(productOperations, set.bounds, rightBounds, intersectUntyped);\n if (set.isSubspace) {\n return [subspace(newLeftBounds), newRightBounds === empty ? empty : subspace(newRightBounds)];\n }\n\n const [ll, lr] = restrictByBounds(productOperations, set.left, leftBounds, rightBounds);\n const [rl, rr] = restrictByBounds(productOperations, set.right, leftBounds, rightBounds);\n return [combineChildren(productOperations, ll, rl), combineChildren(productOperations, lr, rr)];\n}\n\nconst splitByBox = <T>(\n productOperations: ProductOperations<T>,\n set: UntypedProductSet<T>,\n { box: leftBounds }: Box<T>,\n { box: rightBounds }: Box<T>,\n): Pair<UntypedProductSet<T>, UntypedProductSet<T>> => {\n return restrictByBounds(productOperations, set, leftBounds, rightBounds);\n};\n\nfunction recurse<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n currentBox: Box<T>,\n visitFunc: (\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n box: Box<T>\n ) => UntypedProductSet<T>,\n) {\n const [leftBox, rightBox] = splitBox(productOperations, currentBox);\n const [ll, lr] = splitByBox(productOperations, left, leftBox, rightBox);\n const [rl, rr] = splitByBox(productOperations, right, leftBox, rightBox);\n\n const lChild = visitFunc(productOperations, ll, rl, leftBox);\n if (lChild === dense) {\n return dense;\n }\n const rChild = visitFunc(productOperations, lr, rr, rightBox);\n return combineChildren(productOperations, lChild, rChild);\n}\n\nfunction unionUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n currentBox: Box<T>,\n): UntypedProductSet<T> {\n if (right === empty) {\n return left;\n }\n if (left === empty) {\n return right;\n }\n if (left === dense) {\n return left;\n }\n if (right === dense) {\n return right;\n }\n if (left.isSubspace && right.isSubspace) {\n const combinedSubspace = tryUnionSubspaces(productOperations, left, right);\n if (combinedSubspace !== undefined) {\n return combinedSubspace;\n }\n }\n\n return recurse(productOperations, left, right, currentBox, unionUntypedProduct);\n}\n\nexport function unionProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n): ProductSet<T & U> {\n if (right === empty) {\n return left;\n }\n if (right === dense) {\n return right;\n }\n if (left === empty) {\n return right;\n }\n if (left === dense) {\n return left;\n }\n const productOperations = { ...left.productOperations, ...right.productOperations };\n const res = unionUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n if (res === empty) {\n return res;\n }\n return sparseProduct(productOperations, res);\n}\n\nfunction intersectUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n currentBox: Box<T>,\n): UntypedProductSet<T> {\n if (left === empty || right === empty) {\n return empty;\n }\n if (left === dense) {\n return right;\n }\n if (right === dense) {\n return left;\n }\n if (left.isSubspace && right.isSubspace) {\n const res = unsafe.combineProduct(productOperations, left.bounds, right.bounds, intersectUntyped);\n if (res === empty) {\n return empty;\n }\n return subspace(res);\n }\n\n return recurse(productOperations, left, right, currentBox, intersectUntypedProduct);\n}\n\nexport function intersectProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n): ProductSet<T & U> {\n if (left === empty) {\n return left;\n }\n if (right === empty) {\n return right;\n }\n if (left === dense) {\n return right;\n }\n if (right === dense) {\n return left;\n }\n\n const productOperations = { ...left.productOperations, ...right.productOperations };\n const res = intersectUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n if (res === empty) {\n return res;\n }\n return sparseProduct(productOperations, res);\n}\n\nfunction tryExceptSubspaces<T>(\n productOperations: ProductOperations<T>,\n left: Subspace<T>,\n right: Subspace<T>,\n): Subspace<T> | Dense | Empty | undefined {\n const cmp = compareSubspace(productOperations, left.bounds, right.bounds);\n if (cmp === 0 || cmp === -1) {\n return empty;\n }\n let notContainedDimension: keyof T | undefined;\n // because Object.keys only returns string[], we need to downcast\n const po_keys = Object.keys(productOperations) as (keyof T)[];\n for (const dim of po_keys) {\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const cmp_inner = compareUntyped<unknown, unknown>(\n productOperations[dim],\n toBspSet(left.bounds[dim]),\n toBspSet(right.bounds[dim]),\n );\n if (cmp_inner === undefined || cmp_inner > 0) {\n if (notContainedDimension !== undefined) {\n return undefined;\n }\n\n notContainedDimension = dim;\n }\n }\n }\n\n if (notContainedDimension !== undefined) {\n const newDim = exceptUntyped<unknown, unknown>(\n productOperations[notContainedDimension],\n toBspSet(left.bounds[notContainedDimension]),\n toBspSet(right.bounds[notContainedDimension]),\n );\n\n if (newDim === empty) {\n return empty;\n }\n if (newDim === dense) {\n // we are actually deleting the `differentDimension`, so the variable\n // `deleted` must be there. Hence disabling the rule here.\n const { [notContainedDimension]: deleted, ...leftBoundsWithoutDifferentDimension } = left.bounds;\n return subspace<unknown>(leftBoundsWithoutDifferentDimension);\n }\n const newBounds: UntypedProduct<T> = {\n ...left.bounds,\n [notContainedDimension]: newDim,\n };\n return subspace(newBounds);\n }\n\n return undefined;\n}\n\nfunction exceptUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n currentBox: Box<T>,\n): UntypedProductSet<T> {\n if (left === empty) {\n return left;\n }\n if (right === dense) {\n return empty;\n }\n if (right === empty) {\n return left;\n }\n\n if (left === dense) {\n return recurse(productOperations, left, right, currentBox, exceptUntypedProduct);\n }\n\n if (left.isSubspace && right.isSubspace) {\n const combinedSubspace = tryExceptSubspaces(productOperations, left, right);\n if (combinedSubspace !== undefined) {\n return combinedSubspace;\n }\n }\n\n return recurse(productOperations, left, right, currentBox, exceptUntypedProduct);\n}\n\nexport function exceptProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n): ProductSet<T & U> {\n if (left === empty) {\n return left;\n }\n if (right === empty) {\n return left;\n }\n if (right === dense) {\n return empty;\n }\n if (left === dense) {\n const res_inner =\n exceptUntypedProduct(right.productOperations, dense, right.root, top(right.productOperations));\n if (res_inner === empty) {\n return res_inner;\n }\n return sparseProduct(right.productOperations, res_inner);\n }\n\n const productOperations = { ...left.productOperations, ...right.productOperations };\n const res = exceptUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n if (res === empty) {\n return res;\n }\n return sparseProduct(productOperations, res);\n}\n\nfunction compareUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n boundingBox: Box<T>,\n): -1 | 0 | 1 | undefined {\n if (left === right) {\n return 0;\n }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n if (left.isSubspace) {\n if (right.isSubspace) {\n return compareSubspace(productOperations, left.bounds, right.bounds);\n }\n }\n\n const [leftBox, rightBox] = splitBox(productOperations, boundingBox);\n const [ll, lr] = splitByBox(productOperations, left, leftBox, rightBox);\n const [rl, rr] = splitByBox(productOperations, right, leftBox, rightBox);\n\n const leftCmp = compareUntypedProduct(productOperations, ll, rl, leftBox);\n if (leftCmp === undefined) {\n return undefined;\n }\n return combineCmp(leftCmp, compareUntypedProduct(productOperations, lr, rr, rightBox));\n}\n\nexport function compareProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n) {\n if (left === right) {\n return 0;\n }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n const productOperations = { ...left.productOperations, ...right.productOperations };\n return compareUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n}\n\nfunction meetsSubspace<T>(productOperations: ProductOperations<T>, left: UntypedProduct<T>, right: UntypedProduct<T>) {\n for (const dimStr of Object.keys(productOperations)) {\n const dim = dimStr as keyof T;\n if (Object.prototype.hasOwnProperty.call(productOperations, dim)) {\n const lProj = toBspSet(left[dim]);\n const rProj = toBspSet(right[dim]);\n const setOperations = productOperations[dim];\n if (!meetsUntyped<unknown, unknown>(setOperations, lProj, rProj)) {\n return false;\n }\n }\n }\n\n return true;\n}\n\nfunction meetsUntypedProduct<T>(\n productOperations: ProductOperations<T>,\n left: UntypedProductSet<T>,\n right: UntypedProductSet<T>,\n boundingBox: Box<T>,\n): boolean {\n if (left === empty || right === empty) {\n return false;\n }\n if (left === dense || right === dense) {\n return true;\n }\n if (!meetsSubspace(productOperations, left.bounds, right.bounds)) {\n return false;\n }\n if (left.isSubspace && right.isSubspace) {\n return true;\n }\n\n const [leftBox, rightBox] = splitBox(productOperations, boundingBox);\n const [ll, lr] = splitByBox(productOperations, left, leftBox, rightBox);\n const [rl, rr] = splitByBox(productOperations, right, leftBox, rightBox);\n\n return (\n meetsUntypedProduct(productOperations, ll, rl, leftBox)\n || meetsUntypedProduct(productOperations, lr, rr, rightBox)\n );\n}\n\nexport function meetsProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(\n left: ProductSet<T>,\n right: ProductSet<U>,\n) {\n if (left === empty || right === empty) {\n return false;\n }\n if (left === dense || right === dense) {\n return true;\n }\n\n const productOperations = { ...left.productOperations, ...right.productOperations };\n return meetsUntypedProduct(productOperations, left.root, right.root, top(productOperations));\n}\n\nexport const complementProduct = <T>(set: ProductSet<T>) => exceptProduct(dense, set);\n\nexport const symmetricDiffProduct = <T>(left: ProductSet<T>, right: ProductSet<T>) =>\n unionProduct(exceptProduct(left, right), exceptProduct(right, left));\n\nexport function getSubspaces<T>(set: ProductSet<T>) {\n if (set === empty || set === dense) {\n return [];\n }\n const res: UntypedProduct<T>[] = [];\n function loop(root: UntypedSparseProduct<T>) {\n if (root.isSubspace) {\n res.push(root.bounds);\n return;\n }\n\n loop(root.left);\n loop(root.right);\n }\n\n loop(set.root);\n return res;\n}\n\nexport function forEachProduct<T, Props extends (keyof T)[]>(\n set: ProductSet<T>,\n f: (product: Product<Restrict<T, Props>>) => boolean,\n ...dims: Props\n): boolean {\n const newSet = project(set, ...dims);\n if (newSet === empty) {\n return true;\n }\n if (newSet === dense) {\n return f(unsafe.denseProduct(dims));\n }\n\n const { productOperations, root } = newSet;\n\n function loop(root_inner: UntypedSparseProduct<T>): boolean {\n if (root_inner.isSubspace) {\n return f(unsafe.fromUntypedProduct(productOperations, root_inner.bounds, dims));\n }\n return loop(root_inner.left) && loop(root_inner.right);\n }\n\n return loop(root);\n}\n\nexport function getSubspaceCount<T>(set: ProductSet<T>) {\n if (set === empty || set === dense) {\n return 0;\n }\n return getUntypedSubspaceCount(set.root);\n}\n"]}
|
package/dist/range.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Ensures that 0
|
|
6
|
+
* Ensures that 0 \<= 'value' \< 'limit'. Throws a RangeError otherwise.
|
|
7
7
|
*/
|
|
8
8
|
export declare function ensureRange(value: number, limit: number): void;
|
|
9
9
|
//# sourceMappingURL=range.d.ts.map
|
package/dist/range.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ensureRange = void 0;
|
|
8
8
|
/**
|
|
9
|
-
* Ensures that 0
|
|
9
|
+
* Ensures that 0 \<= 'value' \< 'limit'. Throws a RangeError otherwise.
|
|
10
10
|
*/
|
|
11
11
|
function ensureRange(value, limit) {
|
|
12
12
|
// Coerce 'value' to Uint32 so that we can range check with a single branch.
|
package/dist/range.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.js","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEF;;GAEG;AACJ,SAAgB,WAAW,CAAC,KAAa,EAAE,KAAa;IACpD,4EAA4E;IAC5E,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAC,CAAG,iCAAiC;IAE/D,IAAI,MAAM,IAAI,KAAK,EAAE;QACjB,MAAM,IAAI,UAAU,CAAC,gCAAgC,CAAC,CAAC;KAC1D;AACL,CAAC;AAPD,kCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n /**\n * Ensures that 0
|
|
1
|
+
{"version":3,"file":"range.js","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEF;;GAEG;AACJ,SAAgB,WAAW,CAAC,KAAa,EAAE,KAAa;IACpD,4EAA4E;IAC5E,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAC,CAAG,iCAAiC;IAE/D,IAAI,MAAM,IAAI,KAAK,EAAE;QACjB,MAAM,IAAI,UAAU,CAAC,gCAAgC,CAAC,CAAC;KAC1D;AACL,CAAC;AAPD,kCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n /**\n * Ensures that 0 \\<= 'value' \\< 'limit'. Throws a RangeError otherwise.\n */\nexport function ensureRange(value: number, limit: number) {\n // Coerce 'value' to Uint32 so that we can range check with a single branch.\n const _value = value >>> 0; // eslint-disable-line no-bitwise\n\n if (_value >= limit) {\n throw new RangeError(\"Invalid (row, col) coordinate.\");\n }\n}\n"]}
|
package/dist/serialization.js
CHANGED
|
@@ -11,7 +11,7 @@ const serializeBlob = (handle, path, snapshot, serializer) => new protocol_base_
|
|
|
11
11
|
exports.serializeBlob = serializeBlob;
|
|
12
12
|
async function deserializeBlob(storage, path, serializer) {
|
|
13
13
|
const blob = await storage.readBlob(path);
|
|
14
|
-
const utf8 = common_utils_1.bufferToString(blob, "utf8");
|
|
14
|
+
const utf8 = (0, common_utils_1.bufferToString)(blob, "utf8");
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
16
16
|
return serializer.parse(utf8);
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAA8D;AAG9D,+DAA8D;AAEvD,MAAM,aAAa,GAAG,CACzB,MAAoB,EACpB,IAAY,EACZ,QAAsB,EACtB,UAA4B,EAC9B,EAAE,CAAC,IAAI,6BAAa,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AALxD,QAAA,aAAa,iBAK2C;AAE9D,KAAK,UAAU,eAAe,CAAC,OAA+B,EAAE,IAAY,EAAE,UAA4B;IAC7G,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,6BAAc,
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAA8D;AAG9D,+DAA8D;AAEvD,MAAM,aAAa,GAAG,CACzB,MAAoB,EACpB,IAAY,EACZ,QAAsB,EACtB,UAA4B,EAC9B,EAAE,CAAC,IAAI,6BAAa,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AALxD,QAAA,aAAa,iBAK2C;AAE9D,KAAK,UAAU,eAAe,CAAC,OAA+B,EAAE,IAAY,EAAE,UAA4B;IAC7G,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1C,+DAA+D;IAC/D,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AALD,0CAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Serializable, IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { BlobTreeEntry } from \"@fluidframework/protocol-base\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { bufferToString } from \"@fluidframework/common-utils\";\n\nexport const serializeBlob = (\n handle: IFluidHandle,\n path: string,\n snapshot: Serializable,\n serializer: IFluidSerializer,\n) => new BlobTreeEntry(path, serializer.stringify(snapshot, handle));\n\nexport async function deserializeBlob(storage: IChannelStorageService, path: string, serializer: IFluidSerializer) {\n const blob = await storage.readBlob(path);\n const utf8 = bufferToString(blob, \"utf8\");\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return serializer.parse(utf8);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undoprovider.d.ts","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAiB,2BAA2B,EAAsB,MAAM,4BAA4B,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC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AE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,EACjD,UAAU,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI;IAG/D,MAAM,CAAC,SAAS,EAAE,2BAA2B,EAAE,MAAM,EAAE;QAAE,OAAO,EAAE,kBAAkB,CAAC;KAAE,EAAE;IAoDhG,OAAO,CAAC,cAAc;CAmCzB;AAED,qBAAa,kBAAkB,CAAC,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAHJ,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,IAAI,EAAE,iBAAiB,EACvB,IAAI,EAAE,iBAAiB;IAwB5C,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;CAgBxE"}
|
package/dist/undoprovider.js
CHANGED
|
@@ -35,7 +35,7 @@ class VectorUndoProvider {
|
|
|
35
35
|
}
|
|
36
36
|
// For SharedMatrix, each IRevertibles always holds a single row/col operation.
|
|
37
37
|
// Therefore, 'currentOp' must either be undefined or equal to the current op.
|
|
38
|
-
common_utils_1.assert(this.currentOp === undefined || this.currentOp === operation, 0x02a /* "On vector undo, unexpected 'currentOp' type/state!" */);
|
|
38
|
+
(0, common_utils_1.assert)(this.currentOp === undefined || this.currentOp === operation, 0x02a /* "On vector undo, unexpected 'currentOp' type/state!" */);
|
|
39
39
|
switch (operation) {
|
|
40
40
|
case 0 /* INSERT */:
|
|
41
41
|
if (this.currentOp !== 0 /* INSERT */) {
|
|
@@ -62,7 +62,7 @@ class VectorUndoProvider {
|
|
|
62
62
|
pushRevertible(trackingGroup, callback) {
|
|
63
63
|
const revertible = {
|
|
64
64
|
revert: () => {
|
|
65
|
-
common_utils_1.assert(this.currentGroup === undefined && this.currentOp === undefined, 0x02b /* "Must not nest calls to IRevertible.revert()" */);
|
|
65
|
+
(0, common_utils_1.assert)(this.currentGroup === undefined && this.currentOp === undefined, 0x02b /* "Must not nest calls to IRevertible.revert()" */);
|
|
66
66
|
this.currentGroup = new merge_tree_1.TrackingGroup();
|
|
67
67
|
try {
|
|
68
68
|
while (trackingGroup.size > 0) {
|
|
@@ -114,7 +114,7 @@ class MatrixUndoProvider {
|
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
cellSet(rowHandle, colHandle, oldValue) {
|
|
117
|
-
common_utils_1.assert(handletable_1.isHandleValid(rowHandle) && handletable_1.isHandleValid(colHandle), 0x02c /* "On cellSet(), invalid row and/or column handles!" */);
|
|
117
|
+
(0, common_utils_1.assert)((0, handletable_1.isHandleValid)(rowHandle) && (0, handletable_1.isHandleValid)(colHandle), 0x02c /* "On cellSet(), invalid row and/or column handles!" */);
|
|
118
118
|
if (this.consumer !== undefined) {
|
|
119
119
|
this.consumer.pushToCurrentOperation({
|
|
120
120
|
revert: () => {
|
package/dist/undoprovider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undoprovider.js","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,2DAA4G;AAE5G,+CAAsD;AAItD,MAAa,kBAAkB;IAO3B,YACqB,OAAsB,EACtB,UAAiD,EACjD,UAAiD;QAFjD,YAAO,GAAP,OAAO,CAAe;QACtB,eAAU,GAAV,UAAU,CAAuC;QACjD,eAAU,GAAV,UAAU,CAAuC;IAClE,CAAC;IAEE,MAAM,CAAC,SAAsC,EAAE,MAAyC;;QAC3F,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,yFAAyF;YACzF,4FAA4F;YAC5F,EAAE;YACF,0FAA0F;YAC1F,4FAA4F;YAC5F,0BAA0B;YAC1B,EAAE;YACF,6FA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B,CAAC,CAAC,OAA2B,EAAE,EAAE;YAC9C,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CACJ,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,IAAI,kBAAkB,CAC9B,QAAQ;QACR,iBAAiB,CAAC,CAAC,OAA2B,EAAE,EAAE;YAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAC7C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QACxD,CAAC;QACD,iBAAiB,CAAC,CAAC,OAA2B,EAAE,EAAE;YAC9C,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CACJ,CAAC;IACN,CAAC;IAED,OAAO,CAAC,SAAiB,EAAE,SAAiB,EAAE,QAAuB;QACjE,qBAAM,CAAC,2BAAa,CAAC,SAAS,CAAC,IAAI,2BAAa,CAAC,SAAS,CAAC,EACvD,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAEpE,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC7B,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;gBACjC,MAAM,EAAE,GAAG,EAAE;oBACT,IAAI,CAAC,MAAM,CAAC,OAAO,CACf,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,QAAQ,CAAC,CAAC;gBAClB,CAAC;gBACD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;aACpB,CAAC,CAAC;SACN;IACL,CAAC;CACJ;AA7CD,gDA6CC","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 { TrackingGroup, MergeTreeDeltaOperationType, MergeTreeDeltaType } from \"@fluidframework/merge-tree\";\nimport { MatrixItem, SharedMatrix } from \"./matrix\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationSegment, PermutationVector } from \"./permutationvector\";\nimport { IUndoConsumer } from \"./types\";\n\nexport class VectorUndoProvider {\n // 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce\n // the recorded into a single IRevertable / tracking group as they move between the undo <->\n // redo stacks.\n private currentGroup?: TrackingGroup;\n private currentOp?: MergeTreeDeltaType;\n\n constructor(\n private readonly manager: IUndoConsumer,\n private readonly undoInsert: (segment: PermutationSegment) => void,\n private readonly undoRemove: (segment: PermutationSegment) => void,\n ) { }\n\n public record(operation: MergeTreeDeltaOperationType, ranges: { segment: PermutationSegment }[]) {\n if (ranges.length > 0) {\n // Link each segment to a new TrackingGroup. A TrackingGroup keeps track of the original\n // set of linked segments, including any fragmentatiton that occurs due to future splitting.\n //\n // A TrackingGroup also prevents removed segments from being unlinked from the tree during\n // Zamboni and guarantees segments will not be merged/coalesced with segments outside of the\n // current tracking group.\n //\n // These properties allow us to rely on MergeTree.getPosition() to find the locations/lengths\n // of all content contained within the tracking group in the future.\n\n // If we are in the process of reverting, the `IRevertible.revert()` will provide the tracking\n // group so that we can preserve the original segment ranges as a single op/group as we move\n // ops between the undo <-> redo stacks.\n const trackingGroup = this.currentGroup ?? new TrackingGroup();\n for (const range of ranges) {\n trackingGroup.link(range.segment);\n }\n\n // For SharedMatrix, each IRevertibles always holds a single row/col operation.\n // Therefore, 'currentOp' must either be undefined or equal to the current op.\n assert(this.currentOp === undefined || this.currentOp === operation,\n 0x02a /* \"On vector undo, unexpected 'currentOp' type/state!\" */);\n\n switch (operation) {\n case MergeTreeDeltaType.INSERT:\n if (this.currentOp !== MergeTreeDeltaType.INSERT) {\n this.pushRevertible(trackingGroup, this.undoInsert);\n }\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n if (this.currentOp !== MergeTreeDeltaType.REMOVE) {\n this.pushRevertible(trackingGroup, this.undoRemove);\n }\n break;\n }\n\n default:\n throw new Error(\"operation type not revertible\");\n }\n\n // If we are in the process of reverting, set 'currentOp' to remind ourselves not to push\n // another revertible until `IRevertable.revert()` finishes the current op and clears this\n // field.\n if (this.currentGroup !== undefined) {\n this.currentOp = operation;\n }\n }\n }\n\n private pushRevertible(trackingGroup: TrackingGroup, callback: (segment: PermutationSegment) => void) {\n const revertible = {\n revert: () => {\n assert(this.currentGroup === undefined && this.currentOp === undefined,\n 0x02b /* \"Must not nest calls to IRevertible.revert()\" */);\n\n this.currentGroup = new TrackingGroup();\n\n try {\n while (trackingGroup.size > 0) {\n const segment = trackingGroup.segments[0] as PermutationSegment;\n\n // Unlink 'segment' from the current tracking group before invoking the callback\n // to exclude the current undo/redo segment from those copied to the replacement\n // segment (if any). (See 'PermutationSegment.transferToReplacement()')\n segment.trackingCollection.unlink(trackingGroup);\n\n callback(segment);\n }\n } finally {\n this.currentOp = undefined;\n this.currentGroup = undefined;\n }\n },\n discard: () => {\n while (trackingGroup.size > 0) {\n trackingGroup.unlink(trackingGroup.segments[0]);\n }\n },\n };\n\n this.manager.pushToCurrentOperation(revertible);\n\n return revertible;\n }\n}\n\nexport class MatrixUndoProvider<T> {\n constructor(\n private readonly consumer: IUndoConsumer,\n private readonly matrix: SharedMatrix<T>,\n private readonly rows: PermutationVector,\n private readonly cols: PermutationVector,\n ) {\n rows.undo = new VectorUndoProvider(\n consumer,\n /* undoInsert: */ (segment: PermutationSegment) => {\n const start = this.rows.getPosition(segment);\n this.matrix.removeRows(start, segment.cachedLength);\n },\n /* undoRemove: */ (segment: PermutationSegment) => {\n this.matrix._undoRemoveRows(segment);\n },\n );\n cols.undo = new VectorUndoProvider(\n consumer,\n /* undoInsert: */ (segment: PermutationSegment) => {\n const start = this.cols.getPosition(segment);\n this.matrix.removeCols(start, segment.cachedLength);\n },\n /* undoRemove: */ (segment: PermutationSegment) => {\n this.matrix._undoRemoveCols(segment);\n },\n );\n }\n\n cellSet(rowHandle: Handle, colHandle: Handle, oldValue: MatrixItem<T>) {\n assert(isHandleValid(rowHandle) && isHandleValid(colHandle),\n 0x02c /* \"On cellSet(), invalid row and/or column handles!\" */);\n\n if (this.consumer !== undefined) {\n this.consumer.pushToCurrentOperation({\n revert: () => {\n this.matrix.setCell(\n this.rows.handleToPosition(rowHandle),\n this.cols.handleToPosition(colHandle),\n oldValue);\n },\n discard: () => {},\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"undoprovider.js","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,2DAA4G;AAE5G,+CAAsD;AAItD,MAAa,kBAAkB;IAO3B,YACqB,OAAsB,EACtB,UAAiD,EACjD,UAAiD;QAFjD,YAAO,GAAP,OAAO,CAAe;QACtB,eAAU,GAAV,UAAU,CAAuC;QACjD,eAAU,GAAV,UAAU,CAAuC;IAClE,CAAC;IAEE,MAAM,CAAC,SAAsC,EAAE,MAA0C;;QAC5F,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,yFAAyF;YACzF,4FAA4F;YAC5F,EAAE;YACF,0FAA0F;YAC1F,4FAA4F;YAC5F,0BAA0B;YAC1B,EAAE;YACF,6FAA6F;YAC7F,oEAAoE;YAEpE,8FAA8F;YAC9F,4FAA4F;YAC5F,wCAAwC;YACxC,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,YAAY,mCAAI,IAAI,0BAAa,EAAE,CAAC;YAC/D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBACxB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aACrC;YAED,+EAA+E;YAC/E,8EAA8E;YAC9E,IAAA,qBAAM,EAAC,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAC/D,KAAK,CAAC,0DAA0D,CAAC,CAAC;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,iBAAiB,CAAC,CAAC,OAA2B,EAAE,EAAE;YAC9C,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CACJ,CAAC;IACN,CAAC;IAED,OAAO,CAAC,SAAiB,EAAE,SAAiB,EAAE,QAAuB;QACjE,IAAA,qBAAM,EAAC,IAAA,2BAAa,EAAC,SAAS,CAAC,IAAI,IAAA,2BAAa,EAAC,SAAS,CAAC,EACvD,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAEpE,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC7B,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;gBACjC,MAAM,EAAE,GAAG,EAAE;oBACT,IAAI,CAAC,MAAM,CAAC,OAAO,CACf,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACrC,QAAQ,CAAC,CAAC;gBAClB,CAAC;gBACD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;aACpB,CAAC,CAAC;SACN;IACL,CAAC;CACJ;AA7CD,gDA6CC","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 { TrackingGroup, MergeTreeDeltaOperationType, MergeTreeDeltaType } from \"@fluidframework/merge-tree\";\nimport { MatrixItem, SharedMatrix } from \"./matrix\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationSegment, PermutationVector } from \"./permutationvector\";\nimport { IUndoConsumer } from \"./types\";\n\nexport class VectorUndoProvider {\n // 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce\n // the recorded into a single IRevertable / tracking group as they move between the undo <->\n // redo stacks.\n private currentGroup?: TrackingGroup;\n private currentOp?: MergeTreeDeltaType;\n\n constructor(\n private readonly manager: IUndoConsumer,\n private readonly undoInsert: (segment: PermutationSegment) => void,\n private readonly undoRemove: (segment: PermutationSegment) => void,\n ) { }\n\n public record(operation: MergeTreeDeltaOperationType, ranges: { segment: PermutationSegment; }[]) {\n if (ranges.length > 0) {\n // Link each segment to a new TrackingGroup. A TrackingGroup keeps track of the original\n // set of linked segments, including any fragmentatiton that occurs due to future splitting.\n //\n // A TrackingGroup also prevents removed segments from being unlinked from the tree during\n // Zamboni and guarantees segments will not be merged/coalesced with segments outside of the\n // current tracking group.\n //\n // These properties allow us to rely on MergeTree.getPosition() to find the locations/lengths\n // of all content contained within the tracking group in the future.\n\n // If we are in the process of reverting, the `IRevertible.revert()` will provide the tracking\n // group so that we can preserve the original segment ranges as a single op/group as we move\n // ops between the undo <-> redo stacks.\n const trackingGroup = this.currentGroup ?? new TrackingGroup();\n for (const range of ranges) {\n trackingGroup.link(range.segment);\n }\n\n // For SharedMatrix, each IRevertibles always holds a single row/col operation.\n // Therefore, 'currentOp' must either be undefined or equal to the current op.\n assert(this.currentOp === undefined || this.currentOp === operation,\n 0x02a /* \"On vector undo, unexpected 'currentOp' type/state!\" */);\n\n switch (operation) {\n case MergeTreeDeltaType.INSERT:\n if (this.currentOp !== MergeTreeDeltaType.INSERT) {\n this.pushRevertible(trackingGroup, this.undoInsert);\n }\n break;\n\n case MergeTreeDeltaType.REMOVE: {\n if (this.currentOp !== MergeTreeDeltaType.REMOVE) {\n this.pushRevertible(trackingGroup, this.undoRemove);\n }\n break;\n }\n\n default:\n throw new Error(\"operation type not revertible\");\n }\n\n // If we are in the process of reverting, set 'currentOp' to remind ourselves not to push\n // another revertible until `IRevertable.revert()` finishes the current op and clears this\n // field.\n if (this.currentGroup !== undefined) {\n this.currentOp = operation;\n }\n }\n }\n\n private pushRevertible(trackingGroup: TrackingGroup, callback: (segment: PermutationSegment) => void) {\n const revertible = {\n revert: () => {\n assert(this.currentGroup === undefined && this.currentOp === undefined,\n 0x02b /* \"Must not nest calls to IRevertible.revert()\" */);\n\n this.currentGroup = new TrackingGroup();\n\n try {\n while (trackingGroup.size > 0) {\n const segment = trackingGroup.segments[0] as PermutationSegment;\n\n // Unlink 'segment' from the current tracking group before invoking the callback\n // to exclude the current undo/redo segment from those copied to the replacement\n // segment (if any). (See 'PermutationSegment.transferToReplacement()')\n segment.trackingCollection.unlink(trackingGroup);\n\n callback(segment);\n }\n } finally {\n this.currentOp = undefined;\n this.currentGroup = undefined;\n }\n },\n discard: () => {\n while (trackingGroup.size > 0) {\n trackingGroup.unlink(trackingGroup.segments[0]);\n }\n },\n };\n\n this.manager.pushToCurrentOperation(revertible);\n\n return revertible;\n }\n}\n\nexport class MatrixUndoProvider<T> {\n constructor(\n private readonly consumer: IUndoConsumer,\n private readonly matrix: SharedMatrix<T>,\n private readonly rows: PermutationVector,\n private readonly cols: PermutationVector,\n ) {\n rows.undo = new VectorUndoProvider(\n consumer,\n /* undoInsert: */ (segment: PermutationSegment) => {\n const start = this.rows.getPosition(segment);\n this.matrix.removeRows(start, segment.cachedLength);\n },\n /* undoRemove: */ (segment: PermutationSegment) => {\n this.matrix._undoRemoveRows(segment);\n },\n );\n cols.undo = new VectorUndoProvider(\n consumer,\n /* undoInsert: */ (segment: PermutationSegment) => {\n const start = this.cols.getPosition(segment);\n this.matrix.removeCols(start, segment.cachedLength);\n },\n /* undoRemove: */ (segment: PermutationSegment) => {\n this.matrix._undoRemoveCols(segment);\n },\n );\n }\n\n cellSet(rowHandle: Handle, colHandle: Handle, oldValue: MatrixItem<T>) {\n assert(isHandleValid(rowHandle) && isHandleValid(colHandle),\n 0x02c /* \"On cellSet(), invalid row and/or column handles!\" */);\n\n if (this.consumer !== undefined) {\n this.consumer.pushToCurrentOperation({\n revert: () => {\n this.matrix.setCell(\n this.rows.handleToPosition(rowHandle),\n this.cols.handleToPosition(colHandle),\n oldValue);\n },\n discard: () => {},\n });\n }\n }\n}\n"]}
|
package/lib/bspSet.d.ts
CHANGED
|
@@ -117,8 +117,8 @@ export declare function except<Key extends Cachable<Key>, Id>(left: BspSet<Key,
|
|
|
117
117
|
export declare function combineCmp(left: -1 | 0 | 1 | undefined, right: -1 | 0 | 1 | undefined): 0 | 1 | -1 | undefined;
|
|
118
118
|
export declare function compareUntyped<Key extends Cachable<Key>, Id>(setOperations: SetOperations<Key, Id>, left: UntypedBspSet<Key>, right: UntypedBspSet<Key>): -1 | 0 | 1 | undefined;
|
|
119
119
|
export declare function compare<Key extends Cachable<Key>, Id>(left: BspSet<Key, Id>, right: BspSet<Key, Id>): 0 | 1 | -1 | undefined;
|
|
120
|
-
export declare const symmetricDiff: <Key extends Disjoint<keyof Key,
|
|
121
|
-
export declare const complement: <Key extends Disjoint<keyof Key,
|
|
120
|
+
export declare const symmetricDiff: <Key extends Disjoint<keyof Key, keyof KeyCache<T>>, Id>(left: BspSet<Key, Id>, right: BspSet<Key, Id>) => BspSet<Key, Id>;
|
|
121
|
+
export declare const complement: <Key extends Disjoint<keyof Key, keyof KeyCache<T>>, Id>(set: BspSet<Key, Id>) => BspSet<Key, Id>;
|
|
122
122
|
export declare function getNodeCount<Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>): number;
|
|
123
123
|
export declare function forEachKey<Key extends Cachable<Key>, Id>(set: Empty | Sparse<Key, Id>, f: (key: Key) => boolean): boolean;
|
|
124
124
|
export {};
|
package/lib/handlecache.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { IVectorConsumer } from "@tiny-calc/nano";
|
|
|
6
6
|
import { Handle } from "./handletable";
|
|
7
7
|
import { PermutationVector } from "./permutationvector";
|
|
8
8
|
/**
|
|
9
|
-
* Used by PermutationVector to cache position
|
|
9
|
+
* Used by PermutationVector to cache position -\> handle lookups.
|
|
10
10
|
*
|
|
11
11
|
* Perf: Possibly, this should eventually be inlined into PermutationVector itself, but
|
|
12
12
|
* so far there's no measurable perf penalty for being a separate object (node 12 x64)
|
package/lib/handlecache.js
CHANGED
|
@@ -7,7 +7,7 @@ import { assert } from "@fluidframework/common-utils";
|
|
|
7
7
|
import { isHandleValid } from "./handletable";
|
|
8
8
|
import { ensureRange } from "./range";
|
|
9
9
|
/**
|
|
10
|
-
* Used by PermutationVector to cache position
|
|
10
|
+
* Used by PermutationVector to cache position -\> handle lookups.
|
|
11
11
|
*
|
|
12
12
|
* Perf: Possibly, this should eventually be inlined into PermutationVector itself, but
|
|
13
13
|
* so far there's no measurable perf penalty for being a separate object (node 12 x64)
|
package/lib/handlecache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAU,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAIpB,YAA4B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAH7C,YAAO,GAAa,EAAE,CAAC;QACvB,UAAK,GAAG,CAAC,CAAC;IAEuC,CAAC;IAE1D;;;OAGG;IACK,QAAQ,CAAC,QAAgB;QAC7B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;;OAOG;IACI,SAAS,CAAC,QAAgB;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEtC,uFAAuF;QACvF,8BAA8B;QAE9B,oFAAoF;QACpF,qFAAqF;QACrF,uEAAuE;QAEvE,OAAO,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;YAC9B,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,8EAA8E;IACvE,SAAS,CAA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E,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3E,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;YACvB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SAC1B;aAAM;YACH,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;YAEhD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC;YACrG,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAChD;IACL,CAAC;IAED,0BAA0B;IAE1B,YAAY,CAAC,KAAa,EAAE,YAAoB,EAAE,aAAqB;QACnE,8EAA8E;QAC9E,6EAA6E;QAC7E,aAAa;QACb,EAAE;QACF,4EAA4E;QAC5E,wBAAwB;QACxB,EAAE;QACF,6FAA6F;QAC7F,2EAA2E;QAC3E,EAAE;QACF,gFAAgF;QAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SAC/B;IACL,CAAC;CAGJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationVector, PermutationSegment } from \"./permutationvector\";\nimport { ensureRange } from \"./range\";\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C,CAAC;YAEhD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC;YACrG,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAChD;IACL,CAAC;IAED,0BAA0B;IAE1B,YAAY,CAAC,KAAa,EAAE,YAAoB,EAAE,aAAqB;QACnE,8EAA8E;QAC9E,6EAA6E;QAC7E,aAAa;QACb,EAAE;QACF,4EAA4E;QAC5E,wBAAwB;QACxB,EAAE;QACF,6FAA6F;QAC7F,2EAA2E;QAC3E,EAAE;QACF,gFAAgF;QAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SAC/B;IACL,CAAC;CAGJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationVector, PermutationSegment } from \"./permutationvector\";\nimport { ensureRange } from \"./range\";\n\n/**\n * Used by PermutationVector to cache position -\\> handle lookups.\n *\n * Perf: Possibly, this should eventually be inlined into PermutationVector itself, but\n * so far there's no measurable perf penalty for being a separate object (node 12 x64)\n */\nexport class HandleCache implements IVectorConsumer<Handle> {\n private handles: Handle[] = [];\n private start = 0;\n\n constructor(public readonly vector: PermutationVector) { }\n\n /**\n * Returns the index of the given position in the 'handles' array as a Uint32.\n * (If the position is not in the array, returns an integer greater than 'handles.length').\n */\n private getIndex(position: number) {\n return (position - this.start) >>> 0;\n }\n\n /**\n * Returns the handle currently assigned to the given 'position' (if any). Check\n * the result with 'isValidHandle(..)' to see if a handle has been allocated for\n * the given position.\n *\n * Throws a 'RangeError' if the provided 'position' is out-of-bounds wrt. the\n * PermutationVector's length.\n */\n public getHandle(position: number) {\n const index = this.getIndex(position);\n\n // Perf: To encourage inlining, handling of the 'cacheMiss(..)' case has been extracted\n // to a separate method.\n\n // Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer\n // checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an\n // ~40% speedup when the position is in the cache (node v12 x64).\n\n return index < this.handles.length\n ? this.handles[index]\n : this.cacheMiss(position);\n }\n\n /** Update the cache when a handle has been allocated for a given position. */\n public addHandle(position: number, handle: Handle) {\n assert(isHandleValid(handle), 0x017 /* \"Trying to add invalid handle!\" */);\n\n const index = this.getIndex(position);\n if (index < this.handles.length) {\n assert(!isHandleValid(this.handles[index]),\n 0x018 /* \"Trying to insert handle into position with already valid handle!\" */);\n this.handles[index] = handle;\n }\n }\n\n /** Used by 'CacheMiss()' to retrieve handles for a range of positions. */\n private getHandles(start: number, end: number) {\n // TODO: This can be accelerated substantially using 'walkSegments()'. The only catch\n // is that\n\n const handles: Handle[] = [];\n const { vector } = this;\n\n for (let pos = start; pos < end; pos++) {\n const { segment, offset } = vector.getContainingSegment(pos);\n const asPerm = segment as PermutationSegment;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n handles.push(asPerm.start + offset!);\n }\n\n return handles;\n }\n\n private cacheMiss(position: number) {\n // Coercing 'position' to an Uint32 allows us to handle a negative 'position' value\n // with the same logic that handles 'position' >= length.\n const _position = position >>> 0;\n\n // TODO: To bound memory usage, there should be a limit on the maximum size of\n // handle[].\n\n // TODO: To reduce MergeTree lookups, this code should opportunistically grow\n // the cache to the next MergeTree segment boundary (within the limits of\n // the handle cache).\n\n if (_position < this.start) {\n this.handles = this.getHandles(_position, this.start).concat(this.handles);\n this.start = _position;\n return this.handles[0];\n } else {\n ensureRange(_position, this.vector.getLength());\n\n this.handles = this.handles.concat(this.getHandles(this.start + this.handles.length, _position + 1));\n return this.handles[this.handles.length - 1];\n }\n }\n\n // #region IVectorConsumer\n\n itemsChanged(start: number, removedCount: number, insertedCount: number): void {\n // If positions were inserted/removed, our current policy is to trim the array\n // at the beginning of the invalidate range and lazily repopulate the handles\n // on demand.\n //\n // Some alternatives to consider that preserve the previously cached handles\n // that are still valid:\n //\n // * Eagerly populate the 'handles[]' with the newly insert values (currently guaranteed\n // to be Handle.unallocated, so we don't even need to look them up.)\n //\n // * Use a sentinel value or other mechanism to allow \"holes\" in the cache.\n\n const index = this.getIndex(start);\n if (index < this.handles.length) {\n this.handles.length = index;\n }\n }\n\n // #endregion IVectorConsumer\n}\n"]}
|
package/lib/handletable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handletable.js","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,iBAAgB,CAAC;AAExE;;GAEG;AACH,MAAM,OAAO,WAAW;IACpB,4FAA4F;IAC5F,2FAA2F;IAC3F,sFAAsF;IACtF,YAAoC,UAA0B,CAAC,CAAC,CAAC;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAI,CAAC;IAE/D,KAAK;QACR,qFAAqF;QACrF,uFAAuF;QACvF,oBAAoB;QACpB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACI,QAAQ;;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"handletable.js","sourceRoot":"","s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AC,MAAc;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,MAAc,EAAE,KAAQ;QAC/B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IACjC,CAAC;IAED,wFAAwF;IACxF,uBAAuB;IACvB,IAAY,IAAI,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAW,CAAC,CAAC,CAAC;IACxD,IAAY,IAAI,CAAC,MAAc,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAEvD,iBAAiB;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAoB;QACtC,OAAO,IAAI,WAAW,CAAI,IAAI,CAAC,CAAC;IACpC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const enum Handle {\n /** Minimum valid handle. */\n valid = 1,\n\n /** Sentinel representing an unallocated Handle. */\n unallocated = -0x80000000,\n}\n\nexport const isHandleValid = (handle: Handle) => handle >= Handle.valid;\n\n/**\n * A handle table provides a fast mapping from an integer `handle` to a value `T`.\n */\nexport class HandleTable<T> {\n // Note: the first slot of the 'handles' array is reserved to store the pointer to the first\n // free handle. We initialize this slot with a pointer to slot '1', which will cause\n // us to delay allocate the following slot in the array on the first allocation.\n public constructor(private readonly handles: (Handle | T)[] = [1]) { }\n\n public clear() {\n // Restore the HandleTable's initial state by deleting all items in the handles array\n // and then re-inserting the value '1' in the 0th slot. (See comment at `handles` decl\n // for explanation.)\n this.handles.splice(0, this.handles.length, 1);\n }\n\n /**\n * Allocates and returns the next available handle. Note that freed handles are recycled.\n */\n public allocate(): Handle {\n const free = this.next;\n this.next = (this.handles[free] as Handle) ?? (free + 1);\n this.handles[free] = 0;\n return free;\n }\n\n /**\n * Allocates and returns the next available `count` handles.\n */\n public allocateMany(count: Handle) {\n const handles = new Uint32Array(count);\n for (let i = 0; i < count; i++) {\n handles[i] = this.allocate();\n }\n return handles;\n }\n\n /**\n * Returns the given handle to the free list.\n */\n public free(handle: Handle) {\n this.handles[handle] = this.next;\n this.next = handle;\n }\n\n /**\n * Get the value `T` associated with the given handle, if any.\n */\n public get(handle: Handle): T {\n return this.handles[handle] as T;\n }\n\n /**\n * Set the value `T` associated with the given handle.\n */\n public set(handle: Handle, value: T) {\n this.handles[handle] = value;\n }\n\n // Private helpers to get/set the head of the free list, which is stored in the 0th slot\n // of the handle array.\n private get next() { return this.handles[0] as Handle; }\n private set next(handle: Handle) { this.handles[0] = handle; }\n\n public getSummaryContent() {\n return this.handles;\n }\n\n public static load<T>(data: (Handle | T)[]) {\n return new HandleTable<T>(data);\n }\n}\n"]}
|
package/lib/matrix.d.ts
CHANGED
|
@@ -103,6 +103,9 @@ export declare class SharedMatrix<T = any> extends SharedObject implements IMatr
|
|
|
103
103
|
*/
|
|
104
104
|
private isLatestPendingWrite;
|
|
105
105
|
toString(): string;
|
|
106
|
-
|
|
106
|
+
/**
|
|
107
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
108
|
+
*/
|
|
109
|
+
protected applyStashedOp(content: any): unknown;
|
|
107
110
|
}
|
|
108
111
|
//# sourceMappingURL=matrix.d.ts.map
|
package/lib/matrix.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,gBAAgB,EAGhB,YAAY,EACZ,iBAAiB,E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nB,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAyC7D,SAAS,CAAC,YAAY;IAEtB;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB;IAmBxD,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;IA6DrG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAIzB;IAGF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAIzB;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAKnC;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAKnC;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAgBrB,QAAQ;IAkBf;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;CAgDlD"}
|
package/lib/matrix.js
CHANGED
|
@@ -373,10 +373,10 @@ export class SharedMatrix extends SharedObject {
|
|
|
373
373
|
const contents = msg.contents;
|
|
374
374
|
switch (contents.target) {
|
|
375
375
|
case "cols" /* cols */:
|
|
376
|
-
this.cols.applyMsg(msg);
|
|
376
|
+
this.cols.applyMsg(msg, local);
|
|
377
377
|
break;
|
|
378
378
|
case "rows" /* rows */:
|
|
379
|
-
this.rows.applyMsg(msg);
|
|
379
|
+
this.rows.applyMsg(msg, local);
|
|
380
380
|
break;
|
|
381
381
|
default: {
|
|
382
382
|
assert(contents.type === MatrixOp.set, 0x021 /* "SharedMatrix message contents have unexpected type!" */);
|
|
@@ -451,8 +451,43 @@ export class SharedMatrix extends SharedObject {
|
|
|
451
451
|
}
|
|
452
452
|
return `${s}\n`;
|
|
453
453
|
}
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
/**
|
|
455
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
456
|
+
*/
|
|
457
|
+
applyStashedOp(content) {
|
|
458
|
+
if (content.target === "cols" /* cols */ || content.target === "rows" /* rows */) {
|
|
459
|
+
const op = content;
|
|
460
|
+
const currentVector = content.target === "cols" /* cols */ ? this.cols : this.rows;
|
|
461
|
+
const oppositeVector = content.target === "cols" /* cols */ ? this.rows : this.cols;
|
|
462
|
+
const metadata = currentVector.applyStashedOp(op);
|
|
463
|
+
const localSeq = currentVector.getCollabWindow().localSeq;
|
|
464
|
+
const oppositeWindow = oppositeVector.getCollabWindow();
|
|
465
|
+
assert(localSeq > oppositeWindow.localSeq, 0x2d9);
|
|
466
|
+
oppositeWindow.localSeq = localSeq;
|
|
467
|
+
return metadata;
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
assert(content.type === MatrixOp.set, 0x2da /* "Unknown SharedMatrix 'op' type." */);
|
|
471
|
+
const setOp = content;
|
|
472
|
+
const rowHandle = this.rows.getAllocatedHandle(setOp.row);
|
|
473
|
+
const colHandle = this.cols.getAllocatedHandle(setOp.col);
|
|
474
|
+
if (this.undo !== undefined) {
|
|
475
|
+
let oldValue = this.cells.getCell(rowHandle, colHandle);
|
|
476
|
+
if (oldValue === null) {
|
|
477
|
+
oldValue = undefined;
|
|
478
|
+
}
|
|
479
|
+
this.undo.cellSet(rowHandle, colHandle, oldValue);
|
|
480
|
+
}
|
|
481
|
+
this.cells.setCell(rowHandle, colHandle, setOp.value);
|
|
482
|
+
const localSeq = this.nextLocalSeq();
|
|
483
|
+
const metadata = {
|
|
484
|
+
rowHandle,
|
|
485
|
+
colHandle,
|
|
486
|
+
localSeq,
|
|
487
|
+
};
|
|
488
|
+
this.pending.setCell(rowHandle, colHandle, localSeq);
|
|
489
|
+
return metadata;
|
|
490
|
+
}
|
|
456
491
|
}
|
|
457
492
|
}
|
|
458
493
|
//# sourceMappingURL=matrix.js.map
|