@fluidframework/cell 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0

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/.eslintrc.js CHANGED
@@ -4,14 +4,12 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- "extends": [
8
- require.resolve("@fluidframework/eslint-config-fluid/strict"), "prettier"
9
- ],
10
- "parserOptions": {
11
- "project": ["./tsconfig.json", "./src/test/tsconfig.json"]
12
- },
13
- "rules": {
14
- // TODO: consider re-enabling once we have addressed how this rule conflicts with our error codes.
15
- "unicorn/numeric-separators-style": "off",
16
- }
17
- }
7
+ extends: [require.resolve("@fluidframework/eslint-config-fluid/strict"), "prettier"],
8
+ parserOptions: {
9
+ project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
+ },
11
+ rules: {
12
+ // TODO: consider re-enabling once we have addressed how this rule conflicts with our error codes.
13
+ "unicorn/numeric-separators-style": "off",
14
+ },
15
+ };
package/.mocharc.js CHANGED
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- 'use strict';
6
+ "use strict";
7
7
 
8
- const getFluidTestMochaConfig = require('@fluidframework/mocha-test-setup/mocharc-common');
8
+ const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
9
9
 
10
10
  const packageDir = __dirname;
11
11
  const config = getFluidTestMochaConfig(packageDir);
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @fluidframework/cell
2
2
 
3
- The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value that can be edited or deleted.
3
+ The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value that can be edited or deleted.
4
4
 
5
5
  <!-- AUTO-GENERATED-CONTENT:START (README_INSTALLATION_SECTION:includeHeading=TRUE) -->
6
6
 
@@ -1,4 +1,4 @@
1
1
  {
2
- "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "@fluidframework/build-common/api-extractor-common-report.json"
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "@fluidframework/build-common/api-extractor-common-report.json"
4
4
  }
package/dist/cell.d.ts CHANGED
@@ -4,7 +4,7 @@
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
9
  import { ISharedCell, ISharedCellEvents } from "./interfaces";
10
10
  /**
@@ -41,10 +41,14 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
41
41
  */
42
42
  private messageIdObserved;
43
43
  private readonly pendingMessageIds;
44
+ private attribution;
45
+ private readonly options;
44
46
  /**
45
47
  * Constructs a new `SharedCell`.
46
48
  * If the object is non-local an id and service interfaces will be provided.
47
49
  *
50
+ * @alpha
51
+ *
48
52
  * @param runtime - The data store runtime to which the `SharedCell` belongs.
49
53
  * @param id - Unique identifier for the `SharedCell`.
50
54
  */
@@ -65,6 +69,15 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
65
69
  * {@inheritDoc ISharedCell.empty}
66
70
  */
67
71
  empty(): boolean;
72
+ /**
73
+ * {@inheritDoc ISharedCell.getAttribution}
74
+ * @alpha
75
+ */
76
+ getAttribution(): AttributionKey | undefined;
77
+ /**
78
+ * Set the attribution through the SequencedDocumentMessage
79
+ */
80
+ private setAttribution;
68
81
  /**
69
82
  * Creates a summary for the Cell.
70
83
  *
@@ -116,11 +129,11 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
116
129
  */
117
130
  protected rollback(content: any, localOpMetadata: unknown): void;
118
131
  /**
119
- * Submit a cell message to remote clients.
120
- *
121
- * @param op - The cell message.
122
- * @param previousValue - The value of the cell before this op.
123
- */
132
+ * Submit a cell message to remote clients.
133
+ *
134
+ * @param op - The cell message.
135
+ * @param previousValue - The value of the cell before this op.
136
+ */
124
137
  private submitCellMessage;
125
138
  }
126
139
  //# sourceMappingURL=cell.d.ts.map
