@fluidframework/counter 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.2.0.0.245554
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +8 -0
- package/README.md +133 -52
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/counter.api.md +2 -4
- package/dist/counter-alpha.d.ts +2 -2
- package/dist/counter-beta.d.ts +2 -0
- package/dist/counter-public.d.ts +2 -0
- package/dist/counter-untrimmed.d.ts +2 -2
- package/dist/counter.d.ts +3 -3
- package/dist/counter.d.ts.map +1 -1
- package/dist/counter.js +4 -4
- package/dist/counter.js.map +1 -1
- package/dist/counterFactory.d.ts +2 -2
- package/dist/counterFactory.d.ts.map +1 -1
- package/dist/counterFactory.js +5 -5
- package/dist/counterFactory.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/{counter-untrimmed.d.mts → counter-alpha.d.ts} +9 -2
- package/lib/{counter-beta.d.mts → counter-beta.d.ts} +9 -0
- package/lib/{counter-public.d.mts → counter-public.d.ts} +9 -0
- package/lib/{counter-alpha.d.mts → counter-untrimmed.d.ts} +9 -2
- package/lib/{counter.d.mts → counter.d.ts} +4 -4
- package/lib/counter.d.ts.map +1 -0
- package/lib/{counter.mjs → counter.js} +3 -3
- package/lib/counter.js.map +1 -0
- package/lib/{counterFactory.d.mts → counterFactory.d.ts} +3 -3
- package/lib/counterFactory.d.ts.map +1 -0
- package/lib/{counterFactory.mjs → counterFactory.js} +3 -3
- package/lib/counterFactory.js.map +1 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/{interfaces.d.mts → interfaces.d.ts} +1 -1
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/{interfaces.mjs → interfaces.js} +1 -1
- package/lib/interfaces.js.map +1 -0
- package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
- package/lib/packageVersion.js.map +1 -0
- package/lib/test/counter.spec.js +218 -0
- package/lib/test/counter.spec.js.map +1 -0
- package/lib/test/types/validateCounterPrevious.generated.js +8 -0
- package/lib/test/types/validateCounterPrevious.generated.js.map +1 -0
- package/package.json +39 -45
- package/src/counter.ts +5 -5
- package/src/counterFactory.ts +4 -4
- package/src/index.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/lib/counter.d.mts.map +0 -1
- package/lib/counter.mjs.map +0 -1
- package/lib/counterFactory.d.mts.map +0 -1
- package/lib/counterFactory.mjs.map +0 -1
- package/lib/index.d.mts +0 -7
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs +0 -6
- package/lib/index.mjs.map +0 -1
- package/lib/interfaces.d.mts.map +0 -1
- package/lib/interfaces.mjs.map +0 -1
- package/lib/packageVersion.d.mts.map +0 -1
- package/lib/packageVersion.mjs.map +0 -1
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
2
9
|
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
3
10
|
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
@@ -93,14 +100,14 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
93
100
|
*
|
|
94
101
|
* @returns newly create shared counter (but not attached yet)
|
|
95
102
|
*/
|
|
96
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
103
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
97
104
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
98
105
|
/**
|
|
99
106
|
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
100
107
|
*
|
|
101
108
|
* @returns a factory that creates and load SharedCounter
|
|
102
109
|
*/
|
|
103
|
-
static getFactory(): IChannelFactory
|
|
110
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
104
111
|
private _value;
|
|
105
112
|
/**
|
|
106
113
|
* {@inheritDoc ISharedCounter.value}
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
2
9
|
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
3
10
|
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
@@ -15,4 +22,6 @@ import { SharedObject } from '@fluidframework/shared-object-base';
|
|
|
15
22
|
|
|
16
23
|
/* Excluded from this release type: SharedCounter */
|
|
17
24
|
|
|
25
|
+
/* Excluded from this release type: SharedObject */
|
|
26
|
+
|
|
18
27
|
export { }
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
2
9
|
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
3
10
|
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
@@ -15,4 +22,6 @@ import { SharedObject } from '@fluidframework/shared-object-base';
|
|
|
15
22
|
|
|
16
23
|
/* Excluded from this release type: SharedCounter */
|
|
17
24
|
|
|
25
|
+
/* Excluded from this release type: SharedObject */
|
|
26
|
+
|
|
18
27
|
export { }
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
2
9
|
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
3
10
|
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
@@ -93,14 +100,14 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
93
100
|
*
|
|
94
101
|
* @returns newly create shared counter (but not attached yet)
|
|
95
102
|
*/
|
|
96
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
103
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
97
104
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
98
105
|
/**
|
|
99
106
|
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
100
107
|
*
|
|
101
108
|
* @returns a factory that creates and load SharedCounter
|
|
102
109
|
*/
|
|
103
|
-
static getFactory(): IChannelFactory
|
|
110
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
104
111
|
private _value;
|
|
105
112
|
/**
|
|
106
113
|
* {@inheritDoc ISharedCounter.value}
|
|
@@ -6,7 +6,7 @@ import { type ISequencedDocumentMessage } from "@fluidframework/protocol-definit
|
|
|
6
6
|
import { type IFluidDataStoreRuntime, type IChannelStorageService, type IChannelFactory, type IChannelAttributes } from "@fluidframework/datastore-definitions";
|
|
7
7
|
import { type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
8
8
|
import { type IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
|
-
import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces.
|
|
9
|
+
import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces.js";
|
|
10
10
|
/**
|
|
11
11
|
* {@inheritDoc ISharedCounter}
|
|
12
12
|
* @alpha
|
|
@@ -20,14 +20,14 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
20
20
|
*
|
|
21
21
|
* @returns newly create shared counter (but not attached yet)
|
|
22
22
|
*/
|
|
23
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
23
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
24
24
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
25
25
|
/**
|
|
26
26
|
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
27
27
|
*
|
|
28
28
|
* @returns a factory that creates and load SharedCounter
|
|
29
29
|
*/
|
|
30
|
-
static getFactory(): IChannelFactory
|
|
30
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
31
31
|
private _value;
|
|
32
32
|
/**
|
|
33
33
|
* {@inheritDoc ISharedCounter.value}
|
|
@@ -66,4 +66,4 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
66
66
|
*/
|
|
67
67
|
protected applyStashedOp(op: unknown): void;
|
|
68
68
|
}
|
|
69
|
-
//# sourceMappingURL=counter.d.
|
|
69
|
+
//# sourceMappingURL=counter.d.ts.map
|
|
@@ -0,0 +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,iBAAiB,CAAC;AAsBjF;;;GAGG;AACH,qBAAa,aAAc,SAAQ,YAAY,CAAC,oBAAoB,CAAE,YAAW,cAAc;IAC9F;;;;;;;OAOG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,cAAc;gBAKjF,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,kBAAkB;IAK/B;;;;OAIG;WACW,UAAU,IAAI,eAAe,CAAC,cAAc,CAAC;IAI3D,OAAO,CAAC,MAAM,CAAa;IAE3B;;OAEG;IACH,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED;;OAEG;IACI,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI;IAgB/C,OAAO,CAAC,aAAa;IAKrB;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAU5E;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxE;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAkBP;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI;CAU3C"}
|
|
@@ -6,7 +6,7 @@ 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.js";
|
|
10
10
|
const snapshotFileName = "header";
|
|
11
11
|
/**
|
|
12
12
|
* {@inheritDoc ISharedCounter}
|
|
@@ -117,7 +117,7 @@ export class SharedCounter extends SharedObject {
|
|
|
117
117
|
// TODO: Clean up error code linter violations repo-wide.
|
|
118
118
|
// eslint-disable-next-line unicorn/numeric-separators-style
|
|
119
119
|
assert(counterOp.type === "increment", 0x3ec /* Op type is not increment */);
|
|
120
|
-
this.
|
|
120
|
+
this.increment(counterOp.incrementAmount);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
//# sourceMappingURL=counter.
|
|
123
|
+
//# sourceMappingURL=counter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAkC,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAOnG,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EACN,uBAAuB,EAEvB,Y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C;QAClC,MAAM,OAAO,GAA2B;YACvC,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,CAAC;QAEF,wCAAwC;QACxC,OAAO,uBAAuB,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,QAAQ,CAAC,OAA+B;QACvD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAyB,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAEtF,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED;;OAEG;IACO,YAAY,KAAU,CAAC;IAEjC;;;;;;;OAOG;IACO,WAAW,CACpB,OAAkC,EAClC,KAAc,EACd,eAAwB;QAExB,wEAAwE;QACxE,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,IAAI,CAAC,KAAK,EAAE;YACrD,MAAM,EAAE,GAAG,OAAO,CAAC,QAA+B,CAAC;YAEnD,QAAQ,EAAE,CAAC,IAAI,EAAE;gBAChB,KAAK,WAAW,CAAC,CAAC;oBACjB,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;oBACvC,MAAM;iBACN;gBAED,OAAO,CAAC,CAAC;oBACR,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;iBACrC;aACD;SACD;IACF,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,EAAW;QACnC,MAAM,SAAS,GAAG,EAAyB,CAAC;QAE5C,yDAAyD;QAEzD,4DAA4D;QAC5D,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,WAAW,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAE7E,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { type ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelStorageService,\n\ttype IChannelFactory,\n\ttype IChannelAttributes,\n} from \"@fluidframework/datastore-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { type ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n\tcreateSingleBlobSummary,\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { CounterFactory } from \"./counterFactory.js\";\nimport { type ISharedCounter, type ISharedCounterEvents } from \"./interfaces.js\";\n\n/**\n * Describes the operation (op) format for incrementing the {@link SharedCounter}.\n */\ninterface IIncrementOperation {\n\ttype: \"increment\";\n\tincrementAmount: number;\n}\n\n/**\n * @remarks Used in snapshotting.\n */\ninterface ICounterSnapshotFormat {\n\t/**\n\t * The value of the counter.\n\t */\n\tvalue: number;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedCounter}\n * @alpha\n */\nexport class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {\n\t/**\n\t * Create a new {@link SharedCounter}.\n\t *\n\t * @param runtime - The data store runtime to which the new `SharedCounter` will belong.\n\t * @param id - Optional name of the `SharedCounter`. If not provided, one will be generated.\n\t *\n\t * @returns newly create shared counter (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter {\n\t\treturn runtime.createChannel(id, CounterFactory.Type) as SharedCounter;\n\t}\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_counter_\");\n\t}\n\n\t/**\n\t * Get a factory for {@link SharedCounter} to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedCounter\n\t */\n\tpublic static getFactory(): IChannelFactory<ISharedCounter> {\n\t\treturn new CounterFactory();\n\t}\n\n\tprivate _value: number = 0;\n\n\t/**\n\t * {@inheritDoc ISharedCounter.value}\n\t */\n\tpublic get value(): number {\n\t\treturn this._value;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCounter.increment}\n\t */\n\tpublic increment(incrementAmount: number): void {\n\t\t// Incrementing by floating point numbers will be eventually inconsistent, since the order in which the\n\t\t// increments are applied affects the result. A more-robust solution would be required to support this.\n\t\tif (incrementAmount % 1 !== 0) {\n\t\t\tthrow new Error(\"Must increment by a whole number\");\n\t\t}\n\n\t\tconst op: IIncrementOperation = {\n\t\t\ttype: \"increment\",\n\t\t\tincrementAmount,\n\t\t};\n\n\t\tthis.incrementCore(incrementAmount);\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tprivate incrementCore(incrementAmount: number): void {\n\t\tthis._value += incrementAmount;\n\t\tthis.emit(\"incremented\", incrementAmount, this._value);\n\t}\n\n\t/**\n\t * Create a summary for the counter.\n\t *\n\t * @returns The summary of the current state of the counter.\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Get a serializable form of data\n\t\tconst content: ICounterSnapshotFormat = {\n\t\t\tvalue: this.value,\n\t\t};\n\n\t\t// And then construct the summary for it\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<ICounterSnapshotFormat>(storage, snapshotFileName);\n\n\t\tthis._value = content.value;\n\t}\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Process a counter operation (op).\n\t *\n\t * @param message - The message to prepare.\n\t * @param local - Whether or not the message was sent by the local client.\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be `undefined`.\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as IIncrementOperation;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"increment\": {\n\t\t\t\t\tthis.incrementCore(op.incrementAmount);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritdoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t */\n\tprotected applyStashedOp(op: unknown): void {\n\t\tconst counterOp = op as IIncrementOperation;\n\n\t\t// TODO: Clean up error code linter violations repo-wide.\n\n\t\t// eslint-disable-next-line unicorn/numeric-separators-style\n\t\tassert(counterOp.type === \"increment\", 0x3ec /* Op type is not increment */);\n\n\t\tthis.increment(counterOp.incrementAmount);\n\t}\n}\n"]}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type IChannelAttributes, type IFluidDataStoreRuntime, type IChannelServices, type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
-
import { type ISharedCounter } from "./interfaces.
|
|
6
|
+
import { type ISharedCounter } from "./interfaces.js";
|
|
7
7
|
/**
|
|
8
8
|
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.
|
|
9
9
|
*
|
|
10
10
|
* @sealed
|
|
11
11
|
*/
|
|
12
|
-
export declare class CounterFactory implements IChannelFactory {
|
|
12
|
+
export declare class CounterFactory implements IChannelFactory<ISharedCounter> {
|
|
13
13
|
/**
|
|
14
14
|
* Static value for {@link CounterFactory."type"}.
|
|
15
15
|
*/
|
|
@@ -35,4 +35,4 @@ export declare class CounterFactory implements IChannelFactory {
|
|
|
35
35
|
*/
|
|
36
36
|
create(document: IFluidDataStoreRuntime, id: string): ISharedCounter;
|
|
37
37
|
}
|
|
38
|
-
//# sourceMappingURL=counterFactory.d.
|
|
38
|
+
//# sourceMappingURL=counterFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"counterFactory.d.ts","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD;;;;GAIG;AACH,qBAAa,cAAe,YAAW,eAAe,CAAC,cAAc,CAAC;IACrE;;OAEG;IACH,gBAAuB,IAAI,+CAA+C;IAE1E;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,cAAc,CAAC;IAM1B;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,cAAc;CAK3E"}
|
|
@@ -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.js";
|
|
6
|
+
import { pkgVersion } from "./packageVersion.js";
|
|
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.
|
|
54
|
+
//# sourceMappingURL=counterFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;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.js\";\nimport { type ISharedCounter } from \"./interfaces.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.\n *\n * @sealed\n */\nexport class CounterFactory implements IChannelFactory<ISharedCounter> {\n\t/**\n\t * Static value for {@link CounterFactory.\"type\"}.\n\t */\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/counter\";\n\n\t/**\n\t * Static value for {@link CounterFactory.attributes}.\n\t */\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: CounterFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn CounterFactory.Type;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn CounterFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedCounter> {\n\t\tconst counter = new SharedCounter(id, runtime, attributes);\n\t\tawait counter.load(services);\n\t\treturn counter;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic create(document: IFluidDataStoreRuntime, id: string): ISharedCounter {\n\t\tconst counter = new SharedCounter(id, document, this.attributes);\n\t\tcounter.initializeLocal();\n\t\treturn counter;\n\t}\n}\n"]}
|
package/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
|
package/lib/index.js.map
ADDED
|
@@ -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"]}
|
|
@@ -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"}
|
|
@@ -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.
|
|
9
|
-
//# sourceMappingURL=packageVersion.d.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev-rc.2.0.0.245554";
|
|
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.
|
|
9
|
-
//# sourceMappingURL=packageVersion.
|
|
8
|
+
export const pkgVersion = "2.0.0-dev-rc.2.0.0.245554";
|
|
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.245554\";\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":"counter.spec.js","sourceRoot":"","sources":["../../src/test/counter.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EACN,yBAAyB,EACzB,2BAA2B,EAC3B,0CAA0C,EAE1C,wBAAwB,EACxB,WAAW,GACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAuB,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,iBAAkB,SAAQ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AAC;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"]}
|