@fluidframework/matrix 2.0.0-rc.2.0.2 → 2.0.0-rc.3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/api-report/matrix.api.md +6 -6
- package/dist/handlecache.d.ts.map +1 -1
- package/dist/handlecache.js +3 -3
- package/dist/handlecache.js.map +1 -1
- package/dist/legacy.d.ts +20 -0
- package/dist/matrix.d.ts +7 -6
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +45 -45
- package/dist/matrix.js.map +1 -1
- package/dist/ops.d.ts +2 -2
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/permutationvector.d.ts +10 -9
- package/dist/permutationvector.d.ts.map +1 -1
- package/dist/permutationvector.js +19 -19
- package/dist/permutationvector.js.map +1 -1
- package/dist/public.d.ts +12 -0
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/serialization.d.ts +3 -2
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +2 -2
- package/dist/serialization.js.map +1 -1
- package/dist/undoprovider.d.ts +2 -2
- package/dist/undoprovider.d.ts.map +1 -1
- package/dist/undoprovider.js +12 -12
- package/dist/undoprovider.js.map +1 -1
- package/internal.d.ts +11 -0
- package/legacy.d.ts +11 -0
- package/lib/handlecache.d.ts.map +1 -1
- package/lib/handlecache.js +1 -1
- package/lib/handlecache.js.map +1 -1
- package/lib/legacy.d.ts +20 -0
- package/lib/matrix.d.ts +7 -6
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +9 -9
- package/lib/matrix.js.map +1 -1
- package/lib/ops.d.ts +2 -2
- package/lib/ops.d.ts.map +1 -1
- package/lib/ops.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/permutationvector.d.ts +10 -9
- package/lib/permutationvector.d.ts.map +1 -1
- package/lib/permutationvector.js +6 -7
- package/lib/permutationvector.js.map +1 -1
- package/lib/public.d.ts +12 -0
- package/lib/runtime.d.ts +5 -5
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/serialization.d.ts +3 -2
- package/lib/serialization.d.ts.map +1 -1
- package/lib/serialization.js +1 -1
- package/lib/serialization.js.map +1 -1
- package/lib/undoprovider.d.ts +2 -2
- package/lib/undoprovider.d.ts.map +1 -1
- package/lib/undoprovider.js +2 -2
- package/lib/undoprovider.js.map +1 -1
- package/package.json +39 -60
- package/src/handlecache.ts +3 -2
- package/src/matrix.ts +28 -30
- package/src/ops.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/permutationvector.ts +16 -16
- package/src/runtime.ts +8 -7
- package/src/serialization.ts +4 -3
- package/src/undoprovider.ts +10 -9
- package/api-extractor-cjs.json +0 -8
- package/dist/matrix-alpha.d.ts +0 -235
- package/dist/matrix-beta.d.ts +0 -42
- package/dist/matrix-public.d.ts +0 -42
- package/dist/matrix-untrimmed.d.ts +0 -235
- package/lib/matrix-alpha.d.ts +0 -235
- package/lib/matrix-beta.d.ts +0 -42
- package/lib/matrix-public.d.ts +0 -42
- package/lib/matrix-untrimmed.d.ts +0 -235
- package/lib/test/dirname.cjs +0 -16
- package/lib/test/dirname.cjs.map +0 -1
- package/lib/test/matrix.applyStashedOp.spec.js +0 -91
- package/lib/test/matrix.applyStashedOp.spec.js.map +0 -1
- package/lib/test/matrix.big.spec.js +0 -148
- package/lib/test/matrix.big.spec.js.map +0 -1
- package/lib/test/matrix.fuzz.spec.js +0 -188
- package/lib/test/matrix.fuzz.spec.js.map +0 -1
- package/lib/test/matrix.reconnect.spec.js +0 -192
- package/lib/test/matrix.reconnect.spec.js.map +0 -1
- package/lib/test/matrix.spec.js +0 -1234
- package/lib/test/matrix.spec.js.map +0 -1
- package/lib/test/matrix.stress.spec.js +0 -461
- package/lib/test/matrix.stress.spec.js.map +0 -1
- package/lib/test/matrix.undo.spec.js +0 -601
- package/lib/test/matrix.undo.spec.js.map +0 -1
- package/lib/test/memory/matrix.spec.js +0 -122
- package/lib/test/memory/matrix.spec.js.map +0 -1
- package/lib/test/sparsearray2d.spec.js +0 -142
- package/lib/test/sparsearray2d.spec.js.map +0 -1
- package/lib/test/testconsumer.js +0 -76
- package/lib/test/testconsumer.js.map +0 -1
- package/lib/test/types/validateMatrixPrevious.generated.js +0 -14
- package/lib/test/types/validateMatrixPrevious.generated.js.map +0 -1
- package/lib/test/undoRedoStackManager.js +0 -176
- package/lib/test/undoRedoStackManager.js.map +0 -1
- package/lib/test/utils.js +0 -132
- package/lib/test/utils.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @fluidframework/matrix
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Packages now use package.json "exports" and require modern module resolution [97d68aa06b](https://github.com/microsoft/FluidFramework/commit/97d68aa06bd5c022ecb026655814aea222a062ae)
|
|
8
|
+
|
|
9
|
+
Fluid Framework packages have been updated to use the [package.json "exports"
|
|
10
|
+
field](https://nodejs.org/docs/latest-v18.x/api/packages.html#exports) to define explicit entry points for both
|
|
11
|
+
TypeScript types and implementation code.
|
|
12
|
+
|
|
13
|
+
This means that using Fluid Framework packages require the following TypeScript settings in tsconfig.json:
|
|
14
|
+
|
|
15
|
+
- `"moduleResolution": "Node16"` with `"module": "Node16"`
|
|
16
|
+
- `"moduleResolution": "Bundler"` with `"module": "ESNext"`
|
|
17
|
+
|
|
18
|
+
We recommend using Node16/Node16 unless absolutely necessary. That will produce transpiled JavaScript that is suitable
|
|
19
|
+
for use with modern versions of Node.js _and_ Bundlers.
|
|
20
|
+
[See the TypeScript documentation](https://www.typescriptlang.org/tsconfig#moduleResolution) for more information
|
|
21
|
+
regarding the module and moduleResolution options.
|
|
22
|
+
|
|
23
|
+
**Node10 moduleResolution is not supported; it does not support Fluid Framework's API structuring pattern that is used
|
|
24
|
+
to distinguish stable APIs from those that are in development.**
|
|
25
|
+
|
|
3
26
|
## 2.0.0-rc.2.0.0
|
|
4
27
|
|
|
5
28
|
Dependency updates only.
|
package/api-report/matrix.api.md
CHANGED
|
@@ -14,7 +14,7 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
|
14
14
|
import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
|
|
15
15
|
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
16
16
|
import { IFluidSerializer } from '@fluidframework/shared-object-base';
|
|
17
|
-
import { IJSONSegment } from '@fluidframework/merge-tree';
|
|
17
|
+
import { IJSONSegment } from '@fluidframework/merge-tree/internal';
|
|
18
18
|
import { IMatrixConsumer } from '@tiny-calc/nano';
|
|
19
19
|
import { IMatrixProducer } from '@tiny-calc/nano';
|
|
20
20
|
import { IMatrixReader } from '@tiny-calc/nano';
|
|
@@ -22,8 +22,8 @@ import { IMatrixWriter } from '@tiny-calc/nano';
|
|
|
22
22
|
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
23
23
|
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
24
24
|
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
25
|
-
import { Serializable } from '@fluidframework/datastore-definitions';
|
|
26
|
-
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
25
|
+
import { Serializable } from '@fluidframework/datastore-definitions/internal';
|
|
26
|
+
import { SharedObject } from '@fluidframework/shared-object-base/internal';
|
|
27
27
|
|
|
28
28
|
// @alpha (undocumented)
|
|
29
29
|
export interface IRevertible {
|
|
@@ -123,14 +123,14 @@ export class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T> &
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// @alpha
|
|
126
|
-
export class SharedMatrixFactory implements IChannelFactory {
|
|
126
|
+
export class SharedMatrixFactory implements IChannelFactory<ISharedMatrix> {
|
|
127
127
|
// (undocumented)
|
|
128
128
|
static readonly Attributes: IChannelAttributes;
|
|
129
129
|
// (undocumented)
|
|
130
130
|
get attributes(): IChannelAttributes;
|
|
131
131
|
// (undocumented)
|
|
132
|
-
create(document: IFluidDataStoreRuntime, id: string):
|
|
133
|
-
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IChannel>;
|
|
132
|
+
create(document: IFluidDataStoreRuntime, id: string): ISharedMatrix & IChannel;
|
|
133
|
+
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<ISharedMatrix & IChannel>;
|
|
134
134
|
// (undocumented)
|
|
135
135
|
static Type: string;
|
|
136
136
|
// (undocumented)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlecache.d.ts","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"handlecache.d.ts","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAiB,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAsB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG/E;;;;;GAKG;AACH,qBAAa,WAAY,YAAW,eAAe,CAAC,MAAM,CAAC;aAI9B,MAAM,EAAE,iBAAiB;IAHrD,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,KAAK,CAAK;gBAEU,MAAM,EAAE,iBAAiB;IAErD;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;;;OAOG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM;IAajC,8EAA8E;IACvE,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAajD,0EAA0E;IAC1E,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,SAAS;IA4BjB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;CAoB9E"}
|
package/dist/handlecache.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.HandleCache = void 0;
|
|
8
8
|
/* eslint-disable no-bitwise */
|
|
9
|
-
const
|
|
9
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
10
10
|
const handletable_js_1 = require("./handletable.js");
|
|
11
11
|
const range_js_1 = require("./range.js");
|
|
12
12
|
/**
|
|
@@ -47,10 +47,10 @@ class HandleCache {
|
|
|
47
47
|
}
|
|
48
48
|
/** Update the cache when a handle has been allocated for a given position. */
|
|
49
49
|
addHandle(position, handle) {
|
|
50
|
-
(0,
|
|
50
|
+
(0, internal_1.assert)((0, handletable_js_1.isHandleValid)(handle), 0x017 /* "Trying to add invalid handle!" */);
|
|
51
51
|
const index = this.getIndex(position);
|
|
52
52
|
if (index < this.handles.length) {
|
|
53
|
-
(0,
|
|
53
|
+
(0, internal_1.assert)(!(0, handletable_js_1.isHandleValid)(this.handles[index]), 0x018 /* "Trying to insert handle into position with already valid handle!" */);
|
|
54
54
|
this.handles[index] = handle;
|
|
55
55
|
}
|
|
56
56
|
}
|
package/dist/handlecache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":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AO,CAAC,MAAM,CACjC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC,CAAC,CAChE,CAAC;YACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAC7C;IACF,CAAC;IAED,0BAA0B;IAE1B,YAAY,CAAC,KAAa,EAAE,YAAoB,EAAE,aAAqB;QACtE,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;YAChC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SAC5B;IACF,CAAC;CAGD;AAnHD,kCAmHC","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/core-utils/internal\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\n\nimport { Handle, isHandleValid } from \"./handletable.js\";\nimport { PermutationSegment, PermutationVector } from \"./permutationvector.js\";\nimport { ensureRange } from \"./range.js\";\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\tprivate handles: Handle[] = [];\n\tprivate start = 0;\n\n\tconstructor(public readonly vector: PermutationVector) {}\n\n\t/**\n\t * Returns the index of the given position in the 'handles' array as a Uint32.\n\t * (If the position is not in the array, returns an integer greater than 'handles.length').\n\t */\n\tprivate getIndex(position: number) {\n\t\treturn (position - this.start) >>> 0;\n\t}\n\n\t/**\n\t * Returns the handle currently assigned to the given 'position' (if any). Check\n\t * the result with 'isValidHandle(..)' to see if a handle has been allocated for\n\t * the given position.\n\t *\n\t * Throws a 'RangeError' if the provided 'position' is out-of-bounds wrt. the\n\t * PermutationVector's length.\n\t */\n\tpublic getHandle(position: number) {\n\t\tconst index = this.getIndex(position);\n\n\t\t// Perf: To encourage inlining, handling of the 'cacheMiss(..)' case has been extracted\n\t\t// to a separate method.\n\n\t\t// Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer\n\t\t// checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an\n\t\t// ~40% speedup when the position is in the cache (node v12 x64).\n\n\t\treturn index < this.handles.length ? this.handles[index] : this.cacheMiss(position);\n\t}\n\n\t/** Update the cache when a handle has been allocated for a given position. */\n\tpublic addHandle(position: number, handle: Handle) {\n\t\tassert(isHandleValid(handle), 0x017 /* \"Trying to add invalid handle!\" */);\n\n\t\tconst index = this.getIndex(position);\n\t\tif (index < this.handles.length) {\n\t\t\tassert(\n\t\t\t\t!isHandleValid(this.handles[index]),\n\t\t\t\t0x018 /* \"Trying to insert handle into position with already valid handle!\" */,\n\t\t\t);\n\t\t\tthis.handles[index] = handle;\n\t\t}\n\t}\n\n\t/** Used by 'CacheMiss()' to retrieve handles for a range of positions. */\n\tprivate getHandles(start: number, end: number) {\n\t\t// TODO: This can be accelerated substantially using 'walkSegments()'. The only catch\n\t\t// is that\n\n\t\tconst handles: Handle[] = [];\n\t\tconst { vector } = this;\n\n\t\tfor (let pos = start; pos < end; pos++) {\n\t\t\tconst { segment, offset } = vector.getContainingSegment(pos);\n\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\thandles.push(asPerm.start + offset!);\n\t\t}\n\n\t\treturn handles;\n\t}\n\n\tprivate cacheMiss(position: number) {\n\t\t// Coercing 'position' to an Uint32 allows us to handle a negative 'position' value\n\t\t// with the same logic that handles 'position' >= length.\n\t\tconst _position = position >>> 0;\n\n\t\t// TODO: To bound memory usage, there should be a limit on the maximum size of\n\t\t// handle[].\n\n\t\t// TODO: To reduce MergeTree lookups, this code should opportunistically grow\n\t\t// the cache to the next MergeTree segment boundary (within the limits of\n\t\t// the handle cache).\n\n\t\tif (_position < this.start) {\n\t\t\tthis.handles = this.getHandles(_position, this.start).concat(this.handles);\n\t\t\tthis.start = _position;\n\t\t\treturn this.handles[0];\n\t\t} else {\n\t\t\tensureRange(_position, this.vector.getLength());\n\n\t\t\tthis.handles = this.handles.concat(\n\t\t\t\tthis.getHandles(this.start + this.handles.length, _position + 1),\n\t\t\t);\n\t\t\treturn this.handles[this.handles.length - 1];\n\t\t}\n\t}\n\n\t// #region IVectorConsumer\n\n\titemsChanged(start: number, removedCount: number, insertedCount: number): void {\n\t\t// If positions were inserted/removed, our current policy is to trim the array\n\t\t// at the beginning of the invalidate range and lazily repopulate the handles\n\t\t// on demand.\n\t\t//\n\t\t// Some alternatives to consider that preserve the previously cached handles\n\t\t// that are still valid:\n\t\t//\n\t\t// * Eagerly populate the 'handles[]' with the newly insert values (currently guaranteed\n\t\t// to be Handle.unallocated, so we don't even need to look them up.)\n\t\t//\n\t\t// * Use a sentinel value or other mechanism to allow \"holes\" in the cache.\n\n\t\tconst index = this.getIndex(start);\n\t\tif (index < this.handles.length) {\n\t\t\tthis.handles.length = index;\n\t\t}\n\t}\n\n\t// #endregion IVectorConsumer\n}\n"]}
|
package/dist/legacy.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluidframework/build-tools.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
// alpha APIs
|
|
13
|
+
IRevertible,
|
|
14
|
+
ISharedMatrix,
|
|
15
|
+
ISharedMatrixEvents,
|
|
16
|
+
IUndoConsumer,
|
|
17
|
+
MatrixItem,
|
|
18
|
+
SharedMatrix,
|
|
19
|
+
SharedMatrixFactory
|
|
20
|
+
} from "./index.js";
|
package/dist/matrix.d.ts
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { IEvent, IEventProvider, IEventThisPlaceHolder } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { IChannelAttributes, IChannelStorageService, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
|
|
7
|
+
import { IJSONSegment } from "@fluidframework/merge-tree/internal";
|
|
6
8
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
|
-
import { IFluidDataStoreRuntime, IChannelStorageService, IChannelAttributes } from "@fluidframework/datastore-definitions";
|
|
8
|
-
import { IFluidSerializer, ISharedObjectEvents, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
9
|
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { IFluidSerializer, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
11
|
+
import { SharedObject } from "@fluidframework/shared-object-base/internal";
|
|
12
|
+
import { IMatrixConsumer, IMatrixProducer, IMatrixReader, IMatrixWriter } from "@tiny-calc/nano";
|
|
13
|
+
import { MatrixItem } from "./ops.js";
|
|
12
14
|
import { SharedMatrixFactory } from "./runtime.js";
|
|
13
15
|
import { IUndoConsumer } from "./types.js";
|
|
14
|
-
import { MatrixItem } from "./ops.js";
|
|
15
16
|
/**
|
|
16
17
|
* Events emitted by Shared Matrix.
|
|
17
18
|
* @alpha
|
package/dist/matrix.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAEhG,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAGN,YAAY,EAMZ,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIjG,OAAO,EAEN,UAAU,EAKV,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAY3C;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,CAAE,SAAQ,MAAM;IACrD;;;;;;;;;;;;;;;;;;OAkBG;IACH,CACC,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,CACT,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,EAC3B,gBAAg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B;IAGF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAQzB;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAMnC;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAMnC;IAEF;;;OAGG;IACI,mBAAmB;IAU1B;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAiBrB,QAAQ;IAoBf;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;CAiBjD"}
|
package/dist/matrix.js
CHANGED
|
@@ -8,20 +8,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.SharedMatrix = void 0;
|
|
11
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
12
|
+
const internal_2 = require("@fluidframework/merge-tree/internal");
|
|
13
|
+
const internal_3 = require("@fluidframework/runtime-utils/internal");
|
|
14
|
+
const internal_4 = require("@fluidframework/shared-object-base/internal");
|
|
15
|
+
const internal_5 = require("@fluidframework/telemetry-utils/internal");
|
|
11
16
|
const double_ended_queue_1 = __importDefault(require("double-ended-queue"));
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
15
|
-
const merge_tree_1 = require("@fluidframework/merge-tree");
|
|
16
|
-
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
17
|
+
const handletable_js_1 = require("./handletable.js");
|
|
18
|
+
const ops_js_1 = require("./ops.js");
|
|
17
19
|
const permutationvector_js_1 = require("./permutationvector.js");
|
|
18
|
-
const
|
|
20
|
+
const range_js_1 = require("./range.js");
|
|
19
21
|
const runtime_js_1 = require("./runtime.js");
|
|
20
|
-
const handletable_js_1 = require("./handletable.js");
|
|
21
22
|
const serialization_js_1 = require("./serialization.js");
|
|
22
|
-
const
|
|
23
|
+
const sparsearray2d_js_1 = require("./sparsearray2d.js");
|
|
23
24
|
const undoprovider_js_1 = require("./undoprovider.js");
|
|
24
|
-
const ops_js_1 = require("./ops.js");
|
|
25
25
|
/**
|
|
26
26
|
* A SharedMatrix holds a rectangular 2D array of values. Supported operations
|
|
27
27
|
* include setting values and inserting/removing rows and columns.
|
|
@@ -35,7 +35,7 @@ const ops_js_1 = require("./ops.js");
|
|
|
35
35
|
* for more details.)
|
|
36
36
|
* @alpha
|
|
37
37
|
*/
|
|
38
|
-
class SharedMatrix extends
|
|
38
|
+
class SharedMatrix extends internal_4.SharedObject {
|
|
39
39
|
static getFactory() {
|
|
40
40
|
return new runtime_js_1.SharedMatrixFactory();
|
|
41
41
|
}
|
|
@@ -103,7 +103,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
103
103
|
* Subscribes the given IUndoConsumer to the matrix.
|
|
104
104
|
*/
|
|
105
105
|
openUndo(consumer) {
|
|
106
|
-
(0,
|
|
106
|
+
(0, internal_1.assert)(this.undo === undefined, 0x019 /* "SharedMatrix.openUndo() supports at most a single IUndoConsumer." */);
|
|
107
107
|
this.undo = new undoprovider_js_1.MatrixUndoProvider(consumer, this, this.rows, this.cols);
|
|
108
108
|
}
|
|
109
109
|
// TODO: closeUndo()?
|
|
@@ -163,13 +163,13 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
163
163
|
// #endregion IMatrixReader
|
|
164
164
|
setCell(row, col, value) {
|
|
165
165
|
if (row < 0 || row >= this.rowCount || col < 0 || col >= this.colCount) {
|
|
166
|
-
throw new
|
|
166
|
+
throw new internal_5.UsageError("Trying to set out-of-bounds cell.");
|
|
167
167
|
}
|
|
168
168
|
this.setCellCore(row, col, value);
|
|
169
169
|
}
|
|
170
170
|
setCells(rowStart, colStart, colCount, values) {
|
|
171
171
|
const rowCount = Math.ceil(values.length / colCount);
|
|
172
|
-
(0,
|
|
172
|
+
(0, internal_1.assert)(0 <= rowStart &&
|
|
173
173
|
rowStart < this.rowCount &&
|
|
174
174
|
0 <= colStart &&
|
|
175
175
|
colStart < this.colCount &&
|
|
@@ -208,11 +208,11 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
208
208
|
}
|
|
209
209
|
createOpMetadataLocalRef(vector, pos, localSeq) {
|
|
210
210
|
const segoff = vector.getContainingSegment(pos, undefined, localSeq);
|
|
211
|
-
(0,
|
|
212
|
-
return vector.createLocalReferencePosition(segoff.segment, segoff.offset,
|
|
211
|
+
(0, internal_1.assert)(segoff.segment !== undefined && segoff.offset !== undefined, 0x8b3 /* expected valid position */);
|
|
212
|
+
return vector.createLocalReferencePosition(segoff.segment, segoff.offset, internal_2.ReferenceType.StayOnRemove, undefined);
|
|
213
213
|
}
|
|
214
214
|
sendSetCellOp(row, col, value, rowHandle, colHandle, localSeq = this.nextLocalSeq()) {
|
|
215
|
-
(0,
|
|
215
|
+
(0, internal_1.assert)(this.isAttached(), 0x1e2 /* "Caller must ensure 'isAttached()' before calling 'sendSetCellOp'." */);
|
|
216
216
|
const op = {
|
|
217
217
|
type: ops_js_1.MatrixOp.set,
|
|
218
218
|
row,
|
|
@@ -242,11 +242,11 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
242
242
|
* @param callback - code that needs to protected against reentrancy.
|
|
243
243
|
*/
|
|
244
244
|
protectAgainstReentrancy(callback) {
|
|
245
|
-
(0,
|
|
245
|
+
(0, internal_1.assert)(this.reentrantCount === 0, 0x85d /* reentrant code */);
|
|
246
246
|
this.reentrantCount++;
|
|
247
247
|
callback();
|
|
248
248
|
this.reentrantCount--;
|
|
249
|
-
(0,
|
|
249
|
+
(0, internal_1.assert)(this.reentrantCount === 0, 0x85e /* reentrant code on exit */);
|
|
250
250
|
}
|
|
251
251
|
submitVectorMessage(currentVector, oppositeVector, target, message) {
|
|
252
252
|
// Ideally, we would have a single 'localSeq' counter that is shared between both PermutationVectors
|
|
@@ -256,14 +256,14 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
256
256
|
const oppositeWindow = oppositeVector.getCollabWindow();
|
|
257
257
|
// Note that the comparison is '>=' because, in the case the MergeTree is regenerating ops for reconnection,
|
|
258
258
|
// the MergeTree submits the op with the original 'localSeq'.
|
|
259
|
-
(0,
|
|
259
|
+
(0, internal_1.assert)(localSeq >= oppositeWindow.localSeq, 0x01c /* "The 'localSeq' of the vector submitting an op must >= the 'localSeq' of the other vector." */);
|
|
260
260
|
oppositeWindow.localSeq = localSeq;
|
|
261
261
|
// If the SharedMatrix is local, it's state will be submitted via a Snapshot when initially connected.
|
|
262
262
|
// Do not queue a message or track the pending op, as there will never be an ACK, etc.
|
|
263
263
|
if (this.isAttached()) {
|
|
264
264
|
// Record whether this `op` targets rows or cols. (See dispatch in `processCore()`)
|
|
265
265
|
const targetedMessage = { ...message, target };
|
|
266
|
-
this.submitLocalMessage(targetedMessage, currentVector.peekPendingSegmentGroups(message.type ===
|
|
266
|
+
this.submitLocalMessage(targetedMessage, currentVector.peekPendingSegmentGroups(message.type === internal_2.MergeTreeDeltaType.GROUP ? message.ops.length : 1));
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
submitColMessage(message) {
|
|
@@ -274,11 +274,11 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
276
|
if (colStart > this.colCount) {
|
|
277
|
-
throw new
|
|
277
|
+
throw new internal_5.UsageError("insertCols: out of bounds");
|
|
278
278
|
}
|
|
279
279
|
this.protectAgainstReentrancy(() => {
|
|
280
280
|
const message = this.cols.insert(colStart, count);
|
|
281
|
-
(0,
|
|
281
|
+
(0, internal_1.assert)(message !== undefined, 0x8b4 /* must be defined */);
|
|
282
282
|
this.submitColMessage(message);
|
|
283
283
|
});
|
|
284
284
|
}
|
|
@@ -287,7 +287,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
289
|
if (colStart > this.colCount) {
|
|
290
|
-
throw new
|
|
290
|
+
throw new internal_5.UsageError("removeCols: out of bounds");
|
|
291
291
|
}
|
|
292
292
|
this.protectAgainstReentrancy(() => this.submitColMessage(this.cols.remove(colStart, count)));
|
|
293
293
|
}
|
|
@@ -299,11 +299,11 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
301
|
if (rowStart > this.rowCount) {
|
|
302
|
-
throw new
|
|
302
|
+
throw new internal_5.UsageError("insertRows: out of bounds");
|
|
303
303
|
}
|
|
304
304
|
this.protectAgainstReentrancy(() => {
|
|
305
305
|
const message = this.rows.insert(rowStart, count);
|
|
306
|
-
(0,
|
|
306
|
+
(0, internal_1.assert)(message !== undefined, 0x8b5 /* must be defined */);
|
|
307
307
|
this.submitRowMessage(message);
|
|
308
308
|
});
|
|
309
309
|
}
|
|
@@ -312,13 +312,13 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
314
|
if (rowStart > this.rowCount) {
|
|
315
|
-
throw new
|
|
315
|
+
throw new internal_5.UsageError("removeRows: out of bounds");
|
|
316
316
|
}
|
|
317
317
|
this.protectAgainstReentrancy(() => this.submitRowMessage(this.rows.remove(rowStart, count)));
|
|
318
318
|
}
|
|
319
319
|
_undoRemoveRows(rowStart, spec) {
|
|
320
320
|
const { op, inserted } = (0, permutationvector_js_1.reinsertSegmentIntoVector)(this.rows, rowStart, spec);
|
|
321
|
-
(0,
|
|
321
|
+
(0, internal_1.assert)(op !== undefined, 0x8b6 /* must be defined */);
|
|
322
322
|
this.submitRowMessage(op);
|
|
323
323
|
// Generate setCell ops for each populated cell in the reinserted rows.
|
|
324
324
|
let rowHandle = inserted.start;
|
|
@@ -339,7 +339,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
339
339
|
}
|
|
340
340
|
/***/ _undoRemoveCols(colStart, spec) {
|
|
341
341
|
const { op, inserted } = (0, permutationvector_js_1.reinsertSegmentIntoVector)(this.cols, colStart, spec);
|
|
342
|
-
(0,
|
|
342
|
+
(0, internal_1.assert)(op !== undefined, 0x8b7 /* must be defined */);
|
|
343
343
|
this.submitColMessage(op);
|
|
344
344
|
// Generate setCell ops for each populated cell in the reinserted cols.
|
|
345
345
|
let colHandle = inserted.start;
|
|
@@ -359,7 +359,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
summarizeCore(serializer) {
|
|
362
|
-
const builder = new
|
|
362
|
+
const builder = new internal_3.SummaryTreeBuilder();
|
|
363
363
|
builder.addWithStats(ops_js_1.SnapshotPath.rows, this.rows.summarize(this.runtime, this.handle, serializer));
|
|
364
364
|
builder.addWithStats(ops_js_1.SnapshotPath.cols, this.cols.summarize(this.runtime, this.handle, serializer));
|
|
365
365
|
const artifactsToSummarize = [
|
|
@@ -402,11 +402,11 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
402
402
|
submitLocalMessage(message, localOpMetadata) {
|
|
403
403
|
// TODO: Recommend moving this assertion into SharedObject
|
|
404
404
|
// (See https://github.com/microsoft/FluidFramework/issues/2559)
|
|
405
|
-
(0,
|
|
405
|
+
(0, internal_1.assert)(this.isAttached() === true, 0x01d /* "Trying to submit message to runtime while detached!" */);
|
|
406
406
|
this.inFlightRefSeqs.push(this.runtime.deltaManager.lastSequenceNumber);
|
|
407
407
|
super.submitLocalMessage(message, localOpMetadata);
|
|
408
408
|
// Ensure that row/col 'localSeq' are synchronized (see 'nextLocalSeq()').
|
|
409
|
-
(0,
|
|
409
|
+
(0, internal_1.assert)(this.rows.getCollabWindow().localSeq === this.cols.getCollabWindow().localSeq, 0x01e /* "Row and col collab window 'localSeq' desynchronized!" */);
|
|
410
410
|
}
|
|
411
411
|
didAttach() {
|
|
412
412
|
// We've attached we need to start generating and sending ops.
|
|
@@ -417,7 +417,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
onConnect() {
|
|
420
|
-
(0,
|
|
420
|
+
(0, internal_1.assert)(this.rows.getCollabWindow().collaborating === this.cols.getCollabWindow().collaborating, 0x01f /* "Row and col collab window 'collaborating' status desynchronized!" */);
|
|
421
421
|
// Update merge tree collaboration information with new client ID and then resend pending ops
|
|
422
422
|
this.rows.startOrUpdateCollaboration(this.runtime.clientId);
|
|
423
423
|
this.cols.startOrUpdateCollaboration(this.runtime.clientId);
|
|
@@ -431,13 +431,13 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
431
431
|
if (segment === undefined || offset === undefined || segment.removedSeq !== undefined) {
|
|
432
432
|
return;
|
|
433
433
|
}
|
|
434
|
-
(0,
|
|
434
|
+
(0, internal_1.assert)(segment.localRemovedSeq === undefined ||
|
|
435
435
|
(segment.localRemovedSeq !== undefined && segment.localRemovedSeq > localSeq), 0x8b8 /* Attempted to set a cell which was removed locally before the original op applied. */);
|
|
436
436
|
return client.findReconnectionPosition(segment, localSeq) + offset;
|
|
437
437
|
}
|
|
438
438
|
reSubmitCore(incoming, localOpMetadata) {
|
|
439
439
|
const originalRefSeq = this.inFlightRefSeqs.shift();
|
|
440
|
-
(0,
|
|
440
|
+
(0, internal_1.assert)(originalRefSeq !== undefined, 0x8b9 /* Expected a recorded refSeq when resubmitting an op */);
|
|
441
441
|
const content = incoming;
|
|
442
442
|
if (content.type === ops_js_1.MatrixOp.set && content.target === undefined) {
|
|
443
443
|
const setOp = content;
|
|
@@ -475,7 +475,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
475
475
|
this.submitRowMessage(this.rows.regeneratePendingOp(content, localOpMetadata));
|
|
476
476
|
break;
|
|
477
477
|
default: {
|
|
478
|
-
(0,
|
|
478
|
+
(0, internal_1.unreachableCase)(content);
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
}
|
|
@@ -486,8 +486,8 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
486
486
|
*/
|
|
487
487
|
async loadCore(storage) {
|
|
488
488
|
try {
|
|
489
|
-
await this.rows.load(this.runtime, new
|
|
490
|
-
await this.cols.load(this.runtime, new
|
|
489
|
+
await this.rows.load(this.runtime, new internal_3.ObjectStoragePartition(storage, ops_js_1.SnapshotPath.rows), this.serializer);
|
|
490
|
+
await this.cols.load(this.runtime, new internal_3.ObjectStoragePartition(storage, ops_js_1.SnapshotPath.cols), this.serializer);
|
|
491
491
|
const [cellData, _pendingCliSeqData, setCellLwwToFwwPolicySwitchOpSeqNumber, cellLastWriteTracker,] = await (0, serialization_js_1.deserializeBlob)(storage, ops_js_1.SnapshotPath.cells, this.serializer);
|
|
492
492
|
this.cells = sparsearray2d_js_1.SparseArray2D.load(cellData);
|
|
493
493
|
this.setCellLwwToFwwPolicySwitchOpSeqNumber =
|
|
@@ -505,8 +505,8 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
505
505
|
* we are in FWW mode.
|
|
506
506
|
*/
|
|
507
507
|
shouldSetCellBasedOnFWW(rowHandle, colHandle, message) {
|
|
508
|
-
(0,
|
|
509
|
-
(0,
|
|
508
|
+
(0, internal_1.assert)(this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1, 0x85f /* should be in Fww mode when calling this method */);
|
|
509
|
+
(0, internal_1.assert)(message.clientId !== null, 0x860 /* clientId should not be null */);
|
|
510
510
|
const lastCellModificationDetails = this.cellLastWriteTracker.getCell(rowHandle, colHandle);
|
|
511
511
|
// If someone tried to Overwrite the cell value or first write on this cell or
|
|
512
512
|
// same client tried to modify the cell.
|
|
@@ -517,7 +517,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
517
517
|
processCore(msg, local, localOpMetadata) {
|
|
518
518
|
if (local) {
|
|
519
519
|
const recordedRefSeq = this.inFlightRefSeqs.shift();
|
|
520
|
-
(0,
|
|
520
|
+
(0, internal_1.assert)(recordedRefSeq !== undefined, 0x8ba /* No pending recorded refSeq found */);
|
|
521
521
|
// TODO: AB#7076: Some equivalent assert should be enabled. This fails some e2e stashed op tests because
|
|
522
522
|
// the deltaManager may have seen more messages than the runtime has processed while amidst the stashed op
|
|
523
523
|
// flow, so e.g. when `applyStashedOp` is called and the DDS is put in a state where it expects an ack for
|
|
@@ -536,14 +536,14 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
536
536
|
this.rows.applyMsg(msg, local);
|
|
537
537
|
break;
|
|
538
538
|
case undefined: {
|
|
539
|
-
(0,
|
|
539
|
+
(0, internal_1.assert)(contents.type === ops_js_1.MatrixOp.set, 0x021 /* "SharedMatrix message contents have unexpected type!" */);
|
|
540
540
|
const { row, col, value, fwwMode } = contents;
|
|
541
541
|
const isPreviousSetCellPolicyModeFWW = this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1;
|
|
542
542
|
// If this is the first op notifying us of the policy change, then set the policy change seq number.
|
|
543
543
|
if (this.setCellLwwToFwwPolicySwitchOpSeqNumber === -1 && fwwMode === true) {
|
|
544
544
|
this.setCellLwwToFwwPolicySwitchOpSeqNumber = msg.sequenceNumber;
|
|
545
545
|
}
|
|
546
|
-
(0,
|
|
546
|
+
(0, internal_1.assert)(msg.clientId !== null, 0x861 /* clientId should not be null!! */);
|
|
547
547
|
if (local) {
|
|
548
548
|
// We are receiving the ACK for a local pending set operation.
|
|
549
549
|
const { rowHandle, colHandle, localSeq, rowsRef, colsRef } = localOpMetadata;
|
|
@@ -571,7 +571,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
571
571
|
if (adjustedCol !== undefined) {
|
|
572
572
|
const rowHandle = this.rows.getAllocatedHandle(adjustedRow);
|
|
573
573
|
const colHandle = this.cols.getAllocatedHandle(adjustedCol);
|
|
574
|
-
(0,
|
|
574
|
+
(0, internal_1.assert)((0, handletable_js_1.isHandleValid)(rowHandle) && (0, handletable_js_1.isHandleValid)(colHandle), 0x022 /* "SharedMatrix row and/or col handles are invalid!" */);
|
|
575
575
|
if (this.setCellLwwToFwwPolicySwitchOpSeqNumber > -1) {
|
|
576
576
|
// If someone tried to Overwrite the cell value or first write on this cell or
|
|
577
577
|
// same client tried to modify the cell or if the previous mode was LWW, then we need to still
|
|
@@ -615,7 +615,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
615
615
|
break;
|
|
616
616
|
}
|
|
617
617
|
default:
|
|
618
|
-
(0,
|
|
618
|
+
(0, internal_1.unreachableCase)(target, "unknown target");
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
621
|
/**
|
|
@@ -646,7 +646,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
646
646
|
// Note while we're awaiting the ACK for a local set, it's possible for the row/col to be
|
|
647
647
|
// locally removed and the row/col handles recycled. If this happens, the pendingLocalSeq will
|
|
648
648
|
// be 'undefined' or > 'localSeq'.
|
|
649
|
-
(0,
|
|
649
|
+
(0, internal_1.assert)(!(pendingLocalSeq < localSeq), 0x023 /* "The 'localSeq' of pending write (if any) must be <= the localSeq of the currently processed op." */);
|
|
650
650
|
// If this is the most recent write to the cell by the local client, the stored localSeq
|
|
651
651
|
// will be an exact match for the given 'localSeq'.
|
|
652
652
|
return pendingLocalSeq === localSeq;
|