@fluidframework/map 1.2.2 → 2.0.0-internal.1.0.0.82159
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/dist/directory.d.ts +26 -7
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +4 -11
- package/dist/directory.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/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 +9 -2
- package/dist/mapKernel.d.ts.map +1 -1
- package/dist/mapKernel.js +28 -13
- 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 +4 -11
- package/lib/directory.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/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 +9 -2
- package/lib/mapKernel.d.ts.map +1 -1
- package/lib/mapKernel.js +28 -13
- 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 +53 -16
- package/src/directory.ts +30 -15
- package/src/interfaces.ts +146 -181
- package/src/localValues.ts +3 -3
- package/src/map.ts +8 -11
- package/src/mapKernel.ts +42 -16
- package/src/packageVersion.ts +1 -1
package/src/directory.ts
CHANGED
|
@@ -192,24 +192,47 @@ export type IDirectoryOperation = IDirectoryStorageOperation | IDirectorySubDire
|
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
* Defines the in-memory object structure to be used for the conversion to/from serialized.
|
|
195
|
-
*
|
|
196
|
-
* Directly used in
|
|
195
|
+
*
|
|
196
|
+
* @remarks Directly used in
|
|
197
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
|
|
198
|
+
* | JSON.stringify}, direct result from
|
|
199
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.
|
|
197
200
|
*/
|
|
198
201
|
export interface IDirectoryDataObject {
|
|
202
|
+
/**
|
|
203
|
+
* Key/value date set by the user.
|
|
204
|
+
*/
|
|
199
205
|
storage?: { [key: string]: ISerializableValue; };
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Recursive sub-directories {@link IDirectoryDataObject | objects}.
|
|
209
|
+
*/
|
|
200
210
|
subdirectories?: { [subdirName: string]: IDirectoryDataObject; };
|
|
201
211
|
}
|
|
202
212
|
|
|
213
|
+
/**
|
|
214
|
+
* {@link IDirectory} storage format.
|
|
215
|
+
*
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
203
218
|
export interface IDirectoryNewStorageFormat {
|
|
219
|
+
/**
|
|
220
|
+
* Blob IDs representing larger directory data that was serialized.
|
|
221
|
+
*/
|
|
204
222
|
blobs: string[];
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Storage content representing directory data that was not serialized.
|
|
226
|
+
*/
|
|
205
227
|
content: IDirectoryDataObject;
|
|
206
228
|
}
|
|
207
229
|
|
|
208
230
|
/**
|
|
209
|
-
*
|
|
231
|
+
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedDirectory}.
|
|
232
|
+
*
|
|
210
233
|
* @sealed
|
|
211
234
|
*/
|
|
212
|
-
export class DirectoryFactory {
|
|
235
|
+
export class DirectoryFactory implements IChannelFactory {
|
|
213
236
|
/**
|
|
214
237
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
215
238
|
*/
|
|
@@ -264,9 +287,7 @@ export class DirectoryFactory {
|
|
|
264
287
|
}
|
|
265
288
|
|
|
266
289
|
/**
|
|
267
|
-
*
|
|
268
|
-
* The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.
|
|
269
|
-
* SubDirectories can be retrieved for use as working directories.
|
|
290
|
+
* {@inheritDoc ISharedDirectory}
|
|
270
291
|
*
|
|
271
292
|
* @example
|
|
272
293
|
* ```typescript
|
|
@@ -544,7 +565,7 @@ export class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implem
|
|
|
544
565
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
545
566
|
* @internal
|
|
546
567
|
*/
|
|
547
|
-
protected onDisconnect() {}
|
|
568
|
+
protected onDisconnect() { }
|
|
548
569
|
|
|
549
570
|
/**
|
|
550
571
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
@@ -1263,7 +1284,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1263
1284
|
* Process a clear operation.
|
|
1264
1285
|
* @param op - The op to process
|
|
1265
1286
|
* @param local - Whether the message originated from the local client
|
|
1266
|
-
* @param message - The message
|
|
1267
1287
|
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
1268
1288
|
* For messages from a remote client, this will be undefined.
|
|
1269
1289
|
* @internal
|
|
@@ -1276,7 +1296,7 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1276
1296
|
this.throwIfDisposed();
|
|
1277
1297
|
if (local) {
|
|
1278
1298
|
assert(isClearLocalOpMetadata(localOpMetadata),
|
|
1279
|
-
0x00f /*
|
|
1299
|
+
0x00f /* pendingMessageId is missing from the local client's operation */);
|
|
1280
1300
|
const pendingClearMessageId = this.pendingClearMessageIds.shift();
|
|
1281
1301
|
assert(pendingClearMessageId === localOpMetadata.pendingMessageId,
|
|
1282
1302
|
0x32a /* pendingMessageId does not match */);
|
|
@@ -1289,7 +1309,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1289
1309
|
* Process a delete operation.
|
|
1290
1310
|
* @param op - The op to process
|
|
1291
1311
|
* @param local - Whether the message originated from the local client
|
|
1292
|
-
* @param message - The message
|
|
1293
1312
|
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
1294
1313
|
* For messages from a remote client, this will be undefined.
|
|
1295
1314
|
* @internal
|
|
@@ -1310,7 +1329,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1310
1329
|
* Process a set operation.
|
|
1311
1330
|
* @param op - The op to process
|
|
1312
1331
|
* @param local - Whether the message originated from the local client
|
|
1313
|
-
* @param message - The message
|
|
1314
1332
|
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
1315
1333
|
* For messages from a remote client, this will be undefined.
|
|
1316
1334
|
* @internal
|
|
@@ -1337,7 +1355,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1337
1355
|
* Process a create subdirectory operation.
|
|
1338
1356
|
* @param op - The op to process
|
|
1339
1357
|
* @param local - Whether the message originated from the local client
|
|
1340
|
-
* @param message - The message
|
|
1341
1358
|
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
1342
1359
|
* For messages from a remote client, this will be undefined.
|
|
1343
1360
|
* @internal
|
|
@@ -1358,7 +1375,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1358
1375
|
* Process a delete subdirectory operation.
|
|
1359
1376
|
* @param op - The op to process
|
|
1360
1377
|
* @param local - Whether the message originated from the local client
|
|
1361
|
-
* @param message - The message
|
|
1362
1378
|
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
1363
1379
|
* For messages from a remote client, this will be undefined.
|
|
1364
1380
|
* @internal
|
|
@@ -1751,7 +1767,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1751
1767
|
/**
|
|
1752
1768
|
* Clear implementation used for both locally sourced clears as well as incoming remote clears.
|
|
1753
1769
|
* @param local - Whether the message originated from the local client
|
|
1754
|
-
* @param op - The message if from a remote clear, or null if from a local clear
|
|
1755
1770
|
*/
|
|
1756
1771
|
private clearCore(local: boolean) {
|
|
1757
1772
|
this._storage.clear();
|
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
|
}
|
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
|
}
|