@fluidframework/map 0.58.2000-58133 → 0.58.2002

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/lib/directory.js CHANGED
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { assert, TypedEventEmitter } from "@fluidframework/common-utils";
6
- import { UsageError } from "@fluidframework/container-utils";
7
6
  import { readAndParse } from "@fluidframework/driver-utils";
8
7
  import { MessageType, } from "@fluidframework/protocol-definitions";
9
8
  import { SharedObject, ValueType } from "@fluidframework/shared-object-base";
@@ -197,12 +196,6 @@ export class SharedDirectory extends SharedObject {
197
196
  this.root.set(key, value);
198
197
  return this;
199
198
  }
200
- dispose(error) {
201
- this.root.dispose(error);
202
- }
203
- get disposed() {
204
- return this.root.disposed;
205
- }
206
199
  /**
207
200
  * Deletes the given key from within this IDirectory.
208
201
  * @param key - The key to delete
@@ -534,10 +527,6 @@ class SubDirectory extends TypedEventEmitter {
534
527
  this.runtime = runtime;
535
528
  this.serializer = serializer;
536
529
  this.absolutePath = absolutePath;
537
- /**
538
- * Tells if the sub directory is disposed or not.
539
- */
540
- this._disposed = false;
541
530
  /**
542
531
  * String representation for the class.
543
532
  */
@@ -568,25 +557,12 @@ class SubDirectory extends TypedEventEmitter {
568
557
  */
569
558
  this.pendingClearMessageId = -1;
570
559
  }
571
- dispose(error) {
572
- this._disposed = true;
573
- this.emit("disposed", this);
574
- }
575
- get disposed() {
576
- return this._disposed;
577
- }
578
- throwIfDisposed() {
579
- if (this._disposed) {
580
- throw new UsageError("Cannot access Disposed subDirectory");
581
- }
582
- }
583
560
  /**
584
561
  * Checks whether the given key exists in this IDirectory.
585
562
  * @param key - The key to check
586
563
  * @returns True if the key exists, false otherwise
587
564
  */
588
565
  has(key) {
589
- this.throwIfDisposed();
590
566
  return this._storage.has(key);
591
567
  }
592
568
  /**
@@ -594,14 +570,12 @@ class SubDirectory extends TypedEventEmitter {
594
570
  */
595
571
  get(key) {
596
572
  var _a;
597
- this.throwIfDisposed();
598
573
  return (_a = this._storage.get(key)) === null || _a === void 0 ? void 0 : _a.value;
599
574
  }
600
575
  /**
601
576
  * {@inheritDoc IDirectory.set}
602
577
  */
