@fluidframework/cell 2.0.0-dev.3.1.0.125672 → 2.0.0-dev.4.2.0.153917

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/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # @fluidframework/cell
2
+
3
+ ## 2.0.0-internal.4.1.0
4
+
5
+ Dependency updates only.
package/README.md CHANGED
@@ -5,8 +5,7 @@ The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value
5
5
  <!-- AUTO-GENERATED-CONTENT:START (README_INSTALLATION_SECTION:includeHeading=TRUE) -->
6
6
 
7
7
  <!-- prettier-ignore-start -->
8
-
9
- <!-- This section is automatically generated. To update it, make the appropriate changes to docs/md-magic.config.js or the embedded content, then run 'npm run build:md-magic' in the docs folder. -->
8
+ <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
10
9
 
11
10
  ## Installation
12
11
 
@@ -20,6 +19,26 @@ npm i @fluidframework/cell
20
19
 
21
20
  <!-- AUTO-GENERATED-CONTENT:END -->
22
21
 
22
+ <!-- AUTO-GENERATED-CONTENT:START (README_DEPENDENCY_GUIDELINES_SECTION:includeHeading=TRUE) -->
23
+
24
+ <!-- prettier-ignore-start -->
25
+ <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
26
+
27
+ ## Using Fluid Framework libraries
28
+
29
+ When taking a dependency on a Fluid Framework library, we recommend using a `^` (caret) version range, such as `^1.3.4`.
30
+ While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
31
+ library consumers should always prefer `^`.
32
+
33
+ Note that when depending on a library version of the form 2.0.0-internal.x.y.z, called the Fluid internal version
34
+ scheme, you must use a `>= <` dependency range. Standard `^` and `~` ranges will not work as expected. See the
35
+ [@fluid-tools/version-tools](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/version-tools/README.md)
36
+ package for more information including tools to convert between version schemes.
37
+
38
+ <!-- prettier-ignore-end -->
39
+
40
+ <!-- AUTO-GENERATED-CONTENT:END -->
41
+
23
42
  <!-- AUTO-GENERATED-CONTENT:START (README_API_DOCS_SECTION:includeHeading=TRUE) -->
24
43
 
25
44
  <!-- prettier-ignore-start -->
@@ -37,8 +56,7 @@ API documentation for **@fluidframework/cell** is available at <https://fluidfra
37
56
  <!-- AUTO-GENERATED-CONTENT:START (README_CONTRIBUTION_GUIDELINES_SECTION:includeHeading=TRUE) -->
38
57
 
39
58
  <!-- prettier-ignore-start -->
40
-
41
- <!-- This section is automatically generated. To update it, make the appropriate changes to docs/md-magic.config.js or the embedded content, then run 'npm run build:md-magic' in the docs folder. -->
59
+ <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
42
60
 
43
61
  ## Contribution Guidelines
44
62
 
@@ -65,15 +83,16 @@ Use of Microsoft trademarks or logos in modified versions of this project must n
65
83
  <!-- AUTO-GENERATED-CONTENT:START (README_HELP_SECTION:includeHeading=TRUE) -->
66
84
 
67
85
  <!-- prettier-ignore-start -->
68
-
69
- <!-- This section is automatically generated. To update it, make the appropriate changes to docs/md-magic.config.js or the embedded content, then run 'npm run build:md-magic' in the docs folder. -->
86
+ <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
70
87
 
71
88
  ## Help
72
89
 
73
- Not finding what you're looking for in this README?
74
- Check out our [GitHub Wiki](https://github.com/microsoft/FluidFramework/wiki) or [fluidframework.com](https://fluidframework.com/docs/).
90
+ Not finding what you're looking for in this README? Check out our [GitHub
91
+ Wiki](https://github.com/microsoft/FluidFramework/wiki) or [fluidframework.com](https://fluidframework.com/docs/).
92
+
93
+ Still not finding what you're looking for? Please [file an
94
+ issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
75
95
 
76
- Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
77
96
  Thank you!
78
97
 
79
98
  <!-- prettier-ignore-end -->
@@ -83,13 +102,15 @@ Thank you!
83
102
  <!-- AUTO-GENERATED-CONTENT:START (README_TRADEMARK_SECTION:includeHeading=TRUE) -->
84
103
 
85
104
  <!-- prettier-ignore-start -->
86
-
87
- <!-- This section is automatically generated. To update it, make the appropriate changes to docs/md-magic.config.js or the embedded content, then run 'npm run build:md-magic' in the docs folder. -->
105
+ <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
88
106
 
89
107
  ## Trademark
90
108
 
91
109
  This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
92
- Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
110
+
111
+ Use of these trademarks or logos must follow Microsoft's [Trademark & Brand
112
+ Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
113
+
93
114
  Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
94
115
 
95
116
  <!-- prettier-ignore-end -->
package/dist/cell.d.ts CHANGED
@@ -4,9 +4,9 @@
4
4
  */
5
5
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
6
6
  import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory, Serializable } from "@fluidframework/datastore-definitions";
7
- import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
7
+ import { AttributionKey, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
8
8
  import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
9
- import { ISharedCell, ISharedCellEvents, AttributionKey, ICellOptions } from "./interfaces";
9
+ import { ISharedCell, ISharedCellEvents } from "./interfaces";
10
10
  /**
11
11
  * {@inheritDoc ISharedCell}
12
12
  */
@@ -47,12 +47,10 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
47
47
  * Constructs a new `SharedCell`.
48
48
  * If the object is non-local an id and service interfaces will be provided.
49
49
  *
50
- * @alpha
51
- *
52
50
  * @param runtime - The data store runtime to which the `SharedCell` belongs.
53
51
  * @param id - Unique identifier for the `SharedCell`.
54
52
  */
55
- constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, options?: ICellOptions);
53
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
56
54
  /**
57
55
  * {@inheritDoc ISharedCell.get}
58
56
  */
@@ -75,7 +73,8 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
75
73
  */
76
74
  getAttribution(): AttributionKey | undefined;
77
75
  /**
78
- * Set the attribution through the SequencedDocumentMessage
76
+ * Set the Op-based attribution through the SequencedDocumentMessage,
77
+ * or set the local/detached attribution.
79
78
  */
80
79
  private setAttribution;
81
80
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAE9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAEN,gBAAgB,EAChB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACN,WAAW,EACX,iBAAiB,EAEjB,cAAc,EACd,YAAY,EACZ,MAAM,cAAc,CAAC;AA8BtB;;GAEG;AAGH,qBAAa,UAAU,CAAC,CAAC,GAAG,GAAG,CAC9B,SAAQ,YAAY,CAAC,iBAAiB,CAAC,CAAC,CAAC,CACzC,YAAW,WAAW,CAAC,CAAC,CAAC;IAEzB;;;;;;;OAOG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAI9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@@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SharedCell = void 0;
8
8
  const common_utils_1 = require("@fluidframework/common-utils");
9
9
  const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
10
- const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
11
10
  const driver_utils_1 = require("@fluidframework/driver-utils");
12
11
  const shared_object_base_1 = require("@fluidframework/shared-object-base");
13
12
  const cellFactory_1 = require("./cellFactory");
