@fluidframework/counter 2.0.0-dev-rc.3.0.0.250606 → 2.0.0-dev-rc.3.0.0.254274

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.
@@ -13,7 +13,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
13
13
  import { ISharedObject } from '@fluidframework/shared-object-base';
14
14
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
15
15
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
16
- import { SharedObject } from '@fluidframework/shared-object-base';
16
+ import { SharedObject } from '@fluidframework/shared-object-base/internal';
17
17
 
18
18
  // @alpha
19
19
  export interface ISharedCounter extends ISharedObject<ISharedCounterEvents> {
@@ -14,7 +14,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
14
14
  import { ISharedObject } from '@fluidframework/shared-object-base';
15
15
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
16
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
17
+ import { SharedObject } from '@fluidframework/shared-object-base/internal';
18
18
 
19
19
  /**
20
20
  * A shared object that holds a number that can be incremented or decremented.
@@ -14,7 +14,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
14
14
  import { ISharedObject } from '@fluidframework/shared-object-base';
15
15
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
16
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
17
+ import { SharedObject } from '@fluidframework/shared-object-base/internal';
18
18
 
19
19
  /* Excluded from this release type: ISharedCounter */
20
20
 
@@ -14,7 +14,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
14
14
  import { ISharedObject } from '@fluidframework/shared-object-base';
15
15
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
16
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
17
+ import { SharedObject } from '@fluidframework/shared-object-base/internal';
18
18
 
19
19
  /* Excluded from this release type: ISharedCounter */
20
20
 
@@ -14,7 +14,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
14
14
  import { ISharedObject } from '@fluidframework/shared-object-base';
15
15
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
16
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
17
+ import { SharedObject } from '@fluidframework/shared-object-base/internal';
18
18
 
19
19
  /**
20
20
  * A shared object that holds a number that can be incremented or decremented.
package/dist/counter.d.ts CHANGED
@@ -5,7 +5,8 @@
5
5
  import { type IChannelAttributes, type IChannelFactory, type IChannelStorageService, type IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
6
6
  import { type ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
7
  import { type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
8
- import { type IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
8
+ import { type IFluidSerializer } from "@fluidframework/shared-object-base";
9
+ import { SharedObject } from "@fluidframework/shared-object-base/internal";
9
10
  import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces.js";
10
11
  /**
11
12
  * {@inheritDoc ISharedCounter}
@@ -1 +1 @@
1
- {"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,KAAK,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AACnG,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EACN,KAAK,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.js CHANGED
@@ -5,17 +5,17 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SharedCounter = void 0;
8
- const core_utils_1 = require("@fluidframework/core-utils");
9
- const driver_utils_1 = require("@fluidframework/driver-utils");
8
+ const internal_1 = require("@fluidframework/core-utils/internal");
9
+ const internal_2 = require("@fluidframework/driver-utils/internal");
10
10
  const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
11
- const shared_object_base_1 = require("@fluidframework/shared-object-base");
11
+ const internal_3 = require("@fluidframework/shared-object-base/internal");
12
12
  const counterFactory_js_1 = require("./counterFactory.js");
13
13
  const snapshotFileName = "header";
14
14
  /**
15
15
  * {@inheritDoc ISharedCounter}
16
16
  * @alpha
17
17
  */
18
- class SharedCounter extends shared_object_base_1.SharedObject {
18
+ class SharedCounter extends internal_3.SharedObject {
19
19
  /**
20
20
  * Create a new {@link SharedCounter}.
21
21
  *
@@ -76,13 +76,13 @@ class SharedCounter extends shared_object_base_1.SharedObject {
76
76
  value: this.value,
77
77
  };
78
78
  // And then construct the summary for it
79
- return (0, shared_object_base_1.createSingleBlobSummary)(snapshotFileName, JSON.stringify(content));
79
+ return (0, internal_3.createSingleBlobSummary)(snapshotFileName, JSON.stringify(content));
80
80
  }
81
81
  /**
82
82
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
83
83
  */
84
84
  async loadCore(storage) {
85
- const content = await (0, driver_utils_1.readAndParse)(storage, snapshotFileName);
85
+ const content = await (0, internal_2.readAndParse)(storage, snapshotFileName);
86
86
  this._value = content.value;
87
87
  }
88
88
  /**
@@ -119,7 +119,7 @@ class SharedCounter extends shared_object_base_1.SharedObject {
119
119
  const counterOp = op;
120
120
  // TODO: Clean up error code linter violations repo-wide.
121
121
  // eslint-disable-next-line unicorn/numeric-separators-style
122
- (0, core_utils_1.assert)(counterOp.type === "increment", 0x3ec /* Op type is not increment */);
122
+ (0, internal_1.assert)(counterOp.type === "increment", 0x3ec /* Op type is not increment */);
123
123
  this.increment(counterOp.incrementAmount);
124
124
  }
125
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAOpD,+DAA4D;AAC5D,+EAAmG;AAEnG,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;QAY1C,WAAM,GAAW,CAAC,CAAC;IAX3B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,kCAAc,EAAE,CAAC;IAC7B,CAAC;IAID;;OAEG;IACH,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,eAAuB;QACvC,uGAAuG;QACvG,wGAAwG;QACxG,IAAI,eAAe,GAAG,CAAC,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACpD;QAED,MAAM,EAAE,GAAwB;YAC/B,IAAI,EAAE,WAAW;YACjB,eAAe;SACf,CAAC;QAEF,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACpC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAEO,aAAa,CAAC,eAAuB;QAC5C,IAAI,CAAC,MAAM,IAAI,eAAe,CAAC;QAC/B,IAAI,C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AE7E,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 {\n\ttype IChannelAttributes,\n\ttype IChannelFactory,\n\ttype IChannelStorageService,\n\ttype IFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { type ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { type ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\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"]}
1
+ {"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAO7D,oEAAqE;AACrE,+EAAmG;AAGnG,0EAAoG;AAEpG,2DAAqD;AAqBrD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAa,aAAc,SAAQ,uBAAkC;IACpE;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,E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BAAY,EAAyB,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,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,iBAAM,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/internal\";\nimport {\n\ttype IChannelAttributes,\n\ttype IChannelFactory,\n\ttype IChannelStorageService,\n\ttype IFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport { type ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { type ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { type IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { SharedObject, createSingleBlobSummary } from \"@fluidframework/shared-object-base/internal\";\n\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"]}
@@ -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,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,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"}
1
+ {"version":3,"file":"counterFactory.d.ts","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,uCAAuC,CAAC;AAG/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"}
@@ -1 +1 @@
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 IChannelFactory,\n\ttype IChannelServices,\n\ttype IFluidDataStoreRuntime,\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"]}
1
+ {"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,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 IChannelFactory,\n\ttype IChannelServices,\n\ttype IFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\n\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"]}
@@ -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.3.0.0.250606";
8
+ export declare const pkgVersion = "2.0.0-dev-rc.3.0.0.254274";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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-dev-rc.3.0.0.250606";
11
+ exports.pkgVersion = "2.0.0-dev-rc.3.0.0.254274";
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,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.3.0.0.250606\";\n"]}
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,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.3.0.0.254274\";\n"]}
@@ -14,7 +14,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
14
14
  import { ISharedObject } from '@fluidframework/shared-object-base';
