@fluidframework/map 2.0.0-internal.5.3.1 → 2.0.0-internal.5.3.2

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.js CHANGED
@@ -825,7 +825,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
825
825
  throw new Error(`SubDirectory name may not contain ${posix.sep}`);
826
826
  }
827
827
  // Create the sub directory locally first.
828
- const isNew = this.createSubDirectoryCore(subdirName, true, -1, (_c = this.runtime.clientId) !== null && _c !== void 0 ? _c : "detached");
828
+ const isNew = this.createSubDirectoryCore(subdirName, true, this.getLocalSeq(), (_c = this.runtime.clientId) !== null && _c !== void 0 ? _c : "detached");
829
829
  const subDir = this._subdirectories.get(subdirName);
830
830
  (0, common_utils_1.assert)(subDir !== undefined, 0x5aa /* subdirectory should exist after creation */);
831
831
  // If we are not attached, don't submit the op.
@@ -843,6 +843,16 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
843
843
  }
844
844
  return subDir;
845
845
  }
846
+ /**
847
+ * @returns A sequenceNumber which should be used for local changes.
848
+ * @remarks - While detached, 0 is used rather than -1 to represent a change which should be universally known (as opposed to known
849
+ * only by the local client). This ensures that if the directory is later attached, none of its data needs to be updated (the values
850
+ * last set while detached will now be known to any new client, until they are changed).
851
+ * TODO: Convert these conventions to named constants. The semantics used here match those for merge-tree.
852
+ */
853
+ getLocalSeq() {
854
+ return this.directory.isAttached() ? -1 : 0;
855
+ }
846
856
  /**
847
857
  * {@inheritDoc IDirectory.getSubDirectory}
848
858
  */
@@ -1155,7 +1165,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
1155
1165
  var _c;
1156
1166
  this.throwIfDisposed();
1157
1167
  // Create the sub directory locally first.
1158
- this.createSubDirectoryCore(op.subdirName, true, -1, (_c = this.runtime.clientId) !== null && _c !== void 0 ? _c : "detached");
1168
+ this.createSubDirectoryCore(op.subdirName, true, this.getLocalSeq(), (_c = this.runtime.clientId) !== null && _c !== void 0 ? _c : "detached");
1159
1169
  this.updatePendingSubDirMessageCount(op);
1160
1170
  const localOpMetadata = {
1161
1171
  type: "createSubDir",