@fluidframework/counter 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.2.0.0.245554
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/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +8 -0
- package/README.md +133 -52
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/counter.api.md +2 -4
- package/dist/counter-alpha.d.ts +2 -2
- package/dist/counter-beta.d.ts +2 -0
- package/dist/counter-public.d.ts +2 -0
- package/dist/counter-untrimmed.d.ts +2 -2
- package/dist/counter.d.ts +3 -3
- package/dist/counter.d.ts.map +1 -1
- package/dist/counter.js +4 -4
- package/dist/counter.js.map +1 -1
- package/dist/counterFactory.d.ts +2 -2
- package/dist/counterFactory.d.ts.map +1 -1
- package/dist/counterFactory.js +5 -5
- package/dist/counterFactory.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/{counter-untrimmed.d.mts → counter-alpha.d.ts} +9 -2
- package/lib/{counter-beta.d.mts → counter-beta.d.ts} +9 -0
- package/lib/{counter-public.d.mts → counter-public.d.ts} +9 -0
- package/lib/{counter-alpha.d.mts → counter-untrimmed.d.ts} +9 -2
- package/lib/{counter.d.mts → counter.d.ts} +4 -4
- package/lib/counter.d.ts.map +1 -0
- package/lib/{counter.mjs → counter.js} +3 -3
- package/lib/counter.js.map +1 -0
- package/lib/{counterFactory.d.mts → counterFactory.d.ts} +3 -3
- package/lib/counterFactory.d.ts.map +1 -0
- package/lib/{counterFactory.mjs → counterFactory.js} +3 -3
- package/lib/counterFactory.js.map +1 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/{interfaces.d.mts → interfaces.d.ts} +1 -1
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/{interfaces.mjs → interfaces.js} +1 -1
- package/lib/interfaces.js.map +1 -0
- package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
- package/lib/packageVersion.js.map +1 -0
- package/lib/test/counter.spec.js +218 -0
- package/lib/test/counter.spec.js.map +1 -0
- package/lib/test/types/validateCounterPrevious.generated.js +8 -0
- package/lib/test/types/validateCounterPrevious.generated.js.map +1 -0
- package/package.json +39 -45
- package/src/counter.ts +5 -5
- package/src/counterFactory.ts +4 -4
- package/src/index.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/lib/counter.d.mts.map +0 -1
- package/lib/counter.mjs.map +0 -1
- package/lib/counterFactory.d.mts.map +0 -1
- package/lib/counterFactory.mjs.map +0 -1
- package/lib/index.d.mts +0 -7
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs +0 -6
- package/lib/index.mjs.map +0 -1
- package/lib/interfaces.d.mts.map +0 -1
- package/lib/interfaces.mjs.map +0 -1
- package/lib/packageVersion.d.mts.map +0 -1
- package/lib/packageVersion.mjs.map +0 -1
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const getFluidTestMochaConfig = require("@
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
|
|
9
9
|
|
|
10
10
|
const packageDir = __dirname;
|
|
11
11
|
const config = getFluidTestMochaConfig(packageDir);
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @fluidframework/counter
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.2.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- counter: SharedCounter.create now returns ISharedCounter ([#19961](https://github.com/microsoft/FluidFramework/issues/19961)) [e2317bdbd2](https://github.com/microsoft/FluidFramework/commits/e2317bdbd29c40c7888bba2ed657a40a8dd6f45b)
|
|
8
|
+
|
|
9
|
+
`SharedCounter.create` now returns `ISharedCounter` instead of `SharedCounter`.
|
|
10
|
+
|
|
3
11
|
## 2.0.0-rc.1.0.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,94 +1,167 @@
|
|
|
1
|
-
# @fluidframework/
|
|
1
|
+
# @fluidframework/counter
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<!-- AUTO-GENERATED-CONTENT:START (README_INSTALLATION_SECTION:includeHeading=TRUE) -->
|
|
3
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_DEPENDENCY_GUIDELINES_SECTION:includeHeading=TRUE) -->
|
|
6
4
|
|
|
7
5
|
<!-- prettier-ignore-start -->
|
|
8
6
|
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
9
7
|
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
To get started, install the package by running the following command:
|
|
8
|
+
## Using Fluid Framework libraries
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
When taking a dependency on a Fluid Framework library, we recommend using a `^` (caret) version range, such as `^1.3.4`.
|
|
11
|
+
While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
|
|
12
|
+
library consumers should always prefer `^`.
|
|
17
13
|
|
|
18
14
|
<!-- prettier-ignore-end -->
|
|
19
15
|
|
|
20
16
|
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
## Introduction
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
The `SharedCounter` distributed data structure (DDS) is used to store an integer counter value that can be modified by multiple clients simultaneously.
|
|
21
|
+
The data structure affords incrementing and decrementing the shared value via its `increment` method. Decrements are done by providing a negative value.
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
The `SharedCounter` is a specialized [Optimistic DDS][].
|
|
24
|
+
It operates on communicated _deltas_ (amounts by which the shared value should be incremented or decremented), rather than direct changes to the shared value.
|
|
25
|
+
In this way, it avoids the pitfalls of DDSes with simpler merge strategies, in which one user's edit may clobber another's (see [below](#why-a-specialized-dds)).
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
|
|
31
|
-
library consumers should always prefer `^`.
|
|
27
|
+
Note that the `SharedCounter` only operates on integer values.
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
### Why a specialized DDS?
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
You may be asking yourself, why not just store the shared integer value directly in another DDS like a [SharedMap][]?
|
|
32
|
+
Why incur the overhead of another runtime type?
|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
The key to the answer here is that DDSes with simpler merge strategies (like `SharedMap`) take a somewhat brute-force approach to merging concurrent edits.
|
|
35
|
+
For a semantic data type like a counter, this can result in undesirable behavior.
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
#### SharedMap Example
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
Let's illustrate the issue with an example.
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
Consider a polling widget.
|
|
42
|
+
The widget displays a list of options and allows users to click a checkbox to vote for a given option.
|
|
43
|
+
Next to each option in the list, a live counter is displayed that shows the number of votes for that item.
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Whenever a user checks an option, all users should see the counter corresponding to that option increment by 1.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
In this example, the application is storing its vote counts in a [SharedMap][], where the map keys are `strings` representing the IDs of the options, and the values are `numbers` representing the associated vote counts.
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
For simplicity, we will look at a scenario in which 2 users vote for the same option at around the same time.
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
Specifically, **User A** clicks the checkbox for option **Foo**, which currently has **0** votes.
|
|
52
|
+
The application then optimistically updates the vote count for that object by writing the updated counter value of **1** for option **Foo** to its `SharedMap`.
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
54
|
+
The value change operation (op) is then transmitted to the service to be sequenced and eventually sent to other users in the collaborative session.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
At around the same time, **User B** clicks the checkbox for option **Foo**, which in their view currently has **0** votes.
|
|
57
|
+
Similarly to before, the application optimistically updates the associated counter value to **1**, and transmits its own update op.
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
The service receives the op from **User A** first, and sequences their op updating **Foo** to **1** as **op 0**. **User B**'s op is received second, and is sequenced as **op 1**.
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
|
|
61
|
+
Both users then receive acknowledgement of their update, and receive **op 0** and **op 1** to be applied in order.
|
|
62
|
+
Both clients apply **op 0** by setting **Foo** to **1**.
|
|
63
|
+
Then both clients apply **op 1** by setting **Foo** to **1**.
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
But this isn't right.
|
|
66
|
+
Two different users voted for option **Foo**, but the counter now displays **1**.
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
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.
|
|
68
|
+
`SharedCounter` solves this problem by expressing its operations in terms of _increments_ and _decrements_ rather than as direct value updates.
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
70
|
+
So for the scenario above, if the system was using `SharedCounter`s to represent the vote counts, **User A** would submit an op _incrementing_ **Foo** by **+1**, rather than updating the value of **Foo** from **0** to **1**.
|
|
71
|
+
At around the same time, **User B** would submit their own **+1** op for **Foo**.
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
Assuming the same sequencing, both users first apply **op 0** and increment their counter for **Foo** by **+1** (from **0** to **1**).
|
|
74
|
+
Next, they both apply **op 1** and increment their counter for **Foo** by **+1** a second time (from **1** to **2**).
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
Now both users see the right vote count for `Foo`!
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
## Usage
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
80
|
+
The `SharedCounter` object provides a simple API surface for managing a shared integer whose value may be incremented and decremented by collaborators.
|
|
82
81
|
|
|
83
|
-
|
|
82
|
+
A new `SharedCounter` value will be initialized with its value set to `0`.
|
|
83
|
+
If you wish to initialize the counter to a different value, you may [modify the value](#incrementing--decrementing-the-value) before attaching the container, or before storing it in another shared object like a `SharedMap`.
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
Wiki](https://github.com/microsoft/FluidFramework/wiki) or [fluidframework.com](https://fluidframework.com/docs/).
|
|
85
|
+
## Installation
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
|
|
87
|
+
The package containing the `SharedCounter` library is [@fluidframework/shared-counter](https://www.npmjs.com/package/@fluidframework/counter).
|
|
90
88
|
|
|
91
|
-
|
|
89
|
+
To get started, run the following from a terminal in your repository:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm install @fluidframework/shared-counter
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Creation
|
|
96
|
+
|
|
97
|
+
The workflow for creating a `SharedCounter` is effectively the same as many of our other DDSes.
|
|
98
|
+
For an example of how to create one, please see our workflow examples for [SharedMap creation][].
|
|
99
|
+
|
|
100
|
+
### Incrementing / decrementing the value
|
|
101
|
+
|
|
102
|
+
Once you have created your `SharedCounter`, you can change its value using the [increment][] method.
|
|
103
|
+
This method accepts a positive or negative _integer_ to be applied to the shared value.
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
sharedCounter.increment(3); // Adds 3 to the current value
|
|
107
|
+
sharedCounter.increment(-5); // Subtracts 5 from the current value
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### `incremented` event
|
|
111
|
+
|
|
112
|
+
The [incremented][] event is sent when a client in the collaborative session changes the counter value via the `increment` method.
|
|
113
|
+
|
|
114
|
+
Signature:
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
(event: "incremented", listener: (incrementAmount: number, newValue: number) => void)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
By listening to this event, you can receive and apply the changes coming from other collaborators.
|
|
121
|
+
Consider the following code example for configuring a Counter widget:
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
const sharedCounter = container.initialObjects.sharedCounter;
|
|
125
|
+
let counterValue = sharedCounter.value;
|
|
126
|
+
|
|
127
|
+
const incrementButton = document.createElement("button");
|
|
128
|
+
button.textContent = "Increment";
|
|
129
|
+
const decrementButton = document.createElement("button");
|
|
130
|
+
button.textContent = "Decrement";
|
|
131
|
+
|
|
132
|
+
// Increment / decrement shared counter value when the corresponding button is clicked
|
|
133
|
+
incrementButton.addEventListener("click", () => sharedCounter.increment(1));
|
|
134
|
+
decrementButton.addEventListener("click", () => sharedCounter.increment(-1));
|
|
135
|
+
|
|
136
|
+
const counterValueLabel = document.createElement("label");
|
|
137
|
+
counterValueLabel.textContent = `${counterValue}`;
|
|
138
|
+
|
|
139
|
+
// This function will be called each time the shared counter value is incremented
|
|
140
|
+
// (including increments from this client).
|
|
141
|
+
// Update the local counter value and the corresponding label being displayed in the widget.
|
|
142
|
+
const updateCounterValueLabel = (delta) => {
|
|
143
|
+
counterValue += delta;
|
|
144
|
+
counterValueLabel.textContent = `${counterValue}`;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// Register to be notified when the counter is incremented
|
|
148
|
+
sharedCounter.on("incremented", updateCounterValueLabel);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
In the code above, whenever a user presses either the Increment or Decrement button, the `sharedCounter.increment` is called with +/- 1.
|
|
152
|
+
This causes the `incremented` event to be sent to all of the clients who have this container open.
|
|
153
|
+
|
|
154
|
+
Since `updateCounterValueLabel` is listening for all `incremented` events, the view will always refresh with the appropriate updated value any time a collaborator increments or decrements the counter value.
|
|
155
|
+
|
|
156
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_API_DOCS_SECTION:includeHeading=TRUE) -->
|
|
157
|
+
|
|
158
|
+
<!-- prettier-ignore-start -->
|
|
159
|
+
|
|
160
|
+
<!-- This section is automatically generated. To update it, make the appropriate changes to docs/md-magic.config.js or the embedded content, then run 'npm run build:md-magic' in the docs folder. -->
|
|
161
|
+
|
|
162
|
+
## API Documentation
|
|
163
|
+
|
|
164
|
+
API documentation for **@fluidframework/counter** is available at <https://fluidframework.com/docs/apis/counter>.
|
|
92
165
|
|
|
93
166
|
<!-- prettier-ignore-end -->
|
|
94
167
|
|
|
@@ -110,3 +183,11 @@ Use of Microsoft trademarks or logos in modified versions of this project must n
|
|
|
110
183
|
<!-- prettier-ignore-end -->
|
|
111
184
|
|
|
112
185
|
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
186
|
+
|
|
187
|
+
<!-- Links -->
|
|
188
|
+
|
|
189
|
+
[increment]: https://fluidframework.com/docs/apis/counter/isharedcounter-interface#increment-methodsignature
|
|
190
|
+
[incremented]: https://fluidframework.com/docs/apis/counter/isharedcounterevents-interface#_call_-callsignature
|
|
191
|
+
[optimistic dds]: https://fluidframework.com/docs/build/dds/#optimistic-data-structures
|
|
192
|
+
[sharedmap]: https://fluidframework.com/docs/data-structures/map
|
|
193
|
+
[sharedmap creation]: https://fluidframework.com/docs/data-structures/map/#creation
|
|
@@ -1,4 +1,8 @@
|
|
|
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
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-base.cjs.primary.json",
|
|
4
|
+
// CJS is actually secondary; so, no report.
|
|
5
|
+
"apiReport": {
|
|
6
|
+
"enabled": false
|
|
7
|
+
}
|
|
4
8
|
}
|
package/api-extractor-lint.json
CHANGED
package/api-extractor.json
CHANGED
|
@@ -30,12 +30,10 @@ export interface ISharedCounterEvents extends ISharedObjectEvents {
|
|
|
30
30
|
// @alpha
|
|
31
31
|
export class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {
|
|
32
32
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
33
|
-
// (undocumented)
|
|
34
33
|
protected applyStashedOp(op: unknown): void;
|
|
35
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
36
|
-
static getFactory(): IChannelFactory
|
|
34
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
35
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
37
36
|
increment(incrementAmount: number): void;
|
|
38
|
-
// (undocumented)
|
|
39
37
|
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
40
38
|
protected onDisconnect(): void;
|
|
41
39
|
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
package/dist/counter-alpha.d.ts
CHANGED
|
@@ -100,14 +100,14 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
100
100
|
*
|
|
101
101
|
* @returns newly create shared counter (but not attached yet)
|
|
102
102
|
*/
|
|
103
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
103
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
104
104
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
105
105
|
/**
|
|
106
106
|
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
107
107
|
*
|
|
108
108
|
* @returns a factory that creates and load SharedCounter
|
|
109
109
|
*/
|
|
110
|
-
static getFactory(): IChannelFactory
|
|
110
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
111
111
|
private _value;
|
|
112
112
|
/**
|
|
113
113
|
* {@inheritDoc ISharedCounter.value}
|
package/dist/counter-beta.d.ts
CHANGED
package/dist/counter-public.d.ts
CHANGED
|
@@ -100,14 +100,14 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
100
100
|
*
|
|
101
101
|
* @returns newly create shared counter (but not attached yet)
|
|
102
102
|
*/
|
|
103
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
103
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
104
104
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
105
105
|
/**
|
|
106
106
|
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
107
107
|
*
|
|
108
108
|
* @returns a factory that creates and load SharedCounter
|
|
109
109
|
*/
|
|
110
|
-
static getFactory(): IChannelFactory
|
|
110
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
111
111
|
private _value;
|
|
112
112
|
/**
|
|
113
113
|
* {@inheritDoc ISharedCounter.value}
|
package/dist/counter.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type ISequencedDocumentMessage } from "@fluidframework/protocol-definit
|
|
|
6
6
|
import { type IFluidDataStoreRuntime, type IChannelStorageService, type IChannelFactory, type IChannelAttributes } from "@fluidframework/datastore-definitions";
|
|
7
7
|
import { type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
8
8
|
import { type IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
|
-
import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces";
|
|
9
|
+
import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces.js";
|
|
10
10
|
/**
|
|
11
11
|
* {@inheritDoc ISharedCounter}
|
|
12
12
|
* @alpha
|
|
@@ -20,14 +20,14 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
20
20
|
*
|
|
21
21
|
* @returns newly create shared counter (but not attached yet)
|
|
22
22
|
*/
|
|
23
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
23
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
24
24
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
25
25
|
/**
|
|
26
26
|
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
27
27
|
*
|
|
28
28
|
* @returns a factory that creates and load SharedCounter
|
|
29
29
|
*/
|
|
30
|
-
static getFactory(): IChannelFactory
|
|
30
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
31
31
|
private _value;
|
|
32
32
|
/**
|
|
33
33
|
* {@inheritDoc ISharedCounter.value}
|
package/dist/counter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AACnG,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAEN,KAAK,gBAAgB,EACrB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AACnG,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAEN,KAAK,gBAAgB,EACrB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsBjF;;;GAGG;AACH,qBAAa,aAAc,SAAQ,YAAY,CAAC,oBAAoB,CAAE,YAAW,cAAc;IAC9F;;;;;;;OAOG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,cAAc;gBAKjF,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,kBAAkB;IAK/B;;;;OAIG;WACW,UAAU,IAAI,eAAe,CAAC,cAAc,CAAC;IAI3D,OAAO,CAAC,MAAM,CAAa;IAE3B;;OAEG;IACH,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED;;OAEG;IACI,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI;IAgB/C,OAAO,CAAC,aAAa;IAKrB;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAU5E;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxE;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAkBP;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI;CAU3C"}
|
package/dist/counter.js
CHANGED
|
@@ -9,7 +9,7 @@ const core_utils_1 = require("@fluidframework/core-utils");
|
|
|
9
9
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
10
10
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
11
11
|
const shared_object_base_1 = require("@fluidframework/shared-object-base");
|
|
12
|
-
const
|
|
12
|
+
const counterFactory_js_1 = require("./counterFactory.js");
|
|
13
13
|
const snapshotFileName = "header";
|
|
14
14
|
/**
|
|
15
15
|
* {@inheritDoc ISharedCounter}
|
|
@@ -25,7 +25,7 @@ class SharedCounter extends shared_object_base_1.SharedObject {
|
|
|
25
25
|
* @returns newly create shared counter (but not attached yet)
|
|
26
26
|
*/
|
|
27
27
|
static create(runtime, id) {
|
|
28
|
-
return runtime.createChannel(id,
|
|
28
|
+
return runtime.createChannel(id, counterFactory_js_1.CounterFactory.Type);
|
|
29
29
|
}
|
|
30
30
|
constructor(id, runtime, attributes) {
|
|
31
31
|
super(id, runtime, attributes, "fluid_counter_");
|
|
@@ -37,7 +37,7 @@ class SharedCounter extends shared_object_base_1.SharedObject {
|
|
|
37
37
|
* @returns a factory that creates and load SharedCounter
|
|
38
38
|
*/
|
|
39
39
|
static getFactory() {
|
|
40
|
-
return new
|
|
40
|
+
return new counterFactory_js_1.CounterFactory();
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* {@inheritDoc ISharedCounter.value}
|
|
@@ -120,7 +120,7 @@ class SharedCounter extends shared_object_base_1.SharedObject {
|
|
|
120
120
|
// TODO: Clean up error code linter violations repo-wide.
|
|
121
121
|
// eslint-disable-next-line unicorn/numeric-separators-style
|
|
122
122
|
(0, core_utils_1.assert)(counterOp.type === "increment", 0x3ec /* Op type is not increment */);
|
|
123
|
-
this.
|
|
123
|
+
this.increment(counterOp.incrementAmount);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
exports.SharedCounter = SharedCounter;
|
package/dist/counter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,+EAAmG;AAOnG,+DAA4D;AAE5D,2EAI4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"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","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\";\nimport { type ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelStorageService,\n\ttype IChannelFactory,\n\ttype IChannelAttributes,\n} from \"@fluidframework/datastore-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { type ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n\tcreateSingleBlobSummary,\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { CounterFactory } from \"./counterFactory.js\";\nimport { type ISharedCounter, type ISharedCounterEvents } from \"./interfaces.js\";\n\n/**\n * Describes the operation (op) format for incrementing the {@link SharedCounter}.\n */\ninterface IIncrementOperation {\n\ttype: \"increment\";\n\tincrementAmount: 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 * @alpha\n */\nexport class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {\n\t/**\n\t * Create a new {@link SharedCounter}.\n\t *\n\t * @param runtime - The data store runtime to which the new `SharedCounter` will belong.\n\t * @param id - Optional name of the `SharedCounter`. If not provided, one will be generated.\n\t *\n\t * @returns newly create shared counter (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter {\n\t\treturn runtime.createChannel(id, CounterFactory.Type) as SharedCounter;\n\t}\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\t/**\n\t * Get a factory for {@link SharedCounter} to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedCounter\n\t */\n\tpublic static getFactory(): IChannelFactory<ISharedCounter> {\n\t\treturn new CounterFactory();\n\t}\n\n\tprivate _value: 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\n\t\tthis.incrementCore(incrementAmount);\n\t\tthis.submitLocalMessage(op);\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\t/**\n\t * Process a counter operation (op).\n\t *\n\t * @param message - The message to prepare.\n\t * @param local - Whether or not the message was sent by the local client.\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be `undefined`.\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as IIncrementOperation;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"increment\": {\n\t\t\t\t\tthis.incrementCore(op.incrementAmount);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\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\t// eslint-disable-next-line unicorn/numeric-separators-style\n\t\tassert(counterOp.type === \"increment\", 0x3ec /* Op type is not increment */);\n\n\t\tthis.increment(counterOp.incrementAmount);\n\t}\n}\n"]}
|
package/dist/counterFactory.d.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type IChannelAttributes, type IFluidDataStoreRuntime, type IChannelServices, type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
-
import { type ISharedCounter } from "./interfaces";
|
|
6
|
+
import { type ISharedCounter } from "./interfaces.js";
|
|
7
7
|
/**
|
|
8
8
|
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.
|
|
9
9
|
*
|
|
10
10
|
* @sealed
|
|
11
11
|
*/
|
|
12
|
-
export declare class CounterFactory implements IChannelFactory {
|
|
12
|
+
export declare class CounterFactory implements IChannelFactory<ISharedCounter> {
|
|
13
13
|
/**
|
|
14
14
|
* Static value for {@link CounterFactory."type"}.
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterFactory.d.ts","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"counterFactory.d.ts","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD;;;;GAIG;AACH,qBAAa,cAAe,YAAW,eAAe,CAAC,cAAc,CAAC;IACrE;;OAEG;IACH,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"}
|
package/dist/counterFactory.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.CounterFactory = void 0;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const counter_js_1 = require("./counter.js");
|
|
9
|
+
const packageVersion_js_1 = require("./packageVersion.js");
|
|
10
10
|
/**
|
|
11
11
|
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.
|
|
12
12
|
*
|
|
@@ -29,7 +29,7 @@ class CounterFactory {
|
|
|
29
29
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
30
30
|
*/
|
|
31
31
|
async load(runtime, id, services, attributes) {
|
|
32
|
-
const counter = new
|
|
32
|
+
const counter = new counter_js_1.SharedCounter(id, runtime, attributes);
|
|
33
33
|
await counter.load(services);
|
|
34
34
|
return counter;
|
|
35
35
|
}
|
|
@@ -37,7 +37,7 @@ class CounterFactory {
|
|
|
37
37
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
38
38
|
*/
|
|
39
39
|
create(document, id) {
|
|
40
|
-
const counter = new
|
|
40
|
+
const counter = new counter_js_1.SharedCounter(id, document, this.attributes);
|
|
41
41
|
counter.initializeLocal();
|
|
42
42
|
return counter;
|
|
43
43
|
}
|
|
@@ -53,6 +53,6 @@ CounterFactory.Type = "https://graph.microsoft.com/types/counter";
|
|
|
53
53
|
CounterFactory.Attributes = {
|
|
54
54
|
type: CounterFactory.Type,
|
|
55
55
|
snapshotFormatVersion: "0.1",
|
|
56
|
-
packageVersion:
|
|
56
|
+
packageVersion: packageVersion_js_1.pkgVersion,
|
|
57
57
|
};
|
|
58
58
|
//# sourceMappingURL=counterFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,
|
|
1
|
+
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,6CAA6C;AAE7C,2DAAiD;AAEjD;;;;GAIG;AACH,MAAa,cAAc;IAe1B;;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,0BAAa,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC3D,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,0BAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACjE,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IAChB,CAAC;;AAlDF,wCAmDC;AAlDA;;GAEG;AACoB,mBAAI,GAAG,2CAA2C,CAAC;AAE1E;;GAEG;AACoB,yBAAU,GAAuB;IACvD,IAAI,EAAE,cAAc,CAAC,IAAI;IACzB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,8BAAU;CAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype IChannelAttributes,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelServices,\n\ttype IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedCounter } 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\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 SharedCounter(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 SharedCounter(id, document, this.attributes);\n\t\tcounter.initializeLocal();\n\t\treturn counter;\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
|
-
export { SharedCounter } from "./counter";
|
|
12
|
-
export type { ISharedCounter, ISharedCounterEvents } from "./interfaces";
|
|
11
|
+
export { SharedCounter } from "./counter.js";
|
|
12
|
+
export type { ISharedCounter, ISharedCounterEvents } from "./interfaces.js";
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,6 @@ exports.SharedCounter = void 0;
|
|
|
11
11
|
*
|
|
12
12
|
* @packageDocumentation
|
|
13
13
|
*/
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "SharedCounter", { enumerable: true, get: function () { return
|
|
14
|
+
var counter_js_1 = require("./counter.js");
|
|
15
|
+
Object.defineProperty(exports, "SharedCounter", { enumerable: true, get: function () { return counter_js_1.SharedCounter; } });
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;GAKG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;GAKG;AAEH,2CAA6C;AAApC,2GAAA,aAAa,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This library contains the {@link ISharedCounter | SharedCounter} distributed data structure.\n * A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.\n *\n * @packageDocumentation\n */\n\nexport { SharedCounter } from \"./counter.js\";\nexport type { ISharedCounter, ISharedCounterEvents } from \"./interfaces.js\";\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/counter";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-dev-rc.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev-rc.2.0.0.245554";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/counter";
|
|
11
|
-
exports.pkgVersion = "2.0.0-dev-rc.
|
|
11
|
+
exports.pkgVersion = "2.0.0-dev-rc.2.0.0.245554";
|
|
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,2BAA2B,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 = \"2.0.0-dev-rc.
|
|
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,2BAA2B,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 = \"2.0.0-dev-rc.2.0.0.245554\";\n"]}
|