@fluidframework/map 1.2.6 → 2.0.0-dev.1.3.0.96595
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 +4 -1
- package/.mocharc.js +12 -0
- package/dist/directory.d.ts +26 -7
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +10 -25
- package/dist/directory.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +139 -181
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/internalInterfaces.d.ts +62 -0
- package/dist/internalInterfaces.d.ts.map +1 -0
- package/dist/internalInterfaces.js +7 -0
- package/dist/internalInterfaces.js.map +1 -0
- package/dist/localValues.d.ts +3 -3
- package/dist/localValues.js +2 -2
- package/dist/localValues.js.map +1 -1
- package/dist/map.d.ts +3 -5
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +4 -7
- package/dist/map.js.map +1 -1
- package/dist/mapKernel.d.ts +10 -41
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +34 -25
- package/dist/mapKernel.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/directory.d.ts +26 -7
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +10 -25
- package/lib/directory.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +139 -181
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/internalInterfaces.d.ts +62 -0
- package/lib/internalInterfaces.d.ts.map +1 -0
- package/lib/internalInterfaces.js +6 -0
- package/lib/internalInterfaces.js.map +1 -0
- package/lib/localValues.d.ts +3 -3
- package/lib/localValues.js +2 -2
- package/lib/localValues.js.map +1 -1
- package/lib/map.d.ts +3 -5
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +4 -7
- package/lib/map.js.map +1 -1
- package/lib/mapKernel.d.ts +10 -41
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +34 -25
- package/lib/mapKernel.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +61 -21
- package/src/directory.ts +36 -27
- package/src/index.ts +2 -2
- package/src/interfaces.ts +146 -181
- package/src/internalInterfaces.ts +72 -0
- package/src/localValues.ts +3 -3
- package/src/map.ts +8 -11
- package/src/mapKernel.ts +64 -96
- package/src/packageVersion.ts +1 -1
package/src/interfaces.ts
CHANGED
|
@@ -98,94 +98,73 @@ export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryE
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* Events emitted in response to changes to the directory data.
|
|
102
|
-
* and not on subdirectories.
|
|
103
|
-
*
|
|
104
|
-
* @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.
|
|
101
|
+
* Events emitted in response to changes to the directory data.
|
|
102
|
+
* These events only emit on the {@link ISharedDirectory} itself, and not on subdirectories.
|
|
173
103
|
*/
|
|
174
104
|
export interface ISharedDirectoryEvents extends ISharedObjectEvents {
|
|
105
|
+
/**
|
|
106
|
+
* Emitted when a key is set or deleted. This is emitted for any key in the {@link ISharedDirectory} or any
|
|
107
|
+
* subdirectory.
|
|
108
|
+
*
|
|
109
|
+
* @remarks Listener parameters:
|
|
110
|
+
*
|
|
111
|
+
* - `changed` - Information on the key that changed, its value prior to the change, and the path to the
|
|
112
|
+
* key that changed.
|
|
113
|
+
*
|
|
114
|
+
* - `local` - Whether the change originated from this client.
|
|
115
|
+
*
|
|
116
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
117
|
+
*/
|
|
175
118
|
(event: "valueChanged", listener: (
|
|
176
119
|
changed: IDirectoryValueChanged,
|
|
177
120
|
local: boolean,
|
|
178
121
|
target: IEventThisPlaceHolder,
|
|
179
122
|
) => void);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Emitted when the {@link ISharedDirectory} is cleared.
|
|
126
|
+
*
|
|
127
|
+
* @remarks Listener parameters:
|
|
128
|
+
*
|
|
129
|
+
* - `local` - Whether the clear originated from this client.
|
|
130
|
+
*
|
|
131
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
132
|
+
*/
|
|
180
133
|
(event: "clear", listener: (
|
|
181
134
|
local: boolean,
|
|
182
135
|
target: IEventThisPlaceHolder,
|
|
183
136
|
) => void);
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Emitted when a subdirectory is created.
|
|
140
|
+
*
|
|
141
|
+
* @remarks Listener parameters:
|
|
142
|
+
*
|
|
143
|
+
* - `path` - The relative path to the subdirectory that is created.
|
|
144
|
+
* It is relative from the object which raises the event.
|
|
145
|
+
*
|
|
146
|
+
* - `local` - Whether the create originated from the this client.
|
|
147
|
+
*
|
|
148
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
149
|
+
*/
|
|
184
150
|
(event: "subDirectoryCreated", listener: (
|
|
185
151
|
path: string,
|
|
186
152
|
local: boolean,
|
|
187
153
|
target: IEventThisPlaceHolder,
|
|
188
154
|
) => void);
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Emitted when a subdirectory is deleted.
|
|
158
|
+
*
|
|
159
|
+
* @remarks Listener parameters:
|
|
160
|
+
*
|
|
161
|
+
* - `path` - The relative path to the subdirectory that is deleted.
|
|
162
|
+
* It is relative from the object which raises the event.
|
|
163
|
+
*
|
|
164
|
+
* - `local` - Whether the delete originated from the this client.
|
|
165
|
+
*
|
|
166
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
167
|
+
*/
|
|
189
168
|
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
|
190
169
|
(event: "subDirectoryDeleted", listener: (
|
|
191
170
|
path: string,
|
|
@@ -196,95 +175,80 @@ export interface ISharedDirectoryEvents extends ISharedObjectEvents {
|
|
|
196
175
|
|
|
197
176
|
/**
|
|
198
177
|
* 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.
|
|
263
178
|
*/
|
|
264
179
|
export interface IDirectoryEvents extends IEvent {
|
|
180
|
+
/**
|
|
181
|
+
* Emitted when a key is set or deleted. As opposed to the
|
|
182
|
+
* {@link SharedDirectory}'s valueChanged event, this is emitted only on the {@link IDirectory} that directly
|
|
183
|
+
* contains the key.
|
|
184
|
+
*
|
|
185
|
+
* @remarks Listener parameters:
|
|
186
|
+
*
|
|
187
|
+
* - `changed` - Information on the key that changed and its value prior to the change.
|
|
188
|
+
*
|
|
189
|
+
* - `local` - Whether the change originated from this client.
|
|
190
|
+
*
|
|
191
|
+
* - `target` - The {@link IDirectory} itself.
|
|
192
|
+
*/
|
|
265
193
|
(event: "containedValueChanged", listener: (
|
|
266
194
|
changed: IValueChanged,
|
|
267
195
|
local: boolean,
|
|
268
196
|
target: IEventThisPlaceHolder,
|
|
269
197
|
) => void);
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Emitted when a subdirectory is created.
|
|
201
|
+
*
|
|
202
|
+
* @remarks Listener parameters:
|
|
203
|
+
*
|
|
204
|
+
* - `path` - The relative path to the subdirectory that is created.
|
|
205
|
+
* It is relative from the object which raises the event.
|
|
206
|
+
*
|
|
207
|
+
* - `local` - Whether the creation originated from the this client.
|
|
208
|
+
*
|
|
209
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
210
|
+
*/
|
|
270
211
|
(event: "subDirectoryCreated", listener: (
|
|
271
212
|
path: string,
|
|
272
213
|
local: boolean,
|
|
273
214
|
target: IEventThisPlaceHolder,
|
|
274
215
|
) => void);
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Emitted when a subdirectory is deleted.
|
|
219
|
+
*
|
|
220
|
+
* @remarks Listener parameters:
|
|
221
|
+
*
|
|
222
|
+
* - `path` - The relative path to the subdirectory that is deleted.
|
|
223
|
+
* It is relative from the object which raises the event.
|
|
224
|
+
*
|
|
225
|
+
* - `local` - Whether the delete originated from the this client.
|
|
226
|
+
*
|
|
227
|
+
* - `target` - The {@link ISharedDirectory} itself.
|
|
228
|
+
*/
|
|
275
229
|
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
|
276
230
|
(event: "subDirectoryDeleted", listener: (
|
|
277
231
|
path: string,
|
|
278
232
|
local: boolean,
|
|
279
233
|
target: IEventThisPlaceHolder,
|
|
280
234
|
) => void);
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Emitted when this sub directory is deleted.
|
|
238
|
+
*
|
|
239
|
+
* @remarks Listener parameters:
|
|
240
|
+
*
|
|
241
|
+
* - `target` - The {@link IDirectory} itself.
|
|
242
|
+
*/
|
|
281
243
|
(event: "disposed", listener: (
|
|
282
244
|
target: IEventThisPlaceHolder,
|
|
283
245
|
) => void);
|
|
284
246
|
}
|
|
285
247
|
|
|
286
248
|
/**
|
|
287
|
-
*
|
|
249
|
+
* Provides a hierarchical organization of map-like data structures as SubDirectories.
|
|
250
|
+
* The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.
|
|
251
|
+
* SubDirectories can be retrieved for use as working directories.
|
|
288
252
|
*/
|
|
289
253
|
export interface ISharedDirectory extends
|
|
290
254
|
ISharedObject<ISharedDirectoryEvents & IDirectoryEvents>,
|
|
@@ -296,7 +260,7 @@ export interface ISharedDirectory extends
|
|
|
296
260
|
}
|
|
297
261
|
|
|
298
262
|
/**
|
|
299
|
-
* Type of "valueChanged" event parameter for
|
|
263
|
+
* Type of "valueChanged" event parameter for {@link ISharedDirectory}
|
|
300
264
|
*/
|
|
301
265
|
export interface IDirectoryValueChanged extends IValueChanged {
|
|
302
266
|
/**
|
|
@@ -306,60 +270,51 @@ export interface IDirectoryValueChanged extends IValueChanged {
|
|
|
306
270
|
}
|
|
307
271
|
|
|
308
272
|
/**
|
|
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.
|
|
273
|
+
* Events emitted in response to changes to the {@link ISharedMap | map} data.
|
|
346
274
|
*/
|
|
347
275
|
export interface ISharedMapEvents extends ISharedObjectEvents {
|
|
276
|
+
/**
|
|
277
|
+
* Emitted when a key is set or deleted.
|
|
278
|
+
*
|
|
279
|
+
* @remarks Listener parameters:
|
|
280
|
+
*
|
|
281
|
+
* - `changed` - Information on the key that changed and its value prior to the change.
|
|
282
|
+
*
|
|
283
|
+
* - `local` - Whether the change originated from this client.
|
|
284
|
+
*
|
|
285
|
+
* - `target` - The {@link ISharedMap} itself.
|
|
286
|
+
*/
|
|
348
287
|
(event: "valueChanged", listener: (
|
|
349
288
|
changed: IValueChanged,
|
|
350
289
|
local: boolean,
|
|
351
290
|
target: IEventThisPlaceHolder) => void);
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Emitted when the map is cleared.
|
|
294
|
+
*
|
|
295
|
+
* @remarks Listener parameters:
|
|
296
|
+
*
|
|
297
|
+
* - `local` - Whether the clear originated from this client.
|
|
298
|
+
*
|
|
299
|
+
* - `target` - The {@link ISharedMap} itself.
|
|
300
|
+
*/
|
|
352
301
|
(event: "clear", listener: (
|
|
353
302
|
local: boolean,
|
|
354
303
|
target: IEventThisPlaceHolder) => void);
|
|
355
304
|
}
|
|
356
305
|
|
|
357
306
|
/**
|
|
358
|
-
*
|
|
307
|
+
* The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting
|
|
308
|
+
* and retrieving values that JavaScript developers are accustomed to with the
|
|
309
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.
|
|
310
|
+
* However, the keys of a SharedMap must be strings, and the values must either be a JSON-serializable object or a
|
|
311
|
+
* {@link @fluidframework/shared-object-base#SharedObjectHandle}.
|
|
312
|
+
*
|
|
313
|
+
* For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.
|
|
359
314
|
*/
|
|
360
315
|
export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {
|
|
361
316
|
/**
|
|
362
|
-
* Retrieves the given key from the map.
|
|
317
|
+
* Retrieves the given key from the map if it exists.
|
|
363
318
|
* @param key - Key to retrieve from
|
|
364
319
|
* @returns The stored value, or undefined if the key is not set
|
|
365
320
|
*/
|
|
@@ -367,16 +322,17 @@ export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string,
|
|
|
367
322
|
|
|
368
323
|
/**
|
|
369
324
|
* Sets the value stored at key to the provided value.
|
|
370
|
-
* @param key - Key to set
|
|
325
|
+
* @param key - Key to set
|
|
371
326
|
* @param value - Value to set
|
|
372
|
-
* @returns The ISharedMap itself
|
|
327
|
+
* @returns The {@link ISharedMap} itself
|
|
373
328
|
*/
|
|
374
329
|
set<T = any>(key: string, value: T): this;
|
|
375
330
|
}
|
|
376
331
|
|
|
377
332
|
/**
|
|
378
333
|
* 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
|
|
334
|
+
* {@link ISerializableValue."type"} to understand whether they're storing a Plain JavaScript object,
|
|
335
|
+
* a {@link @fluidframework/shared-object-base#SharedObject}, or a value type.
|
|
380
336
|
*
|
|
381
337
|
* @remarks
|
|
382
338
|
*
|
|
@@ -384,13 +340,17 @@ export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string,
|
|
|
384
340
|
* the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to
|
|
385
341
|
* JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)
|
|
386
342
|
* and ops (set).
|
|
343
|
+
*
|
|
387
344
|
* 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
345
|
* just get stringified to a URL string and not rehydrate as a URL object on the other side. It may contain members
|
|
389
346
|
* that are ISerializedHandle (the serialized form of a handle).
|
|
347
|
+
*
|
|
390
348
|
* If type is a value type then it must be amongst the types registered via registerValueType or we won't know how
|
|
391
349
|
* to serialize/deserialize it (we rely on its factory via .load() and .store()). Its value will be type-dependent.
|
|
392
350
|
* 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.
|
|
351
|
+
* channel ID.
|
|
352
|
+
*
|
|
353
|
+
* @deprecated This type is legacy and deprecated.
|
|
394
354
|
*/
|
|
395
355
|
export interface ISerializableValue {
|
|
396
356
|
/**
|
|
@@ -404,6 +364,9 @@ export interface ISerializableValue {
|
|
|
404
364
|
value: any;
|
|
405
365
|
}
|
|
406
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Serialized {@link ISerializableValue} counterpart.
|
|
369
|
+
*/
|
|
407
370
|
export interface ISerializedValue {
|
|
408
371
|
/**
|
|
409
372
|
* A type annotation to help indicate how the value serializes.
|
|
@@ -412,6 +375,8 @@ export interface ISerializedValue {
|
|
|
412
375
|
|
|
413
376
|
/**
|
|
414
377
|
* String representation of the value.
|
|
378
|
+
*
|
|
379
|
+
* @remarks Will be undefined if the original value was undefined.
|
|
415
380
|
*/
|
|
416
381
|
value: string | undefined;
|
|
417
382
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ISerializableValue } from "./interfaces";
|
|
7
|
+
import { ILocalValue } from "./localValues";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Operation indicating a value should be set for a key.
|
|
11
|
+
*/
|
|
12
|
+
export interface IMapSetOperation {
|
|
13
|
+
/**
|
|
14
|
+
* String identifier of the operation type.
|
|
15
|
+
*/
|
|
16
|
+
type: "set";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Map key being modified.
|
|
20
|
+
*/
|
|
21
|
+
key: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Value to be set on the key.
|
|
25
|
+
*/
|
|
26
|
+
value: ISerializableValue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Operation indicating the map should be cleared.
|
|
31
|
+
*/
|
|
32
|
+
export interface IMapClearOperation {
|
|
33
|
+
/**
|
|
34
|
+
* String identifier of the operation type.
|
|
35
|
+
*/
|
|
36
|
+
type: "clear";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Operation indicating a key should be deleted from the map.
|
|
41
|
+
*/
|
|
42
|
+
export interface IMapDeleteOperation {
|
|
43
|
+
/**
|
|
44
|
+
* String identifier of the operation type.
|
|
45
|
+
*/
|
|
46
|
+
type: "delete";
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Map key being modified.
|
|
50
|
+
*/
|
|
51
|
+
key: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface IMapKeyEditLocalOpMetadata {
|
|
55
|
+
type: "edit";
|
|
56
|
+
pendingMessageId: number;
|
|
57
|
+
previousValue: ILocalValue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface IMapKeyAddLocalOpMetadata {
|
|
61
|
+
type: "add";
|
|
62
|
+
pendingMessageId: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface IMapClearLocalOpMetadata {
|
|
66
|
+
type: "clear";
|
|
67
|
+
pendingMessageId: number;
|
|
68
|
+
previousMap?: Map<string, ILocalValue>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type MapKeyLocalOpMetadata = IMapKeyEditLocalOpMetadata | IMapKeyAddLocalOpMetadata;
|
|
72
|
+
export type MapLocalOpMetadata = IMapClearLocalOpMetadata | MapKeyLocalOpMetadata;
|
package/src/localValues.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "./interfaces";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* A local value to be stored in a container type DDS.
|
|
20
|
+
* A local value to be stored in a container type Distributed Data Store (DDS).
|
|
21
21
|
*/
|
|
22
22
|
export interface ILocalValue {
|
|
23
23
|
/**
|
|
@@ -90,8 +90,8 @@ export class PlainLocalValue implements ILocalValue {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
94
|
-
* those objects are stored, serialized, and deserialized.
|
|
93
|
+
* Enables a container type {@link https://fluidframework.com/docs/build/dds/ | DDS} to produce and store local
|
|
94
|
+
* values with minimal awareness of how those objects are stored, serialized, and deserialized.
|
|
95
95
|
*/
|
|
96
96
|
export class LocalValueMaker {
|
|
97
97
|
/**
|
package/src/map.ts
CHANGED
|
@@ -33,7 +33,8 @@ interface IMapSerializationFormat {
|
|
|
33
33
|
const snapshotFileName = "header";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.
|
|
37
|
+
*
|
|
37
38
|
* @sealed
|
|
38
39
|
*/
|
|
39
40
|
export class MapFactory implements IChannelFactory {
|
|
@@ -91,10 +92,7 @@ export class MapFactory implements IChannelFactory {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
/**
|
|
94
|
-
*
|
|
95
|
-
* and retrieving values that JavaScript developers are accustomed to with the
|
|
96
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.
|
|
97
|
-
* However, the keys of a SharedMap must be strings.
|
|
95
|
+
* {@inheritDoc ISharedMap}
|
|
98
96
|
*/
|
|
99
97
|
export class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {
|
|
100
98
|
/**
|
|
@@ -340,7 +338,7 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
|
|
|
340
338
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
341
339
|
* @internal
|
|
342
340
|
*/
|
|
343
|
-
protected onDisconnect() {}
|
|
341
|
+
protected onDisconnect() { }
|
|
344
342
|
|
|
345
343
|
/**
|
|
346
344
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
@@ -355,8 +353,7 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
|
|
|
355
353
|
* @internal
|
|
356
354
|
*/
|
|
357
355
|
protected applyStashedOp(content: any): unknown {
|
|
358
|
-
this.kernel.
|
|
359
|
-
return this.kernel.tryGetStashedOpLocalMetadata(content);
|
|
356
|
+
return this.kernel.tryApplyStashedOp(content);
|
|
360
357
|
}
|
|
361
358
|
|
|
362
359
|
/**
|
|
@@ -373,7 +370,7 @@ export class SharedMap extends SharedObject<ISharedMapEvents> implements IShared
|
|
|
373
370
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
374
371
|
* @internal
|
|
375
372
|
*/
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
373
|
+
protected rollback(content: any, localOpMetadata: unknown) {
|
|
374
|
+
this.kernel.rollback(content, localOpMetadata);
|
|
375
|
+
}
|
|
379
376
|
}
|