@fluidframework/cell 2.0.0-internal.2.2.1 → 2.0.0-internal.2.3.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.
Files changed (44) hide show
  1. package/.eslintrc.js +5 -1
  2. package/README.md +95 -1
  3. package/dist/cell.d.ts +30 -69
  4. package/dist/cell.d.ts.map +1 -1
  5. package/dist/cell.js +34 -69
  6. package/dist/cell.js.map +1 -1
  7. package/dist/cellFactory.d.ts +18 -1
  8. package/dist/cellFactory.d.ts.map +1 -1
  9. package/dist/cellFactory.js +18 -1
  10. package/dist/cellFactory.js.map +1 -1
  11. package/dist/index.d.ts +5 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +5 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/interfaces.d.ts +70 -3
  16. package/dist/interfaces.d.ts.map +1 -1
  17. package/dist/interfaces.js.map +1 -1
  18. package/dist/packageVersion.d.ts +1 -1
  19. package/dist/packageVersion.js +1 -1
  20. package/dist/packageVersion.js.map +1 -1
  21. package/lib/cell.d.ts +30 -69
  22. package/lib/cell.d.ts.map +1 -1
  23. package/lib/cell.js +34 -69
  24. package/lib/cell.js.map +1 -1
  25. package/lib/cellFactory.d.ts +18 -1
  26. package/lib/cellFactory.d.ts.map +1 -1
  27. package/lib/cellFactory.js +18 -1
  28. package/lib/cellFactory.js.map +1 -1
  29. package/lib/index.d.ts +5 -0
  30. package/lib/index.d.ts.map +1 -1
  31. package/lib/index.js +5 -0
  32. package/lib/index.js.map +1 -1
  33. package/lib/interfaces.d.ts +70 -3
  34. package/lib/interfaces.d.ts.map +1 -1
  35. package/lib/interfaces.js.map +1 -1
  36. package/lib/packageVersion.d.ts +1 -1
  37. package/lib/packageVersion.js +1 -1
  38. package/lib/packageVersion.js.map +1 -1
  39. package/package.json +13 -12
  40. package/src/cell.ts +54 -87
  41. package/src/cellFactory.ts +20 -3
  42. package/src/index.ts +6 -0
  43. package/src/interfaces.ts +77 -4
  44. package/src/packageVersion.ts +1 -1
package/src/index.ts CHANGED
@@ -3,5 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ /**
7
+ * The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value that can be edited or deleted.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+
6
12
  export { SharedCell } from "./cell";
7
13
  export { ISharedCell, ISharedCellEvents } from "./interfaces";
package/src/interfaces.ts CHANGED
@@ -6,15 +6,75 @@
6
6
  import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
7
7
  import { Serializable } from "@fluidframework/datastore-definitions";
8
8
 
9
+ /**
10
+ * Events emitted by {@link ISharedCell}.
11
+ */
9
12
  export interface ISharedCellEvents<T> extends ISharedObjectEvents {
13
+ /**
14
+ * Emitted when the value has changed.
15
+ *
16
+ * @remarks Event paramters:
17
+ *
18
+ * - `value`: The new value of the cell.
19
+ */
10
20
  (event: "valueChanged", listener: (value: Serializable<T>) => void);
21
+
22
+ /**
23
+ * Emitted when the value has been deleted.
24
+ */
11
25
  (event: "delete", listener: () => void);
12
26
  }
13
27
 
14
28
  /**
15
- * Shared cell interface
29
+ * A Distributed Data Structure (DDS), which stores a single shared value that can be edited or deleted.
30
+ *
31
+ * @typeParam T - The type of cell data. Must be serializable.
32
+ *
33
+ * @example Creation:
34
+ *
35
+ * To create a `SharedCell`, call the static create method:
36
+ *
37
+ * ```typescript
38
+ * const myCell = SharedCell.create(this.runtime, id);
39
+ * ```
40
+ *
41
+ * @example Usage:
42
+ *
43
+ * The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:
44
+ *
45
+ * ```typescript
46
+ * myCell.set(3);
47
+ * console.log(myCell.get()); // 3
48
+ * ```
49
+ *
50
+ * The value must only be plain JS objects or `SharedObject` handles (e.g. to another DDS or Fluid object).
51
+ * In collaborative scenarios, the value is settled with a policy of _last write wins_.
52
+ *
53
+ * The `.delete()` method will delete the stored value from the cell:
54
+ *
55
+ * ```typescript
56
+ * myCell.delete();
57
+ * console.log(myCell.get()); // undefined
58
+ * ```
59
+ *
60
+ * The `.empty()` method will check if the value is undefined.
61
+ *
62
+ * ```typescript
63
+ * if (myCell.empty()) {
64
+ * // myCell.get() will return undefined
65
+ * } else {
66
+ * // myCell.get() will return a non-undefined value
67
+ * }
68
+ * ```
69
+ *
70
+ * @example Eventing:
71
+ *
72
+ * `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should
73
+ * register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted
74
+ * in response to a `set`, and `delete` will be emitted in response to a `delete`.
16
75
  */
17
-
76
+ // TODO: use `unknown` instead (breaking change).
77
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
78
  export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>> {
19
79
  /**
20
80
  * Retrieves the cell value.
@@ -42,7 +102,20 @@ export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>
42
102
  */
43
103
  delete(): void;
44
104
  }
45
- export interface ICellLocalOpMetadata {
105
+
106
+ /**
107
+ * Describes a local Cell operation (op).
108
+ */
109
+ // TODO: use `unknown` instead.
110
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
+ export interface ICellLocalOpMetadata<T = any> {
112
+ /**
113
+ * Unique identifier for this local operation (op).
114
+ */
46
115
  pendingMessageId: number;
47
- previousValue?: any;
116
+
117
+ /**
118
+ * The value of the {@link ISharedCell} prior to this operation (op).
119
+ */
120
+ previousValue?: Serializable<T> ;
48
121
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/cell";
9
- export const pkgVersion = "2.0.0-internal.2.2.1";
9
+ export const pkgVersion = "2.0.0-internal.2.3.0";