@@ -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;AAC9F,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,YAAY,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAA2B,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE7G,OAAO,EACH,WAAW,EACX,iBAAiB,EAEpB,MAAM,cAAc,CAAC;AAyBtB;;GAEG;AAGH,qBAAa,UAAU,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,YAAY,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IACjG;;;;;;;OAOG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAI9E;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C;;OAEG;IACH,OAAO,CAAC,IAAI,CAA8B;IAE1C;;;OAGG;IACH,OAAO,CAAC,SAAS,CAAc;IAE/B;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAc;IAEvC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAgB;IAElD;;;;;;OAMG;gBACgB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,kBAAkB;IAI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5E;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOxE;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAIrC;;OAEG;IACH,SAAS,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/dist/cell.js CHANGED
@@ -21,9 +21,12 @@ class SharedCell extends shared_object_base_1.SharedObject {
21
21
  * Constructs a new `SharedCell`.
22
22
  * If the object is non-local an id and service interfaces will be provided.
23
23
  *
24
+ * @alpha
25
+ *
24
26
  * @param runtime - The data store runtime to which the `SharedCell` belongs.
25
27
  * @param id - Unique identifier for the `SharedCell`.
26
28
  */
29
+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
27
30
  constructor(id, runtime, attributes) {
28
31
  super(id, runtime, attributes, "fluid_cell_");
29
32
  /**
@@ -37,6 +40,7 @@ class SharedCell extends shared_object_base_1.SharedObject {
37
40
  */
38
41
  this.messageIdObserved = -1;
39
42
  this.pendingMessageIds = [];
43
+ this.options = runtime.options;
40
44
  }
41
45
  /**
42
46
  * Create a new `SharedCell`.
@@ -104,13 +108,29 @@ class SharedCell extends shared_object_base_1.SharedObject {
104
108
  empty() {
105
109
  return this.data === undefined;
106
110
  }
111
+ /**
112
+ * {@inheritDoc ISharedCell.getAttribution}
113
+ * @alpha
114
+ */
115
+ getAttribution() {
116
+ return this.attribution;
117
+ }
118
+ /**
119
+ * Set the attribution through the SequencedDocumentMessage
120
+ */
121
+ setAttribution(message) {
122
+ var _a, _b, _c;
123
+ 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) {
124
+ this.attribution = { type: "op", seq: message.sequenceNumber };
125
+ }
126
+ }
107
127
  /**
108
128
  * Creates a summary for the Cell.
109
129
  *
110
130
  * @returns The summary of the current state of the Cell.
111
131
  */
112
132
  summarizeCore(serializer) {
113
- const content = { value: this.data };
133
+ const content = { value: this.data, attribution: this.attribution };
114
134
  return (0, shared_object_base_1.createSingleBlobSummary)(snapshotFileName, serializer.stringify(content, this.handle));
115
135
  }
