@fluidframework/counter 2.0.0-dev-rc.1.0.0.232845 → 2.0.0-dev-rc.2.0.0.246488

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 (74) hide show
  1. package/{.mocharc.js → .mocharc.cjs} +1 -1
  2. package/CHANGELOG.md +8 -0
  3. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  4. package/api-extractor-lint.json +1 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/counter.api.md +2 -4
  7. package/dist/counter-alpha.d.ts +2 -2
  8. package/dist/counter-beta.d.ts +2 -0
  9. package/dist/counter-public.d.ts +2 -0
  10. package/dist/counter-untrimmed.d.ts +2 -2
  11. package/dist/counter.d.ts +3 -3
  12. package/dist/counter.d.ts.map +1 -1
  13. package/dist/counter.js +4 -4
  14. package/dist/counter.js.map +1 -1
  15. package/dist/counterFactory.d.ts +2 -2
  16. package/dist/counterFactory.d.ts.map +1 -1
  17. package/dist/counterFactory.js +5 -5
  18. package/dist/counterFactory.js.map +1 -1
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +2 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/package.json +3 -0
  24. package/dist/packageVersion.d.ts +1 -1
  25. package/dist/packageVersion.js +1 -1
  26. package/dist/packageVersion.js.map +1 -1
  27. package/dist/tsdoc-metadata.json +1 -1
  28. package/lib/{counter-untrimmed.d.mts → counter-alpha.d.ts} +9 -2
  29. package/lib/{counter-public.d.mts → counter-beta.d.ts} +9 -0
  30. package/lib/{counter-beta.d.mts → counter-public.d.ts} +9 -0
  31. package/lib/{counter-alpha.d.mts → counter-untrimmed.d.ts} +9 -2
  32. package/lib/{counter.d.mts → counter.d.ts} +4 -4
  33. package/lib/counter.d.ts.map +1 -0
  34. package/lib/{counter.mjs → counter.js} +3 -3
  35. package/lib/counter.js.map +1 -0
  36. package/lib/{counterFactory.d.mts → counterFactory.d.ts} +3 -3
  37. package/lib/counterFactory.d.ts.map +1 -0
  38. package/lib/{counterFactory.mjs → counterFactory.js} +3 -3
  39. package/lib/counterFactory.js.map +1 -0
  40. package/lib/index.d.ts +13 -0
  41. package/lib/index.d.ts.map +1 -0
  42. package/lib/index.js +12 -0
  43. package/lib/index.js.map +1 -0
  44. package/lib/{interfaces.d.mts → interfaces.d.ts} +1 -1
  45. package/lib/interfaces.d.ts.map +1 -0
  46. package/lib/{interfaces.mjs → interfaces.js} +1 -1
  47. package/lib/interfaces.js.map +1 -0
  48. package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
  49. package/lib/packageVersion.d.ts.map +1 -0
  50. package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
  51. package/lib/packageVersion.js.map +1 -0
  52. package/lib/test/counter.spec.js +218 -0
  53. package/lib/test/counter.spec.js.map +1 -0
  54. package/lib/test/types/validateCounterPrevious.generated.js +8 -0
  55. package/lib/test/types/validateCounterPrevious.generated.js.map +1 -0
  56. package/package.json +39 -45
  57. package/src/counter.ts +5 -5
  58. package/src/counterFactory.ts +4 -4
  59. package/src/index.ts +2 -2
  60. package/src/packageVersion.ts +1 -1
  61. package/tsconfig.cjs.json +7 -0
  62. package/tsconfig.json +2 -5
  63. package/lib/counter.d.mts.map +0 -1
  64. package/lib/counter.mjs.map +0 -1
  65. package/lib/counterFactory.d.mts.map +0 -1
  66. package/lib/counterFactory.mjs.map +0 -1
  67. package/lib/index.d.mts +0 -7
  68. package/lib/index.d.mts.map +0 -1
  69. package/lib/index.mjs +0 -6
  70. package/lib/index.mjs.map +0 -1
  71. package/lib/interfaces.d.mts.map +0 -1
  72. package/lib/interfaces.mjs.map +0 -1
  73. package/lib/packageVersion.d.mts.map +0 -1
  74. package/lib/packageVersion.mjs.map +0 -1
package/lib/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * This library contains the {@link ISharedCounter | SharedCounter} distributed data structure.
7
+ * A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { SharedCounter } from "./counter.js";
12
+ export type { ISharedCounter, ISharedCounterEvents } from "./interfaces.js";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * This library contains the {@link ISharedCounter | SharedCounter} distributed data structure.
7
+ * A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { SharedCounter } from "./counter.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,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 ISharedCounter | SharedCounter} distributed data structure.\n * A `SharedCounter` is a shared object which holds a whole number that can be incremented or decremented.\n *\n * @packageDocumentation\n */\n\nexport { SharedCounter } from \"./counter.js\";\nexport type { ISharedCounter, ISharedCounterEvents } from \"./interfaces.js\";\n"]}
@@ -72,4 +72,4 @@ export interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {
72
72
  */
73
73
  increment(incrementAmount: number): void;
74
74
  }
