@fluidframework/map 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419

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 (118) hide show
  1. package/.eslintrc.js +12 -11
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +162 -0
  4. package/README.md +24 -8
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/map.api.md +297 -0
  8. package/dist/{directory.js → directory.cjs} +749 -228
  9. package/dist/directory.cjs.map +1 -0
  10. package/dist/directory.d.ts +567 -34
  11. package/dist/directory.d.ts.map +1 -1
  12. package/dist/index.cjs +27 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.ts +5 -5
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/{interfaces.js → interfaces.cjs} +1 -1
  17. package/dist/interfaces.cjs.map +1 -0
  18. package/dist/interfaces.d.ts +167 -184
  19. package/dist/interfaces.d.ts.map +1 -1
  20. package/dist/internalInterfaces.cjs +7 -0
  21. package/dist/internalInterfaces.cjs.map +1 -0
  22. package/dist/internalInterfaces.d.ts +101 -0
  23. package/dist/internalInterfaces.d.ts.map +1 -0
  24. package/dist/{localValues.js → localValues.cjs} +15 -3
  25. package/dist/localValues.cjs.map +1 -0
  26. package/dist/localValues.d.ts +17 -6
  27. package/dist/localValues.d.ts.map +1 -1
  28. package/dist/map-alpha.d.ts +982 -0
  29. package/dist/map-beta.d.ts +275 -0
  30. package/dist/map-public.d.ts +275 -0
  31. package/dist/map-untrimmed.d.ts +996 -0
  32. package/dist/{map.js → map.cjs} +39 -34
  33. package/dist/map.cjs.map +1 -0
  34. package/dist/map.d.ts +10 -17
  35. package/dist/map.d.ts.map +1 -1
  36. package/dist/{mapKernel.js → mapKernel.cjs} +122 -79
  37. package/dist/mapKernel.cjs.map +1 -0
  38. package/dist/mapKernel.d.ts +17 -48
  39. package/dist/mapKernel.d.ts.map +1 -1
  40. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  41. package/dist/packageVersion.cjs.map +1 -0
  42. package/dist/packageVersion.d.ts +1 -1
  43. package/dist/packageVersion.d.ts.map +1 -1
  44. package/dist/tsdoc-metadata.json +11 -0
  45. package/lib/directory.d.mts +902 -0
  46. package/lib/directory.d.mts.map +1 -0
  47. package/lib/{directory.js → directory.mjs} +736 -199
  48. package/lib/directory.mjs.map +1 -0
  49. package/lib/index.d.mts +9 -0
  50. package/lib/index.d.mts.map +1 -0
  51. package/lib/index.mjs +8 -0
  52. package/lib/index.mjs.map +1 -0
  53. package/lib/{interfaces.d.ts → interfaces.d.mts} +167 -184
  54. package/lib/interfaces.d.mts.map +1 -0
  55. package/lib/{interfaces.js → interfaces.mjs} +1 -1
  56. package/lib/interfaces.mjs.map +1 -0
  57. package/lib/internalInterfaces.d.mts +101 -0
  58. package/lib/internalInterfaces.d.mts.map +1 -0
  59. package/lib/internalInterfaces.mjs +6 -0
  60. package/lib/internalInterfaces.mjs.map +1 -0
  61. package/lib/{localValues.d.ts → localValues.d.mts} +18 -7
  62. package/lib/localValues.d.mts.map +1 -0
  63. package/lib/{localValues.js → localValues.mjs} +15 -3
  64. package/lib/localValues.mjs.map +1 -0
  65. package/lib/map-alpha.d.mts +982 -0
  66. package/lib/map-beta.d.mts +275 -0
  67. package/lib/map-public.d.mts +275 -0
  68. package/lib/map-untrimmed.d.mts +996 -0
  69. package/lib/{map.d.ts → map.d.mts} +11 -18
  70. package/lib/map.d.mts.map +1 -0
  71. package/lib/{map.js → map.mjs} +40 -35
  72. package/lib/map.mjs.map +1 -0
  73. package/lib/{mapKernel.d.ts → mapKernel.d.mts} +18 -49
  74. package/lib/mapKernel.d.mts.map +1 -0
  75. package/lib/{mapKernel.js → mapKernel.mjs} +116 -73
  76. package/lib/mapKernel.mjs.map +1 -0
  77. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
  78. package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
  79. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  80. package/lib/packageVersion.mjs.map +1 -0
  81. package/map.test-files.tar +0 -0
  82. package/package.json +105 -65
  83. package/prettier.config.cjs +8 -0
  84. package/src/directory.ts +2544 -1727
  85. package/src/index.ts +31 -5
  86. package/src/interfaces.ts +346 -345
  87. package/src/internalInterfaces.ts +119 -0
  88. package/src/localValues.ts +103 -96
  89. package/src/map.ts +362 -351
  90. package/src/mapKernel.ts +755 -722
  91. package/src/packageVersion.ts +1 -1
  92. package/tsc-multi.test.json +4 -0
  93. package/tsconfig.json +10 -15
  94. package/dist/directory.js.map +0 -1
  95. package/dist/index.js +0 -34
  96. package/dist/index.js.map +0 -1
  97. package/dist/interfaces.js.map +0 -1
  98. package/dist/localValues.js.map +0 -1
  99. package/dist/map.js.map +0 -1
  100. package/dist/mapKernel.js.map +0 -1
  101. package/dist/packageVersion.js.map +0 -1
  102. package/lib/directory.d.ts +0 -369
  103. package/lib/directory.d.ts.map +0 -1
  104. package/lib/directory.js.map +0 -1
  105. package/lib/index.d.ts +0 -20
  106. package/lib/index.d.ts.map +0 -1
  107. package/lib/index.js +0 -20
  108. package/lib/index.js.map +0 -1
  109. package/lib/interfaces.d.ts.map +0 -1
  110. package/lib/interfaces.js.map +0 -1
  111. package/lib/localValues.d.ts.map +0 -1
  112. package/lib/localValues.js.map +0 -1
  113. package/lib/map.d.ts.map +0 -1
  114. package/lib/map.js.map +0 -1
  115. package/lib/mapKernel.d.ts.map +0 -1
  116. package/lib/mapKernel.js.map +0 -1
  117. package/lib/packageVersion.js.map +0 -1
  118. package/tsconfig.esnext.json +0 -7
