@fluidframework/counter 1.2.7 → 2.0.0-dev.1.3.0.96595
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 +12 -0
- package/README.md +159 -1
- package/api-extractor.json +1 -1
- package/dist/counter.d.ts +33 -18
- package/dist/counter.d.ts.map +1 -1
- package/dist/counter.js +34 -19
- package/dist/counter.js.map +1 -1
- package/dist/counterFactory.d.ts +18 -1
- package/dist/counterFactory.d.ts.map +1 -1
- package/dist/counterFactory.js +18 -1
- package/dist/counterFactory.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +9 -4
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.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.d.ts +33 -18
- package/lib/counter.d.ts.map +1 -1
- package/lib/counter.js +34 -19
- package/lib/counter.js.map +1 -1
- package/lib/counterFactory.d.ts +18 -1
- package/lib/counterFactory.d.ts.map +1 -1
- package/lib/counterFactory.js +18 -1
- package/lib/counterFactory.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +9 -4
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +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/package.json +16 -16
- package/src/counter.ts +45 -28
- package/src/counterFactory.ts +20 -3
- package/src/index.ts +2 -2
- package/src/interfaces.ts +9 -4
- package/src/packageVersion.ts +1 -1
package/dist/interfaces.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
6
6
|
/**
|
|
7
|
-
* Events sent by
|
|
7
|
+
* Events sent by {@link SharedCounter}.
|
|
8
|
+
*
|
|
8
9
|
* @public
|
|
9
10
|
*/
|
|
10
11
|
export interface ISharedCounterEvents extends ISharedObjectEvents {
|
|
@@ -19,18 +20,22 @@ export interface ISharedCounterEvents extends ISharedObjectEvents {
|
|
|
19
20
|
(event: "incremented", listener: (incrementAmount: number, newValue: number) => void): any;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
|
-
* SharedCounter interface.
|
|
23
|
+
* {@link SharedCounter} interface.
|
|
24
|
+
*
|
|
23
25
|
* @public
|
|
24
26
|
*/
|
|
25
27
|
export interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {
|
|
26
28
|
/**
|
|
27
29
|
* The counter value.
|
|
30
|
+
*
|
|
31
|
+
* @remarks Must be a whole number.
|
|
28
32
|
*/
|
|
29
33
|
value: number;
|
|
30
34
|
/**
|
|
31
|
-
* Increments or decrements the value.
|
|
35
|
+
* Increments or decrements the value.
|
|
36
|
+
* Must only increment or decrement by a whole number value.
|
|
32
37
|
*
|
|
33
|
-
* @param incrementAmount -
|
|
38
|
+
* @param incrementAmount - A whole number to increment or decrement by.
|
|
34
39
|
*/
|
|
35
40
|
increment(incrementAmount: number): void;
|
|
36
41
|
}
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC7D;;;;;;;OAOG;IACH,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,OAAE;CACzF;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa,CAAC,oBAAoB,CAAC;IACvE;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C"}
|
package/dist/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Events sent by
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Events sent by {@link SharedCounter}.\n *\n * @public\n */\nexport interface ISharedCounterEvents extends ISharedObjectEvents {\n /**\n * This event is raised when the counter is incremented or decremented.\n *\n * @param event - The event name.\n * @param listener - An event listener.\n *\n * @eventProperty\n */\n (event: \"incremented\", listener: (incrementAmount: number, newValue: number) => void);\n}\n\n/**\n * {@link SharedCounter} interface.\n *\n * @public\n */\nexport interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {\n /**\n * The counter value.\n *\n * @remarks Must be a whole number.\n */\n value: number;\n\n /**\n * Increments or decrements the value.\n * Must only increment or decrement by a whole number value.\n *\n * @param incrementAmount - A whole number to increment or decrement by.\n */\n increment(incrementAmount: number): void;\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/counter";
|
|
8
|
-
export declare const pkgVersion = "1.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.1.3.0.96595";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,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,0BAA0B,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 = "1.
|
|
11
|
+
exports.pkgVersion = "2.0.0-dev.1.3.0.96595";
|
|
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,uBAAuB,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.1.3.0.96595\";\n"]}
|
package/lib/counter.d.ts
CHANGED
|
@@ -8,48 +8,58 @@ import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
|
8
8
|
import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
9
|
import { ISharedCounter, ISharedCounterEvents } from "./interfaces";
|
|
10
10
|
/**
|
|
11
|
-
* A
|
|
12
|
-
*
|
|
11
|
+
* A shared object that holds a number that can be incremented or decremented.
|
|
12
|
+
*
|
|
13
|
+
* @remarks Note that `SharedCounter` only operates on integer values. This is validated at runtime.
|
|
13
14
|
*
|
|
14
|
-
* @
|
|
15
|
-
* ### Creation
|
|
15
|
+
* @example Creating a `SharedCounter`:
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
18
|
+
* with a runtime and string ID:
|
|
18
19
|
*
|
|
19
20
|
* ```typescript
|
|
20
21
|
* const factory = SharedCounter.getFactory();
|
|
21
22
|
* const counter = factory.create(this.runtime, id) as SharedCounter;
|
|
22
23
|
* ```
|
|
23
24
|
*
|
|
24
|
-
*
|
|
25
|
+
* The initial value of a new `SharedCounter` is 0.
|
|
26
|
+
* If you wish to initialize the counter to a different value, you may call {@link SharedCounter.increment} before
|
|
27
|
+
* attaching the Container, or before inserting it into an existing shared object.
|
|
28
|
+
*
|
|
29
|
+
* @example Using the `SharedCounter`:
|
|
25
30
|
*
|
|
26
|
-
* Once created, you can call
|
|
31
|
+
* Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or
|
|
32
|
+
* negative number:
|
|
27
33
|
*
|
|
28
34
|
* ```typescript
|
|
29
35
|
* counter.increment(10); // add 10 to the counter value
|
|
30
36
|
* counter.increment(-5); // subtract 5 from the counter value
|
|
31
37
|
* ```
|
|
32
38
|
*
|
|
33
|
-
* To observe changes to the value (including those from remote clients), register for the
|
|
39
|
+
* To observe changes to the value (including those from remote clients), register for the
|
|
40
|
+
* {@link ISharedCounterEvents | incremented} event:
|
|
34
41
|
*
|
|
35
42
|
* ```typescript
|
|
36
43
|
* counter.on("incremented", (incrementAmount, newValue) => {
|
|
37
44
|
* console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);
|
|
38
45
|
* });
|
|
39
46
|
* ```
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
40
49
|
*/
|
|
41
50
|
export declare class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {
|
|
42
51
|
/**
|
|
43
|
-
* Create a new
|
|
52
|
+
* Create a new {@link SharedCounter}.
|
|
53
|
+
*
|
|
54
|
+
* @param runtime - The data store runtime to which the new `SharedCounter` will belong.
|
|
55
|
+
* @param id - Optional name of the `SharedCounter`. If not provided, one will be generated.
|
|
44
56
|
*
|
|
45
|
-
* @param runtime - data store runtime the new shared counter belongs to
|
|
46
|
-
* @param id - optional name of the shared counter
|
|
47
57
|
* @returns newly create shared counter (but not attached yet)
|
|
48
58
|
*/
|
|
49
59
|
static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCounter;
|
|
50
60
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
51
61
|
/**
|
|
52
|
-
* Get a factory for SharedCounter to register with the data store.
|
|
62
|
+
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
53
63
|
*
|
|
54
64
|
* @returns a factory that creates and load SharedCounter
|
|
55
65
|
*/
|
|
@@ -65,34 +75,39 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
65
75
|
increment(incrementAmount: number): void;
|
|
66
76
|
private incrementCore;
|
|
67
77
|
/**
|
|
68
|
-
* Create a summary for the counter
|
|
78
|
+
* Create a summary for the counter.
|
|
79
|
+
*
|
|
80
|
+
* @returns The summary of the current state of the counter.
|
|
69
81
|
*
|
|
70
|
-
* @returns the summary of the current state of the counter
|
|
71
82
|
* @internal
|
|
72
83
|
*/
|
|
73
84
|
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
74
85
|
/**
|
|
75
86
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
87
|
+
*
|
|
76
88
|
* @internal
|
|
77
89
|
*/
|
|
78
90
|
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
79
91
|
/**
|
|
80
92
|
* Called when the object has disconnected from the delta stream.
|
|
93
|
+
*
|
|
81
94
|
* @internal
|
|
82
95
|
*/
|
|
83
96
|
protected onDisconnect(): void;
|
|
84
97
|
/**
|
|
85
|
-
* Process a counter operation
|
|
98
|
+
* Process a counter operation (op).
|
|
86
99
|
*
|
|
87
|
-
* @param message -
|
|
88
|
-
* @param local -
|
|
100
|
+
* @param message - The message to prepare.
|
|
101
|
+
* @param local - Whether or not the message was sent by the local client.
|
|
89
102
|
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
90
|
-
* For messages from a remote client, this will be undefined
|
|
103
|
+
* For messages from a remote client, this will be `undefined`.
|
|
104
|
+
*
|
|
91
105
|
* @internal
|
|
92
106
|
*/
|
|
93
107
|
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
94
108
|
/**
|
|
95
109
|
* Not implemented.
|
|
110
|
+
*
|
|
96
111
|
* @internal
|
|
97
112
|
*/
|
|
98
113
|
protected applyStashedOp(): void;
|
package/lib/counter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EACrB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAA2B,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE7G,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EACrB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAA2B,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE7G,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAsBpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,aAAc,SAAQ,YAAY,CAAC,oBAAoB,CAAE,YAAW,cAAc;IAC3F;;;;;;;OAOG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa;gBAIrE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,kBAAkB;IAIvF;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C,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;;;;;;OAMG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAU5E;;;;OAIG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxE;;;;OAIG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;;;;;;;OASG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAezG;;;;OAIG;IACH,SAAS,CAAC,cAAc;CAG3B"}
|
package/lib/counter.js
CHANGED
|
@@ -8,35 +8,44 @@ import { createSingleBlobSummary, SharedObject } from "@fluidframework/shared-ob
|
|
|
8
8
|
import { CounterFactory } from "./counterFactory";
|
|
9
9
|
const snapshotFileName = "header";
|
|
10
10
|
/**
|
|
11
|
-
* A
|
|
12
|
-
*
|
|
11
|
+
* A shared object that holds a number that can be incremented or decremented.
|
|
12
|
+
*
|
|
13
|
+
* @remarks Note that `SharedCounter` only operates on integer values. This is validated at runtime.
|
|
13
14
|
*
|
|
14
|
-
* @
|
|
15
|
-
* ### Creation
|
|
15
|
+
* @example Creating a `SharedCounter`:
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
18
|
+
* with a runtime and string ID:
|
|
18
19
|
*
|
|
19
20
|
* ```typescript
|
|
20
21
|
* const factory = SharedCounter.getFactory();
|
|
21
22
|
* const counter = factory.create(this.runtime, id) as SharedCounter;
|
|
22
23
|
* ```
|
|
23
24
|
*
|
|
24
|
-
*
|
|
25
|
+
* The initial value of a new `SharedCounter` is 0.
|
|
26
|
+
* If you wish to initialize the counter to a different value, you may call {@link SharedCounter.increment} before
|
|
27
|
+
* attaching the Container, or before inserting it into an existing shared object.
|
|
28
|
+
*
|
|
29
|
+
* @example Using the `SharedCounter`:
|
|
25
30
|
*
|
|
26
|
-
* Once created, you can call
|
|
31
|
+
* Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or
|
|
32
|
+
* negative number:
|
|
27
33
|
*
|
|
28
34
|
* ```typescript
|
|
29
35
|
* counter.increment(10); // add 10 to the counter value
|
|
30
36
|
* counter.increment(-5); // subtract 5 from the counter value
|
|
31
37
|
* ```
|
|
32
38
|
*
|
|
33
|
-
* To observe changes to the value (including those from remote clients), register for the
|
|
39
|
+
* To observe changes to the value (including those from remote clients), register for the
|
|
40
|
+
* {@link ISharedCounterEvents | incremented} event:
|
|
34
41
|
*
|
|
35
42
|
* ```typescript
|
|
36
43
|
* counter.on("incremented", (incrementAmount, newValue) => {
|
|
37
44
|
* console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);
|
|
38
45
|
* });
|
|
39
46
|
* ```
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
40
49
|
*/
|
|
41
50
|
export class SharedCounter extends SharedObject {
|
|
42
51
|
constructor(id, runtime, attributes) {
|
|
@@ -44,17 +53,18 @@ export class SharedCounter extends SharedObject {
|
|
|
44
53
|
this._value = 0;
|
|
45
54
|
}
|
|
46
55
|
/**
|
|
47
|
-
* Create a new
|
|
56
|
+
* Create a new {@link SharedCounter}.
|
|
57
|
+
*
|
|
58
|
+
* @param runtime - The data store runtime to which the new `SharedCounter` will belong.
|
|
59
|
+
* @param id - Optional name of the `SharedCounter`. If not provided, one will be generated.
|
|
48
60
|
*
|
|
49
|
-
* @param runtime - data store runtime the new shared counter belongs to
|
|
50
|
-
* @param id - optional name of the shared counter
|
|
51
61
|
* @returns newly create shared counter (but not attached yet)
|
|
52
62
|
*/
|
|
53
63
|
static create(runtime, id) {
|
|
54
64
|
return runtime.createChannel(id, CounterFactory.Type);
|
|
55
65
|
}
|
|
56
66
|
/**
|
|
57
|
-
* Get a factory for SharedCounter to register with the data store.
|
|
67
|
+
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
58
68
|
*
|
|
59
69
|
* @returns a factory that creates and load SharedCounter
|
|
60
70
|
*/
|
|
@@ -88,9 +98,10 @@ export class SharedCounter extends SharedObject {
|
|
|
88
98
|
this.emit("incremented", incrementAmount, this._value);
|
|
89
99
|
}
|
|
90
100
|
/**
|
|
91
|
-
* Create a summary for the counter
|
|
101
|
+
* Create a summary for the counter.
|
|
102
|
+
*
|
|
103
|
+
* @returns The summary of the current state of the counter.
|
|
92
104
|
*
|
|
93
|
-
* @returns the summary of the current state of the counter
|
|
94
105
|
* @internal
|
|
95
106
|
*/
|
|
96
107
|
summarizeCore(serializer) {
|
|
@@ -103,6 +114,7 @@ export class SharedCounter extends SharedObject {
|
|
|
103
114
|
}
|
|
104
115
|
/**
|
|
105
116
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
117
|
+
*
|
|
106
118
|
* @internal
|
|
107
119
|
*/
|
|
108
120
|
async loadCore(storage) {
|
|
@@ -111,16 +123,18 @@ export class SharedCounter extends SharedObject {
|
|
|
111
123
|
}
|
|
112
124
|
/**
|
|
113
125
|
* Called when the object has disconnected from the delta stream.
|
|
126
|
+
*
|
|
114
127
|
* @internal
|
|
115
128
|
*/
|
|
116
129
|
onDisconnect() { }
|
|
117
130
|
/**
|
|
118
|
-
* Process a counter operation
|
|
131
|
+
* Process a counter operation (op).
|
|
119
132
|
*
|
|
120
|
-
* @param message -
|
|
121
|
-
* @param local -
|
|
133
|
+
* @param message - The message to prepare.
|
|
134
|
+
* @param local - Whether or not the message was sent by the local client.
|
|
122
135
|
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
123
|
-
* For messages from a remote client, this will be undefined
|
|
136
|
+
* For messages from a remote client, this will be `undefined`.
|
|
137
|
+
*
|
|
124
138
|
* @internal
|
|
125
139
|
*/
|
|
126
140
|
processCore(message, local, localOpMetadata) {
|
|
@@ -137,10 +151,11 @@ export class SharedCounter extends SharedObject {
|
|
|
137
151
|
}
|
|
138
152
|
/**
|
|
139
153
|
* Not implemented.
|
|
154
|
+
*
|
|
140
155
|
* @internal
|
|
141
156
|
*/
|
|
142
157
|
applyStashedOp() {
|
|
143
|
-
throw new Error("
|
|
158
|
+
throw new Error("Not implemented");
|
|
144
159
|
}
|
|
145
160
|
}
|
|
146
161
|
//# sourceMappingURL=counter.js.map
|
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,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAO9F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAoB,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAC7G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
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 { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelFactory,\n IChannelAttributes,\n} from \"@fluidframework/datastore-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { createSingleBlobSummary, IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { CounterFactory } from \"./counterFactory\";\nimport { ISharedCounter, ISharedCounterEvents } from \"./interfaces\";\n\n/**\n * Describes the operation (op) format for incrementing the {@link SharedCounter}.\n */\ninterface IIncrementOperation {\n type: \"increment\";\n incrementAmount: number;\n}\n\n/**\n * @remarks Used in snapshotting.\n */\ninterface ICounterSnapshotFormat {\n /**\n * The value of the counter.\n */\n value: number;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * A shared object that holds a number that can be incremented or decremented.\n *\n * @remarks Note that `SharedCounter` only operates on integer values. This is validated at runtime.\n *\n * @example Creating a `SharedCounter`:\n *\n * First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}\n * with a runtime and string ID:\n *\n * ```typescript\n * const factory = SharedCounter.getFactory();\n * const counter = factory.create(this.runtime, id) as SharedCounter;\n * ```\n *\n * The initial value of a new `SharedCounter` is 0.\n * If you wish to initialize the counter to a different value, you may call {@link SharedCounter.increment} before\n * attaching the Container, or before inserting it into an existing shared object.\n *\n * @example Using the `SharedCounter`:\n *\n * Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or\n * negative number:\n *\n * ```typescript\n * counter.increment(10); // add 10 to the counter value\n * counter.increment(-5); // subtract 5 from the counter value\n * ```\n *\n * To observe changes to the value (including those from remote clients), register for the\n * {@link ISharedCounterEvents | incremented} event:\n *\n * ```typescript\n * counter.on(\"incremented\", (incrementAmount, newValue) => {\n * console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);\n * });\n * ```\n *\n * @public\n */\nexport class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {\n /**\n * Create a new {@link SharedCounter}.\n *\n * @param runtime - The data store runtime to which the new `SharedCounter` will belong.\n * @param id - Optional name of the `SharedCounter`. If not provided, one will be generated.\n *\n * @returns newly create shared counter (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCounter {\n return runtime.createChannel(id, CounterFactory.Type) as SharedCounter;\n }\n\n constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {\n super(id, runtime, attributes, \"fluid_counter_\");\n }\n\n /**\n * Get a factory for {@link SharedCounter} to register with the data store.\n *\n * @returns a factory that creates and load SharedCounter\n */\n public static getFactory(): IChannelFactory {\n return new CounterFactory();\n }\n\n private _value: number = 0;\n\n /**\n * {@inheritDoc ISharedCounter.value}\n */\n public get value(): number {\n return this._value;\n }\n\n /**\n * {@inheritDoc ISharedCounter.increment}\n */\n public increment(incrementAmount: number): void {\n // Incrementing by floating point numbers will be eventually inconsistent, since the order in which the\n // increments are applied affects the result. A more-robust solution would be required to support this.\n if (incrementAmount % 1 !== 0) {\n throw new Error(\"Must increment by a whole number\");\n }\n\n const op: IIncrementOperation = {\n type: \"increment\",\n incrementAmount,\n };\n\n this.incrementCore(incrementAmount);\n this.submitLocalMessage(op);\n }\n\n private incrementCore(incrementAmount: number): void {\n this._value += incrementAmount;\n this.emit(\"incremented\", incrementAmount, this._value);\n }\n\n /**\n * Create a summary for the counter.\n *\n * @returns The summary of the current state of the counter.\n *\n * @internal\n */\n protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n // Get a serializable form of data\n const content: ICounterSnapshotFormat = {\n value: this.value,\n };\n\n // And then construct the summary for it\n return createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n *\n * @internal\n */\n protected async loadCore(storage: IChannelStorageService): Promise<void> {\n const content = await readAndParse<ICounterSnapshotFormat>(storage, snapshotFileName);\n\n this._value = content.value;\n }\n\n /**\n * Called when the object has disconnected from the delta stream.\n *\n * @internal\n */\n protected onDisconnect(): void { }\n\n /**\n * Process a counter operation (op).\n *\n * @param message - The message to prepare.\n * @param local - Whether or not the message was sent by the local client.\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be `undefined`.\n *\n * @internal\n */\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n if (message.type === MessageType.Operation && !local) {\n const op = message.contents as IIncrementOperation;\n\n switch (op.type) {\n case \"increment\":\n this.incrementCore(op.incrementAmount);\n break;\n\n default:\n throw new Error(\"Unknown operation\");\n }\n }\n }\n\n /**\n * Not implemented.\n *\n * @internal\n */\n protected applyStashedOp() {\n throw new Error(\"Not implemented\");\n }\n}\n"]}
|
package/lib/counterFactory.d.ts
CHANGED
|
@@ -5,17 +5,34 @@
|
|
|
5
5
|
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelServices, IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
6
|
import { ISharedCounter } from "./interfaces";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.
|
|
9
|
+
*
|
|
10
|
+
* @sealed
|
|
9
11
|
*/
|
|
10
12
|
export declare class CounterFactory implements IChannelFactory {
|
|
13
|
+
/**
|
|
14
|
+
* Static value for {@link CounterFactory."type"}.
|
|
15
|
+
*/
|
|
11
16
|
static readonly Type = "https://graph.microsoft.com/types/counter";
|
|
17
|
+
/**
|
|
18
|
+
* Static value for {@link CounterFactory.attributes}.
|
|
19
|
+
*/
|
|
12
20
|
static readonly Attributes: IChannelAttributes;
|
|
21
|
+
/**
|
|
22
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
23
|
+
*/
|
|
13
24
|
get type(): string;
|
|
25
|
+
/**
|
|
26
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
27
|
+
*/
|
|
14
28
|
get attributes(): IChannelAttributes;
|
|
15
29
|
/**
|
|
16
30
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
17
31
|
*/
|
|
18
32
|
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<ISharedCounter>;
|
|
33
|
+
/**
|
|
34
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
35
|
+
*/
|
|
19
36
|
create(document: IFluidDataStoreRuntime, id: string): ISharedCounter;
|
|
20
37
|
}
|
|
21
38
|
//# sourceMappingURL=counterFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterFactory.d.ts","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C
|
|
1
|
+
{"version":3,"file":"counterFactory.d.ts","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C;;;;GAIG;AACH,qBAAa,cAAe,YAAW,eAAe;IAClD;;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,CACb,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAM5D;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,cAAc;CAK9E"}
|
package/lib/counterFactory.js
CHANGED
|
@@ -5,12 +5,20 @@
|
|
|
5
5
|
import { SharedCounter } from "./counter";
|
|
6
6
|
import { pkgVersion } from "./packageVersion";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.
|
|
9
|
+
*
|
|
10
|
+
* @sealed
|
|
9
11
|
*/
|
|
10
12
|
export class CounterFactory {
|
|
13
|
+
/**
|
|
14
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
15
|
+
*/
|
|
11
16
|
get type() {
|
|
12
17
|
return CounterFactory.Type;
|
|
13
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
21
|
+
*/
|
|
14
22
|
get attributes() {
|
|
15
23
|
return CounterFactory.Attributes;
|
|
16
24
|
}
|
|
@@ -22,13 +30,22 @@ export class CounterFactory {
|
|
|
22
30
|
await counter.load(services);
|
|
23
31
|
return counter;
|
|
24
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
35
|
+
*/
|
|
25
36
|
create(document, id) {
|
|
26
37
|
const counter = new SharedCounter(id, document, this.attributes);
|
|
27
38
|
counter.initializeLocal();
|
|
28
39
|
return counter;
|
|
29
40
|
}
|
|
30
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Static value for {@link CounterFactory."type"}.
|
|
44
|
+
*/
|
|
31
45
|
CounterFactory.Type = "https://graph.microsoft.com/types/counter";
|
|
46
|
+
/**
|
|
47
|
+
* Static value for {@link CounterFactory.attributes}.
|
|
48
|
+
*/
|
|
32
49
|
CounterFactory.Attributes = {
|
|
33
50
|
type: CounterFactory.Type,
|
|
34
51
|
snapshotFormatVersion: "0.1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAevB;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,cAAc,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,cAAc,CAAC,UAAU,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CACb,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAC9B,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC3D,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAgC,EAAE,EAAU;QACtD,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACjE,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IACnB,CAAC;;AAhDD;;GAEG;AACoB,mBAAI,GAAG,2CAA2C,CAAC;AAE1E;;GAEG;AACoB,yBAAU,GAAuB;IACpD,IAAI,EAAE,cAAc,CAAC,IAAI;IACzB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelServices,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedCounter } from \"./counter\";\nimport { ISharedCounter } from \"./interfaces\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.\n *\n * @sealed\n */\nexport class CounterFactory implements IChannelFactory {\n /**\n * Static value for {@link CounterFactory.\"type\"}.\n */\n public static readonly Type = \"https://graph.microsoft.com/types/counter\";\n\n /**\n * Static value for {@link CounterFactory.attributes}.\n */\n public static readonly Attributes: IChannelAttributes = {\n type: CounterFactory.Type,\n snapshotFormatVersion: \"0.1\",\n packageVersion: pkgVersion,\n };\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n */\n public get type(): string {\n return CounterFactory.Type;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public get attributes(): IChannelAttributes {\n return CounterFactory.Attributes;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n */\n public async load(\n runtime: IFluidDataStoreRuntime,\n id: string,\n services: IChannelServices,\n attributes: IChannelAttributes): Promise<ISharedCounter> {\n const counter = new SharedCounter(id, runtime, attributes);\n await counter.load(services);\n return counter;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n */\n public create(document: IFluidDataStoreRuntime, id: string): ISharedCounter {\n const counter = new SharedCounter(id, document, this.attributes);\n counter.initializeLocal();\n return counter;\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* This
|
|
7
|
-
* which holds a number that can be incremented or decremented.
|
|
6
|
+
* This library contains the {@link SharedCounter} distributed data structure.
|
|
7
|
+
* A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.
|
|
8
8
|
*
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
package/lib/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* This
|
|
7
|
-
* which holds a number that can be incremented or decremented.
|
|
6
|
+
* This library contains the {@link SharedCounter} distributed data structure.
|
|
7
|
+
* A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.
|
|
8
8
|
*
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC","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 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 * from \"./counter\";\nexport * from \"./interfaces\";\n"]}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
6
6
|
/**
|
|
7
|
-
* Events sent by
|
|
7
|
+
* Events sent by {@link SharedCounter}.
|
|
8
|
+
*
|
|
8
9
|
* @public
|
|
9
10
|
*/
|
|
10
11
|
export interface ISharedCounterEvents extends ISharedObjectEvents {
|
|
@@ -19,18 +20,22 @@ export interface ISharedCounterEvents extends ISharedObjectEvents {
|
|
|
19
20
|
(event: "incremented", listener: (incrementAmount: number, newValue: number) => void): any;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
|
-
* SharedCounter interface.
|
|
23
|
+
* {@link SharedCounter} interface.
|
|
24
|
+
*
|
|
23
25
|
* @public
|
|
24
26
|
*/
|
|
25
27
|
export interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {
|
|
26
28
|
/**
|
|
27
29
|
* The counter value.
|
|
30
|
+
*
|
|
31
|
+
* @remarks Must be a whole number.
|
|
28
32
|
*/
|
|
29
33
|
value: number;
|
|
30
34
|
/**
|
|
31
|
-
* Increments or decrements the value.
|
|
35
|
+
* Increments or decrements the value.
|
|
36
|
+
* Must only increment or decrement by a whole number value.
|
|
32
37
|
*
|
|
33
|
-
* @param incrementAmount -
|
|
38
|
+
* @param incrementAmount - A whole number to increment or decrement by.
|
|
34
39
|
*/
|
|
35
40
|
increment(incrementAmount: number): void;
|
|
36
41
|
}
|
package/lib/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC7D;;;;;;;OAOG;IACH,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,OAAE;CACzF;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa,CAAC,oBAAoB,CAAC;IACvE;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C"}
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Events sent by
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Events sent by {@link SharedCounter}.\n *\n * @public\n */\nexport interface ISharedCounterEvents extends ISharedObjectEvents {\n /**\n * This event is raised when the counter is incremented or decremented.\n *\n * @param event - The event name.\n * @param listener - An event listener.\n *\n * @eventProperty\n */\n (event: \"incremented\", listener: (incrementAmount: number, newValue: number) => void);\n}\n\n/**\n * {@link SharedCounter} interface.\n *\n * @public\n */\nexport interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {\n /**\n * The counter value.\n *\n * @remarks Must be a whole number.\n */\n value: number;\n\n /**\n * Increments or decrements the value.\n * Must only increment or decrement by a whole number value.\n *\n * @param incrementAmount - A whole number to increment or decrement by.\n */\n increment(incrementAmount: number): void;\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/counter";
|
|
8
|
-
export declare const pkgVersion = "1.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.1.3.0.96595";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,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,0BAA0B,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,uBAAuB,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.1.3.0.96595\";\n"]}
|