@@ -22,14 +21,11 @@ class SharedCell extends shared_object_base_1.SharedObject {
22
21
  * Constructs a new `SharedCell`.
23
22
  * If the object is non-local an id and service interfaces will be provided.
24
23
  *
25
- * @alpha
26
- *
27
24
  * @param runtime - The data store runtime to which the `SharedCell` belongs.
28
25
  * @param id - Unique identifier for the `SharedCell`.
29
26
  */
30
27
  // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
31
- constructor(id, runtime, attributes, options) {
32
- var _a, _b;
28
+ constructor(id, runtime, attributes) {
33
29
  super(id, runtime, attributes, "fluid_cell_");
34
30
  /**
35
31
  * This is used to assign a unique id to outgoing messages. It is used to track messages until
@@ -42,11 +38,7 @@ class SharedCell extends shared_object_base_1.SharedObject {
42
38
  */
43
39
  this.messageIdObserved = -1;
44
40
  this.pendingMessageIds = [];
45
- (_a = this.options) !== null && _a !== void 0 ? _a : (this.options = options);
46
- const configSetAttribution = (0, telemetry_utils_1.loggerToMonitoringContext)(this.logger).config.getBoolean("Fluid.Attribution.EnableOnNewFile");
47
- if (configSetAttribution !== undefined) {
48
- ((_b = this.options) !== null && _b !== void 0 ? _b : (this.options = {})).attribution = { track: configSetAttribution };
49
- }
41
+ this.options = runtime.options;
50
42
  }
51
43
  /**
52
44
  * Create a new `SharedCell`.
@@ -83,6 +75,7 @@ class SharedCell extends shared_object_base_1.SharedObject {
83
75
  };
84
76
  // Set the value locally.
85
77
  const previousValue = this.setCore(value);
78
+ this.setAttribution();
86
79
  // If we are not attached, don't submit the op.
87
80
  if (!this.isAttached()) {
88
81
  return;
@@ -99,6 +92,7 @@ class SharedCell extends shared_object_base_1.SharedObject {
99
92
  delete() {
100
93
  // Delete the value locally.
101
94
  const previousValue = this.deleteCore();
95
+ this.setAttribution();
102
96
  // If we are not attached, don't submit the op.
103
97
  if (!this.isAttached()) {
104
98
  return;
@@ -122,12 +116,17 @@ class SharedCell extends shared_object_base_1.SharedObject {
122
116
  return this.attribution;
123
117
  }
124
118
  /**
125
- * Set the attribution through the SequencedDocumentMessage
119
+ * Set the Op-based attribution through the SequencedDocumentMessage,
120
+ * or set the local/detached attribution.
126
121
  */
127
122
  setAttribution(message) {
128
123
  var _a, _b, _c;
129
124
  if ((_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.attribution) === null || _b === void 0 ? void 0 : _b.track) !== null && _c !== void 0 ? _c : false) {
130
- this.attribution = { type: "op", seq: message.sequenceNumber };
125
+ this.attribution = message
126
+ ? { type: "op", seq: message.sequenceNumber }
127
+ : this.isAttached()
128
+ ? { type: "local" }
129
+ : { type: "detached", id: 0 };
131
130
  }
132
131
  }
133
132
  /**
@@ -136,7 +135,10 @@ class SharedCell extends shared_object_base_1.SharedObject {
136
135
  * @returns The summary of the current state of the Cell.
137
136
  */
138
137
  summarizeCore(serializer) {
139
- const content = { value: this.data, attribution: this.attribution };
138
+ var _a;
139
+ const content = ((_a = this.attribution) === null || _a === void 0 ? void 0 : _a.type) === "local"
140
+ ? { value: this.data, attribution: undefined }
141
+ : { value: this.data, attribution: this.attribution };
140
142
  return (0, shared_object_base_1.createSingleBlobSummary)(snapshotFileName, serializer.stringify(content, this.handle));
141
143
  }
142
144
  /**
package/dist/cell.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,+EAA8F;AAC9F,qEAA4E;AAS5E,+DAA4D;AAC5D,2EAI4C;AAC5C,+CAA4C;AAmC5C,MAAM,gBAAgB,GAAG,Q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AC,qBAAqB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;QACpE,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAC5C,CAAC;CACD;AAtUD,gCAsUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelFactory,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { CellFactory } from \"./cellFactory\";\nimport {\n\tISharedCell,\n\tISharedCellEvents,\n\tICellLocalOpMetadata,\n\tAttributionKey,\n\tICellOptions,\n} from \"./interfaces\";\n\n/**\n * Description of a cell delta operation\n */\ntype ICellOperation = ISetCellOperation | IDeleteCellOperation;\n\ninterface ISetCellOperation {\n\ttype: \"setCell\";\n\tvalue: ICellValue;\n}\n\ninterface IDeleteCellOperation {\n\ttype: \"deleteCell\";\n}\n\ninterface ICellValue {\n\t/**\n\t * The actual value contained in the `Cell`, which needs to be wrapped to handle `undefined`.\n\t */\n\tvalue: unknown;\n\t/**\n\t * The attribution key contained in the `Cell`.\n\t * @alpha\n\t */\n\tattribution?: AttributionKey;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedCell}\n */\n// TODO: use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class SharedCell<T = any>\n\textends SharedObject<ISharedCellEvents<T>>\n\timplements ISharedCell<T>\n{\n\t/**\n\t * Create a new `SharedCell`.\n\t *\n\t * @param runtime - The data store runtime to which the `SharedCell` belongs.\n\t * @param id - Unique identifier for the `SharedCell`.\n\t *\n\t * @returns The newly create `SharedCell`. Note that it will not yet be attached.\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCell {\n\t\treturn runtime.createChannel(id, CellFactory.Type) as SharedCell;\n\t}\n\n\t/**\n\t * Gets the factory for the `SharedCell` to register with the data store.\n\t *\n\t * @returns A factory that creates and loads `SharedCell`s.\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new CellFactory();\n\t}\n\n\t/**\n\t * The data held by this cell.\n\t */\n\tprivate data: Serializable<T> | undefined;\n\n\t/**\n\t * This is used to assign a unique id to outgoing messages. It is used to track messages until\n\t * they are ack'd.\n\t */\n\tprivate messageId: number = -1;\n\n\t/**\n\t * This keeps track of the messageId of messages that have been ack'd. It is updated every time\n\t * we a message is ack'd with it's messageId.\n\t */\n\tprivate messageIdObserved: number = -1;\n\n\tprivate readonly pendingMessageIds: number[] = [];\n\n\tprivate attribution: AttributionKey | undefined;\n\n\tprivate readonly options: ICellOptions | undefined;\n\n\t/**\n\t * Constructs a new `SharedCell`.\n\t * If the object is non-local an id and service interfaces will be provided.\n\t *\n\t * @alpha\n\t *\n\t * @param runtime - The data store runtime to which the `SharedCell` belongs.\n\t * @param id - Unique identifier for the `SharedCell`.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\toptions?: ICellOptions,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_cell_\");\n\n\t\tthis.options ??= options;\n\n\t\tconst configSetAttribution = loggerToMonitoringContext(this.logger).config.getBoolean(\n\t\t\t\"Fluid.Attribution.EnableOnNewFile\",\n\t\t);\n\t\tif (configSetAttribution !== undefined) {\n\t\t\t(this.options ?? (this.options = {})).attribution = { track: configSetAttribution };\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.get}\n\t */\n\tpublic get(): Serializable<T> | undefined {\n\t\treturn this.data;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.set}\n\t */\n\tpublic set(value: Serializable<T>): void {\n\t\t// Serialize the value if required.\n\t\tconst operationValue: ICellValue = {\n\t\t\tvalue: this.serializer.encode(value, this.handle),\n\t\t};\n\n\t\t// Set the value locally.\n\t\tconst previousValue = this.setCore(value);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: ISetCellOperation = {\n\t\t\ttype: \"setCell\",\n\t\t\tvalue: operationValue,\n\t\t};\n\t\tthis.submitCellMessage(op, previousValue);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.delete}\n\t */\n\tpublic delete(): void {\n\t\t// Delete the value locally.\n\t\tconst previousValue = this.deleteCore();\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: IDeleteCellOperation = {\n\t\t\ttype: \"deleteCell\",\n\t\t};\n\t\tthis.submitCellMessage(op, previousValue);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.empty}\n\t */\n\tpublic empty(): boolean {\n\t\treturn this.data === undefined;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.getAttribution}\n\t * @alpha\n\t */\n\tpublic getAttribution(): AttributionKey | undefined {\n\t\treturn this.attribution;\n\t}\n\n\t/**\n\t * Set the attribution through the SequencedDocumentMessage\n\t */\n\tprivate setAttribution(message: ISequencedDocumentMessage): void {\n\t\tif (this.options?.attribution?.track ?? false) {\n\t\t\tthis.attribution = { type: \"op\", seq: message.sequenceNumber };\n\t\t}\n\t}\n\n\t/**\n\t * Creates a summary for the Cell.\n\t *\n\t * @returns The summary of the current state of the Cell.\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst content: ICellValue = { value: this.data, attribution: this.attribution };\n\t\treturn createSingleBlobSummary(\n\t\t\tsnapshotFileName,\n\t\t\tserializer.stringify(content, this.handle),\n\t\t);\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<ICellValue>(storage, snapshotFileName);\n\n\t\tthis.data = this.decode(content);\n\t\tthis.attribution = content.attribution;\n\t}\n\n\t/**\n\t * Initialize a local instance of cell.\n\t */\n\tprotected initializeLocalCore(): void {\n\t\tthis.data = undefined;\n\t}\n\n\t/**\n\t * Call back on disconnect.\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Apply inner op.\n\t *\n\t * @param content - ICellOperation content\n\t */\n\tprivate applyInnerOp(content: ICellOperation): Serializable<T> | undefined {\n\t\tswitch (content.type) {\n\t\t\tcase \"setCell\":\n\t\t\t\treturn this.setCore(this.decode(content.value));\n\n\t\t\tcase \"deleteCell\":\n\t\t\t\treturn this.deleteCore();\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t}\n\t}\n\n\t/**\n\t * Process a cell 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\tconst cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n\t\tif (this.messageId !== this.messageIdObserved) {\n\t\t\t// We are waiting for an ACK on our change to this cell - we will ignore all messages until we get it.\n\t\t\tif (local) {\n\t\t\t\tconst messageIdReceived = cellOpMetadata.pendingMessageId;\n\t\t\t\tassert(\n\t\t\t\t\tmessageIdReceived !== undefined && messageIdReceived <= this.messageId,\n\t\t\t\t\t0x00c /* \"messageId is incorrect from from the local client's ACK\" */,\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tthis.pendingMessageIds !== undefined &&\n\t\t\t\t\t\tthis.pendingMessageIds[0] === cellOpMetadata.pendingMessageId,\n\t\t\t\t\t0x471 /* Unexpected pending message received */,\n\t\t\t\t);\n\t\t\t\tthis.pendingMessageIds.shift();\n\t\t\t\t// We got an ACK. Update messageIdObserved.\n\t\t\t\tthis.messageIdObserved = cellOpMetadata.pendingMessageId;\n\t\t\t\t// update the attributor\n\t\t\t\tthis.setAttribution(message);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (message.type === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as ICellOperation;\n\t\t\t// update the attributor\n\t\t\tthis.setAttribution(message);\n\t\t\tthis.applyInnerOp(op);\n\t\t}\n\t}\n\n\tprivate setCore(value: Serializable<T>): Serializable<T> | undefined {\n\t\tconst previousLocalValue = this.get();\n\t\tthis.data = value;\n\t\tthis.emit(\"valueChanged\", value);\n\t\treturn previousLocalValue;\n\t}\n\n\tprivate deleteCore(): Serializable<T> | undefined {\n\t\tconst previousLocalValue = this.get();\n\t\tthis.data = undefined;\n\t\tthis.emit(\"delete\");\n\t\treturn previousLocalValue;\n\t}\n\n\tprivate decode(cellValue: ICellValue): Serializable<T> {\n\t\tconst value = cellValue.value;\n\t\treturn this.serializer.decode(value) as Serializable<T>;\n\t}\n\n\tprivate createLocalOpMetadata(\n\t\top: ICellOperation,\n\t\tpreviousValue?: Serializable<T>,\n\t): ICellLocalOpMetadata {\n\t\tconst pendingMessageId = ++this.messageId;\n\t\tthis.pendingMessageIds.push(pendingMessageId);\n\t\tconst localMetadata: ICellLocalOpMetadata = {\n\t\t\tpendingMessageId,\n\t\t\tpreviousValue,\n\t\t};\n\t\treturn localMetadata;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t *\n\t * @internal\n\t */\n\tprotected applyStashedOp(content: unknown): unknown {\n\t\tconst cellContent = content as ICellOperation;\n\t\tconst previousValue = this.applyInnerOp(cellContent);\n\t\treturn this.createLocalOpMetadata(cellContent, previousValue);\n\t}\n\n\t/**\n\t * Rollback a local op.\n\t *\n\t * @param content - The operation to rollback.\n\t * @param localOpMetadata - The local metadata associated with the op.\n\t */\n\t// TODO: use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tconst cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\tif (content.type === \"setCell\" || content.type === \"deleteCell\") {\n\t\t\tif (cellOpMetadata.previousValue === undefined) {\n\t\t\t\tthis.deleteCore();\n\t\t\t} else {\n\t\t\t\tthis.setCore(cellOpMetadata.previousValue as Serializable<T>);\n\t\t\t}\n\n\t\t\tconst lastPendingMessageId = this.pendingMessageIds.pop();\n\t\t\tif (lastPendingMessageId !== cellOpMetadata.pendingMessageId) {\n\t\t\t\tthrow new Error(\"Rollback op does not match last pending\");\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(\"Unsupported op for rollback\");\n\t\t}\n\t}\n\n\t/**\n\t * Submit a cell message to remote clients.\n\t *\n\t * @param op - The cell message.\n\t * @param previousValue - The value of the cell before this op.\n\t */\n\tprivate submitCellMessage(op: ICellOperation, previousValue?: Serializable<T>): void {\n\t\tconst localMetadata = this.createLocalOpMetadata(op, previousValue);\n\t\tthis.submitLocalMessage(op, localMetadata);\n\t}\n}\n"]}
1
+ {"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,+EAA8F;AAS9F,+DAA4D;AAC5D,2EAI4C;AAC5C,+CAA4C;AA6B5C,M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IACF,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,EAAkB,EAAE,aAA+B;QAC5E,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;QACpE,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAC5C,CAAC;CACD;AAlUD,gCAkUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelFactory,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions\";\nimport { AttributionKey, ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { CellFactory } from \"./cellFactory\";\nimport { ISharedCell, ISharedCellEvents, ICellLocalOpMetadata, ICellOptions } from \"./interfaces\";\n\n/**\n * Description of a cell delta operation\n */\ntype ICellOperation = ISetCellOperation | IDeleteCellOperation;\n\ninterface ISetCellOperation {\n\ttype: \"setCell\";\n\tvalue: ICellValue;\n}\n\ninterface IDeleteCellOperation {\n\ttype: \"deleteCell\";\n}\n\ninterface ICellValue {\n\t/**\n\t * The actual value contained in the `Cell`, which needs to be wrapped to handle `undefined`.\n\t */\n\tvalue: unknown;\n\t/**\n\t * The attribution key contained in the `Cell`.\n\t * @alpha\n\t */\n\tattribution?: AttributionKey;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedCell}\n */\n// TODO: use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class SharedCell<T = any>\n\textends SharedObject<ISharedCellEvents<T>>\n\timplements ISharedCell<T>\n{\n\t/**\n\t * Create a new `SharedCell`.\n\t *\n\t * @param runtime - The data store runtime to which the `SharedCell` belongs.\n\t * @param id - Unique identifier for the `SharedCell`.\n\t *\n\t * @returns The newly create `SharedCell`. Note that it will not yet be attached.\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCell {\n\t\treturn runtime.createChannel(id, CellFactory.Type) as SharedCell;\n\t}\n\n\t/**\n\t * Gets the factory for the `SharedCell` to register with the data store.\n\t *\n\t * @returns A factory that creates and loads `SharedCell`s.\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new CellFactory();\n\t}\n\n\t/**\n\t * The data held by this cell.\n\t */\n\tprivate data: Serializable<T> | undefined;\n\n\t/**\n\t * This is used to assign a unique id to outgoing messages. It is used to track messages until\n\t * they are ack'd.\n\t */\n\tprivate messageId: number = -1;\n\n\t/**\n\t * This keeps track of the messageId of messages that have been ack'd. It is updated every time\n\t * we a message is ack'd with it's messageId.\n\t */\n\tprivate messageIdObserved: number = -1;\n\n\tprivate readonly pendingMessageIds: number[] = [];\n\n\tprivate attribution: AttributionKey | undefined;\n\n\tprivate readonly options: ICellOptions | undefined;\n\n\t/**\n\t * Constructs a new `SharedCell`.\n\t * If the object is non-local an id and service interfaces will be provided.\n\t *\n\t * @param runtime - The data store runtime to which the `SharedCell` belongs.\n\t * @param id - Unique identifier for the `SharedCell`.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n\tconstructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {\n\t\tsuper(id, runtime, attributes, \"fluid_cell_\");\n\n\t\tthis.options = runtime.options as ICellOptions;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.get}\n\t */\n\tpublic get(): Serializable<T> | undefined {\n\t\treturn this.data;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.set}\n\t */\n\tpublic set(value: Serializable<T>): void {\n\t\t// Serialize the value if required.\n\t\tconst operationValue: ICellValue = {\n\t\t\tvalue: this.serializer.encode(value, this.handle),\n\t\t};\n\n\t\t// Set the value locally.\n\t\tconst previousValue = this.setCore(value);\n\t\tthis.setAttribution();\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: ISetCellOperation = {\n\t\t\ttype: \"setCell\",\n\t\t\tvalue: operationValue,\n\t\t};\n\t\tthis.submitCellMessage(op, previousValue);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.delete}\n\t */\n\tpublic delete(): void {\n\t\t// Delete the value locally.\n\t\tconst previousValue = this.deleteCore();\n\t\tthis.setAttribution();\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: IDeleteCellOperation = {\n\t\t\ttype: \"deleteCell\",\n\t\t};\n\t\tthis.submitCellMessage(op, previousValue);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.empty}\n\t */\n\tpublic empty(): boolean {\n\t\treturn this.data === undefined;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.getAttribution}\n\t * @alpha\n\t */\n\tpublic getAttribution(): AttributionKey | undefined {\n\t\treturn this.attribution;\n\t}\n\n\t/**\n\t * Set the Op-based attribution through the SequencedDocumentMessage,\n\t * or set the local/detached attribution.\n\t */\n\tprivate setAttribution(message?: ISequencedDocumentMessage): void {\n\t\tif (this.options?.attribution?.track ?? false) {\n\t\t\tthis.attribution = message\n\t\t\t\t? { type: \"op\", seq: message.sequenceNumber }\n\t\t\t\t: this.isAttached()\n\t\t\t\t? { type: \"local\" }\n\t\t\t\t: { type: \"detached\", id: 0 };\n\t\t}\n\t}\n\n\t/**\n\t * Creates a summary for the Cell.\n\t *\n\t * @returns The summary of the current state of the Cell.\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst content: ICellValue =\n\t\t\tthis.attribution?.type === \"local\"\n\t\t\t\t? { value: this.data, attribution: undefined }\n\t\t\t\t: { value: this.data, attribution: this.attribution };\n\t\treturn createSingleBlobSummary(\n\t\t\tsnapshotFileName,\n\t\t\tserializer.stringify(content, this.handle),\n\t\t);\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<ICellValue>(storage, snapshotFileName);\n\n\t\tthis.data = this.decode(content);\n\t\tthis.attribution = content.attribution;\n\t}\n\n\t/**\n\t * Initialize a local instance of cell.\n\t */\n\tprotected initializeLocalCore(): void {\n\t\tthis.data = undefined;\n\t}\n\n\t/**\n\t * Call back on disconnect.\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Apply inner op.\n\t *\n\t * @param content - ICellOperation content\n\t */\n\tprivate applyInnerOp(content: ICellOperation): Serializable<T> | undefined {\n\t\tswitch (content.type) {\n\t\t\tcase \"setCell\":\n\t\t\t\treturn this.setCore(this.decode(content.value));\n\n\t\t\tcase \"deleteCell\":\n\t\t\t\treturn this.deleteCore();\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t}\n\t}\n\n\t/**\n\t * Process a cell 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\tconst cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n\t\tif (this.messageId !== this.messageIdObserved) {\n\t\t\t// We are waiting for an ACK on our change to this cell - we will ignore all messages until we get it.\n\t\t\tif (local) {\n\t\t\t\tconst messageIdReceived = cellOpMetadata.pendingMessageId;\n\t\t\t\tassert(\n\t\t\t\t\tmessageIdReceived !== undefined && messageIdReceived <= this.messageId,\n\t\t\t\t\t0x00c /* \"messageId is incorrect from from the local client's ACK\" */,\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tthis.pendingMessageIds !== undefined &&\n\t\t\t\t\t\tthis.pendingMessageIds[0] === cellOpMetadata.pendingMessageId,\n\t\t\t\t\t0x471 /* Unexpected pending message received */,\n\t\t\t\t);\n\t\t\t\tthis.pendingMessageIds.shift();\n\t\t\t\t// We got an ACK. Update messageIdObserved.\n\t\t\t\tthis.messageIdObserved = cellOpMetadata.pendingMessageId;\n\t\t\t\t// update the attributor\n\t\t\t\tthis.setAttribution(message);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (message.type === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as ICellOperation;\n\t\t\t// update the attributor\n\t\t\tthis.setAttribution(message);\n\t\t\tthis.applyInnerOp(op);\n\t\t}\n\t}\n\n\tprivate setCore(value: Serializable<T>): Serializable<T> | undefined {\n\t\tconst previousLocalValue = this.get();\n\t\tthis.data = value;\n\t\tthis.emit(\"valueChanged\", value);\n\t\treturn previousLocalValue;\n\t}\n\n\tprivate deleteCore(): Serializable<T> | undefined {\n\t\tconst previousLocalValue = this.get();\n\t\tthis.data = undefined;\n\t\tthis.emit(\"delete\");\n\t\treturn previousLocalValue;\n\t}\n\n\tprivate decode(cellValue: ICellValue): Serializable<T> {\n\t\tconst value = cellValue.value;\n\t\treturn this.serializer.decode(value) as Serializable<T>;\n\t}\n\n\tprivate createLocalOpMetadata(\n\t\top: ICellOperation,\n\t\tpreviousValue?: Serializable<T>,\n\t): ICellLocalOpMetadata {\n\t\tconst pendingMessageId = ++this.messageId;\n\t\tthis.pendingMessageIds.push(pendingMessageId);\n\t\tconst localMetadata: ICellLocalOpMetadata = {\n\t\t\tpendingMessageId,\n\t\t\tpreviousValue,\n\t\t};\n\t\treturn localMetadata;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t *\n\t * @internal\n\t */\n\tprotected applyStashedOp(content: unknown): unknown {\n\t\tconst cellContent = content as ICellOperation;\n\t\tconst previousValue = this.applyInnerOp(cellContent);\n\t\treturn this.createLocalOpMetadata(cellContent, previousValue);\n\t}\n\n\t/**\n\t * Rollback a local op.\n\t *\n\t * @param content - The operation to rollback.\n\t * @param localOpMetadata - The local metadata associated with the op.\n\t */\n\t// TODO: use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tconst cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\tif (content.type === \"setCell\" || content.type === \"deleteCell\") {\n\t\t\tif (cellOpMetadata.previousValue === undefined) {\n\t\t\t\tthis.deleteCore();\n\t\t\t} else {\n\t\t\t\tthis.setCore(cellOpMetadata.previousValue as Serializable<T>);\n\t\t\t}\n\n\t\t\tconst lastPendingMessageId = this.pendingMessageIds.pop();\n\t\t\tif (lastPendingMessageId !== cellOpMetadata.pendingMessageId) {\n\t\t\t\tthrow new Error(\"Rollback op does not match last pending\");\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(\"Unsupported op for rollback\");\n\t\t}\n\t}\n\n\t/**\n\t * Submit a cell message to remote clients.\n\t *\n\t * @param op - The cell message.\n\t * @param previousValue - The value of the cell before this op.\n\t */\n\tprivate submitCellMessage(op: ICellOperation, previousValue?: Serializable<T>): void {\n\t\tconst localMetadata = this.createLocalOpMetadata(op, previousValue);\n\t\tthis.submitLocalMessage(op, localMetadata);\n\t}\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -8,5 +8,5 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  export { SharedCell } from "./cell";
11
- export { ISharedCell, ISharedCellEvents, AttributionKey, ICellOptions, ICellAttributionOptions, } from "./interfaces";
11
+ export { ISharedCell, ISharedCellEvents, ICellOptions, ICellAttributionOptions, } from "./interfaces";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,uBAAuB,GACvB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,GACvB,MAAM,cAAc,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH,+BAAoC;AAA3B,kGAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value that can be edited or deleted.\n *\n * @packageDocumentation\n */\n\nexport { SharedCell } from \"./cell\";\nexport {\n\tISharedCell,\n\tISharedCellEvents,\n\tAttributionKey,\n\tICellOptions,\n\tICellAttributionOptions,\n} from \"./interfaces\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH,+BAAoC;AAA3B,kGAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value that can be edited or deleted.\n *\n * @packageDocumentation\n */\n\nexport { SharedCell } from \"./cell\";\nexport {\n\tISharedCell,\n\tISharedCellEvents,\n\tICellOptions,\n\tICellAttributionOptions,\n} from \"./interfaces\";\n"]}
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
6
6
  import { Serializable } from "@fluidframework/datastore-definitions";