116
136
  /**
@@ -119,6 +139,7 @@ class SharedCell extends shared_object_base_1.SharedObject {
119
139
  async loadCore(storage) {
120
140
  const content = await (0, driver_utils_1.readAndParse)(storage, snapshotFileName);
121
141
  this.data = this.decode(content);
142
+ this.attribution = content.attribution;
122
143
  }
123
144
  /**
124
145
  * Initialize a local instance of cell.
@@ -165,11 +186,15 @@ class SharedCell extends shared_object_base_1.SharedObject {
165
186
  this.pendingMessageIds.shift();
166
187
  // We got an ACK. Update messageIdObserved.
167
188
  this.messageIdObserved = cellOpMetadata.pendingMessageId;
189
+ // update the attributor
190
+ this.setAttribution(message);
168
191
  }
169
192
  return;
170
193
  }
171
194
  if (message.type === protocol_definitions_1.MessageType.Operation && !local) {
172
195
  const op = message.contents;
196
+ // update the attributor
197
+ this.setAttribution(message);
173
198
  this.applyInnerOp(op);
174
199
  }
175
200
  }
@@ -193,7 +218,8 @@ class SharedCell extends shared_object_base_1.SharedObject {
193
218
  const pendingMessageId = ++this.messageId;
194
219
  this.pendingMessageIds.push(pendingMessageId);
195
220
  const localMetadata = {
196
- pendingMessageId, previousValue,
221
+ pendingMessageId,
222
+ previousValue,
197
223
  };
198
224
  return localMetadata;
199
225
  }
@@ -235,11 +261,11 @@ class SharedCell extends shared_object_base_1.SharedObject {
235
261
  }
236
262
  }
237
263
  /**
238
- * Submit a cell message to remote clients.
239
- *
240
- * @param op - The cell message.
241
- * @param previousValue - The value of the cell before this op.
242
- */
264
+ * Submit a cell message to remote clients.
265
+ *
266
+ * @param op - The cell message.
267
+ * @param previousValue - The value of the cell before this op.
268
+ */
243
269
  submitCellMessage(op, previousValue) {
244
270
  const localMetadata = this.createLocalOpMetadata(op, previousValue);
245
271
  this.submitLocalMessage(op, localMetadata);
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;AAS9F,+DAA4D;AAC5D,2EAA6G;AAC7G,+CAA4C;AA4B5C,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,iDAAiD;AACjD,8DAA8D;AAC9D,MAAa,UAAoB,SAAQ,iCAAkC;IAyCvE;;;;;;OAMG;IACH,YAAmB,EAAU,EAAE,OAA+B,EAAE,UAA8B;QAC1F,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;QAtBlD;;;WAGG;QACK,cAAS,GAAW,CAAC,CAAC,CAAC;QAE/B;;;WAGG;QACK,sBAAiB,GAAW,CAAC,CAAC,CAAC;QAEtB,sBAAiB,GAAa,EAAE,CAAC;IAWlD,CAAC;IAjDD;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAC7D,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,yBAAW,CAAC,IAAI,CAAe,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU;QACp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B;QACrC,MAAM,WAAW,GAAG,OAAyB,CAAC;QAC9C,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,qBAAqB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACH,iDAAiD;IACjD,iHAAiH;IACvG,QAAQ,CAAC,OAAY,EAAE,eAAwB;QACrD,MAAM,cAAc,GAAG,eAAuC,CAAC;QAC/D,sEAAsE;QACtE,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE;YAC7D,IAAI,cAAc,CAAC,aAAa,KAAK,SAAS,EAAE;gBAC5C,IAAI,CAAC,UAAU,EAAE,CAAC;aACrB;iBAAM;gBACH,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,aAAgC,CAAC,CAAC;aACjE;YAED,MAAM,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;YAC1D,IAAI,oBAAoB,KAAK,cAAc,CAAC,gBAAgB,EAAE;gBAC1D,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;aAC9D;SACJ;aAAM;YACH,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAClD;IACL,CAAC;IAEA;;;;;MAKE;IACK,iBAAiB,CAAC,EAAkB,EAAE,aAA+B;QACzE,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;QACpE,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAC/C,CAAC;CACJ;AAzQD,gCAyQC","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 IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelFactory,\n Serializable,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { createSingleBlobSummary, IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { CellFactory } from \"./cellFactory\";\nimport {\n ISharedCell,\n ISharedCellEvents,\n ICellLocalOpMetadata,\n} from \"./interfaces\";\n\n/**\n * Description of a cell delta operation\n */\ntype ICellOperation = ISetCellOperation | IDeleteCellOperation;\n\ninterface ISetCellOperation {\n type: \"setCell\";\n value: ICellValue;\n}\n\ninterface IDeleteCellOperation {\n type: \"deleteCell\";\n}\n\ninterface ICellValue {\n /**\n * The actual value contained in the `Cell`, which needs to be wrapped to handle `undefined`.\n */\n value: unknown;\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> extends SharedObject<ISharedCellEvents<T>> implements ISharedCell<T> {\n /**\n * Create a new `SharedCell`.\n *\n * @param runtime - The data store runtime to which the `SharedCell` belongs.\n * @param id - Unique identifier for the `SharedCell`.\n *\n * @returns The newly create `SharedCell`. Note that it will not yet be attached.\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCell {\n return runtime.createChannel(id, CellFactory.Type) as SharedCell;\n }\n\n /**\n * Gets the factory for the `SharedCell` to register with the data store.\n *\n * @returns A factory that creates and loads `SharedCell`s.\n */\n public static getFactory(): IChannelFactory {\n return new CellFactory();\n }\n\n /**\n * The data held by this cell.\n */\n private data: Serializable<T> | undefined;\n\n /**\n * This is used to assign a unique id to outgoing messages. It is used to track messages until\n * they are ack'd.\n */\n private messageId: number = -1;\n\n /**\n * This keeps track of the messageId of messages that have been ack'd. It is updated every time\n * we a message is ack'd with it's messageId.\n */\n private messageIdObserved: number = -1;\n\n private readonly pendingMessageIds: number[] = [];\n\n /**\n * Constructs a new `SharedCell`.\n * If the object is non-local an id and service interfaces will be provided.\n *\n * @param runtime - The data store runtime to which the `SharedCell` belongs.\n * @param id - Unique identifier for the `SharedCell`.\n */\n public constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {\n super(id, runtime, attributes, \"fluid_cell_\");\n }\n\n /**\n * {@inheritDoc ISharedCell.get}\n */\n public get(): Serializable<T> | undefined {\n return this.data;\n }\n\n /**\n * {@inheritDoc ISharedCell.set}\n */\n public set(value: Serializable<T>): void {\n // Serialize the value if required.\n const operationValue: ICellValue = {\n value: this.serializer.encode(value, this.handle),\n };\n\n // Set the value locally.\n const previousValue = this.setCore(value);\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return;\n }\n\n const op: ISetCellOperation = {\n type: \"setCell\",\n value: operationValue,\n };\n this.submitCellMessage(op, previousValue);\n }\n\n /**\n * {@inheritDoc ISharedCell.delete}\n */\n public delete(): void {\n // Delete the value locally.\n const previousValue = this.deleteCore();\n\n // If we are not attached, don't submit the op.\n if (!this.isAttached()) {\n return;\n }\n\n const op: IDeleteCellOperation = {\n type: \"deleteCell\",\n };\n this.submitCellMessage(op, previousValue);\n }\n\n /**\n * {@inheritDoc ISharedCell.empty}\n */\n public empty(): boolean {\n return this.data === undefined;\n }\n\n /**\n * Creates a summary for the Cell.\n *\n * @returns The summary of the current state of the Cell.\n */\n protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n const content: ICellValue = { value: this.data };\n return createSingleBlobSummary(snapshotFileName, serializer.stringify(content, this.handle));\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n */\n protected async loadCore(storage: IChannelStorageService): Promise<void> {\n const content = await readAndParse<ICellValue>(storage, snapshotFileName);\n\n this.data = this.decode(content);\n }\n\n /**\n * Initialize a local instance of cell.\n */\n protected initializeLocalCore(): void {\n this.data = undefined;\n }\n\n /**\n * Call back on disconnect.\n */\n protected onDisconnect(): void { }\n\n /**\n * Apply inner op.\n *\n * @param content - ICellOperation content\n */\n private applyInnerOp(content: ICellOperation): Serializable<T> | undefined {\n switch (content.type) {\n case \"setCell\":\n return this.setCore(this.decode(content.value));\n\n case \"deleteCell\":\n return this.deleteCore();\n\n default:\n throw new Error(\"Unknown operation\");\n }\n }\n\n /**\n * Process a cell operation (op).\n *\n * @param message - The message to prepare.\n * @param local - Whether or not the message was sent by the local client.\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be `undefined`.\n */\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n const cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n if (this.messageId !== this.messageIdObserved) {\n // We are waiting for an ACK on our change to this cell - we will ignore all messages until we get it.\n if (local) {\n const messageIdReceived = cellOpMetadata.pendingMessageId;\n assert(messageIdReceived !== undefined && messageIdReceived <= this.messageId,\n 0x00c /* \"messageId is incorrect from from the local client's ACK\" */);\n assert(this.pendingMessageIds !== undefined &&\n this.pendingMessageIds[0] === cellOpMetadata.pendingMessageId,\n 0x471 /* Unexpected pending message received */);\n this.pendingMessageIds.shift();\n // We got an ACK. Update messageIdObserved.\n this.messageIdObserved = cellOpMetadata.pendingMessageId;\n }\n return;\n }\n\n if (message.type === MessageType.Operation && !local) {\n const op = message.contents as ICellOperation;\n this.applyInnerOp(op);\n }\n }\n\n private setCore(value: Serializable<T>): Serializable<T> | undefined {\n const previousLocalValue = this.get();\n this.data = value;\n this.emit(\"valueChanged\", value);\n return previousLocalValue;\n }\n\n private deleteCore(): Serializable<T> | undefined {\n const previousLocalValue = this.get();\n this.data = undefined;\n this.emit(\"delete\");\n return previousLocalValue;\n }\n\n private decode(cellValue: ICellValue): Serializable<T> {\n const value = cellValue.value;\n return this.serializer.decode(value) as Serializable<T> ;\n }\n\n private createLocalOpMetadata(op: ICellOperation, previousValue?: Serializable<T>): ICellLocalOpMetadata {\n const pendingMessageId = ++this.messageId;\n this.pendingMessageIds.push(pendingMessageId);\n const localMetadata: ICellLocalOpMetadata = {\n pendingMessageId, previousValue,\n };\n return localMetadata;\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}\n *\n * @internal\n */\n protected applyStashedOp(content: unknown): unknown {\n const cellContent = content as ICellOperation;\n const previousValue = this.applyInnerOp(cellContent);\n return this.createLocalOpMetadata(cellContent, previousValue);\n }\n\n /**\n * Rollback a local op.\n *\n * @param content - The operation to rollback.\n * @param localOpMetadata - The local metadata associated with the op.\n */\n // TODO: use `unknown` instead (breaking change).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\n protected rollback(content: any, localOpMetadata: unknown): void {\n const cellOpMetadata = localOpMetadata as ICellLocalOpMetadata;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (content.type === \"setCell\" || content.type === \"deleteCell\") {\n if (cellOpMetadata.previousValue === undefined) {\n this.deleteCore();\n } else {\n this.setCore(cellOpMetadata.previousValue as Serializable<T>);\n }\n\n const lastPendingMessageId = this.pendingMessageIds.pop();\n if (lastPendingMessageId !== cellOpMetadata.pendingMessageId) {\n throw new Error(\"Rollback op does not match last pending\");\n }\n } else {\n throw new Error(\"Unsupported op for rollback\");\n }\n }\n\n /**\n * Submit a cell message to remote clients.\n *\n * @param op - The cell message.\n * @param previousValue - The value of the cell before this op.\n */\n private submitCellMessage(op: ICellOperation, previousValue?: Serializable<T>): void {\n const localMetadata = this.createLocalOpMetadata(op, previousValue);\n this.submitLocalMessage(op, localMetadata);\n }\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,MAAM,gBAAgB,GAAG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QAC9C,MAAM,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;AA1TD,gCA0TC","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 * @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(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\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 +1 @@
1
- {"version":3,"file":"cellFactory.d.ts","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C;;;;GAIG;AACH,qBAAa,WAAY,YAAW,eAAe;IAC/C;;OAEG;IACH,gBAAuB,IAAI,4CAA4C;IAEvE;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;OAEG;IACU,IAAI,CACb,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAMzD;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW;CAK3E"}
1
+ {"version":3,"file":"cellFactory.d.ts","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C;;;;GAIG;AACH,qBAAa,WAAY,YAAW,eAAe;IAClD;;OAEG;IACH,gBAAuB,IAAI,4CAA4C;IAEvE;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,WAAW,CAAC;IAMvB;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW;CAKxE"}
@@ -1 +1 @@
1
- {"version":3,"file":"cellFactory.js","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,iCAAoC;AAEpC,qDAA8C;AAE9C;;;;GAIG;AACH,MAAa,WAAW;IAepB;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,WAAW,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,WAAW,CAAC,UAAU,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CACb,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAC9B,MAAM,IAAI,GAAG,IAAI,iBAAU,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACrD,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAgC,EAAE,EAAU;QACtD,MAAM,IAAI,GAAG,IAAI,iBAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;;AAjDL,kCAkDC;AAjDG;;GAEG;AACoB,gBAAI,GAAG,wCAAwC,CAAC;AAEvE;;GAEG;AACoB,sBAAU,GAAuB;IACpD,IAAI,EAAE,WAAW,CAAC,IAAI;IACtB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,2BAAU;CAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelServices,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedCell } from \"./cell\";\nimport { ISharedCell } from \"./interfaces\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedCell}.\n *\n * @sealed\n */\nexport class CellFactory implements IChannelFactory {\n /**\n * {@inheritDoc CellFactory.\"type\"}\n */\n public static readonly Type = \"https://graph.microsoft.com/types/cell\";\n\n /**\n * {@inheritDoc CellFactory.attributes}\n */\n public static readonly Attributes: IChannelAttributes = {\n type: CellFactory.Type,\n snapshotFormatVersion: \"0.1\",\n packageVersion: pkgVersion,\n };\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n */\n public get type(): string {\n return CellFactory.Type;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n */\n public get attributes(): IChannelAttributes {\n return CellFactory.Attributes;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n */\n public async load(\n runtime: IFluidDataStoreRuntime,\n id: string,\n services: IChannelServices,\n attributes: IChannelAttributes): Promise<ISharedCell> {\n const cell = new SharedCell(id, runtime, attributes);\n await cell.load(services);\n return cell;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n */\n public create(document: IFluidDataStoreRuntime, id: string): ISharedCell {\n const cell = new SharedCell(id, document, this.attributes);\n cell.initializeLocal();\n return cell;\n }\n}\n"]}
1
+ {"version":3,"file":"cellFactory.js","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,iCAAoC;AAEpC,qDAA8C;AAE9C;;;;GAIG;AACH,MAAa,WAAW;IAevB;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,WAAW,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,WAAW,CAAC,UAAU,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,IAAI,GAAG,IAAI,iBAAU,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACrD,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,IAAI,GAAG,IAAI,iBAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;;AAlDF,kCAmDC;AAlDA;;GAEG;AACoB,gBAAI,GAAG,wCAAwC,CAAC;AAEvE;;GAEG;AACoB,sBAAU,GAAuB;IACvD,IAAI,EAAE,WAAW,CAAC,IAAI;IACtB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,2BAAU;CAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedCell } from \"./cell\";\nimport { ISharedCell } from \"./interfaces\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedCell}.\n *\n * @sealed\n */\nexport class CellFactory implements IChannelFactory {\n\t/**\n\t * {@inheritDoc CellFactory.\"type\"}\n\t */\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/cell\";\n\n\t/**\n\t * {@inheritDoc CellFactory.attributes}\n\t */\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: CellFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn CellFactory.Type;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn CellFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedCell> {\n\t\tconst cell = new SharedCell(id, runtime, attributes);\n\t\tawait cell.load(services);\n\t\treturn cell;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t */\n\tpublic create(document: IFluidDataStoreRuntime, id: string): ISharedCell {\n\t\tconst cell = new SharedCell(id, document, this.attributes);\n\t\tcell.initializeLocal();\n\t\treturn cell;\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 } 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,EAAE,WAAW,EAAE,iBAAiB,EAAE,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 { ISharedCell, ISharedCellEvents } 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
  */
@@ -92,6 +93,11 @@ export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>
92
93
  * Delete the value from the cell.
93
94
  */
94
95
  delete(): void;
96
+ /**
97
+ * @alpha
98
+ * @returns the AttributionKey associated with the cell's most recent change.
99
+ */
100
+ getAttribution(): AttributionKey | undefined;
95
101
  }
96
102
  /**
97
103
  * Describes a local Cell operation (op).
@@ -106,4 +112,23 @@ export interface ICellLocalOpMetadata<T = any> {
106
112
  */
107
113
  previousValue?: Serializable<T>;
108
114
  }
