@fluidframework/map 0.58.0-55983 → 0.58.2000-58133
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 +2 -0
- package/dist/directory.d.ts +2 -0
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +67 -1
- package/dist/directory.js.map +1 -1
- package/dist/interfaces.d.ts +15 -2
- 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.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/directory.d.ts +2 -0
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +67 -1
- package/lib/directory.js.map +1 -1
- package/lib/interfaces.d.ts +15 -2
- 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.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +17 -12
- package/src/directory.ts +74 -1
- package/src/interfaces.ts +17 -2
- package/src/packageVersion.ts +1 -1
package/README.md
CHANGED
|
@@ -52,3 +52,5 @@ To "navigate" the subdirectory structure, `IDirectory` provides a `getWorkingDir
|
|
|
52
52
|
#### Eventing
|
|
53
53
|
|
|
54
54
|
`valueChanged` events additionally provide the absolute path to the subdirectory storing the value that changed.
|
|
55
|
+
|
|
56
|
+
`dispose` events are fired on sub directory which is deleted. Any access to this sub directory will throw an error once it is disposed.
|
package/dist/directory.d.ts
CHANGED
|
@@ -221,6 +221,8 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
221
221
|
* {@inheritDoc IDirectory.set}
|
|
222
222
|
*/
|
|
223
223
|
set<T = any>(key: string, value: T): this;
|
|
224
|
+
dispose(error?: Error): void;
|
|
225
|
+
get disposed(): boolean;
|
|
224
226
|
/**
|
|
225
227
|
* Deletes the given key from within this IDirectory.
|
|
226
228
|
* @param key - The key to delete
|
package/dist/directory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACH,yBAAyB,EAE5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAa,MAAM,oCAAoC,CAAC;AAG/F,OAAO,EACH,UAAU,EAGV,kBAAkB,EAElB,gBAAgB,EAChB,sBAAsB,EAEzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEH,eAAe,EAElB,MAAM,eAAe,CAAC;AAkCvB;;GAEG;AACH,UAAU,sBAAsB;IAC5B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC7B;AAED;;GAEG;AACH,UAAU,yBAAyB;IAC/B;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IAEf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,aAAK,sBAAsB,GAAG,sBAAsB,GAAG,yBAAyB,CAAC;AAEjF;;GAEG;AACH,UAAU,wBAAwB;IAC9B;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;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Q,CAAC,OAAO,EAAE,sBAAsB;IAgBxD;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,oBAAoB;IAmC7C;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IASzG;;;OAGG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;;;;;;OASG;IACH,OAAO,CAAC,SAAS;IAYjB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAgG1B;;OAEG;IACH,SAAS,CAAC,cAAc;CAG3B"}
|
package/dist/directory.js
CHANGED
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.SharedDirectory = exports.DirectoryFactory = void 0;
|
|
27
27
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
28
|
+
const container_utils_1 = require("@fluidframework/container-utils");
|
|
28
29
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
29
30
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
30
31
|
const shared_object_base_1 = require("@fluidframework/shared-object-base");
|
|
@@ -219,6 +220,12 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
219
220
|
this.root.set(key, value);
|
|
220
221
|
return this;
|
|
221
222
|
}
|
|
223
|
+
dispose(error) {
|
|
224
|
+
this.root.dispose(error);
|
|
225
|
+
}
|
|
226
|
+
get disposed() {
|
|
227
|
+
return this.root.disposed;
|
|
228
|
+
}
|
|
222
229
|
/**
|
|
223
230
|
* Deletes the given key from within this IDirectory.
|
|
224
231
|
* @param key - The key to delete
|
|
@@ -551,6 +558,10 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
551
558
|
this.runtime = runtime;
|
|
552
559
|
this.serializer = serializer;
|
|
553
560
|
this.absolutePath = absolutePath;
|
|
561
|
+
/**
|
|
562
|
+
* Tells if the sub directory is disposed or not.
|
|
563
|
+
*/
|
|
564
|
+
this._disposed = false;
|
|
554
565
|
/**
|
|
555
566
|
* String representation for the class.
|
|
556
567
|
*/
|
|
@@ -581,12 +592,25 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
581
592
|
*/
|
|
582
593
|
this.pendingClearMessageId = -1;
|
|
583
594
|
}
|
|
595
|
+
dispose(error) {
|
|
596
|
+
this._disposed = true;
|
|
597
|
+
this.emit("disposed", this);
|
|
598
|
+
}
|
|
599
|
+
get disposed() {
|
|
600
|
+
return this._disposed;
|
|
601
|
+
}
|
|
602
|
+
throwIfDisposed() {
|
|
603
|
+
if (this._disposed) {
|
|
604
|
+
throw new container_utils_1.UsageError("Cannot access Disposed subDirectory");
|
|
605
|
+
}
|
|
606
|
+
}
|
|
584
607
|
/**
|
|
585
608
|
* Checks whether the given key exists in this IDirectory.
|
|
586
609
|
* @param key - The key to check
|
|
587
610
|
* @returns True if the key exists, false otherwise
|
|
588
611
|
*/
|
|
589
612
|
has(key) {
|
|
613
|
+
this.throwIfDisposed();
|
|
590
614
|
return this._storage.has(key);
|
|
591
615
|
}
|
|
592
616
|
/**
|
|
@@ -594,12 +618,14 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
594
618
|
*/
|
|
595
619
|
get(key) {
|
|
596
620
|
var _a;
|
|
621
|
+
this.throwIfDisposed();
|
|
597
622
|
return (_a = this._storage.get(key)) === null || _a === void 0 ? void 0 : _a.value;
|
|
598
623
|
}
|
|
599
624
|
/**
|
|
600
625
|
* {@inheritDoc IDirectory.set}
|
|
601
626
|
*/
|
|
602
627
|
set(key, value) {
|
|
628
|
+
this.throwIfDisposed();
|
|
603
629
|
// Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.
|
|
604
630
|
if (key === undefined || key === null) {
|
|
605
631
|
throw new Error("Undefined and null keys are not supported");
|
|
@@ -626,6 +652,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
626
652
|
* {@inheritDoc IDirectory.createSubDirectory}
|
|
627
653
|
*/
|
|
628
654
|
createSubDirectory(subdirName) {
|
|
655
|
+
this.throwIfDisposed();
|
|
629
656
|
// Undefined/null subdirectory names can't be serialized to JSON in the manner we currently snapshot.
|
|
630
657
|
if (subdirName === undefined || subdirName === null) {
|
|
631
658
|
throw new Error("SubDirectory name may not be undefined or null");
|
|
@@ -653,18 +680,21 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
653
680
|
* {@inheritDoc IDirectory.getSubDirectory}
|
|
654
681
|
*/
|
|
655
682
|
getSubDirectory(subdirName) {
|
|
683
|
+
this.throwIfDisposed();
|
|
656
684
|
return this._subdirectories.get(subdirName);
|
|
657
685
|
}
|
|
658
686
|
/**
|
|
659
687
|
* {@inheritDoc IDirectory.hasSubDirectory}
|
|
660
688
|
*/
|
|
661
689
|
hasSubDirectory(subdirName) {
|
|
690
|
+
this.throwIfDisposed();
|
|
662
691
|
return this._subdirectories.has(subdirName);
|
|
663
692
|
}
|
|
664
693
|
/**
|
|
665
694
|
* {@inheritDoc IDirectory.deleteSubDirectory}
|
|
666
695
|
*/
|
|
667
696
|
deleteSubDirectory(subdirName) {
|
|
697
|
+
this.throwIfDisposed();
|
|
668
698
|
// Delete the sub directory locally first.
|
|
669
699
|
const successfullyRemoved = this.deleteSubDirectoryCore(subdirName, true);
|
|
670
700
|
// If we are not attached, don't submit the op.
|
|
@@ -683,12 +713,14 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
683
713
|
* {@inheritDoc IDirectory.subdirectories}
|
|
684
714
|
*/
|
|
685
715
|
subdirectories() {
|
|
716
|
+
this.throwIfDisposed();
|
|
686
717
|
return this._subdirectories.entries();
|
|
687
718
|
}
|
|
688
719
|
/**
|
|
689
720
|
* {@inheritDoc IDirectory.getWorkingDirectory}
|
|
690
721
|
*/
|
|
691
722
|
getWorkingDirectory(relativePath) {
|
|
723
|
+
this.throwIfDisposed();
|
|
692
724
|
return this.directory.getWorkingDirectory(this.makeAbsolute(relativePath));
|
|
693
725
|
}
|
|
694
726
|
/**
|
|
@@ -697,6 +729,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
697
729
|
* @returns True if the key existed and was deleted, false if it did not exist
|
|
698
730
|
*/
|
|
699
731
|
delete(key) {
|
|
732
|
+
this.throwIfDisposed();
|
|
700
733
|
// Delete the key locally first.
|
|
701
734
|
const successfullyRemoved = this.deleteCore(key, true);
|
|
702
735
|
// If we are not attached, don't submit the op.
|
|
@@ -715,6 +748,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
715
748
|
* Deletes all keys from within this IDirectory.
|
|
716
749
|
*/
|
|
717
750
|
clear() {
|
|
751
|
+
this.throwIfDisposed();
|
|
718
752
|
// Clear the data locally first.
|
|
719
753
|
this.clearCore(true);
|
|
720
754
|
// If we are not attached, don't submit the op.
|
|
@@ -732,6 +766,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
732
766
|
* @param callback - Callback to issue
|
|
733
767
|
*/
|
|
734
768
|
forEach(callback) {
|
|
769
|
+
this.throwIfDisposed();
|
|
735
770
|
this._storage.forEach((localValue, key, map) => {
|
|
736
771
|
callback(localValue.value, key, map);
|
|
737
772
|
});
|
|
@@ -740,6 +775,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
740
775
|
* The number of entries under this IDirectory.
|
|
741
776
|
*/
|
|
742
777
|
get size() {
|
|
778
|
+
this.throwIfDisposed();
|
|
743
779
|
return this._storage.size;
|
|
744
780
|
}
|
|
745
781
|
/**
|
|
@@ -747,6 +783,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
747
783
|
* @returns The iterator
|
|
748
784
|
*/
|
|
749
785
|
entries() {
|
|
786
|
+
this.throwIfDisposed();
|
|
750
787
|
const localEntriesIterator = this._storage.entries();
|
|
751
788
|
const iterator = {
|
|
752
789
|
next() {
|
|
@@ -770,6 +807,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
770
807
|
* @returns The iterator
|
|
771
808
|
*/
|
|
772
809
|
keys() {
|
|
810
|
+
this.throwIfDisposed();
|
|
773
811
|
return this._storage.keys();
|
|
774
812
|
}
|
|
775
813
|
/**
|
|
@@ -777,6 +815,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
777
815
|
* @returns The iterator
|
|
778
816
|
*/
|
|
779
817
|
values() {
|
|
818
|
+
this.throwIfDisposed();
|
|
780
819
|
const localValuesIterator = this._storage.values();
|
|
781
820
|
const iterator = {
|
|
782
821
|
next() {
|
|
@@ -800,6 +839,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
800
839
|
* @returns The iterator
|
|
801
840
|
*/
|
|
802
841
|
[Symbol.iterator]() {
|
|
842
|
+
this.throwIfDisposed();
|
|
803
843
|
return this.entries();
|
|
804
844
|
}
|
|
805
845
|
/**
|
|
@@ -812,6 +852,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
812
852
|
* @internal
|
|
813
853
|
*/
|
|
814
854
|
processClearMessage(op, local, localOpMetadata) {
|
|
855
|
+
this.throwIfDisposed();
|
|
815
856
|
if (local) {
|
|
816
857
|
common_utils_1.assert(localOpMetadata !== undefined, 0x00f /* `pendingMessageId is missing from the local client's ${op.type} operation` */);
|
|
817
858
|
const pendingMessageId = localOpMetadata;
|
|
@@ -833,6 +874,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
833
874
|
* @internal
|
|
834
875
|
*/
|
|
835
876
|
processDeleteMessage(op, local, localOpMetadata) {
|
|
877
|
+
this.throwIfDisposed();
|
|
836
878
|
if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {
|
|
837
879
|
return;
|
|
838
880
|
}
|
|
@@ -848,6 +890,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
848
890
|
* @internal
|
|
849
891
|
*/
|
|
850
892
|
processSetMessage(op, context, local, localOpMetadata) {
|
|
893
|
+
this.throwIfDisposed();
|
|
851
894
|
if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {
|
|
852
895
|
return;
|
|
853
896
|
}
|
|
@@ -866,6 +909,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
866
909
|
* @internal
|
|
867
910
|
*/
|
|
868
911
|
processCreateSubDirectoryMessage(op, local, localOpMetadata) {
|
|
912
|
+
this.throwIfDisposed();
|
|
869
913
|
if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {
|
|
870
914
|
return;
|
|
871
915
|
}
|
|
@@ -881,6 +925,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
881
925
|
* @internal
|
|
882
926
|
*/
|
|
883
927
|
processDeleteSubDirectoryMessage(op, local, localOpMetadata) {
|
|
928
|
+
this.throwIfDisposed();
|
|
884
929
|
if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {
|
|
885
930
|
return;
|
|
886
931
|
}
|
|
@@ -892,6 +937,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
892
937
|
* @internal
|
|
893
938
|
*/
|
|
894
939
|
submitClearMessage(op) {
|
|
940
|
+
this.throwIfDisposed();
|
|
895
941
|
const pendingMessageId = ++this.pendingMessageId;
|
|
896
942
|
this.directory.submitDirectoryMessage(op, pendingMessageId);
|
|
897
943
|
this.pendingClearMessageId = pendingMessageId;
|
|
@@ -902,6 +948,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
902
948
|
* @internal
|
|
903
949
|
*/
|
|
904
950
|
submitKeyMessage(op) {
|
|
951
|
+
this.throwIfDisposed();
|
|
905
952
|
const pendingMessageId = ++this.pendingMessageId;
|
|
906
953
|
this.directory.submitDirectoryMessage(op, pendingMessageId);
|
|
907
954
|
this.pendingKeys.set(op.key, pendingMessageId);
|
|
@@ -912,6 +959,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
912
959
|
* @internal
|
|
913
960
|
*/
|
|
914
961
|
submitSubDirectoryMessage(op) {
|
|
962
|
+
this.throwIfDisposed();
|
|
915
963
|
const pendingMessageId = ++this.pendingMessageId;
|
|
916
964
|
this.directory.submitDirectoryMessage(op, pendingMessageId);
|
|
917
965
|
this.pendingSubDirectories.set(op.subdirName, pendingMessageId);
|
|
@@ -923,6 +971,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
923
971
|
* @internal
|
|
924
972
|
*/
|
|
925
973
|
*getSerializedStorage(serializer) {
|
|
974
|
+
this.throwIfDisposed();
|
|
926
975
|
for (const [key, localValue] of this._storage) {
|
|
927
976
|
const value = localValue.makeSerialized(serializer, this.directory.handle);
|
|
928
977
|
const res = [key, value];
|
|
@@ -936,6 +985,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
936
985
|
* @internal
|
|
937
986
|
*/
|
|
938
987
|
populateStorage(key, localValue) {
|
|
988
|
+
this.throwIfDisposed();
|
|
939
989
|
this._storage.set(key, localValue);
|
|
940
990
|
}
|
|
941
991
|
/**
|
|
@@ -945,6 +995,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
945
995
|
* @internal
|
|
946
996
|
*/
|
|
947
997
|
populateSubDirectory(subdirName, newSubDir) {
|
|
998
|
+
this.throwIfDisposed();
|
|
948
999
|
this._subdirectories.set(subdirName, newSubDir);
|
|
949
1000
|
}
|
|
950
1001
|
/**
|
|
@@ -955,6 +1006,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
955
1006
|
* @internal
|
|
956
1007
|
*/
|
|
957
1008
|
getLocalValue(key) {
|
|
1009
|
+
this.throwIfDisposed();
|
|
958
1010
|
return this._storage.get(key);
|
|
959
1011
|
}
|
|
960
1012
|
/**
|
|
@@ -1098,9 +1150,23 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1098
1150
|
* @param op - The message if from a remote delete, or null if from a local delete
|
|
1099
1151
|
*/
|
|
1100
1152
|
deleteSubDirectoryCore(subdirName, local) {
|
|
1153
|
+
const previousValue = this.getSubDirectory(subdirName);
|
|
1101
1154
|
// This should make the subdirectory structure unreachable so it can be GC'd and won't appear in snapshots
|
|
1102
1155
|
// Might want to consider cleaning out the structure more exhaustively though?
|
|
1103
|
-
|
|
1156
|
+
const successfullyRemoved = this._subdirectories.delete(subdirName);
|
|
1157
|
+
this.disposeSubDirectoryTree(previousValue);
|
|
1158
|
+
return successfullyRemoved;
|
|
1159
|
+
}
|
|
1160
|
+
disposeSubDirectoryTree(directory) {
|
|
1161
|
+
if (!directory) {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
// Dispose the subdirectory tree. This will dispose the subdirectories from bottom to top.
|
|
1165
|
+
const subDirectories = directory.subdirectories();
|
|
1166
|
+
for (const [_, subDirectory] of subDirectories) {
|
|
1167
|
+
this.disposeSubDirectoryTree(subDirectory);
|
|
1168
|
+
}
|
|
1169
|
+
directory.dispose();
|
|
1104
1170
|
}
|
|
1105
1171
|
}
|
|
1106
1172
|
//# sourceMappingURL=directory.js.map
|