@fluidframework/matrix 2.50.0 → 2.51.0-347100
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/handlecache.d.ts +3 -3
- package/dist/handlecache.d.ts.map +1 -1
- package/dist/handlecache.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/matrix.d.ts +9 -9
- package/dist/matrix.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/permutationvector.d.ts +7 -7
- package/dist/permutationvector.d.ts.map +1 -1
- package/dist/permutationvector.js +0 -1
- package/dist/permutationvector.js.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/serialization.d.ts +3 -3
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +0 -1
- package/dist/serialization.js.map +1 -1
- package/dist/sparsearray2d.d.ts +1 -1
- package/dist/sparsearray2d.d.ts.map +1 -1
- package/dist/sparsearray2d.js.map +1 -1
- package/dist/undoprovider.d.ts +6 -6
- package/dist/undoprovider.d.ts.map +1 -1
- package/dist/undoprovider.js.map +1 -1
- package/lib/handlecache.d.ts +3 -3
- package/lib/handlecache.d.ts.map +1 -1
- package/lib/handlecache.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/matrix.d.ts +9 -9
- package/lib/matrix.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/permutationvector.d.ts +7 -7
- package/lib/permutationvector.d.ts.map +1 -1
- package/lib/permutationvector.js +0 -1
- package/lib/permutationvector.js.map +1 -1
- package/lib/runtime.d.ts +1 -1
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/serialization.d.ts +3 -3
- package/lib/serialization.d.ts.map +1 -1
- package/lib/serialization.js +0 -1
- package/lib/serialization.js.map +1 -1
- package/lib/sparsearray2d.d.ts +1 -1
- package/lib/sparsearray2d.d.ts.map +1 -1
- package/lib/sparsearray2d.js.map +1 -1
- package/lib/undoprovider.d.ts +6 -6
- package/lib/undoprovider.d.ts.map +1 -1
- package/lib/undoprovider.js.map +1 -1
- package/package.json +18 -18
- package/src/handlecache.ts +3 -3
- package/src/index.ts +3 -3
- package/src/matrix.ts +18 -18
- package/src/ops.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/permutationvector.ts +11 -12
- package/src/runtime.ts +1 -1
- package/src/serialization.ts +3 -4
- package/src/sparsearray2d.ts +1 -1
- package/src/undoprovider.ts +9 -9
package/lib/runtime.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannel, IChannelAttributes, IChannelFactory, IFluidDataStoreRuntime, IChannelServices } from "@fluidframework/datastore-definitions/internal";
|
|
5
|
+
import type { IChannel, IChannelAttributes, IChannelFactory, IFluidDataStoreRuntime, IChannelServices } from "@fluidframework/datastore-definitions/internal";
|
|
6
6
|
import { type ISharedMatrix } from "./matrix.js";
|
|
7
7
|
/**
|
|
8
8
|
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMatrix}.
|
package/lib/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AAGxD,OAAO,EAAE,KAAK,aAAa,EAAqC,MAAM,aAAa,CAAC;AAGpF;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,eAAe,CAAC,aAAa,CAAC;IACzE,OAAc,IAAI,SAAoD;IAEtE,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,aAAa,GAAG,QAAQ,CAAC;IAM7B,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,QAAQ;CAKrF;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,0LAA6D,CAAC;AAEvF;;;;;;;GAOG;AAIH,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC"}
|
package/lib/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,OAAO,EAAsB,YAAY,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAS/B,IAAW,IAAI;QACd,OAAO,mBAAmB,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,mBAAmB,CAAC,UAAU,CAAC;IACvC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;QAC9D,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,CAAC,eAAe,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC;IACf,CAAC;;AAlCa,wBAAI,GAAG,gDAAgD,CAAC;AAE/C,8BAAU,GAAuB;IACvD,IAAI,EAAE,mBAAmB,CAAC,IAAI;IAC9B,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC1B,CAAC;AA+BH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAgB,mBAAmB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { createSharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { type ISharedMatrix, SharedMatrix as SharedMatrixClass } from \"./matrix.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMatrix}.\n * @legacy\n * @alpha\n * @deprecated - Use `SharedMatrix.getFactory` instead.\n */\nexport class SharedMatrixFactory implements IChannelFactory<ISharedMatrix> {\n\tpublic static Type = \"https://graph.microsoft.com/types/sharedmatrix\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: SharedMatrixFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn SharedMatrixFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn SharedMatrixFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedMatrix & IChannel> {\n\t\tconst matrix = new SharedMatrixClass(runtime, id, attributes);\n\t\tawait matrix.load(services);\n\t\treturn matrix;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): ISharedMatrix & IChannel {\n\t\tconst matrix = new SharedMatrixClass(document, id, this.attributes);\n\t\tmatrix.initializeLocal();\n\t\treturn matrix;\n\t}\n}\n\n/**\n * Entrypoint for {@link ISharedMatrix} creation.\n * @legacy\n * @alpha\n */\nexport const SharedMatrix = createSharedObjectKind<ISharedMatrix>(SharedMatrixFactory);\n\n/**\n * Convenience alias for {@link ISharedMatrix}. Prefer to use {@link ISharedMatrix} when referring to\n * SharedMatrix as a type.\n * @legacy\n * @alpha\n * @privateRemarks\n * This alias is for legacy compat from when the SharedMatrix class was exported as public.\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition SharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SharedMatrix<T = any> = ISharedMatrix<T>;\n"]}
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,OAAO,EAAsB,YAAY,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAS/B,IAAW,IAAI;QACd,OAAO,mBAAmB,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,mBAAmB,CAAC,UAAU,CAAC;IACvC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;QAC9D,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,CAAC,eAAe,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC;IACf,CAAC;;AAlCa,wBAAI,GAAG,gDAAgD,CAAC;AAE/C,8BAAU,GAAuB;IACvD,IAAI,EAAE,mBAAmB,CAAC,IAAI;IAC9B,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC1B,CAAC;AA+BH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAgB,mBAAmB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { createSharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { type ISharedMatrix, SharedMatrix as SharedMatrixClass } from \"./matrix.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMatrix}.\n * @legacy\n * @alpha\n * @deprecated - Use `SharedMatrix.getFactory` instead.\n */\nexport class SharedMatrixFactory implements IChannelFactory<ISharedMatrix> {\n\tpublic static Type = \"https://graph.microsoft.com/types/sharedmatrix\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: SharedMatrixFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn SharedMatrixFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn SharedMatrixFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedMatrix & IChannel> {\n\t\tconst matrix = new SharedMatrixClass(runtime, id, attributes);\n\t\tawait matrix.load(services);\n\t\treturn matrix;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): ISharedMatrix & IChannel {\n\t\tconst matrix = new SharedMatrixClass(document, id, this.attributes);\n\t\tmatrix.initializeLocal();\n\t\treturn matrix;\n\t}\n}\n\n/**\n * Entrypoint for {@link ISharedMatrix} creation.\n * @legacy\n * @alpha\n */\nexport const SharedMatrix = createSharedObjectKind<ISharedMatrix>(SharedMatrixFactory);\n\n/**\n * Convenience alias for {@link ISharedMatrix}. Prefer to use {@link ISharedMatrix} when referring to\n * SharedMatrix as a type.\n * @legacy\n * @alpha\n * @privateRemarks\n * This alias is for legacy compat from when the SharedMatrix class was exported as public.\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition SharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SharedMatrix<T = any> = ISharedMatrix<T>;\n"]}
|
package/lib/serialization.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IChannelStorageService, Serializable } from "@fluidframework/datastore-definitions/internal";
|
|
5
|
+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { IChannelStorageService, Serializable } from "@fluidframework/datastore-definitions/internal";
|
|
7
7
|
import { BlobTreeEntry } from "@fluidframework/driver-utils/internal";
|
|
8
|
-
import { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
8
|
+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
9
9
|
export declare const serializeBlob: <T>(handle: IFluidHandle, path: string, snapshot: Serializable<T>, serializer: IFluidSerializer) => BlobTreeEntry;
|
|
10
10
|
export declare function deserializeBlob(storage: IChannelStorageService, path: string, serializer: IFluidSerializer): Promise<any>;
|
|
11
11
|
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EACX,sBAAsB,EACtB,YAAY,EACZ,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,eAAO,MAAM,aAAa,cACjB,YAAY,QACd,MAAM,YACF,aAAa,CAAC,CAAC,cACb,gBAAgB,KAC1B,aAAgF,CAAC;AAEpF,wBAAsB,eAAe,CACpC,OAAO,EAAE,sBAAsB,EAC/B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,gBAAgB,GAG1B,OAAO,CAAC,GAAG,CAAC,CAId"}
|
package/lib/serialization.js
CHANGED
|
@@ -8,7 +8,6 @@ export const serializeBlob = (handle, path, snapshot, serializer) => new BlobTre
|
|
|
8
8
|
export async function deserializeBlob(storage, path, serializer) {
|
|
9
9
|
const blob = await storage.readBlob(path);
|
|
10
10
|
const utf8 = bufferToString(blob, "utf8");
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
12
11
|
return serializer.parse(utf8);
|
|
13
12
|
}
|
|
14
13
|
//# sourceMappingURL=serialization.js.map
|
package/lib/serialization.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9D,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAGtE,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,MAAoB,EACpB,IAAY,EACZ,QAAyB,EACzB,UAA4B,EACZ,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpF,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,OAA+B,EAC/B,IAAY,EACZ,UAA4B;IAI5B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1C
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9D,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAGtE,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,MAAoB,EACpB,IAAY,EACZ,QAAyB,EACzB,UAA4B,EACZ,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpF,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,OAA+B,EAC/B,IAAY,EACZ,UAA4B;IAI5B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type {\n\tIChannelStorageService,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { BlobTreeEntry } from \"@fluidframework/driver-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\n\nexport const serializeBlob = <T>(\n\thandle: IFluidHandle,\n\tpath: string,\n\tsnapshot: Serializable<T>,\n\tserializer: IFluidSerializer,\n): BlobTreeEntry => new BlobTreeEntry(path, serializer.stringify(snapshot, handle));\n\nexport async function deserializeBlob(\n\tstorage: IChannelStorageService,\n\tpath: string,\n\tserializer: IFluidSerializer,\n\t// Allowing parsed content to remain in its original (any) form.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Promise<any> {\n\tconst blob = await storage.readBlob(path);\n\tconst utf8 = bufferToString(blob, \"utf8\");\n\treturn serializer.parse(utf8);\n}\n"]}
|
package/lib/sparsearray2d.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IMatrixReader, IMatrixWriter,
|
|
5
|
+
import type { IMatrixReader, IMatrixWriter, IMatrixProducer } from "@tiny-calc/nano";
|
|
6
6
|
type RecurArrayHelper<T> = RecurArray<T> | T;
|
|
7
7
|
export type RecurArray<T> = RecurArrayHelper<T>[];
|
|
8
8
|
type UA<T> = (T | undefined)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sparsearray2d.d.ts","sourceRoot":"","sources":["../src/sparsearray2d.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"sparsearray2d.d.ts","sourceRoot":"","sources":["../src/sparsearray2d.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAqCrF,KAAK,gBAAgB,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC7C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,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AAE;gCAClD,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;oCAC1C,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;gCACzB,CAAC,CAAC,CAAC;4BACJ,CAAC,CAAC,CAAC;wBACJ,CAAC,CAAC,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAEO,QAAQ,CAAI,MAAiB,EAAE,MAAc;QACpD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7B,+EAA+E;QAC/E,2BAA2B;QAC3B,gDAAgD;QAChD,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAmB;QACxC,OAAO,IAAI,aAAa,CAAI,eAAe,CAAI,IAAI,CAA6B,CAAC,CAAC;IACnF,CAAC;CACD","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 { IMatrixReader, IMatrixWriter, type IMatrixProducer } from \"@tiny-calc/nano\";\n\n// Build a lookup table that maps a uint8 to the corresponding uint16 where 0s\n// are interleaved between the original bits. (e.g., 1111... -> 01010101...).\n//\n// (Lookup table ~17% faster than inlining the bit-twiddling on Node v12 x64)\n// (Array<T> ~2% faster than typed array on Node v12 x64)\nconst x8ToInterlacedX16 = Array.from({ length: 256 })\n\t.fill(0)\n\t.map((value, i) => {\n\t\tlet j = i;\n\t\tj = (j | (j << 4)) & 0x0f0f; // .... 7654 .... 3210\n\t\tj = (j | (j << 2)) & 0x3333; // ..76 ..54 ..32 ..10\n\t\tj = (j | (j << 1)) & 0x5555; // .7.6 .5.4 .3.2 .1.0\n\t\treturn j;\n\t});\n\n// Selects individual bytes from a given 32b integer. The left shift are used to\n// clear upper bits (faster than using masks on Node 10 x64).\nconst byte0 = (x32: number): number => x32 >>> 24;\nconst byte1 = (x32: number): number => (x32 << 8) >>> 24;\nconst byte2 = (x32: number): number => (x32 << 16) >>> 24;\nconst byte3 = (x32: number): number => (x32 << 24) >>> 24;\n\n// Given a uint16 returns the corresponding uint32 integer where 0s are\n// interleaved between the original bits. (e.g., 1111... -> 01010101...).\nconst interlaceBitsX16 = (x16: number): number =>\n\t(x8ToInterlacedX16[byte2(x16)] << 16) | x8ToInterlacedX16[byte3(x16)];\n\nconst r0ToMorton16 = (row: number): number => (interlaceBitsX16(row) << 1) >>> 0;\nconst c0ToMorton16 = (col: number): number => interlaceBitsX16(col) >>> 0;\n\n// Given a 2D uint16 coordinate returns the corresponding unt32 Morton coded\n// coordinate. (See https://en.wikipedia.org/wiki/Z-order_curve)\nconst r0c0ToMorton2x16 = (row: number, col: number): number =>\n\t(r0ToMorton16(row) | c0ToMorton16(col)) >>> 0;\n\ntype RecurArrayHelper<T> = RecurArray<T> | T;\nexport type RecurArray<T> = RecurArrayHelper<T>[];\n\n/**\n * Undo JSON serialization's coercion of 'undefined' to null.\n */\n// eslint-disable-next-line @rushstack/no-new-null -- Private use of 'null' to preserve 'undefined'\nconst nullToUndefined = <T>(array: RecurArray<T | null>): RecurArray<T | undefined> =>\n\tarray.map((value) => {\n\t\treturn value === null ? undefined : Array.isArray(value) ? nullToUndefined(value) : value;\n\t});\n\ntype UA<T> = (T | undefined)[];\n\n/**\n * A sparse 4 billion x 4 billion array stored as 16x16 tiles.\n */\nexport class SparseArray2D<T>\n\timplements IMatrixReader<T | undefined>, IMatrixWriter<T | undefined>\n{\n\tconstructor(private readonly root: UA<UA<UA<UA<UA<T>>>>> = [undefined]) {}\n\n\tpublic readonly rowCount = 0xffffffff;\n\tpublic readonly colCount = 0xffffffff;\n\n\tpublic getCell(row: number, col: number): T | undefined {\n\t\tconst keyHi = r0c0ToMorton2x16(row >>> 16, col >>> 16);\n\t\tconst level0 = this.root[keyHi];\n\t\tif (level0 !== undefined) {\n\t\t\tconst keyLo = r0c0ToMorton2x16(row, col);\n\t\t\tconst level1 = level0[byte0(keyLo)];\n\t\t\tif (level1 !== undefined) {\n\t\t\t\tconst level2 = level1[byte1(keyLo)];\n\t\t\t\tif (level2 !== undefined) {\n\t\t\t\t\tconst level3 = level2[byte2(keyLo)];\n\t\t\t\t\tif (level3 !== undefined) {\n\t\t\t\t\t\treturn level3[byte3(keyLo)];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<T> {\n\t\t// Cast is needed to satisfy the interface declaration while also not returning\n\t\t// an IMatrixProducer for this class.\n\t\treturn undefined as unknown as IMatrixProducer<T>;\n\t}\n\n\tpublic setCell(row: number, col: number, value: T | undefined): void {\n\t\tconst keyHi = r0c0ToMorton2x16(row >>> 16, col >>> 16);\n\t\tconst keyLo = r0c0ToMorton2x16(row, col);\n\n\t\tconst level0 = this.getLevel(this.root, keyHi);\n\t\tconst level1 = this.getLevel(level0, byte0(keyLo));\n\t\tconst level2 = this.getLevel(level1, byte1(keyLo));\n\t\tconst level3 = this.getLevel(level2, byte2(keyLo));\n\t\tlevel3[byte3(keyLo)] = value;\n\t}\n\n\t/**\n\t * Invokes the given 'callback' for each key in a 16 x 16 tile at the indicated row.\n\t *\n\t * (Note that 'rowBits' is the appropriate byte from 'r0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\tprivate forEachKeyInRow(rowBits: number, callback: (key: number) => void): void {\n\t\tfor (let col = 0; col < 16; col++) {\n\t\t\t// Perf: Potentially faster to replace 'c0ToMorton16()' with a short look up table?\n\t\t\tcallback((rowBits | c0ToMorton16(col)) >>> 0);\n\t\t}\n\t}\n\n\t/**\n\t * Invokes the given 'callback' for each key in a 16 x 16 tile at the indicated col.\n\t *\n\t * (Note that 'colBits' is the appropriate byte from 'c0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\tprivate forEachKeyInCol(col: number, callback: (key: number) => void): void {\n\t\tfor (let row = 0; row < 16; row++) {\n\t\t\t// Perf: Potentially faster to replace 'r0ToMorton16()' with a short look up table?\n\t\t\tcallback((r0ToMorton16(row) | col) >>> 0);\n\t\t}\n\t}\n\n\t/**\n\t * Invokes the give 'callback' with the next 'level' array for each populated region\n\t * of the given row in the 'currentLevel'.\n\t *\n\t * (Note that 'rowBits' is the appropriate byte from 'r0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\t// The suppression is needed because forEachInRow is called in a loop, and expected to\n\t// use various abstractions on UA<T> at each level of the loop.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate forEachInRow<V extends UA<any>, U extends UA<V>>(\n\t\tcurrentLevel: U,\n\t\trowBits: number,\n\t\tcallback: (level: V) => void,\n\t): void {\n\t\tthis.forEachKeyInRow(rowBits, (key) => {\n\t\t\tconst nextLevel = currentLevel[key];\n\t\t\tif (nextLevel !== undefined) {\n\t\t\t\tcallback(nextLevel);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Invokes the give 'callback' with the next 'level' array for each populated region\n\t * of the given col in the 'currentLevel'.\n\t *\n\t * (Note that 'colBits' is the appropriate byte from 'c0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\t// The suppression is needed because forEachInRow is called in a loop, and expected to\n\t// use various abstractions on UA<T> at each level of the loop.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate forEachInCol<V extends UA<any>, U extends UA<V>>(\n\t\tcurrentLevel: U,\n\t\tcolBits: number,\n\t\tcallback: (level: V) => void,\n\t): void {\n\t\tthis.forEachKeyInCol(colBits, (key) => {\n\t\t\tconst nextLevel = currentLevel[key];\n\t\t\tif (nextLevel !== undefined) {\n\t\t\t\tcallback(nextLevel);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Clears the all cells contained within the specified span of rows.\n\t */\n\tpublic clearRows(rowStart: number, rowCount: number): void {\n\t\tconst rowEnd = rowStart + rowCount;\n\t\tfor (let row = rowStart; row < rowEnd; row++) {\n\t\t\tconst rowHi = r0ToMorton16(row >>> 16);\n\n\t\t\t// The top level of tree is a 64k x 64k tile. We need to scan all 64k entries.\n\t\t\tfor (let colHi = 0; colHi < 0x10000; colHi++) {\n\t\t\t\tconst keyHi = (rowHi | c0ToMorton16(colHi)) >>> 0;\n\t\t\t\tconst level0 = this.root[keyHi];\n\t\t\t\tif (level0 !== undefined) {\n\t\t\t\t\t// The remainder of the tree is divided in 16 x 16 tiles.\n\t\t\t\t\tconst rowLo = r0ToMorton16(row);\n\t\t\t\t\tthis.forEachInRow(level0, byte0(rowLo), (level1) => {\n\t\t\t\t\t\tthis.forEachInRow(level1, byte1(rowLo), (level2) => {\n\t\t\t\t\t\t\tthis.forEachInRow(level2, byte2(rowLo), (level3) => {\n\t\t\t\t\t\t\t\tthis.forEachKeyInRow(byte3(rowLo), (key) => {\n\t\t\t\t\t\t\t\t\tlevel3[key] = undefined;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clears the all cells contained within the specifed span of cols.\n\t */\n\tpublic clearCols(colStart: number, colCount: number): void {\n\t\tconst colEnd = colStart + colCount;\n\t\tfor (let col = colStart; col < colEnd; col++) {\n\t\t\tconst colHi = c0ToMorton16(col >>> 16);\n\n\t\t\t// The top level of tree is a 64k x 64k tile. We need to scan all 64k entries.\n\t\t\tfor (let rowHi = 0; rowHi < 0x10000; rowHi++) {\n\t\t\t\tconst keyHi = (colHi | r0ToMorton16(rowHi)) >>> 0;\n\t\t\t\tconst level0 = this.root[keyHi];\n\t\t\t\tif (level0 !== undefined) {\n\t\t\t\t\t// The remainder of the tree is divided in 16 x 16 tiles.\n\t\t\t\t\tconst colLo = c0ToMorton16(col);\n\t\t\t\t\tthis.forEachInCol(level0, byte0(colLo), (level1) => {\n\t\t\t\t\t\tthis.forEachInCol(level1, byte1(colLo), (level2) => {\n\t\t\t\t\t\t\tthis.forEachInCol(level2, byte2(colLo), (level3) => {\n\t\t\t\t\t\t\t\tthis.forEachKeyInCol(byte3(colLo), (key) => {\n\t\t\t\t\t\t\t\t\tlevel3[key] = undefined;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getLevel<T>(parent: UA<UA<T>>, subKey: number): UA<T> {\n\t\tconst level = parent[subKey];\n\t\t// Using new Array is needed because the array created with Array.from does not\n\t\t// satisfy (T|undefined)[].\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\treturn level ?? (parent[subKey] = new Array<T | undefined>(256).fill(undefined));\n\t}\n\n\tpublic snapshot(): UA<UA<UA<UA<UA<T>>>>> {\n\t\treturn this.root;\n\t}\n\n\tpublic static load<T>(data: RecurArray<T>): SparseArray2D<T> {\n\t\treturn new SparseArray2D<T>(nullToUndefined<T>(data) as SparseArray2D<T>[\"root\"]);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sparsearray2d.js","sourceRoot":"","sources":["../src/sparsearray2d.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,8EAA8E;AAC9E,6EAA6E;AAC7E,EAAE;AACF,6EAA6E;AAC7E,yDAAyD;AACzD,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;KACnD,IAAI,CAAC,CAAC,CAAC;KACP,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;IACjB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,CAAC,GAAG,CAAC,CAAC,GAAG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C,SAAS,CAAC,CAAC,CAAC;IAClF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAmB;QACxC,OAAO,IAAI,aAAa,CAAI,eAAe,CAAI,IAAI,CAA6B,CAAC,CAAC;IACnF,CAAC;CACD","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 type { IMatrixReader, IMatrixWriter, IMatrixProducer } from \"@tiny-calc/nano\";\n\n// Build a lookup table that maps a uint8 to the corresponding uint16 where 0s\n// are interleaved between the original bits. (e.g., 1111... -> 01010101...).\n//\n// (Lookup table ~17% faster than inlining the bit-twiddling on Node v12 x64)\n// (Array<T> ~2% faster than typed array on Node v12 x64)\nconst x8ToInterlacedX16 = Array.from({ length: 256 })\n\t.fill(0)\n\t.map((value, i) => {\n\t\tlet j = i;\n\t\tj = (j | (j << 4)) & 0x0f0f; // .... 7654 .... 3210\n\t\tj = (j | (j << 2)) & 0x3333; // ..76 ..54 ..32 ..10\n\t\tj = (j | (j << 1)) & 0x5555; // .7.6 .5.4 .3.2 .1.0\n\t\treturn j;\n\t});\n\n// Selects individual bytes from a given 32b integer. The left shift are used to\n// clear upper bits (faster than using masks on Node 10 x64).\nconst byte0 = (x32: number): number => x32 >>> 24;\nconst byte1 = (x32: number): number => (x32 << 8) >>> 24;\nconst byte2 = (x32: number): number => (x32 << 16) >>> 24;\nconst byte3 = (x32: number): number => (x32 << 24) >>> 24;\n\n// Given a uint16 returns the corresponding uint32 integer where 0s are\n// interleaved between the original bits. (e.g., 1111... -> 01010101...).\nconst interlaceBitsX16 = (x16: number): number =>\n\t(x8ToInterlacedX16[byte2(x16)] << 16) | x8ToInterlacedX16[byte3(x16)];\n\nconst r0ToMorton16 = (row: number): number => (interlaceBitsX16(row) << 1) >>> 0;\nconst c0ToMorton16 = (col: number): number => interlaceBitsX16(col) >>> 0;\n\n// Given a 2D uint16 coordinate returns the corresponding unt32 Morton coded\n// coordinate. (See https://en.wikipedia.org/wiki/Z-order_curve)\nconst r0c0ToMorton2x16 = (row: number, col: number): number =>\n\t(r0ToMorton16(row) | c0ToMorton16(col)) >>> 0;\n\ntype RecurArrayHelper<T> = RecurArray<T> | T;\nexport type RecurArray<T> = RecurArrayHelper<T>[];\n\n/**\n * Undo JSON serialization's coercion of 'undefined' to null.\n */\n// eslint-disable-next-line @rushstack/no-new-null -- Private use of 'null' to preserve 'undefined'\nconst nullToUndefined = <T>(array: RecurArray<T | null>): RecurArray<T | undefined> =>\n\tarray.map((value) => {\n\t\treturn value === null ? undefined : Array.isArray(value) ? nullToUndefined(value) : value;\n\t});\n\ntype UA<T> = (T | undefined)[];\n\n/**\n * A sparse 4 billion x 4 billion array stored as 16x16 tiles.\n */\nexport class SparseArray2D<T>\n\timplements IMatrixReader<T | undefined>, IMatrixWriter<T | undefined>\n{\n\tconstructor(private readonly root: UA<UA<UA<UA<UA<T>>>>> = [undefined]) {}\n\n\tpublic readonly rowCount = 0xffffffff;\n\tpublic readonly colCount = 0xffffffff;\n\n\tpublic getCell(row: number, col: number): T | undefined {\n\t\tconst keyHi = r0c0ToMorton2x16(row >>> 16, col >>> 16);\n\t\tconst level0 = this.root[keyHi];\n\t\tif (level0 !== undefined) {\n\t\t\tconst keyLo = r0c0ToMorton2x16(row, col);\n\t\t\tconst level1 = level0[byte0(keyLo)];\n\t\t\tif (level1 !== undefined) {\n\t\t\t\tconst level2 = level1[byte1(keyLo)];\n\t\t\t\tif (level2 !== undefined) {\n\t\t\t\t\tconst level3 = level2[byte2(keyLo)];\n\t\t\t\t\tif (level3 !== undefined) {\n\t\t\t\t\t\treturn level3[byte3(keyLo)];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<T> {\n\t\t// Cast is needed to satisfy the interface declaration while also not returning\n\t\t// an IMatrixProducer for this class.\n\t\treturn undefined as unknown as IMatrixProducer<T>;\n\t}\n\n\tpublic setCell(row: number, col: number, value: T | undefined): void {\n\t\tconst keyHi = r0c0ToMorton2x16(row >>> 16, col >>> 16);\n\t\tconst keyLo = r0c0ToMorton2x16(row, col);\n\n\t\tconst level0 = this.getLevel(this.root, keyHi);\n\t\tconst level1 = this.getLevel(level0, byte0(keyLo));\n\t\tconst level2 = this.getLevel(level1, byte1(keyLo));\n\t\tconst level3 = this.getLevel(level2, byte2(keyLo));\n\t\tlevel3[byte3(keyLo)] = value;\n\t}\n\n\t/**\n\t * Invokes the given 'callback' for each key in a 16 x 16 tile at the indicated row.\n\t *\n\t * (Note that 'rowBits' is the appropriate byte from 'r0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\tprivate forEachKeyInRow(rowBits: number, callback: (key: number) => void): void {\n\t\tfor (let col = 0; col < 16; col++) {\n\t\t\t// Perf: Potentially faster to replace 'c0ToMorton16()' with a short look up table?\n\t\t\tcallback((rowBits | c0ToMorton16(col)) >>> 0);\n\t\t}\n\t}\n\n\t/**\n\t * Invokes the given 'callback' for each key in a 16 x 16 tile at the indicated col.\n\t *\n\t * (Note that 'colBits' is the appropriate byte from 'c0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\tprivate forEachKeyInCol(col: number, callback: (key: number) => void): void {\n\t\tfor (let row = 0; row < 16; row++) {\n\t\t\t// Perf: Potentially faster to replace 'r0ToMorton16()' with a short look up table?\n\t\t\tcallback((r0ToMorton16(row) | col) >>> 0);\n\t\t}\n\t}\n\n\t/**\n\t * Invokes the give 'callback' with the next 'level' array for each populated region\n\t * of the given row in the 'currentLevel'.\n\t *\n\t * (Note that 'rowBits' is the appropriate byte from 'r0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\t// The suppression is needed because forEachInRow is called in a loop, and expected to\n\t// use various abstractions on UA<T> at each level of the loop.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate forEachInRow<V extends UA<any>, U extends UA<V>>(\n\t\tcurrentLevel: U,\n\t\trowBits: number,\n\t\tcallback: (level: V) => void,\n\t): void {\n\t\tthis.forEachKeyInRow(rowBits, (key) => {\n\t\t\tconst nextLevel = currentLevel[key];\n\t\t\tif (nextLevel !== undefined) {\n\t\t\t\tcallback(nextLevel);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Invokes the give 'callback' with the next 'level' array for each populated region\n\t * of the given col in the 'currentLevel'.\n\t *\n\t * (Note that 'colBits' is the appropriate byte from 'c0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\t// The suppression is needed because forEachInRow is called in a loop, and expected to\n\t// use various abstractions on UA<T> at each level of the loop.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate forEachInCol<V extends UA<any>, U extends UA<V>>(\n\t\tcurrentLevel: U,\n\t\tcolBits: number,\n\t\tcallback: (level: V) => void,\n\t): void {\n\t\tthis.forEachKeyInCol(colBits, (key) => {\n\t\t\tconst nextLevel = currentLevel[key];\n\t\t\tif (nextLevel !== undefined) {\n\t\t\t\tcallback(nextLevel);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Clears the all cells contained within the specified span of rows.\n\t */\n\tpublic clearRows(rowStart: number, rowCount: number): void {\n\t\tconst rowEnd = rowStart + rowCount;\n\t\tfor (let row = rowStart; row < rowEnd; row++) {\n\t\t\tconst rowHi = r0ToMorton16(row >>> 16);\n\n\t\t\t// The top level of tree is a 64k x 64k tile. We need to scan all 64k entries.\n\t\t\tfor (let colHi = 0; colHi < 0x10000; colHi++) {\n\t\t\t\tconst keyHi = (rowHi | c0ToMorton16(colHi)) >>> 0;\n\t\t\t\tconst level0 = this.root[keyHi];\n\t\t\t\tif (level0 !== undefined) {\n\t\t\t\t\t// The remainder of the tree is divided in 16 x 16 tiles.\n\t\t\t\t\tconst rowLo = r0ToMorton16(row);\n\t\t\t\t\tthis.forEachInRow(level0, byte0(rowLo), (level1) => {\n\t\t\t\t\t\tthis.forEachInRow(level1, byte1(rowLo), (level2) => {\n\t\t\t\t\t\t\tthis.forEachInRow(level2, byte2(rowLo), (level3) => {\n\t\t\t\t\t\t\t\tthis.forEachKeyInRow(byte3(rowLo), (key) => {\n\t\t\t\t\t\t\t\t\tlevel3[key] = undefined;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clears the all cells contained within the specifed span of cols.\n\t */\n\tpublic clearCols(colStart: number, colCount: number): void {\n\t\tconst colEnd = colStart + colCount;\n\t\tfor (let col = colStart; col < colEnd; col++) {\n\t\t\tconst colHi = c0ToMorton16(col >>> 16);\n\n\t\t\t// The top level of tree is a 64k x 64k tile. We need to scan all 64k entries.\n\t\t\tfor (let rowHi = 0; rowHi < 0x10000; rowHi++) {\n\t\t\t\tconst keyHi = (colHi | r0ToMorton16(rowHi)) >>> 0;\n\t\t\t\tconst level0 = this.root[keyHi];\n\t\t\t\tif (level0 !== undefined) {\n\t\t\t\t\t// The remainder of the tree is divided in 16 x 16 tiles.\n\t\t\t\t\tconst colLo = c0ToMorton16(col);\n\t\t\t\t\tthis.forEachInCol(level0, byte0(colLo), (level1) => {\n\t\t\t\t\t\tthis.forEachInCol(level1, byte1(colLo), (level2) => {\n\t\t\t\t\t\t\tthis.forEachInCol(level2, byte2(colLo), (level3) => {\n\t\t\t\t\t\t\t\tthis.forEachKeyInCol(byte3(colLo), (key) => {\n\t\t\t\t\t\t\t\t\tlevel3[key] = undefined;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getLevel<T>(parent: UA<UA<T>>, subKey: number): UA<T> {\n\t\tconst level = parent[subKey];\n\t\t// Using new Array is needed because the array created with Array.from does not\n\t\t// satisfy (T|undefined)[].\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\treturn level ?? (parent[subKey] = new Array<T | undefined>(256).fill(undefined));\n\t}\n\n\tpublic snapshot(): UA<UA<UA<UA<UA<T>>>>> {\n\t\treturn this.root;\n\t}\n\n\tpublic static load<T>(data: RecurArray<T>): SparseArray2D<T> {\n\t\treturn new SparseArray2D<T>(nullToUndefined<T>(data) as SparseArray2D<T>[\"root\"]);\n\t}\n}\n"]}
|
package/lib/undoprovider.d.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IMergeTreeDeltaCallbackArgs, MergeTreeRevertibleDriver } from "@fluidframework/merge-tree/internal";
|
|
6
|
-
import { Handle } from "./handletable.js";
|
|
7
|
-
import { SharedMatrix } from "./matrix.js";
|
|
8
|
-
import { MatrixItem } from "./ops.js";
|
|
9
|
-
import { PermutationVector } from "./permutationvector.js";
|
|
10
|
-
import { IUndoConsumer } from "./types.js";
|
|
5
|
+
import { type IMergeTreeDeltaCallbackArgs, type MergeTreeRevertibleDriver } from "@fluidframework/merge-tree/internal";
|
|
6
|
+
import { type Handle } from "./handletable.js";
|
|
7
|
+
import type { SharedMatrix } from "./matrix.js";
|
|
8
|
+
import type { MatrixItem } from "./ops.js";
|
|
9
|
+
import type { PermutationVector } from "./permutationvector.js";
|
|
10
|
+
import type { IUndoConsumer } from "./types.js";
|
|
11
11
|
export declare class VectorUndoProvider {
|
|
12
12
|
private readonly manager;
|
|
13
13
|
private readonly driver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undoprovider.d.ts","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,2BAA2B,
|
|
1
|
+
{"version":3,"file":"undoprovider.d.ts","sourceRoot":"","sources":["../src/undoprovider.ts"],"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C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;oBACzC,CAAC;gBACF,CAAC;gBACD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;aACjB,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tITrackingGroup,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\tMergeTreeRevertibleDriver,\n\tTrackingGroup,\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\trevertMergeTreeDeltaRevertibles,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { Handle, isHandleValid } from \"./handletable.js\";\nimport { SharedMatrix } from \"./matrix.js\";\nimport { MatrixItem } from \"./ops.js\";\nimport { PermutationSegment, PermutationVector } from \"./permutationvector.js\";\nimport { IUndoConsumer } from \"./types.js\";\n\nexport class VectorUndoProvider {\n\t// 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce\n\t// the recorded into a single IRevertable / tracking group as they move between the undo <->\n\t// redo stacks.\n\tprivate currentGroup?: MergeTreeDeltaRevertible[];\n\tprivate currentOp?: MergeTreeDeltaType;\n\tprivate currentRemoveTrackingGroup?: TrackingGroup;\n\n\tconstructor(\n\t\tprivate readonly manager: IUndoConsumer,\n\t\tprivate readonly driver: MergeTreeRevertibleDriver,\n\t) {}\n\n\tpublic record(deltaArgs: IMergeTreeDeltaCallbackArgs): void {\n\t\tif (deltaArgs.deltaSegments.length > 0) {\n\t\t\t// If we are in the process of reverting, the `IRevertible.revert()` will provide the tracking\n\t\t\t// group so that we can preserve the original segment ranges as a single op/group as we move\n\t\t\t// ops between the undo <-> redo stacks.\n\t\t\tconst revertibles: MergeTreeDeltaRevertible[] = this.currentGroup ?? [];\n\t\t\tappendToMergeTreeDeltaRevertibles(deltaArgs, revertibles);\n\n\t\t\t// For SharedMatrix, each IRevertibles always holds a single row/col operation.\n\t\t\t// Therefore, 'currentOp' must either be undefined or equal to the current op.\n\t\t\tassert(\n\t\t\t\tthis.currentOp === undefined || this.currentOp === deltaArgs.operation,\n\t\t\t\t0x02a /* \"On vector undo, unexpected 'currentOp' type/state!\" */,\n\t\t\t);\n\t\t\tlet removeTrackingGroup: TrackingGroup | undefined;\n\t\t\tif (deltaArgs.operation === MergeTreeDeltaType.REMOVE) {\n\t\t\t\t// for removed segment we need a tracking group.\n\t\t\t\t// this is for a few reason:\n\t\t\t\t// 1. the handle for the row/column on the removed segment is still allocated,\n\t\t\t\t//\t\tand needs to be in order to process unacked ops sent before the remove.\n\t\t\t\t// 2. handles are freed on unlink(zamboni), but that also clears the row/column data.\n\t\t\t\t//\t\twhich we don't want to happen, so we can re-insert the cells when the row/col comes back.\n\t\t\t\t//\t\tthe tracking group prevents unlink.\n\t\t\t\t// 3. when we re-insert we need to find the old segment and clear their handles\n\t\t\t\t//\t\tso the new segment takes them over. there is no efficient look-up for this.\n\t\t\t\t//\t\tthe tracking group provides one.\n\t\t\t\tconst trackingGroup = (removeTrackingGroup =\n\t\t\t\t\tthis.currentRemoveTrackingGroup ?? new TrackingGroup());\n\t\t\t\tfor (const d of deltaArgs.deltaSegments)\n\t\t\t\t\td.segment.trackingCollection.link(trackingGroup);\n\t\t\t}\n\n\t\t\tswitch (deltaArgs.operation) {\n\t\t\t\tcase MergeTreeDeltaType.REMOVE:\n\t\t\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\t\t\tif (this.currentOp !== deltaArgs.operation) {\n\t\t\t\t\t\tthis.pushRevertible(revertibles, removeTrackingGroup);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"operation type not revertible\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If we are in the process of reverting, set 'currentOp' to remind ourselves not to push\n\t\t\t// another revertible until `IRevertable.revert()` finishes the current op and clears this\n\t\t\t// field.\n\t\t\tif (this.currentGroup !== undefined) {\n\t\t\t\tthis.currentOp ??= deltaArgs.operation;\n\t\t\t\tthis.currentRemoveTrackingGroup ??= removeTrackingGroup;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate pushRevertible(\n\t\trevertibles: MergeTreeDeltaRevertible[],\n\t\tremovedTrackingGroup: ITrackingGroup | undefined,\n\t): {\n\t\trevert: () => void;\n\t\tdiscard: () => void;\n\t} {\n\t\tconst reverter = {\n\t\t\trevert: (): void => {\n\t\t\t\tassert(\n\t\t\t\t\tthis.currentGroup === undefined && this.currentOp === undefined,\n\t\t\t\t\t0x02b /* \"Must not nest calls to IRevertible.revert()\" */,\n\t\t\t\t);\n\n\t\t\t\tthis.currentGroup = [];\n\n\t\t\t\ttry {\n\t\t\t\t\tif (removedTrackingGroup !== undefined) {\n\t\t\t\t\t\twhile (removedTrackingGroup.size > 0) {\n\t\t\t\t\t\t\tconst tracked = removedTrackingGroup.tracked[0];\n\t\t\t\t\t\t\tremovedTrackingGroup.unlink(tracked);\n\t\t\t\t\t\t\t// if there are groups tracked, this in a revert of a remove.\n\t\t\t\t\t\t\t// this means we are about to re-insert the row/column\n\t\t\t\t\t\t\t// with the same handle. We reuse the handle so the row/columns cells\n\t\t\t\t\t\t\t// get re-inserted too.\n\t\t\t\t\t\t\t// since a new segment will have the handle, we need to\n\t\t\t\t\t\t\t// remove it from the removed segment which was tracked\n\t\t\t\t\t\t\t(tracked as PermutationSegment).reset();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\trevertMergeTreeDeltaRevertibles(this.driver, revertibles);\n\t\t\t\t} finally {\n\t\t\t\t\tthis.currentOp = undefined;\n\t\t\t\t\tthis.currentGroup = undefined;\n\t\t\t\t\tthis.currentRemoveTrackingGroup = undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdiscard: (): void => {\n\t\t\t\tif (removedTrackingGroup !== undefined) {\n\t\t\t\t\twhile (removedTrackingGroup.size > 0) {\n\t\t\t\t\t\tremovedTrackingGroup.unlink(removedTrackingGroup.tracked[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdiscardMergeTreeDeltaRevertible(revertibles);\n\t\t\t},\n\t\t};\n\n\t\tthis.manager.pushToCurrentOperation(reverter);\n\n\t\treturn reverter;\n\t}\n}\n\nexport class MatrixUndoProvider<T> {\n\tconstructor(\n\t\tprivate readonly consumer: IUndoConsumer,\n\t\tprivate readonly matrix: SharedMatrix<T>,\n\t\tprivate readonly rows: PermutationVector,\n\t\tprivate readonly cols: PermutationVector,\n\t) {\n\t\trows.undo = new VectorUndoProvider(consumer, {\n\t\t\tannotateRange(): void {\n\t\t\t\tthrow new Error(\"not implemented\");\n\t\t\t},\n\t\t\tinsertFromSpec(pos, spec): void {\n\t\t\t\tmatrix._undoRemoveRows(pos, spec);\n\t\t\t},\n\t\t\tremoveRange(start, end): void {\n\t\t\t\tmatrix.removeRows(start, end - start);\n\t\t\t},\n\t\t});\n\t\tcols.undo = new VectorUndoProvider(consumer, {\n\t\t\tannotateRange(): void {\n\t\t\t\tthrow new Error(\"not implemented\");\n\t\t\t},\n\t\t\tinsertFromSpec(pos, spec): void {\n\t\t\t\tmatrix._undoRemoveCols(pos, spec);\n\t\t\t},\n\t\t\tremoveRange(start, end): void {\n\t\t\t\tmatrix.removeCols(start, end - start);\n\t\t\t},\n\t\t});\n\t}\n\n\tcellSet(rowHandle: Handle, colHandle: Handle, oldValue: MatrixItem<T>): void {\n\t\tassert(\n\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t0x02c /* \"On cellSet(), invalid row and/or column handles!\" */,\n\t\t);\n\n\t\tif (this.consumer !== undefined) {\n\t\t\tthis.consumer.pushToCurrentOperation({\n\t\t\t\trevert: () => {\n\t\t\t\t\tconst row = this.rows.handleToPosition(rowHandle);\n\t\t\t\t\tconst col = this.cols.handleToPosition(colHandle);\n\t\t\t\t\t// if the row/column no longer exists, we cannot set the cell\n\t\t\t\t\tif (row < this.matrix.rowCount && col < this.matrix.colCount) {\n\t\t\t\t\t\tthis.matrix.setCell(row, col, oldValue);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdiscard: () => {},\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"undoprovider.js","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAIN,kBAAkB,EAElB,aAAa,EACb,iCAAiC,EACjC,+BAA+B,EAC/B,+BAA+B,GAC/B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAe,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAM9D,MAAM,OAAO,kBAAkB;IAQ9B,YACkB,OAAsB,EACtB,MAAiC;QADjC,YAAO,GAAP,OAAO,CAAe;QACtB,WAAM,GAAN,MAAM,CAA2B;IAChD,CAAC;IAEG,MAAM,CAAC,SAAsC;QACnD,IAAI,SAAS,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxC,8FAA8F;YAC9F,4FAA4F;YAC5F,wCAAwC;YACxC,MAAM,WAAW,GAA+B,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;YACxE,iCAAiC,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;YAE1D,+EAA+E;YAC/E,8EAA8E;YAC9E,MAAM,CACL,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,SAAS,EACtE,KAAK,CAAC,0DAA0D,CAChE,CAAC;YACF,IAAI,mBAA8C,CAAC;YACnD,IAAI,SAAS,CAAC,SAAS,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;gBACvD,gDAAgD;gBAChD,4BAA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,CAAC,SAAS,CAAC,CAAC;oBAClD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;oBAClD,6DAA6D;oBAC7D,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;wBAC9D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;oBACzC,CAAC;gBACF,CAAC;gBACD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;aACjB,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IMergeTreeDeltaCallbackArgs,\n\ttype ITrackingGroup,\n\ttype MergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\ttype MergeTreeRevertibleDriver,\n\tTrackingGroup,\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\trevertMergeTreeDeltaRevertibles,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { type Handle, isHandleValid } from \"./handletable.js\";\nimport type { SharedMatrix } from \"./matrix.js\";\nimport type { MatrixItem } from \"./ops.js\";\nimport type { PermutationSegment, PermutationVector } from \"./permutationvector.js\";\nimport type { IUndoConsumer } from \"./types.js\";\n\nexport class VectorUndoProvider {\n\t// 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce\n\t// the recorded into a single IRevertable / tracking group as they move between the undo <->\n\t// redo stacks.\n\tprivate currentGroup?: MergeTreeDeltaRevertible[];\n\tprivate currentOp?: MergeTreeDeltaType;\n\tprivate currentRemoveTrackingGroup?: TrackingGroup;\n\n\tconstructor(\n\t\tprivate readonly manager: IUndoConsumer,\n\t\tprivate readonly driver: MergeTreeRevertibleDriver,\n\t) {}\n\n\tpublic record(deltaArgs: IMergeTreeDeltaCallbackArgs): void {\n\t\tif (deltaArgs.deltaSegments.length > 0) {\n\t\t\t// If we are in the process of reverting, the `IRevertible.revert()` will provide the tracking\n\t\t\t// group so that we can preserve the original segment ranges as a single op/group as we move\n\t\t\t// ops between the undo <-> redo stacks.\n\t\t\tconst revertibles: MergeTreeDeltaRevertible[] = this.currentGroup ?? [];\n\t\t\tappendToMergeTreeDeltaRevertibles(deltaArgs, revertibles);\n\n\t\t\t// For SharedMatrix, each IRevertibles always holds a single row/col operation.\n\t\t\t// Therefore, 'currentOp' must either be undefined or equal to the current op.\n\t\t\tassert(\n\t\t\t\tthis.currentOp === undefined || this.currentOp === deltaArgs.operation,\n\t\t\t\t0x02a /* \"On vector undo, unexpected 'currentOp' type/state!\" */,\n\t\t\t);\n\t\t\tlet removeTrackingGroup: TrackingGroup | undefined;\n\t\t\tif (deltaArgs.operation === MergeTreeDeltaType.REMOVE) {\n\t\t\t\t// for removed segment we need a tracking group.\n\t\t\t\t// this is for a few reason:\n\t\t\t\t// 1. the handle for the row/column on the removed segment is still allocated,\n\t\t\t\t//\t\tand needs to be in order to process unacked ops sent before the remove.\n\t\t\t\t// 2. handles are freed on unlink(zamboni), but that also clears the row/column data.\n\t\t\t\t//\t\twhich we don't want to happen, so we can re-insert the cells when the row/col comes back.\n\t\t\t\t//\t\tthe tracking group prevents unlink.\n\t\t\t\t// 3. when we re-insert we need to find the old segment and clear their handles\n\t\t\t\t//\t\tso the new segment takes them over. there is no efficient look-up for this.\n\t\t\t\t//\t\tthe tracking group provides one.\n\t\t\t\tconst trackingGroup = (removeTrackingGroup =\n\t\t\t\t\tthis.currentRemoveTrackingGroup ?? new TrackingGroup());\n\t\t\t\tfor (const d of deltaArgs.deltaSegments)\n\t\t\t\t\td.segment.trackingCollection.link(trackingGroup);\n\t\t\t}\n\n\t\t\tswitch (deltaArgs.operation) {\n\t\t\t\tcase MergeTreeDeltaType.REMOVE:\n\t\t\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\t\t\tif (this.currentOp !== deltaArgs.operation) {\n\t\t\t\t\t\tthis.pushRevertible(revertibles, removeTrackingGroup);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"operation type not revertible\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If we are in the process of reverting, set 'currentOp' to remind ourselves not to push\n\t\t\t// another revertible until `IRevertable.revert()` finishes the current op and clears this\n\t\t\t// field.\n\t\t\tif (this.currentGroup !== undefined) {\n\t\t\t\tthis.currentOp ??= deltaArgs.operation;\n\t\t\t\tthis.currentRemoveTrackingGroup ??= removeTrackingGroup;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate pushRevertible(\n\t\trevertibles: MergeTreeDeltaRevertible[],\n\t\tremovedTrackingGroup: ITrackingGroup | undefined,\n\t): {\n\t\trevert: () => void;\n\t\tdiscard: () => void;\n\t} {\n\t\tconst reverter = {\n\t\t\trevert: (): void => {\n\t\t\t\tassert(\n\t\t\t\t\tthis.currentGroup === undefined && this.currentOp === undefined,\n\t\t\t\t\t0x02b /* \"Must not nest calls to IRevertible.revert()\" */,\n\t\t\t\t);\n\n\t\t\t\tthis.currentGroup = [];\n\n\t\t\t\ttry {\n\t\t\t\t\tif (removedTrackingGroup !== undefined) {\n\t\t\t\t\t\twhile (removedTrackingGroup.size > 0) {\n\t\t\t\t\t\t\tconst tracked = removedTrackingGroup.tracked[0];\n\t\t\t\t\t\t\tremovedTrackingGroup.unlink(tracked);\n\t\t\t\t\t\t\t// if there are groups tracked, this in a revert of a remove.\n\t\t\t\t\t\t\t// this means we are about to re-insert the row/column\n\t\t\t\t\t\t\t// with the same handle. We reuse the handle so the row/columns cells\n\t\t\t\t\t\t\t// get re-inserted too.\n\t\t\t\t\t\t\t// since a new segment will have the handle, we need to\n\t\t\t\t\t\t\t// remove it from the removed segment which was tracked\n\t\t\t\t\t\t\t(tracked as PermutationSegment).reset();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\trevertMergeTreeDeltaRevertibles(this.driver, revertibles);\n\t\t\t\t} finally {\n\t\t\t\t\tthis.currentOp = undefined;\n\t\t\t\t\tthis.currentGroup = undefined;\n\t\t\t\t\tthis.currentRemoveTrackingGroup = undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdiscard: (): void => {\n\t\t\t\tif (removedTrackingGroup !== undefined) {\n\t\t\t\t\twhile (removedTrackingGroup.size > 0) {\n\t\t\t\t\t\tremovedTrackingGroup.unlink(removedTrackingGroup.tracked[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdiscardMergeTreeDeltaRevertible(revertibles);\n\t\t\t},\n\t\t};\n\n\t\tthis.manager.pushToCurrentOperation(reverter);\n\n\t\treturn reverter;\n\t}\n}\n\nexport class MatrixUndoProvider<T> {\n\tconstructor(\n\t\tprivate readonly consumer: IUndoConsumer,\n\t\tprivate readonly matrix: SharedMatrix<T>,\n\t\tprivate readonly rows: PermutationVector,\n\t\tprivate readonly cols: PermutationVector,\n\t) {\n\t\trows.undo = new VectorUndoProvider(consumer, {\n\t\t\tannotateRange(): void {\n\t\t\t\tthrow new Error(\"not implemented\");\n\t\t\t},\n\t\t\tinsertFromSpec(pos, spec): void {\n\t\t\t\tmatrix._undoRemoveRows(pos, spec);\n\t\t\t},\n\t\t\tremoveRange(start, end): void {\n\t\t\t\tmatrix.removeRows(start, end - start);\n\t\t\t},\n\t\t});\n\t\tcols.undo = new VectorUndoProvider(consumer, {\n\t\t\tannotateRange(): void {\n\t\t\t\tthrow new Error(\"not implemented\");\n\t\t\t},\n\t\t\tinsertFromSpec(pos, spec): void {\n\t\t\t\tmatrix._undoRemoveCols(pos, spec);\n\t\t\t},\n\t\t\tremoveRange(start, end): void {\n\t\t\t\tmatrix.removeCols(start, end - start);\n\t\t\t},\n\t\t});\n\t}\n\n\tcellSet(rowHandle: Handle, colHandle: Handle, oldValue: MatrixItem<T>): void {\n\t\tassert(\n\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t0x02c /* \"On cellSet(), invalid row and/or column handles!\" */,\n\t\t);\n\n\t\tif (this.consumer !== undefined) {\n\t\t\tthis.consumer.pushToCurrentOperation({\n\t\t\t\trevert: () => {\n\t\t\t\t\tconst row = this.rows.handleToPosition(rowHandle);\n\t\t\t\t\tconst col = this.cols.handleToPosition(colHandle);\n\t\t\t\t\t// if the row/column no longer exists, we cannot set the cell\n\t\t\t\t\tif (row < this.matrix.rowCount && col < this.matrix.colCount) {\n\t\t\t\t\t\tthis.matrix.setCell(row, col, oldValue);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdiscard: () => {},\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/matrix",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.51.0-347100",
|
|
4
4
|
"description": "Distributed matrix",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -81,17 +81,17 @@
|
|
|
81
81
|
"temp-directory": "nyc/.nyc_output"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@fluid-internal/client-utils": "
|
|
85
|
-
"@fluidframework/core-interfaces": "
|
|
86
|
-
"@fluidframework/core-utils": "
|
|
87
|
-
"@fluidframework/datastore-definitions": "
|
|
88
|
-
"@fluidframework/driver-definitions": "
|
|
89
|
-
"@fluidframework/driver-utils": "
|
|
90
|
-
"@fluidframework/merge-tree": "
|
|
91
|
-
"@fluidframework/runtime-definitions": "
|
|
92
|
-
"@fluidframework/runtime-utils": "
|
|
93
|
-
"@fluidframework/shared-object-base": "
|
|
94
|
-
"@fluidframework/telemetry-utils": "
|
|
84
|
+
"@fluid-internal/client-utils": "2.51.0-347100",
|
|
85
|
+
"@fluidframework/core-interfaces": "2.51.0-347100",
|
|
86
|
+
"@fluidframework/core-utils": "2.51.0-347100",
|
|
87
|
+
"@fluidframework/datastore-definitions": "2.51.0-347100",
|
|
88
|
+
"@fluidframework/driver-definitions": "2.51.0-347100",
|
|
89
|
+
"@fluidframework/driver-utils": "2.51.0-347100",
|
|
90
|
+
"@fluidframework/merge-tree": "2.51.0-347100",
|
|
91
|
+
"@fluidframework/runtime-definitions": "2.51.0-347100",
|
|
92
|
+
"@fluidframework/runtime-utils": "2.51.0-347100",
|
|
93
|
+
"@fluidframework/shared-object-base": "2.51.0-347100",
|
|
94
|
+
"@fluidframework/telemetry-utils": "2.51.0-347100",
|
|
95
95
|
"@tiny-calc/nano": "0.0.0-alpha.5",
|
|
96
96
|
"double-ended-queue": "^2.1.0-0",
|
|
97
97
|
"tslib": "^1.10.0"
|
|
@@ -99,17 +99,17 @@
|
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
101
101
|
"@biomejs/biome": "~1.9.3",
|
|
102
|
-
"@fluid-internal/mocha-test-setup": "
|
|
103
|
-
"@fluid-private/stochastic-test-utils": "
|
|
104
|
-
"@fluid-private/test-dds-utils": "
|
|
102
|
+
"@fluid-internal/mocha-test-setup": "2.51.0-347100",
|
|
103
|
+
"@fluid-private/stochastic-test-utils": "2.51.0-347100",
|
|
104
|
+
"@fluid-private/test-dds-utils": "2.51.0-347100",
|
|
105
105
|
"@fluid-tools/benchmark": "^0.51.0",
|
|
106
106
|
"@fluid-tools/build-cli": "^0.56.0",
|
|
107
107
|
"@fluidframework/build-common": "^2.0.3",
|
|
108
108
|
"@fluidframework/build-tools": "^0.56.0",
|
|
109
|
-
"@fluidframework/container-definitions": "
|
|
109
|
+
"@fluidframework/container-definitions": "2.51.0-347100",
|
|
110
110
|
"@fluidframework/eslint-config-fluid": "^5.7.4",
|
|
111
|
-
"@fluidframework/matrix-previous": "npm:@fluidframework/matrix@2.
|
|
112
|
-
"@fluidframework/test-runtime-utils": "
|
|
111
|
+
"@fluidframework/matrix-previous": "npm:@fluidframework/matrix@2.50.0",
|
|
112
|
+
"@fluidframework/test-runtime-utils": "2.51.0-347100",
|
|
113
113
|
"@microsoft/api-extractor": "7.52.8",
|
|
114
114
|
"@tiny-calc/micro": "0.0.0-alpha.5",
|
|
115
115
|
"@types/double-ended-queue": "^2.1.0",
|
package/src/handlecache.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
/* eslint-disable no-bitwise */
|
|
7
7
|
|
|
8
8
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
9
|
-
import { IVectorConsumer } from "@tiny-calc/nano";
|
|
9
|
+
import type { IVectorConsumer } from "@tiny-calc/nano";
|
|
10
10
|
|
|
11
|
-
import { Handle, isHandleValid } from "./handletable.js";
|
|
12
|
-
import { PermutationSegment, PermutationVector } from "./permutationvector.js";
|
|
11
|
+
import { type Handle, isHandleValid } from "./handletable.js";
|
|
12
|
+
import type { PermutationSegment, PermutationVector } from "./permutationvector.js";
|
|
13
13
|
import { ensureRange } from "./range.js";
|
|
14
14
|
|
|
15
15
|
/**
|
package/src/index.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export { ISharedMatrixEvents, ISharedMatrix } from "./matrix.js";
|
|
7
|
-
export { MatrixItem } from "./ops.js";
|
|
6
|
+
export type { ISharedMatrixEvents, ISharedMatrix } from "./matrix.js";
|
|
7
|
+
export type { MatrixItem } from "./ops.js";
|
|
8
8
|
export { SharedMatrixFactory, SharedMatrix } from "./runtime.js";
|
|
9
9
|
|
|
10
10
|
// TODO: We temporarily duplicate these contracts from 'framework/undo-redo' to unblock development
|
|
11
11
|
// of SharedMatrix undo while we decide on the correct layering for undo.
|
|
12
|
-
export { IUndoConsumer, IRevertible } from "./types.js";
|
|
12
|
+
export type { IUndoConsumer, IRevertible } from "./types.js";
|
package/src/matrix.ts
CHANGED
|
@@ -3,41 +3,41 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type {
|
|
7
7
|
IEvent,
|
|
8
8
|
IEventThisPlaceHolder,
|
|
9
|
-
|
|
9
|
+
IEventProvider,
|
|
10
10
|
} from "@fluidframework/core-interfaces";
|
|
11
11
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
12
|
-
import {
|
|
12
|
+
import type {
|
|
13
13
|
IChannelAttributes,
|
|
14
14
|
IFluidDataStoreRuntime,
|
|
15
|
-
|
|
15
|
+
IChannel,
|
|
16
16
|
IChannelStorageService,
|
|
17
17
|
} from "@fluidframework/datastore-definitions/internal";
|
|
18
|
-
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
18
|
+
import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
19
19
|
import {
|
|
20
|
-
Client,
|
|
21
|
-
IJSONSegment,
|
|
22
|
-
IMergeTreeOp,
|
|
20
|
+
type Client,
|
|
21
|
+
type IJSONSegment,
|
|
22
|
+
type IMergeTreeOp,
|
|
23
23
|
type ISegmentInternal,
|
|
24
24
|
type LocalReferencePosition,
|
|
25
25
|
MergeTreeDeltaType,
|
|
26
26
|
ReferenceType,
|
|
27
27
|
segmentIsRemoved,
|
|
28
28
|
} from "@fluidframework/merge-tree/internal";
|
|
29
|
-
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
|
|
29
|
+
import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
|
|
30
30
|
import {
|
|
31
31
|
ObjectStoragePartition,
|
|
32
32
|
SummaryTreeBuilder,
|
|
33
33
|
} from "@fluidframework/runtime-utils/internal";
|
|
34
34
|
import {
|
|
35
|
-
IFluidSerializer,
|
|
36
|
-
ISharedObjectEvents,
|
|
35
|
+
type IFluidSerializer,
|
|
36
|
+
type ISharedObjectEvents,
|
|
37
37
|
SharedObject,
|
|
38
38
|
} from "@fluidframework/shared-object-base/internal";
|
|
39
39
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
40
|
-
import {
|
|
40
|
+
import type {
|
|
41
41
|
IMatrixConsumer,
|
|
42
42
|
IMatrixProducer,
|
|
43
43
|
IMatrixReader,
|
|
@@ -46,20 +46,20 @@ import {
|
|
|
46
46
|
import Deque from "double-ended-queue";
|
|
47
47
|
|
|
48
48
|
import type { HandleCache } from "./handlecache.js";
|
|
49
|
-
import { Handle, isHandleValid } from "./handletable.js";
|
|
49
|
+
import { type Handle, isHandleValid } from "./handletable.js";
|
|
50
50
|
import {
|
|
51
|
-
ISetOp,
|
|
52
|
-
MatrixItem,
|
|
51
|
+
type ISetOp,
|
|
52
|
+
type MatrixItem,
|
|
53
53
|
MatrixOp,
|
|
54
|
-
MatrixSetOrVectorOp,
|
|
54
|
+
type MatrixSetOrVectorOp,
|
|
55
55
|
SnapshotPath,
|
|
56
|
-
VectorOp,
|
|
56
|
+
type VectorOp,
|
|
57
57
|
} from "./ops.js";
|
|
58
58
|
import { PermutationVector, reinsertSegmentIntoVector } from "./permutationvector.js";
|
|
59
59
|
import { ensureRange } from "./range.js";
|
|
60
60
|
import { deserializeBlob } from "./serialization.js";
|
|
61
61
|
import { SparseArray2D, type RecurArray } from "./sparsearray2d.js";
|
|
62
|
-
import { IUndoConsumer } from "./types.js";
|
|
62
|
+
import type { IUndoConsumer } from "./types.js";
|
|
63
63
|
import { MatrixUndoProvider } from "./undoprovider.js";
|
|
64
64
|
|
|
65
65
|
interface ISetOpMetadata {
|
package/src/ops.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* Use caustion when making changes and consider backward and forward compatibility of your changes!
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { Serializable } from "@fluidframework/datastore-definitions/internal";
|
|
12
|
-
import { IMergeTreeOp } from "@fluidframework/merge-tree/internal";
|
|
11
|
+
import type { Serializable } from "@fluidframework/datastore-definitions/internal";
|
|
12
|
+
import type { IMergeTreeOp } from "@fluidframework/merge-tree/internal";
|
|
13
13
|
|
|
14
14
|
export enum MatrixOp {
|
|
15
15
|
spliceCols,
|
package/src/packageVersion.ts
CHANGED
package/src/permutationvector.ts
CHANGED
|
@@ -3,39 +3,39 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IFluidHandle, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { IFluidHandle, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
|
-
import {
|
|
8
|
+
import type {
|
|
9
9
|
IFluidDataStoreRuntime,
|
|
10
10
|
IChannelStorageService,
|
|
11
11
|
} from "@fluidframework/datastore-definitions/internal";
|
|
12
|
-
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
12
|
+
import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
13
13
|
import {
|
|
14
14
|
BaseSegment,
|
|
15
15
|
Client,
|
|
16
|
-
IJSONSegment,
|
|
17
|
-
IMergeTreeDeltaCallbackArgs,
|
|
18
|
-
IMergeTreeDeltaOpArgs,
|
|
19
|
-
IMergeTreeMaintenanceCallbackArgs,
|
|
20
|
-
ISegment,
|
|
16
|
+
type IJSONSegment,
|
|
17
|
+
type IMergeTreeDeltaCallbackArgs,
|
|
18
|
+
type IMergeTreeDeltaOpArgs,
|
|
19
|
+
type IMergeTreeMaintenanceCallbackArgs,
|
|
20
|
+
type ISegment,
|
|
21
21
|
MergeTreeDeltaType,
|
|
22
22
|
MergeTreeMaintenanceType,
|
|
23
23
|
segmentIsRemoved,
|
|
24
24
|
type IMergeTreeInsertMsg,
|
|
25
25
|
type IMergeTreeRemoveMsg,
|
|
26
26
|
} from "@fluidframework/merge-tree/internal";
|
|
27
|
-
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
|
|
27
|
+
import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
|
|
28
28
|
import {
|
|
29
29
|
ObjectStoragePartition,
|
|
30
30
|
SummaryTreeBuilder,
|
|
31
31
|
} from "@fluidframework/runtime-utils/internal";
|
|
32
|
-
import { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
32
|
+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
33
33
|
import { createChildLogger } from "@fluidframework/telemetry-utils/internal";
|
|
34
34
|
|
|
35
35
|
import { HandleCache } from "./handlecache.js";
|
|
36
36
|
import { Handle, HandleTable, isHandleValid } from "./handletable.js";
|
|
37
37
|
import { deserializeBlob } from "./serialization.js";
|
|
38
|
-
import { VectorUndoProvider } from "./undoprovider.js";
|
|
38
|
+
import type { VectorUndoProvider } from "./undoprovider.js";
|
|
39
39
|
|
|
40
40
|
const enum SnapshotPath {
|
|
41
41
|
segments = "segments",
|
|
@@ -125,7 +125,6 @@ export class PermutationSegment extends BaseSegment {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
// eslint-disable-next-line import/no-deprecated
|
|
129
128
|
export class PermutationVector extends Client {
|
|
130
129
|
private handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.
|
|
131
130
|
public readonly handleCache = new HandleCache(this);
|
package/src/runtime.ts
CHANGED
package/src/serialization.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { bufferToString } from "@fluid-internal/client-utils";
|
|
7
|
-
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
8
|
-
import {
|
|
7
|
+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
8
|
+
import type {
|
|
9
9
|
IChannelStorageService,
|
|
10
10
|
Serializable,
|
|
11
11
|
} from "@fluidframework/datastore-definitions/internal";
|
|
12
12
|
import { BlobTreeEntry } from "@fluidframework/driver-utils/internal";
|
|
13
|
-
import { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
13
|
+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
14
14
|
|
|
15
15
|
export const serializeBlob = <T>(
|
|
16
16
|
handle: IFluidHandle,
|
|
@@ -28,6 +28,5 @@ export async function deserializeBlob(
|
|
|
28
28
|
): Promise<any> {
|
|
29
29
|
const blob = await storage.readBlob(path);
|
|
30
30
|
const utf8 = bufferToString(blob, "utf8");
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
32
31
|
return serializer.parse(utf8);
|
|
33
32
|
}
|
package/src/sparsearray2d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/* eslint-disable no-bitwise */
|
|
7
7
|
|
|
8
|
-
import { IMatrixReader, IMatrixWriter,
|
|
8
|
+
import type { IMatrixReader, IMatrixWriter, IMatrixProducer } from "@tiny-calc/nano";
|
|
9
9
|
|
|
10
10
|
// Build a lookup table that maps a uint8 to the corresponding uint16 where 0s
|
|
11
11
|
// are interleaved between the original bits. (e.g., 1111... -> 01010101...).
|
package/src/undoprovider.ts
CHANGED
|
@@ -5,22 +5,22 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import {
|
|
8
|
-
IMergeTreeDeltaCallbackArgs,
|
|
9
|
-
ITrackingGroup,
|
|
10
|
-
MergeTreeDeltaRevertible,
|
|
8
|
+
type IMergeTreeDeltaCallbackArgs,
|
|
9
|
+
type ITrackingGroup,
|
|
10
|
+
type MergeTreeDeltaRevertible,
|
|
11
11
|
MergeTreeDeltaType,
|
|
12
|
-
MergeTreeRevertibleDriver,
|
|
12
|
+
type MergeTreeRevertibleDriver,
|
|
13
13
|
TrackingGroup,
|
|
14
14
|
appendToMergeTreeDeltaRevertibles,
|
|
15
15
|
discardMergeTreeDeltaRevertible,
|
|
16
16
|
revertMergeTreeDeltaRevertibles,
|
|
17
17
|
} from "@fluidframework/merge-tree/internal";
|
|
18
18
|
|
|
19
|
-
import { Handle, isHandleValid } from "./handletable.js";
|
|
20
|
-
import { SharedMatrix } from "./matrix.js";
|
|
21
|
-
import { MatrixItem } from "./ops.js";
|
|
22
|
-
import { PermutationSegment, PermutationVector } from "./permutationvector.js";
|
|
23
|
-
import { IUndoConsumer } from "./types.js";
|
|
19
|
+
import { type Handle, isHandleValid } from "./handletable.js";
|
|
20
|
+
import type { SharedMatrix } from "./matrix.js";
|
|
21
|
+
import type { MatrixItem } from "./ops.js";
|
|
22
|
+
import type { PermutationSegment, PermutationVector } from "./permutationvector.js";
|
|
23
|
+
import type { IUndoConsumer } from "./types.js";
|
|
24
24
|
|
|
25
25
|
export class VectorUndoProvider {
|
|
26
26
|
// 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce
|