@fluidframework/map 0.58.2000 → 0.58.2001
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/README.md +0 -2
- package/dist/directory.d.ts +0 -2
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +1 -67
- package/dist/directory.js.map +1 -1
- package/dist/interfaces.d.ts +2 -15
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/directory.d.ts +0 -2
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +1 -67
- package/lib/directory.js.map +1 -1
- package/lib/interfaces.d.ts +2 -15
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +9 -10
- package/src/directory.ts +1 -74
- package/src/interfaces.ts +2 -17
- package/src/packageVersion.ts +1 -1
package/src/directory.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert,TypedEventEmitter } from "@fluidframework/common-utils";
|
|
7
|
-
import { UsageError } from "@fluidframework/container-utils";
|
|
8
7
|
import { readAndParse } from "@fluidframework/driver-utils";
|
|
9
8
|
import {
|
|
10
9
|
ISequencedDocumentMessage,
|
|
@@ -425,14 +424,6 @@ export class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implem
|
|
|
425
424
|
return this;
|
|
426
425
|
}
|
|
427
426
|
|
|
428
|
-
public dispose(error?: Error): void {
|
|
429
|
-
this.root.dispose(error);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
public get disposed(): boolean {
|
|
433
|
-
return this.root.disposed;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
427
|
/**
|
|
437
428
|
* Deletes the given key from within this IDirectory.
|
|
438
429
|
* @param key - The key to delete
|
|
@@ -811,11 +802,6 @@ export class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implem
|
|
|
811
802
|
* @sealed
|
|
812
803
|
*/
|
|
813
804
|
class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirectory {
|
|
814
|
-
/**
|
|
815
|
-
* Tells if the sub directory is disposed or not.
|
|
816
|
-
*/
|
|
817
|
-
private _disposed = false;
|
|
818
|
-
|
|
819
805
|
/**
|
|
820
806
|
* String representation for the class.
|
|
821
807
|
*/
|
|
@@ -868,28 +854,12 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
868
854
|
super();
|
|
869
855
|
}
|
|
870
856
|
|
|
871
|
-
public dispose(error?: Error): void {
|
|
872
|
-
this._disposed = true;
|
|
873
|
-
this.emit("disposed", this);
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
public get disposed(): boolean {
|
|
877
|
-
return this._disposed;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
private throwIfDisposed() {
|
|
881
|
-
if (this._disposed) {
|
|
882
|
-
throw new UsageError("Cannot access Disposed subDirectory");
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
|
|
886
857
|
/**
|
|
887
858
|
* Checks whether the given key exists in this IDirectory.
|
|
888
859
|
* @param key - The key to check
|
|
889
860
|
* @returns True if the key exists, false otherwise
|
|
890
861
|
*/
|
|
891
862
|
public has(key: string): boolean {
|
|
892
|
-
this.throwIfDisposed();
|
|
893
863
|
return this._storage.has(key);
|
|
894
864
|
}
|
|
895
865
|
|
|
@@ -897,7 +867,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
897
867
|
* {@inheritDoc IDirectory.get}
|
|
898
868
|
*/
|
|
899
869
|
public get<T = any>(key: string): T | undefined {
|
|
900
|
-
this.throwIfDisposed();
|
|
901
870
|
return this._storage.get(key)?.value as T | undefined;
|
|
902
871
|
}
|
|
903
872
|
|
|
@@ -905,7 +874,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
905
874
|
* {@inheritDoc IDirectory.set}
|
|
906
875
|
*/
|
|
907
876
|
public set<T = any>(key: string, value: T): this {
|
|
908
|
-
this.throwIfDisposed();
|
|
909
877
|
// Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.
|
|
910
878
|
if (key === undefined || key === null) {
|
|
911
879
|
throw new Error("Undefined and null keys are not supported");
|
|
@@ -944,7 +912,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
944
912
|
* {@inheritDoc IDirectory.createSubDirectory}
|
|
945
913
|
*/
|
|
946
914
|
public createSubDirectory(subdirName: string): IDirectory {
|
|
947
|
-
this.throwIfDisposed();
|
|
948
915
|
// Undefined/null subdirectory names can't be serialized to JSON in the manner we currently snapshot.
|
|
949
916
|
if (subdirName === undefined || subdirName === null) {
|
|
950
917
|
throw new Error("SubDirectory name may not be undefined or null");
|
|
@@ -979,7 +946,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
979
946
|
* {@inheritDoc IDirectory.getSubDirectory}
|
|
980
947
|
*/
|
|
981
948
|
public getSubDirectory(subdirName: string): IDirectory | undefined {
|
|
982
|
-
this.throwIfDisposed();
|
|
983
949
|
return this._subdirectories.get(subdirName);
|
|
984
950
|
}
|
|
985
951
|
|
|
@@ -987,7 +953,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
987
953
|
* {@inheritDoc IDirectory.hasSubDirectory}
|
|
988
954
|
*/
|
|
989
955
|
public hasSubDirectory(subdirName: string): boolean {
|
|
990
|
-
this.throwIfDisposed();
|
|
991
956
|
return this._subdirectories.has(subdirName);
|
|
992
957
|
}
|
|
993
958
|
|
|
@@ -995,7 +960,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
995
960
|
* {@inheritDoc IDirectory.deleteSubDirectory}
|
|
996
961
|
*/
|
|
997
962
|
public deleteSubDirectory(subdirName: string): boolean {
|
|
998
|
-
this.throwIfDisposed();
|
|
999
963
|
// Delete the sub directory locally first.
|
|
1000
964
|
const successfullyRemoved = this.deleteSubDirectoryCore(subdirName, true);
|
|
1001
965
|
|
|
@@ -1018,7 +982,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1018
982
|
* {@inheritDoc IDirectory.subdirectories}
|
|
1019
983
|
*/
|
|
1020
984
|
public subdirectories(): IterableIterator<[string, IDirectory]> {
|
|
1021
|
-
this.throwIfDisposed();
|
|
1022
985
|
return this._subdirectories.entries();
|
|
1023
986
|
}
|
|
1024
987
|
|
|
@@ -1026,7 +989,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1026
989
|
* {@inheritDoc IDirectory.getWorkingDirectory}
|
|
1027
990
|
*/
|
|
1028
991
|
public getWorkingDirectory(relativePath: string): IDirectory | undefined {
|
|
1029
|
-
this.throwIfDisposed();
|
|
1030
992
|
return this.directory.getWorkingDirectory(this.makeAbsolute(relativePath));
|
|
1031
993
|
}
|
|
1032
994
|
|
|
@@ -1036,7 +998,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1036
998
|
* @returns True if the key existed and was deleted, false if it did not exist
|
|
1037
999
|
*/
|
|
1038
1000
|
public delete(key: string): boolean {
|
|
1039
|
-
this.throwIfDisposed();
|
|
1040
1001
|
// Delete the key locally first.
|
|
1041
1002
|
const successfullyRemoved = this.deleteCore(key, true);
|
|
1042
1003
|
|
|
@@ -1059,7 +1020,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1059
1020
|
* Deletes all keys from within this IDirectory.
|
|
1060
1021
|
*/
|
|
1061
1022
|
public clear(): void {
|
|
1062
|
-
this.throwIfDisposed();
|
|
1063
1023
|
// Clear the data locally first.
|
|
1064
1024
|
this.clearCore(true);
|
|
1065
1025
|
|
|
@@ -1080,7 +1040,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1080
1040
|
* @param callback - Callback to issue
|
|
1081
1041
|
*/
|
|
1082
1042
|
public forEach(callback: (value: any, key: string, map: Map<string, any>) => void): void {
|
|
1083
|
-
this.throwIfDisposed();
|
|
1084
1043
|
this._storage.forEach((localValue, key, map) => {
|
|
1085
1044
|
callback(localValue.value, key, map);
|
|
1086
1045
|
});
|
|
@@ -1090,7 +1049,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1090
1049
|
* The number of entries under this IDirectory.
|
|
1091
1050
|
*/
|
|
1092
1051
|
public get size(): number {
|
|
1093
|
-
this.throwIfDisposed();
|
|
1094
1052
|
return this._storage.size;
|
|
1095
1053
|
}
|
|
1096
1054
|
|
|
@@ -1099,7 +1057,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1099
1057
|
* @returns The iterator
|
|
1100
1058
|
*/
|
|
1101
1059
|
public entries(): IterableIterator<[string, any]> {
|
|
1102
|
-
this.throwIfDisposed();
|
|
1103
1060
|
const localEntriesIterator = this._storage.entries();
|
|
1104
1061
|
const iterator = {
|
|
1105
1062
|
next(): IteratorResult<[string, any]> {
|
|
@@ -1123,7 +1080,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1123
1080
|
* @returns The iterator
|
|
1124
1081
|
*/
|
|
1125
1082
|
public keys(): IterableIterator<string> {
|
|
1126
|
-
this.throwIfDisposed();
|
|
1127
1083
|
return this._storage.keys();
|
|
1128
1084
|
}
|
|
1129
1085
|
|
|
@@ -1132,7 +1088,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1132
1088
|
* @returns The iterator
|
|
1133
1089
|
*/
|
|
1134
1090
|
public values(): IterableIterator<any> {
|
|
1135
|
-
this.throwIfDisposed();
|
|
1136
1091
|
const localValuesIterator = this._storage.values();
|
|
1137
1092
|
const iterator = {
|
|
1138
1093
|
next(): IteratorResult<any> {
|
|
@@ -1156,7 +1111,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1156
1111
|
* @returns The iterator
|
|
1157
1112
|
*/
|
|
1158
1113
|
public [Symbol.iterator](): IterableIterator<[string, any]> {
|
|
1159
|
-
this.throwIfDisposed();
|
|
1160
1114
|
return this.entries();
|
|
1161
1115
|
}
|
|
1162
1116
|
|
|
@@ -1174,7 +1128,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1174
1128
|
local: boolean,
|
|
1175
1129
|
localOpMetadata: unknown,
|
|
1176
1130
|
): void {
|
|
1177
|
-
this.throwIfDisposed();
|
|
1178
1131
|
if (local) {
|
|
1179
1132
|
assert(localOpMetadata !== undefined,
|
|
1180
1133
|
0x00f /* `pendingMessageId is missing from the local client's ${op.type} operation` */);
|
|
@@ -1202,7 +1155,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1202
1155
|
local: boolean,
|
|
1203
1156
|
localOpMetadata: unknown,
|
|
1204
1157
|
): void {
|
|
1205
|
-
this.throwIfDisposed();
|
|
1206
1158
|
if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {
|
|
1207
1159
|
return;
|
|
1208
1160
|
}
|
|
@@ -1224,7 +1176,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1224
1176
|
local: boolean,
|
|
1225
1177
|
localOpMetadata: unknown,
|
|
1226
1178
|
): void {
|
|
1227
|
-
this.throwIfDisposed();
|
|
1228
1179
|
if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {
|
|
1229
1180
|
return;
|
|
1230
1181
|
}
|
|
@@ -1250,7 +1201,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1250
1201
|
local: boolean,
|
|
1251
1202
|
localOpMetadata: unknown,
|
|
1252
1203
|
): void {
|
|
1253
|
-
this.throwIfDisposed();
|
|
1254
1204
|
if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {
|
|
1255
1205
|
return;
|
|
1256
1206
|
}
|
|
@@ -1271,7 +1221,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1271
1221
|
local: boolean,
|
|
1272
1222
|
localOpMetadata: unknown,
|
|
1273
1223
|
): void {
|
|
1274
|
-
this.throwIfDisposed();
|
|
1275
1224
|
if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {
|
|
1276
1225
|
return;
|
|
1277
1226
|
}
|
|
@@ -1284,7 +1233,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1284
1233
|
* @internal
|
|
1285
1234
|
*/
|
|
1286
1235
|
public submitClearMessage(op: IDirectoryClearOperation): void {
|
|
1287
|
-
this.throwIfDisposed();
|
|
1288
1236
|
const pendingMessageId = ++this.pendingMessageId;
|
|
1289
1237
|
this.directory.submitDirectoryMessage(op, pendingMessageId);
|
|
1290
1238
|
this.pendingClearMessageId = pendingMessageId;
|
|
@@ -1296,7 +1244,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1296
1244
|
* @internal
|
|
1297
1245
|
*/
|
|
1298
1246
|
public submitKeyMessage(op: IDirectoryKeyOperation): void {
|
|
1299
|
-
this.throwIfDisposed();
|
|
1300
1247
|
const pendingMessageId = ++this.pendingMessageId;
|
|
1301
1248
|
this.directory.submitDirectoryMessage(op, pendingMessageId);
|
|
1302
1249
|
this.pendingKeys.set(op.key, pendingMessageId);
|
|
@@ -1308,7 +1255,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1308
1255
|
* @internal
|
|
1309
1256
|
*/
|
|
1310
1257
|
public submitSubDirectoryMessage(op: IDirectorySubDirectoryOperation): void {
|
|
1311
|
-
this.throwIfDisposed();
|
|
1312
1258
|
const pendingMessageId = ++this.pendingMessageId;
|
|
1313
1259
|
this.directory.submitDirectoryMessage(op, pendingMessageId);
|
|
1314
1260
|
this.pendingSubDirectories.set(op.subdirName, pendingMessageId);
|
|
@@ -1321,7 +1267,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1321
1267
|
* @internal
|
|
1322
1268
|
*/
|
|
1323
1269
|
public *getSerializedStorage(serializer: IFluidSerializer) {
|
|
1324
|
-
this.throwIfDisposed();
|
|
1325
1270
|
for (const [key, localValue] of this._storage) {
|
|
1326
1271
|
const value = localValue.makeSerialized(serializer, this.directory.handle);
|
|
1327
1272
|
const res: [string, ISerializedValue] = [key, value];
|
|
@@ -1336,7 +1281,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1336
1281
|
* @internal
|
|
1337
1282
|
*/
|
|
1338
1283
|
public populateStorage(key: string, localValue: ILocalValue): void {
|
|
1339
|
-
this.throwIfDisposed();
|
|
1340
1284
|
this._storage.set(key, localValue);
|
|
1341
1285
|
}
|
|
1342
1286
|
|
|
@@ -1347,7 +1291,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1347
1291
|
* @internal
|
|
1348
1292
|
*/
|
|
1349
1293
|
public populateSubDirectory(subdirName: string, newSubDir: SubDirectory): void {
|
|
1350
|
-
this.throwIfDisposed();
|
|
1351
1294
|
this._subdirectories.set(subdirName, newSubDir);
|
|
1352
1295
|
}
|
|
1353
1296
|
|
|
@@ -1359,7 +1302,6 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1359
1302
|
* @internal
|
|
1360
1303
|
*/
|
|
1361
1304
|
public getLocalValue<T extends ILocalValue = ILocalValue>(key: string): T {
|
|
1362
|
-
this.throwIfDisposed();
|
|
1363
1305
|
return this._storage.get(key) as T;
|
|
1364
1306
|
}
|
|
1365
1307
|
|
|
@@ -1533,23 +1475,8 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
|
|
|
1533
1475
|
* @param op - The message if from a remote delete, or null if from a local delete
|
|
1534
1476
|
*/
|
|
1535
1477
|
private deleteSubDirectoryCore(subdirName: string, local: boolean) {
|
|
1536
|
-
const previousValue = this.getSubDirectory(subdirName);
|
|
1537
1478
|
// This should make the subdirectory structure unreachable so it can be GC'd and won't appear in snapshots
|
|
1538
1479
|
// Might want to consider cleaning out the structure more exhaustively though?
|
|
1539
|
-
|
|
1540
|
-
this.disposeSubDirectoryTree(previousValue);
|
|
1541
|
-
return successfullyRemoved;
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
private disposeSubDirectoryTree(directory: IDirectory | undefined) {
|
|
1545
|
-
if (!directory) {
|
|
1546
|
-
return;
|
|
1547
|
-
}
|
|
1548
|
-
// Dispose the subdirectory tree. This will dispose the subdirectories from bottom to top.
|
|
1549
|
-
const subDirectories = directory.subdirectories();
|
|
1550
|
-
for (const [_, subDirectory] of subDirectories) {
|
|
1551
|
-
this.disposeSubDirectoryTree(subDirectory);
|
|
1552
|
-
}
|
|
1553
|
-
directory.dispose();
|
|
1480
|
+
return this._subdirectories.delete(subdirName);
|
|
1554
1481
|
}
|
|
1555
1482
|
}
|
package/src/interfaces.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
7
|
-
import {
|
|
7
|
+
import { IEvent, IEventProvider, IEventThisPlaceHolder } from "@fluidframework/common-definitions";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Type of "valueChanged" event parameter.
|
|
@@ -27,7 +27,7 @@ export interface IValueChanged {
|
|
|
27
27
|
* @remarks
|
|
28
28
|
* When used as a Map, operates on its keys.
|
|
29
29
|
*/
|
|
30
|
-
export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryEvents
|
|
30
|
+
export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryEvents> {
|
|
31
31
|
/**
|
|
32
32
|
* The absolute path of the directory.
|
|
33
33
|
*/
|
|
@@ -164,18 +164,6 @@ export interface ISharedDirectoryEvents extends ISharedObjectEvents {
|
|
|
164
164
|
* - `local` - Whether the change originated from the this client.
|
|
165
165
|
*
|
|
166
166
|
* - `target` - The IDirectory itself.
|
|
167
|
-
*
|
|
168
|
-
* ### "disposed"
|
|
169
|
-
*
|
|
170
|
-
* The dispose event is emitted when this sub directory is deleted.
|
|
171
|
-
*
|
|
172
|
-
* #### Listener signature
|
|
173
|
-
*
|
|
174
|
-
* ```typescript
|
|
175
|
-
* (local: boolean, target: IEventThisPlaceHolder) => void
|
|
176
|
-
* ```
|
|
177
|
-
*
|
|
178
|
-
* - `target` - The IDirectory itself.
|
|
179
167
|
*/
|
|
180
168
|
export interface IDirectoryEvents extends IEvent {
|
|
181
169
|
(event: "containedValueChanged", listener: (
|
|
@@ -183,9 +171,6 @@ export interface IDirectoryEvents extends IEvent {
|
|
|
183
171
|
local: boolean,
|
|
184
172
|
target: IEventThisPlaceHolder,
|
|
185
173
|
) => void);
|
|
186
|
-
(event: "disposed", listener: (
|
|
187
|
-
target: IEventThisPlaceHolder,
|
|
188
|
-
) => void);
|
|
189
174
|
}
|
|
190
175
|
|
|
191
176
|
/**
|
package/src/packageVersion.ts
CHANGED