@fluidframework/counter 2.117.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -2
- package/README.md +53 -50
- package/{api-extractor.json → api-extractor/api-extractor-model.json} +1 -1
- package/dist/counter.js +9 -9
- package/dist/counter.js.map +1 -1
- package/dist/counterFactory.d.ts +1 -1
- package/dist/counterFactory.d.ts.map +1 -1
- package/dist/counterFactory.js +15 -15
- package/dist/counterFactory.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/counter.js +9 -9
- package/lib/counter.js.map +1 -1
- package/lib/counterFactory.js +15 -15
- package/lib/counterFactory.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/package.json +36 -56
- package/src/packageVersion.ts +1 -1
- package/tsconfig.json +1 -1
- package/internal.d.ts +0 -11
- package/legacy.d.ts +0 -11
- /package/api-extractor/{api-extractor.current.json → api-extractor-report.current.json} +0 -0
- /package/api-extractor/{api-extractor.legacy.json → api-extractor-report.legacy.json} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
# @fluidframework/counter
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 3.0.0
|
|
4
4
|
|
|
5
|
-
|
|
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
|
+
- Require modern TypeScript module resolution ([#27970](https://github.com/microsoft/FluidFramework/pull/27970)) [325e2016ca9](https://github.com/microsoft/FluidFramework/commit/325e2016ca9978d4a1f7552c97ba34feac9df41f)
|
|
15
|
+
|
|
16
|
+
Fluid Framework Client packages no longer include type declaration compatibility entrypoints for TypeScript's legacy Node10 resolution mode (`"moduleResolution": "node"` or `"node10"`).
|
|
17
|
+
Applications upgrading to Fluid Framework 3.0 must use one of the following supported configurations:
|
|
18
|
+
- `"module": "Node16"` with `"moduleResolution": "Node16"`
|
|
19
|
+
- `"module": "NodeNext"` with `"moduleResolution": "NodeNext"`
|
|
20
|
+
- `"module": "ESNext"` with `"moduleResolution": "Bundler"`
|
|
21
|
+
|
|
22
|
+
Existing public package entrypoints exposed through `package.json` exports, including `/alpha`, `/beta`, and `/legacy`, remain available under supported module resolution modes.
|
|
23
|
+
|
|
24
|
+
See [Removal of Node10 resolutions in v3.0](https://github.com/microsoft/FluidFramework/issues/27457) for more information.
|
|
25
|
+
|
|
26
|
+
- Client packages now target ES2022 ([#27846](https://github.com/microsoft/FluidFramework/pull/27846)) [91c78541bdd](https://github.com/microsoft/FluidFramework/commit/91c78541bddcbca5d6c5f357b023eeaee617d885)
|
|
27
|
+
|
|
28
|
+
The TypeScript compilation `target` and `lib` for the Fluid Framework client packages have been raised from ES2021/ES2020 to **ES2022**.
|
|
29
|
+
The published JavaScript now uses ES2022 language features (with correspondingly less down-leveling), so consuming these packages requires a runtime that supports ES2022.
|
|
30
|
+
All actively supported Node.js versions and evergreen browsers already meet this requirement.
|
|
31
|
+
|
|
32
|
+
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.
|
|
33
|
+
|
|
34
|
+
It is possible this change could impact users of less up to date JavaScript runtimes.
|
|
35
|
+
Impacted users can use a tool like [babel](https://babeljs.io/) to transpile out unsupported language features.
|
|
36
|
+
|
|
37
|
+
- Build with TypeScript 6 ([#28052](https://github.com/microsoft/FluidFramework/pull/28052)) [7ab015c49de](https://github.com/microsoft/FluidFramework/commit/7ab015c49deec84833cdfe1fb5e1606b901f6e81)
|
|
38
|
+
|
|
39
|
+
FluidFramework Client SDK is now built using TypeScript 6. Consumers should build with TypeScript v6 or v7 or compatible tooling.
|
|
6
40
|
|
|
7
41
|
## 2.116.0
|
|
8
42
|
|
package/README.md
CHANGED
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
## Using Fluid Framework libraries
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
library consumers should always prefer `^`.
|
|
10
|
+
For a dependency on a Fluid Framework library's public APIs, we recommend a `^` (caret) version range.
|
|
11
|
+
For example, use `^1.3.4`.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
For a dependency on an unstable API, such as a `beta` API, we recommend a more restrictive version range.
|
|
14
|
+
For example, use a `~` version range.
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Run this command to install the package:
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
21
|
npm i @fluidframework/counter
|
|
@@ -23,16 +23,16 @@ npm i @fluidframework/counter
|
|
|
23
23
|
|
|
24
24
|
## Importing from this package
|
|
25
25
|
|
|
26
|
-
This package
|
|
27
|
-
For
|
|
26
|
+
This package uses [package.json exports](https://nodejs.org/api/packages.html#exports) to separate APIs by support level.
|
|
27
|
+
For information about the support guarantees, read [API Support Levels](https://fluidframework.com/docs/build/releases-and-apitags/#api-support-levels).
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Import the `public` APIs from `@fluidframework/counter`.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Import the `legacy` APIs from `@fluidframework/counter/legacy`.
|
|
32
32
|
|
|
33
33
|
## API Documentation
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Read the **@fluidframework/counter** API documentation at <https://fluidframework.com/docs/apis/counter>.
|
|
36
36
|
|
|
37
37
|
<!-- prettier-ignore-end -->
|
|
38
38
|
|
|
@@ -183,62 +183,69 @@ Since `updateCounterValueLabel` is listening for all `incremented` events, the v
|
|
|
183
183
|
|
|
184
184
|
## Minimum Client Requirements
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
These requirements
|
|
188
|
-
|
|
186
|
+
Fluid Framework client libraries support the platforms in this document.
|
|
187
|
+
These requirements are intentionally restrictive.
|
|
188
|
+
Within a major version series, we can relax these requirements, but we cannot make them stricter.
|
|
189
|
+
For a Long Term Support (LTS) version, we might need to support these platforms for several years.
|
|
189
190
|
|
|
190
|
-
|
|
191
|
-
If
|
|
192
|
-
|
|
191
|
+
Other configurations can work, but Fluid Framework does not support them.
|
|
192
|
+
If an unsupported configuration stops working, we do not classify this as a bug.
|
|
193
|
+
To request support for a configuration that is not listed, file an issue.
|
|
194
|
+
The product team will evaluate your request.
|
|
195
|
+
In the issue, specify the current status of the configuration:
|
|
196
|
+
|
|
197
|
+
- The configuration works but needs official support.
|
|
198
|
+
- The configuration does not work and requires changes.
|
|
193
199
|
|
|
194
200
|
### Supported Runtimes
|
|
195
201
|
|
|
196
|
-
-
|
|
197
|
-
-
|
|
198
|
-
-
|
|
202
|
+
- Fluid Framework supports Node.js versions 22 and 24 while they receive [upstream support](https://nodejs.org/en/about/previous-releases).
|
|
203
|
+
- Fluid Framework will stop support for version 22 [when upstream support ends on 2027-04-30](https://github.com/nodejs/release#release-schedule).
|
|
204
|
+
- Fluid Framework does not support Node.js with the `--no-experimental-fetch` flag.
|
|
205
|
+
- Fluid Framework supports modern browsers that support the ES2022 standard library.
|
|
199
206
|
|
|
200
207
|
### Supported Tools
|
|
201
208
|
|
|
202
|
-
- TypeScript
|
|
203
|
-
-
|
|
204
|
-
-
|
|
205
|
-
- [
|
|
206
|
-
-
|
|
207
|
-
|
|
209
|
+
- [TypeScript 6.0](https://typescriptdocs.com/release-notes/TypeScript%206.0):
|
|
210
|
+
- Fluid Framework supports all [`strict`](https://www.typescriptlang.org/tsconfig) options.
|
|
211
|
+
- Set the build targets (`lib`, `target`) to `ES2022` or later.
|
|
212
|
+
- Enable [`strictNullChecks`](https://www.typescriptlang.org/tsconfig).
|
|
213
|
+
- 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).
|
|
214
|
+
- Fluid Framework does not fully support `exactOptionalPropertyTypes`.
|
|
215
|
+
If you enable this option, do not use `in`, `Reflect.has`, `Object.hasOwn`, or `Object.prototype.hasOwnProperty` to narrow members of Fluid Framework types.
|
|
216
|
+
These methods can incorrectly exclude `undefined` from the possible values.
|
|
208
217
|
- [webpack](https://webpack.js.org/) 5
|
|
209
|
-
- We
|
|
210
|
-
Other bundlers
|
|
218
|
+
- We do not require a specific bundler.
|
|
219
|
+
Other bundlers that handle ES Modules can work, but we actively test only webpack.
|
|
211
220
|
|
|
212
221
|
### Module Resolution
|
|
213
222
|
|
|
214
|
-
[`Node16`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution)
|
|
215
|
-
|
|
223
|
+
In TypeScript `compilerOptions`, use [`Node16`, `Node20`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution) module resolution.
|
|
224
|
+
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).
|
|
225
|
+
|
|
226
|
+
Do not use `Node10` module resolution.
|
|
216
227
|
|
|
217
228
|
### Module Formats
|
|
218
229
|
|
|
219
230
|
- ES Modules:
|
|
220
|
-
ES Modules
|
|
221
|
-
-
|
|
222
|
-
|
|
223
|
-
This is done to accommodate some workflows without good ES Module support.
|
|
224
|
-
If you have a workflow you would like included in this list, file an issue.
|
|
225
|
-
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.
|
|
226
|
-
|
|
227
|
-
- 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))
|
|
231
|
+
Use ES Modules to consume Fluid Framework client packages, including in Node.js.
|
|
232
|
+
- CommonJS:
|
|
233
|
+
Fluid Framework does not officially support CommonJS in version 3.0 or later.
|
|
228
234
|
|
|
229
235
|
## Contribution Guidelines
|
|
230
236
|
|
|
231
|
-
|
|
237
|
+
You can [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid Framework in these ways:
|
|
232
238
|
|
|
233
|
-
-
|
|
234
|
-
- [Submit
|
|
235
|
-
- Review
|
|
239
|
+
- Answer questions in [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
|
|
240
|
+
- [Submit bug reports](https://github.com/microsoft/FluidFramework/issues) and help verify fixes.
|
|
241
|
+
- Review [source code changes](https://github.com/microsoft/FluidFramework/pulls).
|
|
236
242
|
- [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
|
|
237
243
|
|
|
238
|
-
|
|
244
|
+
For detailed instructions, read the [repo documentation](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Home.md).
|
|
239
245
|
|
|
240
|
-
This project
|
|
241
|
-
For more information
|
|
246
|
+
This project follows the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
247
|
+
For more information, read the [Code of Conduct frequently asked questions](https://opensource.microsoft.com/codeofconduct/faq/).
|
|
248
|
+
For questions or comments, contact [opencode@microsoft.com](mailto:opencode@microsoft.com).
|
|
242
249
|
|
|
243
250
|
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
244
251
|
Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
|
|
@@ -246,13 +253,9 @@ Use of Microsoft trademarks or logos in modified versions of this project must n
|
|
|
246
253
|
|
|
247
254
|
## Help
|
|
248
255
|
|
|
249
|
-
|
|
250
|
-
Check out [fluidframework.com](https://fluidframework.com/docs/).
|
|
251
|
-
|
|
252
|
-
Still not finding what you're looking for?
|
|
253
|
-
Please [file an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
|
|
256
|
+
Read the [Fluid Framework documentation](https://fluidframework.com/docs/) for information about Fluid Framework concepts and APIs.
|
|
254
257
|
|
|
255
|
-
|
|
258
|
+
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).
|
|
256
259
|
|
|
257
260
|
## Trademark
|
|
258
261
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "
|
|
3
|
+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-model.esm.json"
|
|
4
4
|
}
|
package/dist/counter.js
CHANGED
|
@@ -17,16 +17,16 @@ const snapshotFileName = "header";
|
|
|
17
17
|
class SharedCounter extends internal_4.SharedObject {
|
|
18
18
|
constructor(id, runtime, attributes) {
|
|
19
19
|
super(id, runtime, attributes, "fluid_counter_");
|
|
20
|
-
this._value = 0;
|
|
21
|
-
/**
|
|
22
|
-
* Tracks pending local ops that have not been ack'd yet.
|
|
23
|
-
*/
|
|
24
|
-
this.pendingOps = [];
|
|
25
|
-
/**
|
|
26
|
-
* The next message id to be used when submitting an op.
|
|
27
|
-
*/
|
|
28
|
-
this.nextPendingMessageId = 0;
|
|
29
20
|
}
|
|
21
|
+
_value = 0;
|
|
22
|
+
/**
|
|
23
|
+
* Tracks pending local ops that have not been ack'd yet.
|
|
24
|
+
*/
|
|
25
|
+
pendingOps = [];
|
|
26
|
+
/**
|
|
27
|
+
* The next message id to be used when submitting an op.
|
|
28
|
+
*/
|
|
29
|
+
nextPendingMessageId = 0;
|
|
30
30
|
/**
|
|
31
31
|
* {@inheritDoc ISharedCounter.value}
|
|
32
32
|
*/
|
package/dist/counter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAM7D,0EAA0E;AAC1E,oEAAqE;AAQrE,0EAGqD;AAgCrD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAa,aACZ,SAAQ,uBAAkC;IAG1C,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAG1C,WAAM,GAAW,CAAC,CAAC;QAE3B;;WAEG;QACc,eAAU,GAAwB,EAAE,CAAC;QAEtD;;WAEG;QACK,yBAAoB,GAAW,CAAC,CAAC;IAZzC,CAAC;IAcD;;OAEG;IACH,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,eAAuB;QACvC,uGAAuG;QACvG,wGAAwG;QACxG,IAAI,eAAe,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,EAAE,GAAwB;YAC/B,IAAI,EAAE,WAAW;YACjB,eAAe;SACf,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAE9C,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACpC,2DAA2D;QAC3D,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACvB,IAAI,C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,EACL,OAAO,eAAe,KAAK,QAAQ,EACnC,KAAK,CAAC,wCAAwC,CAC9C,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;QACxC,IAAA,iBAAM;QACL,sGAAsG;QACtG,SAAS,KAAK,SAAS;YACtB,SAAS,CAAC,SAAS,KAAK,eAAe;YACvC,SAAS,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI;YAC/B,SAAS,CAAC,eAAe,KAAK,OAAO,CAAC,eAAe,EACtD,KAAK,CAAC,6CAA6C,CACnD,CAAC;QACF,gFAAgF;QAChF,0EAA0E;QAC1E,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,CAAC;CACD;AA3KD,sCA2KC;AAED,SAAS,mBAAmB,CAAC,EAAW;IACvC,IAAA,iBAAM,EACL,OAAO,EAAE,KAAK,QAAQ;QACrB,EAAE,KAAK,IAAI;QACX,MAAM,IAAI,EAAE;QACZ,iBAAiB,IAAI,EAAE;QACvB,EAAE,CAAC,IAAI,KAAK,WAAW;QACvB,OAAO,EAAE,CAAC,eAAe,KAAK,QAAQ,EACvC,KAAK,CAAC,iCAAiC,CACvC,CAAC;AACH,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 {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedCounter, ISharedCounterEvents } from \"./interfaces.js\";\n\n/**\n * Describes the operation (op) format for incrementing the {@link SharedCounter}.\n */\nexport interface IIncrementOperation {\n\ttype: \"increment\";\n\tincrementAmount: number;\n}\n\n/**\n * Represents a pending op that has been submitted but not yet ack'd.\n * Includes the messageId that was used when submitting the op.\n */\ninterface IPendingOperation {\n\ttype: \"increment\";\n\tincrementAmount: number;\n\tmessageId: number;\n}\n\n/**\n * @remarks Used in snapshotting.\n */\ninterface ICounterSnapshotFormat {\n\t/**\n\t * The value of the counter.\n\t */\n\tvalue: number;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedCounter}\n * @legacy @beta\n */\nexport class SharedCounter\n\textends SharedObject<ISharedCounterEvents>\n\timplements ISharedCounter\n{\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_counter_\");\n\t}\n\n\tprivate _value: number = 0;\n\n\t/**\n\t * Tracks pending local ops that have not been ack'd yet.\n\t */\n\tprivate readonly pendingOps: IPendingOperation[] = [];\n\n\t/**\n\t * The next message id to be used when submitting an op.\n\t */\n\tprivate nextPendingMessageId: number = 0;\n\n\t/**\n\t * {@inheritDoc ISharedCounter.value}\n\t */\n\tpublic get value(): number {\n\t\treturn this._value;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCounter.increment}\n\t */\n\tpublic increment(incrementAmount: number): void {\n\t\t// Incrementing by floating point numbers will be eventually inconsistent, since the order in which the\n\t\t// increments are applied affects the result. A more-robust solution would be required to support this.\n\t\tif (incrementAmount % 1 !== 0) {\n\t\t\tthrow new Error(\"Must increment by a whole number\");\n\t\t}\n\n\t\tconst op: IIncrementOperation = {\n\t\t\ttype: \"increment\",\n\t\t\tincrementAmount,\n\t\t};\n\t\tconst messageId = this.nextPendingMessageId++;\n\n\t\tthis.incrementCore(incrementAmount);\n\t\t// We don't need to send the op if we are not attached yet.\n\t\tif (this.isAttached()) {\n\t\t\tthis.pendingOps.push({ ...op, messageId });\n\t\t\tthis.submitLocalMessage(op, messageId);\n\t\t}\n\t}\n\n\tprivate incrementCore(incrementAmount: number): void {\n\t\tthis._value += incrementAmount;\n\t\tthis.emit(\"incremented\", incrementAmount, this._value);\n\t}\n\n\t/**\n\t * Create a summary for the counter.\n\t *\n\t * @returns The summary of the current state of the counter.\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Get a serializable form of data\n\t\tconst content: ICounterSnapshotFormat = {\n\t\t\tvalue: this.value,\n\t\t};\n\n\t\t// And then construct the summary for it\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<ICounterSnapshotFormat>(storage, snapshotFileName);\n\n\t\tthis._value = content.value;\n\t}\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IIncrementOperation;\n\n\t\t\t// If the message is local we have already optimistically processed\n\t\t\t// and we should now remove it from this.pendingOps.\n\t\t\t// If the message is from a remote client, we should process it.\n\t\t\tif (local) {\n\t\t\t\tconst pendingOp = this.pendingOps.shift();\n\t\t\t\tconst messageId = messageContent.localOpMetadata;\n\t\t\t\tassert(typeof messageId === \"number\", 0xc8e /* localOpMetadata should be a number */);\n\t\t\t\tassert(\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\t\t\t\tpendingOp !== undefined &&\n\t\t\t\t\t\tpendingOp.messageId === messageId &&\n\t\t\t\t\t\tpendingOp.type === op.type &&\n\t\t\t\t\t\tpendingOp.incrementAmount === op.incrementAmount,\n\t\t\t\t\t0xc8f /* local op mismatch */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tswitch (op.type) {\n\t\t\t\t\tcase \"increment\": {\n\t\t\t\t\t\tthis.incrementCore(op.incrementAmount);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(op: unknown): void {\n\t\tconst counterOp = op as IIncrementOperation;\n\n\t\t// TODO: Clean up error code linter violations repo-wide.\n\n\t\tassert(counterOp.type === \"increment\", 0x3ec /* Op type is not increment */);\n\n\t\tthis.increment(counterOp.incrementAmount);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassertIsIncrementOp(content);\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc90 /* localOpMetadata should be a number */,\n\t\t);\n\t\tconst pendingOp = this.pendingOps.pop();\n\t\tassert(\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\t\tpendingOp !== undefined &&\n\t\t\t\tpendingOp.messageId === localOpMetadata &&\n\t\t\t\tpendingOp.type === content.type &&\n\t\t\t\tpendingOp.incrementAmount === content.incrementAmount,\n\t\t\t0xc91 /* op to rollback mismatch with pending op */,\n\t\t);\n\t\t// To rollback the optimistic increment we can increment by the opposite amount.\n\t\t// This will also emit another incremented event with the opposite amount.\n\t\tthis.incrementCore(-content.incrementAmount);\n\t}\n}\n\nfunction assertIsIncrementOp(op: unknown): asserts op is IIncrementOperation {\n\tassert(\n\t\ttypeof op === \"object\" &&\n\t\t\top !== null &&\n\t\t\t\"type\" in op &&\n\t\t\t\"incrementAmount\" in op &&\n\t\t\top.type === \"increment\" &&\n\t\t\ttypeof op.incrementAmount === \"number\",\n\t\t0xc92 /* invalid increment op format */,\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAM7D,0EAA0E;AAC1E,oEAAqE;AAQrE,0EAGqD;AAgCrD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAa,aACZ,SAAQ,uBAAkC;IAG1C,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAClD,CAAC;IAEO,MAAM,GAAW,CAAC,CAAC;IAE3B;;OAEG;IACc,UAAU,GAAwB,EAAE,CAAC;IAEtD;;OAEG;IACK,oBAAoB,GAAW,CAAC,CAAC;IAEzC;;OAEG;IACH,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,eAAuB;QACvC,uGAAuG;QACvG,wGAAwG;QACxG,IAAI,eAAe,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAC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AM,EAAC,SAAS,CAAC,IAAI,KAAK,WAAW,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAE7E,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACO,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QAC5D,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC7B,IAAA,iBAAM,EACL,OAAO,eAAe,KAAK,QAAQ,EACnC,KAAK,CAAC,wCAAwC,CAC9C,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;QACxC,IAAA,iBAAM;QACL,sGAAsG;QACtG,SAAS,KAAK,SAAS;YACtB,SAAS,CAAC,SAAS,KAAK,eAAe;YACvC,SAAS,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI;YAC/B,SAAS,CAAC,eAAe,KAAK,OAAO,CAAC,eAAe,EACtD,KAAK,CAAC,6CAA6C,CACnD,CAAC;QACF,gFAAgF;QAChF,0EAA0E;QAC1E,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,CAAC;CACD;AA3KD,sCA2KC;AAED,SAAS,mBAAmB,CAAC,EAAW;IACvC,IAAA,iBAAM,EACL,OAAO,EAAE,KAAK,QAAQ;QACrB,EAAE,KAAK,IAAI;QACX,MAAM,IAAI,EAAE;QACZ,iBAAiB,IAAI,EAAE;QACvB,EAAE,CAAC,IAAI,KAAK,WAAW;QACvB,OAAO,EAAE,CAAC,eAAe,KAAK,QAAQ,EACvC,KAAK,CAAC,iCAAiC,CACvC,CAAC;AACH,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 {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedCounter, ISharedCounterEvents } from \"./interfaces.js\";\n\n/**\n * Describes the operation (op) format for incrementing the {@link SharedCounter}.\n */\nexport interface IIncrementOperation {\n\ttype: \"increment\";\n\tincrementAmount: number;\n}\n\n/**\n * Represents a pending op that has been submitted but not yet ack'd.\n * Includes the messageId that was used when submitting the op.\n */\ninterface IPendingOperation {\n\ttype: \"increment\";\n\tincrementAmount: number;\n\tmessageId: number;\n}\n\n/**\n * @remarks Used in snapshotting.\n */\ninterface ICounterSnapshotFormat {\n\t/**\n\t * The value of the counter.\n\t */\n\tvalue: number;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedCounter}\n * @legacy @beta\n */\nexport class SharedCounter\n\textends SharedObject<ISharedCounterEvents>\n\timplements ISharedCounter\n{\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_counter_\");\n\t}\n\n\tprivate _value: number = 0;\n\n\t/**\n\t * Tracks pending local ops that have not been ack'd yet.\n\t */\n\tprivate readonly pendingOps: IPendingOperation[] = [];\n\n\t/**\n\t * The next message id to be used when submitting an op.\n\t */\n\tprivate nextPendingMessageId: number = 0;\n\n\t/**\n\t * {@inheritDoc ISharedCounter.value}\n\t */\n\tpublic get value(): number {\n\t\treturn this._value;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCounter.increment}\n\t */\n\tpublic increment(incrementAmount: number): void {\n\t\t// Incrementing by floating point numbers will be eventually inconsistent, since the order in which the\n\t\t// increments are applied affects the result. A more-robust solution would be required to support this.\n\t\tif (incrementAmount % 1 !== 0) {\n\t\t\tthrow new Error(\"Must increment by a whole number\");\n\t\t}\n\n\t\tconst op: IIncrementOperation = {\n\t\t\ttype: \"increment\",\n\t\t\tincrementAmount,\n\t\t};\n\t\tconst messageId = this.nextPendingMessageId++;\n\n\t\tthis.incrementCore(incrementAmount);\n\t\t// We don't need to send the op if we are not attached yet.\n\t\tif (this.isAttached()) {\n\t\t\tthis.pendingOps.push({ ...op, messageId });\n\t\t\tthis.submitLocalMessage(op, messageId);\n\t\t}\n\t}\n\n\tprivate incrementCore(incrementAmount: number): void {\n\t\tthis._value += incrementAmount;\n\t\tthis.emit(\"incremented\", incrementAmount, this._value);\n\t}\n\n\t/**\n\t * Create a summary for the counter.\n\t *\n\t * @returns The summary of the current state of the counter.\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Get a serializable form of data\n\t\tconst content: ICounterSnapshotFormat = {\n\t\t\tvalue: this.value,\n\t\t};\n\n\t\t// And then construct the summary for it\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<ICounterSnapshotFormat>(storage, snapshotFileName);\n\n\t\tthis._value = content.value;\n\t}\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IIncrementOperation;\n\n\t\t\t// If the message is local we have already optimistically processed\n\t\t\t// and we should now remove it from this.pendingOps.\n\t\t\t// If the message is from a remote client, we should process it.\n\t\t\tif (local) {\n\t\t\t\tconst pendingOp = this.pendingOps.shift();\n\t\t\t\tconst messageId = messageContent.localOpMetadata;\n\t\t\t\tassert(typeof messageId === \"number\", 0xc8e /* localOpMetadata should be a number */);\n\t\t\t\tassert(\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\t\t\t\tpendingOp !== undefined &&\n\t\t\t\t\t\tpendingOp.messageId === messageId &&\n\t\t\t\t\t\tpendingOp.type === op.type &&\n\t\t\t\t\t\tpendingOp.incrementAmount === op.incrementAmount,\n\t\t\t\t\t0xc8f /* local op mismatch */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tswitch (op.type) {\n\t\t\t\t\tcase \"increment\": {\n\t\t\t\t\t\tthis.incrementCore(op.incrementAmount);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(op: unknown): void {\n\t\tconst counterOp = op as IIncrementOperation;\n\n\t\t// TODO: Clean up error code linter violations repo-wide.\n\n\t\tassert(counterOp.type === \"increment\", 0x3ec /* Op type is not increment */);\n\n\t\tthis.increment(counterOp.incrementAmount);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassertIsIncrementOp(content);\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc90 /* localOpMetadata should be a number */,\n\t\t);\n\t\tconst pendingOp = this.pendingOps.pop();\n\t\tassert(\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\t\tpendingOp !== undefined &&\n\t\t\t\tpendingOp.messageId === localOpMetadata &&\n\t\t\t\tpendingOp.type === content.type &&\n\t\t\t\tpendingOp.incrementAmount === content.incrementAmount,\n\t\t\t0xc91 /* op to rollback mismatch with pending op */,\n\t\t);\n\t\t// To rollback the optimistic increment we can increment by the opposite amount.\n\t\t// This will also emit another incremented event with the opposite amount.\n\t\tthis.incrementCore(-content.incrementAmount);\n\t}\n}\n\nfunction assertIsIncrementOp(op: unknown): asserts op is IIncrementOperation {\n\tassert(\n\t\ttypeof op === \"object\" &&\n\t\t\top !== null &&\n\t\t\t\"type\" in op &&\n\t\t\t\"incrementAmount\" in op &&\n\t\t\top.type === \"increment\" &&\n\t\t\ttypeof op.incrementAmount === \"number\",\n\t\t0xc92 /* invalid increment op format */,\n\t);\n}\n"]}
|
package/dist/counterFactory.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare class CounterFactory implements IChannelFactory<ISharedCounter> {
|
|
|
39
39
|
* Entrypoint for {@link ISharedCounter} creation.
|
|
40
40
|
* @legacy @beta
|
|
41
41
|
*/
|
|
42
|
-
export declare const SharedCounter: import("@fluidframework/shared-object-base
|
|
42
|
+
export declare const SharedCounter: import("@fluidframework/shared-object-base", { with: { "resolution-mode": "import" } }).ISharedObjectKind<ISharedCounter> & import("@fluidframework/shared-object-base", { with: { "resolution-mode": "import" } }).SharedObjectKind<ISharedCounter>;
|
|
43
43
|
/**
|
|
44
44
|
* Alias for {@link ISharedCounter} for compatibility.
|
|
45
45
|
* @legacy @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterFactory.d.ts","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AAIxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD;;;;GAIG;AACH,qBAAa,cAAe,YAAW,eAAe,CAAC,cAAc,CAAC;IACrE;;OAEG;IAIH,gBAAuB,IAAI,+CAA+C;IAE1E;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,cAAc,CAAC;IAM1B;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,cAAc;CAK3E;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"counterFactory.d.ts","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AAIxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD;;;;GAIG;AACH,qBAAa,cAAe,YAAW,eAAe,CAAC,cAAc,CAAC;IACrE;;OAEG;IAIH,gBAAuB,IAAI,+CAA+C;IAE1E;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,cAAc,CAAC;IAM1B;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,cAAc;CAK3E;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,sPAAyD,CAAC;AAEpF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC"}
|
package/dist/counterFactory.js
CHANGED
|
@@ -14,6 +14,21 @@ const packageVersion_js_1 = require("./packageVersion.js");
|
|
|
14
14
|
* @sealed
|
|
15
15
|
*/
|
|
16
16
|
class CounterFactory {
|
|
17
|
+
/**
|
|
18
|
+
* Static value for {@link CounterFactory."type"}.
|
|
19
|
+
*/
|
|
20
|
+
// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.
|
|
21
|
+
// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.
|
|
22
|
+
// public static readonly Type = "counter";
|
|
23
|
+
static Type = "https://graph.microsoft.com/types/counter";
|
|
24
|
+
/**
|
|
25
|
+
* Static value for {@link CounterFactory.attributes}.
|
|
26
|
+
*/
|
|
27
|
+
static Attributes = {
|
|
28
|
+
type: CounterFactory.Type,
|
|
29
|
+
snapshotFormatVersion: "0.1",
|
|
30
|
+
packageVersion: packageVersion_js_1.pkgVersion,
|
|
31
|
+
};
|
|
17
32
|
/**
|
|
18
33
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
19
34
|
*/
|
|
@@ -44,21 +59,6 @@ class CounterFactory {
|
|
|
44
59
|
}
|
|
45
60
|
}
|
|
46
61
|
exports.CounterFactory = CounterFactory;
|
|
47
|
-
/**
|
|
48
|
-
* Static value for {@link CounterFactory."type"}.
|
|
49
|
-
*/
|
|
50
|
-
// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.
|
|
51
|
-
// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.
|
|
52
|
-
// public static readonly Type = "counter";
|
|
53
|
-
CounterFactory.Type = "https://graph.microsoft.com/types/counter";
|
|
54
|
-
/**
|
|
55
|
-
* Static value for {@link CounterFactory.attributes}.
|
|
56
|
-
*/
|
|
57
|
-
CounterFactory.Attributes = {
|
|
58
|
-
type: CounterFactory.Type,
|
|
59
|
-
snapshotFormatVersion: "0.1",
|
|
60
|
-
packageVersion: packageVersion_js_1.pkgVersion,
|
|
61
|
-
};
|
|
62
62
|
/**
|
|
63
63
|
* Entrypoint for {@link ISharedCounter} creation.
|
|
64
64
|
* @legacy @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,0EAAqF;AAErF,6CAAmE;AAEnE,2DAAiD;AAEjD;;;;GAIG;AACH,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,0EAAqF;AAErF,6CAAmE;AAEnE,2DAAiD;AAEjD;;;;GAIG;AACH,MAAa,cAAc;IAC1B;;OAEG;IACH,uGAAuG;IACvG,qFAAqF;IACrF,2CAA2C;IACpC,MAAM,CAAU,IAAI,GAAG,2CAA2C,CAAC;IAE1E;;OAEG;IACI,MAAM,CAAU,UAAU,GAAuB;QACvD,IAAI,EAAE,cAAc,CAAC,IAAI;QACzB,qBAAqB,EAAE,KAAK;QAC5B,cAAc,EAAE,8BAAU;KAC1B,CAAC;IAEF;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,cAAc,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,cAAc,CAAC,UAAU,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,OAAO,GAAG,IAAI,0BAAkB,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAChE,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,OAAO,GAAG,IAAI,0BAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACtE,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IAChB,CAAC;;AArDF,wCAsDC;AAED;;;GAGG;AACU,QAAA,aAAa,GAAG,IAAA,iCAAsB,EAAiB,cAAc,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { createSharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { SharedCounter as SharedCounterClass } from \"./counter.js\";\nimport type { ISharedCounter } from \"./interfaces.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.\n *\n * @sealed\n */\nexport class CounterFactory implements IChannelFactory<ISharedCounter> {\n\t/**\n\t * Static value for {@link CounterFactory.\"type\"}.\n\t */\n\t// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.\n\t// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.\n\t// public static readonly Type = \"counter\";\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/counter\";\n\n\t/**\n\t * Static value for {@link CounterFactory.attributes}.\n\t */\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: CounterFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn CounterFactory.Type;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn CounterFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedCounter> {\n\t\tconst counter = new SharedCounterClass(id, runtime, attributes);\n\t\tawait counter.load(services);\n\t\treturn counter;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic create(document: IFluidDataStoreRuntime, id: string): ISharedCounter {\n\t\tconst counter = new SharedCounterClass(id, document, this.attributes);\n\t\tcounter.initializeLocal();\n\t\treturn counter;\n\t}\n}\n\n/**\n * Entrypoint for {@link ISharedCounter} creation.\n * @legacy @beta\n */\nexport const SharedCounter = createSharedObjectKind<ISharedCounter>(CounterFactory);\n\n/**\n * Alias for {@link ISharedCounter} for compatibility.\n * @legacy @beta\n */\nexport type SharedCounter = ISharedCounter;\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,4BAA4B,CAAC;AACjD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,4BAA4B,CAAC;AACjD,eAAO,MAAM,UAAU,UAAU,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/counter";
|
|
11
|
-
exports.pkgVersion = "
|
|
11
|
+
exports.pkgVersion = "3.0.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,yBAAyB,CAAC;AACpC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,yBAAyB,CAAC;AACpC,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/counter\";\nexport const pkgVersion = \"3.0.0\";\n"]}
|
package/lib/counter.js
CHANGED
|
@@ -14,16 +14,16 @@ const snapshotFileName = "header";
|
|
|
14
14
|
export class SharedCounter extends SharedObject {
|
|
15
15
|
constructor(id, runtime, attributes) {
|
|
16
16
|
super(id, runtime, attributes, "fluid_counter_");
|
|
17
|
-
this._value = 0;
|
|
18
|
-
/**
|
|
19
|
-
* Tracks pending local ops that have not been ack'd yet.
|
|
20
|
-
*/
|
|
21
|
-
this.pendingOps = [];
|
|
22
|
-
/**
|
|
23
|
-
* The next message id to be used when submitting an op.
|
|
24
|
-
*/
|
|
25
|
-
this.nextPendingMessageId = 0;
|
|
26
17
|
}
|
|
18
|
+
_value = 0;
|
|
19
|
+
/**
|
|
20
|
+
* Tracks pending local ops that have not been ack'd yet.
|
|
21
|
+
*/
|
|
22
|
+
pendingOps = [];
|
|
23
|
+
/**
|
|
24
|
+
* The next message id to be used when submitting an op.
|
|
25
|
+
*/
|
|
26
|
+
nextPendingMessageId = 0;
|
|
27
27
|
/**
|
|
28
28
|
* {@inheritDoc ISharedCounter.value}
|
|
29
29
|
*/
|
package/lib/counter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAQrE,OAAO,EACN,YAAY,EACZ,uBAAuB,GACvB,MAAM,6CAA6C,CAAC;AAgCrD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAM,OAAO,aACZ,SAAQ,YAAkC;IAG1C,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAG1C,WAAM,GAAW,CAAC,CAAC;QAE3B;;WAEG;QACc,eAAU,GAAwB,EAAE,CAAC;QAEtD;;WAEG;QACK,yBAAoB,GAAW,CAAC,CAAC;IAZzC,CAAC;IAcD;;OAEG;IACH,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;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C;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,EAAW;QACnC,MAAM,SAAS,GAAG,EAAyB,CAAC;QAE5C,yDAAyD;QAEzD,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,WAAW,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAE7E,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACO,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QAC5D,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC7B,MAAM,CACL,OAAO,eAAe,KAAK,QAAQ,EACnC,KAAK,CAAC,wCAAwC,CAC9C,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;QACxC,MAAM;QACL,sGAAsG;QACtG,SAAS,KAAK,SAAS;YACtB,SAAS,CAAC,SAAS,KAAK,eAAe;YACvC,SAAS,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI;YAC/B,SAAS,CAAC,eAAe,KAAK,OAAO,CAAC,eAAe,EACtD,KAAK,CAAC,6CAA6C,CACnD,CAAC;QACF,gFAAgF;QAChF,0EAA0E;QAC1E,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,CAAC;CACD;AAED,SAAS,mBAAmB,CAAC,EAAW;IACvC,MAAM,CACL,OAAO,EAAE,KAAK,QAAQ;QACrB,EAAE,KAAK,IAAI;QACX,MAAM,IAAI,EAAE;QACZ,iBAAiB,IAAI,EAAE;QACvB,EAAE,CAAC,IAAI,KAAK,WAAW;QACvB,OAAO,EAAE,CAAC,eAAe,KAAK,QAAQ,EACvC,KAAK,CAAC,iCAAiC,CACvC,CAAC;AACH,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 {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedCounter, ISharedCounterEvents } from \"./interfaces.js\";\n\n/**\n * Describes the operation (op) format for incrementing the {@link SharedCounter}.\n */\nexport interface IIncrementOperation {\n\ttype: \"increment\";\n\tincrementAmount: number;\n}\n\n/**\n * Represents a pending op that has been submitted but not yet ack'd.\n * Includes the messageId that was used when submitting the op.\n */\ninterface IPendingOperation {\n\ttype: \"increment\";\n\tincrementAmount: number;\n\tmessageId: number;\n}\n\n/**\n * @remarks Used in snapshotting.\n */\ninterface ICounterSnapshotFormat {\n\t/**\n\t * The value of the counter.\n\t */\n\tvalue: number;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedCounter}\n * @legacy @beta\n */\nexport class SharedCounter\n\textends SharedObject<ISharedCounterEvents>\n\timplements ISharedCounter\n{\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_counter_\");\n\t}\n\n\tprivate _value: number = 0;\n\n\t/**\n\t * Tracks pending local ops that have not been ack'd yet.\n\t */\n\tprivate readonly pendingOps: IPendingOperation[] = [];\n\n\t/**\n\t * The next message id to be used when submitting an op.\n\t */\n\tprivate nextPendingMessageId: number = 0;\n\n\t/**\n\t * {@inheritDoc ISharedCounter.value}\n\t */\n\tpublic get value(): number {\n\t\treturn this._value;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCounter.increment}\n\t */\n\tpublic increment(incrementAmount: number): void {\n\t\t// Incrementing by floating point numbers will be eventually inconsistent, since the order in which the\n\t\t// increments are applied affects the result. A more-robust solution would be required to support this.\n\t\tif (incrementAmount % 1 !== 0) {\n\t\t\tthrow new Error(\"Must increment by a whole number\");\n\t\t}\n\n\t\tconst op: IIncrementOperation = {\n\t\t\ttype: \"increment\",\n\t\t\tincrementAmount,\n\t\t};\n\t\tconst messageId = this.nextPendingMessageId++;\n\n\t\tthis.incrementCore(incrementAmount);\n\t\t// We don't need to send the op if we are not attached yet.\n\t\tif (this.isAttached()) {\n\t\t\tthis.pendingOps.push({ ...op, messageId });\n\t\t\tthis.submitLocalMessage(op, messageId);\n\t\t}\n\t}\n\n\tprivate incrementCore(incrementAmount: number): void {\n\t\tthis._value += incrementAmount;\n\t\tthis.emit(\"incremented\", incrementAmount, this._value);\n\t}\n\n\t/**\n\t * Create a summary for the counter.\n\t *\n\t * @returns The summary of the current state of the counter.\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Get a serializable form of data\n\t\tconst content: ICounterSnapshotFormat = {\n\t\t\tvalue: this.value,\n\t\t};\n\n\t\t// And then construct the summary for it\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<ICounterSnapshotFormat>(storage, snapshotFileName);\n\n\t\tthis._value = content.value;\n\t}\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IIncrementOperation;\n\n\t\t\t// If the message is local we have already optimistically processed\n\t\t\t// and we should now remove it from this.pendingOps.\n\t\t\t// If the message is from a remote client, we should process it.\n\t\t\tif (local) {\n\t\t\t\tconst pendingOp = this.pendingOps.shift();\n\t\t\t\tconst messageId = messageContent.localOpMetadata;\n\t\t\t\tassert(typeof messageId === \"number\", 0xc8e /* localOpMetadata should be a number */);\n\t\t\t\tassert(\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\t\t\t\tpendingOp !== undefined &&\n\t\t\t\t\t\tpendingOp.messageId === messageId &&\n\t\t\t\t\t\tpendingOp.type === op.type &&\n\t\t\t\t\t\tpendingOp.incrementAmount === op.incrementAmount,\n\t\t\t\t\t0xc8f /* local op mismatch */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tswitch (op.type) {\n\t\t\t\t\tcase \"increment\": {\n\t\t\t\t\t\tthis.incrementCore(op.incrementAmount);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(op: unknown): void {\n\t\tconst counterOp = op as IIncrementOperation;\n\n\t\t// TODO: Clean up error code linter violations repo-wide.\n\n\t\tassert(counterOp.type === \"increment\", 0x3ec /* Op type is not increment */);\n\n\t\tthis.increment(counterOp.incrementAmount);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassertIsIncrementOp(content);\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc90 /* localOpMetadata should be a number */,\n\t\t);\n\t\tconst pendingOp = this.pendingOps.pop();\n\t\tassert(\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\t\tpendingOp !== undefined &&\n\t\t\t\tpendingOp.messageId === localOpMetadata &&\n\t\t\t\tpendingOp.type === content.type &&\n\t\t\t\tpendingOp.incrementAmount === content.incrementAmount,\n\t\t\t0xc91 /* op to rollback mismatch with pending op */,\n\t\t);\n\t\t// To rollback the optimistic increment we can increment by the opposite amount.\n\t\t// This will also emit another incremented event with the opposite amount.\n\t\tthis.incrementCore(-content.incrementAmount);\n\t}\n}\n\nfunction assertIsIncrementOp(op: unknown): asserts op is IIncrementOperation {\n\tassert(\n\t\ttypeof op === \"object\" &&\n\t\t\top !== null &&\n\t\t\t\"type\" in op &&\n\t\t\t\"incrementAmount\" in op &&\n\t\t\top.type === \"increment\" &&\n\t\t\ttypeof op.incrementAmount === \"number\",\n\t\t0xc92 /* invalid increment op format */,\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAQrE,OAAO,EACN,YAAY,EACZ,uBAAuB,GACvB,MAAM,6CAA6C,CAAC;AAgCrD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAM,OAAO,aACZ,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C,EAAW;IACvC,MAAM,CACL,OAAO,EAAE,KAAK,QAAQ;QACrB,EAAE,KAAK,IAAI;QACX,MAAM,IAAI,EAAE;QACZ,iBAAiB,IAAI,EAAE;QACvB,EAAE,CAAC,IAAI,KAAK,WAAW;QACvB,OAAO,EAAE,CAAC,eAAe,KAAK,QAAQ,EACvC,KAAK,CAAC,iCAAiC,CACvC,CAAC;AACH,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 {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedCounter, ISharedCounterEvents } from \"./interfaces.js\";\n\n/**\n * Describes the operation (op) format for incrementing the {@link SharedCounter}.\n */\nexport interface IIncrementOperation {\n\ttype: \"increment\";\n\tincrementAmount: number;\n}\n\n/**\n * Represents a pending op that has been submitted but not yet ack'd.\n * Includes the messageId that was used when submitting the op.\n */\ninterface IPendingOperation {\n\ttype: \"increment\";\n\tincrementAmount: number;\n\tmessageId: number;\n}\n\n/**\n * @remarks Used in snapshotting.\n */\ninterface ICounterSnapshotFormat {\n\t/**\n\t * The value of the counter.\n\t */\n\tvalue: number;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedCounter}\n * @legacy @beta\n */\nexport class SharedCounter\n\textends SharedObject<ISharedCounterEvents>\n\timplements ISharedCounter\n{\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_counter_\");\n\t}\n\n\tprivate _value: number = 0;\n\n\t/**\n\t * Tracks pending local ops that have not been ack'd yet.\n\t */\n\tprivate readonly pendingOps: IPendingOperation[] = [];\n\n\t/**\n\t * The next message id to be used when submitting an op.\n\t */\n\tprivate nextPendingMessageId: number = 0;\n\n\t/**\n\t * {@inheritDoc ISharedCounter.value}\n\t */\n\tpublic get value(): number {\n\t\treturn this._value;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCounter.increment}\n\t */\n\tpublic increment(incrementAmount: number): void {\n\t\t// Incrementing by floating point numbers will be eventually inconsistent, since the order in which the\n\t\t// increments are applied affects the result. A more-robust solution would be required to support this.\n\t\tif (incrementAmount % 1 !== 0) {\n\t\t\tthrow new Error(\"Must increment by a whole number\");\n\t\t}\n\n\t\tconst op: IIncrementOperation = {\n\t\t\ttype: \"increment\",\n\t\t\tincrementAmount,\n\t\t};\n\t\tconst messageId = this.nextPendingMessageId++;\n\n\t\tthis.incrementCore(incrementAmount);\n\t\t// We don't need to send the op if we are not attached yet.\n\t\tif (this.isAttached()) {\n\t\t\tthis.pendingOps.push({ ...op, messageId });\n\t\t\tthis.submitLocalMessage(op, messageId);\n\t\t}\n\t}\n\n\tprivate incrementCore(incrementAmount: number): void {\n\t\tthis._value += incrementAmount;\n\t\tthis.emit(\"incremented\", incrementAmount, this._value);\n\t}\n\n\t/**\n\t * Create a summary for the counter.\n\t *\n\t * @returns The summary of the current state of the counter.\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Get a serializable form of data\n\t\tconst content: ICounterSnapshotFormat = {\n\t\t\tvalue: this.value,\n\t\t};\n\n\t\t// And then construct the summary for it\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<ICounterSnapshotFormat>(storage, snapshotFileName);\n\n\t\tthis._value = content.value;\n\t}\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\tprotected onDisconnect(): void {}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IIncrementOperation;\n\n\t\t\t// If the message is local we have already optimistically processed\n\t\t\t// and we should now remove it from this.pendingOps.\n\t\t\t// If the message is from a remote client, we should process it.\n\t\t\tif (local) {\n\t\t\t\tconst pendingOp = this.pendingOps.shift();\n\t\t\t\tconst messageId = messageContent.localOpMetadata;\n\t\t\t\tassert(typeof messageId === \"number\", 0xc8e /* localOpMetadata should be a number */);\n\t\t\t\tassert(\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\t\t\t\tpendingOp !== undefined &&\n\t\t\t\t\t\tpendingOp.messageId === messageId &&\n\t\t\t\t\t\tpendingOp.type === op.type &&\n\t\t\t\t\t\tpendingOp.incrementAmount === op.incrementAmount,\n\t\t\t\t\t0xc8f /* local op mismatch */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tswitch (op.type) {\n\t\t\t\t\tcase \"increment\": {\n\t\t\t\t\t\tthis.incrementCore(op.incrementAmount);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(op: unknown): void {\n\t\tconst counterOp = op as IIncrementOperation;\n\n\t\t// TODO: Clean up error code linter violations repo-wide.\n\n\t\tassert(counterOp.type === \"increment\", 0x3ec /* Op type is not increment */);\n\n\t\tthis.increment(counterOp.incrementAmount);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassertIsIncrementOp(content);\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc90 /* localOpMetadata should be a number */,\n\t\t);\n\t\tconst pendingOp = this.pendingOps.pop();\n\t\tassert(\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- using ?. could change behavior\n\t\t\tpendingOp !== undefined &&\n\t\t\t\tpendingOp.messageId === localOpMetadata &&\n\t\t\t\tpendingOp.type === content.type &&\n\t\t\t\tpendingOp.incrementAmount === content.incrementAmount,\n\t\t\t0xc91 /* op to rollback mismatch with pending op */,\n\t\t);\n\t\t// To rollback the optimistic increment we can increment by the opposite amount.\n\t\t// This will also emit another incremented event with the opposite amount.\n\t\tthis.incrementCore(-content.incrementAmount);\n\t}\n}\n\nfunction assertIsIncrementOp(op: unknown): asserts op is IIncrementOperation {\n\tassert(\n\t\ttypeof op === \"object\" &&\n\t\t\top !== null &&\n\t\t\t\"type\" in op &&\n\t\t\t\"incrementAmount\" in op &&\n\t\t\top.type === \"increment\" &&\n\t\t\ttypeof op.incrementAmount === \"number\",\n\t\t0xc92 /* invalid increment op format */,\n\t);\n}\n"]}
|
package/lib/counterFactory.js
CHANGED
|
@@ -11,6 +11,21 @@ import { pkgVersion } from "./packageVersion.js";
|
|
|
11
11
|
* @sealed
|
|
12
12
|
*/
|
|
13
13
|
export class CounterFactory {
|
|
14
|
+
/**
|
|
15
|
+
* Static value for {@link CounterFactory."type"}.
|
|
16
|
+
*/
|
|
17
|
+
// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.
|
|
18
|
+
// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.
|
|
19
|
+
// public static readonly Type = "counter";
|
|
20
|
+
static Type = "https://graph.microsoft.com/types/counter";
|
|
21
|
+
/**
|
|
22
|
+
* Static value for {@link CounterFactory.attributes}.
|
|
23
|
+
*/
|
|
24
|
+
static Attributes = {
|
|
25
|
+
type: CounterFactory.Type,
|
|
26
|
+
snapshotFormatVersion: "0.1",
|
|
27
|
+
packageVersion: pkgVersion,
|
|
28
|
+
};
|
|
14
29
|
/**
|
|
15
30
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
16
31
|
*/
|
|
@@ -40,21 +55,6 @@ export class CounterFactory {
|
|
|
40
55
|
return counter;
|
|
41
56
|
}
|
|
42
57
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Static value for {@link CounterFactory."type"}.
|
|
45
|
-
*/
|
|
46
|
-
// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.
|
|
47
|
-
// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.
|
|
48
|
-
// public static readonly Type = "counter";
|
|
49
|
-
CounterFactory.Type = "https://graph.microsoft.com/types/counter";
|
|
50
|
-
/**
|
|
51
|
-
* Static value for {@link CounterFactory.attributes}.
|
|
52
|
-
*/
|
|
53
|
-
CounterFactory.Attributes = {
|
|
54
|
-
type: CounterFactory.Type,
|
|
55
|
-
snapshotFormatVersion: "0.1",
|
|
56
|
-
packageVersion: pkgVersion,
|
|
57
|
-
};
|
|
58
58
|
/**
|
|
59
59
|
* Entrypoint for {@link ISharedCounter} creation.
|
|
60
60
|
* @legacy @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,OAAO,cAAc;
|
|
1
|
+
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAC1B;;OAEG;IACH,uGAAuG;IACvG,qFAAqF;IACrF,2CAA2C;IACpC,MAAM,CAAU,IAAI,GAAG,2CAA2C,CAAC;IAE1E;;OAEG;IACI,MAAM,CAAU,UAAU,GAAuB;QACvD,IAAI,EAAE,cAAc,CAAC,IAAI;QACzB,qBAAqB,EAAE,KAAK;QAC5B,cAAc,EAAE,UAAU;KAC1B,CAAC;IAEF;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,cAAc,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,cAAc,CAAC,UAAU,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAChE,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACtE,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IAChB,CAAC;;AAGF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,sBAAsB,CAAiB,cAAc,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { createSharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { SharedCounter as SharedCounterClass } from \"./counter.js\";\nimport type { ISharedCounter } from \"./interfaces.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.\n *\n * @sealed\n */\nexport class CounterFactory implements IChannelFactory<ISharedCounter> {\n\t/**\n\t * Static value for {@link CounterFactory.\"type\"}.\n\t */\n\t// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.\n\t// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.\n\t// public static readonly Type = \"counter\";\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/counter\";\n\n\t/**\n\t * Static value for {@link CounterFactory.attributes}.\n\t */\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: CounterFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn CounterFactory.Type;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn CounterFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedCounter> {\n\t\tconst counter = new SharedCounterClass(id, runtime, attributes);\n\t\tawait counter.load(services);\n\t\treturn counter;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic create(document: IFluidDataStoreRuntime, id: string): ISharedCounter {\n\t\tconst counter = new SharedCounterClass(id, document, this.attributes);\n\t\tcounter.initializeLocal();\n\t\treturn counter;\n\t}\n}\n\n/**\n * Entrypoint for {@link ISharedCounter} creation.\n * @legacy @beta\n */\nexport const SharedCounter = createSharedObjectKind<ISharedCounter>(CounterFactory);\n\n/**\n * Alias for {@link ISharedCounter} for compatibility.\n * @legacy @beta\n */\nexport type SharedCounter = ISharedCounter;\n"]}
|
package/lib/legacy.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib
|
|
8
|
+
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,4BAA4B,CAAC;AACjD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,4BAA4B,CAAC;AACjD,eAAO,MAAM,UAAU,UAAU,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,yBAAyB,CAAC;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,yBAAyB,CAAC;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/counter\";\nexport const pkgVersion = \"3.0.0\";\n"]}
|
package/lib/public.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib
|
|
8
|
+
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/counter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Counter DDS",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,50 +14,30 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"require": {
|
|
22
|
-
"types": "./dist/public.d.ts",
|
|
23
|
-
"default": "./dist/index.js"
|
|
17
|
+
"types": "./lib/public.d.ts",
|
|
18
|
+
"default": "./lib/index.js",
|
|
19
|
+
"internal-entrypoint-generation": {
|
|
20
|
+
"types": "./dist/public.d.ts"
|
|
24
21
|
}
|
|
25
22
|
},
|
|
26
23
|
"./legacy": {
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"require": {
|
|
32
|
-
"types": "./dist/legacy.d.ts",
|
|
33
|
-
"default": "./dist/index.js"
|
|
24
|
+
"types": "./lib/legacy.d.ts",
|
|
25
|
+
"default": "./lib/index.js",
|
|
26
|
+
"internal-entrypoint-generation": {
|
|
27
|
+
"types": "./dist/legacy.d.ts"
|
|
34
28
|
}
|
|
35
29
|
},
|
|
36
30
|
"./internal": {
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
"default": "./lib/index.js"
|
|
40
|
-
},
|
|
41
|
-
"require": {
|
|
42
|
-
"types": "./dist/index.d.ts",
|
|
43
|
-
"default": "./dist/index.js"
|
|
44
|
-
}
|
|
31
|
+
"types": "./lib/index.d.ts",
|
|
32
|
+
"default": "./lib/index.js"
|
|
45
33
|
},
|
|
46
34
|
"./internal/test": {
|
|
47
35
|
"allow-ff-test-exports": {
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"default": "./lib/test/index.js"
|
|
51
|
-
},
|
|
52
|
-
"require": {
|
|
53
|
-
"types": "./dist/test/index.d.ts",
|
|
54
|
-
"default": "./dist/test/index.js"
|
|
55
|
-
}
|
|
36
|
+
"types": "./lib/test/index.d.ts",
|
|
37
|
+
"default": "./lib/test/index.js"
|
|
56
38
|
}
|
|
57
39
|
}
|
|
58
40
|
},
|
|
59
|
-
"main": "lib/index.js",
|
|
60
|
-
"types": "lib/public.d.ts",
|
|
61
41
|
"c8": {
|
|
62
42
|
"all": true,
|
|
63
43
|
"cache-dir": "nyc/.cache",
|
|
@@ -81,27 +61,27 @@
|
|
|
81
61
|
"temp-directory": "nyc/.nyc_output"
|
|
82
62
|
},
|
|
83
63
|
"dependencies": {
|
|
84
|
-
"@fluidframework/core-interfaces": "~
|
|
85
|
-
"@fluidframework/core-utils": "~
|
|
86
|
-
"@fluidframework/datastore-definitions": "~
|
|
87
|
-
"@fluidframework/driver-definitions": "~
|
|
88
|
-
"@fluidframework/driver-utils": "~
|
|
89
|
-
"@fluidframework/runtime-definitions": "~
|
|
90
|
-
"@fluidframework/shared-object-base": "~
|
|
64
|
+
"@fluidframework/core-interfaces": "~3.0.0",
|
|
65
|
+
"@fluidframework/core-utils": "~3.0.0",
|
|
66
|
+
"@fluidframework/datastore-definitions": "~3.0.0",
|
|
67
|
+
"@fluidframework/driver-definitions": "~3.0.0",
|
|
68
|
+
"@fluidframework/driver-utils": "~3.0.0",
|
|
69
|
+
"@fluidframework/runtime-definitions": "~3.0.0",
|
|
70
|
+
"@fluidframework/shared-object-base": "~3.0.0"
|
|
91
71
|
},
|
|
92
72
|
"devDependencies": {
|
|
93
73
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
94
74
|
"@biomejs/biome": "~2.4.5",
|
|
95
|
-
"@fluid-internal/mocha-test-setup": "~
|
|
96
|
-
"@fluid-private/stochastic-test-utils": "~
|
|
97
|
-
"@fluid-private/test-dds-utils": "~
|
|
75
|
+
"@fluid-internal/mocha-test-setup": "~3.0.0",
|
|
76
|
+
"@fluid-private/stochastic-test-utils": "~3.0.0",
|
|
77
|
+
"@fluid-private/test-dds-utils": "~3.0.0",
|
|
98
78
|
"@fluid-tools/build-cli": "^0.67.0",
|
|
99
79
|
"@fluidframework/build-common": "^2.0.3",
|
|
100
80
|
"@fluidframework/build-tools": "^0.67.0",
|
|
101
|
-
"@fluidframework/container-definitions": "~
|
|
81
|
+
"@fluidframework/container-definitions": "~3.0.0",
|
|
102
82
|
"@fluidframework/counter-previous": "npm:@fluidframework/counter@2.116.0",
|
|
103
83
|
"@fluidframework/eslint-config-fluid": "^14.0.0",
|
|
104
|
-
"@fluidframework/test-runtime-utils": "~
|
|
84
|
+
"@fluidframework/test-runtime-utils": "~3.0.0",
|
|
105
85
|
"@microsoft/api-extractor": "7.58.1",
|
|
106
86
|
"@types/mocha": "^10.0.10",
|
|
107
87
|
"@types/node": "~22.19.17",
|
|
@@ -114,7 +94,7 @@
|
|
|
114
94
|
"mocha": "^11.7.5",
|
|
115
95
|
"mocha-multi-reporters": "^1.5.1",
|
|
116
96
|
"rimraf": "^6.1.3",
|
|
117
|
-
"typescript": "~
|
|
97
|
+
"typescript": "~6.0.3"
|
|
118
98
|
},
|
|
119
99
|
"typeValidation": {
|
|
120
100
|
"broken": {},
|
|
@@ -123,20 +103,21 @@
|
|
|
123
103
|
"scripts": {
|
|
124
104
|
"build": "fluid-build . --task build",
|
|
125
105
|
"build:api-reports": "concurrently \"npm:build:api-reports:*\"",
|
|
126
|
-
"build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
|
|
127
|
-
"build:api-reports:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
|
|
106
|
+
"build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor-report.current.json",
|
|
107
|
+
"build:api-reports:legacy": "api-extractor run --local --config api-extractor/api-extractor-report.legacy.json",
|
|
108
|
+
"build:cjs": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
128
109
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
129
110
|
"build:compile": "fluid-build . --task compile",
|
|
130
|
-
"build:docs": "api-extractor run --local",
|
|
111
|
+
"build:docs": "api-extractor run --local --config api-extractor/api-extractor-model.json",
|
|
131
112
|
"build:entrypoints": "fluid-build . --task build:entrypoints",
|
|
132
113
|
"build:entrypoints:cjs": "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist",
|
|
133
|
-
"build:entrypoints:esm": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib
|
|
134
|
-
"build:
|
|
114
|
+
"build:entrypoints:esm": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib",
|
|
115
|
+
"build:esm": "tsc --project ./tsconfig.json",
|
|
135
116
|
"build:genver": "gen-version",
|
|
136
117
|
"build:test": "concurrently npm:build:test:esm npm:build:test:cjs",
|
|
137
118
|
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
138
119
|
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
139
|
-
"check:are-the-types-wrong": "attw --pack . --exclude-entrypoints ./internal/test",
|
|
120
|
+
"check:are-the-types-wrong": "attw --pack . --profile esm-only --exclude-entrypoints ./internal/test",
|
|
140
121
|
"check:biome": "biome check .",
|
|
141
122
|
"check:exports": "concurrently \"npm:check:exports:*\"",
|
|
142
123
|
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
|
|
@@ -146,9 +127,9 @@
|
|
|
146
127
|
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
|
|
147
128
|
"check:format": "npm run check:biome",
|
|
148
129
|
"ci:build:api-reports": "concurrently \"npm:ci:build:api-reports:*\"",
|
|
149
|
-
"ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
|
|
150
|
-
"ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
|
|
151
|
-
"ci:build:docs": "api-extractor run",
|
|
130
|
+
"ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor-report.current.json",
|
|
131
|
+
"ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor-report.legacy.json",
|
|
132
|
+
"ci:build:docs": "api-extractor run --config api-extractor/api-extractor-model.json",
|
|
152
133
|
"clean": "rimraf --glob dist lib {alpha,beta,internal,legacy}.d.ts \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
153
134
|
"eslint": "eslint --quiet --format stylish src",
|
|
154
135
|
"eslint:fix": "eslint --quiet --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
@@ -162,7 +143,6 @@
|
|
|
162
143
|
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
|
|
163
144
|
"test:mocha:esm": "mocha",
|
|
164
145
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
165
|
-
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
166
146
|
"typetests:gen": "flub generate typetests --dir . -v"
|
|
167
147
|
}
|
|
168
148
|
}
|
package/src/packageVersion.ts
CHANGED
package/tsconfig.json
CHANGED
package/internal.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export * from "./lib/index.js";
|
package/legacy.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export * from "./lib/legacy.js";
|
|
File without changes
|
|
File without changes
|