7
+ import { AttributionKey } from "@fluidframework/runtime-definitions";
7
8
  /**
8
9
  * Events emitted by {@link ISharedCell}.
9
10
  */
@@ -130,26 +131,4 @@ export interface ICellOptions {
130
131
  export interface ICellAttributionOptions {
131
132
  track?: boolean;
132
133
  }
133
- /**
134
- * Can be indexed into the ContainerRuntime in order to retrieve attribution info.
135
- *
136
- * @alpha
137
- */
138
- export interface AttributionKey {
139
- /**
140
- * The type of attribution this key corresponds to.
141
- *
142
- * Keys currently all represent op-based attribution, so have the form `{ type: "op", key: sequenceNumber }`.
143
- * Thus, they can be used with an `OpStreamAttributor` to recover timestamp/user information.
144
- *
145
- * @remarks - If we want to support different types of attribution, a reasonable extensibility point is to make
146
- * AttributionKey a discriminated union on the 'type' field. This would empower
147
- * consumers with the ability to implement different attribution policies.
148
- */
149
- type: "op";
150
- /**
151
- * The sequenceNumber of the op this attribution key is for.
152
- */
153
- seq: number;
154
- }
155
134
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,CAAE,SAAQ,mBAAmB;IAChE;;;;;;OAMG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ED;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { Serializable } from \"@fluidframework/datastore-definitions\";\n\n/**\n * Events emitted by {@link ISharedCell}.\n */\nexport interface ISharedCellEvents<T> extends ISharedObjectEvents {\n\t/**\n\t * Emitted when the value has changed.\n\t *\n\t * @remarks Event paramters:\n\t *\n\t * - `value`: The new value of the cell.\n\t */\n\t(event: \"valueChanged\", listener: (value: Serializable<T>) => void);\n\n\t/**\n\t * Emitted when the value has been deleted.\n\t */\n\t(event: \"delete\", listener: () => void);\n}\n\n/**\n * A Distributed Data Structure (DDS), which stores a single shared value that can be edited or deleted.\n *\n * @typeParam T - The type of cell data. Must be serializable.\n *\n * @example Creation:\n *\n * To create a `SharedCell`, call the static create method:\n *\n * ```typescript\n * const myCell = SharedCell.create(this.runtime, id);\n * ```\n *\n * @example Usage:\n *\n * The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:\n *\n * ```typescript\n * myCell.set(3);\n * console.log(myCell.get()); // 3\n * ```\n *\n * The value must only be plain JS objects or `SharedObject` handles (e.g. to another DDS or Fluid object).\n * In collaborative scenarios, the value is settled with a policy of _last write wins_.\n *\n * The `.delete()` method will delete the stored value from the cell:\n *\n * ```typescript\n * myCell.delete();\n * console.log(myCell.get()); // undefined\n * ```\n *\n * The `.empty()` method will check if the value is undefined.\n *\n * ```typescript\n * if (myCell.empty()) {\n * // myCell.get() will return undefined\n * } else {\n * // myCell.get() will return a non-undefined value\n * }\n * ```\n *\n * @example Eventing:\n *\n * `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should\n * register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted\n * in response to a `set`, and `delete` will be emitted in response to a `delete`.\n */\n// TODO: use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>> {\n\t/**\n\t * Retrieves the cell value.\n\t *\n\t * @returns - the value of the cell\n\t */\n\tget(): Serializable<T> | undefined;\n\n\t/**\n\t * Sets the cell value.\n\t *\n\t * @param value - a JSON-able or SharedObject value to set the cell to\n\t */\n\tset(value: Serializable<T>): void;\n\n\t/**\n\t * Checks whether cell is empty or not.\n\t *\n\t * @returns - `true` if the value of cell is `undefined`, `false` otherwise\n\t */\n\tempty(): boolean;\n\n\t/**\n\t * Delete the value from the cell.\n\t */\n\tdelete(): void;\n\n\t/**\n\t * @alpha\n\t * @returns the AttributionKey associated with the cell's most recent change.\n\t */\n\tgetAttribution(): AttributionKey | undefined;\n}\n\n/**\n * Describes a local Cell operation (op).\n */\n// TODO: use `unknown` instead.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ICellLocalOpMetadata<T = any> {\n\t/**\n\t * Unique identifier for this local operation (op).\n\t */\n\tpendingMessageId: number;\n\n\t/**\n\t * The value of the {@link ISharedCell} prior to this operation (op).\n\t */\n\tpreviousValue?: Serializable<T>;\n}\n\n/**\n * Options related to attribution\n *\n * @alpha\n */\nexport interface ICellOptions {\n\tattribution?: ICellAttributionOptions;\n}\n\n/**\n * This enables the cell to store the attribution information which can be accessed with the runtime\n * (i.e. who creeated the content and when it was created)\n *\n * default: false\n *\n * @alpha\n */\nexport interface ICellAttributionOptions {\n\ttrack?: boolean;\n}\n\n/**\n * Can be indexed into the ContainerRuntime in order to retrieve attribution info.\n *\n * @alpha\n */\nexport interface AttributionKey {\n\t/**\n\t * The type of attribution this key corresponds to.\n\t *\n\t * Keys currently all represent op-based attribution, so have the form `{ type: \"op\", key: sequenceNumber }`.\n\t * Thus, they can be used with an `OpStreamAttributor` to recover timestamp/user information.\n\t *\n\t * @remarks - If we want to support different types of attribution, a reasonable extensibility point is to make\n\t * AttributionKey a discriminated union on the 'type' field. This would empower\n\t * consumers with the ability to implement different attribution policies.\n\t */\n\ttype: \"op\";\n\n\t/**\n\t * The sequenceNumber of the op this attribution key is for.\n\t */\n\tseq: number;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { Serializable } from \"@fluidframework/datastore-definitions\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions\";\n\n/**\n * Events emitted by {@link ISharedCell}.\n */\nexport interface ISharedCellEvents<T> extends ISharedObjectEvents {\n\t/**\n\t * Emitted when the value has changed.\n\t *\n\t * @remarks Event paramters:\n\t *\n\t * - `value`: The new value of the cell.\n\t */\n\t(event: \"valueChanged\", listener: (value: Serializable<T>) => void);\n\n\t/**\n\t * Emitted when the value has been deleted.\n\t */\n\t(event: \"delete\", listener: () => void);\n}\n\n/**\n * A Distributed Data Structure (DDS), which stores a single shared value that can be edited or deleted.\n *\n * @typeParam T - The type of cell data. Must be serializable.\n *\n * @example Creation:\n *\n * To create a `SharedCell`, call the static create method:\n *\n * ```typescript\n * const myCell = SharedCell.create(this.runtime, id);\n * ```\n *\n * @example Usage:\n *\n * The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:\n *\n * ```typescript\n * myCell.set(3);\n * console.log(myCell.get()); // 3\n * ```\n *\n * The value must only be plain JS objects or `SharedObject` handles (e.g. to another DDS or Fluid object).\n * In collaborative scenarios, the value is settled with a policy of _last write wins_.\n *\n * The `.delete()` method will delete the stored value from the cell:\n *\n * ```typescript\n * myCell.delete();\n * console.log(myCell.get()); // undefined\n * ```\n *\n * The `.empty()` method will check if the value is undefined.\n *\n * ```typescript\n * if (myCell.empty()) {\n * // myCell.get() will return undefined\n * } else {\n * // myCell.get() will return a non-undefined value\n * }\n * ```\n *\n * @example Eventing:\n *\n * `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should\n * register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted\n * in response to a `set`, and `delete` will be emitted in response to a `delete`.\n */\n// TODO: use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>> {\n\t/**\n\t * Retrieves the cell value.\n\t *\n\t * @returns - the value of the cell\n\t */\n\tget(): Serializable<T> | undefined;\n\n\t/**\n\t * Sets the cell value.\n\t *\n\t * @param value - a JSON-able or SharedObject value to set the cell to\n\t */\n\tset(value: Serializable<T>): void;\n\n\t/**\n\t * Checks whether cell is empty or not.\n\t *\n\t * @returns - `true` if the value of cell is `undefined`, `false` otherwise\n\t */\n\tempty(): boolean;\n\n\t/**\n\t * Delete the value from the cell.\n\t */\n\tdelete(): void;\n\n\t/**\n\t * @alpha\n\t * @returns the AttributionKey associated with the cell's most recent change.\n\t */\n\tgetAttribution(): AttributionKey | undefined;\n}\n\n/**\n * Describes a local Cell operation (op).\n */\n// TODO: use `unknown` instead.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ICellLocalOpMetadata<T = any> {\n\t/**\n\t * Unique identifier for this local operation (op).\n\t */\n\tpendingMessageId: number;\n\n\t/**\n\t * The value of the {@link ISharedCell} prior to this operation (op).\n\t */\n\tpreviousValue?: Serializable<T>;\n}\n\n/**\n * Options related to attribution\n *\n * @alpha\n */\nexport interface ICellOptions {\n\tattribution?: ICellAttributionOptions;\n}\n\n/**\n * This enables the cell to store the attribution information which can be accessed with the runtime\n * (i.e. who creeated the content and when it was created)\n *\n * default: false\n *\n * @alpha\n */\nexport interface ICellAttributionOptions {\n\ttrack?: boolean;\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/cell";
8
- export declare const pkgVersion = "2.0.0-dev.3.1.0.125672";
8
+ export declare const pkgVersion = "2.0.0-dev.4.2.0.153917";
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/cell";
11
- exports.pkgVersion = "2.0.0-dev.3.1.0.125672";
11
+ exports.pkgVersion = "2.0.0-dev.4.2.0.153917";
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,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,wBAAwB,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/cell\";\nexport const pkgVersion = \"2.0.0-dev.3.1.0.125672\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,wBAAwB,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/cell\";\nexport const pkgVersion = \"2.0.0-dev.4.2.0.153917\";\n"]}
package/lib/cell.d.ts CHANGED
@@ -4,9 +4,9 @@
4
4
  */
