@fluid-experimental/attributor 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.
Files changed (38) hide show
  1. package/CHANGELOG.md +24 -2
  2. package/README.md +52 -48
  3. package/{api-extractor.json → api-extractor/api-extractor-model.json} +1 -1
  4. package/api-extractor/api-extractor-report.json +5 -0
  5. package/dist/attributor.js +1 -0
  6. package/dist/attributor.js.map +1 -1
  7. package/dist/encoders.d.ts.map +1 -1
  8. package/dist/encoders.js +2 -0
  9. package/dist/encoders.js.map +1 -1
  10. package/dist/lz4Encoder.js +1 -2
  11. package/dist/lz4Encoder.js.map +1 -1
  12. package/dist/mixinAttributor.d.ts.map +1 -1
  13. package/dist/mixinAttributor.js +2 -2
  14. package/dist/mixinAttributor.js.map +1 -1
  15. package/dist/runtimeAttributor.js +6 -7
  16. package/dist/runtimeAttributor.js.map +1 -1
  17. package/dist/runtimeAttributorDataStoreChannel.js +12 -3
  18. package/dist/runtimeAttributorDataStoreChannel.js.map +1 -1
  19. package/dist/runtimeAttributorDataStoreFactory.js +1 -1
  20. package/dist/runtimeAttributorDataStoreFactory.js.map +1 -1
  21. package/dist/stringInterner.js +2 -2
  22. package/dist/stringInterner.js.map +1 -1
  23. package/lib/attributor.js +1 -0
  24. package/lib/attributor.js.map +1 -1
  25. package/lib/encoders.d.ts.map +1 -1
  26. package/lib/encoders.js +2 -0
  27. package/lib/encoders.js.map +1 -1
  28. package/lib/mixinAttributor.d.ts.map +1 -1
  29. package/lib/runtimeAttributor.js +6 -7
  30. package/lib/runtimeAttributor.js.map +1 -1
  31. package/lib/runtimeAttributorDataStoreChannel.js +12 -3
  32. package/lib/runtimeAttributorDataStoreChannel.js.map +1 -1
  33. package/lib/runtimeAttributorDataStoreFactory.js +1 -1
  34. package/lib/runtimeAttributorDataStoreFactory.js.map +1 -1
  35. package/lib/stringInterner.js +2 -2
  36. package/lib/stringInterner.js.map +1 -1
  37. package/package.json +29 -35
  38. package/tsconfig.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,8 +1,30 @@
1
1
  # @fluid-experimental/attributor
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 @@ This package contains definitions and implementations for framework-provided att
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/attributor
@@ -30,7 +31,7 @@ npm i @fluid-experimental/attributor
30
31
 
31
32
  ## API Documentation
32
33
 
33
- API documentation for **@fluid-experimental/attributor** is available at <https://fluidframework.com/docs/apis/attributor>.
34
+ Read the **@fluid-experimental/attributor** API documentation at <https://fluidframework.com/docs/apis/attributor>.
34
35
 
35
36
  <!-- prettier-ignore-end -->
36
37
 
@@ -146,62 +147,69 @@ During the "waiting to saturate" period, developers are free to experiment with
146
147
 
147
148
  ## Minimum Client Requirements
148
149
 
149
- These are the platform requirements for the current version of Fluid Framework Client Packages.
150
- 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.
151
- For Long Term Support (LTS) versions this can require supporting these platforms for several years.
150
+ Fluid Framework client libraries support the platforms in this document.
151
+ These requirements are intentionally restrictive.
152
+ Within a major version series, we can relax these requirements, but we cannot make them stricter.
153
+ For a Long Term Support (LTS) version, we might need to support these platforms for several years.
152
154
 
153
- It is likely that other configurations will work, but they are not supported: if they stop working, we do not consider that a bug.
154
- If you would benefit from support for something not listed here, file an issue and the product team will evaluate your request.
155
- 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.
155
+ Other configurations can work, but Fluid Framework does not support them.
156
+ If an unsupported configuration stops working, we do not classify this as a bug.
157
+ To request support for a configuration that is not listed, file an issue.
158
+ The product team will evaluate your request.
159
+ In the issue, specify the current status of the configuration:
160
+
161
+ - The configuration works but needs official support.
162
+ - The configuration does not work and requires changes.
156
163
 
157
164
  ### Supported Runtimes
158
165
 