115
+ /**
116
+ * Options related to attribution
117
+ *
118
+ * @alpha
119
+ */
120
+ export interface ICellOptions {
121
+ attribution?: ICellAttributionOptions;
122
+ }
123
+ /**
124
+ * This enables the cell to store the attribution information which can be accessed with the runtime
125
+ * (i.e. who creeated the content and when it was created)
126
+ *
127
+ * default: false
128
+ *
129
+ * @alpha
130
+ */
131
+ export interface ICellAttributionOptions {
132
+ track?: boolean;
133
+ }
109
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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AGG","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 /**\n * Emitted when the value has changed.\n *\n * @remarks Event paramters:\n *\n * - `value`: The new value of the cell.\n */\n (event: \"valueChanged\", listener: (value: Serializable<T>) => void);\n\n /**\n * Emitted when the value has been deleted.\n */\n (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 /**\n * Retrieves the cell value.\n *\n * @returns - the value of the cell\n */\n get(): Serializable<T> | undefined;\n\n /**\n * Sets the cell value.\n *\n * @param value - a JSON-able or SharedObject value to set the cell to\n */\n set(value: Serializable<T>): void;\n\n /**\n * Checks whether cell is empty or not.\n *\n * @returns - `true` if the value of cell is `undefined`, `false` otherwise\n */\n empty(): boolean;\n\n /**\n * Delete the value from the cell.\n */\n delete(): void;\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 /**\n * Unique identifier for this local operation (op).\n */\n pendingMessageId: number;\n\n /**\n * The value of the {@link ISharedCell} prior to this operation (op).\n */\n previousValue?: Serializable<T> ;\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-internal.3.0.2";
8
+ export declare const pkgVersion = "2.0.0-internal.3.2.0";
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-internal.3.0.2";
11
+ exports.pkgVersion = "2.0.0-internal.3.2.0";
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,sBAAsB,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-internal.3.0.2\";\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,sBAAsB,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-internal.3.2.0\";\n"]}
package/lib/cell.d.ts CHANGED
@@ -4,7 +4,7 @@
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
9
  import { ISharedCell, ISharedCellEvents } from "./interfaces";