5
5
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
6
6
  import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory, Serializable } from "@fluidframework/datastore-definitions";
7
- import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
7
+ import { AttributionKey, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
8
8
  import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
9
- import { ISharedCell, ISharedCellEvents, AttributionKey, ICellOptions } from "./interfaces";
9
+ import { ISharedCell, ISharedCellEvents } from "./interfaces";
10
10
  /**
11
11
  * {@inheritDoc ISharedCell}
12
12
  */
@@ -47,12 +47,10 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
47
47
  * Constructs a new `SharedCell`.
48
48
  * If the object is non-local an id and service interfaces will be provided.
49
49
  *
50
- * @alpha
51
- *
52
50
  * @param runtime - The data store runtime to which the `SharedCell` belongs.
53
51
  * @param id - Unique identifier for the `SharedCell`.
54
52
  */
55
- constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, options?: ICellOptions);
53
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
56
54
  /**
57
55
  * {@inheritDoc ISharedCell.get}
58
56
  */
@@ -75,7 +73,8 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
75
73
  */
76
74
  getAttribution(): AttributionKey | undefined;
77
75
  /**
78
- * Set the attribution through the SequencedDocumentMessage
76
+ * Set the Op-based attribution through the SequencedDocumentMessage,
77
+ * or set the local/detached attribution.
79
78
  */
80
79
  private setAttribution;
81
80
  /**
package/lib/cell.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC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AAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAapB;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAgCP,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,qBAAqB;IAa7B;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAMnD;;;;;OAKG;IAGH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAmBhE;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CAIzB"}
package/lib/cell.js CHANGED
@@ -4,7 +4,6 @@
4
4
  */
5
5
  import { assert } from "@fluidframework/common-utils";
6
6
  import { MessageType } from "@fluidframework/protocol-definitions";
7
- import { loggerToMonitoringContext } from "@fluidframework/telemetry-utils";
8
7
  import { readAndParse } from "@fluidframework/driver-utils";
9
8
  import { createSingleBlobSummary, SharedObject, } from "@fluidframework/shared-object-base";
10
9
  import { CellFactory } from "./cellFactory";
