@fluidframework/counter 0.56.0 → 0.57.0-51086
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/dist/counter.d.ts +0 -5
- package/dist/counter.d.ts.map +1 -1
- package/dist/counter.js +0 -6
- package/dist/counter.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/counter.d.ts +0 -5
- package/lib/counter.d.ts.map +1 -1
- package/lib/counter.js +0 -6
- package/lib/counter.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +8 -8
- package/src/counter.ts +1 -8
- package/src/packageVersion.ts +1 -1
package/dist/counter.d.ts
CHANGED
|
@@ -75,11 +75,6 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
75
75
|
* @internal
|
|
76
76
|
*/
|
|
77
77
|
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
82
|
-
protected registerCore(): void;
|
|
83
78
|
/**
|
|
84
79
|
* Called when the object has disconnected from the delta stream.
|
|
85
80
|
* @internal
|
package/dist/counter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAA2B,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE7G,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAoBpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,aAAc,SAAQ,YAAY,CAAC,oBAAoB,CAAE,YAAW,cAAc;IAC3F;;;;;;OAMG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM;IAIjE;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C,OAAO,CAAC,MAAM,CAAa;IAE3B;;OAEG;IACH,IAAW,KAAK,WAEf;IAED;;OAEG;IACI,SAAS,CAAC,eAAe,EAAE,MAAM;IAgBxC,OAAO,CAAC,aAAa;IAKrB;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAU5E;;;OAGG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxE;;;OAGG;IACH,SAAS,CAAC,YAAY;IAEtB;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;IAelG;;;OAGG;IACH,SAAS,CAAC,cAAc;CAG3B"}
|
package/dist/counter.js
CHANGED
|
@@ -112,12 +112,6 @@ class SharedCounter extends shared_object_base_1.SharedObject {
|
|
|
112
112
|
const content = await driver_utils_1.readAndParse(storage, snapshotFileName);
|
|
113
113
|
this._value = content.value;
|
|
114
114
|
}
|
|
115
|
-
/**
|
|
116
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}
|
|
117
|
-
* @internal
|
|
118
|
-
*/
|
|
119
|
-
registerCore() {
|
|
120
|
-
}
|
|
121
115
|
/**
|
|
122
116
|
* Called when the object has disconnected from the delta stream.
|
|
123
117
|
* @internal
|
package/dist/counter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+
|
|
1
|
+
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+EAA8F;AAM9F,+DAA4D;AAE5D,2EAA6G;AAC7G,qDAAkD;AAmBlD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAa,aAAc,SAAQ,iCAAkC;IAArE;;QAqBY,WAAM,GAAW,CAAC,CAAC;IAgG/B,CAAC;IApHG;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAC7D,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,+BAAc,CAAC,IAAI,CAAkB,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU;QACpB,OAAO,IAAI,+BAAc,EAAE,CAAC;IAChC,CAAC;IAID;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,eAAuB;QACpC,uGAAuG;QACvG,wGAAwG;QACxG,IAAI,eAAe,GAAG,CAAC,KAAK,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACvD;QAED,MAAM,EAAE,GAAwB;YAC5B,IAAI,EAAE,WAAW;YACjB,eAAe;SAClB,CAAC;QAEF,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACpC,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\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { createSingleBlobSummary, IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { CounterFactory } from \"./counterFactory\";\nimport { ISharedCounter, ISharedCounterEvents } from \"./interfaces\";\n\n/**\n * Describes the op format for incrementing the counter\n */\ninterface IIncrementOperation {\n type: \"increment\";\n incrementAmount: number;\n}\n\n/**\n * Used in snapshotting.\n */\ninterface ICounterSnapshotFormat {\n // The value of the counter\n value: number;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * A `SharedCounter` is a shared object which holds a number that can be incremented or decremented.\n * @public\n *\n * @remarks\n * ### Creation\n *\n * To create a `SharedCounter`, get the factory and call create 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 * ### Usage\n *\n * Once created, you can call `increment` to modify the value with either a positive or 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 `\"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 */\nexport class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {\n /**\n * Create a new shared counter\n *\n * @param runtime - data store runtime the new shared counter belongs to\n * @param id - optional name of the shared counter\n * @returns newly create shared counter (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string) {\n return runtime.createChannel(id, CounterFactory.Type) as SharedCounter;\n }\n\n /**\n * Get a factory for SharedCounter to register with the data store.\n *\n * @returns a factory that creates and load SharedCounter\n */\n public static getFactory(): IChannelFactory {\n return new CounterFactory();\n }\n\n private _value: number = 0;\n\n /**\n * {@inheritDoc ISharedCounter.value}\n */\n public get value() {\n return this._value;\n }\n\n /**\n * {@inheritDoc ISharedCounter.increment}\n */\n public increment(incrementAmount: number) {\n // Incrementing by floating point numbers will be eventually inconsistent, since the order in which the\n // increments are applied affects the result. A more-robust solution would be required to support this.\n if (incrementAmount % 1 !== 0) {\n throw new Error(\"Must increment by a whole number\");\n }\n\n const op: IIncrementOperation = {\n type: \"increment\",\n incrementAmount,\n };\n\n this.incrementCore(incrementAmount);\n this.submitLocalMessage(op);\n }\n\n private incrementCore(incrementAmount: number) {\n this._value += incrementAmount;\n this.emit(\"incremented\", incrementAmount, this._value);\n }\n\n /**\n * Create a summary for the counter\n *\n * @returns the summary of the current state of the counter\n * @internal\n */\n protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n // Get a serializable form of data\n const content: ICounterSnapshotFormat = {\n value: this.value,\n };\n\n // And then construct the summary for it\n return createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n * @internal\n */\n protected async loadCore(storage: IChannelStorageService): Promise<void> {\n const content = await readAndParse<ICounterSnapshotFormat>(storage, snapshotFileName);\n\n this._value = content.value;\n }\n\n /**\n * Called when the object has disconnected from the delta stream.\n * @internal\n */\n protected onDisconnect() { }\n\n /**\n * Process a counter operation\n *\n * @param message - the message to prepare\n * @param local - whether the message was sent by the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @internal\n */\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n if (message.type === MessageType.Operation && !local) {\n const op = message.contents as IIncrementOperation;\n\n switch (op.type) {\n case \"increment\":\n this.incrementCore(op.incrementAmount);\n break;\n\n default:\n throw new Error(\"Unknown operation\");\n }\n }\n }\n\n /**\n * Not implemented.\n * @internal\n */\n protected applyStashedOp() {\n throw new Error(\"not implemented\");\n }\n}\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 = "0.
|
|
8
|
+
export declare const pkgVersion = "0.57.0-51086";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +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,
|
|
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,iBAAiB,CAAC"}
|
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 = "0.
|
|
11
|
+
exports.pkgVersion = "0.57.0-51086";
|
|
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,
|
|
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,cAAc,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 = \"0.57.0-51086\";\n"]}
|
package/lib/counter.d.ts
CHANGED
|
@@ -75,11 +75,6 @@ export declare class SharedCounter extends SharedObject<ISharedCounterEvents> im
|
|
|
75
75
|
* @internal
|
|
76
76
|
*/
|
|
77
77
|
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
82
|
-
protected registerCore(): void;
|
|
83
78
|
/**
|
|
84
79
|
* Called when the object has disconnected from the delta stream.
|
|
85
80
|
* @internal
|
package/lib/counter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAA2B,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE7G,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAoBpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,aAAc,SAAQ,YAAY,CAAC,oBAAoB,CAAE,YAAW,cAAc;IAC3F;;;;;;OAMG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM;IAIjE;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C,OAAO,CAAC,MAAM,CAAa;IAE3B;;OAEG;IACH,IAAW,KAAK,WAEf;IAED;;OAEG;IACI,SAAS,CAAC,eAAe,EAAE,MAAM;IAgBxC,OAAO,CAAC,aAAa;IAKrB;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAU5E;;;OAGG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxE;;;OAGG;IACH,SAAS,CAAC,YAAY;IAEtB;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;IAelG;;;OAGG;IACH,SAAS,CAAC,cAAc;CAG3B"}
|
package/lib/counter.js
CHANGED
|
@@ -109,12 +109,6 @@ export class SharedCounter extends SharedObject {
|
|
|
109
109
|
const content = await readAndParse(storage, snapshotFileName);
|
|
110
110
|
this._value = content.value;
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}
|
|
114
|
-
* @internal
|
|
115
|
-
*/
|
|
116
|
-
registerCore() {
|
|
117
|
-
}
|
|
118
112
|
/**
|
|
119
113
|
* Called when the object has disconnected from the delta stream.
|
|
120
114
|
* @internal
|
package/lib/counter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAM9F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAoB,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAC7G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAmBlD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAkC;IAArE;;QAqBY,WAAM,GAAW,CAAC,CAAC;IAgG/B,CAAC;IApHG;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAC7D,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,CAAkB,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU;QACpB,OAAO,IAAI,cAAc,EAAE,CAAC;IAChC,CAAC;IAID;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,eAAuB;QACpC,uGAAuG;QACvG,wGAAwG;QACxG,IAAI,eAAe,GAAG,CAAC,KAAK,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACvD;QAED,MAAM,EAAE,GAAwB;YAC5B,IAAI,EAAE,WAAW;YACjB,eAAe;SAClB,CAAC;QAEF,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACpC,IAAI,CAAC,kBAAkB,CAAC,EAAE,C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T License.\n */\n\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { createSingleBlobSummary, IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { CounterFactory } from \"./counterFactory\";\nimport { ISharedCounter, ISharedCounterEvents } from \"./interfaces\";\n\n/**\n * Describes the op format for incrementing the counter\n */\ninterface IIncrementOperation {\n type: \"increment\";\n incrementAmount: number;\n}\n\n/**\n * Used in snapshotting.\n */\ninterface ICounterSnapshotFormat {\n // The value of the counter\n value: number;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * A `SharedCounter` is a shared object which holds a number that can be incremented or decremented.\n * @public\n *\n * @remarks\n * ### Creation\n *\n * To create a `SharedCounter`, get the factory and call create 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 * ### Usage\n *\n * Once created, you can call `increment` to modify the value with either a positive or 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 `\"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 */\nexport class SharedCounter extends SharedObject<ISharedCounterEvents> implements ISharedCounter {\n /**\n * Create a new shared counter\n *\n * @param runtime - data store runtime the new shared counter belongs to\n * @param id - optional name of the shared counter\n * @returns newly create shared counter (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string) {\n return runtime.createChannel(id, CounterFactory.Type) as SharedCounter;\n }\n\n /**\n * Get a factory for SharedCounter to register with the data store.\n *\n * @returns a factory that creates and load SharedCounter\n */\n public static getFactory(): IChannelFactory {\n return new CounterFactory();\n }\n\n private _value: number = 0;\n\n /**\n * {@inheritDoc ISharedCounter.value}\n */\n public get value() {\n return this._value;\n }\n\n /**\n * {@inheritDoc ISharedCounter.increment}\n */\n public increment(incrementAmount: number) {\n // Incrementing by floating point numbers will be eventually inconsistent, since the order in which the\n // increments are applied affects the result. A more-robust solution would be required to support this.\n if (incrementAmount % 1 !== 0) {\n throw new Error(\"Must increment by a whole number\");\n }\n\n const op: IIncrementOperation = {\n type: \"increment\",\n incrementAmount,\n };\n\n this.incrementCore(incrementAmount);\n this.submitLocalMessage(op);\n }\n\n private incrementCore(incrementAmount: number) {\n this._value += incrementAmount;\n this.emit(\"incremented\", incrementAmount, this._value);\n }\n\n /**\n * Create a summary for the counter\n *\n * @returns the summary of the current state of the counter\n * @internal\n */\n protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n // Get a serializable form of data\n const content: ICounterSnapshotFormat = {\n value: this.value,\n };\n\n // And then construct the summary for it\n return createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n * @internal\n */\n protected async loadCore(storage: IChannelStorageService): Promise<void> {\n const content = await readAndParse<ICounterSnapshotFormat>(storage, snapshotFileName);\n\n this._value = content.value;\n }\n\n /**\n * Called when the object has disconnected from the delta stream.\n * @internal\n */\n protected onDisconnect() { }\n\n /**\n * Process a counter operation\n *\n * @param message - the message to prepare\n * @param local - whether the message was sent by the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @internal\n */\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n if (message.type === MessageType.Operation && !local) {\n const op = message.contents as IIncrementOperation;\n\n switch (op.type) {\n case \"increment\":\n this.incrementCore(op.incrementAmount);\n break;\n\n default:\n throw new Error(\"Unknown operation\");\n }\n }\n }\n\n /**\n * Not implemented.\n * @internal\n */\n protected applyStashedOp() {\n throw new Error(\"not implemented\");\n }\n}\n"]}
|
package/lib/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 = "0.
|
|
8
|
+
export declare const pkgVersion = "0.57.0-51086";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +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,
|
|
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,iBAAiB,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +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,
|
|
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,cAAc,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 = \"0.57.0-51086\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/counter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0-51086",
|
|
4
4
|
"description": "Counter DDS",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": "https://github.com/microsoft/FluidFramework",
|
|
@@ -55,17 +55,17 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@fluidframework/common-utils": "^0.32.1",
|
|
57
57
|
"@fluidframework/core-interfaces": "^0.42.0",
|
|
58
|
-
"@fluidframework/datastore-definitions": "
|
|
59
|
-
"@fluidframework/driver-utils": "
|
|
58
|
+
"@fluidframework/datastore-definitions": "0.57.0-51086",
|
|
59
|
+
"@fluidframework/driver-utils": "0.57.0-51086",
|
|
60
60
|
"@fluidframework/protocol-definitions": "^0.1026.0",
|
|
61
|
-
"@fluidframework/runtime-definitions": "
|
|
62
|
-
"@fluidframework/shared-object-base": "
|
|
61
|
+
"@fluidframework/runtime-definitions": "0.57.0-51086",
|
|
62
|
+
"@fluidframework/shared-object-base": "0.57.0-51086"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@fluidframework/build-common": "^0.23.0",
|
|
66
|
-
"@fluidframework/eslint-config-fluid": "^0.
|
|
67
|
-
"@fluidframework/mocha-test-setup": "
|
|
68
|
-
"@fluidframework/test-runtime-utils": "
|
|
66
|
+
"@fluidframework/eslint-config-fluid": "^0.26.0-0",
|
|
67
|
+
"@fluidframework/mocha-test-setup": "0.57.0-51086",
|
|
68
|
+
"@fluidframework/test-runtime-utils": "0.57.0-51086",
|
|
69
69
|
"@microsoft/api-extractor": "^7.16.1",
|
|
70
70
|
"@rushstack/eslint-config": "^2.5.1",
|
|
71
71
|
"@types/mocha": "^8.2.2",
|
package/src/counter.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ISequencedDocumentMessage,
|
|
6
|
+
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import {
|
|
8
8
|
IFluidDataStoreRuntime,
|
|
9
9
|
IChannelStorageService,
|
|
@@ -144,13 +144,6 @@ export class SharedCounter extends SharedObject<ISharedCounterEvents> implements
|
|
|
144
144
|
this._value = content.value;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
/**
|
|
148
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}
|
|
149
|
-
* @internal
|
|
150
|
-
*/
|
|
151
|
-
protected registerCore() {
|
|
152
|
-
}
|
|
153
|
-
|
|
154
147
|
/**
|
|
155
148
|
* Called when the object has disconnected from the delta stream.
|
|
156
149
|
* @internal
|
package/src/packageVersion.ts
CHANGED