159
- - 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.
160
- - Running Fluid in a Node.js environment with the `--no-experimental-fetch` flag is not supported.
161
- - 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).
166
+ - Fluid Framework supports Node.js versions 22 and 24 while they receive [upstream support](https://nodejs.org/en/about/previous-releases).
167
+ - Fluid Framework will stop support for version 22 [when upstream support ends on 2027-04-30](https://github.com/nodejs/release#release-schedule).
168
+ - Fluid Framework does not support Node.js with the `--no-experimental-fetch` flag.
169
+ - Fluid Framework supports modern browsers that support the ES2022 standard library.
162
170
 
163
171
  ### Supported Tools
164
172
 
165
- - TypeScript 5.4:
166
- - All [`strict`](https://www.typescriptlang.org/tsconfig) options are supported.
167
- - [`strictNullChecks`](https://www.typescriptlang.org/tsconfig) is required.
168
- - [Configuration options deprecated in 5.0](https://github.com/microsoft/TypeScript/issues/51909) are not supported.
169
- - `exactOptionalPropertyTypes` is currently not fully supported.
170
- 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.
173
+ - [TypeScript 6.0](https://typescriptdocs.com/release-notes/TypeScript%206.0):
174
+ - Fluid Framework supports all [`strict`](https://www.typescriptlang.org/tsconfig) options.
175
+ - Set the build targets (`lib`, `target`) to `ES2022` or later.
176
+ - Enable [`strictNullChecks`](https://www.typescriptlang.org/tsconfig).
177
+ - 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).
178
+ - Fluid Framework does not fully support `exactOptionalPropertyTypes`.
179
+ If you enable this option, do not use `in`, `Reflect.has`, `Object.hasOwn`, or `Object.prototype.hasOwnProperty` to narrow members of Fluid Framework types.
180
+ These methods can incorrectly exclude `undefined` from the possible values.
171
181
  - [webpack](https://webpack.js.org/) 5
172
- - We are not intending to be prescriptive about what bundler to use.
173
- Other bundlers which can handle ES Modules should work, but webpack is the only one we actively test.
182
+ - We do not require a specific bundler.
183
+ Other bundlers that handle ES Modules can work, but we actively test only webpack.
174
184
 
175
185
  ### Module Resolution
176
186
 
177
- [`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).
178
- 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.
187
+ In TypeScript `compilerOptions`, use [`Node16`, `Node20`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution) module resolution.
188
+ 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).
189
+
190
+ Do not use `Node10` module resolution.
179
191
 
180
192
  ### Module Formats
181
193
 
182
194
  - ES Modules:
183
- 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.
184
- - CommonJs:
185
- Consuming our client packages as CommonJs is supported only in NodeJS and only for the cases listed below.
186
- This is done to accommodate some workflows without good ES Module support.
187
- If you have a workflow you would like included in this list, file an issue.
188
- 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.
189
-
190
- - 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))
195
+ Use ES Modules to consume Fluid Framework client packages, including in Node.js.
196
+ - CommonJS:
197
+ Fluid Framework does not officially support CommonJS in version 3.0 or later.
191
198
 
192
199
  ## Contribution Guidelines
193
200
 
194
- There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.
201
+ You can [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid Framework in these ways:
195
202
 
196
- - Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
197
- - [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
198
- - Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
203
+ - Answer questions in [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
204
+ - [Submit bug reports](https://github.com/microsoft/FluidFramework/issues) and help verify fixes.
205
+ - Review [source code changes](https://github.com/microsoft/FluidFramework/pulls).
199
206
  - [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
200
207
 
201
- Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Home.md).
208
+ For detailed instructions, read the [repo documentation](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Home.md).
202
209
 
203
- This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
204
- 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.
210
+ This project follows the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
211
+ For more information, read the [Code of Conduct frequently asked questions](https://opensource.microsoft.com/codeofconduct/faq/).
212
+ For questions or comments, contact [opencode@microsoft.com](mailto:opencode@microsoft.com).
205
213
 
206
214
  This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
207
215
  Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
@@ -209,13 +217,9 @@ Use of Microsoft trademarks or logos in modified versions of this project must n
209
217
 
210
218
  ## Help
211
219
 
212
- Not finding what you're looking for in this README?
213
- Check out [fluidframework.com](https://fluidframework.com/docs/).
214
-
215
- Still not finding what you're looking for?
216
- Please [file an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
220
+ Read the [Fluid Framework documentation](https://fluidframework.com/docs/) for information about Fluid Framework concepts and APIs.
217
221
 
218
- Thank you!
222
+ 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).
219
223
 
220
224
  ## Trademark
221
225
 
@@ -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
+ }
@@ -12,6 +12,7 @@ const internal_3 = require("@fluidframework/telemetry-utils/internal");
12
12
  * {@inheritdoc IAttributor}
13
13
  */
14
14
  class Attributor {
15
+ keyToInfo;
15
16
  /**
16
17
  * @param initialEntries - Any entries which should be populated on instantiation.
17
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"attributor.js","sourceRoot":"","sources":["../src/attributor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAE7D,0EAIqD;AAErD,uEAAsE;AA6BtE;;GAEG;AACH,MAAa,UAAU;IAGtB;;OAEG;IACH,YAAmB,cAAoD;QACtE,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,GAAW;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,qBAAU,CAAC,uDAAuD,GAAG,GAAG,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;OAEG;IACI,qBAAqB,CAAC,GAAW;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,OAAO;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;CACD;AAlCD,gCAkCC;AAED;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,UAAU;IACjD,YACC,YAAwE,EACxE,aAA6B,EAC7B,cAAoD;QAEpD,KAAK,CAAC,cAAc,CAAC,CAAC;QACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,EAAE;YAC5D,IAAI,OAAO,CAAC,IAAI,KAAK,sBAAW,CAAC,SAAS,EAAE,CAAC;gBAC5C,IAAA,iBAAM,EACL,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,EACpC,KAAK,CAAC,8DAA8D,CACpE,CAAC;gBACF,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACzD,IAAA,iBAAM,EACL,MAAM,KAAK,SAAS,EACpB,KAAK,CAAC,yDAAyD,CAC/D,CAAC;gBACF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE;oBAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;oBACxB,SAAS,EAAE,OAAO,CAAC,SAAS;iBAC5B,CAAC,CAAC;YACJ,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAzBD,gDAyBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IQuorumClients } from \"@fluidframework/driver-definitions\";\nimport {\n\tMessageType,\n\ttype IDocumentMessage,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { AttributionInfo } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Provides lookup between attribution keys and their associated attribution information.\n * @internal\n */\nexport interface IAttributor {\n\t/**\n\t * Retrieves attribution information associated with a particular key.\n\t * @param key - Attribution key to look up.\n\t * @throws If no attribution information is recorded for that key.\n\t */\n\tgetAttributionInfo(key: number): AttributionInfo;\n\n\t/**\n\t * @param key - Attribution key to look up.\n\t * @returns the attribution information associated with the provided key, or undefined if no information exists.\n\t */\n\ttryGetAttributionInfo(key: number): AttributionInfo | undefined;\n\n\t/**\n\t * @returns an iterable of (attribution key, attribution info) pairs for each stored key.\n\t */\n\tentries(): IterableIterator<[number, AttributionInfo]>;\n\n\t// TODO:\n\t// - GC\n}\n\n/**\n * {@inheritdoc IAttributor}\n */\nexport class Attributor implements IAttributor {\n\tprotected readonly keyToInfo: Map<number, AttributionInfo>;\n\n\t/**\n\t * @param initialEntries - Any entries which should be populated on instantiation.\n\t */\n\tpublic constructor(initialEntries?: Iterable<[number, AttributionInfo]>) {\n\t\tthis.keyToInfo = new Map(initialEntries ?? []);\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.getAttributionInfo}\n\t */\n\tpublic getAttributionInfo(key: number): AttributionInfo {\n\t\tconst result = this.tryGetAttributionInfo(key);\n\t\tif (!result) {\n\t\t\tthrow new UsageError(`Requested attribution information for unstored key: ${key}.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.tryGetAttributionInfo}\n\t */\n\tpublic tryGetAttributionInfo(key: number): AttributionInfo | undefined {\n\t\treturn this.keyToInfo.get(key);\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.entries}\n\t */\n\tpublic entries(): IterableIterator<[number, AttributionInfo]> {\n\t\treturn this.keyToInfo.entries();\n\t}\n}\n\n/**\n * Attributor which listens to an op stream and records entries for each op.\n * Sequence numbers are used as attribution keys.\n */\nexport class OpStreamAttributor extends Attributor implements IAttributor {\n\tpublic constructor(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorumClients: IQuorumClients,\n\t\tinitialEntries?: Iterable<[number, AttributionInfo]>,\n\t) {\n\t\tsuper(initialEntries);\n\t\tdeltaManager.on(\"op\", (message: ISequencedDocumentMessage) => {\n\t\t\tif (message.type === MessageType.Operation) {\n\t\t\t\tassert(\n\t\t\t\t\ttypeof message.clientId === \"string\",\n\t\t\t\t\t0x966 /* Client id should be present and should be of type string */,\n\t\t\t\t);\n\t\t\t\tconst client = quorumClients.getMember(message.clientId);\n\t\t\t\tassert(\n\t\t\t\t\tclient !== undefined,\n\t\t\t\t\t0x967 /* Received message from user not in the quorumClients */,\n\t\t\t\t);\n\t\t\t\tthis.keyToInfo.set(message.sequenceNumber, {\n\t\t\t\t\tuser: client.client.user,\n\t\t\t\t\ttimestamp: message.timestamp,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"attributor.js","sourceRoot":"","sources":["../src/attributor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAE7D,0EAIqD;AAErD,uEAAsE;AA6BtE;;GAEG;AACH,MAAa,UAAU;IACH,SAAS,CAA+B;IAE3D;;OAEG;IACH,YAAmB,cAAoD;QACtE,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,GAAW;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,qBAAU,CAAC,uDAAuD,GAAG,GAAG,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;OAEG;IACI,qBAAqB,CAAC,GAAW;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,OAAO;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;CACD;AAlCD,gCAkCC;AAED;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,UAAU;IACjD,YACC,YAAwE,EACxE,aAA6B,EAC7B,cAAoD;QAEpD,KAAK,CAAC,cAAc,CAAC,CAAC;QACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,EAAE;YAC5D,IAAI,OAAO,CAAC,IAAI,KAAK,sBAAW,CAAC,SAAS,EAAE,CAAC;gBAC5C,IAAA,iBAAM,EACL,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,EACpC,KAAK,CAAC,8DAA8D,CACpE,CAAC;gBACF,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACzD,IAAA,iBAAM,EACL,MAAM,KAAK,SAAS,EACpB,KAAK,CAAC,yDAAyD,CAC/D,CAAC;gBACF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE;oBAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;oBACxB,SAAS,EAAE,OAAO,CAAC,SAAS;iBAC5B,CAAC,CAAC;YACJ,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAzBD,gDAyBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IQuorumClients } from \"@fluidframework/driver-definitions\";\nimport {\n\tMessageType,\n\ttype IDocumentMessage,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { AttributionInfo } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Provides lookup between attribution keys and their associated attribution information.\n * @internal\n */\nexport interface IAttributor {\n\t/**\n\t * Retrieves attribution information associated with a particular key.\n\t * @param key - Attribution key to look up.\n\t * @throws If no attribution information is recorded for that key.\n\t */\n\tgetAttributionInfo(key: number): AttributionInfo;\n\n\t/**\n\t * @param key - Attribution key to look up.\n\t * @returns the attribution information associated with the provided key, or undefined if no information exists.\n\t */\n\ttryGetAttributionInfo(key: number): AttributionInfo | undefined;\n\n\t/**\n\t * @returns an iterable of (attribution key, attribution info) pairs for each stored key.\n\t */\n\tentries(): IterableIterator<[number, AttributionInfo]>;\n\n\t// TODO:\n\t// - GC\n}\n\n/**\n * {@inheritdoc IAttributor}\n */\nexport class Attributor implements IAttributor {\n\tprotected readonly keyToInfo: Map<number, AttributionInfo>;\n\n\t/**\n\t * @param initialEntries - Any entries which should be populated on instantiation.\n\t */\n\tpublic constructor(initialEntries?: Iterable<[number, AttributionInfo]>) {\n\t\tthis.keyToInfo = new Map(initialEntries ?? []);\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.getAttributionInfo}\n\t */\n\tpublic getAttributionInfo(key: number): AttributionInfo {\n\t\tconst result = this.tryGetAttributionInfo(key);\n\t\tif (!result) {\n\t\t\tthrow new UsageError(`Requested attribution information for unstored key: ${key}.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.tryGetAttributionInfo}\n\t */\n\tpublic tryGetAttributionInfo(key: number): AttributionInfo | undefined {\n\t\treturn this.keyToInfo.get(key);\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.entries}\n\t */\n\tpublic entries(): IterableIterator<[number, AttributionInfo]> {\n\t\treturn this.keyToInfo.entries();\n\t}\n}\n\n/**\n * Attributor which listens to an op stream and records entries for each op.\n * Sequence numbers are used as attribution keys.\n */\nexport class OpStreamAttributor extends Attributor implements IAttributor {\n\tpublic constructor(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorumClients: IQuorumClients,\n\t\tinitialEntries?: Iterable<[number, AttributionInfo]>,\n\t) {\n\t\tsuper(initialEntries);\n\t\tdeltaManager.on(\"op\", (message: ISequencedDocumentMessage) => {\n\t\t\tif (message.type === MessageType.Operation) {\n\t\t\t\tassert(\n\t\t\t\t\ttypeof message.clientId === \"string\",\n\t\t\t\t\t0x966 /* Client id should be present and should be of type string */,\n\t\t\t\t);\n\t\t\t\tconst client = quorumClients.getMember(message.clientId);\n\t\t\t\tassert(\n\t\t\t\t\tclient !== undefined,\n\t\t\t\t\t0x967 /* Received message from user not in the quorumClients */,\n\t\t\t\t);\n\t\t\t\tthis.keyToInfo.set(message.sequenceNumber, {\n\t\t\t\t\tuser: client.client.user,\n\t\t\t\t\ttimestamp: message.timest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,WAAW,EACC,gBAAgB,EAAE,gBAAgB;IAGpD;;OAEG;IACI,MAAM,CAAC,UAAU,EAAE,WAAW,GAAG,oBAAoB;IAsB5D;;OAEG;IACI,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,WAAW;CAiBzD;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAC/B,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAClB,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,KAChB,OAAO,CAAC,EAAE,EAAE,EAAE,CAGf,CAAC"}
package/dist/encoders.js CHANGED
@@ -29,6 +29,8 @@ exports.deltaEncoder = {
29
29
  },
30
30
  };
31
31
  class AttributorSerializer {
32
+ makeAttributor;
33
+ timestampEncoder;
32
34
  constructor(makeAttributor, timestampEncoder) {
33
35
  this.makeAttributor = makeAttributor;
34
36
  this.timestampEncoder = timestampEncoder;
@@ -1 +1 @@
1
- {"version":3,"file":"encoders.js","sourceRoot":"","sources":["../src/encoders.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAK7D,2DAAmF;AAWtE,QAAA,YAAY,GAAqB;IAC7C,MAAM,EAAE,CAAC,UAAoB,EAAE,EAAE;QAChC,MAAM,eAAe,GAAa,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5E,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;YACnD,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;YACtC,IAAI,GAAG,SAAS,CAAC;QAClB,CAAC;QAED,OAAO,eAAe,CAAC;IACxB,CAAC;IACD,MAAM,EAAE,CAAC,OAAgB,EAAE,EAAE;QAC5B,IAAA,iBAAM,EACL,KAA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AClB,CAAkB,EACA,EAAE,CAAC,CAAC;IACtB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;CAChD,CAAC,CAAC;AANU,QAAA,KAAK,SAMf","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IUser } from \"@fluidframework/driver-definitions\";\nimport type { AttributionInfo } from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { IAttributor } from \"./attributor.js\";\nimport { type InternedStringId, MutableStringInterner } from \"./stringInterner.js\";\n\nexport interface Encoder<TDecoded, TEncoded> {\n\tencode(decoded: TDecoded): TEncoded;\n\tdecode(encoded: TEncoded): TDecoded;\n}\n\n// Note: the encoded format doesn't matter as long as it's serializable;\n// these types could be weakened.\nexport type TimestampEncoder = Encoder<number[], number[]>;\n\nexport const deltaEncoder: TimestampEncoder = {\n\tencode: (timestamps: number[]) => {\n\t\tconst deltaTimestamps: number[] = Array.from({ length: timestamps.length });\n\t\tlet prev = 0;\n\t\tfor (const [i, timestamp] of timestamps.entries()) {\n\t\t\tdeltaTimestamps[i] = timestamp - prev;\n\t\t\tprev = timestamp;\n\t\t}\n\n\t\treturn deltaTimestamps;\n\t},\n\tdecode: (encoded: unknown) => {\n\t\tassert(\n\t\t\tArray.isArray(encoded),\n\t\t\t0x4b0 /* Encoded timestamps should be an array of numbers */,\n\t\t);\n\t\tconst timestamps: number[] = Array.from({ length: encoded.length });\n\t\tlet cumulativeSum = 0;\n\t\tfor (let i = 0; i < encoded.length; i++) {\n\t\t\tcumulativeSum += encoded[i];\n\t\t\ttimestamps[i] = cumulativeSum;\n\t\t}\n\t\treturn timestamps;\n\t},\n};\n\nexport type IAttributorSerializer = Encoder<IAttributor, SerializedAttributor>;\n\nexport interface SerializedAttributor {\n\tinterner: readonly string[] /* result of calling getSerializable() on a StringInterner */;\n\tseqs: number[];\n\ttimestamps: number[];\n\tattributionRefs: InternedStringId[];\n}\n\nexport class AttributorSerializer implements IAttributorSerializer {\n\tpublic constructor(\n\t\tprivate readonly makeAttributor: (\n\t\t\tentries: Iterable<[number, AttributionInfo]>,\n\t\t) => IAttributor,\n\t\tprivate readonly timestampEncoder: TimestampEncoder,\n\t) {}\n\n\t/**\n\t * {@inheritDoc Encoder.encode}\n\t */\n\tpublic encode(attributor: IAttributor): SerializedAttributor {\n\t\tconst interner = new MutableStringInterner();\n\t\tconst seqs: number[] = [];\n\t\tconst timestamps: number[] = [];\n\t\tconst attributionRefs: InternedStringId[] = [];\n\t\tfor (const [seq, { user, timestamp }] of attributor.entries()) {\n\t\t\tseqs.push(seq);\n\t\t\ttimestamps.push(timestamp);\n\t\t\tconst ref = interner.getOrCreateInternedId(JSON.stringify(user));\n\t\t\tattributionRefs.push(ref);\n\t\t}\n\n\t\tconst serialized: SerializedAttributor = {\n\t\t\tinterner: interner.getSerializable(),\n\t\t\tseqs,\n\t\t\ttimestamps: this.timestampEncoder.encode(timestamps),\n\t\t\tattributionRefs,\n\t\t};\n\n\t\treturn serialized;\n\t}\n\n\t/**\n\t * {@inheritDoc Encoder.decode}\n\t */\n\tpublic decode(encoded: SerializedAttributor): IAttributor {\n\t\tconst interner = new MutableStringInterner(encoded.interner);\n\t\tconst { seqs, timestamps: encodedTimestamps, attributionRefs } = encoded;\n\t\tconst timestamps = this.timestampEncoder.decode(encodedTimestamps);\n\t\tassert(\n\t\t\tseqs.length === timestamps.length && timestamps.length === attributionRefs.length,\n\t\t\t0x4b1 /* serialized attribution columns should have the same length */,\n\t\t);\n\t\tconst entries: [number, AttributionInfo][] = Array.from({ length: seqs.length });\n\t\tfor (const [i, key] of seqs.entries()) {\n\t\t\tconst timestamp = timestamps[i];\n\t\t\tconst ref = attributionRefs[i];\n\t\t\tconst user = JSON.parse(interner.getString(ref)) as IUser;\n\t\t\tentries[i] = [key, { user, timestamp }];\n\t\t}\n\t\treturn this.makeAttributor(entries);\n\t}\n}\n\n/**\n * Creates an encoder which composes `a` and `b`.\n */\nexport const chain = <T1, T2, T3>(\n\ta: Encoder<T1, T2>,\n\tb: Encoder<T2, T3>,\n): Encoder<T1, T3> => ({\n\tencode: (content) => b.encode(a.encode(content)),\n\tdecode: (content) => a.decode(b.decode(content)),\n});\n"]}
1
+ {"version":3,"file":"encoders.js","sourceRoot":"","sources":["../src/encoders.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAK7D,2DAAmF;AAWtE,QAAA,YAAY,GAAqB;IAC7C,MAAM,EAAE,CAAC,UAAoB,EAAE,EAAE;QAChC,MAAM,eAAe,GAAa,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5E,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;YACnD,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;YACtC,IAAI,GAAG,SAAS,CAAC;QAClB,CAAC;QAED,OAAO,eAAe,CAAC;IACxB,CAAC;IACD,MAAM,EAAE,CAAC,OAAgB,EAAE,EAAE;QAC5B,IAAA,iBAAM,EACL,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EACtB,KAAK,CAAC,sDAAsD,CAC5D,CAAC;QACF,MAAM,UAAU,GAAa,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACpE,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC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C,OAAO,CAAC,CAAC;CAChD,CAAC,CAAC;AANU,QAAA,KAAK,SAMf","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IUser } from \"@fluidframework/driver-definitions\";\nimport type { AttributionInfo } from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { IAttributor } from \"./attributor.js\";\nimport { type InternedStringId, MutableStringInterner } from \"./stringInterner.js\";\n\nexport interface Encoder<TDecoded, TEncoded> {\n\tencode(decoded: TDecoded): TEncoded;\n\tdecode(encoded: TEncoded): TDecoded;\n}\n\n// Note: the encoded format doesn't matter as long as it's serializable;\n// these types could be weakened.\nexport type TimestampEncoder = Encoder<number[], number[]>;\n\nexport const deltaEncoder: TimestampEncoder = {\n\tencode: (timestamps: number[]) => {\n\t\tconst deltaTimestamps: number[] = Array.from({ length: timestamps.length });\n\t\tlet prev = 0;\n\t\tfor (const [i, timestamp] of timestamps.entries()) {\n\t\t\tdeltaTimestamps[i] = timestamp - prev;\n\t\t\tprev = timestamp;\n\t\t}\n\n\t\treturn deltaTimestamps;\n\t},\n\tdecode: (encoded: unknown) => {\n\t\tassert(\n\t\t\tArray.isArray(encoded),\n\t\t\t0x4b0 /* Encoded timestamps should be an array of numbers */,\n\t\t);\n\t\tconst timestamps: number[] = Array.from({ length: encoded.length });\n\t\tlet cumulativeSum = 0;\n\t\tfor (let i = 0; i < encoded.length; i++) {\n\t\t\tcumulativeSum += encoded[i];\n\t\t\ttimestamps[i] = cumulativeSum;\n\t\t}\n\t\treturn timestamps;\n\t},\n};\n\nexport type IAttributorSerializer = Encoder<IAttributor, SerializedAttributor>;\n\nexport interface SerializedAttributor {\n\tinterner: readonly string[] /* result of calling getSerializable() on a StringInterner */;\n\tseqs: number[];\n\ttimestamps: number[];\n\tattributionRefs: InternedStringId[];\n}\n\nexport class AttributorSerializer implements IAttributorSerializer {\n\tpublic constructor(\n\t\tprivate readonly makeAttributor: (\n\t\t\tentries: Iterable<[number, AttributionInfo]>,\n\t\t) => IAttributor,\n\t\tprivate readonly timestampEncoder: TimestampEncoder,\n\t) {}\n\n\t/**\n\t * {@inheritDoc Encoder.encode}\n\t */\n\tpublic encode(attributor: IAttributor): SerializedAttributor {\n\t\tconst interner = new MutableStringInterner();\n\t\tconst seqs: number[] = [];\n\t\tconst timestamps: number[] = [];\n\t\tconst attributionRefs: InternedStringId[] = [];\n\t\tfor (const [seq, { user, timestamp }] of attributor.entries()) {\n\t\t\tseqs.push(seq);\n\t\t\ttimestamps.push(timestamp);\n\t\t\tconst ref = interner.getOrCreateInternedId(JSON.stringify(user));\n\t\t\tattributionRefs.push(ref);\n\t\t}\n\n\t\tconst serialized: SerializedAttributor = {\n\t\t\tinterner: interner.getSerializable(),\n\t\t\tseqs,\n\t\t\ttimestamps: this.timestampEncoder.encode(timestamps),\n\t\t\tattributionRefs,\n\t\t};\n\n\t\treturn serialized;\n\t}\n\n\t/**\n\t * {@inheritDoc Encoder.decode}\n\t */\n\tpublic decode(encoded: SerializedAttributor): IAttributor {\n\t\tconst interner = new MutableStringInterner(encoded.interner);\n\t\tconst { seqs, timestamps: encodedTimestamps, attributionRefs } = encoded;\n\t\tconst timestamps = this.timestampEncoder.decode(encodedTimestamps);\n\t\tassert(\n\t\t\tseqs.length === timestamps.length && timestamps.length === attributionRefs.length,\n\t\t\t0x4b1 /* serialized attribution columns should have the same length */,\n\t\t);\n\t\tconst entries: [number, AttributionInfo][] = Array.from({ length: seqs.length });\n\t\tfor (const [i, key] of seqs.entries()) {\n\t\t\tconst timestamp = timestamps[i];\n\t\t\tconst ref = attributionRefs[i];\n\t\t\tconst user = JSON.parse(interner.getString(ref)) as IUser;\n\t\t\tentries[i] = [key, { user, timestamp }];\n\t\t}\n\t\treturn this.makeAttributor(entries);\n\t}\n}\n\n/**\n * Creates an encoder which composes `a` and `b`.\n */\nexport const chain = <T1, T2, T3>(\n\ta: Encoder<T1, T2>,\n\tb: Encoder<T2, T3>,\n): Encoder<T1, T3> => ({\n\tencode: (content) => b.encode(a.encode(content)),\n\tdecode: (content) => a.decode(b.decode(content)),\n});\n"]}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.makeLZ4Encoder = void 0;
7
+ exports.makeLZ4Encoder = makeLZ4Encoder;
8
8
  const client_utils_1 = require("@fluid-internal/client-utils");
9
9
  const lz4js_1 = require("lz4js");
10
10
  // TODO: document this
@@ -30,5 +30,4 @@ function makeLZ4Encoder() {
30
30
  },
31
31
  };
32
32
  }
33
- exports.makeLZ4Encoder = makeLZ4Encoder;
34
33
  //# sourceMappingURL=lz4Encoder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lz4Encoder.js","sourceRoot":"","sources":["../src/lz4Encoder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8E;AAE9E,iCAA6C;AAI7C,sBAAsB;AACtB,qDAAqD;AACrD;;;GAGG;AACH,SAAgB,cAAc;IAC7B,OAAO;QACN,MAAM,EAAE,CAAC,OAAoB,EAAU,EAAE;YACxC,MAAM,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;YACvE,6DAA6D;YAC7D,MAAM,UAAU,GAAG,IAAA,gBAAQ,EAAC,YAAY,CAAoB,CAAC;YAC7D,OAAO,IAAA,6BAAc,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;QACD,MAAM,EAAE,CAAC,iBAAyB,EAAe,EAAE;YAClD,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAA,6BAAc,EAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC/E,6DAA6D;YAC7D,MAAM,YAAY,GAAG,IAAA,kBAAU,EAAC,UAAU,CAAiB,CAAC;YAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAgB,CAAC;YAClF,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,CAAC;AACH,CAAC;AAhBD,wCAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport type { Jsonable } from \"@fluidframework/datastore-definitions/internal\";\nimport { compress, decompress } from \"lz4js\";\n\nimport type { Encoder } from \"./encoders.js\";\n\n// TODO: document this\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @legacy\n * @beta\n */\nexport function makeLZ4Encoder<T>(): Encoder<Jsonable<T>, string> {\n\treturn {\n\t\tencode: (decoded: Jsonable<T>): string => {\n\t\t\tconst uncompressed = new TextEncoder().encode(JSON.stringify(decoded));\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n\t\t\tconst compressed = compress(uncompressed) as ArrayBufferLike;\n\t\t\treturn bufferToString(compressed, \"base64\");\n\t\t},\n\t\tdecode: (serializedSummary: string): Jsonable<T> => {\n\t\t\tconst compressed = new Uint8Array(stringToBuffer(serializedSummary, \"base64\"));\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n\t\t\tconst uncompressed = decompress(compressed) as BufferSource;\n\t\t\tconst decoded = JSON.parse(new TextDecoder().decode(uncompressed)) as Jsonable<T>;\n\t\t\treturn decoded;\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"lz4Encoder.js","sourceRoot":"","sources":["../src/lz4Encoder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAcH,wCAgBC;AA5BD,+DAA8E;AAE9E,iCAA6C;AAI7C,sBAAsB;AACtB,qDAAqD;AACrD;;;GAGG;AACH,SAAgB,cAAc;IAC7B,OAAO;QACN,MAAM,EAAE,CAAC,OAAoB,EAAU,EAAE;YACxC,MAAM,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;YACvE,6DAA6D;YAC7D,MAAM,UAAU,GAAG,IAAA,gBAAQ,EAAC,YAAY,CAAoB,CAAC;YAC7D,OAAO,IAAA,6BAAc,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;QACD,MAAM,EAAE,CAAC,iBAAyB,EAAe,EAAE;YAClD,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAA,6BAAc,EAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC/E,6DAA6D;YAC7D,MAAM,YAAY,GAAG,IAAA,kBAAU,EAAC,UAAU,CAAiB,CAAC;YAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAgB,CAAC;YAClF,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport type { Jsonable } from \"@fluidframework/datastore-definitions/internal\";\nimport { compress, decompress } from \"lz4js\";\n\nimport type { Encoder } from \"./encoders.js\";\n\n// TODO: document this\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @legacy\n * @beta\n */\nexport function makeLZ4Encoder<T>(): Encoder<Jsonable<T>, string> {\n\treturn {\n\t\tencode: (decoded: Jsonable<T>): string => {\n\t\t\tconst uncompressed = new TextEncoder().encode(JSON.stringify(decoded));\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n\t\t\tconst compressed = compress(uncompressed) as ArrayBufferLike;\n\t\t\treturn bufferToString(compressed, \"base64\");\n\t\t},\n\t\tdecode: (serializedSummary: string): Jsonable<T> => {\n\t\t\tconst compressed = new Uint8Array(stringToBuffer(serializedSummary, \"base64\"));\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n\t\t\tconst uncompressed = decompress(compressed) as BufferSource;\n\t\t\tconst decoded = JSON.parse(new TextDecoder().decode(uncompressed)) as Jsonable<T>;\n\t\t\treturn decoded;\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mixinAttributor.d.ts","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAG9E,OAAO,KAAK,EACX,qBAAqB,EAErB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAIN,KAAK,kBAAkB,EACvB,MAAM,0BAA0B,CAAC;AAGlC;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAMzC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UACrB,uBAAuB,KAC3B,uBAgEqC,CAAC"}
1
+ {"version":3,"file":"mixinAttributor.d.ts","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAG9E,OAAO,KAAK,EACX,qBAAqB,EAErB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAIN,KAAK,kBAAkB,EACvB,MAAM,0BAA0B,CAAC;AAGlC;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAMzC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC3B,OAAM,OAAO,gBAAmC,KAC9C,OAAO,gBAgE8B,CAAC"}
@@ -4,7 +4,8 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.mixinAttributor = exports.getRuntimeAttributor = void 0;
7
+ exports.mixinAttributor = void 0;
8
+ exports.getRuntimeAttributor = getRuntimeAttributor;
8
9
  const internal_1 = require("@fluidframework/container-runtime/internal");
9
10
  const internal_2 = require("@fluidframework/core-utils/internal");
10
11
  const internal_3 = require("@fluidframework/telemetry-utils/internal");
@@ -21,7 +22,6 @@ async function getRuntimeAttributor(runtime) {
21
22
  const runtimeAttributor = (await entryPoint?.get());
22
23
  return runtimeAttributor?.IRuntimeAttributor;
23
24
  }
24
- exports.getRuntimeAttributor = getRuntimeAttributor;
25
25
  /**
26
26
  * Mixes in logic to load and store runtime-based attribution functionality.
27
27
  *
@@ -1 +1 @@
1
- {"version":3,"file":"mixinAttributor.js","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAA8E;AAE9E,kEAA6D;AAK7D,uEAAqF;AAErF,qEAKkC;AAClC,iGAAkF;AAElF;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB,CACzC,OAA8B;IAE9B,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,iDAAwB,CAAC,CAAC;IACzF,MAAM,iBAAiB,GAAG,CAAC,MAAM,UAAU,EAAE,GAAG,EAAE,CAEtC,CAAC;IACb,OAAO,iBAAiB,EAAE,kBAAkB,CAAC;AAC9C,CAAC;AARD,oDAQC;AAED;;;;;;;GAOG;AACI,MAAM,eAAe,GAAG,CAC9B,OAAgC,2BAAgB,EACtB,EAAE,CAC5B,MAAM,8BAA+B,SAAQ,IAAI;IACzC,MAAM,CAAU,KAAK,CAAC,WAAW,CACvC,MAA8C;QAE9C,MAAM,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,oBAAoB,GAAG,8BAAoE,GAC3F,GAAG,MAAM,CAAC;QAEX,MAAM,EAAE,GAAG,IAAA,oCA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iBAAM,EACL,MAAM,KAAK,SAAS,EACpB,KAAK,CAAC,mDAAmD,CACzD,CAAC;gBACF,iBAAiB,GAAG,CAAC,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAuB,CAAC;gBAC7E,IAAA,iBAAM,EAAC,iBAAiB,KAAK,SAAS,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACnF,CAAC;QACF,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACqC,CAAC;AAlE5B,QAAA,eAAe,mBAkEa","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ContainerRuntime } from \"@fluidframework/container-runtime/internal\";\nimport type { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIContainerRuntimeBase,\n\tIFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tattributorDataStoreAlias,\n\tenableOnNewFileKey,\n\ttype IProvideRuntimeAttributor,\n\ttype IRuntimeAttributor,\n} from \"./attributorContracts.js\";\nimport { RuntimeAttributorFactory } from \"./runtimeAttributorDataStoreFactory.js\";\n\n/**\n * Utility function to get the runtime attributor from the container runtime.\n * @param runtime - container runtime from which attributor is to be fetched.\n * @returns IRuntimeAttributor if it exists, otherwise undefined.\n * @internal\n */\nexport async function getRuntimeAttributor(\n\truntime: IContainerRuntimeBase,\n): Promise<IRuntimeAttributor | undefined> {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(attributorDataStoreAlias);\n\tconst runtimeAttributor = (await entryPoint?.get()) as\n\t\t| FluidObject<IProvideRuntimeAttributor>\n\t\t| undefined;\n\treturn runtimeAttributor?.IRuntimeAttributor;\n}\n\n/**\n * Mixes in logic to load and store runtime-based attribution functionality.\n *\n * Existing documents without stored attributor will not start storing attribution information. We only create the attributor\n * if its tracking is enabled and we are creating a new document.\n * @param Base - base class, inherits from FluidAttributorRuntime\n * @internal\n */\nexport const mixinAttributor = (\n\tBase: typeof ContainerRuntime = ContainerRuntime,\n): typeof ContainerRuntime =>\n\tclass ContainerRuntimeWithAttributor extends Base {\n\t\tpublic static override async loadRuntime(\n\t\t\tparams: Parameters<typeof Base.loadRuntime>[0],\n\t\t): Promise<ContainerRuntime> {\n\t\t\tconst {\n\t\t\t\tcontext,\n\t\t\t\tregistry,\n\t\t\t\texisting,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\tcontainerRuntimeCtor = ContainerRuntimeWithAttributor as unknown as typeof ContainerRuntime,\n\t\t\t} = params;\n\n\t\t\tconst mc = loggerToMonitoringContext(context.taggedLogger);\n\t\t\tconst factory = new RuntimeAttributorFactory();\n\t\t\t// Wrap the registry to also include the attributor factory\n\t\t\tconst registryWithAttributor: IFluidDataStoreRegistry = {\n\t\t\t\tget IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\t\t\t\treturn registryWithAttributor;\n\t\t\t\t},\n\t\t\t\tget: async (name: string) => {\n\t\t\t\t\tif (name === RuntimeAttributorFactory.type) {\n\t\t\t\t\t\treturn factory;\n\t\t\t\t\t}\n\t\t\t\t\treturn registry.get(name);\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst shouldTrackAttribution = mc.config.getBoolean(enableOnNewFileKey) ?? false;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tconst { options } = context;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t(options.attribution ??= {}).track = true;\n\t\t\t}\n\n\t\t\tconst runtime = await Base.loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistry: registryWithAttributor,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\texisting,\n\t\t\t\tcontainerRuntimeCtor,\n\t\t\t});\n\n\t\t\tlet runtimeAttributor: IRuntimeAttributor | undefined;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tif (existing) {\n\t\t\t\t\truntimeAttributor = await getRuntimeAttributor(runtime);\n\t\t\t\t} else {\n\t\t\t\t\tconst datastore = await runtime.createDataStore(RuntimeAttributorFactory.type);\n\t\t\t\t\tconst result = await datastore.trySetAlias(attributorDataStoreAlias);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tresult === \"Success\",\n\t\t\t\t\t\t0xa1b /* Failed to set alias for attributor data store */,\n\t\t\t\t\t);\n\t\t\t\t\truntimeAttributor = (await datastore.entryPoint.get()) as IRuntimeAttributor;\n\t\t\t\t\tassert(runtimeAttributor !== undefined, 0xa1c /* Attributor should be defined */);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn runtime;\n\t\t}\n\t} as unknown as typeof ContainerRuntime;\n"]}
1
+ {"version":3,"file":"mixinAttributor.js","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAyBH,oDAQC;AA/BD,yEAA8E;AAE9E,kEAA6D;AAK7D,uEAAqF;AAErF,qEAKkC;AAClC,iGAAkF;AAElF;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB,CACzC,OAA8B;IAE9B,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,iDAAwB,CAAC,CAAC;IACzF,MAAM,iBAAiB,GAAG,CAAC,MAAM,UAAU,EAAE,GAAG,EAAE,CAEtC,CAAC;IACb,OAAO,iBAAiB,EAAE,kBAAkB,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACI,MAAM,eAAe,GAAG,CAC9B,OAAgC,2BAAgB,EACtB,EAAE,CAC5B,MAAM,8BAA+B,SAAQ,IAAI;IACzC,MAAM,CAAU,KAAK,CAAC,WAAW,CACvC,MAA8C;QAE9C,MAAM,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,iBAAiB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C,IAAI,CAAC,CAAC;gBAC/E,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,iDAAwB,CAAC,CAAC;gBACrE,IAAA,iBAAM,EACL,MAAM,KAAK,SAAS,EACpB,KAAK,CAAC,mDAAmD,CACzD,CAAC;gBACF,iBAAiB,GAAG,CAAC,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAuB,CAAC;gBAC7E,IAAA,iBAAM,EAAC,iBAAiB,KAAK,SAAS,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACnF,CAAC;QACF,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACqC,CAAC;AAlE5B,QAAA,eAAe,mBAkEa","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ContainerRuntime } from \"@fluidframework/container-runtime/internal\";\nimport type { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIContainerRuntimeBase,\n\tIFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tattributorDataStoreAlias,\n\tenableOnNewFileKey,\n\ttype IProvideRuntimeAttributor,\n\ttype IRuntimeAttributor,\n} from \"./attributorContracts.js\";\nimport { RuntimeAttributorFactory } from \"./runtimeAttributorDataStoreFactory.js\";\n\n/**\n * Utility function to get the runtime attributor from the container runtime.\n * @param runtime - container runtime from which attributor is to be fetched.\n * @returns IRuntimeAttributor if it exists, otherwise undefined.\n * @internal\n */\nexport async function getRuntimeAttributor(\n\truntime: IContainerRuntimeBase,\n): Promise<IRuntimeAttributor | undefined> {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(attributorDataStoreAlias);\n\tconst runtimeAttributor = (await entryPoint?.get()) as\n\t\t| FluidObject<IProvideRuntimeAttributor>\n\t\t| undefined;\n\treturn runtimeAttributor?.IRuntimeAttributor;\n}\n\n/**\n * Mixes in logic to load and store runtime-based attribution functionality.\n *\n * Existing documents without stored attributor will not start storing attribution information. We only create the attributor\n * if its tracking is enabled and we are creating a new document.\n * @param Base - base class, inherits from FluidAttributorRuntime\n * @internal\n */\nexport const mixinAttributor = (\n\tBase: typeof ContainerRuntime = ContainerRuntime,\n): typeof ContainerRuntime =>\n\tclass ContainerRuntimeWithAttributor extends Base {\n\t\tpublic static override async loadRuntime(\n\t\t\tparams: Parameters<typeof Base.loadRuntime>[0],\n\t\t): Promise<ContainerRuntime> {\n\t\t\tconst {\n\t\t\t\tcontext,\n\t\t\t\tregistry,\n\t\t\t\texisting,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\tcontainerRuntimeCtor = ContainerRuntimeWithAttributor as unknown as typeof ContainerRuntime,\n\t\t\t} = params;\n\n\t\t\tconst mc = loggerToMonitoringContext(context.taggedLogger);\n\t\t\tconst factory = new RuntimeAttributorFactory();\n\t\t\t// Wrap the registry to also include the attributor factory\n\t\t\tconst registryWithAttributor: IFluidDataStoreRegistry = {\n\t\t\t\tget IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\t\t\t\treturn registryWithAttributor;\n\t\t\t\t},\n\t\t\t\tget: async (name: string) => {\n\t\t\t\t\tif (name === RuntimeAttributorFactory.type) {\n\t\t\t\t\t\treturn factory;\n\t\t\t\t\t}\n\t\t\t\t\treturn registry.get(name);\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst shouldTrackAttribution = mc.config.getBoolean(enableOnNewFileKey) ?? false;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tconst { options } = context;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t(options.attribution ??= {}).track = true;\n\t\t\t}\n\n\t\t\tconst runtime = await Base.loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistry: registryWithAttributor,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\texisting,\n\t\t\t\tcontainerRuntimeCtor,\n\t\t\t});\n\n\t\t\tlet runtimeAttributor: IRuntimeAttributor | undefined;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tif (existing) {\n\t\t\t\t\truntimeAttributor = await getRuntimeAttributor(runtime);\n\t\t\t\t} else {\n\t\t\t\t\tconst datastore = await runtime.createDataStore(RuntimeAttributorFactory.type);\n\t\t\t\t\tconst result = await datastore.trySetAlias(attributorDataStoreAlias);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tresult === \"Success\",\n\t\t\t\t\t\t0xa1b /* Failed to set alias for attributor data store */,\n\t\t\t\t\t);\n\t\t\t\t\truntimeAttributor = (await datastore.entryPoint.get()) as IRuntimeAttributor;\n\t\t\t\t\tassert(runtimeAttributor !== undefined, 0xa1c /* Attributor should be defined */);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn runtime;\n\t\t}\n\t} as unknown as typeof ContainerRuntime;\n"]}
@@ -13,13 +13,6 @@ const attributorContracts_js_1 = require("./attributorContracts.js");
13
13
  const encoders_js_1 = require("./encoders.js");
14
14
  const lz4Encoder_js_1 = require("./lz4Encoder.js");
15
15
  class RuntimeAttributor {
16
- constructor() {
17
- this.encoder = {
18
- encode: internal_1.unreachableCase,
19
- decode: internal_1.unreachableCase,
20
- };
21
- this.isEnabled = true;
22
- }
23
16
  get IRuntimeAttributor() {
24
17
  return this;
25
18
  }
@@ -47,6 +40,12 @@ class RuntimeAttributor {
47
40
  }
48
41
  return this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;
49
42
  }
43
+ encoder = {
44
+ encode: internal_1.unreachableCase,
45
+ decode: internal_1.unreachableCase,
46
+ };
47
+ opAttributor;
48
+ isEnabled = true;
50
49
  async initialize(deltaManager, quorum, baseSnapshotForAttributorTree, readBlob) {
51
50
  this.encoder = (0, encoders_js_1.chain)(new encoders_js_1.AttributorSerializer((entries) => new attributor_js_1.OpStreamAttributor(deltaManager, quorum, entries), encoders_js_1.deltaEncoder), (0, lz4Encoder_js_1.makeLZ4Encoder)());
52
51
  if (baseSnapshotForAttributorTree === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeAttributor.js","sourceRoot":"","sources":["../src/runtimeAttributor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAE9D,kEAA8E;AAY9E,qEAA4E;AAE5E,mDAAuE;AACvE,qEAA+E;AAC/E,+CAAwF;AACxF,mDAAiD;AAEjD,MAAa,iBAAiB;IAA9B;QAuCS,YAAO,GAAiC;YAC/C,MAAM,EAAE,0BAAe;YACvB,MAAM,EAAE,0BAAe;SACvB,CAAC;QAGK,cAAS,GAAG,IAAI,CAAC;IAuCzB,CAAC;IAnFA,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,GAAG,CAAC,GAAmB;QAC7B,IAAA,iBAAM,EACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,mFAAmF,CACzF,CAAC;QAEF,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,wGAAwG;YACxG,0GAA0G;YAC1G,wGAAwG;YACxG,qGAAqG;YACrG,uDAAuD;YACvD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;IAEM,GAAG,CAAC,GAAmB;QAC7B,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC;QACd,CAAC;QAED,IAAI,G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OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;CACD;AApFD,8CAoFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIDocumentMessage,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tAttributionInfo,\n\tAttributionKey,\n\tISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport { OpStreamAttributor, type IAttributor } from \"./attributor.js\";\nimport { opBlobName, type IRuntimeAttributor } from \"./attributorContracts.js\";\nimport { AttributorSerializer, chain, deltaEncoder, type Encoder } from \"./encoders.js\";\nimport { makeLZ4Encoder } from \"./lz4Encoder.js\";\n\nexport class RuntimeAttributor implements IRuntimeAttributor {\n\tpublic get IRuntimeAttributor(): IRuntimeAttributor {\n\t\treturn this;\n\t}\n\n\tpublic get(key: AttributionKey): AttributionInfo {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */,\n\t\t);\n\n\t\tif (key.type === \"detached\") {\n\t\t\tthrow new Error(\"Attribution of detached keys is not yet supported.\");\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\t// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current\n\t\t\t// client id in the audience. However, for read->write client transition, the container might have not yet\n\t\t\t// received a client id. This is left as a TODO as it might be more easily solved once the detached case\n\t\t\t// is settled (e.g. if it's reasonable for the host to know the current user information at container\n\t\t\t// creation time, we could just use that here as well).\n\t\t\tthrow new Error(\"Attribution of local keys is not yet supported.\");\n\t\t}\n\n\t\treturn this.opAttributor.getAttributionInfo(key.seq);\n\t}\n\n\tpublic has(key: AttributionKey): boolean {\n\t\tif (key.type === \"detached\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;\n\t}\n\n\tprivate encoder: Encoder<IAttributor, string> = {\n\t\tencode: unreachableCase,\n\t\tdecode: unreachableCase,\n\t};\n\n\tprivate opAttributor: IAttributor | undefined;\n\tpublic isEnabled = true;\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tthis.encoder = chain(\n\t\t\tnew AttributorSerializer(\n\t\t\t\t(entries) => new OpStreamAttributor(deltaManager, quorum, entries),\n\t\t\t\tdeltaEncoder,\n\t\t\t),\n\t\t\tmakeLZ4Encoder(),\n\t\t);\n\n\t\tif (baseSnapshotForAttributorTree === undefined) {\n\t\t\tthis.opAttributor = new OpStreamAttributor(deltaManager, quorum);\n\t\t} else {\n\t\t\tconst id: string | undefined = baseSnapshotForAttributorTree.blobs[opBlobName];\n\t\t\tassert(\n\t\t\t\tid !== undefined,\n\t\t\t\t0x50a /* Attributor tree should have op attributor summary blob. */,\n\t\t\t);\n\t\t\tconst blobContents = await readBlob(id);\n\t\t\tconst attributorSnapshot = bufferToString(blobContents, \"utf8\");\n\t\t\tthis.opAttributor = this.encoder.decode(attributorSnapshot);\n\t\t}\n\t}\n\n\tpublic summarizeOpAttributor(): ISummaryTreeWithStats {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0xa1d /* RuntimeAttributor should be initialized before summarization */,\n\t\t);\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));\n\t\treturn builder.getSummaryTree();\n\t}\n}\n"]}
1
+ {"version":3,"file":"runtimeAttributor.js","sourceRoot":"","sources":["../src/runtimeAttributor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAE9D,kEAA8E;AAY9E,qEAA4E;AAE5E,mDAAuE;AACvE,qEAA+E;AAC/E,+CAAwF;AACxF,mDAAiD;AAEjD,MAAa,iBAAiB;IAC7B,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,GAAG,CAAC,GAAmB;QAC7B,IAAA,iBAAM,EACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,mFAAmF,CACzF,CAAC;QAEF,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,wGAAwG;YACxG,0GAA0G;YAC1G,wGAAwG;YACxG,qGAAqG;YACrG,uDAAuD;YACvD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;IAEM,GAAG,CAAC,GAAmB;QAC7B,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC;QACd,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,EAAE,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;IACxE,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,CAAC,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;CACD;AApFD,8CAoFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIDocumentMessage,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tAttributionInfo,\n\tAttributionKey,\n\tISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport { OpStreamAttributor, type IAttributor } from \"./attributor.js\";\nimport { opBlobName, type IRuntimeAttributor } from \"./attributorContracts.js\";\nimport { AttributorSerializer, chain, deltaEncoder, type Encoder } from \"./encoders.js\";\nimport { makeLZ4Encoder } from \"./lz4Encoder.js\";\n\nexport class RuntimeAttributor implements IRuntimeAttributor {\n\tpublic get IRuntimeAttributor(): IRuntimeAttributor {\n\t\treturn this;\n\t}\n\n\tpublic get(key: AttributionKey): AttributionInfo {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */,\n\t\t);\n\n\t\tif (key.type === \"detached\") {\n\t\t\tthrow new Error(\"Attribution of detached keys is not yet supported.\");\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\t// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current\n\t\t\t// client id in the audience. However, for read->write client transition, the container might have not yet\n\t\t\t// received a client id. This is left as a TODO as it might be more easily solved once the detached case\n\t\t\t// is settled (e.g. if it's reasonable for the host to know the current user information at container\n\t\t\t// creation time, we could just use that here as well).\n\t\t\tthrow new Error(\"Attribution of local keys is not yet supported.\");\n\t\t}\n\n\t\treturn this.opAttributor.getAttributionInfo(key.seq);\n\t}\n\n\tpublic has(key: AttributionKey): boolean {\n\t\tif (key.type === \"detached\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;\n\t}\n\n\tprivate encoder: Encoder<IAttributor, string> = {\n\t\tencode: unreachableCase,\n\t\tdecode: unreachableCase,\n\t};\n\n\tprivate opAttributor: IAttributor | undefined;\n\tpublic isEnabled = true;\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tthis.encoder = chain(\n\t\t\tnew AttributorSerializer(\n\t\t\t\t(entries) => new OpStreamAttributor(deltaManager, quorum, entries),\n\t\t\t\tdeltaEncoder,\n\t\t\t),\n\t\t\tmakeLZ4Encoder(),\n\t\t);\n\n\t\tif (baseSnapshotForAttributorTree === undefined) {\n\t\t\tthis.opAttributor = new OpStreamAttributor(deltaManager, quorum);\n\t\t} else {\n\t\t\tconst id: string | undefined = baseSnapshotForAttributorTree.blobs[opBlobName];\n\t\t\tassert(\n\t\t\t\tid !== undefined,\n\t\t\t\t0x50a /* Attributor tree should have op attributor summary blob. */,\n\t\t\t);\n\t\t\tconst blobContents = await readBlob(id);\n\t\t\tconst attributorSnapshot = bufferToString(blobContents, \"utf8\");\n\t\t\tthis.opAttributor = this.encoder.decode(attributorSnapshot);\n\t\t}\n\t}\n\n\tpublic summarizeOpAttributor(): ISummaryTreeWithStats {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0xa1d /* RuntimeAttributor should be initialized before summarization */,\n\t\t);\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));\n\t\treturn builder.getSummaryTree();\n\t}\n}\n"]}
@@ -16,12 +16,10 @@ const runtimeAttributor_js_1 = require("./runtimeAttributor.js");
16
16
  * Data store channel for the runtime attributor. This channel is responsible for storing and managing the
17
17
  */
18
18
  class RuntimeAttributorDataStoreChannel extends client_utils_1.TypedEventEmitter {
19
+ dataStoreContext;
19
20
  constructor(dataStoreContext, existing) {
20
21
  super();
21
22
  this.dataStoreContext = dataStoreContext;
22
- this._disposed = false;
23
- this.isEnabled = true;
24
- this.deferredAttached = new internal_2.Deferred();
25
23
  this.runtimeAttributor = new runtimeAttributor_js_1.RuntimeAttributor();
26
24
  this.mc = (0, internal_5.createChildMonitoringContext)({
27
25
  logger: dataStoreContext.baseLogger,
@@ -46,12 +44,19 @@ class RuntimeAttributorDataStoreChannel extends client_utils_1.TypedEventEmitter
46
44
  get IFluidDataStoreChannel() {
47
45
  return this;
48
46
  }
47
+ _disposed = false;
49
48
  get disposed() {
50
49
  return this._disposed;
51
50
  }
52
51
  dispose() {
53
52
  this._disposed = true;
54
53
  }
54
+ runtimeAttributor;
55
+ isEnabled = true;
56
+ attachState;
57
+ visibilityState;
58
+ deferredAttached = new internal_2.Deferred();
59
+ mc;
55
60
  get logger() {
56
61
  return this.mc.logger;
57
62
  }
@@ -139,6 +144,10 @@ class RuntimeAttributorDataStoreChannel extends client_utils_1.TypedEventEmitter
139
144
  // Should not rollback anything from the attributor as it does not send ops yet.
140
145
  throw new Error("Should not rollback anything from the attributor");
141
146
  }
147
+ /**
148
+ * {@inheritdoc IFluidDataStoreChannel.entryPoint}
149
+ */
150
+ entryPoint;
142
151
  /**
143
152
  * {@inheritdoc IFluidDataStoreChannel.request}
144
153
  */
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeAttributorDataStoreChannel.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreChannel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+D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AC;gBAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACvB,MAAM;YACP,CAAC;YACD,KAAK,sBAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC3B,IAAA,iBAAM,EACL,IAAI,CAAC,eAAe,KAAK,0BAAe,CAAC,eAAe,EACxD,KAAK,CAAC,8DAA8D,CACpE,CAAC;gBACF,IAAI,CAAC,WAAW,GAAG,sBAAW,CAAC,QAAQ,CAAC;gBACxC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACtB,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,IAAA,0BAAe,EAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAzND,8EAyNC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype IDeltaManager,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject, IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport type { IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, Deferred, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore/internal\";\nimport type { IFluidDataStoreRuntimeEvents } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype IGarbageCollectionData,\n\ttype IFluidDataStoreChannel,\n\ttype IFluidDataStoreContext,\n\ttype IInboundSignalMessage,\n\tVisibilityState,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n\ttype IRuntimeMessageCollection,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tcreateChildMonitoringContext,\n\ttype MonitoringContext,\n\traiseConnectedEvent,\n\ttype TelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributor } from \"./runtimeAttributor.js\";\n\n/**\n * Data store channel for the runtime attributor. This channel is responsible for storing and managing the\n */\nexport class RuntimeAttributorDataStoreChannel\n\textends TypedEventEmitter<IFluidDataStoreRuntimeEvents>\n\timplements IFluidDataStoreChannel\n{\n\tpublic constructor(\n\t\tpublic readonly dataStoreContext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t) {\n\t\tsuper();\n\t\tthis.runtimeAttributor = new RuntimeAttributor();\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: dataStoreContext.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\t\tthis.attachState = dataStoreContext.attachState;\n\t\tif (existing) {\n\t\t\tthis.visibilityState =\n\t\t\t\tdataStoreContext.attachState === AttachState.Detached\n\t\t\t\t\t? VisibilityState.LocallyVisible\n\t\t\t\t\t: VisibilityState.GloballyVisible;\n\t\t} else {\n\t\t\tthis.visibilityState = VisibilityState.NotVisible;\n\t\t}\n\t\t// If it's existing we know it has been attached.\n\t\tif (existing) {\n\t\t\tthis.deferredAttached.resolve();\n\t\t}\n\t\tthis.entryPoint = new FluidObjectHandle<FluidObject>(\n\t\t\tthis.runtimeAttributor,\n\t\t\t\"\",\n\t\t\tdataStoreContext.IFluidHandleContext,\n\t\t);\n\t}\n\n\tpublic get IFluidDataStoreChannel(): IFluidDataStoreChannel {\n\t\treturn this;\n\t}\n\n\tprivate _disposed = false;\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis._disposed = true;\n\t}\n\n\tprivate readonly runtimeAttributor: RuntimeAttributor;\n\tpublic isEnabled = true;\n\tpublic attachState: AttachState;\n\tpublic visibilityState: VisibilityState;\n\tprivate readonly deferredAttached = new Deferred<void>();\n\tprivate readonly mc: MonitoringContext;\n\tpublic get logger(): TelemetryLoggerExt {\n\t\treturn this.mc.logger;\n\t}\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tawait this.runtimeAttributor.initialize(\n\t\t\tdeltaManager,\n\t\t\tquorum,\n\t\t\tbaseSnapshotForAttributorTree,\n\t\t\treadBlob,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.makeVisibleAndAttachGraph}\n\t */\n\tpublic makeVisibleAndAttachGraph(): void {\n\t\tif (this.visibilityState !== VisibilityState.NotVisible) {\n\t\t\treturn;\n\t\t}\n\t\tthis.visibilityState = VisibilityState.LocallyVisible;\n\n\t\tthis.dataStoreContext.makeLocallyVisible();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachSummary}\n\t */\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachGCData}\n\t */\n\tpublic getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData {\n\t\treturn { gcNodes: {} };\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.processMessages}\n\t */\n\tpublic processMessages(messageCollection: IRuntimeMessageCollection): void {\n\t\tthrow new Error(\"Attributor should not receive messages yet\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.processSignal}\n\t */\n\tpublic processSignal(message: IInboundSignalMessage, local: boolean): void {\n\t\tthrow new Error(\"Attributor should not receive signals\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getGCData}\n\t */\n\tpublic async getGCData(fullGC?: boolean): Promise<IGarbageCollectionData> {\n\t\t// Nothing to be GCed from the attributor.\n\t\tconst garbageCollectionData: IGarbageCollectionData = { gcNodes: {} };\n\t\treturn garbageCollectionData;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.updateUsedRoutes}\n\t */\n\tpublic updateUsedRoutes(usedRoutes: string[]): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setConnectionState}\n\t */\n\tpublic setConnectionState(connected: boolean, clientId?: string): void {\n\t\traiseConnectedEvent(this.logger, this, connected, clientId);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.reSubmit}\n\t */\n\tpublic reSubmit(): void {\n\t\t// Should not resubmit anything from the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not resubmit anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.applyStashedOp}\n\t */\n\tpublic async applyStashedOp(content: unknown): Promise<unknown> {\n\t\t// Should not apply stashed ops to the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not apply stashed ops to the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.rollback}\n\t */\n\tpublic rollback?(type: string, content: unknown, localOpMetadata: unknown): void {\n\t\t// Should not rollback anything from the attributor as it does not send ops yet.\n\t\tthrow new Error(\"Should not rollback anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.entryPoint}\n\t */\n\tpublic readonly entryPoint: IFluidHandleInternal<FluidObject>;\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.request}\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\t// Should not request anything from the attributor as the attributor does not have any channels further.\n\t\tthrow new Error(\"Should not request anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setAttachState}\n\t */\n\tpublic setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {\n\t\tswitch (attachState) {\n\t\t\tcase AttachState.Attaching: {\n\t\t\t\tthis.attachState = AttachState.Attaching;\n\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.LocallyVisible,\n\t\t\t\t\t0xa1e /* Data store should be locally visible before it can become globally visible. */,\n\t\t\t\t);\n\n\t\t\t\t// Mark the data store globally visible and make its child channels visible as well.\n\t\t\t\tthis.visibilityState = VisibilityState.GloballyVisible;\n\n\t\t\t\t// This promise resolution will be moved to attached event once we fix the scheduler.\n\t\t\t\tthis.deferredAttached.resolve();\n\t\t\t\tthis.emit(\"attaching\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase AttachState.Attached: {\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.GloballyVisible,\n\t\t\t\t\t0xa1f /* Data store should be globally visible when its attached. */,\n\t\t\t\t);\n\t\t\t\tthis.attachState = AttachState.Attached;\n\t\t\t\tthis.emit(\"attached\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(attachState, \"unreached\");\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"runtimeAttributorDataStoreChannel.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreChannel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,6EAGwD;AAGxD,kEAAwF;AACxF,iEAAuE;AAQvE,2EASsD;AACtD,uEAKkD;AAElD,iEAA2D;AAE3D;;GAEG;AACH,MAAa,iCACZ,SAAQ,gCAA+C;IAItC;IADjB,YACiB,gBAAwC,EACxD,QAAiB;QAEjB,KAAK,EAAE,CAA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AW,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC3B,IAAA,iBAAM,EACL,IAAI,CAAC,eAAe,KAAK,0BAAe,CAAC,eAAe,EACxD,KAAK,CAAC,8DAA8D,CACpE,CAAC;gBACF,IAAI,CAAC,WAAW,GAAG,sBAAW,CAAC,QAAQ,CAAC;gBACxC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACtB,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,IAAA,0BAAe,EAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAzND,8EAyNC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype IDeltaManager,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject, IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport type { IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, Deferred, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore/internal\";\nimport type { IFluidDataStoreRuntimeEvents } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype IGarbageCollectionData,\n\ttype IFluidDataStoreChannel,\n\ttype IFluidDataStoreContext,\n\ttype IInboundSignalMessage,\n\tVisibilityState,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n\ttype IRuntimeMessageCollection,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tcreateChildMonitoringContext,\n\ttype MonitoringContext,\n\traiseConnectedEvent,\n\ttype TelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributor } from \"./runtimeAttributor.js\";\n\n/**\n * Data store channel for the runtime attributor. This channel is responsible for storing and managing the\n */\nexport class RuntimeAttributorDataStoreChannel\n\textends TypedEventEmitter<IFluidDataStoreRuntimeEvents>\n\timplements IFluidDataStoreChannel\n{\n\tpublic constructor(\n\t\tpublic readonly dataStoreContext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t) {\n\t\tsuper();\n\t\tthis.runtimeAttributor = new RuntimeAttributor();\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: dataStoreContext.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\t\tthis.attachState = dataStoreContext.attachState;\n\t\tif (existing) {\n\t\t\tthis.visibilityState =\n\t\t\t\tdataStoreContext.attachState === AttachState.Detached\n\t\t\t\t\t? VisibilityState.LocallyVisible\n\t\t\t\t\t: VisibilityState.GloballyVisible;\n\t\t} else {\n\t\t\tthis.visibilityState = VisibilityState.NotVisible;\n\t\t}\n\t\t// If it's existing we know it has been attached.\n\t\tif (existing) {\n\t\t\tthis.deferredAttached.resolve();\n\t\t}\n\t\tthis.entryPoint = new FluidObjectHandle<FluidObject>(\n\t\t\tthis.runtimeAttributor,\n\t\t\t\"\",\n\t\t\tdataStoreContext.IFluidHandleContext,\n\t\t);\n\t}\n\n\tpublic get IFluidDataStoreChannel(): IFluidDataStoreChannel {\n\t\treturn this;\n\t}\n\n\tprivate _disposed = false;\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis._disposed = true;\n\t}\n\n\tprivate readonly runtimeAttributor: RuntimeAttributor;\n\tpublic isEnabled = true;\n\tpublic attachState: AttachState;\n\tpublic visibilityState: VisibilityState;\n\tprivate readonly deferredAttached = new Deferred<void>();\n\tprivate readonly mc: MonitoringContext;\n\tpublic get logger(): TelemetryLoggerExt {\n\t\treturn this.mc.logger;\n\t}\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tawait this.runtimeAttributor.initialize(\n\t\t\tdeltaManager,\n\t\t\tquorum,\n\t\t\tbaseSnapshotForAttributorTree,\n\t\t\treadBlob,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.makeVisibleAndAttachGraph}\n\t */\n\tpublic makeVisibleAndAttachGraph(): void {\n\t\tif (this.visibilityState !== VisibilityState.NotVisible) {\n\t\t\treturn;\n\t\t}\n\t\tthis.visibilityState = VisibilityState.LocallyVisible;\n\n\t\tthis.dataStoreContext.makeLocallyVisible();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachSummary}\n\t */\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachGCData}\n\t */\n\tpublic getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData {\n\t\treturn { gcNodes: {} };\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.processMessages}\n\t */\n\tpublic processMessages(messageCollection: IRuntimeMessageCollection): void {\n\t\tthrow new Error(\"Attributor should not receive messages yet\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.processSignal}\n\t */\n\tpublic processSignal(message: IInboundSignalMessage, local: boolean): void {\n\t\tthrow new Error(\"Attributor should not receive signals\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getGCData}\n\t */\n\tpublic async getGCData(fullGC?: boolean): Promise<IGarbageCollectionData> {\n\t\t// Nothing to be GCed from the attributor.\n\t\tconst garbageCollectionData: IGarbageCollectionData = { gcNodes: {} };\n\t\treturn garbageCollectionData;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.updateUsedRoutes}\n\t */\n\tpublic updateUsedRoutes(usedRoutes: string[]): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setConnectionState}\n\t */\n\tpublic setConnectionState(connected: boolean, clientId?: string): void {\n\t\traiseConnectedEvent(this.logger, this, connected, clientId);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.reSubmit}\n\t */\n\tpublic reSubmit(): void {\n\t\t// Should not resubmit anything from the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not resubmit anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.applyStashedOp}\n\t */\n\tpublic async applyStashedOp(content: unknown): Promise<unknown> {\n\t\t// Should not apply stashed ops to the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not apply stashed ops to the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.rollback}\n\t */\n\tpublic rollback?(type: string, content: unknown, localOpMetadata: unknown): void {\n\t\t// Should not rollback anything from the attributor as it does not send ops yet.\n\t\tthrow new Error(\"Should not rollback anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.entryPoint}\n\t */\n\tpublic readonly entryPoint: IFluidHandleInternal<FluidObject>;\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.request}\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\t// Should not request anything from the attributor as the attributor does not have any channels further.\n\t\tthrow new Error(\"Should not request anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setAttachState}\n\t */\n\tpublic setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {\n\t\tswitch (attachState) {\n\t\t\tcase AttachState.Attaching: {\n\t\t\t\tthis.attachState = AttachState.Attaching;\n\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.LocallyVisible,\n\t\t\t\t\t0xa1e /* Data store should be locally visible before it can become globally visible. */,\n\t\t\t\t);\n\n\t\t\t\t// Mark the data store globally visible and make its child channels visible as well.\n\t\t\t\tthis.visibilityState = VisibilityState.GloballyVisible;\n\n\t\t\t\t// This promise resolution will be moved to attached event once we fix the scheduler.\n\t\t\t\tthis.deferredAttached.resolve();\n\t\t\t\tthis.emit(\"attaching\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase AttachState.Attached: {\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.GloballyVisible,\n\t\t\t\t\t0xa1f /* Data store should be globally visible when its attached. */,\n\t\t\t\t);\n\t\t\t\tthis.attachState = AttachState.Attached;\n\t\t\t\tthis.emit(\"attached\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(attachState, \"unreached\");\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -11,6 +11,7 @@ const runtimeAttributorDataStoreChannel_js_1 = require("./runtimeAttributorDataS
11
11
  * Factory for the runtime attributor data store channel.
12
12
  */
13
13
  class RuntimeAttributorFactory {
14
+ static type = "@fluid-experimental/attributor";
14
15
  get type() {
15
16
  return RuntimeAttributorFactory.type;
16
17
  }
@@ -35,5 +36,4 @@ class RuntimeAttributorFactory {
35
36
  }
36
37
  }
37
38
  exports.RuntimeAttributorFactory = RuntimeAttributorFactory;
38
- RuntimeAttributorFactory.type = "@fluid-experimental/attributor";
39
39
  //# sourceMappingURL=runtimeAttributorDataStoreFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeAttributorDataStoreFactory.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,uEAA+F;AAE/F,iGAA2F;AAE3F;;GAEG;AACH,MAAa,wBAAwB;IAGpC,IAAW,IAAI;QACd,OAAO,wBAAwB,CAAC,IAAI,CAAC;IACtC,CAAC;IAED,IAAW,sBAAsB;QAChC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAChC,OAA+B,EAC/B,QAAiB;QAEjB,MAAM,OAAO,GAAG,IAAI,wEAAiC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEzE,MAAM,MAAM,GAAG,IAAA,4BAAiB,EAAC;YAChC,MAAM,EAAE,OAAO,CAAC,UAAU;YAC1B,SAAS,EAAE,YAAY;SACvB,CAAC,CAAC;QAEH,MAAM,2BAAgB,CAAC,cAAc,CACpC,MAAM,EACN;YACC,SAAS,EAAE,YAAY;SACvB,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,OAAO,CAAC,UAAU,CACvB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,SAAS,EAAE,EACnB,OAAO,CAAC,YAAY,EACpB,KAAK,EAAE,EAAU,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAClD,CAAC;YACF,KAAK,CAAC,GAAG,CAAC;gBACT,uBAAuB,EAAE,IAAI,EAAE,wDAAwD;aACvF,CAAC,CAAC;QACJ,CAAC,CACD,CAAC;QACF,OAAO,OAAO,CAAC;IAChB,CAAC;;AAxCF,4DAyCC;AAxCuB,6BAAI,GAAG,gCAAgC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributorDataStoreChannel } from \"./runtimeAttributorDataStoreChannel.js\";\n\n/**\n * Factory for the runtime attributor data store channel.\n */\nexport class RuntimeAttributorFactory implements IFluidDataStoreFactory {\n\tpublic static readonly type = \"@fluid-experimental/attributor\";\n\n\tpublic get type(): string {\n\t\treturn RuntimeAttributorFactory.type;\n\t}\n\n\tpublic get IFluidDataStoreFactory(): IFluidDataStoreFactory {\n\t\treturn this;\n\t}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\tconst runtime = new RuntimeAttributorDataStoreChannel(context, existing);\n\n\t\tconst logger = createChildLogger({\n\t\t\tlogger: context.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"initialize\",\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tawait runtime.initialize(\n\t\t\t\t\tcontext.deltaManager,\n\t\t\t\t\tcontext.getQuorum(),\n\t\t\t\t\tcontext.baseSnapshot,\n\t\t\t\t\tasync (id: string) => context.storage.readBlob(id),\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tattributionEnabledInDoc: true, // If we are instantiating the attributor, it is enabled\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t\treturn runtime;\n\t}\n}\n"]}
1
+ {"version":3,"file":"runtimeAttributorDataStoreFactory.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,uEAA+F;AAE/F,iGAA2F;AAE3F;;GAEG;AACH,MAAa,wBAAwB;IAC7B,MAAM,CAAU,IAAI,GAAG,gCAAgC,CAAC;IAE/D,IAAW,IAAI;QACd,OAAO,wBAAwB,CAAC,IAAI,CAAC;IACtC,CAAC;IAED,IAAW,sBAAsB;QAChC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAChC,OAA+B,EAC/B,QAAiB;QAEjB,MAAM,OAAO,GAAG,IAAI,wEAAiC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEzE,MAAM,MAAM,GAAG,IAAA,4BAAiB,EAAC;YAChC,MAAM,EAAE,OAAO,CAAC,UAAU;YAC1B,SAAS,EAAE,YAAY;SACvB,CAAC,CAAC;QAEH,MAAM,2BAAgB,CAAC,cAAc,CACpC,MAAM,EACN;YACC,SAAS,EAAE,YAAY;SACvB,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,OAAO,CAAC,UAAU,CACvB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,SAAS,EAAE,EACnB,OAAO,CAAC,YAAY,EACpB,KAAK,EAAE,EAAU,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAClD,CAAC;YACF,KAAK,CAAC,GAAG,CAAC;gBACT,uBAAuB,EAAE,IAAI,EAAE,wDAAwD;aACvF,CAAC,CAAC;QACJ,CAAC,CACD,CAAC;QACF,OAAO,OAAO,CAAC;IAChB,CAAC;;AAxCF,4DAyCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributorDataStoreChannel } from \"./runtimeAttributorDataStoreChannel.js\";\n\n/**\n * Factory for the runtime attributor data store channel.\n */\nexport class RuntimeAttributorFactory implements IFluidDataStoreFactory {\n\tpublic static readonly type = \"@fluid-experimental/attributor\";\n\n\tpublic get type(): string {\n\t\treturn RuntimeAttributorFactory.type;\n\t}\n\n\tpublic get IFluidDataStoreFactory(): IFluidDataStoreFactory {\n\t\treturn this;\n\t}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\tconst runtime = new RuntimeAttributorDataStoreChannel(context, existing);\n\n\t\tconst logger = createChildLogger({\n\t\t\tlogger: context.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"initialize\",\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tawait runtime.initialize(\n\t\t\t\t\tcontext.deltaManager,\n\t\t\t\t\tcontext.getQuorum(),\n\t\t\t\t\tcontext.baseSnapshot,\n\t\t\t\t\tasync (id: string) => context.storage.readBlob(id),\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tattributionEnabledInDoc: true, // If we are instantiating the attributor, it is enabled\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t\treturn runtime;\n\t}\n}\n"]}
@@ -12,13 +12,13 @@ const internal_1 = require("@fluidframework/telemetry-utils/internal");
12
12
  * retrieve the string.
13
13
  */
14
14
  class MutableStringInterner {
15
+ stringToInternedIdMap = new Map();
16
+ internedStrings = [];
15
17
  /**
16
18
  * @param inputStrings - A list of strings to intern in the order given. Can be used to rehydrate from a previous
17
19
  * `StringInterner`'s {@link StringInterner.getSerializable} return value.
18
20
  */
19
21
  constructor(inputStrings = []) {
20
- this.stringToInternedIdMap = new Map();
21
- this.internedStrings = [];
22
22
  for (const value of inputStrings) {
23
23
  this.getOrCreateInternedId(value);
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stringInterner.js","sourceRoot":"","sources":["../src/stringInterner.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AAoBtE;;;;GAIG;AACH,MAAa,qBAAqB;IAIjC;;;OAGG;IACH,YAAmB,eAAkC,EAAE;QAPtC,0BAAqB,GAAG,IAAI,GAAG,EAA4B,CAAC;QAC5D,oBAAe,GAAa,EAAE,CAAC;QAO/C,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;YAClC,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IAED;;;OAGG;IACI,qBAAqB,CAAC,KAAa;QACzC,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IAEM,aAAa,CAAC,KAAa;QACjC,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,QAAgB;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,qBAAU,CAAC,6BAA6B,QAAQ,GAAG,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,eAAe;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,KAAa;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAwB,CAAC;QACvE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,UAAU,CAAC;IACnB,CAAC;CACD;AA1DD,sDA0DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * The ID of the string that has been interned, which can be used by a {@link StringInterner} to retrieve the\n * original string.\n * @public\n */\nexport type InternedStringId = number & {\n\treadonly InternedStringId: \"e221abc9-9d17-4493-8db0-70c871a1c27c\";\n};\n\n/**\n * Interns strings as integers.\n */\nexport interface StringInterner {\n\tgetInternedId(input: string): InternedStringId | undefined;\n\tgetString(internedId: number): string;\n\tgetSerializable(): readonly string[];\n}\n\n/**\n * Interns strings as integers.\n * Given a string, this class will produce a unique integer associated with that string that can then be used to\n * retrieve the string.\n */\nexport class MutableStringInterner implements StringInterner {\n\tprivate readonly stringToInternedIdMap = new Map<string, InternedStringId>();\n\tprivate readonly internedStrings: string[] = [];\n\n\t/**\n\t * @param inputStrings - A list of strings to intern in the order given. Can be used to rehydrate from a previous\n\t * `StringInterner`'s {@link StringInterner.getSerializable} return value.\n\t */\n\tpublic constructor(inputStrings: readonly string[] = []) {\n\t\tfor (const value of inputStrings) {\n\t\t\tthis.getOrCreateInternedId(value);\n\t\t}\n\t}\n\n\t/**\n\t * Creates an intern ID that is uniquely associated with the input string.\n\t * @param input - The string to get the associated intern ID for.\n\t */\n\tpublic getOrCreateInternedId(input: string): InternedStringId {\n\t\treturn this.getInternedId(input) ?? this.createNewId(input);\n\t}\n\n\tpublic getInternedId(input: string): InternedStringId | undefined {\n\t\treturn this.stringToInternedIdMap.get(input);\n\t}\n\n\t/**\n\t * Creates a string that is uniquely associated with the given intern ID.\n\t * @param internId - The intern ID to get the associated string for. Can only retrieve strings that have been\n\t * used as inputs to calls of `getInternId`.\n\t */\n\tpublic getString(internId: number): string {\n\t\tconst result = this.internedStrings[internId];\n\t\tif (result === undefined) {\n\t\t\tthrow new UsageError(`No string associated with ${internId}.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets the list of strings interned where the indices map to the associated {@link InternedStringId} of\n\t * each string.\n\t */\n\tpublic getSerializable(): readonly string[] {\n\t\treturn this.internedStrings;\n\t}\n\n\t/**\n\t * Create a new interned id.\n\t *\n\t * @remarks Assumes (without validation) that the input doesn't already have an interned id.\n\t */\n\tprivate createNewId(input: string): InternedStringId {\n\t\tconst internedId = this.stringToInternedIdMap.size as InternedStringId;\n\t\tthis.stringToInternedIdMap.set(input, internedId);\n\t\tthis.internedStrings.push(input);\n\t\treturn internedId;\n\t}\n}\n"]}
1
+ {"version":3,"file":"stringInterner.js","sourceRoot":"","sources":["../src/stringInterner.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AAoBtE;;;;GAIG;AACH,MAAa,qBAAqB;IAChB,qBAAqB,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC5D,eAAe,GAAa,EAAE,CAAC;IAEhD;;;OAGG;IACH,YAAmB,eAAkC,EAAE;QACtD,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;YAClC,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IAED;;;OAGG;IACI,qBAAqB,CAAC,KAAa;QACzC,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IAEM,aAAa,CAAC,KAAa;QACjC,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,QAAgB;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,qBAAU,CAAC,6BAA6B,QAAQ,GAAG,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,eAAe;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,KAAa;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAwB,CAAC;QACvE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,UAAU,CAAC;IACnB,CAAC;CACD;AA1DD,sDA0DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * The ID of the string that has been interned, which can be used by a {@link StringInterner} to retrieve the\n * original string.\n * @public\n */\nexport type InternedStringId = number & {\n\treadonly InternedStringId: \"e221abc9-9d17-4493-8db0-70c871a1c27c\";\n};\n\n/**\n * Interns strings as integers.\n */\nexport interface StringInterner {\n\tgetInternedId(input: string): InternedStringId | undefined;\n\tgetString(internedId: number): string;\n\tgetSerializable(): readonly string[];\n}\n\n/**\n * Interns strings as integers.\n * Given a string, this class will produce a unique integer associated with that string that can then be used to\n * retrieve the string.\n */\nexport class MutableStringInterner implements StringInterner {\n\tprivate readonly stringToInternedIdMap = new Map<string, InternedStringId>();\n\tprivate readonly internedStrings: string[] = [];\n\n\t/**\n\t * @param inputStrings - A list of strings to intern in the order given. Can be used to rehydrate from a previous\n\t * `StringInterner`'s {@link StringInterner.getSerializable} return value.\n\t */\n\tpublic constructor(inputStrings: readonly string[] = []) {\n\t\tfor (const value of inputStrings) {\n\t\t\tthis.getOrCreateInternedId(value);\n\t\t}\n\t}\n\n\t/**\n\t * Creates an intern ID that is uniquely associated with the input string.\n\t * @param input - The string to get the associated intern ID for.\n\t */\n\tpublic getOrCreateInternedId(input: string): InternedStringId {\n\t\treturn this.getInternedId(input) ?? this.createNewId(input);\n\t}\n\n\tpublic getInternedId(input: string): InternedStringId | undefined {\n\t\treturn this.stringToInternedIdMap.get(input);\n\t}\n\n\t/**\n\t * Creates a string that is uniquely associated with the given intern ID.\n\t * @param internId - The intern ID to get the associated string for. Can only retrieve strings that have been\n\t * used as inputs to calls of `getInternId`.\n\t */\n\tpublic getString(internId: number): string {\n\t\tconst result = this.internedStrings[internId];\n\t\tif (result === undefined) {\n\t\t\tthrow new UsageError(`No string associated with ${internId}.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets the list of strings interned where the indices map to the associated {@link InternedStringId} of\n\t * each string.\n\t */\n\tpublic getSerializable(): readonly string[] {\n\t\treturn this.internedStrings;\n\t}\n\n\t/**\n\t * Create a new interned id.\n\t *\n\t * @remarks Assumes (without validation) that the input doesn't already have an interned id.\n\t */\n\tprivate createNewId(input: string): InternedStringId {\n\t\tconst internedId = this.stringToInternedIdMap.size as InternedStringId;\n\t\tthis.stringToInternedIdMap.set(input, internedId);\n\t\tthis.internedStrings.push(input);\n\t\treturn internedId;\n\t}\n}\n"]}
package/lib/attributor.js CHANGED
@@ -9,6 +9,7 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
9
9
  * {@inheritdoc IAttributor}
10
10
  */
11
11
  export class Attributor {
12
+ keyToInfo;
12
13
  /**
13
14
  * @param initialEntries - Any entries which should be populated on instantiation.
14
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"attributor.js","sourceRoot":"","sources":["../src/attributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,WAAW,GAGX,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AA6BtE;;GAEG;AACH,MAAM,OAAO,UAAU;IAGtB;;OAEG;IACH,YAAmB,cAAoD;QACtE,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,GAAW;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,UAAU,CAAC,uDAAuD,GAAG,GAAG,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;OAEG;IACI,qBAAqB,CAAC,GAAW;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,OAAO;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IACjD,YACC,YAAwE,EACxE,aAA6B,EAC7B,cAAoD;QAEpD,KAAK,CAAC,cAAc,CAAC,CAAC;QACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,EAAE;YAC5D,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,EAAE,CAAC;gBAC5C,MAAM,CACL,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,EACpC,KAAK,CAAC,8DAA8D,CACpE,CAAC;gBACF,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACzD,MAAM,CACL,MAAM,KAAK,SAAS,EACpB,KAAK,CAAC,yDAAyD,CAC/D,CAAC;gBACF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE;oBAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;oBACxB,SAAS,EAAE,OAAO,CAAC,SAAS;iBAC5B,CAAC,CAAC;YACJ,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IQuorumClients } from \"@fluidframework/driver-definitions\";\nimport {\n\tMessageType,\n\ttype IDocumentMessage,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { AttributionInfo } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Provides lookup between attribution keys and their associated attribution information.\n * @internal\n */\nexport interface IAttributor {\n\t/**\n\t * Retrieves attribution information associated with a particular key.\n\t * @param key - Attribution key to look up.\n\t * @throws If no attribution information is recorded for that key.\n\t */\n\tgetAttributionInfo(key: number): AttributionInfo;\n\n\t/**\n\t * @param key - Attribution key to look up.\n\t * @returns the attribution information associated with the provided key, or undefined if no information exists.\n\t */\n\ttryGetAttributionInfo(key: number): AttributionInfo | undefined;\n\n\t/**\n\t * @returns an iterable of (attribution key, attribution info) pairs for each stored key.\n\t */\n\tentries(): IterableIterator<[number, AttributionInfo]>;\n\n\t// TODO:\n\t// - GC\n}\n\n/**\n * {@inheritdoc IAttributor}\n */\nexport class Attributor implements IAttributor {\n\tprotected readonly keyToInfo: Map<number, AttributionInfo>;\n\n\t/**\n\t * @param initialEntries - Any entries which should be populated on instantiation.\n\t */\n\tpublic constructor(initialEntries?: Iterable<[number, AttributionInfo]>) {\n\t\tthis.keyToInfo = new Map(initialEntries ?? []);\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.getAttributionInfo}\n\t */\n\tpublic getAttributionInfo(key: number): AttributionInfo {\n\t\tconst result = this.tryGetAttributionInfo(key);\n\t\tif (!result) {\n\t\t\tthrow new UsageError(`Requested attribution information for unstored key: ${key}.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.tryGetAttributionInfo}\n\t */\n\tpublic tryGetAttributionInfo(key: number): AttributionInfo | undefined {\n\t\treturn this.keyToInfo.get(key);\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.entries}\n\t */\n\tpublic entries(): IterableIterator<[number, AttributionInfo]> {\n\t\treturn this.keyToInfo.entries();\n\t}\n}\n\n/**\n * Attributor which listens to an op stream and records entries for each op.\n * Sequence numbers are used as attribution keys.\n */\nexport class OpStreamAttributor extends Attributor implements IAttributor {\n\tpublic constructor(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorumClients: IQuorumClients,\n\t\tinitialEntries?: Iterable<[number, AttributionInfo]>,\n\t) {\n\t\tsuper(initialEntries);\n\t\tdeltaManager.on(\"op\", (message: ISequencedDocumentMessage) => {\n\t\t\tif (message.type === MessageType.Operation) {\n\t\t\t\tassert(\n\t\t\t\t\ttypeof message.clientId === \"string\",\n\t\t\t\t\t0x966 /* Client id should be present and should be of type string */,\n\t\t\t\t);\n\t\t\t\tconst client = quorumClients.getMember(message.clientId);\n\t\t\t\tassert(\n\t\t\t\t\tclient !== undefined,\n\t\t\t\t\t0x967 /* Received message from user not in the quorumClients */,\n\t\t\t\t);\n\t\t\t\tthis.keyToInfo.set(message.sequenceNumber, {\n\t\t\t\t\tuser: client.client.user,\n\t\t\t\t\ttimestamp: message.timestamp,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"attributor.js","sourceRoot":"","sources":["../src/attributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,WAAW,GAGX,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AA6BtE;;GAEG;AACH,MAAM,OAAO,UAAU;IACH,SAAS,CAA+B;IAE3D;;OAEG;IACH,YAAmB,cAAoD;QACtE,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,GAAW;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,UAAU,CAAC,uDAAuD,GAAG,GAAG,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;OAEG;IACI,qBAAqB,CAAC,GAAW;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,OAAO;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IACjD,YACC,YAAwE,EACxE,aAA6B,EAC7B,cAAoD;QAEpD,KAAK,CAAC,cAAc,CAAC,CAAC;QACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,OAAkC,EAAE,EAAE;YAC5D,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,EAAE,CAAC;gBAC5C,MAAM,CACL,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,EACpC,KAAK,CAAC,8DAA8D,CACpE,CAAC;gBACF,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACzD,MAAM,CACL,MAAM,KAAK,SAAS,EACpB,KAAK,CAAC,yDAAyD,CAC/D,CAAC;gBACF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE;oBAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;oBACxB,SAAS,EAAE,OAAO,CAAC,SAAS;iBAC5B,CAAC,CAAC;YACJ,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IQuorumClients } from \"@fluidframework/driver-definitions\";\nimport {\n\tMessageType,\n\ttype IDocumentMessage,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { AttributionInfo } from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Provides lookup between attribution keys and their associated attribution information.\n * @internal\n */\nexport interface IAttributor {\n\t/**\n\t * Retrieves attribution information associated with a particular key.\n\t * @param key - Attribution key to look up.\n\t * @throws If no attribution information is recorded for that key.\n\t */\n\tgetAttributionInfo(key: number): AttributionInfo;\n\n\t/**\n\t * @param key - Attribution key to look up.\n\t * @returns the attribution information associated with the provided key, or undefined if no information exists.\n\t */\n\ttryGetAttributionInfo(key: number): AttributionInfo | undefined;\n\n\t/**\n\t * @returns an iterable of (attribution key, attribution info) pairs for each stored key.\n\t */\n\tentries(): IterableIterator<[number, AttributionInfo]>;\n\n\t// TODO:\n\t// - GC\n}\n\n/**\n * {@inheritdoc IAttributor}\n */\nexport class Attributor implements IAttributor {\n\tprotected readonly keyToInfo: Map<number, AttributionInfo>;\n\n\t/**\n\t * @param initialEntries - Any entries which should be populated on instantiation.\n\t */\n\tpublic constructor(initialEntries?: Iterable<[number, AttributionInfo]>) {\n\t\tthis.keyToInfo = new Map(initialEntries ?? []);\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.getAttributionInfo}\n\t */\n\tpublic getAttributionInfo(key: number): AttributionInfo {\n\t\tconst result = this.tryGetAttributionInfo(key);\n\t\tif (!result) {\n\t\t\tthrow new UsageError(`Requested attribution information for unstored key: ${key}.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.tryGetAttributionInfo}\n\t */\n\tpublic tryGetAttributionInfo(key: number): AttributionInfo | undefined {\n\t\treturn this.keyToInfo.get(key);\n\t}\n\n\t/**\n\t * {@inheritdoc IAttributor.entries}\n\t */\n\tpublic entries(): IterableIterator<[number, AttributionInfo]> {\n\t\treturn this.keyToInfo.entries();\n\t}\n}\n\n/**\n * Attributor which listens to an op stream and records entries for each op.\n * Sequence numbers are used as attribution keys.\n */\nexport class OpStreamAttributor extends Attributor implements IAttributor {\n\tpublic constructor(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorumClients: IQuorumClients,\n\t\tinitialEntries?: Iterable<[number, AttributionInfo]>,\n\t) {\n\t\tsuper(initialEntries);\n\t\tdeltaManager.on(\"op\", (message: ISequencedDocumentMessage) => {\n\t\t\tif (message.type === MessageType.Operation) {\n\t\t\t\tassert(\n\t\t\t\t\ttypeof message.clientId === \"string\",\n\t\t\t\t\t0x966 /* Client id should be present and should be of type string */,\n\t\t\t\t);\n\t\t\t\tconst client = quorumClients.getMember(message.clientId);\n\t\t\t\tassert(\n\t\t\t\t\tclient !== undefined,\n\t\t\t\t\t0x967 /* Received message from user not in the quorumClients */,\n\t\t\t\t);\n\t\t\t\tthis.keyToInfo.set(message.sequenceNumber, {\n\t\t\t\t\tuser: client.client.user,\n\t\t\t\t\ttimestamp: message.timestamp,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"encoders.d.ts","sourceRoot":"","sources":["../src/encoders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAEpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAyB,MAAM,qBAAqB,CAAC;AAEnF,MAAM,WAAW,OAAO,CAAC,QAAQ,EAAE,QAAQ;IAC1C,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACpC,MAAM,CAAC,OAAO,EAAE,Q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  export class AttributorSerializer {
29
+ makeAttributor;
30
+ timestampEncoder;
29
31
  constructor(makeAttributor, timestampEncoder) {
30
32
  this.makeAttributor = makeAttributor;
31
33
  this.timestampEncoder = timestampEncoder;
@@ -1 +1 @@
1
- {"version":3,"file":"encoders.js","sourceRoot":"","sources":["../src/encoders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D,OAAO,EAAyB,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAWnF,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC7C,MAAM,EAAE,CAAC,UAAoB,EAAE,EAAE;QAChC,MAAM,eAAe,GAAa,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5E,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;YACnD,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;YACtC,IAAI,GAAG,SAAS,CAAC;QAClB,CAAC;QAED,OAAO,eAAe,CAAC;IACxB,CAAC;IACD,MAAM,EAAE,CAAC,OAAgB,EAAE,EAAE;QAC5B,MAAM,CACL,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EACtB,KAAK,CAAC,sDAAsD,CAC5D,CAAC;QACF,MAAM,UAAU,GAAa,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACpE,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,aAAa,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;YAC5B,UAAU,CAAC,CAAC,CA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I,CAAC,gBAAgB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACnE,MAAM,CACL,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,KAAK,eAAe,CAAC,MAAM,EACjF,KAAK,CAAC,gEAAgE,CACtE,CAAC;QACF,MAAM,OAAO,GAAgC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACjF,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACvC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAU,CAAC;YAC1D,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CACpB,CAAkB,EAClB,CAAkB,EACA,EAAE,CAAC,CAAC;IACtB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;CAChD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IUser } from \"@fluidframework/driver-definitions\";\nimport type { AttributionInfo } from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { IAttributor } from \"./attributor.js\";\nimport { type InternedStringId, MutableStringInterner } from \"./stringInterner.js\";\n\nexport interface Encoder<TDecoded, TEncoded> {\n\tencode(decoded: TDecoded): TEncoded;\n\tdecode(encoded: TEncoded): TDecoded;\n}\n\n// Note: the encoded format doesn't matter as long as it's serializable;\n// these types could be weakened.\nexport type TimestampEncoder = Encoder<number[], number[]>;\n\nexport const deltaEncoder: TimestampEncoder = {\n\tencode: (timestamps: number[]) => {\n\t\tconst deltaTimestamps: number[] = Array.from({ length: timestamps.length });\n\t\tlet prev = 0;\n\t\tfor (const [i, timestamp] of timestamps.entries()) {\n\t\t\tdeltaTimestamps[i] = timestamp - prev;\n\t\t\tprev = timestamp;\n\t\t}\n\n\t\treturn deltaTimestamps;\n\t},\n\tdecode: (encoded: unknown) => {\n\t\tassert(\n\t\t\tArray.isArray(encoded),\n\t\t\t0x4b0 /* Encoded timestamps should be an array of numbers */,\n\t\t);\n\t\tconst timestamps: number[] = Array.from({ length: encoded.length });\n\t\tlet cumulativeSum = 0;\n\t\tfor (let i = 0; i < encoded.length; i++) {\n\t\t\tcumulativeSum += encoded[i];\n\t\t\ttimestamps[i] = cumulativeSum;\n\t\t}\n\t\treturn timestamps;\n\t},\n};\n\nexport type IAttributorSerializer = Encoder<IAttributor, SerializedAttributor>;\n\nexport interface SerializedAttributor {\n\tinterner: readonly string[] /* result of calling getSerializable() on a StringInterner */;\n\tseqs: number[];\n\ttimestamps: number[];\n\tattributionRefs: InternedStringId[];\n}\n\nexport class AttributorSerializer implements IAttributorSerializer {\n\tpublic constructor(\n\t\tprivate readonly makeAttributor: (\n\t\t\tentries: Iterable<[number, AttributionInfo]>,\n\t\t) => IAttributor,\n\t\tprivate readonly timestampEncoder: TimestampEncoder,\n\t) {}\n\n\t/**\n\t * {@inheritDoc Encoder.encode}\n\t */\n\tpublic encode(attributor: IAttributor): SerializedAttributor {\n\t\tconst interner = new MutableStringInterner();\n\t\tconst seqs: number[] = [];\n\t\tconst timestamps: number[] = [];\n\t\tconst attributionRefs: InternedStringId[] = [];\n\t\tfor (const [seq, { user, timestamp }] of attributor.entries()) {\n\t\t\tseqs.push(seq);\n\t\t\ttimestamps.push(timestamp);\n\t\t\tconst ref = interner.getOrCreateInternedId(JSON.stringify(user));\n\t\t\tattributionRefs.push(ref);\n\t\t}\n\n\t\tconst serialized: SerializedAttributor = {\n\t\t\tinterner: interner.getSerializable(),\n\t\t\tseqs,\n\t\t\ttimestamps: this.timestampEncoder.encode(timestamps),\n\t\t\tattributionRefs,\n\t\t};\n\n\t\treturn serialized;\n\t}\n\n\t/**\n\t * {@inheritDoc Encoder.decode}\n\t */\n\tpublic decode(encoded: SerializedAttributor): IAttributor {\n\t\tconst interner = new MutableStringInterner(encoded.interner);\n\t\tconst { seqs, timestamps: encodedTimestamps, attributionRefs } = encoded;\n\t\tconst timestamps = this.timestampEncoder.decode(encodedTimestamps);\n\t\tassert(\n\t\t\tseqs.length === timestamps.length && timestamps.length === attributionRefs.length,\n\t\t\t0x4b1 /* serialized attribution columns should have the same length */,\n\t\t);\n\t\tconst entries: [number, AttributionInfo][] = Array.from({ length: seqs.length });\n\t\tfor (const [i, key] of seqs.entries()) {\n\t\t\tconst timestamp = timestamps[i];\n\t\t\tconst ref = attributionRefs[i];\n\t\t\tconst user = JSON.parse(interner.getString(ref)) as IUser;\n\t\t\tentries[i] = [key, { user, timestamp }];\n\t\t}\n\t\treturn this.makeAttributor(entries);\n\t}\n}\n\n/**\n * Creates an encoder which composes `a` and `b`.\n */\nexport const chain = <T1, T2, T3>(\n\ta: Encoder<T1, T2>,\n\tb: Encoder<T2, T3>,\n): Encoder<T1, T3> => ({\n\tencode: (content) => b.encode(a.encode(content)),\n\tdecode: (content) => a.decode(b.decode(content)),\n});\n"]}
1
+ {"version":3,"file":"encoders.js","sourceRoot":"","sources":["../src/encoders.ts"],"names":[],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tE,CAAC;QACF,MAAM,OAAO,GAAgC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACjF,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACvC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAU,CAAC;YAC1D,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CACpB,CAAkB,EAClB,CAAkB,EACA,EAAE,CAAC,CAAC;IACtB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;CAChD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IUser } from \"@fluidframework/driver-definitions\";\nimport type { AttributionInfo } from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { IAttributor } from \"./attributor.js\";\nimport { type InternedStringId, MutableStringInterner } from \"./stringInterner.js\";\n\nexport interface Encoder<TDecoded, TEncoded> {\n\tencode(decoded: TDecoded): TEncoded;\n\tdecode(encoded: TEncoded): TDecoded;\n}\n\n// Note: the encoded format doesn't matter as long as it's serializable;\n// these types could be weakened.\nexport type TimestampEncoder = Encoder<number[], number[]>;\n\nexport const deltaEncoder: TimestampEncoder = {\n\tencode: (timestamps: number[]) => {\n\t\tconst deltaTimestamps: number[] = Array.from({ length: timestamps.length });\n\t\tlet prev = 0;\n\t\tfor (const [i, timestamp] of timestamps.entries()) {\n\t\t\tdeltaTimestamps[i] = timestamp - prev;\n\t\t\tprev = timestamp;\n\t\t}\n\n\t\treturn deltaTimestamps;\n\t},\n\tdecode: (encoded: unknown) => {\n\t\tassert(\n\t\t\tArray.isArray(encoded),\n\t\t\t0x4b0 /* Encoded timestamps should be an array of numbers */,\n\t\t);\n\t\tconst timestamps: number[] = Array.from({ length: encoded.length });\n\t\tlet cumulativeSum = 0;\n\t\tfor (let i = 0; i < encoded.length; i++) {\n\t\t\tcumulativeSum += encoded[i];\n\t\t\ttimestamps[i] = cumulativeSum;\n\t\t}\n\t\treturn timestamps;\n\t},\n};\n\nexport type IAttributorSerializer = Encoder<IAttributor, SerializedAttributor>;\n\nexport interface SerializedAttributor {\n\tinterner: readonly string[] /* result of calling getSerializable() on a StringInterner */;\n\tseqs: number[];\n\ttimestamps: number[];\n\tattributionRefs: InternedStringId[];\n}\n\nexport class AttributorSerializer implements IAttributorSerializer {\n\tpublic constructor(\n\t\tprivate readonly makeAttributor: (\n\t\t\tentries: Iterable<[number, AttributionInfo]>,\n\t\t) => IAttributor,\n\t\tprivate readonly timestampEncoder: TimestampEncoder,\n\t) {}\n\n\t/**\n\t * {@inheritDoc Encoder.encode}\n\t */\n\tpublic encode(attributor: IAttributor): SerializedAttributor {\n\t\tconst interner = new MutableStringInterner();\n\t\tconst seqs: number[] = [];\n\t\tconst timestamps: number[] = [];\n\t\tconst attributionRefs: InternedStringId[] = [];\n\t\tfor (const [seq, { user, timestamp }] of attributor.entries()) {\n\t\t\tseqs.push(seq);\n\t\t\ttimestamps.push(timestamp);\n\t\t\tconst ref = interner.getOrCreateInternedId(JSON.stringify(user));\n\t\t\tattributionRefs.push(ref);\n\t\t}\n\n\t\tconst serialized: SerializedAttributor = {\n\t\t\tinterner: interner.getSerializable(),\n\t\t\tseqs,\n\t\t\ttimestamps: this.timestampEncoder.encode(timestamps),\n\t\t\tattributionRefs,\n\t\t};\n\n\t\treturn serialized;\n\t}\n\n\t/**\n\t * {@inheritDoc Encoder.decode}\n\t */\n\tpublic decode(encoded: SerializedAttributor): IAttributor {\n\t\tconst interner = new MutableStringInterner(encoded.interner);\n\t\tconst { seqs, timestamps: encodedTimestamps, attributionRefs } = encoded;\n\t\tconst timestamps = this.timestampEncoder.decode(encodedTimestamps);\n\t\tassert(\n\t\t\tseqs.length === timestamps.length && timestamps.length === attributionRefs.length,\n\t\t\t0x4b1 /* serialized attribution columns should have the same length */,\n\t\t);\n\t\tconst entries: [number, AttributionInfo][] = Array.from({ length: seqs.length });\n\t\tfor (const [i, key] of seqs.entries()) {\n\t\t\tconst timestamp = timestamps[i];\n\t\t\tconst ref = attributionRefs[i];\n\t\t\tconst user = JSON.parse(interner.getString(ref)) as IUser;\n\t\t\tentries[i] = [key, { user, timestamp }];\n\t\t}\n\t\treturn this.makeAttributor(entries);\n\t}\n}\n\n/**\n * Creates an encoder which composes `a` and `b`.\n */\nexport const chain = <T1, T2, T3>(\n\ta: Encoder<T1, T2>,\n\tb: Encoder<T2, T3>,\n): Encoder<T1, T3> => ({\n\tencode: (content) => b.encode(a.encode(content)),\n\tdecode: (content) => a.decode(b.decode(content)),\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mixinAttributor.d.ts","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAG9E,OAAO,KAAK,EACX,qBAAqB,EAErB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAIN,KAAK,kBAAkB,EACvB,MAAM,0BAA0B,CAAC;AAGlC;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAMzC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UACrB,uBAAuB,KAC3B,uBAgEqC,CAAC"}
1
+ {"version":3,"file":"mixinAttributor.d.ts","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAG9E,OAAO,KAAK,EACX,qBAAqB,EAErB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAIN,KAAK,kBAAkB,EACvB,MAAM,0BAA0B,CAAC;AAGlC;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAMzC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC3B,OAAM,OAAO,gBAAmC,KAC9C,OAAO,gBAgE8B,CAAC"}
@@ -10,13 +10,6 @@ import { opBlobName } from "./attributorContracts.js";
10
10
  import { AttributorSerializer, chain, deltaEncoder } from "./encoders.js";
11
11
  import { makeLZ4Encoder } from "./lz4Encoder.js";
12
12
  export class RuntimeAttributor {
13
- constructor() {
14
- this.encoder = {
15
- encode: unreachableCase,
16
- decode: unreachableCase,
17
- };
18
- this.isEnabled = true;
19
- }
20
13
  get IRuntimeAttributor() {
21
14
  return this;
22
15
  }
@@ -44,6 +37,12 @@ export class RuntimeAttributor {
44
37
  }
45
38
  return this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;
46
39
  }
40
+ encoder = {
41
+ encode: unreachableCase,
42
+ decode: unreachableCase,
43
+ };
44
+ opAttributor;
45
+ isEnabled = true;
47
46
  async initialize(deltaManager, quorum, baseSnapshotForAttributorTree, readBlob) {
48
47
  this.encoder = chain(new AttributorSerializer((entries) => new OpStreamAttributor(deltaManager, quorum, entries), deltaEncoder), makeLZ4Encoder());
49
48
  if (baseSnapshotForAttributorTree === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeAttributor.js","sourceRoot":"","sources":["../src/runtimeAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAY9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAoB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,UAAU,EAA2B,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,YAAY,EAAgB,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,OAAO,iBAAiB;IAA9B;QAuCS,YAAO,GAAiC;YAC/C,MAAM,EAAE,eAAe;YACvB,MAAM,EAAE,eAAe;SACvB,CAAC;QAGK,cAAS,GAAG,IAAI,CAAC;IAuCzB,CAAC;IAnFA,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,GAAG,CAAC,GAAmB;QAC7B,MAAM,CACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,mFAAmF,CACzF,CAAC;QAEF,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,wGAAwG;YACxG,0GAA0G;YAC1G,wGAAwG;YACxG,qGAAqG;YACrG,uDAAuD;YACvD,MAAM,IAAI,KAAK,CAAC,iD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AAC;IAEM,qBAAqB;QAC3B,MAAM,CACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACjC,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 type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIDocumentMessage,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tAttributionInfo,\n\tAttributionKey,\n\tISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport { OpStreamAttributor, type IAttributor } from \"./attributor.js\";\nimport { opBlobName, type IRuntimeAttributor } from \"./attributorContracts.js\";\nimport { AttributorSerializer, chain, deltaEncoder, type Encoder } from \"./encoders.js\";\nimport { makeLZ4Encoder } from \"./lz4Encoder.js\";\n\nexport class RuntimeAttributor implements IRuntimeAttributor {\n\tpublic get IRuntimeAttributor(): IRuntimeAttributor {\n\t\treturn this;\n\t}\n\n\tpublic get(key: AttributionKey): AttributionInfo {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */,\n\t\t);\n\n\t\tif (key.type === \"detached\") {\n\t\t\tthrow new Error(\"Attribution of detached keys is not yet supported.\");\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\t// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current\n\t\t\t// client id in the audience. However, for read->write client transition, the container might have not yet\n\t\t\t// received a client id. This is left as a TODO as it might be more easily solved once the detached case\n\t\t\t// is settled (e.g. if it's reasonable for the host to know the current user information at container\n\t\t\t// creation time, we could just use that here as well).\n\t\t\tthrow new Error(\"Attribution of local keys is not yet supported.\");\n\t\t}\n\n\t\treturn this.opAttributor.getAttributionInfo(key.seq);\n\t}\n\n\tpublic has(key: AttributionKey): boolean {\n\t\tif (key.type === \"detached\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;\n\t}\n\n\tprivate encoder: Encoder<IAttributor, string> = {\n\t\tencode: unreachableCase,\n\t\tdecode: unreachableCase,\n\t};\n\n\tprivate opAttributor: IAttributor | undefined;\n\tpublic isEnabled = true;\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tthis.encoder = chain(\n\t\t\tnew AttributorSerializer(\n\t\t\t\t(entries) => new OpStreamAttributor(deltaManager, quorum, entries),\n\t\t\t\tdeltaEncoder,\n\t\t\t),\n\t\t\tmakeLZ4Encoder(),\n\t\t);\n\n\t\tif (baseSnapshotForAttributorTree === undefined) {\n\t\t\tthis.opAttributor = new OpStreamAttributor(deltaManager, quorum);\n\t\t} else {\n\t\t\tconst id: string | undefined = baseSnapshotForAttributorTree.blobs[opBlobName];\n\t\t\tassert(\n\t\t\t\tid !== undefined,\n\t\t\t\t0x50a /* Attributor tree should have op attributor summary blob. */,\n\t\t\t);\n\t\t\tconst blobContents = await readBlob(id);\n\t\t\tconst attributorSnapshot = bufferToString(blobContents, \"utf8\");\n\t\t\tthis.opAttributor = this.encoder.decode(attributorSnapshot);\n\t\t}\n\t}\n\n\tpublic summarizeOpAttributor(): ISummaryTreeWithStats {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0xa1d /* RuntimeAttributor should be initialized before summarization */,\n\t\t);\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));\n\t\treturn builder.getSummaryTree();\n\t}\n}\n"]}
1
+ {"version":3,"file":"runtimeAttributor.js","sourceRoot":"","sources":["../src/runtimeAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAY9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAoB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,UAAU,EAA2B,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,YAAY,EAAgB,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,OAAO,iBAAiB;IAC7B,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,GAAG,CAAC,GAAmB;QAC7B,MAAM,CACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,mFAAmF,CACzF,CAAC;QAEF,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,wGAAwG;YACxG,0GAA0G;YAC1G,wGAA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AC,EAAE,CAAC,CAAC;YACxC,MAAM,kBAAkB,GAAG,cAAc,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAChE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC7D,CAAC;IACF,CAAC;IAEM,qBAAqB;QAC3B,MAAM,CACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACjC,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 type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIDocumentMessage,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tAttributionInfo,\n\tAttributionKey,\n\tISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport { OpStreamAttributor, type IAttributor } from \"./attributor.js\";\nimport { opBlobName, type IRuntimeAttributor } from \"./attributorContracts.js\";\nimport { AttributorSerializer, chain, deltaEncoder, type Encoder } from \"./encoders.js\";\nimport { makeLZ4Encoder } from \"./lz4Encoder.js\";\n\nexport class RuntimeAttributor implements IRuntimeAttributor {\n\tpublic get IRuntimeAttributor(): IRuntimeAttributor {\n\t\treturn this;\n\t}\n\n\tpublic get(key: AttributionKey): AttributionInfo {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */,\n\t\t);\n\n\t\tif (key.type === \"detached\") {\n\t\t\tthrow new Error(\"Attribution of detached keys is not yet supported.\");\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\t// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current\n\t\t\t// client id in the audience. However, for read->write client transition, the container might have not yet\n\t\t\t// received a client id. This is left as a TODO as it might be more easily solved once the detached case\n\t\t\t// is settled (e.g. if it's reasonable for the host to know the current user information at container\n\t\t\t// creation time, we could just use that here as well).\n\t\t\tthrow new Error(\"Attribution of local keys is not yet supported.\");\n\t\t}\n\n\t\treturn this.opAttributor.getAttributionInfo(key.seq);\n\t}\n\n\tpublic has(key: AttributionKey): boolean {\n\t\tif (key.type === \"detached\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;\n\t}\n\n\tprivate encoder: Encoder<IAttributor, string> = {\n\t\tencode: unreachableCase,\n\t\tdecode: unreachableCase,\n\t};\n\n\tprivate opAttributor: IAttributor | undefined;\n\tpublic isEnabled = true;\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tthis.encoder = chain(\n\t\t\tnew AttributorSerializer(\n\t\t\t\t(entries) => new OpStreamAttributor(deltaManager, quorum, entries),\n\t\t\t\tdeltaEncoder,\n\t\t\t),\n\t\t\tmakeLZ4Encoder(),\n\t\t);\n\n\t\tif (baseSnapshotForAttributorTree === undefined) {\n\t\t\tthis.opAttributor = new OpStreamAttributor(deltaManager, quorum);\n\t\t} else {\n\t\t\tconst id: string | undefined = baseSnapshotForAttributorTree.blobs[opBlobName];\n\t\t\tassert(\n\t\t\t\tid !== undefined,\n\t\t\t\t0x50a /* Attributor tree should have op attributor summary blob. */,\n\t\t\t);\n\t\t\tconst blobContents = await readBlob(id);\n\t\t\tconst attributorSnapshot = bufferToString(blobContents, \"utf8\");\n\t\t\tthis.opAttributor = this.encoder.decode(attributorSnapshot);\n\t\t}\n\t}\n\n\tpublic summarizeOpAttributor(): ISummaryTreeWithStats {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0xa1d /* RuntimeAttributor should be initialized before summarization */,\n\t\t);\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));\n\t\treturn builder.getSummaryTree();\n\t}\n}\n"]}
@@ -13,12 +13,10 @@ import { RuntimeAttributor } from "./runtimeAttributor.js";
13
13
  * Data store channel for the runtime attributor. This channel is responsible for storing and managing the
14
14
  */
15
15
  export class RuntimeAttributorDataStoreChannel extends TypedEventEmitter {
16
+ dataStoreContext;
16
17
  constructor(dataStoreContext, existing) {
17
18
  super();
18
19
  this.dataStoreContext = dataStoreContext;
19
- this._disposed = false;
20
- this.isEnabled = true;
21
- this.deferredAttached = new Deferred();
22
20
  this.runtimeAttributor = new RuntimeAttributor();
23
21
  this.mc = createChildMonitoringContext({
24
22
  logger: dataStoreContext.baseLogger,
@@ -43,12 +41,19 @@ export class RuntimeAttributorDataStoreChannel extends TypedEventEmitter {
43
41
  get IFluidDataStoreChannel() {
44
42
  return this;
45
43
  }
44
+ _disposed = false;
46
45
  get disposed() {
47
46
  return this._disposed;
48
47
  }
49
48
  dispose() {
50
49
  this._disposed = true;
51
50
  }
51
+ runtimeAttributor;
52
+ isEnabled = true;
53
+ attachState;
54
+ visibilityState;
55
+ deferredAttached = new Deferred();
56
+ mc;
52
57
  get logger() {
53
58
  return this.mc.logger;
54
59
  }
@@ -136,6 +141,10 @@ export class RuntimeAttributorDataStoreChannel extends TypedEventEmitter {
136
141
  // Should not rollback anything from the attributor as it does not send ops yet.
137
142
  throw new Error("Should not rollback anything from the attributor");
138
143
  }
144
+ /**
145
+ * {@inheritdoc IFluidDataStoreChannel.entryPoint}
146
+ */
147
+ entryPoint;
139
148
  /**
140
149
  * {@inheritdoc IFluidDataStoreChannel.request}
141
150
  */
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeAttributorDataStoreChannel.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreChannel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,WAAW,GAEX,MAAM,gDAAgD,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAQvE,OAAO,EAKN,eAAe,GAIf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,4BAA4B,EAE5B,mBAAmB,GAEnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,iCACZ,SAAQ,iBAA+C;IAGvD,YACiB,gBAAwC,EACxD,QAAiB;QAEjB,KAAK,EAAE,CAAC;QAHQ,qBAAgB,GAAhB,gBAAgB,CAAwB;QAiCjD,cAAS,GAAG,KAAK,CAAC;QAUnB,cAAS,GAAG,IAAI,CAAC;QAGP,qBAAgB,GAAG,IAAI,QAAQ,EAAQ,CAAC;QA1CxD,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACjD,IAAI,CAAC,EAAE,GAAG,4BAA4B,CAAC;YACtC,MAAM,EAAE,gBAAgB,CAAC,UAAU;YACnC,SAAS,EAAE,YAAY;SACvB,CAAC,CAAC;QACH,IAAI,CAAC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,IAAY,EAAE,OAAgB,EAAE,eAAwB;QACxE,gFAAgF;QAChF,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACrE,CAAC;IAOD;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,wGAAwG;QACxG,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,WAAyD;QAC9E,QAAQ,WAAW,EAAE,CAAC;YACrB,KAAK,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC5B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC;gBAEzC,MAAM,CACL,IAAI,CAAC,eAAe,KAAK,eAAe,CAAC,cAAc,EACvD,KAAK,CAAC,iFAAiF,CACvF,CAAC;gBAEF,oFAAoF;gBACpF,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC,eAAe,CAAC;gBAEvD,qFAAqF;gBACrF,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACvB,MAAM;YACP,CAAC;YACD,KAAK,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC3B,MAAM,CACL,IAAI,CAAC,eAAe,KAAK,eAAe,CAAC,eAAe,EACxD,KAAK,CAAC,8DAA8D,CACpE,CAAC;gBACF,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC;gBACxC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACtB,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,eAAe,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype IDeltaManager,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject, IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport type { IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, Deferred, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore/internal\";\nimport type { IFluidDataStoreRuntimeEvents } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype IGarbageCollectionData,\n\ttype IFluidDataStoreChannel,\n\ttype IFluidDataStoreContext,\n\ttype IInboundSignalMessage,\n\tVisibilityState,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n\ttype IRuntimeMessageCollection,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tcreateChildMonitoringContext,\n\ttype MonitoringContext,\n\traiseConnectedEvent,\n\ttype TelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributor } from \"./runtimeAttributor.js\";\n\n/**\n * Data store channel for the runtime attributor. This channel is responsible for storing and managing the\n */\nexport class RuntimeAttributorDataStoreChannel\n\textends TypedEventEmitter<IFluidDataStoreRuntimeEvents>\n\timplements IFluidDataStoreChannel\n{\n\tpublic constructor(\n\t\tpublic readonly dataStoreContext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t) {\n\t\tsuper();\n\t\tthis.runtimeAttributor = new RuntimeAttributor();\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: dataStoreContext.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\t\tthis.attachState = dataStoreContext.attachState;\n\t\tif (existing) {\n\t\t\tthis.visibilityState =\n\t\t\t\tdataStoreContext.attachState === AttachState.Detached\n\t\t\t\t\t? VisibilityState.LocallyVisible\n\t\t\t\t\t: VisibilityState.GloballyVisible;\n\t\t} else {\n\t\t\tthis.visibilityState = VisibilityState.NotVisible;\n\t\t}\n\t\t// If it's existing we know it has been attached.\n\t\tif (existing) {\n\t\t\tthis.deferredAttached.resolve();\n\t\t}\n\t\tthis.entryPoint = new FluidObjectHandle<FluidObject>(\n\t\t\tthis.runtimeAttributor,\n\t\t\t\"\",\n\t\t\tdataStoreContext.IFluidHandleContext,\n\t\t);\n\t}\n\n\tpublic get IFluidDataStoreChannel(): IFluidDataStoreChannel {\n\t\treturn this;\n\t}\n\n\tprivate _disposed = false;\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis._disposed = true;\n\t}\n\n\tprivate readonly runtimeAttributor: RuntimeAttributor;\n\tpublic isEnabled = true;\n\tpublic attachState: AttachState;\n\tpublic visibilityState: VisibilityState;\n\tprivate readonly deferredAttached = new Deferred<void>();\n\tprivate readonly mc: MonitoringContext;\n\tpublic get logger(): TelemetryLoggerExt {\n\t\treturn this.mc.logger;\n\t}\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tawait this.runtimeAttributor.initialize(\n\t\t\tdeltaManager,\n\t\t\tquorum,\n\t\t\tbaseSnapshotForAttributorTree,\n\t\t\treadBlob,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.makeVisibleAndAttachGraph}\n\t */\n\tpublic makeVisibleAndAttachGraph(): void {\n\t\tif (this.visibilityState !== VisibilityState.NotVisible) {\n\t\t\treturn;\n\t\t}\n\t\tthis.visibilityState = VisibilityState.LocallyVisible;\n\n\t\tthis.dataStoreContext.makeLocallyVisible();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachSummary}\n\t */\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachGCData}\n\t */\n\tpublic getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData {\n\t\treturn { gcNodes: {} };\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.processMessages}\n\t */\n\tpublic processMessages(messageCollection: IRuntimeMessageCollection): void {\n\t\tthrow new Error(\"Attributor should not receive messages yet\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.processSignal}\n\t */\n\tpublic processSignal(message: IInboundSignalMessage, local: boolean): void {\n\t\tthrow new Error(\"Attributor should not receive signals\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getGCData}\n\t */\n\tpublic async getGCData(fullGC?: boolean): Promise<IGarbageCollectionData> {\n\t\t// Nothing to be GCed from the attributor.\n\t\tconst garbageCollectionData: IGarbageCollectionData = { gcNodes: {} };\n\t\treturn garbageCollectionData;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.updateUsedRoutes}\n\t */\n\tpublic updateUsedRoutes(usedRoutes: string[]): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setConnectionState}\n\t */\n\tpublic setConnectionState(connected: boolean, clientId?: string): void {\n\t\traiseConnectedEvent(this.logger, this, connected, clientId);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.reSubmit}\n\t */\n\tpublic reSubmit(): void {\n\t\t// Should not resubmit anything from the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not resubmit anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.applyStashedOp}\n\t */\n\tpublic async applyStashedOp(content: unknown): Promise<unknown> {\n\t\t// Should not apply stashed ops to the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not apply stashed ops to the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.rollback}\n\t */\n\tpublic rollback?(type: string, content: unknown, localOpMetadata: unknown): void {\n\t\t// Should not rollback anything from the attributor as it does not send ops yet.\n\t\tthrow new Error(\"Should not rollback anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.entryPoint}\n\t */\n\tpublic readonly entryPoint: IFluidHandleInternal<FluidObject>;\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.request}\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\t// Should not request anything from the attributor as the attributor does not have any channels further.\n\t\tthrow new Error(\"Should not request anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setAttachState}\n\t */\n\tpublic setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {\n\t\tswitch (attachState) {\n\t\t\tcase AttachState.Attaching: {\n\t\t\t\tthis.attachState = AttachState.Attaching;\n\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.LocallyVisible,\n\t\t\t\t\t0xa1e /* Data store should be locally visible before it can become globally visible. */,\n\t\t\t\t);\n\n\t\t\t\t// Mark the data store globally visible and make its child channels visible as well.\n\t\t\t\tthis.visibilityState = VisibilityState.GloballyVisible;\n\n\t\t\t\t// This promise resolution will be moved to attached event once we fix the scheduler.\n\t\t\t\tthis.deferredAttached.resolve();\n\t\t\t\tthis.emit(\"attaching\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase AttachState.Attached: {\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.GloballyVisible,\n\t\t\t\t\t0xa1f /* Data store should be globally visible when its attached. */,\n\t\t\t\t);\n\t\t\t\tthis.attachState = AttachState.Attached;\n\t\t\t\tthis.emit(\"attached\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(attachState, \"unreached\");\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"runtimeAttributorDataStoreChannel.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreChannel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,WAAW,GAEX,MAAM,gDAAgD,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAQvE,OAAO,EAKN,eAAe,GAIf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,4BAA4B,EAE5B,mBAAmB,GAEnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,iCACZ,SAAQ,iBAA+C;IAItC;IADjB,YACiB,gBAAwC,EACxD,QAAiB;QAEjB,KAAK,EAAE,CAAC;QAHQ,qBAAgB,GAAhB,gBAAgB,CAAwB;QAIxD,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACjD,IAAI,CAAC,EAAE,GAAG,4BAA4B,CAAC;YACtC,MAAM,EAAE,gBAAgB,CAAC,UAAU;YACnC,SAAS,EAAE,YAAY;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,WAAW,CAAC;QAChD,IAAI,QAAQ,EAAE,CAAC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C,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype IDeltaManager,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { FluidObject, IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport type { IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, Deferred, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore/internal\";\nimport type { IFluidDataStoreRuntimeEvents } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype IGarbageCollectionData,\n\ttype IFluidDataStoreChannel,\n\ttype IFluidDataStoreContext,\n\ttype IInboundSignalMessage,\n\tVisibilityState,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n\ttype IRuntimeMessageCollection,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tcreateChildMonitoringContext,\n\ttype MonitoringContext,\n\traiseConnectedEvent,\n\ttype TelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributor } from \"./runtimeAttributor.js\";\n\n/**\n * Data store channel for the runtime attributor. This channel is responsible for storing and managing the\n */\nexport class RuntimeAttributorDataStoreChannel\n\textends TypedEventEmitter<IFluidDataStoreRuntimeEvents>\n\timplements IFluidDataStoreChannel\n{\n\tpublic constructor(\n\t\tpublic readonly dataStoreContext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t) {\n\t\tsuper();\n\t\tthis.runtimeAttributor = new RuntimeAttributor();\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: dataStoreContext.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\t\tthis.attachState = dataStoreContext.attachState;\n\t\tif (existing) {\n\t\t\tthis.visibilityState =\n\t\t\t\tdataStoreContext.attachState === AttachState.Detached\n\t\t\t\t\t? VisibilityState.LocallyVisible\n\t\t\t\t\t: VisibilityState.GloballyVisible;\n\t\t} else {\n\t\t\tthis.visibilityState = VisibilityState.NotVisible;\n\t\t}\n\t\t// If it's existing we know it has been attached.\n\t\tif (existing) {\n\t\t\tthis.deferredAttached.resolve();\n\t\t}\n\t\tthis.entryPoint = new FluidObjectHandle<FluidObject>(\n\t\t\tthis.runtimeAttributor,\n\t\t\t\"\",\n\t\t\tdataStoreContext.IFluidHandleContext,\n\t\t);\n\t}\n\n\tpublic get IFluidDataStoreChannel(): IFluidDataStoreChannel {\n\t\treturn this;\n\t}\n\n\tprivate _disposed = false;\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis._disposed = true;\n\t}\n\n\tprivate readonly runtimeAttributor: RuntimeAttributor;\n\tpublic isEnabled = true;\n\tpublic attachState: AttachState;\n\tpublic visibilityState: VisibilityState;\n\tprivate readonly deferredAttached = new Deferred<void>();\n\tprivate readonly mc: MonitoringContext;\n\tpublic get logger(): TelemetryLoggerExt {\n\t\treturn this.mc.logger;\n\t}\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tawait this.runtimeAttributor.initialize(\n\t\t\tdeltaManager,\n\t\t\tquorum,\n\t\t\tbaseSnapshotForAttributorTree,\n\t\t\treadBlob,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.makeVisibleAndAttachGraph}\n\t */\n\tpublic makeVisibleAndAttachGraph(): void {\n\t\tif (this.visibilityState !== VisibilityState.NotVisible) {\n\t\t\treturn;\n\t\t}\n\t\tthis.visibilityState = VisibilityState.LocallyVisible;\n\n\t\tthis.dataStoreContext.makeLocallyVisible();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachSummary}\n\t */\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachGCData}\n\t */\n\tpublic getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData {\n\t\treturn { gcNodes: {} };\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.processMessages}\n\t */\n\tpublic processMessages(messageCollection: IRuntimeMessageCollection): void {\n\t\tthrow new Error(\"Attributor should not receive messages yet\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.processSignal}\n\t */\n\tpublic processSignal(message: IInboundSignalMessage, local: boolean): void {\n\t\tthrow new Error(\"Attributor should not receive signals\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getGCData}\n\t */\n\tpublic async getGCData(fullGC?: boolean): Promise<IGarbageCollectionData> {\n\t\t// Nothing to be GCed from the attributor.\n\t\tconst garbageCollectionData: IGarbageCollectionData = { gcNodes: {} };\n\t\treturn garbageCollectionData;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.updateUsedRoutes}\n\t */\n\tpublic updateUsedRoutes(usedRoutes: string[]): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setConnectionState}\n\t */\n\tpublic setConnectionState(connected: boolean, clientId?: string): void {\n\t\traiseConnectedEvent(this.logger, this, connected, clientId);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.reSubmit}\n\t */\n\tpublic reSubmit(): void {\n\t\t// Should not resubmit anything from the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not resubmit anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.applyStashedOp}\n\t */\n\tpublic async applyStashedOp(content: unknown): Promise<unknown> {\n\t\t// Should not apply stashed ops to the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not apply stashed ops to the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.rollback}\n\t */\n\tpublic rollback?(type: string, content: unknown, localOpMetadata: unknown): void {\n\t\t// Should not rollback anything from the attributor as it does not send ops yet.\n\t\tthrow new Error(\"Should not rollback anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.entryPoint}\n\t */\n\tpublic readonly entryPoint: IFluidHandleInternal<FluidObject>;\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.request}\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\t// Should not request anything from the attributor as the attributor does not have any channels further.\n\t\tthrow new Error(\"Should not request anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setAttachState}\n\t */\n\tpublic setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {\n\t\tswitch (attachState) {\n\t\t\tcase AttachState.Attaching: {\n\t\t\t\tthis.attachState = AttachState.Attaching;\n\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.LocallyVisible,\n\t\t\t\t\t0xa1e /* Data store should be locally visible before it can become globally visible. */,\n\t\t\t\t);\n\n\t\t\t\t// Mark the data store globally visible and make its child channels visible as well.\n\t\t\t\tthis.visibilityState = VisibilityState.GloballyVisible;\n\n\t\t\t\t// This promise resolution will be moved to attached event once we fix the scheduler.\n\t\t\t\tthis.deferredAttached.resolve();\n\t\t\t\tthis.emit(\"attaching\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase AttachState.Attached: {\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.GloballyVisible,\n\t\t\t\t\t0xa1f /* Data store should be globally visible when its attached. */,\n\t\t\t\t);\n\t\t\t\tthis.attachState = AttachState.Attached;\n\t\t\t\tthis.emit(\"attached\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(attachState, \"unreached\");\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -8,6 +8,7 @@ import { RuntimeAttributorDataStoreChannel } from "./runtimeAttributorDataStoreC
8
8
  * Factory for the runtime attributor data store channel.
9
9
  */
10
10
  export class RuntimeAttributorFactory {
11
+ static type = "@fluid-experimental/attributor";
11
12
  get type() {
12
13
  return RuntimeAttributorFactory.type;
13
14
  }
@@ -31,5 +32,4 @@ export class RuntimeAttributorFactory {
31
32
  return runtime;
32
33
  }
33
34
  }
34
- RuntimeAttributorFactory.type = "@fluid-experimental/attributor";
35
35
  //# sourceMappingURL=runtimeAttributorDataStoreFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeAttributorDataStoreFactory.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE/F,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAE3F;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAGpC,IAAW,IAAI;QACd,OAAO,wBAAwB,CAAC,IAAI,CAAC;IACtC,CAAC;IAED,IAAW,sBAAsB;QAChC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAChC,OAA+B,EAC/B,QAAiB;QAEjB,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEzE,MAAM,MAAM,GAAG,iBAAiB,CAAC;YAChC,MAAM,EAAE,OAAO,CAAC,UAAU;YAC1B,SAAS,EAAE,YAAY;SACvB,CAAC,CAAC;QAEH,MAAM,gBAAgB,CAAC,cAAc,CACpC,MAAM,EACN;YACC,SAAS,EAAE,YAAY;SACvB,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,OAAO,CAAC,UAAU,CACvB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,SAAS,EAAE,EACnB,OAAO,CAAC,YAAY,EACpB,KAAK,EAAE,EAAU,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAClD,CAAC;YACF,KAAK,CAAC,GAAG,CAAC;gBACT,uBAAuB,EAAE,IAAI,EAAE,wDAAwD;aACvF,CAAC,CAAC;QACJ,CAAC,CACD,CAAC;QACF,OAAO,OAAO,CAAC;IAChB,CAAC;;AAvCsB,6BAAI,GAAG,gCAAgC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributorDataStoreChannel } from \"./runtimeAttributorDataStoreChannel.js\";\n\n/**\n * Factory for the runtime attributor data store channel.\n */\nexport class RuntimeAttributorFactory implements IFluidDataStoreFactory {\n\tpublic static readonly type = \"@fluid-experimental/attributor\";\n\n\tpublic get type(): string {\n\t\treturn RuntimeAttributorFactory.type;\n\t}\n\n\tpublic get IFluidDataStoreFactory(): IFluidDataStoreFactory {\n\t\treturn this;\n\t}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\tconst runtime = new RuntimeAttributorDataStoreChannel(context, existing);\n\n\t\tconst logger = createChildLogger({\n\t\t\tlogger: context.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"initialize\",\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tawait runtime.initialize(\n\t\t\t\t\tcontext.deltaManager,\n\t\t\t\t\tcontext.getQuorum(),\n\t\t\t\t\tcontext.baseSnapshot,\n\t\t\t\t\tasync (id: string) => context.storage.readBlob(id),\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tattributionEnabledInDoc: true, // If we are instantiating the attributor, it is enabled\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t\treturn runtime;\n\t}\n}\n"]}
1
+ {"version":3,"file":"runtimeAttributorDataStoreFactory.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE/F,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAE3F;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAC7B,MAAM,CAAU,IAAI,GAAG,gCAAgC,CAAC;IAE/D,IAAW,IAAI;QACd,OAAO,wBAAwB,CAAC,IAAI,CAAC;IACtC,CAAC;IAED,IAAW,sBAAsB;QAChC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAChC,OAA+B,EAC/B,QAAiB;QAEjB,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEzE,MAAM,MAAM,GAAG,iBAAiB,CAAC;YAChC,MAAM,EAAE,OAAO,CAAC,UAAU;YAC1B,SAAS,EAAE,YAAY;SACvB,CAAC,CAAC;QAEH,MAAM,gBAAgB,CAAC,cAAc,CACpC,MAAM,EACN;YACC,SAAS,EAAE,YAAY;SACvB,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,OAAO,CAAC,UAAU,CACvB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,SAAS,EAAE,EACnB,OAAO,CAAC,YAAY,EACpB,KAAK,EAAE,EAAU,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAClD,CAAC;YACF,KAAK,CAAC,GAAG,CAAC;gBACT,uBAAuB,EAAE,IAAI,EAAE,wDAAwD;aACvF,CAAC,CAAC;QACJ,CAAC,CACD,CAAC;QACF,OAAO,OAAO,CAAC;IAChB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributorDataStoreChannel } from \"./runtimeAttributorDataStoreChannel.js\";\n\n/**\n * Factory for the runtime attributor data store channel.\n */\nexport class RuntimeAttributorFactory implements IFluidDataStoreFactory {\n\tpublic static readonly type = \"@fluid-experimental/attributor\";\n\n\tpublic get type(): string {\n\t\treturn RuntimeAttributorFactory.type;\n\t}\n\n\tpublic get IFluidDataStoreFactory(): IFluidDataStoreFactory {\n\t\treturn this;\n\t}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\tconst runtime = new RuntimeAttributorDataStoreChannel(context, existing);\n\n\t\tconst logger = createChildLogger({\n\t\t\tlogger: context.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"initialize\",\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tawait runtime.initialize(\n\t\t\t\t\tcontext.deltaManager,\n\t\t\t\t\tcontext.getQuorum(),\n\t\t\t\t\tcontext.baseSnapshot,\n\t\t\t\t\tasync (id: string) => context.storage.readBlob(id),\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tattributionEnabledInDoc: true, // If we are instantiating the attributor, it is enabled\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t\treturn runtime;\n\t}\n}\n"]}
@@ -9,13 +9,13 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
9
9
  * retrieve the string.
10
10
  */
11
11
  export class MutableStringInterner {
12
+ stringToInternedIdMap = new Map();
13
+ internedStrings = [];
12
14
  /**
13
15
  * @param inputStrings - A list of strings to intern in the order given. Can be used to rehydrate from a previous
14
16
  * `StringInterner`'s {@link StringInterner.getSerializable} return value.
15
17
  */
16
18
  constructor(inputStrings = []) {
17
- this.stringToInternedIdMap = new Map();
18
- this.internedStrings = [];
19
19
  for (const value of inputStrings) {
20
20
  this.getOrCreateInternedId(value);
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stringInterner.js","sourceRoot":"","sources":["../src/stringInterner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAoBtE;;;;GAIG;AACH,MAAM,OAAO,qBAAqB;IAIjC;;;OAGG;IACH,YAAmB,eAAkC,EAAE;QAPtC,0BAAqB,GAAG,IAAI,GAAG,EAA4B,CAAC;QAC5D,oBAAe,GAAa,EAAE,CAAC;QAO/C,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;YAClC,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IAED;;;OAGG;IACI,qBAAqB,CAAC,KAAa;QACzC,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IAEM,aAAa,CAAC,KAAa;QACjC,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,QAAgB;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,UAAU,CAAC,6BAA6B,QAAQ,GAAG,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,eAAe;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,KAAa;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAwB,CAAC;QACvE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,UAAU,CAAC;IACnB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * The ID of the string that has been interned, which can be used by a {@link StringInterner} to retrieve the\n * original string.\n * @public\n */\nexport type InternedStringId = number & {\n\treadonly InternedStringId: \"e221abc9-9d17-4493-8db0-70c871a1c27c\";\n};\n\n/**\n * Interns strings as integers.\n */\nexport interface StringInterner {\n\tgetInternedId(input: string): InternedStringId | undefined;\n\tgetString(internedId: number): string;\n\tgetSerializable(): readonly string[];\n}\n\n/**\n * Interns strings as integers.\n * Given a string, this class will produce a unique integer associated with that string that can then be used to\n * retrieve the string.\n */\nexport class MutableStringInterner implements StringInterner {\n\tprivate readonly stringToInternedIdMap = new Map<string, InternedStringId>();\n\tprivate readonly internedStrings: string[] = [];\n\n\t/**\n\t * @param inputStrings - A list of strings to intern in the order given. Can be used to rehydrate from a previous\n\t * `StringInterner`'s {@link StringInterner.getSerializable} return value.\n\t */\n\tpublic constructor(inputStrings: readonly string[] = []) {\n\t\tfor (const value of inputStrings) {\n\t\t\tthis.getOrCreateInternedId(value);\n\t\t}\n\t}\n\n\t/**\n\t * Creates an intern ID that is uniquely associated with the input string.\n\t * @param input - The string to get the associated intern ID for.\n\t */\n\tpublic getOrCreateInternedId(input: string): InternedStringId {\n\t\treturn this.getInternedId(input) ?? this.createNewId(input);\n\t}\n\n\tpublic getInternedId(input: string): InternedStringId | undefined {\n\t\treturn this.stringToInternedIdMap.get(input);\n\t}\n\n\t/**\n\t * Creates a string that is uniquely associated with the given intern ID.\n\t * @param internId - The intern ID to get the associated string for. Can only retrieve strings that have been\n\t * used as inputs to calls of `getInternId`.\n\t */\n\tpublic getString(internId: number): string {\n\t\tconst result = this.internedStrings[internId];\n\t\tif (result === undefined) {\n\t\t\tthrow new UsageError(`No string associated with ${internId}.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets the list of strings interned where the indices map to the associated {@link InternedStringId} of\n\t * each string.\n\t */\n\tpublic getSerializable(): readonly string[] {\n\t\treturn this.internedStrings;\n\t}\n\n\t/**\n\t * Create a new interned id.\n\t *\n\t * @remarks Assumes (without validation) that the input doesn't already have an interned id.\n\t */\n\tprivate createNewId(input: string): InternedStringId {\n\t\tconst internedId = this.stringToInternedIdMap.size as InternedStringId;\n\t\tthis.stringToInternedIdMap.set(input, internedId);\n\t\tthis.internedStrings.push(input);\n\t\treturn internedId;\n\t}\n}\n"]}
1
+ {"version":3,"file":"stringInterner.js","sourceRoot":"","sources":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AAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * The ID of the string that has been interned, which can be used by a {@link StringInterner} to retrieve the\n * original string.\n * @public\n */\nexport type InternedStringId = number & {\n\treadonly InternedStringId: \"e221abc9-9d17-4493-8db0-70c871a1c27c\";\n};\n\n/**\n * Interns strings as integers.\n */\nexport interface StringInterner {\n\tgetInternedId(input: string): InternedStringId | undefined;\n\tgetString(internedId: number): string;\n\tgetSerializable(): readonly string[];\n}\n\n/**\n * Interns strings as integers.\n * Given a string, this class will produce a unique integer associated with that string that can then be used to\n * retrieve the string.\n */\nexport class MutableStringInterner implements StringInterner {\n\tprivate readonly stringToInternedIdMap = new Map<string, InternedStringId>();\n\tprivate readonly internedStrings: string[] = [];\n\n\t/**\n\t * @param inputStrings - A list of strings to intern in the order given. Can be used to rehydrate from a previous\n\t * `StringInterner`'s {@link StringInterner.getSerializable} return value.\n\t */\n\tpublic constructor(inputStrings: readonly string[] = []) {\n\t\tfor (const value of inputStrings) {\n\t\t\tthis.getOrCreateInternedId(value);\n\t\t}\n\t}\n\n\t/**\n\t * Creates an intern ID that is uniquely associated with the input string.\n\t * @param input - The string to get the associated intern ID for.\n\t */\n\tpublic getOrCreateInternedId(input: string): InternedStringId {\n\t\treturn this.getInternedId(input) ?? this.createNewId(input);\n\t}\n\n\tpublic getInternedId(input: string): InternedStringId | undefined {\n\t\treturn this.stringToInternedIdMap.get(input);\n\t}\n\n\t/**\n\t * Creates a string that is uniquely associated with the given intern ID.\n\t * @param internId - The intern ID to get the associated string for. Can only retrieve strings that have been\n\t * used as inputs to calls of `getInternId`.\n\t */\n\tpublic getString(internId: number): string {\n\t\tconst result = this.internedStrings[internId];\n\t\tif (result === undefined) {\n\t\t\tthrow new UsageError(`No string associated with ${internId}.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets the list of strings interned where the indices map to the associated {@link InternedStringId} of\n\t * each string.\n\t */\n\tpublic getSerializable(): readonly string[] {\n\t\treturn this.internedStrings;\n\t}\n\n\t/**\n\t * Create a new interned id.\n\t *\n\t * @remarks Assumes (without validation) that the input doesn't already have an interned id.\n\t */\n\tprivate createNewId(input: string): InternedStringId {\n\t\tconst internedId = this.stringToInternedIdMap.size as InternedStringId;\n\t\tthis.stringToInternedIdMap.set(input, internedId);\n\t\tthis.internedStrings.push(input);\n\t\treturn internedId;\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/attributor",
3
- "version": "2.117.0",
3
+ "version": "3.0.0",
4
4
  "description": "Operation attributor",
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,32 +41,32 @@
49
41
  "temp-directory": "nyc/.nyc_output"
50
42
  },
51
43
  "dependencies": {
52
- "@fluid-internal/client-utils": "~2.117.0",
53
- "@fluidframework/container-definitions": "~2.117.0",
54
- "@fluidframework/container-runtime": "~2.117.0",
55
- "@fluidframework/container-runtime-definitions": "~2.117.0",
56
- "@fluidframework/core-interfaces": "~2.117.0",
57
- "@fluidframework/core-utils": "~2.117.0",
58
- "@fluidframework/datastore": "~2.117.0",
59
- "@fluidframework/datastore-definitions": "~2.117.0",
60
- "@fluidframework/driver-definitions": "~2.117.0",
61
- "@fluidframework/runtime-definitions": "~2.117.0",
62
- "@fluidframework/runtime-utils": "~2.117.0",
63
- "@fluidframework/telemetry-utils": "~2.117.0",
44
+ "@fluid-internal/client-utils": "~3.0.0",
45
+ "@fluidframework/container-definitions": "~3.0.0",
46
+ "@fluidframework/container-runtime": "~3.0.0",
47
+ "@fluidframework/container-runtime-definitions": "~3.0.0",
48
+ "@fluidframework/core-interfaces": "~3.0.0",
49
+ "@fluidframework/core-utils": "~3.0.0",
50
+ "@fluidframework/datastore": "~3.0.0",
51
+ "@fluidframework/datastore-definitions": "~3.0.0",
52
+ "@fluidframework/driver-definitions": "~3.0.0",
53
+ "@fluidframework/runtime-definitions": "~3.0.0",
54
+ "@fluidframework/runtime-utils": "~3.0.0",
55
+ "@fluidframework/telemetry-utils": "~3.0.0",
64
56
  "lz4js": "^0.2.0"
65
57
  },
66
58
  "devDependencies": {
67
59
  "@arethetypeswrong/cli": "^0.18.5",
68
60
  "@biomejs/biome": "~2.4.5",
69
- "@fluid-internal/mocha-test-setup": "~2.117.0",
70
- "@fluid-private/stochastic-test-utils": "~2.117.0",
61
+ "@fluid-internal/mocha-test-setup": "~3.0.0",
62
+ "@fluid-private/stochastic-test-utils": "~3.0.0",
71
63
  "@fluid-tools/build-cli": "^0.67.0",
72
64
  "@fluidframework/build-common": "^2.0.3",
73
65
  "@fluidframework/build-tools": "^0.67.0",
74
66
  "@fluidframework/eslint-config-fluid": "^14.0.0",
75
- "@fluidframework/merge-tree": "~2.117.0",
76
- "@fluidframework/sequence": "~2.117.0",
77
- "@fluidframework/test-runtime-utils": "~2.117.0",
67
+ "@fluidframework/merge-tree": "~3.0.0",
68
+ "@fluidframework/sequence": "~3.0.0",
69
+ "@fluidframework/test-runtime-utils": "~3.0.0",
78
70
  "@microsoft/api-extractor": "7.58.1",
79
71
  "@types/mocha": "^10.0.10",
80
72
  "@types/node": "~22.19.17",
@@ -87,28 +79,31 @@
87
79
  "mocha": "^11.7.5",
88
80
  "mocha-multi-reporters": "^1.5.1",
89
81
  "rimraf": "^6.1.3",
90
- "typescript": "~5.4.5"
82
+ "typescript": "~6.0.3"
91
83
  },
92
84
  "typeValidation": {
93
85
  "disabled": true
94
86
  },
95
87
  "scripts": {
96
88
  "build": "fluid-build . --task build",
89
+ "build:api-reports": "api-extractor run --local --config api-extractor/api-extractor-report.json",
90
+ "build:cjs": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
97
91
  "build:commonjs": "fluid-build . --task commonjs",
98
92
  "build:compile": "fluid-build . --task compile",
99
- "build:docs": "api-extractor run --local",
100
- "build:esnext": "tsc --project ./tsconfig.json",
93
+ "build:docs": "api-extractor run --local --config api-extractor/api-extractor-model.json",
94
+ "build:esm": "tsc --project ./tsconfig.json",
101
95
  "build:test": "concurrently npm:build:test:esm npm:build:test:cjs",
102
96
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
103
97
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
104
- "check:are-the-types-wrong": "attw --pack .",
98
+ "check:are-the-types-wrong": "attw --pack . --profile esm-only",
105
99
  "check:biome": "biome check .",
106
100
  "check:exports": "concurrently \"npm:check:exports:*\"",
107
101
  "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
108
102
  "check:exports:cjs:index": "api-extractor run --config api-extractor/api-extractor-lint-index.cjs.json",
109
103
  "check:exports:esm:index": "api-extractor run --config api-extractor/api-extractor-lint-index.esm.json",
110
104
  "check:format": "npm run check:biome",
111
- "ci:build:docs": "api-extractor run",
105
+ "ci:build:api-reports": "api-extractor run --config api-extractor/api-extractor-report.json",
106
+ "ci:build:docs": "api-extractor run --config api-extractor/api-extractor-model.json",
112
107
  "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
113
108
  "eslint": "eslint --quiet --format stylish src",
114
109
  "eslint:fix": "eslint --quiet --format stylish src --fix --fix-type problem,suggestion,layout",
@@ -121,7 +116,6 @@
121
116
  "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
122
117
  "test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
123
118
  "test:mocha:esm": "mocha",
124
- "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
125
- "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist"
119
+ "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha"
126
120
  }
127
121
  }
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
  "include": ["src/**/*"],
4
4
  "exclude": ["src/test/**/*"],
5
5
  "compilerOptions": {