package/src/interfaces.ts CHANGED
@@ -4,379 +4,368 @@
4
4
  */
5
5
 
6
6
  import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
7
- import { IDisposable, IEvent, IEventProvider, IEventThisPlaceHolder } from "@fluidframework/common-definitions";
7
+ import {
8
+ IDisposable,
9
+ IEvent,
10
+ IEventProvider,
11
+ IEventThisPlaceHolder,
12
+ } from "@fluidframework/core-interfaces";
8
13
 
9
14
  /**
10
15
  * Type of "valueChanged" event parameter.
16
+ * @sealed
17
+ * @public
11
18
  */
12
19
  export interface IValueChanged {
13
- /**
14
- * The key storing the value that changed.
15
- */
16
- key: string;
17
-
18
- /**
19
- * The value that was stored at the key prior to the change.
20
- */
21
- previousValue: any;
20
+ /**
21
+ * The key storing the value that changed.
22
+ */
23
+ key: string;
24
+
25
+ /**
26
+ * The value that was stored at the key prior to the change.
27
+ */
28
+ // TODO: Use `unknown` instead (breaking change).
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ previousValue: any;
22
31
  }
23
32
 
24
33
  /**
25
34
  * Interface describing actions on a directory.
26
35
  *
27
- * @remarks
28
- * When used as a Map, operates on its keys.
36
+ * @remarks When used as a Map, operates on its keys.
37
+ * @alpha
29
38
  */