603
578
  set(key, value) {
604
- this.throwIfDisposed();
605
579
  // Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.
606
580
  if (key === undefined || key === null) {
607
581
  throw new Error("Undefined and null keys are not supported");
@@ -628,7 +602,6 @@ class SubDirectory extends TypedEventEmitter {
628
602
  * {@inheritDoc IDirectory.createSubDirectory}
629
603
  */
630
604
  createSubDirectory(subdirName) {
631
- this.throwIfDisposed();
632
605
  // Undefined/null subdirectory names can't be serialized to JSON in the manner we currently snapshot.
633
606
  if (subdirName === undefined || subdirName === null) {
634
607
  throw new Error("SubDirectory name may not be undefined or null");
@@ -656,21 +629,18 @@ class SubDirectory extends TypedEventEmitter {
656
629
  * {@inheritDoc IDirectory.getSubDirectory}
657
630
  */
658
631
  getSubDirectory(subdirName) {
659
- this.throwIfDisposed();
660
632
  return this._subdirectories.get(subdirName);
661
633
  }
662
634
  /**
663
635
  * {@inheritDoc IDirectory.hasSubDirectory}
664
636
  */
665
637
  hasSubDirectory(subdirName) {
666
- this.throwIfDisposed();
667
638
  return this._subdirectories.has(subdirName);
668
639
  }
669
640
  /**
670
641
  * {@inheritDoc IDirectory.deleteSubDirectory}
671
642
  */
672
643
  deleteSubDirectory(subdirName) {
673
- this.throwIfDisposed();
674
644
  // Delete the sub directory locally first.
675
645
  const successfullyRemoved = this.deleteSubDirectoryCore(subdirName, true);
676
646
  // If we are not attached, don't submit the op.
@@ -689,14 +659,12 @@ class SubDirectory extends TypedEventEmitter {
689
659
  * {@inheritDoc IDirectory.subdirectories}
690
660
  */
691
661
  subdirectories() {
692
- this.throwIfDisposed();
693
662
  return this._subdirectories.entries();
694
663
  }
695
664
  /**
696
665
  * {@inheritDoc IDirectory.getWorkingDirectory}
697
666
  */
698
667
  getWorkingDirectory(relativePath) {
699
- this.throwIfDisposed();
700
668
  return this.directory.getWorkingDirectory(this.makeAbsolute(relativePath));
701
669
  }
702
670
  /**
@@ -705,7 +673,6 @@ class SubDirectory extends TypedEventEmitter {
705
673
  * @returns True if the key existed and was deleted, false if it did not exist
706
674
  */
707
675
  delete(key) {
708
- this.throwIfDisposed();
709
676
  // Delete the key locally first.
710
677
  const successfullyRemoved = this.deleteCore(key, true);
711
678
  // If we are not attached, don't submit the op.
@@ -724,7 +691,6 @@ class SubDirectory extends TypedEventEmitter {
724
691
  * Deletes all keys from within this IDirectory.
725
692
  */
726
693
  clear() {
727
- this.throwIfDisposed();
728
694
  // Clear the data locally first.
729
695
  this.clearCore(true);
730
696
  // If we are not attached, don't submit the op.
@@ -742,7 +708,6 @@ class SubDirectory extends TypedEventEmitter {
742
708
  * @param callback - Callback to issue
743
709
  */
744
710
  forEach(callback) {
745
- this.throwIfDisposed();
746
711
  this._storage.forEach((localValue, key, map) => {
747
712
  callback(localValue.value, key, map);
748
713
  });
@@ -751,7 +716,6 @@ class SubDirectory extends TypedEventEmitter {
751
716
  * The number of entries under this IDirectory.
752
717
  */
753
718
  get size() {
754
- this.throwIfDisposed();
755
719
  return this._storage.size;
756
720
  }
757
721
  /**
@@ -759,7 +723,6 @@ class SubDirectory extends TypedEventEmitter {
759
723
  * @returns The iterator
760
724
  */
761
725
  entries() {
762
- this.throwIfDisposed();
763
726
  const localEntriesIterator = this._storage.entries();
764
727
  const iterator = {
765
728
  next() {
@@ -783,7 +746,6 @@ class SubDirectory extends TypedEventEmitter {
783
746
  * @returns The iterator
784
747
  */
785
748
  keys() {
786
- this.throwIfDisposed();
787
749
  return this._storage.keys();
788
750
  }
789
751
  /**
@@ -791,7 +753,6 @@ class SubDirectory extends TypedEventEmitter {
791
753
  * @returns The iterator
792
754
  */
793
755
  values() {
794
- this.throwIfDisposed();
795
756
  const localValuesIterator = this._storage.values();
796
757
  const iterator = {
797
758
  next() {
@@ -815,7 +776,6 @@ class SubDirectory extends TypedEventEmitter {
815
776
  * @returns The iterator
816
777
  */
817
778
  [Symbol.iterator]() {
818
- this.throwIfDisposed();
819
779
  return this.entries();
820
780
  }
821
781
  /**
@@ -828,7 +788,6 @@ class SubDirectory extends TypedEventEmitter {
828
788
  * @internal
829
789
  */
830
790
  processClearMessage(op, local, localOpMetadata) {
831
- this.throwIfDisposed();
832
791
  if (local) {
833
792
  assert(localOpMetadata !== undefined, 0x00f /* `pendingMessageId is missing from the local client's ${op.type} operation` */);
834
793
  const pendingMessageId = localOpMetadata;
@@ -850,7 +809,6 @@ class SubDirectory extends TypedEventEmitter {
850
809
  * @internal
851
810
  */
852
811
  processDeleteMessage(op, local, localOpMetadata) {
853
- this.throwIfDisposed();
854
812
  if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {
855
813
  return;
856
814
  }
@@ -866,7 +824,6 @@ class SubDirectory extends TypedEventEmitter {
866
824
  * @internal
867
825
  */
868
826
  processSetMessage(op, context, local, localOpMetadata) {
869
- this.throwIfDisposed();
870
827
  if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {
871
828
  return;
872
829
  }
@@ -885,7 +842,6 @@ class SubDirectory extends TypedEventEmitter {
885
842
  * @internal
886
843
  */
887
844
  processCreateSubDirectoryMessage(op, local, localOpMetadata) {
888
- this.throwIfDisposed();
889
845
  if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {
890
846
  return;
891
847
  }
@@ -901,7 +857,6 @@ class SubDirectory extends TypedEventEmitter {
901
857
  * @internal
902
858
  */
903
859
  processDeleteSubDirectoryMessage(op, local, localOpMetadata) {
904
- this.throwIfDisposed();
905
860
  if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {
906
861
  return;
907
862
  }
@@ -913,7 +868,6 @@ class SubDirectory extends TypedEventEmitter {
913
868
  * @internal
914
869
  */
915
870
  submitClearMessage(op) {
916
- this.throwIfDisposed();
917
871
  const pendingMessageId = ++this.pendingMessageId;
918
872
  this.directory.submitDirectoryMessage(op, pendingMessageId);
919
873
  this.pendingClearMessageId = pendingMessageId;
@@ -924,7 +878,6 @@ class SubDirectory extends TypedEventEmitter {
924
878
  * @internal
925
879
  */
926
880
  submitKeyMessage(op) {
927
- this.throwIfDisposed();
928
881
  const pendingMessageId = ++this.pendingMessageId;
929
882
  this.directory.submitDirectoryMessage(op, pendingMessageId);
930
883
  this.pendingKeys.set(op.key, pendingMessageId);
@@ -935,7 +888,6 @@ class SubDirectory extends TypedEventEmitter {
935
888
  * @internal
936
889
  */
937
890
  submitSubDirectoryMessage(op) {
938
- this.throwIfDisposed();
939
891
  const pendingMessageId = ++this.pendingMessageId;
940
892
  this.directory.submitDirectoryMessage(op, pendingMessageId);
941
893
  this.pendingSubDirectories.set(op.subdirName, pendingMessageId);
@@ -947,7 +899,6 @@ class SubDirectory extends TypedEventEmitter {
947
899
  * @internal
948
900
  */
949
901
  *getSerializedStorage(serializer) {
950
- this.throwIfDisposed();
951
902
  for (const [key, localValue] of this._storage) {
952
903
  const value = localValue.makeSerialized(serializer, this.directory.handle);
953
904
  const res = [key, value];
@@ -961,7 +912,6 @@ class SubDirectory extends TypedEventEmitter {
961
912
  * @internal
962
913
  */
963
914
  populateStorage(key, localValue) {
964
- this.throwIfDisposed();
965
915
  this._storage.set(key, localValue);
966
916
  }
967
917
  /**
@@ -971,7 +921,6 @@ class SubDirectory extends TypedEventEmitter {
971
921
  * @internal
972
922
  */
973
923
  populateSubDirectory(subdirName, newSubDir) {
974
- this.throwIfDisposed();
975
924
  this._subdirectories.set(subdirName, newSubDir);
976
925
  }
977
926
  /**
@@ -982,7 +931,6 @@ class SubDirectory extends TypedEventEmitter {
982
931
  * @internal
983
932
  */
984
933
  getLocalValue(key) {
985
- this.throwIfDisposed();
986
934
  return this._storage.get(key);
987
935
  }
988
936
  /**
@@ -1126,23 +1074,9 @@ class SubDirectory extends TypedEventEmitter {
1126
1074
  * @param op - The message if from a remote delete, or null if from a local delete
1127
1075
  */
1128
1076
  deleteSubDirectoryCore(subdirName, local) {
1129
- const previousValue = this.getSubDirectory(subdirName);
1130
1077
  // This should make the subdirectory structure unreachable so it can be GC'd and won't appear in snapshots
1131
1078
  // Might want to consider cleaning out the structure more exhaustively though?
1132
- const successfullyRemoved = this._subdirectories.delete(subdirName);
1133
- this.disposeSubDirectoryTree(previousValue);
1134
- return successfullyRemoved;
1135
- }
1136
- disposeSubDirectoryTree(directory) {
1137
- if (!directory) {
1138
- return;
1139
- }
1140
- // Dispose the subdirectory tree. This will dispose the subdirectories from bottom to top.
1141
- const subDirectories = directory.subdirectories();
1142
- for (const [_, subDirectory] of subDirectories) {
1143
- this.disposeSubDirectoryTree(subDirectory);
1144
- }
1145
- directory.dispose();
1079
+ return this._subdirectories.delete(subdirName);
1146
1080
  }
1147
1081
  }
1148
1082
  //# sourceMappingURL=directory.js.map