10
10
  /**
@@ -41,10 +41,14 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
41
41
  */
42
42
  private messageIdObserved;
43
43
  private readonly pendingMessageIds;
44
+ private attribution;
45
+ private readonly options;
44
46
  /**
45
47
  * Constructs a new `SharedCell`.
46
48
  * If the object is non-local an id and service interfaces will be provided.
47
49
  *
50
+ * @alpha
51
+ *
48
52
  * @param runtime - The data store runtime to which the `SharedCell` belongs.
49
53
  * @param id - Unique identifier for the `SharedCell`.
50
54
  */
@@ -65,6 +69,15 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
65
69
  * {@inheritDoc ISharedCell.empty}
66
70
  */
67
71
  empty(): boolean;
72
+ /**
73
+ * {@inheritDoc ISharedCell.getAttribution}
74
+ * @alpha
75
+ */
76
+ getAttribution(): AttributionKey | undefined;
77
+ /**
78
+ * Set the attribution through the SequencedDocumentMessage
79
+ */
80
+ private setAttribution;
68
81
  /**
69
82
  * Creates a summary for the Cell.
70
83
  *
@@ -116,11 +129,11 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
116
129
  */
117
130
  protected rollback(content: any, localOpMetadata: unknown): void;
118
131
  /**
119
- * Submit a cell message to remote clients.
120
- *
121
- * @param op - The cell message.
122
- * @param previousValue - The value of the cell before this op.
123
- */
132
+ * Submit a cell message to remote clients.
133
+ *
134
+ * @param op - The cell message.
135
+ * @param previousValue - The value of the cell before this op.
136
+ */
124
137
  private submitCellMessage;
