@fluid-experimental/ot 2.117.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,8 +1,30 @@
1
1
  # @fluid-experimental/ot
2
2
 
3
- ## 2.117.0
3
+ ## 3.0.0
4
4
 
5
- Dependency updates only.
5
+ ### Minor Changes
6
+
7
+ - Removal of direct CommonJS support ([#28124](https://github.com/microsoft/FluidFramework/pull/28124)) [0f84e3b8878](https://github.com/microsoft/FluidFramework/commit/0f84e3b8878a5e75b2253976d98fd963bbd9db88)
8
+
9
+ Direct `require()` import is no longer directly supported.
10
+ Package is transpiled as ECMAScript Module.
11
+
12
+ See [Removal of direct CommonJS support in v3.0](https://github.com/microsoft/FluidFramework/issues/27444) for more information.
13
+
14
+ - Client packages now target ES2022 ([#27846](https://github.com/microsoft/FluidFramework/pull/27846)) [91c78541bdd](https://github.com/microsoft/FluidFramework/commit/91c78541bddcbca5d6c5f357b023eeaee617d885)
15
+
16
+ The TypeScript compilation `target` and `lib` for the Fluid Framework client packages have been raised from ES2021/ES2020 to **ES2022**.
17
+ The published JavaScript now uses ES2022 language features (with correspondingly less down-leveling), so consuming these packages requires a runtime that supports ES2022.
18
+ All actively supported Node.js versions and evergreen browsers already meet this requirement.
19
+
20
+ Note that Fluid Framework has not officially supported targets older than ES2022 since before 2.0: this is documented in [ClientRequirements.md](https://github.com/microsoft/FluidFramework/blob/main/ClientRequirements.md) as well as the README for every client package.
21
+
22
+ It is possible this change could impact users of less up to date JavaScript runtimes.
23
+ Impacted users can use a tool like [babel](https://babeljs.io/) to transpile out unsupported language features.
24
+
25
+ - Build with TypeScript 6 ([#28052](https://github.com/microsoft/FluidFramework/pull/28052)) [7ab015c49de](https://github.com/microsoft/FluidFramework/commit/7ab015c49deec84833cdfe1fb5e1606b901f6e81)
26
+
27
+ FluidFramework Client SDK is now built using TypeScript 6. Consumers should build with TypeScript v6 or v7 or compatible tooling.
6
28
 
7
29
  ## 2.116.0
8
30
 
package/README.md CHANGED
@@ -8,21 +8,22 @@ Distributed data structure for hosting [Operational Transformation (OT)](https:/
8
8
  <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
9
9
 
10
10
  **IMPORTANT: This package is experimental.**
11
- **Its APIs may change without notice.**
11
+ **The APIs can change without notice.**
12
12
 
13
- **Do not use in production scenarios.**
13
+ **Do not use it as a dependency in production scenarios.**
14
+ **We do not guarantee the stability of this package or its APIs.**
14
15
 
15
16
  ## Using Fluid Framework libraries
16
17
 
17
- When taking a dependency on a Fluid Framework library's public APIs, we recommend using a `^` (caret) version range, such as `^1.3.4`.
18
- While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
19
- library consumers should always prefer `^`.
18
+ For a dependency on a Fluid Framework library's public APIs, we recommend a `^` (caret) version range.
19
+ For example, use `^1.3.4`.
20
20
 
21
- If using any of Fluid Framework's unstable APIs (for example, its `beta` APIs), we recommend using a more constrained version range, such as `~`.
21
+ For a dependency on an unstable API, such as a `beta` API, we recommend a more restrictive version range.
22
+ For example, use a `~` version range.
22
23
 
23
24
  ## Installation
24
25
 
25
- To get started, install the package by running the following command:
26
+ Run this command to install the package:
26
27
 
27
28
  ```bash
28
29
  npm i @fluid-experimental/ot
@@ -30,7 +31,7 @@ npm i @fluid-experimental/ot
30
31
 
31
32
  ## API Documentation
32
33
 
33
- API documentation for **@fluid-experimental/ot** is available at <https://fluidframework.com/docs/apis/ot>.
34
+ Read the **@fluid-experimental/ot** API documentation at <https://fluidframework.com/docs/apis/ot>.
34
35
 
35
36
  <!-- prettier-ignore-end -->
36
37
 
@@ -43,62 +44,69 @@ API documentation for **@fluid-experimental/ot** is available at <https://fluidf
43
44
 
44
45
  ## Minimum Client Requirements
45
46
 
46
- These are the platform requirements for the current version of Fluid Framework Client Packages.
47
- These requirements err on the side of being too strict since within a major version they can be relaxed over time, but not made stricter.
48
- For Long Term Support (LTS) versions this can require supporting these platforms for several years.
47
+ Fluid Framework client libraries support the platforms in this document.
48
+ These requirements are intentionally restrictive.
49
+ Within a major version series, we can relax these requirements, but we cannot make them stricter.
50
+ For a Long Term Support (LTS) version, we might need to support these platforms for several years.
49
51
 
50
- It is likely that other configurations will work, but they are not supported: if they stop working, we do not consider that a bug.
51
- If you would benefit from support for something not listed here, file an issue and the product team will evaluate your request.
52
- When making such a request please include if the configuration already works (and thus the request is just that it becomes officially supported), or if changes are required to get it working.
52
+ Other configurations can work, but Fluid Framework does not support them.
53
+ If an unsupported configuration stops working, we do not classify this as a bug.
54
+ To request support for a configuration that is not listed, file an issue.
55
+ The product team will evaluate your request.
56
+ In the issue, specify the current status of the configuration:
57
+
58
+ - The configuration works but needs official support.
59
+ - The configuration does not work and requires changes.
53
60
 
54
61
  ### Supported Runtimes
55
62
 
56
- - NodeJs ^22.22.2 except that we will drop support for it [when NodeJs 22 loses its upstream support on 2027-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS at least 1 year before 22 is end-of-life.
57
- - Running Fluid in a Node.js environment with the `--no-experimental-fetch` flag is not supported.
58
- - Modern browsers supporting the es2022 standard library: in response to asks we can add explicit support for using babel to polyfill to target specific standards or runtimes (meaning we can avoid/remove use of things that don't polyfill robustly, but otherwise target modern standards).
63
+ - Fluid Framework supports Node.js versions 22 and 24 while they receive [upstream support](https://nodejs.org/en/about/previous-releases).
64
+ - Fluid Framework will stop support for version 22 [when upstream support ends on 2027-04-30](https://github.com/nodejs/release#release-schedule).
65
+ - Fluid Framework does not support Node.js with the `--no-experimental-fetch` flag.
66
+ - Fluid Framework supports modern browsers that support the ES2022 standard library.
59
67
 
60
68
  ### Supported Tools
61
69
 
62
- - TypeScript 5.4:
63
- - All [`strict`](https://www.typescriptlang.org/tsconfig) options are supported.
64
- - [`strictNullChecks`](https://www.typescriptlang.org/tsconfig) is required.
65
- - [Configuration options deprecated in 5.0](https://github.com/microsoft/TypeScript/issues/51909) are not supported.
66
- - `exactOptionalPropertyTypes` is currently not fully supported.
67
- If used, narrowing members of Fluid Framework types types using `in`, `Reflect.has`, `Object.hasOwn` or `Object.prototype.hasOwnProperty` should be avoided as they may incorrectly exclude `undefined` from the possible values in some cases.
70
+ - [TypeScript 6.0](https://typescriptdocs.com/release-notes/TypeScript%206.0):
71
+ - Fluid Framework supports all [`strict`](https://www.typescriptlang.org/tsconfig) options.
72
+ - Set the build targets (`lib`, `target`) to `ES2022` or later.
73
+ - Enable [`strictNullChecks`](https://www.typescriptlang.org/tsconfig).
74
+ - Fluid Framework does not support [configuration options deprecated in TypeScript 6.0](https://typescriptdocs.com/release-notes/TypeScript%206.0#breaking-changes-and-deprecations-in-typescript-6-0).
75
+ - Fluid Framework does not fully support `exactOptionalPropertyTypes`.
76
+ If you enable this option, do not use `in`, `Reflect.has`, `Object.hasOwn`, or `Object.prototype.hasOwnProperty` to narrow members of Fluid Framework types.
77
+ These methods can incorrectly exclude `undefined` from the possible values.
68
78
  - [webpack](https://webpack.js.org/) 5
69
- - We are not intending to be prescriptive about what bundler to use.
70
- Other bundlers which can handle ES Modules should work, but webpack is the only one we actively test.
79
+ - We do not require a specific bundler.
80
+ Other bundlers that handle ES Modules can work, but we actively test only webpack.
71
81
 
72
82
  ### Module Resolution
73
83
 
74
- [`Node16`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution) resolution should be used with TypeScript compilerOptions to follow the [Node.js v12+ ESM Resolution and Loading algorithm](https://nodejs.github.io/nodejs.dev/en/api/v20/esm/#resolution-and-loading-algorithm).
75
- Node10 resolution is not supported as it does not support Fluid Framework's API structuring pattern that is used to distinguish stable APIs from those that are in development.
84
+ In TypeScript `compilerOptions`, use [`Node16`, `Node20`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution) module resolution.
85
+ These settings follow the [Node.js v12+ ESM Resolution and Loading algorithm](https://nodejs.github.io/nodejs.dev/en/api/v20/esm/#resolution-and-loading-algorithm).
86
+
87
+ Do not use `Node10` module resolution.
76
88
 
77
89
  ### Module Formats
78
90
 
79
91
  - ES Modules:
80
- ES Modules are the preferred way to consume our client packages (including in NodeJs) and consuming our client packages from ES Modules is fully supported.
81
- - CommonJs:
82
- Consuming our client packages as CommonJs is supported only in NodeJS and only for the cases listed below.
83
- This is done to accommodate some workflows without good ES Module support.
84
- If you have a workflow you would like included in this list, file an issue.
85
- Once this list of workflows motivating CommonJS support is empty, we may drop support for CommonJS one year after notice of the change is posted here.
86
-
87
- - Testing with Jest (which lacks [stable ESM support](https://jestjs.io/docs/ecmascript-modules) due to [unstable APIs in NodeJs](https://github.com/nodejs/node/issues/37648))
92
+ Use ES Modules to consume Fluid Framework client packages, including in Node.js.
93
+ - CommonJS:
94
+ Fluid Framework does not officially support CommonJS in version 3.0 or later.
88
95
 
89
96
  ## Contribution Guidelines
90
97
 
91
- There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.
98
+ You can [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid Framework in these ways:
92
99
 
93
- - Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
94
- - [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
95
- - Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
100
+ - Answer questions in [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
101
+ - [Submit bug reports](https://github.com/microsoft/FluidFramework/issues) and help verify fixes.
102
+ - Review [source code changes](https://github.com/microsoft/FluidFramework/pulls).
96
103
  - [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
97
104
 
98
- Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Home.md).
105
+ For detailed instructions, read the [repo documentation](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Home.md).
99
106
 
100
- This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
101
- For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
107
+ This project follows the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
108
+ For more information, read the [Code of Conduct frequently asked questions](https://opensource.microsoft.com/codeofconduct/faq/).
109
+ For questions or comments, contact [opencode@microsoft.com](mailto:opencode@microsoft.com).
102
110
 
103
111
  This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
104
112
  Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
@@ -106,13 +114,9 @@ Use of Microsoft trademarks or logos in modified versions of this project must n
106
114
 
107
115
  ## Help
108
116
 
109
- Not finding what you're looking for in this README?
110
- Check out [fluidframework.com](https://fluidframework.com/docs/).
111
-
112
- Still not finding what you're looking for?
113
- Please [file an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
117
+ Read the [Fluid Framework documentation](https://fluidframework.com/docs/) for information about Fluid Framework concepts and APIs.
114
118
 
115
- Thank you!
119
+ To request information that the documentation does not contain, [create an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
116
120
 
117
121
  ## Trademark
118
122
 
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../../common/build/build-common/api-extractor-base.esm.no-legacy.json"
3
+ "extends": "<projectFolder>/../../../../common/build/build-common/api-extractor-model.esm.json"
4
4
  }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "<projectFolder>/../../../../common/build/build-common/api-extractor-report-base.esm.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts"
5
+ }
package/dist/ot.js CHANGED
@@ -12,21 +12,28 @@ const internal_2 = require("@fluidframework/shared-object-base/internal");
12
12
  * @internal
13
13
  */
14
14
  class SharedOT extends internal_2.SharedObject {
15
+ /**
16
+ * Queue of sequenced ops that are above minSeq. Used by 'processCore' to
17
+ * adjust incoming ops to account for prior ops that the sender didn't know about
18
+ * at the time they submitted their op.
19
+ */
20
+ sequencedOps = [];
21
+ /**
22
+ * Queue of local pending ops that have not yet been ACKed by the service. Used
23
+ * to lazily rebuild the "local" state cache when it is invalidated by interleaved
24
+ * remote ops.
25
+ */
26
+ pendingOps = [];
27
+ /** The "global" state is the result of applying all sequenced ops. */
28
+ global;
29
+ /**
30
+ * Lazily cached result of optimistically applying pendingOps on top of the current
31
+ * "global" state.
32
+ */
33
+ local;
34
+ localDirty = false;
15
35
  constructor(id, runtime, attributes, initialValue) {
16
36
  super(id, runtime, attributes, "fluid_ot_");
17
- /**
18
- * Queue of sequenced ops that are above minSeq. Used by 'processCore' to
19
- * adjust incoming ops to account for prior ops that the sender didn't know about
20
- * at the time they submitted their op.
21
- */
22
- this.sequencedOps = [];
23
- /**
24
- * Queue of local pending ops that have not yet been ACKed by the service. Used
25
- * to lazily rebuild the "local" state cache when it is invalidated by interleaved
26
- * remote ops.
27
- */
28
- this.pendingOps = [];
29
- this.localDirty = false;
30
37
  this.global = this.local = initialValue;
31
38
  }
32
39
  apply(op) {
package/dist/ot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ot.js","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA6D;AAY7D,0EAIqD;AAQrD;;GAEG;AACH,MAAsB,QAAsB,SAAQ,uBAAY;IAyB/D,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EAC9B,YAAoB;QAEpB,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CA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,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,QAAe,CAAC,CAAC;QAE3D,IAAI,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;aAAM,CAAC;YACP,2EAA2E;YAC3E,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YAEvB,sFAAsF;YACtF,kDAAkD;YAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,QAAe,CAAC,CAAC;YAC1E,CAAC;QACF,CAAC;IACF,CAAC;IAED,IAAc,KAAK;QAClB,qFAAqF;QACrF,sCAAsC;QACtC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;YAEzB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7C,CAAC;YAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACzB,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AA5JD,4BA4JC","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 { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tISummaryTreeWithStats,\n\ttype IRuntimeMessageCollection,\n\ttype IRuntimeMessagesContent,\n\ttype ISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tIFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\ninterface ISequencedOpInfo<TOp> {\n\tclient: string;\n\tseq: number;\n\top: TOp;\n}\n\n/**\n * @internal\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): void {\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\tassert(\n\t\t\tthis.pendingOps.length === 0,\n\t\t\t0x5f6 /* Summarizer must not have locally pending changes. */,\n\t\t);\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) as TState;\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessagesContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// Discard any sequenced ops that are now below the minimum sequence number.\n\t\tconst minSeq = this.deltaManager.minimumSequenceNumber;\n\t\twhile (this.sequencedOps[0]?.seq < minSeq) {\n\t\t\tthis.sequencedOps.shift();\n\t\t}\n\n\t\tlet remoteOp = messagesContent.contents;\n\t\tconst messageSeq = messageEnvelope.sequenceNumber;\n\t\tconst remoteRefSeq = messageEnvelope.referenceSequenceNumber;\n\t\tconst remoteClient = messageEnvelope.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 as TOp, 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\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\tthis.sequencedOps.push({\n\t\t\tseq: messageSeq,\n\n\t\t\tclient: remoteClient as string,\n\t\t\top: remoteOp as TOp,\n\t\t});\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 as TOp);\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 as TOp);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected get state(): TState {\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(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
1
+ {"version":3,"file":"ot.js","sourceRoot":"","sources":["../src/ot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA6D;AAY7D,0EAIqD;AAQrD;;GAEG;AACH,MAAsB,QAAsB,SAAQ,uBAAY;IAC/D;;;;OAIG;IACc,YAAY,GAA4B,EAAE,CAAC;IAE5D;;;;OAIG;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. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tISummaryTreeWithStats,\n\ttype IRuntimeMessageCollection,\n\ttype IRuntimeMessagesContent,\n\ttype ISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tIFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\ninterface ISequencedOpInfo<TOp> {\n\tclient: string;\n\tseq: number;\n\top: TOp;\n}\n\n/**\n * @internal\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): void {\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\tassert(\n\t\t\tthis.pendingOps.length === 0,\n\t\t\t0x5f6 /* Summarizer must not have locally pending changes. */,\n\t\t);\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) as TState;\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessagesContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// Discard any sequenced ops that are now below the minimum sequence number.\n\t\tconst minSeq = this.deltaManager.minimumSequenceNumber;\n\t\twhile (this.sequencedOps[0]?.seq < minSeq) {\n\t\t\tthis.sequencedOps.shift();\n\t\t}\n\n\t\tlet remoteOp = messagesContent.contents;\n\t\tconst messageSeq = messageEnvelope.sequenceNumber;\n\t\tconst remoteRefSeq = messageEnvelope.referenceSequenceNumber;\n\t\tconst remoteClient = messageEnvelope.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 as TOp, 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\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\tthis.sequencedOps.push({\n\t\t\tseq: messageSeq,\n\n\t\t\tclient: remoteClient as string,\n\t\t\top: remoteOp as TOp,\n\t\t});\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 as TOp);\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 as TOp);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected get state(): TState {\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(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
@@ -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.117.0";
8
+ export declare const pkgVersion = "3.0.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,UAAU,YAAY,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,UAAU,UAAU,CAAC"}
@@ -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.117.0";
11
+ exports.pkgVersion = "3.0.0";
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,SAAS,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.117.0\";\n"]}
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,OAAO,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 = \"3.0.0\";\n"]}
package/lib/ot.js CHANGED
@@ -9,21 +9,28 @@ import { SharedObject, createSingleBlobSummary, } from "@fluidframework/shared-o
9
9
  * @internal
10
10
  */
11
11
  export class SharedOT extends SharedObject {
12
+ /**
13
+ * Queue of sequenced ops that are above minSeq. Used by 'processCore' to
14
+ * adjust incoming ops to account for prior ops that the sender didn't know about
15
+ * at the time they submitted their op.
16
+ */
17
+ sequencedOps = [];
18
+ /**
19
+ * Queue of local pending ops that have not yet been ACKed by the service. Used
20
+ * to lazily rebuild the "local" state cache when it is invalidated by interleaved
21
+ * remote ops.
22
+ */
23
+ pendingOps = [];
24
+ /** The "global" state is the result of applying all sequenced ops. */
25
+ global;
26
+ /**
27
+ * Lazily cached result of optimistically applying pendingOps on top of the current
28
+ * "global" state.
29
+ */
30
+ local;
31
+ localDirty = false;
12
32
  constructor(id, runtime, attributes, initialValue) {
13
33
  super(id, runtime, attributes, "fluid_ot_");
14
- /**
15
- * Queue of sequenced ops that are above minSeq. Used by 'processCore' to
16
- * adjust incoming ops to account for prior ops that the sender didn't know about
17
- * at the time they submitted their op.
18
- */
19
- this.sequencedOps = [];
20
- /**
21
- * Queue of local pending ops that have not yet been ACKed by the service. Used
22
- * to lazily rebuild the "local" state cache when it is invalidated by interleaved
23
- * remote ops.
24
- */
25
- this.pendingOps = [];
26
- this.localDirty = false;
27
34
  this.global = this.local = initialValue;
28
35
  }
29
36
  apply(op) {
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,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;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K,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 { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tISummaryTreeWithStats,\n\ttype IRuntimeMessageCollection,\n\ttype IRuntimeMessagesContent,\n\ttype ISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tIFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\ninterface ISequencedOpInfo<TOp> {\n\tclient: string;\n\tseq: number;\n\top: TOp;\n}\n\n/**\n * @internal\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): void {\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\tassert(\n\t\t\tthis.pendingOps.length === 0,\n\t\t\t0x5f6 /* Summarizer must not have locally pending changes. */,\n\t\t);\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) as TState;\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessagesContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// Discard any sequenced ops that are now below the minimum sequence number.\n\t\tconst minSeq = this.deltaManager.minimumSequenceNumber;\n\t\twhile (this.sequencedOps[0]?.seq < minSeq) {\n\t\t\tthis.sequencedOps.shift();\n\t\t}\n\n\t\tlet remoteOp = messagesContent.contents;\n\t\tconst messageSeq = messageEnvelope.sequenceNumber;\n\t\tconst remoteRefSeq = messageEnvelope.referenceSequenceNumber;\n\t\tconst remoteClient = messageEnvelope.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 as TOp, 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\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\tthis.sequencedOps.push({\n\t\t\tseq: messageSeq,\n\n\t\t\tclient: remoteClient as string,\n\t\t\top: remoteOp as TOp,\n\t\t});\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 as TOp);\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 as TOp);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected get state(): TState {\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(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
1
+ {"version":3,"file":"ot.js","sour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AG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7C,CAAC;YAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACzB,CAAC;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 { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tISummaryTreeWithStats,\n\ttype IRuntimeMessageCollection,\n\ttype IRuntimeMessagesContent,\n\ttype ISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tIFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\ninterface ISequencedOpInfo<TOp> {\n\tclient: string;\n\tseq: number;\n\top: TOp;\n}\n\n/**\n * @internal\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): void {\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\tassert(\n\t\t\tthis.pendingOps.length === 0,\n\t\t\t0x5f6 /* Summarizer must not have locally pending changes. */,\n\t\t);\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) as TState;\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessagesContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// Discard any sequenced ops that are now below the minimum sequence number.\n\t\tconst minSeq = this.deltaManager.minimumSequenceNumber;\n\t\twhile (this.sequencedOps[0]?.seq < minSeq) {\n\t\t\tthis.sequencedOps.shift();\n\t\t}\n\n\t\tlet remoteOp = messagesContent.contents;\n\t\tconst messageSeq = messageEnvelope.sequenceNumber;\n\t\tconst remoteRefSeq = messageEnvelope.referenceSequenceNumber;\n\t\tconst remoteClient = messageEnvelope.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 as TOp, 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\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\tthis.sequencedOps.push({\n\t\t\tseq: messageSeq,\n\n\t\t\tclient: remoteClient as string,\n\t\t\top: remoteOp as TOp,\n\t\t});\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 as TOp);\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 as TOp);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected get state(): TState {\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(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
@@ -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.117.0";
8
+ export declare const pkgVersion = "3.0.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,UAAU,YAAY,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,UAAU,UAAU,CAAC"}
@@ -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.117.0";
8
+ export const pkgVersion = "3.0.0";
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,SAAS,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.117.0\";\n"]}
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,OAAO,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 = \"3.0.0\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/ot",
3
- "version": "2.117.0",
3
+ "version": "3.0.0",
4
4
  "description": "Distributed data structure for hosting ottypes",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -14,18 +14,10 @@
14
14
  "type": "module",
15
15
  "exports": {
16
16
  ".": {
17
- "import": {
18
- "types": "./lib/index.d.ts",
19
- "default": "./lib/index.js"
20
- },
21
- "require": {
22
- "types": "./dist/index.d.ts",
23
- "default": "./dist/index.js"
24
- }
17
+ "types": "./lib/index.d.ts",
18
+ "default": "./lib/index.js"
25
19
  }
26
20
  },
27
- "main": "lib/index.js",
28
- "types": "lib/index.d.ts",
29
21
  "c8": {
30
22
  "all": true,
31
23
  "cache-dir": "nyc/.cache",
@@ -49,24 +41,24 @@
49
41
  "temp-directory": "nyc/.nyc_output"
50
42
  },
51
43
  "dependencies": {
52
- "@fluid-internal/client-utils": "~2.117.0",
53
- "@fluidframework/core-interfaces": "~2.117.0",
54
- "@fluidframework/core-utils": "~2.117.0",
55
- "@fluidframework/datastore-definitions": "~2.117.0",
56
- "@fluidframework/driver-definitions": "~2.117.0",
57
- "@fluidframework/runtime-definitions": "~2.117.0",
58
- "@fluidframework/shared-object-base": "~2.117.0"
44
+ "@fluid-internal/client-utils": "~3.0.0",
45
+ "@fluidframework/core-interfaces": "~3.0.0",
46
+ "@fluidframework/core-utils": "~3.0.0",
47
+ "@fluidframework/datastore-definitions": "~3.0.0",
48
+ "@fluidframework/driver-definitions": "~3.0.0",
49
+ "@fluidframework/runtime-definitions": "~3.0.0",
50
+ "@fluidframework/shared-object-base": "~3.0.0"
59
51
  },
60
52
  "devDependencies": {
61
53
  "@arethetypeswrong/cli": "^0.18.5",
62
54
  "@biomejs/biome": "~2.4.5",
63
- "@fluid-internal/mocha-test-setup": "~2.117.0",
64
- "@fluid-private/test-dds-utils": "~2.117.0",
55
+ "@fluid-internal/mocha-test-setup": "~3.0.0",
56
+ "@fluid-private/test-dds-utils": "~3.0.0",
65
57
  "@fluid-tools/build-cli": "^0.67.0",
66
58
  "@fluidframework/build-common": "^2.0.3",
67
59
  "@fluidframework/build-tools": "^0.67.0",
68
60
  "@fluidframework/eslint-config-fluid": "^14.0.0",
69
- "@fluidframework/test-runtime-utils": "~2.117.0",
61
+ "@fluidframework/test-runtime-utils": "~3.0.0",
70
62
  "@microsoft/api-extractor": "7.58.1",
71
63
  "@types/mocha": "^10.0.10",
72
64
  "@types/node": "~22.19.17",
@@ -81,7 +73,7 @@
81
73
  "mocha-multi-reporters": "^1.5.1",
82
74
  "quill-delta": "^4.2.2",
83
75
  "rimraf": "^6.1.3",
84
- "typescript": "~5.4.5"
76
+ "typescript": "~6.0.3"
85
77
  },
86
78
  "devDependenciesComments": {
87
79
  "quill-delta": "Version 5 does not support CommonJS"
@@ -91,22 +83,25 @@
91
83
  },
92
84
  "scripts": {
93
85
  "build": "fluid-build . --task build",
86
+ "build:api-reports": "api-extractor run --local --config api-extractor/api-extractor-report.json",
87
+ "build:cjs": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../common/build/build-common/src/cjs/package.json ./dist",
94
88
  "build:commonjs": "fluid-build . --task commonjs",
95
89
  "build:compile": "fluid-build . --task compile",
96
- "build:docs": "api-extractor run --local",
97
- "build:esnext": "tsc --project ./tsconfig.json",
90
+ "build:docs": "api-extractor run --local --config api-extractor/api-extractor-model.json",
91
+ "build:esm": "tsc --project ./tsconfig.json",
98
92
  "build:genver": "gen-version",
99
93
  "build:test": "concurrently npm:build:test:esm npm:build:test:cjs",
100
94
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
101
95
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
102
- "check:are-the-types-wrong": "attw --pack .",
96
+ "check:are-the-types-wrong": "attw --pack . --profile esm-only",
103
97
  "check:biome": "biome check .",
104
98
  "check:exports": "concurrently \"npm:check:exports:*\"",
105
99
  "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
106
100
  "check:exports:cjs:index": "api-extractor run --config api-extractor/api-extractor-lint-index.cjs.json",
107
101
  "check:exports:esm:index": "api-extractor run --config api-extractor/api-extractor-lint-index.esm.json",
108
102
  "check:format": "npm run check:biome",
109
- "ci:build:docs": "api-extractor run",
103
+ "ci:build:api-reports": "api-extractor run --config api-extractor/api-extractor-report.json",
104
+ "ci:build:docs": "api-extractor run --config api-extractor/api-extractor-model.json",
110
105
  "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
111
106
  "eslint": "eslint --quiet --format stylish src",
112
107
  "eslint:fix": "eslint --quiet --format stylish src --fix --fix-type problem,suggestion,layout",
@@ -119,7 +114,6 @@
119
114
  "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
120
115
  "test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
121
116
  "test:mocha:esm": "mocha",
122
- "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
123
- "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../common/build/build-common/src/cjs/package.json ./dist"
117
+ "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha"
124
118
  }
125
119
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluid-experimental/ot";
9
- export const pkgVersion = "2.117.0";
9
+ export const pkgVersion = "3.0.0";
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "../../../../common/build/build-common/tsconfig.node16.json",
2
+ "extends": "../../../../common/build/build-common/tsconfig.node20.json",
3
3
  "exclude": ["src/test/**/*"],
4
4
  "compilerOptions": {
5
5
  "rootDir": "./src",