@fluidframework/cell 2.0.0-internal.6.3.2 → 2.0.0-internal.6.4.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/CHANGELOG.md +4 -0
- package/dist/cell.d.ts +5 -5
- package/dist/cell.d.ts.map +1 -1
- package/dist/cell.js +6 -3
- package/dist/cell.js.map +1 -1
- package/dist/cellFactory.d.ts +2 -2
- package/dist/cellFactory.d.ts.map +1 -1
- package/dist/cellFactory.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +8 -8
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/cell.d.ts +5 -5
- package/lib/cell.d.ts.map +1 -1
- package/lib/cell.js +6 -3
- package/lib/cell.js.map +1 -1
- package/lib/cellFactory.d.ts +2 -2
- package/lib/cellFactory.d.ts.map +1 -1
- package/lib/cellFactory.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +8 -8
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +11 -11
- package/src/cell.ts +23 -12
- package/src/cellFactory.ts +5 -5
- package/src/index.ts +1 -1
- package/src/interfaces.ts +8 -8
- package/src/packageVersion.ts +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cell.d.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
6
|
-
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory, Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
-
import { AttributionKey, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
8
|
-
import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
|
-
import { ISharedCell, ISharedCellEvents } from "./interfaces";
|
|
5
|
+
import { type ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
6
|
+
import { type IChannelAttributes, type IFluidDataStoreRuntime, type IChannelStorageService, type IChannelFactory, type Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
+
import { type AttributionKey, type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
8
|
+
import { type IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
|
+
import { type ISharedCell, type ISharedCellEvents } from "./interfaces";
|
|
10
10
|
/**
|
|
11
11
|
* {@inheritDoc ISharedCell}
|
|
12
12
|
*/
|
package/dist/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;
|
|
1
|
+
{"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AACnG,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAEN,KAA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,IAAI,CAAC;IAOxE;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAIrC;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAgBpB;;;;;;;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
|
@@ -164,12 +164,15 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
164
164
|
*/
|
|
165
165
|
applyInnerOp(content) {
|
|
166
166
|
switch (content.type) {
|
|
167
|
-
case "setCell":
|
|
167
|
+
case "setCell": {
|
|
168
168
|
return this.setCore(this.decode(content.value));
|
|
169
|
-
|
|
169
|
+
}
|
|
170
|
+
case "deleteCell": {
|
|
170
171
|
return this.deleteCore();
|
|
171
|
-
|
|
172
|
+
}
|
|
173
|
+
default: {
|
|
172
174
|
throw new Error("Unknown operation");
|
|
175
|
+
}
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
/**
|
package/dist/cell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,+EAA8F;AAS9F,+DAA4D;AAC5D,2EAI4C;AA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;;;;;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/core-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"]}
|
|
1
|
+
{"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,+EAAmG;AAYnG,+DAA4D;AAC5D,2EAI4C;AAC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AAK,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;AArUD,gCAqUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { type ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\ttype IChannelAttributes,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelStorageService,\n\ttype IChannelFactory,\n\ttype Serializable,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype AttributionKey,\n\ttype ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n\tcreateSingleBlobSummary,\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { CellFactory } from \"./cellFactory\";\nimport {\n\ttype ISharedCell,\n\ttype ISharedCellEvents,\n\ttype ICellLocalOpMetadata,\n\ttype ICellOptions,\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 * @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\t\t\t}\n\n\t\t\tcase \"deleteCell\": {\n\t\t\t\treturn this.deleteCore();\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t}\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/cellFactory.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelServices, IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
-
import { ISharedCell } from "./interfaces";
|
|
5
|
+
import { type IChannelAttributes, type IFluidDataStoreRuntime, type IChannelServices, type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
+
import { type ISharedCell } from "./interfaces";
|
|
7
7
|
/**
|
|
8
8
|
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedCell}.
|
|
9
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cellFactory.d.ts","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,
|
|
1
|
+
{"version":3,"file":"cellFactory.d.ts","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD;;;;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"}
|
package/dist/cellFactory.js.map
CHANGED
|
@@ -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;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\
|
|
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\ttype IChannelAttributes,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelServices,\n\ttype IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedCell } from \"./cell\";\nimport { type 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, ICellOptions, ICellAttributionOptions, } from "./interfaces";
|
|
11
|
+
export type { ISharedCell, ISharedCellEvents, ICellOptions, ICellAttributionOptions, } from "./interfaces";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,
|
|
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,YAAY,EACX,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\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 type {\n\tISharedCell,\n\tISharedCellEvents,\n\tICellOptions,\n\tICellAttributionOptions,\n} from \"./interfaces\";\n"]}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
6
|
-
import { Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
-
import { AttributionKey } from "@fluidframework/runtime-definitions";
|
|
5
|
+
import { type ISharedObject, type ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
6
|
+
import { type Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
+
import { type AttributionKey } from "@fluidframework/runtime-definitions";
|
|
8
8
|
/**
|
|
9
9
|
* Events emitted by {@link ISharedCell}.
|
|
10
10
|
*/
|
|
@@ -27,7 +27,7 @@ export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
|
27
27
|
*
|
|
28
28
|
* @typeParam T - The type of cell data. Must be serializable.
|
|
29
29
|
*
|
|
30
|
-
* @example Creation
|
|
30
|
+
* @example Creation
|
|
31
31
|
*
|
|
32
32
|
* To create a `SharedCell`, call the static create method:
|
|
33
33
|
*
|
|
@@ -35,7 +35,7 @@ export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
|
35
35
|
* const myCell = SharedCell.create(this.runtime, id);
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @example Usage
|
|
38
|
+
* @example Usage
|
|
39
39
|
*
|
|
40
40
|
* The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:
|
|
41
41
|
*
|
|
@@ -64,7 +64,7 @@ export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
|
64
64
|
* }
|
|
65
65
|
* ```
|
|
66
66
|
*
|
|
67
|
-
* @example Eventing
|
|
67
|
+
* @example Eventing
|
|
68
68
|
*
|
|
69
69
|
* `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should
|
|
70
70
|
* register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted
|
|
@@ -74,7 +74,7 @@ export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>
|
|
|
74
74
|
/**
|
|
75
75
|
* Retrieves the cell value.
|
|
76
76
|
*
|
|
77
|
-
* @returns
|
|
77
|
+
* @returns The value of the cell
|
|
78
78
|
*/
|
|
79
79
|
get(): Serializable<T> | undefined;
|
|
80
80
|
/**
|
|
@@ -86,7 +86,7 @@ export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>
|
|
|
86
86
|
/**
|
|
87
87
|
* Checks whether cell is empty or not.
|
|
88
88
|
*
|
|
89
|
-
* @returns
|
|
89
|
+
* @returns `true` if the value of cell is `undefined`, `false` otherwise
|
|
90
90
|
*/
|
|
91
91
|
empty(): boolean;
|
|
92
92
|
/**
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAClG,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E;;GAEG;AACH,MA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;;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
|
|
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 { type ISharedObject, type ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { type Serializable } from \"@fluidframework/datastore-definitions\";\nimport { type 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"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/cell";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.6.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.6.4.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/cell";
|
|
11
|
-
exports.pkgVersion = "2.0.0-internal.6.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.6.4.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.6.
|
|
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.6.4.0\";\n"]}
|
package/lib/cell.d.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
6
|
-
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory, Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
-
import { AttributionKey, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
8
|
-
import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
|
-
import { ISharedCell, ISharedCellEvents } from "./interfaces";
|
|
5
|
+
import { type ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
6
|
+
import { type IChannelAttributes, type IFluidDataStoreRuntime, type IChannelStorageService, type IChannelFactory, type Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
+
import { type AttributionKey, type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
8
|
+
import { type IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
|
+
import { type ISharedCell, type ISharedCellEvents } from "./interfaces";
|
|
10
10
|
/**
|
|
11
11
|
* {@inheritDoc ISharedCell}
|
|
12
12
|
*/
|
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;
|
|
1
|
+
{"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AACnG,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAEN,KAAK,gBAAgB,EACrB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,iBAAiB,EAGtB,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;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,OAAO,CAAC,W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}
|
package/lib/cell.js
CHANGED
|
@@ -161,12 +161,15 @@ export class SharedCell extends SharedObject {
|
|
|
161
161
|
*/
|
|
162
162
|
applyInnerOp(content) {
|
|
163
163
|
switch (content.type) {
|
|
164
|
-
case "setCell":
|
|
164
|
+
case "setCell": {
|
|
165
165
|
return this.setCore(this.decode(content.value));
|
|
166
|
-
|
|
166
|
+
}
|
|
167
|
+
case "deleteCell": {
|
|
167
168
|
return this.deleteCore();
|
|
168
|
-
|
|
169
|
+
}
|
|
170
|
+
default: {
|
|
169
171
|
throw new Error("Unknown operation");
|
|
172
|
+
}
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
175
|
/**
|
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,4BAA4B,CAAC;AACpD,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,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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/core-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"]}
|
|
1
|
+
{"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAkC,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAYnG,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;AAkC5C,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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ights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { type ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\ttype IChannelAttributes,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelStorageService,\n\ttype IChannelFactory,\n\ttype Serializable,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype AttributionKey,\n\ttype ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n\tcreateSingleBlobSummary,\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { CellFactory } from \"./cellFactory\";\nimport {\n\ttype ISharedCell,\n\ttype ISharedCellEvents,\n\ttype ICellLocalOpMetadata,\n\ttype ICellOptions,\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 * @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\t\t\t}\n\n\t\t\tcase \"deleteCell\": {\n\t\t\t\treturn this.deleteCore();\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t}\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/cellFactory.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelServices, IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
-
import { ISharedCell } from "./interfaces";
|
|
5
|
+
import { type IChannelAttributes, type IFluidDataStoreRuntime, type IChannelServices, type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
+
import { type ISharedCell } from "./interfaces";
|
|
7
7
|
/**
|
|
8
8
|
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedCell}.
|
|
9
9
|
*
|
package/lib/cellFactory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cellFactory.d.ts","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,
|
|
1
|
+
{"version":3,"file":"cellFactory.d.ts","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD;;;;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"}
|
package/lib/cellFactory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cellFactory.js","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,OAAO,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,UAAU,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,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;;AAjDD;;GAEG;AACoB,gBAAI,GAAG,wCAAwC,CAAC;AAEvE;;GAEG;AACoB,sBAAU,GAAuB;IACvD,IAAI,EAAE,WAAW,CAAC,IAAI;IACtB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\
|
|
1
|
+
{"version":3,"file":"cellFactory.js","sourceRoot":"","sources":["../src/cellFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,OAAO,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,UAAU,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,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;;AAjDD;;GAEG;AACoB,gBAAI,GAAG,wCAAwC,CAAC;AAEvE;;GAEG;AACoB,sBAAU,GAAuB;IACvD,IAAI,EAAE,WAAW,CAAC,IAAI;IACtB,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype IChannelAttributes,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannelServices,\n\ttype IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedCell } from \"./cell\";\nimport { type 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/lib/index.d.ts
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
10
|
export { SharedCell } from "./cell";
|
|
11
|
-
export { ISharedCell, ISharedCellEvents, ICellOptions, ICellAttributionOptions, } from "./interfaces";
|
|
11
|
+
export type { ISharedCell, ISharedCellEvents, ICellOptions, ICellAttributionOptions, } from "./interfaces";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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,YAAY,EACX,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\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 type {\n\tISharedCell,\n\tISharedCellEvents,\n\tICellOptions,\n\tICellAttributionOptions,\n} from \"./interfaces\";\n"]}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
6
|
-
import { Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
-
import { AttributionKey } from "@fluidframework/runtime-definitions";
|
|
5
|
+
import { type ISharedObject, type ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
6
|
+
import { type Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
+
import { type AttributionKey } from "@fluidframework/runtime-definitions";
|
|
8
8
|
/**
|
|
9
9
|
* Events emitted by {@link ISharedCell}.
|
|
10
10
|
*/
|
|
@@ -27,7 +27,7 @@ export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
|
27
27
|
*
|
|
28
28
|
* @typeParam T - The type of cell data. Must be serializable.
|
|
29
29
|
*
|
|
30
|
-
* @example Creation
|
|
30
|
+
* @example Creation
|
|
31
31
|
*
|
|
32
32
|
* To create a `SharedCell`, call the static create method:
|
|
33
33
|
*
|
|
@@ -35,7 +35,7 @@ export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
|
35
35
|
* const myCell = SharedCell.create(this.runtime, id);
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @example Usage
|
|
38
|
+
* @example Usage
|
|
39
39
|
*
|
|
40
40
|
* The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:
|
|
41
41
|
*
|
|
@@ -64,7 +64,7 @@ export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
|
64
64
|
* }
|
|
65
65
|
* ```
|
|
66
66
|
*
|
|
67
|
-
* @example Eventing
|
|
67
|
+
* @example Eventing
|
|
68
68
|
*
|
|
69
69
|
* `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should
|
|
70
70
|
* register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted
|
|
@@ -74,7 +74,7 @@ export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>
|
|
|
74
74
|
/**
|
|
75
75
|
* Retrieves the cell value.
|
|
76
76
|
*
|
|
77
|
-
* @returns
|
|
77
|
+
* @returns The value of the cell
|
|
78
78
|
*/
|
|
79
79
|
get(): Serializable<T> | undefined;
|
|
80
80
|
/**
|
|
@@ -86,7 +86,7 @@ export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>
|
|
|
86
86
|
/**
|
|
87
87
|
* Checks whether cell is empty or not.
|
|
88
88
|
*
|
|
89
|
-
* @returns
|
|
89
|
+
* @returns `true` if the value of cell is `undefined`, `false` otherwise
|
|
90
90
|
*/
|
|
91
91
|
empty(): boolean;
|
|
92
92
|
/**
|
package/lib/interfaces.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAClG,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E;;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;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"}
|
package/lib/interfaces.js.map
CHANGED
|
@@ -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\";\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
|
|
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 { type ISharedObject, type ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { type Serializable } from \"@fluidframework/datastore-definitions\";\nimport { type 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"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/cell";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.6.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.6.4.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAC9C,MAAM,CAAC,MAAM,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.6.
|
|
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,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.6.4.0\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/cell",
|
|
3
|
-
"version": "2.0.0-internal.6.
|
|
3
|
+
"version": "2.0.0-internal.6.4.0",
|
|
4
4
|
"description": "Distributed data structure for a single value",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -35,23 +35,23 @@
|
|
|
35
35
|
"temp-directory": "nyc/.nyc_output"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.6.
|
|
39
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.6.
|
|
40
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-internal.6.
|
|
41
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.6.
|
|
38
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.6.4.0 <2.0.0-internal.6.5.0",
|
|
39
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.6.4.0 <2.0.0-internal.6.5.0",
|
|
40
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-internal.6.4.0 <2.0.0-internal.6.5.0",
|
|
41
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.6.4.0 <2.0.0-internal.6.5.0",
|
|
42
42
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
43
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.6.
|
|
44
|
-
"@fluidframework/shared-object-base": ">=2.0.0-internal.6.
|
|
43
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.6.4.0 <2.0.0-internal.6.5.0",
|
|
44
|
+
"@fluidframework/shared-object-base": ">=2.0.0-internal.6.4.0 <2.0.0-internal.6.5.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@fluid-internal/test-dds-utils": ">=2.0.0-internal.6.
|
|
47
|
+
"@fluid-internal/test-dds-utils": ">=2.0.0-internal.6.4.0 <2.0.0-internal.6.5.0",
|
|
48
48
|
"@fluid-tools/build-cli": "^0.22.0",
|
|
49
49
|
"@fluidframework/build-common": "^2.0.0",
|
|
50
50
|
"@fluidframework/build-tools": "^0.22.0",
|
|
51
|
-
"@fluidframework/cell-previous": "npm:@fluidframework/cell@2.0.0-internal.6.3.
|
|
51
|
+
"@fluidframework/cell-previous": "npm:@fluidframework/cell@2.0.0-internal.6.3.0",
|
|
52
52
|
"@fluidframework/eslint-config-fluid": "^2.1.0",
|
|
53
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.
|
|
54
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.6.
|
|
53
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.4.0 <2.0.0-internal.6.5.0",
|
|
54
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.6.4.0 <2.0.0-internal.6.5.0",
|
|
55
55
|
"@microsoft/api-extractor": "^7.34.4",
|
|
56
56
|
"@types/mocha": "^9.1.1",
|
|
57
57
|
"@types/node": "^16.18.38",
|
package/src/cell.ts
CHANGED
|
@@ -4,23 +4,31 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils";
|
|
7
|
-
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { type ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import {
|
|
9
|
-
IChannelAttributes,
|
|
10
|
-
IFluidDataStoreRuntime,
|
|
11
|
-
IChannelStorageService,
|
|
12
|
-
IChannelFactory,
|
|
13
|
-
Serializable,
|
|
9
|
+
type IChannelAttributes,
|
|
10
|
+
type IFluidDataStoreRuntime,
|
|
11
|
+
type IChannelStorageService,
|
|
12
|
+
type IChannelFactory,
|
|
13
|
+
type Serializable,
|
|
14
14
|
} from "@fluidframework/datastore-definitions";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
type AttributionKey,
|
|
17
|
+
type ISummaryTreeWithStats,
|
|
18
|
+
} from "@fluidframework/runtime-definitions";
|
|
16
19
|
import { readAndParse } from "@fluidframework/driver-utils";
|
|
17
20
|
import {
|
|
18
21
|
createSingleBlobSummary,
|
|
19
|
-
IFluidSerializer,
|
|
22
|
+
type IFluidSerializer,
|
|
20
23
|
SharedObject,
|
|
21
24
|
} from "@fluidframework/shared-object-base";
|
|
22
25
|
import { CellFactory } from "./cellFactory";
|
|
23
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
type ISharedCell,
|
|
28
|
+
type ISharedCellEvents,
|
|
29
|
+
type ICellLocalOpMetadata,
|
|
30
|
+
type ICellOptions,
|
|
31
|
+
} from "./interfaces";
|
|
24
32
|
|
|
25
33
|
/**
|
|
26
34
|
* Description of a cell delta operation
|
|
@@ -242,14 +250,17 @@ export class SharedCell<T = any>
|
|
|
242
250
|
*/
|
|
243
251
|
private applyInnerOp(content: ICellOperation): Serializable<T> | undefined {
|
|
244
252
|
switch (content.type) {
|
|
245
|
-
case "setCell":
|
|
253
|
+
case "setCell": {
|
|
246
254
|
return this.setCore(this.decode(content.value));
|
|
255
|
+
}
|
|
247
256
|
|
|
248
|
-
case "deleteCell":
|
|
257
|
+
case "deleteCell": {
|
|
249
258
|
return this.deleteCore();
|
|
259
|
+
}
|
|
250
260
|
|
|
251
|
-
default:
|
|
261
|
+
default: {
|
|
252
262
|
throw new Error("Unknown operation");
|
|
263
|
+
}
|
|
253
264
|
}
|
|
254
265
|
}
|
|
255
266
|
|
package/src/cellFactory.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
IChannelAttributes,
|
|
8
|
-
IFluidDataStoreRuntime,
|
|
9
|
-
IChannelServices,
|
|
10
|
-
IChannelFactory,
|
|
7
|
+
type IChannelAttributes,
|
|
8
|
+
type IFluidDataStoreRuntime,
|
|
9
|
+
type IChannelServices,
|
|
10
|
+
type IChannelFactory,
|
|
11
11
|
} from "@fluidframework/datastore-definitions";
|
|
12
12
|
import { SharedCell } from "./cell";
|
|
13
|
-
import { ISharedCell } from "./interfaces";
|
|
13
|
+
import { type ISharedCell } from "./interfaces";
|
|
14
14
|
import { pkgVersion } from "./packageVersion";
|
|
15
15
|
|
|
16
16
|
/**
|
package/src/index.ts
CHANGED
package/src/interfaces.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
7
|
-
import { Serializable } from "@fluidframework/datastore-definitions";
|
|
8
|
-
import { AttributionKey } from "@fluidframework/runtime-definitions";
|
|
6
|
+
import { type ISharedObject, type ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
7
|
+
import { type Serializable } from "@fluidframework/datastore-definitions";
|
|
8
|
+
import { type AttributionKey } from "@fluidframework/runtime-definitions";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Events emitted by {@link ISharedCell}.
|
|
@@ -31,7 +31,7 @@ export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
|
31
31
|
*
|
|
32
32
|
* @typeParam T - The type of cell data. Must be serializable.
|
|
33
33
|
*
|
|
34
|
-
* @example Creation
|
|
34
|
+
* @example Creation
|
|
35
35
|
*
|
|
36
36
|
* To create a `SharedCell`, call the static create method:
|
|
37
37
|
*
|
|
@@ -39,7 +39,7 @@ export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
|
39
39
|
* const myCell = SharedCell.create(this.runtime, id);
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
|
-
* @example Usage
|
|
42
|
+
* @example Usage
|
|
43
43
|
*
|
|
44
44
|
* The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:
|
|
45
45
|
*
|
|
@@ -68,7 +68,7 @@ export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
|
68
68
|
* }
|
|
69
69
|
* ```
|
|
70
70
|
*
|
|
71
|
-
* @example Eventing
|
|
71
|
+
* @example Eventing
|
|
72
72
|
*
|
|
73
73
|
* `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should
|
|
74
74
|
* register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted
|
|
@@ -80,7 +80,7 @@ export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>
|
|
|
80
80
|
/**
|
|
81
81
|
* Retrieves the cell value.
|
|
82
82
|
*
|
|
83
|
-
* @returns
|
|
83
|
+
* @returns The value of the cell
|
|
84
84
|
*/
|
|
85
85
|
get(): Serializable<T> | undefined;
|
|
86
86
|
|
|
@@ -94,7 +94,7 @@ export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>
|
|
|
94
94
|
/**
|
|
95
95
|
* Checks whether cell is empty or not.
|
|
96
96
|
*
|
|
97
|
-
* @returns
|
|
97
|
+
* @returns `true` if the value of cell is `undefined`, `false` otherwise
|
|
98
98
|
*/
|
|
99
99
|
empty(): boolean;
|
|
100
100
|
|
package/src/packageVersion.ts
CHANGED