125
138
  }
126
139
  //# sourceMappingURL=cell.d.ts.map
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;AAC9F,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,YAAY,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAA2B,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE7G,OAAO,EACH,WAAW,EACX,iBAAiB,EAEpB,MAAM,cAAc,CAAC;AAyBtB;;GAEG;AAGH,qBAAa,UAAU,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,YAAY,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IACjG;;;;;;;OAOG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAI9E;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C;;OAEG;IACH,OAAO,CAAC,IAAI,CAA8B;IAE1C;;;OAGG;IACH,OAAO,CAAC,SAAS,CAAc;IAE/B;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAc;IAEvC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CA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,OAAO,CAAC,cAAc;IAMtB;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAQ5E;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOxE;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAIrC;;OAEG;IACH,SAAS,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
@@ -5,7 +5,7 @@
5
5
  import { assert } from "@fluidframework/common-utils";
6
6
  import { MessageType } from "@fluidframework/protocol-definitions";
7
7
  import { readAndParse } from "@fluidframework/driver-utils";
8
- import { createSingleBlobSummary, SharedObject } from "@fluidframework/shared-object-base";
8
+ import { createSingleBlobSummary, SharedObject, } from "@fluidframework/shared-object-base";
9
9
  import { CellFactory } from "./cellFactory";