75
- //# sourceMappingURL=interfaces.d.mts.map
75
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +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;;;GAGG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;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.mjs.map
6
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +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 { type ISharedObject, type ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Events sent by {@link SharedCounter}.\n * @alpha\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 * @alpha\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-dev-rc.1.0.0.232845";
9
- //# sourceMappingURL=packageVersion.d.mts.map
8
+ export declare const pkgVersion = "2.0.0-dev-rc.2.0.0.246488";
9
+ //# sourceMappingURL=packageVersion.d.ts.map
@@ -0,0 +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,8BAA8B,CAAC"}
@@ -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-dev-rc.1.0.0.232845";
9
- //# sourceMappingURL=packageVersion.mjs.map
8
+ export const pkgVersion = "2.0.0-dev-rc.2.0.0.246488";
9
+ //# sourceMappingURL=packageVersion.js.map
@@ -0,0 +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,2BAA2B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/counter\";\nexport const pkgVersion = \"2.0.0-dev-rc.2.0.0.246488\";\n"]}
@@ -0,0 +1,218 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { strict as assert } from "node:assert";
6
+ import { MockFluidDataStoreRuntime, MockContainerRuntimeFactory, MockContainerRuntimeFactoryForReconnection, MockSharedObjectServices, MockStorage, } from "@fluidframework/test-runtime-utils";
7
+ import { AttachState } from "@fluidframework/container-definitions";
8
+ import { SharedCounter } from "../index.js";
9
+ import { CounterFactory } from "../counterFactory.js";
10
+ class TestSharedCounter extends SharedCounter {
11
+ testApplyStashedOp(content) {
12
+ this.applyStashedOp(content);
13
+ }
14
+ }
15
+ describe("SharedCounter", () => {
16
+ let testCounter;
17
+ let dataStoreRuntime;
18
+ let factory;
19
+ beforeEach("createTestCounter", async () => {
20
+ dataStoreRuntime = new MockFluidDataStoreRuntime();
21
+ factory = SharedCounter.getFactory();
22
+ testCounter = factory.create(dataStoreRuntime, "counter");
23
+ });
24
+ describe("SharedCounter in local state", () => {
25
+ describe("constructor", () => {
26
+ it("Can create a counter with default value", () => {
27
+ assert.ok(testCounter, "Count not create the SharedCounter");
28
+ assert.equal(testCounter.value, 0, "The default value is incorrect");
29
+ });
30
+ });
31
+ describe("increment", () => {
32
+ it("Can increment a counter with positive and negative values", () => {
33
+ testCounter.increment(20);
34
+ assert.equal(testCounter.value, 20, "Could not increment with positive value");
35
+ testCounter.increment(-30);
36
+ assert.equal(testCounter.value, -10, "Could not increment with negative value");
37
+ });
38
+ it("Fires a listener callback after increment", () => {
39
+ let fired1 = false;
40
+ let fired2 = false;
41
+ testCounter.on("incremented", (incrementAmount, newValue) => {
42
+ if (!fired1) {
43
+ fired1 = true;
44
+ assert.equal(incrementAmount, 10, "The increment amount in the first event is incorrect");
45
+ assert.equal(newValue, 10, "The new value in the first event is incorrect");
46
+ }
47
+ else if (fired2) {
48
+ assert.fail("incremented event fired too many times");
49
+ }
50
+ else {
51
+ fired2 = true;
52
+ assert.equal(incrementAmount, -3, "The increment amount in the second event is incorrect");
53
+ assert.equal(newValue, 7, "The new value in the second event is incorrect");
54
+ }
55
+ });
56
+ testCounter.increment(10);
57
+ testCounter.increment(-3);
58
+ assert.ok(fired1, "The event for first increment was not fired");
59
+ assert.ok(fired2, "The event for second increment was not fired");
60
+ });
61
+ });
62
+ describe("applyStashedOp", () => {
63
+ it("Immediately applies the op's increment locally", () => {
64
+ const amt = 7;
65
+ const dataStoreRuntime1 = new MockFluidDataStoreRuntime();
66
+ const op = { type: "increment", incrementAmount: amt };
67
+ const counter1 = new TestSharedCounter("testCounter1", dataStoreRuntime1, CounterFactory.Attributes);
68
+ counter1.testApplyStashedOp(op);
69
+ assert.equal(counter1.value, amt);
70
+ });
71
+ });
72
+ describe("snapshot / load", () => {
73
+ it("can load a SharedCounter from snapshot", async () => {
74
+ testCounter.increment(20);
75
+ testCounter.increment(-10);
76
+ // Load a new SharedCounter from the snapshot of the first one.
77
+ const services = MockSharedObjectServices.createFromSummary(testCounter.getAttachSummary().summary);
78
+ const testCounter2 = factory.create(dataStoreRuntime, "counter2");
79
+ await testCounter2.load(services);
80
+ // Verify that the new SharedCounter has the correct value.
81
+ assert.equal(testCounter.value, 10, "The loaded SharedCounter does not have the correct value");
82
+ });
83
+ });
84
+ });
85
+ describe("SharedCounter in connected state with a remote SharedCounter", () => {
86
+ let testCounter2;
87
+ let containerRuntimeFactory;
88
+ beforeEach("createTestCounters", () => {
89
+ containerRuntimeFactory = new MockContainerRuntimeFactory();
90
+ // Connect the first SharedCounter.
91
+ dataStoreRuntime.setAttachState(AttachState.Attached);
92
+ containerRuntimeFactory.createContainerRuntime(dataStoreRuntime);
93
+ const services1 = {
94
+ deltaConnection: dataStoreRuntime.createDeltaConnection(),
95
+ objectStorage: new MockStorage(),
96
+ };
97
+ testCounter.connect(services1);
98
+ // Create and connect a second SharedCounter.
99
+ const dataStoreRuntime2 = new MockFluidDataStoreRuntime();
100
+ containerRuntimeFactory.createContainerRuntime(dataStoreRuntime2);
101
+ const services2 = {
102
+ deltaConnection: dataStoreRuntime2.createDeltaConnection(),
103
+ objectStorage: new MockStorage(),
104
+ };
105
+ testCounter2 = factory.create(dataStoreRuntime, "counter2");
106
+ testCounter2.connect(services2);
107
+ });
108
+ describe("increment", () => {
109
+ it("Can increment a counter with positive and negative values", () => {
110
+ testCounter.increment(20);
111
+ containerRuntimeFactory.processAllMessages();
112
+ assert.equal(testCounter.value, 20, "Could not increment with positive value");
113
+ assert.equal(testCounter2.value, 20, "Could not increment with positive value");
114
+ testCounter.increment(-30);
115
+ containerRuntimeFactory.processAllMessages();
116
+ assert.equal(testCounter.value, -10, "Could not increment with negative value");
117
+ assert.equal(testCounter2.value, -10, "Could not increment with negative value");
118
+ });
119
+ it("Fires a listener callback after increment", () => {
120
+ let fired1 = false;
121
+ let fired2 = false;
122
+ testCounter2.on("incremented", (incrementAmount, newValue) => {
123
+ if (!fired1) {
124
+ fired1 = true;
125
+ assert.equal(incrementAmount, 10, "The increment amount in the first event is incorrect");
126
+ assert.equal(newValue, 10, "The new value in the first event is incorrect");
127
+ }
128
+ else if (fired2) {
129
+ assert.fail("incremented event fired too many times");
130
+ }
131
+ else {
132
+ fired2 = true;
133
+ assert.equal(incrementAmount, -3, "The increment amount in the second event is incorrect");
134
+ assert.equal(newValue, 7, "The new value in the second event is incorrect");
135
+ }
136
+ });
137
+ testCounter.increment(10);
138
+ testCounter.increment(-3);
139
+ containerRuntimeFactory.processAllMessages();
140
+ assert.ok(fired1, "The event for first increment was not fired");
141
+ assert.ok(fired2, "The event for second increment was not fired");
142
+ });
143
+ });
144
+ });
145
+ describe("SharedCounter reconnection flow", () => {
146
+ let containerRuntimeFactory;
147
+ let containerRuntime1;
148
+ let containerRuntime2;
149
+ let testCounter2;
150
+ beforeEach("createTestCounters", () => {
151
+ containerRuntimeFactory = new MockContainerRuntimeFactoryForReconnection();
152
+ // Connect the first SharedCounter.
153
+ dataStoreRuntime.setAttachState(AttachState.Attached);
154
+ containerRuntime1 = containerRuntimeFactory.createContainerRuntime(dataStoreRuntime);
155
+ const services1 = {
156
+ deltaConnection: dataStoreRuntime.createDeltaConnection(),
157
+ objectStorage: new MockStorage(),
158
+ };
159
+ testCounter.connect(services1);
160
+ // Create and connect a second SharedCounter.
161
+ const dataStoreRuntime2 = new MockFluidDataStoreRuntime();
162
+ containerRuntime2 = containerRuntimeFactory.createContainerRuntime(dataStoreRuntime2);
163
+ const services2 = {
164
+ deltaConnection: dataStoreRuntime2.createDeltaConnection(),
165
+ objectStorage: new MockStorage(),
166
+ };
167
+ testCounter2 = factory.create(dataStoreRuntime, "counter2");
168
+ testCounter2.connect(services2);
169
+ });
170
+ it("can resend unacked ops on reconnection", async () => {
171
+ // Increment the first SharedCounter.
172
+ testCounter.increment(20);
173
+ // Disconnect and reconnect the first client.
174
+ containerRuntime1.connected = false;
175
+ containerRuntime1.connected = true;
176
+ // Process the messages.
177
+ containerRuntimeFactory.processAllMessages();
178
+ // Verify that the value is incremented in both the clients.
179
+ assert.equal(testCounter.value, 20, "Value not incremented in first client");
180
+ assert.equal(testCounter2.value, 20, "Value not incremented in second client");
181
+ // Increment the second SharedCounter.
182
+ testCounter.increment(-40);
183
+ // Disconnect and reconnect the second client.
184
+ containerRuntime2.connected = false;
185
+ containerRuntime2.connected = true;
186
+ // Process the messages.
187
+ containerRuntimeFactory.processAllMessages();
188
+ // Verify that the value is incremented in both the clients.
189
+ assert.equal(testCounter.value, -20, "Value not incremented in first client");
190
+ assert.equal(testCounter2.value, -20, "Value not incremented in second client");
191
+ });
192
+ it("can store ops in disconnected state and resend them on reconnection", async () => {
193
+ // Disconnect the first client.
194
+ containerRuntime1.connected = false;
195
+ // Increment the first SharedCounter.
196
+ testCounter.increment(20);
197
+ // Reconnect the first client.
198
+ containerRuntime1.connected = true;
199
+ // Process the messages.
200
+ containerRuntimeFactory.processAllMessages();
201
+ // Verify that the value is incremented in both the clients.
202
+ assert.equal(testCounter.value, 20, "Value not incremented in first client");
203
+ assert.equal(testCounter2.value, 20, "Value not incremented in second client");
204
+ // Disconnect the second client.
205
+ containerRuntime2.connected = false;
206
+ // Increment the second SharedCounter.
207
+ testCounter.increment(-40);
208
+ // Reconnect the second client.
209
+ containerRuntime2.connected = true;
210
+ // Process the messages.
211
+ containerRuntimeFactory.processAllMessages();
212
+ // Verify that the value is incremented in both the clients.
213
+ assert.equal(testCounter.value, -20, "Value not incremented in first client");
214
+ assert.equal(testCounter2.value, -20, "Value not incremented in second client");
215
+ });
216
+ });
217
+ });
218
+ //# sourceMappingURL=counter.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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;YACxB,uBAAuB,CAAC,kBAAkB,EAAE,CAAC;YAE7C,4DAA4D;YAC5D,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,uCAAuC,CAAC,CAAC;YAC7E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,EAAE,wCAAwC,CAAC,CAAC;YAE/E,gCAAgC;YAChC,iBAAiB,CAAC,SAAS,GAAG,KAAK,CAAC;YAEpC,sCAAsC;YACtC,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;YAE3B,+BAA+B;YAC/B,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC;YAEnC,wBAAwB;YACxB,uBAAuB,CAAC,kBAAkB,EAAE,CAAC;YAE7C,4DAA4D;YAC5D,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,uCAAuC,CAAC,CAAC;YAC9E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,wCAAwC,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\tMockFluidDataStoreRuntime,\n\tMockContainerRuntimeFactory,\n\tMockContainerRuntimeFactoryForReconnection,\n\ttype MockContainerRuntimeForReconnection,\n\tMockSharedObjectServices,\n\tMockStorage,\n} from \"@fluidframework/test-runtime-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { type ISharedCounter, SharedCounter } from \"../index.js\";\nimport { CounterFactory } from \"../counterFactory.js\";\n\nclass TestSharedCounter extends SharedCounter {\n\tpublic testApplyStashedOp(content: unknown): void {\n\t\tthis.applyStashedOp(content);\n\t}\n}\n\ndescribe(\"SharedCounter\", () => {\n\tlet testCounter: ISharedCounter;\n\tlet dataStoreRuntime: MockFluidDataStoreRuntime;\n\tlet factory: IChannelFactory;\n\n\tbeforeEach(\"createTestCounter\", async () => {\n\t\tdataStoreRuntime = new MockFluidDataStoreRuntime();\n\t\tfactory = SharedCounter.getFactory();\n\t\ttestCounter = factory.create(dataStoreRuntime, \"counter\") as ISharedCounter;\n\t});\n\n\tdescribe(\"SharedCounter in local state\", () => {\n\t\tdescribe(\"constructor\", () => {\n\t\t\tit(\"Can create a counter with default value\", () => {\n\t\t\t\tassert.ok(testCounter, \"Count not create the SharedCounter\");\n\t\t\t\tassert.equal(testCounter.value, 0, \"The default value is incorrect\");\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\"increment\", () => {\n\t\t\tit(\"Can increment a counter with positive and negative values\", () => {\n\t\t\t\ttestCounter.increment(20);\n\t\t\t\tassert.equal(testCounter.value, 20, \"Could not increment with positive value\");\n\t\t\t\ttestCounter.increment(-30);\n\t\t\t\tassert.equal(testCounter.value, -10, \"Could not increment with negative value\");\n\t\t\t});\n\n\t\t\tit(\"Fires a listener callback after increment\", () => {\n\t\t\t\tlet fired1 = false;\n\t\t\t\tlet fired2 = false;\n\n\t\t\t\ttestCounter.on(\"incremented\", (incrementAmount: number, newValue: number) => {\n\t\t\t\t\tif (!fired1) {\n\t\t\t\t\t\tfired1 = true;\n\t\t\t\t\t\tassert.equal(\n\t\t\t\t\t\t\tincrementAmount,\n\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\"The increment amount in the first event is incorrect\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert.equal(newValue, 10, \"The new value in the first event is incorrect\");\n\t\t\t\t\t} else if (fired2) {\n\t\t\t\t\t\tassert.fail(\"incremented event fired too many times\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfired2 = true;\n\t\t\t\t\t\tassert.equal(\n\t\t\t\t\t\t\tincrementAmount,\n\t\t\t\t\t\t\t-3,\n\t\t\t\t\t\t\t\"The increment amount in the second event is incorrect\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert.equal(newValue, 7, \"The new value in the second event is incorrect\");\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\ttestCounter.increment(10);\n\t\t\t\ttestCounter.increment(-3);\n\t\t\t\tassert.ok(fired1, \"The event for first increment was not fired\");\n\t\t\t\tassert.ok(fired2, \"The event for second increment was not fired\");\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\"applyStashedOp\", () => {\n\t\t\tit(\"Immediately applies the op's increment locally\", () => {\n\t\t\t\tconst amt = 7;\n\t\t\t\tconst dataStoreRuntime1 = new MockFluidDataStoreRuntime();\n\t\t\t\tconst op = { type: \"increment\", incrementAmount: amt };\n\t\t\t\tconst counter1 = new TestSharedCounter(\n\t\t\t\t\t\"testCounter1\",\n\t\t\t\t\tdataStoreRuntime1,\n\t\t\t\t\tCounterFactory.Attributes,\n\t\t\t\t);\n\t\t\t\tcounter1.testApplyStashedOp(op);\n\t\t\t\tassert.equal(counter1.value, amt);\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\"snapshot / load\", () => {\n\t\t\tit(\"can load a SharedCounter from snapshot\", async () => {\n\t\t\t\ttestCounter.increment(20);\n\t\t\t\ttestCounter.increment(-10);\n\n\t\t\t\t// Load a new SharedCounter from the snapshot of the first one.\n\t\t\t\tconst services = MockSharedObjectServices.createFromSummary(\n\t\t\t\t\ttestCounter.getAttachSummary().summary,\n\t\t\t\t);\n\t\t\t\tconst testCounter2 = factory.create(dataStoreRuntime, \"counter2\") as SharedCounter;\n\t\t\t\tawait testCounter2.load(services);\n\n\t\t\t\t// Verify that the new SharedCounter has the correct value.\n\t\t\t\tassert.equal(\n\t\t\t\t\ttestCounter.value,\n\t\t\t\t\t10,\n\t\t\t\t\t\"The loaded SharedCounter does not have the correct value\",\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"SharedCounter in connected state with a remote SharedCounter\", () => {\n\t\tlet testCounter2: ISharedCounter;\n\t\tlet containerRuntimeFactory: MockContainerRuntimeFactory;\n\n\t\tbeforeEach(\"createTestCounters\", () => {\n\t\t\tcontainerRuntimeFactory = new MockContainerRuntimeFactory();\n\n\t\t\t// Connect the first SharedCounter.\n\t\t\tdataStoreRuntime.setAttachState(AttachState.Attached);\n\n\t\t\tcontainerRuntimeFactory.createContainerRuntime(dataStoreRuntime);\n\t\t\tconst services1 = {\n\t\t\t\tdeltaConnection: dataStoreRuntime.createDeltaConnection(),\n\t\t\t\tobjectStorage: new MockStorage(),\n\t\t\t};\n\t\t\ttestCounter.connect(services1);\n\n\t\t\t// Create and connect a second SharedCounter.\n\t\t\tconst dataStoreRuntime2 = new MockFluidDataStoreRuntime();\n\n\t\t\tcontainerRuntimeFactory.createContainerRuntime(dataStoreRuntime2);\n\t\t\tconst services2 = {\n\t\t\t\tdeltaConnection: dataStoreRuntime2.createDeltaConnection(),\n\t\t\t\tobjectStorage: new MockStorage(),\n\t\t\t};\n\n\t\t\ttestCounter2 = factory.create(dataStoreRuntime, \"counter2\") as SharedCounter;\n\t\t\ttestCounter2.connect(services2);\n\t\t});\n\n\t\tdescribe(\"increment\", () => {\n\t\t\tit(\"Can increment a counter with positive and negative values\", () => {\n\t\t\t\ttestCounter.increment(20);\n\n\t\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t\tassert.equal(testCounter.value, 20, \"Could not increment with positive value\");\n\t\t\t\tassert.equal(testCounter2.value, 20, \"Could not increment with positive value\");\n\n\t\t\t\ttestCounter.increment(-30);\n\n\t\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t\tassert.equal(testCounter.value, -10, \"Could not increment with negative value\");\n\t\t\t\tassert.equal(testCounter2.value, -10, \"Could not increment with negative value\");\n\t\t\t});\n\n\t\t\tit(\"Fires a listener callback after increment\", () => {\n\t\t\t\tlet fired1 = false;\n\t\t\t\tlet fired2 = false;\n\n\t\t\t\ttestCounter2.on(\"incremented\", (incrementAmount: number, newValue: number) => {\n\t\t\t\t\tif (!fired1) {\n\t\t\t\t\t\tfired1 = true;\n\t\t\t\t\t\tassert.equal(\n\t\t\t\t\t\t\tincrementAmount,\n\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\"The increment amount in the first event is incorrect\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert.equal(newValue, 10, \"The new value in the first event is incorrect\");\n\t\t\t\t\t} else if (fired2) {\n\t\t\t\t\t\tassert.fail(\"incremented event fired too many times\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfired2 = true;\n\t\t\t\t\t\tassert.equal(\n\t\t\t\t\t\t\tincrementAmount,\n\t\t\t\t\t\t\t-3,\n\t\t\t\t\t\t\t\"The increment amount in the second event is incorrect\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert.equal(newValue, 7, \"The new value in the second event is incorrect\");\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\ttestCounter.increment(10);\n\t\t\t\ttestCounter.increment(-3);\n\n\t\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t\tassert.ok(fired1, \"The event for first increment was not fired\");\n\t\t\t\tassert.ok(fired2, \"The event for second increment was not fired\");\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"SharedCounter reconnection flow\", () => {\n\t\tlet containerRuntimeFactory: MockContainerRuntimeFactoryForReconnection;\n\t\tlet containerRuntime1: MockContainerRuntimeForReconnection;\n\t\tlet containerRuntime2: MockContainerRuntimeForReconnection;\n\t\tlet testCounter2: ISharedCounter;\n\n\t\tbeforeEach(\"createTestCounters\", () => {\n\t\t\tcontainerRuntimeFactory = new MockContainerRuntimeFactoryForReconnection();\n\n\t\t\t// Connect the first SharedCounter.\n\t\t\tdataStoreRuntime.setAttachState(AttachState.Attached);\n\t\t\tcontainerRuntime1 = containerRuntimeFactory.createContainerRuntime(dataStoreRuntime);\n\t\t\tconst services1 = {\n\t\t\t\tdeltaConnection: dataStoreRuntime.createDeltaConnection(),\n\t\t\t\tobjectStorage: new MockStorage(),\n\t\t\t};\n\t\t\ttestCounter.connect(services1);\n\n\t\t\t// Create and connect a second SharedCounter.\n\t\t\tconst dataStoreRuntime2 = new MockFluidDataStoreRuntime();\n\t\t\tcontainerRuntime2 = containerRuntimeFactory.createContainerRuntime(dataStoreRuntime2);\n\t\t\tconst services2 = {\n\t\t\t\tdeltaConnection: dataStoreRuntime2.createDeltaConnection(),\n\t\t\t\tobjectStorage: new MockStorage(),\n\t\t\t};\n\n\t\t\ttestCounter2 = factory.create(dataStoreRuntime, \"counter2\") as SharedCounter;\n\t\t\ttestCounter2.connect(services2);\n\t\t});\n\n\t\tit(\"can resend unacked ops on reconnection\", async () => {\n\t\t\t// Increment the first SharedCounter.\n\t\t\ttestCounter.increment(20);\n\n\t\t\t// Disconnect and reconnect the first client.\n\t\t\tcontainerRuntime1.connected = false;\n\t\t\tcontainerRuntime1.connected = true;\n\n\t\t\t// Process the messages.\n\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t// Verify that the value is incremented in both the clients.\n\t\t\tassert.equal(testCounter.value, 20, \"Value not incremented in first client\");\n\t\t\tassert.equal(testCounter2.value, 20, \"Value not incremented in second client\");\n\n\t\t\t// Increment the second SharedCounter.\n\t\t\ttestCounter.increment(-40);\n\n\t\t\t// Disconnect and reconnect the second client.\n\t\t\tcontainerRuntime2.connected = false;\n\t\t\tcontainerRuntime2.connected = true;\n\n\t\t\t// Process the messages.\n\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t// Verify that the value is incremented in both the clients.\n\t\t\tassert.equal(testCounter.value, -20, \"Value not incremented in first client\");\n\t\t\tassert.equal(testCounter2.value, -20, \"Value not incremented in second client\");\n\t\t});\n\n\t\tit(\"can store ops in disconnected state and resend them on reconnection\", async () => {\n\t\t\t// Disconnect the first client.\n\t\t\tcontainerRuntime1.connected = false;\n\n\t\t\t// Increment the first SharedCounter.\n\t\t\ttestCounter.increment(20);\n\n\t\t\t// Reconnect the first client.\n\t\t\tcontainerRuntime1.connected = true;\n\n\t\t\t// Process the messages.\n\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t// Verify that the value is incremented in both the clients.\n\t\t\tassert.equal(testCounter.value, 20, \"Value not incremented in first client\");\n\t\t\tassert.equal(testCounter2.value, 20, \"Value not incremented in second client\");\n\n\t\t\t// Disconnect the second client.\n\t\t\tcontainerRuntime2.connected = false;\n\n\t\t\t// Increment the second SharedCounter.\n\t\t\ttestCounter.increment(-40);\n\n\t\t\t// Reconnect the second client.\n\t\t\tcontainerRuntime2.connected = true;\n\n\t\t\t// Process the messages.\n\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t// Verify that the value is incremented in both the clients.\n\t\t\tassert.equal(testCounter.value, -20, \"Value not incremented in first client\");\n\t\t\tassert.equal(testCounter2.value, -20, \"Value not incremented in second client\");\n\t\t});\n\t});\n});\n"]}
@@ -0,0 +1,8 @@
1
+ use_current_InterfaceDeclaration_ISharedCounter(get_old_InterfaceDeclaration_ISharedCounter());
2
+ use_old_InterfaceDeclaration_ISharedCounter(get_current_InterfaceDeclaration_ISharedCounter());
3
+ use_current_InterfaceDeclaration_ISharedCounterEvents(get_old_InterfaceDeclaration_ISharedCounterEvents());
4
+ use_old_InterfaceDeclaration_ISharedCounterEvents(get_current_InterfaceDeclaration_ISharedCounterEvents());
5
+ use_current_ClassDeclaration_SharedCounter(get_old_ClassDeclaration_SharedCounter());
6
+ use_old_ClassDeclaration_SharedCounter(get_current_ClassDeclaration_SharedCounter());
7
+ export {};
8
+ //# sourceMappingURL=validateCounterPrevious.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateCounterPrevious.generated.js","sourceRoot":"","sources":["../../../src/test/types/validateCounterPrevious.generated.ts"],"names":[],"mappings":"AAgCA,+CAA+C,CAC3C,2CAA2C,EAAE,CAAC,CAAC;AAWnD,2CAA2C,CACvC,+CAA+C,EAAE,CAAC,CAAC;AAWvD,qDAAqD,CACjD,iDAAiD,EAAE,CAAC,CAAC;AAWzD,iDAAiD,CAC7C,qDAAqD,EAAE,CAAC,CAAC;AAW7D,0CAA0C,CACtC,sCAAsC,EAAE,CAAC,CAAC;AAW9C,sCAAsC,CAClC,0CAA0C,EAAE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/*\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n * Generated by fluid-type-test-generator in @fluidframework/build-tools.\n */\nimport type * as old from \"@fluidframework/counter-previous\";\nimport type * as current from \"../../index.js\";\n\n\n// See 'build-tools/src/type-test-generator/compatibility.ts' for more information.\ntype TypeOnly<T> = T extends number\n\t? number\n\t: T extends string\n\t? string\n\t: T extends boolean | bigint | symbol\n\t? T\n\t: {\n\t\t\t[P in keyof T]: TypeOnly<T[P]>;\n\t };\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ISharedCounter\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_ISharedCounter():\n TypeOnly<old.ISharedCounter>;\ndeclare function use_current_InterfaceDeclaration_ISharedCounter(\n use: TypeOnly<current.ISharedCounter>): void;\nuse_current_InterfaceDeclaration_ISharedCounter(\n get_old_InterfaceDeclaration_ISharedCounter());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ISharedCounter\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_ISharedCounter():\n TypeOnly<current.ISharedCounter>;\ndeclare function use_old_InterfaceDeclaration_ISharedCounter(\n use: TypeOnly<old.ISharedCounter>): void;\nuse_old_InterfaceDeclaration_ISharedCounter(\n get_current_InterfaceDeclaration_ISharedCounter());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ISharedCounterEvents\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_ISharedCounterEvents():\n TypeOnly<old.ISharedCounterEvents>;\ndeclare function use_current_InterfaceDeclaration_ISharedCounterEvents(\n use: TypeOnly<current.ISharedCounterEvents>): void;\nuse_current_InterfaceDeclaration_ISharedCounterEvents(\n get_old_InterfaceDeclaration_ISharedCounterEvents());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ISharedCounterEvents\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_ISharedCounterEvents():\n TypeOnly<current.ISharedCounterEvents>;\ndeclare function use_old_InterfaceDeclaration_ISharedCounterEvents(\n use: TypeOnly<old.ISharedCounterEvents>): void;\nuse_old_InterfaceDeclaration_ISharedCounterEvents(\n get_current_InterfaceDeclaration_ISharedCounterEvents());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_SharedCounter\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_ClassDeclaration_SharedCounter():\n TypeOnly<old.SharedCounter>;\ndeclare function use_current_ClassDeclaration_SharedCounter(\n use: TypeOnly<current.SharedCounter>): void;\nuse_current_ClassDeclaration_SharedCounter(\n get_old_ClassDeclaration_SharedCounter());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_SharedCounter\": {\"backCompat\": false}\n*/\ndeclare function get_current_ClassDeclaration_SharedCounter():\n TypeOnly<current.SharedCounter>;\ndeclare function use_old_ClassDeclaration_SharedCounter(\n use: TypeOnly<old.SharedCounter>): void;\nuse_old_ClassDeclaration_SharedCounter(\n get_current_ClassDeclaration_SharedCounter());\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/counter",
3
- "version": "2.0.0-dev-rc.1.0.0.232845",
3
+ "version": "2.0.0-dev-rc.2.0.0.246488",
4
4
  "description": "Counter DDS",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -11,60 +11,50 @@
