@fluid-experimental/ot 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
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.js +5 -7
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/ot.d.ts.map +1 -1
- package/dist/ot.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/lib/ot.d.ts.map +1 -1
- package/lib/ot.js +1 -1
- package/lib/ot.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/package.json +47 -45
- package/prettier.config.cjs +1 -1
- package/src/ot.ts +147 -138
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/.eslintrc.js
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
}
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
|
|
8
|
+
parserOptions: {
|
|
9
|
+
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
|
+
},
|
|
11
|
+
};
|
package/.mocharc.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
"use strict";
|
|
7
7
|
|
|
8
|
-
const getFluidTestMochaConfig = require(
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
|
|
9
9
|
|
|
10
10
|
const packageDir = __dirname;
|
|
11
11
|
const config = getFluidTestMochaConfig(packageDir);
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-common.json"
|
|
4
4
|
}
|
package/dist/ot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ot.d.ts","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,
|
|
1
|
+
{"version":3,"file":"ot.d.ts","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAEN,gBAAgB,EAChB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAQ5C,8BAAsB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAE,SAAQ,YAAY;IAC/D;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA+B;IAE5D;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,sEAAsE;IACtE,OAAO,CAAC,MAAM,CAAS;IAEvB;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,UAAU,CAAS;gBAG1B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,kBAAkB,EAC9B,YAAY,EAAE,MAAM;IAOrB,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG;IAavB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,MAAM;IAE5D;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG,GAAG;IAE7D,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;cAO5D,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxE,SAAS,CAAC,YAAY;IAEtB,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO;IA4CxE,SAAS,KAAK,KAAK,WAclB;IAED,SAAS,CAAC,cAAc;CAGxB"}
|
package/dist/ot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ot.js","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsE;AAQtE,
|
|
1
|
+
{"version":3,"file":"ot.js","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsE;AAQtE,2EAI4C;AAQ5C,MAAsB,QAAsB,SAAQ,iCAAY;IAyB/D,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EAC9B,YAAoB;QAEpB,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QA9B7C;;;;WAIG;QACc,iBAAY,GAA4B,EAAE,CAAC;QAE5D;;;;WAIG;QACc,eAAU,GAAU,EAAE,CAAC;QAUhC,eAAU,GAAG,KAAK,CAAC;QAU1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC;IACzC,CAAC;IAES,KAAK,CAAC,EAAO;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,C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IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;YAEzB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;aAC5C;YAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;SACxB;QAED,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AAzID,4BAyIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, bufferToString } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\n\ninterface ISequencedOpInfo<TOp> {\n\tclient: string;\n\tseq: number;\n\top: TOp;\n}\n\nexport abstract class SharedOT<TState, TOp> extends SharedObject {\n\t/**\n\t * Queue of sequenced ops that are above minSeq. Used by 'processCore' to\n\t * adjust incoming ops to account for prior ops that the sender didn't know about\n\t * at the time they submitted their op.\n\t */\n\tprivate readonly sequencedOps: ISequencedOpInfo<TOp>[] = [];\n\n\t/**\n\t * Queue of local pending ops that have not yet been ACKed by the service. Used\n\t * to lazily rebuild the \"local\" state cache when it is invalidated by interleaved\n\t * remote ops.\n\t */\n\tprivate readonly pendingOps: TOp[] = [];\n\n\t/** The \"global\" state is the result of applying all sequenced ops. */\n\tprivate global: TState;\n\n\t/**\n\t * Lazily cached result of optimistically applying pendingOps on top of the current\n\t * \"global\" state.\n\t */\n\tprivate local: TState;\n\tprivate localDirty = false;\n\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tinitialValue: TState,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_ot_\");\n\n\t\tthis.global = this.local = initialValue;\n\t}\n\n\tprotected apply(op: TOp) {\n\t\tthis.local = this.applyCore(this.state, op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\tthis.global = this.local;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pendingOps.push(op);\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\t/**\n\t * Apply the given 'op' to the provided 'state', producing a new instance of state.\n\t */\n\tprotected abstract applyCore(state: TState, op: TOp): TState;\n\n\t/**\n\t * Transform the 'input' op to adjust for the earlier 'transform' op.\n\t */\n\tprotected abstract transform(input: TOp, transform: TOp): TOp;\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Summarizer must not have locally pending changes.\n\t\tassert(this.pendingOps.length === 0, 0);\n\n\t\treturn createSingleBlobSummary(\"header\", serializer.stringify(this.global, this.handle));\n\t}\n\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst blob = await storage.readBlob(\"header\");\n\t\tconst rawContent = bufferToString(blob, \"utf8\");\n\t\tthis.global = this.local = this.serializer.parse(rawContent);\n\t}\n\n\tprotected onDisconnect() {}\n\n\tprotected processCore(message: ISequencedDocumentMessage, local: boolean) {\n\t\t// Discard any sequenced ops that are now below the minimum sequence number.\n\t\tconst minSeq = this.runtime.deltaManager.minimumSequenceNumber;\n\t\twhile (this.sequencedOps[0]?.seq < minSeq) {\n\t\t\tthis.sequencedOps.shift();\n\t\t}\n\n\t\tlet remoteOp = message.contents;\n\t\tconst messageSeq = message.sequenceNumber;\n\t\tconst remoteRefSeq = message.referenceSequenceNumber;\n\t\tconst remoteClient = message.clientId;\n\n\t\t// Adjust the incoming sequenced op to account for prior sequenced ops that the\n\t\t// sender hadn't yet seen at the time they sent the op.\n\t\tfor (const { op, seq, client } of this.sequencedOps) {\n\t\t\tif (remoteRefSeq < seq && remoteClient !== client) {\n\t\t\t\tremoteOp = this.transform(remoteOp, op);\n\t\t\t}\n\t\t}\n\n\t\t// Retain the adjusted op in order to adjust future remote ops.\n\t\tthis.sequencedOps.push({ seq: messageSeq, client: remoteClient, op: remoteOp });\n\n\t\t// The incoming sequenced op is now part of the \"global\" state. Apply it to \"this.global\"\n\t\t// now.\n\t\t//\n\t\t// TODO: If the op is local, we could defer applying the remoteOp and wait and see if\n\t\t// the global state catches up with our local state.\n\t\tthis.global = this.applyCore(this.global, remoteOp);\n\n\t\tif (local) {\n\t\t\tthis.pendingOps.shift();\n\t\t} else {\n\t\t\t// Our optimistic local cache (if any) did not account for the incoming op.\n\t\t\tthis.localDirty = true;\n\n\t\t\t// Adjust our queue of locally pending ops to account for the incoming op so that they\n\t\t\t// may be reapplied to the global state if needed.\n\t\t\tfor (let i = 0; i < this.pendingOps.length; i++) {\n\t\t\t\tthis.pendingOps[i] = this.transform(this.pendingOps[i], remoteOp);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected get state() {\n\t\t// If the locally cached state is dirty, reset it to the global state and reapply our\n\t\t// pending ops to bring it up to date.\n\t\tif (this.localDirty) {\n\t\t\tthis.local = this.global;\n\n\t\t\tfor (const op of this.pendingOps) {\n\t\t\t\tthis.local = this.applyCore(this.local, op);\n\t\t\t}\n\n\t\t\tthis.localDirty = false;\n\t\t}\n\n\t\treturn this.local;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluid-experimental/ot";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-dev.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.4.1.0.148229";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluid-experimental/ot";
|
|
11
|
-
exports.pkgVersion = "2.0.0-dev.
|
|
11
|
+
exports.pkgVersion = "2.0.0-dev.4.1.0.148229";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,wBAAwB,CAAC;AACnC,QAAA,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/ot\";\nexport const pkgVersion = \"2.0.0-dev.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,wBAAwB,CAAC;AACnC,QAAA,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/ot\";\nexport const pkgVersion = \"2.0.0-dev.4.1.0.148229\";\n"]}
|
package/lib/ot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ot.d.ts","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,
|
|
1
|
+
{"version":3,"file":"ot.d.ts","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAEN,gBAAgB,EAChB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAQ5C,8BAAsB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAE,SAAQ,YAAY;IAC/D;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA+B;IAE5D;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,sEAAsE;IACtE,OAAO,CAAC,MAAM,CAAS;IAEvB;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,UAAU,CAAS;gBAG1B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,kBAAkB,EAC9B,YAAY,EAAE,MAAM;IAOrB,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG;IAavB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,MAAM;IAE5D;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG,GAAG;IAE7D,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;cAO5D,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxE,SAAS,CAAC,YAAY;IAEtB,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO;IA4CxE,SAAS,KAAK,KAAK,WAclB;IAED,SAAS,CAAC,cAAc;CAGxB"}
|
package/lib/ot.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { assert, bufferToString } from "@fluidframework/common-utils";
|
|
6
|
-
import { createSingleBlobSummary, SharedObject } from "@fluidframework/shared-object-base";
|
|
6
|
+
import { createSingleBlobSummary, SharedObject, } from "@fluidframework/shared-object-base";
|
|
7
7
|
export class SharedOT extends SharedObject {
|
|
8
8
|
constructor(id, runtime, attributes, initialValue) {
|
|
9
9
|
super(id, runtime, attributes, "fluid_ot_");
|
package/lib/ot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ot.js","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQtE,OAAO,
|
|
1
|
+
{"version":3,"file":"ot.js","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQtE,OAAO,EACN,uBAAuB,EAEvB,YAAY,GACZ,MAAM,oCAAoC,CAAC;AAQ5C,MAAM,OAAgB,QAAsB,SAAQ,YAAY;IAyB/D,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EAC9B,YAAoB;QAEpB,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,WAA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AG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAChD,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;aAClE;SACD;IACF,CAAC;IAED,IAAc,KAAK;QAClB,qFAAqF;QACrF,sCAAsC;QACtC,IAAI,IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;YAEzB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;aAC5C;YAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;SACxB;QAED,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, bufferToString } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\n\ninterface ISequencedOpInfo<TOp> {\n\tclient: string;\n\tseq: number;\n\top: TOp;\n}\n\nexport abstract class SharedOT<TState, TOp> extends SharedObject {\n\t/**\n\t * Queue of sequenced ops that are above minSeq. Used by 'processCore' to\n\t * adjust incoming ops to account for prior ops that the sender didn't know about\n\t * at the time they submitted their op.\n\t */\n\tprivate readonly sequencedOps: ISequencedOpInfo<TOp>[] = [];\n\n\t/**\n\t * Queue of local pending ops that have not yet been ACKed by the service. Used\n\t * to lazily rebuild the \"local\" state cache when it is invalidated by interleaved\n\t * remote ops.\n\t */\n\tprivate readonly pendingOps: TOp[] = [];\n\n\t/** The \"global\" state is the result of applying all sequenced ops. */\n\tprivate global: TState;\n\n\t/**\n\t * Lazily cached result of optimistically applying pendingOps on top of the current\n\t * \"global\" state.\n\t */\n\tprivate local: TState;\n\tprivate localDirty = false;\n\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tinitialValue: TState,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_ot_\");\n\n\t\tthis.global = this.local = initialValue;\n\t}\n\n\tprotected apply(op: TOp) {\n\t\tthis.local = this.applyCore(this.state, op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\tthis.global = this.local;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pendingOps.push(op);\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\t/**\n\t * Apply the given 'op' to the provided 'state', producing a new instance of state.\n\t */\n\tprotected abstract applyCore(state: TState, op: TOp): TState;\n\n\t/**\n\t * Transform the 'input' op to adjust for the earlier 'transform' op.\n\t */\n\tprotected abstract transform(input: TOp, transform: TOp): TOp;\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Summarizer must not have locally pending changes.\n\t\tassert(this.pendingOps.length === 0, 0);\n\n\t\treturn createSingleBlobSummary(\"header\", serializer.stringify(this.global, this.handle));\n\t}\n\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst blob = await storage.readBlob(\"header\");\n\t\tconst rawContent = bufferToString(blob, \"utf8\");\n\t\tthis.global = this.local = this.serializer.parse(rawContent);\n\t}\n\n\tprotected onDisconnect() {}\n\n\tprotected processCore(message: ISequencedDocumentMessage, local: boolean) {\n\t\t// Discard any sequenced ops that are now below the minimum sequence number.\n\t\tconst minSeq = this.runtime.deltaManager.minimumSequenceNumber;\n\t\twhile (this.sequencedOps[0]?.seq < minSeq) {\n\t\t\tthis.sequencedOps.shift();\n\t\t}\n\n\t\tlet remoteOp = message.contents;\n\t\tconst messageSeq = message.sequenceNumber;\n\t\tconst remoteRefSeq = message.referenceSequenceNumber;\n\t\tconst remoteClient = message.clientId;\n\n\t\t// Adjust the incoming sequenced op to account for prior sequenced ops that the\n\t\t// sender hadn't yet seen at the time they sent the op.\n\t\tfor (const { op, seq, client } of this.sequencedOps) {\n\t\t\tif (remoteRefSeq < seq && remoteClient !== client) {\n\t\t\t\tremoteOp = this.transform(remoteOp, op);\n\t\t\t}\n\t\t}\n\n\t\t// Retain the adjusted op in order to adjust future remote ops.\n\t\tthis.sequencedOps.push({ seq: messageSeq, client: remoteClient, op: remoteOp });\n\n\t\t// The incoming sequenced op is now part of the \"global\" state. Apply it to \"this.global\"\n\t\t// now.\n\t\t//\n\t\t// TODO: If the op is local, we could defer applying the remoteOp and wait and see if\n\t\t// the global state catches up with our local state.\n\t\tthis.global = this.applyCore(this.global, remoteOp);\n\n\t\tif (local) {\n\t\t\tthis.pendingOps.shift();\n\t\t} else {\n\t\t\t// Our optimistic local cache (if any) did not account for the incoming op.\n\t\t\tthis.localDirty = true;\n\n\t\t\t// Adjust our queue of locally pending ops to account for the incoming op so that they\n\t\t\t// may be reapplied to the global state if needed.\n\t\t\tfor (let i = 0; i < this.pendingOps.length; i++) {\n\t\t\t\tthis.pendingOps[i] = this.transform(this.pendingOps[i], remoteOp);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected get state() {\n\t\t// If the locally cached state is dirty, reset it to the global state and reapply our\n\t\t// pending ops to bring it up to date.\n\t\tif (this.localDirty) {\n\t\t\tthis.local = this.global;\n\n\t\t\tfor (const op of this.pendingOps) {\n\t\t\t\tthis.local = this.applyCore(this.local, op);\n\t\t\t}\n\n\t\t\tthis.localDirty = false;\n\t\t}\n\n\t\treturn this.local;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluid-experimental/ot";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-dev.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.4.1.0.148229";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluid-experimental/ot";
|
|
8
|
-
export const pkgVersion = "2.0.0-dev.
|
|
8
|
+
export const pkgVersion = "2.0.0-dev.4.1.0.148229";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAChD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/ot\";\nexport const pkgVersion = \"2.0.0-dev.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAChD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/ot\";\nexport const pkgVersion = \"2.0.0-dev.4.1.0.148229\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/ot",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.4.1.0.148229",
|
|
4
4
|
"description": "Distributed data structure for hosting ottypes",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,31 +14,6 @@
|
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"module": "lib/index.js",
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "npm run build:genver && concurrently npm:build:compile npm:lint",
|
|
19
|
-
"build:commonjs": "npm run tsc && npm run build:test",
|
|
20
|
-
"build:compile": "concurrently npm:build:commonjs npm:build:esnext",
|
|
21
|
-
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
22
|
-
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
23
|
-
"build:full": "npm run build",
|
|
24
|
-
"build:full:compile": "npm run build:compile",
|
|
25
|
-
"build:genver": "gen-version",
|
|
26
|
-
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
27
|
-
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../../_api-extractor-temp/",
|
|
28
|
-
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
29
|
-
"eslint": "eslint --format stylish src",
|
|
30
|
-
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
31
|
-
"format": "npm run prettier:fix",
|
|
32
|
-
"lint": "npm run eslint",
|
|
33
|
-
"lint:fix": "npm run eslint:fix",
|
|
34
|
-
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
35
|
-
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
36
|
-
"test": "npm run test:mocha",
|
|
37
|
-
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
38
|
-
"test:mocha": "mocha --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
39
|
-
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
40
|
-
"tsc": "tsc"
|
|
41
|
-
},
|
|
42
17
|
"nyc": {
|
|
43
18
|
"all": true,
|
|
44
19
|
"cache-dir": "nyc/.cache",
|
|
@@ -60,38 +35,65 @@
|
|
|
60
35
|
"temp-directory": "nyc/.nyc_output"
|
|
61
36
|
},
|
|
62
37
|
"dependencies": {
|
|
63
|
-
"@fluidframework/common-utils": "^1.
|
|
64
|
-
"@fluidframework/core-interfaces": "
|
|
65
|
-
"@fluidframework/datastore-definitions": "
|
|
38
|
+
"@fluidframework/common-utils": "^1.1.1",
|
|
39
|
+
"@fluidframework/core-interfaces": "2.0.0-dev.4.1.0.148229",
|
|
40
|
+
"@fluidframework/datastore-definitions": "2.0.0-dev.4.1.0.148229",
|
|
66
41
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
67
|
-
"@fluidframework/runtime-definitions": "
|
|
68
|
-
"@fluidframework/shared-object-base": "
|
|
42
|
+
"@fluidframework/runtime-definitions": "2.0.0-dev.4.1.0.148229",
|
|
43
|
+
"@fluidframework/shared-object-base": "2.0.0-dev.4.1.0.148229"
|
|
69
44
|
},
|
|
70
45
|
"devDependencies": {
|
|
71
|
-
"@fluid-internal/test-dds-utils": "
|
|
46
|
+
"@fluid-internal/test-dds-utils": "2.0.0-dev.4.1.0.148229",
|
|
72
47
|
"@fluidframework/build-common": "^1.1.0",
|
|
73
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
74
|
-
"@fluidframework/mocha-test-setup": "
|
|
75
|
-
"@fluidframework/test-runtime-utils": "
|
|
76
|
-
"@microsoft/api-extractor": "^7.
|
|
77
|
-
"@rushstack/eslint-config": "^2.5.1",
|
|
48
|
+
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
49
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev.4.1.0.148229",
|
|
50
|
+
"@fluidframework/test-runtime-utils": "2.0.0-dev.4.1.0.148229",
|
|
51
|
+
"@microsoft/api-extractor": "^7.34.4",
|
|
78
52
|
"@types/mocha": "^9.1.1",
|
|
79
|
-
"@types/node": "^14.18.
|
|
53
|
+
"@types/node": "^14.18.38",
|
|
80
54
|
"best-random": "^1.0.0",
|
|
81
|
-
"concurrently": "^6.
|
|
55
|
+
"concurrently": "^7.6.0",
|
|
82
56
|
"copyfiles": "^2.4.1",
|
|
83
|
-
"cross-env": "^7.0.
|
|
57
|
+
"cross-env": "^7.0.3",
|
|
84
58
|
"eslint": "~8.6.0",
|
|
85
|
-
"mocha": "^10.
|
|
86
|
-
"
|
|
59
|
+
"mocha": "^10.2.0",
|
|
60
|
+
"mocha-json-output-reporter": "^2.0.1",
|
|
61
|
+
"mocha-multi-reporters": "^1.5.1",
|
|
62
|
+
"moment": "^2.21.0",
|
|
63
|
+
"nyc": "^15.1.0",
|
|
87
64
|
"prettier": "~2.6.2",
|
|
88
65
|
"quill-delta": "^4.2.2",
|
|
89
|
-
"rimraf": "^
|
|
66
|
+
"rimraf": "^4.4.0",
|
|
90
67
|
"typescript": "~4.5.5"
|
|
91
68
|
},
|
|
92
69
|
"typeValidation": {
|
|
93
70
|
"disabled": true,
|
|
94
|
-
"version": "2.0.0-internal.2.1.0",
|
|
95
71
|
"broken": {}
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "npm run build:genver && concurrently npm:build:compile npm:lint",
|
|
75
|
+
"build:commonjs": "npm run tsc && npm run build:test",
|
|
76
|
+
"build:compile": "concurrently npm:build:commonjs npm:build:esnext",
|
|
77
|
+
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
78
|
+
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
79
|
+
"build:full": "npm run build",
|
|
80
|
+
"build:full:compile": "npm run build:compile",
|
|
81
|
+
"build:genver": "gen-version",
|
|
82
|
+
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
83
|
+
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../../_api-extractor-temp/",
|
|
84
|
+
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
85
|
+
"eslint": "eslint --format stylish src",
|
|
86
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
87
|
+
"format": "npm run prettier:fix",
|
|
88
|
+
"lint": "npm run prettier && npm run eslint",
|
|
89
|
+
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
90
|
+
"prettier": "prettier --check . --ignore-path ../../../../.prettierignore",
|
|
91
|
+
"prettier:fix": "prettier --write . --ignore-path ../../../../.prettierignore",
|
|
92
|
+
"test": "npm run test:mocha",
|
|
93
|
+
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
94
|
+
"test:mocha": "mocha --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
95
|
+
"test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
|
|
96
|
+
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
97
|
+
"tsc": "tsc"
|
|
96
98
|
}
|
|
97
|
-
}
|
|
99
|
+
}
|
package/prettier.config.cjs
CHANGED
package/src/ot.ts
CHANGED
|
@@ -6,149 +6,158 @@
|
|
|
6
6
|
import { assert, bufferToString } from "@fluidframework/common-utils";
|
|
7
7
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
IChannelAttributes,
|
|
10
|
+
IFluidDataStoreRuntime,
|
|
11
|
+
IChannelStorageService,
|
|
12
12
|
} from "@fluidframework/datastore-definitions";
|
|
13
13
|
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
createSingleBlobSummary,
|
|
16
|
+
IFluidSerializer,
|
|
17
|
+
SharedObject,
|
|
18
|
+
} from "@fluidframework/shared-object-base";
|
|
15
19
|
|
|
16
20
|
interface ISequencedOpInfo<TOp> {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
client: string;
|
|
22
|
+
seq: number;
|
|
23
|
+
op: TOp;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export abstract class SharedOT<TState, TOp> extends SharedObject {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Queue of sequenced ops that are above minSeq. Used by 'processCore' to
|
|
29
|
+
* adjust incoming ops to account for prior ops that the sender didn't know about
|
|
30
|
+
* at the time they submitted their op.
|
|
31
|
+
*/
|
|
32
|
+
private readonly sequencedOps: ISequencedOpInfo<TOp>[] = [];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Queue of local pending ops that have not yet been ACKed by the service. Used
|
|
36
|
+
* to lazily rebuild the "local" state cache when it is invalidated by interleaved
|
|
37
|
+
* remote ops.
|
|
38
|
+
*/
|
|
39
|
+
private readonly pendingOps: TOp[] = [];
|
|
40
|
+
|
|
41
|
+
/** The "global" state is the result of applying all sequenced ops. */
|
|
42
|
+
private global: TState;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Lazily cached result of optimistically applying pendingOps on top of the current
|
|
46
|
+
* "global" state.
|
|
47
|
+
*/
|
|
48
|
+
private local: TState;
|
|
49
|
+
private localDirty = false;
|
|
50
|
+
|
|
51
|
+
constructor(
|
|
52
|
+
id: string,
|
|
53
|
+
runtime: IFluidDataStoreRuntime,
|
|
54
|
+
attributes: IChannelAttributes,
|
|
55
|
+
initialValue: TState,
|
|
56
|
+
) {
|
|
57
|
+
super(id, runtime, attributes, "fluid_ot_");
|
|
58
|
+
|
|
59
|
+
this.global = this.local = initialValue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected apply(op: TOp) {
|
|
63
|
+
this.local = this.applyCore(this.state, op);
|
|
64
|
+
|
|
65
|
+
// If we are not attached, don't submit the op.
|
|
66
|
+
if (!this.isAttached()) {
|
|
67
|
+
this.global = this.local;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.pendingOps.push(op);
|
|
72
|
+
this.submitLocalMessage(op);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Apply the given 'op' to the provided 'state', producing a new instance of state.
|
|
77
|
+
*/
|
|
78
|
+
protected abstract applyCore(state: TState, op: TOp): TState;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Transform the 'input' op to adjust for the earlier 'transform' op.
|
|
82
|
+
*/
|
|
83
|
+
protected abstract transform(input: TOp, transform: TOp): TOp;
|
|
84
|
+
|
|
85
|
+
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {
|
|
86
|
+
// Summarizer must not have locally pending changes.
|
|
87
|
+
assert(this.pendingOps.length === 0, 0);
|
|
88
|
+
|
|
89
|
+
return createSingleBlobSummary("header", serializer.stringify(this.global, this.handle));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected async loadCore(storage: IChannelStorageService): Promise<void> {
|
|
93
|
+
const blob = await storage.readBlob("header");
|
|
94
|
+
const rawContent = bufferToString(blob, "utf8");
|
|
95
|
+
this.global = this.local = this.serializer.parse(rawContent);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
protected onDisconnect() {}
|
|
99
|
+
|
|
100
|
+
protected processCore(message: ISequencedDocumentMessage, local: boolean) {
|
|
101
|
+
// Discard any sequenced ops that are now below the minimum sequence number.
|
|
102
|
+
const minSeq = this.runtime.deltaManager.minimumSequenceNumber;
|
|
103
|
+
while (this.sequencedOps[0]?.seq < minSeq) {
|
|
104
|
+
this.sequencedOps.shift();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let remoteOp = message.contents;
|
|
108
|
+
const messageSeq = message.sequenceNumber;
|
|
109
|
+
const remoteRefSeq = message.referenceSequenceNumber;
|
|
110
|
+
const remoteClient = message.clientId;
|
|
111
|
+
|
|
112
|
+
// Adjust the incoming sequenced op to account for prior sequenced ops that the
|
|
113
|
+
// sender hadn't yet seen at the time they sent the op.
|
|
114
|
+
for (const { op, seq, client } of this.sequencedOps) {
|
|
115
|
+
if (remoteRefSeq < seq && remoteClient !== client) {
|
|
116
|
+
remoteOp = this.transform(remoteOp, op);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Retain the adjusted op in order to adjust future remote ops.
|
|
121
|
+
this.sequencedOps.push({ seq: messageSeq, client: remoteClient, op: remoteOp });
|
|
122
|
+
|
|
123
|
+
// The incoming sequenced op is now part of the "global" state. Apply it to "this.global"
|
|
124
|
+
// now.
|
|
125
|
+
//
|
|
126
|
+
// TODO: If the op is local, we could defer applying the remoteOp and wait and see if
|
|
127
|
+
// the global state catches up with our local state.
|
|
128
|
+
this.global = this.applyCore(this.global, remoteOp);
|
|
129
|
+
|
|
130
|
+
if (local) {
|
|
131
|
+
this.pendingOps.shift();
|
|
132
|
+
} else {
|
|
133
|
+
// Our optimistic local cache (if any) did not account for the incoming op.
|
|
134
|
+
this.localDirty = true;
|
|
135
|
+
|
|
136
|
+
// Adjust our queue of locally pending ops to account for the incoming op so that they
|
|
137
|
+
// may be reapplied to the global state if needed.
|
|
138
|
+
for (let i = 0; i < this.pendingOps.length; i++) {
|
|
139
|
+
this.pendingOps[i] = this.transform(this.pendingOps[i], remoteOp);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
protected get state() {
|
|
145
|
+
// If the locally cached state is dirty, reset it to the global state and reapply our
|
|
146
|
+
// pending ops to bring it up to date.
|
|
147
|
+
if (this.localDirty) {
|
|
148
|
+
this.local = this.global;
|
|
149
|
+
|
|
150
|
+
for (const op of this.pendingOps) {
|
|
151
|
+
this.local = this.applyCore(this.local, op);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.localDirty = false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return this.local;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
protected applyStashedOp() {
|
|
161
|
+
throw new Error("not implemented");
|
|
162
|
+
}
|
|
154
163
|
}
|
package/src/packageVersion.ts
CHANGED
package/tsconfig.esnext.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./lib",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
},
|
|
7
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*"
|
|
13
|
-
]
|
|
2
|
+
"extends": "@fluidframework/build-common/ts-common-config.json",
|
|
3
|
+
"exclude": ["src/test/**/*"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"composite": true,
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*"],
|
|
14
10
|
}
|