@fluidframework/counter 2.0.0-internal.7.2.2 → 2.0.0-internal.7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -2
  3. package/api-extractor.json +2 -8
  4. package/api-report/counter.api.md +2 -5
  5. package/dist/counter-alpha.d.ts +153 -0
  6. package/dist/counter-beta.d.ts +153 -0
  7. package/dist/counter-public.d.ts +153 -0
  8. package/dist/counter-untrimmed.d.ts +153 -0
  9. package/dist/{counter.js → counter.cjs} +3 -47
  10. package/dist/counter.cjs.map +1 -0
  11. package/dist/counter.d.ts +1 -45
  12. package/dist/counter.d.ts.map +1 -1
  13. package/dist/{counterFactory.js → counterFactory.cjs} +3 -3
  14. package/dist/counterFactory.cjs.map +1 -0
  15. package/dist/{index.js → index.cjs} +3 -3
  16. package/dist/index.cjs.map +1 -0
  17. package/dist/index.d.ts +1 -1
  18. package/dist/{interfaces.js → interfaces.cjs} +1 -1
  19. package/dist/interfaces.cjs.map +1 -0
  20. package/dist/interfaces.d.ts +36 -1
  21. package/dist/interfaces.d.ts.map +1 -1
  22. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  23. package/dist/packageVersion.cjs.map +1 -0
  24. package/dist/packageVersion.d.ts +1 -1
  25. package/dist/tsdoc-metadata.json +1 -1
  26. package/lib/counter-alpha.d.ts +153 -0
  27. package/lib/counter-beta.d.ts +153 -0
  28. package/lib/counter-public.d.ts +153 -0
  29. package/lib/counter-untrimmed.d.ts +153 -0
  30. package/lib/counter.d.ts +1 -45
  31. package/lib/counter.d.ts.map +1 -1
  32. package/lib/{counter.js → counter.mjs} +3 -47
  33. package/lib/counter.mjs.map +1 -0
  34. package/lib/{counterFactory.js → counterFactory.mjs} +3 -3
  35. package/lib/counterFactory.mjs.map +1 -0
  36. package/lib/index.d.ts +1 -1
  37. package/lib/index.mjs +6 -0
  38. package/lib/index.mjs.map +1 -0
  39. package/lib/interfaces.d.ts +36 -1
  40. package/lib/interfaces.d.ts.map +1 -1
  41. package/lib/{interfaces.js → interfaces.mjs} +1 -1
  42. package/lib/interfaces.mjs.map +1 -0
  43. package/lib/packageVersion.d.ts +1 -1
  44. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  45. package/lib/packageVersion.mjs.map +1 -0
  46. package/package.json +51 -22
  47. package/src/counter.ts +1 -45
  48. package/src/index.ts +1 -1
  49. package/src/interfaces.ts +36 -1
  50. package/src/packageVersion.ts +1 -1
  51. package/tsc-multi.test.json +4 -0
  52. package/tsconfig.json +5 -3
  53. package/dist/counter.js.map +0 -1
  54. package/dist/counterFactory.js.map +0 -1
  55. package/dist/index.js.map +0 -1
  56. package/dist/interfaces.js.map +0 -1
  57. package/dist/packageVersion.js.map +0 -1
  58. package/lib/counter.js.map +0 -1
  59. package/lib/counterFactory.js.map +0 -1
  60. package/lib/index.js +0 -12
  61. package/lib/index.js.map +0 -1
  62. package/lib/interfaces.js.map +0 -1
  63. package/lib/packageVersion.js.map +0 -1
  64. package/tsconfig.esnext.json +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/counter
2
2
 
3
+ ## 2.0.0-internal.7.3.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-internal.7.2.0
4
8
 
5
9
  Dependency updates only.
package/README.md CHANGED
@@ -182,8 +182,7 @@ API documentation for **@fluidframework/counter** is available at <https://fluid
182
182
 
183
183
  This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
184
184
 
185
- Use of these trademarks or logos must follow Microsoft's [Trademark & Brand
186
- Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
185
+ Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
187
186
 