@@ -19,14 +18,11 @@ export class SharedCell extends SharedObject {
19
18
  * Constructs a new `SharedCell`.
20
19
  * If the object is non-local an id and service interfaces will be provided.
21
20
  *
22
- * @alpha
23
- *
24
21
  * @param runtime - The data store runtime to which the `SharedCell` belongs.
25
22
  * @param id - Unique identifier for the `SharedCell`.
26
23
  */
27
24
  // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
28
- constructor(id, runtime, attributes, options) {
29
- var _a, _b;
25
+ constructor(id, runtime, attributes) {
30
26
  super(id, runtime, attributes, "fluid_cell_");
31
27
  /**
32
28
  * This is used to assign a unique id to outgoing messages. It is used to track messages until
@@ -39,11 +35,7 @@ export class SharedCell extends SharedObject {
39
35
  */
40
36
  this.messageIdObserved = -1;
41
37
  this.pendingMessageIds = [];
42
- (_a = this.options) !== null && _a !== void 0 ? _a : (this.options = options);
43
- const configSetAttribution = loggerToMonitoringContext(this.logger).config.getBoolean("Fluid.Attribution.EnableOnNewFile");
44
- if (configSetAttribution !== undefined) {
45
- ((_b = this.options) !== null && _b !== void 0 ? _b : (this.options = {})).attribution = { track: configSetAttribution };
46
- }
38
+ this.options = runtime.options;
47
39
  }
48
40
  /**
49
41
  * Create a new `SharedCell`.
@@ -80,6 +72,7 @@ export class SharedCell extends SharedObject {
80
72
  };
81
73
  // Set the value locally.
82
74
  const previousValue = this.setCore(value);
75
+ this.setAttribution();
83
76
  // If we are not attached, don't submit the op.
84
77
  if (!this.isAttached()) {
85
78
  return;
@@ -96,6 +89,7 @@ export class SharedCell extends SharedObject {
96
89
  delete() {
97
90
  // Delete the value locally.
98
91
  const previousValue = this.deleteCore();
92
+ this.setAttribution();
99
93
  // If we are not attached, don't submit the op.
100
94
  if (!this.isAttached()) {
101
95
  return;
@@ -119,12 +113,17 @@ export class SharedCell extends SharedObject {
119
113
  return this.attribution;
120
114
  }
121
115
  /**
122
- * Set the attribution through the SequencedDocumentMessage
116
+ * Set the Op-based attribution through the SequencedDocumentMessage,
117
+ * or set the local/detached attribution.
123
118
  */
124
119
  setAttribution(message) {
125
120
  var _a, _b, _c;
126
121
  if ((_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.attribution) === null || _b === void 0 ? void 0 : _b.track) !== null && _c !== void 0 ? _c : false) {
127
- this.attribution = { type: "op", seq: message.sequenceNumber };
122
+ this.attribution = message
123
+ ? { type: "op", seq: message.sequenceNumber }
124
+ : this.isAttached()
125
+ ? { type: "local" }
126
+ : { type: "detached", id: 0 };
128
127
  }
129
128
  }
130
129
  /**
@@ -133,7 +132,10 @@ export class SharedCell extends SharedObject {
133
132
  * @returns The summary of the current state of the Cell.
134
133
  */
135
134
  summarizeCore(serializer) {
136
- const content = { value: this.data, attribution: this.attribution };
135
+ var _a;
136
+ const content = ((_a = this.attribution) === null || _a === void 0 ? void 0 : _a.type) === "local"
137
+ ? { value: this.data, attribution: undefined }
138
+ : { value: this.data, attribution: this.attribution };
137
139
  return createSingleBlobSummary(snapshotFileName, serializer.stringify(content, this.handle));
138
140
  }
139
141
  /**
package/lib/cell.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAS5E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACN,uBAAuB,EAEvB,YAAY,GACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAmC5C,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,iDAAiD;AACjD,8DAA8D;AAC9D,MAAM,OAAO,UACZ,SAAQ,YAAkC;IA+C1C;;;;;;;;OAQG;IACH,4EAA4E;IAC5E,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EAC9B,OAAsB;;QAEtB,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;QAlC/C;;;WAGG;QACK,cAAS,GAAW,CAAC,CAAC,CAAC;QAE/B;;;WAGG;QACK,sBAAiB,GAAW,CAAC,CAAC,CAAC;QAEtB,sBAAiB,GAAa,EAAE,CAAC;QAwBjD,MAAA,IAAI,CAAC,OAAO,oCAAZ,IAAI,CAAC,OAAO,GAAK,OAAO,EAAC;QAEzB,MAAM,oBAAoB,GAAG,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,UAAU,CACpF,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CAAC;QAC/D,sEAAsE;QACtE,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE;YAChE,IAAI,cAAc,CAAC,aAAa,KAAK,SAAS,EAAE;gBAC/C,IAAI,CAAC,UAAU,EAAE,CAAC;aAClB;iBAAM;gBACN,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,aAAgC,CAAC,CAAC;aAC9D;YAED,MAAM,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;YAC1D,IAAI,oBAAoB,KAAK,cAAc,CAAC,gBAAgB,EAAE;gBAC7D,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;aAC3D;SACD;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAC/C;IACF,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,EAAkB,EAAE,aAA+B;QAC5E,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;QACpE,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAC5C,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/common-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelFactory,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { CellFactory } from \"./cellFactory\";\nimport {\n\tISharedCell,\n\tISharedCellEvents,\n\tICellLocalOpMetadata,\n\tAttributionKey,\n\tICellOptions,\n} from \"./interfaces\";\n\n/**\n * Description of a cell delta operation\n */\ntype ICellOperation = ISetCellOperation | IDeleteCellOperation;\n\ninterface ISetCellOperation {\n\ttype: \"setCell\";\n\tvalue: ICellValue;\n}\n\ninterface IDeleteCellOperation {\n\ttype: \"deleteCell\";\n}\n\ninterface ICellValue {\n\t/**\n\t * The actual value contained in the `Cell`, which needs to be wrapped to handle `undefined`.\n\t */\n\tvalue: unknown;\n\t/**\n\t * The attribution key contained in the `Cell`.\n\t * @alpha\n\t */\n\tattribution?: AttributionKey;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedCell}\n */\n// TODO: use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class SharedCell<T = any>\n\textends SharedObject<ISharedCellEvents<T>>\n\timplements ISharedCell<T>\n{\n\t/**\n\t * Create a new `SharedCell`.\n\t *\n\t * @param runtime - The data store runtime to which the `SharedCell` belongs.\n\t * @param id - Unique identifier for the `SharedCell`.\n\t *\n\t * @returns The newly create `SharedCell`. Note that it will not yet be attached.\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCell {\n\t\treturn runtime.createChannel(id, CellFactory.Type) as SharedCell;\n\t}\n\n\t/**\n\t * Gets the factory for the `SharedCell` to register with the data store.\n\t *\n\t * @returns A factory that creates and loads `SharedCell`s.\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new CellFactory();\n\t}\n\n\t/**\n\t * The data held by this cell.\n\t */\n\tprivate data: Serializable<T> | undefined;\n\n\t/**\n\t * This is used to assign a unique id to outgoing messages. It is used to track messages until\n\t * they are ack'd.\n\t */\n\tprivate messageId: number = -1;\n\n\t/**\n\t * This keeps track of the messageId of messages that have been ack'd. It is updated every time\n\t * we a message is ack'd with it's messageId.\n\t */\n\tprivate messageIdObserved: number = -1;\n\n\tprivate readonly pendingMessageIds: number[] = [];\n\n\tprivate attribution: AttributionKey | undefined;\n\n\tprivate readonly options: ICellOptions | undefined;\n\n\t/**\n\t * Constructs a new `SharedCell`.\n\t * If the object is non-local an id and service interfaces will be provided.\n\t *\n\t * @alpha\n\t *\n\t * @param runtime - The data store runtime to which the `SharedCell` belongs.\n\t * @param id - Unique identifier for the `SharedCell`.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\toptions?: ICellOptions,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_cell_\");\n\n\t\tthis.options ??= options;\n\n\t\tconst configSetAttribution = loggerToMonitoringContext(this.logger).config.getBoolean(\n\t\t\t\"Fluid.Attribution.EnableOnNewFile\",\n\t\t);\n\t\tif (configSetAttribution !== undefined) {\n\t\t\t(this.options ?? (this.options = {})).attribution = { track: configSetAttribution };\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.get}\n\t */\n\tpublic get(): Serializable<T> | undefined {\n\t\treturn this.data;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.set}\n\t */\n\tpublic set(value: Serializable<T>): void {\n\t\t// Serialize the value if required.\n\t\tconst operationValue: ICellValue = {\n\t\t\tvalue: this.serializer.encode(value, this.handle),\n\t\t};\n\n\t\t// Set the value locally.\n\t\tconst previousValue = this.setCore(value);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: ISetCellOperation = {\n\t\t\ttype: \"setCell\",\n\t\t\tvalue: operationValue,\n\t\t};\n\t\tthis.submitCellMessage(op, previousValue);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.delete}\n\t */\n\tpublic delete(): void {\n\t\t// Delete the value locally.\n\t\tconst previousValue = this.deleteCore();\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: IDeleteCellOperation = {\n\t\t\ttype: \"deleteCell\",\n\t\t};\n\t\tthis.submitCellMessage(op, previousValue);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.empty}\n\t */\n\tpublic empty(): boolean {\n\t\treturn this.data === undefined;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.getAttribution}\n\t * @alpha\n\t */\n\tpublic getAttribution(): AttributionKey | undefined {\n\t\treturn this.attribution;\n\t}\n\n\t/**\n\t * Set the attribution through the SequencedDocumentMessage\n\t */\n\tprivate setAttribution(message: ISequencedDocumentMessage): void {\n\t\tif (this.options?.attribution?.track ?? false) {\n\t\t\tthis.attribution = { type: \"op\", seq: message.sequenceNumber };\n\t\t}\n\t}\n\n\t/**\n\t * Creates a summary for the Cell.\n\t *\n\t * @returns The summary of the current state of the Cell.\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst content: ICellValue = { value: this.data, attribution: this.attribution };\n\t\treturn createSingleBlobSummary(\n\t\t\tsnapshotFileName,\n\t\t\tserializer.stringify(content, this.handle),\n\t\t);\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<ICellValue>(storage, snapshotFileName);\n\n\t\tthis.data = this.decode(content);\n\t\tthis.attribution = content.attribution;\n\t}\n\n\t/**\n\t * Initialize a local instance of cell.\n\t */\n\tprotected initializeLocalCore(): void {\n\t\tthis.data = undefined;\n\t}\n\n\t/**\n\t * Call back on disconnect.\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Apply inner op.\n\t *\n\t * @param content - ICellOperation content\n\t */\n\tprivate applyInnerOp(content: ICellOperation): Serializable<T> | undefined {\n\t\tswitch (content.type) {\n\t\t\tcase \"setCell\":\n\t\t\t\treturn this.setCore(this.decode(content.value));\n\n\t\t\tcase \"deleteCell\":\n\t\t\t\treturn this.deleteCore();\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t}\n\t}\n\n\t/**\n\t * Process a cell 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\tconst cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n\t\tif (this.messageId !== this.messageIdObserved) {\n\t\t\t// We are waiting for an ACK on our change to this cell - we will ignore all messages until we get it.\n\t\t\tif (local) {\n\t\t\t\tconst messageIdReceived = cellOpMetadata.pendingMessageId;\n\t\t\t\tassert(\n\t\t\t\t\tmessageIdReceived !== undefined && messageIdReceived <= this.messageId,\n\t\t\t\t\t0x00c /* \"messageId is incorrect from from the local client's ACK\" */,\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tthis.pendingMessageIds !== undefined &&\n\t\t\t\t\t\tthis.pendingMessageIds[0] === cellOpMetadata.pendingMessageId,\n\t\t\t\t\t0x471 /* Unexpected pending message received */,\n\t\t\t\t);\n\t\t\t\tthis.pendingMessageIds.shift();\n\t\t\t\t// We got an ACK. Update messageIdObserved.\n\t\t\t\tthis.messageIdObserved = cellOpMetadata.pendingMessageId;\n\t\t\t\t// update the attributor\n\t\t\t\tthis.setAttribution(message);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (message.type === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as ICellOperation;\n\t\t\t// update the attributor\n\t\t\tthis.setAttribution(message);\n\t\t\tthis.applyInnerOp(op);\n\t\t}\n\t}\n\n\tprivate setCore(value: Serializable<T>): Serializable<T> | undefined {\n\t\tconst previousLocalValue = this.get();\n\t\tthis.data = value;\n\t\tthis.emit(\"valueChanged\", value);\n\t\treturn previousLocalValue;\n\t}\n\n\tprivate deleteCore(): Serializable<T> | undefined {\n\t\tconst previousLocalValue = this.get();\n\t\tthis.data = undefined;\n\t\tthis.emit(\"delete\");\n\t\treturn previousLocalValue;\n\t}\n\n\tprivate decode(cellValue: ICellValue): Serializable<T> {\n\t\tconst value = cellValue.value;\n\t\treturn this.serializer.decode(value) as Serializable<T>;\n\t}\n\n\tprivate createLocalOpMetadata(\n\t\top: ICellOperation,\n\t\tpreviousValue?: Serializable<T>,\n\t): ICellLocalOpMetadata {\n\t\tconst pendingMessageId = ++this.messageId;\n\t\tthis.pendingMessageIds.push(pendingMessageId);\n\t\tconst localMetadata: ICellLocalOpMetadata = {\n\t\t\tpendingMessageId,\n\t\t\tpreviousValue,\n\t\t};\n\t\treturn localMetadata;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t *\n\t * @internal\n\t */\n\tprotected applyStashedOp(content: unknown): unknown {\n\t\tconst cellContent = content as ICellOperation;\n\t\tconst previousValue = this.applyInnerOp(cellContent);\n\t\treturn this.createLocalOpMetadata(cellContent, previousValue);\n\t}\n\n\t/**\n\t * Rollback a local op.\n\t *\n\t * @param content - The operation to rollback.\n\t * @param localOpMetadata - The local metadata associated with the op.\n\t */\n\t// TODO: use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tconst cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\tif (content.type === \"setCell\" || content.type === \"deleteCell\") {\n\t\t\tif (cellOpMetadata.previousValue === undefined) {\n\t\t\t\tthis.deleteCore();\n\t\t\t} else {\n\t\t\t\tthis.setCore(cellOpMetadata.previousValue as Serializable<T>);\n\t\t\t}\n\n\t\t\tconst lastPendingMessageId = this.pendingMessageIds.pop();\n\t\t\tif (lastPendingMessageId !== cellOpMetadata.pendingMessageId) {\n\t\t\t\tthrow new Error(\"Rollback op does not match last pending\");\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(\"Unsupported op for rollback\");\n\t\t}\n\t}\n\n\t/**\n\t * Submit a cell message to remote clients.\n\t *\n\t * @param op - The cell message.\n\t * @param previousValue - The value of the cell before this op.\n\t */\n\tprivate submitCellMessage(op: ICellOperation, previousValue?: Serializable<T>): void {\n\t\tconst localMetadata = this.createLocalOpMetadata(op, previousValue);\n\t\tthis.submitLocalMessage(op, localMetadata);\n\t}\n}\n"]}
1
+ {"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAS9F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACN,uBAAuB,EAEvB,YAAY,GACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA6B5C,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,iDAAiD;AACjD,8DAA8D;AAC9D,MAAM,OAAO,UACZ,SAAQ,YAAkC;IA+C1C;;;;;;OAMG;IACH,4EAA4E;IAC5E,YAAY,EAAU,EAAE,OAA+B,EAAE,UAA8B;QACtF,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;QA3B/C;;;WAGG;QACK,cAAS,GAAW,CAAC,CAAC,CAAC;QAE/B;;;WAGG;QACK,sBAAiB,GAAW,CAAC,CAAC,CAAC;QAEtB,sBAAiB,GAAa,EAAE,CAAC;QAiBjD,IAAI,CAAC,OAAO,G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aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,qBAAqB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;OAKG;IACH,iDAAiD;IACjD,iHAAiH;IACvG,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACxD,MAAM,cAAc,GAAG,eAAuC,CAAC;QAC/D,sEAAsE;QACtE,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE;YAChE,IAAI,cAAc,CAAC,aAAa,KAAK,SAAS,EAAE;gBAC/C,IAAI,CAAC,UAAU,EAAE,CAAC;aAClB;iBAAM;gBACN,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,aAAgC,CAAC,CAAC;aAC9D;YAED,MAAM,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;YAC1D,IAAI,oBAAoB,KAAK,cAAc,CAAC,gBAAgB,EAAE;gBAC7D,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;aAC3D;SACD;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAC/C;IACF,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,EAAkB,EAAE,aAA+B;QAC5E,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;QACpE,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAC5C,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/common-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelFactory,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions\";\nimport { AttributionKey, ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { CellFactory } from \"./cellFactory\";\nimport { ISharedCell, ISharedCellEvents, ICellLocalOpMetadata, ICellOptions } from \"./interfaces\";\n\n/**\n * Description of a cell delta operation\n */\ntype ICellOperation = ISetCellOperation | IDeleteCellOperation;\n\ninterface ISetCellOperation {\n\ttype: \"setCell\";\n\tvalue: ICellValue;\n}\n\ninterface IDeleteCellOperation {\n\ttype: \"deleteCell\";\n}\n\ninterface ICellValue {\n\t/**\n\t * The actual value contained in the `Cell`, which needs to be wrapped to handle `undefined`.\n\t */\n\tvalue: unknown;\n\t/**\n\t * The attribution key contained in the `Cell`.\n\t * @alpha\n\t */\n\tattribution?: AttributionKey;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc ISharedCell}\n */\n// TODO: use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class SharedCell<T = any>\n\textends SharedObject<ISharedCellEvents<T>>\n\timplements ISharedCell<T>\n{\n\t/**\n\t * Create a new `SharedCell`.\n\t *\n\t * @param runtime - The data store runtime to which the `SharedCell` belongs.\n\t * @param id - Unique identifier for the `SharedCell`.\n\t *\n\t * @returns The newly create `SharedCell`. Note that it will not yet be attached.\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCell {\n\t\treturn runtime.createChannel(id, CellFactory.Type) as SharedCell;\n\t}\n\n\t/**\n\t * Gets the factory for the `SharedCell` to register with the data store.\n\t *\n\t * @returns A factory that creates and loads `SharedCell`s.\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new CellFactory();\n\t}\n\n\t/**\n\t * The data held by this cell.\n\t */\n\tprivate data: Serializable<T> | undefined;\n\n\t/**\n\t * This is used to assign a unique id to outgoing messages. It is used to track messages until\n\t * they are ack'd.\n\t */\n\tprivate messageId: number = -1;\n\n\t/**\n\t * This keeps track of the messageId of messages that have been ack'd. It is updated every time\n\t * we a message is ack'd with it's messageId.\n\t */\n\tprivate messageIdObserved: number = -1;\n\n\tprivate readonly pendingMessageIds: number[] = [];\n\n\tprivate attribution: AttributionKey | undefined;\n\n\tprivate readonly options: ICellOptions | undefined;\n\n\t/**\n\t * Constructs a new `SharedCell`.\n\t * If the object is non-local an id and service interfaces will be provided.\n\t *\n\t * @param runtime - The data store runtime to which the `SharedCell` belongs.\n\t * @param id - Unique identifier for the `SharedCell`.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n\tconstructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {\n\t\tsuper(id, runtime, attributes, \"fluid_cell_\");\n\n\t\tthis.options = runtime.options as ICellOptions;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.get}\n\t */\n\tpublic get(): Serializable<T> | undefined {\n\t\treturn this.data;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.set}\n\t */\n\tpublic set(value: Serializable<T>): void {\n\t\t// Serialize the value if required.\n\t\tconst operationValue: ICellValue = {\n\t\t\tvalue: this.serializer.encode(value, this.handle),\n\t\t};\n\n\t\t// Set the value locally.\n\t\tconst previousValue = this.setCore(value);\n\t\tthis.setAttribution();\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: ISetCellOperation = {\n\t\t\ttype: \"setCell\",\n\t\t\tvalue: operationValue,\n\t\t};\n\t\tthis.submitCellMessage(op, previousValue);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.delete}\n\t */\n\tpublic delete(): void {\n\t\t// Delete the value locally.\n\t\tconst previousValue = this.deleteCore();\n\t\tthis.setAttribution();\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: IDeleteCellOperation = {\n\t\t\ttype: \"deleteCell\",\n\t\t};\n\t\tthis.submitCellMessage(op, previousValue);\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.empty}\n\t */\n\tpublic empty(): boolean {\n\t\treturn this.data === undefined;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedCell.getAttribution}\n\t * @alpha\n\t */\n\tpublic getAttribution(): AttributionKey | undefined {\n\t\treturn this.attribution;\n\t}\n\n\t/**\n\t * Set the Op-based attribution through the SequencedDocumentMessage,\n\t * or set the local/detached attribution.\n\t */\n\tprivate setAttribution(message?: ISequencedDocumentMessage): void {\n\t\tif (this.options?.attribution?.track ?? false) {\n\t\t\tthis.attribution = message\n\t\t\t\t? { type: \"op\", seq: message.sequenceNumber }\n\t\t\t\t: this.isAttached()\n\t\t\t\t? { type: \"local\" }\n\t\t\t\t: { type: \"detached\", id: 0 };\n\t\t}\n\t}\n\n\t/**\n\t * Creates a summary for the Cell.\n\t *\n\t * @returns The summary of the current state of the Cell.\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst content: ICellValue =\n\t\t\tthis.attribution?.type === \"local\"\n\t\t\t\t? { value: this.data, attribution: undefined }\n\t\t\t\t: { value: this.data, attribution: this.attribution };\n\t\treturn createSingleBlobSummary(\n\t\t\tsnapshotFileName,\n\t\t\tserializer.stringify(content, this.handle),\n\t\t);\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<ICellValue>(storage, snapshotFileName);\n\n\t\tthis.data = this.decode(content);\n\t\tthis.attribution = content.attribution;\n\t}\n\n\t/**\n\t * Initialize a local instance of cell.\n\t */\n\tprotected initializeLocalCore(): void {\n\t\tthis.data = undefined;\n\t}\n\n\t/**\n\t * Call back on disconnect.\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Apply inner op.\n\t *\n\t * @param content - ICellOperation content\n\t */\n\tprivate applyInnerOp(content: ICellOperation): Serializable<T> | undefined {\n\t\tswitch (content.type) {\n\t\t\tcase \"setCell\":\n\t\t\t\treturn this.setCore(this.decode(content.value));\n\n\t\t\tcase \"deleteCell\":\n\t\t\t\treturn this.deleteCore();\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t}\n\t}\n\n\t/**\n\t * Process a cell 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\tconst cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n\t\tif (this.messageId !== this.messageIdObserved) {\n\t\t\t// We are waiting for an ACK on our change to this cell - we will ignore all messages until we get it.\n\t\t\tif (local) {\n\t\t\t\tconst messageIdReceived = cellOpMetadata.pendingMessageId;\n\t\t\t\tassert(\n\t\t\t\t\tmessageIdReceived !== undefined && messageIdReceived <= this.messageId,\n\t\t\t\t\t0x00c /* \"messageId is incorrect from from the local client's ACK\" */,\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tthis.pendingMessageIds !== undefined &&\n\t\t\t\t\t\tthis.pendingMessageIds[0] === cellOpMetadata.pendingMessageId,\n\t\t\t\t\t0x471 /* Unexpected pending message received */,\n\t\t\t\t);\n\t\t\t\tthis.pendingMessageIds.shift();\n\t\t\t\t// We got an ACK. Update messageIdObserved.\n\t\t\t\tthis.messageIdObserved = cellOpMetadata.pendingMessageId;\n\t\t\t\t// update the attributor\n\t\t\t\tthis.setAttribution(message);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (message.type === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as ICellOperation;\n\t\t\t// update the attributor\n\t\t\tthis.setAttribution(message);\n\t\t\tthis.applyInnerOp(op);\n\t\t}\n\t}\n\n\tprivate setCore(value: Serializable<T>): Serializable<T> | undefined {\n\t\tconst previousLocalValue = this.get();\n\t\tthis.data = value;\n\t\tthis.emit(\"valueChanged\", value);\n\t\treturn previousLocalValue;\n\t}\n\n\tprivate deleteCore(): Serializable<T> | undefined {\n\t\tconst previousLocalValue = this.get();\n\t\tthis.data = undefined;\n\t\tthis.emit(\"delete\");\n\t\treturn previousLocalValue;\n\t}\n\n\tprivate decode(cellValue: ICellValue): Serializable<T> {\n\t\tconst value = cellValue.value;\n\t\treturn this.serializer.decode(value) as Serializable<T>;\n\t}\n\n\tprivate createLocalOpMetadata(\n\t\top: ICellOperation,\n\t\tpreviousValue?: Serializable<T>,\n\t): ICellLocalOpMetadata {\n\t\tconst pendingMessageId = ++this.messageId;\n\t\tthis.pendingMessageIds.push(pendingMessageId);\n\t\tconst localMetadata: ICellLocalOpMetadata = {\n\t\t\tpendingMessageId,\n\t\t\tpreviousValue,\n\t\t};\n\t\treturn localMetadata;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n\t *\n\t * @internal\n\t */\n\tprotected applyStashedOp(content: unknown): unknown {\n\t\tconst cellContent = content as ICellOperation;\n\t\tconst previousValue = this.applyInnerOp(cellContent);\n\t\treturn this.createLocalOpMetadata(cellContent, previousValue);\n\t}\n\n\t/**\n\t * Rollback a local op.\n\t *\n\t * @param content - The operation to rollback.\n\t * @param localOpMetadata - The local metadata associated with the op.\n\t */\n\t// TODO: use `unknown` instead (breaking change).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tconst cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\tif (content.type === \"setCell\" || content.type === \"deleteCell\") {\n\t\t\tif (cellOpMetadata.previousValue === undefined) {\n\t\t\t\tthis.deleteCore();\n\t\t\t} else {\n\t\t\t\tthis.setCore(cellOpMetadata.previousValue as Serializable<T>);\n\t\t\t}\n\n\t\t\tconst lastPendingMessageId = this.pendingMessageIds.pop();\n\t\t\tif (lastPendingMessageId !== cellOpMetadata.pendingMessageId) {\n\t\t\t\tthrow new Error(\"Rollback op does not match last pending\");\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(\"Unsupported op for rollback\");\n\t\t}\n\t}\n\n\t/**\n\t * Submit a cell message to remote clients.\n\t *\n\t * @param op - The cell message.\n\t * @param previousValue - The value of the cell before this op.\n\t */\n\tprivate submitCellMessage(op: ICellOperation, previousValue?: Serializable<T>): void {\n\t\tconst localMetadata = this.createLocalOpMetadata(op, previousValue);\n\t\tthis.submitLocalMessage(op, localMetadata);\n\t}\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -8,5 +8,5 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  export { SharedCell } from "./cell";
11
- export { ISharedCell, ISharedCellEvents, AttributionKey, ICellOptions, ICellAttributionOptions, } from "./interfaces";
11
+ export { ISharedCell, ISharedCellEvents, ICellOptions, ICellAttributionOptions, } from "./interfaces";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,uBAAuB,GACvB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,GACvB,MAAM,cAAc,CAAC"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value that can be edited or deleted.\n *\n * @packageDocumentation\n */\n\nexport { SharedCell } from \"./cell\";\nexport {\n\tISharedCell,\n\tISharedCellEvents,\n\tAttributionKey,\n\tICellOptions,\n\tICellAttributionOptions,\n} from \"./interfaces\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value that can be edited or deleted.\n *\n * @packageDocumentation\n */\n\nexport { SharedCell } from \"./cell\";\nexport {\n\tISharedCell,\n\tISharedCellEvents,\n\tICellOptions,\n\tICellAttributionOptions,\n} from \"./interfaces\";\n"]}
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
6
6
  import { Serializable } from "@fluidframework/datastore-definitions";
