@fluidframework/counter 2.0.0-rc.1.0.6 → 2.0.0-rc.2.0.1
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/{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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const getFluidTestMochaConfig = require("@
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
|
|
9
9
|
|
|
10
10
|
const packageDir = __dirname;
|
|
11
11
|
const config = getFluidTestMochaConfig(packageDir);
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @fluidframework/counter
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.2.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- counter: SharedCounter.create now returns ISharedCounter ([#19961](https://github.com/microsoft/FluidFramework/issues/19961)) [e2317bdbd2](https://github.com/microsoft/FluidFramework/commits/e2317bdbd29c40c7888bba2ed657a40a8dd6f45b)
|
|
8
|
+
|
|
9
|
+
`SharedCounter.create` now returns `ISharedCounter` instead of `SharedCounter`.
|
|
10
|
+
|
|
3
11
|
## 2.0.0-rc.1.0.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "../../../common/build/build-common/api-extractor-base
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-base.cjs.primary.json",
|
|
4
|
+
// CJS is actually secondary; so, no report.
|
|
5
|
+
"apiReport": {
|
|
6
|
+
"enabled": false
|
|
7
|
+
}
|
|
4
8
|
}
|
package/api-extractor-lint.json
CHANGED
package/api-extractor.json
CHANGED
|
@@ -30,12 +30,10 @@ export interface ISharedCounterEvents extends ISharedObjectEvents {
|
|
|
30
30
|
// @alpha
|
|
31
31
|
export class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {
|
|
32
32
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
33
|
-
// (undocumented)
|
|
34
33
|
protected applyStashedOp(op: unknown): void;
|
|
35
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
36
|
-
static getFactory(): IChannelFactory
|
|
34
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
35
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
37
36
|
increment(incrementAmount: number): void;
|
|
38
|
-
// (undocumented)
|
|
39
37
|
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
40
38
|
protected onDisconnect(): void;
|
|
41
39
|
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
package/dist/counter-alpha.d.ts
CHANGED
|
@@ -100,14 +100,14 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
100
100
|
*
|
|
101
101
|
* @returns newly create shared counter (but not attached yet)
|
|
102
102
|
*/
|
|
103
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
103
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
104
104
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
105
105
|
/**
|
|
106
106
|
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
107
107
|
*
|
|
108
108
|
* @returns a factory that creates and load SharedCounter
|
|
109
109
|
*/
|
|
110
|
-
static getFactory(): IChannelFactory
|
|
110
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
111
111
|
private _value;
|
|
112
112
|
/**
|
|
113
113
|
* {@inheritDoc ISharedCounter.value}
|
package/dist/counter-beta.d.ts
CHANGED
package/dist/counter-public.d.ts
CHANGED
|
@@ -100,14 +100,14 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
100
100
|
*
|
|
101
101
|
* @returns newly create shared counter (but not attached yet)
|
|
102
102
|
*/
|
|
103
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string):
|
|
103
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedCounter;
|
|
104
104
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
105
105
|
/**
|
|
106
106
|
* Get a factory for {@link SharedCounter} to register with the data store.
|
|
107
107
|
*
|
|
108
108
|
* @returns a factory that creates and load SharedCounter
|
|
109
109
|
*/
|
|
110
|
-
static getFactory(): IChannelFactory
|
|
110
|
+
static getFactory(): IChannelFactory<ISharedCounter>;
|
|
111
111
|
private _value;
|
|
112
112
|
/**
|
|
113
113
|
* {@inheritDoc ISharedCounter.value}
|
package/dist/counter.d.ts
CHANGED
|
@@ -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}
|
package/dist/counter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAG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,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"}
|
package/dist/counter.js
CHANGED
|
@@ -9,7 +9,7 @@ const core_utils_1 = require("@fluidframework/core-utils");
|
|
|
9
9
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
10
10
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
11
11
|
const shared_object_base_1 = require("@fluidframework/shared-object-base");
|
|
12
|
-
const
|
|
12
|
+
const counterFactory_js_1 = require("./counterFactory.js");
|
|
13
13
|
const snapshotFileName = "header";
|
|
14
14
|
/**
|
|
15
15
|
* {@inheritDoc ISharedCounter}
|
|
@@ -25,7 +25,7 @@ class SharedCounter extends shared_object_base_1.SharedObject {
|
|
|
25
25
|
* @returns newly create shared counter (but not attached yet)
|
|
26
26
|
*/
|
|
27
27
|
static create(runtime, id) {
|
|
28
|
-
return runtime.createChannel(id,
|
|
28
|
+
return runtime.createChannel(id, counterFactory_js_1.CounterFactory.Type);
|
|
29
29
|
}
|
|
30
30
|
constructor(id, runtime, attributes) {
|
|
31
31
|
super(id, runtime, attributes, "fluid_counter_");
|
|
@@ -37,7 +37,7 @@ class SharedCounter extends shared_object_base_1.SharedObject {
|
|
|
37
37
|
* @returns a factory that creates and load SharedCounter
|
|
38
38
|
*/
|
|
39
39
|
static getFactory() {
|
|
40
|
-
return new
|
|
40
|
+
return new counterFactory_js_1.CounterFactory();
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* {@inheritDoc ISharedCounter.value}
|
|
@@ -120,7 +120,7 @@ class SharedCounter extends shared_object_base_1.SharedObject {
|
|
|
120
120
|
// TODO: Clean up error code linter violations repo-wide.
|
|
121
121
|
// eslint-disable-next-line unicorn/numeric-separators-style
|
|
122
122
|
(0, core_utils_1.assert)(counterOp.type === "increment", 0x3ec /* Op type is not increment */);
|
|
123
|
-
this.
|
|
123
|
+
this.increment(counterOp.incrementAmount);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
exports.SharedCounter = SharedCounter;
|
package/dist/counter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,+EAAmG;AAOnG,+DAA4D;AAE5D,2EAI4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,+EAAmG;AAOnG,+DAA4D;AAE5D,2EAI4C;AAC5C,2DAAqD;AAqBrD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAa,aAAc,SAAQ,iCAAkC;IACpE;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,kCAAc,CAAC,IAAI,CAAkB,CAAC;IACxE,CAAC;IAED,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;QA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IACO,WAAW,CACpB,OAAkC,EAClC,KAAc,EACd,eAAwB;QAExB,wEAAwE;QACxE,IAAI,OAAO,CAAC,IAAI,KAAK,kCAAW,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,IAAA,mBAAM,EAAC,SAAS,CAAC,IAAI,KAAK,WAAW,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAE7E,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;CACD;AAvID,sCAuIC","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"]}
|
package/dist/counterFactory.d.ts
CHANGED
|
@@ -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
|
*/
|
|
@@ -1 +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,
|
|
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"}
|
package/dist/counterFactory.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.CounterFactory = void 0;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const counter_js_1 = require("./counter.js");
|
|
9
|
+
const packageVersion_js_1 = require("./packageVersion.js");
|
|
10
10
|
/**
|
|
11
11
|
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedCounter}.
|
|
12
12
|
*
|
|
@@ -29,7 +29,7 @@ class CounterFactory {
|
|
|
29
29
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
30
30
|
*/
|
|
31
31
|
async load(runtime, id, services, attributes) {
|
|
32
|
-
const counter = new
|
|
32
|
+
const counter = new counter_js_1.SharedCounter(id, runtime, attributes);
|
|
33
33
|
await counter.load(services);
|
|
34
34
|
return counter;
|
|
35
35
|
}
|
|
@@ -37,7 +37,7 @@ class CounterFactory {
|
|
|
37
37
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
38
38
|
*/
|
|
39
39
|
create(document, id) {
|
|
40
|
-
const counter = new
|
|
40
|
+
const counter = new counter_js_1.SharedCounter(id, document, this.attributes);
|
|
41
41
|
counter.initializeLocal();
|
|
42
42
|
return counter;
|
|
43
43
|
}
|
|
@@ -53,6 +53,6 @@ CounterFactory.Type = "https://graph.microsoft.com/types/counter";
|
|
|
53
53
|
CounterFactory.Attributes = {
|
|
54
54
|
type: CounterFactory.Type,
|
|
55
55
|
snapshotFormatVersion: "0.1",
|
|
56
|
-
packageVersion:
|
|
56
|
+
packageVersion: packageVersion_js_1.pkgVersion,
|
|
57
57
|
};
|
|
58
58
|
//# sourceMappingURL=counterFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,
|
|
1
|
+
{"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,6CAA6C;AAE7C,2DAAiD;AAEjD;;;;GAIG;AACH,MAAa,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,0BAAa,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,0BAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACjE,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IAChB,CAAC;;AAlDF,wCAmDC;AAlDA;;GAEG;AACoB,mBAAI,GAAG,2CAA2C,CAAC;AAE1E;;GAEG;AACoB,yBAAU,GAAuB;IACvD,IAAI,EAAE,cAAc,CAAC,IAAI;IACzB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,8BAAU;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/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
|
-
export { SharedCounter } from "./counter";
|
|
12
|
-
export type { ISharedCounter, ISharedCounterEvents } from "./interfaces";
|
|
11
|
+
export { SharedCounter } from "./counter.js";
|
|
12
|
+
export type { ISharedCounter, ISharedCounterEvents } from "./interfaces.js";
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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/dist/index.js
CHANGED
|
@@ -11,6 +11,6 @@ exports.SharedCounter = void 0;
|
|
|
11
11
|
*
|
|
12
12
|
* @packageDocumentation
|
|
13
13
|
*/
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "SharedCounter", { enumerable: true, get: function () { return
|
|
14
|
+
var counter_js_1 = require("./counter.js");
|
|
15
|
+
Object.defineProperty(exports, "SharedCounter", { enumerable: true, get: function () { return counter_js_1.SharedCounter; } });
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;GAKG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;GAKG;AAEH,2CAA6C;AAApC,2GAAA,aAAa,OAAA","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"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/counter";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-rc.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-rc.2.0.1";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/counter";
|
|
11
|
-
exports.pkgVersion = "2.0.0-rc.
|
|
11
|
+
exports.pkgVersion = "2.0.0-rc.2.0.1";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,yBAAyB,CAAC;AACpC,QAAA,UAAU,GAAG,gBAAgB,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-rc.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,yBAAyB,CAAC;AACpC,QAAA,UAAU,GAAG,gBAAgB,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-rc.2.0.1\";\n"]}
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -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,EAC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ed 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"]}
|