188
187
  Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
189
188
 
@@ -1,13 +1,7 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
3
  "extends": "@fluidframework/build-common/api-extractor-base.json",
4
-
5
- // TODO: Fix violations and remove these rule overrides
6
- "messages": {
7
- "extractorMessageReporting": {
8
- "ae-forgotten-export": {
9
- "logLevel": "none"
10
- }
11
- }
4
+ "dtsRollup": {
5
+ "enabled": true
12
6
  }
13
7
  }
@@ -30,18 +30,15 @@ export interface ISharedCounterEvents extends ISharedObjectEvents {
30
30
  // @public
31
31
  export class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {
32
32
  constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
33
- // @internal (undocumented)
33
+ // (undocumented)
34
34
  protected applyStashedOp(op: unknown): void;
35
35
  static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCounter;
36
36
  static getFactory(): IChannelFactory;
37
37
  increment(incrementAmount: number): void;
38
- // @internal (undocumented)
38
+ // (undocumented)
39
39
  protected loadCore(storage: IChannelStorageService): Promise<void>;
40
- // @internal
41
40
  protected onDisconnect(): void;
42
- // @internal
43
41
  protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
44
- // @internal
45
42
  protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
46
43
  get value(): number;
47
44
  }
@@ -0,0 +1,153 @@
1
+ /**
2
+ * This library contains the {@link ISharedCounter | SharedCounter} distributed data structure.
3
+ * A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
9
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
11
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
13
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
14
+ import { ISharedObject } from '@fluidframework/shared-object-base';
15
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
+ import { SharedObject } from '@fluidframework/shared-object-base';
18
+
19
+ /**
20
+ * A shared object that holds a number that can be incremented or decremented.
21
+ *
22
+ * @remarks Note that `SharedCounter` only operates on integer values. This is validated at runtime.
23
+ *
24
+ * @example Creating a `SharedCounter`
25
+ *
26
+ * First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}
27
+ * with a runtime and string ID:
28
+ *
29
+ * ```typescript
30
+ * const factory = SharedCounter.getFactory();
31
+ * const counter = factory.create(this.runtime, id) as SharedCounter;
32
+ * ```
33
+ *
34
+ * The initial value of a new `SharedCounter` is 0.
35
+ * If you wish to initialize the counter to a different value, you may call {@link SharedCounter.increment} before
36
+ * attaching the Container, or before inserting it into an existing shared object.
37
+ *
38
+ * @example Using the `SharedCounter`
39
+ *
40
+ * Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or
41
+ * negative number:
42
+ *
43
+ * ```typescript
44
+ * counter.increment(10); // add 10 to the counter value
45
+ * counter.increment(-5); // subtract 5 from the counter value
46
+ * ```
47
+ *
48
+ * To observe changes to the value (including those from remote clients), register for the
49
+ * {@link ISharedCounterEvents | incremented} event:
50
+ *
51
+ * ```typescript
52
+ * counter.on("incremented", (incrementAmount, newValue) => {
53
+ * console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);
54
+ * });
55
+ * ```
56
+ *
57
+ * @public
58
+ */
59
+ export declare interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {
60
+ /**
61
+ * The counter value.
62
+ *
63
+ * @remarks Must be a whole number.
64
+ */
65
+ value: number;
66
+ /**
67
+ * Increments or decrements the value.
68
+ * Must only increment or decrement by a whole number value.
69
+ *
70
+ * @param incrementAmount - A whole number to increment or decrement by.
71
+ */
72
+ increment(incrementAmount: number): void;
73
+ }
74
+
75
+ /**
76
+ * Events sent by {@link SharedCounter}.
77
+ *
78
+ * @public
79
+ */
80
+ export declare interface ISharedCounterEvents extends ISharedObjectEvents {
81
+ /**
82
+ * This event is raised when the counter is incremented or decremented.
83
+ *
84
+ * @param event - The event name.
85
+ * @param listener - An event listener.
86
+ *
87
+ * @eventProperty
88
+ */
89
+ (event: "incremented", listener: (incrementAmount: number, newValue: number) => void): any;
90
+ }
91
+
92
+ /**
93
+ * {@inheritDoc ISharedCounter}
94
+ *
95
+ * @public
96
+ */
97
+ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {
98
+ /**
99
+ * Create a new {@link SharedCounter}.
100
+ *
101
+ * @param runtime - The data store runtime to which the new `SharedCounter` will belong.
102
+ * @param id - Optional name of the `SharedCounter`. If not provided, one will be generated.
103
+ *
104
+ * @returns newly create shared counter (but not attached yet)
105
+ */
106
+ static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCounter;
107
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
108
+ /**
109
+ * Get a factory for {@link SharedCounter} to register with the data store.
110
+ *
111
+ * @returns a factory that creates and load SharedCounter
112
+ */
113
+ static getFactory(): IChannelFactory;
114
+ private _value;
115
+ /**
116
+ * {@inheritDoc ISharedCounter.value}
117
+ */
118
+ get value(): number;
119
+ /**
120
+ * {@inheritDoc ISharedCounter.increment}
121
+ */
122
+ increment(incrementAmount: number): void;
123
+ private incrementCore;
124
+ /**
125
+ * Create a summary for the counter.
126
+ *
127
+ * @returns The summary of the current state of the counter.
128
+ */
129
+ protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
130
+ /**
131
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
132
+ */
133
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
134
+ /**
135
+ * Called when the object has disconnected from the delta stream.
136
+ */
137
+ protected onDisconnect(): void;
138
+ /**
139
+ * Process a counter operation (op).
140
+ *
141
+ * @param message - The message to prepare.
142
+ * @param local - Whether or not the message was sent by the local client.
143
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
144
+ * For messages from a remote client, this will be `undefined`.
145
+ */
146
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
147
+ /**
148
+ * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
149
+ */
150
+ protected applyStashedOp(op: unknown): void;
151
+ }
152
+
153
+ export { }
@@ -0,0 +1,153 @@
1
+ /**
2
+ * This library contains the {@link ISharedCounter | SharedCounter} distributed data structure.
3
+ * A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
9
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
11
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
13
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
14
+ import { ISharedObject } from '@fluidframework/shared-object-base';
15
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
+ import { SharedObject } from '@fluidframework/shared-object-base';
18
+
19
+ /**
20
+ * A shared object that holds a number that can be incremented or decremented.
21
+ *
22
+ * @remarks Note that `SharedCounter` only operates on integer values. This is validated at runtime.
23
+ *
24
+ * @example Creating a `SharedCounter`
25
+ *
26
+ * First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}
27
+ * with a runtime and string ID:
28
+ *
29
+ * ```typescript
30
+ * const factory = SharedCounter.getFactory();
31
+ * const counter = factory.create(this.runtime, id) as SharedCounter;
32
+ * ```
33
+ *
34
+ * The initial value of a new `SharedCounter` is 0.
35
+ * If you wish to initialize the counter to a different value, you may call {@link SharedCounter.increment} before
36
+ * attaching the Container, or before inserting it into an existing shared object.
37
+ *
38
+ * @example Using the `SharedCounter`
39
+ *
40
+ * Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or
41
+ * negative number:
42
+ *
43
+ * ```typescript
44
+ * counter.increment(10); // add 10 to the counter value
45
+ * counter.increment(-5); // subtract 5 from the counter value
46
+ * ```
47
+ *
48
+ * To observe changes to the value (including those from remote clients), register for the
49
+ * {@link ISharedCounterEvents | incremented} event:
50
+ *
51
+ * ```typescript
52
+ * counter.on("incremented", (incrementAmount, newValue) => {
53
+ * console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);
54
+ * });
55
+ * ```
56
+ *
57
+ * @public
58
+ */
59
+ export declare interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {
60
+ /**
61
+ * The counter value.
62
+ *
63
+ * @remarks Must be a whole number.
64
+ */
65
+ value: number;
66
+ /**
67
+ * Increments or decrements the value.
68
+ * Must only increment or decrement by a whole number value.
69
+ *
70
+ * @param incrementAmount - A whole number to increment or decrement by.
71
+ */
72
+ increment(incrementAmount: number): void;
73
+ }
74
+
75
+ /**
76
+ * Events sent by {@link SharedCounter}.
77
+ *
78
+ * @public
79
+ */
80
+ export declare interface ISharedCounterEvents extends ISharedObjectEvents {
81
+ /**
82
+ * This event is raised when the counter is incremented or decremented.
83
+ *
84
+ * @param event - The event name.
85
+ * @param listener - An event listener.
86
+ *
87
+ * @eventProperty
88
+ */
89
+ (event: "incremented", listener: (incrementAmount: number, newValue: number) => void): any;
90
+ }
91
+
92
+ /**
93
+ * {@inheritDoc ISharedCounter}
94
+ *
95
+ * @public
96
+ */
97
+ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {
98
+ /**
99
+ * Create a new {@link SharedCounter}.
100
+ *
101
+ * @param runtime - The data store runtime to which the new `SharedCounter` will belong.
102
+ * @param id - Optional name of the `SharedCounter`. If not provided, one will be generated.
103
+ *
104
+ * @returns newly create shared counter (but not attached yet)
105
+ */
106
+ static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCounter;
107
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
108
+ /**
109
+ * Get a factory for {@link SharedCounter} to register with the data store.
110
+ *
111
+ * @returns a factory that creates and load SharedCounter
112
+ */
113
+ static getFactory(): IChannelFactory;
114
+ private _value;
115
+ /**
116
+ * {@inheritDoc ISharedCounter.value}
117
+ */
118
+ get value(): number;
119
+ /**
120
+ * {@inheritDoc ISharedCounter.increment}
121
+ */
122
+ increment(incrementAmount: number): void;
123
+ private incrementCore;
124
+ /**
125
+ * Create a summary for the counter.
126
+ *
127
+ * @returns The summary of the current state of the counter.
128
+ */
129
+ protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
130
+ /**
131
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
132
+ */
133
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
134
+ /**
135
+ * Called when the object has disconnected from the delta stream.
136
+ */
137
+ protected onDisconnect(): void;
138
+ /**
139
+ * Process a counter operation (op).
140
+ *
141
+ * @param message - The message to prepare.
142
+ * @param local - Whether or not the message was sent by the local client.
143
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
144
+ * For messages from a remote client, this will be `undefined`.
145
+ */
146
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
147
+ /**
148
+ * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
149
+ */
150
+ protected applyStashedOp(op: unknown): void;
151
+ }
152
+
153
+ export { }
@@ -0,0 +1,153 @@
1
+ /**
2
+ * This library contains the {@link ISharedCounter | SharedCounter} distributed data structure.
3
+ * A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
9
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
11
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
13
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
14
+ import { ISharedObject } from '@fluidframework/shared-object-base';
15
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
+ import { SharedObject } from '@fluidframework/shared-object-base';
18
+
19
+ /**
20
+ * A shared object that holds a number that can be incremented or decremented.
21
+ *
22
+ * @remarks Note that `SharedCounter` only operates on integer values. This is validated at runtime.
23
+ *
24
+ * @example Creating a `SharedCounter`
25
+ *
26
+ * First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}
27
+ * with a runtime and string ID:
28
+ *
29
+ * ```typescript
30
+ * const factory = SharedCounter.getFactory();
31
+ * const counter = factory.create(this.runtime, id) as SharedCounter;
32
+ * ```
33
+ *
34
+ * The initial value of a new `SharedCounter` is 0.
35
+ * If you wish to initialize the counter to a different value, you may call {@link SharedCounter.increment} before
36
+ * attaching the Container, or before inserting it into an existing shared object.
37
+ *
38
+ * @example Using the `SharedCounter`
39
+ *
40
+ * Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or
41
+ * negative number:
42
+ *
43
+ * ```typescript
44
+ * counter.increment(10); // add 10 to the counter value
45
+ * counter.increment(-5); // subtract 5 from the counter value
46
+ * ```
47
+ *
48
+ * To observe changes to the value (including those from remote clients), register for the
49
+ * {@link ISharedCounterEvents | incremented} event:
50
+ *
51
+ * ```typescript
52
+ * counter.on("incremented", (incrementAmount, newValue) => {
53
+ * console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);
54
+ * });
55
+ * ```
56
+ *
57
+ * @public
58
+ */
59
+ export declare interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {
60
+ /**
61
+ * The counter value.
62
+ *
63
+ * @remarks Must be a whole number.
64
+ */
65
+ value: number;
66
+ /**
67
+ * Increments or decrements the value.
68
+ * Must only increment or decrement by a whole number value.
69
+ *
70
+ * @param incrementAmount - A whole number to increment or decrement by.
71
+ */
72
+ increment(incrementAmount: number): void;
73
+ }
74
+
75
+ /**
76
+ * Events sent by {@link SharedCounter}.
77
+ *
78
+ * @public
79
+ */
80
+ export declare interface ISharedCounterEvents extends ISharedObjectEvents {
81
+ /**
82
+ * This event is raised when the counter is incremented or decremented.
83
+ *
84
+ * @param event - The event name.
85
+ * @param listener - An event listener.
86
+ *
87
+ * @eventProperty
88
+ */
89
+ (event: "incremented", listener: (incrementAmount: number, newValue: number) => void): any;
90
+ }
91
+
92
+ /**
93
+ * {@inheritDoc ISharedCounter}
94
+ *
95
+ * @public
96
+ */
97
+ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {
98
+ /**
99
+ * Create a new {@link SharedCounter}.
100
+ *
101
+ * @param runtime - The data store runtime to which the new `SharedCounter` will belong.
102
+ * @param id - Optional name of the `SharedCounter`. If not provided, one will be generated.
103
+ *
104
+ * @returns newly create shared counter (but not attached yet)
105
+ */
106
+ static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCounter;
107
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
108
+ /**
109
+ * Get a factory for {@link SharedCounter} to register with the data store.
110
+ *
111
+ * @returns a factory that creates and load SharedCounter
112
+ */
113
+ static getFactory(): IChannelFactory;
114
+ private _value;
115
+ /**
116
+ * {@inheritDoc ISharedCounter.value}
117
+ */
118
+ get value(): number;
119
+ /**
120
+ * {@inheritDoc ISharedCounter.increment}
121
+ */
122
+ increment(incrementAmount: number): void;
123
+ private incrementCore;
124
+ /**
125
+ * Create a summary for the counter.
126
+ *
127
+ * @returns The summary of the current state of the counter.
128
+ */
129
+ protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
130
+ /**
131
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
132
+ */
133
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
134
+ /**
135
+ * Called when the object has disconnected from the delta stream.
136
+ */
137
+ protected onDisconnect(): void;
138
+ /**
139
+ * Process a counter operation (op).
140
+ *
141
+ * @param message - The message to prepare.
142
+ * @param local - Whether or not the message was sent by the local client.
143
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
144
+ * For messages from a remote client, this will be `undefined`.
145
+ */
146
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
147
+ /**
148
+ * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
149
+ */
150
+ protected applyStashedOp(op: unknown): void;
151
+ }
152
+
153
+ export { }
@@ -0,0 +1,153 @@
1
+ /**
2
+ * This library contains the {@link ISharedCounter | SharedCounter} distributed data structure.
3
+ * A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
9
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
11
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
13
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
14
+ import { ISharedObject } from '@fluidframework/shared-object-base';
15
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
+ import { SharedObject } from '@fluidframework/shared-object-base';
18
+
19
+ /**
20
+ * A shared object that holds a number that can be incremented or decremented.
21
+ *
22
+ * @remarks Note that `SharedCounter` only operates on integer values. This is validated at runtime.
23
+ *
24
+ * @example Creating a `SharedCounter`
25
+ *
26
+ * First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}
27
+ * with a runtime and string ID:
28
+ *
29
+ * ```typescript
30
+ * const factory = SharedCounter.getFactory();
31
+ * const counter = factory.create(this.runtime, id) as SharedCounter;
32
+ * ```
33
+ *
34
+ * The initial value of a new `SharedCounter` is 0.
35
+ * If you wish to initialize the counter to a different value, you may call {@link SharedCounter.increment} before
36
+ * attaching the Container, or before inserting it into an existing shared object.
37
+ *
38
+ * @example Using the `SharedCounter`
39
+ *
40
+ * Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or
41
+ * negative number:
42
+ *
43
+ * ```typescript
44
+ * counter.increment(10); // add 10 to the counter value
45
+ * counter.increment(-5); // subtract 5 from the counter value
46
+ * ```
47
+ *
48
+ * To observe changes to the value (including those from remote clients), register for the
49
+ * {@link ISharedCounterEvents | incremented} event:
50
+ *
51
+ * ```typescript
52
+ * counter.on("incremented", (incrementAmount, newValue) => {
53
+ * console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);
54
+ * });
55
+ * ```
56
+ *
57
+ * @public
58
+ */
59
+ export declare interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {
60
+ /**
61
+ * The counter value.
62
+ *
63
+ * @remarks Must be a whole number.
64
+ */
65
+ value: number;
66
+ /**
67
+ * Increments or decrements the value.
68
+ * Must only increment or decrement by a whole number value.
69
+ *
70
+ * @param incrementAmount - A whole number to increment or decrement by.
71
+ */
72
+ increment(incrementAmount: number): void;
73
+ }
74
+
75
+ /**
76
+ * Events sent by {@link SharedCounter}.
77
+ *
78
+ * @public
79
+ */
80
+ export declare interface ISharedCounterEvents extends ISharedObjectEvents {
81
+ /**
82
+ * This event is raised when the counter is incremented or decremented.
83
+ *
84
+ * @param event - The event name.
85
+ * @param listener - An event listener.
86
+ *
87
+ * @eventProperty
88
+ */
89
+ (event: "incremented", listener: (incrementAmount: number, newValue: number) => void): any;
90
+ }
91
+
92
+ /**
93
+ * {@inheritDoc ISharedCounter}
94
+ *
95
+ * @public
96
+ */
97
+ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {
98
+ /**
99
+ * Create a new {@link SharedCounter}.
100
+ *
101
+ * @param runtime - The data store runtime to which the new `SharedCounter` will belong.
102
+ * @param id - Optional name of the `SharedCounter`. If not provided, one will be generated.
103
+ *
104
+ * @returns newly create shared counter (but not attached yet)
105
+ */
106
+ static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCounter;
107
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
108
+ /**
109
+ * Get a factory for {@link SharedCounter} to register with the data store.
110
+ *
111
+ * @returns a factory that creates and load SharedCounter
112
+ */
113
+ static getFactory(): IChannelFactory;
114
+ private _value;
115
+ /**
116
+ * {@inheritDoc ISharedCounter.value}
117
+ */
118
+ get value(): number;
119
+ /**
120
+ * {@inheritDoc ISharedCounter.increment}
121
+ */
122
+ increment(incrementAmount: number): void;
123
+ private incrementCore;
124
+ /**
125
+ * Create a summary for the counter.
126
+ *
127
+ * @returns The summary of the current state of the counter.
128
+ */
129
+ protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
130
+ /**
131
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
132
+ */
133
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
134
+ /**
135
+ * Called when the object has disconnected from the delta stream.
136
+ */
137
+ protected onDisconnect(): void;
138
+ /**
139
+ * Process a counter operation (op).
140
+ *
141
+ * @param message - The message to prepare.
142
+ * @param local - Whether or not the message was sent by the local client.
143
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
144
+ * For messages from a remote client, this will be `undefined`.
145
+ */
146
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
147
+ /**
148
+ * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
149
+ */
150
+ protected applyStashedOp(op: unknown): void;
151
+ }
152
+
153
+ export { }