7
+ import { AttributionKey } from "@fluidframework/runtime-definitions";
7
8
  /**
8
9
  * Events emitted by {@link ISharedCell}.
9
10
  */
@@ -130,26 +131,4 @@ export interface ICellOptions {
130
131
  export interface ICellAttributionOptions {
131
132
  track?: boolean;
132
133
  }
133
- /**
134
- * Can be indexed into the ContainerRuntime in order to retrieve attribution info.
135
- *
136
- * @alpha
137
- */
138
- export interface AttributionKey {
139
- /**
140
- * The type of attribution this key corresponds to.
141
- *
142
- * Keys currently all represent op-based attribution, so have the form `{ type: "op", key: sequenceNumber }`.
143
- * Thus, they can be used with an `OpStreamAttributor` to recover timestamp/user information.
144
- *
145
- * @remarks - If we want to support different types of attribution, a reasonable extensibility point is to make
146
- * AttributionKey a discriminated union on the 'type' field. This would empower
147
- * consumers with the ability to implement different attribution policies.
148
- */
149
- type: "op";
150
- /**
151
- * The sequenceNumber of the op this attribution key is for.
152
- */
153
- seq: number;
154
- }
155
134
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,CAAE,SAAQ,mBAAmB;IAChE;;;;;;OAMG;IACH,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,OAAE;IAEpE;;OAEG;IACH,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAGH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAChF;;;;OAIG;IACH,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAEnC;;;;OAIG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IAAI,OAAE;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAGH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAChF;;;;OAIG;IACH,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAEnC;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAElC;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC;IAEjB;;OAEG;IACH,MAAM,IAAI,IAAI,CAAC;IAEf;;;OAGG;IACH,cAAc,IAAI,cAAc,GAAG,SAAS,CAAC;CAC7C;AAED;;GAEG;AAGH,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,GAAG;IAC5C;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,aAAa,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,WAAW,CAAC,EAAE,uBAAuB,CAAC;CACtC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { Serializable } from \"@fluidframework/datastore-definitions\";\n\n/**\n * Events emitted by {@link ISharedCell}.\n */\nexport interface ISharedCellEvents<T> extends ISharedObjectEvents {\n\t/**\n\t * Emitted when the value has changed.\n\t *\n\t * @remarks Event paramters:\n\t *\n\t * - `value`: The new value of the cell.\n\t */\n\t(event: \"valueChanged\", listener: (value: Serializable<T>) => void);\n\n\t/**\n\t * Emitted when the value has been deleted.\n\t */\n\t(event: \"delete\", listener: () => void);\n}\n\n/**\n * A Distributed Data Structure (DDS), which stores a single shared value that can be edited or deleted.\n *\n * @typeParam T - The type of cell data. Must be serializable.\n *\n * @example Creation:\n *\n * To create a `SharedCell`, call the static create method:\n *\n * ```typescript\n * const myCell = SharedCell.create(this.runtime, id);\n * ```\n *\n * @example Usage:\n *\n * The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:\n *\n * ```typescript\n * myCell.set(3);\n * console.log(myCell.get()); // 3\n * ```\n *\n * The value must only be plain JS objects or `SharedObject` handles (e.g. to another DDS or Fluid object).\n * In collaborative scenarios, the value is settled with a policy of _last write wins_.\n *\n * The `.delete()` method will delete the stored value from the cell:\n *\n * ```typescript\n * myCell.delete();\n * console.log(myCell.get()); // undefined\n * ```\n *\n * The `.empty()` method will check if the value is undefined.\n *\n * ```typescript\n * if (myCell.empty()) {\n * // myCell.get() will return undefined\n * } else {\n * // myCell.get() will return a non-undefined value\n * }\n * ```\n *\n * @example Eventing:\n *\n * `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should\n * register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted\n * in response to a `set`, and `delete` will be emitted in response to a `delete`.\n */\n// TODO: use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>> {\n\t/**\n\t * Retrieves the cell value.\n\t *\n\t * @returns - the value of the cell\n\t */\n\tget(): Serializable<T> | undefined;\n\n\t/**\n\t * Sets the cell value.\n\t *\n\t * @param value - a JSON-able or SharedObject value to set the cell to\n\t */\n\tset(value: Serializable<T>): void;\n\n\t/**\n\t * Checks whether cell is empty or not.\n\t *\n\t * @returns - `true` if the value of cell is `undefined`, `false` otherwise\n\t */\n\tempty(): boolean;\n\n\t/**\n\t * Delete the value from the cell.\n\t */\n\tdelete(): void;\n\n\t/**\n\t * @alpha\n\t * @returns the AttributionKey associated with the cell's most recent change.\n\t */\n\tgetAttribution(): AttributionKey | undefined;\n}\n\n/**\n * Describes a local Cell operation (op).\n */\n// TODO: use `unknown` instead.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ICellLocalOpMetadata<T = any> {\n\t/**\n\t * Unique identifier for this local operation (op).\n\t */\n\tpendingMessageId: number;\n\n\t/**\n\t * The value of the {@link ISharedCell} prior to this operation (op).\n\t */\n\tpreviousValue?: Serializable<T>;\n}\n\n/**\n * Options related to attribution\n *\n * @alpha\n */\nexport interface ICellOptions {\n\tattribution?: ICellAttributionOptions;\n}\n\n/**\n * This enables the cell to store the attribution information which can be accessed with the runtime\n * (i.e. who creeated the content and when it was created)\n *\n * default: false\n *\n * @alpha\n */\nexport interface ICellAttributionOptions {\n\ttrack?: boolean;\n}\n\n/**\n * Can be indexed into the ContainerRuntime in order to retrieve attribution info.\n *\n * @alpha\n */\nexport interface AttributionKey {\n\t/**\n\t * The type of attribution this key corresponds to.\n\t *\n\t * Keys currently all represent op-based attribution, so have the form `{ type: \"op\", key: sequenceNumber }`.\n\t * Thus, they can be used with an `OpStreamAttributor` to recover timestamp/user information.\n\t *\n\t * @remarks - If we want to support different types of attribution, a reasonable extensibility point is to make\n\t * AttributionKey a discriminated union on the 'type' field. This would empower\n\t * consumers with the ability to implement different attribution policies.\n\t */\n\ttype: \"op\";\n\n\t/**\n\t * The sequenceNumber of the op this attribution key is for.\n\t */\n\tseq: number;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { Serializable } from \"@fluidframework/datastore-definitions\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions\";\n\n/**\n * Events emitted by {@link ISharedCell}.\n */\nexport interface ISharedCellEvents<T> extends ISharedObjectEvents {\n\t/**\n\t * Emitted when the value has changed.\n\t *\n\t * @remarks Event paramters:\n\t *\n\t * - `value`: The new value of the cell.\n\t */\n\t(event: \"valueChanged\", listener: (value: Serializable<T>) => void);\n\n\t/**\n\t * Emitted when the value has been deleted.\n\t */\n\t(event: \"delete\", listener: () => void);\n}\n\n/**\n * A Distributed Data Structure (DDS), which stores a single shared value that can be edited or deleted.\n *\n * @typeParam T - The type of cell data. Must be serializable.\n *\n * @example Creation:\n *\n * To create a `SharedCell`, call the static create method:\n *\n * ```typescript\n * const myCell = SharedCell.create(this.runtime, id);\n * ```\n *\n * @example Usage:\n *\n * The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:\n *\n * ```typescript\n * myCell.set(3);\n * console.log(myCell.get()); // 3\n * ```\n *\n * The value must only be plain JS objects or `SharedObject` handles (e.g. to another DDS or Fluid object).\n * In collaborative scenarios, the value is settled with a policy of _last write wins_.\n *\n * The `.delete()` method will delete the stored value from the cell:\n *\n * ```typescript\n * myCell.delete();\n * console.log(myCell.get()); // undefined\n * ```\n *\n * The `.empty()` method will check if the value is undefined.\n *\n * ```typescript\n * if (myCell.empty()) {\n * // myCell.get() will return undefined\n * } else {\n * // myCell.get() will return a non-undefined value\n * }\n * ```\n *\n * @example Eventing:\n *\n * `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should\n * register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted\n * in response to a `set`, and `delete` will be emitted in response to a `delete`.\n */\n// TODO: use `unknown` instead (breaking change).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>> {\n\t/**\n\t * Retrieves the cell value.\n\t *\n\t * @returns - the value of the cell\n\t */\n\tget(): Serializable<T> | undefined;\n\n\t/**\n\t * Sets the cell value.\n\t *\n\t * @param value - a JSON-able or SharedObject value to set the cell to\n\t */\n\tset(value: Serializable<T>): void;\n\n\t/**\n\t * Checks whether cell is empty or not.\n\t *\n\t * @returns - `true` if the value of cell is `undefined`, `false` otherwise\n\t */\n\tempty(): boolean;\n\n\t/**\n\t * Delete the value from the cell.\n\t */\n\tdelete(): void;\n\n\t/**\n\t * @alpha\n\t * @returns the AttributionKey associated with the cell's most recent change.\n\t */\n\tgetAttribution(): AttributionKey | undefined;\n}\n\n/**\n * Describes a local Cell operation (op).\n */\n// TODO: use `unknown` instead.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ICellLocalOpMetadata<T = any> {\n\t/**\n\t * Unique identifier for this local operation (op).\n\t */\n\tpendingMessageId: number;\n\n\t/**\n\t * The value of the {@link ISharedCell} prior to this operation (op).\n\t */\n\tpreviousValue?: Serializable<T>;\n}\n\n/**\n * Options related to attribution\n *\n * @alpha\n */\nexport interface ICellOptions {\n\tattribution?: ICellAttributionOptions;\n}\n\n/**\n * This enables the cell to store the attribution information which can be accessed with the runtime\n * (i.e. who creeated the content and when it was created)\n *\n * default: false\n *\n * @alpha\n */\nexport interface ICellAttributionOptions {\n\ttrack?: boolean;\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/cell";
8
- export declare const pkgVersion = "2.0.0-dev.3.1.0.125672";
8
+ export declare const pkgVersion = "2.0.0-dev.4.2.0.153917";
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/cell";
8
- export const pkgVersion = "2.0.0-dev.3.1.0.125672";
8
+ export const pkgVersion = "2.0.0-dev.4.2.0.153917";
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,sBAAsB,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,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/cell\";\nexport const pkgVersion = \"2.0.0-dev.3.1.0.125672\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,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/cell\";\nexport const pkgVersion = \"2.0.0-dev.4.2.0.153917\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/cell",
3
- "version": "2.0.0-dev.3.1.0.125672",
3
+ "version": "2.0.0-dev.4.2.0.153917",
4
4
  "description": "Distributed data structure for a single value",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -14,33 +14,6 @@
14
14
  "main": "dist/index.js",
15
15
  "module": "lib/index.js",
16
16
  "types": "dist/index.d.ts",
17
- "scripts": {
18
- "build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
19
- "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
20
- "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
21
- "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
22
- "build:esnext": "tsc --project ./tsconfig.esnext.json",
23
- "build:full": "npm run build",
24
- "build:full:compile": "npm run build:compile",
25
- "build:genver": "gen-version",
26
- "build:test": "tsc --project ./src/test/tsconfig.json",
27
- "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
28
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
29
- "eslint": "eslint --format stylish src",
30
- "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
31
- "format": "npm run prettier:fix",
32
- "lint": "npm run prettier && npm run eslint",
33
- "lint:fix": "npm run prettier:fix && npm run eslint:fix",
34
- "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
35
- "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
36
- "test": "npm run test:mocha",
37
- "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
38
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
39
- "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
40
- "tsc": "tsc",
41
- "typetests:gen": "flub generate typetests --generate --dir .",
42
- "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
43
- },
44
17
  "nyc": {
45
18
  "all": true,
46
19
  "cache-dir": "nyc/.cache",
@@ -62,50 +35,68 @@
62
35
  "temp-directory": "nyc/.nyc_output"
63
36
  },
64
37
  "dependencies": {
65
- "@fluidframework/common-utils": "^1.0.0",
66
- "@fluidframework/core-interfaces": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
67
- "@fluidframework/datastore-definitions": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
68
- "@fluidframework/driver-utils": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
38
+ "@fluidframework/common-utils": "^1.1.1",
39
+ "@fluidframework/core-interfaces": "2.0.0-dev.4.2.0.153917",
40
+ "@fluidframework/datastore-definitions": "2.0.0-dev.4.2.0.153917",
41
+ "@fluidframework/driver-utils": "2.0.0-dev.4.2.0.153917",
69
42
  "@fluidframework/protocol-definitions": "^1.1.0",
70
- "@fluidframework/runtime-definitions": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
71
- "@fluidframework/shared-object-base": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
72
- "@fluidframework/telemetry-utils": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0"
43
+ "@fluidframework/runtime-definitions": "2.0.0-dev.4.2.0.153917",
44
+ "@fluidframework/shared-object-base": "2.0.0-dev.4.2.0.153917"
73
45
  },
74
46
  "devDependencies": {
75
- "@fluid-internal/test-dds-utils": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
76
- "@fluid-tools/build-cli": "^0.8.0",
47
+ "@fluid-internal/test-dds-utils": "2.0.0-dev.4.2.0.153917",
48
+ "@fluid-tools/build-cli": "^0.15.0",
77
49
  "@fluidframework/build-common": "^1.1.0",
78
- "@fluidframework/build-tools": "^0.8.0",
79
- "@fluidframework/cell-previous": "npm:@fluidframework/cell@2.0.0-internal.3.0.0",
50
+ "@fluidframework/build-tools": "^0.15.0",
51
+ "@fluidframework/cell-previous": "npm:@fluidframework/cell@2.0.0-internal.4.0.0",
80
52
  "@fluidframework/eslint-config-fluid": "^2.0.0",
81
- "@fluidframework/mocha-test-setup": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
82
- "@fluidframework/test-runtime-utils": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
83
- "@microsoft/api-extractor": "^7.22.2",
84
- "@rushstack/eslint-config": "^2.5.1",
53
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.4.2.0.153917",
54
+ "@fluidframework/test-runtime-utils": "2.0.0-dev.4.2.0.153917",
55
+ "@microsoft/api-extractor": "^7.34.4",
85
56
  "@types/mocha": "^9.1.1",
86
- "@types/node": "^14.18.36",
87
- "concurrently": "^6.2.0",
57
+ "@types/node": "^14.18.38",
58
+ "concurrently": "^7.6.0",
88
59
  "copyfiles": "^2.4.1",
89
- "cross-env": "^7.0.2",
60
+ "cross-env": "^7.0.3",
90
61
  "eslint": "~8.6.0",
91
- "mocha": "^10.0.0",
92
- "nyc": "^15.0.0",
62
+ "mocha": "^10.2.0",
63
+ "mocha-json-output-reporter": "^2.0.1",
64
+ "mocha-multi-reporters": "^1.5.1",
65
+ "moment": "^2.21.0",
66
+ "nyc": "^15.1.0",
93
67
  "prettier": "~2.6.2",
94
- "rimraf": "^2.6.2",
68
+ "rimraf": "^4.4.0",
95
69
  "typescript": "~4.5.5"
96
70
  },
97
71
  "typeValidation": {
98
- "version": "2.0.0-internal.3.1.0",
99
- "previousVersionStyle": "~previousMinor",
100
- "baselineRange": ">=2.0.0-internal.3.0.0 <2.0.0-internal.3.1.0",
101
- "baselineVersion": "2.0.0-internal.3.0.0",
102
- "broken": {
103
- "ClassDeclaration_SharedCell": {
104
- "forwardCompat": false
105
- },
106
- "InterfaceDeclaration_ISharedCell": {
107
- "forwardCompat": false
108
- }
109
- }
72
+ "broken": {}
73
+ },
74
+ "scripts": {
75
+ "build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
76
+ "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
77
+ "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
78
+ "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
79
+ "build:esnext": "tsc --project ./tsconfig.esnext.json",
80
+ "build:full": "npm run build",
81
+ "build:full:compile": "npm run build:compile",
82
+ "build:genver": "gen-version",
83
+ "build:test": "tsc --project ./src/test/tsconfig.json",
84
+ "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
85
+ "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
86
+ "eslint": "eslint --format stylish src",
87
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
88
+ "format": "npm run prettier:fix",
89
+ "lint": "npm run prettier && npm run eslint",
90
+ "lint:fix": "npm run prettier:fix && npm run eslint:fix",
91
+ "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
92
+ "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
93
+ "test": "npm run test:mocha",
94
+ "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
95
+ "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
96
+ "test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
97
+ "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
98
+ "tsc": "tsc",
99
+ "typetests:gen": "fluid-type-test-generator",
100
+ "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
110
101
  }
111
- }
102
+ }
package/src/cell.ts CHANGED
@@ -5,7 +5,6 @@
5
5
 