10
10
  const snapshotFileName = "header";
11
11
  /**
@@ -18,9 +18,12 @@ export class SharedCell extends SharedObject {
18
18
  * Constructs a new `SharedCell`.
19
19
  * If the object is non-local an id and service interfaces will be provided.
20
20
  *
21
+ * @alpha
22
+ *
21
23
  * @param runtime - The data store runtime to which the `SharedCell` belongs.
22
24
  * @param id - Unique identifier for the `SharedCell`.
23
25
  */
26
+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
24
27
  constructor(id, runtime, attributes) {
25
28
  super(id, runtime, attributes, "fluid_cell_");
26
29
  /**
@@ -34,6 +37,7 @@ export class SharedCell extends SharedObject {
34
37
  */
35
38
  this.messageIdObserved = -1;
36
39
  this.pendingMessageIds = [];
40
+ this.options = runtime.options;
37
41
  }
38
42
  /**
39
43
  * Create a new `SharedCell`.
@@ -101,13 +105,29 @@ export class SharedCell extends SharedObject {
101
105
  empty() {
102
106
  return this.data === undefined;
103
107
  }
108
+ /**
109
+ * {@inheritDoc ISharedCell.getAttribution}
110
+ * @alpha
111
+ */
112
+ getAttribution() {
113
+ return this.attribution;
114
+ }
115
+ /**
116
+ * Set the attribution through the SequencedDocumentMessage
117
+ */
118
+ setAttribution(message) {
119
+ var _a, _b, _c;
120
+ 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) {
121
+ this.attribution = { type: "op", seq: message.sequenceNumber };
122
+ }
123
+ }
104
124
  /**
105
125
  * Creates a summary for the Cell.
106
126
  *
107
127
  * @returns The summary of the current state of the Cell.
108
128
  */
