@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
@@ -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 { }
package/lib/counter.d.ts CHANGED
@@ -8,42 +8,7 @@ import { type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions"
8
8
  import { type IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
9
9
  import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces";
10
10
  /**
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.
14
- *
15
- * @example Creating a `SharedCounter`
16
- *
17
- * First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}
18
- * with a runtime and string ID:
19
- *
20
- * ```typescript
21
- * const factory = SharedCounter.getFactory();
22
- * const counter = factory.create(this.runtime, id) as SharedCounter;
23
- * ```
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`
30
- *
31
- * Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or
32
- * negative number:
33
- *
34
- * ```typescript
35
- * counter.increment(10); // add 10 to the counter value
36
- * counter.increment(-5); // subtract 5 from the counter value
37
- * ```
38
- *
39
- * To observe changes to the value (including those from remote clients), register for the
40
- * {@link ISharedCounterEvents | incremented} event:
41
- *
42
- * ```typescript
43
- * counter.on("incremented", (incrementAmount, newValue) => {
44
- * console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);
45
- * });
46
- * ```
11
+ * {@inheritDoc ISharedCounter}
47
12
  *
48
13
  * @public
49
14
  */
@@ -78,20 +43,14 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
78
43
  * Create a summary for the counter.
79
44
  *
80
45
  * @returns The summary of the current state of the counter.
81
- *
82
- * @internal
83
46
  */
84
47
  protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
85
48
  /**
86
49
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
87
- *
88
- * @internal
89
50
  */
90
51
  protected loadCore(storage: IChannelStorageService): Promise<void>;
91
52
  /**
92
53
  * Called when the object has disconnected from the delta stream.
93
- *
94
- * @internal
95
54
  */
96
55
  protected onDisconnect(): void;
97
56
  /**
@@ -101,13 +60,10 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
101
60
  * @param local - Whether or not the message was sent by the local client.
102
61
  * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
103
62
  * For messages from a remote client, this will be `undefined`.
104
- *
105
- * @internal
106
63
  */
107
64
  protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
108
65
  /**
109
66
  * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
110
- * @internal
111
67
  */
112
68
  protected applyStashedOp(op: unknown): void;
113
69
  }
@@ -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,cAAc,CAAC;AAsB9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,aAAc,SAAQ,YAAY,CAAC,oBAAoB,CAAE,YAAW,cAAc;IAC9F;;;;;;;OAOG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa;gBAKhF,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,kBAAkB;IAK/B;;;;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,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAkBP;;;OAGG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI;CAU3C"}
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,cAAc,CAAC;AAsB9E;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,YAAY,CAAC,oBAAoB,CAAE,YAAW,cAAc;IAC9F;;;;;;;OAOG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa;gBAKhF,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,kBAAkB;IAK/B;;;;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;;;;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"}
@@ -6,45 +6,10 @@ import { assert } from "@fluidframework/core-utils";
6
6
  import { MessageType } from "@fluidframework/protocol-definitions";
7
7
  import { readAndParse } from "@fluidframework/driver-utils";
8
8
  import { createSingleBlobSummary, SharedObject, } from "@fluidframework/shared-object-base";
9
- import { CounterFactory } from "./counterFactory";
9
+ import { CounterFactory } from "./counterFactory.mjs";
10
10
  const snapshotFileName = "header";
11
11
  /**
12
- * A shared object that holds a number that can be incremented or decremented.
13
- *
14
- * @remarks Note that `SharedCounter` only operates on integer values. This is validated at runtime.
15
- *
16
- * @example Creating a `SharedCounter`
17
- *
18
- * First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}
19
- * with a runtime and string ID:
20
- *
21
- * ```typescript
22
- * const factory = SharedCounter.getFactory();
23
- * const counter = factory.create(this.runtime, id) as SharedCounter;
24
- * ```
25
- *
26
- * The initial value of a new `SharedCounter` is 0.
27
- * If you wish to initialize the counter to a different value, you may call {@link SharedCounter.increment} before
28
- * attaching the Container, or before inserting it into an existing shared object.
29
- *
30
- * @example Using the `SharedCounter`
31
- *
32
- * Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or
33
- * negative number:
34
- *
35
- * ```typescript
36
- * counter.increment(10); // add 10 to the counter value
37
- * counter.increment(-5); // subtract 5 from the counter value
38
- * ```
39
- *
40
- * To observe changes to the value (including those from remote clients), register for the
41
- * {@link ISharedCounterEvents | incremented} event:
42
- *
43
- * ```typescript
44
- * counter.on("incremented", (incrementAmount, newValue) => {
45
- * console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);
46
- * });
47
- * ```
12
+ * {@inheritDoc ISharedCounter}
48
13
  *
49
14
  * @public
50
15
  */
@@ -102,8 +67,6 @@ export class SharedCounter extends SharedObject {
102
67
  * Create a summary for the counter.
103
68
  *
104
69
  * @returns The summary of the current state of the counter.
105
- *
106
- * @internal
107
70
  */
108
71
  summarizeCore(serializer) {
109
72
  // Get a serializable form of data
@@ -115,8 +78,6 @@ export class SharedCounter extends SharedObject {
115
78
  }
116
79
  /**
117
80
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
118
- *
119
- * @internal
120
81
  */
121
82
  async loadCore(storage) {
122
83
  const content = await readAndParse(storage, snapshotFileName);
@@ -124,8 +85,6 @@ export class SharedCounter extends SharedObject {
124
85
  }
125
86
  /**
126
87
  * Called when the object has disconnected from the delta stream.
127
- *
128
- * @internal
129
88
  */
130
89
  onDisconnect() { }
131
90
  /**
@@ -135,8 +94,6 @@ export class SharedCounter extends SharedObject {
135
94
  * @param local - Whether or not the message was sent by the local client.
136
95
  * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
137
96
  * For messages from a remote client, this will be `undefined`.
138
- *
139
- * @internal
140
97
  */
141
98
  processCore(message, local, localOpMetadata) {
142
99
  // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
@@ -155,7 +112,6 @@ export class SharedCounter extends SharedObject {
155
112
  }
156
113
  /**
157
114
  * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
158
- * @internal
159
115
  */
160
116
  applyStashedOp(op) {
161
117
  const counterOp = op;
@@ -165,4 +121,4 @@ export class SharedCounter extends SharedObject {
165
121
  this.incrementCore(counterOp.incrementAmount);
166
122
  }
167
123
  }
168
- //# sourceMappingURL=counter.js.map
124
+ //# sourceMappingURL=counter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"counter.mjs","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\";\nimport { type ISharedCounter, type ISharedCounterEvents } from \"./interfaces\";\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 *\n * @public\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): SharedCounter {\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 {\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.incrementCore(counterOp.incrementAmount);\n\t}\n}\n"]}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { SharedCounter } from "./counter";
6
- import { pkgVersion } from "./packageVersion";
5
+ import { SharedCounter } from "./counter.mjs";
6
+ import { pkgVersion } from "./packageVersion.mjs";
7
7
  /**
8
8
  * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.
9
9
  *
@@ -51,4 +51,4 @@ CounterFactory.Attributes = {
51
51
  snapshotFormatVersion: "0.1",
52
52
  packageVersion: pkgVersion,
53
53
  };
54
- //# sourceMappingURL=counterFactory.js.map
54
+ //# sourceMappingURL=counterFactory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"counterFactory.mjs","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAQI,EAAE,aAAa,EAAE;OAEjB,EAAE,UAAU,EAAE;AAErB;;;;GAIG;AACH,MAAM,OAAO,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,aAAa,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,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACjE,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IAChB,CAAC;;AAjDD;;GAEG;AACoB,mBAAI,GAAG,2CAA2C,CAAC;AAE1E;;GAEG;AACoB,yBAAU,GAAuB;IACvD,IAAI,EAAE,cAAc,CAAC,IAAI;IACzB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;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\";\nimport { type 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\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/lib/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  /**
6
- * This library contains the {@link SharedCounter} distributed data structure.
6
+ * This library contains the {@link ISharedCounter | SharedCounter} distributed data structure.
7
7
  * A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.
8
8
  *
9
9
  * @packageDocumentation
package/lib/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { SharedCounter } from "./counter.mjs";
6
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OASI,EAAE,aAAa,EAAE","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\";\nexport type { ISharedCounter, ISharedCounterEvents } from \"./interfaces\";\n"]}
@@ -20,7 +20,42 @@ export interface ISharedCounterEvents extends ISharedObjectEvents {
20
20
  (event: "incremented", listener: (incrementAmount: number, newValue: number) => void): any;
21
21
  }
22
22
  /**
23
- * {@link SharedCounter} interface.
23
+ * A shared object that holds a number that can be incremented or decremented.
24
+ *
25
+ * @remarks Note that `SharedCounter` only operates on integer values. This is validated at runtime.
26
+ *
27
+ * @example Creating a `SharedCounter`
28
+ *
29
+ * First, get the factory and call {@link @fluidframework/datastore-definitions#IChannelFactory.create}
30
+ * with a runtime and string ID:
31
+ *
32
+ * ```typescript
33
+ * const factory = SharedCounter.getFactory();
34
+ * const counter = factory.create(this.runtime, id) as SharedCounter;
35
+ * ```
36
+ *
37
+ * The initial value of a new `SharedCounter` is 0.
38
+ * If you wish to initialize the counter to a different value, you may call {@link SharedCounter.increment} before
39
+ * attaching the Container, or before inserting it into an existing shared object.
40
+ *
41
+ * @example Using the `SharedCounter`
42
+ *
43
+ * Once created, you can call {@link SharedCounter.increment} to modify the value with either a positive or
44
+ * negative number:
45
+ *
46
+ * ```typescript
47
+ * counter.increment(10); // add 10 to the counter value
48
+ * counter.increment(-5); // subtract 5 from the counter value
49
+ * ```
50
+ *
51
+ * To observe changes to the value (including those from remote clients), register for the
52
+ * {@link ISharedCounterEvents | incremented} event:
53
+ *
54
+ * ```typescript
55
+ * counter.on("incremented", (incrementAmount, newValue) => {
56
+ * console.log(`The counter incremented by ${incrementAmount} and now has a value of ${newValue}`);
57
+ * });
58
+ * ```
24
59
  *
25
60
  * @public
26
61
  */
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAElG;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAChE;;;;;;;OAOG;IACH,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,OAAE;CACtF;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa,CAAC,oBAAoB,CAAC;IAC1E;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAElG;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAChE;;;;;;;OAOG;IACH,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,OAAE;CACtF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa,CAAC,oBAAoB,CAAC;IAC1E;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC"}
@@ -3,4 +3,4 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=interfaces.js.map
6
+ //# sourceMappingURL=interfaces.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.mjs","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 { type ISharedObject, type ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Events sent by {@link SharedCounter}.\n *\n * @public\n */\nexport interface ISharedCounterEvents extends ISharedObjectEvents {\n\t/**\n\t * This event is raised when the counter is incremented or decremented.\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"incremented\", listener: (incrementAmount: number, newValue: number) => void);\n}\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 interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {\n\t/**\n\t * The counter value.\n\t *\n\t * @remarks Must be a whole number.\n\t */\n\tvalue: number;\n\n\t/**\n\t * Increments or decrements the value.\n\t * Must only increment or decrement by a whole number value.\n\t *\n\t * @param incrementAmount - A whole number to increment or decrement by.\n\t */\n\tincrement(incrementAmount: number): void;\n}\n"]}
@@ -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-internal.7.2.2";
8
+ export declare const pkgVersion = "2.0.0-internal.7.3.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/counter";
8
- export const pkgVersion = "2.0.0-internal.7.2.2";
9
- //# sourceMappingURL=packageVersion.js.map
8
+ export const pkgVersion = "2.0.0-internal.7.3.0";
9
+ //# sourceMappingURL=packageVersion.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersion.mjs","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,yBAAyB,CAAC;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,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-internal.7.3.0\";\n"]}