6
6
  import { assert } from "@fluidframework/common-utils";
7
7
  import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
8
- import { loggerToMonitoringContext } from "@fluidframework/telemetry-utils";
9
8
  import {
10
9
  IChannelAttributes,
11
10
  IFluidDataStoreRuntime,
@@ -13,7 +12,7 @@ import {
13
12
  IChannelFactory,
14
13
  Serializable,
15
14
  } from "@fluidframework/datastore-definitions";
16
- import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
15
+ import { AttributionKey, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
17
16
  import { readAndParse } from "@fluidframework/driver-utils";
18
17
  import {
19
18
  createSingleBlobSummary,
@@ -21,13 +20,7 @@ import {
21
20
  SharedObject,
22
21
  } from "@fluidframework/shared-object-base";
23
22
  import { CellFactory } from "./cellFactory";
24
- import {
25
- ISharedCell,
26
- ISharedCellEvents,
27
- ICellLocalOpMetadata,
28
- AttributionKey,
29
- ICellOptions,
30
- } from "./interfaces";
23
+ import { ISharedCell, ISharedCellEvents, ICellLocalOpMetadata, ICellOptions } from "./interfaces";
31
24
 
32
25
  /**
33
26
  * Description of a cell delta operation
@@ -114,28 +107,14 @@ export class SharedCell<T = any>
114
107
  * Constructs a new `SharedCell`.
115
108
  * If the object is non-local an id and service interfaces will be provided.
116
109
  *
117
- * @alpha
118
- *
119
110
  * @param runtime - The data store runtime to which the `SharedCell` belongs.
120
111
  * @param id - Unique identifier for the `SharedCell`.
121
112
  */
122
113
  // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
123
- constructor(
124
- id: string,
125
- runtime: IFluidDataStoreRuntime,
126
- attributes: IChannelAttributes,
127
- options?: ICellOptions,
128
- ) {
114
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {
129
115
  super(id, runtime, attributes, "fluid_cell_");
130
116
 
131
- this.options ??= options;
132
-
133
- const configSetAttribution = loggerToMonitoringContext(this.logger).config.getBoolean(
134
- "Fluid.Attribution.EnableOnNewFile",
135
- );
136
- if (configSetAttribution !== undefined) {
137
- (this.options ?? (this.options = {})).attribution = { track: configSetAttribution };
138
- }
117
+ this.options = runtime.options as ICellOptions;
139
118
  }
140
119
 
141
120
  /**
@@ -156,6 +135,7 @@ export class SharedCell<T = any>
156
135
 
157
136
  // Set the value locally.
158
137
  const previousValue = this.setCore(value);
138
+ this.setAttribution();
159
139
 
160
140
  // If we are not attached, don't submit the op.
161
141
  if (!this.isAttached()) {
@@ -175,6 +155,7 @@ export class SharedCell<T = any>
175
155
  public delete(): void {
176
156
  // Delete the value locally.
177
157
  const previousValue = this.deleteCore();
158
+ this.setAttribution();
178
159
 
179
160
  // If we are not attached, don't submit the op.
180
161
  if (!this.isAttached()) {
@@ -203,11 +184,16 @@ export class SharedCell<T = any>
203
184
  }
204
185
 
205
186
  /**
206
- * Set the attribution through the SequencedDocumentMessage
187
+ * Set the Op-based attribution through the SequencedDocumentMessage,
188
+ * or set the local/detached attribution.
207
189
  */
208
- private setAttribution(message: ISequencedDocumentMessage): void {
190
+ private setAttribution(message?: ISequencedDocumentMessage): void {
209
191
  if (this.options?.attribution?.track ?? false) {
210
- this.attribution = { type: "op", seq: message.sequenceNumber };
192
+ this.attribution = message
193
+ ? { type: "op", seq: message.sequenceNumber }
194
+ : this.isAttached()
195
+ ? { type: "local" }
196
+ : { type: "detached", id: 0 };
211
197
  }
212
198
  }
213
199
 
@@ -217,7 +203,10 @@ export class SharedCell<T = any>
217
203
  * @returns The summary of the current state of the Cell.
218
204
  */
219
205
  protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {
220
- const content: ICellValue = { value: this.data, attribution: this.attribution };
206
+ const content: ICellValue =
207
+ this.attribution?.type === "local"
208
+ ? { value: this.data, attribution: undefined }
209
+ : { value: this.data, attribution: this.attribution };
221
210
  return createSingleBlobSummary(
222
211
  snapshotFileName,
223
212
  serializer.stringify(content, this.handle),
package/src/index.ts CHANGED
@@ -13,7 +13,6 @@ export { SharedCell } from "./cell";
13
13
  export {
14
14
  ISharedCell,
15
15
  ISharedCellEvents,
16
- AttributionKey,
17
16
  ICellOptions,
18
17
  ICellAttributionOptions,
19
18
  } from "./interfaces";
package/src/interfaces.ts CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
7
7
  import { Serializable } from "@fluidframework/datastore-definitions";
8
+ import { AttributionKey } from "@fluidframework/runtime-definitions";
8
9
 
9
10
  /**
10
11
  * Events emitted by {@link ISharedCell}.
@@ -146,27 +147,3 @@ export interface ICellOptions {
146
147
  export interface ICellAttributionOptions {
147
148
  track?: boolean;
148
149
  }
149
-
150
- /**
151
- * Can be indexed into the ContainerRuntime in order to retrieve attribution info.
152
- *
153
- * @alpha
154
- */
155
- export interface AttributionKey {
156
- /**
157
- * The type of attribution this key corresponds to.
158
- *
159
- * Keys currently all represent op-based attribution, so have the form `{ type: "op", key: sequenceNumber }`.
160
- * Thus, they can be used with an `OpStreamAttributor` to recover timestamp/user information.
161
- *
162
- * @remarks - If we want to support different types of attribution, a reasonable extensibility point is to make
163
- * AttributionKey a discriminated union on the 'type' field. This would empower
164
- * consumers with the ability to implement different attribution policies.
165
- */
166
- type: "op";
167
-
168
- /**
169
- * The sequenceNumber of the op this attribution key is for.
170
- */
171
- seq: number;
172
- }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/cell";
9
- export const pkgVersion = "2.0.0-dev.3.1.0.125672";
9
+ export const pkgVersion = "2.0.0-dev.4.2.0.153917";