@fluidframework/cell 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +9 -7
- package/.mocharc.js +2 -2
- package/README.md +91 -1
- package/api-extractor.json +2 -2
- package/dist/cell.d.ts +45 -72
- package/dist/cell.d.ts.map +1 -1
- package/dist/cell.js +72 -73
- package/dist/cell.js.map +1 -1
- package/dist/cellFactory.d.ts +18 -1
- package/dist/cellFactory.d.ts.map +1 -1
- package/dist/cellFactory.js +18 -1
- package/dist/cellFactory.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +95 -3
- 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 +45 -72
- package/lib/cell.d.ts.map +1 -1
- package/lib/cell.js +73 -74
- package/lib/cell.js.map +1 -1
- package/lib/cellFactory.d.ts +18 -1
- package/lib/cellFactory.d.ts.map +1 -1
- package/lib/cellFactory.js +18 -1
- package/lib/cellFactory.js.map +1 -1
- package/lib/index.d.ts +6 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +95 -3
- 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 +53 -53
- package/prettier.config.cjs +1 -1
- package/src/cell.ts +349 -320
- package/src/cellFactory.ts +52 -34
- package/src/index.ts +12 -1
- package/src/interfaces.ts +133 -32
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
package/.eslintrc.js
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/strict"), "prettier"],
|
|
8
|
+
parserOptions: {
|
|
9
|
+
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
// TODO: consider re-enabling once we have addressed how this rule conflicts with our error codes.
|
|
13
|
+
"unicorn/numeric-separators-style": "off",
|
|
14
|
+
},
|
|
15
|
+
};
|
package/.mocharc.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
"use strict";
|
|
7
7
|
|
|
8
|
-
const getFluidTestMochaConfig = require(
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
|
|
9
9
|
|
|
10
10
|
const packageDir = __dirname;
|
|
11
11
|
const config = getFluidTestMochaConfig(packageDir);
|
package/README.md
CHANGED
|
@@ -1,3 +1,93 @@
|
|
|
1
1
|
# @fluidframework/cell
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value that can be edited or deleted.
|
|
4
|
+
|
|
5
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_INSTALLATION_SECTION:includeHeading=TRUE) -->
|
|
6
|
+
|
|
7
|
+
<!-- prettier-ignore-start -->
|
|
8
|
+
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
To get started, install the package by running the following command:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm i @fluidframework/cell
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
<!-- prettier-ignore-end -->
|
|
19
|
+
|
|
20
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
21
|
+
|
|
22
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_API_DOCS_SECTION:includeHeading=TRUE) -->
|
|
23
|
+
|
|
24
|
+
<!-- prettier-ignore-start -->
|
|
25
|
+
|
|
26
|
+
<!-- This section is automatically generated. To update it, make the appropriate changes to docs/md-magic.config.js or the embedded content, then run 'npm run build:md-magic' in the docs folder. -->
|
|
27
|
+
|
|
28
|
+
## API Documentation
|
|
29
|
+
|
|
30
|
+
API documentation for **@fluidframework/cell** is available at <https://fluidframework.com/docs/apis/cell>.
|
|
31
|
+
|
|
32
|
+
<!-- prettier-ignore-end -->
|
|
33
|
+
|
|
34
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
35
|
+
|
|
36
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_CONTRIBUTION_GUIDELINES_SECTION:includeHeading=TRUE) -->
|
|
37
|
+
|
|
38
|
+
<!-- prettier-ignore-start -->
|
|
39
|
+
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
40
|
+
|
|
41
|
+
## Contribution Guidelines
|
|
42
|
+
|
|
43
|
+
There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.
|
|
44
|
+
|
|
45
|
+
- Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
|
|
46
|
+
- [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
|
|
47
|
+
- Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
|
|
48
|
+
- [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
|
|
49
|
+
|
|
50
|
+
Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/wiki).
|
|
51
|
+
|
|
52
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
53
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
54
|
+
|
|
55
|
+
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
56
|
+
Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
|
|
57
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
58
|
+
|
|
59
|
+
<!-- prettier-ignore-end -->
|
|
60
|
+
|
|
61
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
62
|
+
|
|
63
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_HELP_SECTION:includeHeading=TRUE) -->
|
|
64
|
+
|
|
65
|
+
<!-- prettier-ignore-start -->
|
|
66
|
+
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
67
|
+
|
|
68
|
+
## Help
|
|
69
|
+
|
|
70
|
+
Not finding what you're looking for in this README?
|
|
71
|
+
Check out our [GitHub Wiki](https://github.com/microsoft/FluidFramework/wiki) or [fluidframework.com](https://fluidframework.com/docs/).
|
|
72
|
+
|
|
73
|
+
Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
|
|
74
|
+
Thank you!
|
|
75
|
+
|
|
76
|
+
<!-- prettier-ignore-end -->
|
|
77
|
+
|
|
78
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
79
|
+
|
|
80
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_TRADEMARK_SECTION:includeHeading=TRUE) -->
|
|
81
|
+
|
|
82
|
+
<!-- prettier-ignore-start -->
|
|
83
|
+
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
84
|
+
|
|
85
|
+
## Trademark
|
|
86
|
+
|
|
87
|
+
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
88
|
+
Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
89
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
90
|
+
|
|
91
|
+
<!-- prettier-ignore-end -->
|
|
92
|
+
|
|
93
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-common-report.json"
|
|
4
4
|
}
|
package/dist/cell.d.ts
CHANGED
|
@@ -4,69 +4,26 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
6
6
|
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory, Serializable } from "@fluidframework/datastore-definitions";
|
|
7
|
-
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
7
|
+
import { AttributionKey, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
8
8
|
import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
9
|
import { ISharedCell, ISharedCellEvents } from "./interfaces";
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* ### Creation
|
|
15
|
-
*
|
|
16
|
-
* To create a `SharedCell`, call the static create method:
|
|
17
|
-
*
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const myCell = SharedCell.create(this.runtime, id);
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* ### Usage
|
|
23
|
-
*
|
|
24
|
-
* The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:
|
|
25
|
-
*
|
|
26
|
-
* ```typescript
|
|
27
|
-
* myCell.set(3);
|
|
28
|
-
* console.log(myCell.get()); // 3
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* The value must only be plain JS objects or `SharedObject` handles (e.g. to another DDS or Fluid object).
|
|
32
|
-
* In collaborative scenarios, the value is settled with a policy of _last write wins_.
|
|
33
|
-
*
|
|
34
|
-
* The `.delete()` method will delete the stored value from the cell:
|
|
35
|
-
*
|
|
36
|
-
* ```typescript
|
|
37
|
-
* myCell.delete();
|
|
38
|
-
* console.log(myCell.get()); // undefined
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* The `.empty()` method will check if the value is undefined.
|
|
42
|
-
*
|
|
43
|
-
* ```typescript
|
|
44
|
-
* if (myCell.empty()) {
|
|
45
|
-
* // myCell.get() will return undefined
|
|
46
|
-
* } else {
|
|
47
|
-
* // myCell.get() will return a non-undefined value
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* ### Eventing
|
|
52
|
-
*
|
|
53
|
-
* `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should
|
|
54
|
-
* register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted
|
|
55
|
-
* in response to a `set`, and `delete` will be emitted in response to a `delete`.
|
|
11
|
+
* {@inheritDoc ISharedCell}
|
|
56
12
|
*/
|
|
57
13
|
export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<T>> implements ISharedCell<T> {
|
|
58
14
|
/**
|
|
59
|
-
* Create a new
|
|
15
|
+
* Create a new `SharedCell`.
|
|
60
16
|
*
|
|
61
|
-
* @param runtime - data store runtime
|
|
62
|
-
* @param id -
|
|
63
|
-
*
|
|
17
|
+
* @param runtime - The data store runtime to which the `SharedCell` belongs.
|
|
18
|
+
* @param id - Unique identifier for the `SharedCell`.
|
|
19
|
+
*
|
|
20
|
+
* @returns The newly create `SharedCell`. Note that it will not yet be attached.
|
|
64
21
|
*/
|
|
65
|
-
static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCell
|
|
22
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): SharedCell;
|
|
66
23
|
/**
|
|
67
|
-
*
|
|
24
|
+
* Gets the factory for the `SharedCell` to register with the data store.
|
|
68
25
|
*
|
|
69
|
-
* @returns
|
|
26
|
+
* @returns A factory that creates and loads `SharedCell`s.
|
|
70
27
|
*/
|
|
71
28
|
static getFactory(): IChannelFactory;
|
|
72
29
|
/**
|
|
@@ -84,12 +41,14 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
|
|
|
84
41
|
*/
|
|
85
42
|
private messageIdObserved;
|
|
86
43
|
private readonly pendingMessageIds;
|
|
44
|
+
private attribution;
|
|
45
|
+
private readonly options;
|
|
87
46
|
/**
|
|
88
|
-
* Constructs a new
|
|
89
|
-
* be provided
|
|
47
|
+
* Constructs a new `SharedCell`.
|
|
48
|
+
* If the object is non-local an id and service interfaces will be provided.
|
|
90
49
|
*
|
|
91
|
-
* @param runtime - data store runtime the
|
|
92
|
-
* @param id -
|
|
50
|
+
* @param runtime - The data store runtime to which the `SharedCell` belongs.
|
|
51
|
+
* @param id - Unique identifier for the `SharedCell`.
|
|
93
52
|
*/
|
|
94
53
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
95
54
|
/**
|
|
@@ -109,9 +68,19 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
|
|
|
109
68
|
*/
|
|
110
69
|
empty(): boolean;
|
|
111
70
|
/**
|
|
112
|
-
*
|
|
71
|
+
* {@inheritDoc ISharedCell.getAttribution}
|
|
72
|
+
* @alpha
|
|
73
|
+
*/
|
|
74
|
+
getAttribution(): AttributionKey | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Set the Op-based attribution through the SequencedDocumentMessage,
|
|
77
|
+
* or set the local/detached attribution.
|
|
78
|
+
*/
|
|
79
|
+
private setAttribution;
|
|
80
|
+
/**
|
|
81
|
+
* Creates a summary for the Cell.
|
|
113
82
|
*
|
|
114
|
-
* @returns
|
|
83
|
+
* @returns The summary of the current state of the Cell.
|
|
115
84
|
*/
|
|
116
85
|
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
117
86
|
/**
|
|
@@ -119,25 +88,26 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
|
|
|
119
88
|
*/
|
|
120
89
|
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
121
90
|
/**
|
|
122
|
-
* Initialize a local instance of cell
|
|
91
|
+
* Initialize a local instance of cell.
|
|
123
92
|
*/
|
|
124
93
|
protected initializeLocalCore(): void;
|
|
125
94
|
/**
|
|
126
|
-
* Call back on disconnect
|
|
95
|
+
* Call back on disconnect.
|
|
127
96
|
*/
|
|
128
97
|
protected onDisconnect(): void;
|
|
129
98
|
/**
|
|
130
|
-
* Apply inner op
|
|
99
|
+
* Apply inner op.
|
|
100
|
+
*
|
|
131
101
|
* @param content - ICellOperation content
|
|
132
102
|
*/
|
|
133
103
|
private applyInnerOp;
|
|
134
104
|
/**
|
|
135
|
-
* Process a cell operation
|
|
105
|
+
* Process a cell operation (op).
|
|
136
106
|
*
|
|
137
|
-
* @param message -
|
|
138
|
-
* @param local -
|
|
107
|
+
* @param message - The message to prepare.
|
|
108
|
+
* @param local - Whether or not the message was sent by the local client.
|
|
139
109
|
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
140
|
-
* For messages from a remote client, this will be undefined
|
|
110
|
+
* For messages from a remote client, this will be `undefined`.
|
|
141
111
|
*/
|
|
142
112
|
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
143
113
|
private setCore;
|
|
@@ -146,20 +116,23 @@ export declare class SharedCell<T = any> extends SharedObject<ISharedCellEvents<
|
|
|
146
116
|
private createLocalOpMetadata;
|
|
147
117
|
/**
|
|
148
118
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
119
|
+
*
|
|
149
120
|
* @internal
|
|
150
121
|
*/
|
|
151
122
|
protected applyStashedOp(content: unknown): unknown;
|
|
152
123
|
/**
|
|
153
|
-
* Rollback a local op
|
|
154
|
-
*
|
|
124
|
+
* Rollback a local op.
|
|
125
|
+
*
|
|
126
|
+
* @param content - The operation to rollback.
|
|
155
127
|
* @param localOpMetadata - The local metadata associated with the op.
|
|
156
128
|
*/
|
|
157
129
|
protected rollback(content: any, localOpMetadata: unknown): void;
|
|
158
130
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
131
|
+
* Submit a cell message to remote clients.
|
|
132
|
+
*
|
|
133
|
+
* @param op - The cell message.
|
|
134
|
+
* @param previousValue - The value of the cell before this op.
|
|
135
|
+
*/
|
|
163
136
|
private submitCellMessage;
|
|
164
137
|
}
|
|
165
138
|
//# sourceMappingURL=cell.d.ts.map
|
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;AAC9F,OAAO,
|
|
1
|
+
{"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5F,OAAO,EAEN,gBAAgB,EAChB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAsC,MAAM,cAAc,CAAC;AA8BlG;;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,WAAW,CAA6B;IAEhD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IAEnD;;;;;;OAMG;gBAES,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,kBAAkB;IAMvF;;OAEG;IACI,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS;IAIzC;;OAEG;IACI,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI;IAsBxC;;OAEG;IACI,MAAM,IAAI,IAAI;IAgBrB;;OAEG;IACI,KAAK,IAAI,OAAO;IAIvB;;;OAGG;IACI,cAAc,IAAI,cAAc,GAAG,SAAS;IAInD;;;OAGG;IACH,OAAO,CAAC,cAAc;IAUtB;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAW5E;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOxE;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAIrC;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAapB;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAgCP,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,qBAAqB;IAa7B;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAMnD;;;;;OAKG;IAGH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAmBhE;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CAIzB"}
|
package/dist/cell.js
CHANGED
|
@@ -12,60 +12,19 @@ const shared_object_base_1 = require("@fluidframework/shared-object-base");
|
|
|
12
12
|
const cellFactory_1 = require("./cellFactory");
|
|
13
13
|
const snapshotFileName = "header";
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* ### Creation
|
|
19
|
-
*
|
|
20
|
-
* To create a `SharedCell`, call the static create method:
|
|
21
|
-
*
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const myCell = SharedCell.create(this.runtime, id);
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* ### Usage
|
|
27
|
-
*
|
|
28
|
-
* The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:
|
|
29
|
-
*
|
|
30
|
-
* ```typescript
|
|
31
|
-
* myCell.set(3);
|
|
32
|
-
* console.log(myCell.get()); // 3
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* The value must only be plain JS objects or `SharedObject` handles (e.g. to another DDS or Fluid object).
|
|
36
|
-
* In collaborative scenarios, the value is settled with a policy of _last write wins_.
|
|
37
|
-
*
|
|
38
|
-
* The `.delete()` method will delete the stored value from the cell:
|
|
39
|
-
*
|
|
40
|
-
* ```typescript
|
|
41
|
-
* myCell.delete();
|
|
42
|
-
* console.log(myCell.get()); // undefined
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* The `.empty()` method will check if the value is undefined.
|
|
46
|
-
*
|
|
47
|
-
* ```typescript
|
|
48
|
-
* if (myCell.empty()) {
|
|
49
|
-
* // myCell.get() will return undefined
|
|
50
|
-
* } else {
|
|
51
|
-
* // myCell.get() will return a non-undefined value
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* ### Eventing
|
|
56
|
-
*
|
|
57
|
-
* `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should
|
|
58
|
-
* register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted
|
|
59
|
-
* in response to a `set`, and `delete` will be emitted in response to a `delete`.
|
|
15
|
+
* {@inheritDoc ISharedCell}
|
|
60
16
|
*/
|
|
17
|
+
// TODO: use `unknown` instead (breaking change).
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
19
|
class SharedCell extends shared_object_base_1.SharedObject {
|
|
62
20
|
/**
|
|
63
|
-
* Constructs a new
|
|
64
|
-
* be provided
|
|
21
|
+
* Constructs a new `SharedCell`.
|
|
22
|
+
* If the object is non-local an id and service interfaces will be provided.
|
|
65
23
|
*
|
|
66
|
-
* @param runtime - data store runtime the
|
|
67
|
-
* @param id -
|
|
24
|
+
* @param runtime - The data store runtime to which the `SharedCell` belongs.
|
|
25
|
+
* @param id - Unique identifier for the `SharedCell`.
|
|
68
26
|
*/
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
69
28
|
constructor(id, runtime, attributes) {
|
|
70
29
|
super(id, runtime, attributes, "fluid_cell_");
|
|
71
30
|
/**
|
|
@@ -79,21 +38,23 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
79
38
|
*/
|
|
80
39
|
this.messageIdObserved = -1;
|
|
81
40
|
this.pendingMessageIds = [];
|
|
41
|
+
this.options = runtime.options;
|
|
82
42
|
}
|
|
83
43
|
/**
|
|
84
|
-
* Create a new
|
|
44
|
+
* Create a new `SharedCell`.
|
|
85
45
|
*
|
|
86
|
-
* @param runtime - data store runtime
|
|
87
|
-
* @param id -
|
|
88
|
-
*
|
|
46
|
+
* @param runtime - The data store runtime to which the `SharedCell` belongs.
|
|
47
|
+
* @param id - Unique identifier for the `SharedCell`.
|
|
48
|
+
*
|
|
49
|
+
* @returns The newly create `SharedCell`. Note that it will not yet be attached.
|
|
89
50
|
*/
|
|
90
51
|
static create(runtime, id) {
|
|
91
52
|
return runtime.createChannel(id, cellFactory_1.CellFactory.Type);
|
|
92
53
|
}
|
|
93
54
|
/**
|
|
94
|
-
*
|
|
55
|
+
* Gets the factory for the `SharedCell` to register with the data store.
|
|
95
56
|
*
|
|
96
|
-
* @returns
|
|
57
|
+
* @returns A factory that creates and loads `SharedCell`s.
|
|
97
58
|
*/
|
|
98
59
|
static getFactory() {
|
|
99
60
|
return new cellFactory_1.CellFactory();
|
|
@@ -114,6 +75,7 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
114
75
|
};
|
|
115
76
|
// Set the value locally.
|
|
116
77
|
const previousValue = this.setCore(value);
|
|
78
|
+
this.setAttribution();
|
|
117
79
|
// If we are not attached, don't submit the op.
|
|
118
80
|
if (!this.isAttached()) {
|
|
119
81
|
return;
|
|
@@ -130,6 +92,7 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
130
92
|
delete() {
|
|
131
93
|
// Delete the value locally.
|
|
132
94
|
const previousValue = this.deleteCore();
|
|
95
|
+
this.setAttribution();
|
|
133
96
|
// If we are not attached, don't submit the op.
|
|
134
97
|
if (!this.isAttached()) {
|
|
135
98
|
return;
|
|
@@ -146,12 +109,36 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
146
109
|
return this.data === undefined;
|
|
147
110
|
}
|
|
148
111
|
/**
|
|
149
|
-
*
|
|
112
|
+
* {@inheritDoc ISharedCell.getAttribution}
|
|
113
|
+
* @alpha
|
|
114
|
+
*/
|
|
115
|
+
getAttribution() {
|
|
116
|
+
return this.attribution;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Set the Op-based attribution through the SequencedDocumentMessage,
|
|
120
|
+
* or set the local/detached attribution.
|
|
121
|
+
*/
|
|
122
|
+
setAttribution(message) {
|
|
123
|
+
var _a, _b, _c;
|
|
124
|
+
if ((_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.attribution) === null || _b === void 0 ? void 0 : _b.track) !== null && _c !== void 0 ? _c : false) {
|
|
125
|
+
this.attribution = message
|
|
126
|
+
? { type: "op", seq: message.sequenceNumber }
|
|
127
|
+
: this.isAttached()
|
|
128
|
+
? { type: "local" }
|
|
129
|
+
: { type: "detached", id: 0 };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Creates a summary for the Cell.
|
|
150
134
|
*
|
|
151
|
-
* @returns
|
|
135
|
+
* @returns The summary of the current state of the Cell.
|
|
152
136
|
*/
|
|
153
137
|
summarizeCore(serializer) {
|
|
154
|
-
|
|
138
|
+
var _a;
|
|
139
|
+
const content = ((_a = this.attribution) === null || _a === void 0 ? void 0 : _a.type) === "local"
|
|
140
|
+
? { value: this.data, attribution: undefined }
|
|
141
|
+
: { value: this.data, attribution: this.attribution };
|
|
155
142
|
return (0, shared_object_base_1.createSingleBlobSummary)(snapshotFileName, serializer.stringify(content, this.handle));
|
|
156
143
|
}
|
|
157
144
|
/**
|
|
@@ -160,19 +147,21 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
160
147
|
async loadCore(storage) {
|
|
161
148
|
const content = await (0, driver_utils_1.readAndParse)(storage, snapshotFileName);
|
|
162
149
|
this.data = this.decode(content);
|
|
150
|
+
this.attribution = content.attribution;
|
|
163
151
|
}
|
|
164
152
|
/**
|
|
165
|
-
* Initialize a local instance of cell
|
|
153
|
+
* Initialize a local instance of cell.
|
|
166
154
|
*/
|
|
167
155
|
initializeLocalCore() {
|
|
168
156
|
this.data = undefined;
|
|
169
157
|
}
|
|
170
158
|
/**
|
|
171
|
-
* Call back on disconnect
|
|
159
|
+
* Call back on disconnect.
|
|
172
160
|
*/
|
|
173
161
|
onDisconnect() { }
|
|
174
162
|
/**
|
|
175
|
-
* Apply inner op
|
|
163
|
+
* Apply inner op.
|
|
164
|
+
*
|
|
176
165
|
* @param content - ICellOperation content
|
|
177
166
|
*/
|
|
178
167
|
applyInnerOp(content) {
|
|
@@ -186,12 +175,12 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
186
175
|
}
|
|
187
176
|
}
|
|
188
177
|
/**
|
|
189
|
-
* Process a cell operation
|
|
178
|
+
* Process a cell operation (op).
|
|
190
179
|
*
|
|
191
|
-
* @param message -
|
|
192
|
-
* @param local -
|
|
180
|
+
* @param message - The message to prepare.
|
|
181
|
+
* @param local - Whether or not the message was sent by the local client.
|
|
193
182
|
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
194
|
-
* For messages from a remote client, this will be undefined
|
|
183
|
+
* For messages from a remote client, this will be `undefined`.
|
|
195
184
|
*/
|
|
196
185
|
processCore(message, local, localOpMetadata) {
|
|
197
186
|
const cellOpMetadata = localOpMetadata;
|
|
@@ -205,11 +194,15 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
205
194
|
this.pendingMessageIds.shift();
|
|
206
195
|
// We got an ACK. Update messageIdObserved.
|
|
207
196
|
this.messageIdObserved = cellOpMetadata.pendingMessageId;
|
|
197
|
+
// update the attributor
|
|
198
|
+
this.setAttribution(message);
|
|
208
199
|
}
|
|
209
200
|
return;
|
|
210
201
|
}
|
|
211
202
|
if (message.type === protocol_definitions_1.MessageType.Operation && !local) {
|
|
212
203
|
const op = message.contents;
|
|
204
|
+
// update the attributor
|
|
205
|
+
this.setAttribution(message);
|
|
213
206
|
this.applyInnerOp(op);
|
|
214
207
|
}
|
|
215
208
|
}
|
|
@@ -227,19 +220,20 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
227
220
|
}
|
|
228
221
|
decode(cellValue) {
|
|
229
222
|
const value = cellValue.value;
|
|
230
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
231
223
|
return this.serializer.decode(value);
|
|
232
224
|
}
|
|
233
225
|
createLocalOpMetadata(op, previousValue) {
|
|
234
226
|
const pendingMessageId = ++this.messageId;
|
|
235
227
|
this.pendingMessageIds.push(pendingMessageId);
|
|
236
228
|
const localMetadata = {
|
|
237
|
-
pendingMessageId,
|
|
229
|
+
pendingMessageId,
|
|
230
|
+
previousValue,
|
|
238
231
|
};
|
|
239
232
|
return localMetadata;
|
|
240
233
|
}
|
|
241
234
|
/**
|
|
242
235
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
236
|
+
*
|
|
243
237
|
* @internal
|
|
244
238
|
*/
|
|
245
239
|
applyStashedOp(content) {
|
|
@@ -248,12 +242,16 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
248
242
|
return this.createLocalOpMetadata(cellContent, previousValue);
|
|
249
243
|
}
|
|
250
244
|
/**
|
|
251
|
-
* Rollback a local op
|
|
252
|
-
*
|
|
245
|
+
* Rollback a local op.
|
|
246
|
+
*
|
|
247
|
+
* @param content - The operation to rollback.
|
|
253
248
|
* @param localOpMetadata - The local metadata associated with the op.
|
|
254
249
|
*/
|
|
250
|
+
// TODO: use `unknown` instead (breaking change).
|
|
251
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
255
252
|
rollback(content, localOpMetadata) {
|
|
256
253
|
const cellOpMetadata = localOpMetadata;
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
257
255
|
if (content.type === "setCell" || content.type === "deleteCell") {
|
|
258
256
|
if (cellOpMetadata.previousValue === undefined) {
|
|
259
257
|
this.deleteCore();
|
|
@@ -271,10 +269,11 @@ class SharedCell extends shared_object_base_1.SharedObject {
|
|
|
271
269
|
}
|
|
272
270
|
}
|
|
273
271
|
/**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
272
|
+
* Submit a cell message to remote clients.
|
|
273
|
+
*
|
|
274
|
+
* @param op - The cell message.
|
|
275
|
+
* @param previousValue - The value of the cell before this op.
|
|
276
|
+
*/
|
|
278
277
|
submitCellMessage(op, previousValue) {
|
|
279
278
|
const localMetadata = this.createLocalOpMetadata(op, previousValue);
|
|
280
279
|
this.submitLocalMessage(op, localMetadata);
|