@fluidframework/matrix 2.1.0-276985 → 2.1.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/.eslintrc.cjs +2 -5
- package/CHANGELOG.md +4 -0
- package/api-extractor/api-extractor.current.json +5 -0
- package/api-extractor/api-extractor.legacy.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/matrix.legacy.public.api.md +9 -0
- package/dist/handlecache.d.ts +7 -3
- package/dist/handlecache.d.ts.map +1 -1
- package/dist/handlecache.js +25 -7
- package/dist/handlecache.js.map +1 -1
- package/dist/handletable.d.ts +3 -1
- package/dist/handletable.d.ts.map +1 -1
- package/dist/handletable.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/matrix.d.ts +2 -1
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +23 -9
- package/dist/matrix.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/permutationvector.d.ts +5 -5
- package/dist/permutationvector.d.ts.map +1 -1
- package/dist/permutationvector.js +11 -4
- package/dist/permutationvector.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/range.d.ts.map +1 -1
- package/dist/range.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js.map +1 -1
- package/dist/sparsearray2d.d.ts +9 -5
- package/dist/sparsearray2d.d.ts.map +1 -1
- package/dist/sparsearray2d.js +27 -7
- package/dist/sparsearray2d.js.map +1 -1
- package/dist/undoprovider.d.ts.map +1 -1
- package/dist/undoprovider.js +10 -3
- package/dist/undoprovider.js.map +1 -1
- package/internal.d.ts +1 -1
- package/legacy.d.ts +1 -1
- package/lib/handlecache.d.ts +7 -3
- package/lib/handlecache.d.ts.map +1 -1
- package/lib/handlecache.js +25 -7
- package/lib/handlecache.js.map +1 -1
- package/lib/handletable.d.ts +3 -1
- package/lib/handletable.d.ts.map +1 -1
- package/lib/handletable.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/matrix.d.ts +2 -1
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +23 -9
- package/lib/matrix.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/permutationvector.d.ts +5 -5
- package/lib/permutationvector.d.ts.map +1 -1
- package/lib/permutationvector.js +11 -4
- package/lib/permutationvector.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/range.d.ts.map +1 -1
- package/lib/range.js.map +1 -1
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/serialization.d.ts.map +1 -1
- package/lib/serialization.js.map +1 -1
- package/lib/sparsearray2d.d.ts +9 -5
- package/lib/sparsearray2d.d.ts.map +1 -1
- package/lib/sparsearray2d.js +27 -7
- package/lib/sparsearray2d.js.map +1 -1
- package/lib/undoprovider.d.ts.map +1 -1
- package/lib/undoprovider.js +10 -3
- package/lib/undoprovider.js.map +1 -1
- package/package.json +36 -30
- package/src/handlecache.ts +31 -16
- package/src/handletable.ts +11 -9
- package/src/matrix.ts +80 -50
- package/src/packageVersion.ts +1 -1
- package/src/permutationvector.ts +38 -23
- package/src/range.ts +1 -1
- package/src/runtime.ts +5 -2
- package/src/serialization.ts +4 -2
- package/src/sparsearray2d.ts +55 -36
- package/src/undoprovider.ts +26 -18
- package/tsconfig.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/matrix",
|
|
3
|
-
"version": "2.1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Distributed matrix",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -63,35 +63,35 @@
|
|
|
63
63
|
"temp-directory": "nyc/.nyc_output"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@fluid-internal/client-utils": "2.1.0
|
|
67
|
-
"@fluidframework/core-interfaces": "2.1.0
|
|
68
|
-
"@fluidframework/core-utils": "2.1.0
|
|
69
|
-
"@fluidframework/datastore-definitions": "2.1.0
|
|
70
|
-
"@fluidframework/driver-definitions": "2.1.0
|
|
71
|
-
"@fluidframework/driver-utils": "2.1.0
|
|
72
|
-
"@fluidframework/merge-tree": "2.1.0
|
|
73
|
-
"@fluidframework/runtime-definitions": "2.1.0
|
|
74
|
-
"@fluidframework/runtime-utils": "2.1.0
|
|
75
|
-
"@fluidframework/shared-object-base": "2.1.0
|
|
76
|
-
"@fluidframework/telemetry-utils": "2.1.0
|
|
66
|
+
"@fluid-internal/client-utils": "~2.1.0",
|
|
67
|
+
"@fluidframework/core-interfaces": "~2.1.0",
|
|
68
|
+
"@fluidframework/core-utils": "~2.1.0",
|
|
69
|
+
"@fluidframework/datastore-definitions": "~2.1.0",
|
|
70
|
+
"@fluidframework/driver-definitions": "~2.1.0",
|
|
71
|
+
"@fluidframework/driver-utils": "~2.1.0",
|
|
72
|
+
"@fluidframework/merge-tree": "~2.1.0",
|
|
73
|
+
"@fluidframework/runtime-definitions": "~2.1.0",
|
|
74
|
+
"@fluidframework/runtime-utils": "~2.1.0",
|
|
75
|
+
"@fluidframework/shared-object-base": "~2.1.0",
|
|
76
|
+
"@fluidframework/telemetry-utils": "~2.1.0",
|
|
77
77
|
"@tiny-calc/nano": "0.0.0-alpha.5",
|
|
78
78
|
"double-ended-queue": "^2.1.0-0",
|
|
79
79
|
"tslib": "^1.10.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
83
|
-
"@biomejs/biome": "
|
|
84
|
-
"@fluid-internal/mocha-test-setup": "2.1.0
|
|
85
|
-
"@fluid-private/stochastic-test-utils": "2.1.0
|
|
86
|
-
"@fluid-private/test-dds-utils": "2.1.0
|
|
83
|
+
"@biomejs/biome": "~1.8.3",
|
|
84
|
+
"@fluid-internal/mocha-test-setup": "~2.1.0",
|
|
85
|
+
"@fluid-private/stochastic-test-utils": "~2.1.0",
|
|
86
|
+
"@fluid-private/test-dds-utils": "~2.1.0",
|
|
87
87
|
"@fluid-tools/benchmark": "^0.48.0",
|
|
88
|
-
"@fluid-tools/build-cli": "^0.
|
|
88
|
+
"@fluid-tools/build-cli": "^0.41.0",
|
|
89
89
|
"@fluidframework/build-common": "^2.0.3",
|
|
90
|
-
"@fluidframework/build-tools": "^0.
|
|
91
|
-
"@fluidframework/container-definitions": "2.1.0
|
|
90
|
+
"@fluidframework/build-tools": "^0.41.0",
|
|
91
|
+
"@fluidframework/container-definitions": "~2.1.0",
|
|
92
92
|
"@fluidframework/eslint-config-fluid": "^5.3.0",
|
|
93
|
-
"@fluidframework/matrix-previous": "npm:@fluidframework/matrix@2.0.0
|
|
94
|
-
"@fluidframework/test-runtime-utils": "2.1.0
|
|
93
|
+
"@fluidframework/matrix-previous": "npm:@fluidframework/matrix@2.0.0",
|
|
94
|
+
"@fluidframework/test-runtime-utils": "~2.1.0",
|
|
95
95
|
"@microsoft/api-extractor": "^7.45.1",
|
|
96
96
|
"@tiny-calc/micro": "0.0.0-alpha.5",
|
|
97
97
|
"@types/double-ended-queue": "^2.1.0",
|
|
@@ -115,7 +115,11 @@
|
|
|
115
115
|
"typescript": "~5.4.5"
|
|
116
116
|
},
|
|
117
117
|
"typeValidation": {
|
|
118
|
-
"broken": {
|
|
118
|
+
"broken": {
|
|
119
|
+
"Variable_SharedMatrix": {
|
|
120
|
+
"forwardCompat": false
|
|
121
|
+
}
|
|
122
|
+
}
|
|
119
123
|
},
|
|
120
124
|
"scripts": {
|
|
121
125
|
"api": "fluid-build . --task api",
|
|
@@ -124,18 +128,19 @@
|
|
|
124
128
|
"bench": "cd bench && node --expose-gc -r ts-node/register src/index.ts",
|
|
125
129
|
"bench:profile": "cd bench && node -r ts-node/register --prof --logfile=profile.log --no-logfile-per-isolate src/index.ts --runInBand && node --prof-process profile.log > profile.txt && rimraf profile.log && echo See results in bench/profile.txt",
|
|
126
130
|
"build": "fluid-build . --task build",
|
|
131
|
+
"build:api-reports": "concurrently \"npm:build:api-reports:*\"",
|
|
132
|
+
"build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
|
|
133
|
+
"build:api-reports:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
|
|
127
134
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
128
135
|
"build:compile": "fluid-build . --task compile",
|
|
129
|
-
"build:docs": "
|
|
130
|
-
"build:docs:current": "api-extractor run --local",
|
|
131
|
-
"build:docs:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
|
|
136
|
+
"build:docs": "api-extractor run --local",
|
|
132
137
|
"build:esnext": "tsc --project ./tsconfig.json",
|
|
133
138
|
"build:genver": "gen-version",
|
|
134
139
|
"build:test": "npm run build:test:esm && npm run build:test:cjs",
|
|
135
140
|
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
136
141
|
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
137
142
|
"check:are-the-types-wrong": "attw --pack .",
|
|
138
|
-
"check:biome": "biome check .
|
|
143
|
+
"check:biome": "biome check .",
|
|
139
144
|
"check:exports": "concurrently \"npm:check:exports:*\"",
|
|
140
145
|
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
|
|
141
146
|
"check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
|
|
@@ -144,14 +149,15 @@
|
|
|
144
149
|
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
|
|
145
150
|
"check:format": "npm run check:biome",
|
|
146
151
|
"check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
147
|
-
"ci:build:
|
|
148
|
-
"ci:build:
|
|
149
|
-
"ci:build:
|
|
152
|
+
"ci:build:api-reports": "concurrently \"npm:ci:build:api-reports:*\"",
|
|
153
|
+
"ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
|
|
154
|
+
"ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
|
|
155
|
+
"ci:build:docs": "api-extractor run",
|
|
150
156
|
"clean": "rimraf --glob dist lib \"*.d.ts\" bench/dist \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
151
157
|
"eslint": "eslint --format stylish src",
|
|
152
158
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
153
159
|
"format": "npm run format:biome",
|
|
154
|
-
"format:biome": "biome check . --
|
|
160
|
+
"format:biome": "biome check . --write",
|
|
155
161
|
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
156
162
|
"lint": "fluid-build . --task lint",
|
|
157
163
|
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
package/src/handlecache.ts
CHANGED
|
@@ -28,7 +28,7 @@ export class HandleCache implements IVectorConsumer<Handle> {
|
|
|
28
28
|
* Returns the index of the given position in the 'handles' array as a Uint32.
|
|
29
29
|
* (If the position is not in the array, returns an integer greater than 'handles.length').
|
|
30
30
|
*/
|
|
31
|
-
private getIndex(position: number) {
|
|
31
|
+
private getIndex(position: number): number {
|
|
32
32
|
return (position - this.start) >>> 0;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -37,10 +37,10 @@ export class HandleCache implements IVectorConsumer<Handle> {
|
|
|
37
37
|
* the result with 'isValidHandle(..)' to see if a handle has been allocated for
|
|
38
38
|
* the given position.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
40
|
+
* @throws A 'RangeError' if the provided 'position' is out-of-bounds with regards to the
|
|
41
41
|
* PermutationVector's length.
|
|
42
42
|
*/
|
|
43
|
-
public getHandle(position: number) {
|
|
43
|
+
public getHandle(position: number): Handle {
|
|
44
44
|
const index = this.getIndex(position);
|
|
45
45
|
|
|
46
46
|
// Perf: To encourage inlining, handling of the 'cacheMiss(..)' case has been extracted
|
|
@@ -50,25 +50,35 @@ export class HandleCache implements IVectorConsumer<Handle> {
|
|
|
50
50
|
// checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an
|
|
51
51
|
// ~40% speedup when the position is in the cache (node v12 x64).
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
const handle = this.handles[index];
|
|
54
|
+
if (handle !== undefined) {
|
|
55
|
+
return handle;
|
|
56
|
+
}
|
|
57
|
+
return this.cacheMiss(position);
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
/**
|
|
57
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Update the cache when a handle has been allocated for a given position.
|
|
62
|
+
*/
|
|
63
|
+
public addHandle(position: number, handle: Handle): void {
|
|
58
64
|
assert(isHandleValid(handle), 0x017 /* "Trying to add invalid handle!" */);
|
|
59
65
|
|
|
60
66
|
const index = this.getIndex(position);
|
|
61
67
|
if (index < this.handles.length) {
|
|
62
68
|
assert(
|
|
63
|
-
|
|
69
|
+
// Non null asserting, above we checked that the index is less than the length.
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
71
|
+
!isHandleValid(this.handles[index]!),
|
|
64
72
|
0x018 /* "Trying to insert handle into position with already valid handle!" */,
|
|
65
73
|
);
|
|
66
74
|
this.handles[index] = handle;
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
/**
|
|
71
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Used by {@link HandleCache.cacheMiss} to retrieve handles for a range of positions.
|
|
80
|
+
*/
|
|
81
|
+
private getHandles(start: number, end: number): Handle[] {
|
|
72
82
|
// TODO: This can be accelerated substantially using 'walkSegments()'. The only catch
|
|
73
83
|
// is that
|
|
74
84
|
|
|
@@ -85,7 +95,7 @@ export class HandleCache implements IVectorConsumer<Handle> {
|
|
|
85
95
|
return handles;
|
|
86
96
|
}
|
|
87
97
|
|
|
88
|
-
private cacheMiss(position: number) {
|
|
98
|
+
private cacheMiss(position: number): Handle {
|
|
89
99
|
// Coercing 'position' to an Uint32 allows us to handle a negative 'position' value
|
|
90
100
|
// with the same logic that handles 'position' >= length.
|
|
91
101
|
const _position = position >>> 0;
|
|
@@ -98,16 +108,21 @@ export class HandleCache implements IVectorConsumer<Handle> {
|
|
|
98
108
|
// the handle cache).
|
|
99
109
|
|
|
100
110
|
if (_position < this.start) {
|
|
101
|
-
this.handles = this.getHandles(_position, this.start)
|
|
111
|
+
this.handles = [...this.getHandles(_position, this.start), ...this.handles];
|
|
102
112
|
this.start = _position;
|
|
103
|
-
|
|
113
|
+
// TODO why are we non null asserting here?
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
115
|
+
return this.handles[0]!;
|
|
104
116
|
} else {
|
|
105
117
|
ensureRange(_position, this.vector.getLength());
|
|
106
118
|
|
|
107
|
-
this.handles =
|
|
108
|
-
this.
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
this.handles = [
|
|
120
|
+
...this.handles,
|
|
121
|
+
...this.getHandles(this.start + this.handles.length, _position + 1),
|
|
122
|
+
];
|
|
123
|
+
// TODO why are we non null asserting here?
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
125
|
+
return this.handles[this.handles.length - 1]!;
|
|
111
126
|
}
|
|
112
127
|
}
|
|
113
128
|
|
package/src/handletable.ts
CHANGED
|
@@ -9,7 +9,9 @@ export const enum Handle {
|
|
|
9
9
|
*/
|
|
10
10
|
none = 0,
|
|
11
11
|
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Minimum valid handle.
|
|
14
|
+
*/
|
|
13
15
|
valid = 1,
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -19,7 +21,7 @@ export const enum Handle {
|
|
|
19
21
|
unallocated = -0x80000000,
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
export const isHandleValid = (handle: Handle) => handle >= Handle.valid;
|
|
24
|
+
export const isHandleValid = (handle: Handle): boolean => handle >= Handle.valid;
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* A handle table provides a fast mapping from an integer `handle` to a value `T`.
|
|
@@ -30,7 +32,7 @@ export class HandleTable<T> {
|
|
|
30
32
|
// us to delay allocate the following slot in the array on the first allocation.
|
|
31
33
|
public constructor(private readonly handles: (Handle | T)[] = [1]) {}
|
|
32
34
|
|
|
33
|
-
public clear() {
|
|
35
|
+
public clear(): void {
|
|
34
36
|
// Restore the HandleTable's initial state by deleting all items in the handles array
|
|
35
37
|
// and then re-inserting the value '1' in the 0th slot. (See comment at `handles` decl
|
|
36
38
|
// for explanation.)
|
|
@@ -62,7 +64,7 @@ export class HandleTable<T> {
|
|
|
62
64
|
/**
|
|
63
65
|
* Allocates and returns the next available `count` handles.
|
|
64
66
|
*/
|
|
65
|
-
public allocateMany(count: Handle) {
|
|
67
|
+
public allocateMany(count: Handle): Uint32Array {
|
|
66
68
|
const handles = new Uint32Array(count);
|
|
67
69
|
for (let i = 0; i < count; i++) {
|
|
68
70
|
handles[i] = this.allocate();
|
|
@@ -73,7 +75,7 @@ export class HandleTable<T> {
|
|
|
73
75
|
/**
|
|
74
76
|
* Returns the given handle to the free list.
|
|
75
77
|
*/
|
|
76
|
-
public free(handle: Handle) {
|
|
78
|
+
public free(handle: Handle): void {
|
|
77
79
|
this.handles[handle] = this.next;
|
|
78
80
|
this.next = handle;
|
|
79
81
|
}
|
|
@@ -88,24 +90,24 @@ export class HandleTable<T> {
|
|
|
88
90
|
/**
|
|
89
91
|
* Set the value `T` associated with the given handle.
|
|
90
92
|
*/
|
|
91
|
-
public set(handle: Handle, value: T) {
|
|
93
|
+
public set(handle: Handle, value: T): void {
|
|
92
94
|
this.handles[handle] = value;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
// Private helpers to get/set the head of the free list, which is stored in the 0th slot
|
|
96
98
|
// of the handle array.
|
|
97
|
-
private get next() {
|
|
99
|
+
private get next(): Handle {
|
|
98
100
|
return this.handles[0] as Handle;
|
|
99
101
|
}
|
|
100
102
|
private set next(handle: Handle) {
|
|
101
103
|
this.handles[0] = handle;
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
public getSummaryContent() {
|
|
106
|
+
public getSummaryContent(): (Handle | T)[] {
|
|
105
107
|
return this.handles;
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
public static load<T>(data: (Handle | T)[]) {
|
|
110
|
+
public static load<T>(data: (Handle | T)[]): HandleTable<T> {
|
|
109
111
|
return new HandleTable<T>(data);
|
|
110
112
|
}
|
|
111
113
|
}
|