11
11
  "license": "MIT",
12
12
  "author": "Microsoft and contributors",
13
13
  "sideEffects": false,
14
+ "type": "module",
14
15
  "exports": {
15
16
  ".": {
16
17
  "import": {
17
- "types": "./lib/index.d.mts",
18
- "default": "./lib/index.mjs"
18
+ "types": "./lib/index.d.ts",
19
+ "default": "./lib/index.js"
19
20
  },
20
21
  "require": {
21
22
  "types": "./dist/index.d.ts",
22
23
  "default": "./dist/index.js"
23
24
  }
24
25
  },
25
- "./alpha": {
26
+ "./public": {
26
27
  "import": {
27
- "types": "./lib/counter-alpha.d.mts",
28
- "default": "./lib/index.mjs"
28
+ "types": "./lib/counter-public.d.ts",
29
+ "default": "./lib/index.js"
29
30
  },
30
31
  "require": {
31
- "types": "./dist/counter-alpha.d.ts",
32
+ "types": "./dist/counter-public.d.ts",
32
33
  "default": "./dist/index.js"
33
34
  }
34
35
  },
35
- "./beta": {
36
+ "./alpha": {
36
37
  "import": {
37
- "types": "./lib/counter-beta.d.mts",
38
- "default": "./lib/index.mjs"
38
+ "types": "./lib/counter-alpha.d.ts",
39
+ "default": "./lib/index.js"
39
40
  },
40
41
  "require": {
41
- "types": "./dist/counter-beta.d.ts",
42
+ "types": "./dist/counter-alpha.d.ts",
42
43
  "default": "./dist/index.js"
43
44
  }
44
45
  },
45
46
  "./internal": {
46
47
  "import": {
47
- "types": "./lib/index.d.mts",
48
- "default": "./lib/index.mjs"
48
+ "types": "./lib/index.d.ts",
49
+ "default": "./lib/index.js"
49
50
  },
50
51
  "require": {
51
52
  "types": "./dist/index.d.ts",
52
53
  "default": "./dist/index.js"
53
54
  }
54
- },
55
- "./public": {
56
- "import": {
57
- "types": "./lib/counter-public.d.mts",
58
- "default": "./lib/index.mjs"
59
- },
60
- "require": {
61
- "types": "./dist/counter-public.d.ts",
62
- "default": "./dist/index.js"
63
- }
64
55
  }
65
56
  },
66
57
  "main": "dist/index.js",
67
- "module": "lib/index.mjs",
68
58
  "types": "dist/index.d.ts",
69
59
  "c8": {
70
60
  "all": true,
@@ -87,30 +77,31 @@
87
77
  "temp-directory": "nyc/.nyc_output"
88
78
  },
89
79
  "dependencies": {
90
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.232845",
91
- "@fluidframework/core-utils": "2.0.0-dev-rc.1.0.0.232845",
92
- "@fluidframework/datastore-definitions": "2.0.0-dev-rc.1.0.0.232845",
93
- "@fluidframework/driver-utils": "2.0.0-dev-rc.1.0.0.232845",
94
- "@fluidframework/protocol-definitions": "^3.2.0-231454",
95
- "@fluidframework/runtime-definitions": "2.0.0-dev-rc.1.0.0.232845",
96
- "@fluidframework/shared-object-base": "2.0.0-dev-rc.1.0.0.232845"
80
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.2.0.0.246488",
81
+ "@fluidframework/core-utils": "2.0.0-dev-rc.2.0.0.246488",
82
+ "@fluidframework/datastore-definitions": "2.0.0-dev-rc.2.0.0.246488",
83
+ "@fluidframework/driver-utils": "2.0.0-dev-rc.2.0.0.246488",
84
+ "@fluidframework/protocol-definitions": "^3.2.0",
85
+ "@fluidframework/runtime-definitions": "2.0.0-dev-rc.2.0.0.246488",
86
+ "@fluidframework/shared-object-base": "2.0.0-dev-rc.2.0.0.246488"
97
87
  },
98
88
  "devDependencies": {
99
89
  "@arethetypeswrong/cli": "^0.13.3",
100
- "@fluid-tools/build-cli": "^0.29.0",
90
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.2.0.0.246488",
91
+ "@fluid-tools/build-cli": "^0.34.0",
101
92
  "@fluidframework/build-common": "^2.0.3",
102
- "@fluidframework/build-tools": "^0.29.0",
93
+ "@fluidframework/build-tools": "^0.34.0",
94
+ "@fluidframework/container-definitions": "2.0.0-dev-rc.2.0.0.246488",
103
95
  "@fluidframework/counter-previous": "npm:@fluidframework/counter@2.0.0-internal.8.0.0",
104
- "@fluidframework/eslint-config-fluid": "^3.3.0",
105
- "@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.232845",
106
- "@fluidframework/test-runtime-utils": "2.0.0-dev-rc.1.0.0.232845",
107
- "@microsoft/api-extractor": "^7.39.1",
96
+ "@fluidframework/eslint-config-fluid": "^5.1.0",
97
+ "@fluidframework/test-runtime-utils": "2.0.0-dev-rc.2.0.0.246488",
98
+ "@microsoft/api-extractor": "^7.42.3",
108
99
  "@types/mocha": "^9.1.1",
109
100
  "@types/node": "^18.19.0",
110
101
  "c8": "^8.0.1",
111
102
  "copyfiles": "^2.4.1",
112
103
  "cross-env": "^7.0.3",
113
- "eslint": "~8.50.0",
104
+ "eslint": "~8.55.0",
114
105
  "mocha": "^10.2.0",
115
106
  "mocha-json-output-reporter": "^2.0.1",
116
107
  "mocha-multi-reporters": "^1.5.1",
@@ -118,7 +109,6 @@
118
109
  "prettier": "~3.0.3",
119
110
  "replace-in-file": "^6.3.5",
120
111
  "rimraf": "^4.4.0",
121
- "tsc-multi": "^1.1.0",
122
112
  "typescript": "~5.1.6"
123
113
  },
124
114
  "fluidBuild": {
@@ -138,15 +128,17 @@
138
128
  },
139
129
  "scripts": {
140
130
  "api": "fluid-build . --task api",
141
- "api-extractor:commonjs": "api-extractor run --local",
142
- "api-extractor:esnext": "api-extractor run --config ./api-extractor-esm.json",
131
+ "api-extractor:commonjs": "api-extractor run --config ./api-extractor-cjs.json",
132
+ "api-extractor:esnext": "api-extractor run --local",
143
133
  "build": "fluid-build . --task build",
144
134
  "build:commonjs": "fluid-build . --task commonjs",
145
135
  "build:compile": "fluid-build . --task compile",
146
136
  "build:docs": "fluid-build . --task api",
147
- "build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
137
+ "build:esnext": "tsc --project ./tsconfig.json",
148
138
  "build:genver": "gen-version",
149
- "build:test": "tsc --project ./src/test/tsconfig.json",
139
+ "build:test": "npm run build:test:esm && npm run build:test:cjs",
140
+ "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
141
+ "build:test:esm": "tsc --project ./src/test/tsconfig.json",
150
142
  "check:are-the-types-wrong": "attw --pack . --entrypoints .",
151
143
  "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
152
144
  "ci:build:docs": "api-extractor run",
@@ -160,9 +152,11 @@
160
152
  "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
161
153
  "test": "npm run test:mocha",
162
154
  "test:coverage": "c8 npm test",
163
- "test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
155
+ "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
156
+ "test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit",
157
+ "test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit",
164
158
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
165
- "tsc": "tsc",
159
+ "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
166
160
  "typetests:gen": "fluid-type-test-generator",
167
161
  "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
168
162
  }
package/src/counter.ts CHANGED
@@ -18,8 +18,8 @@ import {
18
18
  type IFluidSerializer,
19
19
  SharedObject,
20
20
  } from "@fluidframework/shared-object-base";
21
- import { CounterFactory } from "./counterFactory";
22
- import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces";
21
+ import { CounterFactory } from "./counterFactory.js";
22
+ import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces.js";
23
23
 
24
24
  /**
25
25
  * Describes the operation (op) format for incrementing the {@link SharedCounter}.
@@ -54,7 +54,7 @@ export class SharedCounter extends SharedObject<ISharedCounterEvents> implements
54
54
  *
55
55
  * @returns newly create shared counter (but not attached yet)
56
56
  */
57
- public static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCounter {
57
+ public static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter {
58
58
  return runtime.createChannel(id, CounterFactory.Type) as SharedCounter;
59
59
  }
60
60
 
@@ -71,7 +71,7 @@ export class SharedCounter extends SharedObject<ISharedCounterEvents> implements
71
71
  *
72
72
  * @returns a factory that creates and load SharedCounter
73
73
  */
74
- public static getFactory(): IChannelFactory {
74
+ public static getFactory(): IChannelFactory<ISharedCounter> {
75
75
  return new CounterFactory();
76
76
  }
77
77
 
@@ -178,6 +178,6 @@ export class SharedCounter extends SharedObject<ISharedCounterEvents> implements
178
178
  // eslint-disable-next-line unicorn/numeric-separators-style
179
179
  assert(counterOp.type === "increment", 0x3ec /* Op type is not increment */);
180
180
 
181
- this.incrementCore(counterOp.incrementAmount);
181
+ this.increment(counterOp.incrementAmount);
182
182
  }
183
183
  }
@@ -9,16 +9,16 @@ import {
9
9
  type IChannelServices,
10
10
  type IChannelFactory,
11
11
  } from "@fluidframework/datastore-definitions";
12
- import { SharedCounter } from "./counter";
13
- import { type ISharedCounter } from "./interfaces";
14
- import { pkgVersion } from "./packageVersion";
12
+ import { SharedCounter } from "./counter.js";
13
+ import { type ISharedCounter } from "./interfaces.js";
14
+ import { pkgVersion } from "./packageVersion.js";
15
15
 
16
16
  /**
17
17
  * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.
18
18
  *
19
19
  * @sealed
20
20
  */
21
- export class CounterFactory implements IChannelFactory {
21
+ export class CounterFactory implements IChannelFactory<ISharedCounter> {
22
22
  /**
23
23
  * Static value for {@link CounterFactory."type"}.
24
24
  */
package/src/index.ts CHANGED
@@ -10,5 +10,5 @@
10
10
  * @packageDocumentation
11
11
  */
12
12
 
13
- export { SharedCounter } from "./counter";
14
- export type { ISharedCounter, ISharedCounterEvents } from "./interfaces";
13
+ export { SharedCounter } from "./counter.js";
14
+ export type { ISharedCounter, ISharedCounterEvents } from "./interfaces.js";
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/counter";
9
- export const pkgVersion = "2.0.0-dev-rc.1.0.0.232845";
9
+ export const pkgVersion = "2.0.0-dev-rc.2.0.0.246488";