30
- export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryEvents>, Partial<IDisposable> {
31
- /**
32
- * The absolute path of the directory.
33
- */
34
- readonly absolutePath: string;
35
-
36
- /**
37
- * Retrieves the value stored at the given key from the directory.
38
- * @param key - Key to retrieve from
39
- * @returns The stored value, or undefined if the key is not set
40
- */
41
- get<T = any>(key: string): T | undefined;
42
-
43
- /**
44
- * Sets the value stored at key to the provided value.
45
- * @param key - Key to set at
46
- * @param value - Value to set
47
- * @returns The IDirectory itself
48
- */
49
- set<T = any>(key: string, value: T): this;
50
-
51
- /**
52
- * Get the number of sub directory within the directory.
53
- * @returns The number of sub directory within a directory.
54
- */
55
- countSubDirectory?(): number;
56
-
57
- /**
58
- * Creates an IDirectory child of this IDirectory, or retrieves the existing IDirectory child if one with the
59
- * same name already exists.
60
- * @param subdirName - Name of the new child directory to create
61
- * @returns The IDirectory child that was created or retrieved
62
- */
63
- createSubDirectory(subdirName: string): IDirectory;
64
-
65
- /**
66
- * Gets an IDirectory child of this IDirectory, if it exists.
67
- * @param subdirName - Name of the child directory to get
68
- * @returns The requested IDirectory
69
- */
70
- getSubDirectory(subdirName: string): IDirectory | undefined;
71
-
72
- /**
73
- * Checks whether this directory has a child directory with the given name.
74
- * @param subdirName - Name of the child directory to check
75
- * @returns True if it exists, false otherwise
76
- */
77
- hasSubDirectory(subdirName: string): boolean;
78
-
79
- /**
80
- * Deletes an IDirectory child of this IDirectory, if it exists, along with all descendent keys and directories.
81
- * @param subdirName - Name of the child directory to delete
82
- * @returns True if the IDirectory existed and was deleted, false if it did not exist
83
- */
84
- deleteSubDirectory(subdirName: string): boolean;
85
-
86
- /**
87
- * Gets an iterator over the IDirectory children of this IDirectory.
88
- * @returns The IDirectory iterator
89
- */
90
- subdirectories(): IterableIterator<[string, IDirectory]>;
91
-
92
- /**
93
- * Get an IDirectory within the directory, in order to use relative paths from that location.
94
- * @param relativePath - Path of the IDirectory to get, relative to this IDirectory
95
- * @returns The requested IDirectory
96
- */
97
- getWorkingDirectory(relativePath: string): IDirectory | undefined;
39
+ // TODO: Use `unknown` instead (breaking change).
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ export interface IDirectory
42
+ extends Map<string, any>,
43
+ IEventProvider<IDirectoryEvents>,
44
+ Partial<IDisposable> {
45
+ /**
46
+ * The absolute path of the directory.
47
+ */
48
+ readonly absolutePath: string;
49
+
50
+ /**
51
+ * Retrieves the value stored at the given key from the directory.
52
+ * @param key - Key to retrieve from
53
+ * @returns The stored value, or undefined if the key is not set
54
+ */
55
+ // TODO: Use `unknown` instead (breaking change).
56
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
+ get<T = any>(key: string): T | undefined;
58
+
59
+ /**
60
+ * Sets the value stored at key to the provided value.
61
+ * @param key - Key to set at
62
+ * @param value - Value to set
63
+ * @returns The IDirectory itself
64
+ */
65
+ set<T = unknown>(key: string, value: T): this;
66
+
67
+ /**
68
+ * Get the number of sub directory within the directory.
69
+ * @returns The number of sub directory within a directory.
70
+ */
71
+ countSubDirectory?(): number;
72
+
73
+ /**
74
+ * Creates an IDirectory child of this IDirectory, or retrieves the existing IDirectory child if one with the
75
+ * same name already exists.
76
+ * @param subdirName - Name of the new child directory to create
77
+ * @returns The IDirectory child that was created or retrieved
78
+ */
79
+ createSubDirectory(subdirName: string): IDirectory;
80
+
81
+ /**
82
+ * Gets an IDirectory child of this IDirectory, if it exists.
83
+ * @param subdirName - Name of the child directory to get
84
+ * @returns The requested IDirectory
85
+ */
86
+ getSubDirectory(subdirName: string): IDirectory | undefined;
87
+
88
+ /**
89
+ * Checks whether this directory has a child directory with the given name.
90
+ * @param subdirName - Name of the child directory to check
91
+ * @returns True if it exists, false otherwise
92
+ */
93
+ hasSubDirectory(subdirName: string): boolean;
94
+
95
+ /**
96
+ * Deletes an IDirectory child of this IDirectory, if it exists, along with all descendent keys and directories.
97
+ * @param subdirName - Name of the child directory to delete
98
+ * @returns True if the IDirectory existed and was deleted, false if it did not exist
99
+ */
100
+ deleteSubDirectory(subdirName: string): boolean;
101
+
102
+ /**
103
+ * Gets an iterator over the IDirectory children of this IDirectory.
104
+ * @returns The IDirectory iterator
105
+ */
106
+ subdirectories(): IterableIterator<[string, IDirectory]>;
107
+
108
+ /**
109
+ * Get an IDirectory within the directory, in order to use relative paths from that location.
110
+ * @param relativePath - Path of the IDirectory to get, relative to this IDirectory
111
+ * @returns The requested IDirectory
112
+ */
113
+ getWorkingDirectory(relativePath: string): IDirectory | undefined;
98
114
  }
99
115
 
100
116
  /**
101
- * Events emitted in response to changes to the directory data. These events only emit on the ISharedDirectory itself,
102
- * and not on subdirectories.
117
+ * Events emitted in response to changes to the directory data.
103
118
  *
104
119
  * @remarks
105
- *
106
- * The following is the list of events emitted.
107
- *
108
- * ### "valueChanged"
109
- *
110
- * The valueChanged event is emitted when a key is set or deleted. This is emitted for any key in the ISharedDirectory
111
- * or any subdirectory.
112
- *
113
- * #### Listener signature
114
- *
115
- * ```typescript
116
- * (
117
- * changed: IDirectoryValueChanged,
118
- * local: boolean,
119
- * target: IEventThisPlaceHolder,
120
- * ) => void
121
- * ```
122
- * - `changed` - Information on the key that changed, its value prior to the change, and the path to the key that
123
- * changed.
124
- *
125
- * - `local` - Whether the change originated from this client.
126
- *
127
- * - `target` - The ISharedDirectory itself.
128
- *
129
- * ### "clear"
130
- *
131
- * The clear event is emitted when the ISharedDirectory is cleared.
132
- *
133
- * #### Listener signature
134
- *
135
- * ```typescript
136
- * (local: boolean, target: IEventThisPlaceHolder) => void
137
- * ```
138
- * - `local` - Whether the clear originated from this client.
139
- *
140
- * - `target` - The ISharedDirectory itself.
141
- *
142
- * ### "subDirectoryCreated"
143
- *
144
- * The subDirectoryCreated event is emitted when a subdirectory is created.
145
- *
146
- * #### Listener signature
147
- *
148
- * ```typescript
149
- * (path: string, local: boolean, target: IEventThisPlaceHolder) => void
150
- * ```
151
- * - `path` - The relative path to the subdirectory that is created.
152
- * It is relative from the object which raises the event.
153
- *
154
- * - `local` - Whether the create originated from the this client.
155
- *
156
- * - `target` - The ISharedDirectory itself.
157
- *
158
- * ###"subDirectoryDeleted"
159
- *
160
- * The subDirectoryDeleted event is emitted when a subdirectory is deleted.
161
- *
162
- * #### Listener signature
163
- *
164
- * ```typescript
165
- * (path: string, local: boolean, target: IEventThisPlaceHolder) => void
166
- * ```
167
- * - `path` - The relative path to the subdirectory that is deleted.
168
- * It is relative from the object which raises the event.
169
- *
170
- * - `local` - Whether the delete originated from the this client.
171
- *
172
- * - `target` - The ISharedDirectory itself.
120
+ * These events only emit on the {@link ISharedDirectory} itself, and not on subdirectories.
121
+ * @alpha
173
122
  */
174
123
  export interface ISharedDirectoryEvents extends ISharedObjectEvents {
175
- (event: "valueChanged", listener: (
176
- changed: IDirectoryValueChanged,
177
- local: boolean,
178
- target: IEventThisPlaceHolder,
179
- ) => void);
180
- (event: "clear", listener: (
181
- local: boolean,
182
- target: IEventThisPlaceHolder,
183
- ) => void);
184
- (event: "subDirectoryCreated", listener: (
185
- path: string,
186
- local: boolean,
187
- target: IEventThisPlaceHolder,
188
- ) => void);
189
- // eslint-disable-next-line @typescript-eslint/unified-signatures
190
- (event: "subDirectoryDeleted", listener: (
191
- path: string,
192
- local: boolean,
193
- target: IEventThisPlaceHolder,
194
- ) => void);
124
+ /**
125
+ * Emitted when a key is set or deleted. This is emitted for any key in the {@link ISharedDirectory} or any
126
+ * subdirectory.
127
+ *
128
+ * @remarks Listener parameters:
129
+ *
130
+ * - `changed` - Information on the key that changed, its value prior to the change, and the path to the
131
+ * key that changed.
132
+ *
133
+ * - `local` - Whether the change originated from this client.
134
+ *
135
+ * - `target` - The {@link ISharedDirectory} itself.
136
+ */
137
+ (
138
+ event: "valueChanged",
139
+ listener: (
140
+ changed: IDirectoryValueChanged,
141
+ local: boolean,
142
+ target: IEventThisPlaceHolder,
143
+ ) => void,
144
+ );
145
+
146
+ /**
147
+ * Emitted when the {@link ISharedDirectory} is cleared.
148
+ *
149
+ * @remarks Listener parameters:
150
+ *
151
+ * - `local` - Whether the clear originated from this client.
152
+ *
153
+ * - `target` - The {@link ISharedDirectory} itself.
154
+ */
155
+ (event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void);
156
+
157
+ /**
158
+ * Emitted when a subdirectory is created.
159
+ *
160
+ * @remarks Listener parameters:
161
+ *
162
+ * - `path` - The relative path to the subdirectory that is created.
163
+ * It is relative from the object which raises the event.
164
+ *
165
+ * - `local` - Whether the create originated from the this client.
166
+ *
167
+ * - `target` - The {@link ISharedDirectory} itself.
168
+ */
169
+ (
170
+ event: "subDirectoryCreated",
171
+ listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void,
172
+ );
173
+
174
+ /**
175
+ * Emitted when a subdirectory is deleted.
176
+ *
177
+ * @remarks Listener parameters:
178
+ *
179
+ * - `path` - The relative path to the subdirectory that is deleted.
180
+ * It is relative from the object which raises the event.
181
+ *
182
+ * - `local` - Whether the delete originated from the this client.
183
+ *
184
+ * - `target` - The {@link ISharedDirectory} itself.
185
+ */
186
+ (
187
+ event: "subDirectoryDeleted",
188
+ listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void,
189
+ );
195
190
  }
196
191
 
197
192
  /**
198
193
  * Events emitted in response to changes to the directory data.
199
- *
200
- * @remarks
201
- *
202
- * The following is the list of events emitted.
203
- *
204
- * ### "containedValueChanged"
205
- *
206
- * The containedValueChanged event is emitted when a key is set or deleted. As opposed to the SharedDirectory's
207
- * valueChanged event, this is emitted only on the IDirectory that directly contains the key.
208
- *
209
- * #### Listener signature
210
- *
211
- * ```typescript
212
- * (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void
213
- * ```
214
- * - `changed` - Information on the key that changed and its value prior to the change.
215
- *
216
- * - `local` - Whether the change originated from this client.
217
- *
218
- * - `target` - The IDirectory itself.
219
- *
220
- * ### "subDirectoryCreated"
221
- *
222
- * The subDirectoryCreated event is emitted when a subdirectory is created.
223
- *
224
- * #### Listener signature
225
- *
226
- * ```typescript
227
- * (path: string, local: boolean, target: IEventThisPlaceHolder) => void
228
- * ```
229
- * - `path` - The relative path to the subdirectory that is created.
230
- * It is relative from the object which raises the event.
231
- *
232
- * - `local` - Whether the creation originated from the this client.
233
- *
234
- * - `target` - The ISharedDirectory itself.
235
- *
236
- * ### "subDirectoryDeleted"
237
- *
238
- * The subDirectoryDeleted event is emitted when a subdirectory is deleted.
239
- *
240
- * #### Listener signature
241
- *
242
- * ```typescript
243
- * (path: string, local: boolean, target: IEventThisPlaceHolder) => void
244
- * ```
245
- * - `path` - The relative path to the subdirectory that is deleted.
246
- * It is relative from the object which raises the event.
247
- *
248
- * - `local` - Whether the delete originated from the this client.
249
- *
250
- * - `target` - The ISharedDirectory itself.
251
- *
252
- * ### "disposed"
253
- *
254
- * The dispose event is emitted when this sub directory is deleted.
255
- *
256
- * #### Listener signature
257
- *
258
- * ```typescript
259
- * (local: boolean, target: IEventThisPlaceHolder) => void
260
- * ```
261
- *
262
- * - `target` - The IDirectory itself.
194
+ * @alpha
263
195
  */
264
196
  export interface IDirectoryEvents extends IEvent {
265
- (event: "containedValueChanged", listener: (
266
- changed: IValueChanged,
267
- local: boolean,
268
- target: IEventThisPlaceHolder,
269
- ) => void);
270
- (event: "subDirectoryCreated", listener: (
271
- path: string,
272
- local: boolean,
273
- target: IEventThisPlaceHolder,
274
- ) => void);
275
- // eslint-disable-next-line @typescript-eslint/unified-signatures
276
- (event: "subDirectoryDeleted", listener: (
277
- path: string,
278
- local: boolean,
279
- target: IEventThisPlaceHolder,
280
- ) => void);
281
- (event: "disposed", listener: (
282
- target: IEventThisPlaceHolder,
283
- ) => void);
197
+ /**
198
+ * Emitted when a key is set or deleted. As opposed to the
199
+ * {@link SharedDirectory}'s valueChanged event, this is emitted only on the {@link IDirectory} that directly
200
+ * contains the key.
201
+ *
202
+ * @remarks Listener parameters:
203
+ *
204
+ * - `changed` - Information on the key that changed and its value prior to the change.
205
+ *
206
+ * - `local` - Whether the change originated from this client.
207
+ *
208
+ * - `target` - The {@link IDirectory} itself.
209
+ */
210
+ (
211
+ event: "containedValueChanged",
212
+ listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void,
213
+ );
214
+
215
+ /**
216
+ * Emitted when a subdirectory is created. Also emitted when a delete
217
+ * of a subdirectory is rolled back.
218
+ *
219
+ * @remarks Listener parameters:
220
+ *
221
+ * - `path` - The relative path to the subdirectory that is created.
222
+ * It is relative from the object which raises the event.
223
+ *
224
+ * - `local` - Whether the creation originated from the this client.
225
+ *
226
+ * - `target` - The {@link ISharedDirectory} itself.
227
+ */
228
+ (
229
+ event: "subDirectoryCreated",
230
+ listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void,
231
+ );
232
+
233
+ /**
234
+ * Emitted when a subdirectory is deleted.
235
+ *
236
+ * @remarks Listener parameters:
237
+ *
238
+ * - `path` - The relative path to the subdirectory that is deleted.
239
+ * It is relative from the object which raises the event.
240
+ *
241
+ * - `local` - Whether the delete originated from the this client.
242
+ *
243
+ * - `target` - The {@link ISharedDirectory} itself.
244
+ */
245
+ (
246
+ event: "subDirectoryDeleted",
247
+ listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void,
248
+ );
249
+
250
+ /**
251
+ * Emitted when this sub directory is deleted.
252
+ *
253
+ * @remarks Listener parameters:
254
+ *
255
+ * - `target` - The {@link IDirectory} itself.
256
+ */
257
+ (event: "disposed", listener: (target: IEventThisPlaceHolder) => void);
258
+
259
+ /**
260
+ * Emitted when this previously deleted sub directory is restored.
261
+ * This event only needs to be handled in the case of rollback. If your application does
262
+ * not use the local rollback feature, you can ignore this event.
263
+ *
264
+ * @remarks Listener parameters:
265
+ *
266
+ * - `target` - The {@link IDirectory} itself.
267
+ */
268
+ (event: "undisposed", listener: (target: IEventThisPlaceHolder) => void);
284
269
  }
285
270
 
286
271
  /**
287
- * Interface describing a shared directory.
272
+ * Provides a hierarchical organization of map-like data structures as SubDirectories.
273
+ * The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.
274
+ * SubDirectories can be retrieved for use as working directories.
275
+ * @alpha
288
276
  */
289
- export interface ISharedDirectory extends
290
- ISharedObject<ISharedDirectoryEvents & IDirectoryEvents>,
291
- Omit<IDirectory, "on" | "once" | "off"> {
292
- // The Omit type excludes symbols, which we don't want to exclude. Adding them back here manually.
293
- // https://github.com/microsoft/TypeScript/issues/31671
294
- [Symbol.iterator](): IterableIterator<[string, any]>;
295
- readonly [Symbol.toStringTag]: string;
277
+ export interface ISharedDirectory
278
+ extends ISharedObject<ISharedDirectoryEvents & IDirectoryEvents>,
279
+ Omit<IDirectory, "on" | "once" | "off"> {
280
+ // The Omit type excludes symbols, which we don't want to exclude. Adding them back here manually.
281
+ // https://github.com/microsoft/TypeScript/issues/31671
282
+ // TODO: Use `unknown` instead (breaking change).
283
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
284
+ [Symbol.iterator](): IterableIterator<[string, any]>;
285
+ readonly [Symbol.toStringTag]: string;
296
286
  }
297
287
 
298
288
  /**
299
- * Type of "valueChanged" event parameter for SharedDirectory.
289
+ * Type of "valueChanged" event parameter for {@link ISharedDirectory}.
290
+ * @alpha
300
291
  */
301
292
  export interface IDirectoryValueChanged extends IValueChanged {
302
- /**
303
- * The absolute path to the IDirectory storing the key which changed.
304
- */
305
- path: string;
293
+ /**
294
+ * The absolute path to the IDirectory storing the key which changed.
295
+ */
296
+ path: string;
306
297
  }
307
298
 
308
299
  /**
309
- * Events emitted in response to changes to the map data.
310
- *
311
- * @remarks
312
- *
313
- * The following is the list of events emitted.
314
- *
315
- * ### "valueChanged"
316
- *
317
- * The valueChanged event is emitted when a key is set or deleted.
318
- *
319
- * #### Listener signature
320
- *
321
- * ```typescript
322
- * (
323
- * changed: IValueChanged,
324
- * local: boolean,
325
- * target: IEventThisPlaceHolder,
326
- * ) => void
327
- * ```
328
- * - `changed` - Information on the key that changed and its value prior to the change.
329
- *
330
- * - `local` - Whether the change originated from this client.
331
- *
332
- * - `target` - The map itself.
333
- *
334
- * ### "clear"
335
- *
336
- * The clear event is emitted when the map is cleared.
337
- *
338
- * #### Listener signature
339
- *
340
- * ```typescript
341
- * (local: boolean, target: IEventThisPlaceHolder) => void
342
- * ```
343
- * - `local` - Whether the clear originated from this client.
344
- *
345
- * - `target` - The map itself.
300
+ * Events emitted in response to changes to the {@link ISharedMap | map} data.
301
+ * @sealed
302
+ * @public
346
303
  */
347
304
  export interface ISharedMapEvents extends ISharedObjectEvents {
348
- (event: "valueChanged", listener: (
349
- changed: IValueChanged,
350
- local: boolean,
351
- target: IEventThisPlaceHolder) => void);
352
- (event: "clear", listener: (
353
- local: boolean,
354
- target: IEventThisPlaceHolder) => void);
305
+ /**
306
+ * Emitted when a key is set or deleted.
307
+ *
308
+ * @remarks Listener parameters:
309
+ *
310
+ * - `changed` - Information on the key that changed and its value prior to the change.
311
+ *
312
+ * - `local` - Whether the change originated from this client.
313
+ *
314
+ * - `target` - The {@link ISharedMap} itself.
315
+ */
316
+ (
317
+ event: "valueChanged",
318
+ listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void,
319
+ );
320
+
321
+ /**
322
+ * Emitted when the map is cleared.
323
+ *
324
+ * @remarks Listener parameters:
325
+ *
326
+ * - `local` - Whether the clear originated from this client.
327
+ *
328
+ * - `target` - The {@link ISharedMap} itself.
329
+ */
330
+ (event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void);
355
331
  }
356
332
 
357
333
  /**
358
- * Shared map interface
334
+ * The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting
335
+ * and retrieving values that JavaScript developers are accustomed to with the
336
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.
337
+ * However, the keys of a SharedMap must be strings, and the values must either be a JSON-serializable object or a
338
+ * {@link @fluidframework/datastore#FluidObjectHandle}.
339
+ *
340
+ * For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.
341
+ * @sealed
342
+ * @public
359
343
  */
344
+ // TODO: Use `unknown` instead (breaking change).
345
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
360
346
  export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {
361
- /**
362
- * Retrieves the given key from the map.
363
- * @param key - Key to retrieve from
364
- * @returns The stored value, or undefined if the key is not set
365
- */
366
- get<T = any>(key: string): T | undefined;
367
-
368
- /**
369
- * Sets the value stored at key to the provided value.
370
- * @param key - Key to set at
371
- * @param value - Value to set
372
- * @returns The ISharedMap itself
373
- */
374
- set<T = any>(key: string, value: T): this;
347
+ /**
348
+ * Retrieves the given key from the map if it exists.
349
+ * @param key - Key to retrieve from
350
+ * @returns The stored value, or undefined if the key is not set
351
+ */
352
+ // TODO: Use `unknown` instead (breaking change).
353
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
354
+ get<T = any>(key: string): T | undefined;
355
+
356
+ /**
357
+ * Sets the value stored at key to the provided value.
358
+ * @param key - Key to set
359
+ * @param value - Value to set
360
+ * @returns The {@link ISharedMap} itself
361
+ */
362
+ set<T = unknown>(key: string, value: T): this;
375
363
  }
376
364
 
377
365
  /**
378
366
  * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use
379
- * ISerializableValue.type to understand whether they're storing a Plain JS object, a SharedObject, or a value type.
367
+ * {@link ISerializableValue."type"} to understand whether they're storing a Plain JavaScript object,
368
+ * a {@link @fluidframework/shared-object-base#SharedObject}, or a value type.
380
369
  *
381
370
  * @remarks
382
371
  *
@@ -384,34 +373,46 @@ export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string,
384
373
  * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to
385
374
  * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)
386
375
  * and ops (set).
376
+ *
387
377
  * If type is Plain, it must be a plain JS object that can survive a JSON.stringify/parse. E.g. a URL object will
388
378
  * just get stringified to a URL string and not rehydrate as a URL object on the other side. It may contain members
389
379
  * that are ISerializedHandle (the serialized form of a handle).
380
+ *
390
381
  * If type is a value type then it must be amongst the types registered via registerValueType or we won't know how
391
382
  * to serialize/deserialize it (we rely on its factory via .load() and .store()). Its value will be type-dependent.
392
383
  * If type is Shared, then the in-memory value will just be a reference to the SharedObject. Its value will be a
393
- * channel ID. This type is legacy and deprecated.
384
+ * channel ID.
385
+ *
386
+ * @deprecated This type is legacy and deprecated.
387
+ * @alpha
394
388
  */
395
389
  export interface ISerializableValue {
396
- /**
397
- * A type annotation to help indicate how the value serializes.
398
- */
399
- type: string;
400
-
401
- /**
402
- * The JSONable representation of the value.
403
- */
404
- value: any;
390
+ /**
391
+ * A type annotation to help indicate how the value serializes.
392
+ */
393
+ type: string;
394
+
395
+ /**
396
+ * The JSONable representation of the value.
397
+ */
398
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
399
+ value: any;
405
400
  }
406
401
 
402
+ /**
403
+ * Serialized {@link ISerializableValue} counterpart.
404
+ * @alpha
405
+ */
407
406
  export interface ISerializedValue {
408
- /**
409
- * A type annotation to help indicate how the value serializes.
410
- */
411
- type: string;
412
-
413
- /**
414
- * String representation of the value.
415
- */
416
- value: string | undefined;
407
+ /**
408
+ * A type annotation to help indicate how the value serializes.
409
+ */
410
+ type: string;
411
+
412
+ /**
413
+ * String representation of the value.
414
+ *
415
+ * @remarks Will be undefined if the original value was undefined.
416
+ */
417
+ value: string | undefined;
417
418
  }