109
129
  summarizeCore(serializer) {
110
- const content = { value: this.data };
130
+ const content = { value: this.data, attribution: this.attribution };
111
131
  return createSingleBlobSummary(snapshotFileName, serializer.stringify(content, this.handle));
112
132
  }
113
133
  /**
@@ -116,6 +136,7 @@ export class SharedCell extends SharedObject {
116
136
  async loadCore(storage) {
117
137
  const content = await readAndParse(storage, snapshotFileName);
118
138
  this.data = this.decode(content);
139
+ this.attribution = content.attribution;
119
140
  }
120
141
  /**
121
142
  * Initialize a local instance of cell.
@@ -162,11 +183,15 @@ export class SharedCell extends SharedObject {
162
183
  this.pendingMessageIds.shift();
163
184
  // We got an ACK. Update messageIdObserved.
164
185
  this.messageIdObserved = cellOpMetadata.pendingMessageId;
186
+ // update the attributor
187
+ this.setAttribution(message);
165
188
  }
166
189
  return;
167
190
  }
168
191
  if (message.type === MessageType.Operation && !local) {
169
192
  const op = message.contents;
193
+ // update the attributor
194
+ this.setAttribution(message);
170
195
  this.applyInnerOp(op);
171
196
  }
172
197
  }
@@ -190,7 +215,8 @@ export class SharedCell extends SharedObject {
190
215
  const pendingMessageId = ++this.messageId;
191
216
  this.pendingMessageIds.push(pendingMessageId);
192
217
  const localMetadata = {
193
- pendingMessageId, previousValue,
218
+ pendingMessageId,
219
+ previousValue,
194
220
  };
195
221
  return localMetadata;
196
222
  }
@@ -232,11 +258,11 @@ export class SharedCell extends SharedObject {
232
258
  }
233
259
  }
234
260
  /**
235
- * Submit a cell message to remote clients.
236
- *
237
- * @param op - The cell message.
238
- * @param previousValue - The value of the cell before this op.
239
- */
261
+ * Submit a cell message to remote clients.
262
+ *
263
+ * @param op - The cell message.
264
+ * @param previousValue - The value of the cell before this op.
265
+ */
240
266
  submitCellMessage(op, previousValue) {
241
267
  const localMetadata = this.createLocalOpMetadata(op, previousValue);
242
268
  this.submitLocalMessage(op, localMetadata);