15
15
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
16
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
17
+ import { SharedObject } from '@fluidframework/shared-object-base/internal';
18
18
 
19
19
  /**
20
20
  * A shared object that holds a number that can be incremented or decremented.
@@ -14,7 +14,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
14
14
  import { ISharedObject } from '@fluidframework/shared-object-base';
15
15
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
16
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
17
+ import { SharedObject } from '@fluidframework/shared-object-base/internal';
18
18
 
19
19
  /* Excluded from this release type: ISharedCounter */
20
20
 
@@ -14,7 +14,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
14
14
  import { ISharedObject } from '@fluidframework/shared-object-base';
15
15
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
16
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
17
+ import { SharedObject } from '@fluidframework/shared-object-base/internal';
18
18
 
19
19
  /* Excluded from this release type: ISharedCounter */
20
20
 
@@ -14,7 +14,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
14
14
  import { ISharedObject } from '@fluidframework/shared-object-base';
15
15
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
16
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
17
+ import { SharedObject } from '@fluidframework/shared-object-base/internal';
18
18
 
19
19
  /**
20
20
  * A shared object that holds a number that can be incremented or decremented.
package/lib/counter.d.ts CHANGED
@@ -5,7 +5,8 @@
5
5
  import { type IChannelAttributes, type IChannelFactory, type IChannelStorageService, type IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
6
6
  import { type ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
7
  import { type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
8
- import { type IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
8
+ import { type IFluidSerializer } from "@fluidframework/shared-object-base";
9
+ import { SharedObject } from "@fluidframework/shared-object-base/internal";
9
10
  import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces.js";
10
11
  /**
11
12
  * {@inheritDoc ISharedCounter}
@@ -1 +1 @@
1
- {"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,KAAK,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AACnG,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qCAA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O,GAAG,IAAI;CAU3C"}
package/lib/counter.js CHANGED
@@ -2,10 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert } from "@fluidframework/core-utils";
6
- import { readAndParse } from "@fluidframework/driver-utils";
5
+ import { assert } from "@fluidframework/core-utils/internal";
6
+ import { readAndParse } from "@fluidframework/driver-utils/internal";
7
7
  import { MessageType } from "@fluidframework/protocol-definitions";
8
- import { SharedObject, createSingleBlobSummary, } from "@fluidframework/shared-object-base";
8
+ import { SharedObject, createSingleBlobSummary } from "@fluidframework/shared-object-base/internal";
9
9
  import { CounterFactory } from "./counterFactory.js";
10
10
  const snapshotFileName = "header";
11
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAOpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAkC,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEnG,OAAO,EAEN,YAAY,EACZ,uBAAuB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAqBrD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAkC;IACpE;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,cAAc,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;QAY1C,WAAM,GAAW,CAAC,CAAC;IAX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;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 {\n\ttype IChannelAttributes,\n\ttype IChannelFactory,\n\ttype IChannelStorageService,\n\ttype IFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { type ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { type ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\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"]}
1
+ {"version":3,"file":"counter.js","sourceRoot":"","sources":["../src/counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAO7D,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAkC,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGnG,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAEpG,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAqBrD,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAkC;IACpE;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,cAAc,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;QAY1C,WAAM,GAAW,CAAC,CAAC;IAX3B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,cAAc,EAAE,CAAC;IAC7B,CAAC;IAID;;OAEG;IACH,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,eAAuB;QACvC,uGAAuG;QACvG,wGAAwG;QACxG,IAAI,eAAe,GAA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Ae,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/internal\";\nimport {\n\ttype IChannelAttributes,\n\ttype IChannelFactory,\n\ttype IChannelStorageService,\n\ttype IFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport { type ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { type ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { type IFluidSerializer } from \"@fluidframework/shared-object-base\";\nimport { SharedObject, createSingleBlobSummary } from \"@fluidframework/shared-object-base/internal\";\n\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"]}
@@ -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,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,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"}
1
+ {"version":3,"file":"counterFactory.d.ts","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,uCAAuC,CAAC;AAG/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,IAA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,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 IChannelFactory,\n\ttype IChannelServices,\n\ttype IFluidDataStoreRuntime,\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"]}
1
+ {"version":3,"file":"counterFactory.js","sourceRoot":"","sources":["../src/counterFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,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 IChannelFactory,\n\ttype IChannelServices,\n\ttype IFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\n\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"]}
@@ -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.3.0.0.250606";
8
+ export declare const pkgVersion = "2.0.0-dev-rc.3.0.0.254274";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/counter";
8
- export const pkgVersion = "2.0.0-dev-rc.3.0.0.250606";
8
+ export const pkgVersion = "2.0.0-dev-rc.3.0.0.254274";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -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,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.3.0.0.250606\";\n"]}
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.3.0.0.254274\";\n"]}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.42.3"
9
+ }
10
+ ]
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/counter",
3
- "version": "2.0.0-dev-rc.3.0.0.250606",
3
+ "version": "2.0.0-dev-rc.3.0.0.254274",
4
4
  "description": "Counter DDS",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -14,16 +14,6 @@
14
14
  "type": "module",
15
15
  "exports": {
16
16
  ".": {
17
- "import": {
18
- "types": "./lib/index.d.ts",
19
- "default": "./lib/index.js"
20
- },
21
- "require": {
22
- "types": "./dist/index.d.ts",
23
- "default": "./dist/index.js"
24
- }
25
- },
26
- "./public": {
27
17
  "import": {
28
18
  "types": "./lib/counter-public.d.ts",
29
19
  "default": "./lib/index.js"
@@ -55,7 +45,7 @@
55
45
  }
56
46
  },
57
47
  "main": "dist/index.js",
58
- "types": "dist/index.d.ts",
48
+ "types": "./dist/counter-public.d.ts",
59
49
  "c8": {
60
50
  "all": true,
61
51
  "cache-dir": "nyc/.cache",
@@ -77,25 +67,25 @@
77
67
  "temp-directory": "nyc/.nyc_output"
78
68
  },
79
69
  "dependencies": {
80
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.3.0.0.250606",
81
- "@fluidframework/core-utils": "2.0.0-dev-rc.3.0.0.250606",
82
- "@fluidframework/datastore-definitions": "2.0.0-dev-rc.3.0.0.250606",
83
- "@fluidframework/driver-utils": "2.0.0-dev-rc.3.0.0.250606",
70
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.3.0.0.254274",
71
+ "@fluidframework/core-utils": "2.0.0-dev-rc.3.0.0.254274",
72
+ "@fluidframework/datastore-definitions": "2.0.0-dev-rc.3.0.0.254274",
73
+ "@fluidframework/driver-utils": "2.0.0-dev-rc.3.0.0.254274",
84
74
  "@fluidframework/protocol-definitions": "^3.2.0",
85
- "@fluidframework/runtime-definitions": "2.0.0-dev-rc.3.0.0.250606",
86
- "@fluidframework/shared-object-base": "2.0.0-dev-rc.3.0.0.250606"
75
+ "@fluidframework/runtime-definitions": "2.0.0-dev-rc.3.0.0.254274",
76
+ "@fluidframework/shared-object-base": "2.0.0-dev-rc.3.0.0.254274"
87
77
  },
88
78
  "devDependencies": {
89
- "@arethetypeswrong/cli": "^0.13.3",
79
+ "@arethetypeswrong/cli": "^0.15.2",
90
80
  "@biomejs/biome": "^1.6.2",
91
- "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.3.0.0.250606",
81
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.3.0.0.254274",
92
82
  "@fluid-tools/build-cli": "^0.34.0",
93
83
  "@fluidframework/build-common": "^2.0.3",
94
84
  "@fluidframework/build-tools": "^0.34.0",
95
- "@fluidframework/container-definitions": "2.0.0-dev-rc.3.0.0.250606",
85
+ "@fluidframework/container-definitions": "2.0.0-dev-rc.3.0.0.254274",
96
86
  "@fluidframework/counter-previous": "npm:@fluidframework/counter@2.0.0-internal.8.0.0",
97
87
  "@fluidframework/eslint-config-fluid": "^5.1.0",
98
- "@fluidframework/test-runtime-utils": "2.0.0-dev-rc.3.0.0.250606",
88
+ "@fluidframework/test-runtime-utils": "2.0.0-dev-rc.3.0.0.254274",
99
89
  "@microsoft/api-extractor": "^7.42.3",
100
90
  "@types/mocha": "^9.1.1",
101
91
  "@types/node": "^18.19.0",
@@ -141,7 +131,6 @@
141
131
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
142
132
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
143
133
  "check:are-the-types-wrong": "attw --pack . --entrypoints .",
144
- "check:biome": "biome check .",
145
134
  "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
146
135
  "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
147
136
  "ci:build:docs": "api-extractor run",
@@ -149,7 +138,6 @@
149
138
  "eslint": "eslint --format stylish src",
150
139
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
151
140
  "format": "fluid-build --task format .",
152
- "format:biome": "biome check --apply .",
153
141
  "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
154
142
  "lint": "fluid-build . --task lint",
155
143
  "lint:fix": "fluid-build . --task eslint:fix --task format",
package/src/counter.ts CHANGED
@@ -3,21 +3,19 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/core-utils";
6
+ import { assert } from "@fluidframework/core-utils/internal";
7
7
  import {
8
8
  type IChannelAttributes,
9
9
  type IChannelFactory,
10
10
  type IChannelStorageService,
11
11
  type IFluidDataStoreRuntime,
12
12
  } from "@fluidframework/datastore-definitions";
13
- import { readAndParse } from "@fluidframework/driver-utils";
13
+ import { readAndParse } from "@fluidframework/driver-utils/internal";
14
14
  import { type ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
15
15
  import { type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
16
- import {
17
- type IFluidSerializer,
18
- SharedObject,
19
- createSingleBlobSummary,
20
- } from "@fluidframework/shared-object-base";
16
+ import { type IFluidSerializer } from "@fluidframework/shared-object-base";
17
+ import { SharedObject, createSingleBlobSummary } from "@fluidframework/shared-object-base/internal";
18
+
21
19
  import { CounterFactory } from "./counterFactory.js";
22
20
  import { type ISharedCounter, type ISharedCounterEvents } from "./interfaces.js";
23
21
 
@@ -9,6 +9,7 @@ import {
9
9
  type IChannelServices,
10
10
  type IFluidDataStoreRuntime,
11
11
  } from "@fluidframework/datastore-definitions";
12
+
12
13
  import { SharedCounter } from "./counter.js";
13
14
  import { type ISharedCounter } from "./interfaces.js";
14
15
  import { pkgVersion } from "./packageVersion.js";
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/counter";
9
- export const pkgVersion = "2.0.0-dev-rc.3.0.0.250606";
9
+ export const pkgVersion = "2.0.0-dev-rc.3.0.0.254274";
@@ -1,218 +0,0 @@
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 { AttachState } from "@fluidframework/container-definitions";
7
- import { MockContainerRuntimeFactory, MockContainerRuntimeFactoryForReconnection, MockFluidDataStoreRuntime, MockSharedObjectServices, MockStorage, } from "@fluidframework/test-runtime-utils";
8
- import { CounterFactory } from "../counterFactory.js";
9
- import { SharedCounter } from "../index.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
@@ -1 +0,0 @@
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;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EACN,2BAA2B,EAC3B,0CAA0C,EAE1C,yBAAyB,EACzB,wBAAwB,EACxB,WAAW,GACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAuB,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,iBAAkB,SAAQ,aAAa;IACrC,kBAAkB,CAAC,OAAgB;QACzC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;CACD;AAED,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC9B,IAAI,WAA2B,CAAC;IAChC,IAAI,gBAA2C,CAAC;IAChD,IAAI,OAAwB,CAAC;IAE7B,UAAU,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;QAC1C,gBAAgB,GAAG,IAAI,yBAAyB,EAAE,CAAC;QACnD,OAAO,GAAG,aAAa,CAAC,UAAU,EAAE,CAAC;QACrC,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,SAAS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CAAC,CAAC;YAC9E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,wCAAwC,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qEAAqE,EAAE,KAAK,IAAI,EAAE;YACpF,+BAA+B;YAC/B,iBAAiB,CAAC,SAAS,GAAG,KAAK,CAAC;YAEpC,qCAAqC;YACrC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YAE1B,8BAA8B;YAC9B,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC;YAEnC,wBAAwB;YACxB,uBAAuB,CAAC,kBAAkB,EAAE,CAAC;YAE7C,4DAA4D;YAC5D,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,uCAAuC,CAAC,CAAC;YAC7E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,EAAE,wCAAwC,CAAC,CAAC;YAE/E,gCAAgC;YAChC,iBAAiB,CAAC,SAAS,GAAG,KAAK,CAAC;YAEpC,sCAAsC;YACtC,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;YAE3B,+BAA+B;YAC/B,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC;YAEnC,wBAAwB;YACxB,uBAAuB,CAAC,kBAAkB,EAAE,CAAC;YAE7C,4DAA4D;YAC5D,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,uCAAuC,CAAC,CAAC;YAC9E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,wCAAwC,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\tMockContainerRuntimeFactory,\n\tMockContainerRuntimeFactoryForReconnection,\n\ttype MockContainerRuntimeForReconnection,\n\tMockFluidDataStoreRuntime,\n\tMockSharedObjectServices,\n\tMockStorage,\n} from \"@fluidframework/test-runtime-utils\";\nimport { CounterFactory } from \"../counterFactory.js\";\nimport { type ISharedCounter, SharedCounter } from \"../index.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"]}
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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"]}